package v;

import C0.C0116q;
import G.C0232g;
import I0.AbstractC0301k;
import android.content.Context;
import android.os.Build;
import android.widget.EdgeEffect;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt;
import m3.AbstractC2467b;
import m3.AbstractC2478m;
import p0.AbstractC2686D;
import w4.C3137A;
import x.C3161f1;

/* JADX INFO: renamed from: v.u, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C3051u {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final h1.c f24950a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final C3009Y f24952c;

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final boolean f24954e;

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

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

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

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

    public C3051u(Context context, h1.c cVar, long j4, B.J0 j02) {
        this.f24950a = cVar;
        C3009Y c3009y = new C3009Y(context, AbstractC2686D.I(j4));
        this.f24952c = c3009y;
        this.f24953d = SnapshotStateKt.mutableStateOf(C3137A.f25453a, SnapshotStateKt.neverEqualPolicy());
        this.f24954e = true;
        this.f24956g = 0L;
        this.f24957h = -1L;
        C0232g c0232g = new C0232g(this, 7);
        C0116q c0116q = C0.U.f553a;
        C0.b0 b0Var = new C0.b0(null, null, null, c0232g);
        this.f24958i = Build.VERSION.SDK_INT >= 31 ? new C3026h0(b0Var, this, c3009y) : new C3026h0(b0Var, this, c3009y, j02);
    }

    public final void a() {
        boolean z6;
        C3009Y c3009y = this.f24952c;
        EdgeEffect edgeEffect = c3009y.f24817d;
        boolean z7 = true;
        if (edgeEffect != null) {
            edgeEffect.onRelease();
            z6 = !edgeEffect.isFinished();
        } else {
            z6 = false;
        }
        EdgeEffect edgeEffect2 = c3009y.f24818e;
        if (edgeEffect2 != null) {
            edgeEffect2.onRelease();
            z6 = !edgeEffect2.isFinished() || z6;
        }
        EdgeEffect edgeEffect3 = c3009y.f24819f;
        if (edgeEffect3 != null) {
            edgeEffect3.onRelease();
            z6 = !edgeEffect3.isFinished() || z6;
        }
        EdgeEffect edgeEffect4 = c3009y.f24820g;
        if (edgeEffect4 != null) {
            edgeEffect4.onRelease();
            if (edgeEffect4.isFinished() && !z6) {
                z7 = false;
            }
            z6 = z7;
        }
        if (z6) {
            d();
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:50:0x0138, code lost:
    
        if (r4 == r6) goto L51;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x001b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object b(long j4, C3161f1 c3161f1, C4.c cVar) {
        C3047s c3047s;
        long jD;
        if (cVar instanceof C3047s) {
            c3047s = (C3047s) cVar;
            int i6 = c3047s.f24945d;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                c3047s.f24945d = i6 - Integer.MIN_VALUE;
            } else {
                c3047s = new C3047s(this, cVar);
            }
        }
        Object objInvokeSuspend = c3047s.f24943b;
        B4.a aVar = B4.a.f492a;
        int i7 = c3047s.f24945d;
        C3137A c3137a = C3137A.f25453a;
        C3009Y c3009y = this.f24952c;
        if (i7 == 0) {
            AbstractC2467b.l(objInvokeSuspend);
            if (o0.e.e(this.f24956g)) {
                c3047s.f24945d = 1;
                c3161f1.getClass();
                C3161f1 c3161f12 = new C3161f1(c3161f1.f25783d, c3047s);
                c3161f12.f25782c = j4;
                if (c3161f12.invokeSuspend(c3137a) != aVar) {
                    return c3137a;
                }
            } else {
                boolean zG = C3009Y.g(c3009y.f24819f);
                h1.c cVar2 = this.f24950a;
                long jS = W.b.S((!zG || h1.q.b(j4) >= 0.0f) ? (!C3009Y.g(c3009y.f24820g) || h1.q.b(j4) <= 0.0f) ? 0.0f : -AbstractC3058z.e(c3009y.d(), -h1.q.b(j4), Float.intBitsToFloat((int) (this.f24956g >> 32)), cVar2) : AbstractC3058z.e(c3009y.c(), h1.q.b(j4), Float.intBitsToFloat((int) (this.f24956g >> 32)), cVar2), (!C3009Y.g(c3009y.f24817d) || h1.q.c(j4) >= 0.0f) ? (!C3009Y.g(c3009y.f24818e) || h1.q.c(j4) <= 0.0f) ? 0.0f : -AbstractC3058z.e(c3009y.b(), -h1.q.c(j4), Float.intBitsToFloat((int) (this.f24956g & 4294967295L)), cVar2) : AbstractC3058z.e(c3009y.e(), h1.q.c(j4), Float.intBitsToFloat((int) (this.f24956g & 4294967295L)), cVar2));
                if (jS != 0) {
                    d();
                }
                jD = h1.q.d(j4, jS);
                c3047s.f24942a = jD;
                c3047s.f24945d = 2;
                c3161f1.getClass();
                C3161f1 c3161f13 = new C3161f1(c3161f1.f25783d, c3047s);
                c3161f13.f25782c = jD;
                objInvokeSuspend = c3161f13.invokeSuspend(c3137a);
            }
            return aVar;
        }
        if (i7 == 1) {
            AbstractC2467b.l(objInvokeSuspend);
            return c3137a;
        }
        if (i7 != 2) {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        jD = c3047s.f24942a;
        AbstractC2467b.l(objInvokeSuspend);
        long jD2 = h1.q.d(jD, ((h1.q) objInvokeSuspend).f16636a);
        this.f24955f = false;
        if (h1.q.b(jD2) > 0.0f) {
            EdgeEffect edgeEffectC = c3009y.c();
            int iD0 = L4.a.d0(h1.q.b(jD2));
            if (Build.VERSION.SDK_INT >= 31 || edgeEffectC.isFinished()) {
                edgeEffectC.onAbsorb(iD0);
            }
        } else if (h1.q.b(jD2) < 0.0f) {
            EdgeEffect edgeEffectD = c3009y.d();
            int i8 = -L4.a.d0(h1.q.b(jD2));
            if (Build.VERSION.SDK_INT >= 31 || edgeEffectD.isFinished()) {
                edgeEffectD.onAbsorb(i8);
            }
        }
        if (h1.q.c(jD2) > 0.0f) {
            EdgeEffect edgeEffectE = c3009y.e();
            int iD02 = L4.a.d0(h1.q.c(jD2));
            if (Build.VERSION.SDK_INT >= 31 || edgeEffectE.isFinished()) {
                edgeEffectE.onAbsorb(iD02);
            }
        } else if (h1.q.c(jD2) < 0.0f) {
            EdgeEffect edgeEffectB = c3009y.b();
            int i9 = -L4.a.d0(h1.q.c(jD2));
            if (Build.VERSION.SDK_INT >= 31 || edgeEffectB.isFinished()) {
                edgeEffectB.onAbsorb(i9);
            }
        }
        a();
        return c3137a;
    }

    public final long c() {
        long jK = this.f24951b;
        if ((9223372034707292159L & jK) == 9205357640488583168L) {
            jK = AbstractC2478m.k(this.f24956g);
        }
        float fIntBitsToFloat = Float.intBitsToFloat((int) (jK >> 32)) / Float.intBitsToFloat((int) (this.f24956g >> 32));
        return (((long) Float.floatToRawIntBits(Float.intBitsToFloat((int) (jK & 4294967295L)) / Float.intBitsToFloat((int) (this.f24956g & 4294967295L)))) & 4294967295L) | (Float.floatToRawIntBits(fIntBitsToFloat) << 32);
    }

    public final void d() {
        if (this.f24954e) {
            this.f24953d.setValue(C3137A.f25453a);
        }
    }

    public final float e(long j4) {
        float fIntBitsToFloat = Float.intBitsToFloat((int) (c() >> 32));
        int i6 = (int) (j4 & 4294967295L);
        float fIntBitsToFloat2 = Float.intBitsToFloat(i6) / Float.intBitsToFloat((int) (this.f24956g & 4294967295L));
        EdgeEffect edgeEffectB = this.f24952c.b();
        float fC = -fIntBitsToFloat2;
        float f6 = 1 - fIntBitsToFloat;
        int i7 = Build.VERSION.SDK_INT;
        if (i7 >= 31) {
            fC = AbstractC3056x.c(edgeEffectB, fC, f6);
        } else {
            edgeEffectB.onPull(fC, f6);
        }
        return (i7 >= 31 ? AbstractC3056x.b(edgeEffectB) : 0.0f) == 0.0f ? Float.intBitsToFloat((int) (4294967295L & this.f24956g)) * (-fC) : Float.intBitsToFloat(i6);
    }

    public final float f(long j4) {
        float fIntBitsToFloat = Float.intBitsToFloat((int) (c() & 4294967295L));
        int i6 = (int) (j4 >> 32);
        float fIntBitsToFloat2 = Float.intBitsToFloat(i6) / Float.intBitsToFloat((int) (this.f24956g >> 32));
        EdgeEffect edgeEffectC = this.f24952c.c();
        float f6 = 1 - fIntBitsToFloat;
        int i7 = Build.VERSION.SDK_INT;
        if (i7 >= 31) {
            fIntBitsToFloat2 = AbstractC3056x.c(edgeEffectC, fIntBitsToFloat2, f6);
        } else {
            edgeEffectC.onPull(fIntBitsToFloat2, f6);
        }
        return (i7 >= 31 ? AbstractC3056x.b(edgeEffectC) : 0.0f) == 0.0f ? Float.intBitsToFloat((int) (this.f24956g >> 32)) * fIntBitsToFloat2 : Float.intBitsToFloat(i6);
    }

    public final float g(long j4) {
        float fIntBitsToFloat = Float.intBitsToFloat((int) (c() & 4294967295L));
        int i6 = (int) (j4 >> 32);
        float fIntBitsToFloat2 = Float.intBitsToFloat(i6) / Float.intBitsToFloat((int) (this.f24956g >> 32));
        EdgeEffect edgeEffectD = this.f24952c.d();
        float fC = -fIntBitsToFloat2;
        int i7 = Build.VERSION.SDK_INT;
        if (i7 >= 31) {
            fC = AbstractC3056x.c(edgeEffectD, fC, fIntBitsToFloat);
        } else {
            edgeEffectD.onPull(fC, fIntBitsToFloat);
        }
        return (i7 >= 31 ? AbstractC3056x.b(edgeEffectD) : 0.0f) == 0.0f ? Float.intBitsToFloat((int) (this.f24956g >> 32)) * (-fC) : Float.intBitsToFloat(i6);
    }

    public final float h(long j4) {
        float fIntBitsToFloat = Float.intBitsToFloat((int) (c() >> 32));
        int i6 = (int) (j4 & 4294967295L);
        float fIntBitsToFloat2 = Float.intBitsToFloat(i6) / Float.intBitsToFloat((int) (this.f24956g & 4294967295L));
        EdgeEffect edgeEffectE = this.f24952c.e();
        int i7 = Build.VERSION.SDK_INT;
        if (i7 >= 31) {
            fIntBitsToFloat2 = AbstractC3056x.c(edgeEffectE, fIntBitsToFloat2, fIntBitsToFloat);
        } else {
            edgeEffectE.onPull(fIntBitsToFloat2, fIntBitsToFloat);
        }
        return (i7 >= 31 ? AbstractC3056x.b(edgeEffectE) : 0.0f) == 0.0f ? Float.intBitsToFloat((int) (this.f24956g & 4294967295L)) * fIntBitsToFloat2 : Float.intBitsToFloat(i6);
    }

    public final void i(long j4) {
        boolean zA = o0.e.a(this.f24956g, 0L);
        boolean zA2 = o0.e.a(j4, this.f24956g);
        this.f24956g = j4;
        if (!zA2) {
            int iD0 = L4.a.d0(Float.intBitsToFloat((int) (j4 >> 32)));
            long jD0 = (((long) L4.a.d0(Float.intBitsToFloat((int) (j4 & 4294967295L)))) & 4294967295L) | (((long) iD0) << 32);
            C3009Y c3009y = this.f24952c;
            c3009y.f24816c = jD0;
            EdgeEffect edgeEffect = c3009y.f24817d;
            if (edgeEffect != null) {
                edgeEffect.setSize((int) (jD0 >> 32), (int) (jD0 & 4294967295L));
            }
            EdgeEffect edgeEffect2 = c3009y.f24818e;
            if (edgeEffect2 != null) {
                edgeEffect2.setSize((int) (jD0 >> 32), (int) (jD0 & 4294967295L));
            }
            EdgeEffect edgeEffect3 = c3009y.f24819f;
            if (edgeEffect3 != null) {
                edgeEffect3.setSize((int) (jD0 & 4294967295L), (int) (jD0 >> 32));
            }
            EdgeEffect edgeEffect4 = c3009y.f24820g;
            if (edgeEffect4 != null) {
                edgeEffect4.setSize((int) (jD0 & 4294967295L), (int) (jD0 >> 32));
            }
            EdgeEffect edgeEffect5 = c3009y.f24821h;
            if (edgeEffect5 != null) {
                edgeEffect5.setSize((int) (jD0 >> 32), (int) (jD0 & 4294967295L));
            }
            EdgeEffect edgeEffect6 = c3009y.f24822i;
            if (edgeEffect6 != null) {
                edgeEffect6.setSize((int) (jD0 >> 32), (int) (jD0 & 4294967295L));
            }
            EdgeEffect edgeEffect7 = c3009y.f24823j;
            if (edgeEffect7 != null) {
                edgeEffect7.setSize((int) (jD0 & 4294967295L), (int) (jD0 >> 32));
            }
            EdgeEffect edgeEffect8 = c3009y.f24824k;
            if (edgeEffect8 != null) {
                edgeEffect8.setSize((int) (4294967295L & jD0), (int) (jD0 >> 32));
            }
        }
        if (zA || zA2) {
            return;
        }
        a();
    }
}
