package com.strmr.ps.ui.lockout;

import com.strmr.ps.data.supabase.DeviceManager;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.re6;
import defpackage.s38;
import java.util.List;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.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.ui.lockout.DeviceLockoutViewModel$loadDevices$1", f = "DeviceLockoutViewModel.kt", i = {}, l = {62}, m = "invokeSuspend", n = {}, s = {})
final class a extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ DeviceLockoutViewModel b;
    public final /* synthetic */ String c;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public a(DeviceLockoutViewModel deviceLockoutViewModel, String str, Continuation continuation) {
        super(2, continuation);
        this.b = deviceLockoutViewModel;
        this.c = str;
    }

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

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

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Object invokeSuspend(Object obj) {
        DeviceLockoutViewModel deviceLockoutViewModel = this.b;
        DeviceManager deviceManager = deviceLockoutViewModel.a;
        re6 re6Var = deviceLockoutViewModel.d;
        re6 re6Var2 = deviceLockoutViewModel.h;
        ck1 ck1Var = ck1.a;
        int i = this.a;
        try {
        } catch (Exception e) {
            String message = e.getMessage();
            if (message == null) {
                message = "Failed to load devices";
            }
            re6Var2.l(message);
        }
        if (i == 0) {
            s38.b(obj);
            re6Var.l(Boxing.boxBoolean(true));
            re6Var2.l(null);
            String strF = this.c;
            if (strF == null) {
                strF = deviceManager.f();
            }
            if (strF == null) {
                re6Var2.l("No active session found");
                re6Var.l(Boxing.boxBoolean(false));
                return e6a.a;
            }
            deviceLockoutViewModel.j = strF;
            this.a = 1;
            obj = deviceManager.d(strF, this);
            if (obj == ck1Var) {
                return ck1Var;
            }
        } else {
            if (i != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
        }
        deviceLockoutViewModel.b.l((List) obj);
        re6Var.l(Boxing.boxBoolean(false));
        return e6a.a;
    }
}
