package androidx.compose.ui.modifier; import androidx.compose.runtime.collection.MutableVector; import androidx.compose.ui.Modifier; import androidx.compose.ui.node.BackwardsCompatNode; import androidx.compose.ui.node.DelegatableNodeKt; import androidx.compose.ui.node.DelegatingNode; import androidx.compose.ui.node.LayoutNode; import androidx.compose.ui.node.NodeKind; import androidx.compose.ui.node.Owner; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import kotlin.Metadata; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.internal.Intrinsics; /* compiled from: ModifierLocalManager.kt */ @Metadata(d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010#\n\u0002\b\u0004\b\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u001a\u0010\u0011\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u00072\n\u0010\u0014\u001a\u0006\u0012\u0002\b\u00030\tJ\u0006\u0010\u0015\u001a\u00020\u0012J*\u0010\u0016\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u00172\n\u0010\u0014\u001a\u0006\u0012\u0002\b\u00030\t2\f\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u00070\u0019H\u0002J\u001a\u0010\u001a\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u00072\n\u0010\u0014\u001a\u0006\u0012\u0002\b\u00030\tJ\u0006\u0010\u001b\u001a\u00020\u0012J\u001a\u0010\u001c\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u00072\n\u0010\u0014\u001a\u0006\u0012\u0002\b\u00030\tR\u0014\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u0018\u0010\b\u001a\f\u0012\b\u0012\u0006\u0012\u0002\b\u00030\t0\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\f\u0010\rR\u0014\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\u000f0\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u0018\u0010\u0010\u001a\f\u0012\b\u0012\u0006\u0012\u0002\b\u00030\t0\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u001d"}, d2 = {"Landroidx/compose/ui/modifier/ModifierLocalManager;", "", "owner", "Landroidx/compose/ui/node/Owner;", "(Landroidx/compose/ui/node/Owner;)V", "inserted", "Landroidx/compose/runtime/collection/MutableVector;", "Landroidx/compose/ui/node/BackwardsCompatNode;", "insertedLocal", "Landroidx/compose/ui/modifier/ModifierLocal;", "invalidated", "", "getOwner", "()Landroidx/compose/ui/node/Owner;", "removed", "Landroidx/compose/ui/node/LayoutNode;", "removedLocal", "insertedProvider", "", "node", "key", "invalidate", "invalidateConsumersOfNodeForKey", "Landroidx/compose/ui/Modifier$Node;", "set", "", "removedProvider", "triggerUpdates", "updatedProvider", "ui_release"}, k = 1, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ public final class ModifierLocalManager { private final MutableVector inserted; private final MutableVector> insertedLocal; private boolean invalidated; private final Owner owner; private final MutableVector removed; private final MutableVector> removedLocal; public final Owner getOwner() { return this.owner; } public ModifierLocalManager(Owner owner) { Intrinsics.checkNotNullParameter(owner, "owner"); this.owner = owner; this.inserted = new MutableVector<>(new BackwardsCompatNode[16], 0); this.insertedLocal = new MutableVector<>(new ModifierLocal[16], 0); this.removed = new MutableVector<>(new LayoutNode[16], 0); this.removedLocal = new MutableVector<>(new ModifierLocal[16], 0); } public final void invalidate() { if (this.invalidated) { return; } this.invalidated = true; this.owner.registerOnEndApplyChangesListener(new Function0() { // from class: androidx.compose.ui.modifier.ModifierLocalManager$invalidate$1 /* JADX INFO: Access modifiers changed from: package-private */ { super(0); } @Override // kotlin.jvm.functions.Function0 public /* bridge */ /* synthetic */ Unit invoke() { invoke2(); return Unit.INSTANCE; } /* renamed from: invoke, reason: avoid collision after fix types in other method */ public final void invoke2() { ModifierLocalManager.this.triggerUpdates(); } }); } public final void triggerUpdates() { int i = 0; this.invalidated = false; HashSet hashSet = new HashSet(); MutableVector mutableVector = this.removed; int size = mutableVector.getSize(); if (size > 0) { LayoutNode[] content = mutableVector.getContent(); int i2 = 0; do { LayoutNode layoutNode = content[i2]; ModifierLocal modifierLocal = this.removedLocal.getContent()[i2]; if (layoutNode.getNodes().getHead().getIsAttached()) { invalidateConsumersOfNodeForKey(layoutNode.getNodes().getHead(), modifierLocal, hashSet); } i2++; } while (i2 < size); } this.removed.clear(); this.removedLocal.clear(); MutableVector mutableVector2 = this.inserted; int size2 = mutableVector2.getSize(); if (size2 > 0) { BackwardsCompatNode[] content2 = mutableVector2.getContent(); do { BackwardsCompatNode backwardsCompatNode = content2[i]; ModifierLocal modifierLocal2 = this.insertedLocal.getContent()[i]; if (backwardsCompatNode.getIsAttached()) { invalidateConsumersOfNodeForKey(backwardsCompatNode, modifierLocal2, hashSet); } i++; } while (i < size2); } this.inserted.clear(); this.insertedLocal.clear(); Iterator it = hashSet.iterator(); while (it.hasNext()) { ((BackwardsCompatNode) it.next()).updateModifierLocalConsumer(); } } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r14v0, types: [java.util.Set, java.util.Set] */ /* JADX WARN: Type inference failed for: r6v0 */ /* JADX WARN: Type inference failed for: r6v1, types: [androidx.compose.ui.Modifier$Node] */ /* JADX WARN: Type inference failed for: r6v10 */ /* JADX WARN: Type inference failed for: r6v11 */ /* JADX WARN: Type inference failed for: r6v12 */ /* JADX WARN: Type inference failed for: r6v13 */ /* JADX WARN: Type inference failed for: r6v14 */ /* JADX WARN: Type inference failed for: r6v6 */ /* JADX WARN: Type inference failed for: r6v7, types: [androidx.compose.ui.Modifier$Node] */ /* JADX WARN: Type inference failed for: r6v8, types: [java.lang.Object] */ /* JADX WARN: Type inference failed for: r6v9 */ private final void invalidateConsumersOfNodeForKey(Modifier.Node node, ModifierLocal key, Set set) { Modifier.Node node2 = node; int m4091constructorimpl = NodeKind.m4091constructorimpl(32); if (!node2.getNode().getIsAttached()) { throw new IllegalStateException("visitSubtreeIf called on an unattached node".toString()); } MutableVector mutableVector = new MutableVector(new Modifier.Node[16], 0); Modifier.Node child = node2.getNode().getChild(); if (child == null) { DelegatableNodeKt.addLayoutNodeChildren(mutableVector, node2.getNode()); } else { mutableVector.add(child); } while (mutableVector.isNotEmpty()) { Modifier.Node node3 = (Modifier.Node) mutableVector.removeAt(mutableVector.getSize() - 1); if ((node3.getAggregateChildKindSet() & m4091constructorimpl) != 0) { for (Modifier.Node node4 = node3; node4 != null; node4 = node4.getChild()) { if ((node4.getKindSet() & m4091constructorimpl) != 0) { DelegatingNode delegatingNode = node4; MutableVector mutableVector2 = null; while (delegatingNode != 0) { if (delegatingNode instanceof ModifierLocalModifierNode) { ModifierLocalModifierNode modifierLocalModifierNode = (ModifierLocalModifierNode) delegatingNode; if (modifierLocalModifierNode instanceof BackwardsCompatNode) { BackwardsCompatNode backwardsCompatNode = (BackwardsCompatNode) modifierLocalModifierNode; if ((backwardsCompatNode.getElement() instanceof ModifierLocalConsumer) && backwardsCompatNode.getReadValues().contains(key)) { set.add(modifierLocalModifierNode); } } if (!(!modifierLocalModifierNode.getProvidedValues().contains$ui_release(key))) { break; } } else if ((delegatingNode.getKindSet() & m4091constructorimpl) != 0 && (delegatingNode instanceof DelegatingNode)) { Modifier.Node delegate = delegatingNode.getDelegate(); int i = 0; delegatingNode = delegatingNode; while (delegate != null) { if ((delegate.getKindSet() & m4091constructorimpl) != 0) { i++; if (i == 1) { delegatingNode = delegate; } else { if (mutableVector2 == null) { mutableVector2 = new MutableVector(new Modifier.Node[16], 0); } if (delegatingNode != 0) { if (mutableVector2 != null) { mutableVector2.add(delegatingNode); } delegatingNode = 0; } if (mutableVector2 != null) { mutableVector2.add(delegate); } } } delegate = delegate.getChild(); delegatingNode = delegatingNode; } if (i == 1) { } } delegatingNode = DelegatableNodeKt.pop(mutableVector2); } } } } DelegatableNodeKt.addLayoutNodeChildren(mutableVector, node3); } } public final void removedProvider(BackwardsCompatNode node, ModifierLocal key) { Intrinsics.checkNotNullParameter(node, "node"); Intrinsics.checkNotNullParameter(key, "key"); this.removed.add(DelegatableNodeKt.requireLayoutNode(node)); this.removedLocal.add(key); invalidate(); } public final void updatedProvider(BackwardsCompatNode node, ModifierLocal key) { Intrinsics.checkNotNullParameter(node, "node"); Intrinsics.checkNotNullParameter(key, "key"); this.inserted.add(node); this.insertedLocal.add(key); invalidate(); } public final void insertedProvider(BackwardsCompatNode node, ModifierLocal key) { Intrinsics.checkNotNullParameter(node, "node"); Intrinsics.checkNotNullParameter(key, "key"); this.inserted.add(node); this.insertedLocal.add(key); invalidate(); } }