@kachingappz/bundles-js 1.1.4 → 1.1.6

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.
@@ -234,5 +234,5 @@ var BundlesJs=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
234
234
  }
235
235
  }
236
236
  }
237
- `,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},T=e=>[...E(e),...D(e),...O(e),...k(e),...A(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),E=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),D=e=>e.dealBars.flatMap(e=>e.dealBarType===f.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),O=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),k=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),A=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),ee=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],te=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},ne=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],re=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ie=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),ae=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},oe=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),se=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],ce=e=>{let t=[...j(e),...M(e),...N(e),...P(e),...F(e),...I(e),...L(e),...R(e)];return Array.from(new Set(t.filter(e=>e!=null)))},j=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),M=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),N=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],P=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),F=e=>e.dealBars.filter(e=>e.dealBarType===f.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),I=e=>e.dealBars.filter(e=>e.dealBarType===f.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...e.selectedProducts?.map(e=>e.id)??[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),L=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),R=e=>e.dealBars.filter(e=>e.dealBarType===f.Sku).flatMap(({productGID:e})=>e?[e]:[]),z=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},B=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new z({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new z({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},V=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),B(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},H=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},U=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await p(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await p(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await h(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0});return o=o.filter(e=>e.availableForSale),o},W=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`},r=e?le(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},le=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=G(e);return n.find(e=>G(e.locale)===r)?.translations},G=e=>e.toLowerCase().replace(/_/g,`-`),ue=`2026-07`,K=async(e,{productId:t,dealBlockId:n,country:r=void 0,language:i=void 0})=>{try{let a=[Number(t.split(`/`).pop())],o=new de(e);r||=o.i18n?.country,i||=o.i18n?.language;let s=await S(o,{language:i,country:r,useExternalMetafieldNamespace:!0});o.shopifyDomain=s.shopifyDomain;let c=s.storefrontAccessToken?new V(s.shopifyDomain,s.storefrontAccessToken):o,[u,d]=await Promise.all([h(c,{country:r,language:i,productIds:a,useExternalMetafieldNamespace:!0}),l(c,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),f=u[0];if(!f)return null;let p=H(d,f),m;if(n?(m=p.find(e=>e.id===n||e.nanoId===n),m||=p[0]):m=p[0],!m)return null;let g=T(m),_=ce(m),[v,y,b,x]=await Promise.all([h(c,{country:r,language:i,productIds:_,useExternalMetafieldNamespace:!0}),w(c,g,300),U(c,m,{country:r,language:i}),W({language:i,dealBlockId:m.id})]);return{product:f,dealBlock:m,config:s,otherProducts:v,mediaImages:y,collectionBreaksProducts:b??[],translations:x}}catch(e){return console.error(e),null}},de=class{constructor(e){this.storefront=e,this.shopifyDomain=``}async query(e,t){if(`query`in this.storefront&&`i18n`in this.storefront)return await this.storefront.query(e,t);if(`graphql`in this.storefront){let n=await this.storefront.graphql(e,t);if(n.errors?.length)throw Error(n.errors.map(e=>e.message).join(`
238
- `));return n.data}if(`request`in this.storefront)return(await this.storefront.request(e,t)).data;if(`shopifyDomain`in this.storefront&&`storefrontAccessToken`in this.storefront){let n=await fetch(`https://${this.storefront.shopifyDomain}/api/${ue}/graphql.json`,{body:JSON.stringify({query:e,variables:t?.variables}),headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}{let n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:e,variables:t?.variables}),headers:this.storefront.getPublicTokenHeaders(),method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}}get i18n(){if(`i18n`in this.storefront)return this.storefront.i18n}},q=`kaching-bundles-block`,J=1e4,fe=`https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js`,pe=`https://bundles-integrations.kachingappz.app/kaching-bundles-block.js`,Y=new WeakSet,X=async e=>{let t=e.document;if(!e.customElements.get(q)){if(Y.has(t))return Z(e,q);Y.add(t);try{await ge(e)}catch(e){throw Y.delete(t),e}}},me=()=>typeof window<`u`&&window.__KACHING_DEV__!==void 0,he=()=>me()?fe:pe,ge=e=>{let t=e.document;return new Promise((n,r)=>{let i=he();if(t.querySelector(`script[src="${i}"]`)){Z(e,q).then(n).catch(r);return}let a=t.createElement(`script`);a.src=i,a.onload=()=>Z(e,q).then(n).catch(r),a.onerror=()=>r(Error(`Failed to load script`)),t.head.appendChild(a)})},Z=(e,t)=>new Promise((n,r)=>{e.customElements.get(t)?n():Promise.race([e.customElements.whenDefined(t),new Promise((e,n)=>setTimeout(()=>n(Error(`Custom element "${t}" failed to register within ${J}ms`)),J))]).then(()=>n()).catch(r)});[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var Q=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),$={config:{shopifyDomain:``,moneyFormat:"${{amount}}",locale:`en`,country:`US`,currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:``},dealBlock:{id:`example`,nanoId:`example`,blockName:`Bundle`,discountName:``,blockTitle:`BUNDLE & SAVE`,blockLayout:`vertical`,blockVisibility:`all-products`,marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:``,useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:`.00`,updateNativePrice:!1,updateNativePriceType:`item`,skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:`duo`,cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:`14`,style:`bold`},title:{size:`20`,style:`bold`},subtitle:{size:`14`,style:`regular`},label:{size:`12`,style:`bold`},freeGift:{size:`13`,style:`bold`},upsell:{size:`13`,style:`bold`},unitLabel:{size:`14`,style:`regular`}},dealBars:[{id:`single`,dealBarType:Q.QuantityBreak,quantitySelector:!1,title:`Single`,subtitle:`Standard price`,label:``,quantity:1,discountType:`default`,discountValue:``,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`duo`,dealBarType:Q.QuantityBreak,quantitySelector:!1,title:`Duo`,subtitle:`You save 20%`,label:`SAVE $32`,quantity:2,discountType:`percentage`,discountValue:`20`,badgeStyle:`most-popular`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`trio`,dealBarType:Q.QuantityBreak,quantitySelector:!1,title:`Trio`,subtitle:`You save 25%`,label:`SAVE $60`,quantity:3,discountType:`percentage`,discountValue:`25`,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`}],badgesEnabled:!0,badges:[{id:`bdg1`,attachedTo:{type:`dealBar`,dealBarId:`duo`},text:`MOST POPULAR`,colors:null,badgeType:`most-popular`,size:90}],swatchOptions:[],swatchSize:18,swatchShape:`circle`,imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:``,customStyles:``,lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:`example-product`,url:null,availableForSale:!0,title:`Example product`,image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:[`Default Title`],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},_e=class extends HTMLElement{constructor(...e){super(...e),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return[`selected-variant-id`,`product-id`,`country`,`language`]}async connectedCallback(){await this.initialize()}async initialize(){let e=++this.initializeId;if(this.cleanup(),this.hasAttribute(`demo`)){if(await X(window),e!==this.initializeId)return;this.renderInnerElement($);return}let t=this.getAttribute(`shop-domain`),n=this.getAttribute(`storefront-token`),r=this.getAttribute(`product-id`);if(!t||!n||!r)return;let[i]=await Promise.all([K({shopifyDomain:t,storefrontAccessToken:n},{productId:r,dealBlockId:this.getAttribute(`deal-block-id`)??void 0,country:this.getAttribute(`country`)?.toUpperCase()??void 0,language:this.getAttribute(`language`)?.toUpperCase()??void 0}),X(window)]);i&&e===this.initializeId&&this.renderInnerElement(i)}renderInnerElement(e){let{config:t,dealBlock:n,product:r,otherProducts:i,mediaImages:a,collectionBreaksProducts:o,translations:s}=e;this.innerElement=document.createElement(`kaching-bundles-block`),this.innerElement.setAttribute(`deal-block-id`,n.id),this.innerElement.setAttribute(`config`,JSON.stringify(t)),this.innerElement.setAttribute(`deal-block`,JSON.stringify(n)),this.innerElement.setAttribute(`media-images`,JSON.stringify(a??[])),this.innerElement.setAttribute(`product`,JSON.stringify(r)),this.innerElement.setAttribute(`other-products`,JSON.stringify(i??[])),this.innerElement.setAttribute(`collection-breaks-products`,JSON.stringify(o??[])),this.innerElement.setAttribute(`translations`,JSON.stringify(s??{}));let c=this.getAttribute(`selected-variant-id`);this.innerElement.setAttribute(`current-variant-id`,String(c?c.split(`/`).pop():r.variants[0].id)),this.hasAttribute(`compact`)&&this.innerElement.setAttribute(`compact`,``);let l=this.innerElement,u=()=>{if(this.innerElement!==l)return;let e=l.items();e&&this.dispatchEvent(new CustomEvent(`items-changed`,{detail:{items:e},bubbles:!0}))};this.handleItemsChanged=e=>{e.stopPropagation(),u()};let d=this.handleItemsChanged;l.addEventListener(`kaching-bundles-block-loaded`,()=>{this.innerElement===l&&(l.addEventListener(`items-changed`,d),this.dispatchEvent(new CustomEvent(`loaded`,{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener(`items-changed`,this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&=(this.innerElement.remove(),null)}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`product-id`||e===`country`||e===`language`?this.initialize():e===`selected-variant-id`&&this.innerElement&&n&&this.innerElement.setAttribute(`current-variant-id`,n.includes(`/`)?String(n.split(`/`).pop()):n))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}};return customElements.define(`kaching-bundle-component`,_e),e.fetchKachingBundlesData=K,e})({});
237
+ `,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},T=e=>[...E(e),...D(e),...O(e),...k(e),...A(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),E=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),D=e=>e.dealBars.flatMap(e=>e.dealBarType===f.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),O=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),k=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),A=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),ee=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],te=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},ne=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],re=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ie=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),ae=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},oe=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),se=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],ce=e=>{let t=[...le(e),...ue(e),...de(e),...j(e),...M(e),...N(e),...P(e),...F(e)];return Array.from(new Set(t.filter(e=>e!=null)))},le=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),ue=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),de=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],j=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),M=e=>e.dealBars.filter(e=>e.dealBarType===f.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),N=e=>e.dealBars.filter(e=>e.dealBarType===f.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...e.selectedProducts?.map(e=>e.id)??[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),P=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),F=e=>e.dealBars.filter(e=>e.dealBarType===f.Sku).flatMap(({productGID:e})=>e?[e]:[]),I=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},L=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new I({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new I({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},R=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),L(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},z=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},B=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await p(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await p(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await h(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0});return o=o.filter(e=>e.availableForSale),o},V=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`,"system.gifts_required_alert":`Please choose your free gifts`},r=e?H(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},H=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=U(e);return n.find(e=>U(e.locale)===r)?.translations},U=e=>e.toLowerCase().replace(/_/g,`-`),fe=`2026-07`,W=async(e,{productId:t,dealBlockId:n,country:r=void 0,language:i=void 0})=>{try{let a=[Number(t.split(`/`).pop())],o=new pe(e);r||=o.i18n?.country,i||=o.i18n?.language;let s=await S(o,{language:i,country:r,useExternalMetafieldNamespace:!0});o.shopifyDomain=s.shopifyDomain;let c=s.storefrontAccessToken?new R(s.shopifyDomain,s.storefrontAccessToken):o,[u,d]=await Promise.all([h(c,{country:r,language:i,productIds:a,useExternalMetafieldNamespace:!0}),l(c,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),f=u[0];if(!f)return null;let p=z(d,f),m;if(n?(m=p.find(e=>e.id===n||e.nanoId===n),m||=p[0]):m=p[0],!m)return null;let g=T(m),_=ce(m),[v,y,b,x]=await Promise.all([h(c,{country:r,language:i,productIds:_,useExternalMetafieldNamespace:!0}),w(c,g,300),B(c,m,{country:r,language:i}),V({language:i,dealBlockId:m.id})]);return{product:f,dealBlock:m,config:s,otherProducts:v,mediaImages:y,collectionBreaksProducts:b??[],translations:x}}catch(e){return console.error(e),null}},pe=class{constructor(e){this.storefront=e,this.shopifyDomain=``}async query(e,t){if(`query`in this.storefront&&`i18n`in this.storefront)return await this.storefront.query(e,t);if(`graphql`in this.storefront){let n=await this.storefront.graphql(e,t);if(n.errors?.length)throw Error(n.errors.map(e=>e.message).join(`
238
+ `));return n.data}if(`request`in this.storefront)return(await this.storefront.request(e,t)).data;if(`shopifyDomain`in this.storefront&&`storefrontAccessToken`in this.storefront){let n=await fetch(`https://${this.storefront.shopifyDomain}/api/${fe}/graphql.json`,{body:JSON.stringify({query:e,variables:t?.variables}),headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}{let n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:e,variables:t?.variables}),headers:this.storefront.getPublicTokenHeaders(),method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}}get i18n(){if(`i18n`in this.storefront)return this.storefront.i18n}},G=`kaching-bundles-block`,K=1e4,q=`/kaching-bundles-block.js`,me=`https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js`,he=`https://bundles-integrations.kachingappz.app/kaching-bundles-block.js`,J=new WeakSet,Y=async e=>{let t=e.document;if(!e.customElements.get(G)){if(J.has(t))return Q(e,G);J.add(t);try{await _e(e)}catch(e){throw J.delete(t),e}}},ge=()=>typeof window<`u`&&window.__KACHING_DEV__!==void 0,X=()=>ge()?me:he,_e=async e=>{let t=e.document,n=X();if(t.querySelector(`script[src="${n}"]`))return Q(e,G);let r=ve(t);if(r&&await be(t,r))return Q(e,G);let i=t.createElement(`script`);return i.src=n,await Z(t,i),Q(e,G)},ve=e=>{let t=e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);return Array.from(t,e=>e.href).find(ye)},ye=e=>{try{return new URL(e).pathname.endsWith(q)}catch{return!1}},be=async(e,t)=>{let n=e.createElement(`script`);n.type=`module`,n.setAttribute(`crossorigin`,`anonymous`),n.src=t;try{return await Z(e,n),!0}catch{return n.remove(),!1}},Z=(e,t)=>new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(Error(`Failed to load script`)),e.head.appendChild(t)}),Q=(e,t)=>new Promise((n,r)=>{e.customElements.get(t)?n():Promise.race([e.customElements.whenDefined(t),new Promise((e,n)=>setTimeout(()=>n(Error(`Custom element "${t}" failed to register within ${K}ms`)),K))]).then(()=>n()).catch(r)});[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var $=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),xe={config:{shopifyDomain:``,moneyFormat:"${{amount}}",locale:`en`,country:`US`,currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:``},dealBlock:{id:`example`,nanoId:`example`,blockName:`Bundle`,discountName:``,blockTitle:`BUNDLE & SAVE`,blockLayout:`vertical`,blockVisibility:`all-products`,marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:``,useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:`.00`,updateNativePrice:!1,updateNativePriceType:`item`,skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:`duo`,cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:`14`,style:`bold`},title:{size:`20`,style:`bold`},subtitle:{size:`14`,style:`regular`},label:{size:`12`,style:`bold`},freeGift:{size:`13`,style:`bold`},upsell:{size:`13`,style:`bold`},unitLabel:{size:`14`,style:`regular`}},dealBars:[{id:`single`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Single`,subtitle:`Standard price`,label:``,quantity:1,discountType:`default`,discountValue:``,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`duo`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Duo`,subtitle:`You save 20%`,label:`SAVE $32`,quantity:2,discountType:`percentage`,discountValue:`20`,badgeStyle:`most-popular`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`},{id:`trio`,dealBarType:$.QuantityBreak,quantitySelector:!1,title:`Trio`,subtitle:`You save 25%`,label:`SAVE $60`,quantity:3,discountType:`percentage`,discountValue:`25`,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null,subscriptionMode:`customer-choice`}],badgesEnabled:!0,badges:[{id:`bdg1`,attachedTo:{type:`dealBar`,dealBarId:`duo`},text:`MOST POPULAR`,colors:null,badgeType:`most-popular`,size:90}],swatchOptions:[],swatchSize:18,swatchShape:`circle`,imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:``,customStyles:``,lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:`example-product`,url:null,availableForSale:!0,title:`Example product`,image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:[`Default Title`],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},Se=class extends HTMLElement{constructor(...e){super(...e),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return[`selected-variant-id`,`product-id`,`country`,`language`]}async connectedCallback(){await this.initialize()}async initialize(){let e=++this.initializeId;if(this.cleanup(),this.hasAttribute(`demo`)){if(await Y(window),e!==this.initializeId)return;this.renderInnerElement(xe);return}let t=this.getAttribute(`shop-domain`),n=this.getAttribute(`storefront-token`),r=this.getAttribute(`product-id`);if(!t||!n||!r)return;let[i]=await Promise.all([W({shopifyDomain:t,storefrontAccessToken:n},{productId:r,dealBlockId:this.getAttribute(`deal-block-id`)??void 0,country:this.getAttribute(`country`)?.toUpperCase()??void 0,language:this.getAttribute(`language`)?.toUpperCase()??void 0}),Y(window)]);i&&e===this.initializeId&&this.renderInnerElement(i)}renderInnerElement(e){let{config:t,dealBlock:n,product:r,otherProducts:i,mediaImages:a,collectionBreaksProducts:o,translations:s}=e;this.innerElement=document.createElement(`kaching-bundles-block`),this.innerElement.setAttribute(`deal-block-id`,n.id),this.innerElement.setAttribute(`config`,JSON.stringify(t)),this.innerElement.setAttribute(`deal-block`,JSON.stringify(n)),this.innerElement.setAttribute(`media-images`,JSON.stringify(a??[])),this.innerElement.setAttribute(`product`,JSON.stringify(r)),this.innerElement.setAttribute(`other-products`,JSON.stringify(i??[])),this.innerElement.setAttribute(`collection-breaks-products`,JSON.stringify(o??[])),this.innerElement.setAttribute(`translations`,JSON.stringify(s??{}));let c=this.getAttribute(`selected-variant-id`);this.innerElement.setAttribute(`current-variant-id`,String(c?c.split(`/`).pop():r.variants[0].id)),this.hasAttribute(`compact`)&&this.innerElement.setAttribute(`compact`,``);let l=this.innerElement,u=()=>{if(this.innerElement!==l)return;let e=l.items();e&&this.dispatchEvent(new CustomEvent(`items-changed`,{detail:{items:e},bubbles:!0}))};this.handleItemsChanged=e=>{e.stopPropagation(),u()};let d=this.handleItemsChanged;l.addEventListener(`kaching-bundles-block-loaded`,()=>{this.innerElement===l&&(l.addEventListener(`items-changed`,d),this.dispatchEvent(new CustomEvent(`loaded`,{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener(`items-changed`,this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&=(this.innerElement.remove(),null)}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`product-id`||e===`country`||e===`language`?this.initialize():e===`selected-variant-id`&&this.innerElement&&n&&this.innerElement.setAttribute(`current-variant-id`,n.includes(`/`)?String(n.split(`/`).pop()):n))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}};return customElements.define(`kaching-bundle-component`,Se),e.fetchKachingBundlesData=W,e})({});
package/dist/index.d.ts CHANGED
@@ -504,6 +504,7 @@ declare interface GlobalConfig {
504
504
  "system.select_variant_alert"?: string;
505
505
  "system.select_variant_placeholder"?: string;
506
506
  "system.personalisation_required_alert"?: string;
507
+ "system.gifts_required_alert"?: string;
507
508
  "system.deal_page_adding_to_cart"?: string;
508
509
  "system.deal_page_add_to_cart_failed"?: string;
509
510
  "system.deal_page_total"?: string;
@@ -529,7 +530,6 @@ declare interface GlobalConfig {
529
530
  "system.deal_page_full_price_for_now"?: string;
530
531
  "system.deal_page_percentage_unlocked"?: string;
531
532
  "system.deal_page_box_of"?: string;
532
- "system.deal_page_track_box_full"?: string;
533
533
  "system.deal_page_nudge_start_percentage_one"?: string;
534
534
  "system.deal_page_nudge_start_percentage_other"?: string;
535
535
  "system.deal_page_nudge_start_percentage_few"?: string;
@@ -604,7 +604,6 @@ declare interface GlobalConfig {
604
604
  "system.deal_page_your_gifts_row_other"?: string;
605
605
  "system.deal_page_your_gifts_row_few"?: string;
606
606
  "system.deal_page_your_gifts_row_many"?: string;
607
- "system.deal_page_free"?: string;
608
607
  "system.deal_page_gift_count_one"?: string;
609
608
  "system.deal_page_gift_count_other"?: string;
610
609
  "system.deal_page_gift_count_few"?: string;
@@ -637,6 +636,7 @@ declare interface GlobalConfig {
637
636
  label?: string | null;
638
637
  };
639
638
  featureFlags: {
639
+ analytics_tracking_disabled?: boolean;
640
640
  atc_total_price?: boolean;
641
641
  cart_change_response_rewrite?: boolean;
642
642
  cart_interceptor_dedupe_disabled?: boolean;
@@ -783,8 +783,10 @@ declare type MultipleGiftsSelector = {
783
783
  maxQuantity: number;
784
784
  showPrice: boolean;
785
785
  showProductPhotos?: boolean;
786
+ preselected?: boolean;
786
787
  includeInCompareAt?: boolean;
787
788
  applyOnlyForSubscriptions: boolean;
789
+ required?: boolean;
788
790
  };
789
791
 
790
792
  declare type PriceRoundingPrecision = ".99" | ".95" | ".90" | ".x9" | ".x0" | ".00";
package/dist/index.js CHANGED
@@ -633,7 +633,8 @@ var d = /* @__PURE__ */ function(e) {
633
633
  "system.price": "Price:",
634
634
  "system.letters_only": "Only letters are allowed.",
635
635
  "system.numbers_only": "Only numbers are allowed.",
636
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
636
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
637
+ "system.gifts_required_alert": "Please choose your free gifts"
637
638
  }, r = e ? Q(e) : void 0;
638
639
  return {
639
640
  ...n,
@@ -504,6 +504,7 @@ declare interface GlobalConfig {
504
504
  "system.select_variant_alert"?: string;
505
505
  "system.select_variant_placeholder"?: string;
506
506
  "system.personalisation_required_alert"?: string;
507
+ "system.gifts_required_alert"?: string;
507
508
  "system.deal_page_adding_to_cart"?: string;
508
509
  "system.deal_page_add_to_cart_failed"?: string;
509
510
  "system.deal_page_total"?: string;
@@ -529,7 +530,6 @@ declare interface GlobalConfig {
529
530
  "system.deal_page_full_price_for_now"?: string;
530
531
  "system.deal_page_percentage_unlocked"?: string;
531
532
  "system.deal_page_box_of"?: string;
532
- "system.deal_page_track_box_full"?: string;
533
533
  "system.deal_page_nudge_start_percentage_one"?: string;
534
534
  "system.deal_page_nudge_start_percentage_other"?: string;
535
535
  "system.deal_page_nudge_start_percentage_few"?: string;
@@ -604,7 +604,6 @@ declare interface GlobalConfig {
604
604
  "system.deal_page_your_gifts_row_other"?: string;
605
605
  "system.deal_page_your_gifts_row_few"?: string;
606
606
  "system.deal_page_your_gifts_row_many"?: string;
607
- "system.deal_page_free"?: string;
608
607
  "system.deal_page_gift_count_one"?: string;
609
608
  "system.deal_page_gift_count_other"?: string;
610
609
  "system.deal_page_gift_count_few"?: string;
@@ -637,6 +636,7 @@ declare interface GlobalConfig {
637
636
  label?: string | null;
638
637
  };
639
638
  featureFlags: {
639
+ analytics_tracking_disabled?: boolean;
640
640
  atc_total_price?: boolean;
641
641
  cart_change_response_rewrite?: boolean;
642
642
  cart_interceptor_dedupe_disabled?: boolean;
@@ -783,8 +783,10 @@ declare type MultipleGiftsSelector = {
783
783
  maxQuantity: number;
784
784
  showPrice: boolean;
785
785
  showProductPhotos?: boolean;
786
+ preselected?: boolean;
786
787
  includeInCompareAt?: boolean;
787
788
  applyOnlyForSubscriptions: boolean;
789
+ required?: boolean;
788
790
  };
789
791
 
790
792
  declare type PriceRoundingPrecision = ".99" | ".95" | ".90" | ".x9" | ".x0" | ".00";
@@ -496,71 +496,71 @@ var d = /* @__PURE__ */ function(e) {
496
496
  ...D(e),
497
497
  ...O(e),
498
498
  ...k(e),
499
+ ...A(e),
500
+ ...j(e),
499
501
  ...ee(e),
500
502
  ...te(e),
501
503
  ...ne(e),
502
504
  ...re(e),
503
- ...A(e),
504
- ...j(e),
505
- ...M(e),
506
- ...ie(e)
507
- ].filter((e) => e != null && !e.includes("placeholder")), T = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), E = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), D = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), O = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), k = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ee = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
505
+ ...ie(e),
506
+ ...ae(e)
507
+ ].filter((e) => e != null && !e.includes("placeholder")), T = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), E = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), D = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), O = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), k = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), A = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
508
508
  let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
