'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),NoDataState=require("../../../common/components/NoDataState.js"),system=require("@gem-sdk/system"),styles=require("./common/styles.js"),classes=require("./common/classes.js"),useProductBundleDataState=require("./hooks/useProductBundleDataState.js"),useProductBundleDiscountState=require("./hooks/useProductBundleDiscountState.js"),ProductBundleDiscountChildrenItem=require("./ProductBundleDiscountChildrenItem.js");const ProductBundleDiscount=({builderAttrs:e,style:t,children:s,setting:u,styles:n,advanced:l})=>{let{isEditMode:r,isPreviewSharePageMode:a}=core.useRenderMode(),{isSelected:i,setSelected:o}=useProductBundleDiscountState.default(u),{emitRedirectSetupPage:c,redirectGuideline:d,svgVertical:m,svgHorizontal:y}=useProductBundleDataState.default(),{t:S}=core.useI18nStore(),j=system.createClass(classes.getContainerClasses(u,l?.cssClass)),h=system.createClass(classes.getNoDiscountClasses),D=system.createStyle(styles.getSizeSettings(n)?.gap),x=system.createStyle(styles.getContainerStyles(D,n,t));if(!u?.bundleItems?.length&&r)return jsxRuntime.jsx(NoDataState.default,{elementType:"secondary",description:S("Increase AOV with bundle quantity."),descriptionActions:[{text:S("Setup bundle discount"),callback:c},{text:S("read guideline"),callback:d}],additionalMedia:u?.layout=="horizontal-layout"?y:m});let p=(e,t)=>{if(u?.hideNoDiscountItem&&e?.discountType==="no_discount")return null;let l=s?.[t];if(React.isValidElement(l))return jsxRuntime.jsx(ProductBundleDiscountChildrenItem.default,{index:t,childItem:l,setting:u,styles:n,isSelected:i(t),setSelected:o,bundleItem:e},t)},g=(core.isEmptyChildren(s)||u?.bundleItems?.length==0)&&!a;return jsxRuntime.jsxs("div",{...e,className:j,style:x,children:[system.If(g,jsxRuntime.jsx("div",{className:h,children:S("This product has no bundle discount")})),u?.bundleItems?.map((e,t)=>p(e,t))]})};exports.default=ProductBundleDiscount;
