package gc;

import ca.canadapost.core.data.auth.model.ProofingState;
import ca.canadapost.core.data.flex.model.AdditionalStepBeforeAddLocation;
import ca.canadapost.core.data.flex.model.FlexLocation;
import ca.canadapost.core.data.flex.model.FlexService;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.core.data.model.ResultWrapper;
import d9.f;
import java.util.Map;

/* loaded from: classes4.dex */
public final class w1 extends a8.b {
    private final androidx.lifecycle.a0 A;
    private final androidx.lifecycle.f0 B;
    private final androidx.lifecycle.a0 C;
    private final androidx.lifecycle.f0 D;
    private final androidx.lifecycle.a0 E;
    private final androidx.lifecycle.f0 F;
    private final androidx.lifecycle.a0 G;
    private final androidx.lifecycle.f0 H;
    private final androidx.lifecycle.f0 I;
    private final androidx.lifecycle.a0 J;
    private androidx.lifecycle.f0 K;
    private final androidx.lifecycle.a0 L;
    private final androidx.lifecycle.f0 M;
    private final androidx.lifecycle.a0 N;

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

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

    /* renamed from: q, reason: collision with root package name */
    private final aa.a f19826q;

    /* renamed from: r, reason: collision with root package name */
    private final androidx.lifecycle.a0 f19827r;

    /* renamed from: s, reason: collision with root package name */
    private final androidx.lifecycle.a0 f19828s;

    /* renamed from: t, reason: collision with root package name */
    private final androidx.lifecycle.a0 f19829t;

    /* renamed from: u, reason: collision with root package name */
    private final androidx.lifecycle.a0 f19830u;

    /* renamed from: v, reason: collision with root package name */
    private final androidx.lifecycle.a0 f19831v;

    /* renamed from: w, reason: collision with root package name */
    private final androidx.lifecycle.a0 f19832w;

    /* renamed from: x, reason: collision with root package name */
    private final androidx.lifecycle.f0 f19833x;

    /* renamed from: y, reason: collision with root package name */
    private final androidx.lifecycle.a0 f19834y;

    /* renamed from: z, reason: collision with root package name */
    private final androidx.lifecycle.f0 f19835z;

    /* loaded from: classes4.dex */
    static final class a extends kotlin.jvm.internal.v implements dn.l {
        a() {
            super(1);
        }

        public final void a(FlexLocation.FlexLocationItem flexLocationItem) {
            if (flexLocationItem == null) {
                w1.this.I.q(Boolean.TRUE);
                return;
            }
            w1.this.e0(flexLocationItem.getServiceTypes());
            w1.this.d0(flexLocationItem.getAddress());
            w1.this.g0(flexLocationItem.getSupportedLanguage());
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((FlexLocation.FlexLocationItem) obj);
            return rm.n0.f34904a;
        }
    }

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

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ t7.c f19837p;

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(t7.c cVar, w1 w1Var) {
            super(1);
            this.f19837p = cVar;
            this.f19838q = w1Var;
        }

