yt-uikit 0.7.344-shadowdomBundle.47 → 0.7.344-shadowdomBundle.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -3209,7 +3209,7 @@ import*as e from"react";import t,{forwardRef as n,useImperativeHandle as r,useRe
|
|
|
3209
3209
|
scrollbar-width: none;
|
|
3210
3210
|
|
|
3211
3211
|
-ms-overflow-style: none;
|
|
3212
|
-
`,Nm=(e,t)=>{if(!t)return{};for(const n of t)if(n.productId==e)return n;return{}};function _m({bundle:e,addToCartFunction:n,currentProductId:r,shadowRoot:d}){const s=i((()=>{if(r){const t="gid://shopify/Product/"+r,n=e.products?.some((e=>e.productId===t));return n?t:e.products?.[0]?.productId}return e.products?.[0]?.productId}),[r,e.products]),p=i((()=>Nm(s,e.products)),[s,e.products]),u=o(null),m=o(null),f=o({}),g=e.customizations??{},h=(i((()=>p?.productDetails?.variants?.edges?.reduce(((e,{node:t})=>t.inventoryQuantity>0?e+=1:e),0)),[p]),i((()=>Nm(s,e.products)?.id),[s,e.products]));i((()=>h?Nm(s,e.products):void 0),[s,e.products,h]);const x=i((()=>e.products?.some((e=>e.productDetails?.options?.some((e=>e.values.length>1))))||!1),[e.products]);g.volumeBundle;const y=x,b=i((()=>e?.volumeTiers||[]),[e?.volumeTiers]),v=b.findIndex((e=>e.isDefault)),[w,C]=c(-1!==v?b[v].tier:b?.[0]?.tier||1),[k,E]=c(p?.productDetails?.variants?.edges?.[0]?.node?.id||""),[T,S]=c({}),[B,$]=c(b.reduce(((e,t,n)=>(e[t.tier-1]=Array.from({length:t.minimumQuantity},(()=>p?.productDetails?.options?.map((e=>e.values[0]))||[])),e)),{})||{}),[z,D]=c(!1),[I,P]=c(window.innerWidth<550),[N,_]=c(null);o([]);const O=o([]);l((()=>{const e=()=>{P(window.innerWidth<550)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),l((()=>{const e=e=>{N&&O.current[N.index]&&O.current[N.index][N.optionIndex]&&!O.current[N.index][N.optionIndex]?.contains(e.target)&&_(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[N]);const M=a((e=>{if(!g.general?.trackInventory)return null;const t=b.find((t=>t.tier===e));if(!t)return null;const n=t.minimumQuantity,r=p?.productDetails?.variants?.edges||[];for(const e of r){const t=e.node;if(t.inventoryQuantity>=n&&t.availableForSale){const e=t.title.split(" / ");return Array(n).fill(e)}}const o=[],a={},i=[...r].sort(((e,t)=>t.node.inventoryQuantity-e.node.inventoryQuantity));for(let e=0;e<n&&o.length<n;e++){let e=!1;for(const t of i){const n=t.node,r=a[n.id]||0;if(n.inventoryQuantity>r&&n.availableForSale){const t=n.title.split(" / ");o.push(t),a[n.id]=r+1,e=!0;break}}if(!e)return null}return o.length===n?o:null}),[p,b]),A=a((e=>{if(!g.general?.trackInventory)return!0;const t=b.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=p?.productDetails?.variants?.edges||[];let o=0;for(const e of r){const t=e.node;t.availableForSale&&(o+=Math.max(0,t.inventoryQuantity))}return o>=n}),[g.general?.trackInventory,b,p]);l((()=>{const e={},t=p?.productDetails?.variants?.edges?.[0]?.node?.id||"";t&&b.forEach((n=>{e[n.tier]={};for(let r=0;r<n.minimumQuantity;r++)e[n.tier][r]=t})),S(e)}),[p?.id,b?.map((e=>`${e.tier}-${e.minimumQuantity}`)).join("|")]),l((()=>{if(!f.current[w]){const e=M(w);if(e){const t=w-1;$((n=>({...n,[t]:e})));const n={};e.forEach(((e,t)=>{const r=e.join(" / "),o=p?.productDetails?.variants?.edges?.find((e=>e.node.title===r))?.node.id||k;n[t]=o})),S((e=>({...e,[w]:n})))}f.current[w]=!0}}),[w,p,k,M]);const F=(e,t)=>e?.productDetails?.variants?.edges?.find((e=>e.node.id===t))?.node,R=a(((e,t,n,r,o)=>{if(!g?.general?.trackInventory)return!0;const a=b.find((t=>t.tier===e));if(!a)return!1;const i=a.minimumQuantity,l=e-1,c=[...n];c[r]=o;const d=c.join(" / "),s=p?.productDetails?.variants?.edges?.find((e=>e.node.title===d))?.node;if(!s||!s.availableForSale||s.inventoryQuantity<=0)return!1;const u={};for(let e=0;e<i;e++){let n;if(e===t)n=s.id;else{const t=(B[l]?.[e]||p.productDetails.options.map((e=>e.values[0]))).join(" / "),r=p?.productDetails?.variants?.edges?.find((e=>e.node.title===t));if(!r)return!1;n=r.node.id}u[n]=(u[n]||0)+1}for(const[e,t]of Object.entries(u)){const n=F(p,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[g?.general?.trackInventory,b,p,B]),L=a((e=>{if(!g.general?.trackInventory)return!0;const t=b.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=e-1,o={};for(let e=0;e<n;e++){const t=(B[r]?.[e]||p.productDetails.options.map((e=>e.values[0]))).join(" / "),n=p?.productDetails?.variants?.edges?.find((e=>e.node.title===t));if(!n)return!1;const a=n.node.id;o[a]=(o[a]||0)+1}for(const[e,t]of Object.entries(o)){const n=F(p,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[g.general?.trackInventory,b,p,B]),j=(e,t,n)=>{S((r=>({...r,[e]:{...r[e]||{},[t]:n}})))},V=a((()=>!1===g.general?.trackInventory?p?.productDetails?.variants?.edges?.[0]?.node:p?.productDetails?.variants?.edges?.find((e=>e.node.inventoryQuantity>0))?.node||p?.productDetails?.variants?.edges?.[0]?.node),[p]),H=a((()=>new URLSearchParams(window.location.search).get("variant")||""),[]),W=()=>{const e=H();if(e){const t=p?.productDetails?.variants?.edges?.find((t=>String(t.node.id)==="gid://shopify/ProductVariant/"+String(e)));if(t&&t.node.inventoryQuantity>0)E(String(t.node.id));else{const e=V();e&&E(String(e.id))}}};l((()=>{W();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,r=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(r.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",W),()=>{t=!1,window.removeEventListener("urlChange",W),window.history.pushState=n,window.history.replaceState=r}}),[H,p?.id,V]);const U=t=>{const n=b.find((e=>e.tier===t));if(!n)return{original:0,discounted:0};let r=0,o=0;const a=T[t]||{};for(let e=0;e<n.minimumQuantity;e++){const t=a[e]||k,n=F(p,t);n&&(n.compareAtPrice?r+=Number.parseFloat(n.compareAtPrice):r+=Number.parseFloat(n.price),o+=Number.parseFloat(n.price))}return"percentOff"===e?.discountType?o*=1-n.discountValue/100:"amountOff"===e?.discountType&&(o-=n.discountValue),o<0&&(o=0),{original:r,discounted:o,discountValue:n.discountValue}},G=(e,t,n,r)=>{let o=F(e,t);if(r){const a=T[r]?.[n||0]||t;o=F(e,a)}return o?.image?.url?o.image.url:e.productDetails?.media?.edges[0]?.node.image.url||""},Q=i((()=>b.find((e=>e.tier===w))),[b,w]),q=i((()=>Q?U(Q.tier):null),[Q,T,k]),Y=i((()=>{if(!Q||!q)return;const e=T[Q.tier]||{},t={};for(let n=0;n<Q.minimumQuantity;n++){const r=e[n]||k;t[r]=(t[r]||0)+1}return t}),[Q?.minimumQuantity,k,T,q]),Z=i((()=>Object.entries(Y??{}).map((([e,t])=>({variantId:e,quantity:t})))),[Y]);if(l((()=>{if(!Q||!q)return;const e={tier:w,items:Q.minimumQuantity,discountedPrice:q.discounted,originalPrice:q.original,variants:Z,productId:p?.id??null,tierMeta:{title:Q.title,subtitle:Q.subtitle,badgeTitle:Q.badgeTitle},productData:p,tierData:Q},t=m.current;return t&&JSON.stringify(t)===JSON.stringify(e)?void 0:(u.current&&clearTimeout(u.current),u.current=window.setTimeout((()=>{m.current=e;const t=new CustomEvent("ytBundleTierChange",{detail:e});window.dispatchEvent(t)}),50),()=>{u.current&&clearTimeout(u.current)})}),[w,Q?.tier,Q?.minimumQuantity,q?.discounted,q?.original,p?.id,JSON.stringify(Z)]),!n)return t.createElement(t.Fragment,null);const K=g.volumeBundle?.cardStyle,X=g.general?.primaryColor,J=g.general?.secondaryColor,ee=g.general.primaryContrastColor,te=g.general.secondaryContrastColor,ne="high"===e.cornerRadiusType?"20px":"medium"===e.cornerRadiusType?"6px":"0px",re="bundles"==e.appName?e.pageHeader?.title:e?.title,oe="bundles"==e.appName?e.pageHeader?.description:e?.subtitle;return t.createElement(om,{verticalMargin:g.volumeBundle?.verticalMargin,backgroundColor:g.volumeBundle?.sectionBackgroundColor,className:"yt-bundle-container"},t.createElement(am,{className:"yt-bundle-header"},re&&re.trim().length>0&&t.createElement(im,{fontSize:g.volumeBundle?.titleFontSize,backgroundColor:g.volumeBundle?.titleBackgroundColor,textColor:g.volumeBundle?.titleTextColor,className:"yt-bundle-header-title"},re),t.createElement(lm,{className:"yt-bundle-header-subtitle",fontSize:g.volumeBundle?.subtitleFontSize},oe)),"vertical"===K?t.createElement("div",{style:{display:"grid",gridTemplateColumns:I||4===b.length?"repeat(2, 1fr)":b.length>4?"repeat(3, 1fr)":`repeat(${b.length}, 1fr)`,justifyItems:"center",gap:I?"10px":"16px",paddingTop:"10px"},className:"yt-bundle-vertical-container"},b.map((n=>{const r=U(n.tier),o=r.original-r.discounted,a=w===n.tier,i=!A(n.tier);return t.createElement(t.Fragment,{key:n.tier},t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"8px",borderRadius:ne||"24px",...a?{border:`2px solid ${X}`}:{border:`1px solid ${J}`},boxShadow:`6px 6px 0px -1px ${a?X:J}20`,...n.badgeTitle&&{position:"relative"},zIndex:5,backgroundColor:i?"#f5f5f5":"white",cursor:i?"not-allowed":"pointer",position:"relative",height:"100%",maxHeight:"350px",width:"100%",opacity:i?.6:1},className:"yt-volume-vertical-tier-item "+(a?"yt-volume-vertical-tier-item-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),onClick:()=>!i&&C(n.tier)},n.badgeTitle&&t.createElement("div",{style:{position:"absolute",top:"-15px",zIndex:-1,left:"0",right:"0",width:"80%",textAlign:"center",margin:"0 auto",fontSize:"10px",clipPath:"polygon(2% 0%, 98% 0%, 100% 100%, 0% 100%)",backgroundColor:a?X:J,color:a?ee:te,padding:"2px 0",borderRadius:"12px 12px 0px 0px",lineHeight:"normal"},className:a?"yt-volume-vertical-tier-badge-active":"yt-volume-vertical-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",height:"fit-content"},className:"yt-volume-vertical-tier-save-badge-container"},0!==r.discountValue&&t.createElement(t.Fragment,null,I&&o&&!!r?.discountValue&&"Enabled"===g.volumeBundle?.discountBadgeVisibility&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"5px",top:"8px"}},t.createElement(um,{primaryBackgroundColorCta:a?X:J,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?ee:te},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Ig(g.general.currencySymbol,e.storeCurrencyCode)}${Dg(r.discountValue)}`))),n.imageUrl&&t.createElement("img",{src:n.imageUrl,style:{objectFit:"cover",aspectRatio:"1/1",width:"100%",maxHeight:"160px",maxWidth:"160px",height:"fit-content",borderTopLeftRadius:ne||"24px",borderTopRightRadius:ne||"24px"},className:"yt-volume-vertical-tier-badge"})),t.createElement("div",{style:{padding:"8px",paddingTop:"0"}},t.createElement(mm,{style:{display:"flex",width:"100%",gap:"4px"},className:"yt-volume-vertical-details-container"},t.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative",width:"100%"},className:"yt-volume-vertical-details-title-container"},t.createElement(fm,{style:{fontSize:I?"12px":"14px",lineHeight:"normal"},className:"yt-volume-vertical-details-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),!I&&o&&!!r?.discountValue&&"Enabled"===g.volumeBundle?.discountBadgeVisibility&&t.createElement(um,{primaryBackgroundColorCta:a?X:J,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?ee:te},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Ig(g.general.currencySymbol,e.storeCurrencyCode)}${Dg(r.discountValue)}`),a&&n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"0px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:X,color:ee,padding:"2px"}},t.createElement(Xr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))),t.createElement(gm,{style:{lineHeight:"normal",fontSize:I?"10px":"14px",color:"#666"},className:"yt-volume-vertical-details-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null))),t.createElement(hm,{style:{textAlign:"left",marginTop:"4px",display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center"},className:"yt-volume-vertical-details-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},t.createElement(xm,{style:{marginLeft:"0",lineHeight:"normal",marginRight:"8px"},className:"yt-volume-vertical-details-price-discount"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.discounted.toFixed(2))),o?t.createElement(ym,{style:{lineHeight:"normal"},className:"yt-volume-vertical-details-price-original"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.original.toFixed(2))):"")),a&&!n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"10px",bottom:"10px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:X,color:ee,padding:"2px"}},t.createElement(Xr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))))}))):t.createElement(t.Fragment,null,b.map((n=>{const r=U(n.tier),o=r.original-r.discounted,a=!A(n.tier);return t.createElement(t.Fragment,{key:n.tier},n.badgeTitle&&t.createElement(cm,{primaryTextColorCta:ee,primaryBackgroundColorCta:X,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement(dm,{cornerRadiusType:e?.cornerRadiusType??"",key:n.tier,primaryBackgroundColorCta:X??"",isSelected:w===n.tier,onClick:()=>C(n.tier),style:{borderRadius:ne,cursor:"pointer",backgroundColor:a?"#f5f5f5":"white",opacity:a?.6:1},className:"yt-volume-horizontal-tier-container "+(w===n.tier?"yt-volume-horizontal-tier-container-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2)},t.createElement(sm,{cornerRadiusType:e?.cornerRadiusType??"",style:{borderRadius:ne,borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},className:"yt-volume-horizontal-tier-header"},t.createElement(pm,{className:"yt-volume-horizontal-tier-info"},t.createElement(km,{"data-active":w===n.tier,accentColor:X,className:"yt-volume-horizontal-tier-radio-wrapper"},t.createElement(Em,{name:"tier",checked:w===n.tier,onChange:()=>!a&&C(n.tier),disabled:a,className:"yt-volume-horizontal-tier-radio-hidden"}),t.createElement(Tm,{accentColor:X,className:"yt-volume-horizontal-tier-radio-custom"})),t.createElement(mm,{className:"yt-volume-horizontal-tier-details"},t.createElement("div",{style:{display:"flex"},className:"yt-volume-horizontal-tier-title-container"},t.createElement(fm,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),o&&r?.discountValue&&"Enabled"===g.volumeBundle?.discountBadgeVisibility?t.createElement(um,{primaryBackgroundColorCta:X,isSelected:w===n.tier,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Ig(g.general.currencySymbol,e.storeCurrencyCode)}${Dg(r.discountValue)}`):""),t.createElement(gm,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null)))),t.createElement(hm,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},o?t.createElement(ym,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-original-price"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.original.toFixed(2))):"",t.createElement(xm,{className:"yt-volume-horizontal-tier-discounted-price"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.discounted.toFixed(2))))),w===n.tier&&y&&t.createElement(bm,{className:"yt-volume-horizontal-tier-product-grid"},Array.from({length:n.minimumQuantity}).map(((r,o)=>{const i=n.tier-1,l=(B[i]||[])[o]||p.productDetails.options?.map((e=>e.values[0]))||[];return t.createElement("div",{key:o,style:{display:"flex",gap:"10px",alignItems:"center",position:"relative"},className:"yt-volume-horizontal-tier-product-item"},t.createElement(Sm,{src:G(p,k,o,n.tier),alt:p?.productDetails?.title||"Product",className:"yt-volume-horizontal-tier-product-image"}),"auto"===g?.volumeBundle?.variantSelectorType?t.createElement("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"}},p?.productDetails?.options?.map(((r,c)=>{const d=N?.tier===n.tier&&N?.index===o&&N?.optionIndex===c,s=e?.variantOptions?.options?.find((e=>e.name===r.name));let u="";return s&&"color"===s?.type&&(u=s?.values?.find((e=>e.name===l[c]))?.value||""),t.createElement(Dm,{key:c,ref:e=>{O.current[o]||(O.current[o]=[]),O.current[o][c]=e},style:{zIndex:d?1e3:"auto",display:"flex"},isActive:d},t.createElement(Im,{onClick:e=>{e.stopPropagation(),_(d?null:{tier:n.tier,index:o,optionIndex:c})},isActive:d,disabled:a},"color"===s?.type&&u&&t.createElement("div",{className:"yt-fixedBundle-product-card_color-swatch",style:{display:"inline-block",width:20,height:20,borderRadius:"50%",backgroundColor:u||"transparent",border:"1px solid #ddd"}}),l[c],t.createElement(jr,null)),d&&t.createElement(Pm,{style:{zIndex:1001}},r.values.map((e=>{const r=[...l];r[c]=e;const d=!R(n.tier,o,l,c,e)||a,u=p.productDetails.variants.edges.find((({node:e})=>e.title===r.join(" / ")))?.node,m=e=>{if(console.log("clicked"),d)return void e.stopPropagation();$((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t}));const t=u?.id||k;j(n.tier,o,t),_(null)},f=s?.values.find((t=>t.name===e));return"image"===s?.type&&f?.value?t.createElement(Bm,{key:e,onClick:m,style:{opacity:d?.5:1,cursor:d?"not-allowed":"pointer"}},t.createElement($m,{src:f.value,alt:e}),e,d&&" (Out of stock)"):"color"===s?.type&&f?.value?t.createElement(Bm,{key:e,onClick:m,style:{opacity:d?.5:1,cursor:d?"not-allowed":"pointer"}},t.createElement(zm,{style:{backgroundColor:f.value}}),e,d&&"Out of stock"):t.createElement(Bm,{key:e,onClick:m,style:{opacity:d?.5:1,cursor:d?"not-allowed":"pointer"}},e,d&&" (Out of stock)")}))))}))):t.createElement(vm,{style:{display:"flex",flexDirection:"column",gap:"5px"},className:"yt-volume-horizontal-tier-variant-selector"},p?.productDetails?.options.map(((r,c)=>{const d=e.variantOptions?.options?.find((e=>e.name===r.name))||null;return r.values.length<=1?null:t.createElement("div",{key:r.name,style:{width:"100%",display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"},className:"yt-volume-horizontal-tier-variant-option"},t.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"},className:"yt-volume-horizontal-tier-variant-values"},r.values.map((e=>{const r=l[c]===e,s=!R(n.tier,o,l,c,e)||a,u=d?.values.find((t=>t.name===e)),m=t=>{if(t.preventDefault(),s)return;const r=[...l];r[c]=e,$((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t}));const a=r.join(" / "),d=p.productDetails.variants.edges.find((e=>e.node.title===a))?.node.id||k;j(n.tier,o,d)},f={opacity:s?.5:1,cursor:s?"not-allowed":"pointer"};return d&&u?"color"===d.type&&u.value?t.createElement("button",{key:e,onClick:m,style:{...f,borderRadius:"50%",padding:"1px",backgroundColor:"white",border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid transparent",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-color-button",disabled:s},t.createElement("div",{style:{width:r?"24px":"20px",height:r?"24px":"20px",borderRadius:"50%",backgroundColor:u.value,lineHeight:"normal",boxShadow:"rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 2px"}},t.createElement("span",null))):"image"===d.type?t.createElement("button",{key:e,onClick:m,style:{...f,border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:r?"#F7F7F7":"transparent",padding:"0px",width:r?"20px":"18px",height:r?"20px":"18px",overflow:"hidden"},className:"yt-volume-horizontal-tier-variant-image-button",disabled:s},t.createElement("img",{src:u.value,alt:e,style:{width:r?"26px":"24px",height:r?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}})):t.createElement(wm,{key:e,isSelected:r,onClick:m,style:{...f,padding:"4px 8px",border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:r?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button-default",disabled:s},e):t.createElement(wm,{key:e,isSelected:r,onClick:m,disabled:s,style:{...f,padding:"4px 8px",border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:r?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button"},e)}))))}))))})))))}))),e?.showCta&&t.createElement("div",{style:{position:"relative"}},t.createElement(Cm,{bgColor:L(w)?g.general?.ctaBackgroundColor:"#ccc",textColor:L(w)?g.general?.ctaTextColor:"#666",border:`1px solid ${L(w)?g.general?.ctaBorderColor||"#121212":"#999"}`,shadow:g.general.ctaShadowType,padding:g.general?.ctaPadding,width:g.general?.ctaWidth,hoverProperties:{customizeHoverState:!!L(w)&&g.general?.customizeHoverState,backgroundColor:g.general?.ctaHoverBackgroundColor,textColor:g.general?.ctaHoverTextColor},onClick:async()=>{if(L(w))try{D(!0);const e=b.find((e=>e.tier===w));if(!e)return;const t={},r=T[e.tier]||{};for(let n=0;n<e.minimumQuantity;n++){const e=r[n]||k;t[e]?t[e].quantity+=1:t[e]={quantity:1}}const o=U(e.tier),a=Array.from({length:e.minimumQuantity},((e,t)=>r[t]||k));n&&await n(o.original,a)}catch(e){console.error("VolumeBundle handleAddToCart error:",e)}finally{D(!1)}else console.error("Selected tier is out of stock")},borderRadius:g.general.ctaBorderRadius??"",disabled:z||!L(w),className:"yt-volume-add-to-cart-button"},L(w)?t.createElement(t.Fragment,null,z?t.createElement(Wo,{color:"white",loading:z,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):t.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"8px",justifyContent:"center",alignItems:"center"}},t.createElement("span",null,g.volumeBundle?.ctaTitle??"Add Bundle to Cart")," ","•",t.createElement("div",{className:"yt-volume-add-to-cart-button-info"},(()=>{const n=U(w);return t.createElement(t.Fragment,null,Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(n.discounted.toFixed(2))," ",n?.original&&t.createElement("span",{style:{lineHeight:"normal",textDecoration:"line-through",fontWeight:"550"}},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(n?.original.toFixed(2))," "))})()))):t.createElement(t.Fragment,null,"Out of Stock"))))}const Om=x.div`
|
|
3212
|
+
`,Nm=(e,t)=>{if(!t)return{};for(const n of t)if(n.productId==e)return n;return{}};function _m({bundle:e,addToCartFunction:n,currentProductId:r,shadowRoot:d}){const s=i((()=>{if(r){const t="gid://shopify/Product/"+r,n=e.products?.some((e=>e.productId===t));return n?t:e.products?.[0]?.productId}return e.products?.[0]?.productId}),[r,e.products]),p=i((()=>Nm(s,e.products)),[s,e.products]),u=o(null),m=o(null),f=o({}),g=e.customizations??{},h=(i((()=>p?.productDetails?.variants?.edges?.reduce(((e,{node:t})=>t.inventoryQuantity>0?e+=1:e),0)),[p]),i((()=>Nm(s,e.products)?.id),[s,e.products]));i((()=>h?Nm(s,e.products):void 0),[s,e.products,h]);const x=i((()=>e.products?.some((e=>e.productDetails?.options?.some((e=>e.values.length>1))))||!1),[e.products]);g.volumeBundle;const y=x,b=i((()=>e?.volumeTiers||[]),[e?.volumeTiers]),v=b.findIndex((e=>e.isDefault)),[w,C]=c(-1!==v?b[v].tier:b?.[0]?.tier||1),[k,E]=c(p?.productDetails?.variants?.edges?.[0]?.node?.id||""),[T,S]=c({}),[B,$]=c(b.reduce(((e,t,n)=>(e[t.tier-1]=Array.from({length:t.minimumQuantity},(()=>p?.productDetails?.options?.map((e=>e.values[0]))||[])),e)),{})||{}),[z,D]=c(!1),[I,P]=c(window.innerWidth<550),[N,_]=c(null);o([]);const O=o([]);l((()=>{const e=()=>{P(window.innerWidth<550)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),l((()=>{const e=e=>{N&&O.current[N.index]&&O.current[N.index][N.optionIndex]&&!O.current[N.index][N.optionIndex]?.contains(e.target)&&_(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}}),[N]);const M=a((e=>{if(!g.general?.trackInventory)return null;const t=b.find((t=>t.tier===e));if(!t)return null;const n=t.minimumQuantity,r=p?.productDetails?.variants?.edges||[];for(const e of r){const t=e.node;if(t.inventoryQuantity>=n&&t.availableForSale){const e=t.title.split(" / ");return Array(n).fill(e)}}const o=[],a={},i=[...r].sort(((e,t)=>t.node.inventoryQuantity-e.node.inventoryQuantity));for(let e=0;e<n&&o.length<n;e++){let e=!1;for(const t of i){const n=t.node,r=a[n.id]||0;if(n.inventoryQuantity>r&&n.availableForSale){const t=n.title.split(" / ");o.push(t),a[n.id]=r+1,e=!0;break}}if(!e)return null}return o.length===n?o:null}),[p,b]),A=a((e=>{if(!g.general?.trackInventory)return!0;const t=b.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=p?.productDetails?.variants?.edges||[];let o=0;for(const e of r){const t=e.node;t.availableForSale&&(o+=Math.max(0,t.inventoryQuantity))}return o>=n}),[g.general?.trackInventory,b,p]);l((()=>{const e={},t=p?.productDetails?.variants?.edges?.[0]?.node?.id||"";t&&b.forEach((n=>{e[n.tier]={};for(let r=0;r<n.minimumQuantity;r++)e[n.tier][r]=t})),S(e)}),[p?.id,b?.map((e=>`${e.tier}-${e.minimumQuantity}`)).join("|")]),l((()=>{if(!f.current[w]){const e=M(w);if(e){const t=w-1;$((n=>({...n,[t]:e})));const n={};e.forEach(((e,t)=>{const r=e.join(" / "),o=p?.productDetails?.variants?.edges?.find((e=>e.node.title===r))?.node.id||k;n[t]=o})),S((e=>({...e,[w]:n})))}f.current[w]=!0}}),[w,p,k,M]);const F=(e,t)=>e?.productDetails?.variants?.edges?.find((e=>e.node.id===t))?.node,R=a(((e,t,n,r,o)=>{if(!g?.general?.trackInventory)return!0;const a=b.find((t=>t.tier===e));if(!a)return!1;const i=a.minimumQuantity,l=e-1,c=[...n];c[r]=o;const d=c.join(" / "),s=p?.productDetails?.variants?.edges?.find((e=>e.node.title===d))?.node;if(!s||!s.availableForSale||s.inventoryQuantity<=0)return!1;const u={};for(let e=0;e<i;e++){let n;if(e===t)n=s.id;else{const t=(B[l]?.[e]||p.productDetails.options.map((e=>e.values[0]))).join(" / "),r=p?.productDetails?.variants?.edges?.find((e=>e.node.title===t));if(!r)return!1;n=r.node.id}u[n]=(u[n]||0)+1}for(const[e,t]of Object.entries(u)){const n=F(p,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[g?.general?.trackInventory,b,p,B]),L=a((e=>{if(!g.general?.trackInventory)return!0;const t=b.find((t=>t.tier===e));if(!t)return!1;const n=t.minimumQuantity,r=e-1,o={};for(let e=0;e<n;e++){const t=(B[r]?.[e]||p.productDetails.options.map((e=>e.values[0]))).join(" / "),n=p?.productDetails?.variants?.edges?.find((e=>e.node.title===t));if(!n)return!1;const a=n.node.id;o[a]=(o[a]||0)+1}for(const[e,t]of Object.entries(o)){const n=F(p,e);if(n&&t>n.inventoryQuantity)return!1}return!0}),[g.general?.trackInventory,b,p,B]),j=(e,t,n)=>{S((r=>({...r,[e]:{...r[e]||{},[t]:n}})))},V=a((()=>!1===g.general?.trackInventory?p?.productDetails?.variants?.edges?.[0]?.node:p?.productDetails?.variants?.edges?.find((e=>e.node.inventoryQuantity>0))?.node||p?.productDetails?.variants?.edges?.[0]?.node),[p]),H=a((()=>new URLSearchParams(window.location.search).get("variant")||""),[]),W=()=>{const e=H();if(e){const t=p?.productDetails?.variants?.edges?.find((t=>String(t.node.id)==="gid://shopify/ProductVariant/"+String(e)));if(t&&t.node.inventoryQuantity>0)E(String(t.node.id));else{const e=V();e&&E(String(e.id))}}};l((()=>{W();const e=new Event("urlChange");let t=!0;const n=window.history.pushState,r=window.history.replaceState;return window.history.pushState=function(){t&&(n.apply(this,arguments),window.dispatchEvent(e))},window.history.replaceState=function(){t&&(r.apply(this,arguments),window.dispatchEvent(e))},window.addEventListener("urlChange",W),()=>{t=!1,window.removeEventListener("urlChange",W),window.history.pushState=n,window.history.replaceState=r}}),[H,p?.id,V]);const U=t=>{const n=b.find((e=>e.tier===t));if(!n)return{original:0,discounted:0};let r=0,o=0;const a=T[t]||{};for(let e=0;e<n.minimumQuantity;e++){const t=a[e]||k,n=F(p,t);n&&(n.compareAtPrice?r+=Number.parseFloat(n.compareAtPrice):r+=Number.parseFloat(n.price),o+=Number.parseFloat(n.price))}return"percentOff"===e?.discountType?o*=1-n.discountValue/100:"amountOff"===e?.discountType&&(o-=n.discountValue),o<0&&(o=0),{original:r,discounted:o,discountValue:n.discountValue}},G=(e,t,n,r)=>{let o=F(e,t);if(r){const a=T[r]?.[n||0]||t;o=F(e,a)}return o?.image?.url?o.image.url:e.productDetails?.media?.edges[0]?.node.image.url||""},Q=i((()=>b.find((e=>e.tier===w))),[b,w]),q=i((()=>Q?U(Q.tier):null),[Q,T,k]),Y=i((()=>{if(!Q||!q)return;const e=T[Q.tier]||{},t={};for(let n=0;n<Q.minimumQuantity;n++){const r=e[n]||k;t[r]=(t[r]||0)+1}return t}),[Q?.minimumQuantity,k,T,q]),Z=i((()=>Object.entries(Y??{}).map((([e,t])=>({variantId:e,quantity:t})))),[Y]);if(l((()=>{if(!Q||!q)return;const e={tier:w,items:Q.minimumQuantity,discountedPrice:q.discounted,originalPrice:q.original,variants:Z,productId:p?.id??null,tierMeta:{title:Q.title,subtitle:Q.subtitle,badgeTitle:Q.badgeTitle},productData:p,tierData:Q},t=m.current;return t&&JSON.stringify(t)===JSON.stringify(e)?void 0:(u.current&&clearTimeout(u.current),u.current=window.setTimeout((()=>{m.current=e;const t=new CustomEvent("ytBundleTierChange",{detail:e});window.dispatchEvent(t)}),50),()=>{u.current&&clearTimeout(u.current)})}),[w,Q?.tier,Q?.minimumQuantity,q?.discounted,q?.original,p?.id,JSON.stringify(Z)]),!n)return t.createElement(t.Fragment,null);const K=g.volumeBundle?.cardStyle,X=g.general?.primaryColor,J=g.general?.secondaryColor,ee=g.general.primaryContrastColor,te=g.general.secondaryContrastColor,ne="high"===e.cornerRadiusType?"20px":"medium"===e.cornerRadiusType?"6px":"0px",re="bundles"==e.appName?e.pageHeader?.title:e?.title,oe="bundles"==e.appName?e.pageHeader?.description:e?.subtitle;return t.createElement(om,{verticalMargin:g.volumeBundle?.verticalMargin,backgroundColor:g.volumeBundle?.sectionBackgroundColor,className:"yt-bundle-container"},t.createElement(am,{className:"yt-bundle-header"},re&&re.trim().length>0&&t.createElement(im,{fontSize:g.volumeBundle?.titleFontSize,backgroundColor:g.volumeBundle?.titleBackgroundColor,textColor:g.volumeBundle?.titleTextColor,className:"yt-bundle-header-title"},re),t.createElement(lm,{className:"yt-bundle-header-subtitle",fontSize:g.volumeBundle?.subtitleFontSize},oe)),"vertical"===K?t.createElement("div",{style:{display:"grid",gridTemplateColumns:I||4===b.length?"repeat(2, 1fr)":b.length>4?"repeat(3, 1fr)":`repeat(${b.length}, 1fr)`,justifyItems:"center",gap:I?"10px":"16px",paddingTop:"10px"},className:"yt-bundle-vertical-container"},b.map((n=>{const r=U(n.tier),o=r.original-r.discounted,a=w===n.tier,i=!A(n.tier);return t.createElement(t.Fragment,{key:n.tier},t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"8px",borderRadius:ne||"24px",...a?{border:`2px solid ${X}`}:{border:`1px solid ${J}`},boxShadow:`6px 6px 0px -1px ${a?X:J}20`,...n.badgeTitle&&{position:"relative"},zIndex:5,backgroundColor:i?"#f5f5f5":"white",cursor:i?"not-allowed":"pointer",position:"relative",height:"100%",maxHeight:"350px",width:"100%",opacity:i?.6:1},className:"yt-volume-vertical-tier-item "+(a?"yt-volume-vertical-tier-item-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),onClick:()=>!i&&C(n.tier)},n.badgeTitle&&t.createElement("div",{style:{position:"absolute",top:"-15px",zIndex:-1,left:"0",right:"0",width:"80%",textAlign:"center",margin:"0 auto",fontSize:"10px",clipPath:"polygon(2% 0%, 98% 0%, 100% 100%, 0% 100%)",backgroundColor:a?X:J,color:a?ee:te,padding:"2px 0",borderRadius:"12px 12px 0px 0px",lineHeight:"normal"},className:a?"yt-volume-vertical-tier-badge-active":"yt-volume-vertical-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",height:"fit-content"},className:"yt-volume-vertical-tier-save-badge-container"},0!==r.discountValue&&t.createElement(t.Fragment,null,I&&o&&!!r?.discountValue&&"Enabled"===g.volumeBundle?.discountBadgeVisibility&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"5px",top:"8px"}},t.createElement(um,{primaryBackgroundColorCta:a?X:J,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?ee:te},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Ig(g.general.currencySymbol,e.storeCurrencyCode)}${Dg(r.discountValue)}`))),n.imageUrl&&t.createElement("img",{src:n.imageUrl,style:{objectFit:"cover",aspectRatio:"1/1",width:"100%",maxHeight:"160px",maxWidth:"160px",height:"fit-content",borderTopLeftRadius:ne||"24px",borderTopRightRadius:ne||"24px"},className:"yt-volume-vertical-tier-badge"})),t.createElement("div",{style:{padding:"8px",paddingTop:"0"}},t.createElement(mm,{style:{display:"flex",width:"100%",gap:"4px"},className:"yt-volume-vertical-details-container"},t.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative",width:"100%"},className:"yt-volume-vertical-details-title-container"},t.createElement(fm,{style:{fontSize:I?"12px":"14px",lineHeight:"normal"},className:"yt-volume-vertical-details-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),!I&&o&&!!r?.discountValue&&"Enabled"===g.volumeBundle?.discountBadgeVisibility&&t.createElement(um,{primaryBackgroundColorCta:a?X:J,isSelected:a,style:{height:"fit-content",fontSize:"10px",lineHeight:"normal",color:a?ee:te},className:"yt-volume-vertical-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Ig(g.general.currencySymbol,e.storeCurrencyCode)}${Dg(r.discountValue)}`),a&&n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"0px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:X,color:ee,padding:"2px"}},t.createElement(Xr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))),t.createElement(gm,{style:{lineHeight:"normal",fontSize:I?"10px":"14px",color:"#666"},className:"yt-volume-vertical-details-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null))),t.createElement(hm,{style:{textAlign:"left",marginTop:"4px",display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center"},className:"yt-volume-vertical-details-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},t.createElement(xm,{style:{marginLeft:"0",lineHeight:"normal",marginRight:"8px"},className:"yt-volume-vertical-details-price-discount"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.discounted.toFixed(2))),o?t.createElement(ym,{style:{lineHeight:"normal"},className:"yt-volume-vertical-details-price-original"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.original.toFixed(2))):"")),a&&!n.imageUrl&&t.createElement("div",{style:{lineHeight:"normal",position:"absolute",right:"10px",bottom:"10px"},className:"yt-volume-vertical-tier-selected-check"},t.createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:X,color:ee,padding:"2px"}},t.createElement(Xr,{style:{paddingBottom:"1px"},size:20,fontWeight:20})))))}))):t.createElement(t.Fragment,null,b.map((n=>{const r=U(n.tier),o=r.original-r.discounted,a=!A(n.tier);return t.createElement(t.Fragment,{key:n.tier},n.badgeTitle&&t.createElement(cm,{primaryTextColorCta:ee,primaryBackgroundColorCta:X,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-badge","data-tier":n.tier,"data-badge-title":n.badgeTitle},n.badgeTitle),t.createElement(dm,{cornerRadiusType:e?.cornerRadiusType??"",key:n.tier,primaryBackgroundColorCta:X??"",isSelected:w===n.tier,onClick:()=>C(n.tier),style:{borderRadius:ne,cursor:"pointer",backgroundColor:a?"#f5f5f5":"white",opacity:a?.6:1},className:"yt-volume-horizontal-tier-container "+(w===n.tier?"yt-volume-horizontal-tier-container-active":""),"data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType,"data-minimum-quantity":n.minimumQuantity,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2)},t.createElement(sm,{cornerRadiusType:e?.cornerRadiusType??"",style:{borderRadius:ne,borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},className:"yt-volume-horizontal-tier-header"},t.createElement(pm,{className:"yt-volume-horizontal-tier-info"},t.createElement(km,{"data-active":w===n.tier,accentColor:X,className:"yt-volume-horizontal-tier-radio-wrapper"},t.createElement(Em,{name:"tier",checked:w===n.tier,onChange:()=>!a&&C(n.tier),disabled:a,className:"yt-volume-horizontal-tier-radio-hidden"}),t.createElement(Tm,{accentColor:X,className:"yt-volume-horizontal-tier-radio-custom"})),t.createElement(mm,{className:"yt-volume-horizontal-tier-details"},t.createElement("div",{style:{display:"flex"},className:"yt-volume-horizontal-tier-title-container"},t.createElement(fm,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-title"},n.title?n.title:t.createElement(t.Fragment,null,"Buy ",n.minimumQuantity,", Get"," ",n.discountValue,"% Off")),o&&r?.discountValue&&"Enabled"===g.volumeBundle?.discountBadgeVisibility?t.createElement(um,{primaryBackgroundColorCta:X,isSelected:w===n.tier,style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-save-badge","data-tier":n.tier,"data-discount-value":r.discountValue,"data-discount-type":e?.discountType}," ","percentOff"===e?.discountType?`${r.discountValue}% Off`:`Save ${Ig(g.general.currencySymbol,e.storeCurrencyCode)}${Dg(r.discountValue)}`):""),t.createElement(gm,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-subtitle"},n.subtitle?n.subtitle:t.createElement(t.Fragment,null)))),t.createElement(hm,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-price","data-tier":n.tier,"data-original-price":r.original.toFixed(2),"data-discounted-price":r.discounted.toFixed(2),"data-savings":o.toFixed(2)},o?t.createElement(ym,{style:{lineHeight:"normal"},className:"yt-volume-horizontal-tier-original-price"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.original.toFixed(2))):"",t.createElement(xm,{className:"yt-volume-horizontal-tier-discounted-price"},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(r.discounted.toFixed(2))))),w===n.tier&&y&&t.createElement(bm,{className:"yt-volume-horizontal-tier-product-grid"},Array.from({length:n.minimumQuantity}).map(((r,o)=>{const i=n.tier-1,l=(B[i]||[])[o]||p.productDetails.options?.map((e=>e.values[0]))||[];return t.createElement("div",{key:o,style:{display:"flex",gap:"10px",alignItems:"center",position:"relative"},className:"yt-volume-horizontal-tier-product-item"},t.createElement(Sm,{src:G(p,k,o,n.tier),alt:p?.productDetails?.title||"Product",className:"yt-volume-horizontal-tier-product-image"}),"auto"===g?.volumeBundle?.variantSelectorType?t.createElement("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"}},p?.productDetails?.options?.map(((r,c)=>{const d=N?.tier===n.tier&&N?.index===o&&N?.optionIndex===c,s=e?.variantOptions?.options?.find((e=>e.name===r.name));let u="";return s&&"color"===s?.type&&(u=s?.values?.find((e=>e.name===l[c]))?.value||""),t.createElement(Dm,{key:c,ref:e=>{O.current[o]||(O.current[o]=[]),O.current[o][c]=e},style:{zIndex:d?1e3:"auto",display:"flex"},isActive:d},t.createElement(Im,{onClick:e=>{e.stopPropagation(),_(d?null:{tier:n.tier,index:o,optionIndex:c})},isActive:d,disabled:a},"color"===s?.type&&u&&t.createElement("div",{className:"yt-fixedBundle-product-card_color-swatch",style:{display:"inline-block",width:20,height:20,borderRadius:"50%",backgroundColor:u||"transparent",border:"1px solid #ddd"}}),l[c],t.createElement(jr,null)),d&&t.createElement(Pm,{style:{zIndex:1001}},r.values.map((e=>{const r=[...l];r[c]=e;const d=!R(n.tier,o,l,c,e)||a,u=p.productDetails.variants.edges.find((({node:e})=>e.title===r.join(" / ")))?.node,m=e=>{if(console.log("clicked"),d)return void e.stopPropagation();$((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t}));const t=u?.id||k;j(n.tier,o,t),_(null)},f=s?.values.find((t=>t.name===e));return"image"===s?.type&&f?.value?t.createElement(Bm,{key:e,onClick:e=>{e.stopPropagation(),m(e)},style:{opacity:d?.5:1,cursor:d?"not-allowed":"pointer"}},t.createElement($m,{src:f.value,alt:e}),e,d&&" (Out of stock)"):"color"===s?.type&&f?.value?t.createElement(Bm,{key:e,onClick:m,style:{opacity:d?.5:1,cursor:d?"not-allowed":"pointer"}},t.createElement(zm,{style:{backgroundColor:f.value}}),e,d&&"Out of stock"):t.createElement(Bm,{key:e,onClick:m,style:{opacity:d?.5:1,cursor:d?"not-allowed":"pointer"}},e,d&&" (Out of stock)")}))))}))):t.createElement(vm,{style:{display:"flex",flexDirection:"column",gap:"5px"},className:"yt-volume-horizontal-tier-variant-selector"},p?.productDetails?.options.map(((r,c)=>{const d=e.variantOptions?.options?.find((e=>e.name===r.name))||null;return r.values.length<=1?null:t.createElement("div",{key:r.name,style:{width:"100%",display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"},className:"yt-volume-horizontal-tier-variant-option"},t.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"},className:"yt-volume-horizontal-tier-variant-values"},r.values.map((e=>{const r=l[c]===e,s=!R(n.tier,o,l,c,e)||a,u=d?.values.find((t=>t.name===e)),m=t=>{if(t.preventDefault(),s)return;const r=[...l];r[c]=e,$((e=>{const t={...e},n=[...t[i]||[]];return n[o]=r,t[i]=n,t}));const a=r.join(" / "),d=p.productDetails.variants.edges.find((e=>e.node.title===a))?.node.id||k;j(n.tier,o,d)},f={opacity:s?.5:1,cursor:s?"not-allowed":"pointer"};return d&&u?"color"===d.type&&u.value?t.createElement("button",{key:e,onClick:m,style:{...f,borderRadius:"50%",padding:"1px",backgroundColor:"white",border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid transparent",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-color-button",disabled:s},t.createElement("div",{style:{width:r?"24px":"20px",height:r?"24px":"20px",borderRadius:"50%",backgroundColor:u.value,lineHeight:"normal",boxShadow:"rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 2px"}},t.createElement("span",null))):"image"===d.type?t.createElement("button",{key:e,onClick:m,style:{...f,border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:r?"#F7F7F7":"transparent",padding:"0px",width:r?"20px":"18px",height:r?"20px":"18px",overflow:"hidden"},className:"yt-volume-horizontal-tier-variant-image-button",disabled:s},t.createElement("img",{src:u.value,alt:e,style:{width:r?"26px":"24px",height:r?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}})):t.createElement(wm,{key:e,isSelected:r,onClick:m,style:{...f,padding:"4px 8px",border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:r?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button-default",disabled:s},e):t.createElement(wm,{key:e,isSelected:r,onClick:m,disabled:s,style:{...f,padding:"4px 8px",border:r?`1px solid ${g.general?.ctaBackgroundColor||"#121212"}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:r?"#F7F7F7":"transparent",color:"#707070",cursor:"pointer",fontSize:"12px",fontWeight:"600",lineHeight:"normal"},className:"yt-volume-horizontal-tier-variant-button"},e)}))))}))))})))))}))),e?.showCta&&t.createElement("div",{style:{position:"relative"}},t.createElement(Cm,{bgColor:L(w)?g.general?.ctaBackgroundColor:"#ccc",textColor:L(w)?g.general?.ctaTextColor:"#666",border:`1px solid ${L(w)?g.general?.ctaBorderColor||"#121212":"#999"}`,shadow:g.general.ctaShadowType,padding:g.general?.ctaPadding,width:g.general?.ctaWidth,hoverProperties:{customizeHoverState:!!L(w)&&g.general?.customizeHoverState,backgroundColor:g.general?.ctaHoverBackgroundColor,textColor:g.general?.ctaHoverTextColor},onClick:async()=>{if(L(w))try{D(!0);const e=b.find((e=>e.tier===w));if(!e)return;const t={},r=T[e.tier]||{};for(let n=0;n<e.minimumQuantity;n++){const e=r[n]||k;t[e]?t[e].quantity+=1:t[e]={quantity:1}}const o=U(e.tier),a=Array.from({length:e.minimumQuantity},((e,t)=>r[t]||k));n&&await n(o.original,a)}catch(e){console.error("VolumeBundle handleAddToCart error:",e)}finally{D(!1)}else console.error("Selected tier is out of stock")},borderRadius:g.general.ctaBorderRadius??"",disabled:z||!L(w),className:"yt-volume-add-to-cart-button"},L(w)?t.createElement(t.Fragment,null,z?t.createElement(Wo,{color:"white",loading:z,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):t.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"8px",justifyContent:"center",alignItems:"center"}},t.createElement("span",null,g.volumeBundle?.ctaTitle??"Add Bundle to Cart")," ","•",t.createElement("div",{className:"yt-volume-add-to-cart-button-info"},(()=>{const n=U(w);return t.createElement(t.Fragment,null,Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(n.discounted.toFixed(2))," ",n?.original&&t.createElement("span",{style:{lineHeight:"normal",textDecoration:"line-through",fontWeight:"550"}},Ig(g.general.currencySymbol,e.storeCurrencyCode),Dg(n?.original.toFixed(2))," "))})()))):t.createElement(t.Fragment,null,"Out of Stock"))))}const Om=x.div`
|
|
3213
3213
|
container-type: inline-size;
|
|
3214
3214
|
border-radius: ${e=>e.borderRadius?e.borderRadius:"8px"};
|
|
3215
3215
|
max-width: 800px;
|