package o;

import android.os.Build;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import com.google.android.gms.common.R;
import java.util.UUID;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Sr, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class DialogC0484Sr extends DialogC0269Kj {
    public NC p;
    public C0406Pr q;
    public final View r;
    public final C0380Or s;
    public boolean t;

    public DialogC0484Sr(NC nc, C0406Pr c0406Pr, View view, EnumC1280gK enumC1280gK, InterfaceC2281qr interfaceC2281qr, UUID uuid) {
        super(new ContextThemeWrapper(view.getContext(), c0406Pr.d ? R.style.DialogWindowTheme : R.style.FloatingDialogWindowTheme), 0);
        this.p = nc;
        this.q = c0406Pr;
        this.r = view;
        float f = 8;
        Window window = getWindow();
        if (window == null) {
            throw new IllegalStateException("Dialog has no window");
        }
        window.requestFeature(1);
        window.setBackgroundDrawableResource(android.R.color.transparent);
        F3.N(window, this.q.d);
        window.setGravity(17);
        if (!this.q.d) {
            window.addFlags(65792);
            WindowManager.LayoutParams attributes = window.getAttributes();
            int i = Build.VERSION.SDK_INT;
            if (i >= 28) {
                C1645k7.a.a(attributes);
            }
            if (i >= 30) {
                C1740l7 c1740l7 = C1740l7.a;
                c1740l7.a(attributes, 0);
                c1740l7.b(attributes, 0);
            }
            window.setAttributes(attributes);
        }
        C0380Or c0380Or = new C0380Or(getContext(), window);
        setTitle(this.q.e);
        c0380Or.setTag(R.id.compose_view_saveable_id_tag, "Dialog:" + uuid);
        c0380Or.setClipChildren(false);
        c0380Or.setElevation(interfaceC2281qr.B(f));
        c0380Or.setOutlineProvider(new C0458Rr(0));
        this.s = c0380Or;
        View decorView = window.getDecorView();
        ViewGroup viewGroup = decorView instanceof ViewGroup ? (ViewGroup) decorView : null;
        if (viewGroup != null) {
            c(viewGroup);
        }
        setContentView(c0380Or);
        AbstractC2461sm0.D(c0380Or, AbstractC2461sm0.p(view));
        AbstractC0940cn0.G(c0380Or, AbstractC0940cn0.s(view));
        AbstractC2841wm0.C(c0380Or, AbstractC2841wm0.u(view));
        d(this.p, this.q, enumC1280gK);
        getOnBackPressedDispatcher().a(new ZB(1, new C0780b4(this, 1)), this);
    }

    public static final void c(ViewGroup viewGroup) {
        viewGroup.setClipChildren(false);
        if (viewGroup instanceof C0380Or) {
            return;
        }
        int childCount = viewGroup.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = viewGroup.getChildAt(i);
            ViewGroup viewGroup2 = childAt instanceof ViewGroup ? (ViewGroup) childAt : null;
            if (viewGroup2 != null) {
                c(viewGroup2);
            }
        }
    }

    public final void d(NC nc, C0406Pr c0406Pr, EnumC1280gK enumC1280gK) {
        int i;
        this.p = nc;
        this.q = c0406Pr;
        c0406Pr.getClass();
        boolean zB = AbstractC1068e5.b(this.r);
        int iW = AbstractC2462sn.w(1);
        if (iW != 0) {
            if (iW == 1) {
                zB = true;
            } else {
                if (iW != 2) {
                    throw new C2170pj();
                }
                zB = false;
            }
        }
        getWindow().setFlags(zB ? 8192 : -8193, 8192);
        int iOrdinal = enumC1280gK.ordinal();
        if (iOrdinal == 0) {
            i = 0;
        } else {
            if (iOrdinal != 1) {
                throw new C2170pj();
            }
            i = 1;
        }
        C0380Or c0380Or = this.s;
        c0380Or.setLayoutDirection(i);
        boolean z = c0406Pr.d;
        boolean z2 = c0406Pr.c;
        Window window = c0380Or.t;
        boolean z3 = (c0380Or.x && z2 == c0380Or.v && z == c0380Or.w) ? false : true;
        c0380Or.v = z2;
        c0380Or.w = z;
        if (z3) {
            WindowManager.LayoutParams attributes = window.getAttributes();
            int i2 = z2 ? -2 : -1;
            if (i2 != attributes.width || !c0380Or.x) {
                window.setLayout(i2, -2);
                c0380Or.x = true;
            }
        }
        setCanceledOnTouchOutside(c0406Pr.b);
        Window window2 = getWindow();
        if (window2 != null) {
            window2.setSoftInputMode(z ? 0 : Build.VERSION.SDK_INT < 31 ? 16 : 48);
        }
    }

    @Override // android.app.Dialog, android.view.KeyEvent.Callback
    public final boolean onKeyUp(int i, KeyEvent keyEvent) {
        if (!this.q.a || !keyEvent.isTracking() || keyEvent.isCanceled() || i != 111) {
            return super.onKeyUp(i, keyEvent);
        }
        this.p.a();
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:35:0x008b  */
    @Override // android.app.Dialog
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean onTouchEvent(android.view.MotionEvent r10) {
        /*
            r9 = this;
            boolean r0 = super.onTouchEvent(r10)
            o.Pr r1 = r9.q
            boolean r1 = r1.b
            r2 = 3
            r3 = 0
            r4 = 1
            if (r1 == 0) goto L8b
            o.Or r1 = r9.s
            r1.getClass()
            float r5 = r10.getX()
            boolean r6 = java.lang.Float.isInfinite(r5)
            if (r6 != 0) goto L6e
            boolean r5 = java.lang.Float.isNaN(r5)
            if (r5 != 0) goto L6e
            float r5 = r10.getY()
            boolean r6 = java.lang.Float.isInfinite(r5)
            if (r6 != 0) goto L6e
            boolean r5 = java.lang.Float.isNaN(r5)
            if (r5 != 0) goto L6e
            android.view.View r5 = r1.getChildAt(r3)
            if (r5 != 0) goto L39
            goto L6e
        L39:
            int r6 = r1.getLeft()
            int r7 = r5.getLeft()
            int r7 = r7 + r6
            int r6 = r5.getWidth()
            int r6 = r6 + r7
            int r1 = r1.getTop()
            int r8 = r5.getTop()
            int r8 = r8 + r1
            int r1 = r5.getHeight()
            int r1 = r1 + r8
            float r5 = r10.getX()
            int r5 = o.C2887xC.D(r5)
            if (r7 > r5) goto L6e
            if (r5 > r6) goto L6e
            float r5 = r10.getY()
            int r5 = o.C2887xC.D(r5)
            if (r8 > r5) goto L6e
            if (r5 > r1) goto L6e
            goto L8b
        L6e:
            int r10 = r10.getActionMasked()
            if (r10 == 0) goto L88
            if (r10 == r4) goto L7c
            if (r10 == r2) goto L79
            goto L95
        L79:
            r9.t = r3
            return r0
        L7c:
            boolean r10 = r9.t
            if (r10 == 0) goto L95
            o.NC r10 = r9.p
            r10.a()
            r9.t = r3
            return r4
        L88:
            r9.t = r4
            return r4
        L8b:
            int r10 = r10.getActionMasked()
            if (r10 == 0) goto L96
            if (r10 == r4) goto L96
            if (r10 == r2) goto L96
        L95:
            return r0
        L96:
            r9.t = r3
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: o.DialogC0484Sr.onTouchEvent(android.view.MotionEvent):boolean");
    }

    @Override // android.app.Dialog, android.content.DialogInterface
    public final void cancel() {
    }
}
