import{cls as e,convertDecimalToNumber as t,formatMoney as r,makeStyleResponsive as i,getResponsiveValueByScreen as n}from"@gem-sdk/core";import{applyBundleDiscountAmount as o}from"../../../helpers/product-bundle.js";import{DiscountType as l}from"../../constants/product-bundle.js";let u=e=>e.replace(/\.00$/,""),d=(e,t)=>t?Math.round(100*(1e3*t-1e3*e)/(1e3*t)):"0",a=(e,t,i)=>u(r(t?(t-e).toFixed(2):"0",i)),s=(e,i)=>{let n=e?.edges?.length&&e.edges.length>0?1/0:0;return e?.edges.forEach(({node:e})=>{if(!e)return;let r=t(e?.price);void 0!==r&&r<n&&(n=r)}),u(r(n.toString(),i))},c=(e,t)=>{let{discountPercentAmount:r}=o({currentVariant:e?.currentVariant,bundleItem:e?.bundleItem,options:{moneyFormat:t,useProductCompareAtPrice:e?.useProductCompareAtPrice}});return!(e?.bundleItem?.discountType===l.NoDiscount&&e?.useProductCompareAtPrice||Number(e?.bundleItem?.discountValue)&&r)&&!e?.currentVariant?.salePrice},p=(e,i,n)=>{if(!e.detail||!i?.trim()?.length)return i;let{detail:u,currentVariant:c}=e,{discountPercentAmount:p,discountAmount:m}=o({currentVariant:c,bundleItem:e?.bundleItem,options:{moneyFormat:n,useProductCompareAtPrice:e?.useProductCompareAtPrice}}),g=new Map([["{percent_discount}",()=>e?.bundleItem?.discountType!==l.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?`${p}%`:`${d(t(c?.price)??0,t(c?.salePrice)??0)||0}%`:"0%"],["{amount_discount}",()=>e?.bundleItem?.discountType!==l.NoDiscount||e?.useProductCompareAtPrice?Number(e?.bundleItem?.discountValue)>0?m:a(t(c?.price)??0,t(c?.salePrice)??0,n):r("0",n)],["{min_price}",()=>s(u.variants,n)||0],["{inventory_quantity}",()=>c?.inventoryQuantity||0]]);return[...g.entries()].reduce((e,[t,r])=>e.replaceAll(t,r().toString()),i)},m=e=>!!e&&/\{percent_discount\}|\{amount_discount\}/.test(e),g=(e,t,r="desktop")=>e?t?.[`--pos${I(r)}`]?"w-full h-full":"!gp-absolute":t?.[`--d${I(r)}`]?"":"!gp-inline-block gp-w-fit",b=(t,r)=>e("gp-flex",{"gp-justify-start":t?.desktop==="left","gp-justify-center":t?.desktop==="center","gp-justify-end":t?.desktop==="right","tablet:gp-justify-start":t?.tablet==="left","tablet:gp-justify-center":t?.tablet==="center","tablet:gp-justify-end":t?.tablet==="right","mobile:gp-justify-start":t?.mobile==="left","mobile:gp-justify-center":t?.mobile==="center","mobile:gp-justify-end":t?.mobile==="right"}),h=e=>Object.entries(e||{}).reduce((e,[t,r])=>{let i=new Map([["clipPath","clip-path"],["writingMode","writing-mode"],["borderRadius","border-radius"],["transform","transform"],["alignItems","align-items"],["maxWidth","max-width"]]),n=i.get(t)||t;return{...e,[n]:r}},{}),f=e=>({[e?"z-index":"zIndex"]:2}),y=(e,t)=>{let r={};return["desktop","mobile","tablet"].forEach(i=>{let o=n(e,i,null),l=o?.width||t?.wrapperWidth;l&&(r={...r,[i]:l})}),r},P=(e,t)=>{let r={};return["desktop","mobile","tablet"].forEach(i=>{let o=n(e,i,null);r={...r,[i]:o?.height||t?.wrapperHeight}}),r},k=(e,t)=>{let r=i("w",y(t,e)),n=i("h",P(t,e));return{...r,...n}},S=e=>{let t={};return 1!==e||["desktop","mobile","tablet"].forEach(e=>{t={...t,height:0,[`--p${"desktop"!==e?`-${e}`:""}`]:"50% 0"}}),t},I=e=>"desktop"===e?"":`-${e}`,j=(e,t)=>{for(let r of({desktop:["desktop"],tablet:["tablet","desktop"],mobile:["mobile","tablet","desktop"]})[t])if(e?.[r])return e[r]},w=({props:e,product:t,currentVariant:r,moneyFormat:i,useProductCompareAtPrice:n})=>{let{setting:o,"bundle-item":l}=e,u=m(o?.displayContent);return u&&c({currentVariant:r,bundleItem:l,useProductCompareAtPrice:n},i)};export{m as checkDiscountContentProductBadge,c as checkNoDiscountState,h as convertToStyle,I as deviceWithSurfix,b as getAlignShape,p as getBadgeContent,j as getDeviceSpecificStyle,w as getIsNoDiscountState,g as getShapePlacementClass,S as getShapeWrapperPadding,k as getSize,y as getWidthByShapeSize,f as getWrapperStyle};
