@kachingappz/bundles-js 1.1.4 → 1.1.5

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.`},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
@@ -637,6 +637,7 @@ declare interface GlobalConfig {
637
637
  label?: string | null;
638
638
  };
639
639
  featureFlags: {
640
+ analytics_tracking_disabled?: boolean;
640
641
  atc_total_price?: boolean;
641
642
  cart_change_response_rewrite?: boolean;
642
643
  cart_interceptor_dedupe_disabled?: boolean;
@@ -637,6 +637,7 @@ declare interface GlobalConfig {
637
637
  label?: string | null;
638
638
  };
639
639
  featureFlags: {
640
+ analytics_tracking_disabled?: boolean;
640
641
  atc_total_price?: boolean;
641
642
  cart_change_response_rewrite?: boolean;
642
643
  cart_interceptor_dedupe_disabled?: boolean;
@@ -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.",
@@ -634,13 +634,13 @@ var d = /* @__PURE__ */ function(e) {
634
634
  "system.letters_only": "Only letters are allowed.",
635
635
  "system.numbers_only": "Only numbers are allowed.",
636
636
  "system.personalisation_required_alert": "Please add personalisation for every item to continue."
637
- }, r = e ? G(e) : void 0;
637
+ }, r = e ? H(e) : void 0;
638
638
  return {
639
639
  ...n,
640
640
  ...r?.system,
641
641
  ...r?.dealBlocks[t]
642
642
  };
643
- }, G = (e) => {
643
+ }, H = (e) => {
644
644
  if (typeof document > "u") return;
645
645
  let t = document.querySelector("script#kaching-bundles-translations");
646
646
  if (!t?.textContent) return;
@@ -650,11 +650,11 @@ var d = /* @__PURE__ */ function(e) {
650
650
  } catch {
651
651
  return;
652
652
  }
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 }) => {
653
+ let r = U(e);
654
+ return n.find((e) => U(e.locale) === r)?.translations;
655
+ }, 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
656
  try {
657
- let a = [Number(t.split("/").pop())], o = new le(e);
657
+ let a = [Number(t.split("/").pop())], o = new fe(e);
658
658
  r ||= o.i18n?.country, i ||= o.i18n?.language;
659
659
  let s = await x(o, {
660
660
  language: i,
@@ -662,7 +662,7 @@ var d = /* @__PURE__ */ function(e) {
662
662
  useExternalMetafieldNamespace: !0
663
663
  });
664
664
  o.shopifyDomain = s.shopifyDomain;
665
- let l = s.storefrontAccessToken ? new V(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
665
+ let l = s.storefrontAccessToken ? new R(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
666
666
  country: r,
667
667
  language: i,
668
668
  productIds: a,
@@ -672,9 +672,9 @@ var d = /* @__PURE__ */ function(e) {
672
672
  useMetaobjects: s.featureFlags.storefront_metaobjects
673
673
  })]), f = u[0];
674
674
  if (!f) return null;
675
- let p = H(d, f), h;
675
+ let p = z(d, f), h;
676
676
  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([
677
+ let g = w(h), _ = oe(h), [v, y, b, S] = await Promise.all([
678
678
  m(l, {
679
679
  country: r,
680
680
  language: i,
@@ -682,11 +682,11 @@ var d = /* @__PURE__ */ function(e) {
682
682
  useExternalMetafieldNamespace: !0
683
683
  }),
684
684
  C(l, g, 300),
685
- U(l, h, {
685
+ B(l, h, {
686
686
  country: r,
687
687
  language: i
688
688
  }),
689
- W({
689
+ V({
690
690
  language: i,
691
691
  dealBlockId: h.id
692
692
  })
@@ -703,7 +703,7 @@ var d = /* @__PURE__ */ function(e) {
703
703
  } catch (e) {
704
704
  return console.error(e), null;
705
705
  }
706
- }, le = class {
706
+ }, fe = class {
707
707
  constructor(e) {
708
708
  this.storefront = e, this.shopifyDomain = "";
709
709
  }
@@ -716,7 +716,7 @@ var d = /* @__PURE__ */ function(e) {
716
716
  }
717
717
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
718
718
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
719
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ce}/graphql.json`, {
719
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${de}/graphql.json`, {
720
720
  body: JSON.stringify({
721
721
  query: e,
722
722
  variables: t?.variables
@@ -746,30 +746,45 @@ var d = /* @__PURE__ */ function(e) {
746
746
  get i18n() {
747
747
  if ("i18n" in this.storefront) return this.storefront.i18n;
748
748
  }
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) => {
749
+ }, 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
750
  let t = e.document;
751
- if (!e.customElements.get(J)) {
752
- if (X.has(t)) return Q(e, J);
753
- X.add(t);
751
+ if (!e.customElements.get(G)) {
752
+ if (J.has(t)) return Q(e, G);
753
+ J.add(t);
754
754
  try {
755
- await me(e);
755
+ await _e(e);
756
756
  } catch (e) {
757
- throw X.delete(t), e;
757
+ throw J.delete(t), e;
758
758
  }
759
759
  }
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);
760
+ }, he = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, ge = () => he() ? pe : me, _e = async (e) => {
761
+ let t = e.document, n = ge();
762
+ if (t.querySelector(`script[src="${n}"]`)) return Q(e, G);
763
+ let r = ve(t);
764
+ if (r && await X(t, r)) return Q(e, G);
765
+ let i = t.createElement("script");
766
+ return i.src = n, await Z(t, i), Q(e, G);
767
+ }, ve = (e) => {
768
+ let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);
769
+ return Array.from(t, (e) => e.href).find(ye);
770
+ }, ye = (e) => {
771
+ try {
772
+ return new URL(e).pathname.endsWith(q);
773
+ } catch {
774
+ return !1;
775
+ }
776
+ }, X = async (e, t) => {
777
+ let n = e.createElement("script");
778
+ n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
779
+ try {
780
+ return await Z(e, n), !0;
781
+ } catch {
782
+ return n.remove(), !1;
783
+ }
784
+ }, Z = (e, t) => new Promise((n, r) => {
785
+ t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
786
+ }), Q = (e, t) => new Promise((n, r) => {
787
+ 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
788
  });
774
789
  [
775
790
  "primaryBackground",
@@ -786,7 +801,7 @@ var d = /* @__PURE__ */ function(e) {
786
801
  ].map((e) => `brand_${e}`);
787
802
  var $ = /* @__PURE__ */ function(e) {
788
803
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
789
- }({}), he = {
804
+ }({}), be = {
790
805
  config: {
791
806
  shopifyDomain: "",
792
807
  moneyFormat: "${{amount}}",
@@ -1185,7 +1200,7 @@ var $ = /* @__PURE__ */ function(e) {
1185
1200
  mediaImages: [],
1186
1201
  collectionBreaksProducts: [],
1187
1202
  translations: {}
1188
- }, ge = class extends HTMLElement {
1203
+ }, xe = class extends HTMLElement {
1189
1204
  constructor(...e) {
1190
1205
  super(...e), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1191
1206
  }
@@ -1203,13 +1218,13 @@ var $ = /* @__PURE__ */ function(e) {
1203
1218
  async initialize() {
1204
1219
  let e = ++this.initializeId;
1205
1220
  if (this.cleanup(), this.hasAttribute("demo")) {
1206
- if (await Z(window), e !== this.initializeId) return;
1207
- this.renderInnerElement(he);
1221
+ if (await Y(window), e !== this.initializeId) return;
1222
+ this.renderInnerElement(be);
1208
1223
  return;
1209
1224
  }
1210
1225
  let t = this.getAttribute("shop-domain"), n = this.getAttribute("storefront-token"), r = this.getAttribute("product-id");
1211
1226
  if (!t || !n || !r) return;
1212
- let [i] = await Promise.all([q({
1227
+ let [i] = await Promise.all([W({
1213
1228
  shopifyDomain: t,
1214
1229
  storefrontAccessToken: n
1215
1230
  }, {
@@ -1217,7 +1232,7 @@ var $ = /* @__PURE__ */ function(e) {
1217
1232
  dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1218
1233
  country: this.getAttribute("country")?.toUpperCase() ?? void 0,
1219
1234
  language: this.getAttribute("language")?.toUpperCase() ?? void 0
1220
- }), Z(window)]);
1235
+ }), Y(window)]);
1221
1236
  i && e === this.initializeId && this.renderInnerElement(i);
1222
1237
  }
1223
1238
  renderInnerElement(e) {
@@ -1254,5 +1269,5 @@ var $ = /* @__PURE__ */ function(e) {
1254
1269
  this.cleanup(), this.initializeId++;
1255
1270
  }
1256
1271
  };
1257
- customElements.define("kaching-bundle-component", ge);
1258
- export { q as fetchKachingBundlesData };
1272
+ customElements.define("kaching-bundle-component", xe);
1273
+ 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.`},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;
@@ -641,6 +641,7 @@ declare interface GlobalConfig {
641
641
  label?: string | null;
642
642
  };
