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