package ld;

import android.app.Application;
import android.content.Context;
import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.auth.model.RegistrationEmailVerifiedResponse;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import d9.f;
import dn.p;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.jvm.internal.t;
import l8.h;
import rm.n0;
import rm.y;
import tp.m0;
import tp.o0;
import tp.u1;

/* loaded from: classes4.dex */
public final class e extends androidx.lifecycle.b implements l8.h {

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

    /* renamed from: d, reason: collision with root package name */
    private final p9.h f27868d;

    /* renamed from: e, reason: collision with root package name */
    private final d9.f f27869e;

    /* renamed from: f, reason: collision with root package name */
    private final ja.d f27870f;

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

    /* renamed from: h, reason: collision with root package name */
    private final g9.l f27872h;

    /* renamed from: i, reason: collision with root package name */
    private final i9.c f27873i;

    /* renamed from: j, reason: collision with root package name */
    private final /* synthetic */ l8.i f27874j;

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

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

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

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

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

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

    /* renamed from: q, reason: collision with root package name */
    private final l8.g f27881q;

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

    /* renamed from: s, reason: collision with root package name */
    private final l8.g f27883s;

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

    /* renamed from: u, reason: collision with root package name */
    private final l8.g f27885u;

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

    /* renamed from: w, reason: collision with root package name */
    private final l8.g f27887w;

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

    /* loaded from: classes4.dex */
    static final class a extends kotlin.coroutines.jvm.internal.l implements p {

        /* renamed from: p, reason: collision with root package name */
        int f27889p;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ String f27891r;

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ Map f27892s;

