package C0;

import I0.AbstractC0303l;
import I0.y0;
import V4.B0;
import V4.C0772m;
import a.AbstractC0872a;
import androidx.compose.runtime.collection.MutableVector;
import androidx.compose.ui.input.pointer.PointerInputEventHandler;
import i0.AbstractC2254r;
import java.util.ArrayList;
import w4.C3137A;

/* JADX INFO: loaded from: classes.dex */
public final class b0 extends AbstractC2254r implements F, h1.c, y0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Object f575a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object[] f577c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public PointerInputEventHandler f578d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public B0 f579e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public C0116q f580f = U.f553a;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final MutableVector f581j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final MutableVector f582k;
    public final MutableVector l;

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

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

    public b0(Object obj, Object obj2, Object[] objArr, PointerInputEventHandler pointerInputEventHandler) {
        this.f575a = obj;
        this.f576b = obj2;
        this.f577c = objArr;
        this.f578d = pointerInputEventHandler;
        MutableVector mutableVector = new MutableVector(new Y[16], 0);
        this.f581j = mutableVector;
        this.f582k = mutableVector;
        this.l = new MutableVector(new Y[16], 0);
        this.f584n = 0L;
    }

    /* JADX WARN: Type inference failed for: r1v1, types: [java.lang.Object, java.util.Collection, java.util.List] */
    @Override // I0.y0
    public final void F() {
        C0116q c0116q = this.f583m;
        if (c0116q == null) {
            return;
        }
        ?? r12 = c0116q.f627a;
        int size = r12.size();
        for (int i6 = 0; i6 < size; i6++) {
            if (((C0124z) r12.get(i6)).f647d) {
                ArrayList arrayList = new ArrayList(r12.size());
                int size2 = r12.size();
                for (int i7 = 0; i7 < size2; i7++) {
                    C0124z c0124z = (C0124z) r12.get(i7);
                    long j4 = c0124z.f644a;
                    boolean z6 = c0124z.f647d;
                    int i8 = c0124z.f652i;
                    long j6 = c0124z.f645b;
                    long j7 = c0124z.f646c;
                    arrayList.add(new C0124z(j4, j6, j7, false, c0124z.f648e, j6, j7, z6, z6, i8, 0L));
                }
                C0116q c0116q2 = new C0116q(arrayList, null);
                this.f580f = c0116q2;
                u0(c0116q2, r.f633a);
                u0(c0116q2, r.f634b);
                u0(c0116q2, r.f635c);
                this.f583m = null;
                return;
            }
        }
    }

    @Override // h1.c
    public final float T() {
        return AbstractC0303l.t(this).f2155C.T();
    }

    @Override // h1.c
    public final float a() {
        return AbstractC0303l.t(this).f2155C.a();
    }

    /* JADX WARN: Type inference failed for: r5v1, types: [java.lang.Object, java.util.Collection, java.util.List] */
    @Override // I0.y0
    public final void d0(C0116q c0116q, r rVar, long j4) {
        this.f584n = j4;
        if (rVar == r.f633a) {
            this.f580f = c0116q;
        }
        if (this.f579e == null) {
            this.f579e = V4.E.y(getCoroutineScope(), null, V4.D.f8228d, new a0(this, null), 1);
        }
        u0(c0116q, rVar);
        ?? r5 = c0116q.f627a;
        int size = r5.size();
        int i6 = 0;
        while (true) {
            if (i6 >= size) {
                c0116q = null;
                break;
            } else if (!AbstractC0123y.d((C0124z) r5.get(i6))) {
                break;
            } else {
                i6++;
            }
        }
        this.f583m = c0116q;
    }

    @Override // I0.y0
    public final void n0() {
        v0();
    }

    @Override // I0.InterfaceC0299j, I0.y0
    public final void onDensityChange() {
        v0();
    }

    @Override // i0.AbstractC2254r
    public final void onDetach() {
        v0();
        super.onDetach();
    }

    public final Object t0(J4.e eVar, A4.d dVar) {
        C0772m c0772m = new C0772m(1, AbstractC0872a.V(dVar));
        c0772m.s();
        Y y6 = new Y(this, c0772m);
        synchronized (this.f582k) {
            this.f581j.add(y6);
            new A4.l(AbstractC0872a.V(AbstractC0872a.z(y6, y6, eVar)), B4.a.f492a).resumeWith(C3137A.f25453a);
        }
        c0772m.u(new Z(y6, 0));
        return c0772m.r();
    }

    /* JADX WARN: Removed duplicated region for block: B:28:0x0052 A[Catch: all -> 0x0023, TryCatch #1 {all -> 0x0023, blocks: (B:6:0x000f, B:13:0x001d, B:14:0x0022, B:17:0x0025, B:20:0x0033, B:22:0x003b, B:24:0x003f, B:25:0x0044, B:26:0x0047, B:28:0x0052, B:30:0x005a, B:32:0x005e), top: B:43:0x000f }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void u0(C0116q c0116q, r rVar) {
        int size;
        int i6;
        C0772m c0772m;
        C0772m c0772m2;
        synchronized (this.f582k) {
            MutableVector mutableVector = this.l;
            mutableVector.addAll(mutableVector.getSize(), this.f581j);
        }
        try {
            int iOrdinal = rVar.ordinal();
            if (iOrdinal == 0) {
                MutableVector mutableVector2 = this.l;
                Object[] objArr = mutableVector2.content;
                size = mutableVector2.getSize();
                for (i6 = 0; i6 < size; i6++) {
                    Y y6 = (Y) objArr[i6];
                    if (rVar == y6.f567d && (c0772m = y6.f566c) != null) {
                        y6.f566c = null;
                        c0772m.resumeWith(c0116q);
                    }
                }
            } else if (iOrdinal == 1) {
                MutableVector mutableVector3 = this.l;
                int size2 = mutableVector3.getSize() - 1;
                Object[] objArr2 = mutableVector3.content;
                if (size2 < objArr2.length) {
                    while (size2 >= 0) {
                        Y y7 = (Y) objArr2[size2];
                        if (rVar == y7.f567d && (c0772m2 = y7.f566c) != null) {
                            y7.f566c = null;
                            c0772m2.resumeWith(c0116q);
                        }
                        size2--;
                    }
                }
            } else {
                if (iOrdinal != 2) {
                    throw new E3.v();
                }
                MutableVector mutableVector22 = this.l;
                Object[] objArr3 = mutableVector22.content;
                size = mutableVector22.getSize();
                while (i6 < size) {
                }
            }
            this.l.clear();
        } catch (Throwable th) {
            this.l.clear();
            throw th;
        }
    }

    public final void v0() {
        B0 b02 = this.f579e;
        if (b02 != null) {
            b02.o(new E("Pointer input was reset", 1));
            this.f579e = null;
        }
    }
}
