package androidx.compose.foundation.lazy.layout;

import androidx.collection.g0;
import androidx.collection.h0;
import androidx.collection.q0;
import androidx.collection.s0;
import c3.n;
import c3.o;
import c3.s;
import g0.p;
import g0.y;
import g0.z;
import j2.r;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import kotlin.Metadata;
import kotlin.jvm.internal.t;
import l1.i;
import rm.n0;
import sm.b0;
import sm.c0;
import tp.m0;

/* loaded from: classes.dex */
public final class LazyLayoutItemAnimator {

    /* renamed from: b, reason: collision with root package name */
    private androidx.compose.foundation.lazy.layout.c f1888b;

    /* renamed from: c, reason: collision with root package name */
    private int f1889c;

    /* renamed from: j, reason: collision with root package name */
    private r f1896j;

    /* renamed from: a, reason: collision with root package name */
    private final g0 f1887a = q0.d();

    /* renamed from: d, reason: collision with root package name */
    private final h0 f1890d = s0.a();

    /* renamed from: e, reason: collision with root package name */
    private final List f1891e = new ArrayList();

    /* renamed from: f, reason: collision with root package name */
    private final List f1892f = new ArrayList();

    /* renamed from: g, reason: collision with root package name */
    private final List f1893g = new ArrayList();

    /* renamed from: h, reason: collision with root package name */
    private final List f1894h = new ArrayList();

    /* renamed from: i, reason: collision with root package name */
    private final List f1895i = new ArrayList();

    /* renamed from: k, reason: collision with root package name */
    private final l1.i f1897k = new DisplayingDisappearingItemsElement(this);