643
643
  featureFlags: {
644
+ analytics_tracking_disabled?: boolean;
644
645
  atc_total_price?: boolean;
645
646
  cart_change_response_rewrite?: boolean;
646
647
  cart_interceptor_dedupe_disabled?: boolean;
@@ -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.",
@@ -636,13 +636,13 @@ var g = /* @__PURE__ */ function(e) {
636
636
  "system.letters_only": "Only letters are allowed.",
637
637
  "system.numbers_only": "Only numbers are allowed.",
638
638
  "system.personalisation_required_alert": "Please add personalisation for every item to continue."
639
- }, r = e ? fe(e) : void 0;
639
+ }, r = e ? me(e) : void 0;
640
640
  return {
641
641
  ...n,
642
642
  ...r?.system,
643
643
  ...r?.dealBlocks[t]
644
644
  };
645
- }, fe = (e) => {
645
+ }, me = (e) => {
646
646
  if (typeof document > "u") return;
647
647
  let t = document.querySelector("script#kaching-bundles-translations");
648
648
  if (!t?.textContent) return;
@@ -652,11 +652,11 @@ var g = /* @__PURE__ */ function(e) {
652
652
  } catch {
653
653
  return;
654
654
  }
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 }) => {
655
+ let r = W(e);
656
+ return n.find((e) => W(e.locale) === r)?.translations;
657
+ }, 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
658
  try {
659
- let a = [Number(t.split("/").pop())], o = new he(e);
659
+ let a = [Number(t.split("/").pop())], o = new _e(e);
660
660
  r ||= o.i18n?.country, i ||= o.i18n?.language;
661
661
  let s = await E(o, {
662
662
  language: i,
@@ -664,7 +664,7 @@ var g = /* @__PURE__ */ function(e) {
664
664
  useExternalMetafieldNamespace: !0
665
665
  });
666
666
  o.shopifyDomain = s.shopifyDomain;
667
- let c = s.storefrontAccessToken ? new G(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([y(c, {
667
+ let c = s.storefrontAccessToken ? new U(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([y(c, {
668
668
  country: r,
669
669
  language: i,
670
670
  productIds: a,
@@ -674,9 +674,9 @@ var g = /* @__PURE__ */ function(e) {
674
674
  useMetaobjects: s.featureFlags.storefront_metaobjects
675
675
  })]), d = l[0];
676
676
  if (!d) return null;
677
- let f = le(u, d), m;
677
+ let f = de(u, d), m;
678
678
  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([
679
+ let h = k(m), g = M(m), [_, v, b, x] = await Promise.all([
680
680
  y(c, {
681
681
  country: r,
682
682
  language: i,
@@ -684,11 +684,11 @@ var g = /* @__PURE__ */ function(e) {
684
684
  useExternalMetafieldNamespace: !0
685
685
  }),
686
686
  O(c, h, 300),
687
- ue(c, m, {
687
+ fe(c, m, {
688
688
  country: r,
689
689
  language: i
690
690
  }),
691
- de({
691
+ pe({
692
692
  language: i,
693
693
  dealBlockId: m.id
694
694
  })
@@ -705,7 +705,7 @@ var g = /* @__PURE__ */ function(e) {
705
705
  } catch (e) {
706
706
  return console.error(e), null;
707
707
  }
708
- }, he = class {
708
+ }, _e = class {
709
709
  constructor(e) {
710
710
  this.storefront = e, this.shopifyDomain = "";
711
711
  }
@@ -718,7 +718,7 @@ var g = /* @__PURE__ */ function(e) {
718
718
  }
719
719
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
720
720
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
721
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${pe}/graphql.json`, {
721
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${he}/graphql.json`, {
722
722
  body: JSON.stringify({
723
723
  query: e,
724
724
  variables: t?.variables
@@ -748,30 +748,45 @@ var g = /* @__PURE__ */ function(e) {
748
748
  get i18n() {
749
749
  if ("i18n" in this.storefront) return this.storefront.i18n;
750
750
  }
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) => {
751
+ }, 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
752
  let t = e.document;
753
- if (!e.customElements.get(q)) {
754
- if (Y.has(t)) return X(e, q);
755
- Y.add(t);
753
+ if (!e.customElements.get(G)) {
754
+ if (J.has(t)) return X(e, G);
755
+ J.add(t);
756
756
  try {
757
- await Se(e);
757
+ await we(e);
758
758
  } catch (e) {
759
- throw Y.delete(t), e;
759
+ throw J.delete(t), e;
760
760
  }
761
761
  }
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);
762
+ }, Se = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ce = () => Se() ? ye : be, we = async (e) => {
763
+ let t = e.document, n = Ce();
764
+ if (t.querySelector(`script[src="${n}"]`)) return X(e, G);
765
+ let r = Te(t);
766
+ if (r && await De(t, r)) return X(e, G);
767
+ let i = t.createElement("script");
768
+ return i.src = n, await Y(t, i), X(e, G);
769
+ }, Te = (e) => {
770
+ let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);
771
+ return Array.from(t, (e) => e.href).find(Ee);
772
+ }, Ee = (e) => {
773
+ try {
774
+ return new URL(e).pathname.endsWith(q);
775
+ } catch {
776
+ return !1;
777
+ }
778
+ }, De = async (e, t) => {
779
+ let n = e.createElement("script");
780
+ n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
781
+ try {
782
+ return await Y(e, n), !0;
783
+ } catch {
784
+ return n.remove(), !1;
785
+ }
786
+ }, Y = (e, t) => new Promise((n, r) => {
787
+ t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
788
+ }), X = (e, t) => new Promise((n, r) => {
789
+ 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
790
  });
776
791
  [
777
792
  "primaryBackground",
@@ -788,9 +803,9 @@ var g = /* @__PURE__ */ function(e) {
788
803
  ].map((e) => `brand_${e}`);
789
804
  var Z = /* @__PURE__ */ function(e) {
790
805
  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");
806
+ }({}), Q = "a-f\\d", Oe = `#?[${Q}]{3}[${Q}]?`, ke = `#?[${Q}]{6}([${Q}]{2})?`, Ae = RegExp(`[^#${Q}]`, "gi"), $ = RegExp(`^${Oe}$|^${ke}$`, "i");
807
+ function je(e, t = {}) {
808
+ if (typeof e != "string" || Ae.test(e) || !$.test(e)) throw TypeError("Expected a valid hex string");
794
809
  e = e.replace(/^#/, "");
795
810
  let n = 1;
796
811
  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 +823,7 @@ function De(e, t = {}) {
808
823
  };
809
824
  }
810
825
  // src/react/preview.ts
811
- var $ = ({ price: e }) => ({
826
+ var Me = ({ price: e }) => ({
812
827
  id: 123,
813
828
  handle: "123",
814
829
  url: null,
@@ -841,7 +856,7 @@ var $ = ({ price: e }) => ({
841
856
  text4: null
842
857
  },
843
858
  isNativeBundle: !1
844
- }), Oe = () => ({
859
+ }), Ne = () => ({
845
860
  shopifyDomain: "",
846
861
  moneyFormat: "${{amount_with_comma_separator}}",
847
862
  locale: "en",
@@ -897,7 +912,7 @@ var $ = ({ price: e }) => ({
897
912
  },
898
913
  shopCustomStyles: "",
899
914
  featureFlags: {}
900
- }), ke = ({ color: e, cornerRadius: t }) => {
915
+ }), Pe = ({ color: e, cornerRadius: t }) => {
901
916
  let n = {
902
917
  id: "123",
903
918
  nanoId: "123",
@@ -1157,14 +1172,14 @@ var $ = ({ price: e }) => ({
1157
1172
  imageCornerRadius: 6
1158
1173
  };
1159
1174
  return e !== void 0 && (n.colors.border = {
1160
- ...De(e),
1175
+ ...je(e),
1161
1176
  alpha: 1
1162
1177
  }), n;
1163
- }, Ae = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1178
+ }, Fe = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1164
1179
  let l = n(null), [u, d] = r(!1), f = n(!1);
1165
1180
  e(() => {
1166
1181
  l.current && !u && (async () => {
1167
- await ye(c ?? window), d(!0);
1182
+ await xe(c ?? window), d(!0);
1168
1183
  })();
1169
1184
  }, [u, c]), e(() => {
1170
1185
  let e = l.current;
@@ -1185,8 +1200,8 @@ var $ = ({ price: e }) => ({
1185
1200
  e.removeEventListener("kaching-bundles-block-loaded", t), e.removeEventListener("variants-changed", t);
1186
1201
  };
1187
1202
  }, [u, s]);
1188
- let p = t ? Me(t, a) : o ? Ne(o) : null;
1189
- return je(() => {
1203
+ let p = t ? Le(t, a) : o ? Re(o) : null;
1204
+ return Ie(() => {
1190
1205
  let e = l.current;
1191
1206
  if (e && p) for (let [t, n] of Object.entries(p.jsonAttributes)) e.getAttribute(t) !== n && e.setAttribute(t, n);
1192
1207
  }), p ? /* @__PURE__ */ i("kaching-bundles-block", {
@@ -1195,7 +1210,7 @@ var $ = ({ price: e }) => ({
1195
1210
  ...p.jsonAttributes,
1196
1211
  "current-variant-id": p.currentVariantId
1197
1212
  }) : null;
1198
- }, je = typeof window > "u" ? e : t, Me = ({ config: e, dealBlock: t, product: n, otherProducts: r, mediaImages: i, collectionBreaksProducts: a, translations: o }, s) => ({
1213
+ }, Ie = typeof window > "u" ? e : t, Le = ({ config: e, dealBlock: t, product: n, otherProducts: r, mediaImages: i, collectionBreaksProducts: a, translations: o }, s) => ({
1199
1214
  dealBlockId: t.id,
1200
1215
  currentVariantId: s ? s.split("/").pop() : String(n.variants[0].id),
1201
1216
  jsonAttributes: {
@@ -1207,8 +1222,8 @@ var $ = ({ price: e }) => ({
1207
1222
  "collection-breaks-products": JSON.stringify(a),
1208
1223
  translations: JSON.stringify(o)
1209
1224
  }
1210
- }), Ne = ({ cornerRadius: e, color: t, price: n }) => {
1211
- let r = $({ price: n }), i = Oe(), a = ke({
1225
+ }), Re = ({ cornerRadius: e, color: t, price: n }) => {
1226
+ let r = Me({ price: n }), i = Ne(), a = Pe({
1212
1227
  color: t,
1213
1228
  cornerRadius: e
1214
1229
  });
@@ -1226,4 +1241,4 @@ var $ = ({ price: e }) => ({
1226
1241
  }
1227
1242
  };
1228
1243
  };
1229
- export { Ae as KachingBundle, ge as fetchKachingBundlesData };
1244
+ 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.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/kachingappz/bundles.git",