var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/eftposPay/windcave/const.tsx
var const_exports = {};
__export(const_exports, {
  StemTypeEnum: () => StemTypeEnum,
  StepStatusEnum: () => StepStatusEnum,
  default: () => const_default,
  getAmonunt: () => getAmonunt,
  getStepMapping: () => getStepMapping
});
module.exports = __toCommonJS(const_exports);
var import_utils = require("@pisell/utils");
var import_const = require("../const");
var const_default = (params) => {
  const {
    order_id,
    name,
    symbol,
    amount,
    mode,
    number,
    pay,
    device,
    net,
    client,
    ...other
  } = params || {
    mode: import_const.ModeEnum.Pay
  };
  return {
    order_id,
    name,
    symbol,
    amount,
    mode,
    eftpos: import_const.EftposEnum.Windcave,
    key: Date.now(),
    warn: "",
    step: 0,
    type: import_const.PayRouteEnum.Step,
    title: import_utils.locales.getText("page.eftpos-pay.text.loading")(mode),
    component: "",
    status: import_const.StatusEnum.Loading,
    steps: [],
    render: true,
    client: client !== "undefined" && client !== void 0 ? client : import_const.ClientEnum.Merchant,
    custom: other ? { ...other, list: [], step: 1 /* Free */ } : { list: [], step: 1 /* Free */ },
    ...typeof net !== "undefined" ? { net } : {},
    ...typeof number !== "undefined" ? { number } : {},
    ...typeof pay !== "undefined" ? { pay } : {},
    ...typeof device !== "undefined" ? { device } : {}
  };
};
function getAmonunt(store) {
  const { device, pay, custom, name, symbol, amount } = store;
  if (!device || !custom) {
    throw Error("device or custom is not defined");
  }
  const setting = device.setting;
  if (pay) {
    return {
      name,
      symbol,
      // format,
      money: Number(amount),
      amount: Number(pay.amount),
      surRate: Number(pay.surRate),
      surMoney: Number(pay.surMoney),
      surcharge: (setting == null ? void 0 : setting.surcharge) || false,
      useOriginSurcharge: (pay == null ? void 0 : pay.useOriginSurcharge) || false
    };
  }
  if (!setting) {
    return {
      name,
      symbol,
      // format,
      money: Number(amount),
      amount: Number(amount),
      surRate: 0,
      surMoney: 0,
      surcharge: false,
      useOriginSurcharge: false
    };
  }
  const useOriginSurcharge = false;
  const surRate = setting.constant_rate || 0;
  const surMoney = setting.constant_money || 0;
  const surcharge = setting.surcharge;
  return {
    name,
    symbol,
    money: Number(amount),
    amount: Number(amount),
    surRate: useOriginSurcharge ? 0 : surcharge ? surRate : 0,
    surMoney: useOriginSurcharge ? 0 : surcharge ? surMoney : 0,
    surcharge,
    useOriginSurcharge
  };
}
var StepStatusEnum = /* @__PURE__ */ ((StepStatusEnum2) => {
  StepStatusEnum2[StepStatusEnum2["Free"] = 1] = "Free";
  StepStatusEnum2[StepStatusEnum2["Card"] = 2] = "Card";
  StepStatusEnum2[StepStatusEnum2["Account"] = 3] = "Account";
  StepStatusEnum2[StepStatusEnum2["Application"] = 4] = "Application";
  StepStatusEnum2[StepStatusEnum2["Pin"] = 5] = "Pin";
  StepStatusEnum2[StepStatusEnum2["Processing"] = 6] = "Processing";
  StepStatusEnum2[StepStatusEnum2["Receipt"] = 7] = "Receipt";
  StepStatusEnum2[StepStatusEnum2["Wait"] = 8] = "Wait";
  return StepStatusEnum2;
})(StepStatusEnum || {});
var StemTypeEnum = /* @__PURE__ */ ((StemTypeEnum2) => {
  StemTypeEnum2["Active"] = "active";
  StemTypeEnum2["Passive"] = "passive";
  return StemTypeEnum2;
})(StemTypeEnum || {});
var getStepMapping = (type, { money, mode = import_const.ModeEnum.Pay }) => {
  switch (type) {
    case 1 /* Free */:
      return {
        type: "active" /* Active */,
        // passive  active
        status: "pedding",
        // pedding reject resolve
        pedding: import_utils.locales.getText("page.eftpos-pay.text.wait")(
          money || "",
          mode
        ),
        resolve: "",
        index: type,
        peddingStyle: {}
      };
    case 2 /* Card */:
      return {
        type: "active" /* Active */,
        // passive  active
        status: "pedding",
        // pedding reject resolve
        pedding: import_utils.locales.getText("page.eftpos-pay.text.card"),
        resolve: "",
        index: type,
        peddingStyle: {}
      };
    case 3 /* Account */:
      return {
        type: "active" /* Active */,
        // passive  active
        status: "pedding",
        // pedding reject resolve
        pedding: import_utils.locales.getText("page.eftpos-pay.text.account"),
        resolve: "",
        index: type,
        peddingStyle: {}
      };
    case 4 /* Application */:
      return {
        type: "active" /* Active */,
        // passive  active
        status: "pedding",
        // pedding reject resolve
        pedding: import_utils.locales.getText("page.eftpos-pay.text.application"),
        // '等待客户选择应用', // Waiting for customer to select application/等待客户选择应用
        resolve: "",
        index: type,
        peddingStyle: {}
      };
    case 5 /* Pin */:
      return {
        type: "active" /* Active */,
        // passive  active
        status: "pedding",
        // pedding reject resolve
        pedding: import_utils.locales.getText("page.eftpos-pay.text.pin"),
        resolve: "",
        index: type,
        peddingStyle: {}
      };
    case 6 /* Processing */:
      return {
        type: "active" /* Active */,
        // passive  active
        status: "pedding",
        // pedding reject resolve
        pedding: import_utils.locales.getText("page.eftpos-pay.text.transaction.processing"),
        // Processing/处理中
        resolve: "",
        index: type,
        peddingStyle: {}
      };
    case 7 /* Receipt */:
      return {
        type: "passive" /* Passive */,
        // passive  active
        status: "pedding",
        //
        pedding: `${import_utils.locales.getText(
          "page.eftpos-pay.text.receipt.again.title"
        )}
${import_utils.locales.getText("page.eftpos-pay.text.receipt.again.text")}`,
        // pedding:  (
        //   <>
        //     {locales.getText('page.eftpos-pay.text.receipt.again.title')}
        //     <br />
        //     {locales.getText('page.eftpos-pay.text.receipt.again.text')}
        //   </>
        // ),
        resolve: import_utils.locales.getText("page.eftpos-pay.text.receipt.again.title"),
        reject: import_utils.locales.getText("page.eftpos-pay.text.receipt.again.title"),
        // locales.getText('page.eftpos-pay.text.waiting.decline'), // 'Wait for the Decline',
        index: type,
        peddingStyle: {}
      };
    case 8 /* Wait */:
      return {
        type: "active" /* Active */,
        // passive  active
        status: "pedding",
        // pedding reject resolve
        pedding: import_utils.locales.getText("page.eftpos-pay.text.waiting.processing"),
        resolve: import_utils.locales.getText("page.eftpos-pay.text.approved"),
        index: type,
        peddingStyle: {}
      };
    default:
      return null;
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  StemTypeEnum,
  StepStatusEnum,
  getAmonunt,
  getStepMapping
});
