package androidx.compose.runtime.changelist;

import J4.a;
import J4.e;
import androidx.compose.runtime.Anchor;
import androidx.compose.runtime.Applier;
import androidx.compose.runtime.ComposerKt;
import androidx.compose.runtime.RememberManager;
import androidx.compose.runtime.SlotWriter;
import androidx.compose.runtime.changelist.Operation;
import androidx.compose.runtime.changelist.Operations;
import androidx.compose.runtime.internal.StabilityInferred;
import kotlin.jvm.internal.F;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes.dex */
@StabilityInferred(parameters = 0)
public final class FixupList extends OperationsDebugStringFormattable {
    public static final int $stable = 8;
    private final Operations operations = new Operations();
    private final Operations pendingOperations = new Operations();

    public final void clear() {
        this.pendingOperations.clear();
        this.operations.clear();
    }

    public final void createAndInsertNode(a aVar, int i6, Anchor anchor) {
        Operations operations = this.operations;
        Operation.InsertNodeFixup insertNodeFixup = Operation.InsertNodeFixup.INSTANCE;
        operations.pushOp(insertNodeFixup);
        Operations operationsM143constructorimpl = Operations.WriteScope.m143constructorimpl(operations);
        Operations.WriteScope.m151setObjectDKhxnng(operationsM143constructorimpl, Operation.ObjectParameter.m120constructorimpl(0), aVar);
        operationsM143constructorimpl.intArgs[operationsM143constructorimpl.intArgsSize - operationsM143constructorimpl.opCodes[operationsM143constructorimpl.opCodesSize - 1].getInts()] = i6;
        Operations.WriteScope.m151setObjectDKhxnng(operationsM143constructorimpl, Operation.ObjectParameter.m120constructorimpl(1), anchor);
        operations.ensureAllArgumentsPushedFor(insertNodeFixup);
        Operations operations2 = this.pendingOperations;
        Operation.PostInsertNodeFixup postInsertNodeFixup = Operation.PostInsertNodeFixup.INSTANCE;
        operations2.pushOp(postInsertNodeFixup);
        Operations operationsM143constructorimpl2 = Operations.WriteScope.m143constructorimpl(operations2);
        operationsM143constructorimpl2.intArgs[operationsM143constructorimpl2.intArgsSize - operationsM143constructorimpl2.opCodes[operationsM143constructorimpl2.opCodesSize - 1].getInts()] = i6;
        Operations.WriteScope.m151setObjectDKhxnng(operationsM143constructorimpl2, Operation.ObjectParameter.m120constructorimpl(0), anchor);
        operations2.ensureAllArgumentsPushedFor(postInsertNodeFixup);
    }

    public final void endNodeInsert() {
        if (!this.pendingOperations.isNotEmpty()) {
            ComposerKt.composeImmediateRuntimeError("Cannot end node insertion, there are no pending operations that can be realized.");
        }
        this.pendingOperations.popInto(this.operations);
    }

    public final void executeAndFlushAllPendingFixups(Applier<?> applier, SlotWriter slotWriter, RememberManager rememberManager, OperationErrorContext operationErrorContext) {
        if (!this.pendingOperations.isEmpty()) {
            ComposerKt.composeImmediateRuntimeError("FixupList has pending fixup operations that were not realized. Were there mismatched insertNode() and endNodeInsert() calls?");
        }
        this.operations.executeAndFlushAllPendingOperations(applier, slotWriter, rememberManager, operationErrorContext);
    }

    public final int getSize() {
        return this.operations.getSize();
    }

    public final boolean isEmpty() {
        return this.operations.isEmpty();
    }

    public final boolean isNotEmpty() {
        return this.operations.isNotEmpty();
    }

    @Override // androidx.compose.runtime.changelist.OperationsDebugStringFormattable
    public String toDebugString(String str) {
        StringBuilder sb = new StringBuilder();
        sb.append("FixupList instance containing " + getSize() + " operations");
        if (sb.length() > 0) {
            sb.append(":\n" + this.operations.toDebugString(str));
        }
        String string = sb.toString();
        o.g(string, "toString(...)");
        return string;
    }

    public final <V, T> void updateNode(V v3, e eVar) {
        Operations operations = this.operations;
        Operation.UpdateNode updateNode = Operation.UpdateNode.INSTANCE;
        operations.pushOp(updateNode);
        Operations operationsM143constructorimpl = Operations.WriteScope.m143constructorimpl(operations);
        Operations.WriteScope.m151setObjectDKhxnng(operationsM143constructorimpl, Operation.ObjectParameter.m120constructorimpl(0), v3);
        int iM120constructorimpl = Operation.ObjectParameter.m120constructorimpl(1);
        o.f(eVar, "null cannot be cast to non-null type @[ExtensionFunctionType] kotlin.Function2<kotlin.Any?, kotlin.Any?, kotlin.Unit>");
        F.c(2, eVar);
        Operations.WriteScope.m151setObjectDKhxnng(operationsM143constructorimpl, iM120constructorimpl, eVar);
        operations.ensureAllArgumentsPushedFor(updateNode);
    }
}