509
509
  return [...e, ...n];
510
- }, []) : [], te = (e) => {
510
+ }, []) : [], j = (e) => {
511
511
  if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
512
512
  let t = e.collectionBreaks.mediaImageGID;
513
513
  return t ? [t] : [];
514
- }, ne = (e) => e.progressiveGifts ? [
514
+ }, ee = (e) => e.progressiveGifts ? [
515
515
  ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
516
516
  e.progressiveGifts.style?.lockedMediaImageGID,
517
517
  e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
518
- ].filter((e) => e != null) : [], re = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), A = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), j = (e) => {
518
+ ].filter((e) => e != null) : [], te = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ne = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), re = (e) => {
519
519
  let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
520
520
  return n ? [...t, n] : t;
521
- }, M = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ie = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ae = (e) => {
521
+ }, ie = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ae = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], oe = (e) => {
522
522
  let t = [
523
- ...oe(e),
524
523
  ...se(e),
524
+ ...ce(e),
525
+ ...le(e),
526
+ ...ue(e),
527
+ ...M(e),
525
528
  ...N(e),
526
529
  ...P(e),
527
- ...F(e),
528
- ...I(e),
529
- ...L(e),
530
- ...R(e)
530
+ ...F(e)
531
531
  ];
532
532
  return Array.from(new Set(t.filter((e) => e != null)));
533
- }, oe = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), se = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), N = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], P = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), F = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), I = (e) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), L = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), R = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), z = class extends Error {
533
+ }, se = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), ce = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), le = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], ue = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), M = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), N = (e) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), P = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), F = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), I = class extends Error {
534
534
  constructor({ status: e, operationName: t, graphqlErrors: n }) {
535
535
  let r = n.length ? `: ${n.join("; ")}` : "";
536
536
  super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
537
537
  }
538
- }, B = async (e, t) => {
538
+ }, L = async (e, t) => {
539
539
  let n = await e.text();
540
540
  if (!n) throw Error("Empty graphql response");
541
541
  let r;
542
542
  try {
543
543
  r = JSON.parse(n);
544
544
  } catch (n) {
545
- throw e.ok ? n : new z({
545
+ throw e.ok ? n : new I({
546
546
  status: e.status,
547
547
  operationName: t,
548
548
  graphqlErrors: []
549
549
  });
550
550
  }
551
- if (!e.ok || r.data === null || r.data === void 0) throw new z({
551
+ if (!e.ok || r.data === null || r.data === void 0) throw new I({
552
552
  status: e.status,
553
553
  operationName: t,
554
554
  graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
555
555
  });
556
556
  return r.data;
557
- }, V = class {
557
+ }, R = class {
558
558
  constructor(e, t) {
559
559
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
560
560
  }
561
561
  async query(e, t) {
562
562
  let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
563
- return i && (r += `?operation_name=${i}`), B(await fetch(r, {
563
+ return i && (r += `?operation_name=${i}`), L(await fetch(r, {
564
564
  method: "POST",
565
565
  headers: {
566
566
  "Content-Type": "application/json",
@@ -572,7 +572,7 @@ var d = /* @__PURE__ */ function(e) {
572
572
  })
573
573
  }), i);
574
574
  }
575
- }, H = (e, t) => {
575
+ }, z = (e, t) => {
576
576
  let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
577
577
  for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
578
578
  let i = e.filter((e) => e.blockVisibility === "selected-collections");
@@ -582,7 +582,7 @@ var d = /* @__PURE__ */ function(e) {
582
582
  let o = e.filter((e) => e.blockVisibility === "all-products");
583
583
  for (let e of o) n.push(e);
584
584
  return n;
585
- }, U = async (e, t, { country: n, language: r }) => {
585
+ }, B = async (e, t, { country: n, language: r }) => {
586
586
  let i = t.collectionBreaks;
587
587
  if (!t.collectionBreaksEnabled || !i) return;
588
588
  let a;
@@ -608,7 +608,7 @@ var d = /* @__PURE__ */ function(e) {
608
608
  useExternalMetafieldNamespace: !0
609
609
  });
610
610
  return o = o.filter((e) => e.availableForSale), o;
611
- }, W = ({ language: e, dealBlockId: t }) => {
611
+ }, V = ({ language: e, dealBlockId: t }) => {
612
612
  let n = {
613
613
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
614
614
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -633,14 +633,15 @@ var d = /* @__PURE__ */ function(e) {
633
633
  "system.price": "Price:",
634
634
  "system.letters_only": "Only letters are allowed.",
635
635
  "system.numbers_only": "Only numbers are allowed.",
636
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
637
- }, r = e ? G(e) : void 0;
636
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
637
+ "system.gifts_required_alert": "Please choose your free gifts"
638
+ }, r = e ? H(e) : void 0;
638
639
  return {
639
640
  ...n,
640
641
  ...r?.system,
641
642
  ...r?.dealBlocks[t]
642
643
  };
643
- }, G = (e) => {
644
+ }, H = (e) => {
644
645
  if (typeof document > "u") return;
645
646
  let t = document.querySelector("script#kaching-bundles-translations");
646
647
  if (!t?.textContent) return;
@@ -650,11 +651,11 @@ var d = /* @__PURE__ */ function(e) {
650
651
  } catch {
651
652
  return;
652
653
  }
653
- let r = K(e);
654
- return n.find((e) => K(e.locale) === r)?.translations;
655
- }, K = (e) => e.toLowerCase().replace(/_/g, "-"), ce = "2026-07", q = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
654
+ let r = U(e);
655
+ return n.find((e) => U(e.locale) === r)?.translations;
656
+ }, U = (e) => e.toLowerCase().replace(/_/g, "-"), de = "2026-07", W = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
656
657
  try {
657
- let a = [Number(t.split("/").pop())], o = new le(e);
658
+ let a = [Number(t.split("/").pop())], o = new fe(e);
658
659
  r ||= o.i18n?.country, i ||= o.i18n?.language;
659
660
  let s = await x(o, {
660
661
  language: i,
@@ -662,7 +663,7 @@ var d = /* @__PURE__ */ function(e) {
662
663
  useExternalMetafieldNamespace: !0
663
664
  });
664
665
  o.shopifyDomain = s.shopifyDomain;
665
- let l = s.storefrontAccessToken ? new V(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
666
+ let l = s.storefrontAccessToken ? new R(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
666
667
  country: r,
667
668
  language: i,
668
669
  productIds: a,
@@ -672,9 +673,9 @@ var d = /* @__PURE__ */ function(e) {
672
673
  useMetaobjects: s.featureFlags.storefront_metaobjects
673
674
  })]), f = u[0];
674
675
  if (!f) return null;
675
- let p = H(d, f), h;
676
+ let p = z(d, f), h;
676
677
  if (n ? (h = p.find((e) => e.id === n || e.nanoId === n), h ||= p[0]) : h = p[0], !h) return null;
677
- let g = w(h), _ = ae(h), [v, y, b, S] = await Promise.all([
678
+ let g = w(h), _ = oe(h), [v, y, b, S] = await Promise.all([
678
679
  m(l, {
679
680
  country: r,
680
681
  language: i,
@@ -682,11 +683,11 @@ var d = /* @__PURE__ */ function(e) {
682
683
  useExternalMetafieldNamespace: !0
683
684
  }),
684
685
  C(l, g, 300),
685
- U(l, h, {
686
+ B(l, h, {
686
687
  country: r,
687
688
  language: i
688
689
  }),
689
- W({
690
+ V({
690
691
  language: i,
691
692
  dealBlockId: h.id
692
693
  })
@@ -703,7 +704,7 @@ var d = /* @__PURE__ */ function(e) {
703
704
  } catch (e) {
704
705
  return console.error(e), null;
705
706
  }
706
- }, le = class {
707
+ }, fe = class {
707
708
  constructor(e) {
708
709
  this.storefront = e, this.shopifyDomain = "";
709
710
  }
@@ -716,7 +717,7 @@ var d = /* @__PURE__ */ function(e) {
716
717
  }
717
718
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
718
719
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
719
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ce}/graphql.json`, {
720
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${de}/graphql.json`, {
720
721
  body: JSON.stringify({
721
722
  query: e,
722
723
  variables: t?.variables
@@ -746,30 +747,45 @@ var d = /* @__PURE__ */ function(e) {
746
747
  get i18n() {
747
748
  if ("i18n" in this.storefront) return this.storefront.i18n;
748
749
  }
749
- }, J = "kaching-bundles-block", Y = 1e4, ue = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", de = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", X = /* @__PURE__ */ new WeakSet(), Z = async (e) => {
750
+ }, G = "kaching-bundles-block", K = 1e4, q = "/kaching-bundles-block.js", pe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", me = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", J = /* @__PURE__ */ new WeakSet(), Y = async (e) => {
750
751
  let t = e.document;
751
- if (!e.customElements.get(J)) {
752
- if (X.has(t)) return Q(e, J);
753
- X.add(t);
752
+ if (!e.customElements.get(G)) {
753
+ if (J.has(t)) return Q(e, G);
754
+ J.add(t);
754
755
  try {
755
- await me(e);
756
+ await _e(e);
756
757
  } catch (e) {
757
- throw X.delete(t), e;
758
+ throw J.delete(t), e;
758
759
  }
759
760
  }
760
- }, fe = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, pe = () => fe() ? ue : de, me = (e) => {
761
- let t = e.document;
762
- return new Promise((n, r) => {
763
- let i = pe();
764
- if (t.querySelector(`script[src="${i}"]`)) {
765
- Q(e, J).then(n).catch(r);
766
- return;
767
- }
768
- let a = t.createElement("script");
769
- a.src = i, a.onload = () => Q(e, J).then(n).catch(r), a.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), t.head.appendChild(a);
770
- });
771
- }, Q = (e, t) => new Promise((n, r) => {
772
- e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${Y}ms`)), Y))]).then(() => n()).catch(r);
761
+ }, he = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, ge = () => he() ? pe : me, _e = async (e) => {
762
+ let t = e.document, n = ge();
763
+ if (t.querySelector(`script[src="${n}"]`)) return Q(e, G);
764
+ let r = ve(t);
765
+ if (r && await X(t, r)) return Q(e, G);
766
+ let i = t.createElement("script");
767
+ return i.src = n, await Z(t, i), Q(e, G);
768
+ }, ve = (e) => {
769
+ let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);
770
+ return Array.from(t, (e) => e.href).find(ye);
771
+ }, ye = (e) => {
772
+ try {
773
+ return new URL(e).pathname.endsWith(q);
774
+ } catch {
775
+ return !1;
776
+ }
777
+ }, X = async (e, t) => {
778
+ let n = e.createElement("script");
779
+ n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
780
+ try {
781
+ return await Z(e, n), !0;
782
+ } catch {
783
+ return n.remove(), !1;
784
+ }
785
+ }, Z = (e, t) => new Promise((n, r) => {
786
+ t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
787
+ }), Q = (e, t) => new Promise((n, r) => {
788
+ e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${K}ms`)), K))]).then(() => n()).catch(r);
773
789
  });
774
790
  [
775
791
  "primaryBackground",
@@ -786,7 +802,7 @@ var d = /* @__PURE__ */ function(e) {
786
802
  ].map((e) => `brand_${e}`);
787
803
  var $ = /* @__PURE__ */ function(e) {
788
804
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
789
- }({}), he = {
805
+ }({}), be = {
790
806
  config: {
791
807
  shopifyDomain: "",
792
808
  moneyFormat: "${{amount}}",
@@ -1185,7 +1201,7 @@ var $ = /* @__PURE__ */ function(e) {
1185
1201
  mediaImages: [],
1186
1202
  collectionBreaksProducts: [],
1187
1203
  translations: {}
1188
- }, ge = class extends HTMLElement {
1204
+ }, xe = class extends HTMLElement {
1189
1205
  constructor(...e) {
1190
1206
  super(...e), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1191
1207
  }
@@ -1203,13 +1219,13 @@ var $ = /* @__PURE__ */ function(e) {
1203
1219
  async initialize() {
1204
1220
  let e = ++this.initializeId;
1205
1221
  if (this.cleanup(), this.hasAttribute("demo")) {
1206
- if (await Z(window), e !== this.initializeId) return;
1207
- this.renderInnerElement(he);
1222
+ if (await Y(window), e !== this.initializeId) return;
1223
+ this.renderInnerElement(be);
1208
1224
  return;
1209
1225
  }
1210
1226
  let t = this.getAttribute("shop-domain"), n = this.getAttribute("storefront-token"), r = this.getAttribute("product-id");
1211
1227
  if (!t || !n || !r) return;
1212
- let [i] = await Promise.all([q({
1228
+ let [i] = await Promise.all([W({
1213
1229
  shopifyDomain: t,
1214
1230
  storefrontAccessToken: n
1215
1231
  }, {
@@ -1217,7 +1233,7 @@ var $ = /* @__PURE__ */ function(e) {
1217
1233
  dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1218
1234
  country: this.getAttribute("country")?.toUpperCase() ?? void 0,
1219
1235
  language: this.getAttribute("language")?.toUpperCase() ?? void 0
1220
- }), Z(window)]);
1236
+ }), Y(window)]);
1221
1237
  i && e === this.initializeId && this.renderInnerElement(i);
1222
1238
  }
1223
1239
  renderInnerElement(e) {
@@ -1254,5 +1270,5 @@ var $ = /* @__PURE__ */ function(e) {
1254
1270
  this.cleanup(), this.initializeId++;
1255
1271
  }
1256
1272
  };
1257
- customElements.define("kaching-bundle-component", ge);
1258
- export { q as fetchKachingBundlesData };
1273
+ customElements.define("kaching-bundle-component", xe);
1274
+ export { W as fetchKachingBundlesData };
@@ -234,5 +234,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
234
234
  }
235
235
  }
236
236
  }
237
- `,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},E=e=>[...D(e),...O(e),...k(e),...A(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e),...ce(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),D=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),O=e=>e.dealBars.flatMap(e=>e.dealBarType===p.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),k=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),A=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),ee=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),te=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],ne=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},re=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],ie=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ae=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),oe=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},se=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),ce=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],j=e=>{let t=[...M(e),...N(e),...P(e),...F(e),...I(e),...L(e),...R(e),...z(e)];return Array.from(new Set(t.filter(e=>e!=null)))},M=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),N=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),P=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],F=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),I=e=>e.dealBars.filter(e=>e.dealBarType===p.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),L=e=>e.dealBars.filter(e=>e.dealBarType===p.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...e.selectedProducts?.map(e=>e.id)??[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),R=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),z=e=>e.dealBars.filter(e=>e.dealBarType===p.Sku).flatMap(({productGID:e})=>e?[e]:[]),B=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},V=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new B({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new B({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},H=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),V(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},U=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},W=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await m(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await m(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await g(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0});return o=o.filter(e=>e.availableForSale),o},G=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`},r=e?le(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},le=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=K(e);return n.find(e=>K(e.locale)===r)?.translations},K=e=>e.toLowerCase().replace(/_/g,`-`),ue=`2026-07`,de=async(e,{productId:t,dealBlockId:n,country:r=void 0,language:i=void 0})=>{try{let a=[Number(t.split(`/`).pop())],o=new fe(e);r||=o.i18n?.country,i||=o.i18n?.language;let s=await C(o,{language:i,country:r,useExternalMetafieldNamespace:!0});o.shopifyDomain=s.shopifyDomain;let c=s.storefrontAccessToken?new H(s.shopifyDomain,s.storefrontAccessToken):o,[l,d]=await Promise.all([g(c,{country:r,language:i,productIds:a,useExternalMetafieldNamespace:!0}),u(c,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),f=l[0];if(!f)return null;let p=U(d,f),m;if(n?(m=p.find(e=>e.id===n||e.nanoId===n),m||=p[0]):m=p[0],!m)return null;let h=E(m),_=j(m),[v,y,b,x]=await Promise.all([g(c,{country:r,language:i,productIds:_,useExternalMetafieldNamespace:!0}),T(c,h,300),W(c,m,{country:r,language:i}),G({language:i,dealBlockId:m.id})]);return{product:f,dealBlock:m,config:s,otherProducts:v,mediaImages:y,collectionBreaksProducts:b??[],translations:x}}catch(e){return console.error(e),null}},fe=class{constructor(e){this.storefront=e,this.shopifyDomain=``}async query(e,t){if(`query`in this.storefront&&`i18n`in this.storefront)return await this.storefront.query(e,t);if(`graphql`in this.storefront){let n=await this.storefront.graphql(e,t);if(n.errors?.length)throw Error(n.errors.map(e=>e.message).join(`
238
- `));return n.data}if(`request`in this.storefront)return(await this.storefront.request(e,t)).data;if(`shopifyDomain`in this.storefront&&`storefrontAccessToken`in this.storefront){let n=await fetch(`https://${this.storefront.shopifyDomain}/api/${ue}/graphql.json`,{body:JSON.stringify({query:e,variables:t?.variables}),headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}{let n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:e,variables:t?.variables}),headers:this.storefront.getPublicTokenHeaders(),method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}}get i18n(){if(`i18n`in this.storefront)return this.storefront.i18n}},pe=de,q=`kaching-bundles-block`,J=1e4,me=`https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js`,he=`https://bundles-integrations.kachingappz.app/kaching-bundles-block.js`,Y=new WeakSet,ge=async e=>{let t=e.document;if(!e.customElements.get(q)){if(Y.has(t))return X(e,q);Y.add(t);try{await ye(e)}catch(e){throw Y.delete(t),e}}},_e=()=>typeof window<`u`&&window.__KACHING_DEV__!==void 0,ve=()=>_e()?me:he,ye=e=>{let t=e.document;return new Promise((n,r)=>{let i=ve();if(t.querySelector(`script[src="${i}"]`)){X(e,q).then(n).catch(r);return}let a=t.createElement(`script`);a.src=i,a.onload=()=>X(e,q).then(n).catch(r),a.onerror=()=>r(Error(`Failed to load script`)),t.head.appendChild(a)})},X=(e,t)=>new Promise((n,r)=>{e.customElements.get(t)?n():Promise.race([e.customElements.whenDefined(t),new Promise((e,n)=>setTimeout(()=>n(Error(`Custom element "${t}" failed to register within ${J}ms`)),J))]).then(()=>n()).catch(r)});[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var Z=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),Q=`a-f\\d`,be=`#?[${Q}]{3}[${Q}]?`,xe=`#?[${Q}]{6}([${Q}]{2})?`,Se=RegExp(`[^#${Q}]`,`gi`),Ce=RegExp(`^${be}$|^${xe}$`,`i`);function $(e,t={}){if(typeof e!=`string`||Se.test(e)||!Ce.test(e))throw TypeError(`Expected a valid hex string`);e=e.replace(/^#/,``);let n=1;e.length===8&&(n=Number.parseInt(e.slice(6,8),16)/255,e=e.slice(0,6)),e.length===4&&(n=Number.parseInt(e.slice(3,4).repeat(2),16)/255,e=e.slice(0,3)),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let r=Number.parseInt(e,16),i=r>>16,a=r>>8&255,o=r&255,s=typeof t.alpha==`number`?t.alpha:n;return t.format===`array`?[i,a,o,s]:t.format===`css`?`rgb(${i} ${a} ${o}${s===1?``:` / ${Number((s*100).toFixed(2))}%`})`:{red:i,green:a,blue:o,alpha:s}}var we=({price:e})=>({id:123,handle:`123`,url:null,availableForSale:!0,requiresSellingPlan:!1,title:``,image:null,selectedVariantId:456,collectionIds:[],options:[],sellingPlans:[],variants:[{id:456,availableForSale:!0,price:Math.round((e??10)*100),compareAtPrice:null,options:[],imageId:null,image:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50,unitPriceMeasurement:null}],metafields:{text:null,text2:null,text3:null,text4:null},isNativeBundle:!1}),Te=()=>({shopifyDomain:``,moneyFormat:"${{amount_with_comma_separator}}",locale:`en`,liquidLocale:`en`,country:`US`,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!1,previewScratchOff:!1,currencyRate:1,defaultTranslations:{"system.out_of_stock":``,"system.invalid_variant":``,"system.unavailable_option_value":``,"system.confirm":``,"system.cancel":``,"system.free":``,"system.search":``,"system.quantity":``,"system.subscription_plan":``,"system.remove":``,"system.sort_by":``,"system.sort_relevance":``,"system.sort_newest_first":``,"system.sort_price_low_to_high":``,"system.sort_price_high_to_low":``,"system.no_results_found":``,"system.no_results_description":``,"system.clear_search":``,"system.no_products_available":``,"system.original_price":``,"system.price":``,"system.letters_only":``,"system.numbers_only":``},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null},shopCustomStyles:``,featureFlags:{}}),Ee=({color:e,cornerRadius:t})=>{let n={id:`123`,nanoId:`123`,blockName:`Bundle`,discountName:``,blockTitle:`BUNDLE & SAVE`,blockLayout:`vertical`,blockVisibility:`all-products`,marketId:null,currency:null,excludedProductIds:[],excludedCollectionIds:[],selectedProductIds:[],selectedCollectionIds:[],excludeB2bCustomers:!1,excludePos:!1,startTimestamp:175811496e4,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!1,showPricesPerItem:!1,showBothPrices:!1,useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:`.00`,updateNativePrice:!1,updateNativePriceType:`item`,skipCart:!1,showVariantsForSingleQuantity:!0,preselectedDealBarId:`1f-9`,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,lowStockAlertEnabled:!1,lowStockAlert:null,dealBars:[{id:`PfFU`,dealBarType:Z.QuantityBreak,title:`1 pack`,subtitle:`Standard price`,label:``,quantity:1,discountType:`default`,discountValue:``,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null},{id:`1f-9`,dealBarType:Z.QuantityBreak,title:`2 pack`,subtitle:`You save {{saved_percentage}}`,label:`SAVE {{saved_total}}`,quantity:2,discountType:`percentage`,discountValue:`15`,badgeStyle:`most-popular`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null}],badgesEnabled:!0,badges:[{id:`bdg1`,attachedTo:{type:`dealBar`,dealBarId:`1f-9`},text:`MOST POPULAR`,colors:null,badgeType:`most-popular`,size:90}],cornerRadius:t??8,spacing:1,colors:{background:{red:255,green:255,blue:255,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:238,green:238,blue:238,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:255,green:17,blue:17,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:`14`,style:`bold`},title:{size:`20`,style:`bold`},subtitle:{size:`14`,style:`regular`},label:{size:`12`,style:`regular`},freeGift:{size:`13`,style:`bold`},upsell:{size:`13`,style:`bold`},unitLabel:{size:`14`,style:`regular`}},swatchOptions:[],swatchSize:18,swatchShape:`circle`,imageSize:48,imageCornerRadius:6};return e!==void 0&&(n.colors.border={...$(e),alpha:1}),n},De=({data:n,selectedVariantId:r,preview:i,onLinesChange:a,targetWindow:o})=>{let s=(0,e.useRef)(null),[c,l]=(0,e.useState)(!1),u=(0,e.useRef)(!1);(0,e.useEffect)(()=>{s.current&&!c&&(async()=>{await ge(o??window),l(!0)})()},[c,o]),(0,e.useEffect)(()=>{let e=s.current;if(!c||!e)return;let t=()=>{let t=e.items().map(e=>({merchandiseId:`gid://shopify/ProductVariant/${e.id}`,quantity:e.quantity,attributes:Object.entries(e.properties).map(([e,t])=>({key:e,value:String(t)})),sellingPlanId:e.selling_plan?`gid://shopify/SellingPlan/${e.selling_plan}`:void 0}));a?.(t)};return u.current||=(typeof e.items==`function`?t():e.addEventListener(`kaching-bundles-block-loaded`,t),!0),e.addEventListener(`variants-changed`,t),()=>{e.removeEventListener(`kaching-bundles-block-loaded`,t),e.removeEventListener(`variants-changed`,t)}},[c,a]);let d=n?ke(n,r):i?Ae(i):null;return Oe(()=>{let e=s.current;if(e&&d)for(let[t,n]of Object.entries(d.jsonAttributes))e.getAttribute(t)!==n&&e.setAttribute(t,n)}),d?(0,t.jsx)(`kaching-bundles-block`,{ref:s,"deal-block-id":d.dealBlockId,...d.jsonAttributes,"current-variant-id":d.currentVariantId}):null},Oe=typeof window>`u`?e.useEffect:e.useLayoutEffect,ke=({config:e,dealBlock:t,product:n,otherProducts:r,mediaImages:i,collectionBreaksProducts:a,translations:o},s)=>({dealBlockId:t.id,currentVariantId:s?s.split(`/`).pop():String(n.variants[0].id),jsonAttributes:{config:JSON.stringify(e),"deal-block":JSON.stringify(t),"media-images":JSON.stringify(i),product:JSON.stringify(n),"other-products":JSON.stringify(r),"collection-breaks-products":JSON.stringify(a),translations:JSON.stringify(o)}}),Ae=({cornerRadius:e,color:t,price:n})=>{let r=we({price:n}),i=Te(),a=Ee({color:t,cornerRadius:e});return{dealBlockId:a.id,currentVariantId:String(r.variants[0].id),jsonAttributes:{config:JSON.stringify(i),"deal-block":JSON.stringify(a),"media-images":JSON.stringify([]),product:JSON.stringify(r),"other-products":JSON.stringify([]),"collection-breaks-products":JSON.stringify([]),translations:JSON.stringify({})}}};exports.KachingBundle=De,exports.fetchKachingBundlesData=pe;
237
+ `,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},E=e=>[...D(e),...O(e),...k(e),...A(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e),...ce(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),D=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),O=e=>e.dealBars.flatMap(e=>e.dealBarType===p.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),k=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),A=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),ee=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),te=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],ne=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},re=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],ie=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ae=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),oe=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},se=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),ce=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],le=e=>{let t=[...ue(e),...j(e),...M(e),...N(e),...P(e),...F(e),...I(e),...L(e)];return Array.from(new Set(t.filter(e=>e!=null)))},ue=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),j=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),M=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],N=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),P=e=>e.dealBars.filter(e=>e.dealBarType===p.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),F=e=>e.dealBars.filter(e=>e.dealBarType===p.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...e.selectedProducts?.map(e=>e.id)??[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),I=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),L=e=>e.dealBars.filter(e=>e.dealBarType===p.Sku).flatMap(({productGID:e})=>e?[e]:[]),R=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},z=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new R({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new R({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},B=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),z(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},V=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},H=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await m(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await m(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await g(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0});return o=o.filter(e=>e.availableForSale),o},U=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`,"system.gifts_required_alert":`Please choose your free gifts`},r=e?de(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},de=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=W(e);return n.find(e=>W(e.locale)===r)?.translations},W=e=>e.toLowerCase().replace(/_/g,`-`),fe=`2026-07`,pe=async(e,{productId:t,dealBlockId:n,country:r=void 0,language:i=void 0})=>{try{let a=[Number(t.split(`/`).pop())],o=new me(e);r||=o.i18n?.country,i||=o.i18n?.language;let s=await C(o,{language:i,country:r,useExternalMetafieldNamespace:!0});o.shopifyDomain=s.shopifyDomain;let c=s.storefrontAccessToken?new B(s.shopifyDomain,s.storefrontAccessToken):o,[l,d]=await Promise.all([g(c,{country:r,language:i,productIds:a,useExternalMetafieldNamespace:!0}),u(c,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),f=l[0];if(!f)return null;let p=V(d,f),m;if(n?(m=p.find(e=>e.id===n||e.nanoId===n),m||=p[0]):m=p[0],!m)return null;let h=E(m),_=le(m),[v,y,b,x]=await Promise.all([g(c,{country:r,language:i,productIds:_,useExternalMetafieldNamespace:!0}),T(c,h,300),H(c,m,{country:r,language:i}),U({language:i,dealBlockId:m.id})]);return{product:f,dealBlock:m,config:s,otherProducts:v,mediaImages:y,collectionBreaksProducts:b??[],translations:x}}catch(e){return console.error(e),null}},me=class{constructor(e){this.storefront=e,this.shopifyDomain=``}async query(e,t){if(`query`in this.storefront&&`i18n`in this.storefront)return await this.storefront.query(e,t);if(`graphql`in this.storefront){let n=await this.storefront.graphql(e,t);if(n.errors?.length)throw Error(n.errors.map(e=>e.message).join(`
238
+ `));return n.data}if(`request`in this.storefront)return(await this.storefront.request(e,t)).data;if(`shopifyDomain`in this.storefront&&`storefrontAccessToken`in this.storefront){let n=await fetch(`https://${this.storefront.shopifyDomain}/api/${fe}/graphql.json`,{body:JSON.stringify({query:e,variables:t?.variables}),headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}{let n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:e,variables:t?.variables}),headers:this.storefront.getPublicTokenHeaders(),method:`POST`});if(!n.ok)throw Error(n.statusText);return(await n.json()).data}}get i18n(){if(`i18n`in this.storefront)return this.storefront.i18n}},he=pe,G=`kaching-bundles-block`,K=1e4,q=`/kaching-bundles-block.js`,ge=`https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js`,_e=`https://bundles-integrations.kachingappz.app/kaching-bundles-block.js`,J=new WeakSet,ve=async e=>{let t=e.document;if(!e.customElements.get(G)){if(J.has(t))return X(e,G);J.add(t);try{await xe(e)}catch(e){throw J.delete(t),e}}},ye=()=>typeof window<`u`&&window.__KACHING_DEV__!==void 0,be=()=>ye()?ge:_e,xe=async e=>{let t=e.document,n=be();if(t.querySelector(`script[src="${n}"]`))return X(e,G);let r=Se(t);if(r&&await we(t,r))return X(e,G);let i=t.createElement(`script`);return i.src=n,await Y(t,i),X(e,G)},Se=e=>{let t=e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);return Array.from(t,e=>e.href).find(Ce)},Ce=e=>{try{return new URL(e).pathname.endsWith(q)}catch{return!1}},we=async(e,t)=>{let n=e.createElement(`script`);n.type=`module`,n.setAttribute(`crossorigin`,`anonymous`),n.src=t;try{return await Y(e,n),!0}catch{return n.remove(),!1}},Y=(e,t)=>new Promise((n,r)=>{t.onload=()=>n(),t.onerror=()=>r(Error(`Failed to load script`)),e.head.appendChild(t)}),X=(e,t)=>new Promise((n,r)=>{e.customElements.get(t)?n():Promise.race([e.customElements.whenDefined(t),new Promise((e,n)=>setTimeout(()=>n(Error(`Custom element "${t}" failed to register within ${K}ms`)),K))]).then(()=>n()).catch(r)});[`primaryBackground`,`secondaryBackground`,`primaryText`,`secondaryText`,`border`,`overlay`,`primaryAccent`,`primaryAccentText`,`badgeBackground`,`badgeText`,`error`].map(e=>`brand_${e}`);var Z=function(e){return e.QuantityBreak=`quantity-break`,e.Bxgy=`bxgy`,e.Bundle=`bundle`,e.MixAndMatch=`mix-and-match`,e.Sku=`sku`,e}({}),Q=`a-f\\d`,Te=`#?[${Q}]{3}[${Q}]?`,Ee=`#?[${Q}]{6}([${Q}]{2})?`,De=RegExp(`[^#${Q}]`,`gi`),Oe=RegExp(`^${Te}$|^${Ee}$`,`i`);function ke(e,t={}){if(typeof e!=`string`||De.test(e)||!Oe.test(e))throw TypeError(`Expected a valid hex string`);e=e.replace(/^#/,``);let n=1;e.length===8&&(n=Number.parseInt(e.slice(6,8),16)/255,e=e.slice(0,6)),e.length===4&&(n=Number.parseInt(e.slice(3,4).repeat(2),16)/255,e=e.slice(0,3)),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let r=Number.parseInt(e,16),i=r>>16,a=r>>8&255,o=r&255,s=typeof t.alpha==`number`?t.alpha:n;return t.format===`array`?[i,a,o,s]:t.format===`css`?`rgb(${i} ${a} ${o}${s===1?``:` / ${Number((s*100).toFixed(2))}%`})`:{red:i,green:a,blue:o,alpha:s}}var Ae=({price:e})=>({id:123,handle:`123`,url:null,availableForSale:!0,requiresSellingPlan:!1,title:``,image:null,selectedVariantId:456,collectionIds:[],options:[],sellingPlans:[],variants:[{id:456,availableForSale:!0,price:Math.round((e??10)*100),compareAtPrice:null,options:[],imageId:null,image:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50,unitPriceMeasurement:null}],metafields:{text:null,text2:null,text3:null,text4:null},isNativeBundle:!1}),$=()=>({shopifyDomain:``,moneyFormat:"${{amount_with_comma_separator}}",locale:`en`,liquidLocale:`en`,country:`US`,marketId:0,productId:null,storefrontAccessToken:null,includeSellingPlans:!1,includeAvailableQuantity:!1,customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!1,previewScratchOff:!1,currencyRate:1,defaultTranslations:{"system.out_of_stock":``,"system.invalid_variant":``,"system.unavailable_option_value":``,"system.confirm":``,"system.cancel":``,"system.free":``,"system.search":``,"system.quantity":``,"system.subscription_plan":``,"system.remove":``,"system.sort_by":``,"system.sort_relevance":``,"system.sort_newest_first":``,"system.sort_price_low_to_high":``,"system.sort_price_high_to_low":``,"system.no_results_found":``,"system.no_results_description":``,"system.clear_search":``,"system.no_products_available":``,"system.original_price":``,"system.price":``,"system.letters_only":``,"system.numbers_only":``},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null},shopCustomStyles:``,featureFlags:{}}),je=({color:e,cornerRadius:t})=>{let n={id:`123`,nanoId:`123`,blockName:`Bundle`,discountName:``,blockTitle:`BUNDLE & SAVE`,blockLayout:`vertical`,blockVisibility:`all-products`,marketId:null,currency:null,excludedProductIds:[],excludedCollectionIds:[],selectedProductIds:[],selectedCollectionIds:[],excludeB2bCustomers:!1,excludePos:!1,startTimestamp:175811496e4,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!1,showPricesPerItem:!1,showBothPrices:!1,useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:`.00`,updateNativePrice:!1,updateNativePriceType:`item`,skipCart:!1,showVariantsForSingleQuantity:!0,preselectedDealBarId:`1f-9`,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,lowStockAlertEnabled:!1,lowStockAlert:null,dealBars:[{id:`PfFU`,dealBarType:Z.QuantityBreak,title:`1 pack`,subtitle:`Standard price`,label:``,quantity:1,discountType:`default`,discountValue:``,badgeStyle:`simple`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null},{id:`1f-9`,dealBarType:Z.QuantityBreak,title:`2 pack`,subtitle:`You save {{saved_percentage}}`,label:`SAVE {{saved_total}}`,quantity:2,discountType:`percentage`,discountValue:`15`,badgeStyle:`most-popular`,badgeText:``,badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null}],badgesEnabled:!0,badges:[{id:`bdg1`,attachedTo:{type:`dealBar`,dealBarId:`1f-9`},text:`MOST POPULAR`,colors:null,badgeType:`most-popular`,size:90}],cornerRadius:t??8,spacing:1,colors:{background:{red:255,green:255,blue:255,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:238,green:238,blue:238,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:255,green:17,blue:17,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:`14`,style:`bold`},title:{size:`20`,style:`bold`},subtitle:{size:`14`,style:`regular`},label:{size:`12`,style:`regular`},freeGift:{size:`13`,style:`bold`},upsell:{size:`13`,style:`bold`},unitLabel:{size:`14`,style:`regular`}},swatchOptions:[],swatchSize:18,swatchShape:`circle`,imageSize:48,imageCornerRadius:6};return e!==void 0&&(n.colors.border={...ke(e),alpha:1}),n},Me=({data:n,selectedVariantId:r,preview:i,onLinesChange:a,targetWindow:o})=>{let s=(0,e.useRef)(null),[c,l]=(0,e.useState)(!1),u=(0,e.useRef)(!1);(0,e.useEffect)(()=>{s.current&&!c&&(async()=>{await ve(o??window),l(!0)})()},[c,o]),(0,e.useEffect)(()=>{let e=s.current;if(!c||!e)return;let t=()=>{let t=e.items().map(e=>({merchandiseId:`gid://shopify/ProductVariant/${e.id}`,quantity:e.quantity,attributes:Object.entries(e.properties).map(([e,t])=>({key:e,value:String(t)})),sellingPlanId:e.selling_plan?`gid://shopify/SellingPlan/${e.selling_plan}`:void 0}));a?.(t)};return u.current||=(typeof e.items==`function`?t():e.addEventListener(`kaching-bundles-block-loaded`,t),!0),e.addEventListener(`variants-changed`,t),()=>{e.removeEventListener(`kaching-bundles-block-loaded`,t),e.removeEventListener(`variants-changed`,t)}},[c,a]);let d=n?Pe(n,r):i?Fe(i):null;return Ne(()=>{let e=s.current;if(e&&d)for(let[t,n]of Object.entries(d.jsonAttributes))e.getAttribute(t)!==n&&e.setAttribute(t,n)}),d?(0,t.jsx)(`kaching-bundles-block`,{ref:s,"deal-block-id":d.dealBlockId,...d.jsonAttributes,"current-variant-id":d.currentVariantId}):null},Ne=typeof window>`u`?e.useEffect:e.useLayoutEffect,Pe=({config:e,dealBlock:t,product:n,otherProducts:r,mediaImages:i,collectionBreaksProducts:a,translations:o},s)=>({dealBlockId:t.id,currentVariantId:s?s.split(`/`).pop():String(n.variants[0].id),jsonAttributes:{config:JSON.stringify(e),"deal-block":JSON.stringify(t),"media-images":JSON.stringify(i),product:JSON.stringify(n),"other-products":JSON.stringify(r),"collection-breaks-products":JSON.stringify(a),translations:JSON.stringify(o)}}),Fe=({cornerRadius:e,color:t,price:n})=>{let r=Ae({price:n}),i=$(),a=je({color:t,cornerRadius:e});return{dealBlockId:a.id,currentVariantId:String(r.variants[0].id),jsonAttributes:{config:JSON.stringify(i),"deal-block":JSON.stringify(a),"media-images":JSON.stringify([]),product:JSON.stringify(r),"other-products":JSON.stringify([]),"collection-breaks-products":JSON.stringify([]),translations:JSON.stringify({})}}};exports.KachingBundle=Me,exports.fetchKachingBundlesData=he;
@@ -508,6 +508,7 @@ declare interface GlobalConfig {
508
508
  "system.select_variant_alert"?: string;
509
509
  "system.select_variant_placeholder"?: string;
510
510
  "system.personalisation_required_alert"?: string;
511
+ "system.gifts_required_alert"?: string;
511
512
  "system.deal_page_adding_to_cart"?: string;
512
513
  "system.deal_page_add_to_cart_failed"?: string;
513
514
  "system.deal_page_total"?: string;
@@ -533,7 +534,6 @@ declare interface GlobalConfig {
533
534
  "system.deal_page_full_price_for_now"?: string;
534
535
  "system.deal_page_percentage_unlocked"?: string;
535
536
  "system.deal_page_box_of"?: string;
536
- "system.deal_page_track_box_full"?: string;
537
537
  "system.deal_page_nudge_start_percentage_one"?: string;
538
538
  "system.deal_page_nudge_start_percentage_other"?: string;
539
539
  "system.deal_page_nudge_start_percentage_few"?: string;
@@ -608,7 +608,6 @@ declare interface GlobalConfig {
608
608
  "system.deal_page_your_gifts_row_other"?: string;
609
609
  "system.deal_page_your_gifts_row_few"?: string;
610
610
  "system.deal_page_your_gifts_row_many"?: string;
611
- "system.deal_page_free"?: string;
612
611
  "system.deal_page_gift_count_one"?: string;
613
612
  "system.deal_page_gift_count_other"?: string;
614
613
  "system.deal_page_gift_count_few"?: string;
@@ -641,6 +640,7 @@ declare interface GlobalConfig {
641
640
  label?: string | null;
642
641
  };
643
642
  featureFlags: {
643
+ analytics_tracking_disabled?: boolean;
644
644
  atc_total_price?: boolean;
645
645
  cart_change_response_rewrite?: boolean;
646
646
  cart_interceptor_dedupe_disabled?: boolean;
@@ -810,8 +810,10 @@ declare type MultipleGiftsSelector = {
810
810
  maxQuantity: number;
811
811
  showPrice: boolean;
812
812
  showProductPhotos?: boolean;
813
+ preselected?: boolean;
813
814
  includeInCompareAt?: boolean;
814
815
  applyOnlyForSubscriptions: boolean;
816
+ required?: boolean;
815
817
  };
816
818
 
817
819
  declare type PriceRoundingPrecision = ".99" | ".95" | ".90" | ".x9" | ".x0" | ".00";
@@ -503,9 +503,9 @@ var g = /* @__PURE__ */ function(e) {
503
503
  ...oe(e),
504
504
  ...se(e),
505
505
  ...ce(e),
506
- ...j(e),
507
- ...M(e),
508
- ...N(e)
506
+ ...le(e),
507
+ ...ue(e),
508
+ ...j(e)
509
509
  ].filter((e) => e != null && !e.includes("placeholder")), A = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ee = (e) => e.dealBars.flatMap((e) => e.dealBarType === g.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), te = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ne = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), re = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
510
510
  let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
511
511
  return [...e, ...n];
@@ -517,52 +517,52 @@ var g = /* @__PURE__ */ function(e) {
517
517
  ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
518
518
  e.progressiveGifts.style?.lockedMediaImageGID,
519
519
  e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
520
- ].filter((e) => e != null) : [], se = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ce = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), j = (e) => {
520
+ ].filter((e) => e != null) : [], se = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ce = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), le = (e) => {
521
521
  let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
522
522
  return n ? [...t, n] : t;
523
- }, M = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), N = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], P = (e) => {
523
+ }, ue = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), j = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], M = (e) => {
524
524
  let t = [
525
+ ...N(e),
526
+ ...P(e),
525
527
  ...F(e),
526
528
  ...I(e),
527
529
  ...L(e),
528
530
  ...R(e),
529
531
  ...z(e),
530
- ...B(e),
531
- ...V(e),
532
- ...H(e)
532
+ ...B(e)
533
533
  ];
534
534
  return Array.from(new Set(t.filter((e) => e != null)));
535
- }, F = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), I = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), L = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], R = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), z = (e) => e.dealBars.filter((e) => e.dealBarType === g.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), B = (e) => e.dealBars.filter((e) => e.dealBarType === g.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), V = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), H = (e) => e.dealBars.filter((e) => e.dealBarType === g.Sku).flatMap(({ productGID: e }) => e ? [e] : []), U = class extends Error {
535
+ }, N = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), P = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), F = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], I = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), L = (e) => e.dealBars.filter((e) => e.dealBarType === g.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), R = (e) => e.dealBars.filter((e) => e.dealBarType === g.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), z = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), B = (e) => e.dealBars.filter((e) => e.dealBarType === g.Sku).flatMap(({ productGID: e }) => e ? [e] : []), V = class extends Error {
536
536
  constructor({ status: e, operationName: t, graphqlErrors: n }) {
537
537
  let r = n.length ? `: ${n.join("; ")}` : "";
538
538
  super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
539
539
  }
540
- }, W = async (e, t) => {
540
+ }, H = async (e, t) => {
541
541
  let n = await e.text();
542
542
  if (!n) throw Error("Empty graphql response");
543
543
  let r;
544
544
  try {
545
545
  r = JSON.parse(n);
546
546
  } catch (n) {
547
- throw e.ok ? n : new U({
547
+ throw e.ok ? n : new V({
548
548
  status: e.status,
549
549
  operationName: t,
550
550
  graphqlErrors: []
551
551
  });
552
552
  }
553
- if (!e.ok || r.data === null || r.data === void 0) throw new U({
553
+ if (!e.ok || r.data === null || r.data === void 0) throw new V({
554
554
  status: e.status,
555
555
  operationName: t,
556
556
  graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
557
557
  });
558
558
  return r.data;
559
- }, G = class {
559
+ }, U = class {
560
560
  constructor(e, t) {
561
561
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
562
562
  }
563
563
  async query(e, t) {
564
564
  let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
565
- return i && (r += `?operation_name=${i}`), W(await fetch(r, {
565
+ return i && (r += `?operation_name=${i}`), H(await fetch(r, {
566
566
  method: "POST",
567
567
  headers: {
568
568
  "Content-Type": "application/json",
@@ -574,7 +574,7 @@ var g = /* @__PURE__ */ function(e) {
574
574
  })
575
575
  }), i);
576
576
  }
577
- }, le = (e, t) => {
577
+ }, de = (e, t) => {
578
578
  let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
579
579
  for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
580
580
  let i = e.filter((e) => e.blockVisibility === "selected-collections");
@@ -584,7 +584,7 @@ var g = /* @__PURE__ */ function(e) {
584
584
  let o = e.filter((e) => e.blockVisibility === "all-products");
585
585
  for (let e of o) n.push(e);
586
586
  return n;
587
- }, ue = async (e, t, { country: n, language: r }) => {
587
+ }, fe = async (e, t, { country: n, language: r }) => {
588
588
  let i = t.collectionBreaks;
589
589
  if (!t.collectionBreaksEnabled || !i) return;
590
590
  let a;
@@ -610,7 +610,7 @@ var g = /* @__PURE__ */ function(e) {
610
610
  useExternalMetafieldNamespace: !0
611
611
  });
612
612
  return o = o.filter((e) => e.availableForSale), o;
613
- }, de = ({ language: e, dealBlockId: t }) => {
613
+ }, pe = ({ language: e, dealBlockId: t }) => {
614
614
  let n = {
615
615
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
616
616
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -635,14 +635,15 @@ var g = /* @__PURE__ */ function(e) {
635
635
  "system.price": "Price:",
636
636
  "system.letters_only": "Only letters are allowed.",
637
637
  "system.numbers_only": "Only numbers are allowed.",
638
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
639
- }, r = e ? fe(e) : void 0;
638
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
639
+ "system.gifts_required_alert": "Please choose your free gifts"
640
+ }, r = e ? me(e) : void 0;
640
641
  return {
641
642
  ...n,
642
643
  ...r?.system,
643
644
  ...r?.dealBlocks[t]
644
645
  };
645
- }, fe = (e) => {
646
+ }, me = (e) => {
646
647
  if (typeof document > "u") return;
647
648
  let t = document.querySelector("script#kaching-bundles-translations");
648
649
  if (!t?.textContent) return;
@@ -652,11 +653,11 @@ var g = /* @__PURE__ */ function(e) {
652
653
  } catch {
653
654
  return;
654
655
  }
655
- let r = K(e);
656
- return n.find((e) => K(e.locale) === r)?.translations;
657
- }, K = (e) => e.toLowerCase().replace(/_/g, "-"), pe = "2026-07", me = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
656
+ let r = W(e);
657
+ return n.find((e) => W(e.locale) === r)?.translations;
658
+ }, W = (e) => e.toLowerCase().replace(/_/g, "-"), he = "2026-07", ge = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
658
659
  try {
659
- let a = [Number(t.split("/").pop())], o = new he(e);
660
+ let a = [Number(t.split("/").pop())], o = new _e(e);
660
661
  r ||= o.i18n?.country, i ||= o.i18n?.language;
661
662
  let s = await E(o, {
662
663
  language: i,
@@ -664,7 +665,7 @@ var g = /* @__PURE__ */ function(e) {
664
665
  useExternalMetafieldNamespace: !0
665
666
  });
666
667
  o.shopifyDomain = s.shopifyDomain;
667
- let c = s.storefrontAccessToken ? new G(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([y(c, {
668
+ let c = s.storefrontAccessToken ? new U(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([y(c, {
668
669
  country: r,
669
670
  language: i,
670
671
  productIds: a,
@@ -674,9 +675,9 @@ var g = /* @__PURE__ */ function(e) {
674
675
  useMetaobjects: s.featureFlags.storefront_metaobjects
675
676
  })]), d = l[0];
676
677
  if (!d) return null;
677
- let f = le(u, d), m;
678
+ let f = de(u, d), m;
678
679
  if (n ? (m = f.find((e) => e.id === n || e.nanoId === n), m ||= f[0]) : m = f[0], !m) return null;
679
- let h = k(m), g = P(m), [_, v, b, x] = await Promise.all([
680
+ let h = k(m), g = M(m), [_, v, b, x] = await Promise.all([
680
681
  y(c, {
681
682
  country: r,
682
683
  language: i,
@@ -684,11 +685,11 @@ var g = /* @__PURE__ */ function(e) {
684
685
  useExternalMetafieldNamespace: !0
685
686
  }),
686
687
  O(c, h, 300),
687
- ue(c, m, {
688
+ fe(c, m, {
688
689
  country: r,
689
690
  language: i
690
691
  }),
691
- de({
692
+ pe({
692
693
  language: i,
693
694
  dealBlockId: m.id
694
695
  })
@@ -705,7 +706,7 @@ var g = /* @__PURE__ */ function(e) {
705
706
  } catch (e) {
706
707
  return console.error(e), null;
707
708
  }
708
- }, he = class {
709
+ }, _e = class {
709
710
  constructor(e) {
710
711
  this.storefront = e, this.shopifyDomain = "";
711
712
  }
@@ -718,7 +719,7 @@ var g = /* @__PURE__ */ function(e) {
718
719
  }
719
720
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
720
721
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
721
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${pe}/graphql.json`, {
722
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${he}/graphql.json`, {
722
723
  body: JSON.stringify({
723
724
  query: e,
724
725
  variables: t?.variables
@@ -748,30 +749,45 @@ var g = /* @__PURE__ */ function(e) {
748
749
  get i18n() {
749
750
  if ("i18n" in this.storefront) return this.storefront.i18n;
750
751
  }
751
- }, ge = me, q = "kaching-bundles-block", J = 1e4, _e = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", ve = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", Y = /* @__PURE__ */ new WeakSet(), ye = async (e) => {
752
+ }, ve = ge, G = "kaching-bundles-block", K = 1e4, q = "/kaching-bundles-block.js", ye = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", be = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", J = /* @__PURE__ */ new WeakSet(), xe = async (e) => {
752
753
  let t = e.document;
753
- if (!e.customElements.get(q)) {
754
- if (Y.has(t)) return X(e, q);
755
- Y.add(t);
754
+ if (!e.customElements.get(G)) {
755
+ if (J.has(t)) return X(e, G);
756
+ J.add(t);
756
757
  try {
757
- await Se(e);
758
+ await we(e);
758
759
  } catch (e) {
759
- throw Y.delete(t), e;
760
+ throw J.delete(t), e;
760
761
  }
761
762
  }
762
- }, be = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, xe = () => be() ? _e : ve, Se = (e) => {
763
- let t = e.document;
764
- return new Promise((n, r) => {
765
- let i = xe();
766
- if (t.querySelector(`script[src="${i}"]`)) {
767
- X(e, q).then(n).catch(r);
768
- return;
769
- }
770
- let a = t.createElement("script");
771
- a.src = i, a.onload = () => X(e, q).then(n).catch(r), a.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), t.head.appendChild(a);
772
- });
773
- }, X = (e, t) => new Promise((n, r) => {
774
- e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${J}ms`)), J))]).then(() => n()).catch(r);
763
+ }, Se = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ce = () => Se() ? ye : be, we = async (e) => {
764
+ let t = e.document, n = Ce();
765
+ if (t.querySelector(`script[src="${n}"]`)) return X(e, G);
766
+ let r = Te(t);
767
+ if (r && await De(t, r)) return X(e, G);
768
+ let i = t.createElement("script");
769
+ return i.src = n, await Y(t, i), X(e, G);
770
+ }, Te = (e) => {
771
+ let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);
772
+ return Array.from(t, (e) => e.href).find(Ee);
773
+ }, Ee = (e) => {
774
+ try {
775
+ return new URL(e).pathname.endsWith(q);
776
+ } catch {
777
+ return !1;
778
+ }
779
+ }, De = async (e, t) => {
780
+ let n = e.createElement("script");
781
+ n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
782
+ try {
783
+ return await Y(e, n), !0;
784
+ } catch {
785
+ return n.remove(), !1;
786
+ }
787
+ }, Y = (e, t) => new Promise((n, r) => {
788
+ t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
789
+ }), X = (e, t) => new Promise((n, r) => {
790
+ e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${K}ms`)), K))]).then(() => n()).catch(r);
775
791
  });
776
792
  [
777
793
  "primaryBackground",
@@ -788,9 +804,9 @@ var g = /* @__PURE__ */ function(e) {
788
804
  ].map((e) => `brand_${e}`);
789
805
  var Z = /* @__PURE__ */ function(e) {
790
806
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
791
- }({}), Q = "a-f\\d", Ce = `#?[${Q}]{3}[${Q}]?`, we = `#?[${Q}]{6}([${Q}]{2})?`, Te = RegExp(`[^#${Q}]`, "gi"), Ee = RegExp(`^${Ce}$|^${we}$`, "i");
792
- function De(e, t = {}) {
793
- if (typeof e != "string" || Te.test(e) || !Ee.test(e)) throw TypeError("Expected a valid hex string");
807
+ }({}), Q = "a-f\\d", Oe = `#?[${Q}]{3}[${Q}]?`, ke = `#?[${Q}]{6}([${Q}]{2})?`, Ae = RegExp(`[^#${Q}]`, "gi"), $ = RegExp(`^${Oe}$|^${ke}$`, "i");
808
+ function je(e, t = {}) {
809
+ if (typeof e != "string" || Ae.test(e) || !$.test(e)) throw TypeError("Expected a valid hex string");
794
810
  e = e.replace(/^#/, "");
795
811
  let n = 1;
796
812
  e.length === 8 && (n = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (n = Number.parseInt(e.slice(3, 4).repeat(2), 16) / 255, e = e.slice(0, 3)), e.length === 3 && (e = e[0] + e[0] + e[1] + e[1] + e[2] + e[2]);
@@ -808,7 +824,7 @@ function De(e, t = {}) {
808
824
  };
809
825
  }
810
826
  // src/react/preview.ts
811
- var $ = ({ price: e }) => ({
827
+ var Me = ({ price: e }) => ({
812
828
  id: 123,
813
829
  handle: "123",
814
830
  url: null,
@@ -841,7 +857,7 @@ var $ = ({ price: e }) => ({
841
857
  text4: null
842
858
  },
843
859
  isNativeBundle: !1
844
- }), Oe = () => ({
860
+ }), Ne = () => ({
845
861
  shopifyDomain: "",
846
862
  moneyFormat: "${{amount_with_comma_separator}}",
847
863
  locale: "en",
@@ -897,7 +913,7 @@ var $ = ({ price: e }) => ({
897
913
  },
898
914
  shopCustomStyles: "",
899
915
  featureFlags: {}
900
- }), ke = ({ color: e, cornerRadius: t }) => {
916
+ }), Pe = ({ color: e, cornerRadius: t }) => {
901
917
  let n = {
902
918
  id: "123",
903
919
  nanoId: "123",
@@ -1157,14 +1173,14 @@ var $ = ({ price: e }) => ({
1157
1173
  imageCornerRadius: 6
1158
1174
  };
1159
1175
  return e !== void 0 && (n.colors.border = {
1160
- ...De(e),
1176
+ ...je(e),
1161
1177
  alpha: 1
1162
1178
  }), n;
1163
- }, Ae = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1179
+ }, Fe = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1164
1180
  let l = n(null), [u, d] = r(!1), f = n(!1);
1165
1181
  e(() => {
1166
1182
  l.current && !u && (async () => {
1167
- await ye(c ?? window), d(!0);
1183
+ await xe(c ?? window), d(!0);
1168
1184
  })();
1169
1185
  }, [u, c]), e(() => {
1170
1186
  let e = l.current;
@@ -1185,8 +1201,8 @@ var $ = ({ price: e }) => ({
1185
1201
  e.removeEventListener("kaching-bundles-block-loaded", t), e.removeEventListener("variants-changed", t);
1186
1202
  };
1187
1203
  }, [u, s]);
1188
- let p = t ? Me(t, a) : o ? Ne(o) : null;
1189
- return je(() => {
1204
+ let p = t ? Le(t, a) : o ? Re(o) : null;
1205
+ return Ie(() => {
1190
1206
  let e = l.current;
1191
1207
  if (e && p) for (let [t, n] of Object.entries(p.jsonAttributes)) e.getAttribute(t) !== n && e.setAttribute(t, n);
1192
1208
  }), p ? /* @__PURE__ */ i("kaching-bundles-block", {
@@ -1195,7 +1211,7 @@ var $ = ({ price: e }) => ({
1195
1211
  ...p.jsonAttributes,
1196
1212
  "current-variant-id": p.currentVariantId
1197
1213
  }) : null;
1198
- }, je = typeof window > "u" ? e : t, Me = ({ config: e, dealBlock: t, product: n, otherProducts: r, mediaImages: i, collectionBreaksProducts: a, translations: o }, s) => ({
1214
+ }, Ie = typeof window > "u" ? e : t, Le = ({ config: e, dealBlock: t, product: n, otherProducts: r, mediaImages: i, collectionBreaksProducts: a, translations: o }, s) => ({
1199
1215
  dealBlockId: t.id,
1200
1216
  currentVariantId: s ? s.split("/").pop() : String(n.variants[0].id),
1201
1217
  jsonAttributes: {
@@ -1207,8 +1223,8 @@ var $ = ({ price: e }) => ({
1207
1223
  "collection-breaks-products": JSON.stringify(a),
1208
1224
  translations: JSON.stringify(o)
1209
1225
  }
1210
- }), Ne = ({ cornerRadius: e, color: t, price: n }) => {
1211
- let r = $({ price: n }), i = Oe(), a = ke({
1226
+ }), Re = ({ cornerRadius: e, color: t, price: n }) => {
1227
+ let r = Me({ price: n }), i = Ne(), a = Pe({
1212
1228
  color: t,
1213
1229
  cornerRadius: e
1214
1230
  });
@@ -1226,4 +1242,4 @@ var $ = ({ price: e }) => ({
1226
1242
  }
1227
1243
  };
1228
1244
  };
1229
- export { Ae as KachingBundle, ge as fetchKachingBundlesData };
1245
+ export { Fe as KachingBundle, ve as fetchKachingBundlesData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kachingappz/bundles-js",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/kachingappz/bundles.git",
@@ -51,7 +51,7 @@
51
51
  ],
52
52
  "devDependencies": {
53
53
  "@kachingappz/bundles-storefront-api": "^0.1.0",
54
- "@kachingappz/bundles-types": "^0.4.3",
54
+ "@kachingappz/bundles-types": "^0.4.5",
55
55
  "@kachingappz/kaching-bundles-block": "^1.0.0",
56
56
  "@microsoft/api-extractor": "^7.57.7",
57
57
  "@testing-library/react": "^16.3.3",