@kachingappz/bundles-js 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(){"use strict";const N={config:{shopifyDomain:"",moneyFormat:"${{amount}}",locale:"en",country:"US",currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,accessScopes:[],customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,defaultTranslations:{"system.out_of_stock":"There's not enough items in our stock, please select smaller bundle.","system.invalid_variant":"Sorry, this is not currently available.","system.unavailable_option_value":"Unavailable","system.confirm":"Confirm","system.cancel":"Cancel","system.free":"FREE","system.search":"Search","system.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"},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:""},dealBlock:{id:"example",nanoId:"example",blockName:"Bundle",discountName:"",blockTitle:"BUNDLE & SAVE",blockLayout:"vertical",blockVisibility:"all-products",marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:"",useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:".00",updateNativePrice:!1,updateNativePriceType:"item",skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:"duo",cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:"14",style:"bold"},title:{size:"20",style:"medium"},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"}},dealBars:[{id:"single",dealBarType:"quantity-break",quantitySelector:!1,title:"Single",subtitle:"Standard price",label:"",quantity:1,discountType:"default",discountValue:"",badgeStyle:"simple",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null},{id:"duo",dealBarType:"quantity-break",quantitySelector:!1,title:"Duo",subtitle:"You save 20%",label:"SAVE $32",quantity:2,discountType:"percentage",discountValue:"20",badgeStyle:"most-popular",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null},{id:"trio",dealBarType:"quantity-break",quantitySelector:!1,title:"Trio",subtitle:"You save 25%",label:"SAVE $60",quantity:3,discountType:"percentage",discountValue:"25",badgeStyle:"simple",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null}],swatchOptions:[],swatchSize:18,swatchShape:"circle",imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:"",customStyles:"",lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:"example-product",url:null,availableForSale:!0,title:"Example product",image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:["Default Title"],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},P=({country:t,language:e})=>{const l=[];return t&&l.push(`country: ${t}`),e&&l.push(`language: ${e}`),l.length>0?`@inContext(${l.join(", ")})`:""},x=async(t,{useExternalMetafieldNamespace:e,useMetaobjects:l})=>l?T(t):B(t),B=async(t,e)=>{var a;const l=(a=(await t.query(`
1
+ (function(){"use strict";const N={config:{shopifyDomain:"",moneyFormat:"${{amount}}",locale:"en",country:"US",currencyRate:1,marketId:0,productId:null,storefrontAccessToken:null,accessScopes:[],customApiHost:null,keepQuantityInput:!1,ignoreDeselect:!1,ignoreUnitPrice:!1,requireCustomerLogin:!1,abTestsRunning:!1,webPixel:!1,b2bCustomer:!1,isLoggedIn:!1,preview:!0,previewAlerts:!1,defaultTranslations:{"system.out_of_stock":"There's not enough items in our stock, please select smaller bundle.","system.invalid_variant":"Sorry, this is not currently available.","system.unavailable_option_value":"Unavailable","system.confirm":"Confirm","system.cancel":"Cancel","system.free":"FREE","system.search":"Search","system.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"},customSelectors:{quantity:null,addToCartButton:null,variantPicker:null,price:null,priceCompare:null},featureFlags:{},shopCustomStyles:""},dealBlock:{id:"example",nanoId:"example",blockName:"Bundle",discountName:"",blockTitle:"BUNDLE & SAVE",blockLayout:"vertical",blockVisibility:"all-products",marketId:null,currency:null,excludeB2bCustomers:!1,excludePos:!1,startTimestamp:0,endTimestamp:null,differentVariantsEnabled:!0,hideVariantPicker:!0,disableVariantOptionSync:!1,hideUnavailableOptions:!1,showPricesPerItem:!1,showBothPrices:!1,unitLabel:"",useProductCompareAtPrice:!0,showPricesWithoutDecimals:!1,priceRounding:!1,priceRoundingPrecision:".00",updateNativePrice:!1,updateNativePriceType:"item",skipCart:!1,showVariantsForSingleQuantity:!1,preselectedDealBarId:"duo",cornerRadius:16,spacing:1,selectedProductIds:[],selectedCollectionIds:[],excludedProductIds:[],excludedCollectionIds:[],colors:{background:{red:245,green:245,blue:245,alpha:1},selectedBackground:{red:255,green:255,blue:255,alpha:1},border:{red:0,green:0,blue:0,alpha:1},blockTitle:{red:0,green:0,blue:0,alpha:1},title:{red:0,green:0,blue:0,alpha:1},subtitle:{red:85,green:85,blue:85,alpha:1},price:{red:0,green:0,blue:0,alpha:1},fullPrice:{red:85,green:85,blue:85,alpha:1},labelBackground:{red:171,green:239,blue:198,alpha:1},label:{red:0,green:0,blue:0,alpha:1},badgeBackground:{red:0,green:0,blue:0,alpha:1},badgeText:{red:255,green:255,blue:255,alpha:1},freeGiftBackground:{red:0,green:0,blue:0,alpha:.3},freeGiftText:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedBackground:{red:0,green:0,blue:0,alpha:1},freeGiftSelectedText:{red:255,green:255,blue:255,alpha:1},upsellBackground:{red:0,green:0,blue:0,alpha:.2},upsellText:{red:0,green:0,blue:0,alpha:1},upsellSelectedBackground:{red:0,green:0,blue:0,alpha:.2},upsellSelectedText:{red:0,green:0,blue:0,alpha:1}},fonts:{blockTitle:{size:"14",style:"bold"},title:{size:"20",style:"medium"},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"}},dealBars:[{id:"single",dealBarType:"quantity-break",quantitySelector:!1,title:"Single",subtitle:"Standard price",label:"",quantity:1,discountType:"default",discountValue:"",badgeStyle:"simple",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null},{id:"duo",dealBarType:"quantity-break",quantitySelector:!1,title:"Duo",subtitle:"You save 20%",label:"SAVE $32",quantity:2,discountType:"percentage",discountValue:"20",badgeStyle:"most-popular",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null},{id:"trio",dealBarType:"quantity-break",quantitySelector:!1,title:"Trio",subtitle:"You save 25%",label:"SAVE $60",quantity:3,discountType:"percentage",discountValue:"25",badgeStyle:"simple",badgeText:"",badgeImageGID:null,mediaImageGID:null,freeGifts:[],multipleGiftsSelectors:[],upsells:[],showAsSoldOutEnabled:!1,showAsSoldOut:null,productPersonalisation:null,highlights:null,sellingPlanEnabled:!1,sellingPlanGid:null}],swatchOptions:[],swatchSize:18,swatchShape:"circle",imageSize:48,imageCornerRadius:6,defaultVariantsV2:[],collectionBreaksEnabled:!1,collectionBreaks:null,chooseProductModal:null,timerEnabled:!1,timer:null,subscriptionsEnabled:!1,subscriptions:null,stickyAtcEnabled:!1,stickyAtc:null,progressiveGiftsEnabled:!1,progressiveGifts:null,checkboxUpsellsEnabled:!1,checkboxUpsells:null,customStylesEnabled:!1,shopCustomStyles:"",customStyles:"",lowStockAlertEnabled:!1,lowStockAlert:null},product:{id:1,handle:"example-product",url:null,availableForSale:!0,title:"Example product",image:null,collectionIds:[],options:[],selectedVariantId:1,variants:[{id:1,availableForSale:!0,price:8e3,compareAtPrice:null,options:["Default Title"],imageId:null,image:null,unitPriceMeasurement:null,sellingPlans:[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:50}],metafields:{text:null,text2:null,text3:null,text4:null},requiresSellingPlan:!1,sellingPlans:[],isNativeBundle:!1},otherProducts:[],mediaImages:[],collectionBreaksProducts:[],translations:{}},b=({country:t,language:e})=>{const l=[];return t&&l.push(`country: ${t}`),e&&l.push(`language: ${e}`),l.length>0?`@inContext(${l.join(", ")})`:""},x=async(t,{useExternalMetafieldNamespace:e,useMetaobjects:l})=>l?T(t):B(t),B=async(t,e)=>{var a;const l=(a=(await t.query(`
2
2
  query FetchDealBlocks($metafieldNamespace: String!) {
3
3
  shop {
4
4
  metafield(namespace: $metafieldNamespace, key: "deal_blocks") {
@@ -21,10 +21,20 @@
21
21
  }
22
22
  }
23
23
  }
24
- `,{variables:{type:l,cursor:n}});for(const c of o.metaobjects.nodes){const s=c.fields.find(m=>m.key==="settings");s!=null&&s.value&&a.push(JSON.parse(s.value))}if(!o.metaobjects.pageInfo.hasNextPage)break;n=o.metaobjects.pageInfo.endCursor}return a},E="app--2935586817",q=async(t,{language:e,country:l,useExternalMetafieldNamespace:a})=>{const n=`${E}--kaching_bundles`,o=E,{shop:{moneyFormat:c,currencyRateConstant:s,primaryDomain:m,settingsMetafield:p}}=await t.query(`
25
- query config($metafieldNamespace: String!, $settingsNamespace: String!) {
24
+ `,{variables:{type:l,cursor:n}});for(const c of o.metaobjects.nodes){const s=c.fields.find(m=>m.key==="settings");s!=null&&s.value&&a.push(JSON.parse(s.value))}if(!o.metaobjects.pageInfo.hasNextPage)break;n=o.metaobjects.pageInfo.endCursor}return a},E="app--2935586817",q=async(t,{language:e,country:l,useExternalMetafieldNamespace:a})=>{const n=`${E}--kaching_bundles`,o=E,c=b({country:l}),{localization:{country:{currency:{isoCode:s}}},shop:{moneyFormat:m,paymentSettings:{currencyCode:p},currencyRateConstant:d,primaryDomain:f,settingsMetafield:u}}=await t.query(`
25
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
26
+ localization {
27
+ country {
28
+ currency {
29
+ isoCode
30
+ }
31
+ }
32
+ }
26
33
  shop {
27
34
  moneyFormat
35
+ paymentSettings {
36
+ currencyCode
37
+ }
28
38
  primaryDomain {
29
39
  host
30
40
  }
@@ -36,7 +46,7 @@
36
46
  }
37
47
  }
38
48
  }
39
- `,{variables:{metafieldNamespace:n,settingsNamespace:o}}),d=s?M(s.value):1,i=p?JSON.parse(p.value):null,u=(i==null?void 0:i.feature_flags)??{},r=(i==null?void 0:i.custom_selectors)??{};return{shopifyDomain:m.host,moneyFormat:c,locale:(e==null?void 0:e.toLowerCase())||"en",liquidLocale:(e==null?void 0:e.toLowerCase())||"en",country:l??"US",currencyRate:d,marketId:0,productId:null,storefrontAccessToken:(i==null?void 0:i.storefront_access_token)??null,accessScopes:(i==null?void 0:i.access_scopes)??[],customApiHost:(i==null?void 0:i.custom_api_host)??null,keepQuantityInput:(i==null?void 0:i.keep_quantity_input)??!1,ignoreDeselect:(i==null?void 0:i.ignore_deselect)??!1,ignoreUnitPrice:(i==null?void 0:i.ignore_unit_price)??!1,requireCustomerLogin:(i==null?void 0:i.require_customer_login)??!1,abTestsRunning:(i==null?void 0:i.ab_tests_running)??!1,webPixel:(i==null?void 0:i.web_pixel)??!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!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.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"},customSelectors:{quantity:r.quantity??null,addToCartButton:r.add_to_cart_button??null,variantPicker:r.variant_picker??null,price:r.price??null,priceCompare:r.price_compare??null},shopCustomStyles:(i==null?void 0:i.shop_custom_styles)??"",featureFlags:u}},M=t=>JSON.parse(t).amount/1e6,L=async(t,e,l=200)=>(e=e.filter(Boolean).filter(a=>!a.startsWith("placeholder")),e.length===0?[]:(await t.query(`
49
+ `,{variables:{metafieldNamespace:n,settingsNamespace:o}}),r=s===p?m:L(s),g=d?M(d.value):1,i=u?JSON.parse(u.value):null,h=(i==null?void 0:i.feature_flags)??{},y=(i==null?void 0:i.custom_selectors)??{};return{shopifyDomain:f.host,moneyFormat:r,locale:(e==null?void 0:e.toLowerCase())||"en",liquidLocale:(e==null?void 0:e.toLowerCase())||"en",country:l??"US",currencyRate:g,marketId:0,productId:null,storefrontAccessToken:(i==null?void 0:i.storefront_access_token)??null,accessScopes:(i==null?void 0:i.access_scopes)??[],customApiHost:(i==null?void 0:i.custom_api_host)??null,keepQuantityInput:(i==null?void 0:i.keep_quantity_input)??!1,ignoreDeselect:(i==null?void 0:i.ignore_deselect)??!1,ignoreUnitPrice:(i==null?void 0:i.ignore_unit_price)??!1,requireCustomerLogin:(i==null?void 0:i.require_customer_login)??!1,abTestsRunning:(i==null?void 0:i.ab_tests_running)??!1,webPixel:(i==null?void 0:i.web_pixel)??!1,b2bCustomer:!1,isLoggedIn:!1,preview:!1,previewAlerts:!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.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"},customSelectors:{quantity:y.quantity??null,addToCartButton:y.add_to_cart_button??null,variantPicker:y.variant_picker??null,price:y.price??null,priceCompare:y.price_compare??null},shopCustomStyles:(i==null?void 0:i.shop_custom_styles)??"",featureFlags:h}},M=t=>JSON.parse(t).amount/1e6,L=t=>new Intl.NumberFormat("en",{style:"currency",currency:t,currencyDisplay:"narrowSymbol"}).format(1).replace(/1(\.00)?/,"{{amount}}"),O=async(t,e,l=200)=>(e=e.filter(Boolean).filter(a=>!a.startsWith("placeholder")),e.length===0?[]:(await t.query(`
40
50
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
41
51
  nodes(ids: $mediaImageIds) {
42
52
  ... on MediaImage {
@@ -47,7 +57,7 @@
47
57
  }
48
58
  }
49
59
  }
50
- `,{variables:{mediaImageIds:e,size:l}})).nodes.filter(Boolean).map(a=>({gid:a.id,url:a.image.url}))),A=async(t,{country:e,language:l,blockVisibility:a,excludedProductGIDs:n,selectedProductGIDs:o,selectedCollectionGIDs:c,limit:s=250})=>{switch(a){case"selected-products":return o.slice(0,s);case"all-products":case"excluded-products":{const m=P({country:e,language:l});let p=(await t.query(`
60
+ `,{variables:{mediaImageIds:e,size:l}})).nodes.filter(Boolean).map(a=>({gid:a.id,url:a.image.url}))),A=async(t,{country:e,language:l,blockVisibility:a,excludedProductGIDs:n,selectedProductGIDs:o,selectedCollectionGIDs:c,limit:s=250})=>{switch(a){case"selected-products":return o.slice(0,s);case"all-products":case"excluded-products":{const m=b({country:e,language:l});let p=(await t.query(`
51
61
  query FetchProductGIDs($limit: Int!) ${m} {
52
62
  products(first: $limit) {
53
63
  nodes {
@@ -55,7 +65,7 @@
55
65
  }
56
66
  }
57
67
  }
58
- `,{variables:{limit:s}})).products.nodes.map(d=>d.id);return a==="excluded-products"&&(p=p.filter(d=>!n.includes(d))),p}case"selected-collections":{const m=P({country:e,language:l}),p=(await t.query(`
68
+ `,{variables:{limit:s}})).products.nodes.map(d=>d.id);return a==="excluded-products"&&(p=p.filter(d=>!n.includes(d))),p}case"selected-collections":{const m=b({country:e,language:l}),p=(await t.query(`
59
69
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
60
70
  nodes(ids: $collectionGIDs) {
61
71
  ... on Collection {
@@ -67,7 +77,7 @@
67
77
  }
68
78
  }
69
79
  }
70
- `,{variables:{collectionGIDs:c,limit:s}})).nodes.filter(d=>d!==null).flatMap(d=>d.products.nodes.map(i=>i.id));return Array.from(new Set(p)).slice(0,s)}}},w=`
80
+ `,{variables:{collectionGIDs:c,limit:s}})).nodes.filter(d=>d!==null).flatMap(d=>d.products.nodes.map(f=>f.id));return Array.from(new Set(p)).slice(0,s)}}},w=`
71
81
  id
72
82
  availableForSale
73
83
  price {
@@ -104,7 +114,7 @@
104
114
  }
105
115
  }
106
116
  quantityAvailable @include(if: $includeAvailableQuantity)
107
- `,_=async(t,{country:e,language:l,productIds:a,includeSellingPlans:n=!0,includeAvailableQuantity:o=!0,useExternalMetafieldNamespace:c=!1})=>{if(!a.length)return[];const s=a.map(d=>typeof d=="string"&&d.startsWith("gid://")?d:`gid://shopify/Product/${d}`),m=P({country:e,language:l});let p=(await t.query(`
117
+ `,_=async(t,{country:e,language:l,productIds:a,includeSellingPlans:n=!0,includeAvailableQuantity:o=!0,useExternalMetafieldNamespace:c=!1})=>{if(!a.length)return[];const s=a.map(d=>typeof d=="string"&&d.startsWith("gid://")?d:`gid://shopify/Product/${d}`),m=b({country:e,language:l});let p=(await t.query(`
108
118
  query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${m} {
109
119
  nodes(ids: $productGIDs) {
110
120
  ... on Product {
@@ -186,7 +196,7 @@
186
196
  }
187
197
  }
188
198
  }
189
- `,{variables:{productGIDs:s,includeSellingPlans:n,includeAvailableQuantity:o,metafieldNamespace:c?"app--2935586817--kaching_bundles":"$app:kaching_bundles"}})).nodes.filter(d=>d!=null);return p=await Promise.all(p.map(d=>O(t,d,{includeSellingPlans:n,includeAvailableQuantity:o}))),p.map(U)},O=async(t,e,l)=>{if(e.variants.nodes.length<250)return e;const a=new Set,n=[],o=[],c=async s=>{let m=!0,p=null;for(;m;){const d=await t.query(`
199
+ `,{variables:{productGIDs:s,includeSellingPlans:n,includeAvailableQuantity:o,metafieldNamespace:c?"app--2935586817--kaching_bundles":"$app:kaching_bundles"}})).nodes.filter(d=>d!=null);return p=await Promise.all(p.map(d=>U(t,d,{includeSellingPlans:n,includeAvailableQuantity:o}))),p.map(F)},U=async(t,e,l)=>{if(e.variants.nodes.length<250)return e;const a=new Set,n=[],o=[],c=async s=>{let m=!0,p=null;for(;m;){const d=await t.query(`
190
200
  query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) {
191
201
  product(id: $productGID) {
192
202
  variants(first: 250, after: $cursor, reverse: $reverse) {
@@ -200,4 +210,4 @@
200
210
  }
201
211
  }
202
212
  }
203
- `,{variables:{productGID:e.id,cursor:p,reverse:s,...l}}),{nodes:i,pageInfo:u}=d.product.variants;for(const r of i){if(a.has(r.id)){m=!1;break}a.add(r.id),s?o.push(r):n.push(r)}u.hasNextPage||(m=!1),p=u.endCursor}};return await Promise.all([c(!1),c(!0)]),e.variants.nodes=[...n,...o.reverse()],e},U=t=>{var c,s,m,p,d,i;const e=t.variants.nodes.map(({unitPriceMeasurement:u,...r})=>{var f,g;return{id:Number(r.id.split("/").pop()),availableForSale:r.availableForSale,price:Math.round(Number(r.price.amount)*100),compareAtPrice:r.compareAtPrice?Math.round(Number(r.compareAtPrice.amount)*100):null,options:r.selectedOptions.map(h=>h.value),imageId:r.image?Number(r.image.id.split("/").pop()):null,image:((f=r.image)==null?void 0:f.url)||null,sellingPlans:((g=r.sellingPlanAllocations)==null?void 0:g.nodes.map(h=>({id:Number(h.sellingPlan.id.split("/").pop()),price:h.priceAdjustments.length>0?Math.round(Number(h.priceAdjustments[0].price.amount)*100):Math.round(Number(r.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:r.quantityAvailable??null,unitPriceMeasurement:u!=null&&u.quantityUnit&&(u!=null&&u.referenceUnit)?{quantityValue:u.quantityValue,quantityUnit:u.quantityUnit.toLowerCase(),referenceValue:u.referenceValue,referenceUnit:u.referenceUnit.toLowerCase()}:null}}),l=t.options.map((u,r)=>{const f=u.optionValues.map(g=>{var h,y,I,v;return{id:Number(g.id.split("/").pop()),defaultName:g.name,name:g.name,swatch:{color:((h=g.swatch)==null?void 0:h.color)||null,image:((v=(I=(y=g.swatch)==null?void 0:y.image)==null?void 0:I.previewImage)==null?void 0:v.url)||null}}});return{defaultName:u.name,name:u.name,position:r+1,optionValues:V(f,r,e)}}),a=u=>{const r=u.priceAdjustments[0];if(!r)return null;const f=r.adjustmentValue;switch(f.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:f.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:Number(f.adjustmentAmount.amount)*100};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:Number(f.price.amount)*100};default:throw new Error(`Unknown price adjustment type: ${f.__typename}`)}},n=((c=t.sellingPlanGroups)==null?void 0:c.nodes.flatMap(u=>u.sellingPlans.nodes.map(r=>({id:Number(r.id.split("/").pop()),name:r.name,priceAdjustment:a(r)}))))||[],o=t.variants.nodes.some(u=>u.requiresComponents);return{id:Number(t.id.split("/").pop()),handle:t.handle,url:t.onlineStoreUrl,availableForSale:t.availableForSale,createdAt:t.createdAt,title:t.title,image:((s=t.featuredImage)==null?void 0:s.url)||null,collectionIds:t.collections.nodes.map(u=>Number(u.id.split("/").pop())),options:l,selectedVariantId:Number(t.variants.nodes[0].id.split("/").pop()),variants:e,requiresSellingPlan:t.requiresSellingPlan,sellingPlans:n,isNativeBundle:o,metafields:{text:((m=t.metafield)==null?void 0:m.value)||null,text2:((p=t.metafield2)==null?void 0:p.value)||null,text3:((d=t.metafield3)==null?void 0:d.value)||null,text4:((i=t.metafield4)==null?void 0:i.value)||null}}},V=(t,e,l)=>t.filter(a=>l.filter(n=>n.options[e]===a.name).length>0),F=(t,e)=>{const l=[],a=t.filter(s=>s.blockVisibility==="selected-products");for(const s of a)s.selectedProductIds.map(Number).includes(e.id)&&l.push(s);const n=t.filter(s=>s.blockVisibility==="selected-collections");for(const s of n)e.collectionIds.some(m=>s.selectedCollectionIds.map(Number).includes(m))&&l.push(s);const o=t.filter(s=>s.blockVisibility==="excluded-products");for(const s of o)!s.excludedProductIds.map(Number).includes(e.id)&&!(s.excludedCollectionIds||[]).some(m=>e.collectionIds.includes(m))&&l.push(s);const c=t.filter(s=>s.blockVisibility==="all-products");for(const s of c)l.push(s);return l},j=t=>[...z(t),...R(t),...H(t),...J(t),...Q(t),...X(t),...K(t),...W(t),...Y(t),...Z(t)].filter(e=>e!=null&&!e.includes("placeholder")),z=t=>t.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),R=t=>t.dealBars.map(({freeGifts:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),H=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(l=>l.mediaImageGID)).filter(e=>e!=null),J=t=>t.dealBars.map(({upsells:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),Q=t=>t.swatchOptions?t.swatchOptions.reduce((e,l)=>{const a=l.images.map(n=>n.mediaImageGID).filter(n=>n!=null);return[...e,...a]},[]):[],X=t=>{if(!t.collectionBreaksEnabled||!t.collectionBreaks)return[];const e=t.collectionBreaks.mediaImageGID;return e?[e]:[]},K=t=>{var e,l,a;return t.progressiveGifts?[...((e=t.progressiveGifts.gifts)==null?void 0:e.map(n=>n.mediaImageGID))||[],(l=t.progressiveGifts.style)==null?void 0:l.lockedMediaImageGID,(a=t.progressiveGifts.dealBarStyle)==null?void 0:a.lockedMediaImageGID].filter(n=>n!=null):[]},W=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.mediaImageGID).filter(e=>e!=null),Y=t=>t.dealBars.map(e=>{var l;return(l=e.productPersonalisation)==null?void 0:l.mediaImageGID}).filter(e=>e!=null),Z=t=>t.dealBars.map(e=>{var l;return(l=e.highlights)==null?void 0:l.customIconGID}).filter(e=>e!=null),ee=t=>{const e=[...te(t),...le(t),...se(t),...ae(t),...ne(t),...ie(t),...re(t)];return Array.from(new Set(e.filter(l=>l!=null)))},te=t=>t.dealBars.flatMap(({freeGifts:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),le=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(l=>l.products?l.products.map(a=>a.id):[]):[]).filter(e=>e!=null),se=t=>{var e;return t.progressiveGiftsEnabled?((e=t.progressiveGifts)==null?void 0:e.gifts.map(l=>l.productGID).filter(l=>l!=null))||[]:[]},ae=t=>t.dealBars.flatMap(({upsells:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),ne=t=>t.dealBars.filter(e=>e.dealBarType==="bundle").flatMap(({bundleProducts:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),ie=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),re=t=>t.dealBars.filter(e=>e.dealBarType==="sku").flatMap(({productGID:e})=>e?[e]:[]);class D{constructor(e,l){this.storefrontApiVersion="2025-10",this.storefrontAccessToken=l,this.shopifyDomain=e}async query(e,l){var s;const a=(l==null?void 0:l.variables)??{};let n=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const o=(s=e.match(/query\s+(\w+)/))==null?void 0:s[1];o&&(n+=`?operation_name=${o}`);const c=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:a})})).text();if(!c)throw new Error("Empty graphql response");return JSON.parse(c).data}}const oe=async(t,e,{country:l,language:a})=>{const n=e.collectionBreaks;if(!e.collectionBreaksEnabled||!n)return;let o;n.visibility==="deal-products"?o=await A(t,{country:l,language:a,blockVisibility:e.blockVisibility,excludedProductGIDs:(e.excludedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedProductGIDs:(e.selectedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedCollectionGIDs:(e.selectedCollectionIds||[]).map(s=>`gid://shopify/Collection/${s}`)}):o=await A(t,{country:l,language:a,blockVisibility:n.visibility,excludedProductGIDs:(n.excludedProducts||[]).map(({id:s})=>s),selectedProductGIDs:(n.selectedProducts||[]).map(({id:s})=>s),selectedCollectionGIDs:(n.selectedCollections||[]).map(({id:s})=>s)}),o=o.slice(0,250);let c=await _(t,{country:l,language:a,productIds:o.map(s=>Number(s.split("/").pop())),useExternalMetafieldNamespace:!0});return c=c.filter(s=>s.availableForSale),c},ce=()=>({"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.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"}),ue=async(t,{productId:e,dealBlockId:l,country:a,language:n})=>{try{const o=[Number(e.split("/").pop())],c=new D(t.shopifyDomain,t.storefrontAccessToken),s=await q(c,{language:n,country:a,useExternalMetafieldNamespace:!0}),m=s.storefrontAccessToken?new D(s.shopifyDomain,s.storefrontAccessToken):c,[p,d]=await Promise.all([_(m,{country:a,language:n,productIds:o,useExternalMetafieldNamespace:!0}),x(m,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),i=p[0];if(!i)return null;const u=F(d,i);let r;if(l?(r=u.find($=>$.id===l||$.nanoId===l),r||(r=u[0])):r=u[0],!r)return null;const f=j(r),g=ee(r),[h,y,I,v]=await Promise.all([_(m,{country:a,language:n,productIds:g,useExternalMetafieldNamespace:!0}),L(m,f,300),oe(m,r,{country:a,language:n}),ce()]);return{product:i,dealBlock:r,config:s,otherProducts:h,mediaImages:y,collectionBreaksProducts:I??[],translations:v}}catch(o){return console.error(o),null}},b="kaching-bundles-block",C=1e4,de="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",me="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",k=new WeakSet,G=async t=>{const e=t.document;if(!t.customElements.get(b)){if(k.has(e))return S(t,b);k.add(e);try{await ge(t)}catch(l){throw k.delete(e),l}}},pe=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",fe=()=>pe()?de:me,ge=t=>{const e=t.document;return new Promise((l,a)=>{const n=fe();if(e.querySelector(`script[src="${n}"]`)){S(t,b).then(l).catch(a);return}const c=e.createElement("script");c.src=n,c.onload=()=>S(t,b).then(l).catch(a),c.onerror=()=>a(new Error("Failed to load script")),e.head.appendChild(c)})},S=(t,e)=>new Promise((l,a)=>{if(t.customElements.get(e)){l();return}Promise.race([t.customElements.whenDefined(e),new Promise((n,o)=>setTimeout(()=>o(new Error(`Custom element "${e}" failed to register within ${C}ms`)),C))]).then(()=>l()).catch(a)});class he extends HTMLElement{constructor(){super(...arguments),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return["selected-variant-id","product-id","country","language"]}async connectedCallback(){await this.initialize()}async initialize(){var c,s;const e=++this.initializeId;if(this.cleanup(),this.hasAttribute("demo")){if(await G(window),e!==this.initializeId)return;this.renderInnerElement(N);return}const l=this.getAttribute("shop-domain"),a=this.getAttribute("storefront-token"),n=this.getAttribute("product-id");if(!l||!a||!n)return;const[o]=await Promise.all([ue({shopifyDomain:l,storefrontAccessToken:a},{productId:n,dealBlockId:this.getAttribute("deal-block-id")??void 0,country:((c=this.getAttribute("country"))==null?void 0:c.toUpperCase())??void 0,language:((s=this.getAttribute("language"))==null?void 0:s.toUpperCase())??void 0}),G(window)]);!o||e!==this.initializeId||this.renderInnerElement(o)}renderInnerElement(e){const{config:l,dealBlock:a,product:n,otherProducts:o,mediaImages:c,collectionBreaksProducts:s,translations:m}=e;this.innerElement=document.createElement("kaching-bundles-block"),this.innerElement.setAttribute("deal-block-id",a.id),this.innerElement.setAttribute("config",JSON.stringify(l)),this.innerElement.setAttribute("deal-block",JSON.stringify(a)),this.innerElement.setAttribute("media-images",JSON.stringify(c??[])),this.innerElement.setAttribute("product",JSON.stringify(n)),this.innerElement.setAttribute("other-products",JSON.stringify(o??[])),this.innerElement.setAttribute("collection-breaks-products",JSON.stringify(s??[])),this.innerElement.setAttribute("translations",JSON.stringify(m??{}));const p=this.getAttribute("selected-variant-id");this.innerElement.setAttribute("current-variant-id",String(p?p.split("/").pop():n.variants[0].id)),this.hasAttribute("compact")&&this.innerElement.setAttribute("compact","");const d=this.innerElement,i=()=>{if(this.innerElement!==d)return;const r=d.items();r&&this.dispatchEvent(new CustomEvent("items-changed",{detail:{items:r},bubbles:!0}))};this.handleItemsChanged=r=>{r.stopPropagation(),i()};const u=this.handleItemsChanged;d.addEventListener("kaching-bundles-block-loaded",()=>{this.innerElement===d&&(d.addEventListener("items-changed",u),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener("items-changed",this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&(this.innerElement.remove(),this.innerElement=null)}attributeChangedCallback(e,l,a){l!==a&&this.isConnected&&(e==="product-id"||e==="country"||e==="language"?this.initialize():e==="selected-variant-id"&&this.innerElement&&a&&this.innerElement.setAttribute("current-variant-id",a.includes("/")?String(a.split("/").pop()):a))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}}customElements.define("kaching-bundle-component",he)})();
213
+ `,{variables:{productGID:e.id,cursor:p,reverse:s,...l}}),{nodes:f,pageInfo:u}=d.product.variants;for(const r of f){if(a.has(r.id)){m=!1;break}a.add(r.id),s?o.push(r):n.push(r)}u.hasNextPage||(m=!1),p=u.endCursor}};return await Promise.all([c(!1),c(!0)]),e.variants.nodes=[...n,...o.reverse()],e},F=t=>{var c,s,m,p,d,f;const e=t.variants.nodes.map(({unitPriceMeasurement:u,...r})=>{var g,i;return{id:Number(r.id.split("/").pop()),availableForSale:r.availableForSale,price:Math.round(Number(r.price.amount)*100),compareAtPrice:r.compareAtPrice?Math.round(Number(r.compareAtPrice.amount)*100):null,options:r.selectedOptions.map(h=>h.value),imageId:r.image?Number(r.image.id.split("/").pop()):null,image:((g=r.image)==null?void 0:g.url)||null,sellingPlans:((i=r.sellingPlanAllocations)==null?void 0:i.nodes.map(h=>({id:Number(h.sellingPlan.id.split("/").pop()),price:h.priceAdjustments.length>0?Math.round(Number(h.priceAdjustments[0].price.amount)*100):Math.round(Number(r.price.amount)*100)})))||[],inventoryManagement:null,inventoryPolicy:null,inventoryQuantity:r.quantityAvailable??null,unitPriceMeasurement:u!=null&&u.quantityUnit&&(u!=null&&u.referenceUnit)?{quantityValue:u.quantityValue,quantityUnit:u.quantityUnit.toLowerCase(),referenceValue:u.referenceValue,referenceUnit:u.referenceUnit.toLowerCase()}:null}}),l=t.options.map((u,r)=>{const g=u.optionValues.map(i=>{var h,y,v,P;return{id:Number(i.id.split("/").pop()),defaultName:i.name,name:i.name,swatch:{color:((h=i.swatch)==null?void 0:h.color)||null,image:((P=(v=(y=i.swatch)==null?void 0:y.image)==null?void 0:v.previewImage)==null?void 0:P.url)||null}}});return{defaultName:u.name,name:u.name,position:r+1,optionValues:V(g,r,e)}}),a=u=>{const r=u.priceAdjustments[0];if(!r)return null;const g=r.adjustmentValue;switch(g.__typename){case"SellingPlanPercentagePriceAdjustment":return{type:"percentage",value:g.adjustmentPercentage};case"SellingPlanFixedAmountPriceAdjustment":return{type:"fixed_amount",value:Number(g.adjustmentAmount.amount)*100};case"SellingPlanFixedPriceAdjustment":return{type:"price",value:Number(g.price.amount)*100};default:throw new Error(`Unknown price adjustment type: ${g.__typename}`)}},n=((c=t.sellingPlanGroups)==null?void 0:c.nodes.flatMap(u=>u.sellingPlans.nodes.map(r=>({id:Number(r.id.split("/").pop()),name:r.name,priceAdjustment:a(r)}))))||[],o=t.variants.nodes.some(u=>u.requiresComponents);return{id:Number(t.id.split("/").pop()),handle:t.handle,url:t.onlineStoreUrl,availableForSale:t.availableForSale,createdAt:t.createdAt,title:t.title,image:((s=t.featuredImage)==null?void 0:s.url)||null,collectionIds:t.collections.nodes.map(u=>Number(u.id.split("/").pop())),options:l,selectedVariantId:Number(t.variants.nodes[0].id.split("/").pop()),variants:e,requiresSellingPlan:t.requiresSellingPlan,sellingPlans:n,isNativeBundle:o,metafields:{text:((m=t.metafield)==null?void 0:m.value)||null,text2:((p=t.metafield2)==null?void 0:p.value)||null,text3:((d=t.metafield3)==null?void 0:d.value)||null,text4:((f=t.metafield4)==null?void 0:f.value)||null}}},V=(t,e,l)=>t.filter(a=>l.filter(n=>n.options[e]===a.name).length>0),j=(t,e)=>{const l=[],a=t.filter(s=>s.blockVisibility==="selected-products");for(const s of a)s.selectedProductIds.map(Number).includes(e.id)&&l.push(s);const n=t.filter(s=>s.blockVisibility==="selected-collections");for(const s of n)e.collectionIds.some(m=>s.selectedCollectionIds.map(Number).includes(m))&&l.push(s);const o=t.filter(s=>s.blockVisibility==="excluded-products");for(const s of o)!s.excludedProductIds.map(Number).includes(e.id)&&!(s.excludedCollectionIds||[]).some(m=>e.collectionIds.includes(m))&&l.push(s);const c=t.filter(s=>s.blockVisibility==="all-products");for(const s of c)l.push(s);return l},z=t=>[...R(t),...H(t),...J(t),...Q(t),...X(t),...K(t),...W(t),...Y(t),...Z(t),...ee(t)].filter(e=>e!=null&&!e.includes("placeholder")),R=t=>t.dealBars.flatMap(e=>[e.mediaImageGID,e.badgeImageGID]).filter(e=>e!=null),H=t=>t.dealBars.map(({freeGifts:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),J=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>(e||[]).map(l=>l.mediaImageGID)).filter(e=>e!=null),Q=t=>t.dealBars.map(({upsells:e})=>(e||[]).map(l=>l.mediaImageGID)).reduce((e,l)=>e.concat(l),[]).filter(e=>e!=null),X=t=>t.swatchOptions?t.swatchOptions.reduce((e,l)=>{const a=l.images.map(n=>n.mediaImageGID).filter(n=>n!=null);return[...e,...a]},[]):[],K=t=>{if(!t.collectionBreaksEnabled||!t.collectionBreaks)return[];const e=t.collectionBreaks.mediaImageGID;return e?[e]:[]},W=t=>{var e,l,a;return t.progressiveGifts?[...((e=t.progressiveGifts.gifts)==null?void 0:e.map(n=>n.mediaImageGID))||[],(l=t.progressiveGifts.style)==null?void 0:l.lockedMediaImageGID,(a=t.progressiveGifts.dealBarStyle)==null?void 0:a.lockedMediaImageGID].filter(n=>n!=null):[]},Y=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.mediaImageGID).filter(e=>e!=null),Z=t=>t.dealBars.map(e=>{var l;return(l=e.productPersonalisation)==null?void 0:l.mediaImageGID}).filter(e=>e!=null),ee=t=>t.dealBars.map(e=>{var l;return(l=e.highlights)==null?void 0:l.customIconGID}).filter(e=>e!=null),te=t=>{const e=[...le(t),...se(t),...ae(t),...ne(t),...ie(t),...re(t),...oe(t)];return Array.from(new Set(e.filter(l=>l!=null)))},le=t=>t.dealBars.flatMap(({freeGifts:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),se=t=>t.dealBars.flatMap(({multipleGiftsSelectors:e})=>e?e.flatMap(l=>l.products?l.products.map(a=>a.id):[]):[]).filter(e=>e!=null),ae=t=>{var e;return t.progressiveGiftsEnabled?((e=t.progressiveGifts)==null?void 0:e.gifts.map(l=>l.productGID).filter(l=>l!=null))||[]:[]},ne=t=>t.dealBars.flatMap(({upsells:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null),ie=t=>t.dealBars.filter(e=>e.dealBarType==="bundle").flatMap(({bundleProducts:e})=>e?e.map(l=>l.productGID):[]).filter(e=>e!=null).filter(e=>e!=="default"),re=t=>!t.checkboxUpsellsEnabled||!t.checkboxUpsells?[]:t.checkboxUpsells.upsells.map(e=>e.productGID).filter(e=>e!=null),oe=t=>t.dealBars.filter(e=>e.dealBarType==="sku").flatMap(({productGID:e})=>e?[e]:[]);class C{constructor(e,l){this.storefrontApiVersion="2025-10",this.storefrontAccessToken=l,this.shopifyDomain=e}async query(e,l){var s;const a=(l==null?void 0:l.variables)??{};let n=`https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;const o=(s=e.match(/query\s+(\w+)/))==null?void 0:s[1];o&&(n+=`?operation_name=${o}`);const c=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.storefrontAccessToken},body:JSON.stringify({query:e,variables:a})})).text();if(!c)throw new Error("Empty graphql response");return JSON.parse(c).data}}const ce=async(t,e,{country:l,language:a})=>{const n=e.collectionBreaks;if(!e.collectionBreaksEnabled||!n)return;let o;n.visibility==="deal-products"?o=await A(t,{country:l,language:a,blockVisibility:e.blockVisibility,excludedProductGIDs:(e.excludedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedProductGIDs:(e.selectedProductIds||[]).map(s=>`gid://shopify/Product/${s}`),selectedCollectionGIDs:(e.selectedCollectionIds||[]).map(s=>`gid://shopify/Collection/${s}`)}):o=await A(t,{country:l,language:a,blockVisibility:n.visibility,excludedProductGIDs:(n.excludedProducts||[]).map(({id:s})=>s),selectedProductGIDs:(n.selectedProducts||[]).map(({id:s})=>s),selectedCollectionGIDs:(n.selectedCollections||[]).map(({id:s})=>s)}),o=o.slice(0,250);let c=await _(t,{country:l,language:a,productIds:o.map(s=>Number(s.split("/").pop())),useExternalMetafieldNamespace:!0});return c=c.filter(s=>s.availableForSale),c},ue=()=>({"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.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"}),de=async(t,{productId:e,dealBlockId:l,country:a,language:n})=>{try{const o=[Number(e.split("/").pop())],c=new C(t.shopifyDomain,t.storefrontAccessToken),s=await q(c,{language:n,country:a,useExternalMetafieldNamespace:!0}),m=s.storefrontAccessToken?new C(s.shopifyDomain,s.storefrontAccessToken):c,[p,d]=await Promise.all([_(m,{country:a,language:n,productIds:o,useExternalMetafieldNamespace:!0}),x(m,{useExternalMetafieldNamespace:!0,useMetaobjects:s.featureFlags.storefront_metaobjects})]),f=p[0];if(!f)return null;const u=j(d,f);let r;if(l?(r=u.find(G=>G.id===l||G.nanoId===l),r||(r=u[0])):r=u[0],!r)return null;const g=z(r),i=te(r),[h,y,v,P]=await Promise.all([_(m,{country:a,language:n,productIds:i,useExternalMetafieldNamespace:!0}),O(m,g,300),ce(m,r,{country:a,language:n}),ue()]);return{product:f,dealBlock:r,config:s,otherProducts:h,mediaImages:y,collectionBreaksProducts:v??[],translations:P}}catch(o){return console.error(o),null}},I="kaching-bundles-block",D=1e4,me="https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js",pe="https://bundles-integrations.kachingappz.app/kaching-bundles-block.js",k=new WeakSet,$=async t=>{const e=t.document;if(!t.customElements.get(I)){if(k.has(e))return S(t,I);k.add(e);try{await he(t)}catch(l){throw k.delete(e),l}}},fe=()=>typeof window<"u"&&typeof window.__KACHING_DEV__<"u",ge=()=>fe()?me:pe,he=t=>{const e=t.document;return new Promise((l,a)=>{const n=ge();if(e.querySelector(`script[src="${n}"]`)){S(t,I).then(l).catch(a);return}const c=e.createElement("script");c.src=n,c.onload=()=>S(t,I).then(l).catch(a),c.onerror=()=>a(new Error("Failed to load script")),e.head.appendChild(c)})},S=(t,e)=>new Promise((l,a)=>{if(t.customElements.get(e)){l();return}Promise.race([t.customElements.whenDefined(e),new Promise((n,o)=>setTimeout(()=>o(new Error(`Custom element "${e}" failed to register within ${D}ms`)),D))]).then(()=>l()).catch(a)});class ye extends HTMLElement{constructor(){super(...arguments),this.innerElement=null,this.handleItemsChanged=null,this.initializeId=0}static get observedAttributes(){return["selected-variant-id","product-id","country","language"]}async connectedCallback(){await this.initialize()}async initialize(){var c,s;const e=++this.initializeId;if(this.cleanup(),this.hasAttribute("demo")){if(await $(window),e!==this.initializeId)return;this.renderInnerElement(N);return}const l=this.getAttribute("shop-domain"),a=this.getAttribute("storefront-token"),n=this.getAttribute("product-id");if(!l||!a||!n)return;const[o]=await Promise.all([de({shopifyDomain:l,storefrontAccessToken:a},{productId:n,dealBlockId:this.getAttribute("deal-block-id")??void 0,country:((c=this.getAttribute("country"))==null?void 0:c.toUpperCase())??void 0,language:((s=this.getAttribute("language"))==null?void 0:s.toUpperCase())??void 0}),$(window)]);!o||e!==this.initializeId||this.renderInnerElement(o)}renderInnerElement(e){const{config:l,dealBlock:a,product:n,otherProducts:o,mediaImages:c,collectionBreaksProducts:s,translations:m}=e;this.innerElement=document.createElement("kaching-bundles-block"),this.innerElement.setAttribute("deal-block-id",a.id),this.innerElement.setAttribute("config",JSON.stringify(l)),this.innerElement.setAttribute("deal-block",JSON.stringify(a)),this.innerElement.setAttribute("media-images",JSON.stringify(c??[])),this.innerElement.setAttribute("product",JSON.stringify(n)),this.innerElement.setAttribute("other-products",JSON.stringify(o??[])),this.innerElement.setAttribute("collection-breaks-products",JSON.stringify(s??[])),this.innerElement.setAttribute("translations",JSON.stringify(m??{}));const p=this.getAttribute("selected-variant-id");this.innerElement.setAttribute("current-variant-id",String(p?p.split("/").pop():n.variants[0].id)),this.hasAttribute("compact")&&this.innerElement.setAttribute("compact","");const d=this.innerElement,f=()=>{if(this.innerElement!==d)return;const r=d.items();r&&this.dispatchEvent(new CustomEvent("items-changed",{detail:{items:r},bubbles:!0}))};this.handleItemsChanged=r=>{r.stopPropagation(),f()};const u=this.handleItemsChanged;d.addEventListener("kaching-bundles-block-loaded",()=>{this.innerElement===d&&(d.addEventListener("items-changed",u),this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0})))},{once:!0}),this.appendChild(this.innerElement)}cleanup(){this.handleItemsChanged&&this.innerElement&&(this.innerElement.removeEventListener("items-changed",this.handleItemsChanged),this.handleItemsChanged=null),this.innerElement&&(this.innerElement.remove(),this.innerElement=null)}attributeChangedCallback(e,l,a){l!==a&&this.isConnected&&(e==="product-id"||e==="country"||e==="language"?this.initialize():e==="selected-variant-id"&&this.innerElement&&a&&this.innerElement.setAttribute("current-variant-id",a.includes("/")?String(a.split("/").pop()):a))}items(){return this.innerElement?this.innerElement.items():[]}disconnectedCallback(){this.cleanup(),this.initializeId++}}customElements.define("kaching-bundle-component",ye)})();
@@ -249,7 +249,7 @@ const N = {
249
249
  mediaImages: [],
250
250
  collectionBreaksProducts: [],
251
251
  translations: {}
252
- }, _ = ({
252
+ }, v = ({
253
253
  country: t,
254
254
  language: e
255
255
  }) => {
@@ -318,23 +318,39 @@ const N = {
318
318
  n = o.metaobjects.pageInfo.endCursor;
319
319
  }
320
320
  return a;
321
- }, A = "app--2935586817", L = async (t, {
321
+ }, w = "app--2935586817", L = async (t, {
322
322
  language: e,
323
323
  country: l,
324
324
  useExternalMetafieldNamespace: a
325
325
  }) => {
326
- const n = `${A}--kaching_bundles`, o = A, {
326
+ const n = `${w}--kaching_bundles`, o = w, c = v({ country: l }), {
327
+ localization: {
328
+ country: {
329
+ currency: { isoCode: s }
330
+ }
331
+ },
327
332
  shop: {
328
- moneyFormat: c,
329
- currencyRateConstant: s,
330
- primaryDomain: m,
331
- settingsMetafield: p
333
+ moneyFormat: m,
334
+ paymentSettings: { currencyCode: p },
335
+ currencyRateConstant: d,
336
+ primaryDomain: f,
337
+ settingsMetafield: u
332
338
  }
333
339
  } = await t.query(
334
340
  `
335
- query config($metafieldNamespace: String!, $settingsNamespace: String!) {
341
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
342
+ localization {
343
+ country {
344
+ currency {
345
+ isoCode
346
+ }
347
+ }
348
+ }
336
349
  shop {
337
350
  moneyFormat
351
+ paymentSettings {
352
+ currencyCode
353
+ }
338
354
  primaryDomain {
339
355
  host
340
356
  }
@@ -353,14 +369,14 @@ const N = {
353
369
  settingsNamespace: o
354
370
  }
355
371
  }
356
- ), d = s ? O(s.value) : 1, i = p ? JSON.parse(p.value) : null, u = (i == null ? void 0 : i.feature_flags) ?? {}, r = (i == null ? void 0 : i.custom_selectors) ?? {};
372
+ ), r = s === p ? m : V(s), g = d ? O(d.value) : 1, i = u ? JSON.parse(u.value) : null, h = (i == null ? void 0 : i.feature_flags) ?? {}, y = (i == null ? void 0 : i.custom_selectors) ?? {};
357
373
  return {
358
- shopifyDomain: m.host,
359
- moneyFormat: c,
374
+ shopifyDomain: f.host,
375
+ moneyFormat: r,
360
376
  locale: (e == null ? void 0 : e.toLowerCase()) || "en",
361
377
  liquidLocale: (e == null ? void 0 : e.toLowerCase()) || "en",
362
378
  country: l ?? "US",
363
- currencyRate: d,
379
+ currencyRate: g,
364
380
  marketId: 0,
365
381
  productId: null,
366
382
  storefrontAccessToken: (i == null ? void 0 : i.storefront_access_token) ?? null,
@@ -395,16 +411,20 @@ const N = {
395
411
  "system.no_products_available": "No products available"
396
412
  },
397
413
  customSelectors: {
398
- quantity: r.quantity ?? null,
399
- addToCartButton: r.add_to_cart_button ?? null,
400
- variantPicker: r.variant_picker ?? null,
401
- price: r.price ?? null,
402
- priceCompare: r.price_compare ?? null
414
+ quantity: y.quantity ?? null,
415
+ addToCartButton: y.add_to_cart_button ?? null,
416
+ variantPicker: y.variant_picker ?? null,
417
+ price: y.price ?? null,
418
+ priceCompare: y.price_compare ?? null
403
419
  },
404
420
  shopCustomStyles: (i == null ? void 0 : i.shop_custom_styles) ?? "",
405
- featureFlags: u
421
+ featureFlags: h
406
422
  };
407
- }, O = (t) => JSON.parse(t).amount / 1e6, V = async (t, e, l = 200) => (e = e.filter(Boolean).filter((a) => !a.startsWith("placeholder")), e.length === 0 ? [] : (await t.query(
423
+ }, O = (t) => JSON.parse(t).amount / 1e6, V = (t) => new Intl.NumberFormat("en", {
424
+ style: "currency",
425
+ currency: t,
426
+ currencyDisplay: "narrowSymbol"
427
+ }).format(1).replace(/1(\.00)?/, "{{amount}}"), F = async (t, e, l = 200) => (e = e.filter(Boolean).filter((a) => !a.startsWith("placeholder")), e.length === 0 ? [] : (await t.query(
408
428
  `
409
429
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
410
430
  nodes(ids: $mediaImageIds) {
@@ -426,7 +446,7 @@ const N = {
426
446
  )).nodes.filter(Boolean).map((a) => ({
427
447
  gid: a.id,
428
448
  url: a.image.url
429
- }))), w = async (t, {
449
+ }))), A = async (t, {
430
450
  country: e,
431
451
  language: l,
432
452
  blockVisibility: a,
@@ -440,7 +460,7 @@ const N = {
440
460
  return o.slice(0, s);
441
461
  case "all-products":
442
462
  case "excluded-products": {
443
- const m = _({ country: e, language: l });
463
+ const m = v({ country: e, language: l });
444
464
  let p = (await t.query(
445
465
  `
446
466
  query FetchProductGIDs($limit: Int!) ${m} {
@@ -462,7 +482,7 @@ const N = {
462
482
  )), p;
463
483
  }
464
484
  case "selected-collections": {
465
- const m = _({ country: e, language: l }), p = (await t.query(
485
+ const m = v({ country: e, language: l }), p = (await t.query(
466
486
  `
467
487
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
468
488
  nodes(ids: $collectionGIDs) {
@@ -483,7 +503,7 @@ const N = {
483
503
  }
484
504
  }
485
505
  )).nodes.filter((d) => d !== null).flatMap(
486
- (d) => d.products.nodes.map((i) => i.id)
506
+ (d) => d.products.nodes.map((f) => f.id)
487
507
  );
488
508
  return Array.from(new Set(p)).slice(0, s);
489
509
  }
@@ -535,7 +555,7 @@ const N = {
535
555
  }) => {
536
556
  if (!a.length)
537
557
  return [];
538
- const s = a.map((d) => typeof d == "string" && d.startsWith("gid://") ? d : `gid://shopify/Product/${d}`), m = _({ country: e, language: l });
558
+ const s = a.map((d) => typeof d == "string" && d.startsWith("gid://") ? d : `gid://shopify/Product/${d}`), m = v({ country: e, language: l });
539
559
  let p = (await t.query(
540
560
  `
541
561
  query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${m} {
@@ -633,13 +653,13 @@ const N = {
633
653
  );
634
654
  return p = await Promise.all(
635
655
  p.map(
636
- (d) => F(t, d, {
656
+ (d) => j(t, d, {
637
657
  includeSellingPlans: n,
638
658
  includeAvailableQuantity: o
639
659
  })
640
660
  )
641
- ), p.map(j);
642
- }, F = async (t, e, l) => {
661
+ ), p.map(z);
662
+ }, j = async (t, e, l) => {
643
663
  if (e.variants.nodes.length < 250)
644
664
  return e;
645
665
  const a = /* @__PURE__ */ new Set(), n = [], o = [], c = async (s) => {
@@ -669,8 +689,8 @@ const N = {
669
689
  ...l
670
690
  }
671
691
  }
672
- ), { nodes: i, pageInfo: u } = d.product.variants;
673
- for (const r of i) {
692
+ ), { nodes: f, pageInfo: u } = d.product.variants;
693
+ for (const r of f) {
674
694
  if (a.has(r.id)) {
675
695
  m = !1;
676
696
  break;
@@ -684,11 +704,11 @@ const N = {
684
704
  c(!1),
685
705
  c(!0)
686
706
  ]), e.variants.nodes = [...n, ...o.reverse()], e;
687
- }, j = (t) => {
688
- var c, s, m, p, d, i;
707
+ }, z = (t) => {
708
+ var c, s, m, p, d, f;
689
709
  const e = t.variants.nodes.map(
690
710
  ({ unitPriceMeasurement: u, ...r }) => {
691
- var f, g;
711
+ var g, i;
692
712
  return {
693
713
  id: Number(r.id.split("/").pop()),
694
714
  availableForSale: r.availableForSale,
@@ -696,8 +716,8 @@ const N = {
696
716
  compareAtPrice: r.compareAtPrice ? Math.round(Number(r.compareAtPrice.amount) * 100) : null,
697
717
  options: r.selectedOptions.map((h) => h.value),
698
718
  imageId: r.image ? Number(r.image.id.split("/").pop()) : null,
699
- image: ((f = r.image) == null ? void 0 : f.url) || null,
700
- sellingPlans: ((g = r.sellingPlanAllocations) == null ? void 0 : g.nodes.map((h) => ({
719
+ image: ((g = r.image) == null ? void 0 : g.url) || null,
720
+ sellingPlans: ((i = r.sellingPlanAllocations) == null ? void 0 : i.nodes.map((h) => ({
701
721
  id: Number(h.sellingPlan.id.split("/").pop()),
702
722
  price: h.priceAdjustments.length > 0 ? Math.round(Number(h.priceAdjustments[0].price.amount) * 100) : Math.round(Number(r.price.amount) * 100)
703
723
  }))) || [],
@@ -715,15 +735,15 @@ const N = {
715
735
  };
716
736
  }
717
737
  ), l = t.options.map((u, r) => {
718
- const f = u.optionValues.map((g) => {
719
- var h, b, y, I;
738
+ const g = u.optionValues.map((i) => {
739
+ var h, y, b, I;
720
740
  return {
721
- id: Number(g.id.split("/").pop()),
722
- defaultName: g.name,
723
- name: g.name,
741
+ id: Number(i.id.split("/").pop()),
742
+ defaultName: i.name,
743
+ name: i.name,
724
744
  swatch: {
725
- color: ((h = g.swatch) == null ? void 0 : h.color) || null,
726
- image: ((I = (y = (b = g.swatch) == null ? void 0 : b.image) == null ? void 0 : y.previewImage) == null ? void 0 : I.url) || null
745
+ color: ((h = i.swatch) == null ? void 0 : h.color) || null,
746
+ image: ((I = (b = (y = i.swatch) == null ? void 0 : y.image) == null ? void 0 : b.previewImage) == null ? void 0 : I.url) || null
727
747
  }
728
748
  };
729
749
  });
@@ -731,32 +751,32 @@ const N = {
731
751
  defaultName: u.name,
732
752
  name: u.name,
733
753
  position: r + 1,
734
- optionValues: z(f, r, e)
754
+ optionValues: R(g, r, e)
735
755
  };
736
756
  }), a = (u) => {
737
757
  const r = u.priceAdjustments[0];
738
758
  if (!r)
739
759
  return null;
740
- const f = r.adjustmentValue;
741
- switch (f.__typename) {
760
+ const g = r.adjustmentValue;
761
+ switch (g.__typename) {
742
762
  case "SellingPlanPercentagePriceAdjustment":
743
763
  return {
744
764
  type: "percentage",
745
- value: f.adjustmentPercentage
765
+ value: g.adjustmentPercentage
746
766
  };
747
767
  case "SellingPlanFixedAmountPriceAdjustment":
748
768
  return {
749
769
  type: "fixed_amount",
750
- value: Number(f.adjustmentAmount.amount) * 100
770
+ value: Number(g.adjustmentAmount.amount) * 100
751
771
  };
752
772
  case "SellingPlanFixedPriceAdjustment":
753
773
  return {
754
774
  type: "price",
755
- value: Number(f.price.amount) * 100
775
+ value: Number(g.price.amount) * 100
756
776
  };
757
777
  default:
758
778
  throw new Error(
759
- `Unknown price adjustment type: ${f.__typename}`
779
+ `Unknown price adjustment type: ${g.__typename}`
760
780
  );
761
781
  }
762
782
  }, n = ((c = t.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
@@ -791,12 +811,12 @@ const N = {
791
811
  text: ((m = t.metafield) == null ? void 0 : m.value) || null,
792
812
  text2: ((p = t.metafield2) == null ? void 0 : p.value) || null,
793
813
  text3: ((d = t.metafield3) == null ? void 0 : d.value) || null,
794
- text4: ((i = t.metafield4) == null ? void 0 : i.value) || null
814
+ text4: ((f = t.metafield4) == null ? void 0 : f.value) || null
795
815
  }
796
816
  };
797
- }, z = (t, e, l) => t.filter((a) => l.filter(
817
+ }, R = (t, e, l) => t.filter((a) => l.filter(
798
818
  (n) => n.options[e] === a.name
799
- ).length > 0), R = (t, e) => {
819
+ ).length > 0), H = (t, e) => {
800
820
  const l = [], a = t.filter(
801
821
  (s) => s.blockVisibility === "selected-products"
802
822
  );
@@ -822,8 +842,7 @@ const N = {
822
842
  for (const s of c)
823
843
  l.push(s);
824
844
  return l;
825
- }, H = (t) => [
826
- ...J(t),
845
+ }, J = (t) => [
827
846
  ...Q(t),
828
847
  ...W(t),
829
848
  ...X(t),
@@ -832,56 +851,57 @@ const N = {
832
851
  ...Z(t),
833
852
  ...ee(t),
834
853
  ...te(t),
835
- ...le(t)
836
- ].filter((e) => e != null && !e.includes("placeholder")), J = (t) => t.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), Q = (t) => t.dealBars.map(
854
+ ...le(t),
855
+ ...se(t)
856
+ ].filter((e) => e != null && !e.includes("placeholder")), Q = (t) => t.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), W = (t) => t.dealBars.map(
837
857
  ({ freeGifts: e }) => (e || []).map((l) => l.mediaImageGID)
838
- ).reduce((e, l) => e.concat(l), []).filter((e) => e != null), W = (t) => t.dealBars.flatMap(
858
+ ).reduce((e, l) => e.concat(l), []).filter((e) => e != null), X = (t) => t.dealBars.flatMap(
839
859
  ({ multipleGiftsSelectors: e }) => (e || []).map((l) => l.mediaImageGID)
840
- ).filter((e) => e != null), X = (t) => t.dealBars.map(({ upsells: e }) => (e || []).map((l) => l.mediaImageGID)).reduce((e, l) => e.concat(l), []).filter((e) => e != null), K = (t) => t.swatchOptions ? t.swatchOptions.reduce((e, l) => {
860
+ ).filter((e) => e != null), K = (t) => t.dealBars.map(({ upsells: e }) => (e || []).map((l) => l.mediaImageGID)).reduce((e, l) => e.concat(l), []).filter((e) => e != null), Y = (t) => t.swatchOptions ? t.swatchOptions.reduce((e, l) => {
841
861
  const a = l.images.map((n) => n.mediaImageGID).filter((n) => n != null);
842
862
  return [...e, ...a];
843
- }, []) : [], Y = (t) => {
863
+ }, []) : [], Z = (t) => {
844
864
  if (!t.collectionBreaksEnabled || !t.collectionBreaks)
845
865
  return [];
846
866
  const e = t.collectionBreaks.mediaImageGID;
847
867
  return e ? [e] : [];
848
- }, Z = (t) => {
868
+ }, ee = (t) => {
849
869
  var e, l, a;
850
870
  return t.progressiveGifts ? [
851
871
  ...((e = t.progressiveGifts.gifts) == null ? void 0 : e.map((n) => n.mediaImageGID)) || [],
852
872
  (l = t.progressiveGifts.style) == null ? void 0 : l.lockedMediaImageGID,
853
873
  (a = t.progressiveGifts.dealBarStyle) == null ? void 0 : a.lockedMediaImageGID
854
874
  ].filter((n) => n != null) : [];
855
- }, ee = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.mediaImageGID).filter((e) => e != null), te = (t) => t.dealBars.map((e) => {
875
+ }, te = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.mediaImageGID).filter((e) => e != null), le = (t) => t.dealBars.map((e) => {
856
876
  var l;
857
877
  return (l = e.productPersonalisation) == null ? void 0 : l.mediaImageGID;
858
- }).filter((e) => e != null), le = (t) => t.dealBars.map((e) => {
878
+ }).filter((e) => e != null), se = (t) => t.dealBars.map((e) => {
859
879
  var l;
860
880
  return (l = e.highlights) == null ? void 0 : l.customIconGID;
861
- }).filter((e) => e != null), se = (t) => {
881
+ }).filter((e) => e != null), ae = (t) => {
862
882
  const e = [
863
- ...ae(t),
864
883
  ...ne(t),
865
884
  ...ie(t),
866
885
  ...re(t),
867
886
  ...oe(t),
868
887
  ...ce(t),
869
- ...ue(t)
888
+ ...ue(t),
889
+ ...de(t)
870
890
  ];
871
891
  return Array.from(new Set(e.filter((l) => l != null)));
872
- }, ae = (t) => t.dealBars.flatMap(
892
+ }, ne = (t) => t.dealBars.flatMap(
873
893
  ({ freeGifts: e }) => e ? e.map((l) => l.productGID) : []
874
- ).filter((e) => e != null), ne = (t) => t.dealBars.flatMap(
894
+ ).filter((e) => e != null), ie = (t) => t.dealBars.flatMap(
875
895
  ({ multipleGiftsSelectors: e }) => e ? e.flatMap(
876
896
  (l) => l.products ? l.products.map((a) => a.id) : []
877
897
  ) : []
878
- ).filter((e) => e != null), ie = (t) => {
898
+ ).filter((e) => e != null), re = (t) => {
879
899
  var e;
880
900
  return t.progressiveGiftsEnabled ? ((e = t.progressiveGifts) == null ? void 0 : e.gifts.map((l) => l.productGID).filter((l) => l != null)) || [] : [];
881
- }, re = (t) => t.dealBars.flatMap(({ upsells: e }) => e ? e.map((l) => l.productGID) : []).filter((e) => e != null), oe = (t) => t.dealBars.filter((e) => e.dealBarType === "bundle").flatMap(
901
+ }, oe = (t) => t.dealBars.flatMap(({ upsells: e }) => e ? e.map((l) => l.productGID) : []).filter((e) => e != null), ce = (t) => t.dealBars.filter((e) => e.dealBarType === "bundle").flatMap(
882
902
  ({ bundleProducts: e }) => e ? e.map((l) => l.productGID) : []
883
- ).filter((e) => e != null).filter((e) => e !== "default"), ce = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), ue = (t) => t.dealBars.filter((e) => e.dealBarType === "sku").flatMap(({ productGID: e }) => e ? [e] : []);
884
- class D {
903
+ ).filter((e) => e != null).filter((e) => e !== "default"), ue = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), de = (t) => t.dealBars.filter((e) => e.dealBarType === "sku").flatMap(({ productGID: e }) => e ? [e] : []);
904
+ class C {
885
905
  constructor(e, l) {
886
906
  this.storefrontApiVersion = "2025-10", this.storefrontAccessToken = l, this.shopifyDomain = e;
887
907
  }
@@ -907,11 +927,11 @@ class D {
907
927
  return JSON.parse(c).data;
908
928
  }
909
929
  }
910
- const de = async (t, e, { country: l, language: a }) => {
930
+ const me = async (t, e, { country: l, language: a }) => {
911
931
  const n = e.collectionBreaks;
912
932
  if (!e.collectionBreaksEnabled || !n) return;
913
933
  let o;
914
- n.visibility === "deal-products" ? o = await w(t, {
934
+ n.visibility === "deal-products" ? o = await A(t, {
915
935
  country: l,
916
936
  language: a,
917
937
  blockVisibility: e.blockVisibility,
@@ -924,7 +944,7 @@ const de = async (t, e, { country: l, language: a }) => {
924
944
  selectedCollectionGIDs: (e.selectedCollectionIds || []).map(
925
945
  (s) => `gid://shopify/Collection/${s}`
926
946
  )
927
- }) : o = await w(t, {
947
+ }) : o = await A(t, {
928
948
  country: l,
929
949
  language: a,
930
950
  blockVisibility: n.visibility,
@@ -947,7 +967,7 @@ const de = async (t, e, { country: l, language: a }) => {
947
967
  return c = c.filter(
948
968
  (s) => s.availableForSale
949
969
  ), c;
950
- }, me = () => ({
970
+ }, pe = () => ({
951
971
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
952
972
  "system.invalid_variant": "Sorry, this is not currently available.",
953
973
  "system.unavailable_option_value": "Unavailable",
@@ -964,21 +984,21 @@ const de = async (t, e, { country: l, language: a }) => {
964
984
  "system.no_results_description": "We can't find any item matching your search.",
965
985
  "system.clear_search": "Clear search",
966
986
  "system.no_products_available": "No products available"
967
- }), pe = async (t, {
987
+ }), fe = async (t, {
968
988
  productId: e,
969
989
  dealBlockId: l,
970
990
  country: a,
971
991
  language: n
972
992
  }) => {
973
993
  try {
974
- const o = [Number(e.split("/").pop())], c = new D(
994
+ const o = [Number(e.split("/").pop())], c = new C(
975
995
  t.shopifyDomain,
976
996
  t.storefrontAccessToken
977
997
  ), s = await L(c, {
978
998
  language: n,
979
999
  country: a,
980
1000
  useExternalMetafieldNamespace: !0
981
- }), m = s.storefrontAccessToken ? new D(
1001
+ }), m = s.storefrontAccessToken ? new C(
982
1002
  s.shopifyDomain,
983
1003
  s.storefrontAccessToken
984
1004
  ) : c, [p, d] = await Promise.all([
@@ -992,65 +1012,65 @@ const de = async (t, e, { country: l, language: a }) => {
992
1012
  useExternalMetafieldNamespace: !0,
993
1013
  useMetaobjects: s.featureFlags.storefront_metaobjects
994
1014
  })
995
- ]), i = p[0];
996
- if (!i)
1015
+ ]), f = p[0];
1016
+ if (!f)
997
1017
  return null;
998
- const u = R(d, i);
1018
+ const u = H(d, f);
999
1019
  let r;
1000
1020
  if (l ? (r = u.find(
1001
1021
  (E) => E.id === l || E.nanoId === l
1002
1022
  ), r || (r = u[0])) : r = u[0], !r)
1003
1023
  return null;
1004
- const f = H(r), g = se(r), [h, b, y, I] = await Promise.all([
1024
+ const g = J(r), i = ae(r), [h, y, b, I] = await Promise.all([
1005
1025
  k(m, {
1006
1026
  country: a,
1007
1027
  language: n,
1008
- productIds: g,
1028
+ productIds: i,
1009
1029
  useExternalMetafieldNamespace: !0
1010
1030
  }),
1011
- V(m, f, 300),
1012
- de(m, r, {
1031
+ F(m, g, 300),
1032
+ me(m, r, {
1013
1033
  country: a,
1014
1034
  language: n
1015
1035
  }),
1016
- me()
1036
+ pe()
1017
1037
  ]);
1018
1038
  return {
1019
- product: i,
1039
+ product: f,
1020
1040
  dealBlock: r,
1021
1041
  config: s,
1022
1042
  otherProducts: h,
1023
- mediaImages: b,
1024
- collectionBreaksProducts: y ?? [],
1043
+ mediaImages: y,
1044
+ collectionBreaksProducts: b ?? [],
1025
1045
  translations: I
1026
1046
  };
1027
1047
  } catch (o) {
1028
1048
  return console.error(o), null;
1029
1049
  }
1030
- }, v = "kaching-bundles-block", C = 1e4, fe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", ge = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", P = /* @__PURE__ */ new WeakSet(), $ = async (t) => {
1050
+ }, P = "kaching-bundles-block", D = 1e4, ge = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", he = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", _ = /* @__PURE__ */ new WeakSet(), $ = async (t) => {
1031
1051
  const e = t.document;
1032
- if (!t.customElements.get(v)) {
1033
- if (P.has(e))
1034
- return S(t, v);
1035
- P.add(e);
1052
+ if (!t.customElements.get(P)) {
1053
+ if (_.has(e))
1054
+ return S(t, P);
1055
+ _.add(e);
1036
1056
  try {
1037
- await ye(t);
1057
+ await Ie(t);
1038
1058
  } catch (l) {
1039
- throw P.delete(e), l;
1059
+ throw _.delete(e), l;
1040
1060
  }
1041
1061
  }
1042
- }, he = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", be = () => he() ? fe : ge, ye = (t) => {
1062
+ }, ye = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", be = () => ye() ? ge : he, Ie = (t) => {
1043
1063
  const e = t.document;
1044
1064
  return new Promise((l, a) => {
1045
1065
  const n = be();
1046
1066
  if (e.querySelector(
1047
1067
  `script[src="${n}"]`
1048
1068
  )) {
1049
- S(t, v).then(l).catch(a);
1069
+ S(t, P).then(l).catch(a);
1050
1070
  return;
1051
1071
  }
1052
1072
  const c = e.createElement("script");
1053
- c.src = n, c.onload = () => S(t, v).then(l).catch(a), c.onerror = () => a(new Error("Failed to load script")), e.head.appendChild(c);
1073
+ c.src = n, c.onload = () => S(t, P).then(l).catch(a), c.onerror = () => a(new Error("Failed to load script")), e.head.appendChild(c);
1054
1074
  });
1055
1075
  }, S = (t, e) => new Promise((l, a) => {
1056
1076
  if (t.customElements.get(e)) {
@@ -1063,15 +1083,15 @@ const de = async (t, e, { country: l, language: a }) => {
1063
1083
  (n, o) => setTimeout(
1064
1084
  () => o(
1065
1085
  new Error(
1066
- `Custom element "${e}" failed to register within ${C}ms`
1086
+ `Custom element "${e}" failed to register within ${D}ms`
1067
1087
  )
1068
1088
  ),
1069
- C
1089
+ D
1070
1090
  )
1071
1091
  )
1072
1092
  ]).then(() => l()).catch(a);
1073
1093
  });
1074
- class Ie extends HTMLElement {
1094
+ class ve extends HTMLElement {
1075
1095
  constructor() {
1076
1096
  super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1077
1097
  }
@@ -1092,7 +1112,7 @@ class Ie extends HTMLElement {
1092
1112
  const l = this.getAttribute("shop-domain"), a = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
1093
1113
  if (!l || !a || !n) return;
1094
1114
  const [o] = await Promise.all([
1095
- pe(
1115
+ fe(
1096
1116
  {
1097
1117
  shopifyDomain: l,
1098
1118
  storefrontAccessToken: a
@@ -1138,7 +1158,7 @@ class Ie extends HTMLElement {
1138
1158
  "current-variant-id",
1139
1159
  String(p ? p.split("/").pop() : n.variants[0].id)
1140
1160
  ), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
1141
- const d = this.innerElement, i = () => {
1161
+ const d = this.innerElement, f = () => {
1142
1162
  if (this.innerElement !== d) return;
1143
1163
  const r = d.items();
1144
1164
  r && this.dispatchEvent(
@@ -1149,7 +1169,7 @@ class Ie extends HTMLElement {
1149
1169
  );
1150
1170
  };
1151
1171
  this.handleItemsChanged = (r) => {
1152
- r.stopPropagation(), i();
1172
+ r.stopPropagation(), f();
1153
1173
  };
1154
1174
  const u = this.handleItemsChanged;
1155
1175
  d.addEventListener(
@@ -1179,4 +1199,4 @@ class Ie extends HTMLElement {
1179
1199
  this.cleanup(), this.initializeId++;
1180
1200
  }
1181
1201
  }
1182
- customElements.define("kaching-bundle-component", Ie);
1202
+ customElements.define("kaching-bundle-component", ve);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kachingappz/bundles-js",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "main": "./dist/bundles-js.js",
6
6
  "module": "./dist/bundles-js.js",
@@ -26,8 +26,8 @@
26
26
  "vite": "^6.2.0",
27
27
  "vite-plugin-dts": "^4.5.3",
28
28
  "@kachingappz/bundles-storefront-api": "^0.1.0",
29
- "@kachingappz/kaching-bundles-block": "^1.0.0",
30
- "@kachingappz/bundles-types": "^0.1.0"
29
+ "@kachingappz/bundles-types": "^0.1.0",
30
+ "@kachingappz/kaching-bundles-block": "^1.0.0"
31
31
  },
32
32
  "description": "A vanilla JavaScript web component for integrating Kaching Bundles into any Shopify storefront.",
33
33
  "author": "Donatas Stundys",