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/shoppingCart/hooks/usePromotionModal.tsx
var usePromotionModal_exports = {};
__export(usePromotionModal_exports, {
  usePromotionModal: () => usePromotionModal
});
module.exports = __toCommonJS(usePromotionModal_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_ahooks = require("ahooks");
var import_utils = require("@pisell/utils");
var import_Selector = __toESM(require("../../../pro/Selector"));
var import_compensatedPisellContainer = __toESM(require("../../../pro/compensatedPisellContainer"));
var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
var import_server = require("../server");
var import_useSkuModal = require("./useSkuModal");
var import_utils2 = require("../../ticketBooking/components/addServiceVariant/utils");
var import_openNormalService = require("../../booking/info2/service/openNormalService");
var import_serve = require("../../../components/booking/info/service/serve");
var import_utils3 = require("../../booking/info/service2/utils");
var import_utils4 = require("../utils");
var import_buildGiftOrderProducts = require("../../../plus/salesSdk/giftSelect/buildGiftOrderProducts");
var FALLBACK_RESPONSIVE_INFO = {
  currentBreakpoint: "desktop",
  deviceType: "desktop"
};
var useFallbackResponsive = () => FALLBACK_RESPONSIVE_INFO;
var usePromotionModal = (options) => {
  var _a, _b, _c, _d;
  const context = (0, import_useEngineContext.default)();
  const app = (_c = (_b = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.getApp) == null ? void 0 : _c.call(_b);
  const responsive = app == null ? void 0 : app.responsive;
  const useResponsiveHook = typeof ((_d = responsive == null ? void 0 : responsive.hooks) == null ? void 0 : _d.useResponsive) === "function" ? responsive.hooks.useResponsive : useFallbackResponsive;
  const responsiveInfo = useResponsiveHook() || FALLBACK_RESPONSIVE_INFO;
  const currentVariant = responsiveInfo.currentBreakpoint || responsiveInfo.deviceType || "desktop";
  const [open, setOpen] = (0, import_react.useState)(false);
  const [selected, setSelected] = (0, import_react.useState)("");
  const [loading, setLoading] = (0, import_react.useState)(false);
  const [products, setProducts] = (0, import_react.useState)([]);
  const [currentItem, setCurrentItem] = (0, import_react.useState)({});
  const productsRef = (0, import_react.useRef)(null);
  const suppressProductSelectSkuOpenRef = (0, import_react.useRef)(false);
  const [cartProducts, setCartProducts] = (0, import_react.useState)([]);
  const [randomKey, setRandomKey] = (0, import_react.useState)(Math.random());
  (0, import_react.useEffect)(() => {
    const _products = (0, import_utils4.formatProductDatas)(products, currentItem, selected);
    productsRef.current = _products || [];
    if ((_products == null ? void 0 : _products.length) && Array.isArray(_products) && currentItem) {
      const formatted = (0, import_utils4.formatCartProducts)({
        products: _products,
        currentItem
      });
      setCartProducts(formatted);
    } else {
      setCartProducts([]);
    }
  }, [products, currentItem, selected]);
  const handleSkuConfirmCallback = (0, import_react.useCallback)(
    (productId, cacheItem, selected2) => {
      if (!cacheItem || typeof cacheItem !== "object") {
        return;
      }
      const { originProducts } = (0, import_utils4.updateProductInList)({
        products: (productsRef == null ? void 0 : productsRef.current) || [],
        productId,
        cacheItem
      });
      productsRef.current = (0, import_utils4.formatProductDatas)(originProducts || [], currentItem, selected2) || [];
      setProducts(originProducts || []);
      if (!(0, import_utils4.isProductNeedSku)(cacheItem)) {
        setSelected(selected2);
        return;
      }
      suppressProductSelectSkuOpenRef.current = true;
      handleCustomCallback(cacheItem, "onConfirm");
      queueMicrotask(() => {
        suppressProductSelectSkuOpenRef.current = false;
      });
    },
    [currentItem, selected]
  );
  const { SkuModal } = (0, import_useSkuModal.useSkuModal)({
    onConfirm: handleSkuConfirmCallback
  });
  const getProductsRequest = (0, import_ahooks.useRequest)(import_server.getProducts, {
    manual: true,
    onSuccess: (res) => {
      const _lists = (0, import_utils4.transformInitProductLists)(
        res,
        !!(currentItem == null ? void 0 : currentItem.isGift),
        currentItem == null ? void 0 : currentItem._selectedOriginGifts
      );
      if (currentItem == null ? void 0 : currentItem.isGift) {
        (0, import_buildGiftOrderProducts.seedGiftProductQueryCache)(_lists);
      }
      setProducts(_lists);
    },
    onError: (error) => {
      console.error("getProducts error:", error);
    }
  });
  const openModal = (0, import_react.useCallback)(
    (item) => {
      var _a2, _b2, _c2, _d2, _e;
      setCurrentItem(item || {});
      setSelected(item == null ? void 0 : item.selected);
      if ((_a2 = item == null ? void 0 : item.products) == null ? void 0 : _a2.length) {
        const date = (_d2 = (_c2 = (_b2 = item == null ? void 0 : item.state) == null ? void 0 : _b2.date) == null ? void 0 : _c2.value) == null ? void 0 : _d2.format("YYYY-MM-DD");
        getProductsRequest.run({
          ids: ((_e = item == null ? void 0 : item.products) == null ? void 0 : _e.map((option) => option.product_id)) || [],
          isGift: !!(item == null ? void 0 : item.isGift),
          schedule_date: date
        });
      }
      setOpen(true);
    },
    [getProductsRequest]
  );
  const closeModal = (0, import_react.useCallback)(() => {
    var _a2;
    setOpen(false);
    setSelected((currentItem == null ? void 0 : currentItem.isMultiple) ? [] : "");
    setProducts([]);
    setCurrentItem({});
    (_a2 = options == null ? void 0 : options.onCancel) == null ? void 0 : _a2.call(options);
    productsRef.current = [];
    setCartProducts([]);
  }, [currentItem == null ? void 0 : currentItem.isMultiple, options == null ? void 0 : options.onCancel]);
  const handleCustomCallback = (0, import_ahooks.useMemoizedFn)(
    (product, type) => {
      var _a2;
      if (!(0, import_utils4.isProductNeedSku)(product)) return;
      let newSelected;
      if (currentItem == null ? void 0 : currentItem.isMultiple) {
        newSelected = Array.isArray(selected) ? [...selected] : [];
        const isStepper = newSelected.length > 0 && typeof newSelected[0] === "object" && "value" in newSelected[0];
        if (type === "onConfirm") {
          const existingIndex = newSelected.findIndex((item) => item.value === (product == null ? void 0 : product.id));
          const quantity = ((_a2 = product == null ? void 0 : product._extend) == null ? void 0 : _a2.quantity) || (product == null ? void 0 : product.quantity) || 1;
          if (existingIndex >= 0) {
            newSelected[existingIndex] = { value: product.id, quantity };
          } else {
            newSelected.push({ value: product.id, quantity });
          }
        } else {
          if (isStepper) {
            newSelected = newSelected.filter((item) => item.value !== (product == null ? void 0 : product.id));
            productsRef.current = productsRef.current.map((p) => {
              if (p.id === (product == null ? void 0 : product.id)) {
                p._extend.quantity = 1;
              }
              return p;
            });
          } else {
            const index = newSelected.indexOf(product == null ? void 0 : product.id);
            if (index >= 0) {
              newSelected.splice(index, 1);
            }
          }
        }
      } else {
        if (type === "onConfirm") {
          newSelected = product == null ? void 0 : product.id;
        } else {
          newSelected = "";
        }
      }
      setRandomKey(Math.random());
      setSelected(newSelected);
    }
  );
  const skuDetailConfig = (0, import_react.useCallback)(
    (product) => {
      let _customData = {};
      if (currentItem == null ? void 0 : currentItem.isGift) {
        _customData = {
          price: (product == null ? void 0 : product.price) || 0,
          base_price: (product == null ? void 0 : product.base_price) || 0,
          original_price: (product == null ? void 0 : product.origin_price) || 0
        };
      }
      return {
        isShowStepper: false,
        isShowNote: false,
        externalVariant: {
          isCustom: true,
          formatVariant: (variant) => {
            if (!(currentItem == null ? void 0 : currentItem.isGift)) return variant;
            return (0, import_utils4.giftVariants)(variant);
          }
        },
        useCustomData: true,
        customData: _customData,
        isCallProductDetail: true,
        onConfirm: (data) => {
        },
        onRemove: (data) => {
          handleCustomCallback(product, "onRemove");
        }
      };
    },
    [currentItem == null ? void 0 : currentItem.isGift, currentItem == null ? void 0 : currentItem.isMultiple, selected]
  );
  const handleSkuModalCallback = (0, import_ahooks.useMemoizedFn)(
    (data, originalProduct, selected2) => {
      handleSkuConfirmCallback(originalProduct == null ? void 0 : originalProduct.id, data, selected2);
    }
  );
  const prepareProductForSkuModal = (0, import_ahooks.useMemoizedFn)((product) => {
    const filteredProduct = (0, import_utils4.filterProductByPromotionRules)(product, currentItem);
    return filteredProduct;
  });
  const openEditNormalService = (0, import_ahooks.useMemoizedFn)((product, selected2) => {
    const openNormalService = (0, import_openNormalService.getOpenNormalServiceHandler)();
    if (!openNormalService) {
      return;
    }
    openNormalService({
      mode: "edit",
      cacheItem: product,
      skuDetailConfig: skuDetailConfig(product),
      callback: (data) => {
        handleSkuModalCallback(data, product, selected2);
      }
    });
  });
  const openAddService = (0, import_ahooks.useMemoizedFn)((product, selected2) => {
    const handleAddService = (0, import_utils2.getHandleAddService)();
    if (!handleAddService) {
      return;
    }
    handleAddService(
      {
        ...product,
        skuDetailConfig: skuDetailConfig(product)
      },
      (cacheItem) => {
        handleSkuModalCallback(cacheItem, product, selected2);
      }
    );
  });
  const isRetail = (0, import_react.useCallback)((option) => {
    var _a2;
    const item = ((_a2 = option == null ? void 0 : option.dataSource) == null ? void 0 : _a2._origin) || (option == null ? void 0 : option.dataSource) || (option == null ? void 0 : option._origin);
    return (0, import_utils3.isNormalProductByDurationSchedule)(item);
  }, []);
  const isShowEditBtn = (0, import_react.useCallback)((option) => {
    var _a2;
    const item = ((_a2 = option == null ? void 0 : option.dataSource) == null ? void 0 : _a2._origin) || (option == null ? void 0 : option.dataSource) || (option == null ? void 0 : option._origin);
    return (0, import_utils4.isProductNeedSku)(item);
  }, []);
  const _openSkuModal = (0, import_ahooks.useMemoizedFn)(async (product, selected2) => {
    var _a2;
    try {
      if ((currentItem == null ? void 0 : currentItem.isMultiple) && Array.isArray(selected2)) {
        const isNormal = (0, import_utils3.isNormalProductByDurationSchedule)(product);
        const _productId = (product == null ? void 0 : product.product_id) || (product == null ? void 0 : product.id);
        const isSelected = selected2 == null ? void 0 : selected2.some(
          (item) => (item == null ? void 0 : item.value) === _productId
        );
        if (!isSelected && !isNormal) {
          setSelected(selected2);
          return;
        }
      }
      let _product = (0, import_utils4.findProductById)(
        productsRef.current,
        (product == null ? void 0 : product.id) ?? (product == null ? void 0 : product.product_id)
      );
      if (!_product) {
        return;
      }
      _product = prepareProductForSkuModal(_product);
      if (options == null ? void 0 : options.openGiftSkuDetail) {
        await options.openGiftSkuDetail({
          product: _product,
          selected: selected2,
          currentItem,
          onComplete: (cacheItem) => {
            handleSkuModalCallback(cacheItem, _product, selected2);
          }
        });
        return;
      }
      if (((_a2 = _product == null ? void 0 : _product._extend) == null ? void 0 : _a2.isNormalProduct) && (_product == null ? void 0 : _product.is_eject)) {
        const _isProductNeedSku = (0, import_utils4.isProductNeedSku)(_product);
        if (_isProductNeedSku && !(_product == null ? void 0 : _product.created_at)) {
          try {
            const { data } = await (0, import_serve.getProductDetail)(String(_product.id), {
              is_eject: 1
            });
            _product.option_group = data == null ? void 0 : data.option_group;
            _product.bundle_group = data == null ? void 0 : data.bundle_group;
          } catch (error) {
          }
        }
        openEditNormalService(_product, selected2);
      } else {
        openAddService(_product, selected2);
      }
    } catch (error) {
      console.error("openSkuModal error:", error);
    }
  });
  const handleProductSelect = (0, import_react.useCallback)(
    (value) => {
      var _a2;
      if (suppressProductSelectSkuOpenRef.current) {
        suppressProductSelectSkuOpenRef.current = false;
        return;
      }
      if (currentItem == null ? void 0 : currentItem.isMultiple) {
        const newSelectedData = Array.isArray(value) ? value : [];
        const prevSelectedData = Array.isArray(selected) ? selected : [];
        const isStepper = newSelectedData.length > 0 && typeof newSelectedData[0] === "object" && "value" in newSelectedData[0];
        const newSelectedIds = isStepper ? newSelectedData.map((item) => item.value) : newSelectedData;
        const prevSelectedIds = isStepper && prevSelectedData.length > 0 && typeof prevSelectedData[0] === "object" && "value" in prevSelectedData[0] ? prevSelectedData.map((item) => item.value) : prevSelectedData;
        const addedIds = newSelectedIds.filter(
          (id) => !prevSelectedIds.includes(id)
        );
        const removedIds = prevSelectedIds.filter(
          (id) => !newSelectedIds.includes(id)
        );
        if (addedIds.length > 0) {
          const addedId = addedIds[0];
          const selectedProductData = (0, import_utils4.findProductById)(
            productsRef.current,
            addedId
          );
          if (selectedProductData) {
            _openSkuModal(selectedProductData, newSelectedData);
          }
        } else if (removedIds.length > 0) {
          const removedId = removedIds[0];
          const removedProductData = (0, import_utils4.findProductById)(
            productsRef.current,
            removedId
          );
          if (removedProductData == null ? void 0 : removedProductData.is_eject) {
            _openSkuModal(removedProductData, newSelectedData);
          } else {
            setSelected(newSelectedData);
          }
        } else {
          if (isStepper) {
            const updatedProducts = (_a2 = productsRef.current) == null ? void 0 : _a2.map((product) => {
              const stepperItem = newSelectedData.find(
                (item) => item.value === product.id
              );
              if (stepperItem) {
                const _quantity = stepperItem.quantity || 1;
                product._extend.quantity = _quantity;
              }
              return product;
            });
            setProducts(updatedProducts || []);
          }
          setSelected(newSelectedData);
        }
      } else {
        const prevSelected = selected;
        const newSelected = value || "";
        if (newSelected && newSelected !== prevSelected) {
          const selectedProductData = (0, import_utils4.findProductById)(
            productsRef.current,
            newSelected
          );
          if (selectedProductData) {
            _openSkuModal(selectedProductData, newSelected);
          }
        } else if (prevSelected && !newSelected) {
          const prevProductData = (0, import_utils4.findProductById)(
            productsRef.current,
            prevSelected
          );
          if (prevProductData == null ? void 0 : prevProductData.is_eject) {
            _openSkuModal(prevProductData, newSelected);
          } else {
            setSelected(newSelected);
          }
        } else {
          setSelected(newSelected);
        }
      }
    },
    [selected, currentItem == null ? void 0 : currentItem.isMultiple, products, _openSkuModal, setSelected]
  );
  const handleConfirm = (0, import_react.useCallback)(() => {
    var _a2, _b2, _c2, _d2;
    try {
      const selectedIds = Array.isArray(selected) ? selected.map((item) => (item == null ? void 0 : item.value) || item) : selected ? [selected] : [];
      const _selectedProduct = (0, import_utils4.findSelectedProductsFromList)(
        productsRef.current,
        selectedIds
      );
      const promotionInfo = (currentItem == null ? void 0 : currentItem.promotionInfo) || {};
      promotionInfo.lastEvaluatedGiftCount = ((_c2 = (_b2 = (_a2 = currentItem == null ? void 0 : currentItem.selectedProducts) == null ? void 0 : _a2[0]) == null ? void 0 : _b2._giftInfo) == null ? void 0 : _c2.lastEvaluatedGiftCount) || 1;
      let _products = (_selectedProduct || []).map((item) => ({
        ...item,
        _giftInfo: (currentItem == null ? void 0 : currentItem.isGift) ? promotionInfo : null,
        _promotionInfo: (currentItem == null ? void 0 : currentItem.isGift) ? null : promotionInfo
      }));
      (_d2 = options == null ? void 0 : options.onConfirm) == null ? void 0 : _d2.call(options, {
        selectedProducts: _products,
        currentItem
      });
      closeModal();
    } catch (error) {
      console.error("Marketing modal confirm error:", error);
    }
  }, [products, selected, currentItem, options == null ? void 0 : options.onConfirm, closeModal]);
  const isDisabledClick = (0, import_react.useCallback)(
    (option) => {
      const _isShowEditBtn = isShowEditBtn(option);
      if (!_isShowEditBtn) return true;
      if (!(currentItem == null ? void 0 : currentItem.isMultiple)) return true;
      return false;
    },
    [currentItem == null ? void 0 : currentItem.isMultiple]
  );
  const multipleSelected = (0, import_react.useCallback)(
    (option) => {
      var _a2;
      const item = ((_a2 = option == null ? void 0 : option.dataSource) == null ? void 0 : _a2._origin) || (option == null ? void 0 : option.dataSource);
      const productId = (item == null ? void 0 : item.product_id) || (item == null ? void 0 : item.id);
      const isSelected = selected == null ? void 0 : selected.some(
        (item2) => (item2 == null ? void 0 : item2.value) === productId
      );
      return {
        isExist: !!isSelected,
        selectedData: !isSelected ? [{ value: productId, quantity: 1 }] : selected
      };
    },
    [selected]
  );
  const modalContent = (0, import_react.useMemo)(() => {
    if (!open) return null;
    if (getProductsRequest.loading) {
      return /* @__PURE__ */ import_react.default.createElement(import_antd.Skeleton, { active: true, loading: true });
    }
    const _mode = (currentItem == null ? void 0 : currentItem.isMultiple) ? "multiple" : "single";
    const _maxAvailableCount = (0, import_utils4.getMaxAvailableCount)(currentItem);
    const _title = !(currentItem == null ? void 0 : currentItem.isGift) ? import_utils.locales.getText(
      "pisell2.text.shopping-cart.marketing.modal.product.tip"
    )(_maxAvailableCount) : import_utils.locales.getText("pisell2.text.shopping-cart.marketing.modal.tip")(
      _maxAvailableCount
    );
    const _showStepper = !!(currentItem == null ? void 0 : currentItem.isMultiple);
    const enableGiftSkuHost = Boolean(options == null ? void 0 : options.openGiftSkuDetail);
    const handleEditProduct = (dataSource) => {
      const productId = (dataSource == null ? void 0 : dataSource.product_id) || (dataSource == null ? void 0 : dataSource.id);
      let selectedForEdit = selected;
      if (currentItem == null ? void 0 : currentItem.isMultiple) {
        selectedForEdit = Array.isArray(selected) ? selected : [];
      } else {
        selectedForEdit = productId;
      }
      _openSkuModal(dataSource, selectedForEdit);
    };
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: `marketing-modal-content marketing-modal-content--${currentVariant}`
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_Selector.default,
        {
          key: randomKey,
          title: _title,
          dataSource: cartProducts || [],
          mode: _mode,
          showStepper: _showStepper,
          stepperProps: {
            size: "middle",
            shape: "round"
          },
          valueType: _showStepper ? "object" : "primitive",
          fieldNames: { value: "id", label: "title" },
          value: selected,
          onChange: handleProductSelect,
          variant: "card",
          preset: { variant: "3" },
          ruleConfig: { max: _maxAvailableCount },
          itemProps: {
            layout: "horizontal",
            renderContent: (option) => {
              var _a2, _b2;
              return /* @__PURE__ */ import_react.default.createElement(
                import_materials.ProductCard.V2,
                {
                  type: isRetail(option) ? "a9" : "a5",
                  key: ((_a2 = option == null ? void 0 : option.dataSource) == null ? void 0 : _a2._id) || ((_b2 = option == null ? void 0 : option.dataSource) == null ? void 0 : _b2.id),
                  dataSource: option == null ? void 0 : option.dataSource,
                  isShowImage: true,
                  disabledClick: isDisabledClick(option),
                  disabledEdit: true,
                  onCard: () => {
                    const { isExist, selectedData } = multipleSelected(option);
                    const _currentMaxProductCount = (0, import_utils4.getCurrentMaxProductCount)(
                      option,
                      selected,
                      currentItem,
                      false
                    );
                    if (!isExist && _currentMaxProductCount <= 0) return;
                    _openSkuModal(option == null ? void 0 : option.dataSource, selectedData);
                  },
                  isShowDelete: false,
                  isShowOriginalPrice: true,
                  isShowEditProduct: isShowEditBtn(option),
                  disabledEditClick: !enableGiftSkuHost,
                  onEditProduct: enableGiftSkuHost ? handleEditProduct : void 0
                }
              );
            }
          }
        }
      )
    );
  }, [
    open,
    products,
    cartProducts,
    selected,
    currentItem,
    currentVariant,
    getProductsRequest.loading,
    randomKey,
    isDisabledClick,
    isShowEditBtn,
    multipleSelected,
    options == null ? void 0 : options.openGiftSkuDetail,
    _openSkuModal
  ]);
  const MarketingModal = (0, import_react.useMemo)(() => {
    const _title = (currentItem == null ? void 0 : currentItem.isGift) ? import_utils.locales.getText("pisell2.text.shopping-cart.marketing.modal.title") : import_utils.locales.getText("pisell2.text.shopping-cart.marketing.browse.items");
    const confirmDisabled = !selected || Array.isArray(selected) && !(selected == null ? void 0 : selected.length);
    const isPhoneVariant = currentVariant === "phone";
    const containerProps = isPhoneVariant ? {
      open,
      title: _title,
      placement: "bottom",
      width: "100%",
      height: "95dvh",
      style: {
        maxHeight: "95dvh"
      },
      onClose: closeModal,
      destroyOnClose: true,
      closable: false,
      className: "shopping-cart-marketing-modal shopping-cart-marketing-modal--phone",
      bodyStyle: {
        padding: "0 16px",
        overflow: "auto"
      },
      footer: /* @__PURE__ */ import_react.default.createElement("div", { className: "shopping-cart-marketing-modal-footer" }, /* @__PURE__ */ import_react.default.createElement(
        import_materials.Button,
        {
          block: true,
          type: "primary",
          size: "large",
          loading,
          onClick: handleConfirm
        },
        import_utils.locales.getText(
          "pisell2.text.shopping-cart.marketing.modal.confirm"
        )
      ))
    } : {
      open,
      width: 660,
      title: _title,
      okText: import_utils.locales.getText(
        "pisell2.text.shopping-cart.marketing.modal.confirm"
      ),
      okButtonProps: {
        // disabled: confirmDisabled,
      },
      style: {
        maxHeight: "95%"
      },
      destroyOnClose: true,
      confirmLoading: loading,
      cancelVisible: false,
      onOk: handleConfirm,
      onCancel: closeModal,
      className: `shopping-cart-marketing-modal shopping-cart-marketing-modal--${currentVariant}`
    };
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
      import_compensatedPisellContainer.default,
      {
        renderType: isPhoneVariant ? "drawer" : "modal",
        showHandlerBar: isPhoneVariant,
        onHandlerBarClick: closeModal,
        props: containerProps
      },
      modalContent
    ));
  }, [
    open,
    selected,
    loading,
    modalContent,
    handleConfirm,
    closeModal,
    currentItem == null ? void 0 : currentItem.isGift,
    currentVariant
  ]);
  return {
    /** 打开弹窗方法 */
    openModal,
    /** 关闭弹窗方法 */
    closeModal,
    /** Modal 组件 */
    MarketingModal,
    /** 规格选择弹窗组件 */
    SkuModal,
    /** 当前选中的商品 ID */
    selected,
    /** 弹窗是否打开 */
    isOpen: open
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  usePromotionModal
});
