package androidx.core.view;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.WindowInsets;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Objects;

/* JADX INFO: compiled from: WindowInsetsCompat.java */
/* JADX INFO: loaded from: classes.dex */
public class j0 {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final j0 f1900b;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final l f1901a;

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    @SuppressLint({"SoonBlockedPrivateApi"})
    static class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private static Field f1902a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private static Field f1903b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private static Field f1904c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private static boolean f1905d;

        static {
            try {
                Field declaredField = View.class.getDeclaredField("mAttachInfo");
                f1902a = declaredField;
                declaredField.setAccessible(true);
                Class<?> cls = Class.forName("android.view.View$AttachInfo");
                Field declaredField2 = cls.getDeclaredField("mStableInsets");
                f1903b = declaredField2;
                declaredField2.setAccessible(true);
                Field declaredField3 = cls.getDeclaredField("mContentInsets");
                f1904c = declaredField3;
                declaredField3.setAccessible(true);
                f1905d = true;
            } catch (ReflectiveOperationException e3) {
                Log.w("WindowInsetsCompat", "Failed to get visible insets from AttachInfo " + e3.getMessage(), e3);
            }
        }

        public static j0 a(View view) {
            if (f1905d && view.isAttachedToWindow()) {
                try {
                    Object obj = f1902a.get(view.getRootView());
                    if (obj != null) {
                        Rect rect = (Rect) f1903b.get(obj);
                        Rect rect2 = (Rect) f1904c.get(obj);
                        if (rect != null && rect2 != null) {
                            j0 j0VarA = new b().b(androidx.core.graphics.b.c(rect)).c(androidx.core.graphics.b.c(rect2)).a();
                            j0VarA.r(j0VarA);
                            j0VarA.d(view.getRootView());
                            return j0VarA;
                        }
                    }
                } catch (IllegalAccessException e3) {
                    Log.w("WindowInsetsCompat", "Failed to get insets from AttachInfo. " + e3.getMessage(), e3);
                }
            }
            return null;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class e extends d {
        e() {
        }

        e(j0 j0Var) {
            super(j0Var);
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class f {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private final j0 f1914a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        androidx.core.graphics.b[] f1915b;

        f() {
            this(new j0((j0) null));
        }

        protected final void a() {
            androidx.core.graphics.b[] bVarArr = this.f1915b;
            if (bVarArr != null) {
                androidx.core.graphics.b bVarF = bVarArr[m.a(1)];
                androidx.core.graphics.b bVarF2 = this.f1915b[m.a(2)];
                if (bVarF2 == null) {
                    bVarF2 = this.f1914a.f(2);
                }
                if (bVarF == null) {
                    bVarF = this.f1914a.f(1);
                }
                f(androidx.core.graphics.b.a(bVarF, bVarF2));
                androidx.core.graphics.b bVar = this.f1915b[m.a(16)];
                if (bVar != null) {
                    e(bVar);
                }
                androidx.core.graphics.b bVar2 = this.f1915b[m.a(32)];
                if (bVar2 != null) {
                    c(bVar2);
                }
                androidx.core.graphics.b bVar3 = this.f1915b[m.a(64)];
                if (bVar3 != null) {
                    g(bVar3);
                }
            }
        }

        j0 b() {
            a();
            return this.f1914a;
        }

        void c(androidx.core.graphics.b bVar) {
        }

        void d(androidx.core.graphics.b bVar) {
        }

        void e(androidx.core.graphics.b bVar) {
        }

        void f(androidx.core.graphics.b bVar) {
        }

        void g(androidx.core.graphics.b bVar) {
        }

        f(j0 j0Var) {
            this.f1914a = j0Var;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class i extends h {
        i(j0 j0Var, WindowInsets windowInsets) {
            super(j0Var, windowInsets);
        }

        @Override // androidx.core.view.j0.l
        j0 a() {
            return j0.u(this.f1921c.consumeDisplayCutout());
        }

        @Override // androidx.core.view.j0.g, androidx.core.view.j0.l
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof i)) {
                return false;
            }
            i iVar = (i) obj;
            return Objects.equals(this.f1921c, iVar.f1921c) && Objects.equals(this.f1925g, iVar.f1925g);
        }

        @Override // androidx.core.view.j0.l
        androidx.core.view.d f() {
            return androidx.core.view.d.e(this.f1921c.getDisplayCutout());
        }

        @Override // androidx.core.view.j0.l
        public int hashCode() {
            return this.f1921c.hashCode();
        }

        i(j0 j0Var, i iVar) {
            super(j0Var, iVar);
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class k extends j {

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        static final j0 f1930q = j0.u(WindowInsets.CONSUMED);

        k(j0 j0Var, WindowInsets windowInsets) {
            super(j0Var, windowInsets);
        }

        @Override // androidx.core.view.j0.g, androidx.core.view.j0.l
        final void d(View view) {
        }

        @Override // androidx.core.view.j0.g, androidx.core.view.j0.l
        public androidx.core.graphics.b g(int i3) {
            return androidx.core.graphics.b.d(this.f1921c.getInsets(n.a(i3)));
        }

        k(j0 j0Var, k kVar) {
            super(j0Var, kVar);
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class l {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        static final j0 f1931b = new b().a().a().b().c();

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final j0 f1932a;

        l(j0 j0Var) {
            this.f1932a = j0Var;
        }

        j0 a() {
            return this.f1932a;
        }

        j0 b() {
            return this.f1932a;
        }

        j0 c() {
            return this.f1932a;
        }

        void d(View view) {
        }

        void e(j0 j0Var) {
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof l)) {
                return false;
            }
            l lVar = (l) obj;
            return o() == lVar.o() && n() == lVar.n() && androidx.core.util.c.a(k(), lVar.k()) && androidx.core.util.c.a(i(), lVar.i()) && androidx.core.util.c.a(f(), lVar.f());
        }

        androidx.core.view.d f() {
            return null;
        }

        androidx.core.graphics.b g(int i3) {
            return androidx.core.graphics.b.f1684e;
        }

        androidx.core.graphics.b h() {
            return k();
        }

        public int hashCode() {
            return androidx.core.util.c.b(Boolean.valueOf(o()), Boolean.valueOf(n()), k(), i(), f());
        }

        androidx.core.graphics.b i() {
            return androidx.core.graphics.b.f1684e;
        }

        androidx.core.graphics.b j() {
            return k();
        }

        androidx.core.graphics.b k() {
            return androidx.core.graphics.b.f1684e;
        }

        androidx.core.graphics.b l() {
            return k();
        }

        j0 m(int i3, int i4, int i5, int i6) {
            return f1931b;
        }

        boolean n() {
            return false;
        }

        boolean o() {
            return false;
        }

        public void p(androidx.core.graphics.b[] bVarArr) {
        }

        void q(androidx.core.graphics.b bVar) {
        }

        void r(j0 j0Var) {
        }

        public void s(androidx.core.graphics.b bVar) {
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static final class m {
        static int a(int i3) {
            if (i3 == 1) {
                return 0;
            }
            if (i3 == 2) {
                return 1;
            }
            if (i3 == 4) {
                return 2;
            }
            if (i3 == 8) {
                return 3;
            }
            if (i3 == 16) {
                return 4;
            }
            if (i3 == 32) {
                return 5;
            }
            if (i3 == 64) {
                return 6;
            }
            if (i3 == 128) {
                return 7;
            }
            if (i3 == 256) {
                return 8;
            }
            throw new IllegalArgumentException("type needs to be >= FIRST and <= LAST, type=" + i3);
        }

        public static int b() {
            return 32;
        }

        public static int c() {
            return 7;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static final class n {
        static int a(int i3) {
            int iStatusBars;
            int i4 = 0;
            for (int i5 = 1; i5 <= 256; i5 <<= 1) {
                if ((i3 & i5) != 0) {
                    if (i5 == 1) {
                        iStatusBars = WindowInsets.Type.statusBars();
                    } else if (i5 == 2) {
                        iStatusBars = WindowInsets.Type.navigationBars();
                    } else if (i5 == 4) {
                        iStatusBars = WindowInsets.Type.captionBar();
                    } else if (i5 == 8) {
                        iStatusBars = WindowInsets.Type.ime();
                    } else if (i5 == 16) {
                        iStatusBars = WindowInsets.Type.systemGestures();
                    } else if (i5 == 32) {
                        iStatusBars = WindowInsets.Type.mandatorySystemGestures();
                    } else if (i5 == 64) {
                        iStatusBars = WindowInsets.Type.tappableElement();
                    } else if (i5 == 128) {
                        iStatusBars = WindowInsets.Type.displayCutout();
                    }
                    i4 |= iStatusBars;
                }
            }
            return i4;
        }
    }

    static {
        if (Build.VERSION.SDK_INT >= 30) {
            f1900b = k.f1930q;
        } else {
            f1900b = l.f1931b;
        }
    }

    private j0(WindowInsets windowInsets) {
        int i3 = Build.VERSION.SDK_INT;
        if (i3 >= 30) {
            this.f1901a = new k(this, windowInsets);
            return;
        }
        if (i3 >= 29) {
            this.f1901a = new j(this, windowInsets);
            return;
        }
        if (i3 >= 28) {
            this.f1901a = new i(this, windowInsets);
            return;
        }
        if (i3 >= 21) {
            this.f1901a = new h(this, windowInsets);
        } else if (i3 >= 20) {
            this.f1901a = new g(this, windowInsets);
        } else {
            this.f1901a = new l(this);
        }
    }

    static androidx.core.graphics.b m(androidx.core.graphics.b bVar, int i3, int i4, int i5, int i6) {
        int iMax = Math.max(0, bVar.f1685a - i3);
        int iMax2 = Math.max(0, bVar.f1686b - i4);
        int iMax3 = Math.max(0, bVar.f1687c - i5);
        int iMax4 = Math.max(0, bVar.f1688d - i6);
        return (iMax == i3 && iMax2 == i4 && iMax3 == i5 && iMax4 == i6) ? bVar : androidx.core.graphics.b.b(iMax, iMax2, iMax3, iMax4);
    }

    public static j0 u(WindowInsets windowInsets) {
        return v(windowInsets, null);
    }

    public static j0 v(WindowInsets windowInsets, View view) {
        j0 j0Var = new j0((WindowInsets) androidx.core.util.h.f(windowInsets));
        if (view != null && y.U(view)) {
            j0Var.r(y.K(view));
            j0Var.d(view.getRootView());
        }
        return j0Var;
    }

    @Deprecated
    public j0 a() {
        return this.f1901a.a();
    }

    @Deprecated
    public j0 b() {
        return this.f1901a.b();
    }

    @Deprecated
    public j0 c() {
        return this.f1901a.c();
    }

    void d(View view) {
        this.f1901a.d(view);
    }

    public androidx.core.view.d e() {
        return this.f1901a.f();
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof j0) {
            return androidx.core.util.c.a(this.f1901a, ((j0) obj).f1901a);
        }
        return false;
    }

    public androidx.core.graphics.b f(int i3) {
        return this.f1901a.g(i3);
    }

    @Deprecated
    public androidx.core.graphics.b g() {
        return this.f1901a.i();
    }

    @Deprecated
    public int h() {
        return this.f1901a.k().f1688d;
    }

    public int hashCode() {
        l lVar = this.f1901a;
        if (lVar == null) {
            return 0;
        }
        return lVar.hashCode();
    }

    @Deprecated
    public int i() {
        return this.f1901a.k().f1685a;
    }

    @Deprecated
    public int j() {
        return this.f1901a.k().f1687c;
    }

    @Deprecated
    public int k() {
        return this.f1901a.k().f1686b;
    }

    public j0 l(int i3, int i4, int i5, int i6) {
        return this.f1901a.m(i3, i4, i5, i6);
    }

    public boolean n() {
        return this.f1901a.n();
    }

    @Deprecated
    public j0 o(int i3, int i4, int i5, int i6) {
        return new b(this).c(androidx.core.graphics.b.b(i3, i4, i5, i6)).a();
    }

    void p(androidx.core.graphics.b[] bVarArr) {
        this.f1901a.p(bVarArr);
    }

    void q(androidx.core.graphics.b bVar) {
        this.f1901a.q(bVar);
    }

    void r(j0 j0Var) {
        this.f1901a.r(j0Var);
    }

    void s(androidx.core.graphics.b bVar) {
        this.f1901a.s(bVar);
    }

    public WindowInsets t() {
        l lVar = this.f1901a;
        if (lVar instanceof g) {
            return ((g) lVar).f1921c;
        }
        return null;
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class c extends f {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private static Field f1907e = null;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private static boolean f1908f = false;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private static Constructor<WindowInsets> f1909g = null;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        private static boolean f1910h = false;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private WindowInsets f1911c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private androidx.core.graphics.b f1912d;

        c() {
            this.f1911c = h();
        }

        private static WindowInsets h() {
            if (!f1908f) {
                try {
                    f1907e = WindowInsets.class.getDeclaredField("CONSUMED");
                } catch (ReflectiveOperationException e3) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets.CONSUMED field", e3);
                }
                f1908f = true;
            }
            Field field = f1907e;
            if (field != null) {
                try {
                    WindowInsets windowInsets = (WindowInsets) field.get(null);
                    if (windowInsets != null) {
                        return new WindowInsets(windowInsets);
                    }
                } catch (ReflectiveOperationException e4) {
                    Log.i("WindowInsetsCompat", "Could not get value from WindowInsets.CONSUMED field", e4);
                }
            }
            if (!f1910h) {
                try {
                    f1909g = WindowInsets.class.getConstructor(Rect.class);
                } catch (ReflectiveOperationException e5) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets(Rect) constructor", e5);
                }
                f1910h = true;
            }
            Constructor<WindowInsets> constructor = f1909g;
            if (constructor != null) {
                try {
                    return constructor.newInstance(new Rect());
                } catch (ReflectiveOperationException e6) {
                    Log.i("WindowInsetsCompat", "Could not invoke WindowInsets(Rect) constructor", e6);
                }
            }
            return null;
        }

        @Override // androidx.core.view.j0.f
        j0 b() {
            a();
            j0 j0VarU = j0.u(this.f1911c);
            j0VarU.p(this.f1915b);
            j0VarU.s(this.f1912d);
            return j0VarU;
        }

        @Override // androidx.core.view.j0.f
        void d(androidx.core.graphics.b bVar) {
            this.f1912d = bVar;
        }

        @Override // androidx.core.view.j0.f
        void f(androidx.core.graphics.b bVar) {
            WindowInsets windowInsets = this.f1911c;
            if (windowInsets != null) {
                this.f1911c = windowInsets.replaceSystemWindowInsets(bVar.f1685a, bVar.f1686b, bVar.f1687c, bVar.f1688d);
            }
        }

        c(j0 j0Var) {
            super(j0Var);
            this.f1911c = j0Var.t();
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class d extends f {

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        final WindowInsets.Builder f1913c;

        d() {
            this.f1913c = new WindowInsets.Builder();
        }

        @Override // androidx.core.view.j0.f
        j0 b() {
            a();
            j0 j0VarU = j0.u(this.f1913c.build());
            j0VarU.p(this.f1915b);
            return j0VarU;
        }

        @Override // androidx.core.view.j0.f
        void c(androidx.core.graphics.b bVar) {
            this.f1913c.setMandatorySystemGestureInsets(bVar.e());
        }

        @Override // androidx.core.view.j0.f
        void d(androidx.core.graphics.b bVar) {
            this.f1913c.setStableInsets(bVar.e());
        }

        @Override // androidx.core.view.j0.f
        void e(androidx.core.graphics.b bVar) {
            this.f1913c.setSystemGestureInsets(bVar.e());
        }

        @Override // androidx.core.view.j0.f
        void f(androidx.core.graphics.b bVar) {
            this.f1913c.setSystemWindowInsets(bVar.e());
        }

        @Override // androidx.core.view.j0.f
        void g(androidx.core.graphics.b bVar) {
            this.f1913c.setTappableElementInsets(bVar.e());
        }

        d(j0 j0Var) {
            WindowInsets.Builder builder;
            super(j0Var);
            WindowInsets windowInsetsT = j0Var.t();
            if (windowInsetsT != null) {
                builder = new WindowInsets.Builder(windowInsetsT);
            } else {
                builder = new WindowInsets.Builder();
            }
            this.f1913c = builder;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class h extends g {

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        private androidx.core.graphics.b f1926m;

        h(j0 j0Var, WindowInsets windowInsets) {
            super(j0Var, windowInsets);
            this.f1926m = null;
        }

        @Override // androidx.core.view.j0.l
        j0 b() {
            return j0.u(this.f1921c.consumeStableInsets());
        }

        @Override // androidx.core.view.j0.l
        j0 c() {
            return j0.u(this.f1921c.consumeSystemWindowInsets());
        }

        @Override // androidx.core.view.j0.l
        final androidx.core.graphics.b i() {
            if (this.f1926m == null) {
                this.f1926m = androidx.core.graphics.b.b(this.f1921c.getStableInsetLeft(), this.f1921c.getStableInsetTop(), this.f1921c.getStableInsetRight(), this.f1921c.getStableInsetBottom());
            }
            return this.f1926m;
        }

        @Override // androidx.core.view.j0.l
        boolean n() {
            return this.f1921c.isConsumed();
        }

        @Override // androidx.core.view.j0.l
        public void s(androidx.core.graphics.b bVar) {
            this.f1926m = bVar;
        }

        h(j0 j0Var, h hVar) {
            super(j0Var, hVar);
            this.f1926m = null;
            this.f1926m = hVar.f1926m;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class g extends l {

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        private static boolean f1916h = false;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        private static Method f1917i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        private static Class<?> f1918j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        private static Field f1919k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        private static Field f1920l;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        final WindowInsets f1921c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private androidx.core.graphics.b[] f1922d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private androidx.core.graphics.b f1923e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private j0 f1924f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        androidx.core.graphics.b f1925g;

        g(j0 j0Var, WindowInsets windowInsets) {
            super(j0Var);
            this.f1923e = null;
            this.f1921c = windowInsets;
        }

        @SuppressLint({"WrongConstant"})
        private androidx.core.graphics.b t(int i3, boolean z2) {
            androidx.core.graphics.b bVarA = androidx.core.graphics.b.f1684e;
            for (int i4 = 1; i4 <= 256; i4 <<= 1) {
                if ((i3 & i4) != 0) {
                    bVarA = androidx.core.graphics.b.a(bVarA, u(i4, z2));
                }
            }
            return bVarA;
        }

        private androidx.core.graphics.b v() {
            j0 j0Var = this.f1924f;
            return j0Var != null ? j0Var.g() : androidx.core.graphics.b.f1684e;
        }

        private androidx.core.graphics.b w(View view) {
            if (Build.VERSION.SDK_INT >= 30) {
                throw new UnsupportedOperationException("getVisibleInsets() should not be called on API >= 30. Use WindowInsets.isVisible() instead.");
            }
            if (!f1916h) {
                x();
            }
            Method method = f1917i;
            if (method != null && f1918j != null && f1919k != null) {
                try {
                    Object objInvoke = method.invoke(view, new Object[0]);
                    if (objInvoke == null) {
                        Log.w("WindowInsetsCompat", "Failed to get visible insets. getViewRootImpl() returned null from the provided view. This means that the view is either not attached or the method has been overridden", new NullPointerException());
                        return null;
                    }
                    Rect rect = (Rect) f1919k.get(f1920l.get(objInvoke));
                    if (rect != null) {
                        return androidx.core.graphics.b.c(rect);
                    }
                    return null;
                } catch (ReflectiveOperationException e3) {
                    Log.e("WindowInsetsCompat", "Failed to get visible insets. (Reflection error). " + e3.getMessage(), e3);
                }
            }
            return null;
        }

        @SuppressLint({"PrivateApi"})
        private static void x() {
            try {
                f1917i = View.class.getDeclaredMethod("getViewRootImpl", new Class[0]);
                Class<?> cls = Class.forName("android.view.View$AttachInfo");
                f1918j = cls;
                f1919k = cls.getDeclaredField("mVisibleInsets");
                f1920l = Class.forName("android.view.ViewRootImpl").getDeclaredField("mAttachInfo");
                f1919k.setAccessible(true);
                f1920l.setAccessible(true);
            } catch (ReflectiveOperationException e3) {
                Log.e("WindowInsetsCompat", "Failed to get visible insets. (Reflection error). " + e3.getMessage(), e3);
            }
            f1916h = true;
        }

        @Override // androidx.core.view.j0.l
        void d(View view) {
            androidx.core.graphics.b bVarW = w(view);
            if (bVarW == null) {
                bVarW = androidx.core.graphics.b.f1684e;
            }
            q(bVarW);
        }

        @Override // androidx.core.view.j0.l
        void e(j0 j0Var) {
            j0Var.r(this.f1924f);
            j0Var.q(this.f1925g);
        }

        @Override // androidx.core.view.j0.l
        public boolean equals(Object obj) {
            if (super.equals(obj)) {
                return Objects.equals(this.f1925g, ((g) obj).f1925g);
            }
            return false;
        }

        @Override // androidx.core.view.j0.l
        public androidx.core.graphics.b g(int i3) {
            return t(i3, false);
        }

        @Override // androidx.core.view.j0.l
        final androidx.core.graphics.b k() {
            if (this.f1923e == null) {
                this.f1923e = androidx.core.graphics.b.b(this.f1921c.getSystemWindowInsetLeft(), this.f1921c.getSystemWindowInsetTop(), this.f1921c.getSystemWindowInsetRight(), this.f1921c.getSystemWindowInsetBottom());
            }
            return this.f1923e;
        }

        @Override // androidx.core.view.j0.l
        j0 m(int i3, int i4, int i5, int i6) {
            b bVar = new b(j0.u(this.f1921c));
            bVar.c(j0.m(k(), i3, i4, i5, i6));
            bVar.b(j0.m(i(), i3, i4, i5, i6));
            return bVar.a();
        }

        @Override // androidx.core.view.j0.l
        boolean o() {
            return this.f1921c.isRound();
        }

        @Override // androidx.core.view.j0.l
        public void p(androidx.core.graphics.b[] bVarArr) {
            this.f1922d = bVarArr;
        }

        @Override // androidx.core.view.j0.l
        void q(androidx.core.graphics.b bVar) {
            this.f1925g = bVar;
        }

        @Override // androidx.core.view.j0.l
        void r(j0 j0Var) {
            this.f1924f = j0Var;
        }

        protected androidx.core.graphics.b u(int i3, boolean z2) {
            androidx.core.graphics.b bVarG;
            int i4;
            if (i3 == 1) {
                return z2 ? androidx.core.graphics.b.b(0, Math.max(v().f1686b, k().f1686b), 0, 0) : androidx.core.graphics.b.b(0, k().f1686b, 0, 0);
            }
            if (i3 == 2) {
                if (z2) {
                    androidx.core.graphics.b bVarV = v();
                    androidx.core.graphics.b bVarI = i();
                    return androidx.core.graphics.b.b(Math.max(bVarV.f1685a, bVarI.f1685a), 0, Math.max(bVarV.f1687c, bVarI.f1687c), Math.max(bVarV.f1688d, bVarI.f1688d));
                }
                androidx.core.graphics.b bVarK = k();
                j0 j0Var = this.f1924f;
                bVarG = j0Var != null ? j0Var.g() : null;
                int iMin = bVarK.f1688d;
                if (bVarG != null) {
                    iMin = Math.min(iMin, bVarG.f1688d);
                }
                return androidx.core.graphics.b.b(bVarK.f1685a, 0, bVarK.f1687c, iMin);
            }
            if (i3 != 8) {
                if (i3 == 16) {
                    return j();
                }
                if (i3 == 32) {
                    return h();
                }
                if (i3 == 64) {
                    return l();
                }
                if (i3 != 128) {
                    return androidx.core.graphics.b.f1684e;
                }
                j0 j0Var2 = this.f1924f;
                androidx.core.view.d dVarE = j0Var2 != null ? j0Var2.e() : f();
                return dVarE != null ? androidx.core.graphics.b.b(dVarE.b(), dVarE.d(), dVarE.c(), dVarE.a()) : androidx.core.graphics.b.f1684e;
            }
            androidx.core.graphics.b[] bVarArr = this.f1922d;
            bVarG = bVarArr != null ? bVarArr[m.a(8)] : null;
            if (bVarG != null) {
                return bVarG;
            }
            androidx.core.graphics.b bVarK2 = k();
            androidx.core.graphics.b bVarV2 = v();
            int i5 = bVarK2.f1688d;
            if (i5 > bVarV2.f1688d) {
                return androidx.core.graphics.b.b(0, 0, 0, i5);
            }
            androidx.core.graphics.b bVar = this.f1925g;
            return (bVar == null || bVar.equals(androidx.core.graphics.b.f1684e) || (i4 = this.f1925g.f1688d) <= bVarV2.f1688d) ? androidx.core.graphics.b.f1684e : androidx.core.graphics.b.b(0, 0, 0, i4);
        }

        g(j0 j0Var, g gVar) {
            this(j0Var, new WindowInsets(gVar.f1921c));
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    private static class j extends i {

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        private androidx.core.graphics.b f1927n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        private androidx.core.graphics.b f1928o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        private androidx.core.graphics.b f1929p;

        j(j0 j0Var, WindowInsets windowInsets) {
            super(j0Var, windowInsets);
            this.f1927n = null;
            this.f1928o = null;
            this.f1929p = null;
        }

        @Override // androidx.core.view.j0.l
        androidx.core.graphics.b h() {
            if (this.f1928o == null) {
                this.f1928o = androidx.core.graphics.b.d(this.f1921c.getMandatorySystemGestureInsets());
            }
            return this.f1928o;
        }

        @Override // androidx.core.view.j0.l
        androidx.core.graphics.b j() {
            if (this.f1927n == null) {
                this.f1927n = androidx.core.graphics.b.d(this.f1921c.getSystemGestureInsets());
            }
            return this.f1927n;
        }

        @Override // androidx.core.view.j0.l
        androidx.core.graphics.b l() {
            if (this.f1929p == null) {
                this.f1929p = androidx.core.graphics.b.d(this.f1921c.getTappableElementInsets());
            }
            return this.f1929p;
        }

        @Override // androidx.core.view.j0.g, androidx.core.view.j0.l
        j0 m(int i3, int i4, int i5, int i6) {
            return j0.u(this.f1921c.inset(i3, i4, i5, i6));
        }

        @Override // androidx.core.view.j0.h, androidx.core.view.j0.l
        public void s(androidx.core.graphics.b bVar) {
        }

        j(j0 j0Var, j jVar) {
            super(j0Var, jVar);
            this.f1927n = null;
            this.f1928o = null;
            this.f1929p = null;
        }
    }

    /* JADX INFO: compiled from: WindowInsetsCompat.java */
    public static final class b {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private final f f1906a;

        public b() {
            int i3 = Build.VERSION.SDK_INT;
            if (i3 >= 30) {
                this.f1906a = new e();
                return;
            }
            if (i3 >= 29) {
                this.f1906a = new d();
            } else if (i3 >= 20) {
                this.f1906a = new c();
            } else {
                this.f1906a = new f();
            }
        }

        public j0 a() {
            return this.f1906a.b();
        }

        @Deprecated
        public b b(androidx.core.graphics.b bVar) {
            this.f1906a.d(bVar);
            return this;
        }

        @Deprecated
        public b c(androidx.core.graphics.b bVar) {
            this.f1906a.f(bVar);
            return this;
        }

        public b(j0 j0Var) {
            int i3 = Build.VERSION.SDK_INT;
            if (i3 >= 30) {
                this.f1906a = new e(j0Var);
                return;
            }
            if (i3 >= 29) {
                this.f1906a = new d(j0Var);
            } else if (i3 >= 20) {
                this.f1906a = new c(j0Var);
            } else {
                this.f1906a = new f(j0Var);
            }
        }
    }

    public j0(j0 j0Var) {
        if (j0Var != null) {
            l lVar = j0Var.f1901a;
            int i3 = Build.VERSION.SDK_INT;
            if (i3 >= 30 && (lVar instanceof k)) {
                this.f1901a = new k(this, (k) lVar);
            } else if (i3 >= 29 && (lVar instanceof j)) {
                this.f1901a = new j(this, (j) lVar);
            } else if (i3 >= 28 && (lVar instanceof i)) {
                this.f1901a = new i(this, (i) lVar);
            } else if (i3 >= 21 && (lVar instanceof h)) {
                this.f1901a = new h(this, (h) lVar);
            } else if (i3 >= 20 && (lVar instanceof g)) {
                this.f1901a = new g(this, (g) lVar);
            } else {
                this.f1901a = new l(this);
            }
            lVar.e(this);
            return;
        }
        this.f1901a = new l(this);
    }
}
