package c.e.i;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.DisplayCutout;
import android.view.View;
import android.view.WindowInsets;
import c.e.i.l;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Objects;
import java.util.WeakHashMap;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final u f5295a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final j f5296b;

    public static class a extends d {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public static Field f5297b = null;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public static boolean f5298c = false;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public static Constructor<WindowInsets> f5299d = null;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public static boolean f5300e = false;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public WindowInsets f5301f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public c.e.d.b f5302g;

        public a() {
            this.f5301f = e();
        }

        public a(u uVar) {
            super(uVar);
            this.f5301f = uVar.f();
        }

        public static WindowInsets e() {
            if (!f5298c) {
                try {
                    f5297b = WindowInsets.class.getDeclaredField("CONSUMED");
                } catch (ReflectiveOperationException e2) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets.CONSUMED field", e2);
                }
                f5298c = true;
            }
            Field field = f5297b;
            if (field != null) {
                try {
                    WindowInsets windowInsets = (WindowInsets) field.get(null);
                    if (windowInsets != null) {
                        return new WindowInsets(windowInsets);
                    }
                } catch (ReflectiveOperationException e3) {
                    Log.i("WindowInsetsCompat", "Could not get value from WindowInsets.CONSUMED field", e3);
                }
            }
            if (!f5300e) {
                try {
                    f5299d = WindowInsets.class.getConstructor(Rect.class);
                } catch (ReflectiveOperationException e4) {
                    Log.i("WindowInsetsCompat", "Could not retrieve WindowInsets(Rect) constructor", e4);
                }
                f5300e = true;
            }
            Constructor<WindowInsets> constructor = f5299d;
            if (constructor != null) {
                try {
                    return constructor.newInstance(new Rect());
                } catch (ReflectiveOperationException e5) {
                    Log.i("WindowInsetsCompat", "Could not invoke WindowInsets(Rect) constructor", e5);
                }
            }
            return null;
        }

        @Override // c.e.i.u.d
        public u b() {
            a();
            u uVarG = u.g(this.f5301f);
            uVarG.f5296b.k(null);
            uVarG.f5296b.m(this.f5302g);
            return uVarG;
        }

        @Override // c.e.i.u.d
        public void c(c.e.d.b bVar) {
            this.f5302g = bVar;
        }

        @Override // c.e.i.u.d
        public void d(c.e.d.b bVar) {
            WindowInsets windowInsets = this.f5301f;
            if (windowInsets != null) {
                this.f5301f = windowInsets.replaceSystemWindowInsets(bVar.f5187b, bVar.f5188c, bVar.f5189d, bVar.f5190e);
            }
        }
    }

    public static class b extends d {

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

        public b() {
            this.f5303b = new WindowInsets.Builder();
        }

        public b(u uVar) {
            super(uVar);
            WindowInsets windowInsetsF = uVar.f();
            this.f5303b = windowInsetsF != null ? new WindowInsets.Builder(windowInsetsF) : new WindowInsets.Builder();
        }

        @Override // c.e.i.u.d
        public u b() {
            a();
            u uVarG = u.g(this.f5303b.build());
            uVarG.f5296b.k(null);
            return uVarG;
        }

        @Override // c.e.i.u.d
        public void c(c.e.d.b bVar) {
            this.f5303b.setStableInsets(bVar.b());
        }

        @Override // c.e.i.u.d
        public void d(c.e.d.b bVar) {
            this.f5303b.setSystemWindowInsets(bVar.b());
        }
    }

    public static class c extends b {
        public c() {
        }

        public c(u uVar) {
            super(uVar);
        }
    }

    public static class d {

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

        public d() {
            this(new u((u) null));
        }

        public d(u uVar) {
            this.f5304a = uVar;
        }

        public final void a() {
        }

        public u b() {
            throw null;
        }

        public void c(c.e.d.b bVar) {
            throw null;
        }

        public void d(c.e.d.b bVar) {
            throw null;
        }
    }

    public static class e extends j {

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public static boolean f5305c = false;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public static Method f5306d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public static Class<?> f5307e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public static Class<?> f5308f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public static Field f5309g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public static Field f5310h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public final WindowInsets f5311i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public c.e.d.b[] f5312j;
        public c.e.d.b k;
        public u l;
        public c.e.d.b m;

        public e(u uVar, WindowInsets windowInsets) {
            super(uVar);
            this.k = null;
            this.f5311i = windowInsets;
        }

        @SuppressLint({"PrivateApi"})
        public static void o() {
            try {
                f5306d = View.class.getDeclaredMethod("getViewRootImpl", new Class[0]);
                f5307e = Class.forName("android.view.ViewRootImpl");
                Class<?> cls = Class.forName("android.view.View$AttachInfo");
                f5308f = cls;
                f5309g = cls.getDeclaredField("mVisibleInsets");
                f5310h = f5307e.getDeclaredField("mAttachInfo");
                f5309g.setAccessible(true);
                f5310h.setAccessible(true);
            } catch (ReflectiveOperationException e2) {
                StringBuilder sbC = a.b.c.a.a.C("Failed to get visible insets. (Reflection error). ");
                sbC.append(e2.getMessage());
                Log.e("WindowInsetsCompat", sbC.toString(), e2);
            }
            f5305c = true;
        }

        @Override // c.e.i.u.j
        public void d(View view) {
            c.e.d.b bVarN = n(view);
            if (bVarN == null) {
                bVarN = c.e.d.b.f5186a;
            }
            p(bVarN);
        }

        @Override // c.e.i.u.j
        public boolean equals(Object obj) {
            if (super.equals(obj)) {
                return Objects.equals(this.m, ((e) obj).m);
            }
            return false;
        }

        @Override // c.e.i.u.j
        public final c.e.d.b g() {
            if (this.k == null) {
                this.k = c.e.d.b.a(this.f5311i.getSystemWindowInsetLeft(), this.f5311i.getSystemWindowInsetTop(), this.f5311i.getSystemWindowInsetRight(), this.f5311i.getSystemWindowInsetBottom());
            }
            return this.k;
        }

        @Override // c.e.i.u.j
        public u h(int i2, int i3, int i4, int i5) {
            u uVarG = u.g(this.f5311i);
            int i6 = Build.VERSION.SDK_INT;
            d cVar = i6 >= 30 ? new c(uVarG) : i6 >= 29 ? new b(uVarG) : new a(uVarG);
            cVar.d(u.e(g(), i2, i3, i4, i5));
            cVar.c(u.e(f(), i2, i3, i4, i5));
            return cVar.b();
        }

        @Override // c.e.i.u.j
        public boolean j() {
            return this.f5311i.isRound();
        }

        @Override // c.e.i.u.j
        public void k(c.e.d.b[] bVarArr) {
            this.f5312j = bVarArr;
        }

        @Override // c.e.i.u.j
        public void l(u uVar) {
            this.l = uVar;
        }

        public final c.e.d.b n(View view) {
            if (Build.VERSION.SDK_INT >= 30) {
                throw new UnsupportedOperationException("getVisibleInsets() should not be called on API >= 30. Use WindowInsets.isVisible() instead.");
            }
            if (!f5305c) {
                o();
            }
            Method method = f5306d;
            if (method != null && f5308f != null && f5309g != 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) f5309g.get(f5310h.get(objInvoke));
                    if (rect != null) {
                        return c.e.d.b.a(rect.left, rect.top, rect.right, rect.bottom);
                    }
                    return null;
                } catch (ReflectiveOperationException e2) {
                    StringBuilder sbC = a.b.c.a.a.C("Failed to get visible insets. (Reflection error). ");
                    sbC.append(e2.getMessage());
                    Log.e("WindowInsetsCompat", sbC.toString(), e2);
                }
            }
            return null;
        }

        public void p(c.e.d.b bVar) {
            this.m = bVar;
        }
    }

    public static class f extends e {
        public c.e.d.b n;

        public f(u uVar, WindowInsets windowInsets) {
            super(uVar, windowInsets);
            this.n = null;
        }

        @Override // c.e.i.u.j
        public u b() {
            return u.g(this.f5311i.consumeStableInsets());
        }

        @Override // c.e.i.u.j
        public u c() {
            return u.g(this.f5311i.consumeSystemWindowInsets());
        }

        @Override // c.e.i.u.j
        public final c.e.d.b f() {
            if (this.n == null) {
                this.n = c.e.d.b.a(this.f5311i.getStableInsetLeft(), this.f5311i.getStableInsetTop(), this.f5311i.getStableInsetRight(), this.f5311i.getStableInsetBottom());
            }
            return this.n;
        }

        @Override // c.e.i.u.j
        public boolean i() {
            return this.f5311i.isConsumed();
        }

        @Override // c.e.i.u.j
        public void m(c.e.d.b bVar) {
            this.n = bVar;
        }
    }

    public static class g extends f {
        public g(u uVar, WindowInsets windowInsets) {
            super(uVar, windowInsets);
        }

        @Override // c.e.i.u.j
        public u a() {
            return u.g(this.f5311i.consumeDisplayCutout());
        }

        @Override // c.e.i.u.j
        public c.e.i.d e() {
            DisplayCutout displayCutout = this.f5311i.getDisplayCutout();
            if (displayCutout == null) {
                return null;
            }
            return new c.e.i.d(displayCutout);
        }

        @Override // c.e.i.u.e, c.e.i.u.j
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof g)) {
                return false;
            }
            g gVar = (g) obj;
            return Objects.equals(this.f5311i, gVar.f5311i) && Objects.equals(this.m, gVar.m);
        }

        @Override // c.e.i.u.j
        public int hashCode() {
            return this.f5311i.hashCode();
        }
    }

    public static class h extends g {
        public c.e.d.b o;
        public c.e.d.b p;
        public c.e.d.b q;

        public h(u uVar, WindowInsets windowInsets) {
            super(uVar, windowInsets);
            this.o = null;
            this.p = null;
            this.q = null;
        }

        @Override // c.e.i.u.e, c.e.i.u.j
        public u h(int i2, int i3, int i4, int i5) {
            return u.g(this.f5311i.inset(i2, i3, i4, i5));
        }

        @Override // c.e.i.u.f, c.e.i.u.j
        public void m(c.e.d.b bVar) {
        }
    }

    public static class i extends h {
        public static final u r = u.g(WindowInsets.CONSUMED);

        public i(u uVar, WindowInsets windowInsets) {
            super(uVar, windowInsets);
        }

        @Override // c.e.i.u.e, c.e.i.u.j
        public final void d(View view) {
        }
    }

    public static class j {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public static final u f5313a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final u f5314b;

        static {
            int i2 = Build.VERSION.SDK_INT;
            f5313a = (i2 >= 30 ? new c() : i2 >= 29 ? new b() : new a()).b().f5296b.a().f5296b.b().f5296b.c();
        }

        public j(u uVar) {
            this.f5314b = uVar;
        }

        public u a() {
            return this.f5314b;
        }

        public u b() {
            return this.f5314b;
        }

        public u c() {
            return this.f5314b;
        }

        public void d(View view) {
        }

        public c.e.i.d e() {
            return null;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof j)) {
                return false;
            }
            j jVar = (j) obj;
            return j() == jVar.j() && i() == jVar.i() && Objects.equals(g(), jVar.g()) && Objects.equals(f(), jVar.f()) && Objects.equals(e(), jVar.e());
        }

        public c.e.d.b f() {
            return c.e.d.b.f5186a;
        }

        public c.e.d.b g() {
            return c.e.d.b.f5186a;
        }

        public u h(int i2, int i3, int i4, int i5) {
            return f5313a;
        }

        public int hashCode() {
            return Objects.hash(Boolean.valueOf(j()), Boolean.valueOf(i()), g(), f(), e());
        }

        public boolean i() {
            return false;
        }

        public boolean j() {
            return false;
        }

        public void k(c.e.d.b[] bVarArr) {
        }

        public void l(u uVar) {
        }

        public void m(c.e.d.b bVar) {
        }
    }

    static {
        f5295a = Build.VERSION.SDK_INT >= 30 ? i.r : j.f5313a;
    }

    public u(WindowInsets windowInsets) {
        int i2 = Build.VERSION.SDK_INT;
        this.f5296b = i2 >= 30 ? new i(this, windowInsets) : i2 >= 29 ? new h(this, windowInsets) : i2 >= 28 ? new g(this, windowInsets) : new f(this, windowInsets);
    }

    public u(u uVar) {
        this.f5296b = new j(this);
    }

    public static c.e.d.b e(c.e.d.b bVar, int i2, int i3, int i4, int i5) {
        int iMax = Math.max(0, bVar.f5187b - i2);
        int iMax2 = Math.max(0, bVar.f5188c - i3);
        int iMax3 = Math.max(0, bVar.f5189d - i4);
        int iMax4 = Math.max(0, bVar.f5190e - i5);
        return (iMax == i2 && iMax2 == i3 && iMax3 == i4 && iMax4 == i5) ? bVar : c.e.d.b.a(iMax, iMax2, iMax3, iMax4);
    }

    public static u g(WindowInsets windowInsets) {
        return h(windowInsets, null);
    }

    public static u h(WindowInsets windowInsets, View view) {
        Objects.requireNonNull(windowInsets);
        u uVar = new u(windowInsets);
        if (view != null && view.isAttachedToWindow()) {
            WeakHashMap<View, q> weakHashMap = l.f5278a;
            uVar.f5296b.l(l.d.a(view));
            uVar.f5296b.d(view.getRootView());
        }
        return uVar;
    }

    @Deprecated
    public int a() {
        return this.f5296b.g().f5190e;
    }

    @Deprecated
    public int b() {
        return this.f5296b.g().f5187b;
    }

    @Deprecated
    public int c() {
        return this.f5296b.g().f5189d;
    }

    @Deprecated
    public int d() {
        return this.f5296b.g().f5188c;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof u) {
            return Objects.equals(this.f5296b, ((u) obj).f5296b);
        }
        return false;
    }

    public WindowInsets f() {
        j jVar = this.f5296b;
        if (jVar instanceof e) {
            return ((e) jVar).f5311i;
        }
        return null;
    }

    public int hashCode() {
        j jVar = this.f5296b;
        if (jVar == null) {
            return 0;
        }
        return jVar.hashCode();
    }
}
