package androidx.core.view;

import android.os.Build;
import android.view.View;
import android.view.WindowInsets;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

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

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

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

    static {
        if (Build.VERSION.SDK_INT >= 30) {
            f1746b = a3.f1713q;
        } else {
            f1746b = b3.f1722b;
        }
    }

    public f3(WindowInsets windowInsets) {
        int i10 = Build.VERSION.SDK_INT;
        if (i10 >= 30) {
            this.f1747a = new a3(this, windowInsets);
            return;
        }
        if (i10 >= 29) {
            this.f1747a = new z2(this, windowInsets);
        } else if (i10 >= 28) {
            this.f1747a = new y2(this, windowInsets);
        } else {
            this.f1747a = new x2(this, windowInsets);
        }
    }

    public static j0.d e(j0.d dVar, int i10, int i11, int i12, int i13) {
        int iMax = Math.max(0, dVar.f28502a - i10);
        int iMax2 = Math.max(0, dVar.f28503b - i11);
        int iMax3 = Math.max(0, dVar.f28504c - i12);
        int iMax4 = Math.max(0, dVar.f28505d - i13);
        return (iMax == i10 && iMax2 == i11 && iMax3 == i12 && iMax4 == i13) ? dVar : j0.d.b(iMax, iMax2, iMax3, iMax4);
    }

    @NonNull
    @RequiresApi(20)
    public static f3 toWindowInsetsCompat(@NonNull WindowInsets windowInsets, @Nullable View view) {
        f3 f3Var = new f3((WindowInsets) p0.g.checkNotNull(windowInsets));
        if (view != null && view.isAttachedToWindow()) {
            f3Var.setRootWindowInsets(s1.getRootWindowInsets(view));
            f3Var.f1747a.d(view.getRootView());
        }
        return f3Var;
    }

    public final int a() {
        return this.f1747a.j().f28505d;
    }

    public final int b() {
        return this.f1747a.j().f28502a;
    }

    public final int c() {
        return this.f1747a.j().f28504c;
    }

    public final int d() {
        return this.f1747a.j().f28503b;
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof f3) {
            return p0.c.equals(this.f1747a, ((f3) obj).f1747a);
        }
        return false;
    }

    @Nullable
    public r getDisplayCutout() {
        return this.f1747a.getDisplayCutout();
    }

    public final int hashCode() {
        b3 b3Var = this.f1747a;
        if (b3Var == null) {
            return 0;
        }
        return b3Var.hashCode();
    }

    public void setRootWindowInsets(@Nullable f3 f3Var) {
        this.f1747a.setRootWindowInsets(f3Var);
    }

    public void setStableInsets(@Nullable j0.d dVar) {
        this.f1747a.setStableInsets(dVar);
    }

    @Nullable
    @RequiresApi(20)
    public WindowInsets toWindowInsets() {
        b3 b3Var = this.f1747a;
        if (b3Var instanceof w2) {
            return ((w2) b3Var).f1848c;
        }
        return null;
    }

    public f3(@Nullable f3 f3Var) {
        if (f3Var != null) {
            b3 b3Var = f3Var.f1747a;
            int i10 = Build.VERSION.SDK_INT;
            if (i10 >= 30 && (b3Var instanceof a3)) {
                this.f1747a = new a3(this, (a3) b3Var);
            } else if (i10 >= 29 && (b3Var instanceof z2)) {
                this.f1747a = new z2(this, (z2) b3Var);
            } else if (i10 >= 28 && (b3Var instanceof y2)) {
                this.f1747a = new y2(this, (y2) b3Var);
            } else if (b3Var instanceof x2) {
                this.f1747a = new x2(this, (x2) b3Var);
            } else if (b3Var instanceof w2) {
                this.f1747a = new w2(this, (w2) b3Var);
            } else {
                this.f1747a = new b3(this);
            }
            b3Var.e(this);
            return;
        }
        this.f1747a = new b3(this);
    }
}
