package androidx.compose.runtime;

import androidx.compose.runtime.internal.RememberEventDispatcher;
import androidx.compose.runtime.internal.StabilityInferred;
import kotlin.jvm.internal.F;
import n.C2598z;
import n.J;

/* JADX INFO: loaded from: classes.dex */
@StabilityInferred(parameters = 0)
public final class RecordingApplier<N> implements Applier<N> {
    public static final int APPLY = 7;
    public static final int CLEAR = 4;
    public static final int DOWN = 1;
    public static final int INSERT_BOTTOM_UP = 5;
    public static final int INSERT_TOP_DOWN = 6;
    public static final int MOVE = 3;
    public static final int RECOMPOSE_PENDING = 9;
    public static final int REMOVE = 2;
    public static final int REUSE = 8;
    public static final int UP = 0;
    private N current;
    public static final Companion Companion = new Companion(null);
    public static final int $stable = 8;
    private final C2598z operations = new C2598z();
    private final J instances = new J();

    public static final class Companion {
        public /* synthetic */ Companion(kotlin.jvm.internal.h hVar) {
            this();
        }

        private Companion() {
        }
    }

    public RecordingApplier(N n6) {
        this.current = n6;
    }

    @Override // androidx.compose.runtime.Applier
    public void apply(J4.e eVar, Object obj) {
        this.operations.c(7);
        this.instances.g(eVar);
        this.instances.g(obj);
    }

    @Override // androidx.compose.runtime.Applier
    public void clear() {
        this.operations.c(4);
    }

    @Override // androidx.compose.runtime.Applier
    public void down(N n6) {
        this.operations.c(1);
        this.instances.g(n6);
    }

    @Override // androidx.compose.runtime.Applier
    public N getCurrent() {
        return this.current;
    }

    @Override // androidx.compose.runtime.Applier
    public void insertBottomUp(int i6, N n6) {
        this.operations.c(5);
        this.operations.c(i6);
        this.instances.g(n6);
    }

    @Override // androidx.compose.runtime.Applier
    public void insertTopDown(int i6, N n6) {
        this.operations.c(6);
        this.operations.c(i6);
        this.instances.g(n6);
    }

    public final void markRecomposePending() {
        this.operations.c(9);
    }

    @Override // androidx.compose.runtime.Applier
    public void move(int i6, int i7, int i8) {
        this.operations.c(3);
        this.operations.c(i6);
        this.operations.c(i7);
        this.operations.c(i8);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void playTo(Applier<N> applier, RememberEventDispatcher rememberEventDispatcher) {
        Exception exc;
        Exception exc2;
        int i6;
        int i7;
        C2598z c2598z = this.operations;
        int i8 = c2598z.f21454b;
        J j4 = this.instances;
        J j6 = new J();
        applier.onBeginChanges();
        int i9 = 0;
        int i10 = 0;
        while (i9 < i8) {
            int i11 = i9 + 1;
            try {
                try {
                    switch (c2598z.a(i9)) {
                        case 0:
                            applier.up();
                            i9 = i11;
                            break;
                        case 1:
                            int i12 = i10 + 1;
                            applier.down(j4.b(i10));
                            i10 = i12;
                            i9 = i11;
                            break;
                        case 2:
                            int i13 = i9 + 2;
                            i9 += 3;
                            applier.remove(c2598z.a(i11), c2598z.a(i13));
                            break;
                        case 3:
                            int i14 = i9 + 2;
                            try {
                                i6 = i9 + 3;
                            } catch (Exception e6) {
                                exc = e6;
                                i11 = i14;
                            }
                            try {
                                i9 += 4;
                                applier.move(c2598z.a(i11), c2598z.a(i14), c2598z.a(i6));
                            } catch (Exception e7) {
                                exc = e7;
                                i11 = i6;
                                throw new ComposePausableCompositionException(j4, j6, c2598z, i11 - 1, exc);
                            }
                            break;
                        case 4:
                            applier.clear();
                            i9 = i11;
                            break;
                        case 5:
                            i9 += 2;
                            i7 = i10 + 1;
                            applier.insertBottomUp(c2598z.a(i11), j4.b(i10));
                            i10 = i7;
                            break;
                        case 6:
                            i9 += 2;
                            try {
                                i7 = i10 + 1;
                                applier.insertTopDown(c2598z.a(i11), j4.b(i10));
                                i10 = i7;
                            } catch (Exception e8) {
                                exc2 = e8;
                                i11 = i9;
                                exc = exc2;
                                throw new ComposePausableCompositionException(j4, j6, c2598z, i11 - 1, exc);
                            }
                            break;
                        case 7:
                            int i15 = i10 + 1;
                            Object objB = j4.b(i10);
                            kotlin.jvm.internal.o.f(objB, "null cannot be cast to non-null type @[ExtensionFunctionType] kotlin.Function2<kotlin.Any?, kotlin.Any?, kotlin.Unit>");
                            F.c(2, objB);
                            i10 += 2;
                            applier.apply((J4.e) objB, j4.b(i15));
                            i9 = i11;
                            break;
                        case 8:
                            Object current = applier.getCurrent();
                            if (current instanceof ComposeNodeLifecycleCallback) {
                                rememberEventDispatcher.dispatchOnDeactivateIfNecessary((ComposeNodeLifecycleCallback) current);
                            }
                            j6.g(current);
                            applier.reuse();
                            i9 = i11;
                            break;
                        default:
                            i9 = i11;
                            break;
                    }
                } catch (Exception e9) {
                    exc2 = e9;
                    exc = exc2;
                    throw new ComposePausableCompositionException(j4, j6, c2598z, i11 - 1, exc);
                }
            } catch (Throwable th) {
                applier.onEndChanges();
                throw th;
            }
        }
        if (i10 != j4.f21377b) {
            ComposerKt.composeImmediateRuntimeError("Applier operation size mismatch");
        }
        j4.j();
        c2598z.f21454b = 0;
        applier.onEndChanges();
    }

    @Override // androidx.compose.runtime.Applier
    public void remove(int i6, int i7) {
        this.operations.c(2);
        this.operations.c(i6);
        this.operations.c(i7);
    }

    @Override // androidx.compose.runtime.Applier
    public void reuse() {
        this.operations.c(8);
    }

    public void setCurrent(N n6) {
        this.current = n6;
    }

    @Override // androidx.compose.runtime.Applier
    public void up() {
        this.operations.c(0);
    }
}
