package jg;

import android.app.Application;
import android.content.Context;
import ca.canadapost.core.data.consumerhome.model.HomeTrackPin;
import ca.canadapost.core.data.consumerhome.model.UpdateTrackPin;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.module.track.model.PackageItemModel;
import ca.canadapost.module.track.model.UpdatePackageFlow;
import d9.f;
import fg.c;
import ig.a;
import l8.h;

/* loaded from: classes4.dex */
public final class w4 extends androidx.lifecycle.b implements l8.h, l8.c {
    public static final a P = new a(null);
    private static int Q;
    private final androidx.lifecycle.f0 A;
    private final l8.g B;
    private final androidx.lifecycle.a0 C;
    private boolean D;
    private final androidx.lifecycle.f0 E;
    private final androidx.lifecycle.a0 F;
    private final androidx.lifecycle.f0 G;
    private final androidx.lifecycle.a0 H;
    private final androidx.lifecycle.g0 I;
    private final androidx.lifecycle.g0 J;
    private final androidx.lifecycle.f0 K;
    private final l8.g L;
    private final androidx.lifecycle.a0 M;
    private final l8.g N;
    private final androidx.lifecycle.a0 O;

    /* renamed from: c, reason: collision with root package name */
    private final fg.c f24884c;

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

    /* renamed from: e, reason: collision with root package name */
    private final j7.c f24886e;

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

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

    /* renamed from: h, reason: collision with root package name */
    private final w8.p f24889h;

    /* renamed from: i, reason: collision with root package name */
    private final UpdatePackageFlow f24890i;

    /* renamed from: j, reason: collision with root package name */
    private final HomeTrackPin f24891j;

    /* renamed from: k, reason: collision with root package name */
    private final l9.c f24892k;

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

    /* renamed from: m, reason: collision with root package name */
    private final /* synthetic */ l8.d f24894m;

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* 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[] f24908a;

