package D;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.RemoteInput;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.core.graphics.drawable.IconCompat;
import com.riyaz.zvytour.R;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import r.C0967f;

/* JADX INFO: loaded from: classes.dex */
public final class P {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Context f321a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Notification.Builder f322b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final C0044o f323c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Bundle f324d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int f325e;

    public P(C0044o c0044o) {
        ArrayList<Y> arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        Bundle[] bundleArr;
        ArrayList arrayList4;
        C0038i c0038iE;
        int i;
        new ArrayList();
        this.f324d = new Bundle();
        this.f323c = c0044o;
        Context context = c0044o.f392a;
        this.f321a = context;
        if (Build.VERSION.SDK_INT >= 26) {
            this.f322b = L.a(context, c0044o.f385B);
        } else {
            this.f322b = new Notification.Builder(c0044o.f392a);
        }
        Notification notification = c0044o.f390G;
        this.f322b.setWhen(notification.when).setSmallIcon(notification.icon, notification.iconLevel).setContent(notification.contentView).setTicker(notification.tickerText, null).setVibrate(notification.vibrate).setLights(notification.ledARGB, notification.ledOnMS, notification.ledOffMS).setOngoing((notification.flags & 2) != 0).setOnlyAlertOnce((notification.flags & 8) != 0).setAutoCancel((notification.flags & 16) != 0).setDefaults(notification.defaults).setContentTitle(c0044o.f396e).setContentText(c0044o.f397f).setContentInfo(null).setContentIntent(c0044o.f398g).setDeleteIntent(notification.deleteIntent).setFullScreenIntent(c0044o.f399h, (notification.flags & 128) != 0).setNumber(c0044o.f400j).setProgress(c0044o.p, c0044o.q, c0044o.f406r);
        Notification.Builder builder = this.f322b;
        IconCompat iconCompat = c0044o.i;
        builder.setLargeIcon(iconCompat == null ? null : iconCompat.h(context));
        this.f322b.setSubText(c0044o.f405o).setUsesChronometer(c0044o.f403m).setPriority(c0044o.f401k);
        K k5 = c0044o.f404n;
        if (k5 instanceof C0050v) {
            C0050v c0050v = (C0050v) k5;
            PendingIntent pendingIntent = c0050v.f418h;
            C0038i c0038iE2 = pendingIntent == null ? c0050v.e(R.drawable.ic_call_decline, R.string.call_notification_hang_up_action, c0050v.f421l, R.color.call_notification_decline_color, c0050v.i) : c0050v.e(R.drawable.ic_call_decline, R.string.call_notification_decline_action, c0050v.f421l, R.color.call_notification_decline_color, pendingIntent);
            PendingIntent pendingIntent2 = c0050v.f417g;
            if (pendingIntent2 == null) {
                c0038iE = null;
            } else {
                boolean z5 = c0050v.f419j;
                c0038iE = c0050v.e(z5 ? R.drawable.ic_call_answer_video : R.drawable.ic_call_answer, z5 ? R.string.call_notification_answer_video_action : R.string.call_notification_answer_action, c0050v.f420k, R.color.call_notification_answer_color, pendingIntent2);
            }
            ArrayList arrayList5 = new ArrayList(3);
            arrayList5.add(c0038iE2);
            ArrayList<C0038i> arrayList6 = c0050v.f317a.f393b;
            if (arrayList6 != null) {
                i = 2;
                for (C0038i c0038i : arrayList6) {
                    if (c0038i.f375f) {
                        arrayList5.add(c0038i);
                    } else if (!c0038i.f370a.getBoolean("key_action_priority")) {
                        arrayList5.add(c0038i);
                        i--;
                    }
                    if (c0038iE != null && i == 1) {
                        arrayList5.add(c0038iE);
                        i--;
                    }
                }
            } else {
                i = 2;
            }
            if (c0038iE != null && i >= 1) {
                arrayList5.add(c0038iE);
            }
            Iterator it = arrayList5.iterator();
            while (it.hasNext()) {
                a((C0038i) it.next());
            }
        } else {
            Iterator it2 = c0044o.f393b.iterator();
            while (it2.hasNext()) {
                a((C0038i) it2.next());
            }
        }
        Bundle bundle = c0044o.f413y;
        if (bundle != null) {
            this.f324d.putAll(bundle);
        }
        int i5 = Build.VERSION.SDK_INT;
        this.f322b.setShowWhen(c0044o.f402l);
        this.f322b.setLocalOnly(c0044o.f409u);
        this.f322b.setGroup(c0044o.f407s);
        this.f322b.setSortKey(null);
        this.f322b.setGroupSummary(c0044o.f408t);
        this.f325e = c0044o.f388E;
        this.f322b.setCategory(c0044o.f412x);
        this.f322b.setColor(c0044o.f414z);
        this.f322b.setVisibility(c0044o.f384A);
        this.f322b.setPublicVersion(null);
        this.f322b.setSound(notification.sound, notification.audioAttributes);
        ArrayList arrayList7 = c0044o.I;
        ArrayList<Y> arrayList8 = c0044o.f394c;
        if (i5 < 28) {
            if (arrayList8 == null) {
                arrayList4 = null;
            } else {
                arrayList4 = new ArrayList(arrayList8.size());
                for (Y y5 : arrayList8) {
                    String str = y5.f350c;
                    if (str == null) {
                        CharSequence charSequence = y5.f348a;
                        str = charSequence != null ? "name:" + ((Object) charSequence) : "";
                    }
                    arrayList4.add(str);
                }
            }
            if (arrayList4 != null) {
                if (arrayList7 == null) {
                    arrayList7 = arrayList4;
                } else {
                    C0967f c0967f = new C0967f(arrayList7.size() + arrayList4.size());
                    c0967f.addAll(arrayList4);
                    c0967f.addAll(arrayList7);
                    arrayList7 = new ArrayList(c0967f);
                }
            }
        }
        if (arrayList7 != null && !arrayList7.isEmpty()) {
            Iterator it3 = arrayList7.iterator();
            while (it3.hasNext()) {
                this.f322b.addPerson((String) it3.next());
            }
        }
        ArrayList arrayList9 = c0044o.f395d;
        if (arrayList9.size() > 0) {
            if (c0044o.f413y == null) {
                c0044o.f413y = new Bundle();
            }
            Bundle bundle2 = c0044o.f413y.getBundle("android.car.EXTENSIONS");
            bundle2 = bundle2 == null ? new Bundle() : bundle2;
            Bundle bundle3 = new Bundle(bundle2);
            Bundle bundle4 = new Bundle();
            int i6 = 0;
            while (i6 < arrayList9.size()) {
                String string = Integer.toString(i6);
                C0038i c0038i2 = (C0038i) arrayList9.get(i6);
                Bundle bundle5 = new Bundle();
                IconCompat iconCompatA = c0038i2.a();
                bundle5.putInt("icon", iconCompatA != null ? iconCompatA.f() : 0);
                bundle5.putCharSequence("title", c0038i2.f377h);
                bundle5.putParcelable("actionIntent", c0038i2.i);
                Bundle bundle6 = c0038i2.f370a;
                Bundle bundle7 = bundle6 != null ? new Bundle(bundle6) : new Bundle();
                bundle7.putBoolean("android.support.allowGeneratedReplies", c0038i2.f373d);
                bundle5.putBundle("extras", bundle7);
                a0[] a0VarArr = c0038i2.f372c;
                if (a0VarArr == null) {
                    arrayList2 = arrayList9;
                    arrayList3 = arrayList8;
                    bundleArr = null;
                } else {
                    Bundle[] bundleArr2 = new Bundle[a0VarArr.length];
                    arrayList2 = arrayList9;
                    arrayList3 = arrayList8;
                    int i7 = 0;
                    while (i7 < a0VarArr.length) {
                        a0 a0Var = a0VarArr[i7];
                        int i8 = i7;
                        Bundle bundle8 = new Bundle();
                        a0Var.getClass();
                        a0[] a0VarArr2 = a0VarArr;
                        Bundle[] bundleArr3 = bundleArr2;
                        bundle8.putString("resultKey", "FlutterLocalNotificationsPluginInputResult");
                        bundle8.putCharSequence("label", a0Var.f355a);
                        bundle8.putCharSequenceArray("choices", a0Var.f356b);
                        bundle8.putBoolean("allowFreeFormInput", a0Var.f357c);
                        bundle8.putBundle("extras", a0Var.f358d);
                        HashSet hashSet = a0Var.f359e;
                        if (!hashSet.isEmpty()) {
                            ArrayList<String> arrayList10 = new ArrayList<>(hashSet.size());
                            Iterator it4 = hashSet.iterator();
                            while (it4.hasNext()) {
                                arrayList10.add((String) it4.next());
                            }
                            bundle8.putStringArrayList("allowedDataTypes", arrayList10);
                        }
                        bundleArr3[i8] = bundle8;
                        i7 = i8 + 1;
                        a0VarArr = a0VarArr2;
                        bundleArr2 = bundleArr3;
                    }
                    bundleArr = bundleArr2;
                }
                bundle5.putParcelableArray("remoteInputs", bundleArr);
                bundle5.putBoolean("showsUserInterface", c0038i2.f374e);
                bundle5.putInt("semanticAction", 0);
                bundle4.putBundle(string, bundle5);
                i6++;
                arrayList9 = arrayList2;
                arrayList8 = arrayList3;
            }
            arrayList = arrayList8;
            bundle2.putBundle("invisible_actions", bundle4);
            bundle3.putBundle("invisible_actions", bundle4);
            if (c0044o.f413y == null) {
                c0044o.f413y = new Bundle();
            }
            c0044o.f413y.putBundle("android.car.EXTENSIONS", bundle2);
            this.f324d.putBundle("android.car.EXTENSIONS", bundle3);
        } else {
            arrayList = arrayList8;
        }
        int i9 = Build.VERSION.SDK_INT;
        this.f322b.setExtras(c0044o.f413y);
        this.f322b.setRemoteInputHistory(null);
        if (i9 >= 26) {
            L.o(this.f322b);
            L.v(this.f322b);
            L.w(this.f322b, c0044o.f386C);
            L.x(this.f322b, c0044o.f387D);
            L.r(this.f322b, c0044o.f388E);
            if (c0044o.f411w) {
                L.p(this.f322b, c0044o.f410v);
            }
            if (!TextUtils.isEmpty(c0044o.f385B)) {
                this.f322b.setSound(null).setDefaults(0).setLights(0, 0, 0).setVibrate(null);
            }
        }
        if (i9 >= 28) {
            for (Y y6 : arrayList) {
                Notification.Builder builder2 = this.f322b;
                y6.getClass();
                M.a(builder2, M.r(y6));
            }
        }
        int i10 = Build.VERSION.SDK_INT;
        if (i10 >= 29) {
            AbstractC0032c.c(this.f322b, c0044o.f389F);
            AbstractC0032c.d(this.f322b);
        }
        if (i10 >= 36) {
            O.f(this.f322b);
        }
        if (c0044o.f391H) {
            if (this.f323c.f408t) {
                this.f325e = 2;
            } else {
                this.f325e = 1;
            }
            this.f322b.setVibrate(null);
            this.f322b.setSound(null);
            int i11 = notification.defaults & (-4);
            notification.defaults = i11;
            this.f322b.setDefaults(i11);
            if (i10 >= 26) {
                if (TextUtils.isEmpty(this.f323c.f407s)) {
                    this.f322b.setGroup("silent");
                }
                L.r(this.f322b, this.f325e);
            }
        }
    }