        public final void a(String str) {
            if (kotlin.jvm.internal.t.b(str, this.f19837p.getString(e2.f19624d))) {
                this.f19838q.Z().q(this.f19837p.getString(e2.f19641l0));
                return;
            }
            if (kotlin.jvm.internal.t.b(str, this.f19837p.getString(e2.Q))) {
                this.f19838q.Z().q(this.f19837p.getString(e2.f19639k0));
            } else if (kotlin.jvm.internal.t.b(str, this.f19837p.getString(e2.f19629f0))) {
                this.f19838q.Z().q(this.f19837p.getString(e2.f19637j0));
            } else {
                this.f19838q.Z().q(this.f19837p.getString(e2.f19639k0));
            }
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            a((String) obj);
            return rm.n0.f34904a;
        }
    }

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

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

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ FlexLocation.FlexLocationItem.Flex f19841r;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        c(FlexLocation.FlexLocationItem.Flex flex, vm.d dVar) {
            super(2, dVar);
            this.f19841r = flex;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f19839p;
            if (i10 == 0) {
                rm.y.b(obj);
                w1 w1Var = w1.this;
                FlexLocation.FlexLocationItem.Flex flex = this.f19841r;
                this.f19839p = 1;
                if (w1Var.k0(flex, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return rm.n0.f34904a;
        }

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

    /* 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 f19842p;

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19843q = obj;
            this.f19845s |= Integer.MIN_VALUE;
            return w1.this.k0(null, this);
        }
    }

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

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

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ FlexLocation.FlexLocationItem.Apl f19848r;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        e(FlexLocation.FlexLocationItem.Apl apl, vm.d dVar) {
            super(2, dVar);
            this.f19848r = apl;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f19846p;
            if (i10 == 0) {
                rm.y.b(obj);
                w1 w1Var = w1.this;
                FlexLocation.FlexLocationItem.Apl apl = this.f19848r;
                this.f19846p = 1;
                if (w1Var.k0(apl, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return rm.n0.f34904a;
        }

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

    /* loaded from: classes4.dex */
    static final class f extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final f f19849p = new f();

        f() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(ProofingState proofingState) {
            return proofingState != null ? Boolean.valueOf(!proofingState.isL1Authenticated()) : Boolean.FALSE;
        }
    }

    /* loaded from: classes4.dex */
    static final class g extends kotlin.jvm.internal.v implements dn.l {

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

        g() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(Boolean bool) {
            return bool == null ? Boolean.TRUE : Boolean.valueOf(!bool.booleanValue());
        }
    }

    /* loaded from: classes4.dex */
    static final class h extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final h f19851p = new h();

        h() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final androidx.lifecycle.a0 invoke(AdditionalStepBeforeAddLocation additionalStepBeforeAddLocation) {
            return new androidx.lifecycle.f0(new Event(additionalStepBeforeAddLocation));
        }
    }

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

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        i(AdditionalStepBeforeAddLocation additionalStepBeforeAddLocation, vm.d dVar) {
            super(2, dVar);
            this.f19854r = additionalStepBeforeAddLocation;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f19852p;
            if (i10 == 0) {
                rm.y.b(obj);
                w1 w1Var = w1.this;
                FlexLocation.FlexLocationItem.FlexOrApl location = ((AdditionalStepBeforeAddLocation.LOGIN) this.f19854r).getLocation();
                this.f19852p = 1;
                if (w1Var.k0(location, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return rm.n0.f34904a;
        }

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

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

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        j(AdditionalStepBeforeAddLocation additionalStepBeforeAddLocation, vm.d dVar) {
            super(2, dVar);
            this.f19857r = additionalStepBeforeAddLocation;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f19855p;
            if (i10 == 0) {
                rm.y.b(obj);
                v9.d Y = w1.this.Y();
                this.f19855p = 1;
                obj = Y.s(this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    if (i10 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    rm.y.b(obj);
                    return rm.n0.f34904a;
                }
                rm.y.b(obj);
            }
            ProofingState proofingState = (ProofingState) obj;
            if (!(proofingState != null && proofingState.isL1Authenticated())) {
                return rm.n0.f34904a;
            }
            w1 w1Var = w1.this;
            FlexLocation.FlexLocationItem.FlexOrApl location = ((AdditionalStepBeforeAddLocation.L1AUTH) this.f19857r).getLocation();
            this.f19855p = 2;
            if (w1Var.k0(location, this) == f10) {
                return f10;
            }
            return rm.n0.f34904a;
        }

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

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

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        k(AdditionalStepBeforeAddLocation additionalStepBeforeAddLocation, vm.d dVar) {
            super(2, dVar);
            this.f19860r = additionalStepBeforeAddLocation;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f19858p;
            if (i10 == 0) {
                rm.y.b(obj);
                w1 w1Var = w1.this;
                FlexLocation.FlexLocationItem.FlexOrApl location = ((AdditionalStepBeforeAddLocation.TANDC) this.f19860r).getLocation();
                this.f19858p = 1;
                if (w1Var.k0(location, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return rm.n0.f34904a;
        }

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

    /* loaded from: classes4.dex */
    static final class l implements androidx.lifecycle.g0, kotlin.jvm.internal.n {

        /* renamed from: a, reason: collision with root package name */
        private final /* synthetic */ dn.l f19861a;

        l(dn.l function) {
            kotlin.jvm.internal.t.g(function, "function");
            this.f19861a = function;
        }

        @Override // kotlin.jvm.internal.n
        public final rm.i b() {
            return this.f19861a;
        }

        @Override // androidx.lifecycle.g0
        public final /* synthetic */ void d(Object obj) {
            this.f19861a.invoke(obj);
        }

        public final boolean equals(Object obj) {
            if ((obj instanceof androidx.lifecycle.g0) && (obj instanceof kotlin.jvm.internal.n)) {
                return kotlin.jvm.internal.t.b(b(), ((kotlin.jvm.internal.n) obj).b());
            }
            return false;
        }

        public final int hashCode() {
            return b().hashCode();
        }
    }

    /* loaded from: classes4.dex */
    static final class m extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final m f19862p = new m();

        m() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem flexLocationItem) {
            FlexLocation.FlexLocationItem.Apl apl;
            if (flexLocationItem == null || (apl = flexLocationItem.getApl()) == null) {
                return Boolean.FALSE;
            }
            return Boolean.valueOf(!apl.isSaved() && kotlin.jvm.internal.t.b(apl.getStatus(), "ACTIVE"));
        }
    }

    /* loaded from: classes4.dex */
    static final class n extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final n f19863p = new n();

        n() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem flexLocationItem) {
            FlexLocation.FlexLocationItem.Flex flex;
            if (flexLocationItem == null || (flex = flexLocationItem.getFlex()) == null) {
                return Boolean.FALSE;
            }
            return Boolean.valueOf(!flex.isSaved() && kotlin.jvm.internal.t.b(flex.getStatus(), "ACTIVE"));
        }
    }

    /* loaded from: classes4.dex */
    static final class o extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final o f19864p = new o();

        o() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem flexLocationItem) {
            FlexLocation.FlexLocationItem.Apl apl;
            return (flexLocationItem == null || (apl = flexLocationItem.getApl()) == null) ? Boolean.FALSE : Boolean.valueOf(apl.isSaved());
        }
    }

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

        /* renamed from: p, reason: collision with root package name */
        public static final p f19865p = new p();

        p() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem flexLocationItem) {
            FlexLocation.FlexLocationItem.Flex flex;
            return (flexLocationItem == null || (flex = flexLocationItem.getFlex()) == null) ? Boolean.FALSE : Boolean.valueOf(flex.isSaved());
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public w1(v9.d repository, t7.c contextService, g9.h l1Repository, ca.a languageService, d9.f analyticsService, g9.d sessionRepository, aa.a iInAppReviewRepositoryService) {
        super(repository, contextService, languageService);
        kotlin.jvm.internal.t.g(repository, "repository");
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(l1Repository, "l1Repository");
        kotlin.jvm.internal.t.g(languageService, "languageService");
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        kotlin.jvm.internal.t.g(sessionRepository, "sessionRepository");
        kotlin.jvm.internal.t.g(iInAppReviewRepositoryService, "iInAppReviewRepositoryService");
        this.f19824o = analyticsService;
        this.f19825p = sessionRepository;
        this.f19826q = iInAppReviewRepositoryService;
        this.f19827r = androidx.lifecycle.y0.a(l1Repository.c(), f.f19849p);
        this.f19828s = androidx.lifecycle.y0.a(repository.q(), g.f19850p);
        this.f19829t = androidx.lifecycle.y0.a(repository.n(), p.f19865p);
        this.f19830u = androidx.lifecycle.y0.a(repository.n(), o.f19864p);
        this.f19831v = androidx.lifecycle.y0.a(repository.n(), n.f19863p);
        this.f19832w = androidx.lifecycle.y0.a(repository.n(), m.f19862p);
        Boolean bool = Boolean.FALSE;
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0(new Event(bool));
        this.f19833x = f0Var;
        this.f19834y = f0Var;
        androidx.lifecycle.f0 f0Var2 = new androidx.lifecycle.f0(new Event(bool));
        this.f19835z = f0Var2;
        this.A = f0Var2;
        androidx.lifecycle.f0 f0Var3 = new androidx.lifecycle.f0();
        this.B = f0Var3;
        this.C = f0Var3;
        androidx.lifecycle.f0 f0Var4 = new androidx.lifecycle.f0();
        this.D = f0Var4;
        this.E = androidx.lifecycle.y0.b(f0Var4, h.f19851p);
        androidx.lifecycle.f0 f0Var5 = new androidx.lifecycle.f0();
        this.F = f0Var5;
        this.G = f0Var5;
        androidx.lifecycle.f0 f0Var6 = new androidx.lifecycle.f0();
        this.H = f0Var6;
        androidx.lifecycle.f0 f0Var7 = new androidx.lifecycle.f0(bool);
        this.I = f0Var7;
        this.J = f0Var7;
        androidx.lifecycle.f0 f0Var8 = new androidx.lifecycle.f0();
        this.K = f0Var8;
        this.L = f0Var8;
        f0Var8.q("");
        b0().r(a0(), new l(new a()));
        f0Var6.q(null);
        Z().r(b0(), new l(new b(contextService, this)));
        androidx.lifecycle.f0 f0Var9 = new androidx.lifecycle.f0();
        this.M = f0Var9;
        this.N = f0Var9;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:12:0x006a  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x00ac  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0035  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object k0(FlexLocation.FlexLocationItem.FlexOrApl flexOrApl, vm.d dVar) {
        d dVar2;
        Object f10;
        int i10;
        ResultWrapper resultWrapper;
        if (dVar instanceof d) {
            dVar2 = (d) dVar;
            int i11 = dVar2.f19845s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                dVar2.f19845s = i11 - Integer.MIN_VALUE;
                Object obj = dVar2.f19843q;
                f10 = wm.d.f();
                i10 = dVar2.f19845s;
                if (i10 != 0) {
                    rm.y.b(obj);
                    this.B.n(new Event(new w8.r0(w8.q0.ON, S().getString(e2.f19622c))));
                    v9.d Y = Y();
                    dVar2.f19842p = this;
                    dVar2.f19845s = 1;
                    obj = Y.t(flexOrApl, dVar2);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    this = (w1) dVar2.f19842p;
                    rm.y.b(obj);
                }
                resultWrapper = (ResultWrapper) obj;
                if (!(resultWrapper instanceof ResultWrapper.Success)) {
                    this.B.n(new Event(new w8.r0(w8.q0.OFF, null, 2, null)));
                    this.f19826q.a();
                    FlexService flexService = (FlexService) this.H.f();
                    if (flexService != null) {
                        if (flexService == FlexService.FLEX) {
                            this.D0();
                        } else {
                            this.C0();
                        }
                    }
                    f.a.a(this.f19824o, "Flex_Add_a_post_office_Adobe", null, 2, null);
                    this.K.q(this.S().getString(e2.f19644n));
                } else if (resultWrapper instanceof ResultWrapper.Error) {
                    this.B.n(new Event(new w8.r0(w8.q0.OFF, null, 2, null)));
                    ResultWrapper.Error error = (ResultWrapper.Error) resultWrapper;
                    if (error.getAdditionalInfo() instanceof AdditionalStepBeforeAddLocation) {
                        androidx.lifecycle.f0 f0Var = this.D;
                        Object additionalInfo = error.getAdditionalInfo();
                        kotlin.jvm.internal.t.e(additionalInfo, "null cannot be cast to non-null type ca.canadapost.core.data.flex.model.AdditionalStepBeforeAddLocation");
                        f0Var.q((AdditionalStepBeforeAddLocation) additionalInfo);
                        return rm.n0.f34904a;
                    }
                    this.K.q("Error while adding location");
                }
                return rm.n0.f34904a;
            }
        }
        dVar2 = new d(dVar);
        Object obj2 = dVar2.f19843q;
        f10 = wm.d.f();
        i10 = dVar2.f19845s;
        if (i10 != 0) {
        }
        resultWrapper = (ResultWrapper) obj2;
        if (!(resultWrapper instanceof ResultWrapper.Success)) {
        }
        return rm.n0.f34904a;
    }

    public final void A0() {
        try {
            AdditionalStepBeforeAddLocation additionalStepBeforeAddLocation = (AdditionalStepBeforeAddLocation) this.D.f();
            if (additionalStepBeforeAddLocation != null && !(additionalStepBeforeAddLocation instanceof AdditionalStepBeforeAddLocation.NONE)) {
                if (additionalStepBeforeAddLocation instanceof AdditionalStepBeforeAddLocation.LOGIN) {
                    if (this.f19825p.h()) {
                        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new i(additionalStepBeforeAddLocation, null), 3, null);
                    }
                } else if (additionalStepBeforeAddLocation instanceof AdditionalStepBeforeAddLocation.L1AUTH) {
                    tp.k.d(androidx.lifecycle.a1.a(this), null, null, new j(additionalStepBeforeAddLocation, null), 3, null);
                } else if ((additionalStepBeforeAddLocation instanceof AdditionalStepBeforeAddLocation.TANDC) && kotlin.jvm.internal.t.b(Y().q().f(), Boolean.TRUE)) {
                    tp.k.d(androidx.lifecycle.a1.a(this), null, null, new k(additionalStepBeforeAddLocation, null), 3, null);
                }
            }
        } finally {
            this.D.q(AdditionalStepBeforeAddLocation.NONE.INSTANCE);
        }
    }

    public final void B0() {
        StringBuffer m02 = m0();
        if (m02 != null) {
            this.f19824o.b("Flex_Share_Address_Adobe", null);
            this.M.q(m02.toString());
        }
    }

    public final void C0() {
        this.f19835z.q(new Event(Boolean.TRUE));
        this.f19824o.b("APL - Add_Event_See_Postal_Locker_DetailsView", null);
        Y().o(FlexService.APL);
    }

    public final void D0() {
        String costCentreId;
        Map l10;
        this.f19833x.q(new Event(Boolean.TRUE));
        FlexLocation.FlexLocationItem flexLocationItem = (FlexLocation.FlexLocationItem) Y().n().f();
        if (flexLocationItem == null) {
            throw new IllegalStateException("Something is wrong, selected postoffice can not be null here".toString());
        }
        FlexLocation.FlexLocationItem.Flex flex = flexLocationItem.getFlex();
        if (flex != null && (costCentreId = flex.getCostCentreId()) != null) {
            d9.f fVar = this.f19824o;
            l10 = sm.q0.l(rm.c0.a("e.Var148", costCentreId), rm.c0.a("s.prop68", costCentreId));
            fVar.b("Flex_Details_Post_Office_Adobe", l10);
        }
        Y().o(FlexService.FLEX);
    }

    public final void j0() {
        FlexLocation.FlexLocationItem.Flex flex;
        Map l10;
        FlexLocation.FlexLocationItem flexLocationItem = (FlexLocation.FlexLocationItem) a0().f();
        if (flexLocationItem == null || (flex = flexLocationItem.getFlex()) == null) {
            return;
        }
        this.H.q(FlexService.FLEX);
        d9.f fVar = this.f19824o;
        l10 = sm.q0.l(rm.c0.a("e.Var148", flex.getCostCentreId()), rm.c0.a("s.prop68", flex.getCostCentreId()));
        fVar.b("Flex_Save_Post_Office_Adobe", l10);
        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new c(flex, null), 3, null);
    }

    public final void l0() {
        FlexLocation.FlexLocationItem.Apl apl;
        Map l10;
        FlexLocation.FlexLocationItem flexLocationItem = (FlexLocation.FlexLocationItem) a0().f();
        if (flexLocationItem == null || (apl = flexLocationItem.getApl()) == null) {
            return;
        }
        this.H.q(FlexService.APL);
        this.f19824o.b("APL - Add_Event_Save_FlexDelivery_DetailsView", null);
        d9.f fVar = this.f19824o;
        l10 = sm.q0.l(rm.c0.a("e.Var148", apl.getCostCentreId()), rm.c0.a("s.prop68", apl.getCostCentreId()));
        fVar.b("Flex_APL_Save_Automated_Locker_Adobe", l10);
        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new e(apl, null), 3, null);
    }

    public final StringBuffer m0() {
        FlexLocation.FlexLocationItem flexLocationItem = (FlexLocation.FlexLocationItem) a0().f();
        if (flexLocationItem == null) {
            return null;
        }
        String name = flexLocationItem.getName();
        StringBuffer stringBuffer = new StringBuffer();
        FlexLocation.FlexLocationItem.Flex flex = flexLocationItem.getFlex();
        if (flex != null && flex.isSaved()) {
            if (!qa.d.h(flex.getAlias())) {
                name = String.valueOf(flex.getAlias());
            }
            stringBuffer = flex.getMailingAddress().getFormattedAddress();
        }
        StringBuffer stringBuffer2 = new StringBuffer();
        FlexLocation.FlexLocationItem.Apl apl = flexLocationItem.getApl();
        if (apl != null && apl.isSaved()) {
            if (!qa.d.h(apl.getAlias())) {
                name = String.valueOf(apl.getAlias());
            }
            stringBuffer2 = apl.getMailingAddress().getFormattedAddress();
        }
        StringBuffer stringBuffer3 = new StringBuffer();
        stringBuffer3.append(name);
        stringBuffer3.append("\n");
        stringBuffer3.append("\n");
        StringBuffer formattedAddress = flexLocationItem.getAddress().getFormattedAddress();
        if (stringBuffer.length() == 0) {
            if (stringBuffer2.length() == 0) {
                stringBuffer3.append(formattedAddress);
                return stringBuffer3;
            }
        }
        stringBuffer3.append(S().getString(e2.f19645n0));
        stringBuffer3.append("\n");
        if (!(stringBuffer.length() > 0)) {
            stringBuffer = stringBuffer2;
        }
        stringBuffer3.append(stringBuffer);
        stringBuffer3.append("\n");
        stringBuffer3.append("\n");
        stringBuffer3.append(S().getString(e2.f19635i0));
        stringBuffer3.append("\n");
        stringBuffer3.append(formattedAddress);
        return stringBuffer3;
    }

    public final androidx.lifecycle.a0 n0() {
        return this.J;
    }

    public final androidx.lifecycle.a0 o0() {
        return this.E;
    }

    public final androidx.lifecycle.a0 p0() {
        return this.N;
    }

    public final androidx.lifecycle.a0 q0() {
        return this.f19832w;
    }

    public final androidx.lifecycle.a0 r0() {
        return this.f19831v;
    }

    public final androidx.lifecycle.a0 s0() {
        return this.f19830u;
    }

    public final androidx.lifecycle.a0 t0() {
        return this.A;
    }

    public final androidx.lifecycle.a0 u0() {
        return this.f19829t;
    }

    public final androidx.lifecycle.a0 v0() {
        return this.f19834y;
    }

    public final androidx.lifecycle.a0 w0() {
        return this.L;
    }

    public final androidx.lifecycle.a0 x0() {
        return this.C;
    }

    public final androidx.lifecycle.a0 y0() {
        return this.G;
    }

    public final androidx.lifecycle.a0 z0() {
        return this.f19827r;
    }
}
