package com.vinfast.companion.main.ui.gltestdrive.schedule;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@dagger.hilt.android.lifecycle.HiltViewModel
@kotlin.Metadata(d1 = {"\u0000v\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\"\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\n\b\u0007\u0018\u00002\u00020\u0001B\u0011\b\u0007\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\t\u001a\u00020\b2\u0006\u0010\u0007\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\t\u0010\nJ\r\u0010\u000b\u001a\u00020\b¢\u0006\u0004\b\u000b\u0010\fJ\r\u0010\r\u001a\u00020\b¢\u0006\u0004\b\r\u0010\fJ\u0017\u0010\u0010\u001a\u00020\b2\b\u0010\u000f\u001a\u0004\u0018\u00010\u000e¢\u0006\u0004\b\u0010\u0010\u0011J\u0015\u0010\u0014\u001a\u00020\b2\u0006\u0010\u0013\u001a\u00020\u0012¢\u0006\u0004\b\u0014\u0010\u0015J\u0015\u0010\u0018\u001a\u00020\b2\u0006\u0010\u0017\u001a\u00020\u0016¢\u0006\u0004\b\u0018\u0010\u0019J\u0015\u0010\u001c\u001a\u00020\b2\u0006\u0010\u001b\u001a\u00020\u001a¢\u0006\u0004\b\u001c\u0010\u001dJ\u0015\u0010 \u001a\u00020\b2\u0006\u0010\u001f\u001a\u00020\u001e¢\u0006\u0004\b \u0010!J\r\u0010\"\u001a\u00020\u0006¢\u0006\u0004\b\"\u0010#J\u0015\u0010%\u001a\u00020\u001e2\u0006\u0010$\u001a\u00020\u001e¢\u0006\u0004\b%\u0010&J\u000f\u0010'\u001a\u00020\bH\u0014¢\u0006\u0004\b'\u0010\fR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b(\u0010)R\u001a\u0010-\u001a\b\u0012\u0004\u0012\u00020\u001e0*8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b+\u0010,R\u001a\u00100\u001a\b\u0012\u0004\u0012\u00020.0*8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b/\u0010,R \u00103\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e010*8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b2\u0010,R&\u00106\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u001e\u0012\u0004\u0012\u00020\u0006040*8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b5\u0010,R\u0016\u00109\u001a\u00020\u00068\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b7\u00108R\u0018\u0010=\u001a\u0004\u0018\u00010:8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b;\u0010<R\u0017\u0010A\u001a\b\u0012\u0004\u0012\u00020\u001e0>8F¢\u0006\u0006\u001a\u0004\b?\u0010@R\u0017\u0010C\u001a\b\u0012\u0004\u0012\u00020.0>8F¢\u0006\u0006\u001a\u0004\bB\u0010@R\u001d\u0010E\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001e010>8F¢\u0006\u0006\u001a\u0004\bD\u0010@R#\u0010G\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u001e\u0012\u0004\u0012\u00020\u0006040>8F¢\u0006\u0006\u001a\u0004\bF\u0010@¨\u0006H"}, d2 = {"Lcom/vinfast/companion/main/ui/gltestdrive/schedule/GlTestDriveScheduleViewModel;", "Lcom/vinfast/companion/core/base/BaseViewModel;", "Lcom/vinfast/companion/serviceskit/manager/ITestDriveBookingManager;", "testDriveBookingManager", "<init>", "(Lcom/vinfast/companion/serviceskit/manager/ITestDriveBookingManager;)V", "Lcom/vinfast/companion/serviceskit/domain/model/TestDriveScheduleFlow;", "flow", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "W", "(Lcom/vinfast/companion/serviceskit/domain/model/TestDriveScheduleFlow;)V", "X", "()V", "Y", "Landroid/os/Bundle;", "arguments", "R", "(Landroid/os/Bundle;)V", "Lcom/vinfast/companion/serviceskit/domain/model/TestDriveInfo$Vehicle;", "vehicleInfo", "V", "(Lcom/vinfast/companion/serviceskit/domain/model/TestDriveInfo$Vehicle;)V", "Lcom/vinfast/companion/serviceskit/domain/model/TestDriveInfo$GlLocation;", "locationInfo", "T", "(Lcom/vinfast/companion/serviceskit/domain/model/TestDriveInfo$GlLocation;)V", "Lcom/vinfast/companion/serviceskit/domain/model/TestDriveInfo$Time;", "timeInfo", "U", "(Lcom/vinfast/companion/serviceskit/domain/model/TestDriveInfo$Time;)V", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "currentIndex", "S", "(I)V", "L", "()Lcom/vinfast/companion/serviceskit/domain/model/TestDriveScheduleFlow;", "pageIndex", "N", "(I)I", "onCleared", "m", "Lcom/vinfast/companion/serviceskit/manager/ITestDriveBookingManager;", "Landroidx/lifecycle/MutableLiveData;", "n", "Landroidx/lifecycle/MutableLiveData;", "_sessionTimeLiveData", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "o", "_sessionTimeOutLiveData", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "p", "_resetNextStepDataLiveData", "Lkotlin/Pair;", "q", "_navigateToTextStepLiveData", "r", "Lcom/vinfast/companion/serviceskit/domain/model/TestDriveScheduleFlow;", "mFlow", "Lkotlinx/coroutines/Job;", "s", "Lkotlinx/coroutines/Job;", "mSessionTimeoutJob", "Landroidx/lifecycle/LiveData;", "P", "()Landroidx/lifecycle/LiveData;", "sessionTimeLiveData", "Q", "sessionTimeOutLiveData", "O", "resetNextStepDataLiveData", "M", "navigateToTextStepLiveData", "services_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
public final class GlTestDriveScheduleViewModel extends com.vinfast.companion.core.base.BaseViewModel {

    /* JADX INFO: renamed from: m, reason: from kotlin metadata */
    private final com.vinfast.companion.serviceskit.manager.ITestDriveBookingManager testDriveBookingManager;

    /* JADX INFO: renamed from: n, reason: from kotlin metadata */
    private final androidx.lifecycle.MutableLiveData _sessionTimeLiveData;

    /* JADX INFO: renamed from: o, reason: from kotlin metadata */
    private final androidx.lifecycle.MutableLiveData _sessionTimeOutLiveData;

    /* JADX INFO: renamed from: p, reason: from kotlin metadata */
    private final androidx.lifecycle.MutableLiveData _resetNextStepDataLiveData;

    /* JADX INFO: renamed from: q, reason: from kotlin metadata */
    private final androidx.lifecycle.MutableLiveData _navigateToTextStepLiveData;

    /* JADX INFO: renamed from: r, reason: from kotlin metadata */
    private com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow mFlow;

    /* JADX INFO: renamed from: s, reason: from kotlin metadata */
    private kotlinx.coroutines.Job mSessionTimeoutJob;

    public GlTestDriveScheduleViewModel(com.vinfast.companion.serviceskit.manager.ITestDriveBookingManager iTestDriveBookingManager) {
        kotlin.jvm.internal.Intrinsics.l(iTestDriveBookingManager, "testDriveBookingManager");
        this.testDriveBookingManager = iTestDriveBookingManager;
        this._sessionTimeLiveData = new androidx.lifecycle.MutableLiveData();
        this._sessionTimeOutLiveData = new androidx.lifecycle.MutableLiveData();
        this._resetNextStepDataLiveData = new androidx.lifecycle.MutableLiveData();
        this._navigateToTextStepLiveData = new androidx.lifecycle.MutableLiveData();
    }

    /* JADX INFO: Thrown type has an unknown type hierarchy: kotlin.NoWhenBranchMatchedException */
    private final void W(com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow flow) throws kotlin.NoWhenBranchMatchedException {
        if (flow instanceof com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow.Create) {
            this._navigateToTextStepLiveData.q(new kotlin.Pair(0, flow));
            return;
        }
        if (!(flow instanceof com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow.Reschedule)) {
            throw new kotlin.NoWhenBranchMatchedException();
        }
        com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow.Reschedule reschedule = (com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow.Reschedule) flow;
        com.vinfast.companion.serviceskit.domain.response.TestDriveAppointment testDriveAppointmentG = reschedule.g();
        com.vinfast.companion.serviceskit.domain.response.TestDriveVehicle testDriveVehicleP = testDriveAppointmentG.p();
        if (testDriveVehicleP != null) {
            this.testDriveBookingManager.T(new com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.Vehicle(testDriveVehicleP));
        }
        com.vinfast.companion.serviceskit.domain.model.ServiceCenter serviceCenterL = testDriveAppointmentG.l();
        if (serviceCenterL != null) {
            com.vinfast.companion.serviceskit.domain.model.gltestdrive.GlServiceCenter glServiceCenter = new com.vinfast.companion.serviceskit.domain.model.gltestdrive.GlServiceCenter();
            glServiceCenter.q(serviceCenterL.y());
            glServiceCenter.v(serviceCenterL.A());
            glServiceCenter.l(serviceCenterL.f());
            glServiceCenter.o(serviceCenterL.B());
            glServiceCenter.m(serviceCenterL.g());
            glServiceCenter.p(serviceCenterL.k());
            glServiceCenter.s(serviceCenterL.o());
            glServiceCenter.t(serviceCenterL.p());
            this.testDriveBookingManager.x0(new com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.GlLocation(glServiceCenter));
        }
        java.util.Calendar calendar = java.util.Calendar.getInstance();
        java.lang.Long lM = testDriveAppointmentG.m();
        calendar.setTimeInMillis(lM != null ? lM.longValue() : 0L);
        java.util.Date time = calendar.getTime();
        kotlin.jvm.internal.Intrinsics.k(time, "getTime(...)");
        this.testDriveBookingManager.A0(new com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.Time(time, java.lang.String.valueOf(reschedule.g().o())));
        this.testDriveBookingManager.m0(java.lang.String.valueOf(reschedule.g().o()));
        this._navigateToTextStepLiveData.q(new kotlin.Pair(3, flow));
    }

    public final com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow L() {
        com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow testDriveScheduleFlow = this.mFlow;
        if (testDriveScheduleFlow != null) {
            return testDriveScheduleFlow;
        }
        kotlin.jvm.internal.Intrinsics.C("mFlow");
        return null;
    }

    public final androidx.lifecycle.LiveData M() {
        return this._navigateToTextStepLiveData;
    }

    public final int N(int pageIndex) {
        if (pageIndex < 3) {
            return com.vinfast.companion.services.R.string.common_btn_next;
        }
        com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow testDriveScheduleFlow = this.mFlow;
        if (testDriveScheduleFlow == null) {
            kotlin.jvm.internal.Intrinsics.C("mFlow");
            testDriveScheduleFlow = null;
        }
        return testDriveScheduleFlow instanceof com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow.Reschedule ? com.vinfast.companion.services.R.string.common_reschedule : com.vinfast.companion.services.R.string.common_schedule;
    }

    public final androidx.lifecycle.LiveData O() {
        return this._resetNextStepDataLiveData;
    }

    public final androidx.lifecycle.LiveData P() {
        return this._sessionTimeLiveData;
    }

    public final androidx.lifecycle.LiveData Q() {
        return this._sessionTimeOutLiveData;
    }

    /* JADX INFO: Thrown type has an unknown type hierarchy: kotlin.NoWhenBranchMatchedException */
    public final void R(android.os.Bundle arguments) throws kotlin.NoWhenBranchMatchedException {
        com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow create;
        if (arguments == null || (create = (com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow) arguments.getParcelable("ARGUMENT_FLOW")) == null) {
            create = new com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow.Create();
        }
        this.mFlow = create;
        W(create);
    }

    public final void S(int currentIndex) {
        androidx.lifecycle.MutableLiveData mutableLiveData = this._navigateToTextStepLiveData;
        java.lang.Integer numValueOf = java.lang.Integer.valueOf(currentIndex + 1);
        com.vinfast.companion.serviceskit.domain.model.TestDriveScheduleFlow testDriveScheduleFlow = this.mFlow;
        if (testDriveScheduleFlow == null) {
            kotlin.jvm.internal.Intrinsics.C("mFlow");
            testDriveScheduleFlow = null;
        }
        mutableLiveData.q(new kotlin.Pair(numValueOf, testDriveScheduleFlow));
    }

    public final void T(com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.GlLocation locationInfo) {
        kotlin.jvm.internal.Intrinsics.l(locationInfo, "locationInfo");
        com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.Location locationR = this.testDriveBookingManager.r();
        if (locationR != null && !kotlin.jvm.internal.Intrinsics.g(locationInfo, locationR)) {
            this._resetNextStepDataLiveData.q(androidx.collection.ArraySetKt.b(new java.lang.Integer[]{2, 3}));
        }
        this.testDriveBookingManager.x0(locationInfo);
    }

    public final void U(com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.Time timeInfo) {
        kotlin.jvm.internal.Intrinsics.l(timeInfo, "timeInfo");
        com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.Time timeP = this.testDriveBookingManager.p();
        if (timeP != null && !kotlin.jvm.internal.Intrinsics.g(timeInfo, timeP)) {
            this._resetNextStepDataLiveData.q(androidx.collection.ArraySetKt.b(new java.lang.Integer[]{3}));
        }
        this.testDriveBookingManager.A0(timeInfo);
        this.testDriveBookingManager.m0(timeInfo.b());
    }

    public final void V(com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.Vehicle vehicleInfo) {
        kotlin.jvm.internal.Intrinsics.l(vehicleInfo, "vehicleInfo");
        com.vinfast.companion.serviceskit.domain.model.TestDriveInfo.Vehicle vehicleL = this.testDriveBookingManager.l();
        if (vehicleL != null && !kotlin.jvm.internal.Intrinsics.g(vehicleInfo, vehicleL)) {
            this._resetNextStepDataLiveData.q(androidx.collection.ArraySetKt.b(new java.lang.Integer[]{1, 2, 3}));
        }
        this.testDriveBookingManager.T(vehicleInfo);
    }

    public final void X() {
        kotlinx.coroutines.Job job = this.mSessionTimeoutJob;
        if (job != null) {
            kotlinx.coroutines.Job.DefaultImpls.a(job, (java.util.concurrent.CancellationException) null, 1, (java.lang.Object) null);
        }
        this.mSessionTimeoutJob = kotlinx.coroutines.BuildersKt.d(androidx.lifecycle.ViewModelKt.a(this), kotlinx.coroutines.Dispatchers.b(), (kotlinx.coroutines.CoroutineStart) null, new com.vinfast.companion.main.ui.gltestdrive.schedule.GlTestDriveScheduleViewModel$startTimerSession$1(this, null), 2, (java.lang.Object) null);
    }

    public final void Y() {
        kotlinx.coroutines.Job job = this.mSessionTimeoutJob;
        if (job != null) {
            kotlinx.coroutines.Job.DefaultImpls.a(job, (java.util.concurrent.CancellationException) null, 1, (java.lang.Object) null);
        }
    }

    protected void onCleared() {
        super.onCleared();
        this.testDriveBookingManager.q();
    }
}
