package E;

import B.V;
import B.h1;
import D.C0130a;
import F.AbstractC0158l;
import F.C0150d;
import F.C0156j;
import F.C0167v;
import F.N;
import F.P;
import F.Q;
import F.U;
import I0.H;
import androidx.compose.runtime.MutableState;
import androidx.compose.runtime.SnapshotStateKt;
import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt;
import androidx.compose.runtime.collection.MutableVector;
import androidx.compose.runtime.saveable.ListSaverKt;
import androidx.compose.runtime.saveable.Saver;
import java.util.List;
import m3.AbstractC2467b;
import v.z0;
import w4.C3137A;
import x.C3189q;
import x.EnumC3207z0;
import x.InterfaceC3146a1;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public final class D implements InterfaceC3146a1 {

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public static final Saver f963w = ListSaverKt.listSaver(new A4.b(7), new h1(6));

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public r f966c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final D.B f967d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final z.m f969f;

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final C3189q f971h;

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final D.E f974k;
    public final C0150d l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final C0167v f975m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final C0156j f976n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final Q f977o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final A f978p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final N f979q;

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

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

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

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

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final U f984v;

    public D(int i6, int i7) {
        C0130a c0130a = new C0130a();
        c0130a.f790a = -1;
        c0130a.f794e = new MutableVector(new P[16], 0);
        c0130a.f792c = -1;
        this.f964a = c0130a;
        this.f967d = new D.B(i6, i7, 1);
        this.f968e = SnapshotStateKt.mutableStateOf(F.f985a, SnapshotStateKt.neverEqualPolicy());
        this.f969f = new z.m();
        this.f971h = new C3189q(new V(this, 6));
        this.f972i = true;
        this.f974k = new D.E(this, 1);
        this.l = new C0150d();
        this.f975m = new C0167v();
        this.f976n = new C0156j();
        this.f977o = new Q(new D.C(this, i6, 1));
        this.f978p = new A(this);
        this.f979q = new N();
        this.f980r = AbstractC0158l.k();
        this.f981s = AbstractC0158l.k();
        Boolean bool = Boolean.FALSE;
        this.f982t = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(bool, null, 2, null);
        this.f983u = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(bool, null, 2, null);
        this.f984v = new U();
    }

    public static Object i(D d6, int i6, C4.j jVar) {
        d6.getClass();
        Object objE = d6.e(z0.f24987a, new C(d6, i6, null), jVar);
        return objE == B4.a.f492a ? objE : C3137A.f25453a;
    }

    @Override // x.InterfaceC3146a1
    public final boolean a() {
        return this.f971h.a();
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // x.InterfaceC3146a1
    public final boolean b() {
        return ((Boolean) this.f983u.getValue()).booleanValue();
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // x.InterfaceC3146a1
    public final boolean c() {
        return ((Boolean) this.f982t.getValue()).booleanValue();
    }

    @Override // x.InterfaceC3146a1
    public final float d(float f6) {
        return this.f971h.d(f6);
    }

    /* JADX WARN: Code restructure failed: missing block: B:22:0x0063, code lost:
    
        if (r5.f971h.e(r6, r7, r0) == r1) goto L23;
     */
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    @Override // x.InterfaceC3146a1
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object e(z0 z0Var, J4.e eVar, A4.d dVar) {
        B b5;
        if (dVar instanceof B) {
            b5 = (B) dVar;
            int i6 = b5.f960e;
            if ((i6 & Integer.MIN_VALUE) != 0) {
                b5.f960e = i6 - Integer.MIN_VALUE;
            } else {
                b5 = new B(this, dVar);
            }
        }
        Object obj = b5.f958c;
        B4.a aVar = B4.a.f492a;
        int i7 = b5.f960e;
        if (i7 == 0) {
            AbstractC2467b.l(obj);
            if (this.f968e.getValue() == F.f985a) {
                b5.f956a = z0Var;
                b5.f957b = eVar;
                b5.f960e = 1;
                if (this.l.d(b5) != aVar) {
                }
                return aVar;
            }
        } else {
            if (i7 != 1) {
                if (i7 != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                AbstractC2467b.l(obj);
                return C3137A.f25453a;
            }
            eVar = b5.f957b;
            z0Var = b5.f956a;
            AbstractC2467b.l(obj);
        }
        b5.f956a = null;
        b5.f957b = null;
        b5.f960e = 2;
    }

    /* JADX WARN: Removed duplicated region for block: B:36:0x0079  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00b1  */
    /* JADX WARN: Type inference failed for: r0v0, types: [java.lang.Object, java.util.Collection, java.util.List] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void f(r rVar, boolean z6, boolean z7) {
        ?? r02 = rVar.f1065m;
        this.f977o.f1223e = r02.size();
        if (!z6 && this.f965b) {
            this.f966c = rVar;
            return;
        }
        if (z6) {
            this.f965b = true;
        }
        this.f970g -= rVar.f1057d;
        this.f968e.setValue(rVar);
        t tVar = rVar.f1054a;
        int i6 = tVar != null ? tVar.f1089a : 0;
        int i7 = rVar.f1055b;
        this.f983u.setValue(Boolean.valueOf((i6 == 0 && i7 == 0) ? false : true));
        this.f982t.setValue(Boolean.valueOf(rVar.f1056c));
        D.B b5 = this.f967d;
        if (z7) {
            b5.getClass();
            if (i7 < 0.0f) {
                A.b.c("scrollOffset should be non-negative");
            }
            b5.f748c.setIntValue(i7);
        } else {
            b5.getClass();
            if (tVar != null) {
                s[] sVarArr = tVar.f1090b;
                s sVar = sVarArr.length == 0 ? null : sVarArr[0];
                Object obj = sVar != null ? sVar.f1073b : null;
                b5.f750e = obj;
                boolean z8 = b5.f749d;
                int i8 = rVar.f1068p;
                if (z8 || i8 > 0) {
                    b5.f749d = true;
                    if (i7 < 0.0f) {
                        A.b.c("scrollOffset should be non-negative (" + i7 + ')');
                    }
                    if (tVar != null) {
                        s[] sVarArr2 = tVar.f1090b;
                        s sVar2 = sVarArr2.length != 0 ? sVarArr2[0] : null;
                        int i9 = sVar2 != null ? sVar2.f1072a : 0;
                        b5.a(i9, i7);
                    }
                }
                if (this.f972i) {
                    C0130a c0130a = this.f964a;
                    int i10 = c0130a.f790a;
                    boolean z9 = c0130a.f791b;
                    MutableVector mutableVector = (MutableVector) c0130a.f794e;
                    if (i10 != -1 && !r02.isEmpty() && i10 != C0130a.c(rVar, z9)) {
                        c0130a.f790a = -1;
                        Object[] objArr = mutableVector.content;
                        int size = mutableVector.getSize();
                        for (int i11 = 0; i11 < size; i11++) {
                            ((P) objArr[i11]).cancel();
                        }
                        mutableVector.clear();
                    }
                    int i12 = c0130a.f792c;
                    if (i12 != -1 && c0130a.f793d != 0.0f && i12 != i8 && !r02.isEmpty()) {
                        int iC = C0130a.c(rVar, c0130a.f793d < 0.0f);
                        int iA = C0130a.a(rVar, c0130a.f793d < 0.0f);
                        if (iA >= 0 && iA < i8 && iC != c0130a.f790a && iC >= 0) {
                            c0130a.f790a = iC;
                            mutableVector.clear();
                            mutableVector.addAll(mutableVector.getSize(), (List) this.f978p.a(iC));
                        }
                    }
                    c0130a.f792c = i8;
                }
            }
        }
        if (z6) {
            this.f984v.a(rVar.f1059f, rVar.f1062i, rVar.f1061h);
        }
    }

    public final r g() {
        return (r) this.f968e.getValue();
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [java.lang.Object, java.util.Collection] */
    /* JADX WARN: Type inference failed for: r4v2, types: [java.lang.Object, java.util.List] */
    public final void h(float f6, r rVar) {
        if (this.f972i) {
            C0130a c0130a = this.f964a;
            c0130a.getClass();
            if (!rVar.f1065m.isEmpty()) {
                int i6 = 0;
                boolean z6 = f6 < 0.0f;
                int iC = C0130a.c(rVar, z6);
                int iA = C0130a.a(rVar, z6);
                if (iA >= 0 && iA < rVar.f1068p) {
                    int i7 = c0130a.f790a;
                    MutableVector mutableVector = (MutableVector) c0130a.f794e;
                    if (iC != i7 && iC >= 0) {
                        if (c0130a.f791b != z6) {
                            Object[] objArr = mutableVector.content;
                            int size = mutableVector.getSize();
                            for (int i8 = 0; i8 < size; i8++) {
                                ((P) objArr[i8]).cancel();
                            }
                        }
                        c0130a.f791b = z6;
                        c0130a.f790a = iC;
                        mutableVector.clear();
                        mutableVector.addAll(mutableVector.getSize(), (List) this.f978p.a(iC));
                    }
                    EnumC3207z0 enumC3207z0 = rVar.f1069q;
                    ?? r42 = rVar.f1065m;
                    if (z6) {
                        s sVar = (s) AbstractC3251q.n0(r42);
                        if (((AbstractC2467b.g(sVar, enumC3207z0) + ((int) (enumC3207z0 == EnumC3207z0.f25984a ? sVar.f1084n & 4294967295L : sVar.f1084n >> 32))) + rVar.f1071s) - rVar.f1067o < (-f6)) {
                            Object[] objArr2 = mutableVector.content;
                            int size2 = mutableVector.getSize();
                            while (i6 < size2) {
                                ((P) objArr2[i6]).a();
                                i6++;
                            }
                        }
                    } else if (rVar.f1066n - AbstractC2467b.g((s) AbstractC3251q.e0(r42), enumC3207z0) < f6) {
                        Object[] objArr3 = mutableVector.content;
                        int size3 = mutableVector.getSize();
                        while (i6 < size3) {
                            ((P) objArr3[i6]).a();
                            i6++;
                        }
                    }
                }
            }
            c0130a.f793d = f6;
        }
    }
}
