package com.vinfast.companion.core.utils;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes15.dex */
@kotlin.Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\t\bÆ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u001f\u0010\u0007\u001a\u00020\u00052\u000e\u0010\u0006\u001a\n\u0012\u0004\u0012\u00020\u0005\u0018\u00010\u0004H\u0002¢\u0006\u0004\b\u0007\u0010\bJ\u001d\u0010\r\u001a\u00020\u00052\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\f\u001a\u00020\u000b¢\u0006\u0004\b\r\u0010\u000eJ\u001f\u0010\u000f\u001a\u00020\u00052\u0010\b\u0002\u0010\u0006\u001a\n\u0012\u0004\u0012\u00020\u0005\u0018\u00010\u0004¢\u0006\u0004\b\u000f\u0010\bR\u0018\u0010\u0011\u001a\u0004\u0018\u00010\t8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\r\u0010\u0010R\u0016\u0010\u0013\u001a\u00020\u000b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u000f\u0010\u0012¨\u0006\u0014"}, d2 = {"Lcom/vinfast/companion/core/utils/GrowthInitializer;", "", "<init>", "()V", "Lkotlin/Function0;", "", "onSdkReady", "a", "(Lkotlin/jvm/functions/Function0;)V", "Landroid/content/Context;", "context", "", "isEnabled", "b", "(Landroid/content/Context;Z)V", "c", "Landroid/content/Context;", "appContext", "Z", "isFeatureEnabled", "core_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class GrowthInitializer {
    public static final com.vinfast.companion.core.utils.GrowthInitializer a = new com.vinfast.companion.core.utils.GrowthInitializer();

    /* JADX INFO: renamed from: b, reason: from kotlin metadata */
    private static volatile android.content.Context appContext;

    /* JADX INFO: renamed from: c, reason: from kotlin metadata */
    private static volatile boolean isFeatureEnabled;

    private GrowthInitializer() {
    }

    private final void a(final kotlin.jvm.functions.Function0 onSdkReady) {
        android.content.Context context = appContext;
        if (context == null) {
            return;
        }
        boolean z = isFeatureEnabled && com.vinfast.companion.core.utils.CAppShared.a.d().e("growth_tracking_allowed", false);
        if (z && vn.vsf.growth.sdk.VGrowthSdk.INSTANCE.isInitialized()) {
            if (onSdkReady != null) {
                onSdkReady.invoke();
            }
        } else {
            if (z) {
                timber.log.Timber.a.a("[VGrowth] consent granted - initialising from manifest", new java.lang.Object[0]);
                vn.vsf.growth.sdk.VGrowthSdk.INSTANCE.initializeFromManifest(context, new vn.vsf.growth.sdk.GrowthInitCallback() { // from class: com.vinfast.companion.core.utils.GrowthInitializer$applyCurrentState$1
                    /* JADX INFO: Thrown type has an unknown type hierarchy: kotlin.NoWhenBranchMatchedException */
                    public void onComplete(vn.vsf.growth.sdk.GrowthInitResult result) throws kotlin.NoWhenBranchMatchedException {
                        kotlin.jvm.internal.Intrinsics.l(result, "result");
                        if (!(result instanceof vn.vsf.growth.sdk.GrowthInitResult.Success)) {
                            if (!(result instanceof vn.vsf.growth.sdk.GrowthInitResult.Failure)) {
                                throw new kotlin.NoWhenBranchMatchedException();
                            }
                            timber.log.Timber.a.q("[VGrowth] initialisation failed: %s", new java.lang.Object[]{((vn.vsf.growth.sdk.GrowthInitResult.Failure) result).getMessage()});
                        } else {
                            kotlin.jvm.functions.Function0 function0 = onSdkReady;
                            if (function0 != null) {
                                function0.invoke();
                            }
                        }
                    }
                });
                return;
            }
            vn.vsf.growth.sdk.VGrowthSdk vGrowthSdk = vn.vsf.growth.sdk.VGrowthSdk.INSTANCE;
            if (vGrowthSdk.isInitialized()) {
                timber.log.Timber.a.a("[VGrowth] consent withheld or feature off - shutting down", new java.lang.Object[0]);
                vGrowthSdk.shutdown();
            }
        }
    }

    public static /* synthetic */ void d(com.vinfast.companion.core.utils.GrowthInitializer growthInitializer, kotlin.jvm.functions.Function0 function0, int i, java.lang.Object obj) {
        if ((i & 1) != 0) {
            function0 = null;
        }
        growthInitializer.c(function0);
    }

    public final void b(android.content.Context context, boolean isEnabled) {
        kotlin.jvm.internal.Intrinsics.l(context, "context");
        appContext = context.getApplicationContext();
        isFeatureEnabled = isEnabled;
        a(null);
    }

    public final void c(kotlin.jvm.functions.Function0 onSdkReady) {
        a(onSdkReady);
    }
}
