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/Sales/Checkout/utils.ts
var utils_exports = {};
__export(utils_exports, {
  formatProductBundle: () => formatProductBundle,
  formatProductOption: () => formatProductOption,
  formatValues: () => formatValues,
  getFormParams: () => getFormParams
});
module.exports = __toCommonJS(utils_exports);
var formatProductOption = (option) => {
  if (!option) {
    return [];
  }
  return option.map((d) => {
    return {
      num: d.num,
      option_group_item_id: d.product_option_item_id,
      option_group_id: d.option_group_id
    };
  });
};
var formatProductBundle = (bundle) => {
  if (!bundle) {
    return;
  }
  return bundle.map((d) => {
    return {
      bundle_group_id: d.group_id,
      bundle_id: d.id,
      bundle_product_id: d._bundle_product_id,
      bundle_variant_id: d.bundle_variant_id,
      num: d.num,
      extension_id: d.extension_id,
      extension_type: d.extension_type,
      option: formatProductOption(d.option)
    };
  });
};
var formatBookings = (list) => {
  let bookings = [];
  bookings = list.map((item) => {
    return item._originData;
  });
  return bookings;
};
var formatValues = (params) => {
  var _a, _b;
  const { state, otherValue, platform, excludeDisabled, extra } = params;
  let values = {
    type: "event_booking_v2",
    platform: platform === "pc" ? "PC" : "H5",
    sales_channel: "my_pisel",
    order_sales_channel: "online_store",
    bookings: [],
    shop_note: "",
    schedule_date: "",
    ...extra || {},
    ...otherValue || {}
  };
  console.log("values", values);
  let data = [];
  if (excludeDisabled) {
    data = (_b = (_a = state.cartData.cartItems) == null ? void 0 : _a.filter) == null ? void 0 : _b.call(_a, (v) => v.disabled !== true);
  } else {
    data = state.cartData.cartItems;
  }
  const is_deposit = data.find((v) => v.deposit) ? 1 : 0;
  values.is_deposit = is_deposit;
  values.bookings = formatBookings(data);
  return values;
};
var getFormParams = (state) => {
  var _a;
  const product_id = (((_a = state == null ? void 0 : state.cartData) == null ? void 0 : _a.cartItems) || []).map((item) => {
    var _a2, _b;
    return (_b = (_a2 = item._originData) == null ? void 0 : _a2.product) == null ? void 0 : _b.product_id;
  });
  return {
    product_id,
    appointment_type: "event_booking_v2"
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatProductBundle,
  formatProductOption,
  formatValues,
  getFormParams
});
