package o;

import android.R;
import android.app.Activity;
import android.app.Dialog;
import android.app.UiModeManager;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.os.LocaleList;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ActionBarOverlayLayout;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.ContentFrameLayout;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.WeakHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class S7 extends F7 implements AO, LayoutInflater.Factory2 {
    public static final I80 s0 = new I80(0);
    public static final int[] t0 = {R.attr.windowBackground};
    public static final boolean u0 = !"robolectric".equals(Build.FINGERPRINT);
    public Db0 A;
    public CharSequence B;
    public InterfaceC0352Np C;
    public H7 D;
    public H7 E;
    public AbstractC1918n1 F;
    public ActionBarContextView G;
    public PopupWindow H;
    public G7 I;
    public boolean K;
    public ViewGroup L;
    public TextView M;
    public View N;
    public boolean O;
    public boolean P;
    public boolean Q;
    public boolean R;
    public boolean S;
    public boolean T;
    public boolean U;
    public boolean V;
    public R7[] W;
    public R7 X;
    public boolean Y;
    public boolean Z;
    public boolean a0;
    public boolean b0;
    public Configuration c0;
    public final int d0;
    public int e0;
    public int f0;
    public boolean g0;
    public O7 h0;
    public O7 i0;
    public boolean j0;
    public int k0;
    public boolean m0;
    public Rect n0;
    public Rect o0;
    public M8 p0;
    public OnBackInvokedDispatcher q0;
    public OnBackInvokedCallback r0;
    public final Object u;
    public final Context v;
    public Window w;
    public N7 x;
    public final Object y;
    public T0 z;
    public C1698kk0 J = null;
    public final G7 l0 = new G7(this, 0);

    public S7(Context context, Window window, InterfaceC2879x7 interfaceC2879x7, Object obj) {
        AppCompatActivity appCompatActivity = null;
        this.d0 = -100;
        this.v = context;
        this.y = interfaceC2879x7;
        this.u = obj;
        if (obj instanceof Dialog) {
            while (true) {
                if (context != null) {
                    if (!(context instanceof AppCompatActivity)) {
                        if (!(context instanceof ContextWrapper)) {
                            break;
                        } else {
                            context = ((ContextWrapper) context).getBaseContext();
                        }
                    } else {
                        appCompatActivity = (AppCompatActivity) context;
                        break;
                    }
                } else {
                    break;
                }
            }
            if (appCompatActivity != null) {
                this.d0 = ((S7) appCompatActivity.getDelegate()).d0;
            }
        }
        if (this.d0 == -100) {
            String name = this.u.getClass().getName();
            I80 i80 = s0;
            Integer num = (Integer) i80.get(name);
            if (num != null) {
                this.d0 = num.intValue();
                i80.remove(this.u.getClass().getName());
            }
        }
        if (window != null) {
            n(window);
        }
        V7.d();
    }

    public static C2327rM o(Context context) {
        C2327rM c2327rM;
        C2327rM c2327rM2;
        if (Build.VERSION.SDK_INT >= 33 || (c2327rM = F7.n) == null) {
            return null;
        }
        C2422sM c2422sM = c2327rM.a;
        C2327rM c2327rMB = L7.b(context.getApplicationContext().getResources().getConfiguration());
        if (c2422sM.a.isEmpty()) {
            c2327rM2 = C2327rM.b;
        } else {
            LinkedHashSet linkedHashSet = new LinkedHashSet();
            int i = 0;
            while (i < c2327rMB.a.a.size() + c2422sM.a.size()) {
                Locale locale = i < c2422sM.a.size() ? c2422sM.a.get(i) : c2327rMB.a.a.get(i - c2422sM.a.size());
                if (locale != null) {
                    linkedHashSet.add(locale);
                }
                i++;
            }
            c2327rM2 = new C2327rM(new C2422sM(new LocaleList((Locale[]) linkedHashSet.toArray(new Locale[linkedHashSet.size()]))));
        }
        return c2327rM2.a.a.isEmpty() ? c2327rMB : c2327rM2;
    }

    public static Configuration t(Context context, int i, C2327rM c2327rM, Configuration configuration, boolean z) {
        int i2 = i != 1 ? i != 2 ? z ? 0 : context.getApplicationContext().getResources().getConfiguration().uiMode & 48 : 32 : 16;
        Configuration configuration2 = new Configuration();
        configuration2.fontScale = 0.0f;
        if (configuration != null) {
            configuration2.setTo(configuration);
        }
        configuration2.uiMode = i2 | (configuration2.uiMode & (-49));
        if (c2327rM != null) {
            L7.d(configuration2, c2327rM);
        }
        return configuration2;
    }

    public final void A() throws IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
        w();
        if (this.Q && this.z == null) {
            Object obj = this.u;
            if (obj instanceof Activity) {
                this.z = new C1510il0((Activity) obj, this.R);
            } else if (obj instanceof Dialog) {
                this.z = new C1510il0((Dialog) obj);
            }
            T0 t02 = this.z;
            if (t02 != null) {
                t02.l(this.m0);
            }
        }
    }

    public final void B(int i) {
        this.k0 = (1 << i) | this.k0;
        if (this.j0) {
            return;
        }
        View decorView = this.w.getDecorView();
        WeakHashMap weakHashMap = Oj0.a;
        decorView.postOnAnimation(this.l0);
        this.j0 = true;
    }

    public final int C(Context context, int i) {
        if (i != -100) {
            if (i != -1) {
                if (i != 0) {
                    if (i != 1 && i != 2) {
                        if (i != 3) {
                            throw new IllegalStateException("Unknown value set for night mode. Please use one of the MODE_NIGHT values from AppCompatDelegate.");
                        }
                        if (this.i0 == null) {
                            this.i0 = new O7(this, context);
                        }
                        return this.i0.f();
                    }
                } else if (((UiModeManager) context.getApplicationContext().getSystemService("uimode")).getNightMode() != 0) {
                    return y(context).f();
                }
            }
            return i;
        }
        return -1;
    }

    public final boolean D() throws IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
        boolean z = this.Y;
        this.Y = false;
        R7 r7Z = z(0);
        if (!r7Z.m) {
            AbstractC1918n1 abstractC1918n1 = this.F;
            if (abstractC1918n1 != null) {
                abstractC1918n1.a();
                return true;
            }
            A();
            T0 t02 = this.z;
            if (t02 == null || !t02.b()) {
                return false;
            }
        } else if (!z) {
            r(r7Z, true);
            return true;
        }
        return true;
    }

    /* JADX WARN: Code restructure failed: missing block: B:87:0x0176, code lost:
    
        if (r2.q.getCount() > 0) goto L88;
     */
    /* JADX WARN: Removed duplicated region for block: B:100:0x01d3  */
    /* JADX WARN: Removed duplicated region for block: B:105:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void E(o.R7 r18, android.view.KeyEvent r19) throws java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException {
        /*
            Method dump skipped, instructions count: 474
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.E(o.R7, android.view.KeyEvent):void");
    }

    public final boolean F(R7 r7, int i, KeyEvent keyEvent) {
        CO co;
        if (keyEvent.isSystem()) {
            return false;
        }
        if ((r7.k || G(r7, keyEvent)) && (co = r7.h) != null) {
            return co.performShortcut(i, keyEvent, 1);
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:62:0x00d8  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean G(o.R7 r13, android.view.KeyEvent r14) {
        /*
            Method dump skipped, instructions count: 369
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.G(o.R7, android.view.KeyEvent):boolean");
    }

    public final void H() {
        if (this.K) {
            throw new AndroidRuntimeException("Window feature must be requested before adding content");
        }
    }

    public final void I() {
        OnBackInvokedCallback onBackInvokedCallback;
        if (Build.VERSION.SDK_INT >= 33) {
            boolean z = false;
            if (this.q0 != null && (z(0).m || this.F != null)) {
                z = true;
            }
            if (z && this.r0 == null) {
                this.r0 = M7.b(this.q0, this);
            } else {
                if (z || (onBackInvokedCallback = this.r0) == null) {
                    return;
                }
                M7.c(this.q0, onBackInvokedCallback);
                this.r0 = null;
            }
        }
    }

    @Override // o.F7
    public final void a() throws IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
        if (this.z != null) {
            A();
            if (this.z.f()) {
                return;
            }
            B(0);
        }
    }

    @Override // o.F7
    public final void c() throws IllegalAccessException, NoSuchFieldException, PackageManager.NameNotFoundException, SecurityException, IllegalArgumentException {
        String strR;
        this.Z = true;
        m(false, true);
        x();
        Object obj = this.u;
        if (obj instanceof Activity) {
            try {
                Activity activity = (Activity) obj;
                try {
                    strR = C2887xC.r(activity, activity.getComponentName());
                } catch (PackageManager.NameNotFoundException e) {
                    throw new IllegalArgumentException(e);
                }
            } catch (IllegalArgumentException unused) {
                strR = null;
            }
            if (strR != null) {
                T0 t02 = this.z;
                if (t02 == null) {
                    this.m0 = true;
                } else {
                    t02.l(true);
                }
            }
            synchronized (F7.s) {
                F7.e(this);
                F7.r.add(new WeakReference(this));
            }
        }
        this.c0 = new Configuration(this.v.getResources().getConfiguration());
        this.a0 = true;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x004d  */
    @Override // o.F7
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void d() {
        /*
            r3 = this;
            java.lang.Object r0 = r3.u
            boolean r0 = r0 instanceof android.app.Activity
            if (r0 == 0) goto L11
            java.lang.Object r0 = o.F7.s
            monitor-enter(r0)
            o.F7.e(r3)     // Catch: java.lang.Throwable -> Le
            monitor-exit(r0)     // Catch: java.lang.Throwable -> Le
            goto L11
        Le:
            r1 = move-exception
            monitor-exit(r0)     // Catch: java.lang.Throwable -> Le
            throw r1
        L11:
            boolean r0 = r3.j0
            if (r0 == 0) goto L20
            android.view.Window r0 = r3.w
            android.view.View r0 = r0.getDecorView()
            o.G7 r1 = r3.l0
            r0.removeCallbacks(r1)
        L20:
            r0 = 1
            r3.b0 = r0
            int r0 = r3.d0
            r1 = -100
            if (r0 == r1) goto L4d
            java.lang.Object r0 = r3.u
            boolean r1 = r0 instanceof android.app.Activity
            if (r1 == 0) goto L4d
            android.app.Activity r0 = (android.app.Activity) r0
            boolean r0 = r0.isChangingConfigurations()
            if (r0 == 0) goto L4d
            o.I80 r0 = o.S7.s0
            java.lang.Object r1 = r3.u
            java.lang.Class r1 = r1.getClass()
            java.lang.String r1 = r1.getName()
            int r2 = r3.d0
            java.lang.Integer r2 = java.lang.Integer.valueOf(r2)
            r0.put(r1, r2)
            goto L5c
        L4d:
            o.I80 r0 = o.S7.s0
            java.lang.Object r1 = r3.u
            java.lang.Class r1 = r1.getClass()
            java.lang.String r1 = r1.getName()
            r0.remove(r1)
        L5c:
            o.T0 r0 = r3.z
            if (r0 == 0) goto L63
            r0.h()
        L63:
            o.O7 r0 = r3.h0
            if (r0 == 0) goto L6a
            r0.c()
        L6a:
            o.O7 r0 = r3.i0
            if (r0 == 0) goto L71
            r0.c()
        L71:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.d():void");
    }

    @Override // o.F7
    public final boolean f(int i) {
        if (i == 8) {
            i = 108;
        } else if (i == 9) {
            i = 109;
        }
        if (this.U && i == 108) {
            return false;
        }
        if (this.Q && i == 1) {
            this.Q = false;
        }
        if (i == 1) {
            H();
            this.U = true;
            return true;
        }
        if (i == 2) {
            H();
            this.O = true;
            return true;
        }
        if (i == 5) {
            H();
            this.P = true;
            return true;
        }
        if (i == 10) {
            H();
            this.S = true;
            return true;
        }
        if (i == 108) {
            H();
            this.Q = true;
            return true;
        }
        if (i != 109) {
            return this.w.requestFeature(i);
        }
        H();
        this.R = true;
        return true;
    }

    @Override // o.F7
    public final void g(int i) throws IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
        w();
        ViewGroup viewGroup = (ViewGroup) this.L.findViewById(R.id.content);
        viewGroup.removeAllViews();
        LayoutInflater.from(this.v).inflate(i, viewGroup);
        this.x.a(this.w.getCallback());
    }

    @Override // o.F7
    public final void h(View view) throws IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
        w();
        ViewGroup viewGroup = (ViewGroup) this.L.findViewById(R.id.content);
        viewGroup.removeAllViews();
        viewGroup.addView(view);
        this.x.a(this.w.getCallback());
    }

    @Override // o.F7
    public final void i(View view, ViewGroup.LayoutParams layoutParams) throws IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
        w();
        ViewGroup viewGroup = (ViewGroup) this.L.findViewById(R.id.content);
        viewGroup.removeAllViews();
        viewGroup.addView(view, layoutParams);
        this.x.a(this.w.getCallback());
    }

    @Override // o.F7
    public final void j(CharSequence charSequence) {
        this.B = charSequence;
        InterfaceC0352Np interfaceC0352Np = this.C;
        if (interfaceC0352Np != null) {
            interfaceC0352Np.setWindowTitle(charSequence);
            return;
        }
        T0 t02 = this.z;
        if (t02 != null) {
            t02.n(charSequence);
            return;
        }
        TextView textView = this.M;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x0042  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0046  */
    /* JADX WARN: Removed duplicated region for block: B:67:0x01a2  */
    /* JADX WARN: Type inference failed for: r2v0, types: [java.lang.Object, o.x7] */
    @Override // o.F7
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final o.AbstractC1918n1 k(o.InterfaceC1823m1 r9) throws java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException {
        /*
            Method dump skipped, instructions count: 442
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.k(o.m1):o.n1");
    }

    @Override // o.AO
    public final boolean l(CO co, MenuItem menuItem) {
        R7 r7;
        Window.Callback callback = this.w.getCallback();
        if (callback != null && !this.b0) {
            CO coK = co.k();
            R7[] r7Arr = this.W;
            int length = r7Arr != null ? r7Arr.length : 0;
            int i = 0;
            while (true) {
                if (i < length) {
                    r7 = r7Arr[i];
                    if (r7 != null && r7.h == coK) {
                        break;
                    }
                    i++;
                } else {
                    r7 = null;
                    break;
                }
            }
            if (r7 != null) {
                return callback.onMenuItemSelected(r7.a, menuItem);
            }
        }
        return false;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:112:0x016e  */
    /* JADX WARN: Removed duplicated region for block: B:69:0x00f1  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean m(boolean r18, boolean r19) throws java.lang.IllegalAccessException, java.lang.NoSuchFieldException, android.content.pm.PackageManager.NameNotFoundException, java.lang.SecurityException, java.lang.IllegalArgumentException {
        /*
            Method dump skipped, instructions count: 579
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.m(boolean, boolean):boolean");
    }

    /* JADX WARN: Removed duplicated region for block: B:35:0x0074  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void n(android.view.Window r8) {
        /*
            r7 = this;
            java.lang.String r0 = "AppCompat has already installed itself into the Window"
            android.view.Window r1 = r7.w
            if (r1 != 0) goto L80
            android.view.Window$Callback r1 = r8.getCallback()
            boolean r2 = r1 instanceof o.N7
            if (r2 != 0) goto L7a
            o.N7 r0 = new o.N7
            r0.<init>(r7, r1)
            r7.x = r0
            r8.setCallback(r0)
            android.content.Context r0 = r7.v
            int[] r1 = o.S7.t0
            r2 = 0
            android.content.res.TypedArray r1 = r0.obtainStyledAttributes(r2, r1)
            r3 = 0
            boolean r4 = r1.hasValue(r3)
            if (r4 == 0) goto L3f
            int r3 = r1.getResourceId(r3, r3)
            if (r3 == 0) goto L3f
            o.V7 r4 = o.V7.a()
            monitor-enter(r4)
            o.v20 r5 = r4.a     // Catch: java.lang.Throwable -> L3c
            r6 = 1
            android.graphics.drawable.Drawable r0 = r5.d(r0, r3, r6)     // Catch: java.lang.Throwable -> L3c
            monitor-exit(r4)
            goto L40
        L3c:
            r8 = move-exception
            monitor-exit(r4)     // Catch: java.lang.Throwable -> L3c
            throw r8
        L3f:
            r0 = r2
        L40:
            if (r0 == 0) goto L45
            r8.setBackgroundDrawable(r0)
        L45:
            r1.recycle()
            r7.w = r8
            int r8 = android.os.Build.VERSION.SDK_INT
            r0 = 33
            if (r8 < r0) goto L79
            android.window.OnBackInvokedDispatcher r8 = r7.q0
            if (r8 != 0) goto L79
            java.lang.Object r0 = r7.u
            if (r8 == 0) goto L61
            android.window.OnBackInvokedCallback r1 = r7.r0
            if (r1 == 0) goto L61
            o.M7.c(r8, r1)
            r7.r0 = r2
        L61:
            boolean r8 = r0 instanceof android.app.Activity
            if (r8 == 0) goto L74
            android.app.Activity r0 = (android.app.Activity) r0
            android.view.Window r8 = r0.getWindow()
            if (r8 == 0) goto L74
            android.window.OnBackInvokedDispatcher r8 = o.M7.a(r0)
            r7.q0 = r8
            goto L76
        L74:
            r7.q0 = r2
        L76:
            r7.I()
        L79:
            return
        L7a:
            java.lang.IllegalStateException r8 = new java.lang.IllegalStateException
            r8.<init>(r0)
            throw r8
        L80:
            java.lang.IllegalStateException r8 = new java.lang.IllegalStateException
            r8.<init>(r0)
            throw r8
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.n(android.view.Window):void");
    }

    /*  JADX ERROR: JadxRuntimeException in pass: RegionMakerVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Can't find top splitter block for handler:B:113:0x01c0
        	at jadx.core.utils.BlockUtils.getTopSplitterForHandler(BlockUtils.java:1178)
        	at jadx.core.dex.visitors.regions.maker.ExcHandlersRegionMaker.collectHandlerRegions(ExcHandlersRegionMaker.java:53)
        	at jadx.core.dex.visitors.regions.maker.ExcHandlersRegionMaker.process(ExcHandlersRegionMaker.java:38)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:27)
        */
    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0073  */
    @Override // android.view.LayoutInflater.Factory2
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final android.view.View onCreateView(android.view.View r9, java.lang.String r10, android.content.Context r11, android.util.AttributeSet r12) {
        /*
            Method dump skipped, instructions count: 690
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.onCreateView(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet):android.view.View");
    }

    public final void p(int i, R7 r7, CO co) {
        if (co == null) {
            if (r7 == null && i >= 0) {
                R7[] r7Arr = this.W;
                if (i < r7Arr.length) {
                    r7 = r7Arr[i];
                }
            }
            if (r7 != null) {
                co = r7.h;
            }
        }
        if ((r7 == null || r7.m) && !this.b0) {
            N7 n7 = this.x;
            Window.Callback callback = this.w.getCallback();
            n7.getClass();
            try {
                n7.p = true;
                callback.onPanelClosed(i, co);
            } finally {
                n7.p = false;
            }
        }
    }

    public final void q(CO co) {
        C1444i1 c1444i1;
        if (this.V) {
            return;
        }
        this.V = true;
        ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) this.C;
        actionBarOverlayLayout.k();
        ActionMenuView actionMenuView = ((Vf0) actionBarOverlayLayout.p).a.l;
        if (actionMenuView != null && (c1444i1 = actionMenuView.E) != null) {
            c1444i1.e();
            C1156f1 c1156f1 = c1444i1.E;
            if (c1156f1 != null && c1156f1.b()) {
                c1156f1.i.dismiss();
            }
        }
        Window.Callback callback = this.w.getCallback();
        if (callback != null && !this.b0) {
            callback.onPanelClosed(108, co);
        }
        this.V = false;
    }

    public final void r(R7 r7, boolean z) {
        Q7 q7;
        InterfaceC0352Np interfaceC0352Np;
        if (z && r7.a == 0 && (interfaceC0352Np = this.C) != null) {
            ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) interfaceC0352Np;
            actionBarOverlayLayout.k();
            if (((Vf0) actionBarOverlayLayout.p).a.p()) {
                q(r7.h);
                return;
            }
        }
        WindowManager windowManager = (WindowManager) this.v.getSystemService("window");
        if (windowManager != null && r7.m && (q7 = r7.e) != null) {
            windowManager.removeView(q7);
            if (z) {
                p(r7.a, r7, null);
            }
        }
        r7.k = false;
        r7.l = false;
        r7.m = false;
        r7.f = null;
        r7.n = true;
        if (this.X == r7) {
            this.X = null;
        }
        if (r7.a == 0) {
            I();
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:19:0x0048, code lost:
    
        if (r6.h() != false) goto L20;
     */
    @Override // o.AO
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void s(o.CO r6) throws java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException {
        /*
            r5 = this;
            o.Np r6 = r5.C
            r0 = 1
            r1 = 0
            if (r6 == 0) goto Ld3
            androidx.appcompat.widget.ActionBarOverlayLayout r6 = (androidx.appcompat.widget.ActionBarOverlayLayout) r6
            r6.k()
            o.Op r6 = r6.p
            o.Vf0 r6 = (o.Vf0) r6
            androidx.appcompat.widget.Toolbar r6 = r6.a
            int r2 = r6.getVisibility()
            if (r2 != 0) goto Ld3
            androidx.appcompat.widget.ActionMenuView r6 = r6.l
            if (r6 == 0) goto Ld3
            boolean r6 = r6.D
            if (r6 == 0) goto Ld3
            android.content.Context r6 = r5.v
            android.view.ViewConfiguration r6 = android.view.ViewConfiguration.get(r6)
            boolean r6 = r6.hasPermanentMenuKey()
            if (r6 == 0) goto L4a
            o.Np r6 = r5.C
            androidx.appcompat.widget.ActionBarOverlayLayout r6 = (androidx.appcompat.widget.ActionBarOverlayLayout) r6
            r6.k()
            o.Op r6 = r6.p
            o.Vf0 r6 = (o.Vf0) r6
            androidx.appcompat.widget.Toolbar r6 = r6.a
            androidx.appcompat.widget.ActionMenuView r6 = r6.l
            if (r6 == 0) goto Ld3
            o.i1 r6 = r6.E
            if (r6 == 0) goto Ld3
            o.cD r2 = r6.F
            if (r2 != 0) goto L4a
            boolean r6 = r6.h()
            if (r6 == 0) goto Ld3
        L4a:
            android.view.Window r6 = r5.w
            android.view.Window$Callback r6 = r6.getCallback()
            o.Np r2 = r5.C
            androidx.appcompat.widget.ActionBarOverlayLayout r2 = (androidx.appcompat.widget.ActionBarOverlayLayout) r2
            r2.k()
            o.Op r2 = r2.p
            o.Vf0 r2 = (o.Vf0) r2
            androidx.appcompat.widget.Toolbar r2 = r2.a
            boolean r2 = r2.p()
            r3 = 108(0x6c, float:1.51E-43)
            if (r2 == 0) goto L8c
            o.Np r0 = r5.C
            androidx.appcompat.widget.ActionBarOverlayLayout r0 = (androidx.appcompat.widget.ActionBarOverlayLayout) r0
            r0.k()
            o.Op r0 = r0.p
            o.Vf0 r0 = (o.Vf0) r0
            androidx.appcompat.widget.Toolbar r0 = r0.a
            androidx.appcompat.widget.ActionMenuView r0 = r0.l
            if (r0 == 0) goto L7e
            o.i1 r0 = r0.E
            if (r0 == 0) goto L7e
            boolean r0 = r0.e()
        L7e:
            boolean r0 = r5.b0
            if (r0 != 0) goto Ld2
            o.R7 r0 = r5.z(r1)
            o.CO r0 = r0.h
            r6.onPanelClosed(r3, r0)
            return
        L8c:
            if (r6 == 0) goto Ld2
            boolean r2 = r5.b0
            if (r2 != 0) goto Ld2
            boolean r2 = r5.j0
            if (r2 == 0) goto La9
            int r2 = r5.k0
            r0 = r0 & r2
            if (r0 == 0) goto La9
            android.view.Window r0 = r5.w
            android.view.View r0 = r0.getDecorView()
            o.G7 r2 = r5.l0
            r0.removeCallbacks(r2)
            r2.run()
        La9:
            o.R7 r0 = r5.z(r1)
            o.CO r2 = r0.h
            if (r2 == 0) goto Ld2
            boolean r4 = r0.f309o
            if (r4 != 0) goto Ld2
            android.view.View r4 = r0.g
            boolean r1 = r6.onPreparePanel(r1, r4, r2)
            if (r1 == 0) goto Ld2
            o.CO r0 = r0.h
            r6.onMenuOpened(r3, r0)
            o.Np r6 = r5.C
            androidx.appcompat.widget.ActionBarOverlayLayout r6 = (androidx.appcompat.widget.ActionBarOverlayLayout) r6
            r6.k()
            o.Op r6 = r6.p
            o.Vf0 r6 = (o.Vf0) r6
            androidx.appcompat.widget.Toolbar r6 = r6.a
            r6.v()
        Ld2:
            return
        Ld3:
            o.R7 r6 = r5.z(r1)
            r6.n = r0
            r5.r(r6, r1)
            r0 = 0
            r5.E(r6, r0)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.s(o.CO):void");
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x003f  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x00f3  */
    /* JADX WARN: Removed duplicated region for block: B:85:0x011b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean u(android.view.KeyEvent r7) throws java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException {
        /*
            Method dump skipped, instructions count: 309
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.S7.u(android.view.KeyEvent):boolean");
    }

    public final void v(int i) {
        R7 r7Z = z(i);
        if (r7Z.h != null) {
            Bundle bundle = new Bundle();
            r7Z.h.t(bundle);
            if (bundle.size() > 0) {
                r7Z.p = bundle;
            }
            r7Z.h.w();
            r7Z.h.clear();
        }
        r7Z.f309o = true;
        r7Z.n = true;
        if ((i == 108 || i == 0) && this.C != null) {
            R7 r7Z2 = z(0);
            r7Z2.k = false;
            G(r7Z2, null);
        }
    }

    public final void w() throws IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
        ViewGroup viewGroup;
        if (this.K) {
            return;
        }
        Context context = this.v;
        int[] iArr = YZ.j;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(iArr);
        if (!typedArrayObtainStyledAttributes.hasValue(117)) {
            typedArrayObtainStyledAttributes.recycle();
            throw new IllegalStateException("You need to use a Theme.AppCompat theme (or descendant) with this activity.");
        }
        int i = 0;
        int i2 = 1;
        if (typedArrayObtainStyledAttributes.getBoolean(126, false)) {
            f(1);
        } else if (typedArrayObtainStyledAttributes.getBoolean(117, false)) {
            f(108);
        }
        if (typedArrayObtainStyledAttributes.getBoolean(118, false)) {
            f(109);
        }
        if (typedArrayObtainStyledAttributes.getBoolean(119, false)) {
            f(10);
        }
        this.T = typedArrayObtainStyledAttributes.getBoolean(0, false);
        typedArrayObtainStyledAttributes.recycle();
        x();
        this.w.getDecorView();
        LayoutInflater layoutInflaterFrom = LayoutInflater.from(context);
        if (this.U) {
            viewGroup = this.S ? (ViewGroup) layoutInflaterFrom.inflate(com.google.android.gms.common.R.layout.abc_screen_simple_overlay_action_mode, (ViewGroup) null) : (ViewGroup) layoutInflaterFrom.inflate(com.google.android.gms.common.R.layout.abc_screen_simple, (ViewGroup) null);
        } else if (this.T) {
            viewGroup = (ViewGroup) layoutInflaterFrom.inflate(com.google.android.gms.common.R.layout.abc_dialog_title_material, (ViewGroup) null);
            this.R = false;
            this.Q = false;
        } else if (this.Q) {
            TypedValue typedValue = new TypedValue();
            context.getTheme().resolveAttribute(com.google.android.gms.common.R.attr.actionBarTheme, typedValue, true);
            viewGroup = (ViewGroup) LayoutInflater.from(typedValue.resourceId != 0 ? new C0194Hm(context, typedValue.resourceId) : context).inflate(com.google.android.gms.common.R.layout.abc_screen_toolbar, (ViewGroup) null);
            InterfaceC0352Np interfaceC0352Np = (InterfaceC0352Np) viewGroup.findViewById(com.google.android.gms.common.R.id.decor_content_parent);
            this.C = interfaceC0352Np;
            interfaceC0352Np.setWindowCallback(this.w.getCallback());
            if (this.R) {
                ((ActionBarOverlayLayout) this.C).j(109);
            }
            if (this.O) {
                ((ActionBarOverlayLayout) this.C).j(2);
            }
            if (this.P) {
                ((ActionBarOverlayLayout) this.C).j(5);
            }
        } else {
            viewGroup = null;
        }
        if (viewGroup == null) {
            throw new IllegalArgumentException("AppCompat does not support the current theme features: { windowActionBar: " + this.Q + ", windowActionBarOverlay: " + this.R + ", android:windowIsFloating: " + this.T + ", windowActionModeOverlay: " + this.S + ", windowNoTitle: " + this.U + " }");
        }
        H7 h7 = new H7(this, i);
        WeakHashMap weakHashMap = Oj0.a;
        Gj0.l(viewGroup, h7);
        if (this.C == null) {
            this.M = (TextView) viewGroup.findViewById(com.google.android.gms.common.R.id.title);
        }
        boolean z = AbstractC2457sk0.a;
        try {
            Method method = viewGroup.getClass().getMethod("makeOptionalFitsSystemWindows", null);
            if (!method.isAccessible()) {
                method.setAccessible(true);
            }
            method.invoke(viewGroup, null);
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) {
        }
        ContentFrameLayout contentFrameLayout = (ContentFrameLayout) viewGroup.findViewById(com.google.android.gms.common.R.id.action_bar_activity_content);
        ViewGroup viewGroup2 = (ViewGroup) this.w.findViewById(R.id.content);
        if (viewGroup2 != null) {
            while (viewGroup2.getChildCount() > 0) {
                View childAt = viewGroup2.getChildAt(0);
                viewGroup2.removeViewAt(0);
                contentFrameLayout.addView(childAt);
            }
            viewGroup2.setId(-1);
            contentFrameLayout.setId(R.id.content);
            if (viewGroup2 instanceof FrameLayout) {
                ((FrameLayout) viewGroup2).setForeground(null);
            }
        }
        this.w.setContentView(viewGroup);
        contentFrameLayout.setAttachListener(new H7(this, i2));
        this.L = viewGroup;
        Object obj = this.u;
        CharSequence title = obj instanceof Activity ? ((Activity) obj).getTitle() : this.B;
        if (!TextUtils.isEmpty(title)) {
            InterfaceC0352Np interfaceC0352Np2 = this.C;
            if (interfaceC0352Np2 != null) {
                interfaceC0352Np2.setWindowTitle(title);
            } else {
                T0 t02 = this.z;
                if (t02 != null) {
                    t02.n(title);
                } else {
                    TextView textView = this.M;
                    if (textView != null) {
                        textView.setText(title);
                    }
                }
            }
        }
        ContentFrameLayout contentFrameLayout2 = (ContentFrameLayout) this.L.findViewById(R.id.content);
        View decorView = this.w.getDecorView();
        contentFrameLayout2.r.set(decorView.getPaddingLeft(), decorView.getPaddingTop(), decorView.getPaddingRight(), decorView.getPaddingBottom());
        if (contentFrameLayout2.isLaidOut()) {
            contentFrameLayout2.requestLayout();
        }
        TypedArray typedArrayObtainStyledAttributes2 = context.obtainStyledAttributes(iArr);
        typedArrayObtainStyledAttributes2.getValue(124, contentFrameLayout2.getMinWidthMajor());
        typedArrayObtainStyledAttributes2.getValue(125, contentFrameLayout2.getMinWidthMinor());
        if (typedArrayObtainStyledAttributes2.hasValue(122)) {
            typedArrayObtainStyledAttributes2.getValue(122, contentFrameLayout2.getFixedWidthMajor());
        }
        if (typedArrayObtainStyledAttributes2.hasValue(123)) {
            typedArrayObtainStyledAttributes2.getValue(123, contentFrameLayout2.getFixedWidthMinor());
        }
        if (typedArrayObtainStyledAttributes2.hasValue(120)) {
            typedArrayObtainStyledAttributes2.getValue(120, contentFrameLayout2.getFixedHeightMajor());
        }
        if (typedArrayObtainStyledAttributes2.hasValue(121)) {
            typedArrayObtainStyledAttributes2.getValue(121, contentFrameLayout2.getFixedHeightMinor());
        }
        typedArrayObtainStyledAttributes2.recycle();
        contentFrameLayout2.requestLayout();
        this.K = true;
        R7 r7Z = z(0);
        if (this.b0 || r7Z.h != null) {
            return;
        }
        B(108);
    }

    public final void x() {
        if (this.w == null) {
            Object obj = this.u;
            if (obj instanceof Activity) {
                n(((Activity) obj).getWindow());
            }
        }
        if (this.w == null) {
            throw new IllegalStateException("We have not been given a Window");
        }
    }

    public final AbstractC2201q0 y(Context context) {
        if (this.h0 == null) {
            if (C70.p == null) {
                Context applicationContext = context.getApplicationContext();
                C70.p = new C70(applicationContext, (LocationManager) applicationContext.getSystemService("location"));
            }
            this.h0 = new O7(this, C70.p);
        }
        return this.h0;
    }

    public final R7 z(int i) {
        R7[] r7Arr = this.W;
        if (r7Arr == null || r7Arr.length <= i) {
            R7[] r7Arr2 = new R7[i + 1];
            if (r7Arr != null) {
                System.arraycopy(r7Arr, 0, r7Arr2, 0, r7Arr.length);
            }
            this.W = r7Arr2;
            r7Arr = r7Arr2;
        }
        R7 r7 = r7Arr[i];
        if (r7 != null) {
            return r7;
        }
        R7 r72 = new R7();
        r72.a = i;
        r72.n = false;
        r7Arr[i] = r72;
        return r72;
    }

    @Override // android.view.LayoutInflater.Factory
    public final View onCreateView(String str, Context context, AttributeSet attributeSet) {
        return onCreateView(null, str, context, attributeSet);
    }
}
