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/plus/salesSdk/giftSelect/giftSelectDebug.ts
var giftSelectDebug_exports = {};
__export(giftSelectDebug_exports, {
  clearGiftSelectDebug: () => clearGiftSelectDebug,
  pickGiftProductSnapshot: () => pickGiftProductSnapshot,
  pushGiftSelectDebug: () => pushGiftSelectDebug
});
module.exports = __toCommonJS(giftSelectDebug_exports);
function pushGiftSelectDebug(stage, payload) {
  if (typeof window === "undefined") {
    return;
  }
  if (!Array.isArray(window.__GIFT_SELECT_DEBUG__)) {
    window.__GIFT_SELECT_DEBUG__ = [];
  }
  const entry = {
    ts: Date.now(),
    stage,
    payload: payload === void 0 ? void 0 : safeClone(payload)
  };
  window.__GIFT_SELECT_DEBUG__.push(entry);
  if (window.__GIFT_SELECT_DEBUG__.length > 200) {
    window.__GIFT_SELECT_DEBUG__.shift();
  }
}
function clearGiftSelectDebug() {
  if (typeof window !== "undefined") {
    window.__GIFT_SELECT_DEBUG__ = [];
  }
}
function pickGiftProductSnapshot(item) {
  var _a, _b, _c, _d, _e;
  if (!item) return null;
  return {
    id: item.id,
    product_id: item.product_id,
    title: item.title,
    name: item.name,
    num: item.num,
    price: item.price,
    cover: item.cover,
    image: item.image,
    is_eject: item.is_eject,
    extension_type: item.extension_type,
    quantity: (_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.quantity,
    extendPrice: (_b = item == null ? void 0 : item._extend) == null ? void 0 : _b.price,
    extendTotal: (_c = item == null ? void 0 : item._extend) == null ? void 0 : _c.total,
    skuValue: ((_d = item == null ? void 0 : item._extend) == null ? void 0 : _d.skuValue) ?? ((_e = item == null ? void 0 : item._extend) == null ? void 0 : _e._skuValue)
  };
}
function safeClone(value) {
  try {
    return JSON.parse(JSON.stringify(value));
  } catch {
    return String(value);
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  clearGiftSelectDebug,
  pickGiftProductSnapshot,
  pushGiftSelectDebug
});
