yt-uikit 0.8.34 → 0.8.35

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.
Files changed (26) hide show
  1. package/dist/esm/components/BundleBlock/Bundle.js +1 -1
  2. package/dist/esm/components/BundleBlock/BundleBuilder/BundleBuilder.js +1 -1
  3. package/dist/esm/components/BundleBlock/BundleBuilderTracker/BundleBuilderTracker.js +1 -1
  4. package/dist/esm/components/BundleBlock/BundleProductDetailsModal/BundleProductDetailsModal.js +1 -1
  5. package/dist/esm/components/BundleBlock/ComboBundle.js +1 -1
  6. package/dist/esm/components/BundleBlock/Loader.js +1 -1
  7. package/dist/esm/components/BundleBlock/bundle.scss.js +1 -0
  8. package/dist/esm/components/BundleBlock/loader.scss.js +1 -0
  9. package/dist/esm/components/Cart/CartDrawer.js +2 -2
  10. package/dist/esm/components/Cart/CheckoutSection.js +1 -1
  11. package/dist/esm/components/Cart/DatePicker.css.js +1 -0
  12. package/dist/esm/components/Cart/DatePicker.js +2 -2
  13. package/dist/esm/components/Cart/LoyaltyAppliedCTA.js +1 -1
  14. package/dist/esm/components/Cart/MultiStepProgressBar/MultiStepProgressBar.js +1 -1
  15. package/dist/esm/components/Cart/MultiStepProgressBar/multiStepProgressBar.scss.js +1 -0
  16. package/dist/esm/components/Cart/NoteSection.js +1 -1
  17. package/dist/esm/components/Cart/NoteSectionStyles.scss.js +1 -0
  18. package/dist/esm/components/Cart/QuantitySelector.js +1 -1
  19. package/dist/esm/components/Cart/RegionSpecificDelivery.js +1 -1
  20. package/dist/esm/components/Cart/StandardDelivery.js +1 -1
  21. package/dist/esm/components/Cart/StandardDelivery.scss.js +1 -0
  22. package/dist/esm/components/Cart/shared.scss.js +1 -0
  23. package/dist/esm/components/Nudge/LeadGenerationNudge.js +2 -2
  24. package/dist/esm/components/Nudge/Nudge.scss.js +1 -0
  25. package/dist/esm/node_modules/style-inject/dist/style-inject.es.js +1 -0
  26. package/package.json +5 -2
@@ -1 +1 @@
1
- import e from"react";import t from"./BundleBuilder/BundleBuilder.js";import n from"./ComboBundle.js";import d from"./VolumeBundle/VolumeBundle.js";import r from"./MixAndMatchBundle/MixAndMatchBundle.js";import o from"currency-symbol-map";import a from"./FixedBundle/FixedBundle.js";import i from"./CollectionBundle/ColllectionBundle.js";const l=window?.Shopify?.currency||{rate:1,active:"INR"},u=e=>{if(!e)return;const t=navigator.language||"en-US",n=Number((Number(e)*l.rate).toFixed(2));return new Intl.NumberFormat(t).format(n)},c=(e,t)=>t==l.active?e:o(l.active)||l.active,m=(e,t)=>{if(!e||!e.includes("cdn.shopify")&&!e.includes("/cdn/shop/files/"))return e;try{const n=new URL(e),d=n.searchParams;return d.has("format")||d.set("format","webp"),d.has("quality")||d.set("quality",t?.toString()||"70"),d.has("width")||d.set("width","600"),n.toString()}catch{const n=e.includes("?")?"&":"?";return e+n+`format=webp&quality=70&width=${t?.toString()||"600"}`}},s=(e,t,n,d,r,o)=>{const a=d.findIndex(t=>t.variantId===e);r(0===n?e=>e.filter((e,t)=>t!==a):-1===a?d=>[...d,{product:t,variantId:e,quantity:n,isFree:o}]:e=>e.map((e,t)=>t===a?{...e,quantity:e.quantity+n,isFree:o}:e))},p=({bundle:o,currentProductId:l,addToCartFunction:u,addCustomBundleToCart:c,selectedItems:m,setSelectedItems:s,bundleAddToCartLoading:p,handleRemoveItem:b,selectedItemsQuantity:f,renderingOnPage:y,bundleSubtotal:h})=>"fixed"!==o.type&&o.type&&0!==o?.type?.length?"builder"===o.type?e.createElement(t,{bundleAddToCartLoading:p,bundle:o,selectedItems:m,setSelectedItems:s,handleAddToCart:c,handleRemoveItem:b,renderingOnPage:y,selectedItemsQuantity:f??0,bundleSubtotal:h??{price:0,compareAtPrice:0}}):"combo"===o.type?e.createElement(n,{bundle:o,addToCartFunction:u}):"mixAndMatch"===o.type?e.createElement(r,{bundle:o,addToCartFunction:u}):"collection"===o.type?e.createElement(i,{config:o,addCustomBundleToCart:c,bundleAddToCartLoading:p}):e.createElement(d,{bundle:o,currentProductId:l,addToCartFunction:u}):e.createElement(a,{addToCartFunction:u,bundle:o});export{u as currencyPrice,p as default,c as getCurrencySymbol,s as handleAddToBundle,m as optimiseImage};
1
+ import e from"react";import"./bundle.scss.js";import t from"./BundleBuilder/BundleBuilder.js";import n from"./ComboBundle.js";import d from"./VolumeBundle/VolumeBundle.js";import r from"./MixAndMatchBundle/MixAndMatchBundle.js";import o from"currency-symbol-map";import a from"./FixedBundle/FixedBundle.js";import i from"./CollectionBundle/ColllectionBundle.js";const l=window?.Shopify?.currency||{rate:1,active:"INR"},u=e=>{if(!e)return;const t=navigator.language||"en-US",n=Number((Number(e)*l.rate).toFixed(2));return new Intl.NumberFormat(t).format(n)},c=(e,t)=>t==l.active?e:o(l.active)||l.active,m=(e,t)=>{if(!e||!e.includes("cdn.shopify")&&!e.includes("/cdn/shop/files/"))return e;try{const n=new URL(e),d=n.searchParams;return d.has("format")||d.set("format","webp"),d.has("quality")||d.set("quality",t?.toString()||"70"),d.has("width")||d.set("width","600"),n.toString()}catch{const n=e.includes("?")?"&":"?";return e+n+`format=webp&quality=70&width=${t?.toString()||"600"}`}},s=(e,t,n,d,r,o)=>{const a=d.findIndex(t=>t.variantId===e);r(0===n?e=>e.filter((e,t)=>t!==a):-1===a?d=>[...d,{product:t,variantId:e,quantity:n,isFree:o}]:e=>e.map((e,t)=>t===a?{...e,quantity:e.quantity+n,isFree:o}:e))},p=({bundle:o,currentProductId:l,addToCartFunction:u,addCustomBundleToCart:c,selectedItems:m,setSelectedItems:s,bundleAddToCartLoading:p,handleRemoveItem:b,selectedItemsQuantity:f,renderingOnPage:y,bundleSubtotal:h})=>"fixed"!==o.type&&o.type&&0!==o?.type?.length?"builder"===o.type?e.createElement(t,{bundleAddToCartLoading:p,bundle:o,selectedItems:m,setSelectedItems:s,handleAddToCart:c,handleRemoveItem:b,renderingOnPage:y,selectedItemsQuantity:f??0,bundleSubtotal:h??{price:0,compareAtPrice:0}}):"combo"===o.type?e.createElement(n,{bundle:o,addToCartFunction:u}):"mixAndMatch"===o.type?e.createElement(r,{bundle:o,addToCartFunction:u}):"collection"===o.type?e.createElement(i,{config:o,addCustomBundleToCart:c,bundleAddToCartLoading:p}):e.createElement(d,{bundle:o,currentProductId:l,addToCartFunction:u}):e.createElement(a,{addToCartFunction:u,bundle:o});export{u as currencyPrice,p as default,c as getCurrencySymbol,s as handleAddToBundle,m as optimiseImage};
@@ -1 +1 @@
1
- import e,{useState as t,useRef as r,useEffect as o,useCallback as n,useMemo as i}from"react";import{BiTrash as a,BiSearch as l}from"react-icons/bi";import{useAtom as s,useSetAtom as c}from"jotai";import{IoChevronDownOutline as d}from"react-icons/io5";import{IoIosStar as u}from"react-icons/io";import{MdVerified as p}from"react-icons/md";import{ProductContainer as m,ImageWrapper as y,VariantSelector as g,ProductTitle as b,AddToBundleWrapper as f,AddToBundleButton as h,QuantitySelectorContainer as x,AddedButtonText as v,RemoveButton as C,Container as w,Quantity as E}from"./bundleBuilder.style.js";import{optimiseImage as T,getCurrencySymbol as I,currencyPrice as S,handleAddToBundle as k}from"../Bundle.js";import{BundleBuilderTrackerBar as N}from"../BundleBuilderTracker/BundleBuilderTracker.js";import{bundleBuilderProductDetailsState as A}from"../../../atoms/bundleBuilderProductDetailsAtom.js";import B from"../BundleProductDetailsModal/BundleProductDetailsModal.js";import P from"./VariantOptionsModal.js";import{ResponsiveBackgroundImage as z}from"./ResponsiveBgImage.js";function R({quantity:t,setQuantity:r,remainingQuantity:o,handleAddToBundle:n,variantId:i,product:a,handleRemoveItem:l,hideAddToBundle:s,selectedVariantInventoryQty:c}){const d={display:"flex",alignItems:"center",justifyContent:"center",width:"33%",cursor:"pointer",backgroundColor:"#f2f2f2",userSelect:"none",border:"none",padding:"8px",margin:"0",fontSize:"20px",color:"#333",textDecoration:"none",boxShadow:"none",outline:"none",borderRadius:"0",boxSizing:"border-box"},u=t<c;return e.createElement(w,{className:"yt-byob-quantity-selector-container"},e.createElement("button",{className:"yt-byob-quantity-minus-button",onClick:e=>{e.stopPropagation();const o=Math.max(0,t-1);r(o),l&&i&&l(i,1)},style:d},"-"),e.createElement(E,{className:"yt-byob-quantity-display"},t," added"),e.createElement("button",{className:"yt-byob-quantity-plus-button",onClick:e=>{e.stopPropagation();const l=Math.min(o,t+1,c);r(l),n&&i&&a&&n(i,a,1)},disabled:!u||s,style:{...d,cursor:!u||s?"not-allowed":"pointer",opacity:!u||s?.6:1}},"+"))}const D=({product:r,styles:n,selectedVariant:a})=>{const[l,s]=t(!1),c=i(()=>T(a?.image?.url||r?.featuredMedia?.preview?.image?.url||r?.media?.edges?.[0]?.node?.image?.url)||"",[a?.image?.url,r?.featuredMedia?.preview?.image?.url,r?.media?.edges]),d=i(()=>r?.media?.edges?.map(e=>T(e?.node?.preview?.image?.url??e?.node?.image?.url)).filter(Boolean)??[],[r?.media?.edges]),u=i(()=>d?.[1]??c??"",[d,c]);o(()=>{if(c){(new Image).src=c}},[c]);const p=i(()=>c||d?.[0],[c,d]);return e.createElement("div",{className:"yt-byob-image-hover-container",style:{position:"relative",width:"100%",overflow:"hidden",aspectRatio:n.general.imageAspectRatio||"1/1"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)},e.createElement("div",{className:"yt-byob-image-inner-container",style:{width:"100%",height:"100%",position:"relative"}},e.createElement("img",{className:"yt-byob-image-main",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",objectPosition:"top",opacity:l&&p!==u?0:1,transition:d?.length>0?"opacity 300ms ease, transform 300ms ease":"",transform:l?"scale(1.1)":"scale(1)"},src:p,alt:r.title}),p!==u&&e.createElement("img",{className:"yt-byob-image-hover",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",opacity:l?1:0,transition:"opacity 400ms ease, transform 400ms ease",transform:l?"scale(1.1)":"scale(1)",position:"absolute",top:0,left:0,objectPosition:"top"},src:u,alt:r.title})))},Q=({product:r,bundle:i,handleAddToBundle:l,hideAddToBundle:s,remainingQuantity:w,themeColor:E,handleRemoveItem:T,transitionActive:k,idx:N,selecteditems:B,customVariantsQuantity:z,currentProductTier:Q,showFreebieTierProductPrices:F})=>{const j=c(A),O=i.customizations,W=O?.byob?.variantSelectorType,[L,V]=t(!1),M=O.general?.variantTitleSuffix?r?.variants?.edges:(e=>{if(!e||e.length<2)return e;const t=e.map(e=>e.node.title).map(e=>e.split(" "));let r=[...t[0]];for(let e=1;e<t.length;e++){const o=t[e];let n=0;for(;n<r.length&&n<o.length&&r[r.length-1-n]===o[o.length-1-n];)n++;r=r.slice(r.length-n)}return r.length<1?e:e.map(e=>{const t=e.node.title.split(" "),o=t.slice(0,t.length-r.length).join(" ");return{...e,node:{...e.node,title:o,commonSuffix:r.join(" ")}}})})(r?.variants?.edges);if(!M||!M.length)return e.createElement(e.Fragment,null);const q=n(e=>{const t=z?.find(t=>t.variantId===e)?.quantity;if(void 0!==t)return t;if(i?.customProductsQuantity)return i?.customProductsQuantity;const o=M?.find(t=>t.node.id===e),n=o?.node;return n?r.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[M,z,r.tracksInventory]),H=M?.find(e=>q(e.node.id)>0)?.node?.id;if(!H&&!O.general.showOutOfStockProducts)return e.createElement(e.Fragment,null);const[U,$]=t(M?.find(e=>q(e.node.id)>0)?.node?.id||M[0]?.node?.id),[_,J]=t(0),[X,Z]=t(window.innerWidth<450),[G,K]=t("normal"),Y=M?.find(e=>e?.node?.id===U)?.node,ee=q(U||"");o(()=>{const e=B.find(e=>e.variantId===U);J(e?e.quantity:0)},[_,B,U]),o(()=>{const e=()=>{Z(window.innerWidth<450)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),o(()=>{CSS.supports("font-weight","500")?K("500"):CSS.supports("font-weight","400")?K("400"):CSS.supports("font-weight","600")&&K("600")},[]),o(()=>{document.documentElement.style.setProperty("--yt-bundle-font-weight",G)},[G]),o(()=>{if(U&&!M?.some(e=>e.node.id===U)){const e=M.find(e=>q(e.node.id)>0)?.node.id||M[0]?.node?.id;e&&$(e)}},[U,M,q]);const te=r.variants&&r.variants.edges?.length>1&&"customOptions"!==W,re="undefined"!=typeof window?(window?.ytapp||window?.ytBundleApp)?.storeId:void 0,oe="53933408435"===re,ne="75851235630"===re,ie=(e=>{if(e.metafield&&"yourtoken_bundles_app"===e.metafield.namespace&&"categories"===e.metafield.key){if(e.metafield.jsonValue&&Array.isArray(e.metafield.jsonValue))return e.metafield.jsonValue;if(e.metafield.value)try{const t=JSON.parse(e.metafield.value);if(Array.isArray(t))return t}catch(e){console.error("Failed to parse categories:",e)}}return[]})(r),ae=ie.length>0;return e.createElement(e.Fragment,null,e.createElement(m,{borderRadius:O?.byob.borderRadius,borderColor:O?.byob.borderColor,shadowType:O?.byob.shadowType,backgroundColor:O?.byob.cardBackgroundColor,className:"yt-byob-product-container bundle-builder-product-container "+(k?"yt-product-card-transition-active":N%2==0?"yt-product-card-transition":"yt-product-card-transition-up"),onClick:()=>{if(ee<=0)return;const e={...r,variants:{...r.variants,edges:M},selectedVariant:Y};j(e)},onMouseEnter:e=>{e.currentTarget.style.transform="scale(1.01)"},onMouseLeave:e=>{e.currentTarget.style.transform="scale(1)"},style:{WebkitTapHighlightColor:"transparent"}},e.createElement(y,{className:"yt-byob-image-wrapper"},e.createElement(D,{product:r,styles:O,selectedVariant:Y}),i?.productCardBadgeText&&e.createElement("div",{className:"yt-byob-product-badge",style:{position:"absolute",top:"0px",left:"0px",backgroundColor:O?.general.primaryColor||"#111",color:O?.general.primaryContrastColor||"#fff",zIndex:1,margin:"0px",whiteSpace:"pre",padding:"4px 8px",fontSize:"12px",borderTopLeftRadius:O.byob.borderRadius}},i.productCardBadgeText),te&&e.createElement("div",{className:"yt-byob-variant-selector-wrapper",style:{position:"relative",width:"100%"}},e.createElement(g,{className:"yt-byob-variant-selector",isCoralHaze:oe,onClick:e=>{e.preventDefault(),e.stopPropagation()},value:U||"",onChange:e=>{e.stopPropagation(),e.preventDefault(),$(e.target.value)}},M?.map(t=>{const r=window.innerWidth<=320?10:window.innerWidth<=420?15:22,o=t.node.title.length>r?t.node.title.substring(0,r)+"...":t.node.title;return e.createElement("option",{key:t.node.id,value:t.node.id},o)})),e.createElement("div",{className:"yt-byob-variant-chevron",style:{position:"absolute",right:"16px",bottom:"10px",pointerEvents:"none"}},e.createElement(d,null)))),e.createElement("div",{className:"yt-byob-product-content"},"enabled"===i?.customizations?.byob?.productCardCategoryVisibility&&ae&&e.createElement("div",{className:"yt-byob-product-categories-wrapper",style:{padding:"2px 4px"}},e.createElement("div",{className:"yt-byob-product-categories",style:{display:"flex",flexWrap:"wrap",gap:"4px"}},ie.slice(0,2).map((t,r)=>e.createElement("span",{className:"yt-byob-category-tag",key:r,style:{fontSize:X?"8px":"12px",color:"#666",fontWeight:"500"}},t.charAt(0).toUpperCase()+t.slice(1))),ie.length>2&&e.createElement("span",{className:"yt-byob-more-categories",style:{fontSize:"10px",padding:"2px 6px",backgroundColor:"rgba(0, 0, 0, 0.05)",borderRadius:"8px",color:"#666",fontWeight:"500"}},"+",ie.length-2," more"))),e.createElement(b,{isMobile:X,showBorder:i?.showBorder??!0,style:{...!O?.byob.productsPriceVisibility&&{padding:"8px"},...O?.byob.productTitleFontSize&&{fontSize:O?.byob.productTitleFontSize}},className:"yt-byob-product-title-wrapper"},e.createElement("div",{style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:"normal"},className:"yt-byob-product-title"},ne?String(Y?.displayName).replace("- Default Title",""):r.title,Y?.commonSuffix?" -"+Y?.commonSuffix:""))),"ratingOnly"===i?.reviewRatingType&&(r?.rating?.averageRating??0)>0&&e.createElement("div",{className:"yt-byob-product-ratings",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},e.createElement(u,{color:"gold",size:14})," ",e.createElement("span",{style:{marginLeft:6}},r?.rating?.averageRating," rating")),"ratingAndReviewCount"===i?.reviewRatingType&&(r?.rating?.averageRating??0)>0&&e.createElement("div",{className:"yt-byob-product-ratings-count",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},e.createElement(u,{color:"gold",size:14})," ",r?.rating?.averageRating,e.createElement(p,{className:"yt-byob-verified-icon",size:14,style:{color:"dodgerblue",marginLeft:"4px"}})," ","(",r?.rating?.ratingCount," reviews)"),O?.byob.productsPriceVisibility&&e.createElement("div",{className:"yt-byob-product-price yt-bundle-builder-product-price",style:{marginBottom:"5px",padding:i?.showBorder?"0px 10px":"0 4px"}},Q?.isFreebieTier&&!F?e.createElement(e.Fragment,null,e.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"14px",textDecoration:"line-through",color:"#888",marginRight:"6px"}},I(O.general.currencySymbol,i?.storeCurrencyCode)??"Rs.",S(Y?.price)),e.createElement("span",{className:"yt-byob-current-price",style:{color:O.general.primaryColor||"#d32f2f",fontWeight:"bold"}},"FREE")):parseFloat(Y?.price??"0")>0?e.createElement("span",{className:"yt-byob-current-price"},I(O.general.currencySymbol,i?.storeCurrencyCode)??"Rs.",S(Y?.price)):e.createElement("span",{className:"yt-byob-free-price"},"Free"),(!Q?.isFreebieTier||F)&&Y?.compareAtPrice&&O?.byob.compareAtPriceVisibility&&parseFloat(Y.compareAtPrice)>parseFloat(Y?.price)&&e.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"14px"}},I(O.general.currencySymbol,i?.storeCurrencyCode)??"Rs.",S(Y.compareAtPrice))),(ee>0||ee===1/0)&&e.createElement(f,{borderRadius:O?.byob.borderRadius,className:"yt-byob-add-to-bundle-wrapper yt-product-atc-wrapper"},(0===_||void 0===_)&&e.createElement(h,{style:{...!s&&{backgroundColor:O?.general.primaryColor||"#111",color:O?.general.primaryContrastColor||"#fff"}},disabled:s,onClick:e=>{e.stopPropagation(),e.preventDefault(),J(1),(()=>{if(!U)return;"customOptions"===W&&M.length>1?V(!0):l(U,r,1)})()},className:"yt-byob-add-to-bundle-button yt-product-atc-button"},O?.byob.addToBundleCTAText),!i?.disableQuantitySelector&&_>0&&U&&e.createElement(x,{className:"yt-byob-quantity-selector-container visible",style:{overflow:"hidden"}},e.createElement(R,{remainingQuantity:w,setQuantity:J,quantity:_,handleAddToBundle:l,variantId:U,product:r,handleRemoveItem:T,hideAddToBundle:s,selectedVariantInventoryQty:ee})),i?.disableQuantitySelector&&_>0&&U&&e.createElement(h,{style:{backgroundColor:"#747474",color:O?.general.primaryContrastColor||"#fff",display:"flex",justifyContent:"space-between",overflow:"hidden",height:"40px"},className:"yt-byob-added-button yt-product-atc-single-qty-selector"},e.createElement(v,{className:"yt-byob-added-text yt-product-atc-single-qty-selector-added"},"ADDED"),e.createElement(C,{className:"yt-byob-single-qty-remove yt-product-atc-single-qty-selector-remove",onClick:e=>{e.stopPropagation();const t=Math.max(0,_-1);J(t),T&&U&&T(U,1)}},e.createElement(a,{style:{color:"#fff",fontSize:"20px"}})))),ee<=0&&ee!==1/0&&e.createElement(h,{style:{backgroundColor:O.general.disabledButtonColor,color:"#fff",cursor:"not-allowed",transition:"transform 0.2s ease-in-out"},className:"yt-product-atc-disabled"},O?.general.outOfStockLabel||"Out of Stock")),"customOptions"===W&&L&&M.length>1&&e.createElement(P,{product:r,isOpen:L,onClose:()=>V(!1),variantOptions:i.variantOptions,cta:{textColor:O.general.ctaTextColor,backgroundColor:O.general.primaryColor},onConfirm:e=>{$(e),l(e,r,1)}}))},F=({currentStep:t,setCurrentProductTier:r,totalSteps:o,tiers:n,isMobile:i,selectedProductsByTier:a,primaryColor:l="#000",primaryTextColorCta:s="#fff",tierNavigation:c})=>e.createElement("div",{className:"yt-byob-stepper-container",style:{textAlign:"center",fontSize:"20px"}},e.createElement("div",{className:"yt-byob-stepper-steps",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center"}},Array.from({length:o}).map((s,d)=>{const u=d+1,p=n[d].minimumQuantity-(a[d]?.length??0)===0,m=d===t;return l="black"===l?"#000000":l,e.createElement(e.Fragment,{key:u},e.createElement("div",{className:"yt-byob-stepper-step-wrapper",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",gap:i?"4px":"8px"},onClick:()=>!1===c?()=>{}:r(u-1)},e.createElement("div",{className:"yt-byob-stepper-step-number",style:{fontSize:"14px"}},"Step ",u),e.createElement("div",{className:"yt-byob-stepper-step-bar",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center",cursor:"pointer"}},e.createElement("div",{className:"yt-byob-stepper-step-left-bar",style:{height:"3px",width:i?"30px":"50px",backgroundColor:p?l:m?"#666666":"#CBD5E0",display:"block",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px"}}),e.createElement("div",{className:"yt-byob-stepper-step-circle",style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:p?`${l}50`:"white",border:`2px solid ${p?l:m?"#666666":"#CBD5E0"}`,display:"flex",alignItems:"center",justifyContent:"center"}}),e.createElement("div",{className:"yt-byob-stepper-step-right-bar",style:{height:"3px",width:i?"30px":"50px",backgroundColor:p?l:m?"#666666":"#CBD5E0",display:"block",marginRight:d<o?i?"4px":"6px":"",borderTopRightRadius:"5px",borderBottomRightRadius:"5px"}}))))})),e.createElement("div",{className:"yt-byob-stepper-title",style:{margin:i?"16px 0px":"15px 0px",fontSize:i?"16px":"18px",padding:"4px",background:"rgba(0, 0, 0, 0.03)",borderBottom:"1px solid rgba(130, 130, 130, 0.28)"}},n[t]?.title)),j=({isMobile:r,setSearchTerm:n,searchTerm:i,styles:a,setSortBy:s})=>{const[c,d]=t(!1),[u,p]=t(i);return o(()=>{const e=setTimeout(()=>{n(u)},300);return()=>clearTimeout(e)},[u,n]),e.createElement("div",{className:"yt-byob-sort-filter-container",style:{display:"flex",flexDirection:r?"column":"row",justifyContent:"space-between",alignItems:r?"flex-end":"center",textAlign:"center",marginBottom:"20px",width:"97%",gap:r?"10px":"0"}},e.createElement("div",{className:"yt-byob-sort-filter-inner",style:{display:"flex",flexDirection:c&&r?"column":r?"row-reverse":"row",justifyContent:"space-between",alignItems:c?"":"center",gap:"12px",width:"100%"}},e.createElement("div",{className:"yt-byob-search-wrapper",style:{position:"relative",display:"flex",alignItems:"center",width:r?c?"100%":"auto":"400px",transition:"width 0.3s ease-in-out"}},r&&!c?e.createElement(l,{className:"yt-byob-search-icon",fontSize:"20px",color:"#555",style:{cursor:"pointer",lineHeight:"normal"},onClick:()=>d(!0)}):e.createElement(e.Fragment,null,e.createElement("input",{className:"yt-byob-search-input",style:{width:"100%",padding:r?"10px 12px":"10px 14px",fontSize:"14px",outline:"none",color:"#333",border:"1px solid #c7c7c7",borderRadius:a?.byob.borderRadius,boxShadow:a?.byob.borderColor?"0 2px 4px rgba(0, 0, 0, 0.1)":"none",textAlign:"start"},placeholder:"Search by Product Name",value:u,onChange:e=>p(e.target.value)}),!c&&e.createElement("span",{className:"yt-byob-search-icon-input",style:{position:"absolute",right:"12px",color:"#aaa",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",paddingLeft:"5px"}},e.createElement(l,{fontSize:"18px",style:{lineHeight:"normal"}}))),r&&c&&e.createElement("span",{className:"yt-byob-search-close-icon",style:{position:"absolute",right:"12px",color:"#aaa",fontSize:"16px",cursor:"pointer"},onClick:()=>d(!1)},"✖")),e.createElement("div",{className:"yt-byob-filter-wrapper",style:{display:"flex",alignItems:"center",textAlign:"center",border:window.innerWidth>600?"1px solid #d1d5db":"",padding:"8px 12px",fontSize:"14px",cursor:"pointer",borderRadius:a?.byob.borderRadius,boxShadow:a?.byob.borderColor?window.innerWidth>600?"0 2px 4px rgba(0, 0, 0, 0.1)":" ":"none"}},e.createElement("span",{className:"yt-byob-filter-label",style:{fontSize:"14px",color:"#555",marginRight:"6px"}},"Sort:"),e.createElement("select",{className:"yt-byob-filter-select",style:{flex:1,border:"none",height:"auto",padding:"0px",marginBottom:"0px",background:"transparent",fontSize:"14px",color:"#333",fontWeight:"500",width:r?"120px":"",outline:"none",cursor:"pointer",textAlign:"start"},onChange:e=>s(e.target.value)},e.createElement("option",{value:"best-selling"},"Featured"),e.createElement("option",{value:"title-asc"},"Product Title (A-Z)"),e.createElement("option",{value:"title-desc"},"Product Title (Z-A)"),e.createElement("option",{value:"price-low-to-high"},"Price (Low to High)"),e.createElement("option",{value:"price-high-to-low"},"Price (High to Low)")))))},O=({styles:t,isMobile:r,categories:o,activeCategory:n,onCategoryChange:i})=>{const a=e=>{i(e)},l=(e,t)=>{const r=e.replace("#","");return`rgba(${parseInt(r.substring(0,2),16)}, ${parseInt(r.substring(2,4),16)}, ${parseInt(r.substring(4,6),16)}, ${t})`};return"tabs"===t?.byob?.categoryFilterOnPage?e.createElement("div",{className:"yt-byob-category-filter-wrapper",style:{overflowX:r?"auto":"visible",scrollbarWidth:"none",msOverflowStyle:"none",marginBottom:"20px",width:"100%"}},e.createElement("div",{className:"yt-byob-category-tabs-container",style:{display:"flex",gap:"0px",minWidth:"max-content",paddingBottom:"1px",flexWrap:"nowrap",justifyContent:"center",borderBottom:"1px solid #e0e0e0",width:"auto",height:r?"28px":"45px"}},["All",...o].map(o=>{const i=n===o;return e.createElement("button",{key:o,onClick:()=>a(o),className:"yt-byob-category-tab-button",style:{background:"none",border:"none",padding:r?"12px 16px":"12px 20px",fontSize:r?"14px":"16px",fontWeight:i?"600":"400",color:i?t.general.primaryColor:"#666",cursor:"pointer",position:"relative",transition:"all 0.3s ease",backgroundColor:i?l(t.general.primaryColor,.07):"transparent",borderBottom:i?`2px solid ${t?.general.primaryColor}`:"2px solid transparent",marginBottom:"-1px",whiteSpace:"nowrap",minWidth:"fit-content"},onMouseEnter:e=>{i||(e.currentTarget.style.color=t?.general.primaryColor)},onMouseLeave:e=>{i||(e.currentTarget.style.color="#666")}},e.createElement("span",{style:{visibility:"hidden",height:0,display:"block",overflow:"hidden",fontWeight:600},"aria-hidden":"true"},o.charAt(0).toUpperCase()+o.slice(1)),e.createElement("span",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",textAlign:"center"}},o.charAt(0).toUpperCase()+o.slice(1)))}))):e.createElement("div",{className:"yt-byob-category-filter-wrapper",style:{overflowX:r?"auto":"visible",scrollbarWidth:"none",msOverflowStyle:"none",marginBottom:"20px",paddingBottom:"5px"}},e.createElement("div",{className:"yt-byob-category-buttons-container",style:{display:"flex",gap:"8px",minWidth:"max-content",flexWrap:"nowrap",justifyContent:"center",paddingRight:r?"10px":"0px"}},["All",...o].map(o=>e.createElement("button",{key:o,onClick:()=>a(o),className:"yt-byob-category-button",style:{padding:r?"8px 16px":"10px 18px",fontSize:r?"13px":"14px",fontWeight:"500",border:`1px solid ${n===o?t?.general.primaryColor:"#e0e0e0"}`,borderRadius:t?.general.ctaBorderRadius,backgroundColor:n===o?t?.general.primaryColor:"white",color:n===o?"white":"#333",cursor:"pointer",transition:"all 0.3s ease",outline:"none",whiteSpace:"nowrap",minWidth:"fit-content",flexShrink:0},onMouseEnter:e=>{n!==o&&(e.currentTarget.style.borderColor=t?.general.primaryColor,e.currentTarget.style.color=t?.general.primaryColor)},onMouseLeave:e=>{n!==o&&(e.currentTarget.style.borderColor="#e0e0e0",e.currentTarget.style.color="#333")}},o.charAt(0).toUpperCase()+o.slice(1)))))},W=({bundle:i,selectedItems:a,setSelectedItems:l,handleAddToCart:c,bundleAddToCartLoading:d,renderingOnPage:u,selectedItemsQuantity:p,handleRemoveItem:m,bundleSubtotal:y})=>{const[g,b]=t(void 0),[f,h]=t(window.innerWidth<450),[x,v]=t(0),[C,w]=t({}),E=i.builderTiers?.type,I=i.customizations,S=i.builderTiers?.productTier??[],P=i.builderTiers?.offerTier??[],[R,D]=t([]),[W,L]=t(!1),[V,M]=t("All"),[q,H]=t(0),U=r(null);o(()=>{const e=new Set;let t=!1;i?.products?.forEach(r=>{const o=r.productDetails;if(o.metafield&&"yourtoken_bundles_app"===o.metafield.namespace&&"categories"===o.metafield.key){let r=[];if(o.metafield.jsonValue&&Array.isArray(o.metafield.jsonValue))r=o.metafield.jsonValue;else if(o.metafield.value)try{const e=JSON.parse(o.metafield.value);Array.isArray(e)&&(r=e)}catch(e){console.error("Failed to parse categories:",e)}r.length>0&&(t=!0,r.forEach(t=>e.add(t)))}}),D(Array.from(e)),L(t)},[i.products]);const $=((e,t)=>"All"===t?e:e.filter(e=>{const r=e.productDetails;if(r.metafield&&"yourtoken_bundles_app"===r.metafield.namespace&&"categories"===r.metafield.key){let e=[];if(r.metafield.jsonValue&&Array.isArray(r.metafield.jsonValue))e=r.metafield.jsonValue;else if(r.metafield.value)try{const t=JSON.parse(r.metafield.value);Array.isArray(t)&&(e=t)}catch(e){console.error("Failed to parse categories:",e)}return e.includes(t)}return!1}))(i.products.filter(e=>"active"===e.productDetails.status?.toLowerCase()||"unlisted"===e.productDetails.status?.toLowerCase()||void 0===e.productDetails.status||""===e.productDetails.status),V),_="productTier"===E?S.reduce((e,t)=>e+t.minimumQuantity,0):"offerTier"===E?P.reduce((e,t)=>e+t.minimumQuantity,0):i.minimumQuantity,[J,X]=t(""),[Z,G]=t(""),K=((e,t)=>e.filter(e=>e?.productDetails?.title?.toLowerCase().includes(t?.toLowerCase())))($,J),Y=((e,t)=>[...e].sort((e,r)=>{const o=e?.productDetails?.title?.toLowerCase(),n=r?.productDetails?.title?.toLowerCase(),i=parseFloat(e?.productDetails?.variants?.edges?.[0]?.node?.price||"0"),a=parseFloat(r?.productDetails?.variants?.edges?.[0]?.node?.price||"0");switch(t){case"title-asc":return o.localeCompare(n);case"title-desc":return n.localeCompare(o);case"price-low-to-high":return i-a;case"price-high-to-low":return a-i;default:return 0}}))(K,Z),ee=((e,t,r,o,n)=>(e[n]?.products.filter(e=>t.some(t=>t.productId===e.productId&&(e.variantIds.length<1||t.variantIds.includes(e.variantIds[0]))&&t?.productDetails.title.toLowerCase().includes(r?.toLowerCase())))||[]).sort((e,r)=>{let n=t.find(t=>t.productId===e.productId&&(e.variantIds.length<1||t.variantIds.includes(e.variantIds[0]))),i=t.find(e=>e.productId===r.productId&&(r.variantIds.length<1||e.variantIds.includes(r.variantIds[0])));if(!n||!i)return 0;const a=n.productDetails?.title?.toLowerCase(),l=i.productDetails?.title?.toLowerCase(),s=parseFloat(n?.productDetails?.variants?.edges?.[0]?.node?.price||"0"),c=parseFloat(i?.productDetails?.variants?.edges?.[0]?.node?.price||"0");switch(o){case"title-asc":return a.localeCompare(l);case"title-desc":return l.localeCompare(a);case"price-low-to-high":return s-c;case"price-high-to-low":return c-s;default:return 0}}))(S,Y,J,Z,x),[te,re]=s(A),[oe,ne]=t(!1),ie="productTier"===E?ee:Y,ae=ie.slice(0,20*(q+1));o(()=>{setTimeout(()=>{ne(!0)},100)},[]);const le=r(null);o(()=>{const e=()=>{h(window.innerWidth<450)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),o(()=>{if(i.coverImageUrl){const e=new Image;e.src=T(i.coverImageUrl)??"",e.onload=()=>{b(e.width/e.height)}}},[i.coverImageUrl]),o(()=>{ne(!1),setTimeout(()=>ne(!0),100)},[x]);const se=(e,t)=>{if("productTier"===E){let r={...C},o=!1;if(r[t]){const n=r[t].indexOf(e);-1!==n&&(r[t]=[...r[t]],r[t].splice(n,1),o=!0)}if(!o)for(let t=S.length;t>=0;t--){const o=r[t].indexOf(e);if(-1!==o){r[t]=[...r[t]],r[t].splice(o,1);break}}w(r);const n=S.findIndex((e,t)=>r[t]?.length<e.minimumQuantity);-1!==n&&v(n)}m(e)},ce=()=>{const e=document.querySelector(".products-display");e&&e.scrollIntoView({behavior:"smooth"})};o(()=>{if("productTier"===E){const e=Object.fromEntries(S.map(e=>[e.tier,[]]));w(e)}},[i]),o(()=>{if("productTier"!==E||!S[x])return;if(_===p)return;const e=S.findIndex((e,t)=>{const r=C[t]||[];return t>=x&&r.length<e.minimumQuantity});-1!==e&&e!==x&&(v(e),ce())},[C,S,E]),o(()=>{X("")},[x]),o(()=>{function e(e){if(!le.current||!e.target)return;!le.current.contains(e.target)&&re(void 0)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const de=(e,t,r)=>{var o;"productTier"===E&&(o=e,w(e=>{const t={...e},r=S.findIndex((e,r)=>{const o=t[r]||[];return r>=x&&o.length<e.minimumQuantity});return-1!==r&&v(r),t[r]||(t[r]=[]),t[r].push(o),t}));const n=!0===S[x]?.isFreebieTier;k(e,t,r,a,l,n)},ue=(()=>{if(!i?.builderTiers)return i.minimumQuantity;const{type:e,offerTier:t,productTier:r}=i.builderTiers,o="offerTier"===e?t:"productTier"===e?r:null;if(!o)return i.minimumQuantity;let n=0;return o.map(e=>{n+=e.minimumQuantity}),n})(),pe=f&&i.mobileCoverImageUrl?T(i.mobileCoverImageUrl):T(i.coverImageUrl??"")||null,me=i.customStoreDetails?.fixedInventoryDetails,ye=n((e,t)=>{const r=me?.find(e=>e.variantId===t)?.quantity;if(void 0!==r)return r;const o=(e.variants?.edges||[]).find(e=>e.node.id===t),n=o?.node;return n?e.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[me]),ge=n(e=>{const t=I?.general?.showOutOfStockProducts;if(t)return!0;const r=e.productDetails,o=r?.variants?.edges||[];if(me){if(o.some(e=>me.some(t=>t.variantId===e.node.id&&t.quantity>0)))return!0}return o.some(e=>ye(r,e.node.id)>0)},[I?.general?.showOutOfStockProducts,me,ye]);o(()=>{if("productTier"!==E)return;const e=S[x];if(!e)return;if(1!==e.minimumQuantity)return;if(1!==e.products.length)return;const t=e.products[0],r=i.products.find(e=>e.productId===t.productId)?.productDetails;if(!r)return;if(r.variants?.edges?.length>1)return;const o=r.variants?.edges?.find(e=>ye(r,e.node.id)>0)?.node;if(!o)return;const n=o.id,a=C[x]?.includes(n);a||(de(n,r,1),x<S.length-1&&(v(x+1),ce()))},[E,S,x,i.products,C,ye,de]);const be="bundles"==i.appName?i.pageHeader?.title:i?.title,fe="bundles"==i.appName?i.pageHeader?.description:i?.subtitle;o(()=>{H(0)},[J,Z,V,x]);const he=n(()=>{ae.length<ie.length&&H(e=>e+1)},[ae.length,ie.length]);return o(()=>{const e=new IntersectionObserver(([e])=>{e.isIntersecting&&he()},{threshold:.1});return U.current&&e.observe(U.current),()=>{U.current&&e.unobserve(U.current)}},[he]),e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",rowGap:"15px",padding:"20px 0px",marginBottom:"20px",backgroundColor:I.byob.sectionBackgroundColor,..."transparent"!==I.fixedBundle.sectionBackgroundColor&&{padding:"20px"}}},pe?e.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",alignItems:"center",textAlign:"center",overflow:"hidden",...i?.coverImageVerticalMargin&&{marginBottom:i?.coverImageVerticalMargin,marginTop:i?.coverImageVerticalMargin}}},pe&&e.createElement(z,{coverImageUrl:pe,alt:"Background",styles:{width:"100%",height:"auto",display:"block"}}),e.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",padding:"20px",width:"90%",maxWidth:"1000px",textShadow:"2px 2px 8px rgba(0, 0, 0, 0.4)"}},e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.titleFontSize??"3rem",fontWeight:"700",color:I?.byob?.titleTextColor??"#000",marginBottom:"15px",backgroundColor:I?.byob?.titleBackgroundColor??"transparent",width:"100%",textAlign:"center"},className:"bundle-builder-title"},be),e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.subtitleFontSize??"1.5rem",color:I?.byob?.titleTextColor??"#000"},className:"bundle-builder-subtitle"},fe))):(be||fe)&&e.createElement("div",{style:{zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",padding:"20px",width:"90%",maxWidth:"1000px"}},be&&e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.titleFontSize??"3rem",fontWeight:"700",color:I?.byob?.titleTextColor??"#000",marginBottom:"15px",textAlign:"center",width:"100%",backgroundColor:I?.byob?.titleBackgroundColor??"transparent"}},be),fe&&e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.subtitleFontSize??"1.5rem",color:I?.byob?.titleTextColor??"#000"}},fe)),e.createElement("div",{style:{fontSize:"20px",width:"100%"},className:"products-display"},"productTier"===E&&S.length>0&&I?.byob.productTiersVisibility&&e.createElement(e.Fragment,null,e.createElement("div",null,e.createElement(F,{currentStep:x,totalSteps:S.length,tiers:S,isMobile:f,primaryColor:I?.general?.primaryColor,primaryTextColorCta:I?.general?.primaryContrastColor,setCurrentProductTier:v,selectedProductsByTier:C,tierNavigation:I.byob.tierNavigation})))),e.createElement("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"20px"}},i?.enableSortAndFilter&&e.createElement(j,{isMobile:f,searchTerm:J,setSearchTerm:X,setSortBy:G,styles:I}),i?.customizations?.byob?.enableProductCategories&&W&&e.createElement("div",null,e.createElement(O,{styles:I,isMobile:f,categories:R,activeCategory:V,onCategoryChange:e=>{M(e)}}))),e.createElement("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"12px",justifyContent:"center",width:"100%"},className:"products-display"},0===ie?.length?e.createElement("p",{style:{fontSize:"20px",color:"#333",textAlign:"center",width:"100%"}},"No products found"):"productTier"===E&&S.length>0?ae.filter(e=>ge(Y.find(t=>t.productId===e.productId&&(e.variantIds.length<1||t.variantIds.includes(e.variantIds[0]))))).map((t,r)=>{const o=(S[x]?.minimumQuantity??0)>(C[x]?.length??0),n=Y.find(e=>e.productId===t.productId&&(t.variantIds.length<1||e.variantIds.includes(t.variantIds[0])));return n?e.createElement(Q,{bundle:i,idx:r,key:t?.variantIds?.[0]??t.productId,product:n?.productDetails,handleAddToBundle:de,hideAddToBundle:!o,remainingQuantity:ue-p,themeColor:i?.dealTextColor,handleRemoveItem:e=>se(e,x),selecteditems:a,transitionActive:oe,customVariantsQuantity:me,currentProductTier:S[x],showFreebieTierProductPrices:i?.customStoreDetails?.showFreebieTierProductPrices}):null}):ae.filter(ge).map((t,r)=>e.createElement(Q,{bundle:i,idx:r,key:t.productId,product:t?.productDetails,handleAddToBundle:de,hideAddToBundle:p>=ue,remainingQuantity:ue-p,themeColor:i?.dealTextColor,handleRemoveItem:m,selecteditems:a,transitionActive:oe,customVariantsQuantity:me})),ae.length<ie.length&&e.createElement("div",{ref:U,style:{height:"1px",width:"100%",display:"block"}})),!u&&e.createElement(N,{builderTiers:i?.builderTiers,handleAddToCart:c,minimumQuantity:_,selectedProducts:a,showProductDetailsInTracker:i.showProductDetailsInTracker,handleRemoveItem:m,handleRemoveItemProductTier:se,selectedItemsQuantity:p,percentageOff:i.percentageOff,loading:d,bundleSubtotal:y,amountOff:i.amountOff,styles:i.customizations,dealAmount:i.dealAmount,themeColor:i?.dealTextColor??"#333",primaryTextColorCta:i?.primaryTextColorCta??"#fff",cornerRadiusType:i?.cornerRadiusType??"",selectedProductsByTier:C,renderingOnPage:u})),u&&e.createElement(N,{handleAddToCart:c,minimumQuantity:_,builderTiers:i?.builderTiers,selectedProducts:a,showProductDetailsInTracker:i.showProductDetailsInTracker,loading:d,handleRemoveItem:m,handleRemoveItemProductTier:se,percentageOff:i.percentageOff,selectedItemsQuantity:p??0,bundleSubtotal:y??{price:0,compareAtPrice:0},amountOff:i.amountOff,styles:i.customizations,dealAmount:i.dealAmount,themeColor:I?.general.primaryColor||"#000",primaryTextColorCta:I.general.primaryContrastColor??"#fff",cornerRadiusType:i?.cornerRadiusType??"",selectedProductsByTier:C,renderingOnPage:u}),te&&void 0!==p&&(()=>{let t=p<i.minimumQuantity;return"productTier"==E?t=(S[x]?.minimumQuantity??0)>(C[x]?.length??0):"offerTier"==E&&(t=p<P.reduce((e,t)=>e+t.minimumQuantity,0)),e.createElement(B,{handleAddToBundle:de,ref:le,remainingQuantity:i.minimumQuantity-p,hideAddToBundle:!t,disableQuantitySelector:i?.disableQuantitySelector??!1,selectedProducts:a,selectedProductsByTier:C,themeColor:I?.general.primaryColor||"#000",primaryTextColorCta:i?.customizations?.general.primaryContrastColor??"#fff",primaryBackgroundColorCta:I?.general.primaryColor||"#000",cornerRadius:i?.customizations.byob.borderRadius,styles:i.customizations,reviewRatingType:i?.reviewRatingType??"none",customVariantsQuantity:me,bundleProductsCustomQuantity:i?.customProductsQuantity,isFreebieTier:S?.[x]?.isFreebieTier,showFreebieTierProductPrices:i?.customStoreDetails?.showFreebieTierProductPrices})})())};export{R as QuantitySelectorForBundle,W as default};
1
+ import"../bundle.scss.js";import e,{useState as t,useRef as r,useEffect as o,useCallback as n,useMemo as i}from"react";import{BiTrash as a,BiSearch as l}from"react-icons/bi";import{useAtom as s,useSetAtom as c}from"jotai";import{IoChevronDownOutline as d}from"react-icons/io5";import{IoIosStar as u}from"react-icons/io";import{MdVerified as p}from"react-icons/md";import{ProductContainer as m,ImageWrapper as y,VariantSelector as g,ProductTitle as b,AddToBundleWrapper as f,AddToBundleButton as h,QuantitySelectorContainer as x,AddedButtonText as v,RemoveButton as C,Container as w,Quantity as E}from"./bundleBuilder.style.js";import{optimiseImage as T,getCurrencySymbol as I,currencyPrice as S,handleAddToBundle as k}from"../Bundle.js";import{BundleBuilderTrackerBar as N}from"../BundleBuilderTracker/BundleBuilderTracker.js";import{bundleBuilderProductDetailsState as A}from"../../../atoms/bundleBuilderProductDetailsAtom.js";import B from"../BundleProductDetailsModal/BundleProductDetailsModal.js";import P from"./VariantOptionsModal.js";import{ResponsiveBackgroundImage as z}from"./ResponsiveBgImage.js";function R({quantity:t,setQuantity:r,remainingQuantity:o,handleAddToBundle:n,variantId:i,product:a,handleRemoveItem:l,hideAddToBundle:s,selectedVariantInventoryQty:c}){const d={display:"flex",alignItems:"center",justifyContent:"center",width:"33%",cursor:"pointer",backgroundColor:"#f2f2f2",userSelect:"none",border:"none",padding:"8px",margin:"0",fontSize:"20px",color:"#333",textDecoration:"none",boxShadow:"none",outline:"none",borderRadius:"0",boxSizing:"border-box"},u=t<c;return e.createElement(w,{className:"yt-byob-quantity-selector-container"},e.createElement("button",{className:"yt-byob-quantity-minus-button",onClick:e=>{e.stopPropagation();const o=Math.max(0,t-1);r(o),l&&i&&l(i,1)},style:d},"-"),e.createElement(E,{className:"yt-byob-quantity-display"},t," added"),e.createElement("button",{className:"yt-byob-quantity-plus-button",onClick:e=>{e.stopPropagation();const l=Math.min(o,t+1,c);r(l),n&&i&&a&&n(i,a,1)},disabled:!u||s,style:{...d,cursor:!u||s?"not-allowed":"pointer",opacity:!u||s?.6:1}},"+"))}const D=({product:r,styles:n,selectedVariant:a})=>{const[l,s]=t(!1),c=i(()=>T(a?.image?.url||r?.featuredMedia?.preview?.image?.url||r?.media?.edges?.[0]?.node?.image?.url)||"",[a?.image?.url,r?.featuredMedia?.preview?.image?.url,r?.media?.edges]),d=i(()=>r?.media?.edges?.map(e=>T(e?.node?.preview?.image?.url??e?.node?.image?.url)).filter(Boolean)??[],[r?.media?.edges]),u=i(()=>d?.[1]??c??"",[d,c]);o(()=>{if(c){(new Image).src=c}},[c]);const p=i(()=>c||d?.[0],[c,d]);return e.createElement("div",{className:"yt-byob-image-hover-container",style:{position:"relative",width:"100%",overflow:"hidden",aspectRatio:n.general.imageAspectRatio||"1/1"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)},e.createElement("div",{className:"yt-byob-image-inner-container",style:{width:"100%",height:"100%",position:"relative"}},e.createElement("img",{className:"yt-byob-image-main",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",objectPosition:"top",opacity:l&&p!==u?0:1,transition:d?.length>0?"opacity 300ms ease, transform 300ms ease":"",transform:l?"scale(1.1)":"scale(1)"},src:p,alt:r.title}),p!==u&&e.createElement("img",{className:"yt-byob-image-hover",loading:"lazy",style:{width:"100%",height:"100%",objectFit:"cover",opacity:l?1:0,transition:"opacity 400ms ease, transform 400ms ease",transform:l?"scale(1.1)":"scale(1)",position:"absolute",top:0,left:0,objectPosition:"top"},src:u,alt:r.title})))},Q=({product:r,bundle:i,handleAddToBundle:l,hideAddToBundle:s,remainingQuantity:w,themeColor:E,handleRemoveItem:T,transitionActive:k,idx:N,selecteditems:B,customVariantsQuantity:z,currentProductTier:Q,showFreebieTierProductPrices:j})=>{const F=c(A),O=i.customizations,W=O?.byob?.variantSelectorType,[L,V]=t(!1),M=O.general?.variantTitleSuffix?r?.variants?.edges:(e=>{if(!e||e.length<2)return e;const t=e.map(e=>e.node.title).map(e=>e.split(" "));let r=[...t[0]];for(let e=1;e<t.length;e++){const o=t[e];let n=0;for(;n<r.length&&n<o.length&&r[r.length-1-n]===o[o.length-1-n];)n++;r=r.slice(r.length-n)}return r.length<1?e:e.map(e=>{const t=e.node.title.split(" "),o=t.slice(0,t.length-r.length).join(" ");return{...e,node:{...e.node,title:o,commonSuffix:r.join(" ")}}})})(r?.variants?.edges);if(!M||!M.length)return e.createElement(e.Fragment,null);const q=n(e=>{const t=z?.find(t=>t.variantId===e)?.quantity;if(void 0!==t)return t;if(i?.customProductsQuantity)return i?.customProductsQuantity;const o=M?.find(t=>t.node.id===e),n=o?.node;return n?r.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[M,z,r.tracksInventory]),H=M?.find(e=>q(e.node.id)>0)?.node?.id;if(!H&&!O.general.showOutOfStockProducts)return e.createElement(e.Fragment,null);const[U,$]=t(M?.find(e=>q(e.node.id)>0)?.node?.id||M[0]?.node?.id),[_,J]=t(0),[X,Z]=t(window.innerWidth<450),[G,K]=t("normal"),Y=M?.find(e=>e?.node?.id===U)?.node,ee=q(U||"");o(()=>{const e=B.find(e=>e.variantId===U);J(e?e.quantity:0)},[_,B,U]),o(()=>{const e=()=>{Z(window.innerWidth<450)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),o(()=>{CSS.supports("font-weight","500")?K("500"):CSS.supports("font-weight","400")?K("400"):CSS.supports("font-weight","600")&&K("600")},[]),o(()=>{document.documentElement.style.setProperty("--yt-bundle-font-weight",G)},[G]),o(()=>{if(U&&!M?.some(e=>e.node.id===U)){const e=M.find(e=>q(e.node.id)>0)?.node.id||M[0]?.node?.id;e&&$(e)}},[U,M,q]);const te=r.variants&&r.variants.edges?.length>1&&"customOptions"!==W,re="undefined"!=typeof window?(window?.ytapp||window?.ytBundleApp)?.storeId:void 0,oe="53933408435"===re,ne="75851235630"===re,ie=(e=>{if(e.metafield&&"yourtoken_bundles_app"===e.metafield.namespace&&"categories"===e.metafield.key){if(e.metafield.jsonValue&&Array.isArray(e.metafield.jsonValue))return e.metafield.jsonValue;if(e.metafield.value)try{const t=JSON.parse(e.metafield.value);if(Array.isArray(t))return t}catch(e){console.error("Failed to parse categories:",e)}}return[]})(r),ae=ie.length>0;return e.createElement(e.Fragment,null,e.createElement(m,{borderRadius:O?.byob.borderRadius,borderColor:O?.byob.borderColor,shadowType:O?.byob.shadowType,backgroundColor:O?.byob.cardBackgroundColor,className:"yt-byob-product-container bundle-builder-product-container "+(k?"yt-product-card-transition-active":N%2==0?"yt-product-card-transition":"yt-product-card-transition-up"),onClick:()=>{if(ee<=0)return;const e={...r,variants:{...r.variants,edges:M},selectedVariant:Y};F(e)},onMouseEnter:e=>{e.currentTarget.style.transform="scale(1.01)"},onMouseLeave:e=>{e.currentTarget.style.transform="scale(1)"},style:{WebkitTapHighlightColor:"transparent"}},e.createElement(y,{className:"yt-byob-image-wrapper"},e.createElement(D,{product:r,styles:O,selectedVariant:Y}),i?.productCardBadgeText&&e.createElement("div",{className:"yt-byob-product-badge",style:{position:"absolute",top:"0px",left:"0px",backgroundColor:O?.general.primaryColor||"#111",color:O?.general.primaryContrastColor||"#fff",zIndex:1,margin:"0px",whiteSpace:"pre",padding:"4px 8px",fontSize:"12px",borderTopLeftRadius:O.byob.borderRadius}},i.productCardBadgeText),te&&e.createElement("div",{className:"yt-byob-variant-selector-wrapper",style:{position:"relative",width:"100%"}},e.createElement(g,{className:"yt-byob-variant-selector",isCoralHaze:oe,onClick:e=>{e.preventDefault(),e.stopPropagation()},value:U||"",onChange:e=>{e.stopPropagation(),e.preventDefault(),$(e.target.value)}},M?.map(t=>{const r=window.innerWidth<=320?10:window.innerWidth<=420?15:22,o=t.node.title.length>r?t.node.title.substring(0,r)+"...":t.node.title;return e.createElement("option",{key:t.node.id,value:t.node.id},o)})),e.createElement("div",{className:"yt-byob-variant-chevron",style:{position:"absolute",right:"16px",bottom:"10px",pointerEvents:"none"}},e.createElement(d,null)))),e.createElement("div",{className:"yt-byob-product-content"},"enabled"===i?.customizations?.byob?.productCardCategoryVisibility&&ae&&e.createElement("div",{className:"yt-byob-product-categories-wrapper",style:{padding:"2px 4px"}},e.createElement("div",{className:"yt-byob-product-categories",style:{display:"flex",flexWrap:"wrap",gap:"4px"}},ie.slice(0,2).map((t,r)=>e.createElement("span",{className:"yt-byob-category-tag",key:r,style:{fontSize:X?"8px":"12px",color:"#666",fontWeight:"500"}},t.charAt(0).toUpperCase()+t.slice(1))),ie.length>2&&e.createElement("span",{className:"yt-byob-more-categories",style:{fontSize:"10px",padding:"2px 6px",backgroundColor:"rgba(0, 0, 0, 0.05)",borderRadius:"8px",color:"#666",fontWeight:"500"}},"+",ie.length-2," more"))),e.createElement(b,{isMobile:X,showBorder:i?.showBorder??!0,style:{...!O?.byob.productsPriceVisibility&&{padding:"8px"},...O?.byob.productTitleFontSize&&{fontSize:O?.byob.productTitleFontSize}},className:"yt-byob-product-title-wrapper"},e.createElement("div",{style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:"normal"},className:"yt-byob-product-title"},ne?String(Y?.displayName).replace("- Default Title",""):r.title,Y?.commonSuffix?" -"+Y?.commonSuffix:""))),"ratingOnly"===i?.reviewRatingType&&(r?.rating?.averageRating??0)>0&&e.createElement("div",{className:"yt-byob-product-ratings",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},e.createElement(u,{color:"gold",size:14})," ",e.createElement("span",{style:{marginLeft:6}},r?.rating?.averageRating," rating")),"ratingAndReviewCount"===i?.reviewRatingType&&(r?.rating?.averageRating??0)>0&&e.createElement("div",{className:"yt-byob-product-ratings-count",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},e.createElement(u,{color:"gold",size:14})," ",r?.rating?.averageRating,e.createElement(p,{className:"yt-byob-verified-icon",size:14,style:{color:"dodgerblue",marginLeft:"4px"}})," ","(",r?.rating?.ratingCount," reviews)"),O?.byob.productsPriceVisibility&&e.createElement("div",{className:"yt-byob-product-price yt-bundle-builder-product-price",style:{marginBottom:"5px",padding:i?.showBorder?"0px 10px":"0 4px"}},Q?.isFreebieTier&&!j?e.createElement(e.Fragment,null,e.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"14px",textDecoration:"line-through",color:"#888",marginRight:"6px"}},I(O.general.currencySymbol,i?.storeCurrencyCode)??"Rs.",S(Y?.price)),e.createElement("span",{className:"yt-byob-current-price",style:{color:O.general.primaryColor||"#d32f2f",fontWeight:"bold"}},"FREE")):parseFloat(Y?.price??"0")>0?e.createElement("span",{className:"yt-byob-current-price"},I(O.general.currencySymbol,i?.storeCurrencyCode)??"Rs.",S(Y?.price)):e.createElement("span",{className:"yt-byob-free-price"},"Free"),(!Q?.isFreebieTier||j)&&Y?.compareAtPrice&&O?.byob.compareAtPriceVisibility&&parseFloat(Y.compareAtPrice)>parseFloat(Y?.price)&&e.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"14px"}},I(O.general.currencySymbol,i?.storeCurrencyCode)??"Rs.",S(Y.compareAtPrice))),(ee>0||ee===1/0)&&e.createElement(f,{borderRadius:O?.byob.borderRadius,className:"yt-byob-add-to-bundle-wrapper yt-product-atc-wrapper"},(0===_||void 0===_)&&e.createElement(h,{style:{...!s&&{backgroundColor:O?.general.primaryColor||"#111",color:O?.general.primaryContrastColor||"#fff"}},disabled:s,onClick:e=>{e.stopPropagation(),e.preventDefault(),J(1),(()=>{if(!U)return;"customOptions"===W&&M.length>1?V(!0):l(U,r,1)})()},className:"yt-byob-add-to-bundle-button yt-product-atc-button"},O?.byob.addToBundleCTAText),!i?.disableQuantitySelector&&_>0&&U&&e.createElement(x,{className:"yt-byob-quantity-selector-container visible",style:{overflow:"hidden"}},e.createElement(R,{remainingQuantity:w,setQuantity:J,quantity:_,handleAddToBundle:l,variantId:U,product:r,handleRemoveItem:T,hideAddToBundle:s,selectedVariantInventoryQty:ee})),i?.disableQuantitySelector&&_>0&&U&&e.createElement(h,{style:{backgroundColor:"#747474",color:O?.general.primaryContrastColor||"#fff",display:"flex",justifyContent:"space-between",overflow:"hidden",height:"40px"},className:"yt-byob-added-button yt-product-atc-single-qty-selector"},e.createElement(v,{className:"yt-byob-added-text yt-product-atc-single-qty-selector-added"},"ADDED"),e.createElement(C,{className:"yt-byob-single-qty-remove yt-product-atc-single-qty-selector-remove",onClick:e=>{e.stopPropagation();const t=Math.max(0,_-1);J(t),T&&U&&T(U,1)}},e.createElement(a,{style:{color:"#fff",fontSize:"20px"}})))),ee<=0&&ee!==1/0&&e.createElement(h,{style:{backgroundColor:O.general.disabledButtonColor,color:"#fff",cursor:"not-allowed",transition:"transform 0.2s ease-in-out"},className:"yt-product-atc-disabled"},O?.general.outOfStockLabel||"Out of Stock")),"customOptions"===W&&L&&M.length>1&&e.createElement(P,{product:r,isOpen:L,onClose:()=>V(!1),variantOptions:i.variantOptions,cta:{textColor:O.general.ctaTextColor,backgroundColor:O.general.primaryColor},onConfirm:e=>{$(e),l(e,r,1)}}))},j=({currentStep:t,setCurrentProductTier:r,totalSteps:o,tiers:n,isMobile:i,selectedProductsByTier:a,primaryColor:l="#000",primaryTextColorCta:s="#fff",tierNavigation:c})=>e.createElement("div",{className:"yt-byob-stepper-container",style:{textAlign:"center",fontSize:"20px"}},e.createElement("div",{className:"yt-byob-stepper-steps",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center"}},Array.from({length:o}).map((s,d)=>{const u=d+1,p=n[d].minimumQuantity-(a[d]?.length??0)===0,m=d===t;return l="black"===l?"#000000":l,e.createElement(e.Fragment,{key:u},e.createElement("div",{className:"yt-byob-stepper-step-wrapper",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:"pointer",gap:i?"4px":"8px"},onClick:()=>!1===c?()=>{}:r(u-1)},e.createElement("div",{className:"yt-byob-stepper-step-number",style:{fontSize:"14px"}},"Step ",u),e.createElement("div",{className:"yt-byob-stepper-step-bar",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center",cursor:"pointer"}},e.createElement("div",{className:"yt-byob-stepper-step-left-bar",style:{height:"3px",width:i?"30px":"50px",backgroundColor:p?l:m?"#666666":"#CBD5E0",display:"block",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px"}}),e.createElement("div",{className:"yt-byob-stepper-step-circle",style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:p?`${l}50`:"white",border:`2px solid ${p?l:m?"#666666":"#CBD5E0"}`,display:"flex",alignItems:"center",justifyContent:"center"}}),e.createElement("div",{className:"yt-byob-stepper-step-right-bar",style:{height:"3px",width:i?"30px":"50px",backgroundColor:p?l:m?"#666666":"#CBD5E0",display:"block",marginRight:d<o?i?"4px":"6px":"",borderTopRightRadius:"5px",borderBottomRightRadius:"5px"}}))))})),e.createElement("div",{className:"yt-byob-stepper-title",style:{margin:i?"16px 0px":"15px 0px",fontSize:i?"16px":"18px",padding:"4px",background:"rgba(0, 0, 0, 0.03)",borderBottom:"1px solid rgba(130, 130, 130, 0.28)"}},n[t]?.title)),F=({isMobile:r,setSearchTerm:n,searchTerm:i,styles:a,setSortBy:s})=>{const[c,d]=t(!1),[u,p]=t(i);return o(()=>{const e=setTimeout(()=>{n(u)},300);return()=>clearTimeout(e)},[u,n]),e.createElement("div",{className:"yt-byob-sort-filter-container",style:{display:"flex",flexDirection:r?"column":"row",justifyContent:"space-between",alignItems:r?"flex-end":"center",textAlign:"center",marginBottom:"20px",width:"97%",gap:r?"10px":"0"}},e.createElement("div",{className:"yt-byob-sort-filter-inner",style:{display:"flex",flexDirection:c&&r?"column":r?"row-reverse":"row",justifyContent:"space-between",alignItems:c?"":"center",gap:"12px",width:"100%"}},e.createElement("div",{className:"yt-byob-search-wrapper",style:{position:"relative",display:"flex",alignItems:"center",width:r?c?"100%":"auto":"400px",transition:"width 0.3s ease-in-out"}},r&&!c?e.createElement(l,{className:"yt-byob-search-icon",fontSize:"20px",color:"#555",style:{cursor:"pointer",lineHeight:"normal"},onClick:()=>d(!0)}):e.createElement(e.Fragment,null,e.createElement("input",{className:"yt-byob-search-input",style:{width:"100%",padding:r?"10px 12px":"10px 14px",fontSize:"14px",outline:"none",color:"#333",border:"1px solid #c7c7c7",borderRadius:a?.byob.borderRadius,boxShadow:a?.byob.borderColor?"0 2px 4px rgba(0, 0, 0, 0.1)":"none",textAlign:"start"},placeholder:"Search by Product Name",value:u,onChange:e=>p(e.target.value)}),!c&&e.createElement("span",{className:"yt-byob-search-icon-input",style:{position:"absolute",right:"12px",color:"#aaa",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",paddingLeft:"5px"}},e.createElement(l,{fontSize:"18px",style:{lineHeight:"normal"}}))),r&&c&&e.createElement("span",{className:"yt-byob-search-close-icon",style:{position:"absolute",right:"12px",color:"#aaa",fontSize:"16px",cursor:"pointer"},onClick:()=>d(!1)},"✖")),e.createElement("div",{className:"yt-byob-filter-wrapper",style:{display:"flex",alignItems:"center",textAlign:"center",border:window.innerWidth>600?"1px solid #d1d5db":"",padding:"8px 12px",fontSize:"14px",cursor:"pointer",borderRadius:a?.byob.borderRadius,boxShadow:a?.byob.borderColor?window.innerWidth>600?"0 2px 4px rgba(0, 0, 0, 0.1)":" ":"none"}},e.createElement("span",{className:"yt-byob-filter-label",style:{fontSize:"14px",color:"#555",marginRight:"6px"}},"Sort:"),e.createElement("select",{className:"yt-byob-filter-select",style:{flex:1,border:"none",height:"auto",padding:"0px",marginBottom:"0px",background:"transparent",fontSize:"14px",color:"#333",fontWeight:"500",width:r?"120px":"",outline:"none",cursor:"pointer",textAlign:"start"},onChange:e=>s(e.target.value)},e.createElement("option",{value:"best-selling"},"Featured"),e.createElement("option",{value:"title-asc"},"Product Title (A-Z)"),e.createElement("option",{value:"title-desc"},"Product Title (Z-A)"),e.createElement("option",{value:"price-low-to-high"},"Price (Low to High)"),e.createElement("option",{value:"price-high-to-low"},"Price (High to Low)")))))},O=({styles:t,isMobile:r,categories:o,activeCategory:n,onCategoryChange:i})=>{const a=e=>{i(e)},l=(e,t)=>{const r=e.replace("#","");return`rgba(${parseInt(r.substring(0,2),16)}, ${parseInt(r.substring(2,4),16)}, ${parseInt(r.substring(4,6),16)}, ${t})`};return"tabs"===t?.byob?.categoryFilterOnPage?e.createElement("div",{className:"yt-byob-category-filter-wrapper",style:{overflowX:r?"auto":"visible",scrollbarWidth:"none",msOverflowStyle:"none",marginBottom:"20px",width:"100%"}},e.createElement("div",{className:"yt-byob-category-tabs-container",style:{display:"flex",gap:"0px",minWidth:"max-content",paddingBottom:"1px",flexWrap:"nowrap",justifyContent:"center",borderBottom:"1px solid #e0e0e0",width:"auto",height:r?"28px":"45px"}},["All",...o].map(o=>{const i=n===o;return e.createElement("button",{key:o,onClick:()=>a(o),className:"yt-byob-category-tab-button",style:{background:"none",border:"none",padding:r?"12px 16px":"12px 20px",fontSize:r?"14px":"16px",fontWeight:i?"600":"400",color:i?t.general.primaryColor:"#666",cursor:"pointer",position:"relative",transition:"all 0.3s ease",backgroundColor:i?l(t.general.primaryColor,.07):"transparent",borderBottom:i?`2px solid ${t?.general.primaryColor}`:"2px solid transparent",marginBottom:"-1px",whiteSpace:"nowrap",minWidth:"fit-content"},onMouseEnter:e=>{i||(e.currentTarget.style.color=t?.general.primaryColor)},onMouseLeave:e=>{i||(e.currentTarget.style.color="#666")}},e.createElement("span",{style:{visibility:"hidden",height:0,display:"block",overflow:"hidden",fontWeight:600},"aria-hidden":"true"},o.charAt(0).toUpperCase()+o.slice(1)),e.createElement("span",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",textAlign:"center"}},o.charAt(0).toUpperCase()+o.slice(1)))}))):e.createElement("div",{className:"yt-byob-category-filter-wrapper",style:{overflowX:r?"auto":"visible",scrollbarWidth:"none",msOverflowStyle:"none",marginBottom:"20px",paddingBottom:"5px"}},e.createElement("div",{className:"yt-byob-category-buttons-container",style:{display:"flex",gap:"8px",minWidth:"max-content",flexWrap:"nowrap",justifyContent:"center",paddingRight:r?"10px":"0px"}},["All",...o].map(o=>e.createElement("button",{key:o,onClick:()=>a(o),className:"yt-byob-category-button",style:{padding:r?"8px 16px":"10px 18px",fontSize:r?"13px":"14px",fontWeight:"500",border:`1px solid ${n===o?t?.general.primaryColor:"#e0e0e0"}`,borderRadius:t?.general.ctaBorderRadius,backgroundColor:n===o?t?.general.primaryColor:"white",color:n===o?"white":"#333",cursor:"pointer",transition:"all 0.3s ease",outline:"none",whiteSpace:"nowrap",minWidth:"fit-content",flexShrink:0},onMouseEnter:e=>{n!==o&&(e.currentTarget.style.borderColor=t?.general.primaryColor,e.currentTarget.style.color=t?.general.primaryColor)},onMouseLeave:e=>{n!==o&&(e.currentTarget.style.borderColor="#e0e0e0",e.currentTarget.style.color="#333")}},o.charAt(0).toUpperCase()+o.slice(1)))))},W=({bundle:i,selectedItems:a,setSelectedItems:l,handleAddToCart:c,bundleAddToCartLoading:d,renderingOnPage:u,selectedItemsQuantity:p,handleRemoveItem:m,bundleSubtotal:y})=>{const[g,b]=t(void 0),[f,h]=t(window.innerWidth<450),[x,v]=t(0),[C,w]=t({}),E=i.builderTiers?.type,I=i.customizations,S=i.builderTiers?.productTier??[],P=i.builderTiers?.offerTier??[],[R,D]=t([]),[W,L]=t(!1),[V,M]=t("All"),[q,H]=t(0),U=r(null);o(()=>{const e=new Set;let t=!1;i?.products?.forEach(r=>{const o=r.productDetails;if(o.metafield&&"yourtoken_bundles_app"===o.metafield.namespace&&"categories"===o.metafield.key){let r=[];if(o.metafield.jsonValue&&Array.isArray(o.metafield.jsonValue))r=o.metafield.jsonValue;else if(o.metafield.value)try{const e=JSON.parse(o.metafield.value);Array.isArray(e)&&(r=e)}catch(e){console.error("Failed to parse categories:",e)}r.length>0&&(t=!0,r.forEach(t=>e.add(t)))}}),D(Array.from(e)),L(t)},[i.products]);const $=((e,t)=>"All"===t?e:e.filter(e=>{const r=e.productDetails;if(r.metafield&&"yourtoken_bundles_app"===r.metafield.namespace&&"categories"===r.metafield.key){let e=[];if(r.metafield.jsonValue&&Array.isArray(r.metafield.jsonValue))e=r.metafield.jsonValue;else if(r.metafield.value)try{const t=JSON.parse(r.metafield.value);Array.isArray(t)&&(e=t)}catch(e){console.error("Failed to parse categories:",e)}return e.includes(t)}return!1}))(i.products.filter(e=>"active"===e.productDetails.status?.toLowerCase()||"unlisted"===e.productDetails.status?.toLowerCase()||void 0===e.productDetails.status||""===e.productDetails.status),V),_="productTier"===E?S.reduce((e,t)=>e+t.minimumQuantity,0):"offerTier"===E?P.reduce((e,t)=>e+t.minimumQuantity,0):i.minimumQuantity,[J,X]=t(""),[Z,G]=t(""),K=((e,t)=>e.filter(e=>e?.productDetails?.title?.toLowerCase().includes(t?.toLowerCase())))($,J),Y=((e,t)=>[...e].sort((e,r)=>{const o=e?.productDetails?.title?.toLowerCase(),n=r?.productDetails?.title?.toLowerCase(),i=parseFloat(e?.productDetails?.variants?.edges?.[0]?.node?.price||"0"),a=parseFloat(r?.productDetails?.variants?.edges?.[0]?.node?.price||"0");switch(t){case"title-asc":return o.localeCompare(n);case"title-desc":return n.localeCompare(o);case"price-low-to-high":return i-a;case"price-high-to-low":return a-i;default:return 0}}))(K,Z),ee=((e,t,r,o,n)=>(e[n]?.products.filter(e=>t.some(t=>t.productId===e.productId&&(e.variantIds.length<1||t.variantIds.includes(e.variantIds[0]))&&t?.productDetails.title.toLowerCase().includes(r?.toLowerCase())))||[]).sort((e,r)=>{let n=t.find(t=>t.productId===e.productId&&(e.variantIds.length<1||t.variantIds.includes(e.variantIds[0]))),i=t.find(e=>e.productId===r.productId&&(r.variantIds.length<1||e.variantIds.includes(r.variantIds[0])));if(!n||!i)return 0;const a=n.productDetails?.title?.toLowerCase(),l=i.productDetails?.title?.toLowerCase(),s=parseFloat(n?.productDetails?.variants?.edges?.[0]?.node?.price||"0"),c=parseFloat(i?.productDetails?.variants?.edges?.[0]?.node?.price||"0");switch(o){case"title-asc":return a.localeCompare(l);case"title-desc":return l.localeCompare(a);case"price-low-to-high":return s-c;case"price-high-to-low":return c-s;default:return 0}}))(S,Y,J,Z,x),[te,re]=s(A),[oe,ne]=t(!1),ie="productTier"===E?ee:Y,ae=ie.slice(0,20*(q+1));o(()=>{setTimeout(()=>{ne(!0)},100)},[]);const le=r(null);o(()=>{const e=()=>{h(window.innerWidth<450)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),o(()=>{if(i.coverImageUrl){const e=new Image;e.src=T(i.coverImageUrl)??"",e.onload=()=>{b(e.width/e.height)}}},[i.coverImageUrl]),o(()=>{ne(!1),setTimeout(()=>ne(!0),100)},[x]);const se=(e,t)=>{if("productTier"===E){let r={...C},o=!1;if(r[t]){const n=r[t].indexOf(e);-1!==n&&(r[t]=[...r[t]],r[t].splice(n,1),o=!0)}if(!o)for(let t=S.length;t>=0;t--){const o=r[t].indexOf(e);if(-1!==o){r[t]=[...r[t]],r[t].splice(o,1);break}}w(r);const n=S.findIndex((e,t)=>r[t]?.length<e.minimumQuantity);-1!==n&&v(n)}m(e)},ce=()=>{const e=document.querySelector(".products-display");e&&e.scrollIntoView({behavior:"smooth"})};o(()=>{if("productTier"===E){const e=Object.fromEntries(S.map(e=>[e.tier,[]]));w(e)}},[i]),o(()=>{if("productTier"!==E||!S[x])return;if(_===p)return;const e=S.findIndex((e,t)=>{const r=C[t]||[];return t>=x&&r.length<e.minimumQuantity});-1!==e&&e!==x&&(v(e),ce())},[C,S,E]),o(()=>{X("")},[x]),o(()=>{function e(e){if(!le.current||!e.target)return;!le.current.contains(e.target)&&re(void 0)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const de=(e,t,r)=>{var o;"productTier"===E&&(o=e,w(e=>{const t={...e},r=S.findIndex((e,r)=>{const o=t[r]||[];return r>=x&&o.length<e.minimumQuantity});return-1!==r&&v(r),t[r]||(t[r]=[]),t[r].push(o),t}));const n=!0===S[x]?.isFreebieTier;k(e,t,r,a,l,n)},ue=(()=>{if(!i?.builderTiers)return i.minimumQuantity;const{type:e,offerTier:t,productTier:r}=i.builderTiers,o="offerTier"===e?t:"productTier"===e?r:null;if(!o)return i.minimumQuantity;let n=0;return o.map(e=>{n+=e.minimumQuantity}),n})(),pe=f&&i.mobileCoverImageUrl?T(i.mobileCoverImageUrl):T(i.coverImageUrl??"")||null,me=i.customStoreDetails?.fixedInventoryDetails,ye=n((e,t)=>{const r=me?.find(e=>e.variantId===t)?.quantity;if(void 0!==r)return r;const o=(e.variants?.edges||[]).find(e=>e.node.id===t),n=o?.node;return n?e.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[me]),ge=n(e=>{const t=I?.general?.showOutOfStockProducts;if(t)return!0;const r=e.productDetails,o=r?.variants?.edges||[];if(me){if(o.some(e=>me.some(t=>t.variantId===e.node.id&&t.quantity>0)))return!0}return o.some(e=>ye(r,e.node.id)>0)},[I?.general?.showOutOfStockProducts,me,ye]);o(()=>{if("productTier"!==E)return;const e=S[x];if(!e)return;if(1!==e.minimumQuantity)return;if(1!==e.products.length)return;const t=e.products[0],r=i.products.find(e=>e.productId===t.productId)?.productDetails;if(!r)return;if(r.variants?.edges?.length>1)return;const o=r.variants?.edges?.find(e=>ye(r,e.node.id)>0)?.node;if(!o)return;const n=o.id,a=C[x]?.includes(n);a||(de(n,r,1),x<S.length-1&&(v(x+1),ce()))},[E,S,x,i.products,C,ye,de]);const be="bundles"==i.appName?i.pageHeader?.title:i?.title,fe="bundles"==i.appName?i.pageHeader?.description:i?.subtitle;o(()=>{H(0)},[J,Z,V,x]);const he=n(()=>{ae.length<ie.length&&H(e=>e+1)},[ae.length,ie.length]);return o(()=>{const e=new IntersectionObserver(([e])=>{e.isIntersecting&&he()},{threshold:.1});return U.current&&e.observe(U.current),()=>{U.current&&e.unobserve(U.current)}},[he]),e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",rowGap:"15px",padding:"20px 0px",marginBottom:"20px",backgroundColor:I.byob.sectionBackgroundColor,..."transparent"!==I.fixedBundle.sectionBackgroundColor&&{padding:"20px"}}},pe?e.createElement("div",{style:{position:"relative",width:"100%",display:"flex",justifyContent:"center",alignItems:"center",textAlign:"center",overflow:"hidden",...i?.coverImageVerticalMargin&&{marginBottom:i?.coverImageVerticalMargin,marginTop:i?.coverImageVerticalMargin}}},pe&&e.createElement(z,{coverImageUrl:pe,alt:"Background",styles:{width:"100%",height:"auto",display:"block"}}),e.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",padding:"20px",width:"90%",maxWidth:"1000px",textShadow:"2px 2px 8px rgba(0, 0, 0, 0.4)"}},e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.titleFontSize??"3rem",fontWeight:"700",color:I?.byob?.titleTextColor??"#000",marginBottom:"15px",backgroundColor:I?.byob?.titleBackgroundColor??"transparent",width:"100%",textAlign:"center"},className:"bundle-builder-title"},be),e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.subtitleFontSize??"1.5rem",color:I?.byob?.titleTextColor??"#000"},className:"bundle-builder-subtitle"},fe))):(be||fe)&&e.createElement("div",{style:{zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",padding:"20px",width:"90%",maxWidth:"1000px"}},be&&e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.titleFontSize??"3rem",fontWeight:"700",color:I?.byob?.titleTextColor??"#000",marginBottom:"15px",textAlign:"center",width:"100%",backgroundColor:I?.byob?.titleBackgroundColor??"transparent"}},be),fe&&e.createElement("span",{style:{lineHeight:"normal",fontSize:I?.byob?.subtitleFontSize??"1.5rem",color:I?.byob?.titleTextColor??"#000"}},fe)),e.createElement("div",{style:{fontSize:"20px",width:"100%"},className:"products-display"},"productTier"===E&&S.length>0&&I?.byob.productTiersVisibility&&e.createElement(e.Fragment,null,e.createElement("div",null,e.createElement(j,{currentStep:x,totalSteps:S.length,tiers:S,isMobile:f,primaryColor:I?.general?.primaryColor,primaryTextColorCta:I?.general?.primaryContrastColor,setCurrentProductTier:v,selectedProductsByTier:C,tierNavigation:I.byob.tierNavigation})))),e.createElement("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:"20px"}},i?.enableSortAndFilter&&e.createElement(F,{isMobile:f,searchTerm:J,setSearchTerm:X,setSortBy:G,styles:I}),i?.customizations?.byob?.enableProductCategories&&W&&e.createElement("div",null,e.createElement(O,{styles:I,isMobile:f,categories:R,activeCategory:V,onCategoryChange:e=>{M(e)}}))),e.createElement("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"12px",justifyContent:"center",width:"100%"},className:"products-display"},0===ie?.length?e.createElement("p",{style:{fontSize:"20px",color:"#333",textAlign:"center",width:"100%"}},"No products found"):"productTier"===E&&S.length>0?ae.filter(e=>ge(Y.find(t=>t.productId===e.productId&&(e.variantIds.length<1||t.variantIds.includes(e.variantIds[0]))))).map((t,r)=>{const o=(S[x]?.minimumQuantity??0)>(C[x]?.length??0),n=Y.find(e=>e.productId===t.productId&&(t.variantIds.length<1||e.variantIds.includes(t.variantIds[0])));return n?e.createElement(Q,{bundle:i,idx:r,key:t?.variantIds?.[0]??t.productId,product:n?.productDetails,handleAddToBundle:de,hideAddToBundle:!o,remainingQuantity:ue-p,themeColor:i?.dealTextColor,handleRemoveItem:e=>se(e,x),selecteditems:a,transitionActive:oe,customVariantsQuantity:me,currentProductTier:S[x],showFreebieTierProductPrices:i?.customStoreDetails?.showFreebieTierProductPrices}):null}):ae.filter(ge).map((t,r)=>e.createElement(Q,{bundle:i,idx:r,key:t.productId,product:t?.productDetails,handleAddToBundle:de,hideAddToBundle:p>=ue,remainingQuantity:ue-p,themeColor:i?.dealTextColor,handleRemoveItem:m,selecteditems:a,transitionActive:oe,customVariantsQuantity:me})),ae.length<ie.length&&e.createElement("div",{ref:U,style:{height:"1px",width:"100%",display:"block"}})),!u&&e.createElement(N,{builderTiers:i?.builderTiers,handleAddToCart:c,minimumQuantity:_,selectedProducts:a,showProductDetailsInTracker:i.showProductDetailsInTracker,handleRemoveItem:m,handleRemoveItemProductTier:se,selectedItemsQuantity:p,percentageOff:i.percentageOff,loading:d,bundleSubtotal:y,amountOff:i.amountOff,styles:i.customizations,dealAmount:i.dealAmount,themeColor:i?.dealTextColor??"#333",primaryTextColorCta:i?.primaryTextColorCta??"#fff",cornerRadiusType:i?.cornerRadiusType??"",selectedProductsByTier:C,renderingOnPage:u})),u&&e.createElement(N,{handleAddToCart:c,minimumQuantity:_,builderTiers:i?.builderTiers,selectedProducts:a,showProductDetailsInTracker:i.showProductDetailsInTracker,loading:d,handleRemoveItem:m,handleRemoveItemProductTier:se,percentageOff:i.percentageOff,selectedItemsQuantity:p??0,bundleSubtotal:y??{price:0,compareAtPrice:0},amountOff:i.amountOff,styles:i.customizations,dealAmount:i.dealAmount,themeColor:I?.general.primaryColor||"#000",primaryTextColorCta:I.general.primaryContrastColor??"#fff",cornerRadiusType:i?.cornerRadiusType??"",selectedProductsByTier:C,renderingOnPage:u}),te&&void 0!==p&&(()=>{let t=p<i.minimumQuantity;return"productTier"==E?t=(S[x]?.minimumQuantity??0)>(C[x]?.length??0):"offerTier"==E&&(t=p<P.reduce((e,t)=>e+t.minimumQuantity,0)),e.createElement(B,{handleAddToBundle:de,ref:le,remainingQuantity:i.minimumQuantity-p,hideAddToBundle:!t,disableQuantitySelector:i?.disableQuantitySelector??!1,selectedProducts:a,selectedProductsByTier:C,themeColor:I?.general.primaryColor||"#000",primaryTextColorCta:i?.customizations?.general.primaryContrastColor??"#fff",primaryBackgroundColorCta:I?.general.primaryColor||"#000",cornerRadius:i?.customizations.byob.borderRadius,styles:i.customizations,reviewRatingType:i?.reviewRatingType??"none",customVariantsQuantity:me,bundleProductsCustomQuantity:i?.customProductsQuantity,isFreebieTier:S?.[x]?.isFreebieTier,showFreebieTierProductPrices:i?.customStoreDetails?.showFreebieTierProductPrices})})())};export{R as QuantitySelectorForBundle,W as default};
@@ -1 +1 @@
1
- import e,{useState as t,useEffect as r}from"react";import{getCurrencySymbol as a,currencyPrice as o}from"../Bundle.js";import{BiPlus as n}from"react-icons/bi";import{ClipLoader as l}from"react-spinners";import{FiTrash as i}from"react-icons/fi";import{RxMinus as c}from"react-icons/rx";import{Container as s,OfferTierTag as m,MobileRemaining as d,TierProgressContainer as b,TierProgressText as u,TierProgressBarBackground as p,TierProgressBarFill as y,ProductListWrapper as x,BundleBuilderTrackerItem as g,QuantityBadge as f,RemoveButton as k,DetailedItemContainer as E,DetailedImage as h,Badge as N,InfoBlock as w,ProductTitle as v,ProductPrice as T,RemoveLink as I,PlaceholderBox as C,SummaryContainer as S,SummaryInfo as R,SubtotalLabel as z,SaveLabel as F,SubtotalRow as B,FinalPrice as M,LineThroughPrice as A,CheckoutButton as P,CheckoutText as Q,ProductListTrackerItem as W,DetailedProductItem as q,PlusIconContainer as X}from"./bundleBuilderTracker.style.js";import H from"canvas-confetti";import{GrGift as V}from"react-icons/gr";const D=({tiers:t,isMobile:r=!1,selectedProductsByTier:a,selectedProducts:l,themeColor:s,showProductDetailsInTracker:m,handleRemoveItemProductTier:d,cornerRadius:b,currencySymbol:u})=>e.createElement(e.Fragment,null,t.map((s,p)=>{const y=s.minimumQuantity-(a[p]?.length??0),x=l?.filter(e=>a[p]?.includes(e.variantId));return Math.min(a[p]?.length/s.minimumQuantity*100,100),e.createElement("div",{className:"yt-byob-tracker-product-list-tier-wrapper",style:{display:"flex",width:"100%"}},e.createElement("div",{className:"yt-byob-tracker-product-list-tier-items"},e.createElement("div",{className:"yt-byob-tracker-product-list-items",style:{display:"flex",gap:"5px"}},x?.map?.(t=>{const n=t.product.variants?.edges?.find(e=>e.node.id===t.variantId),l=a[p]?.filter(e=>e===n?.node.id).length||0;return m?e.createElement(q,{className:"yt-byob-tracker-detailed-product-item",key:t.variantId},e.createElement(h,{className:"yt-byob-tracker-detailed-image",style:{backgroundImage:`url(${n?.node.image?.url&&n?.node.image?.url?.length>0?n?.node.image.url:t.product.featuredMedia?.preview?.image?.url})`}},t?.isFree&&e.createElement("div",{style:{position:"absolute",bottom:4,left:"30%",background:"linear-gradient(135deg, #ff0080, #ff4d4d)",color:"white",fontWeight:900,fontSize:"8px",padding:"4px 6px",borderRadius:"40px",letterSpacing:"1.5px",textTransform:"uppercase",boxShadow:"0 6px 20px rgba(255, 0, 128, 0.7)",zIndex:20,border:"1px solid white",animation:"popup 0.6s ease-out"}},"FREE",e.createElement("style",null,"\n @keyframes popup {\n 0% { transform: scale(0) rotate(-30deg); opacity: 0; }\n 70% { transform: scale(1.3); }\n 100% { transform: scale(1); }\n }\n ")),t?.quantity>1&&e.createElement(f,{className:"yt-byob-tracker-quantity-badge",borderRadius:b},t.quantity,"x")),e.createElement(w,{className:"yt-byob-tracker-info-block"},e.createElement(v,{className:"yt-byob-tracker-product-title"},t.product.title),e.createElement(T,{className:"yt-byob-tracker-product-price"},u,o(n?.node?.price)),e.createElement(k,{className:"yt-byob-tracker-remove-detailed-btn",onClick:()=>d(t.variantId,p),style:{...1===s.minimumQuantity&&1===s.products.length&&1===a[p]?.length?{display:"none"}:{}}},e.createElement(i,null),e.createElement("span",null,"Remove")))):e.createElement("div",{className:"yt-byob-tracker-product-item",key:t.variantId},e.createElement(W,{className:"yt-byob-tracker-product-list-item",isMobile:r,borderRadius:b,imageUrl:n?.node.image?.url&&n?.node.image?.url?.length>0?n?.node.image.url:t.product.featuredMedia?.preview?.image?.url,style:{borderRadius:b||"12px"}},t?.isFree&&e.createElement("div",{style:{position:"absolute",top:4,left:4,background:"linear-gradient(135deg, #ff0080, #ff4d4d)",color:"white",fontWeight:900,fontSize:"8px",padding:"4px 6px",borderRadius:"8px",letterSpacing:"1.5px",textTransform:"uppercase",boxShadow:"0 6px 20px rgba(255, 0, 128, 0.7)",zIndex:20,border:"1px solid white",animation:"popup 0.6s ease-out"}},e.createElement(V,null),e.createElement("style",null,"\n @keyframes popup {\n 0% { transform: scale(0) rotate(-30deg); opacity: 0; }\n 70% { transform: scale(1.3); }\n 100% { transform: scale(1); }\n }\n ")),l>1&&e.createElement(f,{className:"yt-byob-tracker-quantity-badge",borderRadius:b},l,"x"),e.createElement(k,{className:"yt-byob-tracker-remove-btn",onClick:()=>d(t.variantId,p),style:{...1===s.minimumQuantity&&1===s.products.length&&1===a[p]?.length?{display:"none"}:{}}},e.createElement(c,{fontSize:"12px"}))))}),y>=1&&[...Array(y)].map((t,a)=>e.createElement(C,{className:"yt-byob-tracker-placeholder-box",isMobile:r,borderRadius:b,key:a},e.createElement(n,{size:40,color:"#A0A0A0"}))))),p<t.length-1&&e.createElement(X,{className:"yt-byob-tracker-plus-icon-container"},e.createElement(n,{size:"16px",style:{backgroundColor:"#f2f2f2"}})))})),j=({builderTiers:W,handleAddToCart:q,minimumQuantity:X,selectedProducts:V,showProductDetailsInTracker:j,loading:O,handleRemoveItem:L,percentageOff:U,selectedItemsQuantity:Y,bundleSubtotal:$,amountOff:G,styles:J,dealAmount:K,isMobile:Z=!1,themeColor:_,cornerRadiusType:ee,primaryTextColorCta:te,handleRemoveItemProductTier:re,selectedProductsByTier:ae,storeCurrencyCode:oe})=>{const[ne,le]=t(!1),[ie,ce]=t(0),[se,me]=t([]),[de,be]=t(0),[ue,pe]=t(0),[ye,xe]=t(!1),[ge,fe]=t(null),ke=$?.price||0,Ee=W?.type,he=e=>{if(e<0||!se[e])return ke;const t=se[e].discountValue??0;return U?ke*(1-t/100):K?t:G?ke-t:ke};r(()=>{if(W&&"none"!==W.type)if("productTier"===Ee&&W.productTier){const e=W.productTier||[];me(e);let t=0;W.productTier.map(e=>{t+=e.minimumQuantity}),pe(t-Y)}else if(se.length)de>0&&Y<se[de-1]?.minimumQuantity?(be(de-1),fe(de-1)):Y<se[de]?.minimumQuantity&&fe(de-1),ce(he(de));else{const e=W.offerTier||[];me(e),be(0),pe(e[0]?.minimumQuantity-Y||X-Y)}else me([]),pe(X-Y),be(0)},[W,X,Y]),r(()=>{se.length&&"productTier"!=Ee?(()=>{if(!se?.length)return;let e=-1,t=null,r=0;if("offerTier"===Ee)for(let a=0;a<se.length&&(r+=se[a].minimumQuantity,Y>=r);a++)t=a,e=a+1<se.length?a+1:a;if(be(e),fe(t),null!==t){let e=se.slice(0,t+1).reduce((e,t)=>e+t.minimumQuantity,0);xe(e===Y),le(!0),ce(he(t))}else xe(!1),le(!1),ce(ke);const a=e>=0&&e<se.length?se.slice(0,e+1).reduce((e,t)=>e+t.minimumQuantity,0)-Y:se[0].minimumQuantity-Y;pe(a)})():Y===X?(le(!0),ce(U?ke*(1-U/100):K||(G?ke-G:ke)),xe(!0)):(xe(!1),le(!1))},[Y,se]);const Ne=ne?Math.max($?.compareAtPrice,$?.price):$?.compareAtPrice>$?.price?$?.compareAtPrice:null,we=ne?ie.toFixed(2):$?.price?.toFixed(2),ve=Ne&&we?(Ne-Number(we)).toFixed(2):0,Te=W&&"none"!==Ee&&W.offerTier?"offerTier"===Ee?Math.min(Y/(Y+ue)*100,100):void 0:Y/X*100;r(()=>{if(ne&&J.byob.enableConfetti){console.log("remainingItems",ue);const e=document.getElementById("checkoutButton");if(!e)return;const t=e.getBoundingClientRect(),r=(t.left+t.width/2)/window.innerWidth,a=(t.top+t.height/2)/window.innerHeight;H({particleCount:100,spread:70,origin:{x:r,y:a},zIndex:9999})}},[ne,J]),de>=0&&de<se.length&&se[de].tier;const Ie=e.useMemo(()=>null!==ge&&se[ge+1]?se[ge+1]?.customText||"":W?.offerTier?.[0]?.customText||"",[ge,se,W]),Ce="number"==typeof ge?se[ge]?.customText:void 0,Se="string"==typeof Ce&&""!==Ce.trim();return e.createElement(s,{className:"yt-byob-tracker-container bundle-builder-tracker-container "+(Z?"yt-byob-tracker-mobile":"yt-byob-tracker-desktop"),isMobile:Z,style:{justifyContent:J.byob.selectedProductsVisibility&&!Z?"space-between":"center"}},"offerTier"==Ee&&null!==ge&&ge>=0&&e.createElement(m,{className:"yt-byob-tracker-offer-tier-tag"},Se?e.createElement(e.Fragment,null,Ce," unlocked"):e.createElement(e.Fragment,null,e.createElement(e.Fragment,null,"Buy"," ",se.slice(0,ge+1).reduce((e,t)=>e+t.minimumQuantity,0)," ","at",G||K?e.createElement(e.Fragment,null," ",a(J.general.currencySymbol,oe)):""," ",o(se[ge]?.discountValue),U?e.createElement(e.Fragment,null,"% "):o(K)?e.createElement(e.Fragment,null):"",U||G?e.createElement(e.Fragment,null," Off"):""),e.createElement("span",{style:{fontStyle:"italic"}}," applied"))),Z&&ue>=1&&!ye&&"offerTier"!==Ee?e.createElement(d,{className:"yt-byob-tracker-mobile-remaining",style:{margin:"0"}},"Select ",ue," more item(s)"):e.createElement(e.Fragment,null),"productTier"!==Ee&&e.createElement(b,{className:"yt-byob-tracker-tier-progress-container"},e.createElement(u,{className:"yt-byob-tracker-tier-progress-text"},"offerTier"==Ee&&se.length>0&&ue>0&&e.createElement(e.Fragment,null,Ie?e.createElement("div",{className:"yt-byob-tracker-add-more-text",style:{padding:"4px",fontWeight:"600",...window.innerWidth<=768&&{fontSize:"12px"},color:"#121212"}},"Add ",ue," more to unlock"," ",Ie):e.createElement(e.Fragment,null,e.createElement("div",{className:"yt-byob-tracker-add-more-text",style:{padding:"4px",fontWeight:"600",...window.innerWidth<=768&&{fontSize:"12px"},color:"#121212"}},"Add ",ue," More Item(s)",e.createElement("span",{style:{fontWeight:"500"}}," to "),"Buy ",Y+ue," at "," ",G||K?e.createElement(e.Fragment,null,a(J.general.currencySymbol,oe)):""," ",o(se[de>=0?de:0]?.discountValue),U?e.createElement(e.Fragment,null,"% "):o(K)?e.createElement(e.Fragment,null):"",U||G?e.createElement(e.Fragment,null," Off"):"")))),e.createElement(p,{className:"yt-byob-tracker-progress-bar-bg"},e.createElement(y,{className:"yt-byob-tracker-progress-bar-fill bundle-builder-tracker-progress",progressPercentage:Te??0,primaryColor:_??J?.general.primaryColor}," "))),J.byob.selectedProductsVisibility&&e.createElement(x,{className:"yt-byob-tracker-product-list-wrapper hide-tracker-scrollbar "+(Z?"yt-byob-tracker-mobile-product-list":"yt-byob-tracker-desktop-product-list"),tierType:Ee??"",isMobile:Z},"productTier"===Ee?e.createElement(D,{tiers:se,isMobile:Z,selectedProductsByTier:ae??{},selectedProducts:V,themeColor:J.general.primaryColor,showProductDetailsInTracker:j,handleRemoveItemProductTier:re,cornerRadius:J.byob.borderRadius,currencySymbol:a(J.general.currencySymbol,oe)}):e.createElement(e.Fragment,null,V?.map?.(t=>{const r=t.product.variants?.edges?.find(e=>e.node.id===t.variantId);return j?e.createElement(E,{className:"yt-byob-tracker-detailed-item-container",borderRadius:J.byob.borderRadius,key:t.variantId},e.createElement(h,{className:"yt-byob-tracker-detailed-image",style:{backgroundImage:`url(${r?.node.image?.url&&r?.node.image?.url?.length>0?r?.node.image.url:t.product.featuredMedia?.preview?.image?.url})`}},t?.quantity>1&&e.createElement(N,{className:"yt-byob-tracker-badge"},t.quantity,"x")),e.createElement(w,{className:"yt-byob-tracker-info-block"},e.createElement(v,{className:"yt-byob-tracker-product-title"},t.product.title),e.createElement(T,{className:"yt-byob-tracker-product-price"},J.general.currencySymbol,r?.node?.price),e.createElement(I,{className:"yt-byob-tracker-remove-link",onClick:()=>L(t.variantId)},e.createElement(i,null),e.createElement("span",null,"Remove")))):e.createElement("div",{className:"yt-byob-tracker-product-item",key:t.variantId},e.createElement(g,{className:"yt-byob-tracker-item bundle-builder-tracker-item",isMobile:Z,borderRadius:J.byob.borderRadius,imageUrl:r?.node.image?.url&&r?.node.image?.url?.length>0?r?.node.image.url:t.product.featuredMedia?.preview?.image?.url},t?.quantity>1&&e.createElement(f,{className:"yt-byob-tracker-quantity-badge",borderRadius:J.byob.borderRadius},t.quantity,"x"),e.createElement(k,{className:"yt-byob-tracker-remove-btn",onClick:()=>L(t.variantId)},e.createElement(c,{fontSize:"12px"}))))}),ue>=1&&[...Array(ue)].map((t,r)=>e.createElement(C,{className:"yt-byob-tracker-placeholder-box",isMobile:Z,borderRadius:J.byob.borderRadius,key:r},e.createElement(n,{size:40,color:"#A0A0A0"}))))),(!Z||ye)&&e.createElement(S,{className:"yt-byob-tracker-summary-container bundle-summary "+(Z?"yt-byob-tracker-mobile-summary":"yt-byob-tracker-desktop-summary"),isMobile:Z},Number(we)>0&&e.createElement(R,{className:"yt-byob-tracker-summary-info summary-info"},e.createElement("div",{className:"yt-byob-tracker-summary-info-content",style:{display:"flex",...window.innerWidth<=600&&{flexDirection:"column"},gap:"5px",justifyContent:"center"}},Z?e.createElement("div",{className:"yt-byob-tracker-mobile-subtotal-row",style:{display:"flex",flexDirection:"row",gap:"6px",alignItems:"center"}},e.createElement(z,{className:"yt-byob-tracker-subtotal-label"},"Subtotal"),Number(ve)>0&&e.createElement(F,{className:"yt-byob-tracker-save-label",style:{}},"Save:"," ",a(J.general.currencySymbol,oe),o(ve))):e.createElement(e.Fragment,null,e.createElement(z,{className:"yt-byob-tracker-subtotal-label"},"Subtotal"),Number(ve)>0&&!Z&&e.createElement(F,{className:"yt-byob-tracker-save-label"},"Save:"," ",a(J.general.currencySymbol,oe),o(ve)))),e.createElement(B,{className:"yt-byob-tracker-subtotal-row"},e.createElement(M,{className:"yt-byob-tracker-final-price"},a(J.general.currencySymbol,oe),Number(we)>=0?o(Number(we).toFixed(2)):0),Ne&&J.byob.compareAtPriceVisibility&&Number(Ne)>Number(we)&&e.createElement(A,{className:"yt-byob-tracker-line-through-price"},a(J.general.currencySymbol,oe),o(Number(Ne).toFixed(2))))),e.createElement(P,{className:"yt-byob-tracker-checkout-button yt-tracking-bar-checkout-button",canCheckout:ye,progressPercentage:Te??0,ctaColors:{ctaBackgroundColor:J.general.ctaBackgroundColor,ctaBorderColor:J.general.ctaBorderColor,ctaHoverBackgroundColor:J.general.ctaHoverBackgroundColor,ctaHoverTextColor:J.general.ctaHoverTextColor},borderRadius:J.general.ctaBorderRadius,disabled:!ye&&ue>=1,onClick:e=>{O||console.log("saving"),q(e.target??e.currentTarget)},id:"checkoutButton"},O?e.createElement(l,{color:"white",loading:O,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):ue>=1&&!ye?e.createElement("div",{className:"yt-byob-tracker-add-more-btn-text yt-tracking-bar-checkout-button-items-text",style:{color:J.general.primaryColor}},"Add ",ue," More Item(s)"):e.createElement(Q,{className:"yt-byob-tracker-checkout-text yt-tracking-bar-checkout-button-text",ctaTextColor:J.general.ctaTextColor,ctaHoverTextColor:te??J.general.ctaHoverTextColor},J.byob.checkoutCTAText??"Checkout"))))},O={8087437412:{position:"fixed",bottom:"10px",zIndex:100,width:"95%",left:"50%",transform:"translateX(-50%)",mobile:{bottom:"50px"}},66134737152:{position:"fixed",zIndex:20,width:"90%",left:"50%",transform:"translateX(-50%)",bottom:"10px"},83438567714:{zIndex:100,position:"fixed",width:"95%",left:"50%",transform:"translateX(-50%)",bottom:"10px"},72726479068:{position:"fixed",zIndex:20,width:"90%",left:"50%",transform:"translateX(-50%)",bottom:"10px",mobile:{bottom:"70px"}},64800161992:{zIndex:20,mobile:{bottom:"50px"},position:"sticky",bottom:"10px"},53933408435:{zIndex:5,mobile:{bottom:"60px"},position:"sticky",bottom:"10px"},68377018594:{zIndex:5,bottom:"10px",position:"fixed",left:"50%",transform:"translateX(-50%)",mobile:{bottom:"70px"}},84569063743:{zIndex:999,bottom:"0px",width:"100%",position:"fixed",right:"0px",left:"0px"},62022680789:{bottom:"65px",zIndex:999,width:"100%",position:"fixed",right:"0px",left:"0px"},63102222549:{position:"sticky",bottom:"100px",zIndex:999,mobile:{bottom:"60px"}},26666008755:{bottom:"10px",zIndex:999,position:"fixed",left:"50%",transform:"translateX(-50%)"},67641475285:{bottom:"10px",zIndex:999,position:"fixed",left:"50%",transform:"translateX(-50%)"},61613179125:{position:"fixed",left:"50%",transform:"translateX(-50%)"},80866345280:{bottom:"10px",mobile:{bottom:"70px"}}},L={position:"sticky",bottom:"10px",zIndex:999,width:"96%"},U=a=>{const[o,n]=t(!1);r(()=>{const e=()=>{n(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const l="undefined"!=typeof window?(window?.ytapp||window?.ytBundleApp)?.storeId:void 0,i=((e,t=!1)=>{const r=e&&O[e]?O[e]:{},a={...L,...r};return t&&r.mobile?{...a,...r.mobile}:a})(String(l),o);a.renderingOnPage||(i.position="static",i.zIndex=0);const c={display:"flex",backgroundColor:"white",borderRadius:"4px",paddingBottom:"5px",justifyContent:"center",margin:"0 auto",transition:"box-shadow 0.3s ease, transform 0.3s ease",border:"1px solid #CBCBCB",boxShadow:"\n 0px 3px 6px 0px #00000040, \n 0px 11px 11px 0px #00000036, \n 0px 24px 14px 0px #00000021, \n 0px 43px 17px 0px #0000000A, \n 0px 68px 19px 0px #00000000\n ",...i};return e.createElement("div",{className:"yt-byob-tracker-bar yt-bundle-builder-tracker-bar "+(o?"yt-byob-tracker-mobile-bar":"yt-byob-tracker-desktop-bar"),style:{...c,width:o?"100%":i.width,...!a.styles.byob.selectedProductsVisibility&&{width:o?"96%":"fit-content",paddingInline:"10px"},...o&&{display:"flex",flexDirection:"row",paadingTop:"0px"}},onMouseEnter:e=>{e.currentTarget.style.boxShadow="\n 0px 8px 16px 0px #00000040, \n 0px 24px 24px 0px #00000036, \n 0px 50px 30px 0px #00000021, \n 0px 90px 36px 0px #0000000A, \n 0px 140px 40px 0px #00000000\n ",e.currentTarget.style.transform="translateX(-50%)"===i.transform?"translate(-50%, -3px)":"translateY(-3px)"},onMouseLeave:e=>{e.currentTarget.style.boxShadow="\n 0px 5px 12px 0px #00000040, \n 0px 22px 22px 0px #00000036, \n 0px 49px 29px 0px #00000021, \n 0px 87px 35px 0px #0000000A, \n 0px 136px 38px 0px #00000000\n ",e.currentTarget.style.transform=i.transform||"translateY(0)"}},e.createElement(j,{...a,isMobile:o}))};export{U as BundleBuilderTrackerBar,U as default};
1
+ import e,{useState as t,useEffect as r}from"react";import{getCurrencySymbol as a,currencyPrice as o}from"../Bundle.js";import{BiPlus as n}from"react-icons/bi";import{ClipLoader as l}from"react-spinners";import{FiTrash as i}from"react-icons/fi";import{RxMinus as c}from"react-icons/rx";import"../bundle.scss.js";import{Container as s,OfferTierTag as m,MobileRemaining as d,TierProgressContainer as b,TierProgressText as u,TierProgressBarBackground as p,TierProgressBarFill as y,ProductListWrapper as x,BundleBuilderTrackerItem as g,QuantityBadge as f,RemoveButton as k,DetailedItemContainer as E,DetailedImage as h,Badge as N,InfoBlock as w,ProductTitle as v,ProductPrice as T,RemoveLink as I,PlaceholderBox as C,SummaryContainer as S,SummaryInfo as R,SubtotalLabel as z,SaveLabel as F,SubtotalRow as B,FinalPrice as M,LineThroughPrice as A,CheckoutButton as P,CheckoutText as Q,ProductListTrackerItem as W,DetailedProductItem as q,PlusIconContainer as X}from"./bundleBuilderTracker.style.js";import H from"canvas-confetti";import{GrGift as V}from"react-icons/gr";const j=({tiers:t,isMobile:r=!1,selectedProductsByTier:a,selectedProducts:l,themeColor:s,showProductDetailsInTracker:m,handleRemoveItemProductTier:d,cornerRadius:b,currencySymbol:u})=>e.createElement(e.Fragment,null,t.map((s,p)=>{const y=s.minimumQuantity-(a[p]?.length??0),x=l?.filter(e=>a[p]?.includes(e.variantId));return Math.min(a[p]?.length/s.minimumQuantity*100,100),e.createElement("div",{className:"yt-byob-tracker-product-list-tier-wrapper",style:{display:"flex",width:"100%"}},e.createElement("div",{className:"yt-byob-tracker-product-list-tier-items"},e.createElement("div",{className:"yt-byob-tracker-product-list-items",style:{display:"flex",gap:"5px"}},x?.map?.(t=>{const n=t.product.variants?.edges?.find(e=>e.node.id===t.variantId),l=a[p]?.filter(e=>e===n?.node.id).length||0;return m?e.createElement(q,{className:"yt-byob-tracker-detailed-product-item",key:t.variantId},e.createElement(h,{className:"yt-byob-tracker-detailed-image",style:{backgroundImage:`url(${n?.node.image?.url&&n?.node.image?.url?.length>0?n?.node.image.url:t.product.featuredMedia?.preview?.image?.url})`}},t?.isFree&&e.createElement("div",{style:{position:"absolute",bottom:4,left:"30%",background:"linear-gradient(135deg, #ff0080, #ff4d4d)",color:"white",fontWeight:900,fontSize:"8px",padding:"4px 6px",borderRadius:"40px",letterSpacing:"1.5px",textTransform:"uppercase",boxShadow:"0 6px 20px rgba(255, 0, 128, 0.7)",zIndex:20,border:"1px solid white",animation:"popup 0.6s ease-out"}},"FREE",e.createElement("style",null,"\n @keyframes popup {\n 0% { transform: scale(0) rotate(-30deg); opacity: 0; }\n 70% { transform: scale(1.3); }\n 100% { transform: scale(1); }\n }\n ")),t?.quantity>1&&e.createElement(f,{className:"yt-byob-tracker-quantity-badge",borderRadius:b},t.quantity,"x")),e.createElement(w,{className:"yt-byob-tracker-info-block"},e.createElement(v,{className:"yt-byob-tracker-product-title"},t.product.title),e.createElement(T,{className:"yt-byob-tracker-product-price"},u,o(n?.node?.price)),e.createElement(k,{className:"yt-byob-tracker-remove-detailed-btn",onClick:()=>d(t.variantId,p),style:{...1===s.minimumQuantity&&1===s.products.length&&1===a[p]?.length?{display:"none"}:{}}},e.createElement(i,null),e.createElement("span",null,"Remove")))):e.createElement("div",{className:"yt-byob-tracker-product-item",key:t.variantId},e.createElement(W,{className:"yt-byob-tracker-product-list-item",isMobile:r,borderRadius:b,imageUrl:n?.node.image?.url&&n?.node.image?.url?.length>0?n?.node.image.url:t.product.featuredMedia?.preview?.image?.url,style:{borderRadius:b||"12px"}},t?.isFree&&e.createElement("div",{style:{position:"absolute",top:4,left:4,background:"linear-gradient(135deg, #ff0080, #ff4d4d)",color:"white",fontWeight:900,fontSize:"8px",padding:"4px 6px",borderRadius:"8px",letterSpacing:"1.5px",textTransform:"uppercase",boxShadow:"0 6px 20px rgba(255, 0, 128, 0.7)",zIndex:20,border:"1px solid white",animation:"popup 0.6s ease-out"}},e.createElement(V,null),e.createElement("style",null,"\n @keyframes popup {\n 0% { transform: scale(0) rotate(-30deg); opacity: 0; }\n 70% { transform: scale(1.3); }\n 100% { transform: scale(1); }\n }\n ")),l>1&&e.createElement(f,{className:"yt-byob-tracker-quantity-badge",borderRadius:b},l,"x"),e.createElement(k,{className:"yt-byob-tracker-remove-btn",onClick:()=>d(t.variantId,p),style:{...1===s.minimumQuantity&&1===s.products.length&&1===a[p]?.length?{display:"none"}:{}}},e.createElement(c,{fontSize:"12px"}))))}),y>=1&&[...Array(y)].map((t,a)=>e.createElement(C,{className:"yt-byob-tracker-placeholder-box",isMobile:r,borderRadius:b,key:a},e.createElement(n,{size:40,color:"#A0A0A0"}))))),p<t.length-1&&e.createElement(X,{className:"yt-byob-tracker-plus-icon-container"},e.createElement(n,{size:"16px",style:{backgroundColor:"#f2f2f2"}})))})),D=({builderTiers:W,handleAddToCart:q,minimumQuantity:X,selectedProducts:V,showProductDetailsInTracker:D,loading:O,handleRemoveItem:L,percentageOff:U,selectedItemsQuantity:Y,bundleSubtotal:$,amountOff:G,styles:J,dealAmount:K,isMobile:Z=!1,themeColor:_,cornerRadiusType:ee,primaryTextColorCta:te,handleRemoveItemProductTier:re,selectedProductsByTier:ae,storeCurrencyCode:oe})=>{const[ne,le]=t(!1),[ie,ce]=t(0),[se,me]=t([]),[de,be]=t(0),[ue,pe]=t(0),[ye,xe]=t(!1),[ge,fe]=t(null),ke=$?.price||0,Ee=W?.type,he=e=>{if(e<0||!se[e])return ke;const t=se[e].discountValue??0;return U?ke*(1-t/100):K?t:G?ke-t:ke};r(()=>{if(W&&"none"!==W.type)if("productTier"===Ee&&W.productTier){const e=W.productTier||[];me(e);let t=0;W.productTier.map(e=>{t+=e.minimumQuantity}),pe(t-Y)}else if(se.length)de>0&&Y<se[de-1]?.minimumQuantity?(be(de-1),fe(de-1)):Y<se[de]?.minimumQuantity&&fe(de-1),ce(he(de));else{const e=W.offerTier||[];me(e),be(0),pe(e[0]?.minimumQuantity-Y||X-Y)}else me([]),pe(X-Y),be(0)},[W,X,Y]),r(()=>{se.length&&"productTier"!=Ee?(()=>{if(!se?.length)return;let e=-1,t=null,r=0;if("offerTier"===Ee)for(let a=0;a<se.length&&(r+=se[a].minimumQuantity,Y>=r);a++)t=a,e=a+1<se.length?a+1:a;if(be(e),fe(t),null!==t){let e=se.slice(0,t+1).reduce((e,t)=>e+t.minimumQuantity,0);xe(e===Y),le(!0),ce(he(t))}else xe(!1),le(!1),ce(ke);const a=e>=0&&e<se.length?se.slice(0,e+1).reduce((e,t)=>e+t.minimumQuantity,0)-Y:se[0].minimumQuantity-Y;pe(a)})():Y===X?(le(!0),ce(U?ke*(1-U/100):K||(G?ke-G:ke)),xe(!0)):(xe(!1),le(!1))},[Y,se]);const Ne=ne?Math.max($?.compareAtPrice,$?.price):$?.compareAtPrice>$?.price?$?.compareAtPrice:null,we=ne?ie.toFixed(2):$?.price?.toFixed(2),ve=Ne&&we?(Ne-Number(we)).toFixed(2):0,Te=W&&"none"!==Ee&&W.offerTier?"offerTier"===Ee?Math.min(Y/(Y+ue)*100,100):void 0:Y/X*100;r(()=>{if(ne&&J.byob.enableConfetti){console.log("remainingItems",ue);const e=document.getElementById("checkoutButton");if(!e)return;const t=e.getBoundingClientRect(),r=(t.left+t.width/2)/window.innerWidth,a=(t.top+t.height/2)/window.innerHeight;H({particleCount:100,spread:70,origin:{x:r,y:a},zIndex:9999})}},[ne,J]),de>=0&&de<se.length&&se[de].tier;const Ie=e.useMemo(()=>null!==ge&&se[ge+1]?se[ge+1]?.customText||"":W?.offerTier?.[0]?.customText||"",[ge,se,W]),Ce="number"==typeof ge?se[ge]?.customText:void 0,Se="string"==typeof Ce&&""!==Ce.trim();return e.createElement(s,{className:"yt-byob-tracker-container bundle-builder-tracker-container "+(Z?"yt-byob-tracker-mobile":"yt-byob-tracker-desktop"),isMobile:Z,style:{justifyContent:J.byob.selectedProductsVisibility&&!Z?"space-between":"center"}},"offerTier"==Ee&&null!==ge&&ge>=0&&e.createElement(m,{className:"yt-byob-tracker-offer-tier-tag"},Se?e.createElement(e.Fragment,null,Ce," unlocked"):e.createElement(e.Fragment,null,e.createElement(e.Fragment,null,"Buy"," ",se.slice(0,ge+1).reduce((e,t)=>e+t.minimumQuantity,0)," ","at",G||K?e.createElement(e.Fragment,null," ",a(J.general.currencySymbol,oe)):""," ",o(se[ge]?.discountValue),U?e.createElement(e.Fragment,null,"% "):o(K)?e.createElement(e.Fragment,null):"",U||G?e.createElement(e.Fragment,null," Off"):""),e.createElement("span",{style:{fontStyle:"italic"}}," applied"))),Z&&ue>=1&&!ye&&"offerTier"!==Ee?e.createElement(d,{className:"yt-byob-tracker-mobile-remaining",style:{margin:"0"}},"Select ",ue," more item(s)"):e.createElement(e.Fragment,null),"productTier"!==Ee&&e.createElement(b,{className:"yt-byob-tracker-tier-progress-container"},e.createElement(u,{className:"yt-byob-tracker-tier-progress-text"},"offerTier"==Ee&&se.length>0&&ue>0&&e.createElement(e.Fragment,null,Ie?e.createElement("div",{className:"yt-byob-tracker-add-more-text",style:{padding:"4px",fontWeight:"600",...window.innerWidth<=768&&{fontSize:"12px"},color:"#121212"}},"Add ",ue," more to unlock"," ",Ie):e.createElement(e.Fragment,null,e.createElement("div",{className:"yt-byob-tracker-add-more-text",style:{padding:"4px",fontWeight:"600",...window.innerWidth<=768&&{fontSize:"12px"},color:"#121212"}},"Add ",ue," More Item(s)",e.createElement("span",{style:{fontWeight:"500"}}," to "),"Buy ",Y+ue," at "," ",G||K?e.createElement(e.Fragment,null,a(J.general.currencySymbol,oe)):""," ",o(se[de>=0?de:0]?.discountValue),U?e.createElement(e.Fragment,null,"% "):o(K)?e.createElement(e.Fragment,null):"",U||G?e.createElement(e.Fragment,null," Off"):"")))),e.createElement(p,{className:"yt-byob-tracker-progress-bar-bg"},e.createElement(y,{className:"yt-byob-tracker-progress-bar-fill bundle-builder-tracker-progress",progressPercentage:Te??0,primaryColor:_??J?.general.primaryColor}," "))),J.byob.selectedProductsVisibility&&e.createElement(x,{className:"yt-byob-tracker-product-list-wrapper hide-tracker-scrollbar "+(Z?"yt-byob-tracker-mobile-product-list":"yt-byob-tracker-desktop-product-list"),tierType:Ee??"",isMobile:Z},"productTier"===Ee?e.createElement(j,{tiers:se,isMobile:Z,selectedProductsByTier:ae??{},selectedProducts:V,themeColor:J.general.primaryColor,showProductDetailsInTracker:D,handleRemoveItemProductTier:re,cornerRadius:J.byob.borderRadius,currencySymbol:a(J.general.currencySymbol,oe)}):e.createElement(e.Fragment,null,V?.map?.(t=>{const r=t.product.variants?.edges?.find(e=>e.node.id===t.variantId);return D?e.createElement(E,{className:"yt-byob-tracker-detailed-item-container",borderRadius:J.byob.borderRadius,key:t.variantId},e.createElement(h,{className:"yt-byob-tracker-detailed-image",style:{backgroundImage:`url(${r?.node.image?.url&&r?.node.image?.url?.length>0?r?.node.image.url:t.product.featuredMedia?.preview?.image?.url})`}},t?.quantity>1&&e.createElement(N,{className:"yt-byob-tracker-badge"},t.quantity,"x")),e.createElement(w,{className:"yt-byob-tracker-info-block"},e.createElement(v,{className:"yt-byob-tracker-product-title"},t.product.title),e.createElement(T,{className:"yt-byob-tracker-product-price"},J.general.currencySymbol,r?.node?.price),e.createElement(I,{className:"yt-byob-tracker-remove-link",onClick:()=>L(t.variantId)},e.createElement(i,null),e.createElement("span",null,"Remove")))):e.createElement("div",{className:"yt-byob-tracker-product-item",key:t.variantId},e.createElement(g,{className:"yt-byob-tracker-item bundle-builder-tracker-item",isMobile:Z,borderRadius:J.byob.borderRadius,imageUrl:r?.node.image?.url&&r?.node.image?.url?.length>0?r?.node.image.url:t.product.featuredMedia?.preview?.image?.url},t?.quantity>1&&e.createElement(f,{className:"yt-byob-tracker-quantity-badge",borderRadius:J.byob.borderRadius},t.quantity,"x"),e.createElement(k,{className:"yt-byob-tracker-remove-btn",onClick:()=>L(t.variantId)},e.createElement(c,{fontSize:"12px"}))))}),ue>=1&&[...Array(ue)].map((t,r)=>e.createElement(C,{className:"yt-byob-tracker-placeholder-box",isMobile:Z,borderRadius:J.byob.borderRadius,key:r},e.createElement(n,{size:40,color:"#A0A0A0"}))))),(!Z||ye)&&e.createElement(S,{className:"yt-byob-tracker-summary-container bundle-summary "+(Z?"yt-byob-tracker-mobile-summary":"yt-byob-tracker-desktop-summary"),isMobile:Z},Number(we)>0&&e.createElement(R,{className:"yt-byob-tracker-summary-info summary-info"},e.createElement("div",{className:"yt-byob-tracker-summary-info-content",style:{display:"flex",...window.innerWidth<=600&&{flexDirection:"column"},gap:"5px",justifyContent:"center"}},Z?e.createElement("div",{className:"yt-byob-tracker-mobile-subtotal-row",style:{display:"flex",flexDirection:"row",gap:"6px",alignItems:"center"}},e.createElement(z,{className:"yt-byob-tracker-subtotal-label"},"Subtotal"),Number(ve)>0&&e.createElement(F,{className:"yt-byob-tracker-save-label",style:{}},"Save:"," ",a(J.general.currencySymbol,oe),o(ve))):e.createElement(e.Fragment,null,e.createElement(z,{className:"yt-byob-tracker-subtotal-label"},"Subtotal"),Number(ve)>0&&!Z&&e.createElement(F,{className:"yt-byob-tracker-save-label"},"Save:"," ",a(J.general.currencySymbol,oe),o(ve)))),e.createElement(B,{className:"yt-byob-tracker-subtotal-row"},e.createElement(M,{className:"yt-byob-tracker-final-price"},a(J.general.currencySymbol,oe),Number(we)>=0?o(Number(we).toFixed(2)):0),Ne&&J.byob.compareAtPriceVisibility&&Number(Ne)>Number(we)&&e.createElement(A,{className:"yt-byob-tracker-line-through-price"},a(J.general.currencySymbol,oe),o(Number(Ne).toFixed(2))))),e.createElement(P,{className:"yt-byob-tracker-checkout-button yt-tracking-bar-checkout-button",canCheckout:ye,progressPercentage:Te??0,ctaColors:{ctaBackgroundColor:J.general.ctaBackgroundColor,ctaBorderColor:J.general.ctaBorderColor,ctaHoverBackgroundColor:J.general.ctaHoverBackgroundColor,ctaHoverTextColor:J.general.ctaHoverTextColor},borderRadius:J.general.ctaBorderRadius,disabled:!ye&&ue>=1,onClick:e=>{O||console.log("saving"),q(e.target??e.currentTarget)},id:"checkoutButton"},O?e.createElement(l,{color:"white",loading:O,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):ue>=1&&!ye?e.createElement("div",{className:"yt-byob-tracker-add-more-btn-text yt-tracking-bar-checkout-button-items-text",style:{color:J.general.primaryColor}},"Add ",ue," More Item(s)"):e.createElement(Q,{className:"yt-byob-tracker-checkout-text yt-tracking-bar-checkout-button-text",ctaTextColor:J.general.ctaTextColor,ctaHoverTextColor:te??J.general.ctaHoverTextColor},J.byob.checkoutCTAText??"Checkout"))))},O={8087437412:{position:"fixed",bottom:"10px",zIndex:100,width:"95%",left:"50%",transform:"translateX(-50%)",mobile:{bottom:"50px"}},66134737152:{position:"fixed",zIndex:20,width:"90%",left:"50%",transform:"translateX(-50%)",bottom:"10px"},83438567714:{zIndex:100,position:"fixed",width:"95%",left:"50%",transform:"translateX(-50%)",bottom:"10px"},72726479068:{position:"fixed",zIndex:20,width:"90%",left:"50%",transform:"translateX(-50%)",bottom:"10px",mobile:{bottom:"70px"}},64800161992:{zIndex:20,mobile:{bottom:"50px"},position:"sticky",bottom:"10px"},53933408435:{zIndex:5,mobile:{bottom:"60px"},position:"sticky",bottom:"10px"},68377018594:{zIndex:5,bottom:"10px",position:"fixed",left:"50%",transform:"translateX(-50%)",mobile:{bottom:"70px"}},84569063743:{zIndex:999,bottom:"0px",width:"100%",position:"fixed",right:"0px",left:"0px"},62022680789:{bottom:"65px",zIndex:999,width:"100%",position:"fixed",right:"0px",left:"0px"},63102222549:{position:"sticky",bottom:"100px",zIndex:999,mobile:{bottom:"60px"}},26666008755:{bottom:"10px",zIndex:999,position:"fixed",left:"50%",transform:"translateX(-50%)"},67641475285:{bottom:"10px",zIndex:999,position:"fixed",left:"50%",transform:"translateX(-50%)"},61613179125:{position:"fixed",left:"50%",transform:"translateX(-50%)"},80866345280:{bottom:"10px",mobile:{bottom:"70px"}}},L={position:"sticky",bottom:"10px",zIndex:999,width:"96%"},U=a=>{const[o,n]=t(!1);r(()=>{const e=()=>{n(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const l="undefined"!=typeof window?(window?.ytapp||window?.ytBundleApp)?.storeId:void 0,i=((e,t=!1)=>{const r=e&&O[e]?O[e]:{},a={...L,...r};return t&&r.mobile?{...a,...r.mobile}:a})(String(l),o);a.renderingOnPage||(i.position="static",i.zIndex=0);const c={display:"flex",backgroundColor:"white",borderRadius:"4px",paddingBottom:"5px",justifyContent:"center",margin:"0 auto",transition:"box-shadow 0.3s ease, transform 0.3s ease",border:"1px solid #CBCBCB",boxShadow:"\n 0px 3px 6px 0px #00000040, \n 0px 11px 11px 0px #00000036, \n 0px 24px 14px 0px #00000021, \n 0px 43px 17px 0px #0000000A, \n 0px 68px 19px 0px #00000000\n ",...i};return e.createElement("div",{className:"yt-byob-tracker-bar yt-bundle-builder-tracker-bar "+(o?"yt-byob-tracker-mobile-bar":"yt-byob-tracker-desktop-bar"),style:{...c,width:o?"100%":i.width,...!a.styles.byob.selectedProductsVisibility&&{width:o?"96%":"fit-content",paddingInline:"10px"},...o&&{display:"flex",flexDirection:"row",paadingTop:"0px"}},onMouseEnter:e=>{e.currentTarget.style.boxShadow="\n 0px 8px 16px 0px #00000040, \n 0px 24px 24px 0px #00000036, \n 0px 50px 30px 0px #00000021, \n 0px 90px 36px 0px #0000000A, \n 0px 140px 40px 0px #00000000\n ",e.currentTarget.style.transform="translateX(-50%)"===i.transform?"translate(-50%, -3px)":"translateY(-3px)"},onMouseLeave:e=>{e.currentTarget.style.boxShadow="\n 0px 5px 12px 0px #00000040, \n 0px 22px 22px 0px #00000036, \n 0px 49px 29px 0px #00000021, \n 0px 87px 35px 0px #0000000A, \n 0px 136px 38px 0px #00000000\n ",e.currentTarget.style.transform=i.transform||"translateY(0)"}},e.createElement(D,{...a,isMobile:o}))};export{U as BundleBuilderTrackerBar,U as default};
@@ -1 +1 @@
1
- import{useAtom as e}from"jotai";import t,{forwardRef as o,useMemo as a,useState as l,useEffect as n}from"react";import{FaTimes as r}from"react-icons/fa";import i from"react-dom";import s from"react-modal-image";import{BsChevronDown as c,BsXLg as d}from"react-icons/bs";import{IoIosStar as m}from"react-icons/io";import{MdVerified as y}from"react-icons/md";import{optimiseImage as p,getCurrencySymbol as b,currencyPrice as g}from"../Bundle.js";import{bundleBuilderProductDetailsState as u}from"../../../atoms/bundleBuilderProductDetailsAtom.js";import{ModalOverlay as x,ModalContent as f,BundlProductDetailsModalContainer as h,CloseButton as v}from"./bundleProductDetailsModal.style.js";const E=o((o,E)=>{const[w,N]=e(u),k=a(()=>e=>{const t=o?.customVariantsQuantity?.find(t=>t.variantId===e?.id)?.quantity;return void 0!==t?t:o?.bundleProductsCustomQuantity?o?.bundleProductsCustomQuantity:e?w?.tracksInventory&&e.inventoryItem?.tracked?e.inventoryQuantity>0?e.inventoryQuantity:e.inventoryQuantity<=0&&"continue"===e.inventoryPolicy?1/0:0:1/0:0},[w?.tracksInventory,o?.customVariantsQuantity,o?.bundleProductsCustomQuantity]),C=w?.variants.edges?.filter(e=>k(e.node)>0)||[],[S,T]=l(C?.[0]?.node),[R,z]=l(0),[F,I]=l("undefined"!=typeof window&&window.innerWidth<=600),[P,B]=l(1),[D,A]=l("idle"),[j,W]=l(null),[L,H]=l(null);n(()=>{if(w){const e=w.variants.edges?.filter(e=>k(e.node)>0);T(w?.selectedVariant??e[0]?.node)}},[w,k]),n(()=>{const e=o.selectedProducts.find(e=>e.variantId===S?.id);B(e?e.quantity:0)},[P,o.selectedProducts,S]);const Q=()=>{S?.id&&w&&(A("check"),o.handleAddToBundle(S?.id,w,1),setTimeout(()=>{A("idle"),N(void 0)},500))};if(n(()=>{const e=()=>I(window.innerWidth<=600);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),!w)return null;const{title:$,descriptionHtml:M,media:q,variants:O}=w,V=q.edges.map(e=>e?.node.preview.image??e?.node.image).filter(e=>e?.url?.length>0);n(()=>{if(w&&S?.image?.url&&Array.isArray(V)){const e=V.findIndex(e=>e?.url===S?.image?.url);-1!==e&&e!==R&&z(e)}},[S]);const _=e=>{const t=e.target.value,o=C?.find(e=>e.node.id===t)?.node;o&&k(o)>0&&T(o)};n(()=>{if(w){window.history.pushState({modalOpen:!0},"",window.location.href);const e=e=>{N(void 0),e.preventDefault()};return window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e),window.history.state?.modalOpen&&window.history.back()}}},[w,N]);const X=e=>{W(e.targetTouches[0].clientX),H(null)},Y=e=>{H(e.targetTouches[0].clientX)},G=()=>{if(null!==j&&null!==L&&V.length>1){const e=j-L,t=50;e>t?z(e=>e<V.length-1?e+1:0):e<-t&&z(e=>e>0?e-1:V.length-1)}W(null),H(null)},J=o.selectedProducts.filter(e=>e.variantId===S?.id).reduce((e,t)=>e+t.quantity,0),K=o.customVariantsQuantity?.find(e=>e.variantId===S?.id)?.quantity??o.bundleProductsCustomQuantity??1/0,U=K!==1/0&&J>=K,Z=o.hideAddToBundle||!S||k(S)<=0||U||"idle"!==D||o?.disableQuantitySelector&&1===P,ee=t.createElement(x,{className:"yt-byob-modal-desktop-overlay"},t.createElement(f,{$isSmallScreen:F,ref:E},t.createElement(h,{ref:E,className:"yt-byob-modal-desktop-container yt-variant-selection-modal"},t.createElement("div",{className:"yt-byob-modal-desktop yt-variant-selection-modal "+(F?"small-screen":"large-screen")},t.createElement(v,{className:"yt-byob-modal-desktop-close",onClick:()=>{N(void 0)},style:{backgroundColor:"white"}},t.createElement(r,{size:"25"})),t.createElement("div",{className:"yt-byob-modal-desktop-image-section image-section"},t.createElement(t.Fragment,null,t.createElement("div",{className:"yt-byob-modal-desktop-image-swipe",onTouchStart:X,onTouchMove:Y,onTouchEnd:G},t.createElement(s,{small:p(V[R]?.url),medium:p(V[R]?.url),large:p(V[R]?.url),hideDownload:!0,className:"yt-byob-modal-desktop-main-image main-image",imageBackgroundColor:"#000"})),t.createElement("div",{className:"yt-byob-modal-desktop-image-gallery image-gallery",style:{display:"flex",flexDirection:"row",overflow:"auto",gap:"10px",scrollbarWidth:"none"}},V.length>1&&V.filter(e=>e?.url.length>0).map((e,a)=>t.createElement("img",{key:a,className:"yt-byob-modal-desktop-gallery-thumb "+(R===a?"active":""),src:p(e?.url),alt:e.altText||`${$} - Image ${a+1}`,onClick:()=>z(a),style:{width:"73px",height:"73px",cursor:"pointer",borderRadius:"7px",border:"1px solid lightgray",...R===a&&{border:`2px solid ${o.themeColor||"#111"}`},objectFit:"cover"},loading:"lazy"}))))),t.createElement("div",{className:"yt-byob-modal-desktop-details-section details-section",style:{marginLeft:"20px",minHeight:"100%",maxHeight:"70vh",scrollbarWidth:"none",overflowY:"auto",display:"flex",flexDirection:"column"}},t.createElement("h2",{className:"yt-byob-modal-desktop-title"},C.length>1?S?.displayName:w.title),"ratingOnly"===o.reviewRatingType&&(w?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-desktop-rating",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",t.createElement("span",{style:{marginLeft:6}},w?.rating?.averageRating,"rating")),"ratingAndReviewCount"===o.reviewRatingType&&(w?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-desktop-rating-count",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",w?.rating?.averageRating,t.createElement(y,{size:14,style:{color:"dodgerblue",marginLeft:"4px"}})," ","(",w?.rating?.ratingCount," reviews)"),t.createElement("div",{className:"yt-byob-modal-desktop-variant-price-wrapper",style:{display:"flex",flexDirection:"column",gap:"2px",marginTop:"20px"}},C.length>1&&t.createElement("div",{className:"yt-byob-modal-desktop-variant-selector"},t.createElement("div",{className:"yt-byob-modal-desktop-variant-label",style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",paddingBottom:"5px",fontSize:"16px",color:"#999",position:"relative",marginBottom:"10px"}},t.createElement("span",{style:{flexShrink:0}},w.options[0].name," :"," ",t.createElement("strong",{style:{color:"#000",paddingLeft:"5px"}},S?.title)),t.createElement("select",{className:"yt-byob-modal-desktop-variant-select",value:S?.id||"",onChange:_,style:{appearance:"none",border:"none",background:"transparent",fontWeight:"bold",color:"#000",cursor:"pointer",paddingRight:"20px",position:"absolute",right:0,top:0,bottom:0,width:"100%",opacity:0,zIndex:2}},C.map(({node:e})=>t.createElement("option",{key:e.id,value:e.id,disabled:0===k(e)},e.title))),t.createElement("span",{className:"yt-byob-modal-desktop-variant-chevron",style:{position:"absolute",right:5,pointerEvents:"none",fontSize:"12px",color:"#000"}},t.createElement(c,null)))),t.createElement("div",{className:"yt-byob-modal-desktop-price-atc-wrapper",style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"}},t.createElement("div",{className:"yt-byob-modal-desktop-price",style:{width:"fit-content",minWidth:"fit-content",paddingRight:"10px",display:"flex",flexDirection:"row",alignItems:"baseline",gap:"6px"}},o?.isFreebieTier&&!o.showFreebieTierProductPrices?t.createElement(t.Fragment,null,t.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"20px",textDecoration:"line-through",color:"#888",marginRight:"6px"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price)),t.createElement("span",{className:"yt-byob-current-price",style:{color:o.styles.general.primaryColor||"#d32f2f",fontWeight:"bold",fontSize:"20px"}},"FREE")):t.createElement(t.Fragment,null,t.createElement("div",{className:"yt-byob-modal-desktop-current-price"},t.createElement("span",{style:{fontSize:"20px",fontWeight:"600",color:"#000",textAlign:"center",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price))),S?.compareAtPrice&&parseFloat(S.compareAtPrice)>parseFloat(S?.price)&&t.createElement("div",{className:"yt-byob-modal-desktop-compare-price",style:{textDecoration:"line-through",opacity:"0.5",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.compareAtPrice)))),t.createElement("div",{className:"yt-byob-modal-desktop-atc-wrapper yt-product-modal-atc-wrapper",style:{width:"80%"}},t.createElement("button",{className:"yt-byob-modal-desktop-atc-button yt-product-modal-atc-button",style:{textTransform:"uppercase",fontWeight:"800",width:"100%",border:"none",backgroundColor:o.themeColor||"#111",borderRadius:o.cornerRadius,color:o.primaryTextColorCta||"#fff",minHeight:"40px",padding:"0px 15px",position:"relative",overflow:"hidden",opacity:Z?.5:1,cursor:Z?"not-allowed":"pointer"},onClick:e=>{e.stopPropagation(),e.preventDefault(),Q()},disabled:Z},o.styles.byob.addToBundleCTAText??"Add to bundle")))),t.createElement("div",{className:"yt-byob-modal-desktop-divider",style:{height:"10px",minHeight:"10px",border:"none",backgroundColor:"#D9D9D96B",margin:"20px 0 10px 0",display:"block !important"}},t.createElement("span",null)),t.createElement("span",{className:"yt-byob-modal-desktop-description yt-description-content",style:{scrollBehavior:"smooth"},dangerouslySetInnerHTML:{__html:M}})))))),te=t.createElement(x,{className:"yt-byob-modal-mobile-overlay"},t.createElement(f,{className:"yt-byob-modal-mobile-content",style:{padding:"0px",position:"relative"},$isSmallScreen:F,ref:E},t.createElement(h,{ref:E,className:"yt-byob-modal-mobile-container yt-variant-selection-modal"},t.createElement("button",{className:"yt-byob-modal-mobile-close-btn",style:{position:"fixed",top:"20px",right:"20px",zIndex:9999999999,backgroundColor:"#FFFFFF",padding:"4px",borderRadius:"50%",border:"1px solid lightgray",display:"flex",justifyContent:"center",alignItems:"center"},onClick:()=>{N(void 0)}},t.createElement(d,{className:"yt-byob-modal-mobile-close-icon",style:{height:"22px",width:"22px",padding:"4px",color:"black"},onMouseEnter:e=>e.currentTarget.style.color="black"})),t.createElement("div",{className:"yt-byob-modal-mobile yt-variant-selection-modal small-screen",style:{padding:"0px"}},t.createElement("div",{className:"yt-byob-modal-mobile-image-section image-section"},t.createElement(t.Fragment,null,t.createElement("div",{className:"yt-byob-modal-mobile-image-swipe",style:{position:"relative"},onTouchStart:X,onTouchMove:Y,onTouchEnd:G},t.createElement(s,{small:p(V[R]?.url),medium:p(V[R]?.url),large:p(V[R]?.url),hideDownload:!0,className:"yt-byob-modal-mobile-main-image main-image",imageBackgroundColor:"#000"}),t.createElement("div",{className:"yt-byob-modal-mobile-image-indicators",style:{position:"absolute",bottom:"20px",width:"100%",display:"flex",justifyContent:"center",alignItems:"center"}},V.length>1&&V.map((e,o)=>t.createElement("span",{key:o,className:"yt-byob-modal-mobile-indicator "+(R===o?"active":""),style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:R===o?"#FFFFFF":"#EBEBEB",margin:"0 3px",cursor:"pointer",backdropFilter:"blur(10px)"}})))),t.createElement("div",{className:"yt-byob-modal-mobile-image-gallery image-gallery",style:{display:"flex",flexDirection:"row",overflowX:"auto",padding:"5px 20px",gap:"5px",scrollbarWidth:"none"}},V.length>1&&V.map((e,a)=>t.createElement("img",{key:a,className:"yt-byob-modal-mobile-gallery-thumb "+(R===a?"active":""),src:p(e?.url),alt:e.altText||`${$} - Image ${a+1}`,onClick:()=>z(a),style:{width:"60px",height:"60px",cursor:"pointer",borderRadius:"7px",border:"1px solid lightgray",...R===a&&{border:`2px solid ${o.themeColor||"#111"}`},objectFit:"cover"},loading:"lazy"}))))),t.createElement("div",{className:"yt-byob-modal-mobile-details-section details-section",style:{padding:"0 30px",margin:"15px 0",paddingBottom:"120px"}},t.createElement("h2",{className:"yt-byob-modal-mobile-title",style:{margin:"0px"}},C.length>1?S?.displayName:w.title),"ratingOnly"===o.reviewRatingType&&(o?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-mobile-rating",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",t.createElement("span",{style:{marginLeft:6}},o?.rating?.averageRating," rating")),"ratingAndReviewCount"===o.reviewRatingType&&(o?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-mobile-rating-count",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",o?.rating?.averageRating,t.createElement(y,{className:"yt-byob-modal-mobile-verified-icon",style:{color:"dodgerblue",marginLeft:"4px"},size:14})," ","(",o?.rating?.ratingCount," reviews)"),t.createElement("div",{className:"yt-byob-modal-mobile-divider",style:{opacity:"0.2",border:"none",height:"2px",backgroundColor:"#000000",margin:"10px 0px",display:"block !important"}},t.createElement("span",null)),t.createElement("div",{className:"yt-byob-modal-mobile-description yt-description-content",style:{scrollbarWidth:"none",scrollBehavior:"smooth",margin:"0px"},dangerouslySetInnerHTML:{__html:M}})))),t.createElement("div",{className:"yt-byob-modal-mobile-bottom-bar",style:{position:"fixed",bottom:"0px",left:"0px",right:"0px",padding:"12px 15px",borderTop:"1px solid lightgray",boxShadow:"0px -4px 5px rgba(0, 0, 0, 0.1)",backgroundColor:"#fff",display:"flex",flexDirection:"column",gap:"2px",zIndex:9999999999}},C.length>1&&t.createElement("div",{className:"yt-byob-modal-mobile-variant-selector"},t.createElement("div",{className:"yt-byob-modal-mobile-variant-label",style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",paddingBottom:"5px",fontSize:"16px",color:"#999",position:"relative",margin:"10px 0"}},t.createElement("span",{style:{flexShrink:0}},w.options[0].name," :"," ",t.createElement("strong",{style:{color:"#000",paddingLeft:"5px"}},S?.title)),t.createElement("select",{className:"yt-byob-modal-mobile-variant-select",value:S?.id||"",onChange:_,style:{appearance:"none",border:"none",background:"transparent",fontWeight:"bold",color:"#000",cursor:"pointer",paddingRight:"20px",position:"absolute",right:0,top:0,bottom:0,width:"100%",opacity:0,zIndex:2}},C.map(({node:e})=>t.createElement("option",{key:e.id,value:e.id,disabled:0===k(e)},e.title))),t.createElement("span",{className:"yt-byob-modal-mobile-variant-chevron",style:{position:"absolute",right:5,pointerEvents:"none",fontSize:"12px",color:"#000"}},t.createElement(c,null)))),t.createElement("div",{className:"yt-byob-modal-mobile-price-atc-wrapper",style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"}},t.createElement("div",{className:"yt-byob-modal-mobile-price",style:{width:"fit-content",minWidth:"fit-content",display:"flex",flexDirection:"row",paddingRight:"10px",alignItems:"center"}},o?.isFreebieTier&&!o.showFreebieTierProductPrices?t.createElement(t.Fragment,null,t.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"20px",textDecoration:"line-through",color:"#888",marginRight:"6px"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price)),t.createElement("span",{className:"yt-byob-current-price",style:{color:o.styles.general.primaryColor||"#d32f2f",fontWeight:"bold",fontSize:"20px"}},"FREE")):t.createElement(t.Fragment,null,S?.compareAtPrice&&t.createElement("div",{className:"yt-byob-modal-mobile-compare-price",style:{textDecoration:"line-through",opacity:"0.5",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.compareAtPrice)),t.createElement("div",{className:"yt-byob-modal-mobile-current-price"},t.createElement("span",{style:{fontSize:"20px",fontWeight:"600",color:"#000",textAlign:"center",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price))))),t.createElement("div",{className:"yt-byob-modal-mobile-atc-wrapper",style:{width:"100%"}},t.createElement("button",{className:"yt-byob-modal-mobile-atc-button",style:{textTransform:"uppercase",fontWeight:"800",width:"100%",border:"none",backgroundColor:o.themeColor||"#111",borderRadius:o.cornerRadius,color:o.primaryTextColorCta||"#fff",minHeight:"40px",padding:"0px 15px",position:"relative",overflow:"hidden",opacity:Z?.5:1,cursor:Z?"not-allowed":"pointer"},onClick:e=>{e.stopPropagation(),e.preventDefault(),Q()},disabled:Z},o.styles.byob.addToBundleCTAText||"Add to Bundle"))))));return i.createPortal(F?te:ee,document.body)});export{E as default};
1
+ import{useAtom as e}from"jotai";import t,{forwardRef as o,useMemo as a,useState as l,useEffect as n}from"react";import{FaTimes as r}from"react-icons/fa";import i from"react-dom";import s from"react-modal-image";import{BsChevronDown as c,BsXLg as d}from"react-icons/bs";import{IoIosStar as m}from"react-icons/io";import{MdVerified as y}from"react-icons/md";import{optimiseImage as p,getCurrencySymbol as b,currencyPrice as g}from"../Bundle.js";import{bundleBuilderProductDetailsState as u}from"../../../atoms/bundleBuilderProductDetailsAtom.js";import{ModalOverlay as x,ModalContent as f,BundlProductDetailsModalContainer as h,CloseButton as v}from"./bundleProductDetailsModal.style.js";import"../bundle.scss.js";const E=o((o,E)=>{const[w,N]=e(u),k=a(()=>e=>{const t=o?.customVariantsQuantity?.find(t=>t.variantId===e?.id)?.quantity;return void 0!==t?t:o?.bundleProductsCustomQuantity?o?.bundleProductsCustomQuantity:e?w?.tracksInventory&&e.inventoryItem?.tracked?e.inventoryQuantity>0?e.inventoryQuantity:e.inventoryQuantity<=0&&"continue"===e.inventoryPolicy?1/0:0:1/0:0},[w?.tracksInventory,o?.customVariantsQuantity,o?.bundleProductsCustomQuantity]),C=w?.variants.edges?.filter(e=>k(e.node)>0)||[],[S,T]=l(C?.[0]?.node),[R,z]=l(0),[F,I]=l("undefined"!=typeof window&&window.innerWidth<=600),[P,B]=l(1),[D,A]=l("idle"),[j,W]=l(null),[L,H]=l(null);n(()=>{if(w){const e=w.variants.edges?.filter(e=>k(e.node)>0);T(w?.selectedVariant??e[0]?.node)}},[w,k]),n(()=>{const e=o.selectedProducts.find(e=>e.variantId===S?.id);B(e?e.quantity:0)},[P,o.selectedProducts,S]);const Q=()=>{S?.id&&w&&(A("check"),o.handleAddToBundle(S?.id,w,1),setTimeout(()=>{A("idle"),N(void 0)},500))};if(n(()=>{const e=()=>I(window.innerWidth<=600);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),!w)return null;const{title:$,descriptionHtml:M,media:q,variants:O}=w,V=q.edges.map(e=>e?.node.preview.image??e?.node.image).filter(e=>e?.url?.length>0);n(()=>{if(w&&S?.image?.url&&Array.isArray(V)){const e=V.findIndex(e=>e?.url===S?.image?.url);-1!==e&&e!==R&&z(e)}},[S]);const _=e=>{const t=e.target.value,o=C?.find(e=>e.node.id===t)?.node;o&&k(o)>0&&T(o)};n(()=>{if(w){window.history.pushState({modalOpen:!0},"",window.location.href);const e=e=>{N(void 0),e.preventDefault()};return window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e),window.history.state?.modalOpen&&window.history.back()}}},[w,N]);const X=e=>{W(e.targetTouches[0].clientX),H(null)},Y=e=>{H(e.targetTouches[0].clientX)},G=()=>{if(null!==j&&null!==L&&V.length>1){const e=j-L,t=50;e>t?z(e=>e<V.length-1?e+1:0):e<-t&&z(e=>e>0?e-1:V.length-1)}W(null),H(null)},J=o.selectedProducts.filter(e=>e.variantId===S?.id).reduce((e,t)=>e+t.quantity,0),K=o.customVariantsQuantity?.find(e=>e.variantId===S?.id)?.quantity??o.bundleProductsCustomQuantity??1/0,U=K!==1/0&&J>=K,Z=o.hideAddToBundle||!S||k(S)<=0||U||"idle"!==D||o?.disableQuantitySelector&&1===P,ee=t.createElement(x,{className:"yt-byob-modal-desktop-overlay"},t.createElement(f,{$isSmallScreen:F,ref:E},t.createElement(h,{ref:E,className:"yt-byob-modal-desktop-container yt-variant-selection-modal"},t.createElement("div",{className:"yt-byob-modal-desktop yt-variant-selection-modal "+(F?"small-screen":"large-screen")},t.createElement(v,{className:"yt-byob-modal-desktop-close",onClick:()=>{N(void 0)},style:{backgroundColor:"white"}},t.createElement(r,{size:"25"})),t.createElement("div",{className:"yt-byob-modal-desktop-image-section image-section"},t.createElement(t.Fragment,null,t.createElement("div",{className:"yt-byob-modal-desktop-image-swipe",onTouchStart:X,onTouchMove:Y,onTouchEnd:G},t.createElement(s,{small:p(V[R]?.url),medium:p(V[R]?.url),large:p(V[R]?.url),hideDownload:!0,className:"yt-byob-modal-desktop-main-image main-image",imageBackgroundColor:"#000"})),t.createElement("div",{className:"yt-byob-modal-desktop-image-gallery image-gallery",style:{display:"flex",flexDirection:"row",overflow:"auto",gap:"10px",scrollbarWidth:"none"}},V.length>1&&V.filter(e=>e?.url.length>0).map((e,a)=>t.createElement("img",{key:a,className:"yt-byob-modal-desktop-gallery-thumb "+(R===a?"active":""),src:p(e?.url),alt:e.altText||`${$} - Image ${a+1}`,onClick:()=>z(a),style:{width:"73px",height:"73px",cursor:"pointer",borderRadius:"7px",border:"1px solid lightgray",...R===a&&{border:`2px solid ${o.themeColor||"#111"}`},objectFit:"cover"},loading:"lazy"}))))),t.createElement("div",{className:"yt-byob-modal-desktop-details-section details-section",style:{marginLeft:"20px",minHeight:"100%",maxHeight:"70vh",scrollbarWidth:"none",overflowY:"auto",display:"flex",flexDirection:"column"}},t.createElement("h2",{className:"yt-byob-modal-desktop-title"},C.length>1?S?.displayName:w.title),"ratingOnly"===o.reviewRatingType&&(w?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-desktop-rating",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",t.createElement("span",{style:{marginLeft:6}},w?.rating?.averageRating,"rating")),"ratingAndReviewCount"===o.reviewRatingType&&(w?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-desktop-rating-count",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",w?.rating?.averageRating,t.createElement(y,{size:14,style:{color:"dodgerblue",marginLeft:"4px"}})," ","(",w?.rating?.ratingCount," reviews)"),t.createElement("div",{className:"yt-byob-modal-desktop-variant-price-wrapper",style:{display:"flex",flexDirection:"column",gap:"2px",marginTop:"20px"}},C.length>1&&t.createElement("div",{className:"yt-byob-modal-desktop-variant-selector"},t.createElement("div",{className:"yt-byob-modal-desktop-variant-label",style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",paddingBottom:"5px",fontSize:"16px",color:"#999",position:"relative",marginBottom:"10px"}},t.createElement("span",{style:{flexShrink:0}},w.options[0].name," :"," ",t.createElement("strong",{style:{color:"#000",paddingLeft:"5px"}},S?.title)),t.createElement("select",{className:"yt-byob-modal-desktop-variant-select",value:S?.id||"",onChange:_,style:{appearance:"none",border:"none",background:"transparent",fontWeight:"bold",color:"#000",cursor:"pointer",paddingRight:"20px",position:"absolute",right:0,top:0,bottom:0,width:"100%",opacity:0,zIndex:2}},C.map(({node:e})=>t.createElement("option",{key:e.id,value:e.id,disabled:0===k(e)},e.title))),t.createElement("span",{className:"yt-byob-modal-desktop-variant-chevron",style:{position:"absolute",right:5,pointerEvents:"none",fontSize:"12px",color:"#000"}},t.createElement(c,null)))),t.createElement("div",{className:"yt-byob-modal-desktop-price-atc-wrapper",style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"}},t.createElement("div",{className:"yt-byob-modal-desktop-price",style:{width:"fit-content",minWidth:"fit-content",paddingRight:"10px",display:"flex",flexDirection:"row",alignItems:"baseline",gap:"6px"}},o?.isFreebieTier&&!o.showFreebieTierProductPrices?t.createElement(t.Fragment,null,t.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"20px",textDecoration:"line-through",color:"#888",marginRight:"6px"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price)),t.createElement("span",{className:"yt-byob-current-price",style:{color:o.styles.general.primaryColor||"#d32f2f",fontWeight:"bold",fontSize:"20px"}},"FREE")):t.createElement(t.Fragment,null,t.createElement("div",{className:"yt-byob-modal-desktop-current-price"},t.createElement("span",{style:{fontSize:"20px",fontWeight:"600",color:"#000",textAlign:"center",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price))),S?.compareAtPrice&&parseFloat(S.compareAtPrice)>parseFloat(S?.price)&&t.createElement("div",{className:"yt-byob-modal-desktop-compare-price",style:{textDecoration:"line-through",opacity:"0.5",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.compareAtPrice)))),t.createElement("div",{className:"yt-byob-modal-desktop-atc-wrapper yt-product-modal-atc-wrapper",style:{width:"80%"}},t.createElement("button",{className:"yt-byob-modal-desktop-atc-button yt-product-modal-atc-button",style:{textTransform:"uppercase",fontWeight:"800",width:"100%",border:"none",backgroundColor:o.themeColor||"#111",borderRadius:o.cornerRadius,color:o.primaryTextColorCta||"#fff",minHeight:"40px",padding:"0px 15px",position:"relative",overflow:"hidden",opacity:Z?.5:1,cursor:Z?"not-allowed":"pointer"},onClick:e=>{e.stopPropagation(),e.preventDefault(),Q()},disabled:Z},o.styles.byob.addToBundleCTAText??"Add to bundle")))),t.createElement("div",{className:"yt-byob-modal-desktop-divider",style:{height:"10px",minHeight:"10px",border:"none",backgroundColor:"#D9D9D96B",margin:"20px 0 10px 0",display:"block !important"}},t.createElement("span",null)),t.createElement("span",{className:"yt-byob-modal-desktop-description yt-description-content",style:{scrollBehavior:"smooth"},dangerouslySetInnerHTML:{__html:M}})))))),te=t.createElement(x,{className:"yt-byob-modal-mobile-overlay"},t.createElement(f,{className:"yt-byob-modal-mobile-content",style:{padding:"0px",position:"relative"},$isSmallScreen:F,ref:E},t.createElement(h,{ref:E,className:"yt-byob-modal-mobile-container yt-variant-selection-modal"},t.createElement("button",{className:"yt-byob-modal-mobile-close-btn",style:{position:"fixed",top:"20px",right:"20px",zIndex:9999999999,backgroundColor:"#FFFFFF",padding:"4px",borderRadius:"50%",border:"1px solid lightgray",display:"flex",justifyContent:"center",alignItems:"center"},onClick:()=>{N(void 0)}},t.createElement(d,{className:"yt-byob-modal-mobile-close-icon",style:{height:"22px",width:"22px",padding:"4px",color:"black"},onMouseEnter:e=>e.currentTarget.style.color="black"})),t.createElement("div",{className:"yt-byob-modal-mobile yt-variant-selection-modal small-screen",style:{padding:"0px"}},t.createElement("div",{className:"yt-byob-modal-mobile-image-section image-section"},t.createElement(t.Fragment,null,t.createElement("div",{className:"yt-byob-modal-mobile-image-swipe",style:{position:"relative"},onTouchStart:X,onTouchMove:Y,onTouchEnd:G},t.createElement(s,{small:p(V[R]?.url),medium:p(V[R]?.url),large:p(V[R]?.url),hideDownload:!0,className:"yt-byob-modal-mobile-main-image main-image",imageBackgroundColor:"#000"}),t.createElement("div",{className:"yt-byob-modal-mobile-image-indicators",style:{position:"absolute",bottom:"20px",width:"100%",display:"flex",justifyContent:"center",alignItems:"center"}},V.length>1&&V.map((e,o)=>t.createElement("span",{key:o,className:"yt-byob-modal-mobile-indicator "+(R===o?"active":""),style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:R===o?"#FFFFFF":"#EBEBEB",margin:"0 3px",cursor:"pointer",backdropFilter:"blur(10px)"}})))),t.createElement("div",{className:"yt-byob-modal-mobile-image-gallery image-gallery",style:{display:"flex",flexDirection:"row",overflowX:"auto",padding:"5px 20px",gap:"5px",scrollbarWidth:"none"}},V.length>1&&V.map((e,a)=>t.createElement("img",{key:a,className:"yt-byob-modal-mobile-gallery-thumb "+(R===a?"active":""),src:p(e?.url),alt:e.altText||`${$} - Image ${a+1}`,onClick:()=>z(a),style:{width:"60px",height:"60px",cursor:"pointer",borderRadius:"7px",border:"1px solid lightgray",...R===a&&{border:`2px solid ${o.themeColor||"#111"}`},objectFit:"cover"},loading:"lazy"}))))),t.createElement("div",{className:"yt-byob-modal-mobile-details-section details-section",style:{padding:"0 30px",margin:"15px 0",paddingBottom:"120px"}},t.createElement("h2",{className:"yt-byob-modal-mobile-title",style:{margin:"0px"}},C.length>1?S?.displayName:w.title),"ratingOnly"===o.reviewRatingType&&(o?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-mobile-rating",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",t.createElement("span",{style:{marginLeft:6}},o?.rating?.averageRating," rating")),"ratingAndReviewCount"===o.reviewRatingType&&(o?.rating?.averageRating??0)>0&&t.createElement("div",{className:"yt-byob-modal-mobile-rating-count",style:{display:"flex",alignItems:"center",justifyContent:"start",fontSize:"14px",color:"#333"}},t.createElement(m,{color:"gold",size:14})," ",o?.rating?.averageRating,t.createElement(y,{className:"yt-byob-modal-mobile-verified-icon",style:{color:"dodgerblue",marginLeft:"4px"},size:14})," ","(",o?.rating?.ratingCount," reviews)"),t.createElement("div",{className:"yt-byob-modal-mobile-divider",style:{opacity:"0.2",border:"none",height:"2px",backgroundColor:"#000000",margin:"10px 0px",display:"block !important"}},t.createElement("span",null)),t.createElement("div",{className:"yt-byob-modal-mobile-description yt-description-content",style:{scrollbarWidth:"none",scrollBehavior:"smooth",margin:"0px"},dangerouslySetInnerHTML:{__html:M}})))),t.createElement("div",{className:"yt-byob-modal-mobile-bottom-bar",style:{position:"fixed",bottom:"0px",left:"0px",right:"0px",padding:"12px 15px",borderTop:"1px solid lightgray",boxShadow:"0px -4px 5px rgba(0, 0, 0, 0.1)",backgroundColor:"#fff",display:"flex",flexDirection:"column",gap:"2px",zIndex:9999999999}},C.length>1&&t.createElement("div",{className:"yt-byob-modal-mobile-variant-selector"},t.createElement("div",{className:"yt-byob-modal-mobile-variant-label",style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",paddingBottom:"5px",fontSize:"16px",color:"#999",position:"relative",margin:"10px 0"}},t.createElement("span",{style:{flexShrink:0}},w.options[0].name," :"," ",t.createElement("strong",{style:{color:"#000",paddingLeft:"5px"}},S?.title)),t.createElement("select",{className:"yt-byob-modal-mobile-variant-select",value:S?.id||"",onChange:_,style:{appearance:"none",border:"none",background:"transparent",fontWeight:"bold",color:"#000",cursor:"pointer",paddingRight:"20px",position:"absolute",right:0,top:0,bottom:0,width:"100%",opacity:0,zIndex:2}},C.map(({node:e})=>t.createElement("option",{key:e.id,value:e.id,disabled:0===k(e)},e.title))),t.createElement("span",{className:"yt-byob-modal-mobile-variant-chevron",style:{position:"absolute",right:5,pointerEvents:"none",fontSize:"12px",color:"#000"}},t.createElement(c,null)))),t.createElement("div",{className:"yt-byob-modal-mobile-price-atc-wrapper",style:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"}},t.createElement("div",{className:"yt-byob-modal-mobile-price",style:{width:"fit-content",minWidth:"fit-content",display:"flex",flexDirection:"row",paddingRight:"10px",alignItems:"center"}},o?.isFreebieTier&&!o.showFreebieTierProductPrices?t.createElement(t.Fragment,null,t.createElement("span",{className:"yt-byob-compare-price yt-fixed-bundle-original-price",style:{fontSize:"20px",textDecoration:"line-through",color:"#888",marginRight:"6px"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price)),t.createElement("span",{className:"yt-byob-current-price",style:{color:o.styles.general.primaryColor||"#d32f2f",fontWeight:"bold",fontSize:"20px"}},"FREE")):t.createElement(t.Fragment,null,S?.compareAtPrice&&t.createElement("div",{className:"yt-byob-modal-mobile-compare-price",style:{textDecoration:"line-through",opacity:"0.5",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.compareAtPrice)),t.createElement("div",{className:"yt-byob-modal-mobile-current-price"},t.createElement("span",{style:{fontSize:"20px",fontWeight:"600",color:"#000",textAlign:"center",lineHeight:"normal"}},b(o.styles.general.currencySymbol,o.styles.general.currencySymbol),g(S?.price))))),t.createElement("div",{className:"yt-byob-modal-mobile-atc-wrapper",style:{width:"100%"}},t.createElement("button",{className:"yt-byob-modal-mobile-atc-button",style:{textTransform:"uppercase",fontWeight:"800",width:"100%",border:"none",backgroundColor:o.themeColor||"#111",borderRadius:o.cornerRadius,color:o.primaryTextColorCta||"#fff",minHeight:"40px",padding:"0px 15px",position:"relative",overflow:"hidden",opacity:Z?.5:1,cursor:Z?"not-allowed":"pointer"},onClick:e=>{e.stopPropagation(),e.preventDefault(),Q()},disabled:Z},o.styles.byob.addToBundleCTAText||"Add to Bundle"))))));return i.createPortal(F?te:ee,document.body)});export{E as default};
@@ -1 +1 @@
1
- import e,{useState as t,useMemo as o,useEffect as n}from"react";import{getCurrencySymbol as r,currencyPrice as l,optimiseImage as i}from"./Bundle.js";import{ClipLoader as a}from"react-spinners";import{IoChevronDownOutline as c}from"react-icons/io5";const d=({product:t,selectedVariantId:n,onVariantChange:a,styles:d,originalPrice:s,dealPrice:u,isVertical:p=!1,variantOptions:m,storeCurrencyCode:b})=>{const g=o(()=>e=>{const o=t?.productDetails?.variants?.edges?.find(t=>t.node.id===e),n=o?.node;return n?t.productDetails.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[t.productDetails]),y=t?.productDetails?.variants?.edges?.find(e=>e?.node?.id===n)?.node;g(n);const x=o(()=>{if(y?.title&&t.productDetails.options){const e=y.title.split(" / ");if(e.length===t.productDetails.options.length)return e}return t.productDetails.options?.map(e=>e.values[0])||[]},[y,t.productDetails.options]),f=e=>{a(e)};return p?e.createElement("div",{className:"yt-comboBundle-product-card-vertical",style:{display:"flex",flexDirection:"column",alignItems:"center",lineHeight:"normal",width:"165px",backgroundColor:"#F6F6F6",borderRadius:"20px",border:"1px solid #B3B3B3",boxShadow:"4px 4px 0px -1px #00000033",overflow:"hidden"}},e.createElement("div",{className:"yt-comboBundle-product-card-image-container-vertical",style:{position:"relative",width:"100%"}},d.comboBundle.subProductsImageVisibility&&e.createElement(e.Fragment,null,e.createElement("img",{className:"yt-comboBundle-product-image-vertical",src:i(y?.image?.url||t?.productDetails?.featuredMedia?.preview?.image?.url||"/placeholder.svg"),alt:t?.productDetails?.featuredMedia?.alt,width:165,height:165,style:{objectFit:"cover",borderRadius:"20px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px",height:"100%",aspectRatio:d.general?.imageAspectRatio||"1/1"}}),e.createElement("div",{className:"yt-comboBundle-product-variant-selector-container-vertical",style:{marginTop:"8px",position:"absolute",bottom:"10px",left:"5px",right:"5px"}},t?.productDetails?.variants?.edges?.length>1&&e.createElement(e.Fragment,null,e.createElement("select",{className:"yt-comboBundle-product-variant-select-vertical",value:n,onChange:e=>f(e.target.value),style:{padding:"6px",border:"1px solid #ddd",backgroundColor:"#fff",color:"#333",width:"100%",appearance:"none",marginRight:"30px",fontSize:"12px",fontWeight:600}},t?.productDetails?.variants?.edges.map(t=>{const o=g(t?.node?.id);return e.createElement("option",{key:t?.node?.id,value:t?.node?.id,disabled:0===o,className:"yt-comboBundle-product-variant-option"},t?.node?.title)})),e.createElement("div",{className:"yt-comboBundle-product-variant-select-icon-vertical",style:{position:"absolute",right:"1px",top:"2px",bottom:"0px",pointerEvents:"none",backgroundColor:"#F3F3F3",width:"15%",height:"calc(100% - 4px)",display:"flex",justifyContent:"center",alignItems:"center"}},e.createElement(c,null)))))),(d.comboBundle.subProductsProductTitleVisibility||d.comboBundle.subProductsProductPriceVisibility)&&e.createElement("div",{className:"yt-comboBundle-product-info-container-vertical",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"40px",width:"100%",paddingBlock:"5px"}},d.comboBundle.subProductsProductTitleVisibility&&e.createElement("span",{className:"yt-comboBundle-product-title-vertical",style:{fontSize:"12px",color:"#333",fontWeight:"600",lineHeight:"normal",textAlign:"center",width:"fit-content"}},t?.productDetails?.title),d.comboBundle.subProductsProductPriceVisibility&&e.createElement("div",{className:"yt-comboBundle-product-price-container-vertical",style:{display:"flex",alignItems:"center",gap:"8px",lineHeight:"normal",fontSize:"14px"}},e.createElement("span",{className:"yt-comboBundle-product-deal-price-vertical",style:{lineHeight:"normal"}},r(d.general.currencySymbol,b),l((Number(y?.compareAtPrice?Number(y?.compareAtPrice):y?.price)/Number(s)*Number(u)).toFixed(2))),y?.compareAtPrice&&e.createElement("span",{className:"yt-comboBundle-product-original-price-vertical",style:{textDecoration:"line-through",color:"#999",lineHeight:"normal",fontSize:"12px"}},r(d.general.currencySymbol,b),l(y?.compareAtPrice?y?.compareAtPrice:y?.price))))):e.createElement("div",{className:"yt-comboBundle-product-card-horizontal",style:{display:"flex",alignItems:"center",gap:"16px",padding:"4px",lineHeight:"normal",borderRadius:"8px",transition:"background-color 0.3s",width:"100%",border:"1px solid transparent",..."right"===d.comboBundle.infoAlignment&&{flexDirection:"row-reverse"},..."center"===d.comboBundle.infoAlignment&&{justifyContent:"center"}},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#fafafa",e.currentTarget.style.border="1px solid #DFDFDF"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent",e.currentTarget.style.border="1px solid transparent"}},d.comboBundle.subProductsImageVisibility&&e.createElement("div",{className:"yt-comboBundle-product-image-wrapper-horizontal"},e.createElement("img",{className:"yt-comboBundle-product-image-horizontal",src:i(y?.image?.url||t?.productDetails?.featuredMedia?.preview?.image?.url||"/placeholder.svg"),alt:t?.productDetails?.featuredMedia?.alt,height:80,style:{objectFit:"cover",borderRadius:"10px",border:"1px solid #DEDEDE",aspectRatio:"1/1",width:"90px",height:"90px"}})),e.createElement("div",{className:"yt-comboBundle-product-info-horizontal",style:{display:"flex",flexDirection:"column",alignItems:"left"===d.comboBundle?.infoAlignment?"flex-start":"right"===d.comboBundle?.infoAlignment?"flex-end":"center"===d.comboBundle?.infoAlignment?"flex-start":void 0}},d.comboBundle.subProductsProductTitleVisibility&&e.createElement("span",{className:"yt-comboBundle-product-title-horizontal",style:{fontSize:"14px",fontWeight:"600",lineHeight:"normal",display:"flex",alignItems:"center",gap:"8px"}},e.createElement("span",{className:"yt-comboBundle-product-title-text"}," ",t?.productDetails?.title," "),"dropdown"!==d.comboBundle.comboVariantTypeSelector&&t.productDetails.variants.edges.length>1&&m&&x&&e.createElement("span",{className:"yt-comboBundle-product-variant-tag-horizontal",style:{fontSize:"10px",color:"#666",backgroundColor:"#F4F4F4",padding:"2px 8px",borderRadius:"10px",border:"1px solid #ddd"}},x.length>1?x.join(" / "):x)),d.comboBundle.subProductsProductPriceVisibility&&e.createElement("div",{className:"yt-comboBundle-product-price-wrapper-horizontal",style:{display:"flex",gap:"8px",marginTop:"5px",alignItems:"baseline"}},e.createElement("span",{className:"yt-comboBundle-product-deal-price-horizontal",style:{lineHeight:"normal"}},r(d.general.currencySymbol,b),l((Number(y?.compareAtPrice?Number(y?.compareAtPrice):y?.price)/Number(s)*Number(u)).toFixed(2))),y?.compareAtPrice&&e.createElement("span",{className:"yt-comboBundle-product-original-price-horizontal",style:{textDecoration:"line-through",color:"#999",fontSize:"14px",lineHeight:"normal"}},r(d.general.currencySymbol,b),l(y?.compareAtPrice?y?.compareAtPrice:y?.price))),t.productDetails.variants.edges.length>1&&("dropdown"===d.comboBundle.comboVariantTypeSelector?e.createElement("div",{className:"yt-comboBundle-product-variant-dropdown-horizontal",style:{display:"flex",gap:"8px",flexWrap:"wrap",lineHeight:"normal",marginTop:"10px"}},e.createElement("select",{className:"yt-comboBundle-product-variant-select-horizontal",value:n,onChange:e=>f(e.target.value),style:{padding:"6px",border:"1px solid #ddd",backgroundColor:"#fff",color:"#333",fontSize:"12px",fontWeight:600,borderRadius:"4px"}},t.productDetails.variants.edges.map(t=>{const o=g(t?.node?.id);return e.createElement("option",{key:t?.node?.id,value:t?.node?.id,disabled:0===o,className:"yt-comboBundle-product-variant-option"},t?.node?.title)})),e.createElement("div",{className:"yt-comboBundle-product-variant-select-icon-horizontal",style:{position:"absolute",right:"1px",top:"2px",bottom:"0px",pointerEvents:"none",backgroundColor:"#F3F3F3",width:"15%",height:"calc(100% - 4px)",display:"flex",justifyContent:"center",alignItems:"center"}},e.createElement(c,null))):t.productDetails.options.length>0?e.createElement(e.Fragment,null,t.productDetails.options.map((o,n)=>e.createElement("div",{key:o.name,className:"yt-comboBundle-product-option-group-horizontal",style:{...o?.values?.length>1&&{marginTop:"10px"},display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"}},t.productDetails.options.length>1&&o?.values?.length>1&&e.createElement("label",{className:"yt-comboBundle-product-option-label",style:{fontSize:"12px",fontWeight:"500",color:"#333"}},o.name,":"),o?.values?.length>1&&e.createElement("div",{className:"yt-comboBundle-product-option-values-horizontal",style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"}},o.values.map(r=>{const l=[...x];l[n]=r;const a=t.productDetails.options.length>0?l.join(" / "):l[n],c=t.productDetails.variants.edges.find(e=>e.node.title===a)?.node,s=0===(c?g(c.id):0),u=x[n]===r,p=m&&m?.options?.find(e=>e.name===o.name);return p&&"color"===p?.type?e.createElement("button",{key:r,className:`yt-comboBundle-product-option-button-color ${u?"yt-comboBundle-product-option-button-selected":""} ${s?"yt-comboBundle-product-option-button-disabled":""}`,onClick:()=>{!s&&c&&f(c.id)},disabled:s,style:{borderRadius:"50%",padding:"1px",backgroundColor:"white",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:"1px solid transparent",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"}},p?.values.find(e=>e.name===r)?.value?e.createElement("div",{className:"yt-comboBundle-product-option-color-swatch",style:{width:u&&!s?"26px":"24px",height:u&&!s?"26px":"24px",borderRadius:"50%",backgroundColor:p?.values.find(e=>e.name===r)?.value}},e.createElement("span",null)):e.createElement("span",{key:r,className:"yt-comboBundle-product-option-text",style:{padding:"4px 8px",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:s?"1px solid #ccc":"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:u&&!s?"#F7F7F7":"transparent",color:s?"#ccc":"#707070",fontSize:"10px",fontWeight:"600"}},r)):p&&"image"===p?.type?e.createElement("button",{key:r,className:`yt-comboBundle-product-option-button-image ${u?"yt-comboBundle-product-option-button-selected":""} ${s?"yt-comboBundle-product-option-button-disabled":""}`,onClick:()=>{!s&&c&&f(c.id)},disabled:s,style:{border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:u&&!s?"#F7F7F7":"transparent",cursor:s?"not-allowed":"pointer",padding:"0px",width:u&&!s?"26px":"24px",height:u&&!s?"26px":"24px",overflow:"hidden",opacity:s?.5:1}},p?.values.find(e=>e.name===r)?.value?e.createElement("img",{className:"yt-comboBundle-product-option-image",src:i(p?.values.find(e=>e.name===r)?.value||"/placeholder.svg"),alt:r,style:{width:u&&!s?"26px":"24px",height:u&&!s?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}}):e.createElement("span",{key:r,className:"yt-comboBundle-product-option-text",style:{padding:"4px 8px",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:s?"1px solid #ccc":"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:u&&!s?"#F7F7F7":"transparent",color:s?"#ccc":"#707070",fontSize:"10px",fontWeight:"600"}},r)):e.createElement("button",{key:r,className:`yt-comboBundle-product-option-button-text ${u?"yt-comboBundle-product-option-button-selected":""} ${s?"yt-comboBundle-product-option-button-disabled":""}`,onClick:()=>{!s&&c&&f(c.id)},disabled:s,style:{padding:"4px 8px",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:s?"1px solid #ccc":"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:u&&!s?"#F7F7F7":"transparent",color:s?"#ccc":"#707070",cursor:s?"not-allowed":"pointer",fontSize:"10px",fontWeight:"600",opacity:s?.5:1}},r)}))))):e.createElement(e.Fragment,null,t?.productDetails?.variants?.edges?.length>1&&e.createElement("div",{className:"yt-comboBundle-product-variant-buttons-horizontal",style:{display:"flex",gap:"8px",flexWrap:"wrap",lineHeight:"normal",marginTop:"10px"}},t?.productDetails?.variants?.edges.map(t=>{const o=0===g(t?.node?.id);return e.createElement("button",{key:t?.node?.id,className:`yt-comboBundle-product-variant-button ${n===t?.node?.id?"yt-comboBundle-product-variant-button-selected":""} ${o?"yt-comboBundle-product-variant-button-disabled":""}`,onClick:()=>f(t?.node?.id),disabled:o,style:{padding:"4px 8px",border:n===t?.node?.id?`1px solid ${d.general?.ctaBackgroundColor}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:n===t?.node?.id?"#F7F7F7":"transparent",color:o?"#ccc":"#707070",cursor:o?"not-allowed":"pointer",fontSize:"12px",fontWeight:"500",opacity:o?.5:1}},t?.node?.title)}))))))},s=({bundle:i,addToCartFunction:c})=>{const[s,u]=t(!1),[p,m]=t(window.innerWidth<786),b=o(()=>(e,t)=>{const o=e?.variants?.edges?.find(e=>e.node.id===t),n=o?.node;return n?e.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[]),[g,y]=t(()=>{const e={};return i.products.forEach((t,o)=>{const n=t.productDetails?.variants?.edges?.find(e=>b(t.productDetails,e?.node?.id)>0)?.node;e[o]=n?n.id:t?.productDetails?.variants?.edges[0]?.node?.id}),e});n(()=>(c&&(window.ytComboBundle={bundle:i,addToCart:c,selectedVariants:g},window.dispatchEvent(new CustomEvent("yt-combo-bundle-updated",{detail:window.ytComboBundle}))),()=>{window.ytComboBundle=void 0,window.dispatchEvent(new CustomEvent("yt-combo-bundle-updated",{detail:void 0}))}),[i,c,g]);const x=i.products?.every((e,t)=>{const o=g[t];return b(e.productDetails,o)>0}),f=(e,t)=>{y(o=>({...o,[e]:t}))},{originalPrice:h,dealPrice:v,offerValue:B}=o(()=>{const{price:e,compareAtPrice:t}=Object.entries(g).reduce((e,[t,o])=>{const n=i.products[parseInt(t)],r=n.productDetails.variants.edges?.find(e=>e.node.id===o)?.node,l=parseFloat(r?.price??"0"),a=parseFloat(r?.compareAtPrice||l.toString());return e.price+=l,e.compareAtPrice+=a,e},{price:0,compareAtPrice:0}),o=Math.max(e,t);let n=Math.min(e,t);i?.percentageOff?n=e*(1-i.percentageOff/100):i?.dealAmount?n=i.dealAmount:i?.amountOff&&(n=e-i.amountOff);const r=t-n;return{originalPrice:o.toFixed(2),dealPrice:n.toFixed(2),offerValue:r.toFixed(2)}},[g,i.products,i.percentageOff,i.dealAmount,i.amountOff]);n(()=>{const e=()=>{m(window.innerWidth<786)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]);const E=i.customizations,C=E.comboBundle?.comboCardStyle||"auto",N="vertical"===C||"auto"===C&&!p,w=E.comboBundle?.embedContentVisibility,F="bundles"==i.appName?i.pageHeader?.title:i?.title,k="bundles"==i.appName?i.pageHeader?.description:i?.subtitle;return e.createElement("div",{className:`yt-comboBundle-bundle-container ${"left"===E.comboBundle?.infoAlignment?"yt-comboBundle-bundle-align-left":"right"===E.comboBundle?.infoAlignment?"yt-comboBundle-bundle-align-right":"center"===E.comboBundle?.infoAlignment?"yt-comboBundle-bundle-align-center":void 0}`,style:{lineHeight:"normal",maxWidth:"800px",marginBlock:E.comboBundle?.verticalMargin||"0px",display:"flex",flexDirection:"column",alignItems:"left"===E.comboBundle?.infoAlignment?"flex-start":"right"===E.comboBundle?.infoAlignment?"flex-end":"center"===E.comboBundle?.infoAlignment?"center":void 0,textAlign:E.comboBundle?.infoAlignment??"left",fontFamily:"system-ui, -apple-system, sans-serif"}},w&&E.comboBundle?.selectedEmbedContentVisibilityOptions?.includes("Combo Title")&&e.createElement("div",{className:"yt-comboBundle-bundle-title-container",style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"10px"}},e.createElement("h2",{className:"yt-comboBundle-bundle-title",style:{fontSize:E.comboBundle?.productTitleFontSize||"28px",color:E.comboBundle?.titleTextColor||"#000",fontWeight:"bold",lineHeight:"1.6",margin:0}},F)),w&&E?.comboBundle?.selectedEmbedContentVisibilityOptions?.includes("Combo Price")&&e.createElement(e.Fragment,null,e.createElement("div",{className:"yt-comboBundle-bundle-price-container",style:{display:"flex",alignItems:"center",gap:"8px",color:E.comboBundle?.titleTextColor||"#000",fontSize:(parseInt(E.comboBundle?.productTitleFontSize?.replace("px",""))||28)-4+"px"}},e.createElement("div",{className:"yt-comboBundle-bundle-price-details",style:{display:"flex",alignItems:"center",gap:"5px",flexWrap:"wrap"}},e.createElement("span",{className:"yt-comboBundle-bundle-deal-price-text",style:{fontWeight:"bold",lineHeight:"1",minWidth:"fit-content"}},r(E.general.currencySymbol,i.storeCurrencyCode),l(v)),e.createElement("div",{className:"yt-comboBundle-bundle-original-price-text",style:{color:E.comboBundle?.titleTextColor||"#666",textDecoration:"line-through",verticalAlign:"middle",display:"inline-block",minWidth:"fit-content"}},r(E.general.currencySymbol,i.storeCurrencyCode),l(h)),e.createElement("span",{className:"yt-comboBundle-bundle-offer-badge",style:{backgroundColor:"#D3122A",color:"white",padding:"4px 8px",fontSize:"14px",borderRadius:"20px",fontWeight:"500",lineHeight:"1",minWidth:"fit-content"}},i?.percentageOff?`${i?.percentageOff}% Off`:i?.amountOff?`${r(E.general.currencySymbol,i.storeCurrencyCode)}${l(i?.amountOff)} Off`:`Save ${r(E.general.currencySymbol,i.storeCurrencyCode)}${l(B)}`))),e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"15px 0px"},className:"yt-comboBundle-checkoutSpecific-container"},e.createElement("div",{style:{display:"flex",width:"12px",height:"12px",justifyContent:"center",alignItems:"center",alignContent:"center",borderRadius:"50%",backgroundColor:E.general?.ctaBackgroundColor||"#1e1e1e",flexShrink:0},className:"yt-comboBundle-checkoutSpecific-dot"},e.createElement("span",null)),e.createElement("p",{style:{fontSize:E.comboBundle.productDescriptionFontSize||"16px",color:E.comboBundle?.descriptionTextColor||"#000",alignItems:"center",margin:0,lineHeight:"1.2"},className:"yt-comboBundle-checkoutSpecific-text"},"Tax included. ",e.createElement("u",null,"Shipping")," calculated at checkout."))),E.comboBundle.subProductsSectionVisibility&&e.createElement(e.Fragment,null,N?e.createElement("div",{className:"yt-comboBundle-products-grid-vertical "+(p?"yt-comboBundle-products-grid-mobile":""),style:{display:"flex",flexDirection:"row",gap:"20px",marginTop:"10px",flexWrap:"wrap"}},i.products.map((t,o)=>{const n=t?.productDetails?.variants?.edges?.find(e=>e?.node?.id===g[o])?.node;return n?e.createElement(d,{key:`combo-product-${o}-${t.productId}`,product:t,styles:E,originalPrice:h,dealPrice:v,selectedVariantId:g[o],onVariantChange:e=>f(o,e),isVertical:N,variantOptions:i.variantOptions,storeCurrencyCode:i.storeCurrencyCode}):null})):e.createElement("div",{className:"yt-comboBundle-products-list-horizontal "+(p?"yt-comboBundle-products-list-mobile":""),style:{display:"flex",flexDirection:"column",gap:"10px",width:"100%"}},E.comboBundle.subProductsSectionVisibility&&i.products.map((t,o)=>e.createElement(d,{key:`combo-product-horizontal-${o}-${t.productId}`,product:t,styles:E,originalPrice:h,dealPrice:v,selectedVariantId:g[o],onVariantChange:e=>f(o,e),variantOptions:i.variantOptions})))),e.createElement("div",{className:"yt-comboBundle-bundle-cta-section",style:{borderTop:"1px solid #eee",display:"flex",flexDirection:"column",rowGap:"5px",marginTop:"20px",width:"100%"}},e.createElement("button",{className:`yt-comboBundle-bundle-cta-button ${x?"":"yt-comboBundle-bundle-cta-button-disabled"} ${p?"yt-comboBundle-bundle-cta-button-mobile":""}`,style:{backgroundColor:x?E.general?.ctaBackgroundColor||"#121212":E.general.disabledButtonColor,color:E.general?.ctaTextColor||"#FFFFFF",fontSize:"16px",borderRadius:E.general.ctaBorderRadius??"20px",fontWeight:"bold",cursor:x?"pointer":"not-allowed",border:`1px solid ${x?E.general?.ctaBackgroundColor||"#121212":E.general.disabledButtonColor}`,boxShadow:E.general.ctaShadowType,padding:E.general?.ctaPadding,width:E.general?.ctaWidth,margin:"0"},disabled:!x,onMouseOver:e=>{E.general.customizeHoverState&&x&&(e.currentTarget.style.backgroundColor=E.general?.ctaHoverBackgroundColor||"#F1F1F1",e.currentTarget.style.color=E.general?.ctaHoverTextColor||"#121212")},onMouseOut:e=>{E.general.customizeHoverState&&x&&(e.currentTarget.style.backgroundColor=E.general?.ctaBackgroundColor||"#121212",e.currentTarget.style.color=E.general?.ctaTextColor||"#FFFFFF")},onClick:async()=>{try{if(u(!0),!c)return console.error("[ComboBundle.tsx] No addToCartFunction available"),void u(!1);const e=Object.entries(g).map(([e,t])=>{const o=i.products[parseInt(e)],n=o.productDetails.variants.edges.find(e=>e.node.id===t)?.node;return n?{variantId:t,price:Number(n.price)}:null}).filter(e=>null!==e),t=Object.values(g);await c(Number(h),t,Number(v),e)}catch(e){console.error("[ComboBundle.tsx] Error adding to cart:",e)}u(!1)}},s?e.createElement(a,{color:"white",loading:s,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):e.createElement(e.Fragment,null,x?E.comboBundle?.ctaTitle??"Add Bundle to cart":E.general.outOfStockLabel||"Out of Stock"," "))),w&&E.comboBundle?.selectedEmbedContentVisibilityOptions?.includes("Combo Description")&&e.createElement("div",{className:"yt-comboBundle-bundle-description-section",style:{margin:"20px 0px"}},e.createElement("h4",{className:"yt-comboBundle-bundle-description-header",style:{fontSize:"16px",color:E.comboBundle?.descriptionTextColor||"#000",lineHeight:"1.2",margin:0,padding:"8px",backgroundColor:E.general.primaryColor+"20"}},"Description"),e.createElement("div",{className:"yt-comboBundle-bundle-description-content",style:{fontSize:E.comboBundle.productDescriptionFontSize||"16px",color:E.comboBundle?.descriptionTextColor||"#000",lineHeight:"1.2",padding:"8px",backgroundColor:E.general.primaryColor+"08"}},e.createElement("p",null,k))))};export{s as default};
1
+ import e,{useState as t,useMemo as o,useEffect as n}from"react";import{getCurrencySymbol as r,currencyPrice as l,optimiseImage as i}from"./Bundle.js";import{ClipLoader as a}from"react-spinners";import"./bundle.scss.js";import{IoChevronDownOutline as c}from"react-icons/io5";const d=({product:t,selectedVariantId:n,onVariantChange:a,styles:d,originalPrice:s,dealPrice:u,isVertical:p=!1,variantOptions:m,storeCurrencyCode:b})=>{const g=o(()=>e=>{const o=t?.productDetails?.variants?.edges?.find(t=>t.node.id===e),n=o?.node;return n?t.productDetails.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[t.productDetails]),y=t?.productDetails?.variants?.edges?.find(e=>e?.node?.id===n)?.node;g(n);const x=o(()=>{if(y?.title&&t.productDetails.options){const e=y.title.split(" / ");if(e.length===t.productDetails.options.length)return e}return t.productDetails.options?.map(e=>e.values[0])||[]},[y,t.productDetails.options]),f=e=>{a(e)};return p?e.createElement("div",{className:"yt-comboBundle-product-card-vertical",style:{display:"flex",flexDirection:"column",alignItems:"center",lineHeight:"normal",width:"165px",backgroundColor:"#F6F6F6",borderRadius:"20px",border:"1px solid #B3B3B3",boxShadow:"4px 4px 0px -1px #00000033",overflow:"hidden"}},e.createElement("div",{className:"yt-comboBundle-product-card-image-container-vertical",style:{position:"relative",width:"100%"}},d.comboBundle.subProductsImageVisibility&&e.createElement(e.Fragment,null,e.createElement("img",{className:"yt-comboBundle-product-image-vertical",src:i(y?.image?.url||t?.productDetails?.featuredMedia?.preview?.image?.url||"/placeholder.svg"),alt:t?.productDetails?.featuredMedia?.alt,width:165,height:165,style:{objectFit:"cover",borderRadius:"20px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px",height:"100%",aspectRatio:d.general?.imageAspectRatio||"1/1"}}),e.createElement("div",{className:"yt-comboBundle-product-variant-selector-container-vertical",style:{marginTop:"8px",position:"absolute",bottom:"10px",left:"5px",right:"5px"}},t?.productDetails?.variants?.edges?.length>1&&e.createElement(e.Fragment,null,e.createElement("select",{className:"yt-comboBundle-product-variant-select-vertical",value:n,onChange:e=>f(e.target.value),style:{padding:"6px",border:"1px solid #ddd",backgroundColor:"#fff",color:"#333",width:"100%",appearance:"none",marginRight:"30px",fontSize:"12px",fontWeight:600}},t?.productDetails?.variants?.edges.map(t=>{const o=g(t?.node?.id);return e.createElement("option",{key:t?.node?.id,value:t?.node?.id,disabled:0===o,className:"yt-comboBundle-product-variant-option"},t?.node?.title)})),e.createElement("div",{className:"yt-comboBundle-product-variant-select-icon-vertical",style:{position:"absolute",right:"1px",top:"2px",bottom:"0px",pointerEvents:"none",backgroundColor:"#F3F3F3",width:"15%",height:"calc(100% - 4px)",display:"flex",justifyContent:"center",alignItems:"center"}},e.createElement(c,null)))))),(d.comboBundle.subProductsProductTitleVisibility||d.comboBundle.subProductsProductPriceVisibility)&&e.createElement("div",{className:"yt-comboBundle-product-info-container-vertical",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"40px",width:"100%",paddingBlock:"5px"}},d.comboBundle.subProductsProductTitleVisibility&&e.createElement("span",{className:"yt-comboBundle-product-title-vertical",style:{fontSize:"12px",color:"#333",fontWeight:"600",lineHeight:"normal",textAlign:"center",width:"fit-content"}},t?.productDetails?.title),d.comboBundle.subProductsProductPriceVisibility&&e.createElement("div",{className:"yt-comboBundle-product-price-container-vertical",style:{display:"flex",alignItems:"center",gap:"8px",lineHeight:"normal",fontSize:"14px"}},e.createElement("span",{className:"yt-comboBundle-product-deal-price-vertical",style:{lineHeight:"normal"}},r(d.general.currencySymbol,b),l((Number(y?.compareAtPrice?Number(y?.compareAtPrice):y?.price)/Number(s)*Number(u)).toFixed(2))),y?.compareAtPrice&&e.createElement("span",{className:"yt-comboBundle-product-original-price-vertical",style:{textDecoration:"line-through",color:"#999",lineHeight:"normal",fontSize:"12px"}},r(d.general.currencySymbol,b),l(y?.compareAtPrice?y?.compareAtPrice:y?.price))))):e.createElement("div",{className:"yt-comboBundle-product-card-horizontal",style:{display:"flex",alignItems:"center",gap:"16px",padding:"4px",lineHeight:"normal",borderRadius:"8px",transition:"background-color 0.3s",width:"100%",border:"1px solid transparent",..."right"===d.comboBundle.infoAlignment&&{flexDirection:"row-reverse"},..."center"===d.comboBundle.infoAlignment&&{justifyContent:"center"}},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#fafafa",e.currentTarget.style.border="1px solid #DFDFDF"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent",e.currentTarget.style.border="1px solid transparent"}},d.comboBundle.subProductsImageVisibility&&e.createElement("div",{className:"yt-comboBundle-product-image-wrapper-horizontal"},e.createElement("img",{className:"yt-comboBundle-product-image-horizontal",src:i(y?.image?.url||t?.productDetails?.featuredMedia?.preview?.image?.url||"/placeholder.svg"),alt:t?.productDetails?.featuredMedia?.alt,height:80,style:{objectFit:"cover",borderRadius:"10px",border:"1px solid #DEDEDE",aspectRatio:"1/1",width:"90px",height:"90px"}})),e.createElement("div",{className:"yt-comboBundle-product-info-horizontal",style:{display:"flex",flexDirection:"column",alignItems:"left"===d.comboBundle?.infoAlignment?"flex-start":"right"===d.comboBundle?.infoAlignment?"flex-end":"center"===d.comboBundle?.infoAlignment?"flex-start":void 0}},d.comboBundle.subProductsProductTitleVisibility&&e.createElement("span",{className:"yt-comboBundle-product-title-horizontal",style:{fontSize:"14px",fontWeight:"600",lineHeight:"normal",display:"flex",alignItems:"center",gap:"8px"}},e.createElement("span",{className:"yt-comboBundle-product-title-text"}," ",t?.productDetails?.title," "),"dropdown"!==d.comboBundle.comboVariantTypeSelector&&t.productDetails.variants.edges.length>1&&m&&x&&e.createElement("span",{className:"yt-comboBundle-product-variant-tag-horizontal",style:{fontSize:"10px",color:"#666",backgroundColor:"#F4F4F4",padding:"2px 8px",borderRadius:"10px",border:"1px solid #ddd"}},x.length>1?x.join(" / "):x)),d.comboBundle.subProductsProductPriceVisibility&&e.createElement("div",{className:"yt-comboBundle-product-price-wrapper-horizontal",style:{display:"flex",gap:"8px",marginTop:"5px",alignItems:"baseline"}},e.createElement("span",{className:"yt-comboBundle-product-deal-price-horizontal",style:{lineHeight:"normal"}},r(d.general.currencySymbol,b),l((Number(y?.compareAtPrice?Number(y?.compareAtPrice):y?.price)/Number(s)*Number(u)).toFixed(2))),y?.compareAtPrice&&e.createElement("span",{className:"yt-comboBundle-product-original-price-horizontal",style:{textDecoration:"line-through",color:"#999",fontSize:"14px",lineHeight:"normal"}},r(d.general.currencySymbol,b),l(y?.compareAtPrice?y?.compareAtPrice:y?.price))),t.productDetails.variants.edges.length>1&&("dropdown"===d.comboBundle.comboVariantTypeSelector?e.createElement("div",{className:"yt-comboBundle-product-variant-dropdown-horizontal",style:{display:"flex",gap:"8px",flexWrap:"wrap",lineHeight:"normal",marginTop:"10px"}},e.createElement("select",{className:"yt-comboBundle-product-variant-select-horizontal",value:n,onChange:e=>f(e.target.value),style:{padding:"6px",border:"1px solid #ddd",backgroundColor:"#fff",color:"#333",fontSize:"12px",fontWeight:600,borderRadius:"4px"}},t.productDetails.variants.edges.map(t=>{const o=g(t?.node?.id);return e.createElement("option",{key:t?.node?.id,value:t?.node?.id,disabled:0===o,className:"yt-comboBundle-product-variant-option"},t?.node?.title)})),e.createElement("div",{className:"yt-comboBundle-product-variant-select-icon-horizontal",style:{position:"absolute",right:"1px",top:"2px",bottom:"0px",pointerEvents:"none",backgroundColor:"#F3F3F3",width:"15%",height:"calc(100% - 4px)",display:"flex",justifyContent:"center",alignItems:"center"}},e.createElement(c,null))):t.productDetails.options.length>0?e.createElement(e.Fragment,null,t.productDetails.options.map((o,n)=>e.createElement("div",{key:o.name,className:"yt-comboBundle-product-option-group-horizontal",style:{...o?.values?.length>1&&{marginTop:"10px"},display:"flex",flexDirection:"row",gap:"8px",alignItems:"center"}},t.productDetails.options.length>1&&o?.values?.length>1&&e.createElement("label",{className:"yt-comboBundle-product-option-label",style:{fontSize:"12px",fontWeight:"500",color:"#333"}},o.name,":"),o?.values?.length>1&&e.createElement("div",{className:"yt-comboBundle-product-option-values-horizontal",style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"8px",flexWrap:"wrap"}},o.values.map(r=>{const l=[...x];l[n]=r;const a=t.productDetails.options.length>0?l.join(" / "):l[n],c=t.productDetails.variants.edges.find(e=>e.node.title===a)?.node,s=0===(c?g(c.id):0),u=x[n]===r,p=m&&m?.options?.find(e=>e.name===o.name);return p&&"color"===p?.type?e.createElement("button",{key:r,className:`yt-comboBundle-product-option-button-color ${u?"yt-comboBundle-product-option-button-selected":""} ${s?"yt-comboBundle-product-option-button-disabled":""}`,onClick:()=>{!s&&c&&f(c.id)},disabled:s,style:{borderRadius:"50%",padding:"1px",backgroundColor:"white",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:"1px solid transparent",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"}},p?.values.find(e=>e.name===r)?.value?e.createElement("div",{className:"yt-comboBundle-product-option-color-swatch",style:{width:u&&!s?"26px":"24px",height:u&&!s?"26px":"24px",borderRadius:"50%",backgroundColor:p?.values.find(e=>e.name===r)?.value}},e.createElement("span",null)):e.createElement("span",{key:r,className:"yt-comboBundle-product-option-text",style:{padding:"4px 8px",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:s?"1px solid #ccc":"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:u&&!s?"#F7F7F7":"transparent",color:s?"#ccc":"#707070",fontSize:"10px",fontWeight:"600"}},r)):p&&"image"===p?.type?e.createElement("button",{key:r,className:`yt-comboBundle-product-option-button-image ${u?"yt-comboBundle-product-option-button-selected":""} ${s?"yt-comboBundle-product-option-button-disabled":""}`,onClick:()=>{!s&&c&&f(c.id)},disabled:s,style:{border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:"1px solid #E4E4E4",borderRadius:"100%",backgroundColor:u&&!s?"#F7F7F7":"transparent",cursor:s?"not-allowed":"pointer",padding:"0px",width:u&&!s?"26px":"24px",height:u&&!s?"26px":"24px",overflow:"hidden",opacity:s?.5:1}},p?.values.find(e=>e.name===r)?.value?e.createElement("img",{className:"yt-comboBundle-product-option-image",src:i(p?.values.find(e=>e.name===r)?.value||"/placeholder.svg"),alt:r,style:{width:u&&!s?"26px":"24px",height:u&&!s?"26px":"24px",objectFit:"cover",borderRadius:"100%",aspectRatio:"1/1"}}):e.createElement("span",{key:r,className:"yt-comboBundle-product-option-text",style:{padding:"4px 8px",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:s?"1px solid #ccc":"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:u&&!s?"#F7F7F7":"transparent",color:s?"#ccc":"#707070",fontSize:"10px",fontWeight:"600"}},r)):e.createElement("button",{key:r,className:`yt-comboBundle-product-option-button-text ${u?"yt-comboBundle-product-option-button-selected":""} ${s?"yt-comboBundle-product-option-button-disabled":""}`,onClick:()=>{!s&&c&&f(c.id)},disabled:s,style:{padding:"4px 8px",border:u&&!s?`1px solid ${d.general?.ctaBackgroundColor}`:s?"1px solid #ccc":"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:u&&!s?"#F7F7F7":"transparent",color:s?"#ccc":"#707070",cursor:s?"not-allowed":"pointer",fontSize:"10px",fontWeight:"600",opacity:s?.5:1}},r)}))))):e.createElement(e.Fragment,null,t?.productDetails?.variants?.edges?.length>1&&e.createElement("div",{className:"yt-comboBundle-product-variant-buttons-horizontal",style:{display:"flex",gap:"8px",flexWrap:"wrap",lineHeight:"normal",marginTop:"10px"}},t?.productDetails?.variants?.edges.map(t=>{const o=0===g(t?.node?.id);return e.createElement("button",{key:t?.node?.id,className:`yt-comboBundle-product-variant-button ${n===t?.node?.id?"yt-comboBundle-product-variant-button-selected":""} ${o?"yt-comboBundle-product-variant-button-disabled":""}`,onClick:()=>f(t?.node?.id),disabled:o,style:{padding:"4px 8px",border:n===t?.node?.id?`1px solid ${d.general?.ctaBackgroundColor}`:"1px solid #E4E4E4",borderRadius:"16px",backgroundColor:n===t?.node?.id?"#F7F7F7":"transparent",color:o?"#ccc":"#707070",cursor:o?"not-allowed":"pointer",fontSize:"12px",fontWeight:"500",opacity:o?.5:1}},t?.node?.title)}))))))},s=({bundle:i,addToCartFunction:c})=>{const[s,u]=t(!1),[p,m]=t(window.innerWidth<786),b=o(()=>(e,t)=>{const o=e?.variants?.edges?.find(e=>e.node.id===t),n=o?.node;return n?e.tracksInventory&&n.inventoryItem?.tracked?n.inventoryQuantity>0?n.inventoryQuantity:n.inventoryQuantity<=0&&"continue"===n.inventoryPolicy?1/0:0:1/0:0},[]),[g,y]=t(()=>{const e={};return i.products.forEach((t,o)=>{const n=t.productDetails?.variants?.edges?.find(e=>b(t.productDetails,e?.node?.id)>0)?.node;e[o]=n?n.id:t?.productDetails?.variants?.edges[0]?.node?.id}),e});n(()=>(c&&(window.ytComboBundle={bundle:i,addToCart:c,selectedVariants:g},window.dispatchEvent(new CustomEvent("yt-combo-bundle-updated",{detail:window.ytComboBundle}))),()=>{window.ytComboBundle=void 0,window.dispatchEvent(new CustomEvent("yt-combo-bundle-updated",{detail:void 0}))}),[i,c,g]);const x=i.products?.every((e,t)=>{const o=g[t];return b(e.productDetails,o)>0}),f=(e,t)=>{y(o=>({...o,[e]:t}))},{originalPrice:h,dealPrice:v,offerValue:B}=o(()=>{const{price:e,compareAtPrice:t}=Object.entries(g).reduce((e,[t,o])=>{const n=i.products[parseInt(t)],r=n.productDetails.variants.edges?.find(e=>e.node.id===o)?.node,l=parseFloat(r?.price??"0"),a=parseFloat(r?.compareAtPrice||l.toString());return e.price+=l,e.compareAtPrice+=a,e},{price:0,compareAtPrice:0}),o=Math.max(e,t);let n=Math.min(e,t);i?.percentageOff?n=e*(1-i.percentageOff/100):i?.dealAmount?n=i.dealAmount:i?.amountOff&&(n=e-i.amountOff);const r=t-n;return{originalPrice:o.toFixed(2),dealPrice:n.toFixed(2),offerValue:r.toFixed(2)}},[g,i.products,i.percentageOff,i.dealAmount,i.amountOff]);n(()=>{const e=()=>{m(window.innerWidth<786)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]);const E=i.customizations,C=E.comboBundle?.comboCardStyle||"auto",N="vertical"===C||"auto"===C&&!p,w=E.comboBundle?.embedContentVisibility,F="bundles"==i.appName?i.pageHeader?.title:i?.title,k="bundles"==i.appName?i.pageHeader?.description:i?.subtitle;return e.createElement("div",{className:`yt-comboBundle-bundle-container ${"left"===E.comboBundle?.infoAlignment?"yt-comboBundle-bundle-align-left":"right"===E.comboBundle?.infoAlignment?"yt-comboBundle-bundle-align-right":"center"===E.comboBundle?.infoAlignment?"yt-comboBundle-bundle-align-center":void 0}`,style:{lineHeight:"normal",maxWidth:"800px",marginBlock:E.comboBundle?.verticalMargin||"0px",display:"flex",flexDirection:"column",alignItems:"left"===E.comboBundle?.infoAlignment?"flex-start":"right"===E.comboBundle?.infoAlignment?"flex-end":"center"===E.comboBundle?.infoAlignment?"center":void 0,textAlign:E.comboBundle?.infoAlignment??"left",fontFamily:"system-ui, -apple-system, sans-serif"}},w&&E.comboBundle?.selectedEmbedContentVisibilityOptions?.includes("Combo Title")&&e.createElement("div",{className:"yt-comboBundle-bundle-title-container",style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"10px"}},e.createElement("h2",{className:"yt-comboBundle-bundle-title",style:{fontSize:E.comboBundle?.productTitleFontSize||"28px",color:E.comboBundle?.titleTextColor||"#000",fontWeight:"bold",lineHeight:"1.6",margin:0}},F)),w&&E?.comboBundle?.selectedEmbedContentVisibilityOptions?.includes("Combo Price")&&e.createElement(e.Fragment,null,e.createElement("div",{className:"yt-comboBundle-bundle-price-container",style:{display:"flex",alignItems:"center",gap:"8px",color:E.comboBundle?.titleTextColor||"#000",fontSize:(parseInt(E.comboBundle?.productTitleFontSize?.replace("px",""))||28)-4+"px"}},e.createElement("div",{className:"yt-comboBundle-bundle-price-details",style:{display:"flex",alignItems:"center",gap:"5px",flexWrap:"wrap"}},e.createElement("span",{className:"yt-comboBundle-bundle-deal-price-text",style:{fontWeight:"bold",lineHeight:"1",minWidth:"fit-content"}},r(E.general.currencySymbol,i.storeCurrencyCode),l(v)),e.createElement("div",{className:"yt-comboBundle-bundle-original-price-text",style:{color:E.comboBundle?.titleTextColor||"#666",textDecoration:"line-through",verticalAlign:"middle",display:"inline-block",minWidth:"fit-content"}},r(E.general.currencySymbol,i.storeCurrencyCode),l(h)),e.createElement("span",{className:"yt-comboBundle-bundle-offer-badge",style:{backgroundColor:"#D3122A",color:"white",padding:"4px 8px",fontSize:"14px",borderRadius:"20px",fontWeight:"500",lineHeight:"1",minWidth:"fit-content"}},i?.percentageOff?`${i?.percentageOff}% Off`:i?.amountOff?`${r(E.general.currencySymbol,i.storeCurrencyCode)}${l(i?.amountOff)} Off`:`Save ${r(E.general.currencySymbol,i.storeCurrencyCode)}${l(B)}`))),e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px",margin:"15px 0px"},className:"yt-comboBundle-checkoutSpecific-container"},e.createElement("div",{style:{display:"flex",width:"12px",height:"12px",justifyContent:"center",alignItems:"center",alignContent:"center",borderRadius:"50%",backgroundColor:E.general?.ctaBackgroundColor||"#1e1e1e",flexShrink:0},className:"yt-comboBundle-checkoutSpecific-dot"},e.createElement("span",null)),e.createElement("p",{style:{fontSize:E.comboBundle.productDescriptionFontSize||"16px",color:E.comboBundle?.descriptionTextColor||"#000",alignItems:"center",margin:0,lineHeight:"1.2"},className:"yt-comboBundle-checkoutSpecific-text"},"Tax included. ",e.createElement("u",null,"Shipping")," calculated at checkout."))),E.comboBundle.subProductsSectionVisibility&&e.createElement(e.Fragment,null,N?e.createElement("div",{className:"yt-comboBundle-products-grid-vertical "+(p?"yt-comboBundle-products-grid-mobile":""),style:{display:"flex",flexDirection:"row",gap:"20px",marginTop:"10px",flexWrap:"wrap"}},i.products.map((t,o)=>{const n=t?.productDetails?.variants?.edges?.find(e=>e?.node?.id===g[o])?.node;return n?e.createElement(d,{key:`combo-product-${o}-${t.productId}`,product:t,styles:E,originalPrice:h,dealPrice:v,selectedVariantId:g[o],onVariantChange:e=>f(o,e),isVertical:N,variantOptions:i.variantOptions,storeCurrencyCode:i.storeCurrencyCode}):null})):e.createElement("div",{className:"yt-comboBundle-products-list-horizontal "+(p?"yt-comboBundle-products-list-mobile":""),style:{display:"flex",flexDirection:"column",gap:"10px",width:"100%"}},E.comboBundle.subProductsSectionVisibility&&i.products.map((t,o)=>e.createElement(d,{key:`combo-product-horizontal-${o}-${t.productId}`,product:t,styles:E,originalPrice:h,dealPrice:v,selectedVariantId:g[o],onVariantChange:e=>f(o,e),variantOptions:i.variantOptions})))),e.createElement("div",{className:"yt-comboBundle-bundle-cta-section",style:{borderTop:"1px solid #eee",display:"flex",flexDirection:"column",rowGap:"5px",marginTop:"20px",width:"100%"}},e.createElement("button",{className:`yt-comboBundle-bundle-cta-button ${x?"":"yt-comboBundle-bundle-cta-button-disabled"} ${p?"yt-comboBundle-bundle-cta-button-mobile":""}`,style:{backgroundColor:x?E.general?.ctaBackgroundColor||"#121212":E.general.disabledButtonColor,color:E.general?.ctaTextColor||"#FFFFFF",fontSize:"16px",borderRadius:E.general.ctaBorderRadius??"20px",fontWeight:"bold",cursor:x?"pointer":"not-allowed",border:`1px solid ${x?E.general?.ctaBackgroundColor||"#121212":E.general.disabledButtonColor}`,boxShadow:E.general.ctaShadowType,padding:E.general?.ctaPadding,width:E.general?.ctaWidth,margin:"0"},disabled:!x,onMouseOver:e=>{E.general.customizeHoverState&&x&&(e.currentTarget.style.backgroundColor=E.general?.ctaHoverBackgroundColor||"#F1F1F1",e.currentTarget.style.color=E.general?.ctaHoverTextColor||"#121212")},onMouseOut:e=>{E.general.customizeHoverState&&x&&(e.currentTarget.style.backgroundColor=E.general?.ctaBackgroundColor||"#121212",e.currentTarget.style.color=E.general?.ctaTextColor||"#FFFFFF")},onClick:async()=>{try{if(u(!0),!c)return console.error("[ComboBundle.tsx] No addToCartFunction available"),void u(!1);const e=Object.entries(g).map(([e,t])=>{const o=i.products[parseInt(e)],n=o.productDetails.variants.edges.find(e=>e.node.id===t)?.node;return n?{variantId:t,price:Number(n.price)}:null}).filter(e=>null!==e),t=Object.values(g);await c(Number(h),t,Number(v),e)}catch(e){console.error("[ComboBundle.tsx] Error adding to cart:",e)}u(!1)}},s?e.createElement(a,{color:"white",loading:s,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}):e.createElement(e.Fragment,null,x?E.comboBundle?.ctaTitle??"Add Bundle to cart":E.general.outOfStockLabel||"Out of Stock"," "))),w&&E.comboBundle?.selectedEmbedContentVisibilityOptions?.includes("Combo Description")&&e.createElement("div",{className:"yt-comboBundle-bundle-description-section",style:{margin:"20px 0px"}},e.createElement("h4",{className:"yt-comboBundle-bundle-description-header",style:{fontSize:"16px",color:E.comboBundle?.descriptionTextColor||"#000",lineHeight:"1.2",margin:0,padding:"8px",backgroundColor:E.general.primaryColor+"20"}},"Description"),e.createElement("div",{className:"yt-comboBundle-bundle-description-content",style:{fontSize:E.comboBundle.productDescriptionFontSize||"16px",color:E.comboBundle?.descriptionTextColor||"#000",lineHeight:"1.2",padding:"8px",backgroundColor:E.general.primaryColor+"08"}},e.createElement("p",null,k))))};export{s as default};
@@ -1 +1 @@
1
- import e from"react";const a=()=>e.createElement("div",{className:"scene"},e.createElement("div",{className:"floating"},e.createElement("div",{className:"cube"},e.createElement("div",{className:"side front"},"‎"),e.createElement("div",{className:"side back"},"‎"),e.createElement("div",{className:"side left"},"‎"),e.createElement("div",{className:"side right"},"‎"),e.createElement("div",{className:"side bottom"},"‎"),e.createElement("div",{className:"lid"},e.createElement("div",{className:"flap north"},"‎"),e.createElement("div",{className:"flap south"},"‎"),e.createElement("div",{className:"flap east"},"‎"),e.createElement("div",{className:"flap west"},"‎")))));export{a as default};
1
+ import e from"react";import"./loader.scss.js";const a=()=>e.createElement("div",{className:"scene"},e.createElement("div",{className:"floating"},e.createElement("div",{className:"cube"},e.createElement("div",{className:"side front"},"‎"),e.createElement("div",{className:"side back"},"‎"),e.createElement("div",{className:"side left"},"‎"),e.createElement("div",{className:"side right"},"‎"),e.createElement("div",{className:"side bottom"},"‎"),e.createElement("div",{className:"lid"},e.createElement("div",{className:"flap north"},"‎"),e.createElement("div",{className:"flap south"},"‎"),e.createElement("div",{className:"flap east"},"‎"),e.createElement("div",{className:"flap west"},"‎")))));export{a as default};
@@ -0,0 +1 @@
1
+ import n from"../../node_modules/style-inject/dist/style-inject.es.js";var t='@media (max-width: 108px) {\n .yt-fixed-bundle-price-section {\n width: 100% !important;\n }\n .yt-fixed-bundle-product-list {\n max-width: 100% !important;\n width: 100% !important;\n justify-content: center !important;\n }\n .price-text {\n text-align: center !important;\n }\n .bundle-builder-add-to-bundle-button {\n font-size: 12px !important;\n padding: 0px 8px !important;\n }\n .quantity .input-text.qty {\n width: 12px !important;\n height: 18px !important;\n }\n .quantity.buttons_added .minus,\n .quantity.buttons_added .plus {\n padding: 6px !important;\n height: 20px !important;\n }\n .bundle-builder-tracker-container {\n justify-content: center !important;\n }\n .bundle-builder-title .bundle-builder-subtitle {\n font-size: 30px !important;\n }\n .bundle-builder-title {\n font-size: 2rem !important;\n }\n .bundle-builder-tracker-item {\n width: 64px !important;\n height: 64px !important;\n }\n .bundle-builder-product-title {\n font-size: 14px !important;\n }\n}\n.hide-tracker-scrollbar {\n overflow-x: auto;\n scrollbar-width: none;\n -ms-overflow-style: none;\n -webkit-overflow-scrolling: touch;\n}\n\n.hide-tracker-scrollbar::-webkit-scrollbar {\n display: none;\n}\n\n.yt-fixed-bundle-border {\n border: 1px solid #c7c7c7;\n}\n\n.yt-fixed-bundle-border-minor-curved {\n border-radius: 8px;\n}\n\n.yt-fixed-bundle-border-minor-curved-image {\n border-radius: 6px;\n}\n\n.yt-fixed-bundle-border-major-curved {\n border-radius: 20px;\n}\n\n.yt-fixed-bundle-border-major-curved-image {\n border-radius: 18px;\n}\n\n@media (min-width: 1200px) {\n .bundle-builder-title .bundle-builder-subtitle {\n font-size: 30px !important;\n }\n}\n@media (max-width: 540px) {\n .bundle-builder-tracker-container {\n gap: 5px !important;\n margin-block: 0 !important;\n }\n .bundle-summary {\n display: flex;\n flex-direction: column !important;\n align-items: flex-start;\n gap: 2px !important;\n }\n .bundle-summary button {\n padding-top: 2px !important;\n padding-inline: 13px !important;\n font-size: 14px !important;\n padding-inline: 10px !important;\n padding: 0px;\n width: -webkit-fill-available;\n }\n .bundle-builder-tracker-progress {\n display: block !important;\n }\n .summary-info {\n width: 100% !important;\n min-width: 200px !important;\n display: flex;\n justify-content: space-between !important;\n flex-direction: row !important;\n flex-grow: 1 !important;\n font-size: 14px !important;\n }\n}\n@media (max-width: 540px) {\n .products-display {\n justify-content: space-between !important;\n column-gap: 5px !important;\n }\n .bundle-builder-product-container {\n width: 49% !important;\n }\n .bundle-builder-title {\n font-size: 1.5rem !important;\n margin-bottom: 8px !important;\n }\n .bundle-builder-subtitle {\n padding-top: 4px;\n font-size: 1rem !important;\n }\n}\n@media (max-width: 540px) {\n .bundle-summary.bundle-filled {\n display: flex !important;\n }\n}\n.yt-bundle-builder-product-price {\n font-weight: 600;\n color: black;\n margin-bottom: 2px;\n}\n\n/* Fixed bundle block */\n.yt-fixed-bundle-fixed-bundle {\n box-sizing: unset;\n max-width: 1000px;\n margin: 0 auto;\n container-type: inline-size;\n text-align: left;\n}\n\n.yt-fixed-bundle-bundle-header {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 10px 0px;\n gap: 8px;\n line-height: normal;\n}\n\n.yt-fixed-bundle-bundle-title {\n font-size: 24px;\n font-weight: 600;\n text-align: center;\n width: 100%;\n}\n\n.yt-fixed-bundle-bundle-subtitle {\n font-size: 16px;\n font-weight: 300;\n text-align: center;\n}\n\n.yt-fixed-bundle-bundle-content {\n display: flex;\n flex-direction: column;\n padding: 10px 0px;\n}\n\n.yt-fixed-bundle-product-list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.yt-product-main {\n width: 100%;\n}\n\n.yt-fixed-bundle-product-card {\n display: flex;\n width: 90%;\n align-items: flex-start;\n padding: 0px;\n box-shadow: 2px 2px 11.8px 0px rgba(0, 0, 0, 0.1411764706);\n transition: transform 0.3s ease, box-shadow 0.3s ease;\n}\n\n.yt-fixed-bundle-product-image-container {\n margin-right: 8px;\n height: 110px;\n position: unset;\n}\n\n.yt-fixed-bundle-product-image {\n max-width: none;\n height: 110px;\n aspect-ratio: 1;\n object-fit: cover;\n}\n\n.yt-fixed-bundle-product-details {\n width: 100%;\n align-self: center;\n display: flex;\n flex-direction: column;\n gap: 6px;\n text-align: left;\n}\n\n.yt-fixed-bundle-product-title {\n font-size: 16px;\n font-weight: 700;\n display: block;\n line-height: 1.4;\n}\n\n.yt-fixed-bundle-product-price {\n font-size: 16px;\n display: block;\n margin-bottom: 6px;\n}\n\n.yt-fixed-bundle-original-price {\n text-decoration: line-through !important;\n color: #6b7280;\n margin-left: 4px;\n}\n\n.yt-fixed-bundle-variant-select-wrapper-desktop {\n position: absolute;\n display: none;\n width: 100%;\n bottom: 6px;\n}\n\n.yt-fixed-bundle-variant-select-wrapper-mobile {\n width: 98%;\n position: relative;\n display: flex;\n}\n\n.yt-fixed-bundle-checkbox-container-desktop {\n position: absolute;\n height: 100%;\n left: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.yt-fixed-bundle-checkbox {\n display: none !important;\n}\n\n.yt-fixed-bundle-checkbox-label {\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: 1px solid #000;\n background: white;\n cursor: pointer;\n color: white !important;\n}\n\n.yt-fixed-bundle-checkbox:checked + .yt-fixed-bundle-checkbox-label {\n border-color: #000;\n color: white !important;\n border: 0px;\n font-size: 16px;\n}\n\n.yt-fixed-bundle-variant-select {\n appearance: none;\n -webkit-appearance: none;\n width: 100%;\n padding: 4px 20px;\n background-color: #ffffff;\n font-size: 15px;\n background-image: none;\n color: #2d2d2d;\n cursor: pointer;\n transition: border-color 0.3s ease, box-shadow 0.3s ease;\n}\n\n.yt-fixed-bundle-variant-select:focus {\n border-color: #cac6c6;\n box-shadow: 0 0 8px 0 rgba(56, 55, 57, 0.3);\n outline: none;\n}\n\n.yt-fixed-bundle-select-dot {\n position: absolute;\n top: 50%;\n left: 10px;\n transform: translateY(-50%);\n font-weight: 700;\n color: #4d4d4d;\n width: 8px; /* Adjust size */\n font-size: 8px;\n border-radius: 50%;\n pointer-events: none;\n}\n\n.yt-fixed-bundle-select-dot::after {\n content: "";\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background-color: #1b1b1b;\n}\n\n.yt-fixed-bundle-select-icon {\n position: absolute;\n top: 50%;\n right: 0;\n transform: translateY(-50%);\n pointer-events: none;\n color: #6b7280;\n background-color: rgba(30, 57, 103, 0.1);\n font-size: 20px;\n height: 100%;\n padding: 0px 5px;\n}\n\n.yt-fixed-bundle-plus-sign {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.yt-fixed-bundle-plus-sign span {\n display: flex;\n justify-content: center;\n width: 24px;\n height: 22px;\n align-items: center;\n padding-bottom: 2px;\n background-color: #f2f2f2;\n color: black;\n border-radius: 2px;\n font-size: 20px;\n font-weight: bold;\n}\n\n.yt-fixed-bundle-price-section {\n display: flex;\n flex-direction: column;\n margin-top: 20px;\n width: 1000px;\n}\n\n.yt-fixed-bundle-subtotal {\n font-size: 13px;\n font-weight: 400 !important;\n}\n\n.yt-fixed-bundle-subtotal-amount {\n font-weight: 600;\n font-size: 13px;\n}\n\n.yt-fixed-bundle-deal-price-container {\n display: flex;\n justify-content: center;\n align-items: center;\n margin-bottom: 12px;\n gap: 8px;\n margin-top: 3px;\n flex-direction: row;\n}\n\n.yt-fixed-bundle-deal-price {\n font-size: 16px;\n font-weight: 600;\n}\n\n.yt-fixed-bundle-extra-savings {\n font-size: 12px;\n color: #f6f8f7;\n padding: 4px 8px;\n background-color: #d3122a;\n border-radius: 2px;\n font-weight: 700 !important;\n}\n\n.yt-fixed-bundle-add-to-cart-button {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n background-color: #8b5cf6;\n border: none;\n padding: 8px 0px;\n font-size: 16px;\n font-weight: 500 !important;\n cursor: pointer;\n width: 100%;\n}\n\n.yt-fixed-bundle-add-to-cart-button:disabled,\n.yt-fixed-bundle-add-to-cart-button[disabled] {\n color: #7d7d7d;\n cursor: default;\n}\n\n.yt-fixed-bundle-product-card.horizontal {\n max-width: 100%;\n flex-direction: row;\n}\n\n.yt-fixed-bundle-product-card.horizontal:hover {\n transform: none;\n}\n\n.yt-fixed-bundle-product-list.horizontal {\n width: 100%;\n flex-direction: row;\n justify-content: center;\n align-items: stretch;\n flex-wrap: wrap;\n gap: 15px;\n}\n\n.yt-product-main.horizontal {\n width: 100%;\n}\n\n.yt-fixed-bundle-product-image-container.horizontal {\n height: 110px;\n margin-bottom: 0px;\n position: unset;\n width: 30%;\n}\n\n.yt-fixed-bundle-product-image.horizontal {\n height: 110px;\n aspect-ratio: 1;\n object-fit: cover;\n user-select: none;\n}\n\n.yt-fixed-bundle-variant-select-wrapper-desktop.horizontal {\n position: absolute;\n display: none;\n width: 100%;\n bottom: 6px;\n}\n\n.yt-fixed-bundle-variant-select-wrapper-mobile.horizontal {\n width: 98%;\n position: relative;\n display: flex;\n}\n\n.yt-fixed-bundle-checkbox-container-desktop.horizontal {\n position: absolute;\n height: 100%;\n left: -8px;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.yt-fixed-bundle-product-details.horizontal {\n padding-left: 0px;\n}\n\n.yt-fixed-bundle-product-price.horizontal {\n margin-bottom: 0px;\n}\n\n@media (min-width: 100px) {\n @container (width > 100px) {\n .yt-fixed-bundle-fixed-bundle {\n padding: 40px;\n }\n .yt-fixed-bundle-variant-select-wrapper-desktop {\n position: absolute;\n display: flex;\n width: 100%;\n bottom: 6px;\n }\n .yt-fixed-bundle-variant-select-wrapper-mobile {\n display: none;\n width: 100%;\n }\n .yt-fixed-bundle-checkbox-label {\n width: 24px;\n height: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: 1px solid #000;\n background: white;\n cursor: pointer;\n color: white !important;\n }\n .yt-fixed-bundle-checkbox:checked + .yt-fixed-bundle-checkbox-label {\n border-color: #000;\n color: white !important;\n border: 0px;\n font-size: 16px;\n }\n .yt-fixed-bundle-variant-select {\n margin: 0px 4px;\n }\n .yt-fixed-bundle-select-icon {\n right: 4px;\n }\n .yt-fixed-bundle-bundle-title {\n font-size: 32px;\n }\n .yt-fixed-bundle-bundle-subtitle {\n font-size: 20px;\n }\n .yt-fixed-bundle-bundle-content {\n flex-direction: column;\n justify-content: space-between;\n align-items: flex-start;\n }\n .yt-fixed-bundle-product-list {\n width: 100%;\n flex-direction: row;\n justify-content: center;\n align-items: stretch;\n flex-wrap: wrap;\n gap: 15px;\n }\n .yt-fixed-bundle-product-card {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n align-items: center;\n text-align: center;\n }\n .yt-fixed-bundle-product-image-container {\n width: 100%;\n height: 100%;\n margin-right: 0;\n margin-bottom: 12px;\n justify-content: center;\n position: relative;\n }\n .yt-fixed-bundle-product-details {\n width: 100%;\n align-self: center;\n display: flex;\n flex-direction: column;\n gap: 6px;\n text-align: left;\n }\n .yt-fixed-bundle-product-image {\n height: 230px;\n width: 100%;\n aspect-ratio: 1;\n align-self: center;\n }\n .yt-fixed-bundle-plus-sign {\n align-self: center;\n margin-left: 0;\n }\n .yt-fixed-bundle-price-section {\n width: 100%;\n margin-top: 32px;\n align-items: center;\n justify-content: center;\n text-align: center;\n }\n .yt-fixed-bundle-extra-savings {\n font-size: 10px;\n }\n .yt-fixed-bundle-subtotal {\n font-size: 15px;\n }\n .yt-fixed-bundle-subtotal-amount {\n font-size: 15px;\n }\n .yt-fixed-bundle-checkbox-container-desktop {\n position: absolute;\n top: 8px;\n left: 10px;\n height: auto;\n display: flex;\n align-items: center;\n }\n .yt-fixed-bundle-deal-price {\n font-size: 24px;\n }\n .yt-fixed-bundle-extra-savings {\n font-size: 13px;\n padding: 4px 8px;\n }\n .yt-fixed-bundle-add-to-cart-button {\n font-size: 20px;\n padding: 10px 0px;\n width: 100%;\n }\n .yt-product-main {\n width: 29%;\n }\n .yt-fixed-bundle-product-card:hover {\n transform: translateY(-5px);\n box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.1411764706);\n }\n }\n}\n.yt-product-main {\n display: flex;\n position: relative;\n}\n\n/* Container query */\n@container (max-width: 100px) {\n .yt-fixed-bundle-variant-select-wrapper-desktop {\n position: absolute;\n display: none;\n width: 100%;\n bottom: 6px;\n }\n .yt-product-main {\n width: 100%;\n }\n .yt-fixed-bundle-variant-select-wrapper-mobile {\n width: 98%;\n position: relative;\n display: flex;\n bottom: 6px;\n }\n .yt-fixed-bundle-product-image {\n height: 110px;\n aspect-ratio: 1;\n object-fit: cover;\n }\n .yt-fixed-bundle-variant-select-wrapper {\n position: relative;\n width: 100%;\n }\n .yt-fixed-bundle-checkbox-container-desktop {\n position: absolute;\n height: 100%;\n left: -8px;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .yt-fixed-bundle-product-image-container {\n margin-right: 8px;\n height: 110px;\n margin-bottom: 0px;\n position: unset;\n }\n .yt-fixed-bundle-product-card {\n max-width: 100%;\n flex-direction: row;\n }\n .yt-fixed-bundle-price-section {\n width: 100%;\n }\n}\n.yt-product-card-transition {\n opacity: 0;\n transform: translateY(20px);\n transition: transform 0.6s ease, box-shadow 0.6s ease;\n}\n\n.yt-product-card-transition-up {\n opacity: 0;\n transform: translateY(-20px);\n transition: opacity 0.6s ease, transform 0.6s ease;\n}\n\n.yt-product-card-transition-active {\n opacity: 1;\n transform: translateY(0);\n}\n\n.yt-description-content img,\n.yt-collection-bundle-modal-description img,\n.yt-collection-bundle-modal-description iframe {\n max-width: 100%;\n height: auto;\n display: block;\n margin: 0 auto 15px;\n border-radius: 7px;\n}\n\n.yt-description-content,\n.yt-collection-bundle-modal-description {\n text-align: left;\n overflow-wrap: break-word;\n}';n(t);export{t as default};
@@ -0,0 +1 @@
1
+ import n from"../../node_modules/style-inject/dist/style-inject.es.js";var t=".scene {\n width: 100%;\n height: 60vh;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.floating {\n animation: float 3s ease-in-out infinite;\n}\n\n@keyframes float {\n 0%, 100% {\n transform: translateY(0);\n }\n 50% {\n transform: translateY(-10px);\n }\n}\n.cube {\n position: relative;\n width: 50px;\n height: 50px;\n transform-style: preserve-3d;\n transform: rotateX(-45deg) rotateY(50deg) rotateZ(0deg);\n}\n\n.side,\n.lid,\n.flap {\n position: absolute;\n width: 100px;\n height: 100px;\n border: 4px solid #333366;\n background: transparent;\n box-sizing: border-box;\n}\n\n.side {\n background: #fff;\n backface-visibility: hidden;\n}\n\n.side.front {\n transform: translateZ(50px);\n}\n\n.side.back {\n transform: rotateY(180deg) translateZ(50px);\n}\n\n.side.left {\n transform: rotateY(-90deg) translateZ(50px);\n}\n\n.side.right {\n transform: rotateY(90deg) translateZ(50px);\n}\n\n.side.bottom {\n transform: rotateX(-90deg) translateZ(50px);\n}\n\n.lid {\n transform: rotateX(90deg) translateZ(50px);\n transform-style: preserve-3d;\n}\n\n.flap.north {\n top: 0;\n left: 0;\n width: 100%;\n height: 50%;\n transform-origin: top center;\n animation: openNorth 3s ease-in-out infinite;\n}\n\n.flap.south {\n bottom: 0;\n left: 0;\n width: 100%;\n height: 50%;\n transform-origin: bottom center;\n animation: openSouth 3s ease-in-out infinite;\n}\n\n.flap.east {\n top: 0;\n right: 0;\n width: 50%;\n height: 100%;\n transform-origin: right center;\n animation: openEast 3s ease-in-out infinite;\n}\n\n.flap.west {\n top: 0;\n left: 0;\n width: 50%;\n height: 100%;\n transform-origin: left center;\n animation: openWest 3s ease-in-out infinite;\n}\n\n@keyframes openNorth {\n 0%, 100% {\n transform: rotateX(0deg);\n }\n 50% {\n transform: rotateX(180deg);\n }\n}\n@keyframes openSouth {\n 0%, 100% {\n transform: rotateX(0deg);\n }\n 50% {\n transform: rotateX(-180deg);\n }\n}\n@keyframes openEast {\n 0%, 100% {\n transform: rotateY(0deg);\n }\n 50% {\n transform: rotateY(180deg);\n }\n}\n@keyframes openWest {\n 0%, 100% {\n transform: rotateY(0deg);\n }\n 50% {\n transform: rotateY(-180deg);\n }\n}";n(t);export{t as default};
@@ -1,4 +1,4 @@
1
- import e,{useState as t,useRef as o,useEffect as r}from"react";import{FaChevronDown as a,FaChevronUp as n}from"react-icons/fa";import{RxInfoCircled as i}from"react-icons/rx";import{RiCloseLine as s}from"react-icons/ri";import{useAtomValue as l,useAtom as c}from"jotai";import{cartDataState as m}from"../../atoms/cartDataAtom.js";import{deliveryOptionChosenState as d,deliveryTypeState as u}from"../../atoms/shippingAtom.js";import{deliverySlotDateState as p}from"../../atoms/dateAtom.js";import{cartLoadingState as C,useCartLoading as h}from"../../atoms/cartLoadingAtom.js";import{variantSelectionModalState as y}from"../../atoms/variantSelectionModalAtom.js";import{getCurrencyValueFromShopifyPrice as g}from"../../utils/converter.js";import f from"styled-components";import w from"./ProductRecList.js";import T from"./MultiStepProgressBar/MultiStepProgressBar.js";import x from"./EmptyCart.js";import b from"./CheckoutSection.js";import P from"./LoyaltyGuestCTA.js";import S from"./FooterSections.js";import v from"./LoyaltyApplyCTA.js";import k from"./LoyaltyAppliedCTA.js";import B from"./CartProductsList.js";import E from"./Bundle.js";import D from"./GSTSection.js";import I from"./NoteSection.js";import L from"./FreebieClaimManager.js";import O from"./InlineCartOfferInfoText.js";import $ from"./RegionSpecificDelivery.js";import A from"./StandardDelivery.js";import R from"./GiftWrap.js";import M from"./CartTimer.js";import j from"./CartOffersCarousel.js";import F from"./ProgressBarCartLoader.js";import _ from"./RewardPointsPreview.js";import N from"./LoyaltyBadge.js";import V from"./ApplyCoupon.js";import W from"./MultiStepProgressBar/CheckpointConfetti.js";import{hasAnyProgress as z}from"./MultiStepProgressBar/MultiStepUtils.js";import G from"./SubtotalSection.js";const U=f.div`
1
+ import e,{useState as t,useRef as o,useEffect as r}from"react";import{FaChevronDown as a,FaChevronUp as n}from"react-icons/fa";import{RxInfoCircled as i}from"react-icons/rx";import{RiCloseLine as s}from"react-icons/ri";import{useAtomValue as l,useAtom as c}from"jotai";import{cartDataState as m}from"../../atoms/cartDataAtom.js";import{deliveryOptionChosenState as d,deliveryTypeState as u}from"../../atoms/shippingAtom.js";import{deliverySlotDateState as p}from"../../atoms/dateAtom.js";import{cartLoadingState as C,useCartLoading as h}from"../../atoms/cartLoadingAtom.js";import{variantSelectionModalState as y}from"../../atoms/variantSelectionModalAtom.js";import{getCurrencyValueFromShopifyPrice as g}from"../../utils/converter.js";import f from"styled-components";import w from"./ProductRecList.js";import T from"./MultiStepProgressBar/MultiStepProgressBar.js";import x from"./EmptyCart.js";import b from"./CheckoutSection.js";import P from"./LoyaltyGuestCTA.js";import S from"./FooterSections.js";import v from"./LoyaltyApplyCTA.js";import k from"./LoyaltyAppliedCTA.js";import B from"./CartProductsList.js";import E from"./Bundle.js";import D from"./GSTSection.js";import I from"./NoteSection.js";import L from"./FreebieClaimManager.js";import O from"./InlineCartOfferInfoText.js";import $ from"./RegionSpecificDelivery.js";import A from"./StandardDelivery.js";import R from"./GiftWrap.js";import j from"./CartTimer.js";import M from"./CartOffersCarousel.js";import F from"./ProgressBarCartLoader.js";import _ from"./RewardPointsPreview.js";import N from"./LoyaltyBadge.js";import"./shared.scss.js";import V from"./ApplyCoupon.js";import W from"./MultiStepProgressBar/CheckpointConfetti.js";import{hasAnyProgress as z}from"./MultiStepProgressBar/MultiStepUtils.js";import G from"./SubtotalSection.js";const U=f.div`
2
2
  line-height: normal;
3
3
  position: ${e=>e.$enableCustomCartOnCartPage&&e.$isCartPage?"relative":"fixed"};
4
4
  top: ${e=>e.$enableCustomCartOnCartPage&&e.$isCartPage?"auto":"0"};
@@ -33,4 +33,4 @@ import e,{useState as t,useRef as o,useEffect as r}from"react";import{FaChevronD
33
33
  font-weight: 400;
34
34
  min-width: 14px;
35
35
  line-height: 14px;
36
- `,X=({isOpen:f,setIsOpen:X,backgroundColor:q="white",backgroundSubdued:Q="#3947821F",tertiaryColor:Y="#067D431A",tertiaryTextColor:J="#000000",exploreCTAColor:K,checkoutFontSize:Z,cartTitle:ee="My Cart",emptyCartTitle:te,emptyCartDescription:oe,emptyCartButtons:re,removeCartItem:ae,handleIncrement:ne,handleDecrement:ie,addCartItem:se,isUserSignedIn:le,showBundle:ce,bundleProducts:me,discountAmountOff:de,loyaltyIcon:ue,pointsToBeUsed:pe,rewardMultiplier:Ce,redemptionMultiplier:he,discountApplied:ye,removeDiscount:ge,applyDiscount:fe,checkoutFunction:we,joinNowFunction:Te,guestLoyaltyPercentage:xe,isDev:be,recProductsList:Pe,showMultiStepProgressBar:Se,cartCheckpoints:ve,redemptionRate:ke,pointsRewardRate:Be,showCartLevelAltPay:Ee,exploreCtaRedirectLink:De,discountAmountApplied:Ie,minimumCartValue:Le,discountInCheckoutButton:Oe,isStickyCheckout:$e,handleCheckpointCrossed:Ae,customCartProgressBarCriteria:Re,checkoutButtonColor:Me="#252E69",ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,productRecsCtaButtonText:Ve,productRecsTitleText:We,emptyProductRecsTitleText:ze,showProductRecsOnDesktop:Ge,showProductRecsOnMobile:Ue,themeColor:He,themeTextColor:Xe,companyName:qe,gstNumber:Qe,showGSTOption:Ye,applyGSTToCart:Je,showMOVForProgressTiers:Ke,freeProduct:Ze,showLoyaltyCta:et=!1,freeProductAdjustedCartTotal:tt,minimumOrderValueToAvailDiscount:ot,signinCTAButtonVisible:rt,cartSigninCTAMainText:at,applyNoteToCart:nt,note:it,showNoteOption:st,inlineCartOfferInfoText:lt,inlineCartOfferInfoRedirectLink:ct,cartOfferTermsAndConditionsText:mt,showEditOptionOnProducts:dt,onSetLoading:ut,showVariantSelectionDropdownInProductRecs:pt,originalCartSubtotal:Ct,freebieProductsInCart:ht,showFreebieClaim:yt,addFreebieToCart:gt,freebiesInCart:ft,effectiveQuantityForProgressBar:wt,productPercentageOffMapping:Tt,removeFreebieFromCart:xt,postalCodeList:bt,enableGeoLocationDeliveryRestriction:Pt=!1,getProductDetailsByVariantId:St,applyPostalCodeAndDeliverySlotToCart:vt,showDeleteOnFreebies:kt,freebieCouponTemplates:Bt,freebieFlowCheckpoints:Et,freebieClaimData:Dt,postalCodeBasedItemTrackingParameter:It,enableSlotPicker:Lt,deliveryHeaderTitle:Ot,deliveryAvailableText:$t,deliveryNotAvailableText:At,giftWrapSetupData:Rt,giftWrapProductDetail:Mt,progressBarFreeProductIconType:jt,enableCustomCartOnCartPage:Ft,isCartPage:_t,showCartTimer:Nt,showFreebieMilestone:Vt,freebieMilestoneData:Wt,cartTimerInMinutes:zt,cartTimerCustomText:Gt,productRecsCardLayout:Ut,productRecsCardListVariant:Ht,imageAspectSelector:Xt,cartComponentsCornerType:qt,cartComponentsCornerRadius:Qt,cartOffersCarousalData:Yt,gstSectionCustomizationData:Jt,noteSectionTitle:Kt,checkoutSectionMessage:Zt,checkoutSectionMessageDisplay:eo,showVariantSelectionDropdownInProductClaim:to,loyaltyDiscount:oo,brandTokenName:ro,showDiscountOnMRP:ao,switchWidthVariant:no,prefixMessageText:io,suffixMessageText:so,successMessageText:lo,toggleDecimal:co,cartOffersCarouselHeight:mo,disableCheckoutButton:uo,showEmptyCartRecommendations:po=!1,checkoutButtonBottomSpacing:Co,showPoweredByBadge:ho,applyCouponCode:yo,showApplyCoupon:go,enableConfetti:fo,checkoutSectionMessageRedirectLink:wo,showCheckoutButtonPaymentIcons:To})=>{const xo=l(m),bo=l(C),[Po,So]=t(!1),[vo,ko]=t(!1),[Bo,Eo]=t(!0),{setLoading:Do}=h();e.useEffect(()=>{ut&&ut(Do)},[ut]);const Io=o(!1),Lo=o(null),Oo=o(null);r(()=>{const e=()=>{X(!1)};return f?(Io.current||(Lo.current=window.history.state,Oo.current=window.location.href,window.history.pushState({ytCustomCartDrawer:"open"},"")),window.addEventListener("popstate",e),Io.current=!0):(Io.current&&"open"===window.history.state?.ytCustomCartDrawer&&window.history.replaceState(Lo.current,"",Oo.current??window.location.href),Io.current=!1),()=>{window.removeEventListener("popstate",e)}},[f,X]);const[$o,Ao]=t(!1);r(()=>{const e=document.querySelector("body");e&&(Ft&&_t?e.classList.remove("drawer-open"):!$o&&f?e.classList.add("drawer-open"):e.classList.remove("drawer-open"))},[f,Ft,_t,$o]),r(()=>{function e(){const e=window.innerWidth;Ao(e>=450)}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]);const Ro=xo?.items?.reduce((e,t)=>e+t?.quantity,0);r(()=>{const e=()=>{So(!0),window.setTimeout(()=>So(!1),3e3)};return window.addEventListener("yt:autoFreebieAdded",e),()=>window.removeEventListener("yt:autoFreebieAdded",e)},[]);const[Mo,jo]=t("normal"),[Fo,_o]=t("normal"),[No,Vo]=t("auto");r(()=>{CSS.supports("font-weight","500")?jo("500"):CSS.supports("font-weight","400")?jo("400"):CSS.supports("font-weight","600")&&jo("600"),CSS.supports("font-weight","400")?_o("400"):CSS.supports("font-weight","300")?_o("300"):CSS.supports("font-weight","200")&&_o("200"),CSS.supports("width","-webkit-fill-available")?Vo("-webkit-fill-available"):CSS.supports("width","-moz-available")&&Vo("-moz-available")},[]),r(()=>{document.documentElement.style.setProperty("--yt-cart-font-weight",Mo),document.documentElement.style.setProperty("--yt-cart-product-rec-price-font-weight",Fo),document.documentElement.style.setProperty("--yt-cart-custom-fill-width",No)},[Mo,Fo]);const[Wo]=c(d),[zo]=c(p),[Go]=c(u);r(()=>{Eo(!("all-products"!==It&&("specific-tags"!==It||Wo.isPostalCodeValid||Lt)&&("specific-tags"!==It||Wo.isPostalCodeValid||zo||!Lt)&&("specific-tags"===It&&"standard"===Go||vo&&(Lt?Wo.isPostalCodeValid&&zo:Wo.isPostalCodeValid))))},[Wo.isPostalCodeValid,zo,vo,It,Lt]),c(y);const[Uo,Ho]=t(!0);r(()=>{"true"===localStorage.getItem("cartTimerRanOnce")&&Ho(!1);const e=localStorage.getItem("cartTimerTimeLeft");e&&parseInt(e,10)<=0&&Ho(!1)},[]);const Xo=new Date("2024-11-01");return g(xo?.items_subtotal_price,xo?.currency),e.createElement(U,{className:"yt-cart-drawer",$isDev:be,$isOpen:f,$backgroundColor:q,$enableCustomCartOnCartPage:Ft,$isCartPage:_t,$isLargeScreen:$o,$switchWidthVariant:no},bo.cartLoading?e.createElement("div",{style:{backgroundColor:"#fff",width:"100%",height:"100%",alignItems:"center",justifyContent:"center",display:"flex",position:"absolute",opacity:0,zIndex:51}},bo.showLoader&&!bo.showSkeletonLoader&&e.createElement("div",{className:"loader"},"‎")):e.createElement(e.Fragment,null),e.createElement(e.Fragment,null,e.createElement("div",{className:"yt-cart-drawer-content",style:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"space-between"}},e.createElement("div",null,e.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",margin:"1rem 1rem 0px"}},e.createElement("span",{className:"yt-cart-title-container",style:{fontWeight:"var(--yt-cart-font-weight, bold)",color:_e,fontSize:"16px"}},e.createElement("span",{style:{whiteSpace:"nowrap",flexShrink:0}},ee),xo?.item_count>0&&Ee&&!(et&&Ee)&&Be>0&&e.createElement(N,{pointsRewardRate:Be,loyaltyIcon:ue,brandTokenName:ro,themeColor:He,themeTextColor:Xe,rewardMultiplier:Ce}),Ro>0&&e.createElement(H,{$backgroundSubdued:Q},Ro)),e.createElement("div",{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center"}},!(Ft&&_t)&&e.createElement("div",{className:"close-button",style:{backgroundColor:Q||"#cacaca30"}},e.createElement(s,{style:{height:"auto",width:"auto",color:_e},fontSize:24,cursor:"pointer",onClick:()=>{X(!f)}})))),bo&&e.createElement(F,{$themeColor:He,show:bo.showLoader}),Yt?.enableCartOffersCarousel&&e.createElement(j,{themeColor:He,cartOffersCarousalData:Yt,cartOffersCarouselHeight:mo,cartData:xo}),Nt&&Uo&&xo?.item_count?e.createElement(M,{minutes:zt,customText:Gt,onTimerComplete:()=>{Ho(!1),localStorage.setItem("cartTimerRanOnce","true"),localStorage.removeItem("timeLeft"),localStorage.removeItem("lastUpdate")}}):null,Po&&fo&&e.createElement(W,{particleCount:50,spread:90,origin:{y:.3}}),lt?e.createElement(O,{inlineCartOfferInfoText:lt,inlineCartOfferInfoRedirectLink:ct,themeColor:He,tooltipText:mt,themeTextColor:Xe}):null),Se&&xo?.items_subtotal_price>0&&xo?.currency&&!!ve&&z(ve,g(void 0!==Ct?Ct:xo?.items_subtotal_price,xo.currency),void 0===wt?xo?.item_count:wt,Re??"minimum_order_value",xo?.item_count)&&e.createElement(e.Fragment,null,e.createElement(T,{customCartProgressBarCriteria:Re??"minimum_order_value",handleCheckpointCrossed:Ae,checkpoints:ve,effectiveQuantityForProgressBar:void 0===wt?xo?.item_count:wt,currentCartAmount:g(void 0!==Ct?Ct:xo?.items_subtotal_price,xo.currency),themeColor:He,themeTextColor:Xe,primaryTextColor:_e,secondaryTextColor:Ne,showMOVForProgressTiers:Ke,progressBarFreeProductIconType:jt,ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,prefixMessageText:io,suffixMessageText:so,successMessageText:lo,enableConfetti:fo})),xo?.item_count>0&&e.createElement("div",{style:{display:"flex",height:"12px",background:"#87878717"}}),0===xo?.items?.length&&0===xo?.item_count&&!1===bo?.showSkeletonLoader?e.createElement(x,{showLoyaltyCta:et,joinNowFunction:Te,emptyCartTitle:te,emptyCartDescription:oe,exploreCTAColor:K,isUserSignedIn:le,exploreCtaRedirectLink:De,themeColor:He,emptyCartButtons:re,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,themeTextColor:Xe,recProductsList:Pe,addCartItem:se,productRecsCtaButtonText:Ve,ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,showVariantSelectionDropdownInProductRecs:pt,emptyProductRecsTitleText:ze,backgroundSubdued:Q,showEmptyCartRecommendations:po,tertiaryColor:Y,tertiaryTextColor:J}):e.createElement("div",{style:{display:"flex",flexDirection:"column",overflowY:"auto",flex:1,overflowX:"hidden",height:"100%",scrollbarWidth:"none"}},e.createElement(B,{isDev:be,themeColor:He,handleDecrement:ie,handleIncrement:ne,removeCartItem:ae,addCartItem:se,primaryTextColor:_e,secondaryTextColor:Ne,freeProduct:Ze,themeTextColor:Xe,showEditOptionOnProducts:dt,productPercentageOffMapping:Tt,removeFreebieFromCart:xt,showDeleteOnFreebies:kt,freebieCouponTemplates:Bt??[],freebieFlowCheckpoints:Et??[],cartCheckpoints:ve,freeProductAdjustedCartTotal:tt,imageAspectSelector:Xt,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,giftWrapVariantId:Mt?.variants?.nodes[0]?.id,giftWrapProductId:Rt?.giftProductId,showGiftWrapAsLineItem:Rt?.showGiftWrapAsLineItem,backgroundSubdued:Q,tertiaryColor:Y,tertiaryTextColor:J,backgroundColor:q,showDiscountOnMRP:ao,checkoutSectionMessage:Zt,checkoutSectionMessageRedirectLink:wo,showFreebieMilestone:Vt,freebieMilestoneData:Wt}),$o&&Ge&&!!Pe&&Pe?.length>0&&xo?.item_count>0&&se&&e.createElement(w,{addCartItem:se,products:Pe,productRecsCtaButtonText:Ve,ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,productRecsTitleText:We,themeColor:He,primaryTextColor:_e,secondaryTextColor:Ne,showVariantSelectionDropdownInProductRecs:pt,cardLayout:Ut,variant:Ht,cartComponentsCornerType:qt,cartComponentsCornerRadius:Qt,backgroundSubdued:Q,backgroundColor:q,tertiaryColor:Y,tertiaryTextColor:J}),!$o&&Ue&&!!Pe&&Pe?.length>0&&xo?.item_count>0&&se&&e.createElement(w,{addCartItem:se,products:Pe,productRecsCtaButtonText:Ve,ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,productRecsTitleText:We,themeColor:He,primaryTextColor:_e,secondaryTextColor:Ne,showVariantSelectionDropdownInProductRecs:pt,cardLayout:Ut,variant:Ht,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,backgroundSubdued:Q,tertiaryColor:Y,tertiaryTextColor:J}),"devlhok.myshopify.com"===window.ytapp?.storeDomain&&e.createElement(G,{showDiscountOnMRP:ao,cartCheckpoints:ve,toggleDecimal:co,primaryTextColor:_e,discountApplied:ye,showPoweredByBadge:ho})),e.createElement(S,null,xo?.item_count>0&&ce&&me&&e.createElement(E,{bundleProducts:me}),Ye&&!!Je&&xo?.item_count>0&&e.createElement(D,{companyName:qe,gstNumber:Qe,themeColor:He,iconColor:Jt?.iconColor,showIcon:Jt?.showIcon,backgroundColor:Jt?.backgroundColor,textColor:Jt?.textColor,title:Jt?.title}),!!xo&&xo?.item_count>0&&!!gt&&!!ht&&!!ft&&ht.length>0&&e.createElement(L,{freebieProductsInCart:ht,themeColor:He,themeTextColor:Xe,primaryTextColor:_e,addFreebieToCart:gt,freebiesInCart:ft,imageAspectSelector:Xt,freebieCouponTemplates:Bt,freebieClaimData:Dt,cartCheckpoints:ve,isCartDrawerOpen:f}),Pt&&(bt?.length??0)>0&&!!vt&&xo?.item_count>0&&e.createElement("div",{className:"form-group"},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"6px 1rem 1rem 1rem"},onClick:()=>Eo(!Bo)},e.createElement("span",{style:{fontSize:"12px",display:"flex",gap:"5px",alignItems:"center"}},"Shipping ",e.createElement(i,null)),e.createElement("div",{className:"icon-transition"},Bo?e.createElement(a,null):e.createElement(n,null))),"all-products"===It&&Bo?e.createElement($,{postalCodeList:bt,themeColor:He,themeTextColor:Xe,enableSlotPicker:Lt,deliveryHeaderTitle:Ot,deliveryAvailableText:$t,deliveryNotAvailableText:At,disabledDates:Xo}):Bo&&(vo?e.createElement($,{postalCodeList:bt,themeColor:He,themeTextColor:Xe,enableSlotPicker:Lt,deliveryHeaderTitle:Ot,deliveryAvailableText:$t,deliveryNotAvailableText:At,disabledDates:Xo}):e.createElement(A,{postalCodeList:bt,themeColor:He,themeTextColor:Xe,enableSlotPicker:Lt,disabledDates:Xo}))),st&&!!nt&&xo?.item_count>0&&e.createElement(I,{note:it,noteSectionTitle:Kt}),Rt?.showGiftWrapOption&&xo?.item_count>0&&e.createElement(R,{themeColor:He,id:Rt?.giftProductId,detail:Mt,showPrice:Rt?.showPrice,errorText:Rt?.errorText,customText:Rt?.customText,showGiftIcon:Rt?.showGiftIcon,showProductImage:Rt?.showProductImage,addCartItem:se,removeCartItem:ae}),xo?.item_count>0&&go&&!et&&yo&&e.createElement(V,{backgroundSubdued:Q,themeColor:He,themeTextColor:Xe,primaryTextColor:_e,cartComponentsCornerRadius:Qt,applyCouponCode:yo,removeDiscount:ge,enableConfetti:fo}),xo?.item_count>0&&e.createElement(e.Fragment,null,le||!et||oo?!oo&&void 0!==de&&void 0!==pe&&!!ue&&et&&!!fe&&e.createElement(v,{themeColor:He,applyDiscount:fe,discountAmountOff:de,loyaltyIcon:ue,pointsToBeUsed:pe,ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,minimumOrderValueToAvailDiscount:ot,brandTokenName:ro,showCartLevelAltPay:Ee,redemptionMultiplier:he}):!!xe&&!!Te&&e.createElement(P,{cartSigninCTAMainText:at,signinCTAButtonVisible:rt,themeColor:He,joinNowFunction:Te,guestLoyaltyPercentage:xe,ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,showCartLevelAltPay:Ee})),xo?.item_count>0&&!!oo&&!!ge&&et&&oo&&void 0!==pe&&e.createElement(k,{themeColor:He,removeDiscount:ge,loyaltyDiscount:oo,isDev:be,ctaButtonBackgroundColor:je,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,pointsToBeUsed:pe,brandTokenName:ro,showCartLevelAltPay:Ee}),et&&Ee&&ke&&ue&&xo?.item_count>0&&e.createElement(_,{loyaltyIcon:ue,backgroundSubdued:Q,primaryTextColor:_e,pointsRewardRate:Be,rewardMultiplier:Ce}),et&&xo&&xo.item_count>0&&!!ot&&ot>1&&e.createElement("span",{className:"yt-cart-loyalty-mov-text",style:{fontSize:"10px",color:He??"#50D1AA",fontWeight:600,display:"flex",justifyContent:rt?"space-between":"center"}},"Minimum order value to use ",ro,":"," ",ot),xo&&we&&xo?.item_count>0&&e.createElement("div",null,e.createElement(b,{disableCheckoutButton:!!uo||bo.cartLoading,discountApplied:ye,checkoutFunction:we,checkoutButtonColor:Me,checkoutFontSize:Z,discountInCheckoutButton:Oe,isStickyCheckout:$e,discountAmountApplied:Ie,minimumCartValue:Le,themeTextColor:Xe,applyGSTToCart:Je,showGSTOption:Ye,applyNoteToCart:nt,showNoteOption:st,enableGeoLocationDeliveryRestriction:Pt,applyPostalCodeAndDeliverySlotToCart:vt,enableSlotPicker:Lt,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,checkoutSectionMessage:Zt,checkoutSectionMessageDisplay:eo,checkoutSectionMessageRedirectLink:wo,showDiscountOnMRP:ao,tertiaryColor:Y,tertiaryTextColor:J,cartCheckpoints:ve,toggleDecimal:co,checkoutButtonBottomSpacing:Co,showPoweredByBadge:ho,showCheckoutButtonPaymentIcons:To,primaryTextColor:_e,hideSubtotalAndBadge:"devlhok.myshopify.com"===window.ytapp?.storeDomain}))))))};export{X as default};
36
+ `,X=({isOpen:f,setIsOpen:X,backgroundColor:q="white",backgroundSubdued:Q="#3947821F",tertiaryColor:Y="#067D431A",tertiaryTextColor:J="#000000",exploreCTAColor:K,checkoutFontSize:Z,cartTitle:ee="My Cart",emptyCartTitle:te,emptyCartDescription:oe,emptyCartButtons:re,removeCartItem:ae,handleIncrement:ne,handleDecrement:ie,addCartItem:se,isUserSignedIn:le,showBundle:ce,bundleProducts:me,discountAmountOff:de,loyaltyIcon:ue,pointsToBeUsed:pe,rewardMultiplier:Ce,redemptionMultiplier:he,discountApplied:ye,removeDiscount:ge,applyDiscount:fe,checkoutFunction:we,joinNowFunction:Te,guestLoyaltyPercentage:xe,isDev:be,recProductsList:Pe,showMultiStepProgressBar:Se,cartCheckpoints:ve,redemptionRate:ke,pointsRewardRate:Be,showCartLevelAltPay:Ee,exploreCtaRedirectLink:De,discountAmountApplied:Ie,minimumCartValue:Le,discountInCheckoutButton:Oe,isStickyCheckout:$e,handleCheckpointCrossed:Ae,customCartProgressBarCriteria:Re,checkoutButtonColor:je="#252E69",ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,productRecsCtaButtonText:Ve,productRecsTitleText:We,emptyProductRecsTitleText:ze,showProductRecsOnDesktop:Ge,showProductRecsOnMobile:Ue,themeColor:He,themeTextColor:Xe,companyName:qe,gstNumber:Qe,showGSTOption:Ye,applyGSTToCart:Je,showMOVForProgressTiers:Ke,freeProduct:Ze,showLoyaltyCta:et=!1,freeProductAdjustedCartTotal:tt,minimumOrderValueToAvailDiscount:ot,signinCTAButtonVisible:rt,cartSigninCTAMainText:at,applyNoteToCart:nt,note:it,showNoteOption:st,inlineCartOfferInfoText:lt,inlineCartOfferInfoRedirectLink:ct,cartOfferTermsAndConditionsText:mt,showEditOptionOnProducts:dt,onSetLoading:ut,showVariantSelectionDropdownInProductRecs:pt,originalCartSubtotal:Ct,freebieProductsInCart:ht,showFreebieClaim:yt,addFreebieToCart:gt,freebiesInCart:ft,effectiveQuantityForProgressBar:wt,productPercentageOffMapping:Tt,removeFreebieFromCart:xt,postalCodeList:bt,enableGeoLocationDeliveryRestriction:Pt=!1,getProductDetailsByVariantId:St,applyPostalCodeAndDeliverySlotToCart:vt,showDeleteOnFreebies:kt,freebieCouponTemplates:Bt,freebieFlowCheckpoints:Et,freebieClaimData:Dt,postalCodeBasedItemTrackingParameter:It,enableSlotPicker:Lt,deliveryHeaderTitle:Ot,deliveryAvailableText:$t,deliveryNotAvailableText:At,giftWrapSetupData:Rt,giftWrapProductDetail:jt,progressBarFreeProductIconType:Mt,enableCustomCartOnCartPage:Ft,isCartPage:_t,showCartTimer:Nt,showFreebieMilestone:Vt,freebieMilestoneData:Wt,cartTimerInMinutes:zt,cartTimerCustomText:Gt,productRecsCardLayout:Ut,productRecsCardListVariant:Ht,imageAspectSelector:Xt,cartComponentsCornerType:qt,cartComponentsCornerRadius:Qt,cartOffersCarousalData:Yt,gstSectionCustomizationData:Jt,noteSectionTitle:Kt,checkoutSectionMessage:Zt,checkoutSectionMessageDisplay:eo,showVariantSelectionDropdownInProductClaim:to,loyaltyDiscount:oo,brandTokenName:ro,showDiscountOnMRP:ao,switchWidthVariant:no,prefixMessageText:io,suffixMessageText:so,successMessageText:lo,toggleDecimal:co,cartOffersCarouselHeight:mo,disableCheckoutButton:uo,showEmptyCartRecommendations:po=!1,checkoutButtonBottomSpacing:Co,showPoweredByBadge:ho,applyCouponCode:yo,showApplyCoupon:go,enableConfetti:fo,checkoutSectionMessageRedirectLink:wo,showCheckoutButtonPaymentIcons:To})=>{const xo=l(m),bo=l(C),[Po,So]=t(!1),[vo,ko]=t(!1),[Bo,Eo]=t(!0),{setLoading:Do}=h();e.useEffect(()=>{ut&&ut(Do)},[ut]);const Io=o(!1),Lo=o(null),Oo=o(null);r(()=>{const e=()=>{X(!1)};return f?(Io.current||(Lo.current=window.history.state,Oo.current=window.location.href,window.history.pushState({ytCustomCartDrawer:"open"},"")),window.addEventListener("popstate",e),Io.current=!0):(Io.current&&"open"===window.history.state?.ytCustomCartDrawer&&window.history.replaceState(Lo.current,"",Oo.current??window.location.href),Io.current=!1),()=>{window.removeEventListener("popstate",e)}},[f,X]);const[$o,Ao]=t(!1);r(()=>{const e=document.querySelector("body");e&&(Ft&&_t?e.classList.remove("drawer-open"):!$o&&f?e.classList.add("drawer-open"):e.classList.remove("drawer-open"))},[f,Ft,_t,$o]),r(()=>{function e(){const e=window.innerWidth;Ao(e>=450)}return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]);const Ro=xo?.items?.reduce((e,t)=>e+t?.quantity,0);r(()=>{const e=()=>{So(!0),window.setTimeout(()=>So(!1),3e3)};return window.addEventListener("yt:autoFreebieAdded",e),()=>window.removeEventListener("yt:autoFreebieAdded",e)},[]);const[jo,Mo]=t("normal"),[Fo,_o]=t("normal"),[No,Vo]=t("auto");r(()=>{CSS.supports("font-weight","500")?Mo("500"):CSS.supports("font-weight","400")?Mo("400"):CSS.supports("font-weight","600")&&Mo("600"),CSS.supports("font-weight","400")?_o("400"):CSS.supports("font-weight","300")?_o("300"):CSS.supports("font-weight","200")&&_o("200"),CSS.supports("width","-webkit-fill-available")?Vo("-webkit-fill-available"):CSS.supports("width","-moz-available")&&Vo("-moz-available")},[]),r(()=>{document.documentElement.style.setProperty("--yt-cart-font-weight",jo),document.documentElement.style.setProperty("--yt-cart-product-rec-price-font-weight",Fo),document.documentElement.style.setProperty("--yt-cart-custom-fill-width",No)},[jo,Fo]);const[Wo]=c(d),[zo]=c(p),[Go]=c(u);r(()=>{Eo(!("all-products"!==It&&("specific-tags"!==It||Wo.isPostalCodeValid||Lt)&&("specific-tags"!==It||Wo.isPostalCodeValid||zo||!Lt)&&("specific-tags"===It&&"standard"===Go||vo&&(Lt?Wo.isPostalCodeValid&&zo:Wo.isPostalCodeValid))))},[Wo.isPostalCodeValid,zo,vo,It,Lt]),c(y);const[Uo,Ho]=t(!0);r(()=>{"true"===localStorage.getItem("cartTimerRanOnce")&&Ho(!1);const e=localStorage.getItem("cartTimerTimeLeft");e&&parseInt(e,10)<=0&&Ho(!1)},[]);const Xo=new Date("2024-11-01");return g(xo?.items_subtotal_price,xo?.currency),e.createElement(U,{className:"yt-cart-drawer",$isDev:be,$isOpen:f,$backgroundColor:q,$enableCustomCartOnCartPage:Ft,$isCartPage:_t,$isLargeScreen:$o,$switchWidthVariant:no},bo.cartLoading?e.createElement("div",{style:{backgroundColor:"#fff",width:"100%",height:"100%",alignItems:"center",justifyContent:"center",display:"flex",position:"absolute",opacity:0,zIndex:51}},bo.showLoader&&!bo.showSkeletonLoader&&e.createElement("div",{className:"loader"},"‎")):e.createElement(e.Fragment,null),e.createElement(e.Fragment,null,e.createElement("div",{className:"yt-cart-drawer-content",style:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"space-between"}},e.createElement("div",null,e.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",margin:"1rem 1rem 0px"}},e.createElement("span",{className:"yt-cart-title-container",style:{fontWeight:"var(--yt-cart-font-weight, bold)",color:_e,fontSize:"16px"}},e.createElement("span",{style:{whiteSpace:"nowrap",flexShrink:0}},ee),xo?.item_count>0&&Ee&&!(et&&Ee)&&Be>0&&e.createElement(N,{pointsRewardRate:Be,loyaltyIcon:ue,brandTokenName:ro,themeColor:He,themeTextColor:Xe,rewardMultiplier:Ce}),Ro>0&&e.createElement(H,{$backgroundSubdued:Q},Ro)),e.createElement("div",{style:{display:"flex",gap:"8px",flexDirection:"row",alignItems:"center"}},!(Ft&&_t)&&e.createElement("div",{className:"close-button",style:{backgroundColor:Q||"#cacaca30"}},e.createElement(s,{style:{height:"auto",width:"auto",color:_e},fontSize:24,cursor:"pointer",onClick:()=>{X(!f)}})))),bo&&e.createElement(F,{$themeColor:He,show:bo.showLoader}),Yt?.enableCartOffersCarousel&&e.createElement(M,{themeColor:He,cartOffersCarousalData:Yt,cartOffersCarouselHeight:mo,cartData:xo}),Nt&&Uo&&xo?.item_count?e.createElement(j,{minutes:zt,customText:Gt,onTimerComplete:()=>{Ho(!1),localStorage.setItem("cartTimerRanOnce","true"),localStorage.removeItem("timeLeft"),localStorage.removeItem("lastUpdate")}}):null,Po&&fo&&e.createElement(W,{particleCount:50,spread:90,origin:{y:.3}}),lt?e.createElement(O,{inlineCartOfferInfoText:lt,inlineCartOfferInfoRedirectLink:ct,themeColor:He,tooltipText:mt,themeTextColor:Xe}):null),Se&&xo?.items_subtotal_price>0&&xo?.currency&&!!ve&&z(ve,g(void 0!==Ct?Ct:xo?.items_subtotal_price,xo.currency),void 0===wt?xo?.item_count:wt,Re??"minimum_order_value",xo?.item_count)&&e.createElement(e.Fragment,null,e.createElement(T,{customCartProgressBarCriteria:Re??"minimum_order_value",handleCheckpointCrossed:Ae,checkpoints:ve,effectiveQuantityForProgressBar:void 0===wt?xo?.item_count:wt,currentCartAmount:g(void 0!==Ct?Ct:xo?.items_subtotal_price,xo.currency),themeColor:He,themeTextColor:Xe,primaryTextColor:_e,secondaryTextColor:Ne,showMOVForProgressTiers:Ke,progressBarFreeProductIconType:Mt,ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,prefixMessageText:io,suffixMessageText:so,successMessageText:lo,enableConfetti:fo})),xo?.item_count>0&&e.createElement("div",{style:{display:"flex",height:"12px",background:"#87878717"}}),0===xo?.items?.length&&0===xo?.item_count&&!1===bo?.showSkeletonLoader?e.createElement(x,{showLoyaltyCta:et,joinNowFunction:Te,emptyCartTitle:te,emptyCartDescription:oe,exploreCTAColor:K,isUserSignedIn:le,exploreCtaRedirectLink:De,themeColor:He,emptyCartButtons:re,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,themeTextColor:Xe,recProductsList:Pe,addCartItem:se,productRecsCtaButtonText:Ve,ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,showVariantSelectionDropdownInProductRecs:pt,emptyProductRecsTitleText:ze,backgroundSubdued:Q,showEmptyCartRecommendations:po,tertiaryColor:Y,tertiaryTextColor:J}):e.createElement("div",{style:{display:"flex",flexDirection:"column",overflowY:"auto",flex:1,overflowX:"hidden",height:"100%",scrollbarWidth:"none"}},e.createElement(B,{isDev:be,themeColor:He,handleDecrement:ie,handleIncrement:ne,removeCartItem:ae,addCartItem:se,primaryTextColor:_e,secondaryTextColor:Ne,freeProduct:Ze,themeTextColor:Xe,showEditOptionOnProducts:dt,productPercentageOffMapping:Tt,removeFreebieFromCart:xt,showDeleteOnFreebies:kt,freebieCouponTemplates:Bt??[],freebieFlowCheckpoints:Et??[],cartCheckpoints:ve,freeProductAdjustedCartTotal:tt,imageAspectSelector:Xt,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,giftWrapVariantId:jt?.variants?.nodes[0]?.id,giftWrapProductId:Rt?.giftProductId,showGiftWrapAsLineItem:Rt?.showGiftWrapAsLineItem,backgroundSubdued:Q,tertiaryColor:Y,tertiaryTextColor:J,backgroundColor:q,showDiscountOnMRP:ao,checkoutSectionMessage:Zt,checkoutSectionMessageRedirectLink:wo,showFreebieMilestone:Vt,freebieMilestoneData:Wt}),$o&&Ge&&!!Pe&&Pe?.length>0&&xo?.item_count>0&&se&&e.createElement(w,{addCartItem:se,products:Pe,productRecsCtaButtonText:Ve,ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,productRecsTitleText:We,themeColor:He,primaryTextColor:_e,secondaryTextColor:Ne,showVariantSelectionDropdownInProductRecs:pt,cardLayout:Ut,variant:Ht,cartComponentsCornerType:qt,cartComponentsCornerRadius:Qt,backgroundSubdued:Q,backgroundColor:q,tertiaryColor:Y,tertiaryTextColor:J}),!$o&&Ue&&!!Pe&&Pe?.length>0&&xo?.item_count>0&&se&&e.createElement(w,{addCartItem:se,products:Pe,productRecsCtaButtonText:Ve,ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,productRecsTitleText:We,themeColor:He,primaryTextColor:_e,secondaryTextColor:Ne,showVariantSelectionDropdownInProductRecs:pt,cardLayout:Ut,variant:Ht,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,backgroundSubdued:Q,tertiaryColor:Y,tertiaryTextColor:J}),"devlhok.myshopify.com"===window.ytapp?.storeDomain&&e.createElement(G,{showDiscountOnMRP:ao,cartCheckpoints:ve,toggleDecimal:co,primaryTextColor:_e,discountApplied:ye,showPoweredByBadge:ho})),e.createElement(S,null,xo?.item_count>0&&ce&&me&&e.createElement(E,{bundleProducts:me}),Ye&&!!Je&&xo?.item_count>0&&e.createElement(D,{companyName:qe,gstNumber:Qe,themeColor:He,iconColor:Jt?.iconColor,showIcon:Jt?.showIcon,backgroundColor:Jt?.backgroundColor,textColor:Jt?.textColor,title:Jt?.title}),!!xo&&xo?.item_count>0&&!!gt&&!!ht&&!!ft&&ht.length>0&&e.createElement(L,{freebieProductsInCart:ht,themeColor:He,themeTextColor:Xe,primaryTextColor:_e,addFreebieToCart:gt,freebiesInCart:ft,imageAspectSelector:Xt,freebieCouponTemplates:Bt,freebieClaimData:Dt,cartCheckpoints:ve,isCartDrawerOpen:f}),Pt&&(bt?.length??0)>0&&!!vt&&xo?.item_count>0&&e.createElement("div",{className:"form-group"},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"6px 1rem 1rem 1rem"},onClick:()=>Eo(!Bo)},e.createElement("span",{style:{fontSize:"12px",display:"flex",gap:"5px",alignItems:"center"}},"Shipping ",e.createElement(i,null)),e.createElement("div",{className:"icon-transition"},Bo?e.createElement(a,null):e.createElement(n,null))),"all-products"===It&&Bo?e.createElement($,{postalCodeList:bt,themeColor:He,themeTextColor:Xe,enableSlotPicker:Lt,deliveryHeaderTitle:Ot,deliveryAvailableText:$t,deliveryNotAvailableText:At,disabledDates:Xo}):Bo&&(vo?e.createElement($,{postalCodeList:bt,themeColor:He,themeTextColor:Xe,enableSlotPicker:Lt,deliveryHeaderTitle:Ot,deliveryAvailableText:$t,deliveryNotAvailableText:At,disabledDates:Xo}):e.createElement(A,{postalCodeList:bt,themeColor:He,themeTextColor:Xe,enableSlotPicker:Lt,disabledDates:Xo}))),st&&!!nt&&xo?.item_count>0&&e.createElement(I,{note:it,noteSectionTitle:Kt}),Rt?.showGiftWrapOption&&xo?.item_count>0&&e.createElement(R,{themeColor:He,id:Rt?.giftProductId,detail:jt,showPrice:Rt?.showPrice,errorText:Rt?.errorText,customText:Rt?.customText,showGiftIcon:Rt?.showGiftIcon,showProductImage:Rt?.showProductImage,addCartItem:se,removeCartItem:ae}),xo?.item_count>0&&go&&!et&&yo&&e.createElement(V,{backgroundSubdued:Q,themeColor:He,themeTextColor:Xe,primaryTextColor:_e,cartComponentsCornerRadius:Qt,applyCouponCode:yo,removeDiscount:ge,enableConfetti:fo}),xo?.item_count>0&&e.createElement(e.Fragment,null,le||!et||oo?!oo&&void 0!==de&&void 0!==pe&&!!ue&&et&&!!fe&&e.createElement(v,{themeColor:He,applyDiscount:fe,discountAmountOff:de,loyaltyIcon:ue,pointsToBeUsed:pe,ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,minimumOrderValueToAvailDiscount:ot,brandTokenName:ro,showCartLevelAltPay:Ee,redemptionMultiplier:he}):!!xe&&!!Te&&e.createElement(P,{cartSigninCTAMainText:at,signinCTAButtonVisible:rt,themeColor:He,joinNowFunction:Te,guestLoyaltyPercentage:xe,ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,showCartLevelAltPay:Ee})),xo?.item_count>0&&!!oo&&!!ge&&et&&oo&&void 0!==pe&&e.createElement(k,{themeColor:He,removeDiscount:ge,loyaltyDiscount:oo,isDev:be,ctaButtonBackgroundColor:Me,ctaButtonTextColor:Fe,primaryTextColor:_e,secondaryTextColor:Ne,pointsToBeUsed:pe,brandTokenName:ro,showCartLevelAltPay:Ee}),et&&Ee&&ke&&ue&&xo?.item_count>0&&e.createElement(_,{loyaltyIcon:ue,backgroundSubdued:Q,primaryTextColor:_e,pointsRewardRate:Be,rewardMultiplier:Ce}),et&&xo&&xo.item_count>0&&!!ot&&ot>1&&e.createElement("span",{className:"yt-cart-loyalty-mov-text",style:{fontSize:"10px",color:He??"#50D1AA",fontWeight:600,display:"flex",justifyContent:rt?"space-between":"center"}},"Minimum order value to use ",ro,":"," ",ot),xo&&we&&xo?.item_count>0&&e.createElement("div",null,e.createElement(b,{disableCheckoutButton:!!uo||bo.cartLoading,discountApplied:ye,checkoutFunction:we,checkoutButtonColor:je,checkoutFontSize:Z,discountInCheckoutButton:Oe,isStickyCheckout:$e,discountAmountApplied:Ie,minimumCartValue:Le,themeTextColor:Xe,applyGSTToCart:Je,showGSTOption:Ye,applyNoteToCart:nt,showNoteOption:st,enableGeoLocationDeliveryRestriction:Pt,applyPostalCodeAndDeliverySlotToCart:vt,enableSlotPicker:Lt,cartComponentsCornerRadius:Qt,cartComponentsCornerType:qt,checkoutSectionMessage:Zt,checkoutSectionMessageDisplay:eo,checkoutSectionMessageRedirectLink:wo,showDiscountOnMRP:ao,tertiaryColor:Y,tertiaryTextColor:J,cartCheckpoints:ve,toggleDecimal:co,checkoutButtonBottomSpacing:Co,showPoweredByBadge:ho,showCheckoutButtonPaymentIcons:To,primaryTextColor:_e,hideSubtotalAndBadge:"devlhok.myshopify.com"===window.ytapp?.storeDomain}))))))};export{X as default};
@@ -1 +1 @@
1
- import e,{useState as t,useRef as n,useMemo as o,useEffect as i}from"react";import{useAtomValue as r}from"jotai";import{cartDataState as l}from"../../atoms/cartDataAtom.js";import{getCurrencySymbol as a,getCurrencyValueFromShopifyPrice as c}from"../../utils/converter.js";import{darkenColor as s,formatPriceWithCommas as p,setContrastTextColor as d,extractBundleDiscountTitle as m,shouldRenderCheckoutMessageInCartList as u}from"../../utils/index.js";import{IoIosCart as x}from"react-icons/io";import{GrFormNext as y}from"react-icons/gr";import{gstNumberState as f}from"../../atoms/gstInputAtom.js";import{gstCompanyNameState as g}from"../../atoms/gstCompanyNameAtom.js";import{noteInputState as h}from"../../atoms/noteInputAtom.js";import{isDeliveryOptionValidState as E,deliveryOptionChosenState as b,deliveryTypeState as w}from"../../atoms/shippingAtom.js";import{postalCodeState as C}from"../../atoms/postalCodeAtom.js";import{deliverySlotDateState as v}from"../../atoms/dateAtom.js";function k({checkoutButtonColor:k,checkoutFontSize:S,checkoutFunction:F,discountApplied:z,discountInCheckoutButton:j,discountAmountApplied:T,minimumCartValue:I,themeTextColor:A,applyGSTToCart:D,showGSTOption:B,applyNoteToCart:N,showNoteOption:R,enableGeoLocationDeliveryRestriction:V,applyPostalCodeAndDeliverySlotToCart:H,enableSlotPicker:L,isStickyCheckout:P,cartComponentsCornerType:W,cartComponentsCornerRadius:_,checkoutSectionMessage:M,checkoutSectionMessageDisplay:O,checkoutSectionMessageRedirectLink:Z,showDiscountOnMRP:G,tertiaryColor:$,tertiaryTextColor:Y,cartCheckpoints:q,toggleDecimal:K,disableCheckoutButton:U,checkoutButtonBottomSpacing:J=8,showPoweredByBadge:Q=!0,showCheckoutButtonPaymentIcons:X,primaryTextColor:ee,hideSubtotalAndBadge:te=!1}){const ne=r(l),oe=r(f),ie=r(g),re=r(h),le=r(E),ae=r(b),ce=r(C),se=r(v),pe=r(w),[de,me]=t(!1),ue=a(ne,ne?.currency),[xe,ye]=t("closed"),fe=n(null),[ge,he]=t(!1),Ee=o(()=>s($,.22),[$]),be=o(()=>c(I??0,ne?.currency??"INR"),[I,ne?.currency]),we=o(()=>p(K?be.toFixed(2):be.toFixed(0)),[be,K]),Ce=n(null),ve=n(null),ke=n(null),Se=()=>{ye("closing"),setTimeout(()=>{ye("closed")},300)},Fe=c(ne?.original_total_price,ne?.currency),ze=o(()=>q?.find(e=>"free_delivery"===e.couponType&&void 0!==e.discountValue),[q]),je=o(()=>!(!ze||!ze.minimumOrderValue)&&Fe>=ze.minimumOrderValue,[ze,Fe]),Te=je&&ze&&ze.discountValue||0,Ie=T?c(T,ne?.currency??"INR"):0,Ae=Number((Fe-Ie).toFixed(2)),De=o(()=>{if(!ne?.items?.length)return 0;const e=ne.items.reduce((e,t)=>e+(G&&t?.compare_at_price&&t?.compare_at_price>t?.original_price?t.compare_at_price:t.original_price)*t.quantity,0);return c(e,ne?.currency)},[ne?.items,G]),Be=o(()=>je?De+Te:De,[je,De,Te]),Ne=o(()=>be&&be>0?`Add products worth more than ${ue}${we}`:"",[be,ue,we]),Re=o(()=>ne?.items?.length?ne.items.reduce((e,t)=>t.compare_at_price&&t.compare_at_price>t.original_price?e+(t.compare_at_price-t.original_price)*t.quantity:e,0):0,[ne?.items]),Ve=c(Re,ne?.currency??"INR");i(()=>{Ce.current&&d(Ce.current),ve.current&&d(ve.current),ke.current&&d(ke.current)},[k,Ie,G,Ve,xe,Te]);const He=o(()=>{const e={};return ne?.items?.length?(ne.items.forEach(t=>{t.discounts&&Array.isArray(t.discounts)&&t.discounts.forEach(t=>{e[t.title]=(e[t.title]||0)+t.amount})}),e):e},[ne?.items]),Le=o(()=>{const e=[];for(const t in He)if(Object.prototype.hasOwnProperty.call(He,t)){const n=He[t],o=c(n,ne?.currency??"INR"),i=m(t);e.push({title:i,amount:o})}return e},[He,ne?.currency]),Pe=o(()=>{let e=0;return e+=G?Ie+Ve:Ie,je&&(e+=Te),e},[Ie,Ve,G,je,Te]),We=async e=>{if(me(!0),Ae<=0)me(!1);else{if(V){if("standard"!==pe&&(L?!le:!ae.isPostalCodeValid))return void me(!1);if(H)try{"standard"===pe?await H(pe):await H(pe,String(ce)||"",se&&L?new Date(se).toDateString():"")}catch(e){console.error("Error applying postal code and delivery slot"),alert("There was an error processing your delivery options. Please try again.")}}B&&D&&""!==ie&&""!==oe&&await D(oe,ie),R&&N&&""!==re&&await N(re),await F(e),me(!1)}},[_e,Me]=t(!1);i(()=>{Me(Ae<=0||(!!U||!!V&&("standard"!==pe&&(L?!le:!ae.isPostalCodeValid))))},[ae,pe,V,L,le,se,U,Ae]);const[Oe,Ze]=t(!1),Ge=n(null),[$e,Ye]=t("0px");i(()=>{Ge.current&&Ye(Oe?`${Ge.current.scrollHeight}px`:"0px")},[Oe,Le,je]);const qe=()=>{Ze(!Oe)};i(()=>{function e(e){fe.current&&!fe.current.contains(e.target)&&Se()}return"open"!==xe&&"opening"!==xe||document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[xe]);const Ke=(t,n="Checkout")=>t?e.createElement("span",{style:{fontSize:"13px",width:"100%",textAlign:"center"}},"Redirecting to Checkout..."):X?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",pointerEvents:"none"}},e.createElement("span",{className:"yt-cart-summary-checkout-span",style:{fontSize:"16px"}},n),e.createElement("div",{style:{display:"flex",alignItems:"center",marginLeft:"1.5rem"}},e.createElement("img",{src:"https://r2.yourtoken.io/checkout-button-payment-provider-icons.png",alt:"Payment methods",style:{height:"22px",width:"auto"}}),e.createElement(y,{className:"yt-cart-summary-checkout-next-icon",fontSize:"24px"}))):e.createElement("div",{style:{alignItems:"center",display:"flex",columnGap:"5px",pointerEvents:"none"}},"Proceed to Checkout"!==n&&e.createElement(x,{fontSize:"20px"}),e.createElement("span",{style:{fontSize:"16px",pointerEvents:"none"}},n));return e.createElement("div",{style:{position:"relative"}},!!M&&M.length>0&&!u()&&(()=>{const t=O||"ribbon";if("ribbon"===t)return e.createElement("div",{className:"yt-cart-bottom-bar",style:{fontSize:"10px",textAlign:"center",backgroundColor:$,padding:"3px",boxShadow:"1px 2px 4px 0px #00000061",color:Y,marginBottom:te?"0px":"4px",borderTopLeftRadius:"14px",borderTopRightRadius:"14px",cursor:Z?"pointer":"default"},onClick:()=>{Z&&(window.location.href=Z)}},M);const n=({children:n})=>e.createElement("div",{className:"yt-cart-checkout-ribbon-container",style:{display:"flex",justifyContent:"center",alignItems:"center",width:"max-content",padding:"0 55px",marginBottom:"4px",position:"bookmark"===t?"absolute":"static",top:"bookmark"===t?"-11px":void 0,cursor:Z?"pointer":"default"},onClick:()=>{Z&&(window.location.href=Z)}},n);return"tag"===t?e.createElement(n,null,e.createElement("div",{className:"yt-cart-checkout-ribbon-tag-container",style:{display:"flex",alignItems:"center",width:"100%"}},e.createElement("svg",{width:"20",height:"26",viewBox:"0 0 20 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flex:"0 0 auto"}},e.createElement("path",{d:"M0 0H20V20H0L7.41935 10.7639L0 0Z",fill:Ee}),e.createElement("path",{d:"M12.2581 5.80645L20 0V5.80645H12.2581Z",fill:"black",fillOpacity:"0.36"}),e.createElement("path",{d:"M12 5.80646L20 5.80645V25.8065H12V5.80646Z",fill:$})),e.createElement("div",{className:"yt-cart-checkout-ribbon-tag-center",style:{display:"flex",flex:1,justifyContent:"center",alignItems:"center",backgroundColor:$,color:Y,padding:"8px 16px",fontSize:"10px",marginTop:"5px",lineHeight:"5px"}},M),e.createElement("svg",{width:"20",height:"26",viewBox:"0 0 20 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flex:"0 0 auto"}},e.createElement("path",{d:"M20 0H0V20H20L12.5806 10.7639L20 0Z",fill:Ee}),e.createElement("path",{d:"M7.74194 5.80645L0 0V5.80645H7.74194Z",fill:"black",fillOpacity:"0.36"}),e.createElement("path",{d:"M8 5.80646L0 5.80645V25.8065H8V5.80646Z",fill:$})))):e.createElement(n,null,e.createElement("div",{className:"yt-cart-checkout-ribbon-bookmark-container",style:{display:"flex",alignItems:"center",width:"100%"}},e.createElement("svg",{width:"14",height:"19",viewBox:"0 0 14 19",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M8.34334 4.75V9.5H0V4.75C0 2.12665 1.86772 0 4.17167 0C6.47562 0 8.34334 2.12665 8.34334 4.75Z",fill:Ee}),e.createElement("path",{d:"M12.1545 19H13.9056V0H4.17167C6.27666 0 7.98284 1.943 7.98284 4.33981V14.25C7.98284 16.8734 9.85056 19 12.1545 19Z",fill:$})),e.createElement("div",{className:"yt-cart-checkout-ribbon-bookmark-center",style:{display:"flex",flex:1,justifyContent:"center",alignItems:"center",backgroundColor:$,color:Y,padding:"8px 16px",fontSize:"10px",lineHeight:"3px",marginRight:"-1px",marginLeft:"-1px"}},M),e.createElement("svg",{width:"14",height:"19",viewBox:"0 0 14 19",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M5.65666 4.75V9.5H14V4.75C14 2.12665 12.1323 0 9.82833 0C7.52438 0 5.65666 2.12665 5.65666 4.75Z",fill:Ee}),e.createElement("path",{d:"M1.84549 19H0.0944166V0H9.82833C7.72334 0 6.01716 1.943 6.01716 4.33981V14.25C6.01716 16.8734 4.14944 19 1.84549 19Z",fill:$}))))})(),(!0===j||"true"===j)&&"closed"!==xe&&e.createElement(e.Fragment,null,e.createElement("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",opacity:"open"===xe?1:0,transition:"opacity 0.3s ease-in-out",display:"block",zIndex:2147483643},onClick:Se}),e.createElement("div",{ref:fe,style:{position:"fixed",bottom:0,left:0,right:0,zIndex:2147483644,transform:"open"===xe?"translateY(0)":"translateY(100%)",transition:"transform 0.3s cubic-bezier(0.22, 1, 0.36, 1)"}},e.createElement("div",{style:{backgroundColor:"#F1F1F1",padding:"1rem",display:"flex",justifyContent:"space-between",alignItems:"center",color:"#000000",borderTopLeftRadius:"8px",borderTopRightRadius:"8px",fontWeight:"bold",fontSize:"16px"}},e.createElement("span",null,"Price Summary"),e.createElement("button",{onClick:Se,style:{background:"none",border:"none",color:"#000000",fontSize:"16px",fontWeight:"bold",cursor:"pointer",padding:0,marginLeft:"auto",transition:"transform 0.3s ease"}},"✕")),e.createElement("div",{style:{backgroundColor:"white",padding:"10px 1rem 0"}},e.createElement(e.Fragment,null,(G&&Ve>0||z&&Le.length>0||je&&Te>0)&&e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"14px",color:"#212529"}},"Subtotal"),e.createElement("span",{style:{fontSize:"14px",color:"#212529"}},ue,p(je?K?Be.toFixed(2):Be.toFixed(0):K?De.toFixed(2):De.toFixed(0)))),(Ie>0||G&&Ve>0||je&&Te>0)&&e.createElement("div",{style:{display:"flex",flexDirection:"column",paddingBottom:"5px",marginTop:"5px",fontWeight:"600"}},G&&Ve>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#212529"}},e.createElement("span",null,"Discount on MRP"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Ve.toFixed(2):Ve.toFixed(0)))),je&&Te>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#212529"}},e.createElement("span",null,"Free Shipping"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Te.toFixed(2):Te.toFixed(0)))),Le.map(t=>e.createElement("div",{key:t.title,style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#1E1E1E"}},e.createElement("span",null,t.title),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?t.amount.toFixed(2):t.amount.toFixed(0))))),Pe>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#212529",marginTop:"5px",paddingTop:"5px",borderTop:"1px solid #E5E7EB"}},e.createElement("span",null,"Total Savings"),e.createElement("span",{style:{color:"#D3122A",fontWeight:"bold"}},"-",ue,p(K?Pe.toFixed(2):Pe.toFixed(0))))),(Ie>0||G&&Ve>0||je&&Te>0)&&e.createElement("div",{style:{height:"12px",display:"flex",background:"#F5F5F5",width:"calc(100% + 2rem)",margin:"10px -1rem 0 -1rem",position:"relative",borderTop:"0.8px solid #C5C5C5",borderBottom:"0.8px solid #C5C5C5"}}))),e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:Ie>0||G&&Ve>0||je&&Te>0?"10px":"0"}},e.createElement("div",{style:{display:"flex",flexDirection:"column"}},e.createElement("span",{style:{fontSize:"14px",fontWeight:"600",color:"#212529"}},"Grand Total"),e.createElement("span",{style:{fontSize:"9px",color:"#4A5157"}},"Inclusive of all taxes")),e.createElement("span",{style:{fontSize:"16px",color:"black",fontWeight:"var(--yt-cart-font-weight)"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0)))),e.createElement("div",{style:{display:"flex",background:$,color:Y,width:"calc(100% + 2rem)",margin:"10px -1rem 0 -1rem",position:"relative",fontSize:"12px",fontWeight:"600",justifyContent:"center",alignItems:"center",gap:"5px",padding:"4px 0"}},e.createElement("img",{src:"https://r2.yourtoken.io/image%2016.png",alt:"confetti-image",style:{width:"30px",height:"30px"}}),"You saved"," ",e.createElement("span",null,ue,p(K?Pe.toFixed(2):Pe.toFixed(0)))," ","on your order")),e.createElement("button",{ref:ve,id:"yt-checkout-button-popout",className:"yt-checkout-button",onClick:We,disabled:_e,style:{display:"flex",flexDirection:"row",alignItems:"center",margin:0,height:"45px",padding:"10px",justifyContent:"center",columnGap:"8px",backgroundColor:k,border:0,textTransform:"uppercase",fontSize:S,letterSpacing:"1px",opacity:_e?.5:1,cursor:_e?"not-allowed":"pointer",borderRadius:"0px",boxShadow:"none",width:"100%"}},Ke(de)))),(!0===j||"true"===j)&&U&&_e&&Ne&&e.createElement("div",{style:{display:"flex",justifyContent:"center",textAlign:"center",fontSize:"13px",color:"red"}},Ne),!0===j||"true"===j?e.createElement("div",{className:"yt-cart-checkout-section-concise-container",style:{display:"flex",flexDirection:"column",backgroundColor:"rgba(138, 138, 138, 0.08)",paddingTop:"10px"}},e.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"stretch",justifyContent:"space-between",width:"auto",padding:P?"7px 0 8px 8px":`7px 8px ${J}px 8px`}},e.createElement("div",{style:{display:"flex",flexDirection:"column",textAlign:"center",justifyContent:"center",alignItems:"flex-start",paddingRight:"2rem",overflowWrap:"normal"}},(Ie>0||G&&Ve>0||je&&Te>0)&&e.createElement("div",{className:"yt-cart-checkout-save-badge",ref:ke,style:{fontSize:"9px",backgroundColor:k,width:"max-content",padding:"2px 8px"}},"Saving ",ue,p(K?Pe.toFixed(2):Pe.toFixed(0))),de?e.createElement("div",{style:{fontSize:"12px",color:"#4a4a4a"}},"Redirecting to Checkout..."):z||je&&ze?e.createElement("div",null,e.createElement("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"center"}},e.createElement("span",{style:{fontSize:"15px",color:"#1E1E1E",fontWeight:"600"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0))),(Ie>0||Ve>0||je&&Te>0)&&e.createElement("span",{style:{fontSize:"14px",color:"#8C8C8C",textDecoration:"line-through",marginLeft:"4px",fontWeight:"normal"}},ue,p(je?Be.toFixed(0):De.toFixed(0))))):e.createElement("div",{style:{fontSize:"18px",color:"#1E1E1E",fontWeight:"600"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0))),G&&Ve>0||z&&Ie>0||je&&Te>0?e.createElement("div",{style:{fontSize:"11px",color:"#4A5157",width:"max-content",cursor:"pointer",textDecoration:"underline"},onClick:e=>{e.stopPropagation(),ye("opening"),requestAnimationFrame(()=>{ye("open")}),he(!ge)}},"See Details"):e.createElement("div",{style:{fontSize:"9px",color:"#4A5157",width:"max-content"}},"Inclusive of all taxes")),e.createElement("div",{style:{display:"flex",justifyContent:"center",width:"100%"}},e.createElement("button",{ref:Ce,id:"yt-checkout-button",className:"yt-checkout-button",onClick:We,disabled:_e,style:{backgroundColor:k,border:0,textTransform:"uppercase",letterSpacing:"1px",fontSize:"12px",padding:"10px 15px",opacity:_e?.5:1,cursor:_e?"not-allowed":"pointer",borderRadius:"rounded"===W?`${_}px`:"0px",width:"100%",margin:"0 auto",boxShadow:"none"}},X?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",pointerEvents:"none"}},e.createElement("span",{style:{fontSize:"12px"}},"CHECKOUT"),e.createElement("div",{style:{display:"flex",alignItems:"center",marginLeft:"1.5rem"}},e.createElement("img",{src:"https://r2.yourtoken.io/checkout-button-payment-provider-icons.png",alt:"Payment methods",style:{height:"22px",width:"auto"}}),e.createElement(y,{fontSize:"24px"}))):"CHECKOUT"))),Q&&!te&&e.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingBlock:"0 6px"}},e.createElement("img",{src:"https://r2.yourtoken.io/powered-by-badge-v2.png",alt:"Powered by YourToken",style:{height:"auto",width:"340px"}}))):e.createElement(e.Fragment,null,U&&_e&&Ne&&e.createElement("div",{style:{display:"flex",justifyContent:"center",textAlign:"center",fontSize:"13px",color:"red"}},Ne),e.createElement("div",{className:"yt-cart-checkout-summary",style:{display:"flex",flexDirection:"column",rowGap:"5px",backgroundColor:"rgba(138, 138, 138, 0.08)",paddingTop:te?"0px":"10px"}},e.createElement("div",{style:{display:te?"none":"flex",flexDirection:"column",rowGap:"2px",margin:"0 1rem",color:ee}},(Ve>0||z&&Le.length>0||je&&Te>0)&&Pe>0&&e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px"}},"Subtotal"),e.createElement("span",{style:{fontSize:"14px"}},ue,p(je?K?Be.toFixed(2):Be.toFixed(0):K?De.toFixed(2):De.toFixed(0)))),(Ie>0||Ve>0||je&&Te>0)&&e.createElement("div",{style:{display:"flex",flexDirection:"column",paddingBottom:"5px"}},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center"}},"Discounts Applied",e.createElement("button",{onClick:qe,className:"yt-cart-details-button",style:{marginBottom:"0",marginLeft:"5px",background:"none",border:"none",color:"#7E7E7E",cursor:"pointer",fontSize:"12px",fontWeight:"600",textDecoration:"underline",padding:"0 !important",minHeight:"10px !important",boxShadow:"none",minWidth:"fit-content",height:"auto",lineHeight:"normal",marginTop:"0"}},Oe?"Hide details":"See details")),e.createElement("span",{style:{fontSize:"14px",color:"#D3122A",fontWeight:"600"}},"-",ue,p(K?Pe.toFixed(2):Pe.toFixed(0)))),e.createElement("div",{ref:Ge,style:{height:$e,overflow:"hidden",transition:"height 0.3s ease, opacity 0.3s ease",opacity:Oe?1:0,marginTop:Oe?"5px":"0",borderTop:Oe?"1px solid #E5E7EB":"none",paddingTop:Oe?"5px":"0",fontWeight:"600"}},G&&Ve>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Discount on MRP"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Ve.toFixed(2):Ve.toFixed(0)))),je&&Te>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Free Shipping"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Te.toFixed(2):Te.toFixed(0)))),Le.map(t=>e.createElement("div",{key:t.title,style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,t.title),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?t.amount.toFixed(2):t.amount.toFixed(0))))))),e.createElement("hr",{className:"yt-cart-checkout-divider",style:{height:"1px",margin:"2px 0",backgroundColor:"#E5E7EB",border:"none",maxWidth:"unset"}})),e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"14px",fontWeight:"600"}},"Total"),e.createElement("span",{style:{fontSize:"16px",fontWeight:"var(--yt-cart-font-weight)"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0))))),e.createElement("button",{ref:Ce,id:"yt-checkout-button",className:"yt-checkout-button",onClick:We,disabled:_e,style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"closed"!==xe||P?"0":`4px 1rem ${J}px 1rem`,height:"45px",paddingTop:"10px",paddingBottom:"10px",justifyContent:"center",columnGap:"8px",backgroundColor:k,border:0,color:A??"white",textTransform:"uppercase",fontSize:S,letterSpacing:"1px",opacity:_e?.5:1,cursor:_e?"not-allowed":"pointer",borderRadius:"closed"!==xe?"0px":"rounded"===W?`${_}px`:"0px",boxShadow:"none"}},Ke(de,X?"Checkout":"Proceed to Checkout")),Q&&!te&&e.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingBlock:"0px 6px"}},e.createElement("img",{src:"https://r2.yourtoken.io/powered-by-badge-v2.png",alt:"Powered by YourToken",style:{height:"auto",width:"340px"}})))))}export{k as default};
1
+ import e,{useState as t,useRef as n,useMemo as o,useEffect as i}from"react";import{useAtomValue as r}from"jotai";import{cartDataState as l}from"../../atoms/cartDataAtom.js";import{getCurrencySymbol as a,getCurrencyValueFromShopifyPrice as c}from"../../utils/converter.js";import{darkenColor as s,formatPriceWithCommas as p,setContrastTextColor as d,extractBundleDiscountTitle as m,shouldRenderCheckoutMessageInCartList as u}from"../../utils/index.js";import{IoIosCart as x}from"react-icons/io";import{GrFormNext as y}from"react-icons/gr";import{gstNumberState as f}from"../../atoms/gstInputAtom.js";import{gstCompanyNameState as g}from"../../atoms/gstCompanyNameAtom.js";import{noteInputState as h}from"../../atoms/noteInputAtom.js";import"./shared.scss.js";import{isDeliveryOptionValidState as E,deliveryOptionChosenState as b,deliveryTypeState as w}from"../../atoms/shippingAtom.js";import{postalCodeState as C}from"../../atoms/postalCodeAtom.js";import{deliverySlotDateState as v}from"../../atoms/dateAtom.js";function k({checkoutButtonColor:k,checkoutFontSize:S,checkoutFunction:F,discountApplied:z,discountInCheckoutButton:j,discountAmountApplied:T,minimumCartValue:I,themeTextColor:A,applyGSTToCart:D,showGSTOption:B,applyNoteToCart:N,showNoteOption:R,enableGeoLocationDeliveryRestriction:V,applyPostalCodeAndDeliverySlotToCart:H,enableSlotPicker:L,isStickyCheckout:P,cartComponentsCornerType:W,cartComponentsCornerRadius:_,checkoutSectionMessage:M,checkoutSectionMessageDisplay:O,checkoutSectionMessageRedirectLink:Z,showDiscountOnMRP:G,tertiaryColor:$,tertiaryTextColor:Y,cartCheckpoints:q,toggleDecimal:K,disableCheckoutButton:U,checkoutButtonBottomSpacing:J=8,showPoweredByBadge:Q=!0,showCheckoutButtonPaymentIcons:X,primaryTextColor:ee,hideSubtotalAndBadge:te=!1}){const ne=r(l),oe=r(f),ie=r(g),re=r(h),le=r(E),ae=r(b),ce=r(C),se=r(v),pe=r(w),[de,me]=t(!1),ue=a(ne,ne?.currency),[xe,ye]=t("closed"),fe=n(null),[ge,he]=t(!1),Ee=o(()=>s($,.22),[$]),be=o(()=>c(I??0,ne?.currency??"INR"),[I,ne?.currency]),we=o(()=>p(K?be.toFixed(2):be.toFixed(0)),[be,K]),Ce=n(null),ve=n(null),ke=n(null),Se=()=>{ye("closing"),setTimeout(()=>{ye("closed")},300)},Fe=c(ne?.original_total_price,ne?.currency),ze=o(()=>q?.find(e=>"free_delivery"===e.couponType&&void 0!==e.discountValue),[q]),je=o(()=>!(!ze||!ze.minimumOrderValue)&&Fe>=ze.minimumOrderValue,[ze,Fe]),Te=je&&ze&&ze.discountValue||0,Ie=T?c(T,ne?.currency??"INR"):0,Ae=Number((Fe-Ie).toFixed(2)),De=o(()=>{if(!ne?.items?.length)return 0;const e=ne.items.reduce((e,t)=>e+(G&&t?.compare_at_price&&t?.compare_at_price>t?.original_price?t.compare_at_price:t.original_price)*t.quantity,0);return c(e,ne?.currency)},[ne?.items,G]),Be=o(()=>je?De+Te:De,[je,De,Te]),Ne=o(()=>be&&be>0?`Add products worth more than ${ue}${we}`:"",[be,ue,we]),Re=o(()=>ne?.items?.length?ne.items.reduce((e,t)=>t.compare_at_price&&t.compare_at_price>t.original_price?e+(t.compare_at_price-t.original_price)*t.quantity:e,0):0,[ne?.items]),Ve=c(Re,ne?.currency??"INR");i(()=>{Ce.current&&d(Ce.current),ve.current&&d(ve.current),ke.current&&d(ke.current)},[k,Ie,G,Ve,xe,Te]);const He=o(()=>{const e={};return ne?.items?.length?(ne.items.forEach(t=>{t.discounts&&Array.isArray(t.discounts)&&t.discounts.forEach(t=>{e[t.title]=(e[t.title]||0)+t.amount})}),e):e},[ne?.items]),Le=o(()=>{const e=[];for(const t in He)if(Object.prototype.hasOwnProperty.call(He,t)){const n=He[t],o=c(n,ne?.currency??"INR"),i=m(t);e.push({title:i,amount:o})}return e},[He,ne?.currency]),Pe=o(()=>{let e=0;return e+=G?Ie+Ve:Ie,je&&(e+=Te),e},[Ie,Ve,G,je,Te]),We=async e=>{if(me(!0),Ae<=0)me(!1);else{if(V){if("standard"!==pe&&(L?!le:!ae.isPostalCodeValid))return void me(!1);if(H)try{"standard"===pe?await H(pe):await H(pe,String(ce)||"",se&&L?new Date(se).toDateString():"")}catch(e){console.error("Error applying postal code and delivery slot"),alert("There was an error processing your delivery options. Please try again.")}}B&&D&&""!==ie&&""!==oe&&await D(oe,ie),R&&N&&""!==re&&await N(re),await F(e),me(!1)}},[_e,Me]=t(!1);i(()=>{Me(Ae<=0||(!!U||!!V&&("standard"!==pe&&(L?!le:!ae.isPostalCodeValid))))},[ae,pe,V,L,le,se,U,Ae]);const[Oe,Ze]=t(!1),Ge=n(null),[$e,Ye]=t("0px");i(()=>{Ge.current&&Ye(Oe?`${Ge.current.scrollHeight}px`:"0px")},[Oe,Le,je]);const qe=()=>{Ze(!Oe)};i(()=>{function e(e){fe.current&&!fe.current.contains(e.target)&&Se()}return"open"!==xe&&"opening"!==xe||document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[xe]);const Ke=(t,n="Checkout")=>t?e.createElement("span",{style:{fontSize:"13px",width:"100%",textAlign:"center"}},"Redirecting to Checkout..."):X?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",pointerEvents:"none"}},e.createElement("span",{className:"yt-cart-summary-checkout-span",style:{fontSize:"16px"}},n),e.createElement("div",{style:{display:"flex",alignItems:"center",marginLeft:"1.5rem"}},e.createElement("img",{src:"https://r2.yourtoken.io/checkout-button-payment-provider-icons.png",alt:"Payment methods",style:{height:"22px",width:"auto"}}),e.createElement(y,{className:"yt-cart-summary-checkout-next-icon",fontSize:"24px"}))):e.createElement("div",{style:{alignItems:"center",display:"flex",columnGap:"5px",pointerEvents:"none"}},"Proceed to Checkout"!==n&&e.createElement(x,{fontSize:"20px"}),e.createElement("span",{style:{fontSize:"16px",pointerEvents:"none"}},n));return e.createElement("div",{style:{position:"relative"}},!!M&&M.length>0&&!u()&&(()=>{const t=O||"ribbon";if("ribbon"===t)return e.createElement("div",{className:"yt-cart-bottom-bar",style:{fontSize:"10px",textAlign:"center",backgroundColor:$,padding:"3px",boxShadow:"1px 2px 4px 0px #00000061",color:Y,marginBottom:te?"0px":"4px",borderTopLeftRadius:"14px",borderTopRightRadius:"14px",cursor:Z?"pointer":"default"},onClick:()=>{Z&&(window.location.href=Z)}},M);const n=({children:n})=>e.createElement("div",{className:"yt-cart-checkout-ribbon-container",style:{display:"flex",justifyContent:"center",alignItems:"center",width:"max-content",padding:"0 55px",marginBottom:"4px",position:"bookmark"===t?"absolute":"static",top:"bookmark"===t?"-11px":void 0,cursor:Z?"pointer":"default"},onClick:()=>{Z&&(window.location.href=Z)}},n);return"tag"===t?e.createElement(n,null,e.createElement("div",{className:"yt-cart-checkout-ribbon-tag-container",style:{display:"flex",alignItems:"center",width:"100%"}},e.createElement("svg",{width:"20",height:"26",viewBox:"0 0 20 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flex:"0 0 auto"}},e.createElement("path",{d:"M0 0H20V20H0L7.41935 10.7639L0 0Z",fill:Ee}),e.createElement("path",{d:"M12.2581 5.80645L20 0V5.80645H12.2581Z",fill:"black",fillOpacity:"0.36"}),e.createElement("path",{d:"M12 5.80646L20 5.80645V25.8065H12V5.80646Z",fill:$})),e.createElement("div",{className:"yt-cart-checkout-ribbon-tag-center",style:{display:"flex",flex:1,justifyContent:"center",alignItems:"center",backgroundColor:$,color:Y,padding:"8px 16px",fontSize:"10px",marginTop:"5px",lineHeight:"5px"}},M),e.createElement("svg",{width:"20",height:"26",viewBox:"0 0 20 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{flex:"0 0 auto"}},e.createElement("path",{d:"M20 0H0V20H20L12.5806 10.7639L20 0Z",fill:Ee}),e.createElement("path",{d:"M7.74194 5.80645L0 0V5.80645H7.74194Z",fill:"black",fillOpacity:"0.36"}),e.createElement("path",{d:"M8 5.80646L0 5.80645V25.8065H8V5.80646Z",fill:$})))):e.createElement(n,null,e.createElement("div",{className:"yt-cart-checkout-ribbon-bookmark-container",style:{display:"flex",alignItems:"center",width:"100%"}},e.createElement("svg",{width:"14",height:"19",viewBox:"0 0 14 19",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M8.34334 4.75V9.5H0V4.75C0 2.12665 1.86772 0 4.17167 0C6.47562 0 8.34334 2.12665 8.34334 4.75Z",fill:Ee}),e.createElement("path",{d:"M12.1545 19H13.9056V0H4.17167C6.27666 0 7.98284 1.943 7.98284 4.33981V14.25C7.98284 16.8734 9.85056 19 12.1545 19Z",fill:$})),e.createElement("div",{className:"yt-cart-checkout-ribbon-bookmark-center",style:{display:"flex",flex:1,justifyContent:"center",alignItems:"center",backgroundColor:$,color:Y,padding:"8px 16px",fontSize:"10px",lineHeight:"3px",marginRight:"-1px",marginLeft:"-1px"}},M),e.createElement("svg",{width:"14",height:"19",viewBox:"0 0 14 19",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M5.65666 4.75V9.5H14V4.75C14 2.12665 12.1323 0 9.82833 0C7.52438 0 5.65666 2.12665 5.65666 4.75Z",fill:Ee}),e.createElement("path",{d:"M1.84549 19H0.0944166V0H9.82833C7.72334 0 6.01716 1.943 6.01716 4.33981V14.25C6.01716 16.8734 4.14944 19 1.84549 19Z",fill:$}))))})(),(!0===j||"true"===j)&&"closed"!==xe&&e.createElement(e.Fragment,null,e.createElement("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",opacity:"open"===xe?1:0,transition:"opacity 0.3s ease-in-out",display:"block",zIndex:2147483643},onClick:Se}),e.createElement("div",{ref:fe,style:{position:"fixed",bottom:0,left:0,right:0,zIndex:2147483644,transform:"open"===xe?"translateY(0)":"translateY(100%)",transition:"transform 0.3s cubic-bezier(0.22, 1, 0.36, 1)"}},e.createElement("div",{style:{backgroundColor:"#F1F1F1",padding:"1rem",display:"flex",justifyContent:"space-between",alignItems:"center",color:"#000000",borderTopLeftRadius:"8px",borderTopRightRadius:"8px",fontWeight:"bold",fontSize:"16px"}},e.createElement("span",null,"Price Summary"),e.createElement("button",{onClick:Se,style:{background:"none",border:"none",color:"#000000",fontSize:"16px",fontWeight:"bold",cursor:"pointer",padding:0,marginLeft:"auto",transition:"transform 0.3s ease"}},"✕")),e.createElement("div",{style:{backgroundColor:"white",padding:"10px 1rem 0"}},e.createElement(e.Fragment,null,(G&&Ve>0||z&&Le.length>0||je&&Te>0)&&e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"14px",color:"#212529"}},"Subtotal"),e.createElement("span",{style:{fontSize:"14px",color:"#212529"}},ue,p(je?K?Be.toFixed(2):Be.toFixed(0):K?De.toFixed(2):De.toFixed(0)))),(Ie>0||G&&Ve>0||je&&Te>0)&&e.createElement("div",{style:{display:"flex",flexDirection:"column",paddingBottom:"5px",marginTop:"5px",fontWeight:"600"}},G&&Ve>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#212529"}},e.createElement("span",null,"Discount on MRP"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Ve.toFixed(2):Ve.toFixed(0)))),je&&Te>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#212529"}},e.createElement("span",null,"Free Shipping"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Te.toFixed(2):Te.toFixed(0)))),Le.map(t=>e.createElement("div",{key:t.title,style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#1E1E1E"}},e.createElement("span",null,t.title),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?t.amount.toFixed(2):t.amount.toFixed(0))))),Pe>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#212529",marginTop:"5px",paddingTop:"5px",borderTop:"1px solid #E5E7EB"}},e.createElement("span",null,"Total Savings"),e.createElement("span",{style:{color:"#D3122A",fontWeight:"bold"}},"-",ue,p(K?Pe.toFixed(2):Pe.toFixed(0))))),(Ie>0||G&&Ve>0||je&&Te>0)&&e.createElement("div",{style:{height:"12px",display:"flex",background:"#F5F5F5",width:"calc(100% + 2rem)",margin:"10px -1rem 0 -1rem",position:"relative",borderTop:"0.8px solid #C5C5C5",borderBottom:"0.8px solid #C5C5C5"}}))),e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:Ie>0||G&&Ve>0||je&&Te>0?"10px":"0"}},e.createElement("div",{style:{display:"flex",flexDirection:"column"}},e.createElement("span",{style:{fontSize:"14px",fontWeight:"600",color:"#212529"}},"Grand Total"),e.createElement("span",{style:{fontSize:"9px",color:"#4A5157"}},"Inclusive of all taxes")),e.createElement("span",{style:{fontSize:"16px",color:"black",fontWeight:"var(--yt-cart-font-weight)"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0)))),e.createElement("div",{style:{display:"flex",background:$,color:Y,width:"calc(100% + 2rem)",margin:"10px -1rem 0 -1rem",position:"relative",fontSize:"12px",fontWeight:"600",justifyContent:"center",alignItems:"center",gap:"5px",padding:"4px 0"}},e.createElement("img",{src:"https://r2.yourtoken.io/image%2016.png",alt:"confetti-image",style:{width:"30px",height:"30px"}}),"You saved"," ",e.createElement("span",null,ue,p(K?Pe.toFixed(2):Pe.toFixed(0)))," ","on your order")),e.createElement("button",{ref:ve,id:"yt-checkout-button-popout",className:"yt-checkout-button",onClick:We,disabled:_e,style:{display:"flex",flexDirection:"row",alignItems:"center",margin:0,height:"45px",padding:"10px",justifyContent:"center",columnGap:"8px",backgroundColor:k,border:0,textTransform:"uppercase",fontSize:S,letterSpacing:"1px",opacity:_e?.5:1,cursor:_e?"not-allowed":"pointer",borderRadius:"0px",boxShadow:"none",width:"100%"}},Ke(de)))),(!0===j||"true"===j)&&U&&_e&&Ne&&e.createElement("div",{style:{display:"flex",justifyContent:"center",textAlign:"center",fontSize:"13px",color:"red"}},Ne),!0===j||"true"===j?e.createElement("div",{className:"yt-cart-checkout-section-concise-container",style:{display:"flex",flexDirection:"column",backgroundColor:"rgba(138, 138, 138, 0.08)",paddingTop:"10px"}},e.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"stretch",justifyContent:"space-between",width:"auto",padding:P?"7px 0 8px 8px":`7px 8px ${J}px 8px`}},e.createElement("div",{style:{display:"flex",flexDirection:"column",textAlign:"center",justifyContent:"center",alignItems:"flex-start",paddingRight:"2rem",overflowWrap:"normal"}},(Ie>0||G&&Ve>0||je&&Te>0)&&e.createElement("div",{className:"yt-cart-checkout-save-badge",ref:ke,style:{fontSize:"9px",backgroundColor:k,width:"max-content",padding:"2px 8px"}},"Saving ",ue,p(K?Pe.toFixed(2):Pe.toFixed(0))),de?e.createElement("div",{style:{fontSize:"12px",color:"#4a4a4a"}},"Redirecting to Checkout..."):z||je&&ze?e.createElement("div",null,e.createElement("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"center"}},e.createElement("span",{style:{fontSize:"15px",color:"#1E1E1E",fontWeight:"600"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0))),(Ie>0||Ve>0||je&&Te>0)&&e.createElement("span",{style:{fontSize:"14px",color:"#8C8C8C",textDecoration:"line-through",marginLeft:"4px",fontWeight:"normal"}},ue,p(je?Be.toFixed(0):De.toFixed(0))))):e.createElement("div",{style:{fontSize:"18px",color:"#1E1E1E",fontWeight:"600"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0))),G&&Ve>0||z&&Ie>0||je&&Te>0?e.createElement("div",{style:{fontSize:"11px",color:"#4A5157",width:"max-content",cursor:"pointer",textDecoration:"underline"},onClick:e=>{e.stopPropagation(),ye("opening"),requestAnimationFrame(()=>{ye("open")}),he(!ge)}},"See Details"):e.createElement("div",{style:{fontSize:"9px",color:"#4A5157",width:"max-content"}},"Inclusive of all taxes")),e.createElement("div",{style:{display:"flex",justifyContent:"center",width:"100%"}},e.createElement("button",{ref:Ce,id:"yt-checkout-button",className:"yt-checkout-button",onClick:We,disabled:_e,style:{backgroundColor:k,border:0,textTransform:"uppercase",letterSpacing:"1px",fontSize:"12px",padding:"10px 15px",opacity:_e?.5:1,cursor:_e?"not-allowed":"pointer",borderRadius:"rounded"===W?`${_}px`:"0px",width:"100%",margin:"0 auto",boxShadow:"none"}},X?e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",pointerEvents:"none"}},e.createElement("span",{style:{fontSize:"12px"}},"CHECKOUT"),e.createElement("div",{style:{display:"flex",alignItems:"center",marginLeft:"1.5rem"}},e.createElement("img",{src:"https://r2.yourtoken.io/checkout-button-payment-provider-icons.png",alt:"Payment methods",style:{height:"22px",width:"auto"}}),e.createElement(y,{fontSize:"24px"}))):"CHECKOUT"))),Q&&!te&&e.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingBlock:"0 6px"}},e.createElement("img",{src:"https://r2.yourtoken.io/powered-by-badge-v2.png",alt:"Powered by YourToken",style:{height:"auto",width:"340px"}}))):e.createElement(e.Fragment,null,U&&_e&&Ne&&e.createElement("div",{style:{display:"flex",justifyContent:"center",textAlign:"center",fontSize:"13px",color:"red"}},Ne),e.createElement("div",{className:"yt-cart-checkout-summary",style:{display:"flex",flexDirection:"column",rowGap:"5px",backgroundColor:"rgba(138, 138, 138, 0.08)",paddingTop:te?"0px":"10px"}},e.createElement("div",{style:{display:te?"none":"flex",flexDirection:"column",rowGap:"2px",margin:"0 1rem",color:ee}},(Ve>0||z&&Le.length>0||je&&Te>0)&&Pe>0&&e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px"}},"Subtotal"),e.createElement("span",{style:{fontSize:"14px"}},ue,p(je?K?Be.toFixed(2):Be.toFixed(0):K?De.toFixed(2):De.toFixed(0)))),(Ie>0||Ve>0||je&&Te>0)&&e.createElement("div",{style:{display:"flex",flexDirection:"column",paddingBottom:"5px"}},e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"12px",fontWeight:"600",display:"flex",alignItems:"center"}},"Discounts Applied",e.createElement("button",{onClick:qe,className:"yt-cart-details-button",style:{marginBottom:"0",marginLeft:"5px",background:"none",border:"none",color:"#7E7E7E",cursor:"pointer",fontSize:"12px",fontWeight:"600",textDecoration:"underline",padding:"0 !important",minHeight:"10px !important",boxShadow:"none",minWidth:"fit-content",height:"auto",lineHeight:"normal",marginTop:"0"}},Oe?"Hide details":"See details")),e.createElement("span",{style:{fontSize:"14px",color:"#D3122A",fontWeight:"600"}},"-",ue,p(K?Pe.toFixed(2):Pe.toFixed(0)))),e.createElement("div",{ref:Ge,style:{height:$e,overflow:"hidden",transition:"height 0.3s ease, opacity 0.3s ease",opacity:Oe?1:0,marginTop:Oe?"5px":"0",borderTop:Oe?"1px solid #E5E7EB":"none",paddingTop:Oe?"5px":"0",fontWeight:"600"}},G&&Ve>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Discount on MRP"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Ve.toFixed(2):Ve.toFixed(0)))),je&&Te>0&&e.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,"Free Shipping"),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?Te.toFixed(2):Te.toFixed(0)))),Le.map(t=>e.createElement("div",{key:t.title,style:{display:"flex",justifyContent:"space-between",fontSize:"12px"}},e.createElement("span",null,t.title),e.createElement("span",{style:{color:"#D3122A"}},"-",ue,p(K?t.amount.toFixed(2):t.amount.toFixed(0))))))),e.createElement("hr",{className:"yt-cart-checkout-divider",style:{height:"1px",margin:"2px 0",backgroundColor:"#E5E7EB",border:"none",maxWidth:"unset"}})),e.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},e.createElement("span",{style:{fontSize:"14px",fontWeight:"600"}},"Total"),e.createElement("span",{style:{fontSize:"16px",fontWeight:"var(--yt-cart-font-weight)"}},ue,p(K?Ae.toFixed(2):Ae.toFixed(0))))),e.createElement("button",{ref:Ce,id:"yt-checkout-button",className:"yt-checkout-button",onClick:We,disabled:_e,style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"closed"!==xe||P?"0":`4px 1rem ${J}px 1rem`,height:"45px",paddingTop:"10px",paddingBottom:"10px",justifyContent:"center",columnGap:"8px",backgroundColor:k,border:0,color:A??"white",textTransform:"uppercase",fontSize:S,letterSpacing:"1px",opacity:_e?.5:1,cursor:_e?"not-allowed":"pointer",borderRadius:"closed"!==xe?"0px":"rounded"===W?`${_}px`:"0px",boxShadow:"none"}},Ke(de,X?"Checkout":"Proceed to Checkout")),Q&&!te&&e.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingBlock:"0px 6px"}},e.createElement("img",{src:"https://r2.yourtoken.io/powered-by-badge-v2.png",alt:"Powered by YourToken",style:{height:"auto",width:"340px"}})))))}export{k as default};
@@ -0,0 +1 @@
1
+ import n from"../../node_modules/style-inject/dist/style-inject.es.js";var e=".custom-date-picker {\n position: relative;\n width: 100%;\n}\n\n.date-display {\n display: flex;\n justify-content: space-between;\n align-items: center;\n cursor: pointer;\n}\n\n.date-display span {\n color: black;\n}\n\n.date-display svg {\n width: 20px;\n height: 20px;\n color: rgb(73, 69, 69);\n}\n\n.calendar-container {\n position: absolute;\n bottom: 100%;\n left: -10%;\n z-index: 10;\n margin-top: 10px;\n}\n\n.custom-calendar {\n background-color: white;\n border-radius: 6px;\n box-shadow: 0 4px 6px rgba(10, 8, 8, 0.1);\n border: 1px solid darken(#674918, 50%);\n}\n";n(e);export{e as default};
@@ -1,4 +1,4 @@
1
- import e,{useState as t,useCallback as a,useEffect as r}from"react";import o from"react-calendar";import{IoCalendar as n}from"react-icons/io5";import"react-calendar/dist/Calendar.css";import{deliverySlotDateState as l}from"../../atoms/dateAtom.js";import{useAtom as c,useSetAtom as i}from"jotai";import d from"styled-components";import{deliveryOptionChosenState as m}from"../../atoms/shippingAtom.js";import{hexToRGBWithOpacity as s}from"../../utils/index.js";const _=d(o)`
1
+ import e,{useState as t,useCallback as a,useEffect as r}from"react";import o from"react-calendar";import{IoCalendar as n}from"react-icons/io5";import"react-calendar/dist/Calendar.css";import"./DatePicker.css.js";import{deliverySlotDateState as l}from"../../atoms/dateAtom.js";import{useAtom as c,useSetAtom as i}from"jotai";import d from"styled-components";import{deliveryOptionChosenState as s}from"../../atoms/shippingAtom.js";import{hexToRGBWithOpacity as m}from"../../utils/index.js";const _=d(o)`
2
2
  .react-calendar {
3
3
  font-family: Arial, sans-serif;
4
4
  color: ${e=>e.tileTextColor||"#374151"} !important;
@@ -95,4 +95,4 @@ import e,{useState as t,useCallback as a,useEffect as r}from"react";import o fro
95
95
  .active-date abbr {
96
96
  color: ${e=>e.tileTextColor||"#374151"} !important;
97
97
  }
98
- `,b=({themeColor:o,themeTextColor:d,disabledDates:b=[]})=>{const[u,g]=t(!1),[p,f]=c(l),v=i(m),D=e.useRef(null),w=p?new Date(p):null,h=Array.isArray(b)?b:[b],k=a(()=>{const e=new Date;return e.setDate(e.getDate()+1),e},[]),y=a(e=>h.some(t=>t instanceof Date&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())),[h]),C=a(e=>{if(!e)return!1;const t=k(),a=new Date(e.getFullYear(),e.getMonth(),e.getDate());return a>=new Date(t.getFullYear(),t.getMonth(),t.getDate())&&!y(a)},[k,y]);r(()=>{const e=e=>{D.current&&!D.current.contains(e.target)&&g(!1)};return u&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[u]),r(()=>{const e=C(w);v(t=>t.isDateValid!==e?{...t,isDateValid:e}:t)},[w,C,v]);const x=a(({date:e,view:t})=>{if("month"===t){const t=k(),a=new Date(e.getFullYear(),e.getMonth(),e.getDate());if(a>=new Date(t.getFullYear(),t.getMonth(),t.getDate())&&!y(a)){const e=p?new Date(p):null;return e&&a.getFullYear()===e.getFullYear()&&a.getMonth()===e.getMonth()&&a.getDate()===e.getDate()?"active-date":"black-date"}}return null},[k,p,y]);return e.createElement("div",{className:"custom-date-picker"},e.createElement("div",{className:"date-display",onClick:()=>g(!u)},e.createElement("span",{style:{fontSize:"12px"}},($=p?new Date(p):null)?$.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}).replace(/\//g,"/"):"Select a date"),e.createElement(n,null)),u&&e.createElement("div",{className:"calendar-container",ref:D},e.createElement(_,{onChange:(e,t)=>{e instanceof Date&&!y(e)&&(f(e.toISOString()),g(!1));const a=C(e instanceof Date?e:null);v(e=>e.isDateValid!==a?{...e,isDateValid:a}:e)},value:p?new Date(p):null,className:"custom-calendar",minDate:k(),tileBackgroundColor:o,tileTextColor:d,tileHoverColor:s(o,.2),tileClassName:x,tileDisabled:({date:e,view:t})=>"month"===t&&y(e)})));var $};export{b as default};
98
+ `,b=({themeColor:o,themeTextColor:d,disabledDates:b=[]})=>{const[u,g]=t(!1),[p,D]=c(l),f=i(s),v=e.useRef(null),w=p?new Date(p):null,h=Array.isArray(b)?b:[b],k=a(()=>{const e=new Date;return e.setDate(e.getDate()+1),e},[]),y=a(e=>h.some(t=>t instanceof Date&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())),[h]),C=a(e=>{if(!e)return!1;const t=k(),a=new Date(e.getFullYear(),e.getMonth(),e.getDate());return a>=new Date(t.getFullYear(),t.getMonth(),t.getDate())&&!y(a)},[k,y]);r(()=>{const e=e=>{v.current&&!v.current.contains(e.target)&&g(!1)};return u&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[u]),r(()=>{const e=C(w);f(t=>t.isDateValid!==e?{...t,isDateValid:e}:t)},[w,C,f]);const x=a(({date:e,view:t})=>{if("month"===t){const t=k(),a=new Date(e.getFullYear(),e.getMonth(),e.getDate());if(a>=new Date(t.getFullYear(),t.getMonth(),t.getDate())&&!y(a)){const e=p?new Date(p):null;return e&&a.getFullYear()===e.getFullYear()&&a.getMonth()===e.getMonth()&&a.getDate()===e.getDate()?"active-date":"black-date"}}return null},[k,p,y]);return e.createElement("div",{className:"custom-date-picker"},e.createElement("div",{className:"date-display",onClick:()=>g(!u)},e.createElement("span",{style:{fontSize:"12px"}},($=p?new Date(p):null)?$.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}).replace(/\//g,"/"):"Select a date"),e.createElement(n,null)),u&&e.createElement("div",{className:"calendar-container",ref:v},e.createElement(_,{onChange:(e,t)=>{e instanceof Date&&!y(e)&&(D(e.toISOString()),g(!1));const a=C(e instanceof Date?e:null);f(e=>e.isDateValid!==a?{...e,isDateValid:a}:e)},value:p?new Date(p):null,className:"custom-calendar",minDate:k(),tileBackgroundColor:o,tileTextColor:d,tileHoverColor:m(o,.2),tileClassName:x,tileDisabled:({date:e,view:t})=>"month"===t&&y(e)})));var $};export{b as default};
@@ -1 +1 @@
1
- import e,{useState as t,useEffect as a}from"react";import{TbTrashXFilled as o,TbTrashX as l}from"react-icons/tb";import{cartDataState as r}from"../../atoms/cartDataAtom.js";import{useAtomValue as C}from"jotai";import{useCartLoading as n}from"../../atoms/cartLoadingAtom.js";import{getCookieValue as i}from"../../utils/index.js";import{ClipLoader as c}from"react-spinners";import{getCurrencyValueFromShopifyPrice as s,getCurrencySymbol as m}from"../../utils/converter.js";const p=()=>{const[o,l]=t(0);return a(()=>{const e=setTimeout(()=>{l(100)},1e3);return()=>clearTimeout(e)},[]),e.createElement("div",{className:"yt-loyalty-cta-progress-bar-container"},e.createElement("div",{className:"yt-loyalty-cta-progress-bar",style:{width:`${o}%`}},"‎"))},d=({removeDiscount:a,isDev:d,themeColor:y,ctaButtonBackgroundColor:x,ctaButtonTextColor:L,primaryTextColor:g,secondaryTextColor:f,loyaltyDiscount:u,pointsToBeUsed:E,brandTokenName:b,showCartLevelAltPay:v})=>{const h=C(r),{cartLoading:w,setLoading:A}=n(),[N,z]=t(!1),B=w.showLoyaltyCtaLoading,S=s(u?.total_allocated_amount??0,h?.currency);return B?e.createElement("div",{className:"yt-loyalty-apply-cta-loading-container",style:{marginBottom:v?"0":"1rem"}},e.createElement("span",{style:{fontSize:"13px"}},"Processing points..."),e.createElement(c,{color:"black",loading:B,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}),e.createElement(p,null)):e.createElement("div",{className:"yt-loyalty-cta-applied-container",style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"#FAFAFA",border:"1px solid #E5E7E8",borderRadius:"10px",padding:"12px 16px",margin:"0 1rem",boxShadow:"0px 3px 3.8px 0px rgba(1, 1, 1, 0.231372549)",zIndex:100,marginBottom:v?"0":"1rem"}},e.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"10px",alignItems:"center"}},e.createElement("svg",{width:"17",height:"18",viewBox:"0 0 17 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M16.3716 9.64475C16.2849 9.50135 16.239 9.33692 16.239 9.1693C16.239 9.00167 16.2849 8.83724 16.3716 8.69384L16.67 8.20819C16.821 7.96172 16.9167 7.68543 16.9507 7.39837C16.9847 7.1113 16.9561 6.82027 16.8669 6.54532C16.7777 6.27038 16.63 6.01805 16.4339 5.80572C16.2379 5.59339 15.9982 5.42611 15.7313 5.31539L15.2044 5.09696C15.0488 5.03308 14.914 4.92711 14.8152 4.79093C14.7164 4.65474 14.6574 4.49372 14.6448 4.32588L14.6012 3.75431C14.5775 3.46646 14.4919 3.18711 14.3505 2.93534C14.209 2.68358 14.0149 2.46533 13.7814 2.2955C13.5479 2.12567 13.2805 2.00826 12.9975 1.95128C12.7145 1.8943 12.4226 1.89909 12.1416 1.96534L11.5857 2.09713C11.4226 2.13644 11.2518 2.13007 11.0922 2.07869C10.9325 2.02731 10.79 1.93293 10.6804 1.80588L10.3122 1.36901C10.1245 1.14887 9.89139 0.972091 9.62882 0.850869C9.36625 0.729647 9.08052 0.66687 8.79134 0.66687C8.50217 0.66687 8.21644 0.729647 7.95387 0.850869C7.6913 0.972091 7.45814 1.14887 7.27048 1.36901L6.89863 1.80588C6.78907 1.93319 6.64649 2.02775 6.48663 2.07914C6.32677 2.13053 6.15584 2.13675 5.99267 2.09713L5.43671 1.96534C5.15574 1.89909 4.8638 1.8943 4.5808 1.95128C4.29781 2.00826 4.03044 2.12567 3.79695 2.2955C3.56346 2.46533 3.36934 2.68358 3.22786 2.93534C3.08637 3.18711 3.00085 3.46646 2.97714 3.75431L2.93348 4.32588C2.92053 4.49352 2.86128 4.65426 2.76233 4.79015C2.66339 4.92605 2.52866 5.03177 2.37316 5.0955L1.84631 5.31393C1.57905 5.4243 1.33887 5.59134 1.14236 5.80354C0.945839 6.01575 0.79765 6.26807 0.708004 6.54312C0.618359 6.81817 0.58939 7.10939 0.623094 7.39672C0.656799 7.68406 0.752375 7.96066 0.903234 8.20746L1.20158 8.69311C1.28834 8.83651 1.3342 9.00094 1.3342 9.16857C1.3342 9.3362 1.28834 9.50062 1.20158 9.64403L0.903234 10.1355C0.752508 10.3821 0.656925 10.6584 0.623055 10.9455C0.589185 11.2325 0.61783 11.5235 0.707022 11.7984C0.796215 12.0734 0.943839 12.3257 1.13975 12.5381C1.33566 12.7506 1.57521 12.918 1.84195 13.029L2.36879 13.2475C2.52387 13.3107 2.65833 13.4158 2.75715 13.551C2.85597 13.6863 2.91525 13.8464 2.92838 14.0134L2.97204 14.585C2.99511 14.8731 3.08023 15.1527 3.22156 15.4047C3.3629 15.6567 3.55709 15.8751 3.79079 16.0449C4.02449 16.2147 4.29217 16.3318 4.57541 16.3882C4.85865 16.4447 5.15075 16.4391 5.43162 16.3718L5.98757 16.24C6.15078 16.2015 6.32137 16.2083 6.48101 16.2596C6.64064 16.311 6.78327 16.4049 6.89354 16.5313L7.26539 16.9681C7.45339 17.1876 7.68662 17.3638 7.94908 17.4846C8.21153 17.6053 8.497 17.6679 8.78589 17.6679C9.07477 17.6679 9.36024 17.6053 9.62269 17.4846C9.88515 17.3638 10.1184 17.1876 10.3064 16.9681L10.6746 16.5313C10.7848 16.405 10.9273 16.3112 11.0868 16.2599C11.2463 16.2085 11.4167 16.2017 11.5798 16.24L12.1358 16.3718C12.4167 16.4391 12.7088 16.4447 12.992 16.3882C13.2752 16.3318 13.5429 16.2147 13.7766 16.0449C14.0103 15.8751 14.2045 15.6567 14.3458 15.4047C14.4872 15.1527 14.5723 14.8731 14.5954 14.585L14.639 14.0134C14.6523 13.8465 14.7116 13.6866 14.8104 13.5515C14.9093 13.4163 15.0436 13.3113 15.1986 13.2482L15.7255 13.0298C15.8212 12.99 15.9136 12.9428 16.002 12.8885C16.2266 12.7517 16.4221 12.572 16.5772 12.3595C16.7323 12.1471 16.8441 11.9061 16.9061 11.6504C16.968 11.3947 16.979 11.1293 16.9384 10.8694C16.8978 10.6094 16.8063 10.3601 16.6693 10.1355L16.3716 9.64475ZM5.98393 7.35411C5.98393 7.2101 6.02661 7.06933 6.10657 6.94959C6.18653 6.82985 6.30018 6.73653 6.43315 6.68142C6.56611 6.62631 6.71243 6.61189 6.85358 6.63999C6.99474 6.66808 7.1244 6.73743 7.22617 6.83925C7.32794 6.94108 7.39724 7.07082 7.42532 7.21206C7.4534 7.3533 7.43899 7.4997 7.38391 7.63275C7.32884 7.76579 7.23557 7.87951 7.1159 7.95951C6.99623 8.03952 6.85554 8.08222 6.71162 8.08222C6.51862 8.08222 6.33354 8.00551 6.19707 7.86896C6.0606 7.73241 5.98393 7.54722 5.98393 7.35411ZM6.98959 11.7374C6.9397 11.7884 6.88002 11.8288 6.81412 11.8562C6.74822 11.8837 6.67746 11.8974 6.6061 11.8968C6.49941 11.8968 6.39509 11.8653 6.30613 11.8064C6.21718 11.7474 6.14753 11.6636 6.10587 11.5653C6.06421 11.467 6.05237 11.3586 6.07184 11.2537C6.0913 11.1487 6.14121 11.0518 6.21534 10.975L10.5814 6.60634C10.682 6.50598 10.8177 6.44884 10.9596 6.44708C11.1016 6.44531 11.2387 6.49906 11.3417 6.59688C11.4447 6.6947 11.5054 6.82888 11.511 6.97084C11.5166 7.11281 11.4667 7.25137 11.3717 7.35702L11.3513 7.37741L6.98959 11.7374ZM11.0806 11.7148C10.8887 11.7148 10.7044 11.6389 10.5681 11.5036C10.4318 11.3683 10.3545 11.1846 10.353 10.9925V10.9874C10.353 10.8434 10.3956 10.7026 10.4756 10.5829C10.5556 10.4631 10.6692 10.3698 10.8022 10.3147C10.9351 10.2596 11.0814 10.2452 11.2226 10.2733C11.3638 10.3014 11.4934 10.3707 11.5952 10.4725C11.697 10.5744 11.7663 10.7041 11.7943 10.8453C11.8224 10.9866 11.808 11.133 11.7529 11.266C11.6979 11.3991 11.6046 11.5128 11.4849 11.5928C11.3653 11.6728 11.2246 11.7155 11.0806 11.7155",fill:y})),e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"4px"}},e.createElement("span",{className:"yt-loyalty-cta-applied-text",style:{fontSize:"13px",fontWeight:"bold",color:g??"#000"}},m(h,h?.currency),Number(S?.toFixed(1))??0," Off Coupon Applied!"),e.createElement("span",{className:"yt-loyalty-cta-applied-code-text",style:{fontSize:"9px",color:y??"#EF4444"}},"Code: ",i("discount_code")))),e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"4px",cursor:"pointer"},onClick:async()=>{A&&A(!0,!1,!1,!0);try{await a()}catch(e){}A&&A(!1,!1,!1,!1)},onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1)}," ",N?e.createElement(o,{className:"yt-loyalty-cta-applied-delete-btn",color:"#9CA3AF",fontSize:"16px"}):e.createElement(l,{className:"yt-loyalty-cta-applied-delete-btn",color:"#9CA3AF",fontSize:"16px"}),e.createElement("span",{className:"yt-loyalty-cta-applied-text",style:{fontSize:"8px",color:f??"#6B7280",fontWeight:"600"}},"REMOVE")))};export{p as LoyaltyCtaProgressBar,d as default};
1
+ import e,{useState as t,useEffect as a}from"react";import{TbTrashXFilled as o,TbTrashX as l}from"react-icons/tb";import"./shared.scss.js";import{cartDataState as r}from"../../atoms/cartDataAtom.js";import{useAtomValue as C}from"jotai";import{useCartLoading as n}from"../../atoms/cartLoadingAtom.js";import{getCookieValue as s}from"../../utils/index.js";import{ClipLoader as i}from"react-spinners";import{getCurrencyValueFromShopifyPrice as c,getCurrencySymbol as m}from"../../utils/converter.js";const p=()=>{const[o,l]=t(0);return a(()=>{const e=setTimeout(()=>{l(100)},1e3);return()=>clearTimeout(e)},[]),e.createElement("div",{className:"yt-loyalty-cta-progress-bar-container"},e.createElement("div",{className:"yt-loyalty-cta-progress-bar",style:{width:`${o}%`}},"‎"))},d=({removeDiscount:a,isDev:d,themeColor:y,ctaButtonBackgroundColor:x,ctaButtonTextColor:L,primaryTextColor:g,secondaryTextColor:f,loyaltyDiscount:u,pointsToBeUsed:E,brandTokenName:b,showCartLevelAltPay:v})=>{const h=C(r),{cartLoading:w,setLoading:A}=n(),[N,z]=t(!1),B=w.showLoyaltyCtaLoading,S=c(u?.total_allocated_amount??0,h?.currency);return B?e.createElement("div",{className:"yt-loyalty-apply-cta-loading-container",style:{marginBottom:v?"0":"1rem"}},e.createElement("span",{style:{fontSize:"13px"}},"Processing points..."),e.createElement(i,{color:"black",loading:B,size:15,"aria-label":"Loading Spinner","data-testid":"loader"}),e.createElement(p,null)):e.createElement("div",{className:"yt-loyalty-cta-applied-container",style:{display:"flex",alignItems:"center",justifyContent:"space-between",background:"#FAFAFA",border:"1px solid #E5E7E8",borderRadius:"10px",padding:"12px 16px",margin:"0 1rem",boxShadow:"0px 3px 3.8px 0px rgba(1, 1, 1, 0.231372549)",zIndex:100,marginBottom:v?"0":"1rem"}},e.createElement("div",{style:{display:"flex",flexDirection:"row",gap:"10px",alignItems:"center"}},e.createElement("svg",{width:"17",height:"18",viewBox:"0 0 17 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M16.3716 9.64475C16.2849 9.50135 16.239 9.33692 16.239 9.1693C16.239 9.00167 16.2849 8.83724 16.3716 8.69384L16.67 8.20819C16.821 7.96172 16.9167 7.68543 16.9507 7.39837C16.9847 7.1113 16.9561 6.82027 16.8669 6.54532C16.7777 6.27038 16.63 6.01805 16.4339 5.80572C16.2379 5.59339 15.9982 5.42611 15.7313 5.31539L15.2044 5.09696C15.0488 5.03308 14.914 4.92711 14.8152 4.79093C14.7164 4.65474 14.6574 4.49372 14.6448 4.32588L14.6012 3.75431C14.5775 3.46646 14.4919 3.18711 14.3505 2.93534C14.209 2.68358 14.0149 2.46533 13.7814 2.2955C13.5479 2.12567 13.2805 2.00826 12.9975 1.95128C12.7145 1.8943 12.4226 1.89909 12.1416 1.96534L11.5857 2.09713C11.4226 2.13644 11.2518 2.13007 11.0922 2.07869C10.9325 2.02731 10.79 1.93293 10.6804 1.80588L10.3122 1.36901C10.1245 1.14887 9.89139 0.972091 9.62882 0.850869C9.36625 0.729647 9.08052 0.66687 8.79134 0.66687C8.50217 0.66687 8.21644 0.729647 7.95387 0.850869C7.6913 0.972091 7.45814 1.14887 7.27048 1.36901L6.89863 1.80588C6.78907 1.93319 6.64649 2.02775 6.48663 2.07914C6.32677 2.13053 6.15584 2.13675 5.99267 2.09713L5.43671 1.96534C5.15574 1.89909 4.8638 1.8943 4.5808 1.95128C4.29781 2.00826 4.03044 2.12567 3.79695 2.2955C3.56346 2.46533 3.36934 2.68358 3.22786 2.93534C3.08637 3.18711 3.00085 3.46646 2.97714 3.75431L2.93348 4.32588C2.92053 4.49352 2.86128 4.65426 2.76233 4.79015C2.66339 4.92605 2.52866 5.03177 2.37316 5.0955L1.84631 5.31393C1.57905 5.4243 1.33887 5.59134 1.14236 5.80354C0.945839 6.01575 0.79765 6.26807 0.708004 6.54312C0.618359 6.81817 0.58939 7.10939 0.623094 7.39672C0.656799 7.68406 0.752375 7.96066 0.903234 8.20746L1.20158 8.69311C1.28834 8.83651 1.3342 9.00094 1.3342 9.16857C1.3342 9.3362 1.28834 9.50062 1.20158 9.64403L0.903234 10.1355C0.752508 10.3821 0.656925 10.6584 0.623055 10.9455C0.589185 11.2325 0.61783 11.5235 0.707022 11.7984C0.796215 12.0734 0.943839 12.3257 1.13975 12.5381C1.33566 12.7506 1.57521 12.918 1.84195 13.029L2.36879 13.2475C2.52387 13.3107 2.65833 13.4158 2.75715 13.551C2.85597 13.6863 2.91525 13.8464 2.92838 14.0134L2.97204 14.585C2.99511 14.8731 3.08023 15.1527 3.22156 15.4047C3.3629 15.6567 3.55709 15.8751 3.79079 16.0449C4.02449 16.2147 4.29217 16.3318 4.57541 16.3882C4.85865 16.4447 5.15075 16.4391 5.43162 16.3718L5.98757 16.24C6.15078 16.2015 6.32137 16.2083 6.48101 16.2596C6.64064 16.311 6.78327 16.4049 6.89354 16.5313L7.26539 16.9681C7.45339 17.1876 7.68662 17.3638 7.94908 17.4846C8.21153 17.6053 8.497 17.6679 8.78589 17.6679C9.07477 17.6679 9.36024 17.6053 9.62269 17.4846C9.88515 17.3638 10.1184 17.1876 10.3064 16.9681L10.6746 16.5313C10.7848 16.405 10.9273 16.3112 11.0868 16.2599C11.2463 16.2085 11.4167 16.2017 11.5798 16.24L12.1358 16.3718C12.4167 16.4391 12.7088 16.4447 12.992 16.3882C13.2752 16.3318 13.5429 16.2147 13.7766 16.0449C14.0103 15.8751 14.2045 15.6567 14.3458 15.4047C14.4872 15.1527 14.5723 14.8731 14.5954 14.585L14.639 14.0134C14.6523 13.8465 14.7116 13.6866 14.8104 13.5515C14.9093 13.4163 15.0436 13.3113 15.1986 13.2482L15.7255 13.0298C15.8212 12.99 15.9136 12.9428 16.002 12.8885C16.2266 12.7517 16.4221 12.572 16.5772 12.3595C16.7323 12.1471 16.8441 11.9061 16.9061 11.6504C16.968 11.3947 16.979 11.1293 16.9384 10.8694C16.8978 10.6094 16.8063 10.3601 16.6693 10.1355L16.3716 9.64475ZM5.98393 7.35411C5.98393 7.2101 6.02661 7.06933 6.10657 6.94959C6.18653 6.82985 6.30018 6.73653 6.43315 6.68142C6.56611 6.62631 6.71243 6.61189 6.85358 6.63999C6.99474 6.66808 7.1244 6.73743 7.22617 6.83925C7.32794 6.94108 7.39724 7.07082 7.42532 7.21206C7.4534 7.3533 7.43899 7.4997 7.38391 7.63275C7.32884 7.76579 7.23557 7.87951 7.1159 7.95951C6.99623 8.03952 6.85554 8.08222 6.71162 8.08222C6.51862 8.08222 6.33354 8.00551 6.19707 7.86896C6.0606 7.73241 5.98393 7.54722 5.98393 7.35411ZM6.98959 11.7374C6.9397 11.7884 6.88002 11.8288 6.81412 11.8562C6.74822 11.8837 6.67746 11.8974 6.6061 11.8968C6.49941 11.8968 6.39509 11.8653 6.30613 11.8064C6.21718 11.7474 6.14753 11.6636 6.10587 11.5653C6.06421 11.467 6.05237 11.3586 6.07184 11.2537C6.0913 11.1487 6.14121 11.0518 6.21534 10.975L10.5814 6.60634C10.682 6.50598 10.8177 6.44884 10.9596 6.44708C11.1016 6.44531 11.2387 6.49906 11.3417 6.59688C11.4447 6.6947 11.5054 6.82888 11.511 6.97084C11.5166 7.11281 11.4667 7.25137 11.3717 7.35702L11.3513 7.37741L6.98959 11.7374ZM11.0806 11.7148C10.8887 11.7148 10.7044 11.6389 10.5681 11.5036C10.4318 11.3683 10.3545 11.1846 10.353 10.9925V10.9874C10.353 10.8434 10.3956 10.7026 10.4756 10.5829C10.5556 10.4631 10.6692 10.3698 10.8022 10.3147C10.9351 10.2596 11.0814 10.2452 11.2226 10.2733C11.3638 10.3014 11.4934 10.3707 11.5952 10.4725C11.697 10.5744 11.7663 10.7041 11.7943 10.8453C11.8224 10.9866 11.808 11.133 11.7529 11.266C11.6979 11.3991 11.6046 11.5128 11.4849 11.5928C11.3653 11.6728 11.2246 11.7155 11.0806 11.7155",fill:y})),e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"4px"}},e.createElement("span",{className:"yt-loyalty-cta-applied-text",style:{fontSize:"13px",fontWeight:"bold",color:g??"#000"}},m(h,h?.currency),Number(S?.toFixed(1))??0," Off Coupon Applied!"),e.createElement("span",{className:"yt-loyalty-cta-applied-code-text",style:{fontSize:"9px",color:y??"#EF4444"}},"Code: ",s("discount_code")))),e.createElement("div",{style:{display:"flex",alignItems:"center",gap:"4px",cursor:"pointer"},onClick:async()=>{A&&A(!0,!1,!1,!0);try{await a()}catch(e){}A&&A(!1,!1,!1,!1)},onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1)}," ",N?e.createElement(o,{className:"yt-loyalty-cta-applied-delete-btn",color:"#9CA3AF",fontSize:"16px"}):e.createElement(l,{className:"yt-loyalty-cta-applied-delete-btn",color:"#9CA3AF",fontSize:"16px"}),e.createElement("span",{className:"yt-loyalty-cta-applied-text",style:{fontSize:"8px",color:f??"#6B7280",fontWeight:"600"}},"REMOVE")))};export{p as LoyaltyCtaProgressBar,d as default};
@@ -1 +1 @@
1
- import e from"react";import r from"./SingleTierProgressBar.js";import t from"./MultiTierProgressBar.js";const o=o=>o?.checkpoints&&o.checkpoints.length>0?1===o.checkpoints.length?e.createElement(r,{...o}):e.createElement(t,{...o}):null;export{o as default};
1
+ import e from"react";import"./multiStepProgressBar.scss.js";import r from"./SingleTierProgressBar.js";import t from"./MultiTierProgressBar.js";const s=s=>s?.checkpoints&&s.checkpoints.length>0?1===s.checkpoints.length?e.createElement(r,{...s}):e.createElement(t,{...s}):null;export{s as default};
@@ -0,0 +1 @@
1
+ import n from"../../../node_modules/style-inject/dist/style-inject.es.js";var e='.progress-container {\n --yt-line-border-fill: #3498db;\n --yt-line-border-empty: #e0e0e0;\n display: flex;\n justify-content: space-between;\n position: relative;\n margin-bottom: 30px;\n max-width: 100%;\n width: 350px;\n}\n\n.progress-container::before {\n content: ""; /* Mandatory with ::before */\n background-color: var(--yt-line-border-empty);\n position: absolute;\n top: 50%;\n left: 0;\n transform: translateY(-50%);\n height: 4px;\n width: 100%;\n z-index: -1;\n}\n\n.progress {\n background-color: var(--yt-line-border-fill);\n position: absolute;\n top: 50%;\n left: 0;\n transform: translateY(-50%);\n height: 4px;\n width: 0%;\n z-index: -1;\n transition: 0.4s ease;\n}';n(e);export{e as default};
@@ -1 +1 @@
1
- import{noteInputState as e}from"../../atoms/noteInputAtom.js";import{useAtom as t}from"jotai";import n,{useState as a,useEffect as r}from"react";import{FaChevronDown as o,FaChevronUp as l}from"react-icons/fa";import{RxInfoCircled as m}from"react-icons/rx";const i=({note:i,noteSectionTitle:c="Order Note"})=>{const[s,p]=t(e),[f,u]=a(!1);return r(()=>{""===s&&i&&""!==i&&p(i)},[i]),n.createElement("div",{className:"form-group"},n.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"6px 1rem"},onClick:()=>u(!f)},n.createElement("span",{style:{fontSize:"12px",display:"flex",gap:"5px",alignItems:"center"}},c," ",n.createElement(m,null)),n.createElement("div",{className:"icon-transition"},f?n.createElement(o,null):n.createElement(l,null))),f&&n.createElement("textarea",{className:"floating-input-note",value:s,onChange:e=>{p(e.target.value)}}))};export{i as default};
1
+ import{noteInputState as e}from"../../atoms/noteInputAtom.js";import{useAtom as t}from"jotai";import n,{useState as a,useEffect as r}from"react";import{FaChevronDown as o,FaChevronUp as l}from"react-icons/fa";import{RxInfoCircled as m}from"react-icons/rx";import"./NoteSectionStyles.scss.js";const i=({note:i,noteSectionTitle:s="Order Note"})=>{const[c,p]=t(e),[f,u]=a(!1);return r(()=>{""===c&&i&&""!==i&&p(i)},[i]),n.createElement("div",{className:"form-group"},n.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"6px 1rem"},onClick:()=>u(!f)},n.createElement("span",{style:{fontSize:"12px",display:"flex",gap:"5px",alignItems:"center"}},s," ",n.createElement(m,null)),n.createElement("div",{className:"icon-transition"},f?n.createElement(o,null):n.createElement(l,null))),f&&n.createElement("textarea",{className:"floating-input-note",value:c,onChange:e=>{p(e.target.value)}}))};export{i as default};
@@ -0,0 +1 @@
1
+ import n from"../../node_modules/style-inject/dist/style-inject.es.js";var o='.form-group {\n position: relative;\n display: block;\n}\n\n.floating-input-note {\n position: relative;\n display: block;\n width: 95%;\n max-width: 95%;\n border: 1px solid rgba(0, 0, 0, 0.37);\n background-color: transparent;\n margin: 0px 1rem;\n outline: none !important;\n font-size: 14px;\n color: rgba(0, 0, 0, 0.85);\n transition: all 0.2s ease-in-out;\n}\n\n.icon-transition {\n transition: all 0.2s ease-in-out;\n cursor: pointer;\n}\n\n.floating-label {\n position: absolute;\n top: -6px;\n left: 12px;\n text-align: left;\n display: inline-block;\n padding: 0 4px;\n height: 14px;\n line-height: 14px;\n font-size: 12px;\n font-weight: 400;\n background: #fff;\n color: rgba(0, 0, 0, 0.5);\n margin: 0px auto;\n cursor: text;\n transition: all 0.15s ease-in-out;\n}\n\n.floating-input-note:hover,\n.floating-input-note:focus {\n border: 1px solid #000;\n}\n\n.floating-input-note:valid + label,\n.floating-input-note:focus + label {\n color: #000;\n font-size: 9px;\n}\n\n.gl-form-asterisk {\n background-color: inherit;\n color: rgba(0, 0, 0, 0.5);\n padding: 0;\n padding-left: 3px;\n}\n\n.gl-form-asterisk:after {\n content: "*";\n color: #000;\n}';n(o);export{o as default};
@@ -1 +1 @@
1
- import e from"react";import{hexToRGBWithOpacity as t}from"../../utils/index.js";const n=({value:n,handleItemQuantityDecrement:o,handleItemQuantityIncrement:r,isDev:a,themeColor:d,cartComponentsCornerType:i,cartComponentsCornerRadius:l,backgroundSubdued:c})=>e.createElement("form",{style:{marginBottom:"0px",width:"auto",height:"auto"}},e.createElement("div",{style:{border:"1px solid #dddddd",display:"flex",flexDirection:"row",borderRadius:"rounded"===i?`${l}px`:"8px",overflow:"hidden"}},e.createElement("button",{onClick:()=>0!==n&&o(),type:"button",className:"qty-selector-decrement-button",style:{backgroundColor:c??t(d,.1)}},"-"),e.createElement("input",{readOnly:!0,type:"text","aria-describedby":"helper-text-explanation",className:"qty-selector-input",style:{textIndent:0,border:0,margin:0,width:"28px",minHeight:"22px !important",fontSize:"14px",padding:0,height:"auto",textAlign:"center",color:"black !important",background:"#ffffff !important"},value:n,required:!0}),e.createElement("button",{onClick:()=>r(),type:"button",id:"increment-button",className:"qty-selector-decrement-button",style:{backgroundColor:c??t(d,.1)}},"+")));export{n as QuantitySelector};
1
+ import e from"react";import"./shared.scss.js";import{hexToRGBWithOpacity as t}from"../../utils/index.js";const r=({value:r,handleItemQuantityDecrement:n,handleItemQuantityIncrement:o,isDev:a,themeColor:d,cartComponentsCornerType:i,cartComponentsCornerRadius:l,backgroundSubdued:c})=>e.createElement("form",{style:{marginBottom:"0px",width:"auto",height:"auto"}},e.createElement("div",{style:{border:"1px solid #dddddd",display:"flex",flexDirection:"row",borderRadius:"rounded"===i?`${l}px`:"8px",overflow:"hidden"}},e.createElement("button",{onClick:()=>0!==r&&n(),type:"button",className:"qty-selector-decrement-button",style:{backgroundColor:c??t(d,.1)}},"-"),e.createElement("input",{readOnly:!0,type:"text","aria-describedby":"helper-text-explanation",className:"qty-selector-input",style:{textIndent:0,border:0,margin:0,width:"28px",minHeight:"22px !important",fontSize:"14px",padding:0,height:"auto",textAlign:"center",color:"black !important",background:"#ffffff !important"},value:r,required:!0}),e.createElement("button",{onClick:()=>o(),type:"button",id:"increment-button",className:"qty-selector-decrement-button",style:{backgroundColor:c??t(d,.1)}},"+")));export{r as QuantitySelector};
@@ -1 +1 @@
1
- import e,{useState as t,useRef as a,useCallback as l,useEffect as i}from"react";import r from"./DatePicker.js";import{postalCodeState as s}from"../../atoms/postalCodeAtom.js";import{useAtom as o,useAtomValue as m}from"jotai";import{deliveryOptionChosenState as c,deliveryTypeState as d,isDeliveryOptionValidState as n}from"../../atoms/shippingAtom.js";const v=({title:v="Cart Item(s) available in NCR only",backgroundColor:u="#F6EFDD78",tag:p="NCR",postalCodeList:b=[110001,110002,110003,110004,110005],themeColor:C,themeTextColor:h,enableSlotPicker:y,deliveryHeaderTitle:E,deliveryAvailableText:N,deliveryNotAvailableText:x,disabledDates:f})=>{const[g,D]=t(!1),[T,P]=o(s),[V,k]=o(c),[A,j]=o(d),S=m(n),R=a(null),F=l(e=>{const t=b.includes(e);D(!t),k(e=>({...e,isPostalCodeValid:t}))},[b,k]);return i(()=>{j("specific")},[]),i(()=>{void 0!==T&&F(T)},[T,F]),i(()=>{!1===y&&k(e=>e.isDateValid?e:{...e,isDateValid:!0})},[y,k]),e.createElement("div",null,E&&e.createElement("div",{className:"shipment-header"},e.createElement("h2",{className:"shipment-header-text"},E)),e.createElement("div",{className:"availability-check",style:{border:`2px solid ${C||"black"}`,padding:"12px",borderRadius:"8px",margin:"8px 1rem"}},e.createElement("div",{className:"availability-title"},"Check Shipment Availability"),e.createElement("input",{className:"availability-input",type:"text",placeholder:"Enter Postal Code",value:T||"",onChange:e=>{const t=e.target.value;if(""===t)return P(void 0),D(!1),void k(e=>({...e,isPostalCodeValid:!1}));if(!/^\d+$/.test(t))return;const a=Number(t);P(a),D(!1),k(e=>({...e,isPostalCodeValid:!1})),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{F(a)},1e3)},onBlur:()=>{R.current&&clearTimeout(R.current),void 0!==T&&F(T)}}),g&&e.createElement("div",{className:"error-message"},x||"Cart items aren't available at your address"),V.isPostalCodeValid&&y&&e.createElement("div",{className:"slot"},e.createElement("label",{className:"slot-label"},"Select Delivery Slot"),e.createElement(r,{themeColor:C,themeTextColor:h,disabledDates:f})),S&&e.createElement("div",{className:"success-message"},N||"Voila! Local delivery is available")))};export{v as default};
1
+ import e,{useState as t,useRef as a,useCallback as l,useEffect as i}from"react";import r from"./DatePicker.js";import"./StandardDelivery.scss.js";import{postalCodeState as s}from"../../atoms/postalCodeAtom.js";import{useAtom as o,useAtomValue as m}from"jotai";import{deliveryOptionChosenState as d,deliveryTypeState as c,isDeliveryOptionValidState as n}from"../../atoms/shippingAtom.js";const v=({title:v="Cart Item(s) available in NCR only",backgroundColor:u="#F6EFDD78",tag:p="NCR",postalCodeList:b=[110001,110002,110003,110004,110005],themeColor:C,themeTextColor:h,enableSlotPicker:y,deliveryHeaderTitle:E,deliveryAvailableText:N,deliveryNotAvailableText:x,disabledDates:f})=>{const[g,D]=t(!1),[T,P]=o(s),[V,k]=o(d),[j,A]=o(c),S=m(n),R=a(null),F=l(e=>{const t=b.includes(e);D(!t),k(e=>({...e,isPostalCodeValid:t}))},[b,k]);return i(()=>{A("specific")},[]),i(()=>{void 0!==T&&F(T)},[T,F]),i(()=>{!1===y&&k(e=>e.isDateValid?e:{...e,isDateValid:!0})},[y,k]),e.createElement("div",null,E&&e.createElement("div",{className:"shipment-header"},e.createElement("h2",{className:"shipment-header-text"},E)),e.createElement("div",{className:"availability-check",style:{border:`2px solid ${C||"black"}`,padding:"12px",borderRadius:"8px",margin:"8px 1rem"}},e.createElement("div",{className:"availability-title"},"Check Shipment Availability"),e.createElement("input",{className:"availability-input",type:"text",placeholder:"Enter Postal Code",value:T||"",onChange:e=>{const t=e.target.value;if(""===t)return P(void 0),D(!1),void k(e=>({...e,isPostalCodeValid:!1}));if(!/^\d+$/.test(t))return;const a=Number(t);P(a),D(!1),k(e=>({...e,isPostalCodeValid:!1})),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{F(a)},1e3)},onBlur:()=>{R.current&&clearTimeout(R.current),void 0!==T&&F(T)}}),g&&e.createElement("div",{className:"error-message"},x||"Cart items aren't available at your address"),V.isPostalCodeValid&&y&&e.createElement("div",{className:"slot"},e.createElement("label",{className:"slot-label"},"Select Delivery Slot"),e.createElement(r,{themeColor:C,themeTextColor:h,disabledDates:f})),S&&e.createElement("div",{className:"success-message"},N||"Voila! Local delivery is available")))};export{v as default};
@@ -1 +1 @@
1
- import e,{useState as t,useRef as a,useCallback as l,useEffect as i}from"react";import{FaCheckCircle as s}from"react-icons/fa";import r from"./DatePicker.js";import{postalCodeState as o}from"../../atoms/postalCodeAtom.js";import{useAtom as c,useAtomValue as n}from"jotai";import{deliveryOptionChosenState as m,deliveryTypeState as d,isDeliveryOptionValidState as p}from"../../atoms/shippingAtom.js";const v=({postalCodeList:v=[110001,110002,110003,110004,110005],themeColor:h,themeTextColor:u,enableSlotPicker:E,disabledDates:N})=>{const[C,b]=t("standard"),[f,k]=t(!1),[y,P]=c(o),[x,g]=c(m),[V,T]=c(d),j=n(p),D=a(null),S=l(e=>{const t=v.includes(e);e?(k(!t),g(e=>({...e,isPostalCodeValid:t}))):g(e=>({...e,isPostalCodeValid:!1}))},[v,g]);return i(()=>{T("delhi-ncr"===C?"specific":"standard"),y&&S(y)},[C]),e.createElement("div",{className:"shipment-container"},e.createElement("div",{className:"shipment-header"},e.createElement("p",{className:"shipment-header-text"},"Cart Item(s) are available for standard shipment")),e.createElement("div",{className:"shipment-option "+("standard"===C?"selected":""),onClick:()=>b("standard")},e.createElement("div",{className:"option-content"},e.createElement("div",{className:"option-text"},e.createElement("div",{className:"option-title"},"Pan India"),e.createElement("div",{className:"option-subtitle"},"7-10 days")),"standard"===C&&e.createElement(s,{className:"checkmark"}))),e.createElement("div",{className:"shipment-option "+("delhi-ncr"===C?"selected":""),onClick:()=>b("delhi-ncr")},e.createElement("div",{className:"option-content"},e.createElement("div",{className:"option-text"},e.createElement("div",{className:"option-title"},"Delhi NCR"),e.createElement("div",{className:"option-subtitle"},"Single day delivery")),"delhi-ncr"===C&&e.createElement(s,{className:"checkmark"})),"delhi-ncr"===C&&e.createElement("div",{className:"availability-check"},e.createElement("div",{className:"availability-title"},"Check Product Availability"),e.createElement("input",{className:"availability-input",type:"text",placeholder:"Enter Postal Code",value:y,onChange:e=>{const t=e.target.value;if(""===t)return P(void 0),k(!1),void g(e=>({...e,isPostalCodeValid:!1}));if(!/^\d+$/.test(t))return;const a=Number(t);P(a),k(!1),g(e=>({...e,isPostalCodeValid:!1})),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{S(a)},1e3)},onBlur:()=>{D.current&&clearTimeout(D.current),S(y)}}),f&&e.createElement("div",{className:"error-message"},"Cart items aren't available on your selected pincode for quick shipment"),x.isPostalCodeValid&&E&&e.createElement("div",{className:"slot"},e.createElement("label",{className:"slot-label"},"Pick a Selivery Slot"),e.createElement(r,{themeColor:h,themeTextColor:u,disabledDates:N})),j&&e.createElement("div",{className:"success-message"},"Voila! Local delivery is available"))))};export{v as default};
1
+ import e,{useState as t,useRef as a,useCallback as l,useEffect as s}from"react";import{FaCheckCircle as i}from"react-icons/fa";import r from"./DatePicker.js";import"./StandardDelivery.scss.js";import{postalCodeState as o}from"../../atoms/postalCodeAtom.js";import{useAtom as c,useAtomValue as n}from"jotai";import{deliveryOptionChosenState as m,deliveryTypeState as d,isDeliveryOptionValidState as p}from"../../atoms/shippingAtom.js";const v=({postalCodeList:v=[110001,110002,110003,110004,110005],themeColor:h,themeTextColor:u,enableSlotPicker:E,disabledDates:N})=>{const[C,b]=t("standard"),[f,k]=t(!1),[y,P]=c(o),[x,g]=c(m),[V,j]=c(d),D=n(p),S=a(null),T=l(e=>{const t=v.includes(e);e?(k(!t),g(e=>({...e,isPostalCodeValid:t}))):g(e=>({...e,isPostalCodeValid:!1}))},[v,g]);return s(()=>{j("delhi-ncr"===C?"specific":"standard"),y&&T(y)},[C]),e.createElement("div",{className:"shipment-container"},e.createElement("div",{className:"shipment-header"},e.createElement("p",{className:"shipment-header-text"},"Cart Item(s) are available for standard shipment")),e.createElement("div",{className:"shipment-option "+("standard"===C?"selected":""),onClick:()=>b("standard")},e.createElement("div",{className:"option-content"},e.createElement("div",{className:"option-text"},e.createElement("div",{className:"option-title"},"Pan India"),e.createElement("div",{className:"option-subtitle"},"7-10 days")),"standard"===C&&e.createElement(i,{className:"checkmark"}))),e.createElement("div",{className:"shipment-option "+("delhi-ncr"===C?"selected":""),onClick:()=>b("delhi-ncr")},e.createElement("div",{className:"option-content"},e.createElement("div",{className:"option-text"},e.createElement("div",{className:"option-title"},"Delhi NCR"),e.createElement("div",{className:"option-subtitle"},"Single day delivery")),"delhi-ncr"===C&&e.createElement(i,{className:"checkmark"})),"delhi-ncr"===C&&e.createElement("div",{className:"availability-check"},e.createElement("div",{className:"availability-title"},"Check Product Availability"),e.createElement("input",{className:"availability-input",type:"text",placeholder:"Enter Postal Code",value:y,onChange:e=>{const t=e.target.value;if(""===t)return P(void 0),k(!1),void g(e=>({...e,isPostalCodeValid:!1}));if(!/^\d+$/.test(t))return;const a=Number(t);P(a),k(!1),g(e=>({...e,isPostalCodeValid:!1})),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{T(a)},1e3)},onBlur:()=>{S.current&&clearTimeout(S.current),T(y)}}),f&&e.createElement("div",{className:"error-message"},"Cart items aren't available on your selected pincode for quick shipment"),x.isPostalCodeValid&&E&&e.createElement("div",{className:"slot"},e.createElement("label",{className:"slot-label"},"Pick a Selivery Slot"),e.createElement(r,{themeColor:h,themeTextColor:u,disabledDates:N})),D&&e.createElement("div",{className:"success-message"},"Voila! Local delivery is available"))))};export{v as default};
@@ -0,0 +1 @@
1
+ import n from"../../node_modules/style-inject/dist/style-inject.es.js";var o=".shipment-container {\n font-family: Arial, sans-serif;\n max-width: 400px;\n padding: 3px;\n padding-bottom: 0;\n background-color: #fff;\n border-radius: 8px;\n margin: 8px 1rem;\n}\n\n.shipment-header {\n background-color: #f6efdd;\n padding: 4px;\n border-radius: 0px;\n margin-bottom: 12px;\n}\n\n.shipment-header-text {\n color: #ae8846;\n font-size: 14px;\n font-weight: 500;\n text-align: center;\n margin: 0;\n line-height: normal;\n}\n\n.shipment-option {\n border: 1px solid #e5e7eb;\n border-radius: 8px;\n padding: 12px;\n margin-bottom: 8px;\n cursor: pointer;\n transition: all 0.3s ease;\n}\n\n.shipment-option:hover {\n background-color: #f9fafb;\n}\n\n.shipment-option.selected {\n border-color: #ae8846;\n border-width: 1 1 0 2 px;\n box-shadow: 0 0 0 1px #ae8846;\n}\n\n.option-content {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.option-title {\n font-size: 12px;\n margin-bottom: 4px;\n font-weight: 600;\n}\n\n.option-subtitle {\n color: #6b7280;\n font-size: 10px;\n}\n\n.checkmark {\n color: #ae8846;\n font-size: 20px;\n font-weight: bold;\n}\n\n.availability-check {\n margin-top: 8px;\n}\n\n.availability-title {\n font-size: 12px;\n color: #374151;\n margin-bottom: 3px;\n font-weight: 600;\n}\n\n.availability-input {\n width: 98%;\n padding: 2px;\n border: none;\n border-bottom: 2px solid #d1d5db;\n border-radius: 0;\n font-size: 12px;\n transition: border-color 0.3s ease;\n background: none;\n outline: none;\n font-weight: 500 !important;\n box-shadow: none;\n text-shadow: none;\n}\n\n.availability-input:focus {\n outline: none;\n border-color: #ae8846;\n border: none;\n border-bottom: 2px solid #000000;\n border-radius: 0;\n font-weight: 500 !important;\n box-shadow: none;\n text-shadow: none;\n}\n\n.availability-input:hover {\n outline: none;\n border-color: #ae8846;\n border: none;\n border-bottom: 2px solid #000000;\n border-radius: 0;\n font-weight: 500 !important;\n}\n\n.error-message {\n background-color: #fee2e2;\n color: #b91c1c;\n padding: 6px;\n border-bottom-left-radius: 6px;\n border-bottom-right-radius: 6px;\n font-size: 13px;\n margin-top: 10px;\n display: flex;\n align-items: center;\n margin-bottom: -12px;\n margin-left: -12px;\n margin-right: -12px;\n line-height: normal;\n justify-content: center;\n text-align: center;\n}\n\n.error-icon {\n margin-right: 8px;\n}\n\n.slot {\n width: 98%;\n margin-top: 4px;\n padding: 4px;\n display: flex;\n justify-content: space-between;\n align-items: left;\n flex-direction: column;\n border-bottom: 2px solid #e5e7eb;\n}\n\n.slot:focus {\n outline: none;\n border-color: #ae8846;\n border: none;\n border-bottom: 2px solid #000000;\n border-radius: 0;\n}\n\n.slot:hover {\n outline: none;\n border-color: #ae8846;\n border: none;\n border-bottom: 2px solid #000000;\n border-radius: 0;\n}\n\n.slot-label {\n font-size: 12px;\n margin-bottom: 4px;\n color: #374151;\n margin-left: -4px;\n font-weight: 600;\n}\n\n.success-message {\n background-color: #dcf6ee;\n color: #307d66;\n padding: 6px;\n border-bottom-left-radius: 6px;\n border-bottom-right-radius: 6px;\n font-size: 13px;\n margin-top: 6px;\n display: flex;\n align-items: center;\n margin-bottom: -12px;\n margin-left: -12px;\n margin-right: -12px;\n line-height: normal;\n justify-content: center;\n}";n(o);export{o as default};
@@ -0,0 +1 @@
1
+ import n from"../../node_modules/style-inject/dist/style-inject.es.js";var t="/* Body when cart drawer is open */\nbody.drawer-open {\n overflow: hidden;\n}\n\n/* Quantity Selector */\n.qty-selector-decrement-button {\n display: flex !important;\n justify-content: center !important;\n align-items: center !important;\n flex-wrap: nowrap !important;\n margin: 0 !important;\n cursor: pointer;\n width: 25px !important;\n height: 22px !important;\n min-height: 22px !important;\n padding: 10px !important;\n border: 0 !important;\n outline: none;\n /* focus:outline-none */\n background-color: #ffffff;\n color: black !important;\n border-radius: 0px !important;\n font-size: 16px !important;\n font-weight: 200 !important;\n min-width: fit-content;\n box-shadow: none;\n}\n\n.qty-selector-decrement-button:hover {\n background-color: #e5e7eb;\n /* hover:bg-gray-200 */\n}\n\n.qty-selector-input {\n background-color: white !important;\n /* bg-white */\n text-align: center;\n /* text-center */\n color: #111827;\n /* text-gray-900 */\n font-size: 1.1rem;\n /* text-sm */\n display: block;\n /* block */\n width: 3.4rem;\n /* w-12 */\n height: 28px;\n border: 0;\n margin: 0;\n}\n\nform .qty-selector-input {\n min-height: 22px !important;\n height: auto !important;\n text-align: center !important;\n line-height: 22px !important;\n box-shadow: none;\n}\n\n@media screen and (max-width: 450px) {\n .qty-selector-decrement-button {\n width: 30px;\n height: 28px;\n padding: 10px;\n }\n .qty-selector-input {\n height: 28px;\n width: 2rem;\n }\n}\n.close-button {\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n transition: transform 0.5s ease-in-out;\n}\n\n.close-button:hover {\n transform: rotate(360deg);\n}\n\n.qty-selector-decrement-button,\n.yt-checkout-button {\n background-image: none !important;\n}\n\nbutton.yt-checkout-button,\nbutton.add-to-cart-button {\n min-height: auto !important;\n line-height: normal !important;\n}\n\n.yt-cart-title-container {\n display: -webkit-flex !important;\n display: -moz-flex !important;\n display: -ms-flexbox !important;\n display: flex !important;\n align-items: center !important;\n gap: 8px !important;\n flex-direction: row !important;\n flex-wrap: nowrap !important;\n}\n\n.yt-cart-details-button {\n margin-left: 5px;\n background: none;\n border: none;\n color: #d3122a;\n cursor: pointer;\n font-size: 12px;\n font-weight: 600;\n text-decoration: underline;\n padding: 0 !important;\n min-height: 10px !important;\n}\n\n.delete-icon,\n.edit-icon {\n height: 24px !important;\n width: 24px !important;\n}\n\n:root {\n --yt-base-color: #ddd;\n --yt-shine-color: #e8e8e8;\n --yt-animation-duration: 1.6s;\n --yt-cart-skeleton-loader-media-offset: 68px;\n /* 52px + 16px */\n}\n\n.yt-cart-skeleton-loader-container {\n display: flex;\n flex-direction: column;\n margin-top: 15px;\n}\n\n.yt-cart-skeleton-loader-item {\n width: 250px;\n height: 80px;\n}\n\n.yt-cart-skeleton-loader-item .yt-cart-skeleton-loader-media {\n float: left;\n width: 52px;\n height: 52px;\n background-color: #ccc;\n border-radius: 25%;\n margin: 8px;\n background-image: linear-gradient(90deg, var(--yt-base-color) 0px, var(--yt-shine-color) 40px, var(--yt-base-color) 80px);\n background-size: 600px;\n animation: shine-yt-cart-skeleton-loader-media var(--yt-animation-duration) infinite linear;\n}\n\n.yt-cart-skeleton-loader-item .yt-cart-skeleton-loader-line {\n float: left;\n width: 180px;\n height: 16px;\n margin-top: 12px;\n border-radius: 7px;\n background-image: linear-gradient(90deg, var(--yt-base-color) 0px, var(--yt-shine-color) 40px, var(--yt-base-color) 80px);\n background-size: 600px;\n animation: shine-lines var(--yt-animation-duration) infinite linear;\n}\n\n.yt-cart-skeleton-loader-item .yt-cart-skeleton-loader-media + .yt-cart-skeleton-loader-line {\n margin-top: 11px;\n width: 140px;\n}\n\n.yt-cart-skeleton-loader-item .yt-cart-skeleton-loader-line ~ .yt-cart-skeleton-loader-line {\n background-color: var(--yt-base-color);\n}\n\n@keyframes shine-lines {\n 0% {\n background-position: -100px;\n }\n 40%, 100% {\n background-position: 140px;\n }\n}\n@keyframes shine-yt-cart-skeleton-loader-media {\n 0% {\n background-position: calc(-100px + var(--yt-cart-skeleton-loader-media-offset));\n }\n 40%, 100% {\n background-position: calc(140px + var(--yt-cart-skeleton-loader-media-offset));\n }\n}\n.yt-loyalty-cta-container {\n box-shadow: 0px 3px 3.8px 0px rgba(1, 1, 1, 0.231372549);\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n padding: 10px;\n border-radius: 10px;\n}\n\n.yt-loyalty-apply-cta-loading-container {\n box-shadow: 0px 3px 3.8px 0px rgba(1, 1, 1, 0.231372549);\n border: 1px solid #e5e7e8;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n padding: 10px;\n border-radius: 10px;\n position: relative;\n overflow: hidden;\n margin: 0 1rem;\n min-height: 54.5px;\n background: #fafafa;\n z-index: 100;\n}\n\n.yt-loyalty-cta-progress-bar-container {\n width: 100%;\n height: 2px;\n background-color: #f0f0f0;\n position: absolute;\n bottom: 0;\n left: 0;\n z-index: 100;\n}\n\n.yt-loyalty-cta-progress-bar {\n height: 100%;\n background-color: red;\n transition: width 2.25s ease-in-out;\n z-index: 100;\n}";n(t);export{t as default};
@@ -1,4 +1,4 @@
1
- import e,{useState as t,useEffect as o}from"react";import n from"styled-components";import i from"react-otp-input";import{IoClose as r}from"react-icons/io5";import{PhoneInput as a}from"react-international-phone";import"react-international-phone/style.css";const l=n.div`
1
+ import e,{useState as t,useEffect as o}from"react";import n from"styled-components";import i from"react-otp-input";import{IoClose as r}from"react-icons/io5";import"./Nudge.scss.js";import{PhoneInput as a}from"react-international-phone";import"react-international-phone/style.css";const l=n.div`
2
2
  position: absolute;
3
3
  top: 10px;
4
4
  right: 10px;
@@ -146,4 +146,4 @@ import e,{useState as t,useEffect as o}from"react";import n from"styled-componen
146
146
  color: ${e=>(e.$clickable,"#000000")};
147
147
  text-decoration: ${e=>e.$clickable?"underline":"none"};
148
148
  cursor: ${e=>e.$clickable?"pointer":"default"};
149
- `,v=({ctaButtonColor:n="black",headerColor:i="black",handleLoginOrSignup:v,handleSubmit:E,title:k="Everything here to give you the Best Value!",subtitle:C="Sign up to avail upto 20% extra discount on all products and unlock exclusive offers",onClose:P,closeIconColor:S="white"})=>{const[$,F]=t(""),[z,I]=t(""),[O,R]=t(""),[T,B]=t(""),[L,j]=t(!1),[A,W]=t(!1),[D,V]=t(!1),[q,N]=t(30),[G,M]=t(!1);o(()=>{let e;return A&&q>0?e=setInterval(()=>{N(e=>e-1)},1e3):0===q&&M(!0),()=>clearInterval(e)},[A,q]),o(()=>{const e=()=>{V(window.innerWidth<540)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const H=async e=>{if(e.preventDefault(),j(!0),B(""),!(e=>{const t=e.replace(/\D/g,"");return t.length>5&&t.length<=15&&/^\+?([0-9]{1,3})?[-. ]?([0-9]{1,4})[-. ]?([0-9]{1,4})[-. ]?([0-9]{1,4})$/.test(e)})($))return B("Please enter a valid phone number with country code"),void j(!1);if(!(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(z))return B("Please enter a valid email address"),void j(!1);try{v&&await v($,z),W(!0),N(30),M(!1)}catch(e){B(e?.message||"An error occurred. Please try again.")}finally{j(!1)}};return e.createElement(e.Fragment,null,e.createElement(d,{onClick:e=>{e.stopPropagation(),P&&P()}},e.createElement(p,{onClick:e=>e.stopPropagation()},e.createElement(l,{onClick:e=>{e.stopPropagation(),P&&P()}},e.createElement(r,{size:D?20:24,color:S})),e.createElement(c,null,e.createElement(s,{$headerColor:i},e.createElement(m,{className:"yt-lead-generation-nudge-title"},k),e.createElement(u,{className:"yt-lead-generation-nudge-subtitle"},C)),e.createElement(h,null,A?e.createElement("form",{onSubmit:async e=>{if(e.preventDefault(),j(!0),B(""),4!==O.length||!/^\d+$/.test(O))return B("Please enter a valid 4-digit OTP"),void j(!1);try{E&&await E($,O)}catch(e){B(e?.message||"Invalid OTP. Please try again.")}finally{j(!1),T||P&&P()}}},e.createElement(y,{value:O,onChange:R,numInputs:4,containerStyle:{display:"flex",justifyContent:"center"},renderSeparator:()=>e.createElement("span",{style:{margin:"0 8px"}}),renderInput:t=>e.createElement("input",{...t,style:{display:"flex",fontFamily:"Poppins !important",alignItems:"center",justifyContent:"center",border:"1px solid",borderColor:"black",width:40,height:40,borderRadius:0,borderTopWidth:0,borderRightWidth:0,borderLeftWidth:0,textAlign:"center",background:"#FFFFFF",boxShadow:"none"}})}),T&&e.createElement(f,null,T),e.createElement(b,{type:"submit",$ctaButtonColor:n,disabled:L},L?"Verifying...":"Verify OTP"),q>0?e.createElement(w,null,"Resend OTP in 00:",q.toString().padStart(2,"0")):e.createElement(w,{$clickable:G,onClick:()=>{G&&H(new Event("submit"))}},"Resend OTP")):e.createElement("form",{onSubmit:H},e.createElement(x,null,e.createElement(a,{defaultCountry:"in",value:$,onChange:e=>F(e),inputProps:{required:!0},inputStyle:{width:"100%",height:"40px",fontFamily:"Poppins !important",borderRadius:"0px",boxShadow:"none !important"},style:{boxShadow:"none !important"},countrySelectorStyleProps:{buttonStyle:{height:"40px",borderRight:"none",background:"white",padding:"0 10px"}}})),e.createElement(g,{type:"email",value:z,onChange:e=>I(e.target.value),placeholder:"Email Address",required:!0}),T&&e.createElement(f,null,T),e.createElement(b,{type:"submit",$ctaButtonColor:n,disabled:L},L?"Loading...":"Submit")))))))};export{v as default};
149
+ `,v=({ctaButtonColor:n="black",headerColor:i="black",handleLoginOrSignup:v,handleSubmit:E,title:k="Everything here to give you the Best Value!",subtitle:C="Sign up to avail upto 20% extra discount on all products and unlock exclusive offers",onClose:P,closeIconColor:S="white"})=>{const[$,F]=t(""),[z,I]=t(""),[O,R]=t(""),[T,j]=t(""),[B,L]=t(!1),[A,W]=t(!1),[D,N]=t(!1),[V,q]=t(30),[G,M]=t(!1);o(()=>{let e;return A&&V>0?e=setInterval(()=>{q(e=>e-1)},1e3):0===V&&M(!0),()=>clearInterval(e)},[A,V]),o(()=>{const e=()=>{N(window.innerWidth<540)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const H=async e=>{if(e.preventDefault(),L(!0),j(""),!(e=>{const t=e.replace(/\D/g,"");return t.length>5&&t.length<=15&&/^\+?([0-9]{1,3})?[-. ]?([0-9]{1,4})[-. ]?([0-9]{1,4})[-. ]?([0-9]{1,4})$/.test(e)})($))return j("Please enter a valid phone number with country code"),void L(!1);if(!(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(z))return j("Please enter a valid email address"),void L(!1);try{v&&await v($,z),W(!0),q(30),M(!1)}catch(e){j(e?.message||"An error occurred. Please try again.")}finally{L(!1)}};return e.createElement(e.Fragment,null,e.createElement(d,{onClick:e=>{e.stopPropagation(),P&&P()}},e.createElement(p,{onClick:e=>e.stopPropagation()},e.createElement(l,{onClick:e=>{e.stopPropagation(),P&&P()}},e.createElement(r,{size:D?20:24,color:S})),e.createElement(c,null,e.createElement(s,{$headerColor:i},e.createElement(m,{className:"yt-lead-generation-nudge-title"},k),e.createElement(u,{className:"yt-lead-generation-nudge-subtitle"},C)),e.createElement(h,null,A?e.createElement("form",{onSubmit:async e=>{if(e.preventDefault(),L(!0),j(""),4!==O.length||!/^\d+$/.test(O))return j("Please enter a valid 4-digit OTP"),void L(!1);try{E&&await E($,O)}catch(e){j(e?.message||"Invalid OTP. Please try again.")}finally{L(!1),T||P&&P()}}},e.createElement(y,{value:O,onChange:R,numInputs:4,containerStyle:{display:"flex",justifyContent:"center"},renderSeparator:()=>e.createElement("span",{style:{margin:"0 8px"}}),renderInput:t=>e.createElement("input",{...t,style:{display:"flex",fontFamily:"Poppins !important",alignItems:"center",justifyContent:"center",border:"1px solid",borderColor:"black",width:40,height:40,borderRadius:0,borderTopWidth:0,borderRightWidth:0,borderLeftWidth:0,textAlign:"center",background:"#FFFFFF",boxShadow:"none"}})}),T&&e.createElement(f,null,T),e.createElement(b,{type:"submit",$ctaButtonColor:n,disabled:B},B?"Verifying...":"Verify OTP"),V>0?e.createElement(w,null,"Resend OTP in 00:",V.toString().padStart(2,"0")):e.createElement(w,{$clickable:G,onClick:()=>{G&&H(new Event("submit"))}},"Resend OTP")):e.createElement("form",{onSubmit:H},e.createElement(x,null,e.createElement(a,{defaultCountry:"in",value:$,onChange:e=>F(e),inputProps:{required:!0},inputStyle:{width:"100%",height:"40px",fontFamily:"Poppins !important",borderRadius:"0px",boxShadow:"none !important"},style:{boxShadow:"none !important"},countrySelectorStyleProps:{buttonStyle:{height:"40px",borderRight:"none",background:"white",padding:"0 10px"}}})),e.createElement(g,{type:"email",value:z,onChange:e=>I(e.target.value),placeholder:"Email Address",required:!0}),T&&e.createElement(f,null,T),e.createElement(b,{type:"submit",$ctaButtonColor:n,disabled:B},B?"Loading...":"Submit")))))))};export{v as default};
@@ -0,0 +1 @@
1
+ import t from"../../node_modules/style-inject/dist/style-inject.es.js";var s='@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Space+Grotesk:wght@300..700&display=swap");';t(s);export{s as default};
@@ -0,0 +1 @@
1
+ function e(e,t){void 0===t&&(t={});var d=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===d&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}export{e as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yt-uikit",
3
- "version": "0.8.34",
3
+ "version": "0.8.35",
4
4
  "description": "YourToken UI Kit",
5
5
  "scripts": {
6
6
  "rollup": "rm -rf dist && tsc && rollup -c",
@@ -91,5 +91,8 @@
91
91
  "dist"
92
92
  ],
93
93
  "types": "dist/esm/index.d.ts",
94
- "sideEffects": false
94
+ "sideEffects": [
95
+ "**/*.css",
96
+ "**/*.scss"
97
+ ]
95
98
  }