    public final void a(C0038i c0038i) {
        IconCompat iconCompatA = c0038i.a();
        Notification.Action.Builder builder = new Notification.Action.Builder(iconCompatA != null ? iconCompatA.h(null) : null, c0038i.f377h, c0038i.i);
        a0[] a0VarArr = c0038i.f372c;
        if (a0VarArr != null) {
            RemoteInput[] remoteInputArr = new RemoteInput[a0VarArr.length];
            for (int i = 0; i < a0VarArr.length; i++) {
                a0 a0Var = a0VarArr[i];
                a0Var.getClass();
                RemoteInput.Builder builderAddExtras = new RemoteInput.Builder("FlutterLocalNotificationsPluginInputResult").setLabel(a0Var.f355a).setChoices(a0Var.f356b).setAllowFreeFormInput(a0Var.f357c).addExtras(a0Var.f358d);
                if (Build.VERSION.SDK_INT >= 26) {
                    Iterator it = a0Var.f359e.iterator();
                    while (it.hasNext()) {
                        L.m(builderAddExtras, (String) it.next());
                    }
                }
                if (Build.VERSION.SDK_INT >= 29) {
                    AbstractC0032c.f(builderAddExtras);
                }
                remoteInputArr[i] = builderAddExtras.build();
            }
            for (RemoteInput remoteInput : remoteInputArr) {
                builder.addRemoteInput(remoteInput);
            }
        }
        Bundle bundle = c0038i.f370a;
        Bundle bundle2 = bundle != null ? new Bundle(bundle) : new Bundle();
        boolean z5 = c0038i.f373d;
        bundle2.putBoolean("android.support.allowGeneratedReplies", z5);
        int i5 = Build.VERSION.SDK_INT;
        builder.setAllowGeneratedReplies(z5);
        bundle2.putInt("android.support.action.semanticAction", 0);
        if (i5 >= 28) {
            M.p(builder);
        }
        if (i5 >= 29) {
            AbstractC0032c.e(builder, c0038i.f375f);
        }
        if (i5 >= 31) {
            N.b(builder);
        }
        bundle2.putBoolean("android.support.action.showsUserInterface", c0038i.f374e);
        builder.addExtras(bundle2);
        this.f322b.addAction(builder.build());
    }
}
