@kachingappz/bundles-js 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,7 @@ Without a bundler, load the script from a CDN instead:
42
42
  | `storefront-token` | Yes | Shopify Storefront API access token |
43
43
  | `product-id` | Yes | Shopify product ID |
44
44
  | `deal-block-id` | No | Specific deal block ID to display |
45
+ | `ab-test-variant-id` | No | A/B test variant of that deal block to display. Without it, a deal with a running A/B test shows its first variant |
45
46
  | `selected-variant-id` | No | Currently selected variant ID (plain ID or full GID) |
46
47
  | `country` | No | Country code for localization (e.g. `US`) |
47
48
  | `language` | No | Language code for localization (e.g. `EN`) |
@@ -124,6 +125,7 @@ useEffect(() => {
124
125
  {
125
126
  productId: "gid://shopify/Product/123456789",
126
127
  dealBlockId: "abc123", // optional - specify which deal block to display
128
+ abTestVariantId: "def456", // optional - specify which A/B test variant of it to display
127
129
  country: "US", // optional
128
130
  language: "EN", // optional
129
131
  },
@@ -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=[...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})({});
237
+ `,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},T=e=>[...E(e),...D(e),...O(e),...k(e),...A(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),E=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),D=e=>e.dealBars.flatMap(e=>e.dealBarType===f.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),O=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),k=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),A=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),ee=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],te=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},ne=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],re=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ie=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),ae=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},oe=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),se=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],ce=e=>{let t=[...le(e),...ue(e),...de(e),...j(e),...M(e),...N(e),...P(e),...F(e)];return Array.from(new Set(t.filter(e=>e!=null)))},le=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),ue=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),de=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],j=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),M=e=>e.dealBars.filter(e=>e.dealBarType===f.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),N=e=>e.dealBars.filter(e=>e.dealBarType===f.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...e.selectedProducts?.map(e=>e.id)??[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),P=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),F=e=>e.dealBars.filter(e=>e.dealBarType===f.Sku).flatMap(({productGID:e})=>e?[e]:[]),I=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},L=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new I({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new I({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},R=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),L(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},z=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},B=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await p(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await p(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await h(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0});return o=o.filter(e=>e.availableForSale),o},V=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`,"system.gifts_required_alert":`Please choose your free gifts`},r=e?H(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},H=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=U(e);return n.find(e=>U(e.locale)===r)?.translations},U=e=>e.toLowerCase().replace(/_/g,`-`),fe=`2026-07`,W=async(e,{productId:t,dealBlockId:n,abTestVariantId:r,country:i=void 0,language:a=void 0})=>{try{let o=[Number(t.split(`/`).pop())],s=new pe(e);i||=s.i18n?.country,a||=s.i18n?.language;let c=await S(s,{language:a,country:i,useExternalMetafieldNamespace:!0});s.shopifyDomain=c.shopifyDomain;let u=c.storefrontAccessToken?new R(c.shopifyDomain,c.storefrontAccessToken):s,[d,f]=await Promise.all([h(u,{country:i,language:a,productIds:o,useExternalMetafieldNamespace:!0}),l(u,{useExternalMetafieldNamespace:!0,useMetaobjects:c.featureFlags.storefront_metaobjects})]),p=d[0];if(!p)return null;let m=z(f,p),g=n?m.filter(e=>e.id===n||e.nanoId===n):m,_=(r?g.find(e=>e.abTestVariantId===r):void 0)??g[0]??m[0];if(!_)return null;let v=T(_),y=ce(_),[b,x,C,E]=await Promise.all([h(u,{country:i,language:a,productIds:y,useExternalMetafieldNamespace:!0}),w(u,v,300),B(u,_,{country:i,language:a}),V({language:a,dealBlockId:_.id})]);return{product:p,dealBlock:_,config:c,otherProducts:b,mediaImages:x,collectionBreaksProducts:C??[],translations:E}}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,abTestVariantId:this.getAttribute(`ab-test-variant-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
@@ -412,9 +412,10 @@ declare type DefaultSortOption = "relevance" | "newest-first" | "price-low-to-hi
412
412
 
413
413
  declare type DiscountType = "default" | "percentage" | "amount" | "specific";
414
414
 
415
- export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, country, language, }: {
415
+ export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, abTestVariantId, country, language, }: {
416
416
  productId: string;
417
417
  dealBlockId?: string;
418
+ abTestVariantId?: string;
418
419
  country?: string;
419
420
  language?: string;
420
421
  }) => Promise<KachingBundlesData | null>;
@@ -504,6 +505,8 @@ declare interface GlobalConfig {
504
505
  "system.select_variant_alert"?: string;
505
506
  "system.select_variant_placeholder"?: string;
506
507
  "system.personalisation_required_alert"?: string;
508
+ "system.gifts_required_alert"?: string;
509
+ "system.deal_page_start_your_box"?: string;
507
510
  "system.deal_page_adding_to_cart"?: string;
508
511
  "system.deal_page_add_to_cart_failed"?: string;
509
512
  "system.deal_page_total"?: string;
@@ -524,12 +527,10 @@ declare interface GlobalConfig {
524
527
  "system.deal_page_remove_one"?: string;
525
528
  "system.deal_page_box_full"?: string;
526
529
  "system.deal_page_sold_out"?: string;
527
- "system.deal_page_start_your_box"?: string;
528
530
  "system.deal_page_not_a_box_size"?: string;
529
531
  "system.deal_page_full_price_for_now"?: string;
530
532
  "system.deal_page_percentage_unlocked"?: string;
531
533
  "system.deal_page_box_of"?: string;
532
- "system.deal_page_track_box_full"?: string;
533
534
  "system.deal_page_nudge_start_percentage_one"?: string;
534
535
  "system.deal_page_nudge_start_percentage_other"?: string;
535
536
  "system.deal_page_nudge_start_percentage_few"?: string;
@@ -604,7 +605,6 @@ declare interface GlobalConfig {
604
605
  "system.deal_page_your_gifts_row_other"?: string;
605
606
  "system.deal_page_your_gifts_row_few"?: string;
606
607
  "system.deal_page_your_gifts_row_many"?: string;
607
- "system.deal_page_free"?: string;
608
608
  "system.deal_page_gift_count_one"?: string;
609
609
  "system.deal_page_gift_count_other"?: string;
610
610
  "system.deal_page_gift_count_few"?: string;
@@ -643,7 +643,6 @@ declare interface GlobalConfig {
643
643
  cart_interceptor_dedupe_disabled?: boolean;
644
644
  debug_cart_add?: boolean;
645
645
  disable_nested_cart_lines?: boolean;
646
- early_xhr_wrapper?: boolean;
647
646
  hide_missing_variants?: boolean;
648
647
  initialize_with_form_variant?: boolean;
649
648
  intercept_cart_request?: boolean;
@@ -658,7 +657,6 @@ declare interface GlobalConfig {
658
657
  price_rounding_v2?: boolean;
659
658
  propagate_line_properties?: boolean;
660
659
  propagate_picker_option_changes?: boolean;
661
- reinitialize_morphed_placeholders?: boolean;
662
660
  remove_variant_change_delay?: boolean;
663
661
  rever_non_returnable?: boolean;
664
662
  show_single_variant_name?: boolean;
@@ -666,6 +664,7 @@ declare interface GlobalConfig {
666
664
  split_quantity_break_items?: boolean;
667
665
  storefront_metaobjects?: boolean;
668
666
  pos_extension?: boolean;
667
+ variant_gallery_switch?: boolean;
669
668
  variant_images?: boolean;
670
669
  widget_scroll_guard?: boolean;
671
670
  };
@@ -784,8 +783,10 @@ declare type MultipleGiftsSelector = {
784
783
  maxQuantity: number;
785
784
  showPrice: boolean;
786
785
  showProductPhotos?: boolean;
786
+ preselected?: boolean;
787
787
  includeInCompareAt?: boolean;
788
788
  applyOnlyForSubscriptions: boolean;
789
+ required?: boolean;
789
790
  };
790
791
 
791
792
  declare type PriceRoundingPrecision = ".99" | ".95" | ".90" | ".x9" | ".x0" | ".00";
@@ -991,6 +992,9 @@ declare type SimpleBadge = BaseBadge & {
991
992
 
992
993
  declare interface SkuDealBar extends BaseDealBar, ShowAsSoldOutFeature {
993
994
  dealBarType: DealBarType.Sku;
995
+ quantity?: number;
996
+ discountType?: DiscountType;
997
+ discountValue?: string | number;
994
998
  productGID: string | null;
995
999
  variantGIDs?: string[] | null;
996
1000
  }
@@ -1114,6 +1118,7 @@ declare interface Variant {
1114
1118
  compareAtPrice: number | null;
1115
1119
  options: string[];
1116
1120
  imageId: number | null;
1121
+ featuredMediaId?: number | null;
1117
1122
  image: string | null;
1118
1123
  sellingPlans: {
1119
1124
  id: number;
package/dist/index.js CHANGED
@@ -633,7 +633,8 @@ var d = /* @__PURE__ */ function(e) {
633
633
  "system.price": "Price:",
634
634
  "system.letters_only": "Only letters are allowed.",
635
635
  "system.numbers_only": "Only numbers are allowed.",
636
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
636
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
637
+ "system.gifts_required_alert": "Please choose your free gifts"
637
638
  }, r = e ? Q(e) : void 0;
638
639
  return {
639
640
  ...n,
@@ -652,53 +653,53 @@ var d = /* @__PURE__ */ function(e) {
652
653
  }
653
654
  let r = $(e);
654
655
  return n.find((e) => $(e.locale) === r)?.translations;
655
- }, $ = (e) => e.toLowerCase().replace(/_/g, "-"), te = "2026-07", ne = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
656
+ }, $ = (e) => e.toLowerCase().replace(/_/g, "-"), te = "2026-07", ne = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
656
657
  try {
657
- let a = [Number(t.split("/").pop())], o = new re(e);
658
- r ||= o.i18n?.country, i ||= o.i18n?.language;
659
- let s = await x(o, {
660
- language: i,
661
- country: r,
658
+ let o = [Number(t.split("/").pop())], s = new re(e);
659
+ i ||= s.i18n?.country, a ||= s.i18n?.language;
660
+ let l = await x(s, {
661
+ language: a,
662
+ country: i,
662
663
  useExternalMetafieldNamespace: !0
663
664
  });
664
- o.shopifyDomain = s.shopifyDomain;
665
- let l = s.storefrontAccessToken ? new J(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
666
- country: r,
667
- language: i,
668
- productIds: a,
665
+ s.shopifyDomain = l.shopifyDomain;
666
+ let u = l.storefrontAccessToken ? new J(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
667
+ country: i,
668
+ language: a,
669
+ productIds: o,
669
670
  useExternalMetafieldNamespace: !0
670
- }), c(l, {
671
+ }), c(u, {
671
672
  useExternalMetafieldNamespace: !0,
672
- useMetaobjects: s.featureFlags.storefront_metaobjects
673
- })]), f = u[0];
674
- if (!f) return null;
675
- let p = Y(d, f), h;
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), _ = L(h), [v, y, b, S] = await Promise.all([
678
- m(l, {
679
- country: r,
680
- language: i,
681
- productIds: _,
673
+ useMetaobjects: l.featureFlags.storefront_metaobjects
674
+ })]), p = d[0];
675
+ if (!p) return null;
676
+ let h = Y(f, p), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
677
+ if (!_) return null;
678
+ let v = w(_), y = L(_), [b, S, T, E] = await Promise.all([
679
+ m(u, {
680
+ country: i,
681
+ language: a,
682
+ productIds: y,
682
683
  useExternalMetafieldNamespace: !0
683
684
  }),
684
- C(l, g, 300),
685
- X(l, h, {
686
- country: r,
687
- language: i
685
+ C(u, v, 300),
686
+ X(u, _, {
687
+ country: i,
688
+ language: a
688
689
  }),
689
690
  Z({
690
- language: i,
691
- dealBlockId: h.id
691
+ language: a,
692
+ dealBlockId: _.id
692
693
  })
693
694
  ]);
694
695
  return {
695
- product: f,
696
- dealBlock: h,
697
- config: s,
698
- otherProducts: v,
699
- mediaImages: y,
700
- collectionBreaksProducts: b ?? [],
701
- translations: S
696
+ product: p,
697
+ dealBlock: _,
698
+ config: l,
699
+ otherProducts: b,
700
+ mediaImages: S,
701
+ collectionBreaksProducts: T ?? [],
702
+ translations: E
702
703
  };
703
704
  } catch (e) {
704
705
  return console.error(e), null;
@@ -412,9 +412,10 @@ declare type DefaultSortOption = "relevance" | "newest-first" | "price-low-to-hi
412
412
 
413
413
  declare type DiscountType = "default" | "percentage" | "amount" | "specific";
414
414
 
415
- export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, country, language, }: {
415
+ export declare const fetchKachingBundlesData: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, abTestVariantId, country, language, }: {
416
416
  productId: string;
417
417
  dealBlockId?: string;
418
+ abTestVariantId?: string;
418
419
  country?: string;
419
420
  language?: string;
420
421
  }) => Promise<KachingBundlesData | null>;
@@ -504,6 +505,8 @@ declare interface GlobalConfig {
504
505
  "system.select_variant_alert"?: string;
505
506
  "system.select_variant_placeholder"?: string;
506
507
  "system.personalisation_required_alert"?: string;
508
+ "system.gifts_required_alert"?: string;
509
+ "system.deal_page_start_your_box"?: string;
507
510
  "system.deal_page_adding_to_cart"?: string;
508
511
  "system.deal_page_add_to_cart_failed"?: string;
509
512
  "system.deal_page_total"?: string;
@@ -524,12 +527,10 @@ declare interface GlobalConfig {
524
527
  "system.deal_page_remove_one"?: string;
525
528
  "system.deal_page_box_full"?: string;
526
529
  "system.deal_page_sold_out"?: string;
527
- "system.deal_page_start_your_box"?: string;
528
530
  "system.deal_page_not_a_box_size"?: string;
529
531
  "system.deal_page_full_price_for_now"?: string;
530
532
  "system.deal_page_percentage_unlocked"?: string;
531
533
  "system.deal_page_box_of"?: string;
532
- "system.deal_page_track_box_full"?: string;
533
534
  "system.deal_page_nudge_start_percentage_one"?: string;
534
535
  "system.deal_page_nudge_start_percentage_other"?: string;
535
536
  "system.deal_page_nudge_start_percentage_few"?: string;
@@ -604,7 +605,6 @@ declare interface GlobalConfig {
604
605
  "system.deal_page_your_gifts_row_other"?: string;
605
606
  "system.deal_page_your_gifts_row_few"?: string;
606
607
  "system.deal_page_your_gifts_row_many"?: string;
607
- "system.deal_page_free"?: string;
608
608
  "system.deal_page_gift_count_one"?: string;
609
609
  "system.deal_page_gift_count_other"?: string;
610
610
  "system.deal_page_gift_count_few"?: string;
@@ -643,7 +643,6 @@ declare interface GlobalConfig {
643
643
  cart_interceptor_dedupe_disabled?: boolean;
644
644
  debug_cart_add?: boolean;
645
645
  disable_nested_cart_lines?: boolean;
646
- early_xhr_wrapper?: boolean;
647
646
  hide_missing_variants?: boolean;
648
647
  initialize_with_form_variant?: boolean;
649
648
  intercept_cart_request?: boolean;
@@ -658,7 +657,6 @@ declare interface GlobalConfig {
658
657
  price_rounding_v2?: boolean;
659
658
  propagate_line_properties?: boolean;
660
659
  propagate_picker_option_changes?: boolean;
661
- reinitialize_morphed_placeholders?: boolean;
662
660
  remove_variant_change_delay?: boolean;
663
661
  rever_non_returnable?: boolean;
664
662
  show_single_variant_name?: boolean;
@@ -666,6 +664,7 @@ declare interface GlobalConfig {
666
664
  split_quantity_break_items?: boolean;
667
665
  storefront_metaobjects?: boolean;
668
666
  pos_extension?: boolean;
667
+ variant_gallery_switch?: boolean;
669
668
  variant_images?: boolean;
670
669
  widget_scroll_guard?: boolean;
671
670
  };
@@ -784,8 +783,10 @@ declare type MultipleGiftsSelector = {
784
783
  maxQuantity: number;
785
784
  showPrice: boolean;
786
785
  showProductPhotos?: boolean;
786
+ preselected?: boolean;
787
787
  includeInCompareAt?: boolean;
788
788
  applyOnlyForSubscriptions: boolean;
789
+ required?: boolean;
789
790
  };
790
791
 
791
792
  declare type PriceRoundingPrecision = ".99" | ".95" | ".90" | ".x9" | ".x0" | ".00";
@@ -991,6 +992,9 @@ declare type SimpleBadge = BaseBadge & {
991
992
 
992
993
  declare interface SkuDealBar extends BaseDealBar, ShowAsSoldOutFeature {
993
994
  dealBarType: DealBarType.Sku;
995
+ quantity?: number;
996
+ discountType?: DiscountType;
997
+ discountValue?: string | number;
994
998
  productGID: string | null;
995
999
  variantGIDs?: string[] | null;
996
1000
  }
@@ -1114,6 +1118,7 @@ declare interface Variant {
1114
1118
  compareAtPrice: number | null;
1115
1119
  options: string[];
1116
1120
  imageId: number | null;
1121
+ featuredMediaId?: number | null;
1117
1122
  image: string | null;
1118
1123
  sellingPlans: {
1119
1124
  id: number;
@@ -633,7 +633,8 @@ var d = /* @__PURE__ */ function(e) {
633
633
  "system.price": "Price:",
634
634
  "system.letters_only": "Only letters are allowed.",
635
635
  "system.numbers_only": "Only numbers are allowed.",
636
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
636
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
637
+ "system.gifts_required_alert": "Please choose your free gifts"
637
638
  }, r = e ? H(e) : void 0;
638
639
  return {
639
640
  ...n,
@@ -652,53 +653,53 @@ var d = /* @__PURE__ */ function(e) {
652
653
  }
653
654
  let r = U(e);
654
655
  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
+ }, U = (e) => e.toLowerCase().replace(/_/g, "-"), de = "2026-07", W = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
656
657
  try {
657
- let a = [Number(t.split("/").pop())], o = new fe(e);
658
- r ||= o.i18n?.country, i ||= o.i18n?.language;
659
- let s = await x(o, {
660
- language: i,
661
- country: r,
658
+ let o = [Number(t.split("/").pop())], s = new fe(e);
659
+ i ||= s.i18n?.country, a ||= s.i18n?.language;
660
+ let l = await x(s, {
661
+ language: a,
662
+ country: i,
662
663
  useExternalMetafieldNamespace: !0
663
664
  });
664
- o.shopifyDomain = s.shopifyDomain;
665
- let l = s.storefrontAccessToken ? new R(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
666
- country: r,
667
- language: i,
668
- productIds: a,
665
+ s.shopifyDomain = l.shopifyDomain;
666
+ let u = l.storefrontAccessToken ? new R(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
667
+ country: i,
668
+ language: a,
669
+ productIds: o,
669
670
  useExternalMetafieldNamespace: !0
670
- }), c(l, {
671
+ }), c(u, {
671
672
  useExternalMetafieldNamespace: !0,
672
- useMetaobjects: s.featureFlags.storefront_metaobjects
673
- })]), f = u[0];
674
- if (!f) return null;
675
- let p = z(d, f), h;
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), _ = oe(h), [v, y, b, S] = await Promise.all([
678
- m(l, {
679
- country: r,
680
- language: i,
681
- productIds: _,
673
+ useMetaobjects: l.featureFlags.storefront_metaobjects
674
+ })]), p = d[0];
675
+ if (!p) return null;
676
+ let h = z(f, p), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
677
+ if (!_) return null;
678
+ let v = w(_), y = oe(_), [b, S, T, E] = await Promise.all([
679
+ m(u, {
680
+ country: i,
681
+ language: a,
682
+ productIds: y,
682
683
  useExternalMetafieldNamespace: !0
683
684
  }),
684
- C(l, g, 300),
685
- B(l, h, {
686
- country: r,
687
- language: i
685
+ C(u, v, 300),
686
+ B(u, _, {
687
+ country: i,
688
+ language: a
688
689
  }),
689
690
  V({
690
- language: i,
691
- dealBlockId: h.id
691
+ language: a,
692
+ dealBlockId: _.id
692
693
  })
693
694
  ]);
694
695
  return {
695
- product: f,
696
- dealBlock: h,
697
- config: s,
698
- otherProducts: v,
699
- mediaImages: y,
700
- collectionBreaksProducts: b ?? [],
701
- translations: S
696
+ product: p,
697
+ dealBlock: _,
698
+ config: l,
699
+ otherProducts: b,
700
+ mediaImages: S,
701
+ collectionBreaksProducts: T ?? [],
702
+ translations: E
702
703
  };
703
704
  } catch (e) {
704
705
  return console.error(e), null;
@@ -1230,6 +1231,7 @@ var $ = /* @__PURE__ */ function(e) {
1230
1231
  }, {
1231
1232
  productId: r,
1232
1233
  dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1234
+ abTestVariantId: this.getAttribute("ab-test-variant-id") ?? void 0,
1233
1235
  country: this.getAttribute("country")?.toUpperCase() ?? void 0,
1234
1236
  language: this.getAttribute("language")?.toUpperCase() ?? void 0
1235
1237
  }), Y(window)]);
@@ -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]:[],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(`
237
+ `,{variables:{mediaImageIds:t,size:n}})))).flatMap(e=>e.nodes).flatMap(e=>e?.image?[{gid:e.id,url:e.image.url}]:[])},E=e=>[...D(e),...O(e),...k(e),...A(e),...ee(e),...te(e),...ne(e),...re(e),...ie(e),...ae(e),...oe(e),...se(e),...ce(e)].filter(e=>e!=null&&!e.includes(`placeholder`)),D=e=>e.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),O=e=>e.dealBars.flatMap(e=>e.dealBarType===p.Bundle?e.bundleProducts.map(e=>e.mediaImageGID):[]).filter(e=>e!=null),k=e=>e.dealBars.map(({freeGifts:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),A=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(e=>e.mediaImageGID)).filter(e=>e!=null),ee=e=>e.dealBars.map(({upsells:e})=>(e||[]).map(e=>e.mediaImageGID)).reduce((e,t)=>e.concat(t),[]).filter(e=>e!=null),te=e=>e.swatchOptions?e.swatchOptions.reduce((e,t)=>{let n=t.images.map(e=>e.mediaImageGID).filter(e=>e!=null);return[...e,...n]},[]):[],ne=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];let t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},re=e=>e.progressiveGifts?[...e.progressiveGifts.gifts?.map(e=>e.mediaImageGID)||[],e.progressiveGifts.style?.lockedMediaImageGID,e.progressiveGifts.dealBarStyle?.lockedMediaImageGID].filter(e=>e!=null):[],ie=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),ae=e=>e.dealBars.map(e=>e.productPersonalisation?.mediaImageGID).filter(e=>e!=null),oe=e=>{let t=e.dealBars.map(e=>e.highlights?.customIconGID).filter(e=>e!=null),n=e.subscriptions?.highlights?.customIconGID;return n?[...t,n]:t},se=e=>(e.badges||[]).flatMap(e=>e.badgeType===`custom`&&e.imageGID?[e.imageGID]:[]),ce=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],le=e=>{let t=[...ue(e),...j(e),...M(e),...N(e),...P(e),...F(e),...I(e),...L(e)];return Array.from(new Set(t.filter(e=>e!=null)))},ue=e=>e.dealBars.flatMap(({freeGifts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),j=e=>e.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(e=>e.products?e.products.map(e=>e.id):[]):[]).filter(e=>e!=null),M=e=>e.progressiveGiftsEnabled&&e.progressiveGifts?.gifts.map(e=>e.productGID).filter(e=>e!=null)||[],N=e=>e.dealBars.flatMap(({upsells:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null),P=e=>e.dealBars.filter(e=>e.dealBarType===p.Bundle).flatMap(({bundleProducts:e})=>e?e.map(e=>e.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),F=e=>e.dealBars.filter(e=>e.dealBarType===p.MixAndMatch).flatMap(({bundleProducts:e})=>e?e.flatMap(e=>[e.productGID,...e.selectedProducts?.map(e=>e.id)??[]]):[]).filter(e=>e!=null).filter(e=>e!=="default"),I=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),L=e=>e.dealBars.filter(e=>e.dealBarType===p.Sku).flatMap(({productGID:e})=>e?[e]:[]),R=class extends Error{constructor({status:e,operationName:t,graphqlErrors:n}){let r=n.length?`: ${n.join(`; `)}`:``;super(`Storefront API ${t??`query`} failed (HTTP ${e})${r}`),this.name=`StorefrontApiError`,this.status=e,this.operationName=t,this.graphqlErrors=n}},z=async(e,t)=>{let n=await e.text();if(!n)throw Error(`Empty graphql response`);let r;try{r=JSON.parse(n)}catch(n){throw e.ok?n:new R({status:e.status,operationName:t,graphqlErrors:[]})}if(!e.ok||r.data===null||r.data===void 0)throw new R({status:e.status,operationName:t,graphqlErrors:(r.errors??[]).map(({message:e})=>e).filter(Boolean)});return r.data},B=class{constructor(e,t){this.storefrontApiVersion=`2026-07`,this.storefrontAccessToken=t,this.shopifyDomain=e}async query(e,t){let n=t?.variables??{},r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`,i=e.match(/query\s+(\w+)/)?.[1];return i&&(r+=`?operation_name=${i}`),z(await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:n})}),i)}},V=(e,t)=>{let n=[],r=e.filter(e=>e.blockVisibility===`selected-products`);for(let e of r)e.selectedProductIds.map(Number).includes(t.id)&&n.push(e);let i=e.filter(e=>e.blockVisibility===`selected-collections`);for(let e of i)t.collectionIds.some(t=>e.selectedCollectionIds.map(Number).includes(t))&&n.push(e);let a=e.filter(e=>e.blockVisibility===`excluded-products`);for(let e of a)!e.excludedProductIds.map(Number).includes(t.id)&&!(e.excludedCollectionIds||[]).some(e=>t.collectionIds.includes(e))&&n.push(e);let o=e.filter(e=>e.blockVisibility===`all-products`);for(let e of o)n.push(e);return n},H=async(e,t,{country:n,language:r})=>{let i=t.collectionBreaks;if(!t.collectionBreaksEnabled||!i)return;let a;a=i.visibility===`deal-products`?await m(e,{country:n,language:r,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedProductGIDs:(t.selectedProductIds||[]).map(e=>`gid://shopify/Product/${e}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(e=>`gid://shopify/Collection/${e}`)}):await m(e,{country:n,language:r,blockVisibility:i.visibility,excludedProductGIDs:(i.excludedProducts||[]).map(({id:e})=>e),selectedProductGIDs:(i.selectedProducts||[]).map(({id:e})=>e),selectedCollectionGIDs:(i.selectedCollections||[]).map(({id:e})=>e)});let o=await g(e,{country:n,language:r,productIds:a.map(e=>Number(e.split(`/`).pop())),useExternalMetafieldNamespace:!0});return o=o.filter(e=>e.availableForSale),o},U=({language:e,dealBlockId:t})=>{let n={"system.out_of_stock":`There's not enough items in our stock, please select smaller bundle.`,"system.invalid_variant":`Sorry, this is not currently available.`,"system.unavailable_option_value":`Unavailable`,"system.confirm":`Confirm`,"system.cancel":`Cancel`,"system.free":`FREE`,"system.search":`Search`,"system.quantity":`Quantity`,"system.subscription_plan":`Subscription plan`,"system.remove":`Remove`,"system.sort_by":`Sort by`,"system.sort_relevance":`Relevance`,"system.sort_newest_first":`Newest first`,"system.sort_price_low_to_high":`Price: Low → High`,"system.sort_price_high_to_low":`Price: High → Low`,"system.no_results_found":`No results found`,"system.no_results_description":`We can't find any item matching your search.`,"system.clear_search":`Clear search`,"system.no_products_available":`No products available`,"system.original_price":`Original price:`,"system.price":`Price:`,"system.letters_only":`Only letters are allowed.`,"system.numbers_only":`Only numbers are allowed.`,"system.personalisation_required_alert":`Please add personalisation for every item to continue.`,"system.gifts_required_alert":`Please choose your free gifts`},r=e?de(e):void 0;return{...n,...r?.system,...r?.dealBlocks[t]}},de=e=>{if(typeof document>`u`)return;let t=document.querySelector(`script#kaching-bundles-translations`);if(!t?.textContent)return;let n;try{n=JSON.parse(t.textContent)}catch{return}let r=W(e);return n.find(e=>W(e.locale)===r)?.translations},W=e=>e.toLowerCase().replace(/_/g,`-`),fe=`2026-07`,pe=async(e,{productId:t,dealBlockId:n,abTestVariantId:r,country:i=void 0,language:a=void 0})=>{try{let o=[Number(t.split(`/`).pop())],s=new me(e);i||=s.i18n?.country,a||=s.i18n?.language;let c=await C(s,{language:a,country:i,useExternalMetafieldNamespace:!0});s.shopifyDomain=c.shopifyDomain;let l=c.storefrontAccessToken?new B(c.shopifyDomain,c.storefrontAccessToken):s,[d,f]=await Promise.all([g(l,{country:i,language:a,productIds:o,useExternalMetafieldNamespace:!0}),u(l,{useExternalMetafieldNamespace:!0,useMetaobjects:c.featureFlags.storefront_metaobjects})]),p=d[0];if(!p)return null;let m=V(f,p),h=n?m.filter(e=>e.id===n||e.nanoId===n):m,_=(r?h.find(e=>e.abTestVariantId===r):void 0)??h[0]??m[0];if(!_)return null;let v=E(_),y=le(_),[b,x,S,w]=await Promise.all([g(l,{country:i,language:a,productIds:y,useExternalMetafieldNamespace:!0}),T(l,v,300),H(l,_,{country:i,language:a}),U({language:a,dealBlockId:_.id})]);return{product:p,dealBlock:_,config:c,otherProducts:b,mediaImages:x,collectionBreaksProducts:S??[],translations:w}}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
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;
@@ -416,9 +416,10 @@ declare type DiscountType = "default" | "percentage" | "amount" | "specific";
416
416
 
417
417
  export declare const fetchKachingBundlesData: (...args: Parameters<typeof fetchKachingBundlesData_2>) => Promise<KachingBundlesData | null>;
418
418
 
419
- declare const fetchKachingBundlesData_2: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, country, language, }: {
419
+ declare const fetchKachingBundlesData_2: (storefront: HydrogenV2Storefront | HydrogenStorefrontClient | ReactHydrogenStorefront | ShopifyStorefrontApiClient | StorefrontCredentials, { productId, dealBlockId, abTestVariantId, country, language, }: {
420
420
  productId: string;
421
421
  dealBlockId?: string;
422
+ abTestVariantId?: string;
422
423
  country?: string;
423
424
  language?: string;
424
425
  }) => Promise<KachingBundlesData_2 | null>;
@@ -508,6 +509,8 @@ declare interface GlobalConfig {
508
509
  "system.select_variant_alert"?: string;
509
510
  "system.select_variant_placeholder"?: string;
510
511
  "system.personalisation_required_alert"?: string;
512
+ "system.gifts_required_alert"?: string;
513
+ "system.deal_page_start_your_box"?: string;
511
514
  "system.deal_page_adding_to_cart"?: string;
512
515
  "system.deal_page_add_to_cart_failed"?: string;
513
516
  "system.deal_page_total"?: string;
@@ -528,12 +531,10 @@ declare interface GlobalConfig {
528
531
  "system.deal_page_remove_one"?: string;
529
532
  "system.deal_page_box_full"?: string;
530
533
  "system.deal_page_sold_out"?: string;
531
- "system.deal_page_start_your_box"?: string;
532
534
  "system.deal_page_not_a_box_size"?: string;
533
535
  "system.deal_page_full_price_for_now"?: string;
534
536
  "system.deal_page_percentage_unlocked"?: string;
535
537
  "system.deal_page_box_of"?: string;
536
- "system.deal_page_track_box_full"?: string;
537
538
  "system.deal_page_nudge_start_percentage_one"?: string;
538
539
  "system.deal_page_nudge_start_percentage_other"?: string;
539
540
  "system.deal_page_nudge_start_percentage_few"?: string;
@@ -608,7 +609,6 @@ declare interface GlobalConfig {
608
609
  "system.deal_page_your_gifts_row_other"?: string;
609
610
  "system.deal_page_your_gifts_row_few"?: string;
610
611
  "system.deal_page_your_gifts_row_many"?: string;
611
- "system.deal_page_free"?: string;
612
612
  "system.deal_page_gift_count_one"?: string;
613
613
  "system.deal_page_gift_count_other"?: string;
614
614
  "system.deal_page_gift_count_few"?: string;
@@ -647,7 +647,6 @@ declare interface GlobalConfig {
647
647
  cart_interceptor_dedupe_disabled?: boolean;
648
648
  debug_cart_add?: boolean;
649
649
  disable_nested_cart_lines?: boolean;
650
- early_xhr_wrapper?: boolean;
651
650
  hide_missing_variants?: boolean;
652
651
  initialize_with_form_variant?: boolean;
653
652
  intercept_cart_request?: boolean;
@@ -662,7 +661,6 @@ declare interface GlobalConfig {
662
661
  price_rounding_v2?: boolean;
663
662
  propagate_line_properties?: boolean;
664
663
  propagate_picker_option_changes?: boolean;
665
- reinitialize_morphed_placeholders?: boolean;
666
664
  remove_variant_change_delay?: boolean;
667
665
  rever_non_returnable?: boolean;
668
666
  show_single_variant_name?: boolean;
@@ -670,6 +668,7 @@ declare interface GlobalConfig {
670
668
  split_quantity_break_items?: boolean;
671
669
  storefront_metaobjects?: boolean;
672
670
  pos_extension?: boolean;
671
+ variant_gallery_switch?: boolean;
673
672
  variant_images?: boolean;
674
673
  widget_scroll_guard?: boolean;
675
674
  };
@@ -811,8 +810,10 @@ declare type MultipleGiftsSelector = {
811
810
  maxQuantity: number;
812
811
  showPrice: boolean;
813
812
  showProductPhotos?: boolean;
813
+ preselected?: boolean;
814
814
  includeInCompareAt?: boolean;
815
815
  applyOnlyForSubscriptions: boolean;
816
+ required?: boolean;
816
817
  };
817
818
 
818
819
  declare type PriceRoundingPrecision = ".99" | ".95" | ".90" | ".x9" | ".x0" | ".00";
@@ -1018,6 +1019,9 @@ declare type SimpleBadge = BaseBadge & {
1018
1019
 
1019
1020
  declare interface SkuDealBar extends BaseDealBar, ShowAsSoldOutFeature {
1020
1021
  dealBarType: DealBarType.Sku;
1022
+ quantity?: number;
1023
+ discountType?: DiscountType;
1024
+ discountValue?: string | number;
1021
1025
  productGID: string | null;
1022
1026
  variantGIDs?: string[] | null;
1023
1027
  }
@@ -1141,6 +1145,7 @@ declare interface Variant {
1141
1145
  compareAtPrice: number | null;
1142
1146
  options: string[];
1143
1147
  imageId: number | null;
1148
+ featuredMediaId?: number | null;
1144
1149
  image: string | null;
1145
1150
  sellingPlans: {
1146
1151
  id: number;
@@ -635,7 +635,8 @@ var g = /* @__PURE__ */ function(e) {
635
635
  "system.price": "Price:",
636
636
  "system.letters_only": "Only letters are allowed.",
637
637
  "system.numbers_only": "Only numbers are allowed.",
638
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
638
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
639
+ "system.gifts_required_alert": "Please choose your free gifts"
639
640
  }, r = e ? me(e) : void 0;
640
641
  return {
641
642
  ...n,
@@ -654,53 +655,53 @@ var g = /* @__PURE__ */ function(e) {
654
655
  }
655
656
  let r = W(e);
656
657
  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
+ }, W = (e) => e.toLowerCase().replace(/_/g, "-"), he = "2026-07", ge = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
658
659
  try {
659
- let a = [Number(t.split("/").pop())], o = new _e(e);
660
- r ||= o.i18n?.country, i ||= o.i18n?.language;
661
- let s = await E(o, {
662
- language: i,
663
- country: r,
660
+ let o = [Number(t.split("/").pop())], s = new _e(e);
661
+ i ||= s.i18n?.country, a ||= s.i18n?.language;
662
+ let c = await E(s, {
663
+ language: a,
664
+ country: i,
664
665
  useExternalMetafieldNamespace: !0
665
666
  });
666
- o.shopifyDomain = s.shopifyDomain;
667
- let c = s.storefrontAccessToken ? new U(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([y(c, {
668
- country: r,
669
- language: i,
670
- productIds: a,
667
+ s.shopifyDomain = c.shopifyDomain;
668
+ let l = c.storefrontAccessToken ? new U(c.shopifyDomain, c.storefrontAccessToken) : s, [u, d] = await Promise.all([y(l, {
669
+ country: i,
670
+ language: a,
671
+ productIds: o,
671
672
  useExternalMetafieldNamespace: !0
672
- }), p(c, {
673
+ }), p(l, {
673
674
  useExternalMetafieldNamespace: !0,
674
- useMetaobjects: s.featureFlags.storefront_metaobjects
675
- })]), d = l[0];
676
- if (!d) return null;
677
- let f = de(u, d), m;
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 = M(m), [_, v, b, x] = await Promise.all([
680
- y(c, {
681
- country: r,
682
- language: i,
683
- productIds: g,
675
+ useMetaobjects: c.featureFlags.storefront_metaobjects
676
+ })]), f = u[0];
677
+ if (!f) return null;
678
+ let m = de(d, f), h = n ? m.filter((e) => e.id === n || e.nanoId === n) : m, g = (r ? h.find((e) => e.abTestVariantId === r) : void 0) ?? h[0] ?? m[0];
679
+ if (!g) return null;
680
+ let _ = k(g), v = M(g), [b, x, S, C] = await Promise.all([
681
+ y(l, {
682
+ country: i,
683
+ language: a,
684
+ productIds: v,
684
685
  useExternalMetafieldNamespace: !0
685
686
  }),
686
- O(c, h, 300),
687
- fe(c, m, {
688
- country: r,
689
- language: i
687
+ O(l, _, 300),
688
+ fe(l, g, {
689
+ country: i,
690
+ language: a
690
691
  }),
691
692
  pe({
692
- language: i,
693
- dealBlockId: m.id
693
+ language: a,
694
+ dealBlockId: g.id
694
695
  })
695
696
  ]);
696
697
  return {
697
- product: d,
698
- dealBlock: m,
699
- config: s,
700
- otherProducts: _,
701
- mediaImages: v,
702
- collectionBreaksProducts: b ?? [],
703
- translations: x
698
+ product: f,
699
+ dealBlock: g,
700
+ config: c,
701
+ otherProducts: b,
702
+ mediaImages: x,
703
+ collectionBreaksProducts: S ?? [],
704
+ translations: C
704
705
  };
705
706
  } catch (e) {
706
707
  return console.error(e), null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kachingappz/bundles-js",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/kachingappz/bundles.git",
@@ -51,7 +51,7 @@
51
51
  ],
52
52
  "devDependencies": {
53
53
  "@kachingappz/bundles-storefront-api": "^0.1.0",
54
- "@kachingappz/bundles-types": "^0.4.3",
54
+ "@kachingappz/bundles-types": "^0.4.8",
55
55
  "@kachingappz/kaching-bundles-block": "^1.0.0",
56
56
  "@microsoft/api-extractor": "^7.57.7",
57
57
  "@testing-library/react": "^16.3.3",