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/toC/payGroup.ts
var payGroup_exports = {};
__export(payGroup_exports, {
  getPayGroupFromStorage: () => getPayGroupFromStorage,
  getPayGroupParamsFromStorage: () => getPayGroupParamsFromStorage,
  removePayGroupFromStorage: () => removePayGroupFromStorage,
  setPayNumber: () => setPayNumber,
  syncPayGroupToStorage: () => syncPayGroupToStorage
});
module.exports = __toCommonJS(payGroup_exports);
var STORAGE_KEY = "payGroup";
var createPayGroupKey = (orderId) => {
  return `${STORAGE_KEY}_${orderId}`;
};
var syncPayGroupToStorage = (payGroup) => {
  localStorage.setItem(createPayGroupKey(payGroup.order_id), JSON.stringify(payGroup));
};
var getPayGroupFromStorage = (orderId) => {
  const key = createPayGroupKey(orderId);
  const payGroupStr = localStorage.getItem(key);
  if (payGroupStr) {
    return JSON.parse(payGroupStr);
  }
  return null;
};
var removePayGroupFromStorage = (orderId) => {
  const key = createPayGroupKey(orderId);
  localStorage.removeItem(key);
};
var getPayGroupParamsFromStorage = (orderId, rest) => {
  try {
    const payGroup = getPayGroupFromStorage(orderId);
    if (!payGroup) {
      return null;
    }
    return {
      ...rest,
      amount: payGroup == null ? void 0 : payGroup.wait_amount,
      payment_group_id: payGroup == null ? void 0 : payGroup.payment_group_id
    };
  } catch (err) {
  }
  return null;
};
var setPayNumber = (orderId, payNumber) => {
  const payGroup = getPayGroupFromStorage(orderId);
  if (payGroup) {
    payGroup.pay_number = payNumber;
    syncPayGroupToStorage(payGroup);
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getPayGroupFromStorage,
  getPayGroupParamsFromStorage,
  removePayGroupFromStorage,
  setPayNumber,
  syncPayGroupToStorage
});
