@kachingappz/bundles-js 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -243,6 +243,8 @@ declare type DealBarProgressiveGiftStyle = {
243
243
  labelBackgroundColor: Color;
244
244
  labelTextColor: Color;
245
245
  labelTextSize: number;
246
+ backgroundColor?: Color | null;
247
+ selectedBackgroundColor?: Color | null;
246
248
  textColor: Color;
247
249
  selectedTextColor: Color;
248
250
  textSize: number;
@@ -243,6 +243,8 @@ declare type DealBarProgressiveGiftStyle = {
243
243
  labelBackgroundColor: Color;
244
244
  labelTextColor: Color;
245
245
  labelTextSize: number;
246
+ backgroundColor?: Color | null;
247
+ selectedBackgroundColor?: Color | null;
246
248
  textColor: Color;
247
249
  selectedTextColor: Color;
248
250
  textSize: number;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),S=require("react"),F=(e,t)=>{const a=[],l=e.filter(n=>n.blockVisibility==="selected-products");for(const n of l)n.selectedProductIds.map(Number).includes(t.id)&&a.push(n);const r=e.filter(n=>n.blockVisibility==="selected-collections");for(const n of r)t.collectionIds.some(m=>n.selectedCollectionIds.map(Number).includes(m))&&a.push(n);const i=e.filter(n=>n.blockVisibility==="excluded-products");for(const n of i)!n.excludedProductIds.map(Number).includes(t.id)&&!(n.excludedCollectionIds||[]).some(m=>t.collectionIds.includes(m))&&a.push(n);const o=e.filter(n=>n.blockVisibility==="all-products");for(const n of o)a.push(n);return a},R=(e,{language:t,country:a})=>{var g,y;const l=L(t,a),r=new Intl.NumberFormat(l,{style:"currency",currency:e,currencyDisplay:"narrowSymbol"}).formatToParts(123456789e-2),i=(g=r.find(p=>p.type==="decimal"))==null?void 0:g.value,o=J((y=r.find(p=>p.type==="group"))==null?void 0:y.value),n=r.some(p=>p.type==="fraction"),m=z(o,i,n),c=r.findIndex(C),d=r.findLastIndex(C);return[...r.slice(0,c).map(E),m,...r.slice(d+1).map(E)].join("")},E=e=>U(e.value),U=e=>e.replace(/\s/g," "),C=e=>e.type==="integer"||e.type==="group"||e.type==="decimal"||e.type==="fraction",L=(e,t)=>e&&t?`${e}-${t.toUpperCase()}`:e||(t?t.toUpperCase():"en"),J=e=>e===void 0?void 0:U(e).replace(/’/g,"'"),z=(e,t,a)=>t===","&&e==="."?a?"{{amount_with_comma_separator}}":"{{amount_no_decimals_with_comma_separator}}":t===","&&e===" "?a?"{{amount_with_space_separator}}":"{{amount_no_decimals_with_space_separator}}":t==="."&&e===" "?"{{amount_with_period_and_space_separator}}":t==="."&&e==="'"?"{{amount_with_apostrophe_separator}}":a?"{{amount}}":"{{amount_no_decimals}}",$=({country:e,language:t})=>{const a=[];return e&&a.push(`country: ${e}`),t&&a.push(`language: ${t}`),a.length>0?`@inContext(${a.join(", ")})`:""},Q=async(e,{useExternalMetafieldNamespace:t,useMetaobjects:a})=>a?K(e):H(e),H=async(e,t)=>{var l;const a=(l=(await e.query(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react/jsx-runtime"),S=require("react"),F=(e,t)=>{const a=[],n=e.filter(l=>l.blockVisibility==="selected-products");for(const l of n)l.selectedProductIds.map(Number).includes(t.id)&&a.push(l);const r=e.filter(l=>l.blockVisibility==="selected-collections");for(const l of r)t.collectionIds.some(m=>l.selectedCollectionIds.map(Number).includes(m))&&a.push(l);const i=e.filter(l=>l.blockVisibility==="excluded-products");for(const l of i)!l.excludedProductIds.map(Number).includes(t.id)&&!(l.excludedCollectionIds||[]).some(m=>t.collectionIds.includes(m))&&a.push(l);const o=e.filter(l=>l.blockVisibility==="all-products");for(const l of o)a.push(l);return a},R=(e,{language:t,country:a})=>{var f,g;const n=L(t,a),r=new Intl.NumberFormat(n,{style:"currency",currency:e,currencyDisplay:"narrowSymbol"}).formatToParts(123456789e-2),i=(f=r.find(y=>y.type==="decimal"))==null?void 0:f.value,o=J((g=r.find(y=>y.type==="group"))==null?void 0:g.value),l=r.some(y=>y.type==="fraction"),m=z(o,i,l),d=r.findIndex(E),c=r.findLastIndex(E);return[...r.slice(0,d).map(G),m,...r.slice(c+1).map(G)].join("")},G=e=>O(e.value),O=e=>e.replace(/\s/g," "),E=e=>e.type==="integer"||e.type==="group"||e.type==="decimal"||e.type==="fraction",L=(e,t)=>e&&t?`${e}-${t.toUpperCase()}`:e||(t?t.toUpperCase():"en"),J=e=>e===void 0?void 0:O(e).replace(/’/g,"'"),z=(e,t,a)=>t===","&&e==="."?a?"{{amount_with_comma_separator}}":"{{amount_no_decimals_with_comma_separator}}":t===","&&e===" "?a?"{{amount_with_space_separator}}":"{{amount_no_decimals_with_space_separator}}":t==="."&&e===" "?"{{amount_with_period_and_space_separator}}":t==="."&&e==="'"?"{{amount_with_apostrophe_separator}}":a?"{{amount}}":"{{amount_no_decimals}}",$=({country:e,language:t})=>{const a=[];return e&&a.push(`country: ${e}`),t&&a.push(`language: ${t}`),a.length>0?`@inContext(${a.join(", ")})`:""},Q=async(e,{useExternalMetafieldNamespace:t,useMetaobjects:a})=>a?K(e):H(e),H=async(e,t)=>{var n;const a=(n=(await e.query(`
2
2
  query FetchDealBlocks($metafieldNamespace: String!) {
3
3
  shop {
4
4
  metafield(namespace: $metafieldNamespace, key: "deal_blocks") {
@@ -6,7 +6,7 @@
6
6
  }
7
7
  }
8
8
  }
9
- `,{variables:{metafieldNamespace:"app--2935586817--kaching_bundles"}})).shop.metafield)==null?void 0:l.value;return a?JSON.parse(a):[]},K=async(e,t)=>{const a="app--2935586817--deal_block",l=[];let r=null;for(;;){const i=await e.query(`
9
+ `,{variables:{metafieldNamespace:"app--2935586817--kaching_bundles"}})).shop.metafield)==null?void 0:n.value;return a?JSON.parse(a):[]},K=async(e,t)=>{const a="app--2935586817--deal_block",n=[];let r=null;for(;;){const i=await e.query(`
10
10
  query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
11
11
  metaobjects(type: $type, first: 250, after: $cursor) {
12
12
  nodes {
@@ -21,7 +21,7 @@
21
21
  }
22
22
  }
23
23
  }
24
- `,{variables:{type:a,cursor:r}});for(const o of i.metaobjects.nodes){const n=o.fields.find(m=>m.key==="settings");n!=null&&n.value&&l.push(JSON.parse(n.value))}if(!i.metaobjects.pageInfo.hasNextPage)break;r=i.metaobjects.pageInfo.endCursor}return l},M=async(e,{country:t,language:a,blockVisibility:l,excludedProductGIDs:r,selectedProductGIDs:i,selectedCollectionGIDs:o,limit:n=1e3})=>{switch(l){case"selected-products":return i.slice(0,n);case"all-products":case"excluded-products":{const m=$({country:t,language:a});let c=[],d=null;for(;c.length<n;){const g=Math.min(n-c.length,250),y=await e.query(`
24
+ `,{variables:{type:a,cursor:r}});for(const o of i.metaobjects.nodes){const l=o.fields.find(m=>m.key==="settings");l!=null&&l.value&&n.push(JSON.parse(l.value))}if(!i.metaobjects.pageInfo.hasNextPage)break;r=i.metaobjects.pageInfo.endCursor}return n},C=async(e,{country:t,language:a,blockVisibility:n,excludedProductGIDs:r,selectedProductGIDs:i,selectedCollectionGIDs:o,limit:l=1e3})=>{switch(n){case"selected-products":return i.slice(0,l);case"all-products":case"excluded-products":{const m=$({country:t,language:a});let d=[],c=null;for(;d.length<l;){const f=Math.min(l-d.length,250),g=await e.query(`
25
25
  query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
26
26
  products(first: $limit, after: $cursor) {
27
27
  nodes {
@@ -33,7 +33,7 @@
33
33
  }
34
34
  }
35
35
  }
36
- `,{variables:{limit:g,cursor:d}});if(c.push(...y.products.nodes.map(p=>p.id)),!y.products.pageInfo.hasNextPage)break;d=y.products.pageInfo.endCursor}if(l==="excluded-products"){const g=new Set(r);c=c.filter(y=>!g.has(y))}return c}case"selected-collections":{const m=$({country:t,language:a}),c=(await e.query(`
36
+ `,{variables:{limit:f,cursor:c}});if(d.push(...g.products.nodes.map(y=>y.id)),!g.products.pageInfo.hasNextPage)break;c=g.products.pageInfo.endCursor}if(n==="excluded-products"){const f=new Set(r);d=d.filter(g=>!f.has(g))}return d}case"selected-collections":{const m=$({country:t,language:a}),d=(await e.query(`
37
37
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
38
38
  nodes(ids: $collectionGIDs) {
39
39
  ... on Collection {
@@ -45,7 +45,7 @@
45
45
  }
46
46
  }
47
47
  }
48
- `,{variables:{collectionGIDs:o,limit:Math.min(n,250)}})).nodes.filter(d=>d!==null).flatMap(d=>d.products.nodes.map(g=>g.id));return Array.from(new Set(c)).slice(0,n)}}},V=`
48
+ `,{variables:{collectionGIDs:o,limit:Math.min(l,250)}})).nodes.filter(c=>c!==null).flatMap(c=>c.products.nodes.map(f=>f.id));return Array.from(new Set(d)).slice(0,l)}}},V=`
49
49
  id
50
50
  availableForSale
51
51
  price {
@@ -88,8 +88,8 @@
88
88
  }
89
89
  }
90
90
  quantityAvailable @include(if: $includeAvailableQuantity)
91
- `,A=async(e,{country:t,language:a,productIds:l,includeSellingPlans:r=!0,includeAvailableQuantity:i=!0,useExternalMetafieldNamespace:o=!1,batchSize:n=250,onBatchError:m})=>{if(!l.length)return[];const c=l.map(u=>typeof u=="string"&&u.startsWith("gid://")?u:`gid://shopify/Product/${u}`),d=$({country:t,language:a}),g=`
92
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${d} {
91
+ `,A=async(e,{country:t,language:a,productIds:n,includeSellingPlans:r=!0,includeAvailableQuantity:i=!0,useExternalMetafieldNamespace:o=!1,batchSize:l=250,onBatchError:m})=>{if(!n.length)return[];const d=n.map(u=>typeof u=="string"&&u.startsWith("gid://")?u:`gid://shopify/Product/${u}`),c=$({country:t,language:a}),f=`
92
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${c} {
93
93
  shop {
94
94
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
95
95
  value
@@ -175,8 +175,8 @@
175
175
  }
176
176
  }
177
177
  }
178
- `,y=o?"app--2935586817--kaching_bundles":"$app:kaching_bundles",p=[],h=Math.min(n,250);for(let u=0;u<c.length;u+=h)p.push(c.slice(u,u+h));let s=1;const f=async u=>{const v=await e.query(g,{variables:{productGIDs:u,includeSellingPlans:r,includeAvailableQuantity:i,metafieldNamespace:y}});return v.shop.currencyRateConstant&&(s=JSON.parse(v.shop.currencyRateConstant.value).amount/1e6),v};let b;if(m){const u=await Promise.allSettled(p.map(f));for(const v of u)v.status==="rejected"&&m(v.reason instanceof Error?v.reason:new Error(String(v.reason)));b=u.filter(v=>v.status==="fulfilled").flatMap(v=>v.value.nodes)}else b=(await Promise.all(p.map(f))).flatMap(u=>u.nodes);const _=b.filter(u=>u!=null);if(m){const u=await Promise.allSettled(_.map(async P=>{const I=await T(e,P,{includeSellingPlans:r,includeAvailableQuantity:i},d);return q(I,e.shopifyDomain,s)})),v=[];for(const P of u)P.status==="fulfilled"?v.push(P.value):m(P.reason instanceof Error?P.reason:new Error(String(P.reason)));return v}return(await Promise.all(_.map(u=>T(e,u,{includeSellingPlans:r,includeAvailableQuantity:i},d)))).map(u=>q(u,e.shopifyDomain,s))},T=async(e,t,a,l="")=>{if(t.variants.nodes.length<250)return t;const r=new Set,i=[],o=[],n=async m=>{let c=!0,d=null;for(;c;){const g=await e.query(`
179
- query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${l} {
178
+ `,g=o?"app--2935586817--kaching_bundles":"$app:kaching_bundles",y=[],h=Math.min(l,250);for(let u=0;u<d.length;u+=h)y.push(d.slice(u,u+h));let s=1;const p=async u=>{const v=await e.query(f,{variables:{productGIDs:u,includeSellingPlans:r,includeAvailableQuantity:i,metafieldNamespace:g}});return v.shop.currencyRateConstant&&(s=JSON.parse(v.shop.currencyRateConstant.value).amount/1e6),v};let b;if(m){const u=await Promise.allSettled(y.map(p));for(const v of u)v.status==="rejected"&&m(v.reason instanceof Error?v.reason:new Error(String(v.reason)));b=u.filter(v=>v.status==="fulfilled").flatMap(v=>v.value.nodes)}else b=(await Promise.all(y.map(p))).flatMap(u=>u.nodes);const _=b.filter(u=>u!=null);if(m){const u=await Promise.allSettled(_.map(async I=>{const P=await M(e,I,{includeSellingPlans:r,includeAvailableQuantity:i},c);return T(P,e.shopifyDomain,s)})),v=[];for(const I of u)I.status==="fulfilled"?v.push(I.value):m(I.reason instanceof Error?I.reason:new Error(String(I.reason)));return v}return(await Promise.all(_.map(u=>M(e,u,{includeSellingPlans:r,includeAvailableQuantity:i},c)))).map(u=>T(u,e.shopifyDomain,s))},M=async(e,t,a,n="")=>{if(t.variants.nodes.length<250)return t;const r=new Set,i=[],o=[],l=async m=>{let d=!0,c=null;for(;d;){const f=await e.query(`
179
+ query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${n} {
180
180
  product(id: $productGID) {
181
181
  variants(first: 250, after: $cursor, reverse: $reverse) {
182
182
  nodes {
@@ -189,7 +189,7 @@
189
189
  }
190
190
  }
191
191
  }
192
- `,{variables:{productGID:t.id,cursor:d,reverse:m,...a}}),{nodes:y,pageInfo:p}=g.product.variants;for(const h of y){if(r.has(h.id)){c=!1;break}r.add(h.id),m?o.push(h):i.push(h)}p.hasNextPage||(c=!1),d=p.endCursor}};return await Promise.all([n(!1),n(!0)]),t.variants.nodes=[...i,...o.reverse()],t},q=(e,t,a)=>{var c,d,g,y,p,h;const l=e.variants.nodes.map(({unitPriceMeasurement:s,...f})=>{var b,_;return{id:Number(f.id.split("/").pop()),availableForSale:f.availableForSale,price:Math.round(Number(f.price.amount)*100),compareAtPrice:f.compareAtPrice?Math.round(Number(f.compareAtPrice.amount)*100):null,options:f.selectedOptions.map(u=>u.value),imageId:f.image?Number(f.image.id.split("/").pop()):null,image:((b=f.image)==null?void 0:b.url)||null,sellingPlans:((_=f.sellingPlanAllocations)==null?void 0:_.nodes.map(u=>({id:Number(u.sellingPlan.id.split("/").pop()),price:u.priceAdjustments.length>0?Math.round(Number(u.priceAdjustments[0].price.amount)*100):Math.round(Number(f.price.amount)*100),compareAtPrice:u.priceAdjustments.length>0?Math.round(Number(u.priceAdjustments[0].compareAtPrice.amount)*100):Math.round(Number(f.price.amount)*100),perDeliveryPrice:u.priceAdjustments.length>0?Math.round(Number(u.priceAdjustments[0].perDeliveryPrice.amount)*100):Math.round(Number(f.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:f.quantityAvailable??null,unitPriceMeasurement:s!=null&&s.quantityUnit&&(s!=null&&s.referenceUnit)?{quantityValue:s.quantityValue,quantityUnit:s.quantityUnit.toLowerCase(),referenceValue:s.referenceValue,referenceUnit:s.referenceUnit.toLowerCase()}:null}}),r=e.options.map((s,f)=>{const b=s.optionValues.map(_=>{var u,v,P,I;return{id:Number(_.id.split("/").pop()),defaultName:_.name,name:_.name,swatch:{color:((u=_.swatch)==null?void 0:u.color)||null,image:((I=(P=(v=_.swatch)==null?void 0:v.image)==null?void 0:P.previewImage)==null?void 0:I.url)||null}}});return{defaultName:s.name,name:s.name,position:f+1,optionValues:W(b,f,l)}}),i=s=>{const f=s.priceAdjustments[0];if(!f)return null;const b=f.adjustmentValue;switch(b.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:b.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:o(b.adjustmentAmount.amount)};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:o(b.price.amount)};default:throw new Error(`Unknown price adjustment type: ${b.__typename}`)}},o=s=>a===1?Number(s)*100:Math.round(Number(s)*100*a),n=((c=e.sellingPlanGroups)==null?void 0:c.nodes.flatMap(s=>s.sellingPlans.nodes.map(f=>({id:Number(f.id.split("/").pop()),name:f.name,priceAdjustment:i(f)}))))||[],m=e.variants.nodes.some(s=>s.requiresComponents);return{id:Number(e.id.split("/").pop()),handle:e.handle,url:e.onlineStoreUrl||`https://${t}/products/${e.handle}`,availableForSale:e.availableForSale,createdAt:e.createdAt,title:e.title,image:((d=e.featuredImage)==null?void 0:d.url)||null,collectionIds:e.collections.nodes.map(s=>Number(s.id.split("/").pop())),options:r,selectedVariantId:Number(e.variants.nodes[0].id.split("/").pop()),variants:l,requiresSellingPlan:e.requiresSellingPlan,sellingPlans:n,isNativeBundle:m,metafields:{text:((g=e.metafield)==null?void 0:g.value)||null,text2:((y=e.metafield2)==null?void 0:y.value)||null,text3:((p=e.metafield3)==null?void 0:p.value)||null,text4:((h=e.metafield4)==null?void 0:h.value)||null}}},W=(e,t,a)=>e.filter(l=>a.filter(r=>r.options[t]===l.name).length>0),O="app--2935586817",X=async(e,{language:t,country:a,useExternalMetafieldNamespace:l})=>{const r=`${O}--kaching_bundles`,i=O,o=$({country:a}),{localization:{country:{currency:{isoCode:n}}},shop:{moneyFormat:m,paymentSettings:{currencyCode:c},currencyRateConstant:d,primaryDomain:g,settingsMetafield:y}}=await e.query(`
192
+ `,{variables:{productGID:t.id,cursor:c,reverse:m,...a}}),{nodes:g,pageInfo:y}=f.product.variants;for(const h of g){if(r.has(h.id)){d=!1;break}r.add(h.id),m?o.push(h):i.push(h)}y.hasNextPage||(d=!1),c=y.endCursor}};return await Promise.all([l(!1),l(!0)]),t.variants.nodes=[...i,...o.reverse()],t},T=(e,t,a)=>{var d,c,f,g,y,h;const n=e.variants.nodes.map(({unitPriceMeasurement:s,...p})=>{var b,_;return{id:Number(p.id.split("/").pop()),availableForSale:p.availableForSale,price:Math.round(Number(p.price.amount)*100),compareAtPrice:p.compareAtPrice?Math.round(Number(p.compareAtPrice.amount)*100):null,options:p.selectedOptions.map(u=>u.value),imageId:p.image?Number(p.image.id.split("/").pop()):null,image:((b=p.image)==null?void 0:b.url)||null,sellingPlans:((_=p.sellingPlanAllocations)==null?void 0:_.nodes.map(u=>({id:Number(u.sellingPlan.id.split("/").pop()),price:u.priceAdjustments.length>0?Math.round(Number(u.priceAdjustments[0].price.amount)*100):Math.round(Number(p.price.amount)*100),compareAtPrice:u.priceAdjustments.length>0?Math.round(Number(u.priceAdjustments[0].compareAtPrice.amount)*100):Math.round(Number(p.price.amount)*100),perDeliveryPrice:u.priceAdjustments.length>0?Math.round(Number(u.priceAdjustments[0].perDeliveryPrice.amount)*100):Math.round(Number(p.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:p.quantityAvailable??null,unitPriceMeasurement:s!=null&&s.quantityUnit&&(s!=null&&s.referenceUnit)?{quantityValue:s.quantityValue,quantityUnit:s.quantityUnit.toLowerCase(),referenceValue:s.referenceValue,referenceUnit:s.referenceUnit.toLowerCase()}:null}}),r=e.options.map((s,p)=>{const b=s.optionValues.map(_=>{var u,v,I,P;return{id:Number(_.id.split("/").pop()),defaultName:_.name,name:_.name,swatch:{color:((u=_.swatch)==null?void 0:u.color)||null,image:((P=(I=(v=_.swatch)==null?void 0:v.image)==null?void 0:I.previewImage)==null?void 0:P.url)||null}}});return{defaultName:s.name,name:s.name,position:p+1,optionValues:W(b,p,n)}}),i=s=>{const p=s.priceAdjustments[0];if(!p)return null;const b=p.adjustmentValue;switch(b.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:b.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:o(b.adjustmentAmount.amount)};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:o(b.price.amount)};default:throw new Error(`Unknown price adjustment type: ${b.__typename}`)}},o=s=>a===1?Number(s)*100:Math.round(Number(s)*100*a),l=((d=e.sellingPlanGroups)==null?void 0:d.nodes.flatMap(s=>s.sellingPlans.nodes.map(p=>({id:Number(p.id.split("/").pop()),name:p.name,priceAdjustment:i(p)}))))||[],m=e.variants.nodes.some(s=>s.requiresComponents);return{id:Number(e.id.split("/").pop()),handle:e.handle,url:e.onlineStoreUrl||`https://${t}/products/${e.handle}`,availableForSale:e.availableForSale,createdAt:e.createdAt,title:e.title,image:((c=e.featuredImage)==null?void 0:c.url)||null,collectionIds:e.collections.nodes.map(s=>Number(s.id.split("/").pop())),options:r,selectedVariantId:Number(e.variants.nodes[0].id.split("/").pop()),variants:n,requiresSellingPlan:e.requiresSellingPlan,sellingPlans:l,isNativeBundle:m,metafields:{text:((f=e.metafield)==null?void 0:f.value)||null,text2:((g=e.metafield2)==null?void 0:g.value)||null,text3:((y=e.metafield3)==null?void 0:y.value)||null,text4:((h=e.metafield4)==null?void 0:h.value)||null}}},W=(e,t,a)=>e.filter(n=>a.filter(r=>r.options[t]===n.name).length>0),q="app--2935586817",X=async(e,{language:t,country:a,useExternalMetafieldNamespace:n})=>{const r=`${q}--kaching_bundles`,i=q,o=$({country:a}),{localization:{country:{currency:{isoCode:l}}},shop:{moneyFormat:m,paymentSettings:{currencyCode:d},currencyRateConstant:c,primaryDomain:f,settingsMetafield:g}}=await e.query(`
193
193
  query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
194
194
  localization {
195
195
  country {
@@ -214,7 +214,7 @@
214
214
  }
215
215
  }
216
216
  }
217
- `,{variables:{metafieldNamespace:r,settingsNamespace:i}}),p=n===c?m:R(n,{language:t,country:a}),h=d?Y(d.value):1,s=y?JSON.parse(y.value):null,f=(s==null?void 0:s.feature_flags)??{},b=(s==null?void 0:s.custom_selectors)??{};return{shopifyDomain:g.host,moneyFormat:p,locale:(t==null?void 0:t.toLowerCase())||"en",liquidLocale:(t==null?void 0:t.toLowerCase())||"en",country:a??"US",currencyRate:h,marketId:0,productId:null,storefrontAccessToken:(s==null?void 0:s.storefront_access_token)??null,includeSellingPlans:(s==null?void 0:s.include_selling_plans)??!1,includeAvailableQuantity:(s==null?void 0:s.include_available_quantity)??!1,customApiHost:(s==null?void 0:s.custom_api_host)??null,keepQuantityInput:(s==null?void 0:s.keep_quantity_input)??!1,ignoreDeselect:(s==null?void 0:s.ignore_deselect)??!1,ignoreUnitPrice:(s==null?void 0:s.ignore_unit_price)??!1,requireCustomerLogin:(s==null?void 0:s.require_customer_login)??!1,abTestsRunning:(s==null?void 0:s.ab_tests_running)??!1,webPixel:(s==null?void 0:s.web_pixel)??!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":"Out of stock","system.invalid_variant":"Invalid variant","system.unavailable_option_value":"Unavailable option value","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:b.quantity??null,addToCartButton:b.add_to_cart_button??null,variantPicker:b.variant_picker??null,price:b.price??null,priceCompare:b.price_compare??null},shopCustomStyles:(s==null?void 0:s.shop_custom_styles)??"",featureFlags:f,brandColors:(s==null?void 0:s.brand_colors)??null}},Y=e=>JSON.parse(e).amount/1e6,Z=async(e,t,a=200)=>(t=t.filter(Boolean).filter(l=>!l.startsWith("placeholder")),t.length===0?[]:(await e.query(`
217
+ `,{variables:{metafieldNamespace:r,settingsNamespace:i}}),y=l===d?m:R(l,{language:t,country:a}),h=c?Y(c.value):1,s=g?JSON.parse(g.value):null,p=(s==null?void 0:s.feature_flags)??{},b=(s==null?void 0:s.custom_selectors)??{};return{shopifyDomain:f.host,moneyFormat:y,locale:(t==null?void 0:t.toLowerCase())||"en",liquidLocale:(t==null?void 0:t.toLowerCase())||"en",country:a??"US",currencyRate:h,marketId:0,productId:null,storefrontAccessToken:(s==null?void 0:s.storefront_access_token)??null,includeSellingPlans:(s==null?void 0:s.include_selling_plans)??!1,includeAvailableQuantity:(s==null?void 0:s.include_available_quantity)??!1,customApiHost:(s==null?void 0:s.custom_api_host)??null,keepQuantityInput:(s==null?void 0:s.keep_quantity_input)??!1,ignoreDeselect:(s==null?void 0:s.ignore_deselect)??!1,ignoreUnitPrice:(s==null?void 0:s.ignore_unit_price)??!1,requireCustomerLogin:(s==null?void 0:s.require_customer_login)??!1,abTestsRunning:(s==null?void 0:s.ab_tests_running)??!1,webPixel:(s==null?void 0:s.web_pixel)??!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!1,previewScratchOff:!1,defaultTranslations:{"system.out_of_stock":"Out of stock","system.invalid_variant":"Invalid variant","system.unavailable_option_value":"Unavailable option value","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:b.quantity??null,addToCartButton:b.add_to_cart_button??null,variantPicker:b.variant_picker??null,price:b.price??null,priceCompare:b.price_compare??null},shopCustomStyles:(s==null?void 0:s.shop_custom_styles)??"",featureFlags:p,brandColors:(s==null?void 0:s.brand_colors)??null}},Y=e=>JSON.parse(e).amount/1e6,Z=async(e,t,a=200)=>(t=t.filter(Boolean).filter(n=>!n.startsWith("placeholder")),t.length===0?[]:(await e.query(`
218
218
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
219
219
  nodes(ids: $mediaImageIds) {
220
220
  ... on MediaImage {
@@ -225,4 +225,4 @@
225
225
  }
226
226
  }
227
227
  }
228
- `,{variables:{mediaImageIds:t,size:a}})).nodes.filter(Boolean).map(l=>({gid:l.id,url:l.image.url})));var w=(e=>(e.QuantityBreak="quantity-break",e.Bxgy="bxgy",e.Bundle="bundle",e.MixAndMatch="mix-and-match",e.Sku="sku",e))(w||{});const ee=e=>[...te(e),...ae(e),...se(e),...le(e),...ne(e),...re(e),...ie(e),...oe(e),...ce(e),...ue(e),...de(e),...me(e),...pe(e)].filter(t=>t!=null&&!t.includes("placeholder")),te=e=>e.dealBars.flatMap(t=>[t.mediaImageGID,t.badgeImageGID]).filter(t=>t!=null),ae=e=>e.dealBars.flatMap(t=>t.dealBarType===w.Bundle?t.bundleProducts.map(a=>a.mediaImageGID):[]).filter(t=>t!=null),se=e=>e.dealBars.map(({freeGifts:t})=>(t||[]).map(a=>a.mediaImageGID)).reduce((t,a)=>t.concat(a),[]).filter(t=>t!=null),le=e=>e.dealBars.flatMap(({multipleGiftsSelectors:t})=>(t||[]).map(a=>a.mediaImageGID)).filter(t=>t!=null),ne=e=>e.dealBars.map(({upsells:t})=>(t||[]).map(a=>a.mediaImageGID)).reduce((t,a)=>t.concat(a),[]).filter(t=>t!=null),re=e=>e.swatchOptions?e.swatchOptions.reduce((t,a)=>{const l=a.images.map(r=>r.mediaImageGID).filter(r=>r!=null);return[...t,...l]},[]):[],ie=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];const t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},oe=e=>{var t,a,l;return e.progressiveGifts?[...((t=e.progressiveGifts.gifts)==null?void 0:t.map(r=>r.mediaImageGID))||[],(a=e.progressiveGifts.style)==null?void 0:a.lockedMediaImageGID,(l=e.progressiveGifts.dealBarStyle)==null?void 0:l.lockedMediaImageGID].filter(r=>r!=null):[]},ce=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(t=>[t.mediaImageGID,t.badgeImageGID]).filter(t=>t!=null),ue=e=>e.dealBars.map(t=>{var a;return(a=t.productPersonalisation)==null?void 0:a.mediaImageGID}).filter(t=>t!=null),de=e=>{var l,r;const t=e.dealBars.map(i=>{var o;return(o=i.highlights)==null?void 0:o.customIconGID}).filter(i=>i!=null),a=(r=(l=e.subscriptions)==null?void 0:l.highlights)==null?void 0:r.customIconGID;return a?[...t,a]:t},me=e=>(e.badges||[]).flatMap(t=>t.badgeType==="custom"&&t.imageGID?[t.imageGID]:[]),pe=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],fe=e=>{const t=[...ye(e),...ge(e),...he(e),...be(e),...ve(e),..._e(e),...Pe(e),...Ie(e)];return Array.from(new Set(t.filter(a=>a!=null)))},ye=e=>e.dealBars.flatMap(({freeGifts:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null),ge=e=>e.dealBars.flatMap(({multipleGiftsSelectors:t})=>t?t.flatMap(a=>a.products?a.products.map(l=>l.id):[]):[]).filter(t=>t!=null),he=e=>{var t;return e.progressiveGiftsEnabled?((t=e.progressiveGifts)==null?void 0:t.gifts.map(a=>a.productGID).filter(a=>a!=null))||[]:[]},be=e=>e.dealBars.flatMap(({upsells:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null),ve=e=>e.dealBars.filter(t=>t.dealBarType===w.Bundle).flatMap(({bundleProducts:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null).filter(t=>t!=="default"),_e=e=>e.dealBars.filter(t=>t.dealBarType===w.MixAndMatch).flatMap(({bundleProducts:t})=>t?t.flatMap(a=>{var l;return[a.productGID,...((l=a.selectedProducts)==null?void 0:l.map(r=>r.id))??[]]}):[]).filter(t=>t!=null).filter(t=>t!=="default"),Pe=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(t=>t.productGID).filter(t=>t!=null),Ie=e=>e.dealBars.filter(t=>t.dealBarType===w.Sku).flatMap(({productGID:t})=>t?[t]:[]);class Se{constructor(t,a){this.storefrontApiVersion="2026-07",this.storefrontAccessToken=a,this.shopifyDomain=t}async query(t,a){var n;const l=(a==null?void 0:a.variables)??{};let r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const i=(n=t.match(/query\s+(\w+)/))==null?void 0:n[1];i&&(r+=`?operation_name=${i}`);const o=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:t,variables:l})})).text();if(!o)throw new Error("Empty graphql response");return JSON.parse(o).data}}const ke=async(e,t,{country:a,language:l})=>{const r=t.collectionBreaks;if(!t.collectionBreaksEnabled||!r)return;let i;r.visibility==="deal-products"?i=await M(e,{country:a,language:l,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(n=>`gid://shopify/Product/${n}`),selectedProductGIDs:(t.selectedProductIds||[]).map(n=>`gid://shopify/Product/${n}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(n=>`gid://shopify/Collection/${n}`)}):i=await M(e,{country:a,language:l,blockVisibility:r.visibility,excludedProductGIDs:(r.excludedProducts||[]).map(({id:n})=>n),selectedProductGIDs:(r.selectedProducts||[]).map(({id:n})=>n),selectedCollectionGIDs:(r.selectedCollections||[]).map(({id:n})=>n)});let o=await A(e,{country:a,language:l,productIds:i.map(n=>Number(n.split("/").pop())),useExternalMetafieldNamespace:!0});return o=o.filter(n=>n.availableForSale),o},we=()=>({"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."}),$e="2026-07",Ne=async(e,{productId:t,dealBlockId:a,country:l=void 0,language:r=void 0})=>{var i,o;try{const n=[Number(t.split("/").pop())],m=new De(e);l=l||((i=m.i18n)==null?void 0:i.country),r=r||((o=m.i18n)==null?void 0:o.language);const c=await X(m,{language:r,country:l,useExternalMetafieldNamespace:!0});m.shopifyDomain=c.shopifyDomain;const d=c.storefrontAccessToken?new Se(c.shopifyDomain,c.storefrontAccessToken):m,[g,y]=await Promise.all([A(d,{country:l,language:r,productIds:n,useExternalMetafieldNamespace:!0}),Q(d,{useExternalMetafieldNamespace:!0,useMetaobjects:c.featureFlags.storefront_metaobjects})]),p=g[0];if(!p)return null;const h=F(y,p);let s;if(a?(s=h.find(I=>I.id===a||I.nanoId===a),s||(s=h[0])):s=h[0],!s)return null;const f=ee(s),b=fe(s),[_,u,v,P]=await Promise.all([A(d,{country:l,language:r,productIds:b,useExternalMetafieldNamespace:!0}),Z(d,f,300),ke(d,s,{country:l,language:r}),we()]);return{product:p,dealBlock:s,config:c,otherProducts:_,mediaImages:u,collectionBreaksProducts:v??[],translations:P}}catch(n){return console.error(n),null}};class De{constructor(t){this.storefront=t,this.shopifyDomain=""}async query(t,a){if("query"in this.storefront&&"i18n"in this.storefront)return await this.storefront.query(t,a);if("request"in this.storefront)return(await this.storefront.request(t,a)).data;if("shopifyDomain"in this.storefront&&"storefrontAccessToken"in this.storefront){const l=await fetch(`https://${this.storefront.shopifyDomain}/api/${$e}/graphql.json`,{body:JSON.stringify({query:t,variables:a==null?void 0:a.variables}),headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:"POST"});if(!l.ok)throw new Error(l.statusText);return(await l.json()).data}else{const l=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:t,variables:a==null?void 0:a.variables}),headers:this.storefront.getPublicTokenHeaders(),method:"POST"});if(!l.ok)throw new Error(l.statusText);return(await l.json()).data}}get i18n(){if("i18n"in this.storefront)return this.storefront.i18n}}const Ae=Ne,N="kaching-bundles-block",j=1e4,xe="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",Ge="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",D=new WeakSet,Be=async e=>{const t=e.document;if(!e.customElements.get(N)){if(D.has(t))return x(e,N);D.add(t);try{await Me(e)}catch(a){throw D.delete(t),a}}},Ee=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",Ce=()=>Ee()?xe:Ge,Me=e=>{const t=e.document;return new Promise((a,l)=>{const r=Ce();if(t.querySelector(`script[src="${r}"]`)){x(e,N).then(a).catch(l);return}const o=t.createElement("script");o.src=r,o.onload=()=>x(e,N).then(a).catch(l),o.onerror=()=>l(new Error("Failed to load script")),t.head.appendChild(o)})},x=(e,t)=>new Promise((a,l)=>{if(e.customElements.get(t)){a();return}Promise.race([e.customElements.whenDefined(t),new Promise((r,i)=>setTimeout(()=>i(new Error(`Custom element "${t}" failed to register within ${j}ms`)),j))]).then(()=>a()).catch(l)});var G=(e=>(e.QuantityBreak="quantity-break",e.Bxgy="bxgy",e.Bundle="bundle",e.MixAndMatch="mix-and-match",e.Sku="sku",e))(G||{});const k="a-f\\d",Te=`#?[${k}]{3}[${k}]?`,qe=`#?[${k}]{6}([${k}]{2})?`,Oe=new RegExp(`[^#${k}]`,"gi"),je=new RegExp(`^${Te}$|^${qe}$`,"i");function Ue(e,t={}){if(typeof e!="string"||Oe.test(e)||!je.test(e))throw new TypeError("Expected a valid hex string");e=e.replace(/^#/,"");let a=1;e.length===8&&(a=Number.parseInt(e.slice(6,8),16)/255,e=e.slice(0,6)),e.length===4&&(a=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]);const l=Number.parseInt(e,16),r=l>>16,i=l>>8&255,o=l&255,n=typeof t.alpha=="number"?t.alpha:a;if(t.format==="array")return[r,i,o,n];if(t.format==="css"){const m=n===1?"":` / ${Number((n*100).toFixed(2))}%`;return`rgb(${r} ${i} ${o}${m})`}return{red:r,green:i,blue:o,alpha:n}}const Ve=({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}),Fe=()=>({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:{}}),Re=({color:e,cornerRadius:t})=>{const a={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:G.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:G.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&&(a.colors.border={...Ue(e),alpha:1}),a},Le=({data:e,selectedVariantId:t,preview:a,onLinesChange:l,targetWindow:r})=>{const i=S.useRef(null),[o,n]=S.useState(!1),m=S.useRef(!1);if(S.useEffect(()=>{if(!i.current||o)return;(async()=>{await Be(r??window),n(!0)})()},[o,r]),S.useEffect(()=>{const c=i.current;if(!o||!c)return;const d=()=>{const y=c.items().map(p=>({merchandiseId:`gid://shopify/ProductVariant/${p.id}`,quantity:p.quantity,attributes:Object.entries(p.properties).map(([h,s])=>({key:h,value:String(s)})),sellingPlanId:p.selling_plan?`gid://shopify/SellingPlan/${p.selling_plan}`:void 0}));l==null||l(y)};return m.current||(typeof c.items=="function"?d():c.addEventListener("kaching-bundles-block-loaded",d),m.current=!0),c.addEventListener("variants-changed",d),()=>{c.removeEventListener("kaching-bundles-block-loaded",d),c.removeEventListener("variants-changed",d)}},[o,l]),e){const{config:c,dealBlock:d,product:g,otherProducts:y,mediaImages:p,collectionBreaksProducts:h,translations:s}=e;return B.jsx("kaching-bundles-block",{ref:i,"deal-block-id":d.id,config:JSON.stringify(c),"deal-block":JSON.stringify(d),"media-images":JSON.stringify(p),product:JSON.stringify(g),"other-products":JSON.stringify(y),"collection-breaks-products":JSON.stringify(h),translations:JSON.stringify(s),"current-variant-id":t?t.split("/").pop():String(g.variants[0].id)})}else if(a){const{cornerRadius:c,color:d,price:g}=a,y=Ve({price:g}),p=Fe(),h=Re({color:d,cornerRadius:c});return B.jsx("kaching-bundles-block",{ref:i,"deal-block-id":h.id,config:JSON.stringify(p),"deal-block":JSON.stringify(h),"media-images":JSON.stringify([]),product:JSON.stringify(y),"other-products":JSON.stringify([]),"collection-breaks-products":JSON.stringify([]),translations:JSON.stringify({}),"current-variant-id":String(y.variants[0].id)})}else return null};exports.KachingBundle=Le;exports.fetchKachingBundlesData=Ae;
228
+ `,{variables:{mediaImageIds:t,size:a}})).nodes.filter(Boolean).map(n=>({gid:n.id,url:n.image.url})));var w=(e=>(e.QuantityBreak="quantity-break",e.Bxgy="bxgy",e.Bundle="bundle",e.MixAndMatch="mix-and-match",e.Sku="sku",e))(w||{});const ee=e=>[...te(e),...ae(e),...se(e),...ne(e),...le(e),...re(e),...ie(e),...oe(e),...ce(e),...ue(e),...de(e),...me(e),...pe(e)].filter(t=>t!=null&&!t.includes("placeholder")),te=e=>e.dealBars.flatMap(t=>[t.mediaImageGID,t.badgeImageGID]).filter(t=>t!=null),ae=e=>e.dealBars.flatMap(t=>t.dealBarType===w.Bundle?t.bundleProducts.map(a=>a.mediaImageGID):[]).filter(t=>t!=null),se=e=>e.dealBars.map(({freeGifts:t})=>(t||[]).map(a=>a.mediaImageGID)).reduce((t,a)=>t.concat(a),[]).filter(t=>t!=null),ne=e=>e.dealBars.flatMap(({multipleGiftsSelectors:t})=>(t||[]).map(a=>a.mediaImageGID)).filter(t=>t!=null),le=e=>e.dealBars.map(({upsells:t})=>(t||[]).map(a=>a.mediaImageGID)).reduce((t,a)=>t.concat(a),[]).filter(t=>t!=null),re=e=>e.swatchOptions?e.swatchOptions.reduce((t,a)=>{const n=a.images.map(r=>r.mediaImageGID).filter(r=>r!=null);return[...t,...n]},[]):[],ie=e=>{if(!e.collectionBreaksEnabled||!e.collectionBreaks)return[];const t=e.collectionBreaks.mediaImageGID;return t?[t]:[]},oe=e=>{var t,a,n;return e.progressiveGifts?[...((t=e.progressiveGifts.gifts)==null?void 0:t.map(r=>r.mediaImageGID))||[],(a=e.progressiveGifts.style)==null?void 0:a.lockedMediaImageGID,(n=e.progressiveGifts.dealBarStyle)==null?void 0:n.lockedMediaImageGID].filter(r=>r!=null):[]},ce=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.flatMap(t=>[t.mediaImageGID,t.badgeImageGID]).filter(t=>t!=null),ue=e=>e.dealBars.map(t=>{var a;return(a=t.productPersonalisation)==null?void 0:a.mediaImageGID}).filter(t=>t!=null),de=e=>{var n,r;const t=e.dealBars.map(i=>{var o;return(o=i.highlights)==null?void 0:o.customIconGID}).filter(i=>i!=null),a=(r=(n=e.subscriptions)==null?void 0:n.highlights)==null?void 0:r.customIconGID;return a?[...t,a]:t},me=e=>(e.badges||[]).flatMap(t=>t.badgeType==="custom"&&t.imageGID?[t.imageGID]:[]),pe=e=>!e.savingsSummaryEnabled||!e.savingsSummary?[]:e.savingsSummary.customIconGID?[e.savingsSummary.customIconGID]:[],fe=e=>{const t=[...ye(e),...ge(e),...he(e),...be(e),...ve(e),..._e(e),...Ie(e),...Pe(e)];return Array.from(new Set(t.filter(a=>a!=null)))},ye=e=>e.dealBars.flatMap(({freeGifts:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null),ge=e=>e.dealBars.flatMap(({multipleGiftsSelectors:t})=>t?t.flatMap(a=>a.products?a.products.map(n=>n.id):[]):[]).filter(t=>t!=null),he=e=>{var t;return e.progressiveGiftsEnabled?((t=e.progressiveGifts)==null?void 0:t.gifts.map(a=>a.productGID).filter(a=>a!=null))||[]:[]},be=e=>e.dealBars.flatMap(({upsells:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null),ve=e=>e.dealBars.filter(t=>t.dealBarType===w.Bundle).flatMap(({bundleProducts:t})=>t?t.map(a=>a.productGID):[]).filter(t=>t!=null).filter(t=>t!=="default"),_e=e=>e.dealBars.filter(t=>t.dealBarType===w.MixAndMatch).flatMap(({bundleProducts:t})=>t?t.flatMap(a=>{var n;return[a.productGID,...((n=a.selectedProducts)==null?void 0:n.map(r=>r.id))??[]]}):[]).filter(t=>t!=null).filter(t=>t!=="default"),Ie=e=>!e.checkboxUpsellsEnabled||!e.checkboxUpsells?[]:e.checkboxUpsells.upsells.map(t=>t.productGID).filter(t=>t!=null),Pe=e=>e.dealBars.filter(t=>t.dealBarType===w.Sku).flatMap(({productGID:t})=>t?[t]:[]);class Se{constructor(t,a){this.storefrontApiVersion="2026-07",this.storefrontAccessToken=a,this.shopifyDomain=t}async query(t,a){var l;const n=(a==null?void 0:a.variables)??{};let r=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const i=(l=t.match(/query\s+(\w+)/))==null?void 0:l[1];i&&(r+=`?operation_name=${i}`);const o=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:t,variables:n})})).text();if(!o)throw new Error("Empty graphql response");return JSON.parse(o).data}}const ke=async(e,t,{country:a,language:n})=>{const r=t.collectionBreaks;if(!t.collectionBreaksEnabled||!r)return;let i;r.visibility==="deal-products"?i=await C(e,{country:a,language:n,blockVisibility:t.blockVisibility,excludedProductGIDs:(t.excludedProductIds||[]).map(l=>`gid://shopify/Product/${l}`),selectedProductGIDs:(t.selectedProductIds||[]).map(l=>`gid://shopify/Product/${l}`),selectedCollectionGIDs:(t.selectedCollectionIds||[]).map(l=>`gid://shopify/Collection/${l}`)}):i=await C(e,{country:a,language:n,blockVisibility:r.visibility,excludedProductGIDs:(r.excludedProducts||[]).map(({id:l})=>l),selectedProductGIDs:(r.selectedProducts||[]).map(({id:l})=>l),selectedCollectionGIDs:(r.selectedCollections||[]).map(({id:l})=>l)});let o=await A(e,{country:a,language:n,productIds:i.map(l=>Number(l.split("/").pop())),useExternalMetafieldNamespace:!0});return o=o.filter(l=>l.availableForSale),o},we=()=>({"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."}),$e="2026-07",De=async(e,{productId:t,dealBlockId:a,country:n=void 0,language:r=void 0})=>{var i,o;try{const l=[Number(t.split("/").pop())],m=new Ne(e);n=n||((i=m.i18n)==null?void 0:i.country),r=r||((o=m.i18n)==null?void 0:o.language);const d=await X(m,{language:r,country:n,useExternalMetafieldNamespace:!0});m.shopifyDomain=d.shopifyDomain;const c=d.storefrontAccessToken?new Se(d.shopifyDomain,d.storefrontAccessToken):m,[f,g]=await Promise.all([A(c,{country:n,language:r,productIds:l,useExternalMetafieldNamespace:!0}),Q(c,{useExternalMetafieldNamespace:!0,useMetaobjects:d.featureFlags.storefront_metaobjects})]),y=f[0];if(!y)return null;const h=F(g,y);let s;if(a?(s=h.find(P=>P.id===a||P.nanoId===a),s||(s=h[0])):s=h[0],!s)return null;const p=ee(s),b=fe(s),[_,u,v,I]=await Promise.all([A(c,{country:n,language:r,productIds:b,useExternalMetafieldNamespace:!0}),Z(c,p,300),ke(c,s,{country:n,language:r}),we()]);return{product:y,dealBlock:s,config:d,otherProducts:_,mediaImages:u,collectionBreaksProducts:v??[],translations:I}}catch(l){return console.error(l),null}};class Ne{constructor(t){this.storefront=t,this.shopifyDomain=""}async query(t,a){if("query"in this.storefront&&"i18n"in this.storefront)return await this.storefront.query(t,a);if("request"in this.storefront)return(await this.storefront.request(t,a)).data;if("shopifyDomain"in this.storefront&&"storefrontAccessToken"in this.storefront){const n=await fetch(`https://${this.storefront.shopifyDomain}/api/${$e}/graphql.json`,{body:JSON.stringify({query:t,variables:a==null?void 0:a.variables}),headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefront.storefrontAccessToken},method:"POST"});if(!n.ok)throw new Error(n.statusText);return(await n.json()).data}else{const n=await fetch(this.storefront.getStorefrontApiUrl(),{body:JSON.stringify({query:t,variables:a==null?void 0:a.variables}),headers:this.storefront.getPublicTokenHeaders(),method:"POST"});if(!n.ok)throw new Error(n.statusText);return(await n.json()).data}}get i18n(){if("i18n"in this.storefront)return this.storefront.i18n}}const Ae=De,D="kaching-bundles-block",j=1e4,xe="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",Be="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",N=new WeakSet,Ge=async e=>{const t=e.document;if(!e.customElements.get(D)){if(N.has(t))return x(e,D);N.add(t);try{await Me(e)}catch(a){throw N.delete(t),a}}},Ee=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",Ce=()=>Ee()?xe:Be,Me=e=>{const t=e.document;return new Promise((a,n)=>{const r=Ce();if(t.querySelector(`script[src="${r}"]`)){x(e,D).then(a).catch(n);return}const o=t.createElement("script");o.src=r,o.onload=()=>x(e,D).then(a).catch(n),o.onerror=()=>n(new Error("Failed to load script")),t.head.appendChild(o)})},x=(e,t)=>new Promise((a,n)=>{if(e.customElements.get(t)){a();return}Promise.race([e.customElements.whenDefined(t),new Promise((r,i)=>setTimeout(()=>i(new Error(`Custom element "${t}" failed to register within ${j}ms`)),j))]).then(()=>a()).catch(n)});var B=(e=>(e.QuantityBreak="quantity-break",e.Bxgy="bxgy",e.Bundle="bundle",e.MixAndMatch="mix-and-match",e.Sku="sku",e))(B||{});const k="a-f\\d",Te=`#?[${k}]{3}[${k}]?`,qe=`#?[${k}]{6}([${k}]{2})?`,je=new RegExp(`[^#${k}]`,"gi"),Oe=new RegExp(`^${Te}$|^${qe}$`,"i");function Ve(e,t={}){if(typeof e!="string"||je.test(e)||!Oe.test(e))throw new TypeError("Expected a valid hex string");e=e.replace(/^#/,"");let a=1;e.length===8&&(a=Number.parseInt(e.slice(6,8),16)/255,e=e.slice(0,6)),e.length===4&&(a=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]);const n=Number.parseInt(e,16),r=n>>16,i=n>>8&255,o=n&255,l=typeof t.alpha=="number"?t.alpha:a;if(t.format==="array")return[r,i,o,l];if(t.format==="css"){const m=l===1?"":` / ${Number((l*100).toFixed(2))}%`;return`rgb(${r} ${i} ${o}${m})`}return{red:r,green:i,blue:o,alpha:l}}const Ue=({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}),Fe=()=>({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:{}}),Re=({color:e,cornerRadius:t})=>{const a={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:B.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:B.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&&(a.colors.border={...Ve(e),alpha:1}),a},Le=({data:e,selectedVariantId:t,preview:a,onLinesChange:n,targetWindow:r})=>{const i=S.useRef(null),[o,l]=S.useState(!1),m=S.useRef(!1);S.useEffect(()=>{if(!i.current||o)return;(async()=>{await Ge(r??window),l(!0)})()},[o,r]),S.useEffect(()=>{const c=i.current;if(!o||!c)return;const f=()=>{const y=c.items().map(h=>({merchandiseId:`gid://shopify/ProductVariant/${h.id}`,quantity:h.quantity,attributes:Object.entries(h.properties).map(([s,p])=>({key:s,value:String(p)})),sellingPlanId:h.selling_plan?`gid://shopify/SellingPlan/${h.selling_plan}`:void 0}));n==null||n(y)};return m.current||(typeof c.items=="function"?f():c.addEventListener("kaching-bundles-block-loaded",f),m.current=!0),c.addEventListener("variants-changed",f),()=>{c.removeEventListener("kaching-bundles-block-loaded",f),c.removeEventListener("variants-changed",f)}},[o,n]);const d=e?ze(e,t):a?Qe(a):null;return Je(()=>{const c=i.current;if(!(!c||!d))for(const[f,g]of Object.entries(d.jsonAttributes))c.getAttribute(f)!==g&&c.setAttribute(f,g)}),d?U.jsx("kaching-bundles-block",{ref:i,"deal-block-id":d.dealBlockId,...d.jsonAttributes,"current-variant-id":d.currentVariantId}):null},Je=typeof window>"u"?S.useEffect:S.useLayoutEffect,ze=({config:e,dealBlock:t,product:a,otherProducts:n,mediaImages:r,collectionBreaksProducts:i,translations:o},l)=>({dealBlockId:t.id,currentVariantId:l?l.split("/").pop():String(a.variants[0].id),jsonAttributes:{config:JSON.stringify(e),"deal-block":JSON.stringify(t),"media-images":JSON.stringify(r),product:JSON.stringify(a),"other-products":JSON.stringify(n),"collection-breaks-products":JSON.stringify(i),translations:JSON.stringify(o)}}),Qe=({cornerRadius:e,color:t,price:a})=>{const n=Ue({price:a}),r=Fe(),i=Re({color:t,cornerRadius:e});return{dealBlockId:i.id,currentVariantId:String(n.variants[0].id),jsonAttributes:{config:JSON.stringify(r),"deal-block":JSON.stringify(i),"media-images":JSON.stringify([]),product:JSON.stringify(n),"other-products":JSON.stringify([]),"collection-breaks-products":JSON.stringify([]),translations:JSON.stringify({})}}};exports.KachingBundle=Le;exports.fetchKachingBundlesData=Ae;
@@ -245,6 +245,8 @@ declare type DealBarProgressiveGiftStyle = {
245
245
  labelBackgroundColor: Color;
246
246
  labelTextColor: Color;
247
247
  labelTextSize: number;
248
+ backgroundColor?: Color | null;
249
+ selectedBackgroundColor?: Color | null;
248
250
  textColor: Color;
249
251
  selectedTextColor: Color;
250
252
  textSize: number;
@@ -1,6 +1,6 @@
1
- import { jsx as G } from "react/jsx-runtime";
2
- import { useRef as B, useState as R, useEffect as E } from "react";
3
- const L = (e, t) => {
1
+ import { jsx as F } from "react/jsx-runtime";
2
+ import { useRef as B, useState as R, useEffect as D, useLayoutEffect as L } from "react";
3
+ const J = (e, t) => {
4
4
  const a = [], l = e.filter(
5
5
  (n) => n.blockVisibility === "selected-products"
6
6
  );
@@ -26,36 +26,36 @@ const L = (e, t) => {
26
26
  for (const n of o)
27
27
  a.push(n);
28
28
  return a;
29
- }, J = (e, { language: t, country: a }) => {
30
- var g, y;
31
- const l = z(t, a), r = new Intl.NumberFormat(l, {
29
+ }, z = (e, { language: t, country: a }) => {
30
+ var f, g;
31
+ const l = Q(t, a), r = new Intl.NumberFormat(l, {
32
32
  style: "currency",
33
33
  currency: e,
34
34
  currencyDisplay: "narrowSymbol"
35
- }).formatToParts(123456789e-2), i = (g = r.find((p) => p.type === "decimal")) == null ? void 0 : g.value, o = Q(
36
- (y = r.find((p) => p.type === "group")) == null ? void 0 : y.value
37
- ), n = r.some((p) => p.type === "fraction"), m = H(
35
+ }).formatToParts(123456789e-2), i = (f = r.find((y) => y.type === "decimal")) == null ? void 0 : f.value, o = H(
36
+ (g = r.find((y) => y.type === "group")) == null ? void 0 : g.value
37
+ ), n = r.some((y) => y.type === "fraction"), m = K(
38
38
  o,
39
39
  i,
40
40
  n
41
- ), c = r.findIndex(M), d = r.findLastIndex(M);
41
+ ), d = r.findIndex(C), c = r.findLastIndex(C);
42
42
  return [
43
- ...r.slice(0, c).map(C),
43
+ ...r.slice(0, d).map(E),
44
44
  m,
45
- ...r.slice(d + 1).map(C)
45
+ ...r.slice(c + 1).map(E)
46
46
  ].join("");
47
- }, C = (e) => V(e.value), V = (e) => e.replace(/\s/g, " "), M = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", z = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), Q = (e) => e === void 0 ? void 0 : V(e).replace(/’/g, "'"), H = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
47
+ }, E = (e) => V(e.value), V = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", Q = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), H = (e) => e === void 0 ? void 0 : V(e).replace(/’/g, "'"), K = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
48
48
  country: e,
49
49
  language: t
50
50
  }) => {
51
51
  const a = [];
52
52
  return e && a.push(`country: ${e}`), t && a.push(`language: ${t}`), a.length > 0 ? `@inContext(${a.join(", ")})` : "";
53
- }, K = async (e, {
53
+ }, W = async (e, {
54
54
  useExternalMetafieldNamespace: t,
55
55
  useMetaobjects: a
56
- }) => a ? X(
56
+ }) => a ? Y(
57
57
  e
58
- ) : W(e), W = async (e, t) => {
58
+ ) : X(e), X = async (e, t) => {
59
59
  var l;
60
60
  const a = (l = (await e.query(
61
61
  `
@@ -74,7 +74,7 @@ const L = (e, t) => {
74
74
  }
75
75
  )).shop.metafield) == null ? void 0 : l.value;
76
76
  return a ? JSON.parse(a) : [];
77
- }, X = async (e, t) => {
77
+ }, Y = async (e, t) => {
78
78
  const a = "app--2935586817--deal_block", l = [];
79
79
  let r = null;
80
80
  for (; ; ) {
@@ -113,7 +113,7 @@ const L = (e, t) => {
113
113
  r = i.metaobjects.pageInfo.endCursor;
114
114
  }
115
115
  return l;
116
- }, T = async (e, {
116
+ }, M = async (e, {
117
117
  country: t,
118
118
  language: a,
119
119
  blockVisibility: l,
@@ -128,9 +128,9 @@ const L = (e, t) => {
128
128
  case "all-products":
129
129
  case "excluded-products": {
130
130
  const m = w({ country: t, language: a });
131
- let c = [], d = null;
132
- for (; c.length < n; ) {
133
- const g = Math.min(n - c.length, 250), y = await e.query(
131
+ let d = [], c = null;
132
+ for (; d.length < n; ) {
133
+ const f = Math.min(n - d.length, 250), g = await e.query(
134
134
  `
135
135
  query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
136
136
  products(first: $limit, after: $cursor) {
@@ -146,22 +146,22 @@ const L = (e, t) => {
146
146
  `,
147
147
  {
148
148
  variables: {
149
- limit: g,
150
- cursor: d
149
+ limit: f,
150
+ cursor: c
151
151
  }
152
152
  }
153
153
  );
154
- if (c.push(...y.products.nodes.map((p) => p.id)), !y.products.pageInfo.hasNextPage) break;
155
- d = y.products.pageInfo.endCursor;
154
+ if (d.push(...g.products.nodes.map((y) => y.id)), !g.products.pageInfo.hasNextPage) break;
155
+ c = g.products.pageInfo.endCursor;
156
156
  }
157
157
  if (l === "excluded-products") {
158
- const g = new Set(r);
159
- c = c.filter((y) => !g.has(y));
158
+ const f = new Set(r);
159
+ d = d.filter((g) => !f.has(g));
160
160
  }
161
- return c;
161
+ return d;
162
162
  }
163
163
  case "selected-collections": {
164
- const m = w({ country: t, language: a }), c = (await e.query(
164
+ const m = w({ country: t, language: a }), d = (await e.query(
165
165
  `
166
166
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
167
167
  nodes(ids: $collectionGIDs) {
@@ -181,13 +181,13 @@ const L = (e, t) => {
181
181
  limit: Math.min(n, 250)
182
182
  }
183
183
  }
184
- )).nodes.filter((d) => d !== null).flatMap(
185
- (d) => d.products.nodes.map((g) => g.id)
184
+ )).nodes.filter((c) => c !== null).flatMap(
185
+ (c) => c.products.nodes.map((f) => f.id)
186
186
  );
187
- return Array.from(new Set(c)).slice(0, n);
187
+ return Array.from(new Set(d)).slice(0, n);
188
188
  }
189
189
  }
190
- }, F = `
190
+ }, U = `
191
191
  id
192
192
  availableForSale
193
193
  price {
@@ -230,7 +230,7 @@ const L = (e, t) => {
230
230
  }
231
231
  }
232
232
  quantityAvailable @include(if: $includeAvailableQuantity)
233
- `, D = async (e, {
233
+ `, A = async (e, {
234
234
  country: t,
235
235
  language: a,
236
236
  productIds: l,
@@ -242,8 +242,8 @@ const L = (e, t) => {
242
242
  }) => {
243
243
  if (!l.length)
244
244
  return [];
245
- const c = l.map((u) => typeof u == "string" && u.startsWith("gid://") ? u : `gid://shopify/Product/${u}`), d = w({ country: t, language: a }), g = `
246
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${d} {
245
+ const d = l.map((u) => typeof u == "string" && u.startsWith("gid://") ? u : `gid://shopify/Product/${u}`), c = w({ country: t, language: a }), f = `
246
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${c} {
247
247
  shop {
248
248
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
249
249
  value
@@ -277,7 +277,7 @@ const L = (e, t) => {
277
277
  }
278
278
  variants(first: 250) {
279
279
  nodes {
280
- ${F}
280
+ ${U}
281
281
  }
282
282
  }
283
283
  collections(first: 50) {
@@ -329,24 +329,24 @@ const L = (e, t) => {
329
329
  }
330
330
  }
331
331
  }
332
- `, y = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", p = [], h = Math.min(n, 250);
333
- for (let u = 0; u < c.length; u += h)
334
- p.push(c.slice(u, u + h));
332
+ `, g = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", y = [], h = Math.min(n, 250);
333
+ for (let u = 0; u < d.length; u += h)
334
+ y.push(d.slice(u, u + h));
335
335
  let s = 1;
336
- const f = async (u) => {
337
- const v = await e.query(g, {
336
+ const p = async (u) => {
337
+ const v = await e.query(f, {
338
338
  variables: {
339
339
  productGIDs: u,
340
340
  includeSellingPlans: r,
341
341
  includeAvailableQuantity: i,
342
- metafieldNamespace: y
342
+ metafieldNamespace: g
343
343
  }
344
344
  });
345
345
  return v.shop.currencyRateConstant && (s = JSON.parse(v.shop.currencyRateConstant.value).amount / 1e6), v;
346
346
  };
347
347
  let b;
348
348
  if (m) {
349
- const u = await Promise.allSettled(p.map(f));
349
+ const u = await Promise.allSettled(y.map(p));
350
350
  for (const v of u)
351
351
  v.status === "rejected" && m(
352
352
  v.reason instanceof Error ? v.reason : new Error(String(v.reason))
@@ -355,18 +355,18 @@ const L = (e, t) => {
355
355
  (v) => v.status === "fulfilled"
356
356
  ).flatMap((v) => v.value.nodes);
357
357
  } else
358
- b = (await Promise.all(p.map(f))).flatMap((u) => u.nodes);
358
+ b = (await Promise.all(y.map(p))).flatMap((u) => u.nodes);
359
359
  const _ = b.filter((u) => u != null);
360
360
  if (m) {
361
361
  const u = await Promise.allSettled(
362
362
  _.map(async (I) => {
363
- const P = await q(
363
+ const P = await T(
364
364
  e,
365
365
  I,
366
366
  { includeSellingPlans: r, includeAvailableQuantity: i },
367
- d
367
+ c
368
368
  );
369
- return O(
369
+ return q(
370
370
  P,
371
371
  e.shopifyDomain,
372
372
  s
@@ -381,32 +381,32 @@ const L = (e, t) => {
381
381
  }
382
382
  return (await Promise.all(
383
383
  _.map(
384
- (u) => q(
384
+ (u) => T(
385
385
  e,
386
386
  u,
387
387
  {
388
388
  includeSellingPlans: r,
389
389
  includeAvailableQuantity: i
390
390
  },
391
- d
391
+ c
392
392
  )
393
393
  )
394
394
  )).map(
395
- (u) => O(u, e.shopifyDomain, s)
395
+ (u) => q(u, e.shopifyDomain, s)
396
396
  );
397
- }, q = async (e, t, a, l = "") => {
397
+ }, T = async (e, t, a, l = "") => {
398
398
  if (t.variants.nodes.length < 250)
399
399
  return t;
400
400
  const r = /* @__PURE__ */ new Set(), i = [], o = [], n = async (m) => {
401
- let c = !0, d = null;
402
- for (; c; ) {
403
- const g = await e.query(
401
+ let d = !0, c = null;
402
+ for (; d; ) {
403
+ const f = await e.query(
404
404
  `
405
405
  query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${l} {
406
406
  product(id: $productGID) {
407
407
  variants(first: 250, after: $cursor, reverse: $reverse) {
408
408
  nodes {
409
- ${F}
409
+ ${U}
410
410
  }
411
411
  pageInfo {
412
412
  endCursor
@@ -419,54 +419,54 @@ const L = (e, t) => {
419
419
  {
420
420
  variables: {
421
421
  productGID: t.id,
422
- cursor: d,
422
+ cursor: c,
423
423
  reverse: m,
424
424
  ...a
425
425
  }
426
426
  }
427
- ), { nodes: y, pageInfo: p } = g.product.variants;
428
- for (const h of y) {
427
+ ), { nodes: g, pageInfo: y } = f.product.variants;
428
+ for (const h of g) {
429
429
  if (r.has(h.id)) {
430
- c = !1;
430
+ d = !1;
431
431
  break;
432
432
  }
433
433
  r.add(h.id), m ? o.push(h) : i.push(h);
434
434
  }
435
- p.hasNextPage || (c = !1), d = p.endCursor;
435
+ y.hasNextPage || (d = !1), c = y.endCursor;
436
436
  }
437
437
  };
438
438
  return await Promise.all([
439
439
  n(!1),
440
440
  n(!0)
441
441
  ]), t.variants.nodes = [...i, ...o.reverse()], t;
442
- }, O = (e, t, a) => {
443
- var c, d, g, y, p, h;
442
+ }, q = (e, t, a) => {
443
+ var d, c, f, g, y, h;
444
444
  const l = e.variants.nodes.map(
445
- ({ unitPriceMeasurement: s, ...f }) => {
445
+ ({ unitPriceMeasurement: s, ...p }) => {
446
446
  var b, _;
447
447
  return {
448
- id: Number(f.id.split("/").pop()),
449
- availableForSale: f.availableForSale,
450
- price: Math.round(Number(f.price.amount) * 100),
451
- compareAtPrice: f.compareAtPrice ? Math.round(Number(f.compareAtPrice.amount) * 100) : null,
452
- options: f.selectedOptions.map((u) => u.value),
453
- imageId: f.image ? Number(f.image.id.split("/").pop()) : null,
454
- image: ((b = f.image) == null ? void 0 : b.url) || null,
455
- sellingPlans: ((_ = f.sellingPlanAllocations) == null ? void 0 : _.nodes.map((u) => ({
448
+ id: Number(p.id.split("/").pop()),
449
+ availableForSale: p.availableForSale,
450
+ price: Math.round(Number(p.price.amount) * 100),
451
+ compareAtPrice: p.compareAtPrice ? Math.round(Number(p.compareAtPrice.amount) * 100) : null,
452
+ options: p.selectedOptions.map((u) => u.value),
453
+ imageId: p.image ? Number(p.image.id.split("/").pop()) : null,
454
+ image: ((b = p.image) == null ? void 0 : b.url) || null,
455
+ sellingPlans: ((_ = p.sellingPlanAllocations) == null ? void 0 : _.nodes.map((u) => ({
456
456
  id: Number(u.sellingPlan.id.split("/").pop()),
457
- price: u.priceAdjustments.length > 0 ? Math.round(Number(u.priceAdjustments[0].price.amount) * 100) : Math.round(Number(f.price.amount) * 100),
457
+ price: u.priceAdjustments.length > 0 ? Math.round(Number(u.priceAdjustments[0].price.amount) * 100) : Math.round(Number(p.price.amount) * 100),
458
458
  compareAtPrice: u.priceAdjustments.length > 0 ? Math.round(
459
459
  Number(u.priceAdjustments[0].compareAtPrice.amount) * 100
460
- ) : Math.round(Number(f.price.amount) * 100),
460
+ ) : Math.round(Number(p.price.amount) * 100),
461
461
  perDeliveryPrice: u.priceAdjustments.length > 0 ? Math.round(
462
462
  Number(u.priceAdjustments[0].perDeliveryPrice.amount) * 100
463
- ) : Math.round(Number(f.price.amount) * 100)
463
+ ) : Math.round(Number(p.price.amount) * 100)
464
464
  }))) || [],
465
465
  inventoryManagement: null,
466
466
  // Storefront API does not return inventory management, only available in liquid
467
467
  inventoryPolicy: null,
468
468
  // Storefront API does not return inventory policy, only available in liquid
469
- inventoryQuantity: f.quantityAvailable ?? null,
469
+ inventoryQuantity: p.quantityAvailable ?? null,
470
470
  unitPriceMeasurement: s != null && s.quantityUnit && (s != null && s.referenceUnit) ? {
471
471
  quantityValue: s.quantityValue,
472
472
  quantityUnit: s.quantityUnit.toLowerCase(),
@@ -475,7 +475,7 @@ const L = (e, t) => {
475
475
  } : null
476
476
  };
477
477
  }
478
- ), r = e.options.map((s, f) => {
478
+ ), r = e.options.map((s, p) => {
479
479
  const b = s.optionValues.map((_) => {
480
480
  var u, v, I, P;
481
481
  return {
@@ -491,14 +491,14 @@ const L = (e, t) => {
491
491
  return {
492
492
  defaultName: s.name,
493
493
  name: s.name,
494
- position: f + 1,
495
- optionValues: Y(b, f, l)
494
+ position: p + 1,
495
+ optionValues: Z(b, p, l)
496
496
  };
497
497
  }), i = (s) => {
498
- const f = s.priceAdjustments[0];
499
- if (!f)
498
+ const p = s.priceAdjustments[0];
499
+ if (!p)
500
500
  return null;
501
- const b = f.adjustmentValue;
501
+ const b = p.adjustmentValue;
502
502
  switch (b.__typename) {
503
503
  case "SellingPlanPercentagePriceAdjustment":
504
504
  return {
@@ -520,11 +520,11 @@ const L = (e, t) => {
520
520
  `Unknown price adjustment type: ${b.__typename}`
521
521
  );
522
522
  }
523
- }, o = (s) => a === 1 ? Number(s) * 100 : Math.round(Number(s) * 100 * a), n = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
524
- (s) => s.sellingPlans.nodes.map((f) => ({
525
- id: Number(f.id.split("/").pop()),
526
- name: f.name,
527
- priceAdjustment: i(f)
523
+ }, o = (s) => a === 1 ? Number(s) * 100 : Math.round(Number(s) * 100 * a), n = ((d = e.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
524
+ (s) => s.sellingPlans.nodes.map((p) => ({
525
+ id: Number(p.id.split("/").pop()),
526
+ name: p.name,
527
+ priceAdjustment: i(p)
528
528
  }))
529
529
  )) || [], m = e.variants.nodes.some(
530
530
  (s) => s.requiresComponents
@@ -536,7 +536,7 @@ const L = (e, t) => {
536
536
  availableForSale: e.availableForSale,
537
537
  createdAt: e.createdAt,
538
538
  title: e.title,
539
- image: ((d = e.featuredImage) == null ? void 0 : d.url) || null,
539
+ image: ((c = e.featuredImage) == null ? void 0 : c.url) || null,
540
540
  collectionIds: e.collections.nodes.map(
541
541
  (s) => Number(s.id.split("/").pop())
542
542
  ),
@@ -549,20 +549,20 @@ const L = (e, t) => {
549
549
  sellingPlans: n,
550
550
  isNativeBundle: m,
551
551
  metafields: {
552
- text: ((g = e.metafield) == null ? void 0 : g.value) || null,
553
- text2: ((y = e.metafield2) == null ? void 0 : y.value) || null,
554
- text3: ((p = e.metafield3) == null ? void 0 : p.value) || null,
552
+ text: ((f = e.metafield) == null ? void 0 : f.value) || null,
553
+ text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
554
+ text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
555
555
  text4: ((h = e.metafield4) == null ? void 0 : h.value) || null
556
556
  }
557
557
  };
558
- }, Y = (e, t, a) => e.filter((l) => a.filter(
558
+ }, Z = (e, t, a) => e.filter((l) => a.filter(
559
559
  (r) => r.options[t] === l.name
560
- ).length > 0), j = "app--2935586817", Z = async (e, {
560
+ ).length > 0), O = "app--2935586817", ee = async (e, {
561
561
  language: t,
562
562
  country: a,
563
563
  useExternalMetafieldNamespace: l
564
564
  }) => {
565
- const r = `${j}--kaching_bundles`, i = j, o = w({ country: a }), {
565
+ const r = `${O}--kaching_bundles`, i = O, o = w({ country: a }), {
566
566
  localization: {
567
567
  country: {
568
568
  currency: { isoCode: n }
@@ -570,10 +570,10 @@ const L = (e, t) => {
570
570
  },
571
571
  shop: {
572
572
  moneyFormat: m,
573
- paymentSettings: { currencyCode: c },
574
- currencyRateConstant: d,
575
- primaryDomain: g,
576
- settingsMetafield: y
573
+ paymentSettings: { currencyCode: d },
574
+ currencyRateConstant: c,
575
+ primaryDomain: f,
576
+ settingsMetafield: g
577
577
  }
578
578
  } = await e.query(
579
579
  `
@@ -608,10 +608,10 @@ const L = (e, t) => {
608
608
  settingsNamespace: i
609
609
  }
610
610
  }
611
- ), p = n === c ? m : J(n, { language: t, country: a }), h = d ? ee(d.value) : 1, s = y ? JSON.parse(y.value) : null, f = (s == null ? void 0 : s.feature_flags) ?? {}, b = (s == null ? void 0 : s.custom_selectors) ?? {};
611
+ ), y = n === d ? m : z(n, { language: t, country: a }), h = c ? te(c.value) : 1, s = g ? JSON.parse(g.value) : null, p = (s == null ? void 0 : s.feature_flags) ?? {}, b = (s == null ? void 0 : s.custom_selectors) ?? {};
612
612
  return {
613
- shopifyDomain: g.host,
614
- moneyFormat: p,
613
+ shopifyDomain: f.host,
614
+ moneyFormat: y,
615
615
  locale: (t == null ? void 0 : t.toLowerCase()) || "en",
616
616
  liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
617
617
  country: a ?? "US",
@@ -666,10 +666,10 @@ const L = (e, t) => {
666
666
  priceCompare: b.price_compare ?? null
667
667
  },
668
668
  shopCustomStyles: (s == null ? void 0 : s.shop_custom_styles) ?? "",
669
- featureFlags: f,
669
+ featureFlags: p,
670
670
  brandColors: (s == null ? void 0 : s.brand_colors) ?? null
671
671
  };
672
- }, ee = (e) => JSON.parse(e).amount / 1e6, te = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
672
+ }, te = (e) => JSON.parse(e).amount / 1e6, ae = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
673
673
  `
674
674
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
675
675
  nodes(ids: $mediaImageIds) {
@@ -693,8 +693,7 @@ const L = (e, t) => {
693
693
  url: l.image.url
694
694
  })));
695
695
  var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
696
- const ae = (e) => [
697
- ...se(e),
696
+ const se = (e) => [
698
697
  ...le(e),
699
698
  ...ne(e),
700
699
  ...re(e),
@@ -706,66 +705,67 @@ const ae = (e) => [
706
705
  ...me(e),
707
706
  ...pe(e),
708
707
  ...fe(e),
709
- ...ye(e)
710
- ].filter((t) => t != null && !t.includes("placeholder")), se = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
708
+ ...ye(e),
709
+ ...ge(e)
710
+ ].filter((t) => t != null && !t.includes("placeholder")), le = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ne = (e) => e.dealBars.flatMap(
711
711
  (t) => t.dealBarType === k.Bundle ? t.bundleProducts.map(
712
712
  (a) => a.mediaImageGID
713
713
  ) : []
714
- ).filter((t) => t != null), ne = (e) => e.dealBars.map(
714
+ ).filter((t) => t != null), re = (e) => e.dealBars.map(
715
715
  ({ freeGifts: t }) => (t || []).map((a) => a.mediaImageGID)
716
- ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), re = (e) => e.dealBars.flatMap(
716
+ ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ie = (e) => e.dealBars.flatMap(
717
717
  ({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
718
- ).filter((t) => t != null), ie = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), oe = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
718
+ ).filter((t) => t != null), oe = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ce = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
719
719
  const l = a.images.map((r) => r.mediaImageGID).filter((r) => r != null);
720
720
  return [...t, ...l];
721
- }, []) : [], ce = (e) => {
721
+ }, []) : [], ue = (e) => {
722
722
  if (!e.collectionBreaksEnabled || !e.collectionBreaks)
723
723
  return [];
724
724
  const t = e.collectionBreaks.mediaImageGID;
725
725
  return t ? [t] : [];
726
- }, ue = (e) => {
726
+ }, de = (e) => {
727
727
  var t, a, l;
728
728
  return e.progressiveGifts ? [
729
729
  ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((r) => r.mediaImageGID)) || [],
730
730
  (a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
731
731
  (l = e.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
732
732
  ].filter((r) => r != null) : [];
733
- }, de = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), me = (e) => e.dealBars.map((t) => {
733
+ }, me = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), pe = (e) => e.dealBars.map((t) => {
734
734
  var a;
735
735
  return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
736
- }).filter((t) => t != null), pe = (e) => {
736
+ }).filter((t) => t != null), fe = (e) => {
737
737
  var l, r;
738
738
  const t = e.dealBars.map((i) => {
739
739
  var o;
740
740
  return (o = i.highlights) == null ? void 0 : o.customIconGID;
741
741
  }).filter((i) => i != null), a = (r = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : r.customIconGID;
742
742
  return a ? [...t, a] : t;
743
- }, fe = (e) => (e.badges || []).flatMap(
743
+ }, ye = (e) => (e.badges || []).flatMap(
744
744
  (t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
745
- ), ye = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ge = (e) => {
745
+ ), ge = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
746
746
  const t = [
747
- ...he(e),
748
747
  ...be(e),
749
748
  ...ve(e),
750
749
  ..._e(e),
751
750
  ...Ie(e),
752
751
  ...Pe(e),
753
752
  ...Se(e),
754
- ...ke(e)
753
+ ...ke(e),
754
+ ...we(e)
755
755
  ];
756
756
  return Array.from(new Set(t.filter((a) => a != null)));
757
- }, he = (e) => e.dealBars.flatMap(
757
+ }, be = (e) => e.dealBars.flatMap(
758
758
  ({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
759
- ).filter((t) => t != null), be = (e) => e.dealBars.flatMap(
759
+ ).filter((t) => t != null), ve = (e) => e.dealBars.flatMap(
760
760
  ({ multipleGiftsSelectors: t }) => t ? t.flatMap(
761
761
  (a) => a.products ? a.products.map((l) => l.id) : []
762
762
  ) : []
763
- ).filter((t) => t != null), ve = (e) => {
763
+ ).filter((t) => t != null), _e = (e) => {
764
764
  var t;
765
765
  return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((a) => a.productGID).filter((a) => a != null)) || [] : [];
766
- }, _e = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), Ie = (e) => e.dealBars.filter((t) => t.dealBarType === k.Bundle).flatMap(
766
+ }, Ie = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), Pe = (e) => e.dealBars.filter((t) => t.dealBarType === k.Bundle).flatMap(
767
767
  ({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
768
- ).filter((t) => t != null).filter((t) => t !== "default"), Pe = (e) => e.dealBars.filter((t) => t.dealBarType === k.MixAndMatch).flatMap(
768
+ ).filter((t) => t != null).filter((t) => t !== "default"), Se = (e) => e.dealBars.filter((t) => t.dealBarType === k.MixAndMatch).flatMap(
769
769
  ({ bundleProducts: t }) => t ? t.flatMap((a) => {
770
770
  var l;
771
771
  return [
@@ -773,8 +773,8 @@ const ae = (e) => [
773
773
  ...((l = a.selectedProducts) == null ? void 0 : l.map((r) => r.id)) ?? []
774
774
  ];
775
775
  }) : []
776
- ).filter((t) => t != null).filter((t) => t !== "default"), Se = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), ke = (e) => e.dealBars.filter((t) => t.dealBarType === k.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
777
- class we {
776
+ ).filter((t) => t != null).filter((t) => t !== "default"), ke = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), we = (e) => e.dealBars.filter((t) => t.dealBarType === k.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
777
+ class $e {
778
778
  constructor(t, a) {
779
779
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
780
780
  }
@@ -800,11 +800,11 @@ class we {
800
800
  return JSON.parse(o).data;
801
801
  }
802
802
  }
803
- const $e = async (e, t, { country: a, language: l }) => {
803
+ const Ne = async (e, t, { country: a, language: l }) => {
804
804
  const r = t.collectionBreaks;
805
805
  if (!t.collectionBreaksEnabled || !r) return;
806
806
  let i;
807
- r.visibility === "deal-products" ? i = await T(e, {
807
+ r.visibility === "deal-products" ? i = await M(e, {
808
808
  country: a,
809
809
  language: l,
810
810
  blockVisibility: t.blockVisibility,
@@ -817,7 +817,7 @@ const $e = async (e, t, { country: a, language: l }) => {
817
817
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
818
818
  (n) => `gid://shopify/Collection/${n}`
819
819
  )
820
- }) : i = await T(e, {
820
+ }) : i = await M(e, {
821
821
  country: a,
822
822
  language: l,
823
823
  blockVisibility: r.visibility,
@@ -831,7 +831,7 @@ const $e = async (e, t, { country: a, language: l }) => {
831
831
  ({ id: n }) => n
832
832
  )
833
833
  });
834
- let o = await D(e, {
834
+ let o = await A(e, {
835
835
  country: a,
836
836
  language: l,
837
837
  productIds: i.map((n) => Number(n.split("/").pop())),
@@ -840,7 +840,7 @@ const $e = async (e, t, { country: a, language: l }) => {
840
840
  return o = o.filter(
841
841
  (n) => n.availableForSale
842
842
  ), o;
843
- }, Ne = () => ({
843
+ }, De = () => ({
844
844
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
845
845
  "system.invalid_variant": "Sorry, this is not currently available.",
846
846
  "system.unavailable_option_value": "Unavailable",
@@ -865,7 +865,7 @@ const $e = async (e, t, { country: a, language: l }) => {
865
865
  "system.letters_only": "Only letters are allowed.",
866
866
  "system.numbers_only": "Only numbers are allowed.",
867
867
  "system.personalisation_required_alert": "Please add personalisation for every item to continue."
868
- }), De = "2026-07", Ae = async (e, {
868
+ }), Ae = "2026-07", xe = async (e, {
869
869
  productId: t,
870
870
  dealBlockId: a,
871
871
  country: l = void 0,
@@ -873,55 +873,55 @@ const $e = async (e, t, { country: a, language: l }) => {
873
873
  }) => {
874
874
  var i, o;
875
875
  try {
876
- const n = [Number(t.split("/").pop())], m = new xe(e);
876
+ const n = [Number(t.split("/").pop())], m = new Ge(e);
877
877
  l = l || ((i = m.i18n) == null ? void 0 : i.country), r = r || ((o = m.i18n) == null ? void 0 : o.language);
878
- const c = await Z(m, {
878
+ const d = await ee(m, {
879
879
  language: r,
880
880
  country: l,
881
881
  useExternalMetafieldNamespace: !0
882
882
  });
883
- m.shopifyDomain = c.shopifyDomain;
884
- const d = c.storefrontAccessToken ? new we(
885
- c.shopifyDomain,
886
- c.storefrontAccessToken
887
- ) : m, [g, y] = await Promise.all([
888
- D(d, {
883
+ m.shopifyDomain = d.shopifyDomain;
884
+ const c = d.storefrontAccessToken ? new $e(
885
+ d.shopifyDomain,
886
+ d.storefrontAccessToken
887
+ ) : m, [f, g] = await Promise.all([
888
+ A(c, {
889
889
  country: l,
890
890
  language: r,
891
891
  productIds: n,
892
892
  useExternalMetafieldNamespace: !0
893
893
  }),
894
- K(d, {
894
+ W(c, {
895
895
  useExternalMetafieldNamespace: !0,
896
- useMetaobjects: c.featureFlags.storefront_metaobjects
896
+ useMetaobjects: d.featureFlags.storefront_metaobjects
897
897
  })
898
- ]), p = g[0];
899
- if (!p)
898
+ ]), y = f[0];
899
+ if (!y)
900
900
  return null;
901
- const h = L(y, p);
901
+ const h = J(g, y);
902
902
  let s;
903
903
  if (a ? (s = h.find(
904
904
  (P) => P.id === a || P.nanoId === a
905
905
  ), s || (s = h[0])) : s = h[0], !s)
906
906
  return null;
907
- const f = ae(s), b = ge(s), [_, u, v, I] = await Promise.all([
908
- D(d, {
907
+ const p = se(s), b = he(s), [_, u, v, I] = await Promise.all([
908
+ A(c, {
909
909
  country: l,
910
910
  language: r,
911
911
  productIds: b,
912
912
  useExternalMetafieldNamespace: !0
913
913
  }),
914
- te(d, f, 300),
915
- $e(d, s, {
914
+ ae(c, p, 300),
915
+ Ne(c, s, {
916
916
  country: l,
917
917
  language: r
918
918
  }),
919
- Ne()
919
+ De()
920
920
  ]);
921
921
  return {
922
- product: p,
922
+ product: y,
923
923
  dealBlock: s,
924
- config: c,
924
+ config: d,
925
925
  otherProducts: _,
926
926
  mediaImages: u,
927
927
  collectionBreaksProducts: v ?? [],
@@ -931,7 +931,7 @@ const $e = async (e, t, { country: a, language: l }) => {
931
931
  return console.error(n), null;
932
932
  }
933
933
  };
934
- class xe {
934
+ class Ge {
935
935
  constructor(t) {
936
936
  this.storefront = t, this.shopifyDomain = "";
937
937
  }
@@ -942,7 +942,7 @@ class xe {
942
942
  return (await this.storefront.request(t, a)).data;
943
943
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
944
944
  const l = await fetch(
945
- `https://${this.storefront.shopifyDomain}/api/${De}/graphql.json`,
945
+ `https://${this.storefront.shopifyDomain}/api/${Ae}/graphql.json`,
946
946
  {
947
947
  body: JSON.stringify({
948
948
  query: t,
@@ -977,32 +977,32 @@ class xe {
977
977
  return this.storefront.i18n;
978
978
  }
979
979
  }
980
- const Qe = Ae, $ = "kaching-bundles-block", U = 1e4, Ge = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Be = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Ee = async (e) => {
980
+ const Xe = xe, $ = "kaching-bundles-block", j = 1e4, Be = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ee = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Ce = async (e) => {
981
981
  const t = e.document;
982
982
  if (!e.customElements.get($)) {
983
983
  if (N.has(t))
984
- return A(e, $);
984
+ return x(e, $);
985
985
  N.add(t);
986
986
  try {
987
- await Te(e);
987
+ await qe(e);
988
988
  } catch (a) {
989
989
  throw N.delete(t), a;
990
990
  }
991
991
  }
992
- }, Ce = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Me = () => Ce() ? Ge : Be, Te = (e) => {
992
+ }, Me = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Te = () => Me() ? Be : Ee, qe = (e) => {
993
993
  const t = e.document;
994
994
  return new Promise((a, l) => {
995
- const r = Me();
995
+ const r = Te();
996
996
  if (t.querySelector(
997
997
  `script[src="${r}"]`
998
998
  )) {
999
- A(e, $).then(a).catch(l);
999
+ x(e, $).then(a).catch(l);
1000
1000
  return;
1001
1001
  }
1002
1002
  const o = t.createElement("script");
1003
- o.src = r, o.onload = () => A(e, $).then(a).catch(l), o.onerror = () => l(new Error("Failed to load script")), t.head.appendChild(o);
1003
+ o.src = r, o.onload = () => x(e, $).then(a).catch(l), o.onerror = () => l(new Error("Failed to load script")), t.head.appendChild(o);
1004
1004
  });
1005
- }, A = (e, t) => new Promise((a, l) => {
1005
+ }, x = (e, t) => new Promise((a, l) => {
1006
1006
  if (e.customElements.get(t)) {
1007
1007
  a();
1008
1008
  return;
@@ -1013,18 +1013,18 @@ const Qe = Ae, $ = "kaching-bundles-block", U = 1e4, Ge = "https://bundles-integ
1013
1013
  (r, i) => setTimeout(
1014
1014
  () => i(
1015
1015
  new Error(
1016
- `Custom element "${t}" failed to register within ${U}ms`
1016
+ `Custom element "${t}" failed to register within ${j}ms`
1017
1017
  )
1018
1018
  ),
1019
- U
1019
+ j
1020
1020
  )
1021
1021
  )
1022
1022
  ]).then(() => a()).catch(l);
1023
1023
  });
1024
- var x = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(x || {});
1025
- const S = "a-f\\d", qe = `#?[${S}]{3}[${S}]?`, Oe = `#?[${S}]{6}([${S}]{2})?`, je = new RegExp(`[^#${S}]`, "gi"), Ue = new RegExp(`^${qe}$|^${Oe}$`, "i");
1026
- function Ve(e, t = {}) {
1027
- if (typeof e != "string" || je.test(e) || !Ue.test(e))
1024
+ var G = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(G || {});
1025
+ const S = "a-f\\d", Oe = `#?[${S}]{3}[${S}]?`, je = `#?[${S}]{6}([${S}]{2})?`, Ve = new RegExp(`[^#${S}]`, "gi"), Ue = new RegExp(`^${Oe}$|^${je}$`, "i");
1026
+ function Fe(e, t = {}) {
1027
+ if (typeof e != "string" || Ve.test(e) || !Ue.test(e))
1028
1028
  throw new TypeError("Expected a valid hex string");
1029
1029
  e = e.replace(/^#/, "");
1030
1030
  let a = 1;
@@ -1038,7 +1038,7 @@ function Ve(e, t = {}) {
1038
1038
  }
1039
1039
  return { red: r, green: i, blue: o, alpha: n };
1040
1040
  }
1041
- const Fe = ({ price: e }) => ({
1041
+ const Re = ({ price: e }) => ({
1042
1042
  id: 123,
1043
1043
  handle: "123",
1044
1044
  url: null,
@@ -1073,7 +1073,7 @@ const Fe = ({ price: e }) => ({
1073
1073
  text4: null
1074
1074
  },
1075
1075
  isNativeBundle: !1
1076
- }), Re = () => ({
1076
+ }), Le = () => ({
1077
1077
  shopifyDomain: "",
1078
1078
  moneyFormat: "${{amount_with_comma_separator}}",
1079
1079
  locale: "en",
@@ -1129,7 +1129,7 @@ const Fe = ({ price: e }) => ({
1129
1129
  },
1130
1130
  shopCustomStyles: "",
1131
1131
  featureFlags: {}
1132
- }), Le = ({
1132
+ }), Je = ({
1133
1133
  color: e,
1134
1134
  cornerRadius: t
1135
1135
  }) => {
@@ -1183,7 +1183,7 @@ const Fe = ({ price: e }) => ({
1183
1183
  dealBars: [
1184
1184
  {
1185
1185
  id: "PfFU",
1186
- dealBarType: x.QuantityBreak,
1186
+ dealBarType: G.QuantityBreak,
1187
1187
  title: "1 pack",
1188
1188
  subtitle: "Standard price",
1189
1189
  label: "",
@@ -1203,7 +1203,7 @@ const Fe = ({ price: e }) => ({
1203
1203
  },
1204
1204
  {
1205
1205
  id: "1f-9",
1206
- dealBarType: x.QuantityBreak,
1206
+ dealBarType: G.QuantityBreak,
1207
1207
  title: "2 pack",
1208
1208
  subtitle: "You save {{saved_percentage}}",
1209
1209
  label: "SAVE {{saved_total}}",
@@ -1393,8 +1393,8 @@ const Fe = ({ price: e }) => ({
1393
1393
  imageSize: 48,
1394
1394
  imageCornerRadius: 6
1395
1395
  };
1396
- return e !== void 0 && (a.colors.border = { ...Ve(e), alpha: 1 }), a;
1397
- }, He = ({
1396
+ return e !== void 0 && (a.colors.border = { ...Fe(e), alpha: 1 }), a;
1397
+ }, Ye = ({
1398
1398
  data: e,
1399
1399
  selectedVariantId: t,
1400
1400
  preview: a,
@@ -1402,75 +1402,86 @@ const Fe = ({ price: e }) => ({
1402
1402
  targetWindow: r
1403
1403
  }) => {
1404
1404
  const i = B(null), [o, n] = R(!1), m = B(!1);
1405
- if (E(() => {
1405
+ D(() => {
1406
1406
  if (!i.current || o) return;
1407
1407
  (async () => {
1408
- await Ee(r ?? window), n(!0);
1408
+ await Ce(r ?? window), n(!0);
1409
1409
  })();
1410
- }, [o, r]), E(() => {
1410
+ }, [o, r]), D(() => {
1411
1411
  const c = i.current;
1412
1412
  if (!o || !c) return;
1413
- const d = () => {
1414
- const y = c.items().map((p) => ({
1415
- merchandiseId: `gid://shopify/ProductVariant/${p.id}`,
1416
- quantity: p.quantity,
1417
- attributes: Object.entries(p.properties).map(([h, s]) => ({
1418
- key: h,
1419
- value: String(s)
1413
+ const f = () => {
1414
+ const y = c.items().map((h) => ({
1415
+ merchandiseId: `gid://shopify/ProductVariant/${h.id}`,
1416
+ quantity: h.quantity,
1417
+ attributes: Object.entries(h.properties).map(([s, p]) => ({
1418
+ key: s,
1419
+ value: String(p)
1420
1420
  })),
1421
- sellingPlanId: p.selling_plan ? `gid://shopify/SellingPlan/${p.selling_plan}` : void 0
1421
+ sellingPlanId: h.selling_plan ? `gid://shopify/SellingPlan/${h.selling_plan}` : void 0
1422
1422
  }));
1423
1423
  l == null || l(y);
1424
1424
  };
1425
- return m.current || (typeof c.items == "function" ? d() : c.addEventListener("kaching-bundles-block-loaded", d), m.current = !0), c.addEventListener("variants-changed", d), () => {
1426
- c.removeEventListener("kaching-bundles-block-loaded", d), c.removeEventListener("variants-changed", d);
1425
+ return m.current || (typeof c.items == "function" ? f() : c.addEventListener("kaching-bundles-block-loaded", f), m.current = !0), c.addEventListener("variants-changed", f), () => {
1426
+ c.removeEventListener("kaching-bundles-block-loaded", f), c.removeEventListener("variants-changed", f);
1427
1427
  };
1428
- }, [o, l]), e) {
1429
- const {
1430
- config: c,
1431
- dealBlock: d,
1432
- product: g,
1433
- otherProducts: y,
1434
- mediaImages: p,
1435
- collectionBreaksProducts: h,
1436
- translations: s
1437
- } = e;
1438
- return /* @__PURE__ */ G(
1439
- "kaching-bundles-block",
1440
- {
1441
- ref: i,
1442
- "deal-block-id": d.id,
1443
- config: JSON.stringify(c),
1444
- "deal-block": JSON.stringify(d),
1445
- "media-images": JSON.stringify(p),
1446
- product: JSON.stringify(g),
1447
- "other-products": JSON.stringify(y),
1448
- "collection-breaks-products": JSON.stringify(h),
1449
- translations: JSON.stringify(s),
1450
- "current-variant-id": t ? t.split("/").pop() : String(g.variants[0].id)
1451
- }
1452
- );
1453
- } else if (a) {
1454
- const { cornerRadius: c, color: d, price: g } = a, y = Fe({ price: g }), p = Re(), h = Le({ color: d, cornerRadius: c });
1455
- return /* @__PURE__ */ G(
1456
- "kaching-bundles-block",
1457
- {
1458
- ref: i,
1459
- "deal-block-id": h.id,
1460
- config: JSON.stringify(p),
1461
- "deal-block": JSON.stringify(h),
1462
- "media-images": JSON.stringify([]),
1463
- product: JSON.stringify(y),
1464
- "other-products": JSON.stringify([]),
1465
- "collection-breaks-products": JSON.stringify([]),
1466
- translations: JSON.stringify({}),
1467
- "current-variant-id": String(y.variants[0].id)
1468
- }
1469
- );
1470
- } else
1471
- return null;
1428
+ }, [o, l]);
1429
+ const d = e ? Qe(e, t) : a ? He(a) : null;
1430
+ return ze(() => {
1431
+ const c = i.current;
1432
+ if (!(!c || !d))
1433
+ for (const [f, g] of Object.entries(d.jsonAttributes))
1434
+ c.getAttribute(f) !== g && c.setAttribute(f, g);
1435
+ }), d ? /* @__PURE__ */ F(
1436
+ "kaching-bundles-block",
1437
+ {
1438
+ ref: i,
1439
+ "deal-block-id": d.dealBlockId,
1440
+ ...d.jsonAttributes,
1441
+ "current-variant-id": d.currentVariantId
1442
+ }
1443
+ ) : null;
1444
+ }, ze = typeof window > "u" ? D : L, Qe = ({
1445
+ config: e,
1446
+ dealBlock: t,
1447
+ product: a,
1448
+ otherProducts: l,
1449
+ mediaImages: r,
1450
+ collectionBreaksProducts: i,
1451
+ translations: o
1452
+ }, n) => ({
1453
+ dealBlockId: t.id,
1454
+ currentVariantId: n ? n.split("/").pop() : String(a.variants[0].id),
1455
+ jsonAttributes: {
1456
+ config: JSON.stringify(e),
1457
+ "deal-block": JSON.stringify(t),
1458
+ "media-images": JSON.stringify(r),
1459
+ product: JSON.stringify(a),
1460
+ "other-products": JSON.stringify(l),
1461
+ "collection-breaks-products": JSON.stringify(i),
1462
+ translations: JSON.stringify(o)
1463
+ }
1464
+ }), He = ({
1465
+ cornerRadius: e,
1466
+ color: t,
1467
+ price: a
1468
+ }) => {
1469
+ const l = Re({ price: a }), r = Le(), i = Je({ color: t, cornerRadius: e });
1470
+ return {
1471
+ dealBlockId: i.id,
1472
+ currentVariantId: String(l.variants[0].id),
1473
+ jsonAttributes: {
1474
+ config: JSON.stringify(r),
1475
+ "deal-block": JSON.stringify(i),
1476
+ "media-images": JSON.stringify([]),
1477
+ product: JSON.stringify(l),
1478
+ "other-products": JSON.stringify([]),
1479
+ "collection-breaks-products": JSON.stringify([]),
1480
+ translations: JSON.stringify({})
1481
+ }
1482
+ };
1472
1483
  };
1473
1484
  export {
1474
- He as KachingBundle,
1475
- Qe as fetchKachingBundlesData
1485
+ Ye as KachingBundle,
1486
+ Xe as fetchKachingBundlesData
1476
1487
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kachingappz/bundles-js",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/kachingappz/bundles.git",
@@ -64,15 +64,17 @@
64
64
  "hex-rgb": "^5.0.0",
65
65
  "jsdom": "^29.1.1",
66
66
  "react": "^18.2.0",
67
+ "react-19": "npm:react@^19.2.0",
67
68
  "react-dom": "^18.2.0",
69
+ "react-dom-19": "npm:react-dom@^19.2.0",
68
70
  "typescript": "~5.7.2",
69
71
  "typescript-eslint": "^8.24.1",
70
72
  "vite": "^6.2.0",
71
73
  "vite-plugin-dts": "^4.5.3",
72
74
  "vitest": "^3.2.7",
73
75
  "@kachingappz/bundles-types": "^0.1.0",
74
- "@kachingappz/kaching-bundles-block": "^1.0.0",
75
- "@kachingappz/bundles-storefront-api": "^0.1.0"
76
+ "@kachingappz/bundles-storefront-api": "^0.1.0",
77
+ "@kachingappz/kaching-bundles-block": "^1.0.0"
76
78
  },
77
79
  "peerDependencies": {
78
80
  "react": "^18.2.0 || ^19.0.0",