package androidx.compose.foundation.lazy.layout; import androidx.compose.foundation.gestures.Orientation; import androidx.compose.runtime.Composer; import androidx.compose.runtime.ComposerKt; import androidx.compose.runtime.CompositionScopedCoroutineScopeCanceller; import androidx.compose.runtime.EffectsKt; import androidx.compose.ui.Modifier; import androidx.compose.ui.semantics.CollectionInfo; import androidx.compose.ui.semantics.ScrollAxisRange; import androidx.compose.ui.semantics.SemanticsModifierKt; import androidx.compose.ui.semantics.SemanticsPropertiesKt; import androidx.compose.ui.semantics.SemanticsPropertyReceiver; import io.sentry.protocol.Device; import io.sentry.protocol.SentryThread; import kotlin.Metadata; import kotlin.ResultKt; import kotlin.Unit; import kotlin.coroutines.Continuation; import kotlin.coroutines.EmptyCoroutineContext; import kotlin.coroutines.intrinsics.IntrinsicsKt; import kotlin.coroutines.jvm.internal.DebugMetadata; import kotlin.coroutines.jvm.internal.SuspendLambda; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.functions.Function2; import kotlin.jvm.internal.Intrinsics; import kotlinx.coroutines.BuildersKt__Builders_commonKt; import kotlinx.coroutines.CoroutineScope; /* compiled from: LazyLayoutSemantics.kt */ @Metadata(d1 = {"\u0000&\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\u001a?\u0010\u0000\u001a\u00020\u0001*\u00020\u00012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\nH\u0001¢\u0006\u0002\u0010\f¨\u0006\r"}, d2 = {"lazyLayoutSemantics", "Landroidx/compose/ui/Modifier;", "itemProviderLambda", "Lkotlin/Function0;", "Landroidx/compose/foundation/lazy/layout/LazyLayoutItemProvider;", SentryThread.JsonKeys.STATE, "Landroidx/compose/foundation/lazy/layout/LazyLayoutSemanticState;", Device.JsonKeys.ORIENTATION, "Landroidx/compose/foundation/gestures/Orientation;", "userScrollEnabled", "", "reverseScrolling", "(Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function0;Landroidx/compose/foundation/lazy/layout/LazyLayoutSemanticState;Landroidx/compose/foundation/gestures/Orientation;ZZLandroidx/compose/runtime/Composer;I)Landroidx/compose/ui/Modifier;", "foundation_release"}, k = 2, mv = {1, 8, 0}, xi = 48) /* loaded from: classes.dex */ public final class LazyLayoutSemanticsKt { public static final Modifier lazyLayoutSemantics(Modifier modifier, final Function0 itemProviderLambda, final LazyLayoutSemanticState state, Orientation orientation, boolean z, boolean z2, Composer composer, int i) { Intrinsics.checkNotNullParameter(modifier, ""); Intrinsics.checkNotNullParameter(itemProviderLambda, "itemProviderLambda"); Intrinsics.checkNotNullParameter(state, "state"); Intrinsics.checkNotNullParameter(orientation, "orientation"); composer.startReplaceableGroup(1070136913); ComposerKt.sourceInformation(composer, "C(lazyLayoutSemantics)P(!1,3!1,4)47@1936L24,49@1991L3667:LazyLayoutSemantics.kt#wow0x6"); if (ComposerKt.isTraceInProgress()) { ComposerKt.traceEventStart(1070136913, i, -1, "androidx.compose.foundation.lazy.layout.lazyLayoutSemantics (LazyLayoutSemantics.kt:40)"); } composer.startReplaceableGroup(773894976); ComposerKt.sourceInformation(composer, "CC(rememberCoroutineScope)488@20446L144:Effects.kt#9igjgp"); composer.startReplaceableGroup(-492369756); ComposerKt.sourceInformation(composer, "CC(remember):Composables.kt#9igjgp"); Object rememberedValue = composer.rememberedValue(); if (rememberedValue == Composer.INSTANCE.getEmpty()) { CompositionScopedCoroutineScopeCanceller compositionScopedCoroutineScopeCanceller = new CompositionScopedCoroutineScopeCanceller(EffectsKt.createCompositionCoroutineScope(EmptyCoroutineContext.INSTANCE, composer)); composer.updateRememberedValue(compositionScopedCoroutineScopeCanceller); rememberedValue = compositionScopedCoroutineScopeCanceller; } composer.endReplaceableGroup(); final CoroutineScope coroutineScope = ((CompositionScopedCoroutineScopeCanceller) rememberedValue).getCoroutineScope(); composer.endReplaceableGroup(); Object[] objArr = {itemProviderLambda, state, orientation, Boolean.valueOf(z)}; composer.startReplaceableGroup(-568225417); ComposerKt.sourceInformation(composer, "CC(remember)P(1):Composables.kt#9igjgp"); boolean z3 = false; for (int i2 = 0; i2 < 4; i2++) { z3 |= composer.changed(objArr[i2]); } Object rememberedValue2 = composer.rememberedValue(); if (z3 || rememberedValue2 == Composer.INSTANCE.getEmpty()) { final boolean z4 = orientation == Orientation.Vertical; final Function1 function1 = new Function1() { // from class: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$indexForKeyMapping$1 /* 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(1); } /* JADX WARN: Can't rename method to resolve collision */ @Override // kotlin.jvm.functions.Function1 public final Integer invoke(Object needle) { Intrinsics.checkNotNullParameter(needle, "needle"); LazyLayoutItemProvider invoke = itemProviderLambda.invoke(); int itemCount = invoke.getItemCount(); int i3 = 0; while (true) { if (i3 >= itemCount) { i3 = -1; break; } if (Intrinsics.areEqual(invoke.getKey(i3), needle)) { break; } i3++; } return Integer.valueOf(i3); } }; final ScrollAxisRange scrollAxisRange = new ScrollAxisRange(new Function0() { // from class: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$accessibilityScrollState$1 /* JADX INFO: Access modifiers changed from: package-private */ { super(0); } /* JADX WARN: Can't rename method to resolve collision */ @Override // kotlin.jvm.functions.Function0 public final Float invoke() { return Float.valueOf(LazyLayoutSemanticState.this.getCurrentPosition()); } }, new Function0() { // from class: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$accessibilityScrollState$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(0); } /* JADX WARN: Can't rename method to resolve collision */ @Override // kotlin.jvm.functions.Function0 public final Float invoke() { float currentPosition; LazyLayoutItemProvider invoke = itemProviderLambda.invoke(); if (state.getCanScrollForward()) { currentPosition = invoke.getItemCount() + 1.0f; } else { currentPosition = state.getCurrentPosition(); } return Float.valueOf(currentPosition); } }, z2); final Function2 function2 = z ? new Function2() { // from class: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$scrollByAction$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(2); } @Override // kotlin.jvm.functions.Function2 public /* bridge */ /* synthetic */ Boolean invoke(Float f, Float f2) { return invoke(f.floatValue(), f2.floatValue()); } public final Boolean invoke(float f, float f2) { if (z4) { f = f2; } BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new AnonymousClass1(state, f, null), 3, null); return true; } /* JADX INFO: Access modifiers changed from: package-private */ /* compiled from: LazyLayoutSemantics.kt */ @Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\u008a@"}, d2 = {"", "", "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {1, 8, 0}, xi = 48) @DebugMetadata(c = "androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$scrollByAction$1$1", f = "LazyLayoutSemantics.kt", i = {}, l = {99}, m = "invokeSuspend", n = {}, s = {}) /* renamed from: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$scrollByAction$1$1, reason: invalid class name */ /* loaded from: classes.dex */ public static final class AnonymousClass1 extends SuspendLambda implements Function2, Object> { final /* synthetic */ float $delta; final /* synthetic */ LazyLayoutSemanticState $state; int label; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ AnonymousClass1(LazyLayoutSemanticState lazyLayoutSemanticState, float f, Continuation continuation) { super(2, continuation); this.$state = lazyLayoutSemanticState; this.$delta = f; } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Continuation create(Object obj, Continuation continuation) { return new AnonymousClass1(this.$state, this.$delta, continuation); } @Override // kotlin.jvm.functions.Function2 public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) { return ((AnonymousClass1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE); } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Object invokeSuspend(Object obj) { Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED(); int i = this.label; if (i == 0) { ResultKt.throwOnFailure(obj); this.label = 1; if (this.$state.animateScrollBy(this.$delta, this) == coroutine_suspended) { return coroutine_suspended; } } else { if (i != 1) { throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine"); } ResultKt.throwOnFailure(obj); } return Unit.INSTANCE; } } } : null; final Function1 function12 = z ? new Function1() { // from class: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$scrollToIndexAction$1 /* 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(1); } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Boolean invoke(Integer num) { return invoke(num.intValue()); } public final Boolean invoke(int i3) { LazyLayoutItemProvider invoke = itemProviderLambda.invoke(); if (i3 >= 0 && i3 < invoke.getItemCount()) { BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new AnonymousClass2(state, i3, null), 3, null); return true; } throw new IllegalArgumentException(("Can't scroll to index " + i3 + ", it is out of bounds [0, " + invoke.getItemCount() + ')').toString()); } /* JADX INFO: Access modifiers changed from: package-private */ /* compiled from: LazyLayoutSemantics.kt */ @Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\u008a@"}, d2 = {"", "", "Lkotlinx/coroutines/CoroutineScope;"}, k = 3, mv = {1, 8, 0}, xi = 48) @DebugMetadata(c = "androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$scrollToIndexAction$1$2", f = "LazyLayoutSemantics.kt", i = {}, l = {116}, m = "invokeSuspend", n = {}, s = {}) /* renamed from: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$scrollToIndexAction$1$2, reason: invalid class name */ /* loaded from: classes.dex */ public static final class AnonymousClass2 extends SuspendLambda implements Function2, Object> { final /* synthetic */ int $index; final /* synthetic */ LazyLayoutSemanticState $state; int label; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ AnonymousClass2(LazyLayoutSemanticState lazyLayoutSemanticState, int i, Continuation continuation) { super(2, continuation); this.$state = lazyLayoutSemanticState; this.$index = i; } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Continuation create(Object obj, Continuation continuation) { return new AnonymousClass2(this.$state, this.$index, continuation); } @Override // kotlin.jvm.functions.Function2 public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) { return ((AnonymousClass2) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE); } @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl public final Object invokeSuspend(Object obj) { Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED(); int i = this.label; if (i == 0) { ResultKt.throwOnFailure(obj); this.label = 1; if (this.$state.scrollToItem(this.$index, this) == coroutine_suspended) { return coroutine_suspended; } } else { if (i != 1) { throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine"); } ResultKt.throwOnFailure(obj); } return Unit.INSTANCE; } } } : null; final CollectionInfo collectionInfo = state.collectionInfo(); rememberedValue2 = SemanticsModifierKt.semantics$default(Modifier.INSTANCE, false, new Function1() { // from class: androidx.compose.foundation.lazy.layout.LazyLayoutSemanticsKt$lazyLayoutSemantics$1$1 /* 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(1); } @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(SemanticsPropertyReceiver semanticsPropertyReceiver) { invoke2(semanticsPropertyReceiver); return Unit.INSTANCE; } /* renamed from: invoke, reason: avoid collision after fix types in other method */ public final void invoke2(SemanticsPropertyReceiver semantics) { Intrinsics.checkNotNullParameter(semantics, "$this$semantics"); SemanticsPropertiesKt.setTraversalGroup(semantics, true); SemanticsPropertiesKt.indexForKey(semantics, function1); if (z4) { SemanticsPropertiesKt.setVerticalScrollAxisRange(semantics, scrollAxisRange); } else { SemanticsPropertiesKt.setHorizontalScrollAxisRange(semantics, scrollAxisRange); } Function2 function22 = function2; if (function22 != null) { SemanticsPropertiesKt.scrollBy$default(semantics, null, function22, 1, null); } Function1 function13 = function12; if (function13 != null) { SemanticsPropertiesKt.scrollToIndex$default(semantics, null, function13, 1, null); } SemanticsPropertiesKt.setCollectionInfo(semantics, collectionInfo); } }, 1, null); composer.updateRememberedValue(rememberedValue2); } composer.endReplaceableGroup(); Modifier then = modifier.then((Modifier) rememberedValue2); if (ComposerKt.isTraceInProgress()) { ComposerKt.traceEventEnd(); } composer.endReplaceableGroup(); return then; } }