import { ROUTE_NAMES, RouteNamesType } from '@/shared/constants/route-names';

export type PathType = RouteNamesType[keyof RouteNamesType];
const generatePath = (base: string, path?: PathType): string => {
  base = base.replace(/\/\*/g, '');
  if (typeof path === 'string') {
    path = path?.replace(/:.*/, '');
  }
  let rs = path ? `${base}/${path as string}` : base;
  return rs;
};

export const PATHS: RouteNamesType = {
  home: generatePath(ROUTE_NAMES.home),
  transaction: {
    base: generatePath(ROUTE_NAMES.transaction.base),
    allTransaction: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`,
        ROUTE_NAMES.transaction.allTransaction.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`,
        ROUTE_NAMES.transaction.allTransaction.detail,
      ),
      cancel: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`,
        ROUTE_NAMES.transaction.allTransaction.cancel,
      ),
    },
    cashReceipt: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`,
        ROUTE_NAMES.transaction.cashReceipt.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`,
        ROUTE_NAMES.transaction.cashReceipt.detail,
      ),
      handWrittenIssuance: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`,
        ROUTE_NAMES.transaction.cashReceipt.handWrittenIssuance,
      ),
    },
    escrow: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.escrow.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.escrow.base}`,
        ROUTE_NAMES.transaction.escrow.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.escrow.base}`,
        ROUTE_NAMES.transaction.escrow.detail,
      ),
    },
    billing: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`,
        ROUTE_NAMES.transaction.billing.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`,
        ROUTE_NAMES.transaction.billing.detail,
      ),
      charge: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`,
        ROUTE_NAMES.transaction.billing.charge,
      ),
    }
  },
  settlement: {
    base: generatePath(ROUTE_NAMES.settlement.base),
    calendar: generatePath(ROUTE_NAMES.settlement.base, ROUTE_NAMES.settlement.calendar),
    list: generatePath(ROUTE_NAMES.settlement.base, ROUTE_NAMES.settlement.list),
    detail: generatePath(ROUTE_NAMES.settlement.base, ROUTE_NAMES.settlement.detail),
  },
  merchant: {
    base: generatePath(ROUTE_NAMES.merchant.base),
    info: generatePath(ROUTE_NAMES.merchant.base, ROUTE_NAMES.merchant.info),
    registrationStatus: generatePath(ROUTE_NAMES.merchant.base, ROUTE_NAMES.merchant.registrationStatus),
  },
  payment: {
    base: generatePath(ROUTE_NAMES.payment.base),
    info: generatePath(ROUTE_NAMES.payment.base, ROUTE_NAMES.payment.info),
    notificationData: generatePath(ROUTE_NAMES.payment.base, ROUTE_NAMES.payment.notificationData),
  },
  account: {
    base: generatePath(ROUTE_NAMES.account.base),
    user: {
      base: generatePath(`${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`),
      manage: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.manage,
      ),
      loginAuthInfo: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.loginAuthInfo,
      ),
      accountAuth: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.accountAuth,
      ),
      menuAuth: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.menuAuth,
      ),
      addAccount: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.addAccount,
      ),
    },
    password: {
      base: generatePath(`${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.password.base}`),
      manage: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.password.base}`,
        ROUTE_NAMES.account.password.manage,
      ),
      modifyLoginPassword: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.password.base}`,
        ROUTE_NAMES.account.password.modifyLoginPassword,
      ),
      modifyCancelPassword: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.password.base}`,
        ROUTE_NAMES.account.password.modifyCancelPassword,
      ),
    }
  },
  vatReturn: {
    base: generatePath(ROUTE_NAMES.vatReturn.base),
    list: generatePath(ROUTE_NAMES.vatReturn.base, ROUTE_NAMES.vatReturn.list),
    detail: generatePath(ROUTE_NAMES.vatReturn.base, ROUTE_NAMES.vatReturn.detail),
    reference: generatePath(ROUTE_NAMES.vatReturn.base, ROUTE_NAMES.vatReturn.reference),
  },
  additionalService: {
    base: generatePath(ROUTE_NAMES.additionalService.base),
    list: generatePath(ROUTE_NAMES.additionalService.base, ROUTE_NAMES.additionalService.list),
    ars: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.ars.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.ars.base}`,
        ROUTE_NAMES.additionalService.ars.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.ars.base}`,
        ROUTE_NAMES.additionalService.ars.detail,
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.ars.base}`,
        ROUTE_NAMES.additionalService.ars.request,
      ),
      requestSuccess: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.ars.base}`,
        ROUTE_NAMES.additionalService.ars.requestSuccess,
      ),
    },
    keyInPayment: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`,
        ROUTE_NAMES.additionalService.keyInPayment.list
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`,
        ROUTE_NAMES.additionalService.keyInPayment.request,
      ),
      requestSuccess: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`,
        ROUTE_NAMES.additionalService.keyInPayment.requestSuccess,
      ),
    },
    smsPaymentNotification: generatePath(ROUTE_NAMES.additionalService.base, ROUTE_NAMES.additionalService.smsPaymentNotification),
    accountHolderSearch: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`,
        ROUTE_NAMES.additionalService.accountHolderSearch.list
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`,
        ROUTE_NAMES.additionalService.accountHolderSearch.detail
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`,
        ROUTE_NAMES.additionalService.accountHolderSearch.request,
      )
    },
    accountHolderAuth: {
      base: generatePath(ROUTE_NAMES.additionalService.base, ROUTE_NAMES.additionalService.accountHolderAuth.base),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderAuth.base}`,
        ROUTE_NAMES.additionalService.accountHolderAuth.list
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderAuth.base}`,
        ROUTE_NAMES.additionalService.accountHolderAuth.detail
      ),
    },
    linkPayment: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`),
      shippingHistory: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.shippingHistory,
      ),
      pendingSend: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.pendingSend,
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.request,
      ),
      requestConfirm: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.requestConfirm,
      ),
      confirmSuccess: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.confirmSuccess,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.detail,
      ),
      pendingDetail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.pendingDetail,
      ),
      separateApproval: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.separateApproval
      )
    },
    alimtalk: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.alimtalk.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.alimtalk.base}`,
        ROUTE_NAMES.additionalService.alimtalk.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.alimtalk.base}`,
        ROUTE_NAMES.additionalService.alimtalk.detail,
      ),
      setting: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.alimtalk.base}`,
        ROUTE_NAMES.additionalService.alimtalk.setting,
      ),
    },
    fundAccount: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundAccount.base}`),
      transferList: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundAccount.base}`,
        ROUTE_NAMES.additionalService.fundAccount.transferList,
      ),
      transferDetail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundAccount.base}`,
        ROUTE_NAMES.additionalService.fundAccount.transferDetail,
      ),
      transferRequest: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundAccount.base}`,
        ROUTE_NAMES.additionalService.fundAccount.transferRequest,
      ),
      resultList: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundAccount.base}`,
        ROUTE_NAMES.additionalService.fundAccount.resultList,
      ),
      resultDetail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundAccount.base}`,
        ROUTE_NAMES.additionalService.fundAccount.resultDetail,
      ),
    },
    settlementAgency: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`),
      manage: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.manage,
      ),
      deposit: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.deposit,
      ),
      member: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.member,
      ),
      register: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.register,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.detail,
      ),
    },
    payout: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.payout.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.payout.base}`,
        ROUTE_NAMES.additionalService.payout.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.payout.base}`,
        ROUTE_NAMES.additionalService.payout.detail,
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.payout.base}`,
        ROUTE_NAMES.additionalService.payout.request,
      ),
    },
    faceAuth: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.faceAuth.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.faceAuth.base}`,
        ROUTE_NAMES.additionalService.faceAuth.list,
      ),
    }
  },
  support: {
    base: generatePath(ROUTE_NAMES.support.base),
    notice: {
      base: generatePath(`${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.notice.base}`),
      list: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.notice.base}`,
        ROUTE_NAMES.support.notice.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.notice.base}`,
        ROUTE_NAMES.support.notice.detail,
      ),
    },
    faq: {
      base: generatePath(`${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.faq.base}`),
      list: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.faq.base}`,
        ROUTE_NAMES.support.notice.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.faq.base}`,
        ROUTE_NAMES.support.faq.detail,
      ),
    },
    qna: {
      base: generatePath(`${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`),
      list: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`,
        ROUTE_NAMES.support.qna.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`,
        ROUTE_NAMES.support.qna.detail,
      ),
      register: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`,
        ROUTE_NAMES.support.qna.register,
      ),
    },
  },
  setting: generatePath(ROUTE_NAMES.setting),
  alarm: {
    base: generatePath(ROUTE_NAMES.alarm.base),
    list: generatePath(ROUTE_NAMES.alarm.base, ROUTE_NAMES.alarm.list),
  },
  xkeypad: generatePath(ROUTE_NAMES.xkeypad),
  xkeypadSample: generatePath(ROUTE_NAMES.xkeypadSample),
  taxInvoice: {
    base: generatePath(ROUTE_NAMES.taxInvoice.base),
    sample: generatePath(ROUTE_NAMES.taxInvoice.base, ROUTE_NAMES.taxInvoice.sample),
  }
};

export const BACK_BLOCKED_PATHS = {
  /*
  [PATHS.home]: [
    PATHS.intro,
    PATHS.start,
    PATHS.appAuth,
    PATHS.mobileVerification,
    PATHS.signUp.bioPinNumber,
    PATHS.signUp.inputPinNumber,
    PATHS.signUp.setPinNumber,
    PATHS.signUp.reSetBiometricAuth,
    PATHS.signUp.setBiometricAuth,
    
  ],
  */
  //[PATHS.appAuth]: [PATHS.intro],
};
