package com.strmr.ps;

import android.content.SharedPreferences;
import com.strmr.ps.data.repository.DebridLibraryRepository;
import com.strmr.ps.data.repository.PreferencesRepository;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.fi7;
import defpackage.gr3;
import defpackage.kq;
import defpackage.n41;
import defpackage.s38;
import java.util.concurrent.ExecutorService;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.StrmrApp$migrateDebridLibraryFlag$1", f = "StrmrApp.kt", i = {}, l = {376}, m = "invokeSuspend", n = {}, s = {})
final class n extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ StrmrApp b;
    public final /* synthetic */ SharedPreferences c;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public n(StrmrApp strmrApp, SharedPreferences sharedPreferences, Continuation continuation) {
        super(2, continuation);
        this.b = strmrApp;
        this.c = sharedPreferences;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new n(this.b, this.c, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((n) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        ck1 ck1Var = ck1.a;
        int i = this.a;
        StrmrApp strmrApp = this.b;
        try {
            if (i == 0) {
                s38.b(obj);
                DebridLibraryRepository debridLibraryRepository = strmrApp.p;
                if (debridLibraryRepository == null) {
                    cr4.n("debridLibraryRepository");
                    throw null;
                }
                this.a = 1;
                obj = debridLibraryRepository.hasAnyDebridAccount(this);
                if (obj == ck1Var) {
                    return ck1Var;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
            }
            if (((Boolean) obj).booleanValue()) {
                PreferencesRepository preferencesRepository = strmrApp.o;
                if (preferencesRepository == null) {
                    cr4.n("preferencesRepository");
                    throw null;
                }
                preferencesRepository.setShowDebridLibrary(true);
                ExecutorService executorService = kq.a;
                kq.h("StrmrApp", "Migrated: enabled debrid library for existing user");
            }
        } catch (Exception e) {
            n41.ab("Debrid library migration check failed: ", e.getMessage(), "StrmrApp");
        }
        fi7.p(this.c, "debrid_library_flag_migrated", true);
        return e6a.a;
    }
}
