package androidx.compose.foundation.lazy.layout; import androidx.compose.runtime.Composer; import androidx.compose.runtime.ComposerKt; import androidx.compose.runtime.DisposableEffectResult; import androidx.compose.runtime.DisposableEffectScope; import androidx.compose.runtime.EffectsKt; import androidx.compose.runtime.MutableState; import androidx.compose.runtime.RecomposeScopeImplKt; import androidx.compose.runtime.ScopeUpdateScope; import androidx.compose.runtime.SnapshotStateKt__SnapshotStateKt; import androidx.compose.runtime.saveable.SaveableStateHolder; import androidx.compose.runtime.saveable.SaveableStateRegistry; import androidx.compose.runtime.saveable.SaveableStateRegistryKt; import androidx.compose.runtime.saveable.Saver; import androidx.compose.runtime.saveable.SaverKt; import androidx.compose.runtime.saveable.SaverScope; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import kotlin.Metadata; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* compiled from: LazySaveableStateHolder.kt */ @Metadata(d1 = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\u0010 \n\u0002\u0010\u0000\n\u0002\b\u0004\n\u0002\u0010#\n\u0002\b\t\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0002\u0018\u0000 &2\u00020\u00012\u00020\u0002:\u0001&B/\b\u0016\u0012\b\u0010\u0003\u001a\u0004\u0018\u00010\u0001\u0012\u001c\u0010\u0004\u001a\u0018\u0012\u0004\u0012\u00020\u0006\u0012\f\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\b0\u0007\u0018\u00010\u0005¢\u0006\u0002\u0010\tB\r\u0012\u0006\u0010\n\u001a\u00020\u0001¢\u0006\u0002\u0010\u000bJ(\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\b2\u0011\u0010\u0019\u001a\r\u0012\u0004\u0012\u00020\u00170\u001a¢\u0006\u0002\b\u001bH\u0017¢\u0006\u0002\u0010\u001cJ\u0011\u0010\u001d\u001a\u00020\u001e2\u0006\u0010\u001f\u001a\u00020\bH\u0096\u0001J\u0013\u0010 \u001a\u0004\u0018\u00010\b2\u0006\u0010\u0018\u001a\u00020\u0006H\u0096\u0001J\u001c\u0010!\u001a\u0016\u0012\u0004\u0012\u00020\u0006\u0012\f\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\b0\u00070\u0005H\u0016J!\u0010\"\u001a\u00020#2\u0006\u0010\u0018\u001a\u00020\u00062\u000e\u0010$\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\b0\u001aH\u0096\u0001J\u0010\u0010%\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\bH\u0016R\u0014\u0010\f\u001a\b\u0012\u0004\u0012\u00020\b0\rX\u0082\u0004¢\u0006\u0002\n\u0000R/\u0010\u000f\u001a\u0004\u0018\u00010\u00022\b\u0010\u000e\u001a\u0004\u0018\u00010\u00028F@FX\u0086\u008e\u0002¢\u0006\u0012\n\u0004\b\u0014\u0010\u0015\u001a\u0004\b\u0010\u0010\u0011\"\u0004\b\u0012\u0010\u0013R\u000e\u0010\n\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006'"}, d2 = {"Landroidx/compose/foundation/lazy/layout/LazySaveableStateHolder;", "Landroidx/compose/runtime/saveable/SaveableStateRegistry;", "Landroidx/compose/runtime/saveable/SaveableStateHolder;", "parentRegistry", "restoredValues", "", "", "", "", "(Landroidx/compose/runtime/saveable/SaveableStateRegistry;Ljava/util/Map;)V", "wrappedRegistry", "(Landroidx/compose/runtime/saveable/SaveableStateRegistry;)V", "previouslyComposedKeys", "", "", "wrappedHolder", "getWrappedHolder", "()Landroidx/compose/runtime/saveable/SaveableStateHolder;", "setWrappedHolder", "(Landroidx/compose/runtime/saveable/SaveableStateHolder;)V", "wrappedHolder$delegate", "Landroidx/compose/runtime/MutableState;", "SaveableStateProvider", "", "key", "content", "Lkotlin/Function0;", "Landroidx/compose/runtime/Composable;", "(Ljava/lang/Object;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V", "canBeSaved", "", "value", "consumeRestored", "performSave", "registerProvider", "Landroidx/compose/runtime/saveable/SaveableStateRegistry$Entry;", "valueProvider", "removeState", "Companion", "foundation_release"}, k = 1, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ final class LazySaveableStateHolder implements SaveableStateRegistry, SaveableStateHolder { /* renamed from: Companion, reason: from kotlin metadata */ public static final Companion INSTANCE = new Companion(null); private final Set previouslyComposedKeys; /* renamed from: wrappedHolder$delegate, reason: from kotlin metadata */ private final MutableState wrappedHolder; private final SaveableStateRegistry wrappedRegistry; @Override // androidx.compose.runtime.saveable.SaveableStateRegistry public boolean canBeSaved(Object value) { Intrinsics.checkNotNullParameter(value, "value"); return this.wrappedRegistry.canBeSaved(value); } @Override // androidx.compose.runtime.saveable.SaveableStateRegistry public Object consumeRestored(String key) { Intrinsics.checkNotNullParameter(key, "key"); return this.wrappedRegistry.consumeRestored(key); } @Override // androidx.compose.runtime.saveable.SaveableStateRegistry public SaveableStateRegistry.Entry registerProvider(String key, Function0 valueProvider) { Intrinsics.checkNotNullParameter(key, "key"); Intrinsics.checkNotNullParameter(valueProvider, "valueProvider"); return this.wrappedRegistry.registerProvider(key, valueProvider); } public LazySaveableStateHolder(SaveableStateRegistry wrappedRegistry) { MutableState mutableStateOf$default; Intrinsics.checkNotNullParameter(wrappedRegistry, "wrappedRegistry"); this.wrappedRegistry = wrappedRegistry; mutableStateOf$default = SnapshotStateKt__SnapshotStateKt.mutableStateOf$default(null, null, 2, null); this.wrappedHolder = mutableStateOf$default; this.previouslyComposedKeys = new LinkedHashSet(); } public LazySaveableStateHolder(final SaveableStateRegistry saveableStateRegistry, Map> map) { this(SaveableStateRegistryKt.SaveableStateRegistry(map, new Function1() { // from class: androidx.compose.foundation.lazy.layout.LazySaveableStateHolder.1 { super(1); } /* JADX WARN: Can't rename method to resolve collision */ @Override // kotlin.jvm.functions.Function1 public final Boolean invoke(Object it) { Intrinsics.checkNotNullParameter(it, "it"); SaveableStateRegistry saveableStateRegistry2 = SaveableStateRegistry.this; return Boolean.valueOf(saveableStateRegistry2 != null ? saveableStateRegistry2.canBeSaved(it) : true); } })); } public final SaveableStateHolder getWrappedHolder() { return (SaveableStateHolder) this.wrappedHolder.getValue(); } @Override // androidx.compose.runtime.saveable.SaveableStateRegistry public Map> performSave() { SaveableStateHolder wrappedHolder = getWrappedHolder(); if (wrappedHolder != null) { Iterator it = this.previouslyComposedKeys.iterator(); while (it.hasNext()) { wrappedHolder.removeState(it.next()); } } return this.wrappedRegistry.performSave(); } @Override // androidx.compose.runtime.saveable.SaveableStateHolder public void SaveableStateProvider(final Object key, final Function2 content, Composer composer, final int i) { Intrinsics.checkNotNullParameter(key, "key"); Intrinsics.checkNotNullParameter(content, "content"); Composer startRestartGroup = composer.startRestartGroup(-697180401); ComposerKt.sourceInformation(startRestartGroup, "C(SaveableStateProvider)P(1)83@3415L35,84@3459L159:LazySaveableStateHolder.kt#wow0x6"); if (ComposerKt.isTraceInProgress()) { ComposerKt.traceEventStart(-697180401, i, -1, "androidx.compose.foundation.lazy.layout.LazySaveableStateHolder.SaveableStateProvider (LazySaveableStateHolder.kt:82)"); } SaveableStateHolder wrappedHolder = getWrappedHolder(); if (wrappedHolder == null) { throw new IllegalArgumentException("Required value was null.".toString()); } wrappedHolder.SaveableStateProvider(key, content, startRestartGroup, (i & 112) | 520); EffectsKt.DisposableEffect(key, new Function1() { // from class: androidx.compose.foundation.lazy.layout.LazySaveableStateHolder$SaveableStateProvider$1 /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ { super(1); } @Override // kotlin.jvm.functions.Function1 public final DisposableEffectResult invoke(DisposableEffectScope DisposableEffect) { Set set; Intrinsics.checkNotNullParameter(DisposableEffect, "$this$DisposableEffect"); set = LazySaveableStateHolder.this.previouslyComposedKeys; set.remove(key); final LazySaveableStateHolder lazySaveableStateHolder = LazySaveableStateHolder.this; final Object obj = key; return new DisposableEffectResult() { // from class: androidx.compose.foundation.lazy.layout.LazySaveableStateHolder$SaveableStateProvider$1$invoke$$inlined$onDispose$1 @Override // androidx.compose.runtime.DisposableEffectResult public void dispose() { Set set2; set2 = LazySaveableStateHolder.this.previouslyComposedKeys; set2.add(obj); } }; } }, startRestartGroup, 8); if (ComposerKt.isTraceInProgress()) { ComposerKt.traceEventEnd(); } ScopeUpdateScope endRestartGroup = startRestartGroup.endRestartGroup(); if (endRestartGroup == null) { return; } endRestartGroup.updateScope(new Function2() { // from class: androidx.compose.foundation.lazy.layout.LazySaveableStateHolder$SaveableStateProvider$2 /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ /* JADX WARN: Multi-variable type inference failed */ { super(2); } @Override // kotlin.jvm.functions.Function2 public /* bridge */ /* synthetic */ Unit invoke(Composer composer2, Integer num) { invoke(composer2, num.intValue()); return Unit.INSTANCE; } public final void invoke(Composer composer2, int i2) { LazySaveableStateHolder.this.SaveableStateProvider(key, content, composer2, RecomposeScopeImplKt.updateChangedFlags(i | 1)); } }); } @Override // androidx.compose.runtime.saveable.SaveableStateHolder public void removeState(Object key) { Intrinsics.checkNotNullParameter(key, "key"); SaveableStateHolder wrappedHolder = getWrappedHolder(); if (wrappedHolder == null) { throw new IllegalArgumentException("Required value was null.".toString()); } wrappedHolder.removeState(key); } /* compiled from: LazySaveableStateHolder.kt */ @Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\u0010 \n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J0\u0010\u0003\u001a\"\u0012\u0004\u0012\u00020\u0005\u0012\u0018\u0012\u0016\u0012\u0004\u0012\u00020\u0007\u0012\f\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\u00010\b0\u00060\u00042\b\u0010\t\u001a\u0004\u0018\u00010\n¨\u0006\u000b"}, d2 = {"Landroidx/compose/foundation/lazy/layout/LazySaveableStateHolder$Companion;", "", "()V", "saver", "Landroidx/compose/runtime/saveable/Saver;", "Landroidx/compose/foundation/lazy/layout/LazySaveableStateHolder;", "", "", "", "parentRegistry", "Landroidx/compose/runtime/saveable/SaveableStateRegistry;", "foundation_release"}, k = 1, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } public final Saver>> saver(final SaveableStateRegistry parentRegistry) { return SaverKt.Saver(new Function2>>() { // from class: androidx.compose.foundation.lazy.layout.LazySaveableStateHolder$Companion$saver$1 @Override // kotlin.jvm.functions.Function2 public final Map> invoke(SaverScope Saver, LazySaveableStateHolder it) { Intrinsics.checkNotNullParameter(Saver, "$this$Saver"); Intrinsics.checkNotNullParameter(it, "it"); Map> performSave = it.performSave(); if (performSave.isEmpty()) { return null; } return performSave; } }, new Function1>, LazySaveableStateHolder>() { // from class: androidx.compose.foundation.lazy.layout.LazySaveableStateHolder$Companion$saver$2 /* JADX INFO: Access modifiers changed from: package-private */ { super(1); } @Override // kotlin.jvm.functions.Function1 public final LazySaveableStateHolder invoke(Map> restored) { Intrinsics.checkNotNullParameter(restored, "restored"); return new LazySaveableStateHolder(SaveableStateRegistry.this, restored); } }); } } public final void setWrappedHolder(SaveableStateHolder saveableStateHolder) { this.wrappedHolder.setValue(saveableStateHolder); } }