var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/eventBooking/components/Provider/Cart/Item/index.tsx
var Item_exports = {};
__export(Item_exports, {
  default: () => Item_default
});
module.exports = __toCommonJS(Item_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_shoppingCart = __toESM(require("../../../../../shoppingCart"));
var import_Sales = require("../../../../../Sales");
var import_SelectHolderModal = __toESM(require("../../SelectHolderModal"));
var import_ContinueButton = __toESM(require("../ContinueButton"));
var import_Total = __toESM(require("./Total"));
var import_Deposit = __toESM(require("../Deposit"));
var import_index = require("./index.less");
var CartItem = () => {
  var _a;
  const { open, holderData, selectedHolderIds } = (0, import_Sales.useHolder)();
  const {
    deleteCartItem,
    deleteCartItemByHolder,
    cartData,
    addNoteToCartItem
  } = (0, import_Sales.useCart)();
  const { deposit } = (0, import_Sales.useSummary)();
  const { isLastStep } = (0, import_Sales.useStep)();
  const handleClickCard = (e, type, key) => {
    if (type === "note") {
      return addNoteToCartItem(e);
    }
    console.log(e, type, key, "wh9988767");
    if (type === "delete") {
      return deleteCartItem(e);
    }
    if (type === "delete_holders") {
      return deleteCartItemByHolder(key);
    }
  };
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `cart-item-wrap ${(0, import_utils.isMobile)() ? "cart-mobile-item-wrap" : ""}`
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "content" }, /* @__PURE__ */ import_react.default.createElement(
      import_shoppingCart.default,
      {
        productParams: {
          products: (cartData == null ? void 0 : cartData.cartItems) || [],
          hideAddBtn: false,
          holders: (holderData == null ? void 0 : holderData.selectedHolderItems) || [],
          disabledEdit: isLastStep
        },
        collapseParams: {
          activeKey: selectedHolderIds,
          ghost: true
        },
        platform: "h5",
        emptyText: import_utils.locales.getText("pisell2.event.empty.service"),
        isOpenGroup: !!(selectedHolderIds == null ? void 0 : selectedHolderIds.length),
        onChange: (e, type, key) => handleClickCard(e, type, key)
      }
    )),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "event-footer" }, /* @__PURE__ */ import_react.default.createElement(import_Total.default, null), ((_a = cartData == null ? void 0 : cartData.cartItems) == null ? void 0 : _a.length) > 0 && (deposit == null ? void 0 : deposit.hasDeposit) ? /* @__PURE__ */ import_react.default.createElement(import_Deposit.default, null) : null, /* @__PURE__ */ import_react.default.createElement(import_ContinueButton.default, null))
  ), /* @__PURE__ */ import_react.default.createElement(import_SelectHolderModal.default, { open }));
};
var Item_default = CartItem;