        static {
            int[] iArr = new int[UpdatePackageFlow.values().length];
            try {
                iArr[UpdatePackageFlow.UPDATE_PACKAGE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[UpdatePackageFlow.UPDATE_PACKAGE_FROM_HOME.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[UpdatePackageFlow.ADD_PACKAGE.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            f24908a = 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 f24909p;

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f24911r = obj;
            this.f24913t |= Integer.MIN_VALUE;
            return w4.this.Z(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.l implements dn.p {

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f24914p;
            if (i10 == 0) {
                rm.y.b(obj);
                w4 w4Var = w4.this;
                String str = this.f24916r;
                String str2 = this.f24917s;
                this.f24914p = 1;
                if (w4Var.c0(str, str2, 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 ((d) create(m0Var, dVar)).invokeSuspend(rm.n0.f34904a);
        }
    }

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

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f24918p;
            if (i10 == 0) {
                rm.y.b(obj);
                fg.c q02 = w4.this.q0();
                String str = this.f24920r;
                this.f24918p = 1;
                obj = q02.I(str, 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);
            }
            if (((Boolean) obj).booleanValue()) {
                w4.this.f24905x.q(w4.this.g0().getString(yf.h.V2));
                return rm.n0.f34904a;
            }
            w4.this.D0("Track_Single_Adobe");
            w4 w4Var = w4.this;
            String str2 = this.f24920r;
            String str3 = this.f24921s;
            this.f24918p = 2;
            if (w4Var.Z(str2, str3, this) == f10) {
                return f10;
            }
            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);
        }
    }

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

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        f(UpdateTrackPin updateTrackPin, vm.d dVar) {
            super(2, dVar);
            this.f24924r = updateTrackPin;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f24922p;
            if (i10 == 0) {
                rm.y.b(obj);
                l9.c f02 = w4.this.f0();
                UpdateTrackPin updateTrackPin = this.f24924r;
                this.f24922p = 1;
                obj = f02.c(updateTrackPin, 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);
                    w4.this.L.s();
                    return rm.n0.f34904a;
                }
                rm.y.b(obj);
            }
            ResultWrapper resultWrapper = (ResultWrapper) obj;
            if (!(resultWrapper instanceof ResultWrapper.Success)) {
                if (resultWrapper instanceof ResultWrapper.Error) {
                    w4.this.w0((ResultWrapper.Error) resultWrapper, true);
                }
                return rm.n0.f34904a;
            }
            this.f24922p = 2;
            if (tp.w0.a(1000L, this) == f10) {
                return f10;
            }
            w4.this.L.s();
            return rm.n0.f34904a;
        }

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

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f24925p;
            if (i10 == 0) {
                rm.y.b(obj);
                fg.c q02 = w4.this.q0();
                String str = this.f24927r;
                this.f24925p = 1;
                obj = q02.I(str, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            if (!((Boolean) obj).booleanValue()) {
                androidx.lifecycle.f0 f0Var = w4.this.f24903v;
                String upperCase = this.f24927r.toUpperCase();
                kotlin.jvm.internal.t.f(upperCase, "toUpperCase(...)");
                f0Var.q(upperCase);
            }
            return rm.n0.f34904a;
        }

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f24929q = obj;
            this.f24931s |= Integer.MIN_VALUE;
            return w4.this.c0(null, null, this);
        }
    }

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f24932p;
            if (i10 == 0) {
                rm.y.b(obj);
                fg.c q02 = w4.this.q0();
                String str = this.f24934r;
                this.f24932p = 1;
                obj = q02.I(str, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            if (((Boolean) obj).booleanValue()) {
                w4.this.f24905x.q(w4.this.g0().getString(yf.h.V2));
            }
            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);
        }
    }

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f24935p;
            if (i10 == 0) {
                rm.y.b(obj);
                fg.c q02 = w4.this.q0();
                String str = this.f24937r;
                this.f24935p = 1;
                obj = q02.F(str, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            PackageItemModel packageItemModel = (PackageItemModel) obj;
            if (packageItemModel != null) {
                w4.this.q0().A(packageItemModel);
            }
            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);
        }
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public w4(fg.c repository, t7.c contextService, j7.c clipboardService, ja.d sharedPreferencesService, d9.f analyticsService, w8.p appExecutors, UpdatePackageFlow packageFlow, HomeTrackPin homeTrackPin, l9.c consumerHomeRepository) {
        super((Application) r0);
        kotlin.jvm.internal.t.g(repository, "repository");
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(clipboardService, "clipboardService");
        kotlin.jvm.internal.t.g(sharedPreferencesService, "sharedPreferencesService");
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        kotlin.jvm.internal.t.g(appExecutors, "appExecutors");
        kotlin.jvm.internal.t.g(packageFlow, "packageFlow");
        kotlin.jvm.internal.t.g(consumerHomeRepository, "consumerHomeRepository");
        Context a10 = contextService.a();
        kotlin.jvm.internal.t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f24884c = repository;
        this.f24885d = contextService;
        this.f24886e = clipboardService;
        this.f24887f = sharedPreferencesService;
        this.f24888g = analyticsService;
        this.f24889h = appExecutors;
        this.f24890i = packageFlow;
        this.f24891j = homeTrackPin;
        this.f24892k = consumerHomeRepository;
        this.f24893l = new l8.i(contextService);
        this.f24894m = new l8.d();
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0();
        this.f24895n = f0Var;
        this.f24896o = new androidx.lifecycle.f0();
        this.f24897p = repository.s();
        this.f24898q = repository.c();
        androidx.lifecycle.f0 f0Var2 = new androidx.lifecycle.f0();
        this.f24899r = f0Var2;
        this.f24900s = f0Var2;
        androidx.lifecycle.f0 f0Var3 = new androidx.lifecycle.f0();
        this.f24901t = f0Var3;
        this.f24902u = f0Var3;
        androidx.lifecycle.f0 f0Var4 = new androidx.lifecycle.f0();
        this.f24903v = f0Var4;
        this.f24904w = f0Var4;
        androidx.lifecycle.f0 f0Var5 = new androidx.lifecycle.f0();
        this.f24905x = f0Var5;
        this.f24906y = f0Var5;
        this.f24907z = new androidx.lifecycle.f0();
        Boolean bool = Boolean.FALSE;
        this.A = new androidx.lifecycle.f0(bool);
        l8.g gVar = new l8.g();
        this.B = gVar;
        this.C = gVar;
        androidx.lifecycle.f0 f0Var6 = new androidx.lifecycle.f0();
        this.E = f0Var6;
        this.F = f0Var6;
        androidx.lifecycle.f0 f0Var7 = new androidx.lifecycle.f0(bool);
        this.G = f0Var7;
        this.H = f0Var7;
        androidx.lifecycle.g0 g0Var = new androidx.lifecycle.g0() { // from class: jg.u4
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                w4.C0(w4.this, (PackageItemModel) obj);
            }
        };
        this.I = g0Var;
        androidx.lifecycle.g0 g0Var2 = new androidx.lifecycle.g0() { // from class: jg.v4
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                w4.A0(w4.this, (String) obj);
            }
        };
        this.J = g0Var2;
        this.K = new androidx.lifecycle.f0(contextService.getString(yf.h.W2));
        l8.g gVar2 = new l8.g();
        this.L = gVar2;
        this.M = gVar2;
        l8.g gVar3 = new l8.g();
        this.N = gVar3;
        this.O = gVar3;
        repository.c().k(g0Var);
        x0((PackageItemModel) repository.c().f());
        y0();
        z0();
        f0Var.k(g0Var2);
        f.a.c(analyticsService, "TrackAdd", null, 2, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void A0(w4 this$0, String str) {
        kotlin.jvm.internal.t.g(this$0, "this$0");
        if (str != null) {
            this$0.B0(str);
        }
    }

    private final void B0(String str) {
        if (this.D) {
            if (str.length() == 0) {
                this.f24905x.q(null);
            } else {
                this.f24905x.q(null);
                tp.k.d(androidx.lifecycle.a1.a(this), null, null, new i(str, null), 3, null);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void C0(w4 this$0, PackageItemModel packageItemModel) {
        kotlin.jvm.internal.t.g(this$0, "this$0");
        this$0.x0(packageItemModel);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void D0(String str) {
        this.f24884c.L(str);
    }

    private final void F0(String str) {
        d0();
        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new j(str, null), 3, null);
        this.f24899r.q(new Event(this.f24885d.getString(yf.h.f52578f3)));
        this.f24901t.q(new Event(Boolean.TRUE));
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:12:0x0058  */
    /* JADX WARN: Removed duplicated region for block: B:19:0x008b  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x003b  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0024  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object Z(String str, String str2, vm.d dVar) {
        c cVar;
        Object f10;
        int i10;
        ResultWrapper resultWrapper;
        if (dVar instanceof c) {
            cVar = (c) dVar;
            int i11 = cVar.f24913t;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                cVar.f24913t = i11 - Integer.MIN_VALUE;
                c cVar2 = cVar;
                Object obj = cVar2.f24911r;
                f10 = wm.d.f();
                i10 = cVar2.f24913t;
                if (i10 != 0) {
                    rm.y.b(obj);
                    fg.c cVar3 = this.f24884c;
                    cVar2.f24909p = this;
                    cVar2.f24910q = str;
                    cVar2.f24913t = 1;
                    obj = c.a.a(cVar3, str, str2, false, cVar2, 4, null);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    str = (String) cVar2.f24910q;
                    this = (w4) cVar2.f24909p;
                    rm.y.b(obj);
                }
                resultWrapper = (ResultWrapper) obj;
                if (resultWrapper instanceof ResultWrapper.Error) {
                    this.F0(str);
                } else {
                    ResultWrapper.Error error = (ResultWrapper.Error) resultWrapper;
                    RepositoryError error2 = error.getError();
                    RepositoryError repositoryError = RepositoryError.NoNetworkError;
                    if (error2 == repositoryError) {
                        this.w0(new ResultWrapper.Error(error.getException(), null, repositoryError, null, 8, null), true);
                        this.F0(str);
                    } else {
                        this.f24899r.q(new Event(this.f24885d.getString(yf.h.f52629q)));
                    }
                }
                return rm.n0.f34904a;
            }
        }
        cVar = new c(dVar);
        c cVar22 = cVar;
        Object obj2 = cVar22.f24911r;
        f10 = wm.d.f();
        i10 = cVar22.f24913t;
        if (i10 != 0) {
        }
        resultWrapper = (ResultWrapper) obj2;
        if (resultWrapper instanceof ResultWrapper.Error) {
        }
        return rm.n0.f34904a;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:13:0x00e4  */
    /* JADX WARN: Removed duplicated region for block: B:17:0x00f7  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x009a  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x00ad  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0041  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0024  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object c0(String str, String str2, vm.d dVar) {
        h hVar;
        Object f10;
        int i10;
        if (dVar instanceof h) {
            hVar = (h) dVar;
            int i11 = hVar.f24931s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                hVar.f24931s = i11 - Integer.MIN_VALUE;
                Object obj = hVar.f24929q;
                f10 = wm.d.f();
                i10 = hVar.f24931s;
                if (i10 != 0) {
                    rm.y.b(obj);
                    PackageItemModel packageItemModel = (PackageItemModel) this.f24884c.c().f();
                    if (packageItemModel == null) {
                        return rm.n0.f34904a;
                    }
                    if (kotlin.jvm.internal.t.b(str, packageItemModel.getItemNumber()) && kotlin.jvm.internal.t.b(str2, packageItemModel.getUserDescription())) {
                        this.f24901t.q(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
                        return rm.n0.f34904a;
                    }
                    if (kotlin.jvm.internal.t.b(str, packageItemModel.getItemNumber())) {
                        packageItemModel.setUserDescription(str2);
                        fg.c cVar = this.f24884c;
                        hVar.f24928p = this;
                        hVar.f24931s = 1;
                        obj = cVar.h(packageItemModel, hVar);
                        if (obj == f10) {
                            return f10;
                        }
                        if (((ResultWrapper) obj) instanceof ResultWrapper.Error) {
                        }
                    } else {
                        fg.c cVar2 = this.f24884c;
                        hVar.f24928p = this;
                        hVar.f24931s = 2;
                        obj = cVar2.v(str, str2, hVar);
                        if (obj == f10) {
                            return f10;
                        }
                        if (((ResultWrapper) obj) instanceof ResultWrapper.Error) {
                        }
                    }
                } else if (i10 == 1) {
                    this = (w4) hVar.f24928p;
                    rm.y.b(obj);
                    if (((ResultWrapper) obj) instanceof ResultWrapper.Error) {
                        this.d0();
                        this.f24899r.q(new Event(this.f24885d.getString(yf.h.f52553a3)));
                        this.f24901t.q(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
                    } else {
                        this.f24899r.q(new Event(this.f24885d.getString(yf.h.f52629q)));
                    }
                } else {
                    if (i10 != 2) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    this = (w4) hVar.f24928p;
                    rm.y.b(obj);
                    if (((ResultWrapper) obj) instanceof ResultWrapper.Error) {
                        this.d0();
                        this.f24899r.q(new Event(this.f24885d.getString(yf.h.f52553a3)));
                        this.f24901t.q(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
                    } else {
                        this.f24899r.q(new Event(this.f24885d.getString(yf.h.f52629q)));
                    }
                }
                return rm.n0.f34904a;
            }
        }
        hVar = new h(dVar);
        Object obj2 = hVar.f24929q;
        f10 = wm.d.f();
        i10 = hVar.f24931s;
        if (i10 != 0) {
        }
        return rm.n0.f34904a;
    }

    private final void d0() {
    }

    private final void x0(PackageItemModel packageItemModel) {
        HomeTrackPin homeTrackPin;
        int i10 = b.f24908a[this.f24890i.ordinal()];
        if (i10 == 1) {
            if (packageItemModel != null) {
                this.E.q(packageItemModel.isItemSourceSNF() ? this.f24885d.getString(yf.h.f52623o3) : this.f24885d.getString(yf.h.f52628p3));
                this.f24895n.q(packageItemModel.getItemNumber());
                this.f24896o.q(packageItemModel.getUserDescription());
                this.G.q(Boolean.valueOf(packageItemModel.isItemSourceSNF()));
                return;
            }
            return;
        }
        if (i10 == 2 && (homeTrackPin = this.f24891j) != null) {
            this.f24895n.q(homeTrackPin.getTrackId());
            this.f24896o.q(homeTrackPin.getUserDescription());
            this.K.q(this.f24885d.getString(yf.h.f52662w2));
            this.G.q(Boolean.TRUE);
        }
    }

    private final void y0() {
        androidx.lifecycle.f0 f0Var = this.f24907z;
        t7.c cVar = this.f24885d;
        int i10 = b.f24908a[this.f24890i.ordinal()];
        f0Var.q(cVar.getString((i10 == 1 || i10 == 2) ? yf.h.C1 : yf.h.f52614n));
    }

    private final void z0() {
        this.A.q(Boolean.valueOf(this.f24890i == UpdatePackageFlow.ADD_PACKAGE));
    }

    public final void E0(String itemNumber) {
        kotlin.jvm.internal.t.g(itemNumber, "itemNumber");
        this.f24895n.q(itemNumber);
        D0("Track_Single_Adobe");
    }

    public final void G0() {
        this.B.s();
    }

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

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.lifecycle.z0
    public void O() {
        this.f24884c.c().o(this.I);
        this.f24895n.o(this.J);
        super.O();
    }

    public final void Y(String number) {
        kotlin.jvm.internal.t.g(number, "number");
        a.C0491a c0491a = ig.a.f23217a;
        if (!c0491a.d(number)) {
            if (qa.d.h(number) || number.length() != 28) {
                this.f24899r.q(new Event(this.f24885d.getString(yf.h.f52604l)));
                return;
            }
            number = number.substring(7, 23);
            kotlin.jvm.internal.t.f(number, "substring(...)");
            if (!c0491a.d(number)) {
                number = null;
            }
        }
        if (number != null) {
            D0("Track_Scan_Adobe");
            Q++;
            this.f24895n.q(number);
            a0();
        }
    }

    public final void a0() {
        boolean z10;
        CharSequence charSequence;
        String str;
        CharSequence e12;
        this.D = true;
        PackageItemModel packageItemModel = (PackageItemModel) this.f24898q.f();
        if (!(packageItemModel != null ? packageItemModel.isItemSourceSNF() : false)) {
            HomeTrackPin homeTrackPin = this.f24891j;
            if (!kotlin.jvm.internal.t.b(homeTrackPin != null ? homeTrackPin.getSource() : null, "SET_AND_FORGET")) {
                z10 = false;
                charSequence = (CharSequence) this.f24895n.f();
                if (!(charSequence != null || charSequence.length() == 0) || (!ig.a.f23217a.d((String) this.f24895n.f()) && !z10)) {
                    this.f24905x.q(this.f24885d.getString(yf.h.Y2));
                }
                String str2 = (String) this.f24895n.f();
                if (str2 != null) {
                    String g10 = new kotlin.text.l("\\s").g(str2, "");
                    String str3 = (String) this.f24896o.f();
                    if (str3 != null) {
                        kotlin.jvm.internal.t.d(str3);
                        e12 = kotlin.text.z.e1(str3);
                        str = e12.toString();
                    } else {
                        str = null;
                    }
                    this.f24905x.q(null);
                    int i10 = b.f24908a[this.f24890i.ordinal()];
                    if (i10 == 1) {
                        this.D = false;
                        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new d(g10, str, null), 3, null);
                        return;
                    } else if (i10 != 2) {
                        if (i10 != 3) {
                            throw new rm.t();
                        }
                        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new e(g10, str, null), 3, null);
                        return;
                    } else {
                        HomeTrackPin homeTrackPin2 = this.f24891j;
                        if (homeTrackPin2 != null) {
                            h.a.a(this, androidx.lifecycle.a1.a(this), null, null, null, new f(new UpdateTrackPin(homeTrackPin2.getRecordId(), homeTrackPin2.getSource(), homeTrackPin2.getTrackId(), homeTrackPin2.getType(), str), null), 7, null);
                            return;
                        }
                        return;
                    }
                }
                return;
            }
        }
        z10 = true;
        charSequence = (CharSequence) this.f24895n.f();
        if (!(charSequence != null || charSequence.length() == 0)) {
        }
        this.f24905x.q(this.f24885d.getString(yf.h.Y2));
    }

    public final void b0() {
        String b10 = this.f24886e.b();
        if (b10 == null || b10.length() >= 20) {
            return;
        }
        String string = this.f24887f.getString("lastClipboardData", "");
        kotlin.jvm.internal.t.f(string, "getString(...)");
        if (kotlin.jvm.internal.t.b(string, b10) || !ig.a.f23217a.d(b10)) {
            return;
        }
        this.f24887f.putString("lastClipboardData", b10);
        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new g(b10, null), 3, null);
    }

    public final androidx.lifecycle.a0 e0() {
        return this.f24902u;
    }

    public final l9.c f0() {
        return this.f24892k;
    }

    public final t7.c g0() {
        return this.f24885d;
    }

    public final androidx.lifecycle.a0 h0() {
        return this.H;
    }

    public final androidx.lifecycle.f0 i0() {
        return this.f24896o;
    }

    public final androidx.lifecycle.a0 j0() {
        return this.O;
    }

    public final androidx.lifecycle.f0 k0() {
        return this.K;
    }

    public final androidx.lifecycle.f0 l0() {
        return this.f24895n;
    }

    public final androidx.lifecycle.a0 m0() {
        return this.f24906y;
    }

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

    @Override // l8.c
    public androidx.lifecycle.a0 o() {
        return this.f24894m.o();
    }

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

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

    public final fg.c q0() {
        return this.f24884c;
    }

    public final androidx.lifecycle.f0 r0() {
        return this.f24907z;
    }

    public final androidx.lifecycle.f0 s0() {
        return this.A;
    }

    @Override // l8.c
    public androidx.lifecycle.a0 t() {
        return this.f24894m.t();
    }

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

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

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

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

    public void w0(ResultWrapper.Error error, boolean z10) {
        kotlin.jvm.internal.t.g(error, "error");
        this.f24894m.a(error, z10);
    }
}
