package gg;

import androidx.lifecycle.a0;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.module.track.model.PackageItemModel;
import com.amplifyframework.AmplifyException;
import com.amplifyframework.api.ApiException;
import com.amplifyframework.api.aws.AWSApiPlugin;
import com.amplifyframework.api.aws.ApiAuthProviders;
import com.amplifyframework.api.graphql.GraphQLRequest;
import com.amplifyframework.api.graphql.GraphQLResponse;
import com.amplifyframework.api.graphql.PaginatedResult;
import com.amplifyframework.api.graphql.model.ModelMutation;
import com.amplifyframework.api.graphql.model.ModelPagination;
import com.amplifyframework.api.graphql.model.ModelQuery;
import com.amplifyframework.core.Amplify;
import com.amplifyframework.core.AmplifyConfiguration;
import com.amplifyframework.core.Consumer;
import com.amplifyframework.core.model.query.predicate.QueryPredicateOperation;
import com.amplifyframework.core.model.temporal.Temporal;
import com.amplifyframework.datastore.generated.model.TrackItemSource;
import com.amplifyframework.datastore.generated.model.TrackItemType;
import com.amplifyframework.datastore.generated.model.TrackSyncItem;
import java.io.InputStream;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.o0;
import kotlin.jvm.internal.t;
import org.json.JSONObject;
import rm.n0;
import rm.v;
import rm.x;
import rm.y;
import sm.c0;
import sm.p0;
import sm.q0;
import tr.a;

/* loaded from: classes4.dex */
public final class e implements gg.b {

    /* renamed from: g, reason: collision with root package name */
    public static final a f19919g = new a(null);

    /* renamed from: a, reason: collision with root package name */
    private final t7.c f19920a;

    /* renamed from: b, reason: collision with root package name */
    private final g9.d f19921b;

    /* renamed from: c, reason: collision with root package name */
    private boolean f19922c;

    /* renamed from: d, reason: collision with root package name */
    private Temporal.DateTime f19923d;

    /* renamed from: e, reason: collision with root package name */
    private final f0 f19924e;

    /* renamed from: f, reason: collision with root package name */
    private final a0 f19925f;