    @Metadata(d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0082\b\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0013\u0012\n\u0010\u0012\u001a\u0006\u0012\u0002\b\u00030\u000f¢\u0006\u0004\b\u0013\u0010\u0014J\b\u0010\u0003\u001a\u00020\u0002H\u0016J\u0010\u0010\u0006\u001a\u00020\u00052\u0006\u0010\u0004\u001a\u00020\u0002H\u0016J\t\u0010\b\u001a\u00020\u0007HÖ\u0001J\t\u0010\n\u001a\u00020\tHÖ\u0001J\u0013\u0010\u000e\u001a\u00020\r2\b\u0010\f\u001a\u0004\u0018\u00010\u000bHÖ\u0003R\u0018\u0010\u0012\u001a\u0006\u0012\u0002\b\u00030\u000f8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0010\u0010\u0011¨\u0006\u0015"}, d2 = {"Landroidx/compose/foundation/lazy/layout/LazyLayoutItemAnimator$DisplayingDisappearingItemsElement;", "Lj2/s0;", "Landroidx/compose/foundation/lazy/layout/LazyLayoutItemAnimator$a;", "k", "node", "Lrm/n0;", "l", "", "toString", "", "hashCode", "", "other", "", "equals", "Landroidx/compose/foundation/lazy/layout/LazyLayoutItemAnimator;", "b", "Landroidx/compose/foundation/lazy/layout/LazyLayoutItemAnimator;", "animator", "<init>", "(Landroidx/compose/foundation/lazy/layout/LazyLayoutItemAnimator;)V", "foundation_release"}, k = 1, mv = {1, 8, 0})
    /* loaded from: classes.dex */
    private static final /* data */ class DisplayingDisappearingItemsElement extends j2.s0 {

        /* renamed from: b, reason: collision with root package name and from kotlin metadata and from toString */
        private final LazyLayoutItemAnimator animator;

        public DisplayingDisappearingItemsElement(LazyLayoutItemAnimator lazyLayoutItemAnimator) {
            this.animator = lazyLayoutItemAnimator;
        }

        public boolean equals(Object other) {
            if (this == other) {
                return true;
            }
            return (other instanceof DisplayingDisappearingItemsElement) && t.b(this.animator, ((DisplayingDisappearingItemsElement) other).animator);
        }

        public int hashCode() {
            return this.animator.hashCode();
        }

        @Override // j2.s0
        /* renamed from: k, reason: merged with bridge method [inline-methods] */
        public a getNode() {
            return new a(this.animator);
        }

        @Override // j2.s0
        /* renamed from: l, reason: merged with bridge method [inline-methods] */
        public void j(a aVar) {
            aVar.h2(this.animator);
        }

        public String toString() {
            return "DisplayingDisappearingItemsElement(animator=" + this.animator + ')';
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static final class a extends i.c implements r {
        private LazyLayoutItemAnimator C;

        public a(LazyLayoutItemAnimator lazyLayoutItemAnimator) {
            this.C = lazyLayoutItemAnimator;
        }

        @Override // l1.i.c
        public void R1() {
            this.C.f1896j = this;
        }

        @Override // l1.i.c
        public void S1() {
            this.C.n();
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            return (obj instanceof a) && t.b(this.C, ((a) obj).C);
        }

        public final void h2(LazyLayoutItemAnimator lazyLayoutItemAnimator) {
            if (t.b(this.C, lazyLayoutItemAnimator) || !P0().O1()) {
                return;
            }
            this.C.n();
            lazyLayoutItemAnimator.f1896j = this;
            this.C = lazyLayoutItemAnimator;
        }

        public int hashCode() {
            return this.C.hashCode();
        }

        @Override // j2.r
        public void r(u1.c cVar) {
            List list = this.C.f1895i;
            int size = list.size();
            for (int i10 = 0; i10 < size; i10++) {
                androidx.compose.foundation.lazy.layout.b bVar = (androidx.compose.foundation.lazy.layout.b) list.get(i10);
                v1.c g10 = bVar.g();
                if (g10 != null) {
                    float h10 = n.h(bVar.f());
                    float h11 = h10 - n.h(g10.w());
                    float i11 = n.i(bVar.f()) - n.i(g10.w());
                    cVar.Q0().f().d(h11, i11);
                    try {
                        v1.e.a(cVar, g10);
                    } finally {
                        cVar.Q0().f().d(-h11, -i11);
                    }
                }
            }
            cVar.z1();
        }

        public String toString() {
            return "DisplayingDisappearingItemsNode(animator=" + this.C + ')';
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public final class b {

        /* renamed from: a, reason: collision with root package name */
        private androidx.compose.foundation.lazy.layout.b[] f1899a;

        /* renamed from: b, reason: collision with root package name */
        private c3.b f1900b;

        /* renamed from: c, reason: collision with root package name */
        private int f1901c;

        /* renamed from: d, reason: collision with root package name */
        private int f1902d;

        /* renamed from: e, reason: collision with root package name */
        private int f1903e;

        /* renamed from: f, reason: collision with root package name */
        private int f1904f;

        /* renamed from: g, reason: collision with root package name */
        private int f1905g;

        public b() {
            androidx.compose.foundation.lazy.layout.b[] bVarArr;
            bVarArr = p.f18964a;
            this.f1899a = bVarArr;
            this.f1903e = 1;
        }

        private final boolean h() {
            androidx.compose.foundation.lazy.layout.b[] bVarArr = this.f1899a;
            int length = bVarArr.length;
            for (int i10 = 0; i10 < length; i10++) {
                androidx.compose.foundation.lazy.layout.b bVar = bVarArr[i10];
                if (bVar != null && bVar.n()) {
                    return true;
                }
            }
            return false;
        }

        public static /* synthetic */ void l(b bVar, y yVar, m0 m0Var, s1.s0 s0Var, int i10, int i11, int i12, int i13, Object obj) {
            if ((i13 & 32) != 0) {
                i12 = LazyLayoutItemAnimator.this.e(yVar);
            }
            bVar.k(yVar, m0Var, s0Var, i10, i11, i12);
        }

        public final androidx.compose.foundation.lazy.layout.b[] a() {
            return this.f1899a;
        }

        public final c3.b b() {
            return this.f1900b;
        }

        public final int c() {
            return this.f1901c;
        }

        public final int d() {
            return this.f1902d;
        }

        public final int e() {
            return this.f1905g;
        }

        public final int f() {
            return this.f1904f;
        }

        public final int g() {
            return this.f1903e;
        }

        public final void i(int i10) {
            this.f1902d = i10;
        }

        public final void j(int i10) {
            this.f1903e = i10;
        }

        public final void k(y yVar, m0 m0Var, s1.s0 s0Var, int i10, int i11, int i12) {
            if (!h()) {
                this.f1904f = i10;
                this.f1905g = i11;
            }
            int length = this.f1899a.length;
            for (int c10 = yVar.c(); c10 < length; c10++) {
                androidx.compose.foundation.lazy.layout.b bVar = this.f1899a[c10];
                if (bVar != null) {
                    bVar.o();
                }
            }
            if (this.f1899a.length != yVar.c()) {
                Object[] copyOf = Arrays.copyOf(this.f1899a, yVar.c());
                t.f(copyOf, "copyOf(this, newSize)");
                this.f1899a = (androidx.compose.foundation.lazy.layout.b[]) copyOf;
            }
            this.f1900b = c3.b.a(yVar.h());
            this.f1901c = i12;
            this.f1902d = yVar.k();
            this.f1903e = yVar.f();
            int c11 = yVar.c();
            for (int i13 = 0; i13 < c11; i13++) {
                p.b(yVar.g(i13));
                androidx.compose.foundation.lazy.layout.b bVar2 = this.f1899a[i13];
                if (bVar2 != null) {
                    bVar2.o();
                }
                this.f1899a[i13] = null;
            }
        }
    }

    /* loaded from: classes.dex */
    public static final class c implements Comparator {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.compose.foundation.lazy.layout.c f1907p;

        public c(androidx.compose.foundation.lazy.layout.c cVar) {
            this.f1907p = cVar;
        }

        @Override // java.util.Comparator
        public final int compare(Object obj, Object obj2) {
            int d10;
            d10 = um.c.d(Integer.valueOf(this.f1907p.c(((y) obj).getKey())), Integer.valueOf(this.f1907p.c(((y) obj2).getKey())));
            return d10;
        }
    }

    /* loaded from: classes.dex */
    public static final class d implements Comparator {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.compose.foundation.lazy.layout.c f1908p;

        public d(androidx.compose.foundation.lazy.layout.c cVar) {
            this.f1908p = cVar;
        }

        @Override // java.util.Comparator
        public final int compare(Object obj, Object obj2) {
            int d10;
            d10 = um.c.d(Integer.valueOf(this.f1908p.c(((y) obj).getKey())), Integer.valueOf(this.f1908p.c(((y) obj2).getKey())));
            return d10;
        }
    }

    /* loaded from: classes.dex */
    public static final class e implements Comparator {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.compose.foundation.lazy.layout.c f1909p;

        public e(androidx.compose.foundation.lazy.layout.c cVar) {
            this.f1909p = cVar;
        }

        @Override // java.util.Comparator
        public final int compare(Object obj, Object obj2) {
            int d10;
            d10 = um.c.d(Integer.valueOf(this.f1909p.c(((y) obj2).getKey())), Integer.valueOf(this.f1909p.c(((y) obj).getKey())));
            return d10;
        }
    }

    /* loaded from: classes.dex */
    public static final class f implements Comparator {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.compose.foundation.lazy.layout.c f1910p;

        public f(androidx.compose.foundation.lazy.layout.c cVar) {
            this.f1910p = cVar;
        }

        @Override // java.util.Comparator
        public final int compare(Object obj, Object obj2) {
            int d10;
            d10 = um.c.d(Integer.valueOf(this.f1910p.c(((y) obj2).getKey())), Integer.valueOf(this.f1910p.c(((y) obj).getKey())));
            return d10;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final int e(y yVar) {
        long j10 = yVar.j(0);
        return !yVar.i() ? n.i(j10) : n.h(j10);
    }

    private final boolean f(y yVar) {
        int c10 = yVar.c();
        for (int i10 = 0; i10 < c10; i10++) {
            p.b(yVar.g(i10));
        }
        return false;
    }

    private final int g(y yVar) {
        long j10 = yVar.j(0);
        return yVar.i() ? n.i(j10) : n.h(j10);
    }

    private final void j(y yVar, int i10, b bVar) {
        int i11 = 0;
        long j10 = yVar.j(0);
        long e10 = yVar.i() ? n.e(j10, 0, i10, 1, null) : n.e(j10, i10, 0, 2, null);
        androidx.compose.foundation.lazy.layout.b[] a10 = bVar.a();
        int length = a10.length;
        int i12 = 0;
        while (i11 < length) {
            androidx.compose.foundation.lazy.layout.b bVar2 = a10[i11];
            int i13 = i12 + 1;
            if (bVar2 != null) {
                bVar2.r(n.l(e10, n.k(yVar.j(i12), j10)));
            }
            i11++;
            i12 = i13;
        }
    }

    static /* synthetic */ void k(LazyLayoutItemAnimator lazyLayoutItemAnimator, y yVar, int i10, b bVar, int i11, Object obj) {
        if ((i11 & 4) != 0) {
            Object b10 = lazyLayoutItemAnimator.f1887a.b(yVar.getKey());
            t.d(b10);
            bVar = (b) b10;
        }
        lazyLayoutItemAnimator.j(yVar, i10, bVar);
    }

    private final void m(Object obj) {
        androidx.compose.foundation.lazy.layout.b[] a10;
        b bVar = (b) this.f1887a.o(obj);
        if (bVar == null || (a10 = bVar.a()) == null) {
            return;
        }
        for (androidx.compose.foundation.lazy.layout.b bVar2 : a10) {
            if (bVar2 != null) {
                bVar2.o();
            }
        }
    }

    private final void o(y yVar, boolean z10) {
        Object b10 = this.f1887a.b(yVar.getKey());
        t.d(b10);
        androidx.compose.foundation.lazy.layout.b[] a10 = ((b) b10).a();
        int length = a10.length;
        int i10 = 0;
        int i11 = 0;
        while (i10 < length) {
            androidx.compose.foundation.lazy.layout.b bVar = a10[i10];
            int i12 = i11 + 1;
            if (bVar != null) {
                long j10 = yVar.j(i11);
                long j11 = bVar.j();
                if (!n.g(j11, androidx.compose.foundation.lazy.layout.b.f1918a.a()) && !n.g(j11, j10)) {
                    bVar.d(n.k(j10, j11), z10);
                }
                bVar.r(j10);
            }
            i10++;
            i11 = i12;
        }
    }

    static /* synthetic */ void p(LazyLayoutItemAnimator lazyLayoutItemAnimator, y yVar, boolean z10, int i10, Object obj) {
        if ((i10 & 2) != 0) {
            z10 = false;
        }
        lazyLayoutItemAnimator.o(yVar, z10);
    }

    private final int q(int[] iArr, y yVar) {
        int k10 = yVar.k();
        int f10 = yVar.f() + k10;
        int i10 = 0;
        while (k10 < f10) {
            int e10 = iArr[k10] + yVar.e();
            iArr[k10] = e10;
            i10 = Math.max(i10, e10);
            k10++;
        }
        return i10;
    }

    public final androidx.compose.foundation.lazy.layout.b d(Object obj, int i10) {
        androidx.compose.foundation.lazy.layout.b[] a10;
        b bVar = (b) this.f1887a.b(obj);
        if (bVar == null || (a10 = bVar.a()) == null) {
            return null;
        }
        return a10[i10];
    }

    public final long h() {
        long a10 = c3.r.f7432b.a();
        List list = this.f1895i;
        int size = list.size();
        for (int i10 = 0; i10 < size; i10++) {
            androidx.compose.foundation.lazy.layout.b bVar = (androidx.compose.foundation.lazy.layout.b) list.get(i10);
            v1.c g10 = bVar.g();
            if (g10 != null) {
                a10 = s.a(Math.max(c3.r.g(a10), n.h(bVar.j()) + c3.r.g(g10.v())), Math.max(c3.r.f(a10), n.i(bVar.j()) + c3.r.f(g10.v())));
            }
        }
        return a10;
    }

    public final l1.i i() {
        return this.f1897k;
    }

    /* JADX WARN: Removed duplicated region for block: B:203:0x0404 A[LOOP:13: B:196:0x03ea->B:203:0x0404, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:204:0x0402 A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void l(int i10, int i11, int i12, List list, androidx.compose.foundation.lazy.layout.c cVar, z zVar, boolean z10, boolean z11, int i13, boolean z12, int i14, int i15, m0 m0Var, s1.s0 s0Var) {
        boolean z13;
        Object e02;
        androidx.compose.foundation.lazy.layout.c cVar2;
        androidx.compose.foundation.lazy.layout.c cVar3;
        int[] iArr;
        int i16;
        int i17;
        int[] iArr2;
        int e10;
        Object o02;
        int f10;
        Object c02;
        long[] jArr;
        Object[] objArr;
        long[] jArr2;
        Object[] objArr2;
        int[] iArr3;
        boolean z14;
        androidx.compose.foundation.lazy.layout.b[] bVarArr;
        boolean z15;
        androidx.compose.foundation.lazy.layout.b[] bVarArr2;
        int i18;
        androidx.compose.foundation.lazy.layout.c cVar4;
        androidx.compose.foundation.lazy.layout.c cVar5;
        long[] jArr3;
        Object[] objArr3;
        long[] jArr4;
        Object[] objArr4;
        List list2 = list;
        int i19 = i13;
        androidx.compose.foundation.lazy.layout.c cVar6 = this.f1888b;
        this.f1888b = cVar;
        int size = list.size();
        int i20 = 0;
        int i21 = 0;
        while (true) {
            if (i21 >= size) {
                z13 = false;
                break;
            } else {
                if (f((y) list2.get(i21))) {
                    z13 = true;
                    break;
                }
                i21++;
            }
        }
        if (!z13 && this.f1887a.e()) {
            n();
            return;
        }
        int i22 = this.f1889c;
        e02 = c0.e0(list);
        y yVar = (y) e02;
        this.f1889c = yVar != null ? yVar.getIndex() : 0;
        long a10 = z10 ? o.a(0, i10) : o.a(i10, 0);
        boolean z16 = z11 || !z12;
        g0 g0Var = this.f1887a;
        Object[] objArr5 = g0Var.f1367b;
        long[] jArr5 = g0Var.f1366a;
        int length = jArr5.length - 2;
        boolean z17 = z16;
        if (length >= 0) {
            while (true) {
                long j10 = jArr5[i20];
                if ((((~j10) << 7) & j10 & (-9187201950435737472L)) != -9187201950435737472L) {
                    int i23 = 8 - ((~(i20 - length)) >>> 31);
                    int i24 = 0;
                    while (i24 < i23) {
                        if ((j10 & 255) < 128) {
                            jArr4 = jArr5;
                            objArr4 = objArr5;
                            this.f1890d.h(objArr5[(i20 << 3) + i24]);
                        } else {
                            jArr4 = jArr5;
                            objArr4 = objArr5;
                        }
                        j10 >>= 8;
                        i24++;
                        objArr5 = objArr4;
                        jArr5 = jArr4;
                    }
                    jArr3 = jArr5;
                    objArr3 = objArr5;
                    if (i23 != 8) {
                        break;
                    }
                } else {
                    jArr3 = jArr5;
                    objArr3 = objArr5;
                }
                if (i20 == length) {
                    break;
                }
                i20++;
                objArr5 = objArr3;
                jArr5 = jArr3;
            }
        }
        int size2 = list.size();
        int i25 = 0;
        while (i25 < size2) {
            y yVar2 = (y) list2.get(i25);
            this.f1890d.x(yVar2.getKey());
            if (f(yVar2)) {
                b bVar = (b) this.f1887a.b(yVar2.getKey());
                int c10 = cVar6 != null ? cVar6.c(yVar2.getKey()) : -1;
                boolean z18 = c10 == -1 && cVar6 != null;
                if (bVar == null) {
                    b bVar2 = new b();
                    b.l(bVar2, yVar2, m0Var, s0Var, i14, i15, 0, 32, null);
                    this.f1887a.r(yVar2.getKey(), bVar2);
                    if (yVar2.getIndex() == c10 || c10 == -1) {
                        long j11 = yVar2.j(0);
                        j(yVar2, yVar2.i() ? n.i(j11) : n.h(j11), bVar2);
                        if (z18) {
                            androidx.compose.foundation.lazy.layout.b[] a11 = bVar2.a();
                            for (androidx.compose.foundation.lazy.layout.b bVar3 : a11) {
                                if (bVar3 != null) {
                                    bVar3.b();
                                    n0 n0Var = n0.f34904a;
                                }
                            }
                        }
                    } else if (c10 < i22) {
                        this.f1891e.add(yVar2);
                    } else {
                        this.f1892f.add(yVar2);
                    }
                } else if (z17) {
                    b.l(bVar, yVar2, m0Var, s0Var, i14, i15, 0, 32, null);
                    androidx.compose.foundation.lazy.layout.b[] a12 = bVar.a();
                    int length2 = a12.length;
                    int i26 = 0;
                    while (i26 < length2) {
                        int i27 = size2;
                        androidx.compose.foundation.lazy.layout.b bVar4 = a12[i26];
                        if (bVar4 != null) {
                            cVar5 = cVar6;
                            if (!n.g(bVar4.j(), androidx.compose.foundation.lazy.layout.b.f1918a.a())) {
                                bVar4.r(n.l(bVar4.j(), a10));
                            }
                        } else {
                            cVar5 = cVar6;
                        }
                        i26++;
                        size2 = i27;
                        cVar6 = cVar5;
                    }
                    i18 = size2;
                    cVar4 = cVar6;
                    if (z18) {
                        for (androidx.compose.foundation.lazy.layout.b bVar5 : bVar.a()) {
                            if (bVar5 != null) {
                                if (bVar5.l()) {
                                    this.f1895i.remove(bVar5);
                                    r rVar = this.f1896j;
                                    if (rVar != null) {
                                        j2.s.a(rVar);
                                        n0 n0Var2 = n0.f34904a;
                                    }
                                }
                                bVar5.b();
                            }
                        }
                    }
                    p(this, yVar2, false, 2, null);
                }
                i18 = size2;
                cVar4 = cVar6;
            } else {
                i18 = size2;
                cVar4 = cVar6;
                m(yVar2.getKey());
            }
            i25++;
            list2 = list;
            i19 = i13;
            size2 = i18;
            cVar6 = cVar4;
        }
        int i28 = i19;
        androidx.compose.foundation.lazy.layout.c cVar7 = cVar6;
        int[] iArr4 = new int[i28];
        for (int i29 = 0; i29 < i28; i29++) {
            iArr4[i29] = 0;
        }
        if (!z17 || cVar7 == null) {
            cVar2 = cVar7;
        } else {
            if (!this.f1891e.isEmpty()) {
                List list3 = this.f1891e;
                if (list3.size() > 1) {
                    cVar2 = cVar7;
                    sm.y.z(list3, new e(cVar2));
                } else {
                    cVar2 = cVar7;
                }
                List list4 = this.f1891e;
                int size3 = list4.size();
                for (int i30 = 0; i30 < size3; i30++) {
                    y yVar3 = (y) list4.get(i30);
                    k(this, yVar3, i14 - q(iArr4, yVar3), null, 4, null);
                    p(this, yVar3, false, 2, null);
                }
                sm.o.w(iArr4, 0, 0, 0, 6, null);
            } else {
                cVar2 = cVar7;
            }
            if (!this.f1892f.isEmpty()) {
                List list5 = this.f1892f;
                if (list5.size() > 1) {
                    sm.y.z(list5, new c(cVar2));
                }
                List list6 = this.f1892f;
                int size4 = list6.size();
                for (int i31 = 0; i31 < size4; i31++) {
                    y yVar4 = (y) list6.get(i31);
                    k(this, yVar4, (i15 + q(iArr4, yVar4)) - yVar4.e(), null, 4, null);
                    p(this, yVar4, false, 2, null);
                }
                sm.o.w(iArr4, 0, 0, 0, 6, null);
            }
        }
        h0 h0Var = this.f1890d;
        Object[] objArr6 = h0Var.f1380b;
        long[] jArr6 = h0Var.f1379a;
        int length3 = jArr6.length - 2;
        if (length3 >= 0) {
            int i32 = 0;
            while (true) {
                long j12 = jArr6[i32];
                if ((((~j12) << 7) & j12 & (-9187201950435737472L)) != -9187201950435737472L) {
                    int i33 = 8 - ((~(i32 - length3)) >>> 31);
                    int i34 = 0;
                    while (i34 < i33) {
                        if ((j12 & 255) < 128) {
                            Object obj = objArr6[(i32 << 3) + i34];
                            Object b10 = this.f1887a.b(obj);
                            t.d(b10);
                            b bVar6 = (b) b10;
                            int c11 = cVar.c(obj);
                            jArr2 = jArr6;
                            bVar6.j(Math.min(i28, bVar6.g()));
                            objArr2 = objArr6;
                            bVar6.i(Math.min(i28 - bVar6.g(), bVar6.d()));
                            if (c11 == -1) {
                                androidx.compose.foundation.lazy.layout.b[] a13 = bVar6.a();
                                int length4 = a13.length;
                                int i35 = 0;
                                int i36 = 0;
                                boolean z19 = false;
                                while (i35 < length4) {
                                    androidx.compose.foundation.lazy.layout.b bVar7 = a13[i35];
                                    int i37 = i36 + 1;
                                    if (bVar7 != null) {
                                        if (bVar7.l()) {
                                            bVarArr2 = a13;
                                        } else if (bVar7.k()) {
                                            bVar7.o();
                                            bVar6.a()[i36] = null;
                                            bVarArr2 = a13;
                                            this.f1895i.remove(bVar7);
                                            r rVar2 = this.f1896j;
                                            if (rVar2 != null) {
                                                j2.s.a(rVar2);
                                                n0 n0Var3 = n0.f34904a;
                                            }
                                        } else {
                                            bVarArr2 = a13;
                                            if (bVar7.g() != null) {
                                                bVar7.c();
                                            }
                                            if (bVar7.l()) {
                                                this.f1895i.add(bVar7);
                                                r rVar3 = this.f1896j;
                                                if (rVar3 != null) {
                                                    j2.s.a(rVar3);
                                                    n0 n0Var4 = n0.f34904a;
                                                }
                                            } else {
                                                bVar7.o();
                                                bVar6.a()[i36] = null;
                                                i35++;
                                                i36 = i37;
                                                a13 = bVarArr2;
                                            }
                                        }
                                        z19 = true;
                                        i35++;
                                        i36 = i37;
                                        a13 = bVarArr2;
                                    } else {
                                        bVarArr2 = a13;
                                    }
                                    i35++;
                                    i36 = i37;
                                    a13 = bVarArr2;
                                }
                                if (!z19) {
                                    m(obj);
                                }
                            } else {
                                c3.b b11 = bVar6.b();
                                t.d(b11);
                                y a14 = zVar.a(c11, bVar6.d(), bVar6.g(), b11.r());
                                a14.d(true);
                                androidx.compose.foundation.lazy.layout.b[] a15 = bVar6.a();
                                int length5 = a15.length;
                                iArr3 = iArr4;
                                int i38 = 0;
                                while (true) {
                                    if (i38 >= length5) {
                                        z14 = false;
                                        break;
                                    }
                                    androidx.compose.foundation.lazy.layout.b bVar8 = a15[i38];
                                    int i39 = length5;
                                    if (bVar8 != null) {
                                        boolean m10 = bVar8.m();
                                        bVarArr = a15;
                                        if (m10) {
                                            z15 = true;
                                            if (!z15) {
                                                z14 = true;
                                                break;
                                            } else {
                                                i38++;
                                                a15 = bVarArr;
                                                length5 = i39;
                                            }
                                        }
                                    } else {
                                        bVarArr = a15;
                                    }
                                    z15 = false;
                                    if (!z15) {
                                    }
                                }
                                if (!z14) {
                                    if (cVar2 != null && c11 == cVar2.c(obj)) {
                                        m(obj);
                                        j12 >>= 8;
                                        i34++;
                                        jArr6 = jArr2;
                                        i28 = i13;
                                        objArr6 = objArr2;
                                        iArr4 = iArr3;
                                    }
                                }
                                bVar6.k(a14, m0Var, s0Var, i14, i15, bVar6.c());
                                if (c11 < this.f1889c) {
                                    this.f1893g.add(a14);
                                } else {
                                    this.f1894h.add(a14);
                                }
                                j12 >>= 8;
                                i34++;
                                jArr6 = jArr2;
                                i28 = i13;
                                objArr6 = objArr2;
                                iArr4 = iArr3;
                            }
                        } else {
                            jArr2 = jArr6;
                            objArr2 = objArr6;
                        }
                        iArr3 = iArr4;
                        j12 >>= 8;
                        i34++;
                        jArr6 = jArr2;
                        i28 = i13;
                        objArr6 = objArr2;
                        iArr4 = iArr3;
                    }
                    cVar3 = cVar;
                    jArr = jArr6;
                    objArr = objArr6;
                    iArr = iArr4;
                    if (i33 != 8) {
                        break;
                    }
                } else {
                    cVar3 = cVar;
                    jArr = jArr6;
                    objArr = objArr6;
                    iArr = iArr4;
                }
                if (i32 == length3) {
                    break;
                }
                i32++;
                jArr6 = jArr;
                i28 = i13;
                objArr6 = objArr;
                iArr4 = iArr;
            }
        } else {
            cVar3 = cVar;
            iArr = iArr4;
        }
        if (!this.f1893g.isEmpty()) {
            List list7 = this.f1893g;
            if (list7.size() > 1) {
                sm.y.z(list7, new f(cVar3));
            }
            List list8 = this.f1893g;
            int size5 = list8.size();
            int i40 = 0;
            while (i40 < size5) {
                y yVar5 = (y) list8.get(i40);
                Object b12 = this.f1887a.b(yVar5.getKey());
                t.d(b12);
                b bVar9 = (b) b12;
                int[] iArr5 = iArr;
                int q10 = q(iArr5, yVar5);
                if (z11) {
                    c02 = c0.c0(list);
                    f10 = g((y) c02);
                } else {
                    f10 = bVar9.f();
                }
                yVar5.l(f10 - q10, bVar9.c(), i11, i12);
                if (z17) {
                    o(yVar5, true);
                }
                i40++;
                iArr = iArr5;
            }
            i16 = i11;
            i17 = i12;
            iArr2 = iArr;
            sm.o.w(iArr2, 0, 0, 0, 6, null);
        } else {
            i16 = i11;
            i17 = i12;
            iArr2 = iArr;
        }
        if (!this.f1894h.isEmpty()) {
            List list9 = this.f1894h;
            if (list9.size() > 1) {
                sm.y.z(list9, new d(cVar3));
            }
            List list10 = this.f1894h;
            int size6 = list10.size();
            for (int i41 = 0; i41 < size6; i41++) {
                y yVar6 = (y) list10.get(i41);
                Object b13 = this.f1887a.b(yVar6.getKey());
                t.d(b13);
                b bVar10 = (b) b13;
                int q11 = q(iArr2, yVar6);
                if (z11) {
                    o02 = c0.o0(list);
                    e10 = g((y) o02);
                } else {
                    e10 = bVar10.e() - yVar6.e();
                }
                yVar6.l(e10 + q11, bVar10.c(), i16, i17);
                if (z17) {
                    o(yVar6, true);
                }
            }
        }
        List list11 = this.f1893g;
        b0.Q(list11);
        n0 n0Var5 = n0.f34904a;
        list.addAll(0, list11);
        list.addAll(this.f1894h);
        this.f1891e.clear();
        this.f1892f.clear();
        this.f1893g.clear();
        this.f1894h.clear();
        this.f1890d.m();
    }

    public final void n() {
        if (this.f1887a.f()) {
            g0 g0Var = this.f1887a;
            Object[] objArr = g0Var.f1368c;
            long[] jArr = g0Var.f1366a;
            int length = jArr.length - 2;
            if (length >= 0) {
                int i10 = 0;
                while (true) {
                    long j10 = jArr[i10];
                    if ((((~j10) << 7) & j10 & (-9187201950435737472L)) != -9187201950435737472L) {
                        int i11 = 8 - ((~(i10 - length)) >>> 31);
                        for (int i12 = 0; i12 < i11; i12++) {
                            if ((255 & j10) < 128) {
                                for (androidx.compose.foundation.lazy.layout.b bVar : ((b) objArr[(i10 << 3) + i12]).a()) {
                                    if (bVar != null) {
                                        bVar.o();
                                    }
                                }
                            }
                            j10 >>= 8;
                        }
                        if (i11 != 8) {
                            break;
                        }
                    }
                    if (i10 == length) {
                        break;
                    } else {
                        i10++;
                    }
                }
            }
            this.f1887a.h();
        }
        this.f1888b = androidx.compose.foundation.lazy.layout.c.f1921a;
        this.f1889c = -1;
    }
}
