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/pay/toB/store/utils.ts
var utils_exports = {};
__export(utils_exports, {
  handlePayMethodList: () => handlePayMethodList,
  limitDecimals: () => limitDecimals
});
module.exports = __toCommonJS(utils_exports);
var import_utils = require("@pisell/utils");
var import_types = require("../types");
var handlePayMethodList = (payMethodList) => {
  if (payMethodList.length <= 0) {
    return [];
  }
  const list = [];
  const normalPay = {
    title: import_utils.locales.getText("tobPay.text.group.normalPay"),
    list: []
  };
  const thirdPay = {
    title: import_utils.locales.getText("tobPay.text.group.thirdPay"),
    list: []
  };
  for (const item of payMethodList) {
    if ((item == null ? void 0 : item.status) === 1) {
      if (item.code === import_types.PayMethodCode.CASHMANUAL) {
        normalPay.list.push(item);
      } else if (item.type === "eftpos") {
        thirdPay.list.push(item);
      }
    }
  }
  if (normalPay.list.length > 0) {
    list.push(normalPay);
  }
  if (thirdPay.list.length > 0) {
    list.push(thirdPay);
  }
  return list;
};
var limitDecimals = (value) => {
  const reg = /^(\-)*(\d+)\.(\d\d).*$/;
  if (typeof value === "string") {
    return !isNaN(Number(value)) ? value.replace(reg, "$1$2.$3") : "";
  } else if (typeof value === "number") {
    return !isNaN(value) ? String(value).replace(reg, "$1$2.$3") : "";
  } else {
    return "";
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  handlePayMethodList,
  limitDecimals
});
