package wf;

import androidx.lifecycle.a0;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.google.api.IGooglePassApi;
import ca.canadapost.core.data.google.model.googlepass.GooglePass;
import ca.canadapost.core.data.google.model.googlepass.GooglePassType;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import kotlin.coroutines.jvm.internal.d;
import kotlin.jvm.internal.t;
import rm.y;
import uq.e0;

/* loaded from: classes4.dex */
public final class b implements wf.a {

    /* renamed from: a, reason: collision with root package name */
    private final vf.a f49358a;

    /* renamed from: b, reason: collision with root package name */
    private final IGooglePassApi f49359b;

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

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

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

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

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f49365q = obj;
            this.f49367s |= Integer.MIN_VALUE;
            return b.this.d(this);
        }
    }

    public b(vf.a sfsbCardDao, IGooglePassApi googlePassApi) {
        t.g(sfsbCardDao, "sfsbCardDao");
        t.g(googlePassApi, "googlePassApi");
        this.f49358a = sfsbCardDao;
        this.f49359b = googlePassApi;
        f0 f0Var = new f0();
        this.f49360c = f0Var;
        this.f49361d = f0Var;
        f0 f0Var2 = new f0();
        this.f49362e = f0Var2;
        this.f49363f = f0Var2;
        f0Var.q(sfsbCardDao.b());
    }

    @Override // wf.a
    public void a() {
        this.f49358a.a();
        this.f49362e.q(null);
        this.f49360c.n(null);
    }

    @Override // wf.a
    public a0 b() {
        return this.f49361d;
    }

    @Override // wf.a
    public a0 c() {
        return this.f49363f;
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0035  */
    /* JADX WARN: Removed duplicated region for block: B:9:0x0023  */
    @Override // wf.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object d(vm.d dVar) {
        a aVar;
        Object f10;
        int i10;
        try {
            if (dVar instanceof a) {
                aVar = (a) dVar;
                int i11 = aVar.f49367s;
                if ((i11 & Integer.MIN_VALUE) != 0) {
                    aVar.f49367s = i11 - Integer.MIN_VALUE;
                    Object obj = aVar.f49365q;
                    f10 = wm.d.f();
                    i10 = aVar.f49367s;
                    if (i10 != 0) {
                        y.b(obj);
                        uf.a aVar2 = (uf.a) this.f49360c.f();
                        if (aVar2 == null) {
                            return null;
                        }
                        IGooglePassApi iGooglePassApi = this.f49359b;
                        String urlPath = GooglePassType.SFSBPass.getUrlPath();
                        GooglePass c10 = aVar2.c();
                        aVar.f49364p = this;
                        aVar.f49367s = 1;
                        obj = iGooglePassApi.createGooglePass(urlPath, c10, aVar);
                        if (obj == f10) {
                            return f10;
                        }
                    } else {
                        if (i10 != 1) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        this = (b) aVar.f49364p;
                        y.b(obj);
                    }
                    this.f49362e.n(((e0) obj).j());
                    return null;
                }
            }
            if (i10 != 0) {
            }
            this.f49362e.n(((e0) obj).j());
            return null;
        } catch (Exception e10) {
            tr.a.f36618a.d(e10, e10.getMessage(), new Object[0]);
            return new ResultWrapper.Error(e10, "Error while getting google pass token", RepositoryError.ClientError, null, 8, null);
        }
        aVar = new a(dVar);
        Object obj2 = aVar.f49365q;
        f10 = wm.d.f();
        i10 = aVar.f49367s;
    }

    @Override // wf.a
    public void e(uf.a card) {
        t.g(card, "card");
        this.f49358a.c(card);
        this.f49360c.n(card);
    }
}