    /* loaded from: classes4.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    /* loaded from: classes4.dex */
    public /* synthetic */ class b {

        /* renamed from: a, reason: collision with root package name */
        public static final /* synthetic */ int[] f19926a;

        static {
            int[] iArr = new int[RepositoryError.values().length];
            try {
                iArr[RepositoryError.AuthError.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            f19926a = iArr;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class c extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19927p;

        /* renamed from: q, reason: collision with root package name */
        Object f19928q;

        /* renamed from: r, reason: collision with root package name */
        /* synthetic */ Object f19929r;

        /* renamed from: t, reason: collision with root package name */
        int f19931t;

        c(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19929r = obj;
            this.f19931t |= Integer.MIN_VALUE;
            return e.this.e(null, null, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class d extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19932p;

        /* renamed from: q, reason: collision with root package name */
        Object f19933q;

        /* renamed from: r, reason: collision with root package name */
        int f19934r;

        /* renamed from: s, reason: collision with root package name */
        /* synthetic */ Object f19935s;

        /* renamed from: u, reason: collision with root package name */
        int f19937u;

        d(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19935s = obj;
            this.f19937u |= Integer.MIN_VALUE;
            return e.this.m(null, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: gg.e$e, reason: collision with other inner class name */
    /* loaded from: classes4.dex */
    public static final class C0438e implements Consumer {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ vm.d f19938a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ e f19939b;

        C0438e(vm.d dVar, e eVar) {
            this.f19938a = dVar;
            this.f19939b = eVar;
        }

        @Override // com.amplifyframework.core.Consumer
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final void accept(GraphQLResponse response) {
            t.g(response, "response");
            tr.a.f36618a.a("Authentication", "TrackCloudApi -> queryItem actual completed");
            if (response.hasErrors()) {
                vm.d dVar = this.f19938a;
                x.a aVar = x.f34910p;
                dVar.resumeWith(x.a(new ResultWrapper.Error(null, null, this.f19939b.q(response) ? RepositoryError.AuthError : RepositoryError.ServiceError, null, 8, null)));
            } else if (response.hasData()) {
                vm.d dVar2 = this.f19938a;
                x.a aVar2 = x.f34910p;
                dVar2.resumeWith(x.a(new ResultWrapper.Success(response.getData())));
            } else {
                vm.d dVar3 = this.f19938a;
                x.a aVar3 = x.f34910p;
                dVar3.resumeWith(x.a(new ResultWrapper.Success(null)));
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class f implements Consumer {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ vm.d f19940a;

        f(vm.d dVar) {
            this.f19940a = dVar;
        }

        @Override // com.amplifyframework.core.Consumer
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final void accept(ApiException failure) {
            t.g(failure, "failure");
            tr.a.f36618a.c("Authentication", "TrackCloudApi -> queryItem actual failed", failure);
            vm.d dVar = this.f19940a;
            x.a aVar = x.f34910p;
            dVar.resumeWith(x.a(new ResultWrapper.Success(null)));
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class g extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        /* synthetic */ Object f19941p;

        /* renamed from: r, reason: collision with root package name */
        int f19943r;

        g(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19941p = obj;
            this.f19943r |= Integer.MIN_VALUE;
            return e.this.n(null, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class h extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19944p;

        /* renamed from: q, reason: collision with root package name */
        Object f19945q;

        /* renamed from: r, reason: collision with root package name */
        /* synthetic */ Object f19946r;

        /* renamed from: t, reason: collision with root package name */
        int f19948t;

        h(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19946r = obj;
            this.f19948t |= Integer.MIN_VALUE;
            return e.this.c(this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class i extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19949p;

        /* renamed from: q, reason: collision with root package name */
        Object f19950q;

        /* renamed from: r, reason: collision with root package name */
        Object f19951r;

        /* renamed from: s, reason: collision with root package name */
        int f19952s;

        /* renamed from: t, reason: collision with root package name */
        /* synthetic */ Object f19953t;

        /* renamed from: v, reason: collision with root package name */
        int f19955v;

        i(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19953t = obj;
            this.f19955v |= Integer.MIN_VALUE;
            return e.this.s(null, false, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class j implements Consumer {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ vm.d f19956a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ e f19957b;

        j(vm.d dVar, e eVar) {
            this.f19956a = dVar;
            this.f19957b = eVar;
        }

        @Override // com.amplifyframework.core.Consumer
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final void accept(GraphQLResponse response) {
            t.g(response, "response");
            tr.a.f36618a.a("Authentication", "TrackCloudApi -> updateItem actual completed");
            if (response.hasErrors()) {
                vm.d dVar = this.f19956a;
                x.a aVar = x.f34910p;
                dVar.resumeWith(x.a(new ResultWrapper.Error(null, null, this.f19957b.q(response) ? RepositoryError.AuthError : RepositoryError.ServiceError, null, 8, null)));
            } else if (response.hasData()) {
                vm.d dVar2 = this.f19956a;
                x.a aVar2 = x.f34910p;
                dVar2.resumeWith(x.a(new ResultWrapper.Success(response.getData())));
            } else {
                vm.d dVar3 = this.f19956a;
                x.a aVar3 = x.f34910p;
                dVar3.resumeWith(x.a(new ResultWrapper.Success(null)));
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class k implements Consumer {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ vm.d f19958a;

        k(vm.d dVar) {
            this.f19958a = dVar;
        }

        @Override // com.amplifyframework.core.Consumer
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final void accept(ApiException failure) {
            t.g(failure, "failure");
            tr.a.f36618a.c("Authentication", "TrackCloudApi -> updateItem actual failed", failure);
            vm.d dVar = this.f19958a;
            x.a aVar = x.f34910p;
            dVar.resumeWith(x.a(new ResultWrapper.Success(null)));
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class l extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19959p;

        /* renamed from: q, reason: collision with root package name */
        Object f19960q;

        /* renamed from: r, reason: collision with root package name */
        Object f19961r;

        /* renamed from: s, reason: collision with root package name */
        int f19962s;

        /* renamed from: t, reason: collision with root package name */
        /* synthetic */ Object f19963t;

        /* renamed from: v, reason: collision with root package name */
        int f19965v;

        l(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19963t = obj;
            this.f19965v |= Integer.MIN_VALUE;
            return e.this.u(null, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class m implements Consumer {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ vm.d f19966a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ e f19967b;

        m(vm.d dVar, e eVar) {
            this.f19966a = dVar;
            this.f19967b = eVar;
        }

        @Override // com.amplifyframework.core.Consumer
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final void accept(GraphQLResponse response) {
            int v10;
            int d10;
            int d11;
            Map i10;
            t.g(response, "response");
            tr.a.f36618a.a("Authentication", "TrackCloudApi -> queryPage completed");
            if (response.hasErrors()) {
                vm.d dVar = this.f19966a;
                x.a aVar = x.f34910p;
                dVar.resumeWith(x.a(new ResultWrapper.Error(null, null, this.f19967b.q(response) ? RepositoryError.AuthError : RepositoryError.ServiceError, null, 8, null)));
                return;
            }
            if (!response.hasData()) {
                vm.d dVar2 = this.f19966a;
                x.a aVar2 = x.f34910p;
                i10 = q0.i();
                dVar2.resumeWith(x.a(new ResultWrapper.Success(new v(i10, null))));
                return;
            }
            Iterable items = ((PaginatedResult) response.getData()).getItems();
            t.f(items, "getItems(...)");
            v10 = sm.v.v(items, 10);
            d10 = p0.d(v10);
            d11 = jn.o.d(d10, 16);
            LinkedHashMap linkedHashMap = new LinkedHashMap(d11);
            for (Object obj : items) {
                linkedHashMap.put(((TrackSyncItem) obj).getTrackId(), obj);
            }
            vm.d dVar3 = this.f19966a;
            x.a aVar3 = x.f34910p;
            dVar3.resumeWith(x.a(new ResultWrapper.Success(new v(linkedHashMap, ((PaginatedResult) response.getData()).getRequestForNextResult()))));
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class n implements Consumer {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ vm.d f19968a;

        n(vm.d dVar) {
            this.f19968a = dVar;
        }

        @Override // com.amplifyframework.core.Consumer
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final void accept(ApiException failure) {
            Map i10;
            t.g(failure, "failure");
            tr.a.f36618a.c("Authentication", "TrackCloudApi -> queryPage failed", failure);
            vm.d dVar = this.f19968a;
            x.a aVar = x.f34910p;
            i10 = q0.i();
            dVar.resumeWith(x.a(new ResultWrapper.Success(new v(i10, null))));
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class o extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19969p;

        /* renamed from: q, reason: collision with root package name */
        Object f19970q;

        /* renamed from: r, reason: collision with root package name */
        /* synthetic */ Object f19971r;

        /* renamed from: t, reason: collision with root package name */
        int f19973t;

        o(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19971r = obj;
            this.f19973t |= Integer.MIN_VALUE;
            return e.this.a(null, this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class p extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19974p;

        /* renamed from: q, reason: collision with root package name */
        Object f19975q;

        /* renamed from: r, reason: collision with root package name */
        Object f19976r;

        /* renamed from: s, reason: collision with root package name */
        Object f19977s;

        /* renamed from: t, reason: collision with root package name */
        Object f19978t;

        /* renamed from: u, reason: collision with root package name */
        boolean f19979u;

        /* renamed from: v, reason: collision with root package name */
        boolean f19980v;

        /* renamed from: w, reason: collision with root package name */
        /* synthetic */ Object f19981w;

        /* renamed from: y, reason: collision with root package name */
        int f19983y;

        p(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19981w = obj;
            this.f19983y |= Integer.MIN_VALUE;
            return e.this.d(null, null, null, null, null, false, false, this);
        }
    }

    public e(t7.c contextService, g9.d sessionRepository) {
        t.g(contextService, "contextService");
        t.g(sessionRepository, "sessionRepository");
        this.f19920a = contextService;
        this.f19921b = sessionRepository;
        f0 f0Var = new f0();
        this.f19924e = f0Var;
        this.f19925f = f0Var;
    }

    private final void i() {
        try {
            Amplify.configure(AmplifyConfiguration.fromJson(j(this.f19920a)), this.f19920a.a());
        } catch (AmplifyException unused) {
            Amplify.configure(this.f19920a.a());
        }
    }

    private static final JSONObject j(t7.c cVar) {
        try {
            InputStream open = cVar.a().getAssets().open("amplifyconfiguration.json");
            t.f(open, "open(...)");
            byte[] bArr = new byte[open.available()];
            open.read(bArr);
            open.close();
            return new JSONObject(new String(bArr, kotlin.text.d.f26484b));
        } catch (Exception e10) {
            tr.a.f36618a.d(e10, e10.getMessage(), new Object[0]);
            throw new AmplifyException("Failed to find amplifyconfiguration.json.", e10, "Please check that it has been created.");
        }
    }

    private final Object l(GraphQLRequest graphQLRequest, vm.d dVar) {
        vm.d d10;
        Object f10;
        d10 = wm.c.d(dVar);
        vm.i iVar = new vm.i(d10);
        tr.a.f36618a.a("Authentication", "TrackCloudApi -> queryItem actual started");
        Amplify.API.query(graphQLRequest, new C0438e(iVar, this), new f(iVar));
        Object a10 = iVar.a();
        f10 = wm.d.f();
        if (a10 == f10) {
            kotlin.coroutines.jvm.internal.h.c(dVar);
        }
        return a10;
    }

    private final boolean o() {
        Boolean bool = (Boolean) this.f19921b.i().f();
        if (bool == null ? false : bool.booleanValue()) {
            return !this.f19922c ? p() : true;
        }
        return false;
    }

    private final synchronized boolean p() {
        a.C0867a c0867a = tr.a.f36618a;
        c0867a.e("Authentication", "Initializing");
        Boolean bool = (Boolean) this.f19921b.i().f();
        if (bool == null) {
            bool = Boolean.FALSE;
        }
        if (!bool.booleanValue()) {
            return false;
        }
        if (this.f19922c) {
            return true;
        }
        try {
            c0867a.e("Authentication", "Start Initializing");
            Amplify.addPlugin(new AWSApiPlugin(ApiAuthProviders.builder().oidcAuthProvider(this.f19921b).build()));
            i();
            c0867a.e("Authentication", "Successful Initializing Amplify");
            this.f19922c = true;
            return true;
        } catch (AmplifyException e10) {
            tr.a.f36618a.c("Authentication", "Fail to initialize Amplify", e10);
            this.f19922c = false;
            return false;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final boolean q(GraphQLResponse graphQLResponse) {
        tr.a.f36618a.a("Authentication", "TrackCloudApi -> isExpiredError");
        List<GraphQLResponse.Error> errors = graphQLResponse.getErrors();
        t.f(errors, "getErrors(...)");
        Iterator<T> it = errors.iterator();
        while (it.hasNext()) {
            Map<String, Object> extensions = ((GraphQLResponse.Error) it.next()).getExtensions();
            Object obj = extensions != null ? extensions.get("errorType") : null;
            tr.a.f36618a.a("Authentication", "isExpiredError -> errorName = " + obj);
            if (obj != null && (t.b(obj, "UnauthorizedException") || t.b(obj, "Unauthorized"))) {
                return true;
            }
        }
        return false;
    }

    private final Object r(GraphQLRequest graphQLRequest, vm.d dVar) {
        vm.d d10;
        Object f10;
        d10 = wm.c.d(dVar);
        vm.i iVar = new vm.i(d10);
        tr.a.f36618a.a("Authentication", "TrackCloudApi -> updateItem actual started");
        Amplify.API.mutate(graphQLRequest, new j(iVar, this), new k(iVar));
        Object a10 = iVar.a();
        f10 = wm.d.f();
        if (a10 == f10) {
            kotlin.coroutines.jvm.internal.h.c(dVar);
        }
        return a10;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:35:0x0081, code lost:
    
        r11 = r0;
        r0 = r1;
        r1 = r2;
     */
    /* JADX WARN: Removed duplicated region for block: B:13:0x0091 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0092  */
    /* JADX WARN: Removed duplicated region for block: B:18:0x009d  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x00c7  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0061  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0026  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object s(TrackSyncItem trackSyncItem, boolean z10, vm.d dVar) {
        i iVar;
        Object f10;
        int i10;
        o0 o0Var;
        GraphQLRequest graphQLRequest;
        int i11;
        Object obj;
        i iVar2;
        o0 o0Var2;
        ResultWrapper resultWrapper;
        Object r10;
        if (dVar instanceof i) {
            iVar = (i) dVar;
            int i12 = iVar.f19955v;
            if ((i12 & Integer.MIN_VALUE) != 0) {
                iVar.f19955v = i12 - Integer.MIN_VALUE;
                Object obj2 = iVar.f19953t;
                f10 = wm.d.f();
                i10 = iVar.f19955v;
                if (i10 != 0) {
                    y.b(obj2);
                    o0Var = new o0();
                    GraphQLRequest create = z10 ? ModelMutation.create(trackSyncItem) : ModelMutation.update(trackSyncItem);
                    tr.a.f36618a.a("Authentication", "TrackCloudApi -> updateItem wrapper started");
                    graphQLRequest = create;
                    i11 = 1;
                } else {
                    if (i10 == 1) {
                        int i13 = iVar.f19952s;
                        GraphQLRequest graphQLRequest2 = (GraphQLRequest) iVar.f19951r;
                        o0 o0Var3 = (o0) iVar.f19950q;
                        e eVar = (e) iVar.f19949p;
                        y.b(obj2);
                        i11 = i13;
                        this = eVar;
                        obj = f10;
                        iVar2 = iVar;
                        o0Var2 = o0Var3;
                        graphQLRequest = graphQLRequest2;
                        resultWrapper = (ResultWrapper) obj2;
                        if (resultWrapper instanceof ResultWrapper.Success) {
                            TrackSyncItem trackSyncItem2 = (TrackSyncItem) ((ResultWrapper.Success) resultWrapper).getData();
                            if (trackSyncItem2 != null) {
                                o0Var2.f26199p = trackSyncItem2.getId();
                                Map map = (Map) this.f19924e.f();
                                if (map != null) {
                                    t.d(map);
                                    String trackId = trackSyncItem2.getTrackId();
                                    t.f(trackId, "getTrackId(...)");
                                    map.put(trackId, trackSyncItem2);
                                }
                            }
                        } else {
                            if (resultWrapper instanceof ResultWrapper.Error) {
                                if (b.f19926a[((ResultWrapper.Error) resultWrapper).getError().ordinal()] == 1 && i11 != 0) {
                                    g9.d dVar2 = this.f19921b;
                                    iVar2.f19949p = this;
                                    iVar2.f19950q = o0Var2;
                                    iVar2.f19951r = graphQLRequest;
                                    iVar2.f19952s = 0;
                                    iVar2.f19955v = 2;
                                    if (dVar2.b(iVar2) == obj) {
                                        return obj;
                                    }
                                    i11 = 0;
                                }
                            }
                            o0Var = o0Var2;
                            iVar = iVar2;
                            f10 = obj;
                        }
                        tr.a.f36618a.a("Authentication", "TrackCloudApi -> updateItem wrapper completed");
                        return o0Var2.f26199p;
                    }
                    if (i10 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    int i14 = iVar.f19952s;
                    GraphQLRequest graphQLRequest3 = (GraphQLRequest) iVar.f19951r;
                    o0 o0Var4 = (o0) iVar.f19950q;
                    e eVar2 = (e) iVar.f19949p;
                    y.b(obj2);
                    o0Var = o0Var4;
                    graphQLRequest = graphQLRequest3;
                    i11 = i14;
                    this = eVar2;
                }
                iVar.f19949p = this;
                iVar.f19950q = o0Var;
                iVar.f19951r = graphQLRequest;
                iVar.f19952s = i11;
                iVar.f19955v = 1;
                r10 = this.r(graphQLRequest, iVar);
                if (r10 != f10) {
                    return f10;
                }
                i iVar3 = iVar;
                o0Var2 = o0Var;
                obj2 = r10;
                obj = f10;
                iVar2 = iVar3;
                resultWrapper = (ResultWrapper) obj2;
                if (resultWrapper instanceof ResultWrapper.Success) {
                }
                tr.a.f36618a.a("Authentication", "TrackCloudApi -> updateItem wrapper completed");
                return o0Var2.f26199p;
            }
        }
        iVar = new i(dVar);
        Object obj22 = iVar.f19953t;
        f10 = wm.d.f();
        i10 = iVar.f19955v;
        if (i10 != 0) {
        }
        iVar.f19949p = this;
        iVar.f19950q = o0Var;
        iVar.f19951r = graphQLRequest;
        iVar.f19952s = i11;
        iVar.f19955v = 1;
        r10 = this.r(graphQLRequest, iVar);
        if (r10 != f10) {
        }
    }

    static /* synthetic */ Object t(e eVar, TrackSyncItem trackSyncItem, boolean z10, vm.d dVar, int i10, Object obj) {
        if ((i10 & 2) != 0) {
            z10 = false;
        }
        return eVar.s(trackSyncItem, z10, dVar);
    }

    /*  JADX ERROR: JadxOverflowException in pass: RegionMakerVisitor
        jadx.core.utils.exceptions.JadxOverflowException: Regions count limit reached
        	at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:59)
        	at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:31)
        	at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:19)
        */
    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:18:0x0097  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x00b7  */
    /* JADX WARN: Type inference failed for: r2v11, types: [java.util.Map] */
    /* JADX WARN: Type inference failed for: r2v9, types: [java.util.Map] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final java.lang.Object u(com.amplifyframework.api.graphql.GraphQLRequest r10, vm.d r11) {
        /*
            Method dump skipped, instructions count: 243
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: gg.e.u(com.amplifyframework.api.graphql.GraphQLRequest, vm.d):java.lang.Object");
    }

    private final Object v(GraphQLRequest graphQLRequest, vm.d dVar) {
        vm.d d10;
        Object f10;
        d10 = wm.c.d(dVar);
        vm.i iVar = new vm.i(d10);
        tr.a.f36618a.a("Authentication", "TrackCloudApi -> queryPage started");
        Amplify.API.query(graphQLRequest, new m(iVar, this), new n(iVar));
        Object a10 = iVar.a();
        f10 = wm.d.f();
        if (a10 == f10) {
            kotlin.coroutines.jvm.internal.h.c(dVar);
        }
        return a10;
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x0095  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0107 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0108  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x0057  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0026  */
    @Override // gg.b
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object a(PackageItemModel packageItemModel, vm.d dVar) {
        o oVar;
        Object obj;
        Object f10;
        int i10;
        e eVar;
        TrackSyncItem trackSyncItem;
        PackageItemModel packageItemModel2;
        TrackSyncItem trackSyncItem2;
        if (dVar instanceof o) {
            oVar = (o) dVar;
            int i11 = oVar.f19973t;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                oVar.f19973t = i11 - Integer.MIN_VALUE;
                obj = oVar.f19971r;
                f10 = wm.d.f();
                i10 = oVar.f19973t;
                if (i10 != 0) {
                    y.b(obj);
                    if (!o()) {
                        this.f19924e.n(null);
                        return n0.f34904a;
                    }
                    Map map = (Map) this.f19924e.f();
                    if (map != null) {
                        trackSyncItem = (TrackSyncItem) map.get(packageItemModel.getItemNumber());
                        if (trackSyncItem == null) {
                            String itemNumber = packageItemModel.getItemNumber();
                            oVar.f19969p = this;
                            oVar.f19970q = packageItemModel;
                            oVar.f19973t = 1;
                            obj = n(itemNumber, oVar);
                            if (obj == f10) {
                                return f10;
                            }
                        }
                        eVar = this;
                        trackSyncItem2 = trackSyncItem;
                        if (trackSyncItem2 != null) {
                            if (ig.a.f23217a.e(packageItemModel, trackSyncItem2)) {
                                String id2 = trackSyncItem2.getId();
                                t.f(id2, "getId(...)");
                                String itemNumber2 = packageItemModel.getItemNumber();
                                String userDescription = packageItemModel.getUserDescription();
                                Date createdAt = packageItemModel.getCreatedAt();
                                Date modifiedAt = packageItemModel.getModifiedAt();
                                boolean isSNFItemRead = packageItemModel.isSNFItemRead();
                                boolean isFlaggedAsNotMine = packageItemModel.isFlaggedAsNotMine();
                                oVar.f19969p = packageItemModel;
                                oVar.f19970q = trackSyncItem2;
                                oVar.f19973t = 2;
                                if (eVar.d(id2, itemNumber2, userDescription, createdAt, modifiedAt, isSNFItemRead, isFlaggedAsNotMine, oVar) == f10) {
                                    return f10;
                                }
                            }
                            Date date = trackSyncItem2.getCreatedAt().toDate();
                            t.f(date, "toDate(...)");
                            packageItemModel.setCreatedAt(date);
                            packageItemModel.setCloudId(trackSyncItem2.getId());
                            return n0.f34904a;
                        }
                        String itemNumber3 = packageItemModel.getItemNumber();
                        String userDescription2 = packageItemModel.getUserDescription();
                        Date createdAt2 = packageItemModel.getCreatedAt();
                        boolean isItemSourceSNF = packageItemModel.isItemSourceSNF();
                        oVar.f19969p = packageItemModel;
                        oVar.f19970q = null;
                        oVar.f19973t = 3;
                        obj = eVar.k(itemNumber3, userDescription2, createdAt2, isItemSourceSNF, oVar);
                        if (obj != f10) {
                            return f10;
                        }
                        packageItemModel2 = packageItemModel;
                        packageItemModel2.setCloudId((String) obj);
                        return n0.f34904a;
                    }
                    eVar = this;
                    String itemNumber32 = packageItemModel.getItemNumber();
                    String userDescription22 = packageItemModel.getUserDescription();
                    Date createdAt22 = packageItemModel.getCreatedAt();
                    boolean isItemSourceSNF2 = packageItemModel.isItemSourceSNF();
                    oVar.f19969p = packageItemModel;
                    oVar.f19970q = null;
                    oVar.f19973t = 3;
                    obj = eVar.k(itemNumber32, userDescription22, createdAt22, isItemSourceSNF2, oVar);
                    if (obj != f10) {
                    }
                } else {
                    if (i10 != 1) {
                        if (i10 != 2) {
                            if (i10 != 3) {
                                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                            }
                            packageItemModel2 = (PackageItemModel) oVar.f19969p;
                            y.b(obj);
                            packageItemModel2.setCloudId((String) obj);
                            return n0.f34904a;
                        }
                        trackSyncItem2 = (TrackSyncItem) oVar.f19970q;
                        packageItemModel = (PackageItemModel) oVar.f19969p;
                        y.b(obj);
                        Date date2 = trackSyncItem2.getCreatedAt().toDate();
                        t.f(date2, "toDate(...)");
                        packageItemModel.setCreatedAt(date2);
                        packageItemModel.setCloudId(trackSyncItem2.getId());
                        return n0.f34904a;
                    }
                    packageItemModel = (PackageItemModel) oVar.f19970q;
                    this = (e) oVar.f19969p;
                    y.b(obj);
                }
                trackSyncItem = (TrackSyncItem) obj;
                eVar = this;
                trackSyncItem2 = trackSyncItem;
                if (trackSyncItem2 != null) {
                }
                String itemNumber322 = packageItemModel.getItemNumber();
                String userDescription222 = packageItemModel.getUserDescription();
                Date createdAt222 = packageItemModel.getCreatedAt();
                boolean isItemSourceSNF22 = packageItemModel.isItemSourceSNF();
                oVar.f19969p = packageItemModel;
                oVar.f19970q = null;
                oVar.f19973t = 3;
                obj = eVar.k(itemNumber322, userDescription222, createdAt222, isItemSourceSNF22, oVar);
                if (obj != f10) {
                }
            }
        }
        oVar = new o(dVar);
        obj = oVar.f19971r;
        f10 = wm.d.f();
        i10 = oVar.f19973t;
        if (i10 != 0) {
        }
        trackSyncItem = (TrackSyncItem) obj;
        eVar = this;
        trackSyncItem2 = trackSyncItem;
        if (trackSyncItem2 != null) {
        }
        String itemNumber3222 = packageItemModel.getItemNumber();
        String userDescription2222 = packageItemModel.getUserDescription();
        Date createdAt2222 = packageItemModel.getCreatedAt();
        boolean isItemSourceSNF222 = packageItemModel.isItemSourceSNF();
        oVar.f19969p = packageItemModel;
        oVar.f19970q = null;
        oVar.f19973t = 3;
        obj = eVar.k(itemNumber3222, userDescription2222, createdAt2222, isItemSourceSNF222, oVar);
        if (obj != f10) {
        }
    }

    @Override // gg.b
    public void b() {
        if (this.f19921b.h()) {
            return;
        }
        this.f19923d = null;
        this.f19924e.n(null);
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x00b6  */
    /* JADX WARN: Removed duplicated region for block: B:17:0x003a  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    @Override // gg.b
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object c(vm.d dVar) {
        h hVar;
        Object f10;
        int i10;
        GraphQLRequest list;
        e eVar;
        Map map;
        Map i11;
        Map o10;
        Map w10;
        if (dVar instanceof h) {
            hVar = (h) dVar;
            int i12 = hVar.f19948t;
            if ((i12 & Integer.MIN_VALUE) != 0) {
                hVar.f19948t = i12 - Integer.MIN_VALUE;
                Object obj = hVar.f19946r;
                f10 = wm.d.f();
                i10 = hVar.f19948t;
                if (i10 != 0) {
                    y.b(obj);
                    tr.a.f36618a.a("Authentication", "TrackCloudApi -> getItems");
                    if (!o()) {
                        this.f19924e.n(null);
                        i11 = q0.i();
                        return i11;
                    }
                    Temporal.DateTime dateTime = this.f19923d;
                    QueryPredicateOperation gt = dateTime != null ? TrackSyncItem.UPDATED_AT.gt(dateTime) : null;
                    if (gt == null) {
                        ModelPagination withLimit = ModelPagination.firstPage().withLimit(30);
                        t.f(withLimit, "withLimit(...)");
                        list = ModelQuery.list(TrackSyncItem.class, withLimit);
                    } else {
                        ModelPagination withLimit2 = ModelPagination.firstPage().withLimit(30);
                        t.f(withLimit2, "withLimit(...)");
                        list = ModelQuery.list(TrackSyncItem.class, gt, withLimit2);
                    }
                    Map map2 = (Map) this.f19924e.f();
                    if (map2 == null) {
                        map2 = q0.i();
                    }
                    hVar.f19944p = this;
                    hVar.f19945q = map2;
                    hVar.f19948t = 1;
                    obj = u(list, hVar);
                    if (obj == f10) {
                        return f10;
                    }
                    eVar = this;
                    map = map2;
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    map = (Map) hVar.f19945q;
                    eVar = (e) hVar.f19944p;
                    y.b(obj);
                }
                o10 = q0.o(map, (Map) obj);
                if (!o10.isEmpty()) {
                    eVar.f19923d = new Temporal.DateTime(new Date(), 0);
                    f0 f0Var = eVar.f19924e;
                    w10 = q0.w(o10);
                    f0Var.n(w10);
                }
                return o10;
            }
        }
        hVar = new h(dVar);
        Object obj2 = hVar.f19946r;
        f10 = wm.d.f();
        i10 = hVar.f19948t;
        if (i10 != 0) {
        }
        o10 = q0.o(map, (Map) obj2);
        if (!o10.isEmpty()) {
        }
        return o10;
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x007b A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:19:0x007c  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0056  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0025  */
    @Override // gg.b
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object d(String str, String str2, String str3, Date date, Date date2, boolean z10, boolean z11, vm.d dVar) {
        p pVar;
        Object f10;
        int i10;
        TrackSyncItem trackSyncItem;
        if (dVar instanceof p) {
            pVar = (p) dVar;
            int i11 = pVar.f19983y;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                pVar.f19983y = i11 - Integer.MIN_VALUE;
                Object obj = pVar.f19981w;
                f10 = wm.d.f();
                i10 = pVar.f19983y;
                if (i10 != 0) {
                    y.b(obj);
                    if (!o()) {
                        return null;
                    }
                    pVar.f19974p = this;
                    pVar.f19975q = str2;
                    pVar.f19976r = str3;
                    pVar.f19977s = date;
                    pVar.f19978t = date2;
                    pVar.f19979u = z10;
                    pVar.f19980v = z11;
                    pVar.f19983y = 1;
                    obj = m(str, pVar);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        if (i10 == 2) {
                            y.b(obj);
                        }
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    z11 = pVar.f19980v;
                    z10 = pVar.f19979u;
                    date2 = (Date) pVar.f19978t;
                    date = (Date) pVar.f19977s;
                    str3 = (String) pVar.f19976r;
                    str2 = (String) pVar.f19975q;
                    this = (e) pVar.f19974p;
                    y.b(obj);
                }
                trackSyncItem = (TrackSyncItem) obj;
                if (trackSyncItem != null) {
                    return null;
                }
                Temporal.DateTime dateTime = date != null ? new Temporal.DateTime(date, 0) : null;
                Temporal.DateTime dateTime2 = date2 != null ? new Temporal.DateTime(date2, 0) : null;
                TrackSyncItem.CopyOfBuilder trackId = trackSyncItem.copyOfBuilder().trackId(str2);
                if (str3 == null) {
                    str3 = "";
                }
                TrackSyncItem build = trackId.userDescription(str3).deleted(kotlin.coroutines.jvm.internal.b.a(false)).isRead(kotlin.coroutines.jvm.internal.b.a(z10)).isFlaggedAsNotMine(kotlin.coroutines.jvm.internal.b.a(z11)).createdAt(dateTime).updatedAt(dateTime2).build();
                t.f(build, "build(...)");
                pVar.f19974p = null;
                pVar.f19975q = null;
                pVar.f19976r = null;
                pVar.f19977s = null;
                pVar.f19978t = null;
                pVar.f19983y = 2;
                obj = t(this, build, false, pVar, 2, null);
                return obj == f10 ? f10 : obj;
            }
        }
        pVar = new p(dVar);
        Object obj2 = pVar.f19981w;
        f10 = wm.d.f();
        i10 = pVar.f19983y;
        if (i10 != 0) {
        }
        trackSyncItem = (TrackSyncItem) obj2;
        if (trackSyncItem != null) {
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x005f A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0044  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0026  */
    @Override // gg.b
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object e(String str, Date date, vm.d dVar) {
        c cVar;
        Object f10;
        int i10;
        TrackSyncItem trackSyncItem;
        if (dVar instanceof c) {
            cVar = (c) dVar;
            int i11 = cVar.f19931t;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                cVar.f19931t = i11 - Integer.MIN_VALUE;
                c cVar2 = cVar;
                Object obj = cVar2.f19929r;
                f10 = wm.d.f();
                i10 = cVar2.f19931t;
                if (i10 != 0) {
                    y.b(obj);
                    if (!o()) {
                        return null;
                    }
                    cVar2.f19927p = this;
                    cVar2.f19928q = date;
                    cVar2.f19931t = 1;
                    obj = m(str, cVar2);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        if (i10 == 2) {
                            y.b(obj);
                        }
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    date = (Date) cVar2.f19928q;
                    this = (e) cVar2.f19927p;
                    y.b(obj);
                }
                e eVar = this;
                trackSyncItem = (TrackSyncItem) obj;
                if (trackSyncItem != null) {
                    return null;
                }
                TrackSyncItem build = trackSyncItem.copyOfBuilder().deleted(kotlin.coroutines.jvm.internal.b.a(true)).updatedAt(date != null ? new Temporal.DateTime(date, 0) : null).build();
                t.f(build, "build(...)");
                cVar2.f19927p = null;
                cVar2.f19928q = null;
                cVar2.f19931t = 2;
                obj = t(eVar, build, false, cVar2, 2, null);
                return obj == f10 ? f10 : obj;
            }
        }
        cVar = new c(dVar);
        c cVar22 = cVar;
        Object obj2 = cVar22.f19929r;
        f10 = wm.d.f();
        i10 = cVar22.f19931t;
        if (i10 != 0) {
        }
        e eVar2 = this;
        trackSyncItem = (TrackSyncItem) obj2;
        if (trackSyncItem != null) {
        }
    }

    public Object k(String str, String str2, Date date, boolean z10, vm.d dVar) {
        TrackItemType trackItemType;
        TrackItemSource trackItemSource;
        if (!o()) {
            return null;
        }
        Temporal.DateTime dateTime = date != null ? new Temporal.DateTime(date, 0) : null;
        if (z10) {
            trackItemType = TrackItemType.SET_AND_FORGET;
            trackItemSource = TrackItemSource.SET_AND_FORGET;
        } else {
            trackItemType = TrackItemType.DEFAULT;
            trackItemSource = TrackItemSource.USER;
        }
        TrackSyncItem.BuildStep trackId = TrackSyncItem.builder().trackId(str);
        if (str2 == null) {
            str2 = "";
        }
        TrackSyncItem build = trackId.userDescription(str2).type(trackItemType).source(trackItemSource).createdAt(dateTime).deleted(kotlin.coroutines.jvm.internal.b.a(false)).build();
        t.d(build);
        return s(build, true, dVar);
    }

    /* JADX WARN: Code restructure failed: missing block: B:32:0x006d, code lost:
    
        r10 = r0;
        r0 = r1;
        r1 = r2;
     */
    /* JADX WARN: Removed duplicated region for block: B:13:0x007b A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:15:0x007c  */
    /* JADX WARN: Removed duplicated region for block: B:18:0x0087  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0090  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x0057  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0026  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object m(String str, vm.d dVar) {
        d dVar2;
        Object f10;
        int i10;
        GraphQLRequest graphQLRequest;
        int i11;
        Object obj;
        d dVar3;
        GraphQLRequest graphQLRequest2;
        ResultWrapper resultWrapper;
        TrackSyncItem trackSyncItem;
        Object l10;
        if (dVar instanceof d) {
            dVar2 = (d) dVar;
            int i12 = dVar2.f19937u;
            if ((i12 & Integer.MIN_VALUE) != 0) {
                dVar2.f19937u = i12 - Integer.MIN_VALUE;
                Object obj2 = dVar2.f19935s;
                f10 = wm.d.f();
                i10 = dVar2.f19937u;
                if (i10 != 0) {
                    y.b(obj2);
                    GraphQLRequest graphQLRequest3 = ModelQuery.get(TrackSyncItem.class, str);
                    tr.a.f36618a.a("Authentication", "TrackCloudApi -> queryItem wrapper started");
                    graphQLRequest = graphQLRequest3;
                    i11 = 1;
                } else {
                    if (i10 == 1) {
                        int i13 = dVar2.f19934r;
                        GraphQLRequest graphQLRequest4 = (GraphQLRequest) dVar2.f19933q;
                        e eVar = (e) dVar2.f19932p;
                        y.b(obj2);
                        i11 = i13;
                        this = eVar;
                        obj = f10;
                        dVar3 = dVar2;
                        graphQLRequest2 = graphQLRequest4;
                        resultWrapper = (ResultWrapper) obj2;
                        if (resultWrapper instanceof ResultWrapper.Success) {
                            trackSyncItem = (TrackSyncItem) ((ResultWrapper.Success) resultWrapper).getData();
                        } else {
                            if (resultWrapper instanceof ResultWrapper.Error) {
                                if (b.f19926a[((ResultWrapper.Error) resultWrapper).getError().ordinal()] != 1 || i11 == 0) {
                                    trackSyncItem = null;
                                } else {
                                    g9.d dVar4 = this.f19921b;
                                    dVar3.f19932p = this;
                                    dVar3.f19933q = graphQLRequest2;
                                    dVar3.f19934r = 0;
                                    dVar3.f19937u = 2;
                                    if (dVar4.b(dVar3) == obj) {
                                        return obj;
                                    }
                                    i11 = 0;
                                }
                            }
                            graphQLRequest = graphQLRequest2;
                            dVar2 = dVar3;
                            f10 = obj;
                        }
                        tr.a.f36618a.a("Authentication", "TrackCloudApi -> queryItem wrapper completed");
                        return trackSyncItem;
                    }
                    if (i10 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    int i14 = dVar2.f19934r;
                    GraphQLRequest graphQLRequest5 = (GraphQLRequest) dVar2.f19933q;
                    e eVar2 = (e) dVar2.f19932p;
                    y.b(obj2);
                    graphQLRequest = graphQLRequest5;
                    i11 = i14;
                    this = eVar2;
                }
                dVar2.f19932p = this;
                dVar2.f19933q = graphQLRequest;
                dVar2.f19934r = i11;
                dVar2.f19937u = 1;
                l10 = this.l(graphQLRequest, dVar2);
                if (l10 != f10) {
                    return f10;
                }
                d dVar5 = dVar2;
                graphQLRequest2 = graphQLRequest;
                obj2 = l10;
                obj = f10;
                dVar3 = dVar5;
                resultWrapper = (ResultWrapper) obj2;
                if (resultWrapper instanceof ResultWrapper.Success) {
                }
                tr.a.f36618a.a("Authentication", "TrackCloudApi -> queryItem wrapper completed");
                return trackSyncItem;
            }
        }
        dVar2 = new d(dVar);
        Object obj22 = dVar2.f19935s;
        f10 = wm.d.f();
        i10 = dVar2.f19937u;
        if (i10 != 0) {
        }
        dVar2.f19932p = this;
        dVar2.f19933q = graphQLRequest;
        dVar2.f19934r = i11;
        dVar2.f19937u = 1;
        l10 = this.l(graphQLRequest, dVar2);
        if (l10 != f10) {
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0031  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object n(String str, vm.d dVar) {
        g gVar;
        Object f10;
        int i10;
        Object d02;
        if (dVar instanceof g) {
            gVar = (g) dVar;
            int i11 = gVar.f19943r;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                gVar.f19943r = i11 - Integer.MIN_VALUE;
                Object obj = gVar.f19941p;
                f10 = wm.d.f();
                i10 = gVar.f19943r;
                if (i10 != 0) {
                    y.b(obj);
                    if (!o()) {
                        this.f19924e.n(null);
                        return null;
                    }
                    QueryPredicateOperation<Object> eq2 = TrackSyncItem.TRACK_ID.eq(str);
                    t.d(eq2);
                    ModelPagination withLimit = ModelPagination.firstPage().withLimit(100000);
                    t.f(withLimit, "withLimit(...)");
                    GraphQLRequest list = ModelQuery.list(TrackSyncItem.class, eq2, withLimit);
                    gVar.f19943r = 1;
                    obj = u(list, gVar);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    y.b(obj);
                }
                d02 = c0.d0(((Map) obj).values());
                return d02;
            }
        }
        gVar = new g(dVar);
        Object obj2 = gVar.f19941p;
        f10 = wm.d.f();
        i10 = gVar.f19943r;
        if (i10 != 0) {
        }
        d02 = c0.d0(((Map) obj2).values());
        return d02;
    }
}
