package com.vinfast.companion.corecompose;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes15.dex */
@kotlin.Metadata(d1 = {"\u0000P\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\u001a\u0080\u0001\u0010\u0011\u001a\u00020\u000e\"\b\b\u0000\u0010\u0001*\u00020\u0000\"\b\b\u0001\u0010\u0003*\u00020\u0002\"\b\b\u0002\u0010\u0005*\u00020\u0004*\u0014\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u0001\u0012\u0004\u0012\u00028\u00020\u00062\b\b\u0002\u0010\b\u001a\u00020\u000721\u0010\u0010\u001a-\b\u0001\u0012\u0013\u0012\u00118\u0002¢\u0006\f\b\n\u0012\b\b\u000b\u0012\u0004\b\b(\f\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u000e0\r\u0012\u0006\u0012\u0004\u0018\u00010\u000f0\tH\u0007¢\u0006\u0004\b\u0011\u0010\u0012\u001aK\u0010\u0015\u001a\u00020\u000e\"\b\b\u0000\u0010\u0001*\u00020\u0000\"\b\b\u0001\u0010\u0003*\u00020\u0002\"\b\b\u0002\u0010\u0005*\u00020\u0004*\u0014\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u0001\u0012\u0004\u0012\u00028\u00020\u00062\u0006\u0010\u0014\u001a\u00020\u0013H\u0007¢\u0006\u0004\b\u0015\u0010\u0016\u001aS\u0010\u0018\u001a\b\u0012\u0004\u0012\u00028\u00010\u0017\"\b\b\u0000\u0010\u0001*\u00020\u0000\"\b\b\u0001\u0010\u0003*\u00020\u0002\"\b\b\u0002\u0010\u0005*\u00020\u0004*\u0014\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00028\u0001\u0012\u0004\u0012\u00028\u00020\u00062\b\b\u0002\u0010\b\u001a\u00020\u0007H\u0007¢\u0006\u0004\b\u0018\u0010\u0019\u001a/\u0010\u001c\u001a\b\u0012\u0004\u0012\u00028\u00000\u0017\"\u0004\b\u0000\u0010\u001a*\b\u0012\u0004\u0012\u00028\u00000\u001b2\b\b\u0002\u0010\b\u001a\u00020\u0007H\u0003¢\u0006\u0004\b\u001c\u0010\u001d¨\u0006\u001e"}, d2 = {"Lcom/vinfast/companion/corecompose/BaseAction;", "A", "Lcom/vinfast/companion/corecompose/BaseState;", "S", "Lcom/vinfast/companion/corecompose/BaseEvent;", "E", "Lcom/vinfast/companion/corecompose/BaseViewModel;", "Landroidx/lifecycle/Lifecycle$State;", "lifecycleState", "Lkotlin/Function2;", "Lkotlin/ParameterName;", "name", "event", "Lkotlin/coroutines/Continuation;", "", "", "eventHandler", "c", "(Lcom/vinfast/companion/corecompose/BaseViewModel;Landroidx/lifecycle/Lifecycle$State;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V", "Lcom/vinfast/companion/corecompose/Controller;", "controller", "g", "(Lcom/vinfast/companion/corecompose/BaseViewModel;Lcom/vinfast/companion/corecompose/Controller;Landroidx/compose/runtime/Composer;I)V", "Landroidx/compose/runtime/State;", "e", "(Lcom/vinfast/companion/corecompose/BaseViewModel;Landroidx/lifecycle/Lifecycle$State;Landroidx/compose/runtime/Composer;II)Landroidx/compose/runtime/State;", "T", "Lkotlinx/coroutines/flow/StateFlow;", "f", "(Lkotlinx/coroutines/flow/StateFlow;Landroidx/lifecycle/Lifecycle$State;Landroidx/compose/runtime/Composer;II)Landroidx/compose/runtime/State;", "core-compose_release"}, k = 2, mv = {2, 2, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class BaseComposeViewModelKt {
    public static final void c(final com.vinfast.companion.corecompose.BaseViewModel baseViewModel, androidx.lifecycle.Lifecycle.State state, final kotlin.jvm.functions.Function2 function2, androidx.compose.runtime.Composer composer, final int i, final int i2) {
        int i3;
        final androidx.lifecycle.Lifecycle.State state2;
        androidx.lifecycle.LifecycleOwner lifecycleOwner;
        kotlin.jvm.internal.Intrinsics.l(baseViewModel, "<this>");
        kotlin.jvm.internal.Intrinsics.l(function2, "eventHandler");
        androidx.compose.runtime.Composer composerB = composer.B(1161087182);
        if ((i & 6) == 0) {
            i3 = (composerB.P(baseViewModel) ? 4 : 2) | i;
        } else {
            i3 = i;
        }
        int i4 = i2 & 1;
        if (i4 != 0) {
            i3 |= 48;
        } else if ((i & 48) == 0) {
            i3 |= composerB.x(state == null ? -1 : state.ordinal()) ? 32 : 16;
        }
        if ((i & 384) == 0) {
            i3 |= composerB.P(function2) ? 256 : 128;
        }
        if (composerB.f((i3 & 147) != 146, i3 & 1)) {
            androidx.lifecycle.Lifecycle.State state3 = i4 != 0 ? androidx.lifecycle.Lifecycle.State.STARTED : state;
            if (androidx.compose.runtime.ComposerKt.m()) {
                androidx.compose.runtime.ComposerKt.q(1161087182, i3, -1, "com.vinfast.companion.corecompose.collectEvents (BaseComposeViewModel.kt:181)");
            }
            int i5 = i3;
            androidx.lifecycle.Lifecycle.State state4 = state3;
            kotlinx.coroutines.flow.SharedFlow event = baseViewModel.getEvent();
            androidx.lifecycle.LifecycleOwner lifecycleOwner2 = (androidx.lifecycle.LifecycleOwner) composerB.F(androidx.lifecycle.compose.LocalLifecycleOwnerKt.c());
            boolean zP = composerB.P(lifecycleOwner2) | ((i5 & 112) == 32) | composerB.P(event) | composerB.P(function2);
            java.lang.Object objN = composerB.N();
            if (zP || objN == androidx.compose.runtime.Composer.a.a()) {
                lifecycleOwner = lifecycleOwner2;
                com.vinfast.companion.corecompose.BaseComposeViewModelKt$collectEvents$1$1 baseComposeViewModelKt$collectEvents$1$1 = new com.vinfast.companion.corecompose.BaseComposeViewModelKt$collectEvents$1$1(lifecycleOwner, state4, event, function2, null);
                composerB.H(baseComposeViewModelKt$collectEvents$1$1);
                objN = baseComposeViewModelKt$collectEvents$1$1;
            } else {
                lifecycleOwner = lifecycleOwner2;
            }
            androidx.compose.runtime.EffectsKt.f(event, lifecycleOwner, (kotlin.jvm.functions.Function2) objN, composerB, 0);
            if (androidx.compose.runtime.ComposerKt.m()) {
                androidx.compose.runtime.ComposerKt.p();
            }
            state2 = state4;
        } else {
            composerB.n();
            state2 = state;
        }
        androidx.compose.runtime.ScopeUpdateScope scopeUpdateScopeD = composerB.D();
        if (scopeUpdateScopeD != null) {
            scopeUpdateScopeD.a(new kotlin.jvm.functions.Function2() { // from class: com.vinfast.companion.corecompose.b
                public final java.lang.Object invoke(java.lang.Object obj, java.lang.Object obj2) {
                    return com.vinfast.companion.corecompose.BaseComposeViewModelKt.d(baseViewModel, state2, function2, i, i2, (androidx.compose.runtime.Composer) obj, ((java.lang.Integer) obj2).intValue());
                }
            });
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit d(com.vinfast.companion.corecompose.BaseViewModel baseViewModel, androidx.lifecycle.Lifecycle.State state, kotlin.jvm.functions.Function2 function2, int i, int i2, androidx.compose.runtime.Composer composer, int i3) {
        c(baseViewModel, state, function2, composer, androidx.compose.runtime.RecomposeScopeImplKt.a(i | 1), i2);
        return kotlin.Unit.a;
    }

    public static final androidx.compose.runtime.State e(com.vinfast.companion.corecompose.BaseViewModel baseViewModel, androidx.lifecycle.Lifecycle.State state, androidx.compose.runtime.Composer composer, int i, int i2) {
        kotlin.jvm.internal.Intrinsics.l(baseViewModel, "<this>");
        if ((i2 & 1) != 0) {
            state = androidx.lifecycle.Lifecycle.State.STARTED;
        }
        if (androidx.compose.runtime.ComposerKt.m()) {
            androidx.compose.runtime.ComposerKt.q(530742068, i, -1, "com.vinfast.companion.corecompose.collectState (BaseComposeViewModel.kt:222)");
        }
        androidx.compose.runtime.State stateF = f(baseViewModel.getState(), state, composer, i & 112, 0);
        if (androidx.compose.runtime.ComposerKt.m()) {
            androidx.compose.runtime.ComposerKt.p();
        }
        return stateF;
    }

    private static final androidx.compose.runtime.State f(kotlinx.coroutines.flow.StateFlow stateFlow, androidx.lifecycle.Lifecycle.State state, androidx.compose.runtime.Composer composer, int i, int i2) {
        if ((i2 & 1) != 0) {
            state = androidx.lifecycle.Lifecycle.State.STARTED;
        }
        if (androidx.compose.runtime.ComposerKt.m()) {
            androidx.compose.runtime.ComposerKt.q(-254009376, i, -1, "com.vinfast.companion.corecompose.collectState (BaseComposeViewModel.kt:229)");
        }
        androidx.lifecycle.LifecycleOwner lifecycleOwner = (androidx.lifecycle.LifecycleOwner) composer.F(androidx.lifecycle.compose.LocalLifecycleOwnerKt.c());
        boolean zS = composer.s(stateFlow) | composer.s(lifecycleOwner);
        java.lang.Object objN = composer.N();
        if (zS || objN == androidx.compose.runtime.Composer.a.a()) {
            objN = androidx.lifecycle.FlowExtKt.a(stateFlow, lifecycleOwner.getLifecycle(), state);
            composer.H(objN);
        }
        androidx.compose.runtime.State stateA = androidx.compose.runtime.SnapshotStateKt.a((kotlinx.coroutines.flow.Flow) objN, stateFlow.getValue(), (kotlin.coroutines.CoroutineContext) null, composer, 0, 2);
        if (androidx.compose.runtime.ComposerKt.m()) {
            androidx.compose.runtime.ComposerKt.p();
        }
        return stateA;
    }

    public static final void g(final com.vinfast.companion.corecompose.BaseViewModel baseViewModel, final com.vinfast.companion.corecompose.Controller controller, androidx.compose.runtime.Composer composer, final int i) {
        int i2;
        kotlin.jvm.internal.Intrinsics.l(baseViewModel, "<this>");
        kotlin.jvm.internal.Intrinsics.l(controller, "controller");
        androidx.compose.runtime.Composer composerB = composer.B(-1951884994);
        if ((i & 6) == 0) {
            i2 = (composerB.P(baseViewModel) ? 4 : 2) | i;
        } else {
            i2 = i;
        }
        if ((i & 48) == 0) {
            i2 |= composerB.s(controller) ? 32 : 16;
        }
        if (composerB.f((i2 & 19) != 18, i2 & 1)) {
            if (androidx.compose.runtime.ComposerKt.m()) {
                androidx.compose.runtime.ComposerKt.q(-1951884994, i2, -1, "com.vinfast.companion.corecompose.collectViewModelState (BaseComposeViewModel.kt:195)");
            }
            androidx.lifecycle.LifecycleOwner lifecycleOwner = (androidx.lifecycle.LifecycleOwner) composerB.F(androidx.lifecycle.compose.LocalLifecycleOwnerKt.c());
            kotlinx.coroutines.flow.SharedFlow viewModelState = baseViewModel.getViewModelState();
            boolean zP = composerB.P(baseViewModel) | ((i2 & 112) == 32) | composerB.P(lifecycleOwner);
            java.lang.Object objN = composerB.N();
            if (zP || objN == androidx.compose.runtime.Composer.a.a()) {
                objN = new com.vinfast.companion.corecompose.BaseComposeViewModelKt$collectViewModelState$1$1(baseViewModel, lifecycleOwner, controller, null);
                composerB.H(objN);
            }
            androidx.compose.runtime.EffectsKt.f(viewModelState, lifecycleOwner, (kotlin.jvm.functions.Function2) objN, composerB, 0);
            if (androidx.compose.runtime.ComposerKt.m()) {
                androidx.compose.runtime.ComposerKt.p();
            }
        } else {
            composerB.n();
        }
        androidx.compose.runtime.ScopeUpdateScope scopeUpdateScopeD = composerB.D();
        if (scopeUpdateScopeD != null) {
            scopeUpdateScopeD.a(new kotlin.jvm.functions.Function2() { // from class: com.vinfast.companion.corecompose.c
                public final java.lang.Object invoke(java.lang.Object obj, java.lang.Object obj2) {
                    return com.vinfast.companion.corecompose.BaseComposeViewModelKt.h(baseViewModel, controller, i, (androidx.compose.runtime.Composer) obj, ((java.lang.Integer) obj2).intValue());
                }
            });
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final kotlin.Unit h(com.vinfast.companion.corecompose.BaseViewModel baseViewModel, com.vinfast.companion.corecompose.Controller controller, int i, androidx.compose.runtime.Composer composer, int i2) {
        g(baseViewModel, controller, composer, androidx.compose.runtime.RecomposeScopeImplKt.a(i | 1));
        return kotlin.Unit.a;
    }
}
