package s0;

import C0.D;
import I2.O;
import android.graphics.Outline;
import android.graphics.Path;
import android.graphics.RectF;
import android.os.Build;
import h1.m;
import java.util.Locale;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.p;
import m3.AbstractC2467b;
import n.a0;
import o0.C2631b;
import o0.C2632c;
import p.C2646H;
import p0.C2693K;
import p0.C2694L;
import p0.C2702h;
import p0.M;
import p0.N;
import r0.AbstractC2865d;
import r0.C2863b;
import r0.InterfaceC2866e;

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public float f24030j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public N f24031k;
    public C2702h l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public C2702h f24032m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public boolean f24033n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public C2863b f24034o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public O f24035p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f24036q;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public boolean f24038s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public long f24039t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public long f24040u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public long f24041v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public boolean f24042w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public RectF f24043x;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public h1.c f24022b = AbstractC2865d.f23806a;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public m f24023c = m.f16628a;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public p f24024d = C2896a.f24018b;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final C2646H f24025e = new C2646H(this, 2);

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f24027g = true;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public long f24028h = 0;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public long f24029i = 9205357640488583168L;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final D f24037r = new D();

    static {
        String lowerCase = Build.FINGERPRINT.toLowerCase(Locale.ROOT);
        o.g(lowerCase, "toLowerCase(...)");
        lowerCase.equals("robolectric");
    }

    public b(d dVar) {
        this.f24021a = dVar;
        dVar.B(false);
        this.f24039t = 0L;
        this.f24040u = 0L;
        this.f24041v = 9205357640488583168L;
    }

    public final void a() {
        Outline outline;
        if (this.f24027g) {
            boolean z6 = this.f24042w;
            d dVar = this.f24021a;
            Outline outline2 = null;
            if (z6 || dVar.J() > 0.0f) {
                C2702h c2702h = this.l;
                if (c2702h != null) {
                    RectF rectF = this.f24043x;
                    if (rectF == null) {
                        rectF = new RectF();
                        this.f24043x = rectF;
                    }
                    Path path = c2702h.f22920a;
                    path.computeBounds(rectF, false);
                    int i6 = Build.VERSION.SDK_INT;
                    if (i6 > 28 || path.isConvex()) {
                        outline = this.f24026f;
                        if (outline == null) {
                            outline = new Outline();
                            this.f24026f = outline;
                        }
                        if (i6 >= 30) {
                            outline.setPath(path);
                        } else {
                            outline.setConvexPath(path);
                        }
                        this.f24033n = !outline.canClip();
                    } else {
                        Outline outline3 = this.f24026f;
                        if (outline3 != null) {
                            outline3.setEmpty();
                        }
                        this.f24033n = true;
                        outline = null;
                    }
                    this.l = c2702h;
                    if (outline != null) {
                        outline.setAlpha(dVar.getAlpha());
                        outline2 = outline;
                    }
                    dVar.g(outline2, (4294967295L & ((long) Math.round(rectF.height()))) | (((long) Math.round(rectF.width())) << 32));
                    if (this.f24033n && this.f24042w) {
                        dVar.B(false);
                        dVar.j();
                    } else {
                        dVar.B(this.f24042w);
                    }
                } else {
                    dVar.B(this.f24042w);
                    Outline outline4 = this.f24026f;
                    if (outline4 == null) {
                        outline4 = new Outline();
                        this.f24026f = outline4;
                    }
                    Outline outline5 = outline4;
                    long jK = W0.e.K(this.f24040u);
                    long j4 = this.f24028h;
                    long j6 = this.f24029i;
                    if (j6 != 9205357640488583168L) {
                        jK = j6;
                    }
                    int i7 = (int) (j4 >> 32);
                    int i8 = (int) (j4 & 4294967295L);
                    int i9 = (int) (jK >> 32);
                    int i10 = (int) (jK & 4294967295L);
                    outline5.setRoundRect(Math.round(Float.intBitsToFloat(i7)), Math.round(Float.intBitsToFloat(i8)), Math.round(Float.intBitsToFloat(i9) + Float.intBitsToFloat(i7)), Math.round(Float.intBitsToFloat(i10) + Float.intBitsToFloat(i8)), this.f24030j);
                    outline5.setAlpha(dVar.getAlpha());
                    dVar.g(outline5, (((long) Math.round(Float.intBitsToFloat(i10))) & 4294967295L) | (((long) Math.round(Float.intBitsToFloat(i9))) << 32));
                }
            } else {
                dVar.B(false);
                dVar.g(null, 0L);
            }
        }
        this.f24027g = false;
    }

    /* JADX WARN: Removed duplicated region for block: B:23:0x005c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void b() {
        if (this.f24038s && this.f24036q == 0) {
            D d6 = this.f24037r;
            b bVar = (b) d6.f519b;
            if (bVar != null) {
                bVar.e();
                d6.f519b = null;
            }
            n.O o6 = (n.O) d6.f521d;
            if (o6 != null) {
                Object[] objArr = o6.f21389b;
                long[] jArr = o6.f21388a;
                int length = jArr.length - 2;
                if (length >= 0) {
                    int i6 = 0;
                    while (true) {
                        long j4 = jArr[i6];
                        if ((((~j4) << 7) & j4 & (-9187201950435737472L)) != -9187201950435737472L) {
                            int i7 = 8 - ((~(i6 - length)) >>> 31);
                            for (int i8 = 0; i8 < i7; i8++) {
                                if ((255 & j4) < 128) {
                                    ((b) objArr[(i6 << 3) + i8]).e();
                                }
                                j4 >>= 8;
                            }
                            if (i7 != 8) {
                                break;
                            } else if (i6 == length) {
                                break;
                            } else {
                                i6++;
                            }
                        }
                    }
                }
                o6.e();
            }
            this.f24021a.j();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x008b  */
    /* JADX WARN: Type inference failed for: r3v4, types: [J4.c, kotlin.jvm.internal.p] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void c(InterfaceC2866e interfaceC2866e) {
        D d6 = this.f24037r;
        d6.f520c = (b) d6.f519b;
        n.O o6 = (n.O) d6.f521d;
        if (o6 != null && o6.c()) {
            n.O o7 = (n.O) d6.f522e;
            if (o7 == null) {
                n.O o8 = a0.f21397a;
                o7 = new n.O();
                d6.f522e = o7;
            }
            o7.k(o6);
            o6.e();
        }
        d6.f518a = true;
        this.f24024d.invoke(interfaceC2866e);
        d6.f518a = false;
        b bVar = (b) d6.f520c;
        if (bVar != null) {
            bVar.e();
        }
        n.O o9 = (n.O) d6.f522e;
        if (o9 == null || !o9.c()) {
            return;
        }
        Object[] objArr = o9.f21389b;
        long[] jArr = o9.f21388a;
        int length = jArr.length - 2;
        if (length >= 0) {
            int i6 = 0;
            while (true) {
                long j4 = jArr[i6];
                if ((((~j4) << 7) & j4 & (-9187201950435737472L)) != -9187201950435737472L) {
                    int i7 = 8 - ((~(i6 - length)) >>> 31);
                    for (int i8 = 0; i8 < i7; i8++) {
                        if ((255 & j4) < 128) {
                            ((b) objArr[(i6 << 3) + i8]).e();
                        }
                        j4 >>= 8;
                    }
                    if (i7 != 8) {
                        break;
                    } else if (i6 == length) {
                        break;
                    } else {
                        i6++;
                    }
                }
            }
        }
        o9.e();
    }

    public final N d() {
        N c2694l;
        N n6 = this.f24031k;
        C2702h c2702h = this.l;
        if (n6 != null) {
            return n6;
        }
        if (c2702h != null) {
            C2693K c2693k = new C2693K(c2702h);
            this.f24031k = c2693k;
            return c2693k;
        }
        long jK = W0.e.K(this.f24040u);
        long j4 = this.f24028h;
        long j6 = this.f24029i;
        if (j6 != 9205357640488583168L) {
            jK = j6;
        }
        float fIntBitsToFloat = Float.intBitsToFloat((int) (j4 >> 32));
        float fIntBitsToFloat2 = Float.intBitsToFloat((int) (j4 & 4294967295L));
        float fIntBitsToFloat3 = Float.intBitsToFloat((int) (jK >> 32)) + fIntBitsToFloat;
        float fIntBitsToFloat4 = Float.intBitsToFloat((int) (jK & 4294967295L)) + fIntBitsToFloat2;
        float f6 = this.f24030j;
        if (f6 > 0.0f) {
            c2694l = new M(AbstractC2467b.a(fIntBitsToFloat, fIntBitsToFloat2, fIntBitsToFloat3, fIntBitsToFloat4, (((long) Float.floatToRawIntBits(f6)) << 32) | (4294967295L & ((long) Float.floatToRawIntBits(f6)))));
        } else {
            c2694l = new C2694L(new C2632c(fIntBitsToFloat, fIntBitsToFloat2, fIntBitsToFloat3, fIntBitsToFloat4));
        }
        this.f24031k = c2694l;
        return c2694l;
    }

    public final void e() {
        this.f24036q--;
        b();
    }

    public final void f(long j4, float f6, long j6) {
        if (C2631b.b(this.f24028h, j4) && o0.e.a(this.f24029i, j6) && this.f24030j == f6 && this.l == null) {
            return;
        }
        this.f24031k = null;
        this.l = null;
        this.f24027g = true;
        this.f24033n = false;
        this.f24028h = j4;
        this.f24029i = j6;
        this.f24030j = f6;
        a();
    }
}