        /* renamed from: ld.e$a$a, reason: collision with other inner class name */
        /* loaded from: classes4.dex */
        public /* synthetic */ class C0625a {

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

            static {
                int[] iArr = new int[RepositoryError.values().length];
                try {
                    iArr[RepositoryError.EmailTokenExpired.ordinal()] = 1;
                } catch (NoSuchFieldError unused) {
                }
                try {
                    iArr[RepositoryError.EmailLinkNotValid.ordinal()] = 2;
                } catch (NoSuchFieldError unused2) {
                }
                try {
                    iArr[RepositoryError.ServiceError.ordinal()] = 3;
                } catch (NoSuchFieldError unused3) {
                }
                try {
                    iArr[RepositoryError.Unknown.ordinal()] = 4;
                } catch (NoSuchFieldError unused4) {
                }
                f27893a = iArr;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(String str, Map map, vm.d dVar) {
            super(2, dVar);
            this.f27891r = str;
            this.f27892s = map;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new a(this.f27891r, this.f27892s, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f27889p;
            if (i10 == 0) {
                y.b(obj);
                g9.d dVar = e.this.f27867c;
                String str = this.f27891r;
                this.f27889p = 1;
                obj = dVar.linkEmailVerificationToken(str, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            ResultWrapper.Error error = (ResultWrapper.Error) obj;
            RepositoryError error2 = error != null ? error.getError() : null;
            int i11 = error2 == null ? -1 : C0625a.f27893a[error2.ordinal()];
            if (i11 == -1) {
                e.this.f27885u.s();
                f.a.a(e.this.f27869e, "Email_verification_success_Adobe", null, 2, null);
                e.this.b0().putBoolean("one_to_one_duplicate_email_flow", false);
            } else if (i11 == 1) {
                e.this.f27881q.s();
                f.a.c(e.this.f27869e, "1-1 Email - Link Verification Error - We could not verify your email", null, 2, null);
            } else if (i11 == 2) {
                e.this.f27887w.s();
                f.a.c(e.this.f27869e, "1-1 Email - Link Verification Error - Link no longer valid", null, 2, null);
            } else if (i11 == 3 || i11 == 4) {
                e.this.f27883s.s();
                e.this.f27869e.c("Error Page", this.f27892s);
            } else {
                e.this.f27883s.s();
                e.this.f27869e.c("Error Page", this.f27892s);
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((a) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    /* loaded from: classes4.dex */
    static final class b extends kotlin.coroutines.jvm.internal.l implements p {

        /* renamed from: p, reason: collision with root package name */
        int f27894p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ String f27895q;

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

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

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

            static {
                int[] iArr = new int[RepositoryError.values().length];
                try {
                    iArr[RepositoryError.EmailTokenExpired.ordinal()] = 1;
                } catch (NoSuchFieldError unused) {
                }
                try {
                    iArr[RepositoryError.ServiceError.ordinal()] = 2;
                } catch (NoSuchFieldError unused2) {
                }
                try {
                    iArr[RepositoryError.AuthError.ordinal()] = 3;
                } catch (NoSuchFieldError unused3) {
                }
                try {
                    iArr[RepositoryError.NoNetworkError.ordinal()] = 4;
                } catch (NoSuchFieldError unused4) {
                }
                f27897a = iArr;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(String str, e eVar, vm.d dVar) {
            super(2, dVar);
            this.f27895q = str;
            this.f27896r = eVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new b(this.f27895q, this.f27896r, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f27894p;
            if (i10 == 0) {
                y.b(obj);
                if (this.f27895q == null) {
                    this.f27896r.f27875k.q(new Event(kotlin.coroutines.jvm.internal.b.a(false)));
                    return n0.f34904a;
                }
                g9.d dVar = this.f27896r.f27867c;
                String str = this.f27895q;
                this.f27894p = 1;
                obj = dVar.verifyUserEmailToken(str, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            ResultWrapper resultWrapper = (ResultWrapper) obj;
            if (resultWrapper instanceof ResultWrapper.Success) {
                this.f27896r.f27875k.q(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
                LinkedHashMap linkedHashMap = new LinkedHashMap();
                ResultWrapper.Success success = (ResultWrapper.Success) resultWrapper;
                linkedHashMap.put("e.Var106", ((RegistrationEmailVerifiedResponse) success.getData()).getAnalytics().getSourceApp());
                String sourceUrl = ((RegistrationEmailVerifiedResponse) success.getData()).getAnalytics().getSourceUrl();
                if (sourceUrl == null) {
                    sourceUrl = "";
                }
                linkedHashMap.put("e.Var107", sourceUrl);
                String targetUrl = ((RegistrationEmailVerifiedResponse) success.getData()).getAnalytics().getTargetUrl();
                linkedHashMap.put("e.Var108", targetUrl != null ? targetUrl : "");
                if (t.b(((RegistrationEmailVerifiedResponse) success.getData()).getStatus(), "104")) {
                    linkedHashMap.put("s.events", "100");
                }
                this.f27896r.f27869e.c("CPC_consumer_Sign_up_Adobe", linkedHashMap);
            } else if (resultWrapper instanceof ResultWrapper.Error) {
                int i11 = a.f27897a[((ResultWrapper.Error) resultWrapper).getError().ordinal()];
                if (i11 == 1) {
                    this.f27896r.f27877m.q(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
                } else if (i11 == 2 || i11 == 3 || i11 == 4) {
                    this.f27896r.f27879o.q(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
                } else {
                    this.f27896r.f27879o.q(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
                }
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((b) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public e(t7.c contextService, g9.d repository, p9.h featureFlagRepository, d9.f analyticsService, ja.d sharedPreferencesService, g9.d cpcSessionRepository, g9.l userAuthenticationRepository, i9.c oAuthResponseDao) {
        super((Application) r0);
        t.g(contextService, "contextService");
        t.g(repository, "repository");
        t.g(featureFlagRepository, "featureFlagRepository");
        t.g(analyticsService, "analyticsService");
        t.g(sharedPreferencesService, "sharedPreferencesService");
        t.g(cpcSessionRepository, "cpcSessionRepository");
        t.g(userAuthenticationRepository, "userAuthenticationRepository");
        t.g(oAuthResponseDao, "oAuthResponseDao");
        Context a10 = contextService.a();
        t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f27867c = repository;
        this.f27868d = featureFlagRepository;
        this.f27869e = analyticsService;
        this.f27870f = sharedPreferencesService;
        this.f27871g = cpcSessionRepository;
        this.f27872h = userAuthenticationRepository;
        this.f27873i = oAuthResponseDao;
        this.f27874j = new l8.i(contextService);
        Boolean bool = Boolean.FALSE;
        f0 f0Var = new f0(new Event(bool));
        this.f27875k = f0Var;
        this.f27876l = f0Var;
        f0 f0Var2 = new f0(new Event(bool));
        this.f27877m = f0Var2;
        this.f27878n = f0Var2;
        f0 f0Var3 = new f0(new Event(bool));
        this.f27879o = f0Var3;
        this.f27880p = f0Var3;
        l8.g gVar = new l8.g();
        this.f27881q = gVar;
        this.f27882r = gVar;
        l8.g gVar2 = new l8.g();
        this.f27883s = gVar2;
        this.f27884t = gVar2;
        l8.g gVar3 = new l8.g();
        this.f27885u = gVar3;
        this.f27886v = gVar3;
        l8.g gVar4 = new l8.g();
        this.f27887w = gVar4;
        this.f27888x = gVar4;
    }

    @Override // l8.h
    public a0 J() {
        return this.f27874j.J();
    }

    public final g9.d Z() {
        return this.f27871g;
    }

    public final i9.c a0() {
        return this.f27873i;
    }

    public final ja.d b0() {
        return this.f27870f;
    }

    public final g9.l c0() {
        return this.f27872h;
    }

    public final a0 d0() {
        return this.f27876l;
    }

    public final a0 e0() {
        return this.f27878n;
    }

    public final a0 f0() {
        return this.f27882r;
    }

    public final a0 g0() {
        return this.f27888x;
    }

    public final a0 h0() {
        return this.f27884t;
    }

    public final a0 i0() {
        return this.f27886v;
    }

    public final a0 j0() {
        return this.f27880p;
    }

    public final void k0(String str) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("e.Var13", "1-1 Email - Link Verification Error - Try again later");
        if (!(str == null || str.length() == 0)) {
            h.a.a(this, a1.a(this), null, null, null, new a(str, linkedHashMap, null), 7, null);
        } else {
            this.f27883s.s();
            this.f27869e.c("Error Page", linkedHashMap);
        }
    }

    public final void l0(String str) {
        h.a.a(this, a1.a(this), null, null, null, new b(str, this, null), 7, null);
    }

    @Override // l8.h
    public u1 u(m0 m0Var, vm.g context, o0 start, String str, p block) {
        t.g(m0Var, "<this>");
        t.g(context, "context");
        t.g(start, "start");
        t.g(block, "block");
        return this.f27874j.u(m0Var, context, start, str, block);
    }
}
