import { routeData } from "@/router/constants/routes";
import { navigationScenarios } from "@/router/constants/navigation-scenarios";
import store from "@/store";
import { paymentMethods } from "@/constants/payment-method-constants";

// Get as function to live-evaluate filters
const routingTable = function () {
    return [
        {
            pageName: routeData.VEHICLE.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                },
            ],
        },
        {
            pageName: routeData.VEHICLE_DAMAGE.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.VEHICLE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_VIN,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITHOUT_VIN,
                    destinationPageData: routeData.ESTIMATE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_SKIP_VIN,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
                {
                    scenario:
                        navigationScenarios.CLICKED_FORWARD_WITH_REPAIR_AND_VERIFIED_INSURANCE,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
                {
                    scenario:
                        navigationScenarios.CLICKED_FORWARD_WITH_REPLACE_AND_VERIFIED_INSURANCE,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
            ],
        },
        {
            pageName: routeData.VIN_LOOKUP.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.ESTIMATE,
                },
                {
                    scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                    params: {
                        displayVehicleChangeAlert: true,
                    },
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_VIN,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
                {
                    scenario: navigationScenarios.CLICKED_VIN_RETRY,
                    destinationPageData: routeData.ESTIMATE,
                },
            ],
        },
        {
            pageName: routeData.LICENSE_PLATE_LOOKUP.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.ESTIMATE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                    params: {
                        displayVehicleChangeAlert: true,
                    },
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
                {
                    scenario: navigationScenarios.CLICKED_VIN_RETRY,
                    destinationPageData: routeData.ESTIMATE,
                },
            ],
        },
        {
            pageName: routeData.ADDRESS_LOOKUP.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.ESTIMATE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_VEHICLES,
                    destinationPageData: routeData.ADDRESS_VEHICLES,
                },
                {
                    scenario: navigationScenarios.SELECTED_VIN_WITH_MISMATCHED_GLASS,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                    params: {
                        displayVehicleChangeAlert: true,
                    },
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
                {
                    scenario: navigationScenarios.CLICKED_VIN_RETRY,
                    destinationPageData: routeData.ESTIMATE,
                },
            ],
        },
        {
            pageName: routeData.ADDRESS_VEHICLES.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.ADDRESS_LOOKUP,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                    params: {
                        displayVehicleChangeAlert: true,
                    },
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
                {
                    scenario: navigationScenarios.CLICKED_VIN_RETRY,
                    destinationPageData: routeData.ESTIMATE,
                },
            ],
        },
        {
            pageName: routeData.ESTIMATE.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                },
                {
                    scenario: navigationScenarios.SELECTED_MANUAL_VIN,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
                {
                    scenario: navigationScenarios.SELECTED_LICENSE_PLATE,
                    destinationPageData: routeData.LICENSE_PLATE_LOOKUP,
                },
                {
                    scenario: navigationScenarios.SELECTED_HOME_ADDRESS,
                    destinationPageData: routeData.ADDRESS_LOOKUP,
                },
                {
                    scenario: navigationScenarios.SELECTED_NO_VIN,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
            ],
        },
        {
            pageName: routeData.SERVICE_ZIP.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.ESTIMATE,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_SKIP_VIN,
                    destinationPageData: routeData.VEHICLE_DAMAGE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
            ],
        },
        {
            pageName: routeData.PART_QUESTIONS.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
            ],
        },
        {
            pageName: routeData.VEHICLE_PARTS.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
            ],
        },
        {
            pageName: routeData.MOLDING_QUESTIONS.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
            ],
        },
        {
            pageName: routeData.CAPABILITY_QUESTIONS.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.QUOTE,
                },
            ],
        },
        {
            pageName: routeData.QUOTE.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
                    destinationPageData: routeData.VIN_LOOKUP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
                    destinationPageData: routeData.SERVICE_ZIP,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS,
                    destinationPageData: routeData.PART_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_MULTIPLE_PARTS_TO_CHOOSE,
                    destinationPageData: routeData.VEHICLE_PARTS,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_MOLDING_QUESTIONS,
                    destinationPageData: routeData.MOLDING_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_CAPABILITY_QUESTIONS,
                    destinationPageData: routeData.CAPABILITY_QUESTIONS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_CASH,
                    destinationPageData: routeData.SCHEDULE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_INSURANCE,
                    destinationPageData: routeData.INSURANCE_COMPANY,
                },
            ],
        },
        {
            pageName: routeData.INSURANCE_COMPANY.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.QUOTE,
                },
                {
                    scenario: navigationScenarios.CLICKED_PAY_ON_MY_OWN,
                    destinationPageData: routeData.QUOTE,
                    params: {
                        offer: "cash",
                    },
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.INSURANCE_DETAILS,
                },
            ],
        },
        // TODO: REMOVE THIS COMMENT AND BELOW, ONCE CASH-803 (SERVICE-LOCATION AND SCHEDULE PAGE COMBINATION) HAS BEEN VETTED
        // {
        //     pageName: routeData.SERVICE_LOCATION.name,
        //     maps: [
        //         {
        //             scenario: navigationScenarios.CLICKED_BACK,
        //             destinationPageData: routeData.QUOTE,
        //         },
        //         {
        //             scenario: navigationScenarios.CLICKED_FORWARD,
        //             destinationPageData: routeData.SCHEDULE,
        //         },
        //         {
        //             scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOBILE_SERVICE,
        //             destinationPageData: routeData.MOBILE_DETAILS,
        //         },
        //     ],
        // },
        {
            pageName: routeData.SCHEDULE.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.QUOTE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.CUSTOMER_DETAILS,
                },
                // {
                //     scenario: navigationScenarios.CLICKED_CHANGE_LOCATION,
                //     destinationPageData: routeData.SERVICE_LOCATION,
                // },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD_WITH_MOBILE_SERVICE,
                    destinationPageData: routeData.MOBILE_DETAILS,
                },
            ],
        },
        {
            pageName: routeData.MOBILE_DETAILS.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.SCHEDULE,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.CUSTOMER_DETAILS,
                },
            ],
        },
        {
            pageName: routeData.CUSTOMER_DETAILS.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.SCHEDULE,
                },
                {
                    scenario: navigationScenarios.CLICKED_BACK_WITH_MOBILE_SERVICE,
                    destinationPageData: routeData.MOBILE_DETAILS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.PAYMENT_METHOD,
                },
                {
                    scenario: navigationScenarios.CLICKED_PAY_NOW,
                    destinationPageData: routeData.PAYMENT_METHOD,
                },
            ],
        },
        {
            pageName: routeData.PAYMENT_METHOD.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.CUSTOMER_DETAILS,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.CONFIRMATION,
                },
                {
                    scenario: navigationScenarios.CLICKED_PAY_NOW,
                    destinationPageData: routeData.PAYMENT,
                },
                {
                    scenario: navigationScenarios.CLICKED_INSURANCE,
                    destinationPageData: routeData.INSURANCE_COMPANY,
                },
            ],
        },
        {
            pageName: routeData.PAYMENT.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_BACK,
                    destinationPageData: routeData.PAYMENT_METHOD,
                },
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.CONFIRMATION,
                },
                {
                    scenario: navigationScenarios.PIA_ERROR,
                    destinationPageData: routeData.PAYMENT_METHOD,
                    params: {
                        piaError: "true",
                    },
                },
            ],
        },
        {
            pageName: routeData.PAYMENT_PIA_RETURN.name,
            maps: [
                {
                    scenario: navigationScenarios.PIA_ERROR,
                    destinationPageData: routeData.PAYMENT_METHOD,
                    params: {
                        piaError: "true",
                    },
                },
                {
                    scenario: navigationScenarios.PIA_CC_ERROR,
                    destinationPageData: routeData.PAYMENT,
                    params: {
                        piaErrorType: paymentMethods.CREDIT_CARD,
                    },
                },
                {
                    scenario: navigationScenarios.PIA_APPLE_ERROR,
                    destinationPageData: routeData.PAYMENT,
                    params: {
                        piaErrorType: paymentMethods.APPLE_PAY,
                    },
                },
                {
                    scenario: navigationScenarios.PIA_AFTERPAY_ERROR,
                    destinationPageData: routeData.PAYMENT,
                    params: {
                        piaErrorType: paymentMethods.AFTERPAY,
                    },
                },
                {
                    scenario: navigationScenarios.PIA_SUCCESS,
                    destinationPageData: routeData.CONFIRMATION,
                },
            ],
        },
        {
            pageName: routeData.CONFIRMATION.name,
        },
        {
            pageName: routeData.RETURN_USER.name,
            maps: [
                {
                    scenario: navigationScenarios.CLICKED_FORWARD,
                    destinationPageData: routeData.LOAD_SESSION,
                },
                {
                    scenario: navigationScenarios.CLICKED_RESTART,
                    destinationPageData: routeData.RESTART,
                },
            ],
        },
    ];
};

export { routingTable };
