(()=>{var t=9007199254740991,e=t=>{const e=+t;return e!=e||0===e?0:Number.isFinite(e)?e<0?Math.ceil(e):Math.floor(e):e},o=o=>Math.min(Math.max(e(o.length),0),t),n=t=>{if(null==t)throw new TypeError("Cannot convert null or undefined to object");return Object(t)},i=t=>{if(!Array.isArray(t))return[];let e=t.constructor;return"function"==typeof e&&e!==Array&&Array.isArray(e.prototype)&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Array)&&(e=void 0),null===e||"object"!=typeof e&&"function"!=typeof e||(e=e[Symbol.species],null===e&&(e=void 0)),void 0===e?[]:new e(0)},l=(e,n,i,a,r,s,d)=>{for(let c=0;c0&&Array.isArray(i))r=l(e,i,o(i),a-1,r);else{if(r>=t)throw new TypeError("Flattened array is too large");Object.defineProperty(e,r++,{value:i,writable:!0,enumerable:!0,configurable:!0})}}return r};function a(t){const a=n(this),r=o(a),s=void 0===t?1:e(t),d=i(a);return l(d,a,r,s,0),d}function r(t,e){const a=n(this),r=o(a);if("function"!=typeof t)throw new TypeError("flatMap callback must be a function");const s=i(a);return l(s,a,r,1,0,t,e),s}function s(t){const e=n(this);let o=e.constructor;if(void 0===o)o=Promise;else{if(null===o||"object"!=typeof o&&"function"!=typeof o)throw new TypeError("Promise constructor must be an object");o=o[Symbol.species],null==o&&(o=Promise)}if("function"!=typeof o)throw new TypeError("Promise species must be a constructor");let i=t,l=t;return"function"==typeof t&&(i=e=>Reflect.apply(Promise.resolve,o,[t()]).then(()=>e),l=e=>Reflect.apply(Promise.resolve,o,[t()]).then(()=>{throw e})),e.then(i,l)}var d,c,u,b,p,_,g,m,v,h,y,f,x,S,E,A,q=(t,e)=>"function"==typeof t?Function.prototype.bind.call(t,e):function(){return Reflect.apply(t,e,arguments)};function P(t,e){if(null==t)throw new TypeError("Cannot read method from null or undefined");let o=t[e];return void 0!==o||e in Object(t)||(Array.isArray(t)?"flat"===e?o=a:"flatMap"===e&&(o=r):"finally"===e&&"[object Promise]"===Object.prototype.toString.call(t)&&(o=s)),q(o,t)}function M(t){const e={};for(const o of t){if(null===o||"object"!=typeof o&&"function"!=typeof o)throw new TypeError("Iterator value is not an entry object");const t=o[0],n=o[1];Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}return e}function C(t){if(null==t)throw new TypeError("Cannot read fromEntries from null or undefined");let e=t.fromEntries;var o;return void 0!==e||t!==Object||(o=Object,Object.prototype.hasOwnProperty.call(o,"fromEntries"))||(e=M),q(e,t)}d=Object.defineProperty,c=Object.defineProperties,u=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,g=(t,e,o)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,m=(t,e)=>{for(var o in e||(e={}))p.call(e,o)&&g(t,o,e[o]);if(b)for(var o of b(e))_.call(e,o)&&g(t,o,e[o]);return t},v=(t,e)=>c(t,u(e)),h=(t,e,o)=>new Promise((n,i)=>{var l=t=>{try{r(o.next(t))}catch(e){i(e)}},a=t=>{try{r(o.throw(t))}catch(e){i(e)}},r=t=>t.done?n(t.value):Promise.resolve(t.value).then(l,a);r((o=o.apply(t,e)).next())}),y=["a","b","strong","i","em","u","s","br","span","small","sup","sub","mark","p","div"],f=["class","style"],x=["href","target","rel"],S=["script","style","template","iframe","object","embed","noscript"],E=t=>null==t?t:String(t).replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),A=t=>{const e=document.createElement("template");return e.innerHTML=null!=t?t:"",e.content.textContent.replace(/\s+/g," ").trim().replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},window.fgSummaryIconsObj="undefined"!=typeof fgSummaryIconsObj&&fgSummaryIconsObj,window.fgShippingIconsObj="undefined"!=typeof fgShippingIconsObj&&fgShippingIconsObj,function(){var t,e,o,n,i,l,a,r,s,d,c,u,b,p,_,g,q,M;if((null==(n=null==(o=null==(e=null==(t=window.fgData)?void 0:t.appearance)?void 0:e.bundle)?void 0:o.content)?void 0:n.shopify_shipping_icon_path)&&"undefined"!=typeof fgShippingIconsObj){const t=null==(a=null==(l=null==(i=window.fgData.appearance)?void 0:i.bundle)?void 0:l.content)?void 0:a.shopify_shipping_icon_path;window.fgData.appearance.bundle.content.shipping_icon_path=null!=(r=fgShippingIconsObj[t])?r:t}if((null==(u=null==(c=null==(d=null==(s=window.fgData)?void 0:s.appearance)?void 0:d.mix_match)?void 0:c.content)?void 0:u.shopify_shipping_icon_path)&&"undefined"!=typeof fgShippingIconsObj){const t=null==(_=null==(p=null==(b=window.fgData.appearance)?void 0:b.mix_match)?void 0:p.content)?void 0:_.shopify_shipping_icon_path;window.fgData.appearance.mix_match.content.shipping_icon_path=null!=(g=fgShippingIconsObj[t])?g:t}const{proxy:O,integration:T,shopifyFunc:L,storefront:k,collect:w,utils:I,customize:D,recurring_handler:F}=window.FGSECOMAPP.helper||{};FGSECOMAPP.variables=v(m({},FGSECOMAPP.variables),{productsChooseInCollections:[],bundles:{offer_codes:{}}});const G=null!=(q=FGSECOMAPP.variables.RATE_PRICE)?q:100;FGSECOMAPP.CUSTOM_EVENTS=v(m({},FGSECOMAPP.CUSTOM_EVENTS),{BOGOS_BUNDLE_INIT:"bogos:bundle-init",BOGOS_BUNDLE_START:"bogos:bundle-start",BOGOS_BUNDLE_ADDED:"bogos:bundle-added",BOGOS_BUNDLE_RENDER:"bogos:bundle-render",BOGOS_QTY_BREAK_RENDER:"bogos:quantity-break-render",BOGOS_MIX_MATCH_RENDER:"bogos:mix-match-render"});const B={BUNDLE_TYPE:{default:"bundle",classic:"classic_bundle",quantity_break:"quantity_break",mix_match:"mix_match",bundle_page:"bundle_page",bundle_product_page:"bundle_product_page"},APP_REVIEW:{judgeme:"judgeme",trustoo:"trustoo",yotpo:"yotpo"},NARROW_TYPE:{product:"variants_ids",product_types:"product_types",product_vendors:"product_vendors",collection:"product_collections",config:"config"},DISCOUNT_TYPE:{percentage:"percentage",fixed_amount:"fixed_amount",fixed_price:"fixed_price",free_products:"free_products",cheapest_free:"cheapest_free"}};B.TRIGGER_FUNC={[B.BUNDLE_TYPE.quantity_break]:"QB",[B.BUNDLE_TYPE.classic]:"CB",[B.BUNDLE_TYPE.default]:"CB",[B.BUNDLE_TYPE.mix_match]:"MM",[B.BUNDLE_TYPE.bundle_page]:"BP",[B.BUNDLE_TYPE.bundle_product_page]:"BPP"};const H={seq:0,LABEL:{ADDING:"Adding to cart",ADDED:"Added to cart",REACHED:"Reached",NOT_REACHED:"Not reached yet"},status:{announce:(t,e)=>{const o=null==e?void 0:e.closest(".bogos-bundles-widget, .bogos-mix-match-widget, .bogos-bundle-pp-widget");(o?[...o.querySelectorAll(".bogos-bn-status")]:[document.querySelector(".bogos-bn-status")].filter(Boolean)).forEach(e=>{e.textContent=e.textContent===t?"".concat(t," "):t})},busy:t=>{t.setAttribute("aria-busy","true"),H.status.announce(H.LABEL.ADDING,t)},done:(t,e)=>{t.removeAttribute("aria-busy");const o=String(null!=e?e:"").replace(/\s+/g," ").trim();H.status.announce(o||H.LABEL.ADDED,t)},idle:t=>t.removeAttribute("aria-busy"),change:(t,e,o)=>{const n=String(null!=o?o:"").replace(/\s+/g," ").trim();if(!t||!n||t.dataset[e]===n)return;const i=void 0!==t.dataset[e];t.dataset[e]=n,i&&H.status.announce(n,t)}},COMBOBOX:{mixVariant:{dropdown:".bogos-mix-item-select-variant-dropdown",trigger:".bogos-mix-item-select-variant-title-contain",list:".bogos-mix-item-select-variant-options",option:".bogos-mix-item-select-variant-option",openClass:"opened",role:"button",synthetic:!0,closeOnTab:!0},ppVariant:{dropdown:".bogos-bundle-pp-select-variant-dropdown",trigger:".bogos-bundle-pp-select-variant-title-contain",list:".bogos-bundle-pp-select-variant-options",option:".bogos-bundle-pp-select-variant-option",openClass:"opened",role:"button",synthetic:!0,closeOnTab:!0},classicVariant:{dropdown:".bogos-bundle-variant-option-container",trigger:".bogos-bundle-variant-selected",list:".bogos-bundle-variant-item-select",option:".bogos-bundle-select-variant-option",openClass:"opened",role:"button",synthetic:!0,closeOnTab:!0}},combobox:{ACTIVE_CLASS:"bogos-bn-option-active",isOpen:(t,e)=>t.classList.contains(e.openClass),options:(t,e)=>[...t.querySelectorAll(e.option)],sync:(t,e)=>{var o,n,i,l;const a=t.querySelector(e.trigger),r=t.querySelector(e.list);if(!a||!r)return;e.role&&(a.setAttribute("role",e.role),a.setAttribute("tabindex","0"));const s=H.combobox.options(t,e);if(r.id||(r.id="bogos-bn-listbox-".concat(++H.seq)),a.setAttribute("aria-controls",r.id),s.length){r.setAttribute("role","listbox"),r.setAttribute("aria-label",null!=(o=e.label)?o:"Variants"),a.setAttribute("aria-haspopup","listbox");const t=(null!=(n=a.textContent)?n:"").trim();s.forEach(e=>{e.id||(e.id="bogos-bn-option-".concat(++H.seq)),e.setAttribute("role","option"),e.setAttribute("aria-selected",e.textContent.trim()===t?"true":"false")})}else r.querySelector('[role="radiogroup"], .bogos-select-option-name-container')&&(r.setAttribute("role","group"),r.setAttribute("aria-label",null!=(i=e.label)?i:"Variant options"),a.setAttribute("aria-haspopup","true"));H.status.change(a,"bogosSelected",null!=(l=a.value)?l:a.textContent);const d=H.combobox.isOpen(t,e);a.setAttribute("aria-expanded",d?"true":"false"),d||H.combobox.clearActive(t,e)},markActive:(t,e)=>{t&&t.classList.contains(H.combobox.ACTIVE_CLASS)!==e&&t.classList.toggle(H.combobox.ACTIVE_CLASS,e)},clearActive:(t,e)=>{var o;H.combobox.options(t,e).forEach(t=>H.combobox.markActive(t,!1)),null==(o=t.querySelector(e.trigger))||o.removeAttribute("aria-activedescendant")},setActive:(t,e,o)=>{var n,i;o&&(H.combobox.options(t,e).forEach(t=>H.combobox.markActive(t,t===o)),null==(n=t.querySelector(e.trigger))||n.setAttribute("aria-activedescendant",o.id),null==(i=o.scrollIntoView)||i.call(o,{block:"nearest"}))},move:(t,e,o)=>{const n=H.combobox.options(t,e);if(!n.length)return;const i=n.findIndex(t=>t.classList.contains(H.combobox.ACTIVE_CLASS)),l=n.findIndex(t=>"true"===t.getAttribute("aria-selected"));let a=(i>=0?i:l)+o;a<0&&(a=n.length-1),a>=n.length&&(a=0),H.combobox.setActive(t,e,n[a])},close:(t,e,o=!0)=>{const n=t.querySelector(e.trigger);H.combobox.isOpen(t,e)&&(null==n||n.click()),H.combobox.clearActive(t,e),o&&(null==n||n.focus())},bind:(t,e)=>{t&&"1"!==t.dataset.bogosBnCombo&&(t.dataset.bogosBnCombo="1",H.combobox.sync(t,e),new MutationObserver(()=>H.combobox.sync(t,e)).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class"]}),t.addEventListener("keydown",o=>{var n,i;if("Escape"!==o.key&&(null==(i=null==(n=o.target)?void 0:n.closest)?void 0:i.call(n,'[role="radiogroup"]')))return;const l=t.querySelector(e.trigger),a=H.combobox.isOpen(t,e);switch(o.key){case"Escape":if(!a)return;return o.preventDefault(),void H.combobox.close(t,e);case"ArrowDown":case"ArrowUp":return o.preventDefault(),a?void H.combobox.move(t,e,"ArrowDown"===o.key?1:-1):void(null==l||l.click());case"Enter":case" ":{if(!a){if(!e.synthetic)return;return o.preventDefault(),void(null==l||l.click())}const n=t.querySelector(".".concat(H.combobox.ACTIVE_CLASS));if(!n)return;return o.preventDefault(),n.click(),void(null==l||l.focus())}case"Tab":return void(a&&e.closeOnTab&&H.combobox.options(t,e).length&&H.combobox.close(t,e,!1));default:return}}))}},radioGroup:{GROUP:'.bogos-select-option-items[role="radiogroup"]',radios:t=>[...t.querySelectorAll(".bogos-select-option-custom-item")],sync:t=>{const e=H.radioGroup.radios(t);if(!e.length)return;e.forEach(t=>t.setAttribute("aria-checked",t.classList.contains("bogos-active")?"true":"false"));const o=e.find(t=>t.classList.contains("bogos-active"));e.forEach(t=>t.setAttribute("tabindex",t===(null!=o?o:e[0])?"0":"-1"))},syncAll:t=>(null!=t?t:document).querySelectorAll(H.radioGroup.GROUP).forEach(H.radioGroup.sync),init:t=>{t&&(H.radioGroup.syncAll(t),"1"!==t.dataset.bogosBnRadio&&(t.dataset.bogosBnRadio="1",new MutationObserver(()=>H.radioGroup.syncAll(t)).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class"]}),t.addEventListener("keydown",t=>{var e,o;const n=null==(o=null==(e=t.target)?void 0:e.closest)?void 0:o.call(e,".bogos-select-option-custom-item");if(!n)return;const i=n.closest(H.radioGroup.GROUP);if(i)switch(t.key){case"ArrowRight":case"ArrowDown":return t.preventDefault(),void H.radioGroup.move(i,n,1);case"ArrowLeft":case"ArrowUp":return t.preventDefault(),void H.radioGroup.move(i,n,-1);case" ":case"Enter":return t.preventDefault(),void n.click();default:return}})))},move:(t,e,o)=>{const n=H.radioGroup.radios(t);if(n.length<2)return;const i=n.indexOf(e);let l=i<0?0:i+o;l<0&&(l=n.length-1),l>=n.length&&(l=0);const a=n[l];n.forEach(t=>t.setAttribute("tabindex",t===a?"0":"-1")),a.focus(),a.click()}},dialog:{VISIBLE:"sca-is-visible-fg",FOCUSABLE:["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])"].map(t=>"".concat(t,':not([tabindex="-1"])')).concat('[tabindex="0"]').join(","),lastFocused:null,panel:t=>null==t?void 0:t.querySelector('[role="dialog"]'),POPUPS:[{container:"#bogos-mix-match-main-collection-popup-container",open:"sca-is-visible-fg",close:".bogos-mix-match-collection-popup-off"},{container:"#bogos-main-popup-product-detail-container",open:"sca-is-visible-fg",close:".bogos-product-modal-close-btn"}],escape:t=>{"Escape"!==t.key||t.defaultPrevented||H.dialog.POPUPS.some(t=>{const e=document.querySelector("".concat(t.container,".").concat(t.open)),o=null==e?void 0:e.querySelector(t.close);return!!o&&(o.click(),!0)})&&t.preventDefault()},focusables:t=>[...t.querySelectorAll(H.dialog.FOCUSABLE)].filter(t=>t.offsetWidth||t.offsetHeight||t===document.activeElement),focusWhenReady:(t,e)=>{if(!t)return;const o=null!=e?e:Date.now()+600;t.focus(),document.activeElement===t||Date.now()>o||window.requestAnimationFrame(()=>H.dialog.focusWhenReady(t,o))},trap:t=>{if("Tab"!==t.key)return;const e=H.dialog.panel(document.querySelector('[data-bogos-dialog-open="1"]'));if(!e)return;const o=H.dialog.focusables(e);if(!o.length)return;const n=o[0],i=o[o.length-1];e.contains(document.activeElement)?t.shiftKey&&document.activeElement===n?(t.preventDefault(),i.focus()):t.shiftKey||document.activeElement!==i||(t.preventDefault(),n.focus()):(t.preventDefault(),n.focus())},watch:t=>{if(!t||"1"===t.dataset.bogosDialogWatch)return;t.dataset.bogosDialogWatch="1";const e=()=>{const e=t.classList.contains(H.dialog.VISIBLE);if(e===("1"===t.dataset.bogosDialogOpen)){const o=H.dialog.panel(t);return void(!e||!o||o.contains(document.activeElement)||document.activeElement&&document.activeElement!==document.body||H.dialog.focusWhenReady(o))}if(t.dataset.bogosDialogOpen=e?"1":"0",e)H.dialog.lastFocused=document.activeElement,H.dialog.focusWhenReady(H.dialog.panel(t));else{const t=H.dialog.lastFocused;H.dialog.lastFocused=null,(null==t?void 0:t.isConnected)&&t.focus()}};new MutationObserver(e).observe(t,{attributes:!0,attributeFilter:["class"],childList:!0}),e(),"1"!==document.body.dataset.bogosBnDialogTrap&&(document.body.dataset.bogosBnDialogTrap="1",document.addEventListener("keydown",H.dialog.trap),document.addEventListener("keydown",H.dialog.escape))}},mix:{sync:t=>{(null!=t?t:document).querySelectorAll(".bogos-mix-match-badge-item, .bogos-mix-match-progress-item").forEach(t=>{const e=t.querySelector("[data-bn-reached]");if(!e)return;const o=t.classList.contains("success")?H.LABEL.REACHED:H.LABEL.NOT_REACHED;e.textContent!==o&&(e.textContent=o),H.status.change(e,"bogosReached",o)})},bindAll:t=>{t.querySelectorAll(".bogos-mix-item-select-variant-dropdown").forEach(t=>H.combobox.bind(t,H.COMBOBOX.mixVariant)),t.querySelectorAll(".bogos-mix-item-select-variant-wrapper").forEach(t=>H.radioGroup.init(t))},init:t=>{t&&(H.mix.sync(t),H.mix.bindAll(t),"1"!==t.dataset.bogosMixA11y&&(t.dataset.bogosMixA11y="1",new MutationObserver(()=>{H.mix.sync(t),H.mix.bindAll(t)}).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class"]})))}},sync:t=>{if(!t)return;const e="tabs"===t.getAttribute("data-layout");t.querySelectorAll(".bogos-bundle-pp-tab-item").forEach(t=>{t.setAttribute("aria-current",t.classList.contains("bogos-active")?"step":"false")}),t.querySelectorAll(".bogos-bundle-pp-size-item").forEach(t=>{t.setAttribute("aria-current",t.classList.contains("bogos-active")?"true":"false")}),t.querySelectorAll(".bogos-bundle-pp-step").forEach(t=>{const o=t.querySelector(".bogos-bundle-pp-step-header");if(o){if(e)return o.removeAttribute("role"),o.removeAttribute("tabindex"),void o.removeAttribute("aria-expanded");o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.setAttribute("aria-expanded",t.classList.contains("bogos-bundle-pp-step-collapsed")?"false":"true")}}),t.querySelectorAll(".bogos-bundle-pp-select-variant-dropdown").forEach(t=>H.combobox.bind(t,H.COMBOBOX.ppVariant)),t.querySelectorAll(".bogos-bundle-pp-select-variant-wrapper").forEach(t=>H.radioGroup.init(t))},init:t=>{H.sync(t),"1"!==t.dataset.bogosPpKeys&&(t.dataset.bogosPpKeys="1",new MutationObserver(()=>H.sync(t)).observe(t,{subtree:!0,attributes:!0,attributeFilter:["class"]}),t.addEventListener("keydown",t=>{var e,o;if("Enter"!==t.key&&" "!==t.key)return;const n=null==(o=null==(e=t.target)?void 0:e.closest)?void 0:o.call(e,'.bogos-bundle-pp-tab-item[role="button"], .bogos-bundle-pp-step-header[role="button"], .bogos-bundle-pp-item-name[role="button"]');n&&(t.preventDefault(),n.click())}))}},N={items_add_bundle:{},activationTimer:null,widgetStyle:(t,e)=>{var o;const n=R.mergeSections(t,e,["content","color"]);return R.withIcons(n.content,e.content,t.content,{shipping_icon_path:window.fgShippingIconsObj}),n.own=R.filled(m(m({},e.content),R.countdownOwn(null==(o=e.content)?void 0:o.countdown_cfg))),n},add:(t,e,...o)=>h(null,[t,e,...o],function*(t,e,o=B.BUNDLE_TYPE.default,n=!0){var i,l,a,r;try{const{quantity_break:s,bundle_page:d,default:c}=B.BUNDLE_TYPE,{current_product:u}=FGSECOMAPP.variables.Shopify,b=o===s?"":"r".concat(Math.random().toString(36).slice(2,8)),p="".concat(B.TRIGGER_FUNC[o],"_").concat(e,"_").concat(o===d?"":null==u?void 0:u.id,"_").concat(b),_=yield L.add_items_trigger(t,{_bogos_trigger_id:e,_bogos_trigger:p,_bogos_trigger_type:o,_bogos_code:FGSECOMAPP.variables.bundles.offer_codes[e]},o);let g="";if(_.ok){const s=null==(l=null==(i=FGSECOMAPP.bundles)?void 0:i.find(t=>{var o;return(null==(o=t.id)?void 0:o.toString())===(null==e?void 0:e.toString())}))?void 0:l.code;n&&(yield L.apply_discounts([s])),w.addToCart([{id:e}],o,c).then(),document.dispatchEvent(new CustomEvent(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_BUNDLE_ADDED,{detail:{items:t,code:s}})),yield J.renderCart({item_count:1}),document.dispatchEvent(new CustomEvent(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_FG_PROCESS,{detail:{event:"bundle:added"}})),null==(r=null==(a=L.dispatch_add_event)?void 0:a.call(L,_,t))||r.then()}else g=(yield _.json()).message;return{ok:_.ok,message:g}}catch(s){return console.error("BOGOS track: bundle added failed",s),{ok:!1,message:"Something went wrong!"}}}),convertDiscountMarket:t=>{var e,o,n;if(X.empty(t))return;const{currency:i}=null!=(e=FGSECOMAPP.variables.Shopify)?e:{},l=null==(o=null==t?void 0:t.other_currencies)?void 0:o.find(t=>t.currency===(null==i?void 0:i.active)),{fixed_amount:a,fixed_price:r}=B.DISCOUNT_TYPE;let s=X.convertMultiCurrency(t.value);[a,r].includes(t.type)&&(t.value=null!=(n=null==l?void 0:l.value)?n:s)},handleTransformProductData:t=>{const e=FGSECOMAPP.productsByID;return t.map(t=>{var o,n,i,l,a,r;const s=e[t.id];return v(m({},t),{available:null!=(n=null!=(o=null==s?void 0:s.available)?o:null==t?void 0:t.available)&&n,thumbnail:null!=(i=null==s?void 0:s.featured_image)?i:t.thumbnail,title:null!=(l=null==s?void 0:s.title)?l:t.title,handle:null!=(a=null==s?void 0:s.handle)?a:t.handle,options:null!=(r=null==s?void 0:s.options)?r:[],variants:t.variants.map(e=>{var o,n,i,l,a,r,d,c,u,b,p;const _=null==(o=null==s?void 0:s.variants)?void 0:o.find(t=>t.id===e.id);return v(m({},e),{title:null!=(n=null==_?void 0:_.title)?n:e.title,price:(null!=(i=null==_?void 0:_.price)?i:e.price*G)/G,available:null!=(r=null!=(a=null!=(l=null==_?void 0:_.available)?l:null==e?void 0:e.available)?a:null==e?void 0:e.availableForSale)&&r,thumbnail:null!=(b=null!=(u=null!=(c=null==(d=null==_?void 0:_.featured_image)?void 0:d.src)?c:null==s?void 0:s.featured_image)?u:e.thumbnail)?b:t.thumbnail,options:null!=(p=null==_?void 0:_.options)?p:[]})})})})},calculateDiscountPrice:(t,e,o)=>{var n,i;let l;switch(t.type){case B.DISCOUNT_TYPE.percentage:l=e*(100-t.value)/100;break;case B.DISCOUNT_TYPE.fixed_amount:l="total"===o?Math.max(0,e-t.value):e;break;case B.DISCOUNT_TYPE.fixed_price:l="total"===o?t.value:e;break;default:l=e}return l.toFixed(null!=(i=null==(n=FGSECOMAPP.variables.Shopify)?void 0:n.fg_decimal)?i:2)},renderEmpty:t=>{t.style.display="",t.innerHTML="There is no bundle including this product."},renderAppReviewEl:(t,e=B.APP_REVIEW.judgeme)=>{var o,n,i,l,a,r,s,d,c;const u=null!=(n=null==(o=FGSECOMAPP.fgIntegration)?void 0:o[e])?n:{},{display_star_rating:b,bundle:p,status:_}=null!=(i=null==u?void 0:u.settings)?i:{};if(null==(l=_&&b&&p)||!l)return"";const g="bogos_".concat(e,"_ratings"),m=X.convertStringToObj(null!=(r=localStorage.getItem(null==(a=FGSECOMAPP.variables.constants)?void 0:a[g]))?r:""),{rating:v}=null!=(s=(null!=m?m:[]).find(({product_id:e})=>e===t))?s:{},h={[B.APP_REVIEW.judgeme]:J.renderStarRatingJudgeme,[B.APP_REVIEW.trustoo]:J.renderStarRatingTrustoo,[B.APP_REVIEW.yotpo]:J.renderStarRatingYotpo};return null!=(c=null==(d=h[e])?void 0:d.call(h,v,t))?c:""},loadScriptBp:()=>{var t,e;if(!FGSECOMAPP.bundles.some(({type:t})=>t===B.BUNDLE_TYPE.bundle_page))return;const o=document.querySelector("#bogos-bundle-page-script");if(!o)return;const n=document.createElement("script");n.src=null==o?void 0:o.getAttribute("data-url"),n.async=!0,document.querySelector('script[src="'.concat(n.src,'"]'))||(null!=(e=null!=(t=null==o?void 0:o.parentNode)?t:document.querySelector("#bogos-integration-block"))?e:document.body).appendChild(n)},init:t=>h(null,null,function*(){var e,o;try{document.dispatchEvent(new CustomEvent(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_BUNDLE_START));const n=JSON.parse(JSON.stringify(null!=(o=null==(e=window.fgData)?void 0:e.bundles)?o:[]));FGSECOMAPP.bundles=null==n?void 0:n.filter(t=>{var e,o,n;const{start_time:i,end_time:l,sub_conditions:a}=t;return FGSECOMAPP.variables.bundles.offer_codes[t.id]=null==(e=null==t?void 0:t.sub_conditions)?void 0:e.specific_link_address,!((t.type===B.BUNDLE_TYPE.classic||!t.type)&&(null==t?void 0:t.recurring_status)&&!(null==(o=null==F?void 0:F.isOfferRecurringActive)?void 0:o.call(F,t.recurring,t.start_time)))&&X.checkValidTimeOffer(i,l)&&(!a||(null==(n=X.checkOfferWithSubCondition)?void 0:n.call(X,t,"bundle")))}).sort((t,e)=>new Date(t.start_time)-new Date(e.start_time)),N.activationTimer&&(N.activationTimer.cancel(),N.activationTimer=null);const i=(null!=n?n:[]).filter(t=>{var e;return(t.type===B.BUNDLE_TYPE.classic||!t.type)&&(null==t?void 0:t.recurring_status)&&!(null==(e=null==F?void 0:F.isOfferRecurringActive)?void 0:e.call(F,t.recurring,t.start_time))&&X.checkValidTimeOffer(t.start_time,t.end_time)}).map(t=>t.recurring);i.length&&(N.activationTimer=F.scheduleNextActivation(i,()=>{N.init("recurring:auto-activate")})),yield Promise.all([V.init(t),j.init(t),U.init(t),Y.init(t),W.init(t)]),N.loadScriptBp()}catch(n){console.warn("BOGOS track: bundle core init failed",n)}}),convertProductWithOptions:t=>{var e;return v(m({},t),{optionsConverted:(null!=(e=null==t?void 0:t.options)?e:[]).map((e,o)=>{var n;return{name:e,values:[...new Set(null==(n=null==t?void 0:t.variants)?void 0:n.map(t=>{var e;return null==(e=null==t?void 0:t.options)?void 0:e[o]}))].filter(Boolean)}})})},renderProductOptionWithValue:(t,e)=>{var o,n,i,l,a,r,s,d;const{configs:c=[]}=null!=(n=null==(o=FGSECOMAPP.fgAppearance)?void 0:o.select_variant)?n:{},u={small:"12px",medium:"20px",large:"32px"},b=X.empty(e)?null==(i=t.variants[0])?void 0:i.options:null!=(r=null==(a=null==(l=t.variants)?void 0:l.find(t=>String(t.id)===String(e)))?void 0:a.options)?r:[],p=null!=(s=null==t?void 0:t.optionsConverted)?s:[],_=null!=(d=null==t?void 0:t.optionsConvertedDefault)?d:[];return p.map((t,e)=>{var o;const n=c.find(t=>{var o,n;return(null==(o=t.data)?void 0:o.option_name)===(null==(n=_[e])?void 0:n.name)}),i="color"===(null==n?void 0:n.type),l=n?i?'':'':'',a=null==(o=t.values)?void 0:o.map((o,a)=>{var r,s,d,c;if(n){const p=n.customize,g=X.safeText(null!=(c=null==(d=null==(s=null==(r=null==n?void 0:n.data)?void 0:r.values)?void 0:s.find(t=>{var o,n;return t.name===(null==(n=null==(o=_[e])?void 0:o.values)?void 0:n[a])}))?void 0:d.label)?c:i?"#ffffff":"https://static.bogos.io/assets/bogos-images/1760928468.png");return FGSECOMAPP.helper.templateHTML.render(l,{bogos_option_value:encodeURIComponent(o),bogos_option_value_title:X.safeText(o),bogos_option_value_label:X.attrText(o),bogos_option_custom_data:g,bogos_option_name:X.safeText(t.name),check_activate_aria:(null==b?void 0:b.includes(o))?"true":"false",bogos_option_color_style:"background-color: ".concat(g,"; width: ").concat(u[p.size],";\n height: ").concat(u[p.size],"; border-radius: ").concat("circle"===p.shape?"50%":"4px"),bogos_option_color_container_style:"border-radius: ".concat("circle"!==p.shape||p.show_name?"4px":"50%"),check_show_title:p.show_name?"":"sca-d-none",check_activate:(null==b?void 0:b.includes(o))?"bogos-active":"",bogos_option_image_style:"width: ".concat(u[p.size],"; height: ").concat(u[p.size],"; border-radius: ").concat("circle"===p.shape?"50%":"4px")})}return FGSECOMAPP.helper.templateHTML.render(l,{bogos_option_value:encodeURIComponent(o),bogos_option_value_title:X.safeText(o),bogos_option_name:X.safeText(t.name),check_activate:(null==b?void 0:b.includes(o))?"bogos-active":"",check_activate_aria:(null==b?void 0:b.includes(o))?"true":"false"})}).join("");return FGSECOMAPP.helper.templateHTML.render('
{{bogos_option_name}}
{{bogos_option_items}}
',{bogos_option_name:X.safeText(t.name),bogos_option_uid:"".concat(++H.seq),bogos_option_style_vars:K(),bogos_option_items:a})}).join("")},handleInvalidVariantOption:(t,e,o)=>{let n=[...t.variants];const i=[];e.forEach((t,e)=>{n.some(o=>o.options[e]===t)?n=n.filter(o=>o.options[e]===t):i.push({position:e,value:t})}),o.querySelectorAll(".bogos-select-option-name-container").forEach((t,e)=>{t.querySelectorAll(".bogos-select-option-custom-item").forEach(t=>{const o=decodeURIComponent(t.getAttribute("data-option-value"));i.some(t=>t.position===e&&t.value===o)?t.classList.add("bogos-deactivate"):t.classList.remove("bogos-deactivate")})})},handleValidVariantOption:(t,e,o,n)=>{var i,l,a;const r=decodeURIComponent(t.getAttribute("data-option-value")),s=null==(i=null==o?void 0:o.variants)?void 0:i.find(t=>{var o;return(null==(o=t.id)?void 0:o.toString())===e}),d=null!=(l=null==s?void 0:s.options)?l:[],c=null==o?void 0:o.options.findIndex(e=>t.getAttribute("data-option-name")===e),u=null==d?void 0:d.map((t,e)=>c===e?r:t);return n.querySelectorAll(".bogos-select-option-custom-item").forEach(t=>{const e=decodeURIComponent(t.getAttribute("data-option-value"));u.includes(e)?t.classList.add("bogos-active"):t.classList.remove("bogos-active"),t.classList.remove("bogos-deactivate")}),{selectedVariant:null==(a=null==o?void 0:o.variants)?void 0:a.find(t=>t.options.length===u.length&&t.options.every((t,e)=>t===u[e])),newOptions:u}},convertProductWithOptionsDefault:(t,e)=>{var o,n;const i=v(m({},e),{optionsDefault:null!=(o=null==t?void 0:t.options)?o:[],variants:e.variants.map(e=>{var o,n;const i=null==(o=null==t?void 0:t.variants)?void 0:o.find(t=>String(t.id)===String(e.id));return v(m({},e),{optionsDefault:null!=(n=null==i?void 0:i.options)?n:[]})})});return v(m({},i),{optionsConvertedDefault:(null!=(n=null==i?void 0:i.optionsDefault)?n:[]).map((t,e)=>{var o;return{name:t,values:[...new Set(null==(o=null==i?void 0:i.variants)?void 0:o.map(t=>{var o;return null==(o=null==t?void 0:t.optionsDefault)?void 0:o[e]}))]}})})}},R={CUSTOM:"custom",TIME_LABELS:{day:"Days",hour:"Hours",minute:"Minutes",second:"Seconds"},cache:new WeakMap,isObject:t=>!!t&&"object"==typeof t&&!Array.isArray(t),hasValue:t=>null!=t&&""!==t,filled:t=>C(Object)(Object.entries(null!=t?t:{}).filter(([,t])=>R.hasValue(t))),mergeFilled:(t,e)=>Object.entries(null!=e?e:{}).reduce((t,[e,o])=>(R.isObject(o)&&!Array.isArray(o.value)?t[e]=R.mergeFilled(R.isObject(t[e])?t[e]:{},o):!R.hasValue(o)||Array.isArray(o)&&!o.length||(t[e]=o),t),m({},null!=t?t:{})),mergeSections:(t,e,o)=>m(m({},t),C(Object)(o.map(o=>[o,R.mergeFilled(t[o],e[o])]))),parse:t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return null}},resolve:(t,e,o,n)=>{const i=t?R.cache.get(t):null;if(i&&i.group===e&&i.base===o&&i.customize===t.customize)return i.value;const l=R.parse(null==t?void 0:t.customize),a=(null==l?void 0:l.style)===R.CUSTOM,r=v(m({},n(null!=o?o:{},a?l:{})),{custom:a,id:null==t?void 0:t.id,group:e});return t&&R.cache.set(t,{group:e,base:o,customize:t.customize,value:r}),r},themeIcon:(t,e,o)=>{var n;return/^(https?:)?\/\//.test(t)?t:null!=(n=null==e?void 0:e[String(t).split("/").pop()])?n:o},withIcons:(t,e,o,n)=>(Object.entries(n).forEach(([n,i])=>{X.empty(null==e?void 0:e[n])||(t[n]=R.themeIcon(e[n],i,null==o?void 0:o[n]))}),t),timeLabelsOwn:(t,e="")=>C(Object)(Object.entries(null!=t?t:{}).map(([t,o])=>["".concat(e,"time_label_").concat(t),o])),countdownOwn:(t,e="")=>m({["".concat(e,"countdown_text")]:null==t?void 0:t.countdown_text},R.timeLabelsOwn(null==t?void 0:t.time_labels,e)),text:(t,e,o,n,i=n,...l)=>{var a,r,s;const d=null!=(r=null==(a=null==t?void 0:t.content)?void 0:a[e])?r:o,c=(null==t?void 0:t.custom)&&!X.empty(null==(s=t.own)?void 0:s[e])?"".concat(t.group,".").concat(t.id,".customize.").concat(e):null;return J.convertIntegration(d,null!=c?c:n,null!=c?c:i,...l)},countdownTexts:(t,e)=>{var o;return v(m({},t),{countdown_text:e("countdown_text",null!=(o=null==t?void 0:t.countdown_text)?o:"Expiring in"),time_labels:C(Object)(Object.entries(R.TIME_LABELS).map(([o,n])=>{var i;return[o,e("time_label_".concat(o),(null==(i=null==t?void 0:t.time_labels)?void 0:i[o])||n)]}))})},setVars:(t,e)=>Object.entries(e).forEach(([e,o])=>{X.empty(o)?t.style.removeProperty(e):t.style.setProperty(e,o)})},z={DISPLAY_MODE:{top_bar:"top_bar",in_widget:"in_widget",banner:"banner",badge:"badge"},insertByMode:(t,e,o,n={})=>{var i;if(e!==z.DISPLAY_MODE.in_widget||"function"!=typeof n.inWidget){if(e===z.DISPLAY_MODE.badge)return void(null!=(i=n.header)?i:o).insertAdjacentElement("afterend",t);o.insertBefore(t,o.firstChild)}else n.inWidget(t)},mount:(t,e)=>{var o,n,i;const l=F;if(!l||!e)return;if(!0!==(null==(o=null==t?void 0:t.recurring)?void 0:o.show_countdown))return;const{recurring:a={},recurring_status:r=!1}=t,s=!(!a||!r),d=(null==t?void 0:t.end_time)?new Date(t.end_time).getTime():null,c=Number.isFinite(d)&&d>Date.now();if(!s&&!c)return;const u=s?null:()=>{const e=new Date(t.end_time).getTime();return Number.isFinite(e)&&e>Date.now()?new Date(e):null},b=V.appearanceOf(t),{countdown_cfg:p}=null!=(n=b.color)?n:{},{countdown_cfg:_}=null!=(i=b.content)?i:{},g=b.custom?l.mergeCountdownCfg(R.countdownTexts(_,(t,e)=>{const o="customize.bundle_classic.".concat(t);return R.text(b,t,e,o,o)}),p,null):l.mergeCountdownCfg(_,p,"customize.bundle_classic"),m=l.create({cfg:g,recurring:a,onWindowClosed:()=>h(null,null,function*(){try{const e=null==t?void 0:t.code;e&&(yield L.remove_discount([e]),yield J.renderCart({item_count:1}))}catch(o){}e&&e.parentNode&&(e.style.display="none")}),startTime:null==t?void 0:t.start_time,resolveEnd:u});m&&z.insertByMode(m.el,g.display_mode,e,{inWidget:t=>{const o=e.querySelector(".bogos-bundles-widget-footer"),n=e.querySelector(".bogos-bundles-button-add");o&&n?o.insertBefore(t,n):e.appendChild(t)},header:e.querySelector(".bogos-bundles-widget-header")})}},V={DISCOUNT_FUNCTION:{product:"product_discount",shipping:"shipping_discount"},appearanceOf:t=>{var e,o;return R.resolve(t,"classic_bundles",null!=(o=null==(e=FGSECOMAPP.fgAppearance)?void 0:e.bundle)?o:{},N.widgetStyle)},ITEM_LEVEL:{product:"product",variant:"variant"},dataProduct:{},productsTemp:{},matchDisplayOn:(t,e)=>{var o;if(X.empty(e))return!1;const n=null==(o=null==t?void 0:t.extra_info)?void 0:o.display_on;return n&&"products"===n.scope?(Array.isArray(n.products)?n.products:[]).some(t=>{var o;return String(null!=(o=null==t?void 0:t.id)?o:t)===String(e)}):(null!=(r=null!=(a=null==(l=null==(i=null==t?void 0:t.products)?void 0:i[0])?void 0:l.value)?a:null==t?void 0:t.products)?r:[]).some(t=>String(t.id)===String(e));var i,l,a,r},filterWithBlocks:t=>{var e,o,n,i;let l={};const a=t?FGSECOMAPP.current_bundles:null==(e=FGSECOMAPP.bundles)?void 0:e.filter(t=>t.type===B.BUNDLE_TYPE.classic||!t.type),{current_product:r}=null!=(o=FGSECOMAPP.variables.Shopify)?o:{},s=X.empty(null==r?void 0:r.id)?[]:null==a?void 0:a.filter(t=>V.matchDisplayOn(t,null==r?void 0:r.id)),{product_form_query:d}=null!=(n=FGSECOMAPP.QUERY_SELECTOR)?n:{};let c=t?[t]:document.querySelectorAll(null==(i=null==d?void 0:d.customize)?void 0:i.join(","));return c.forEach(t=>{var e,o;const n=Number(X.getIntShopifyId(t.getAttribute("data-product-id"))),i=Number(t.getAttribute("data-offer-id"));let r=null;i&&(r=null==(e=null!=r?r:a)?void 0:e.filter(t=>t.id.toString()===i.toString())),n&&(r=null==(o=null!=r?r:a)?void 0:o.filter(t=>V.matchDisplayOn(t,n))),null==r||r.forEach(t=>l[t.id]=t),i||n||s.forEach(t=>l[t.id]=t)}),c.length||s.forEach(t=>l[t.id]=t),Object.values(l)},filter:t=>h(null,null,function*(){var e,o,n,i;try{FGSECOMAPP.current_bundles=V.filterWithBlocks();const a=[],r=[],s={handles:[...null!=(n=null==(o=null==(e=FGSECOMAPP.current_bundles)?void 0:e.map(t=>{var e,o,n,i,l,s;t.products_root=[...t.products],t.products=null!=(n=null==(o=null==(e=t.products_root)?void 0:e[0])?void 0:o.value)?n:t.products_root;const d=null!=(i=null==t?void 0:t.discount[0])?i:null==t?void 0:t.discount,c=null!=(s=null!=(l=null==d?void 0:d.discount)?l:d)?s:{};if(c.type===B.DISCOUNT_TYPE.free_products){const t=c.value.map(t=>t.handle);a.push(...c.value.map(t=>t.id)),r.push(...t)}return t}))?void 0:o.reduce((t,e)=>(t=[...t,...e.products.map(t=>(a.push(t.id),t.handle))],[...new Set(t)]),[]))?n:[],...r],ids:a};!t&&(yield O.cacheProducts(null==s?void 0:s.handles,{"sca-bundle-search":"1"},()=>h(null,null,function*(){console.info("BOGOS track: classic-bundle:sync-quantity:".concat(Date.now()))}),s));try{J.syncStarRating([...new Set(a)]).then()}catch(l){}FGSECOMAPP.current_bundles=null==(i=FGSECOMAPP.current_bundles)?void 0:i.filter(t=>{var e,o;const{discount:n,extra_info:i}=t,l=null!=(e=n[0])?e:n,{discount:a}=l,r=null!=a?a:n,s=r.type===B.DISCOUNT_TYPE.fixed_amount,d=r.type===B.DISCOUNT_TYPE.fixed_price,c=r.type===B.DISCOUNT_TYPE.free_products,u=(null==r?void 0:r.discount_function)===V.DISCOUNT_FUNCTION.shipping,{item_level:b}=null!=i?i:{},p=(null!=b?b:V.ITEM_LEVEL.product)===V.ITEM_LEVEL.product;N.convertDiscountMarket(r),t.discount=v(m({},l),{discount:r});const _=t.products.every(t=>{var e,o;const n=null==(e=FGSECOMAPP.productsByID)?void 0:e[t.id],i=t=>{var e,o,i,l;const{id:a,price:r}=t,s=null!=(e=null==n?void 0:n.variants_quantity)?e:{},{available:d,price:c}=null!=(i=null==(o=null==n?void 0:n.variants)?void 0:o.find(t=>t.id===a))?i:{};return t.handle=null!=(l=null==n?void 0:n.handle)?l:t.handle,t.price=c?c/G:X.convertMultiCurrency(r),s[a]>0||d};return p?(t.variants=null!=(o=t.variants.filter(i))?o:[],t.variants.length>0):t.variants.length>0&&t.variants.every(i)});if(_){t.original_price=t.products.reduce((t,e)=>{const{variants:o,quantity:n}=e;if(p){const{price:e}=(null==o?void 0:o[0])||{price:0};return t+parseFloat(null!=e?e:0)*n}return t+o.reduce((t,e)=>{const{price:o,quantity:n}=e;return t+o*parseInt(null!=n?n:"1")},0)},0),t.discount.convert=s?r.value/t.original_price*100:r.value,t.discount_price=u?t.original_price:N.calculateDiscountPrice(r,t.original_price,"total"),t.products.forEach(t=>{t.variants.forEach(t=>{const{price:e,quantity:o}=t,n=e*(p?1:o);t.discount_price=u?n:N.calculateDiscountPrice(r,n)})});let e=0;c&&(null!=(o=r.value)?o:[]).forEach(t=>{const o=FGSECOMAPP.productsByID[t.id];t.variants.forEach(t=>{var n,i;const l=null==(n=null==o?void 0:o.variants)?void 0:n.find(e=>e.id===t.id);let a=parseFloat(t.price)*parseInt(null!=(i=t.quantity)?i:"1");l&&!(null==l?void 0:l.available)&&(a=0),e+=a})}),t.original_price+=e,t.discount.label=d||c||u?"":"(".concat(FGSECOMAPP.helper.templateHTML.render(X.safeMerchantHTML(J.convertIntegration("{{discountAmount}} OFF","customize.bundle_discount_label","customize.bundle_classic.discount_text",!0),!0),{discountAmount:"".concat(s?X.renderPrice(r.value):r.value+"%")}),")"),N.items_add_bundle[t.id]=P(t.products.map(t=>{t.quantity=parseInt("".concat(t.quantity));const{variants:e,quantity:o}=t;if(!p)return e;const n=v(m({},e[0]),{quantity:o});return 1===e.length?[n]:Array(o).fill(v(m({},n),{quantity:1}))}),"flat")()}return _})}catch(l){console.warn("BOGOS track: bundle filter",l)}}),renderBundleProduct:(t,e,o,n,i)=>{var l,a,r,s,d;const{show_discount_each_item:c}=i.content,u=FGSECOMAPP.productsByID;let{variants:b,id:p,handle:_,title:g,quantity:m}=t;const v=null!=(l=null==u?void 0:u[p])?l:{},h=1===(null==b?void 0:b.length),y=null!=(a=null==t?void 0:t.variants[0])?a:{},f=null==v?void 0:v.variants[0],x=null!=(d=null!=(s=null==y?void 0:y.thumbnail)?s:null==(r=null==f?void 0:f.featured_image)?void 0:r.src)?d:null==v?void 0:v.featured_image,S=N.renderAppReviewEl(p),E=N.renderAppReviewEl(p,B.APP_REVIEW.trustoo),A=N.renderAppReviewEl(p,B.APP_REVIEW.yotpo),q=c&&e.type===B.DISCOUNT_TYPE.percentage&&e.value,P=v?v.title:g,M=h?"":R.text(i,"select_variant_text","Select variant","customize.bundle_select_variant","customize.bundle_classic.select_variant_text");return FGSECOMAPP.helper.templateHTML.render(o,{bogos_bundle_item_handle:X.safeText(X.routePath("products/".concat(_))),bogos_bundle_item_img:X.safeText(X.handleResizeGiftImage(x,!0)),bogos_bundle_item_title:X.safeText(v?v.title:g),bogos_product_id:p,bogos_integration_judgeme:S,bogos_integration_trustoo:E,bogos_integration_yotpo:A,bogos_bundle_item_original:q?X.renderPrice(y.price):"",bogos_bundle_item_sr_sale:q?'Sale price':"",bogos_bundle_item_sr_regular:q?'Regular price':"",bogos_bundle_item_discount:X.renderPrice(y.discount_price),bogos_bundle_item_quantity:m,bogos_bundle_select_variant_a11y:h?'aria-hidden="true"':'role="button" tabindex="0" aria-expanded="false"'+' aria-label="'.concat(X.attrText("".concat(M," ").concat(P)),'"'),bogos_bundle_select_variant:X.safeMerchantHTML(M,!0),bogos_bundle_section_variants:V.renderBundleOptions(null!=b?b:[],x,m,v,n,i),product:t})},renderBundleVariant:(t,e,o,n)=>{var i,l,a,r,s,d;const c=null!=(l=null==(i=document.querySelector("#sca_bundle_variant_level_id"))?void 0:i.innerHTML)?l:'
{{ bogos_bundle_item_title }}
{{ bogos_bundle_item_title }} {{ bogos_integration_judgeme }} {{ bogos_integration_trustoo }} {{ bogos_integration_yotpo }}
{{ bogos_bundle_variant_title }}
{{ bogos_variant_out_stock }}
x{{ bogos_bundle_item_quantity }} {{ bogos_bundle_item_discount }} {{ bogos_bundle_item_original }}
',{out_stock_text:u,show_discount_each_item:b}=n.content,p=FGSECOMAPP.productsByID;let{id:_,handle:g,title:m}=e;const v=null!=(a=null==p?void 0:p[_])?a:{},h=(null!=(r=null==v?void 0:v.variants)?r:[]).find(e=>e.id===t.id),y=null!=(d=null==(s=null==h?void 0:h.featured_image)?void 0:s.src)?d:null==v?void 0:v.featured_image,f=h?h.title:t.title,x=N.renderAppReviewEl(_),S=N.renderAppReviewEl(_,B.APP_REVIEW.trustoo),E=N.renderAppReviewEl(_,B.APP_REVIEW.yotpo),A=b&&o.type===B.DISCOUNT_TYPE.percentage&&o.value,q=t.price*t.quantity;return FGSECOMAPP.helper.templateHTML.render(c,{bogos_bundle_item_handle:X.safeText(X.routePath("products/".concat(g))),bogos_bundle_item_img:X.safeText(X.handleResizeGiftImage(y,!0)),bogos_bundle_item_title:X.safeText(v?v.title:m),bogos_product_id:_,bogos_integration_judgeme:x,bogos_integration_trustoo:S,bogos_integration_yotpo:E,bogos_bundle_item_original:A?X.renderPrice(q):"",bogos_bundle_variant_title:X.checkIsDefaultTitle(f)?"":X.safeText(f),bogos_bundle_item_discount:X.renderPrice(t.discount_price),bogos_bundle_item_quantity:t.quantity,bogos_out_stock_class:h&&(null==h?void 0:h.available)?"sca-d-none":"",bogos_variant_out_stock:h&&(null==h?void 0:h.available)?"":X.safeMerchantHTML(J.convertIntegration(null!=u?u:"Out of stock!","customize.bundle_classic_out_stock_text","customize.bundle_classic.out_stock_text"),!0)})},renderDiscountShipping:(t,e,o)=>{var n,i,l,a,r;const s=null!=(i=null==(n=document.querySelector("#sca_bundle_shipping_discount_section"))?void 0:n.innerHTML)?i:'
{{ bogos_shipping_discount_title }}
',{shipping_icon_path:d}=o.content;return FGSECOMAPP.helper.templateHTML.render(s,{bogos_shipping_discount_title:X.safeMerchantHTML(J.convertIntegration(null!=(r=null!=(a=null==e?void 0:e.shipping_label)?a:null==(l=null==e?void 0:e.shipping_discount)?void 0:l.label)?r:"","bundle.".concat(t,".shipping_label"),"classic_bundles.".concat(t,".shipping_label")),!0),bogos_shipping_icon:X.safeText(null!=d?d:fgShippingIconsObj["shipping-icon-1.png"])})},renderFreeProducts:(t,e)=>{var o,n;const i=null!=(n=null==(o=document.querySelector("#sca_bundle_free_products_container"))?void 0:o.innerHTML)?n:'
{{ bogos_free_products_header }}
{{ bogos_free_products_body }}
',l=P(t.map(t=>t.variants.map(o=>V.renderFreeProductItem(t,o,e))),"flat")().join(" ");return FGSECOMAPP.helper.templateHTML.render(i,{bogos_free_products_header:X.safeMerchantHTML(R.text(e,"free_product_title","\ud83c\udf81 Free Gift","customize.bundle_classic_free_product_title","customize.bundle_classic.free_product_title"),!0),bogos_free_products_body:l})},renderFreeProductItem:(t,e,o)=>{var n,i,l,a,r,s;const d=null!=(i=null==(n=document.querySelector("#sca_bundle_free_products"))?void 0:n.innerHTML)?i:'
{{ bogos_bundle_item_title }}
{{ bogos_bundle_item_title }} {{ bogos_integration_judgeme }} {{ bogos_integration_trustoo }} {{ bogos_integration_yotpo }}
{{ bogos_bundle_variant_title }}
{{ bogos_variant_out_stock }}
x{{ bogos_bundle_item_quantity }} {{ bogos_bundle_item_discount }} {{ bogos_bundle_item_original }}
',{out_stock_text:c}=o.content,u=FGSECOMAPP.productsByID;let{id:b,handle:p,title:_}=t;const g=null!=(l=null==u?void 0:u[b])?l:{},m=(null!=(a=null==g?void 0:g.variants)?a:[]).find(t=>t.id===e.id),v=null!=(s=null==(r=null==m?void 0:m.featured_image)?void 0:r.src)?s:null==g?void 0:g.featured_image,h=m?m.title:e.title,y=m?(null==m?void 0:m.price)/G:X.convertMultiCurrency(null==e?void 0:e.price),f=N.renderAppReviewEl(b),x=N.renderAppReviewEl(b,B.APP_REVIEW.trustoo),S=N.renderAppReviewEl(b,B.APP_REVIEW.yotpo);return FGSECOMAPP.helper.templateHTML.render(d,{bogos_bundle_item_handle:X.safeText(X.routePath("products/".concat(p))),bogos_bundle_item_img:X.safeText(X.handleResizeGiftImage(v,!0)),bogos_bundle_item_title:X.safeText(g?g.title:_),bogos_product_id:b,bogos_integration_judgeme:f,bogos_integration_trustoo:x,bogos_integration_yotpo:S,bogos_bundle_item_original:X.renderPrice(y),bogos_bundle_variant_title:X.checkIsDefaultTitle(h)?"":X.safeText(h),bogos_bundle_item_discount:X.safeMerchantHTML(R.text(o,"free_price","FREE","customize.bundle_classic_free_price","customize.bundle_classic.free_price"),!0),bogos_bundle_item_quantity:e.quantity,bogos_out_stock_class:m&&(null==m?void 0:m.available)?"sca-d-none":"",bogos_variant_out_stock:m&&(null==m?void 0:m.available)?"":X.safeMerchantHTML(J.convertIntegration(null!=c?c:"Out of stock!","customize.bundle_classic_out_stock_text","customize.bundle_classic.out_stock_text"),!0)})},renderBundles:t=>{var e,o,n,i,l,a,r;const s=null!=(o=null==(e=document.querySelector("#sca_bundle_section_frame"))?void 0:e.innerHTML)?o:'
{{ bogos_bundle_title }}
{{ bogos_bundle_description }}
{{ bogos_bundle_section_items }} {{ bogos_bundle_free_products }} {{ bogos_bundle_discount_shipping }}
',d=null!=(i=null==(n=document.querySelector("#sca_bundle_section_items"))?void 0:n.innerHTML)?i:'
{{ bogos_bundle_item_title }}
{{ bogos_bundle_item_title }} {{ bogos_integration_judgeme }} {{ bogos_integration_trustoo }} {{ bogos_integration_yotpo }}
{{ bogos_bundle_item_sr_sale }} {{ bogos_bundle_item_discount }} {{ bogos_bundle_item_sr_regular }} {{ bogos_bundle_item_original }}
x{{ bogos_bundle_item_quantity }}
{{ bogos_bundle_select_variant }}
{{ bogos_bundle_section_variants }}
',c=null!=(a=null==(l=document.querySelector("#sca_bundle_section_footer"))?void 0:l.innerHTML)?a:'
{{ bundle_total_price_text }}
Sale price {{ bundle_discount_price }} Regular price {{ bundle_original_price }}
';return null==(r=null!=t?t:FGSECOMAPP.current_bundles)?void 0:r.map(t=>{var e,o,n,i;const l=V.appearanceOf(t),{show_description:a,show_discount_on_button:r}=l.content,{discount:u,extra_info:b}=null!=t?t:{},{discount:p,shipping_discount:_}=null!=u?u:{},g=null!=p?p:u,{item_level:m}=null!=b?b:{},v=(null!=m?m:V.ITEM_LEVEL.product)===V.ITEM_LEVEL.product?null==(e=t.products)?void 0:e.map(e=>V.renderBundleProduct(e,g,d,t.id,l)).join(" "):P(t.products,"flatMap")(t=>t.variants.map(e=>V.renderBundleVariant(e,t,g,l))).join(" "),h=g.type===B.DISCOUNT_TYPE.free_products,y=!X.empty(_)||(null==(o=t.discount)?void 0:o.discount_function)===V.DISCOUNT_FUNCTION.shipping,f=h?g.value:[],x=92*(2+t.products.length)+40,S=92*(t.products.length+f.length)>x,E=V.renderFreeProducts(f,l),A=V.renderDiscountShipping(t.id,u,l),q=g.type!==B.DISCOUNT_TYPE.free_products&&r&&g.value,M=Number(Number(t.discount_price)<=Number(t.original_price)?t.discount_price:t.original_price),C=FGSECOMAPP.helper.templateHTML.render(c,{bundle_total_price_text:X.safeMerchantHTML(R.text(l,"total_price_text","Total bundle price","customize.bundle_total_price","customize.bundle_classic.total_price_text",!0),!0)+" ".concat(g.type!==B.DISCOUNT_TYPE.free_products&&g.value&&null!=(n=t.discount.label)?n:"",":"),bundle_discount_price:X.renderPrice(M),bundle_original_price:Number(t.original_price)!==M?X.renderPrice(t.original_price):"",bundle_add_button:X.safeMerchantHTML(R.text(l,"button_text","Add bundle to cart","customize.bundle_add_to_cart","customize.bundle_classic.button_text",!0),!0)+(q?" ".concat(null!=(i=t.discount.label)?i:""):""),bundle:t}),O=X.empty(null==t?void 0:t.sub_title)?t.title:null==t?void 0:t.sub_title;return FGSECOMAPP.helper.templateHTML.render(s,{bogos_bundle_id:t.id,bogos_bundle_title:X.safeMerchantHTML(J.convertIntegration(O,"bundle.bundle_title_".concat(t.id),"classic_bundles.".concat(t.id,".title")),!0),bogos_bundle_description:a?X.safeMerchantHTML(J.convertIntegration(t.description,"bundle.bundle_description_".concat(t.id),"classic_bundles.".concat(t.id,".description")),!0):"",bogos_bundle_section_items:v,bogos_bundle_free_products:h?E:"",bogos_bundle_discount_shipping:y?A:"",bogos_bundle_footer:"".concat(C," ").concat(Z.BRAND_MARK_TEMPLATE("bogos-bundles-brand-mark")),bogos_bundle_overflow:h&&S?"max-height: ".concat(x,"px;overflow-y: scroll;"):"",bogos_custom_style:h&&S?"bogos-bundles-footer-box-shadow":"",bundle:t})}).join(" ")},renderBundleOptions:(t,e,o,n,i,l)=>{var a,r,s;const d=null!=(a=null==n?void 0:n.variants)?a:[],c=v(m({},n),{variants:t.map(t=>{var e;return(null==(e=null==n?void 0:n.variants)?void 0:e.find(e=>String(e.id)===String(t.id)))||null}).filter(Boolean)}),u=1===t.length,b=null!=(s=null==(r=document.querySelector("#sca_bundle_section_variant"))?void 0:r.innerHTML)?s:'
{{ bogos_bundle_option_index }}
{{ bogos_bundle_option_variants }}
',{item_index_text:p}=l.content,_=u?[o-1]:Array.from({length:o},(t,e)=>e);return _.map(o=>{var l,a;return FGSECOMAPP.helper.templateHTML.render(b,{bogos_bundle_option_index:X.safeMerchantHTML(J.convertIntegration(null!=p?p:"Item","customize.bundle_item_index","customize.bundle_classic.item_text",!0),!0)+" ".concat(1===_.length?"":o+1),bogos_bundle_option_variants:V.renderProductOptions(t,N.convertProductWithOptions(c),e,i),bogos_bundle_selected:X.safeText(null!=(a=null==(l=d.find(e=>e.id===t[0].id))?void 0:l.title)?a:t[0].title),bogos_product_id:n.id,bogos_variant_id:t[0].id})}).join(" ")},render:t=>{var e,o,n;const{product_form_query:i}=null!=(e=FGSECOMAPP.QUERY_SELECTOR)?e:{};let l=document.querySelectorAll(null==(o=null==i?void 0:i.customize)?void 0:o.join(","));const a=!(null==(n=FGSECOMAPP.current_bundles)?void 0:n.length);let r=[];if(a||console.info("BOGOS track: classic-bundle core",t),l.forEach(t=>{const e=V.filterWithBlocks(t),o=!e.length,n=t.querySelector("#bogos-bundle-preview-mode");n&&o?N.renderEmpty(n):o||(t.innerHTML=V.renderBundles(e),r.push(...e))}),a)return;if(!l.length){const t=V.renderBundles(),e=[...null==i?void 0:i.integration,...null==i?void 0:i.default].filter(Boolean).join(",");l=document.querySelector(e);const o=document.createElement("div");o.id="bogos-bundle-view",o.innerHTML=t,null==l||l.appendChild(o),r.push(...FGSECOMAPP.current_bundles)}const{classic:s,default:d}=B.BUNDLE_TYPE;X.empty(r)||(r=Object.values(Object.assign({},...r.map(t=>({[t.id]:t})))),w.sessionViews(r,s,d).then()),r.forEach(t=>{var e;const o=null==t?void 0:t.type;if(o!==s&&o!==d&&!X.empty(o))return;const n=null!=(e=document.querySelector('.bogos-bundles-widget[data-bundle-id="'.concat(t.id,'"]')))?e:document.querySelector(".bogos-bundles-widget");z.mount(t,n)}),document.dispatchEvent(new CustomEvent(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_BUNDLE_RENDER,{detail:{bundles:r,addFunction:(t,e)=>N.add(t,e,s)}}))},renderProductOptions:(t,e,o,n)=>{var i,l,a,r;const s=null!=(i=null==e?void 0:e.variants)?i:[],{type:d="variant"}=null!=(a=null==(l=FGSECOMAPP.fgAppearance)?void 0:l.select_variant)?a:{};if("variant"===d){const n='
\n {{ bundle_variant_title }}\n
';return t.map(t=>{var i,l;const a=s.find(e=>e.id===t.id),r=null!=(l=null==(i=null==a?void 0:a.featured_image)?void 0:i.src)?l:null==e?void 0:e.featured_image;return FGSECOMAPP.helper.templateHTML.render(n,{bundle_variant_img:X.safeText(X.handleResizeGiftImage(null!=r?r:o,!0)),bundle_variant_id:t.id,bundle_variant_discount_price:t.discount_price,bundle_variant_original_price:t.price,bundle_variant_title:X.safeText(a?a.title:t.title),bogos_sv_style:K(!0)})}).join("")}return V.productsTemp[n]=m({},null!=(r=V.productsTemp[n])?r:{}),V.productsTemp[n][e.id]=e,k.queryProductDefault(e.id).then(),'
'},styleVarsOf:t=>{const e=V.appearanceOf(t).color;return{"--bogos-bundle-bg":e.widget_background_color,"--bogos-bundle-border":"clean"===e.theme_color?"1px solid #616161":null,"--bogos-bundle-card-bg":e.item_card_background_color,"--bogos-bundle-title":e.title_text_color,"--bogos-bundle-description":e.description_text_color,"--bogos-bundle-item-name":e.item_name_color,"--bogos-bundle-price":e.bundle_price_color,"--bogos-bundle-compare":e.original_price_color,"--bogos-bundle-btn-bg":e.button_background_color,"--bogos-bundle-btn-text":e.button_text_color,"--bogos-bundle-ship-bg":e.shipping_discount_background,"--bogos-bundle-ship-text":e.shipping_discount_text_color}},applyStyleVars:()=>{document.querySelectorAll(".bogos-bundles-widget").forEach(t=>{var e;const o=null==(e=FGSECOMAPP.current_bundles)?void 0:e.find(e=>String(e.id)===t.dataset.bundleId);R.setVars(t,V.styleVarsOf(o))})},renderEventQuery:()=>{var t,e,o,n,i,l,a;V.applyStyleVars();const r=null==(i=null==(n=null==(o=null==(e=null==(t=FGSECOMAPP.QUERY_SELECTOR)?void 0:t.product_form_query)?void 0:e.customize)?void 0:o.filter(Boolean))?void 0:n.map(t=>"".concat(t," .bogos-bundles-widget")))?void 0:i.join(","),{type:s="variant"}=null!=(a=null==(l=FGSECOMAPP.fgAppearance)?void 0:l.select_variant)?a:{};X.empty(r)||document.querySelectorAll(r).forEach(t=>{var e,o,n;const i=t.getAttribute("data-bundle-id"),l=null==(e=FGSECOMAPP.current_bundles)?void 0:e.find(t=>{var e;return(null==(e=t.id)?void 0:e.toString())===i});if(X.empty(i)||X.empty(l))return;const a=[...null==(o=N.items_add_bundle)?void 0:o[i]],{discount:r}=l,d=null!=(n=null==r?void 0:r.discount)?n:(null==r?void 0:r.discount_function)===V.DISCOUNT_FUNCTION.shipping?{type:B.DISCOUNT_TYPE.percentage,value:0}:r,c=(e,o)=>{const n=t.querySelector('.bogos-bundle-item-container:has([data-variant-id="'.concat(e.id,'"]) .bogos-bundle-item-img'));!X.empty(e.thumbnail)&&n&&(n.src=e.thumbnail);const i=null==a?void 0:a[o];!X.empty(i)&&(a[o]=m(m({},a[o]),e));const r=a.reduce((t,e)=>t+e.price*e.quantity,0);[{query:".bogos-bundles-total-discount-price",price:N.calculateDiscountPrice(d,r,"total")},{query:".bogos-bundles-total-original-price",price:r,disable:!d.value},{query:'.bogos-bundle-item-container:has([data-variant-id="'.concat(e.id,'"]) .bogos-bundle-item-discount-price'),price:e.discount_price},{query:'.bogos-bundle-item-container:has([data-variant-id="'.concat(e.id,'"]) .bogos-bundle-item-original-price'),price:e.price,disable:!V.appearanceOf(l).content.show_discount_each_item||d.type!==B.DISCOUNT_TYPE.percentage||!d.value}].forEach(e=>{e.disable||t.querySelector(e.query)&&(t.querySelector(e.query).innerHTML=X.renderPrice(e.price))})};t.querySelectorAll(".bogos-bundle-variant-option-container:has(.bogos-bundle-select-variant-option)").forEach((t,e)=>{const o=t.querySelector(".bogos-bundle-variant-selected"),n=t.querySelectorAll(".bogos-bundle-select-variant-option"),i=t=>{o.textContent=t.currentTarget.textContent.trim();const n=t.currentTarget.getAttribute("data-variant-id"),i=t.currentTarget.getAttribute("data-original-price");o.setAttribute("data-variant-id",n),o.setAttribute("data-original-price",i);const l={id:n-0,price:i-0,thumbnail:t.currentTarget.getAttribute("data-img"),discount_price:t.currentTarget.getAttribute("data-discount-price")-0};c(l,e)};document.addEventListener("click",e=>{!t.contains(e.target)&&t.classList.contains("opened")&&t.classList.remove("opened")}),n.forEach(t=>{t.addEventListener("click",i)}),t.addEventListener("click",()=>{t.classList.toggle("opened")}),H.combobox.bind(t,H.COMBOBOX.classicVariant)}),t.querySelectorAll(".bogos-bundle-variant-option-container:not(:has(.bogos-bundle-select-variant-option))").forEach((e,o)=>{const n=e.getAttribute("data-product-id"),a=e.querySelector(".bogos-bundle-variant-selected");a.addEventListener("click",()=>h(null,null,function*(){var t;if(e.classList.toggle("opened"),"option"===s&&!e.querySelector(".bogos-select-option-name-container")){const o=e.querySelector(".bogos-bundle-variant-item-select"),l=null!=(t=V.productsTemp[i][n])?t:{};FGSECOMAPP.productsDefaultByID[l.id]||(yield k.queryProductDefault(l.id));const a=N.convertProductWithOptionsDefault(FGSECOMAPP.productsDefaultByID[l.id],l);o.innerHTML=N.renderProductOptionWithValue(a)}})),e.addEventListener("click",r=>h(null,null,function*(){var s,d;const u=null!=(s=r.target)?s:document.createElement("div");if(u.closest(".bogos-select-option-custom-item")){const r=u.closest(".bogos-select-option-custom-item"),s=null!=(d=V.productsTemp[i][n])?d:{},b=a.getAttribute("data-variant-id"),{selectedVariant:p,newOptions:_}=N.handleValidVariantOption(r,b,s,e);if(t.querySelector(".bogos-bundles-button-add").disabled=!p,!p)return void N.handleInvalidVariantOption(s,_,e);a.setAttribute("data-variant-id",p.id.toString()),a.setAttribute("data-original-price",p.price.toString()),a.textContent=p.title;const g=l.products.find(t=>String(t.id)===n).variants.find(t=>String(p.id)===String(t.id)),m={id:p.id-0,price:(null==g?void 0:g.price)-0,title:p.title.trim(),thumbnail:null==g?void 0:g.thumbnail,discount_price:(null==g?void 0:g.discount_price)-0};c(m,o)}})),document.addEventListener("click",t=>{!e.contains(t.target)&&e.classList.contains("opened")&&e.classList.remove("opened")}),H.combobox.bind(e,H.COMBOBOX.classicVariant),H.radioGroup.init(e)}),t.querySelectorAll(".bogos-bundle-item-container").forEach(t=>{const e=t.querySelector(".bogos-bundle-item-select-button");e.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click())}),e.addEventListener("click",function(){this.setAttribute("aria-expanded","true"===this.getAttribute("aria-expanded")?"false":"true");const e=t.querySelector(".bogos-bundle-variants-collapse"),o=e.querySelector(".bogos-bundle-variants-container").scrollHeight;e.classList.toggle("bogos-bundle-active-dropdown-select"),e.style.maxHeight&&"0px"!==e.style.maxHeight?(e.style.maxHeight="0px",e.style.opacity="0",e.style.overflow="hidden"):(e.style.maxHeight=o+"px",e.style.opacity="1",e.style.overflow="unset")})}),t.querySelector(".bogos-bundles-button-add").addEventListener("click",function(){return h(this,null,function*(){var t;this.disabled=!0,this.classList.add("bogos-bundles-adding"),H.status.busy(this);const e=Object.values(a.reduce((t,e)=>{var o;const{id:n,quantity:i}=e;return t[n]={id:n,quantity:((null==(o=t[n])?void 0:o.quantity)||0)+i},t},{})),o=d.type,n=d.value<=0;o===B.DISCOUNT_TYPE.free_products&&d.value.forEach(t=>{var o;const n=null!=(o=FGSECOMAPP.productsByID[t.id])?o:{};return t.variants.forEach(t=>{var o;const i=null==(o=null==n?void 0:n.variants)?void 0:o.find(e=>e.id===t.id);i&&!(null==i?void 0:i.available)||e.push({id:t.id,quantity:t.quantity,is_free:!0})})});const l=(null==d?void 0:d.discount_function)===V.DISCOUNT_FUNCTION.shipping||!X.empty(null==r?void 0:r.shipping_discount),s=!((o===B.DISCOUNT_TYPE.fixed_amount||o===B.DISCOUNT_TYPE.percentage)&&n)||o===B.DISCOUNT_TYPE.free_products||l,{ok:c,message:u}=yield N.add(e,i,B.BUNDLE_TYPE.default,s);let b=null;if(c)this.disabled=!1;else{const e=document.createElement("div");e.classList.add("bogos-bundle-error"),e.textContent=u,null==(t=this.parentElement)||t.insertBefore(e,this),b=e.textContent}H.status.done(this,b),this.classList.remove("bogos-bundles-adding")})})})},init:(t,e)=>h(null,null,function*(){try{yield V.filter(e),V.render(t),V.renderEventQuery()}catch(o){console.warn("BOGOS track: bundle core init failed",o)}})},j={tiers:{},filter:()=>h(null,null,function*(){var t,e,o;try{const n=null==(t=FGSECOMAPP.bundles)?void 0:t.filter(t=>t.type===B.BUNDLE_TYPE.quantity_break),{current_product:i}=FGSECOMAPP.variables.Shopify;if(!X.empty(null==i?void 0:i.id)){const t=null==(e=null==i?void 0:i.variants)?void 0:e.map(t=>({variant_id:t.id,product_id:i.id,product_title:i.title,price:t.price,variant_title:t.title,handle:i.handle,vendor:i.vendor,product_type:i.type,collections:i.collections}));FGSECOMAPP.current_bundles_quantity_break=null==n?void 0:n.filter(e=>{var o;return(null==(o=X.findProductsMatchConditions(t,{product_narrow:e.products}))?void 0:o.length)>0})}FGSECOMAPP.current_bundles_quantity_break=null==(o=FGSECOMAPP.current_bundles_quantity_break)?void 0:o.filter(t=>{var e,o,n,i,l;const{discount:a}=t,r=JSON.parse(JSON.stringify(a.map(t=>(t.discount.type===B.DISCOUNT_TYPE.fixed_amount&&(t.discount.value=X.convertMultiCurrency(t.discount.value)),t)))),s=r.map(t=>t.quantity),d=m({},null==(e=FGSECOMAPP.variables.Shopify)?void 0:e.current_product);let c=d.variants.filter(t=>{var e;return(null==(e=d.variants_quantity)?void 0:e[t.id])>=Math.min(...s)||t.available}).map(t=>(t.quantity=d.variants_quantity[t.id],t));if((null==(n=null==(o=t.products)?void 0:o[0])?void 0:n.type)===B.NARROW_TYPE.product){const e=null==(i=t.products[0])?void 0:i.filter_option,o=P(Object.values(null==(l=t.products[0])?void 0:l.value).map(t=>{var e;return null!=(e=t.variants)?e:t.variant}),"flat")().map(t=>t.id);c=c.filter(t=>"include"===e?o.includes(t.id):!o.includes(t.id))}r.forEach(t=>{t.items_bundle=c.map(t=>{const e=t.price;return v(m({},t),{price:e?e/G:X.convertMultiCurrency(e)})})}),j.tiers[t.id]=r;const u=r.find(t=>t.pre_selected),b=null==u?void 0:u.items_bundle;return(null==b?void 0:b.length)?N.items_add_bundle[t.id]=Array(u.quantity).fill(X.convertVariantAddBundle(v(m({},u.items_bundle[0]),{discount:u.discount,quantity:1}))):N.items_add_bundle[t.id]=[],c.length>0})}catch(n){console.warn("BOGOS track: bundle quantity break filter",n)}}),refreshBundleAdd:(t,e,o)=>{const n=e.querySelectorAll(".bogos-bundle-quantity-break-variant-item-select"),i=t.length,l=n.length;t.splice(0,i),n.forEach(e=>{const n=e.value,i=e.querySelector('[value="'.concat(n,'"]'));if(!i)return;const a={id:n,thumbnail:i.getAttribute("thumbnail"),price:i.getAttribute("data-original-price")-0,title:i.textContent};1!==l?t.push(X.convertVariantAddBundle(a)):t.push(...Array(o).fill(X.convertVariantAddBundle(a)))})},renderQuantityBreakItem:(t,e,o)=>{var n,i,l,a,r,s,d,c,u,b,p,_;const g=null!=(s=null!=(r=null==(i=null==(n=FGSECOMAPP.fgAppearance)?void 0:n.quantity_break)?void 0:i.content)?r:null==(a=null==(l=FGSECOMAPP.fgAppearance)?void 0:l.volume_discount)?void 0:a.content)?s:{},{select_variant_text:m}=g,v=j.tiers[o].find(e=>e.id===t.id).items_bundle,h=1===(null==v?void 0:v.length),y=null!=(d=null==v?void 0:v[0])?d:{};return FGSECOMAPP.helper.templateHTML.render(e,{quantity_break_tier_id:"".concat(o,"_").concat(t.id),quantity_break_tier_title:X.safeMerchantHTML(J.convertIntegration(t.title,"quantity_break.".concat(o,".tiers.title_").concat(t.id),"quantity_break.".concat(o,".tiers.").concat(t.id,".title")),!0),quantity_break_tier_sub_title:X.safeMerchantHTML(J.convertIntegration(null!=(c=t.sub_title)?c:"","quantity_break.".concat(o,".tiers.sub_title_").concat(t.id),"quantity_break.".concat(o,".tiers.").concat(t.id,".sub_title")),!0),quantity_break_tier_label:X.safeMerchantHTML(J.convertIntegration(null!=(u=t.label)?u:"","quantity_break.".concat(o,".tiers.label_").concat(t.id),"quantity_break.".concat(o,".tiers.").concat(t.id,".label")),!0),quantity_break_tier_tag:X.safeMerchantHTML(J.convertIntegration(null!=(b=t.tag)?b:"","quantity_break.".concat(o,".tiers.tag_").concat(t.id),"quantity_break.".concat(o,".tiers.").concat(t.id,".tag")),!0),quantity_break_tier_original:0!==t.discount.value?X.renderPrice((null!=(p=null==y?void 0:y.price)?p:0)*t.quantity):"",quantity_break_select_variant:h?"":X.safeMerchantHTML(J.convertIntegration(null!=m?m:"Select variant","customize.quantity_break_select_variant","customize.quantity_break.select_variant_text"),!0),quantity_break_tier_discount:X.renderPrice(N.calculateDiscountPrice(t.discount,(null!=(_=null==y?void 0:y.price)?_:0)*t.quantity,"total")),bogos_bundle_quantity_break_section_variants:j.renderBundleOptions(null!=v?v:[],t.quantity)})},renderBundles:()=>{var t,e,o,n,i,l,a;const r=null!=(e=null==(t=document.querySelector("#sca_bundle_section_frame"))?void 0:t.innerHTML)?e:'
{{ bogos_quantity_break_block_title }}
{{ bogos_quantity_break_description }}
{{ bogos_quantity_break_section_items }}
',s=null!=(n=null==(o=document.querySelector("#sca_bundle_quantity_break_section_items"))?void 0:o.innerHTML)?n:'
{{ bogos_bundle_quantity_break_section_variants }}
',d=null!=(l=null==(i=document.querySelector("#sca_bundle_quantity_break_section_footer"))?void 0:i.innerHTML)?l:'
{{ quantity_break_total_price_text }}
{{ quantity_break_total_price_discount }}
{{ quantity_break_total_price_origin }}
';return null==(a=FGSECOMAPP.current_bundles_quantity_break)?void 0:a.map(t=>{var e,o,n,i,l,a,c,u,b,p;const _=null!=(n=null==(e=FGSECOMAPP.fgAppearance)?void 0:e.volume_discount)?n:null==(o=FGSECOMAPP.fgAppearance)?void 0:o.quantity_break,{button_text:g,total_price_text:m}=null!=(i=null==_?void 0:_.content)?i:{},v=null==(u=null!=(c=null==(l=null==_?void 0:_.default)?void 0:l.show_description)?c:null==(a=null==_?void 0:_.content)?void 0:a.show_description)||u,h=null==(b=t.discount)?void 0:b.map(e=>j.renderQuantityBreakItem(e,s,t.id)).join(" \n"),y=FGSECOMAPP.helper.templateHTML.render(d,{quantity_break_total_price_text:X.safeMerchantHTML(J.convertIntegration(null!=m?m:"Total price","customize.quantity_break_total_price","customize.quantity_break.total_price_text",!0),!0)+":",quantity_break_total_price_discount:X.renderPrice(0),quantity_break_total_price_origin:X.renderPrice(0),quantity_break_add_button:X.safeMerchantHTML(J.convertIntegration(null!=g?g:"Add bundle to cart","customize.quantity_break_add_to_cart","customize.quantity_break.button_text"),!0),bundle:t});return FGSECOMAPP.helper.templateHTML.render(r,{bogos_bundle_id:t.id,bogos_quantity_break_block_title:X.safeMerchantHTML(J.convertIntegration(null!=(p=t.sub_title)?p:"","quantity_break.header_".concat(t.id),"quantity_break.".concat(t.id,".sub_title")),!0),bogos_quantity_break_description:v?X.safeMerchantHTML(J.convertIntegration(t.description,"quantity_break.quantity_break_description_".concat(t.id),"quantity_break.".concat(t.id,".description")),!0):"",bogos_quantity_break_section_items:h,bogos_quantity_break_footer:"".concat(y," ").concat(Z.BRAND_MARK_TEMPLATE("bogos-bundles-brand-mark")),bundle:t})}).join(" ")},renderBundleOptions:(t,e)=>{var o,n,i,l,a,r,s,d;const c=null!=(n=null==(o=document.querySelector("#sca_bundle_quantity_break_section_variant"))?void 0:o.innerHTML)?n:'
{{ bogos_bundle_quantity_break_option_index }}
',u=null!=(d=null!=(s=null==(l=null==(i=FGSECOMAPP.fgAppearance)?void 0:i.quantity_break)?void 0:l.content)?s:null==(r=null==(a=FGSECOMAPP.fgAppearance)?void 0:a.volume_discount)?void 0:r.content)?d:{},{item_index_text:b}=u,p=1===t.length?[e-1]:Array.from({length:e},(t,e)=>e),_=t.map(t=>FGSECOMAPP.helper.templateHTML.render('',{bundle_quantity_break_variant_id:t.id,bundle_quantity_break_variant_title:X.safeText(t.title),bundle_quantity_break_variant_original_price:t.price,variant:t})).join(" ");return p.map(t=>FGSECOMAPP.helper.templateHTML.render(c,{bogos_bundle_quantity_break_option_index:X.safeMerchantHTML(J.convertIntegration(null!=b?b:"Item","customize.bundle_item_index","customize.quantity_break.item_text",!0),!0)+" ".concat(t+1,":"),bogos_bundle_quantity_break_option_variants:_})).join(" ")},render:t=>{var e,o,n;const i=document.querySelector("#bogos-bundle-quantity-break-preview-mode"),l=!(null==(e=FGSECOMAPP.current_bundles_quantity_break)?void 0:e.length),{product_form_query:a}=null!=(o=FGSECOMAPP.QUERY_SELECTOR)?o:{};let r=document.querySelectorAll(null==(n=null==a?void 0:a.quantity_break)?void 0:n.join(","));if(l&&r.forEach(t=>t.innerHTML=""),i&&l)return void N.renderEmpty(i);if(l)return;console.info("BOGOS track: bundle quantity break core",t);const s=j.renderBundles();if(X.empty(r)){const t=[...null==a?void 0:a.integration,...null==a?void 0:a.default].filter(Boolean).join(",");r=document.querySelector(t);const e=document.createElement("div");e.id="bogos-bundle-quantity-break-view",e.innerHTML=s,null==r||r.appendChild(e)}else r.forEach(t=>{t.innerHTML=s});const{quantity_break:d,default:c}=B.BUNDLE_TYPE;X.empty(r)||w.sessionViews(FGSECOMAPP.current_bundles_quantity_break,d,c).then(),document.dispatchEvent(new CustomEvent(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_QTY_BREAK_RENDER,{detail:{bundles:FGSECOMAPP.current_bundles_quantity_break,addFunction:(t,e)=>N.add(t,e,d)}}))},applyStyleVars:()=>{var t,e,o,n,i,l;const a=null!=(t=FGSECOMAPP.fgAppearance)?t:{},r=null!=(o=null==(e=a.quantity_break)?void 0:e.color)?o:{};let s;Object.keys(r).length>0?(s=m({},r),X.empty(s.bundle_origin_price)&&(s.bundle_origin_price="#B5B5B5")):s=null!=(l=null==(i=null==(n=a.volume_discount)?void 0:n.default)?void 0:i.color)?l:{};const d={"--bogos-qb-bg":s.widget_background_color,"--bogos-qb-card-bg":s.item_card_background_color,"--bogos-qb-bundle-title":s.bundle_title,"--bogos-qb-bundle-description":s.bundle_description,"--bogos-qb-tier-title":s.tier_title,"--bogos-qb-tier-description":s.tier_description,"--bogos-qb-tier-price":s.tier_price,"--bogos-qb-bundle-price":s.bundle_price,"--bogos-qb-bundle-origin-price":s.bundle_origin_price,"--bogos-qb-label":s.label_color,"--bogos-qb-label-text":s.label_text_color,"--bogos-qb-tag":s.tag_color,"--bogos-qb-tag-text":s.tag_text_color,"--bogos-qb-btn-bg":s.button_background_color,"--bogos-qb-btn-text":s.button_text_color,"--bogos-qb-border":"clean"===s.theme_color?"1px solid #616161":null};document.querySelectorAll(".bogos-bundles-quantity-break-widget").forEach(t=>{Object.entries(d).forEach(([e,o])=>{X.empty(o)||t.style.setProperty(e,o)})})},renderEventQuery:()=>{var t,e,o,n,i,l,a,r;j.applyStyleVars();const s=null==(i=null==(n=null==(o=null==(e=null==(t=FGSECOMAPP.QUERY_SELECTOR)?void 0:t.product_form_query)?void 0:e.quantity_break)?void 0:o.filter(Boolean))?void 0:n.map(t=>"".concat(t," .bogos-bundles-quantity-break-widget")))?void 0:i.join(",");if(X.empty(s))return;const{button_text:d}=null!=(r=null==(a=null==(l=FGSECOMAPP.fgAppearance)?void 0:l.quantity_break)?void 0:a.content)?r:{};document.querySelectorAll(s).forEach(t=>{var e,o;const n=t.getAttribute("data-bundle-id"),i=null==(e=FGSECOMAPP.current_bundles_quantity_break)?void 0:e.find(t=>{var e;return(null==(e=t.id)?void 0:e.toString())===n});if(X.empty(n)||X.empty(i))return;const l=null==(o=N.items_add_bundle)?void 0:o[n],a=t.querySelectorAll(".bogos-quantity-break-tier-input"),r=[];a.forEach(t=>{r.push(t.getAttribute("id"))});const s=i.discount.find(t=>t.pre_selected);if(s){const e="".concat(n,"_").concat(s.id);t.querySelector("#bogos_quantity_tier_".concat(e)).checked=!0;const o=t.querySelector('[data-bogos-tier-id="'.concat(e,'"]')),l=o.querySelector(".bogos-bundle-quantity-break-item-discount-price").textContent,a=o.querySelector(".bogos-bundle-quantity-break-item-original-price").textContent;t.querySelector(".bogos-bundles-quantity-break-discount-price").innerHTML="".concat(l),t.querySelector(".bogos-bundles-quantity-break-origin-price").innerHTML="".concat(a);const r=X.safeMerchantHTML(J.convertIntegration(null!=d?d:"Add bundle to cart","customize.quantity_break_add_to_cart","customize.quantity_break.button_text",!0),!0),c=X.safeMerchantHTML(J.convertIntegration(s.label,"quantity_break.tiers.label_".concat(s.id),"quantity_break.".concat(i.id,".tiers.").concat(s.id,".label"),!0),!0);t.querySelector(".bogos-bundles-quantity-break-button-add").innerHTML="".concat(r," ").concat(s.label?"("+c+")":"")}r.forEach(e=>{const o=e.replace("bogos_quantity_tier_",""),a=i.discount.find(t=>"".concat(n,"_").concat(t.id)===o),r=t.querySelector('.bogos-bundle-quantity-break_item-container:has([data-bogos-tier-id="'.concat(o,'"])'));t.querySelector("#".concat(e)).addEventListener("click",()=>{const n=t.querySelector('[data-bogos-tier-id="'.concat(o,'"]')),s=n.querySelector(".bogos-bundle-quantity-break-item-discount-price").textContent,c=n.querySelector(".bogos-bundle-quantity-break-item-original-price").textContent;t.querySelector(".bogos-bundles-quantity-break-discount-price").innerHTML="".concat(s),t.querySelector(".bogos-bundles-quantity-break-origin-price").innerHTML="".concat(c),t.querySelector("#".concat(e)).focus(),t.querySelector("#".concat(e)).checked=!0;const u=X.safeMerchantHTML(J.convertIntegration(null!=d?d:"Add bundle to cart","customize.quantity_break_add_to_cart","customize.quantity_break.button_text",!0),!0),b=X.safeMerchantHTML(J.convertIntegration(a.label,"quantity_break.tiers.label_".concat(a.id),"quantity_break.".concat(i.id,".tiers.").concat(a.id,".label"),!0),!0);t.querySelector(".bogos-bundles-quantity-break-button-add").innerHTML="".concat(u," ").concat(a.label?"("+b+")":""),j.refreshBundleAdd(l,r,a.quantity),t.querySelector(".bogos-bundles-quantity-break-button-add").disabled=!1;const p=t.querySelector(".bogos-bundle-error");p&&p.parentNode.removeChild(p)}),r.querySelectorAll(".bogos-bundle-quantity-break-variant-item-select").forEach((o,n)=>{o.addEventListener("change",i=>{var s,d;let c={id:(null==(d=null!=(s=i.target)?s:{value:"0"})?void 0:d.value)-0};const u=o.querySelector('[value="'.concat(c.id,'"]'));if(c=v(m({},c),{price:u.getAttribute("data-original-price")-0,title:u.textContent,quantity:1}),a.quantity!==(null==l?void 0:l.length))j.refreshBundleAdd(l,r,a.quantity);else{const t=null==l?void 0:l[n];!X.empty(t)&&(l[n]=X.convertVariantAddBundle(m(m({},l[n]),c)))}const b=l.reduce((t,e)=>t+e.price,0),p=t.querySelector("#".concat(e)).checked,_=[{query:".bogos-bundles-quantity-break-discount-price",price:N.calculateDiscountPrice(a.discount,b,"total"),isTotal:!0},{query:".bogos-bundles-quantity-break-origin-price",price:b,isTotal:!0,disable:!a.discount.value},{query:'.bogos-bundle-quantity-break_item-container:has([value="'.concat(c.id,'"]) .bogos-bundle-quantity-break-item-discount-price'),price:N.calculateDiscountPrice(a.discount,b,"total")},{query:'.bogos-bundle-quantity-break_item-container:has([value="'.concat(c.id,'"]) .bogos-bundle-quantity-break-item-original-price'),price:b,disable:0===a.discount.value}];t.querySelector(".bogos-bundles-quantity-break-button-add").disabled=!1;const g=t.querySelector(".bogos-bundle-error");g&&g.parentNode.removeChild(g),_.forEach(e=>{e.disable||(e.isTotal&&p?t.querySelector(e.query)&&(t.querySelector(e.query).innerHTML=X.renderPrice(e.price)):r.querySelector(e.query)&&(r.querySelector(e.query).innerHTML=X.renderPrice(e.price)))})})})}),t.querySelectorAll(".bogos-bundle-quantity-break_item-container").forEach(t=>{t.querySelector(".bogos-bundle-quantity-break-item-select-button").addEventListener("click",function(){const e=t.querySelector(".bogos-bundle-quantity-break-variants-collapse"),o=e.querySelector(".bogos-bundle-quantity-break-variants-container").scrollHeight;e.classList.toggle("bogos-bundle-quantity-break-active-dropdown-select"),e.style.maxHeight&&"0px"!==e.style.maxHeight?e.style.maxHeight="0px":e.style.maxHeight=o+"px"})}),t.querySelector(".bogos-bundles-quantity-break-button-add").addEventListener("click",function(){return h(this,null,function*(){var t,e;this.disabled=!0,this.classList.add("bogos-bundles-adding");const o=Object.values(l.reduce((t,e)=>{var o;const{id:n,quantity:i}=e;return t[n]={id:n,quantity:((null==(o=t[n])?void 0:o.quantity)||0)+i},t},{}));if(o.length){const{ok:t,message:i}=yield N.add(o,n,B.BUNDLE_TYPE.quantity_break);if(t)this.disabled=!1;else{const t=document.createElement("div");t.classList.add("bogos-bundle-error"),t.textContent=i,null==(e=this.parentElement)||e.insertBefore(t,this)}}else{const e=document.createElement("div");e.classList.add("bogos-bundle-quantity-break-custom-error"),e.innerHTML="Please select one option",null==(t=this.parentElement)||t.insertBefore(e,this)}this.classList.remove("bogos-bundles-adding")})})})},init:(t,e)=>h(null,null,function*(){try{yield j.filter(e),j.render(t),j.renderEventQuery()}catch(o){console.warn("BOGOS track: bundle quantity break core init failed",o)}})},U={trackCollection:{},product_chosen:{},free_products:{},productsTemp:{},catalogs:{},carouselState:new WeakMap,modal:null,PAGE_SIZE:8,MODAL_BATCH:8,FILL_MAX_ROUNDS:5,DEFAULT_EXTRA_PAGES:2,CAROUSEL_SKELETONS:3,CAROUSEL_TRACK_PADDING:12,CAROUSEL_PRELOAD_PX:160,CAROUSEL_CLOSE_FALLBACK_MS:450,MODAL_PRELOAD_PX:320,SCROLL_DEBOUNCE_MS:80,MODAL_CHOSEN_DELAY_MS:650,MODAL_CLOSE_FALLBACK_MS:360,LAYOUT:{modal:"modal",expand:"expand"},DEFAULT_MODE:{auto:"auto",selected:"selected",empty:"empty"},MIX_TYPE:{diff:"diff_set",single:"single_set"},TIER_TYPE:{label:"label",progress:"progress",none:"none"},TOGGLE_QUERY:".bogos-mix-item-toggle, .bogos-mix-item-empty-button, .bogos-mix-item-title",ITEM_CLICK_IGNORE_QUERY:"a[href], input, select, textarea, label, .bogos-mix-item-select-variant-wrapper, .bogos-mix-match-quantity-container, .bogos-mix-item-remove",normalizeDefaultProduct:t=>{var e;const{auto:o,selected:n,empty:i}=U.DEFAULT_MODE,l=[o,n,i].includes(null==t?void 0:t.mode)?t.mode:o;if(l!==n)return{mode:l,product:null};const a=null==(e=null==t?void 0:t.product)?void 0:e.id,r=null==a?"":String(a).split("/").pop();return r?{mode:l,product:v(m({},t.product),{id:r})}:{mode:i,product:null}},normalizeDisplayOn:t=>{const e="products"===(null==t?void 0:t.scope);return{scope:e?"products":"all",products:e&&Array.isArray(null==t?void 0:t.products)?t.products:[]}},normalizeBundle:t=>{var e,o,n,i;const{layout:l,display_on:a}=null!=(e=null==t?void 0:t.extra_info)?e:{},r=null!=(i=null==(n=null==(o=null==t?void 0:t.products)?void 0:o.find(t=>(null==t?void 0:t.type)===B.NARROW_TYPE.config))?void 0:n.value)?i:{},s=Array.isArray(null==r?void 0:r.mix_items)?r.mix_items:[];return{layout:null!=l?l:U.LAYOUT.modal,display_on:U.normalizeDisplayOn(a),mix_items:s.map(t=>{const e=null==t?void 0:t.max_quantity,o=["number","string"].includes(typeof e)?Number(e):NaN;return{id:null==t?void 0:t.id,max_quantity:Number.isFinite(o)&&o>=1?Math.floor(o):null,default_product:U.normalizeDefaultProduct(null==t?void 0:t.default_product),product_ids:Array.isArray(null==t?void 0:t.product_ids)?t.product_ids.map(String):[]}})}},matchDisplayOn:(t,e)=>{var o,n,i,l,a,r,s;const d=U.normalizeDisplayOn(null==(o=null==t?void 0:t.extra_info)?void 0:o.display_on);if("products"===d.scope)return!X.empty(null==e?void 0:e.id)&&d.products.some(t=>{var o;return String(null!=(o=null==t?void 0:t.id)?o:t)===String(e.id)});const c=(null!=(l=null==(i=null==(n=null==t?void 0:t.products)?void 0:n.find(t=>t.type===B.NARROW_TYPE.product))?void 0:i.value)?l:[]).some(t=>t.id===(null==e?void 0:e.id)),u=(null!=(s=null==(r=null==(a=null==t?void 0:t.products)?void 0:a.find(t=>t.type===B.NARROW_TYPE.collection))?void 0:r.value)?s:[]).some(t=>{var o;return null==(o=null==e?void 0:e.collections)?void 0:o.some(e=>String(null==e?void 0:e.id)===String(null==t?void 0:t.collection_id))});return c||u},sortByProductIds:(t,e=[])=>{if((null==t?void 0:t.type)!==B.NARROW_TYPE.product||!e.length)return t;const o=new Map(e.map((t,e)=>[t,e])),n=t=>{var e;return null!=(e=o.get(String(null==t?void 0:t.id)))?e:o.size};return v(m({},t),{value:[...t.value].sort((t,e)=>n(t)-n(e))})},getItemSelected:(t,e)=>{var o;return null!=(o=(null==t?void 0:t.mix_type)===U.MIX_TYPE.single?null==t?void 0:t.selected:null==e?void 0:e.selected)?o:{}},isVariantAvailable:t=>{var e;return Boolean(null!=(e=null==t?void 0:t.available)?e:null==t?void 0:t.availableForSale)},firstAvailableVariant:t=>{var e,o;return null!=(o=(null!=(e=null==t?void 0:t.variants)?e:[]).find(U.isVariantAvailable))?o:null},resolveVariant:(t,e)=>{var o,n,i,l;return null!=(l=null!=(n=null==(o=null==t?void 0:t.variants)?void 0:o.find(t=>String(t.id)===String(e)))?n:U.firstAvailableVariant(t))?l:null==(i=null==t?void 0:t.variants)?void 0:i[0]},resolveDefaults:(t,e)=>{var o;const{lists:n={},nodes:i={}}=null!=e?e:{},{auto:l,selected:a}=U.DEFAULT_MODE,r=null!=(o=null==t?void 0:t.mix_items)?o:[],s=new Set,d={},c=(t,e)=>{const o=U.firstAvailableVariant(e);return!!o&&(s.add(String(e.id)),d[t.id]={product:e,variant_id:o.id},!0)};return r.forEach(e=>{var o,l,r,s;d[e.id]=null;const{mode:u,product:b}=e.default_product;if(u!==a)return;const p=U.getItemSelected(t,e);let _=null;if(p.type===B.NARROW_TYPE.collection){const t=i[b.id],e=(null!=(o=p.value)?o:[]).map(String);_=(null!=(l=null==t?void 0:t.collections)?l:[]).some(t=>{var o;return e.includes(String(null!=(o=null==t?void 0:t.id)?o:t))})?t:null}else _=null!=(s=(null!=(r=n[e.id])?r:[]).find(t=>String(null==t?void 0:t.id)===b.id))?s:null;_&&c(e,_)}),r.forEach(t=>{var e;t.default_product.mode===l&&(null!=(e=n[t.id])?e:[]).some(e=>!s.has(String(null==e?void 0:e.id))&&c(t,e))}),d},chosenKey:(t,e)=>"".concat(t,"_").concat(e),getDefaults:t=>{var e,o;if(t&&!t.defaults){const o=C(Object)((null!=(e=t.mix_items)?e:[]).map(e=>[e.id,U.getCatalog(t,e).products]));t.defaults=U.resolveDefaults(t,{lists:o})}return null!=(o=null==t?void 0:t.defaults)?o:{}},getItemState:(t,e)=>{var o,n;const i=U.chosenKey(null==t?void 0:t.id,null==e?void 0:e.id);return Object.prototype.hasOwnProperty.call(U.product_chosen,i)?null!=(o=U.product_chosen[i])?o:null:null!=(n=U.getDefaults(t)[null==e?void 0:e.id])?n:null},setItemState:(t,e,o)=>{U.product_chosen[U.chosenKey(t,e)]=null!=o?o:null},getCatalog:(t,e)=>{var o,n;const i=U.getItemSelected(t,e);if(i.type!==B.NARROW_TYPE.collection)return{products:null!=(o=i.value)?o:[],sources:[],hasMore:!1,loading:null};const l=null!=(n=i.value)?n:[],a="".concat(null==t?void 0:t.id,"_").concat(l.join(","));if(U.catalogs[a])return U.catalogs[a];const r={products:[],sources:[],hasMore:!1,loading:null},s=new Set;return l.forEach(t=>{var e,o,n,i;const l=U.trackCollection[t],a=!X.empty(null==l?void 0:l.data);a&&l.data.forEach(t=>{s.has(String(t.id))||(s.add(String(t.id)),r.products.push(t))}),r.sources.push({id:t,cursor:a&&null!=(o=null==(e=l.meta_data)?void 0:e.endCursor)?o:"",hasNext:!a||Boolean((null==(n=l.meta_data)?void 0:n.hasNextPage)&&(null==(i=l.meta_data)?void 0:i.endCursor))})}),r.hasMore=r.sources.some(t=>t.hasNext),U.catalogs[a]=r,r},loadMore:t=>(null==t?void 0:t.hasMore)?(t.loading||(t.loading=P(h(null,null,function*(){var e,o,n,i;const l=t.sources.find(t=>t.hasNext);if(!l)return!1;let a=null;try{a=yield k.queryProductsInCollection(l.id,U.PAGE_SIZE,l.cursor)}catch(d){a=null}l.cursor=null!=(o=null==(e=null==a?void 0:a.meta_data)?void 0:e.endCursor)?o:"",l.hasNext=Boolean(null==(n=null==a?void 0:a.meta_data)?void 0:n.hasNextPage)&&!X.empty(l.cursor);const r=new Set(t.products.map(t=>String(t.id))),s=(null!=(i=null==a?void 0:a.data)?i:[]).filter(t=>!r.has(String(t.id)));return t.products.push(...s),s.length&&J.syncStarRating(s.map(t=>t.id)).catch(t=>console.warn("BOGOS track: mix match star rating",t)),s.length>0}).catch(()=>!1),"finally")(()=>{t.hasMore=t.sources.some(t=>t.hasNext),t.loading=null})),t.loading):Promise.resolve(!1),fillCatalog:(t,e)=>h(null,null,function*(){for(let o=0;oh(null,null,function*(){var e,o;const n=[...new Set((null!=(e=null==t?void 0:t.mix_items)?e:[]).filter(e=>U.getItemSelected(t,e).type===B.NARROW_TYPE.collection).map(t=>t.default_product).filter(({mode:t})=>t===U.DEFAULT_MODE.selected).map(({product:t})=>t.id))];if(!n.length||"function"!=typeof(null==k?void 0:k.queryProductsNode))return{};try{const t=null!=(o=yield k.queryProductsNode(n))?o:[];return C(Object)(t.map(t=>v(m({},t),{variants:t.variants.filter(U.isVariantAvailable)})).filter(t=>t.variants.length).map(t=>[String(t.id),t]))}catch(i){return console.warn("BOGOS track: mix match default products",i),{}}}),loadDefaults:t=>h(null,null,function*(){var e;const o=null!=(e=null==t?void 0:t.mix_items)?e:[],n={},i={};o.forEach(e=>{n[e.id]=U.getCatalog(t,e),i[e.id]=n[e.id].products});const l=yield U.queryDefaultNodes(t);let a=U.resolveDefaults(t,{lists:i,nodes:l});for(let r=0;r!a[t.id]&&t.default_product.mode===U.DEFAULT_MODE.auto).map(t=>n[t.id]).filter(t=>t.hasMore))];if(!e.length)break;(yield Promise.all(e.map(t=>U.loadMore(t)))).some(Boolean)&&(a=U.resolveDefaults(t,{lists:i,nodes:l}))}return t.defaults=a,a}),getWidgetBundle:t=>{var e;const o=null==t?void 0:t.getAttribute("data-mix-match-id");return null==(e=FGSECOMAPP.current_bundles_mix_match)?void 0:e.find(t=>String(t.id)===String(o))},getItemContext:(t,e)=>{var o,n;const i=U.getWidgetBundle(t),l=null==e?void 0:e.getAttribute("data-mix-id"),a=null!=(n=null==(o=null==i?void 0:i.mix_items)?void 0:o.findIndex(t=>String(t.id)===String(l)))?n:-1;return{bundle:i,mixItem:a>=0?i.mix_items[a]:null,index:a}},getQuantityBounds:t=>{var e;const o=null!=(e=null==t?void 0:t.max_quantity)?e:null,n=Math.max(1,parseInt(null==t?void 0:t.min_quantity)||1);return{lower:o?Math.min(n,o):n,max:o}},toggleClass:(t,e,o)=>{t&&t.classList.contains(e)!==o&&t.classList.toggle(e,o)},setDisabled:(t,e)=>{const o=e?"true":"false";t&&t.getAttribute("aria-disabled")!==o&&t.setAttribute("aria-disabled",o)},setExpanded:(t,e)=>{null==t||t.querySelectorAll(U.TOGGLE_QUERY).forEach(t=>{t.hasAttribute("aria-expanded")&&t.setAttribute("aria-expanded",e?"true":"false")})},appearanceOf:t=>{var e,o;return R.resolve(t,"mix_match",null!=(o=null==(e=FGSECOMAPP.fgAppearance)?void 0:e.mix_match)?o:{},N.widgetStyle)},renderMixLabel:(t,e)=>FGSECOMAPP.helper.templateHTML.render(R.text(e,"mix_item_header","Mix item {{itemIndex}}","customize.mix_match_item_header","customize.mix_match.mix_item_header"),{itemIndex:t+1}),renderChooseText:t=>R.text(t,"choose_button_text","Choose","customize.mix_match_choose_button_text","customize.mix_match.choose_button_text"),renderMinQuantityText:(t,e,o)=>FGSECOMAPP.helper.templateHTML.render(R.text(o,"min_quantity_text","Add at least {{quantity}} item(s) to {{mixItem}}","customize.mix_match_min_quantity_text","customize.mix_match.min_quantity_text"),{quantity:t,mixItem:e}),renderSkeletons:(t,e)=>{const o=e?'':"";return Array.from({length:t},()=>FGSECOMAPP.helper.templateHTML.render('',{bogos_mix_match_skeleton_extra:o})).join("")},getItemTemplates:()=>{var t,e,o,n,i,l;return{filled:null!=(e=null==(t=document.querySelector("#bogos_mix_match_item_filled"))?void 0:t.innerHTML)?e:'
{{ bogos_integration_judgeme }} {{ bogos_integration_trustoo }} {{ bogos_integration_yotpo }}
{{ bogos_variant_title }}
{{ bogos_mix_item_select_variant_section }}
{{ bogos_mix_item_out_of_stock }}
{{ bogos_mix_item_toggle }}
{{ bogos_mix_item_price }}
',empty:null!=(n=null==(o=document.querySelector("#bogos_mix_match_item_empty"))?void 0:o.innerHTML)?n:'
',toggle:null!=(l=null==(i=document.querySelector("#bogos_mix_match_item_toggle"))?void 0:i.innerHTML)?l:''}},filterWithBlocks:t=>{var e,o,n,i;let l={};const a=t?FGSECOMAPP.current_bundles_mix_match:null==(e=FGSECOMAPP.bundles)?void 0:e.filter(t=>t.type===B.BUNDLE_TYPE.mix_match),{current_product:r}=null!=(o=FGSECOMAPP.variables.Shopify)?o:{},s=X.empty(null==r?void 0:r.id)?[]:null==a?void 0:a.filter(t=>U.matchDisplayOn(t,r)),{product_form_query:d}=null!=(n=FGSECOMAPP.QUERY_SELECTOR)?n:{};let c=t?[t]:document.querySelectorAll(null==(i=null==d?void 0:d.mix_match)?void 0:i.join(","));return c.forEach(e=>{var o,n;const i=Number(X.getIntShopifyId(e.getAttribute("data-product-id"))),r=Number(e.getAttribute("data-offer-id"));let d=null;r&&(d=null==(o=null!=d?d:a)?void 0:o.filter(t=>t.id.toString()===r.toString())),i&&(d=null==(n=null!=d?d:a)?void 0:n.filter(t=>{var e,o,n,l,a;return U.matchDisplayOn(t,null!=(a=null!=(l=null==(o=null==(e=window.BOGOS)?void 0:e.block_products)?void 0:o[i])?l:null==(n=FGSECOMAPP.productsByID)?void 0:n[i])?a:{id:i})})),null==d||d.forEach(e=>l[e.id]=v(m({},e),{current_product:t?i:void 0})),r||i||s.forEach(t=>l[t.id]=t)}),c.length||s.forEach(t=>l[t.id]=t),Object.values(l)},filter:t=>h(null,null,function*(){var e,o,n;try{yield null==(e=null==J?void 0:J.searchProductsBlock)?void 0:e.call(J,"mix_match");const l=U.PAGE_SIZE;FGSECOMAPP.current_bundles_mix_match=U.filterWithBlocks();const a=[],r=[],s={handles:[...null!=(n=null==(o=FGSECOMAPP.current_bundles_mix_match)?void 0:o.reduce((t,e)=>{var o,n;const i=null!=(n=null==(o=e.products.find(t=>t.type===B.NARROW_TYPE.product))?void 0:o.value)?n:[];t=[...t,...i.map(t=>(a.push(t.id),t.handle))];const l=e.discount.filter(t=>t.discount.type===B.DISCOUNT_TYPE.free_products);return l.length&&l.forEach(t=>{const e=t.discount.value.map(t=>t.handle);a.push(...t.discount.value.map(t=>t.id)),r.push(...e)}),[...new Set(t)]},[]))?n:[],...new Set(r)],ids:a};if(!t&&(yield O.cacheProducts(null==s?void 0:s.handles,{"sca-mix-match-search":"1"},()=>{console.info("BOGOS track: mix-match:sync-quantity:".concat(Date.now()))},s)),X.empty(FGSECOMAPP.current_bundles_mix_match))return;FGSECOMAPP.current_bundles_mix_match=FGSECOMAPP.current_bundles_mix_match.map(t=>U.convertDataMixMatch(t)),U.getCollectionsInCache();const d=(t,e)=>h(null,null,function*(){let o,n=!1;for(let i=0;it.id)),n=!0;break}}return{isHasData:n,collectionIdNeedUpdateCache:o}}),c=[],u=[];for(const t of FGSECOMAPP.current_bundles_mix_match){if(t.mix_type===U.MIX_TYPE.single&&t.selected.type===B.NARROW_TYPE.collection){const{isHasData:e,collectionIdNeedUpdateCache:o}=yield d(t.selected.value,l);X.empty(o)||c.push(o),e||u.push(t.id);continue}if(t.mix_type===U.MIX_TYPE.diff)for(const e of t.mix_items){const{selected:o}=e;if(o.type!==B.NARROW_TYPE.collection)continue;const{isHasData:n,collectionIdNeedUpdateCache:i}=yield d(o.value,l);if(X.empty(i)||c.push(i),!n){u.push(t.id);break}}}u.length&&(FGSECOMAPP.current_bundles_mix_match=FGSECOMAPP.current_bundles_mix_match.filter(t=>!u.includes(t.id))),yield Promise.all(FGSECOMAPP.current_bundles_mix_match.map(t=>U.loadDefaults(t).then(t=>Object.values(null!=t?t:{}).forEach(t=>(null==t?void 0:t.product)&&a.push(t.product.id))).catch(t=>console.warn("BOGOS track: mix match defaults",t)))),U.cacheCollections(c,l).then();try{J.syncStarRating([...new Set(a)]).then()}catch(i){}}catch(i){console.warn("BOGOS track: mix match filter",i)}}),cacheCollections:(t,e)=>h(null,null,function*(){var o;if(X.empty(U.trackCollection))return;let n={data:{},time:0};try{n=X.convertStringToObj(localStorage.getItem("bogos_collections_info"))}catch(l){}const i=[...new Set(t)];for(const t of i){const o=yield k.queryProductsInCollection(t,e);X.empty(o.data)||(n.data[t]=o)}localStorage.setItem("bogos_collections_info",X.convertObjToString({data:m(m({},null!=(o=U.trackCollection)?o:{}),n.data),time:Date.now()})),console.info("BOGOS track: mix-match:cache collection: ".concat(Date.now()))}),getCollectionsInCache:()=>{let t={data:{},time:0};try{t=X.convertStringToObj(localStorage.getItem("bogos_collections_info"))}catch(e){}Date.now()-t.time<3e5&&(U.trackCollection=t.data)},renderProductOptions:(t,e,o)=>{var n,i,l,a;const{available:r,bundleId:s}=null!=o?o:{},d=N.convertProductWithOptions(t),c=null==(n=FGSECOMAPP.productsByID)?void 0:n[d.id],{type:u="variant"}=null!=(l=null==(i=FGSECOMAPP.fgAppearance)?void 0:i.select_variant)?l:{};if("variant"===u){const t='
\n {{ bundle_variant_title }}\n
';return d.variants.map(o=>{var n,i,l,a,s,u,b,p;return FGSECOMAPP.helper.templateHTML.render(t,{bundle_variant_img:X.safeText(null!=(i=X.handleResizeGiftImage(null!=(n=o.thumbnail)?n:e,!0))?i:""),bundle_variant_id:o.id,bundle_variant_original_price:o.price,bundle_variant_title:X.safeText(null!=(l=o.title)?l:""),bogos_variant_available:null!=r?r:(null!=(p=null==(s=null==(a=null==d?void 0:d.variants)?void 0:a.find(t=>t.id===o.id))?void 0:s.availableForSale)?p:null==(b=null==(u=null==c?void 0:c.variants)?void 0:u.find(t=>t.id===o.id))?void 0:b.available)?1:0,bogos_sv_style:K(!0)})}).join("")}return U.productsTemp[s]=m({},null!=(a=U.productsTemp[s])?a:{}),U.productsTemp[s][d.id]=d,k.queryProductDefault(d.id).then(),'
'},renderTextChooseProduct:(t,e,o)=>FGSECOMAPP.helper.templateHTML.render(X.safeMerchantHTML(t?R.text(o,"select_product_text","Choose from {{number}} product(s)","customize.mix_match_select_product_text","customize.mix_match.select_product_text"):R.text(o,"select_collection_text","Choose from {{number}} collection(s)","customize.mix_match_select_collection_text","customize.mix_match.select_collection_text"),!0),{number:e.length}),renderMixItem:(t,e,o,n)=>{var i,l,a,r,s,d,c,u,b;const{templates:p,bundleKey:_,state:g}=null!=n?n:{},h=U.appearanceOf(t),y=U.getItemSelected(t,e),f=null!=(i=null==n?void 0:n.uid)?i:"".concat(++H.seq),x="bogos-mix-match-carousel-".concat(f),S=U.renderMixLabel(o,h),E=X.attrText(S),A=(null==t?void 0:t.layout)===U.LAYOUT.expand,q={bogos_mix_item_uid:f,bogos_mix_item_label:E,bogos_mix_id:e.id,bogos_mix_key:_,bogos_mix_item_open_a11y:A?'aria-expanded="false" aria-controls="'.concat(x,'"'):'aria-haspopup="dialog"'},P=null==g?void 0:g.product,M=U.resolveVariant(P,null==g?void 0:g.variant_id);if(!P||!M)return FGSECOMAPP.helper.templateHTML.render(p.empty,v(m({},q),{bogos_mix_item_header_title:X.safeMerchantHTML(S,!0),bogos_mix_item_choose_product_btn:U.renderTextChooseProduct(y.type===B.NARROW_TYPE.product,null!=(l=y.value)?l:[],h)}));const C=P.variants.length>1,{lower:O,max:T}=U.getQuantityBounds(e);return FGSECOMAPP.helper.templateHTML.render(p.filled,v(m({},q),{bogos_mix_item_img:X.safeText(null!=(s=X.handleResizeGiftImage(null!=(r=null!=(a=M.thumbnail)?a:P.thumbnail)?r:"",!0))?s:""),bogos_mix_item_title:X.safeText(null!=(d=P.title)?d:""),bogos_mix_item_remove_label:X.attrText("Remove ".concat(P.title)),bogos_mix_item_select_variant_section:C?U.renderProductOptions(P,P.thumbnail,{bundleId:U.chosenKey(t.id,e.id)}):"",bogos_variant_title:X.safeText(null!=(c=M.title)?c:""),check_show_mix_item_select:C?"":"sca-d-none",bogos_mix_item_price:X.renderPrice(Number(null!=(u=M.price)?u:0)),bogos_mix_item_price_value:null!=(b=M.price)?b:0,bogos_mix_min_quantity:O,bogos_mix_item_max:null!=T?T:"",bogos_mix_item_variant_id:M.id,bogos_mix_item_variant_quantity:O,bogos_product_id:P.id,bogos_mix_item_available:U.isVariantAvailable(M)?1:0,bogos_mix_item_out_of_stock:X.safeMerchantHTML(R.text(h,"out_stock_text","Out of stock!","customize.mix_match_out_stock_text","customize.mix_match.out_stock_text"),!0),bogos_mix_item_toggle:A?FGSECOMAPP.helper.templateHTML.render(p.toggle,{bogos_mix_match_carousel_id:x,bogos_mix_item_label:E}):"",bogos_integration_judgeme:N.renderAppReviewEl(P.id),bogos_integration_trustoo:N.renderAppReviewEl(P.id,B.APP_REVIEW.trustoo),bogos_integration_yotpo:N.renderAppReviewEl(P.id,B.APP_REVIEW.yotpo)}))},renderBundles:t=>{var e,o,n,i,l,a,r,s,d;const c=null!=(o=null==(e=document.querySelector("#bogos_mix_match_section_frame"))?void 0:e.innerHTML)?o:'
{{ bogos_mix_match_title }}
{{ bogos_mix_match_description }}
{{ bogos_mix_match_labels }}
{{ bogos_mix_match_items }}
',u=null!=(i=null==(n=document.querySelector("#bogos_mix_match_section_footer"))?void 0:n.innerHTML)?i:'
{{ bogos_mix_match_total_price_text }}
{{ bogos_mix_match_discount_price }} {{ bogos_mix_match_original_price }}
',b=null!=(a=null==(l=document.querySelector("#bogos_mix_match_section_badge_item"))?void 0:l.innerHTML)?a:'
{{ bogos_label_mix_match }}
',p=null!=(s=null==(r=document.querySelector("#bogos_mix_match_section_progress_item"))?void 0:r.innerHTML)?s:'
{{ bogos_label_mix_match }}
',_=U.getItemTemplates();return null==(d=null!=t?t:FGSECOMAPP.current_bundles_mix_match)?void 0:d.map(t=>{var e;const o="".concat(t.id,".").concat(Math.random().toString(36).substring(8)),n=U.appearanceOf(t),{show_description:i,tier_style:l}=n.content,a=l===U.TIER_TYPE.progress,r=l===U.TIER_TYPE.none,s=(null!=(e=t.mix_items)?e:[]).map((e,n)=>U.renderMixItem(t,e,n,{templates:_,bundleKey:o,state:U.getItemState(t,e)})).join(" "),d=a?[...t.discount].sort((t,e)=>t.quantity-e.quantity):t.discount,g=r?"":d.map(e=>FGSECOMAPP.helper.templateHTML.render(a?p:b,{bogos_label_mix_match:X.safeMerchantHTML(J.convertIntegration(e.label,"mix_match.".concat(t.id,".tiers.label_").concat(e.id),"mix_match.".concat(t.id,".tiers.").concat(e.id,".label")),!0),bogos_mix_match_discount_id:e.id})).join(" "),m=FGSECOMAPP.helper.templateHTML.render(u,{bogos_mix_match_total_price_text:X.safeMerchantHTML(R.text(n,"total_price_text","Total bundle price","customize.mix_match_total_price","customize.mix_match.total_price_text",!0),!0)+":",bogos_mix_match_discount_price:0,bogos_mix_match_original_price:0,bogos_mix_match_add_button:X.safeMerchantHTML(R.text(n,"button_text","Add bundle to cart","customize.mix_match_add_to_cart","customize.mix_match.button_text"),!0),bundle:t});return FGSECOMAPP.helper.templateHTML.render(c,{bogos_mix_match_id:t.id,bogos_mix_match_key:o,bogos_mix_match_title:X.safeMerchantHTML(J.convertIntegration(t.sub_title,"mix_match.header_".concat(t.id),"mix_match.".concat(t.id,".sub_title")),!0),bogos_mix_match_description:null==i||i?X.safeMerchantHTML(J.convertIntegration(t.description,"mix_match.mix_match_description_".concat(t.id),"mix_match.".concat(t.id,".description")),!0):"",bogos_mix_match_items:s,bogos_mix_match_footer:"".concat(m," ").concat(Z.BRAND_MARK_TEMPLATE("bogos-mix-match-brand-mark")),bogos_labels_container_class:r?"sca-d-none":a?"bogos-mix-match-progress-container":"bogos-mix-match-badges-container",bogos_mix_match_labels:g,bogos_check_show_line_progress:a?"":"sca-d-none",bundle:t})}).join(" ")},render:t=>{var e,o,n,i,l,a,r,s,d,c,u,b;const{product_form_query:p}=null!=(e=FGSECOMAPP.QUERY_SELECTOR)?e:{};let _=document.querySelectorAll(null==(o=null==p?void 0:p.mix_match)?void 0:o.join(","));const g=!(null==(n=FGSECOMAPP.current_bundles_mix_match)?void 0:n.length);let m=[];if(g||console.info("BOGOS track: mix-n-match core",t),_.forEach(t=>{const e=U.filterWithBlocks(t),o=!e.length,n=t.querySelector("#bogos-mix-match-preview-mode");n&&o?N.renderEmpty(n):o||(t.innerHTML=U.renderBundles(e),m.push(...e))}),!0===(null==(l=null==(i=FGSECOMAPP.variables)?void 0:i.Shopify)?void 0:l.reserve_widget_height)&&document.dispatchEvent(new CustomEvent("bogos:reserved-widget-pass",{detail:{id:"bogos-mix-match-view"}})),g)return;if(!_.length){const t=U.renderBundles(),e=[...null==p?void 0:p.integration,...null==p?void 0:p.default].filter(Boolean).join(",");_=document.querySelector(e);const o=document.createElement("div");o.id="bogos-mix-match-view",o.innerHTML=t,null==(r=null!=(a=null==_?void 0:_.querySelector(":scope > .group-block-content"))?a:_)||r.appendChild(o),m.push(...FGSECOMAPP.current_bundles_mix_match)}const{mix_match:v,default:h}=B.BUNDLE_TYPE;X.empty(m)||(m=Object.values(Object.assign({},...m.map(t=>({[t.id]:t})))),w.sessionViews(m,v,h).then());const y=null==(b=null==(u=null==(c=null==(d=null==(s=FGSECOMAPP.QUERY_SELECTOR)?void 0:s.product_form_query)?void 0:d.mix_match)?void 0:c.filter(Boolean))?void 0:u.map(t=>"".concat(t," .bogos-mix-match-widget")))?void 0:b.join(",");X.empty(y)||(document.querySelectorAll(y).forEach(t=>{U.refreshStatesBundle(t)}),document.dispatchEvent(new CustomEvent(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_MIX_MATCH_RENDER,{detail:{bundles:m,addFunction:(t,e)=>N.add(t,e,v)}})))},styleVarsOf:t=>{const e=U.appearanceOf(t).color;return{"--bogos-mix-bg":e.widget_background_color,"--bogos-mix-border":"clean"===e.theme_color?"1px solid #616161":null,"--bogos-mix-card-bg":e.item_card_background_color,"--bogos-mix-title":e.title_text_color,"--bogos-mix-description":e.description_text_color,"--bogos-mix-item-name":e.item_name_color,"--bogos-mix-price":e.bundle_price_color,"--bogos-mix-compare":e.original_price_color,"--bogos-mix-btn-bg":e.button_background_color,"--bogos-mix-btn-text":e.button_text_color,"--bogos-mix-badge-bg":e.default_label_background_color,"--bogos-mix-badge-text":e.default_label_text_color,"--bogos-mix-badge-bg-success":e.success_label_background_color,"--bogos-mix-badge-text-success":e.success_label_text_color,"--bogos-mix-ship-bg":e.shipping_discount_background,"--bogos-mix-ship-text":e.shipping_discount_text_color}},bundleOfWidget:t=>{var e;return null==(e=FGSECOMAPP.current_bundles_mix_match)?void 0:e.find(e=>String(e.id)===t.getAttribute("data-mix-match-id"))},applyStyleVars:()=>{var t;document.querySelectorAll(".bogos-mix-match-widget").forEach(t=>{R.setVars(t,U.styleVarsOf(U.bundleOfWidget(t)))});const e=U.getModalHost();e&&R.setVars(e,U.styleVarsOf(null==(t=U.modal)?void 0:t.bundle))},renderEventQuery:()=>{var t,e,o,n,i;U.applyStyleVars();const l=null==(i=null==(n=null==(o=null==(e=null==(t=FGSECOMAPP.QUERY_SELECTOR)?void 0:t.product_form_query)?void 0:e.mix_match)?void 0:o.filter(Boolean))?void 0:n.map(t=>"".concat(t," .bogos-mix-match-widget")))?void 0:i.join(",");X.empty(l)||document.querySelectorAll(l).forEach(t=>{if("1"===t.dataset.bogosMixMatchBound)return;t.dataset.bogosMixMatchBound="1";const e=t.getAttribute("data-mix-match-id");t.addEventListener("click",e=>U.onWidgetClick(e,t)),t.addEventListener("change",e=>{var o,n;const i=null==(n=null==(o=e.target)?void 0:o.closest)?void 0:n.call(o,".bogos-mix-match-quantity-input");i&&U.setQuantity(t,i.closest(".bogos-mix-item-container"),parseInt(i.value))}),H.mix.init(t),t.querySelector(".bogos-mix-match-button-add").addEventListener("click",function(){return h(this,null,function*(){var o;this.disabled=!0,this.classList.add("bogos-bundles-adding"),H.status.busy(this);const n=[];t.querySelectorAll(".bogos-mix-item-container").forEach(t=>{"1"===t.getAttribute("data-check-item")&&n.push({id:parseInt(t.getAttribute("data-variant-id")),quantity:parseInt(t.getAttribute("data-quantity-variant")),bogos_mix_id:parseInt(t.getAttribute("data-mix-id"))})});const i=U.free_products["offer_".concat(e)];X.empty(i)||i.forEach(t=>{const e=FGSECOMAPP.productsByID[t.id];t.variants.forEach(t=>{var o;const i=e.variants.find(e=>e.id===t.id);i&&!(null==i?void 0:i.available)||n.push({id:parseInt(t.id),quantity:parseInt(null!=(o=t.quantity)?o:"1"),bogos_mix_id:null})})});const l=t.querySelector(".bogos-mix-match-total-original-price"),a=t.querySelector(".bogos-mix-match-shipping-discount-container"),r=!X.empty(null==l?void 0:l.innerHTML)||!X.empty(null==a?void 0:a.innerHTML),{ok:s,message:d}=yield N.add(n,e,B.BUNDLE_TYPE.mix_match,r);let c=null;if(s)this.disabled=!1;else{const t=document.createElement("div");t.classList.add("bogos-bundle-error"),t.textContent=d,null==(o=this.parentElement)||o.insertBefore(t,this),c=t.textContent}H.status.done(this,c),this.classList.remove("bogos-bundles-adding")})})})},onWidgetClick:(t,e)=>{var o,n;const i=(null==(o=t.target)?void 0:o.closest)?t.target:null;if(!i)return;if(U.handleVariantClick(i,e,U.getItemVariantContext(e)))return;const l=i.closest(".bogos-mix-item-container");if(!l||!e.contains(l))return;if(i.closest(".bogos-mix-match-carousel-closing"))return;const a=i.closest(".bogos-mix-match-carousel .bogos-mix-match-card");if(a)return void U.selectCarouselCard(e,l,a);const r=i.closest(".bogos-mix-match-carousel-nav");if(r){if("true"===r.getAttribute("aria-disabled"))return;return void U.scrollCarousel(l,r.classList.contains("bogos-mix-match-carousel-prev")?-1:1)}if(i.closest(".bogos-mix-item-remove"))return void U.removeItem(e,l);const s=i.closest(".bogos-minus-mix-btn, .bogos-plus-mix-btn");if(s){if(s.disabled)return;const t=parseInt(null==(n=l.querySelector(".bogos-mix-match-quantity-input"))?void 0:n.value),o=s.classList.contains("bogos-plus-mix-btn")?1:-1;return void U.setQuantity(e,l,(isNaN(t)?0:t)+o)}i.closest(".bogos-mix-item-toggle")?U.toggleCarousel(e,l):(i.closest(".bogos-mix-item-empty-button")||i.closest(".bogos-mix-item")&&!i.closest(U.ITEM_CLICK_IGNORE_QUERY))&&U.openItem(e,l)},getItemVariantContext:t=>({holderSelector:".bogos-mix-item-container",tempKey:e=>U.chosenKey(t.getAttribute("data-mix-match-id"),e.getAttribute("data-mix-id")),apply:(e,o)=>U.applyItemVariant(t,e,o),invalid:e=>{e.setAttribute("data-mix-available","0"),U.refreshStatesBundle(t)}}),handleVariantClick:(t,e,o)=>{var n,i,l,a,r,s,d;const c=t.closest(".bogos-mix-item-select-variant-dropdown");if(e.querySelectorAll(".bogos-mix-item-select-variant-dropdown.opened").forEach(t=>t!==c&&t.classList.remove("opened")),!c||!e.contains(c))return!1;const u=c.closest(o.holderSelector);if(!u)return!0;const b=t.closest(".bogos-mix-item-select-variant-option");if(b)return c.classList.remove("opened"),o.apply(u,{id:b.getAttribute("data-variant-id"),title:b.textContent.trim(),price:b.getAttribute("data-original-price"),img:b.getAttribute("data-img"),available:"1"===b.getAttribute("data-option-available")}),!0;const p=t.closest(".bogos-select-option-custom-item");if(p){const t=null==(n=U.productsTemp[o.tempKey(u)])?void 0:n[u.getAttribute("data-product-id")];if(!t)return!0;const e=null==(i=u.querySelector(".bogos-mix-item-select-variant-title"))?void 0:i.getAttribute("data-variant-id"),{selectedVariant:c,newOptions:b}=N.handleValidVariantOption(p,e,t,u);return c?(o.apply(u,{id:String(c.id),title:c.title,price:c.price,img:null!=(d=null!=(s=null!=(r=null==(a=null==c?void 0:c.featured_image)?void 0:a.src)?r:null==c?void 0:c.thumbnail)?s:null==t?void 0:t.featured_image)?d:null==t?void 0:t.thumbnail,available:U.isVariantAvailable(c)}),!0):(N.handleInvalidVariantOption(t,b,u),null==(l=o.invalid)||l.call(o,u),!0)}return t.closest(".bogos-mix-item-select-variant-options")||(c.classList.toggle("opened"),c.classList.contains("opened")&&U.loadVariantSwatches(c,u,o.tempKey(u)).then()),!0},loadVariantSwatches:(t,e,o)=>h(null,null,function*(){var n,i,l,a,r;const{type:s="variant"}=null!=(i=null==(n=FGSECOMAPP.fgAppearance)?void 0:n.select_variant)?i:{};if("option"!==s||t.querySelector(".bogos-select-option-name-container"))return;const d=e.getAttribute("data-product-id");if(!(null==(l=FGSECOMAPP.productsDefaultByID)?void 0:l[d])){const t=yield k.queryProductDefault(d);if(X.empty(t))return}const c=null==(a=U.productsTemp[o])?void 0:a[d],u=t.querySelector(".bogos-mix-item-select-variant-options");if(!c||!u)return;const b=null==(r=t.querySelector(".bogos-mix-item-select-variant-title"))?void 0:r.getAttribute("data-variant-id"),p=N.convertProductWithOptionsDefault(FGSECOMAPP.productsDefaultByID[d],c);u.innerHTML=N.renderProductOptionWithValue(p,b)}),applyItemVariant:(t,e,o)=>{var n;const{bundle:i,mixItem:l}=U.getItemContext(t,e),a=i&&l?U.getItemState(i,l):null,r=e.querySelector(".bogos-mix-item-img");r&&o.img&&r.setAttribute("src",X.handleResizeGiftImage(o.img,!0));const s=e.querySelector(".bogos-mix-item-select-variant-title");s&&(s.textContent=o.title,s.setAttribute("data-variant-id",String(o.id))),e.setAttribute("data-variant-id",String(o.id)),e.setAttribute("data-item-original-price",String(null!=(n=o.price)?n:0)),e.setAttribute("data-mix-available",o.available?"1":"0"),(null==a?void 0:a.product)&&U.setItemState(i.id,l.id,{product:a.product,variant_id:o.id}),U.refreshStatesBundle(t)},updateItem:(t,e,o)=>{const{bundle:n,mixItem:i,index:l}=U.getItemContext(t,e);if(!n||!i)return;const a=document.createElement("div");a.innerHTML=U.renderMixItem(n,i,l,{templates:U.getItemTemplates(),bundleKey:e.getAttribute("data-mix-key"),uid:e.getAttribute("data-mix-match-uid"),state:o});const r=a.firstElementChild;if(!r)return;const s=e.querySelector(".bogos-mix-match-carousel:not(.bogos-mix-match-carousel-closing)");s&&(r.classList.add("bogos-mix-item-expanded"),U.setExpanded(r,!0)),[...e.attributes].forEach(t=>{r.hasAttribute(t.name)||e.removeAttribute(t.name)}),[...r.attributes].forEach(t=>{e.getAttribute(t.name)!==t.value&&e.setAttribute(t.name,t.value)});const d=document.createDocumentFragment();for(;r.firstChild;)d.appendChild(r.firstChild);[...e.childNodes].forEach(t=>t!==s&&t.remove()),e.insertBefore(d,null!=s?s:null),s&&U.syncCarouselSelection(e)},buildState:(t,e)=>{const o=U.resolveVariant(t,e);return t&&o?{product:t,variant_id:o.id}:null},chooseProduct:(t,e,o,n)=>{const{bundle:i,mixItem:l}=U.getItemContext(t,e);if(!i||!l)return;const a=U.buildState(o,n);U.setItemState(i.id,l.id,a),U.updateItem(t,e,a),U.refreshStatesBundle(t)},removeItem:(t,e)=>{var o;U.chooseProduct(t,e,null),null==(o=e.querySelector(".bogos-mix-item-empty-button"))||o.focus()},setQuantity:(t,e,o)=>{const{mixItem:n}=U.getItemContext(t,e),i=null==e?void 0:e.querySelector(".bogos-mix-match-quantity-input");if(!n||!i)return;const{lower:l,max:a}=U.getQuantityBounds(n);let r=isNaN(o)?l:Math.max(l,o);a&&(r=Math.min(r,a)),String(i.value)!==String(r)&&(i.value=r),e.setAttribute("data-quantity-variant",r.toString()),U.refreshStatesBundle(t)},syncStepper:(t,e,o)=>{const{lower:n,max:i}=U.getQuantityBounds(e),l=t.querySelector(".bogos-minus-mix-btn"),a=t.querySelector(".bogos-plus-mix-btn"),r=o<=n,s=null!==i&&o>=i;l&&l.disabled!==r&&(l.disabled=r),a&&a.disabled!==s&&(a.disabled=s)},openItem:(t,e)=>{const{bundle:o}=U.getItemContext(t,e);o&&(o.layout!==U.LAYOUT.expand?U.openModal(t,e):U.toggleCarousel(t,e))},getModalHost:()=>{var t,e;const{mix_match_collection_popup_query:o}=null!=(t=FGSECOMAPP.QUERY_SELECTOR)?t:{},n=[...null!=(e=null==o?void 0:o.default)?e:[]].filter(Boolean).join(",");return n?document.querySelector(n):null},getModalItem:t=>{var e,o,n;if(null==(e=null==t?void 0:t.itemEl)?void 0:e.isConnected)return{bundleEl:t.bundleEl,itemEl:t.itemEl};const i=String(null==(o=null==t?void 0:t.bundle)?void 0:o.id),l=String(null==(n=null==t?void 0:t.mixItem)?void 0:n.id);for(const a of document.querySelectorAll(".bogos-mix-match-widget")){if(a.getAttribute("data-mix-match-id")!==i)continue;const t=[...a.querySelectorAll(".bogos-mix-item-container")].find(t=>t.getAttribute("data-mix-id")===l);if(t)return{bundleEl:a,itemEl:t}}return{bundleEl:null,itemEl:null}},bindModalHost:t=>{"1"!==t.dataset.bogosMixMatchModal&&(t.dataset.bogosMixMatchModal="1",t.addEventListener("click",e=>U.onModalClick(e,t)),H.mix.init(t),H.dialog.watch(t))},openModal:(t,e)=>{var o,n,i,l;const a=U.getModalHost(),{bundle:r,mixItem:s,index:d}=U.getItemContext(t,e);if(!a||!r||!s)return;U.bindModalHost(a),null==(n=null==(o=U.modal)?void 0:o.observer)||n.disconnect();const c={bundleEl:t,itemEl:e,bundle:r,mixItem:s,catalog:U.getCatalog(r,s),rendered:0,loading:!1,choosing:!1,observer:null,context:null};U.modal=c,R.setVars(a,U.styleVarsOf(r));const u=null!=(l=null==(i=document.querySelector("#bogos_mix_match_modal"))?void 0:i.innerHTML)?l:'';a.classList.toggle("bogos-mix-match-main-collection-popup-container",!0),a.innerHTML=FGSECOMAPP.helper.templateHTML.render(u,{bogos_mix_match_modal_title:X.safeMerchantHTML(U.renderMixLabel(d,U.appearanceOf(r)),!0),bogos_mix_match_modal_cards:U.renderSkeletons(U.MODAL_BATCH,!0)}),a.classList.add("sca-is-visible-fg"),U.renderModalScroll(c)},getGridColumns:t=>getComputedStyle(t).gridTemplateColumns.split(" ").filter(Boolean).length||1,getModalCardContext:t=>{var e,o,n;const i=null!=(e=U.getModalItem(t).itemEl)?e:t.itemEl,l="1"===i.getAttribute("data-check-item");return{template:null!=(n=null==(o=document.querySelector("#bogos_mix_match_modal_card"))?void 0:o.innerHTML)?n:'
{{ bogos_mix_match_card_title }}
{{ bogos_mix_match_card_price }}
{{ bogos_variant_title }}
{{ bogos_mix_item_select_variant_section }}
',currentProductId:l?i.getAttribute("data-product-id"):"",currentVariantId:l?i.getAttribute("data-variant-id"):"",tempKey:U.chosenKey(t.bundle.id,t.mixItem.id),chooseText:U.renderChooseText(U.appearanceOf(t.bundle))}},renderModalScroll:t=>{const e=U.getModalHost(),o=null==e?void 0:e.querySelector(".bogos-mix-match-grid"),n=null==e?void 0:e.querySelector(".bogos-mix-match-collection-popup-body");if(!o||!n||U.modal!==t)return;t.context=U.getModalCardContext(t),o.insertAdjacentHTML("beforeend",'');const i=()=>U.appendModalBatch(t).then(),l=U.MODAL_PRELOAD_PX;"function"==typeof window.IntersectionObserver?t.observer=new IntersectionObserver(t=>{t.some(t=>t.isIntersecting)&&i()},{root:n,rootMargin:"0px 0px ".concat(l,"px 0px")}):n.addEventListener("scroll",X.debounce(()=>{n.scrollTop+n.clientHeight>=n.scrollHeight-l&&i()},U.SCROLL_DEBOUNCE_MS),{passive:!0}),i()},appendModalBatch:t=>h(null,null,function*(){var e,o,n;if(t.loading||U.modal!==t)return;const i=U.getModalHost(),l=null==i?void 0:i.querySelector(".bogos-mix-match-grid"),a=null==l?void 0:l.querySelector(".bogos-mix-match-grid-sentinel");if(!l||!a)return;const{catalog:r}=t,s=U.MODAL_BATCH;t.loading=!0,l.setAttribute("aria-busy","true");try{if(r.products.lengtht.remove());const e=r.products.slice(t.rendered,t.rendered+s).map(e=>U.renderModalCard(e,t.context)).join("");t.rendered=Math.min(r.products.length,t.rendered+s),a.insertAdjacentHTML("beforebegin",e)}finally{l.setAttribute("aria-busy","false"),t.loading=!1}if(t.rendered>=r.products.length&&!r.hasMore)return null==(e=t.observer)||e.disconnect(),void a.remove();null==(o=t.observer)||o.unobserve(a),null==(n=t.observer)||n.observe(a)}),renderModalCard:(t,e)=>{var o,n,i,l,a,r,s,d,c,u;const{template:b,currentProductId:p,currentVariantId:_,tempKey:g,chooseText:m}=e,v=!X.empty(p)&&String(t.id)===String(p),h=U.resolveVariant(t,v?_:null),y=(null!=(n=null==(o=t.variants)?void 0:o.length)?n:0)>1;return FGSECOMAPP.helper.templateHTML.render(b,{bogos_product_id:t.id,bogos_mix_match_card_selected:v?"bogos-mix-match-card-selected":"",bogos_mix_match_card_current:v?'aria-current="true"':"",bogos_mix_match_card_img:X.safeText(null!=(a=X.handleResizeGiftImage(null!=(l=null!=(i=null==h?void 0:h.thumbnail)?i:t.thumbnail)?l:"",!1))?a:""),bogos_mix_match_card_title:X.safeText(null!=(r=t.title)?r:""),bogos_mix_match_card_url:X.safeText(null!=(s=X.routeLink(t.handle?"/products/".concat(t.handle):"/"))?s:""),bogos_mix_match_card_price:X.renderPrice(Number(null!=(d=null==h?void 0:h.price)?d:0)),check_show_mix_item_select:y?"":"sca-d-none",bogos_variant_id:null!=(c=null==h?void 0:h.id)?c:"",bogos_variant_title:X.safeText(null!=(u=null==h?void 0:h.title)?u:""),bogos_mix_item_select_variant_section:y?U.renderProductOptions(t,t.thumbnail,{bundleId:g}):"",bogos_mix_match_card_choose_label:X.attrText("".concat(m," ").concat(t.title)),bogos_mix_match_card_choose_state:v?"disabled":"",bogos_mix_match_card_choose_text:X.safeMerchantHTML(m,!0)})},applyCardVariant:(t,e)=>{var o,n,i,l,a,r,s,d,c;const u=null==(i=null==(n=null==(o=U.modal)?void 0:o.catalog)?void 0:n.products)?void 0:i.find(e=>String(e.id)===t.getAttribute("data-product-id")),b=null==(l=null==u?void 0:u.variants)?void 0:l.find(t=>String(t.id)===String(e.id)),p=null!=(s=null!=(r=null==b?void 0:b.thumbnail)?r:null==(a=null==b?void 0:b.featured_image)?void 0:a.src)?s:null==u?void 0:u.thumbnail,_=t.querySelector(".bogos-mix-match-card-img");_&&p&&_.setAttribute("src",X.handleResizeGiftImage(p,!1));const g=t.querySelector(".bogos-mix-match-card-price");g&&(g.textContent=X.renderPrice(Number(null!=(c=null!=(d=e.price)?d:null==b?void 0:b.price)?c:0)));const m=t.querySelector(".bogos-mix-item-select-variant-title");m&&(m.textContent=e.title,m.setAttribute("data-variant-id",String(e.id)))},onModalClick:(t,e)=>{var o,n;const i=(null==(o=t.target)?void 0:o.closest)?t.target:null;if(!i)return;if(i===e||i.closest(".bogos-mix-match-collection-popup-off"))return void U.closeModal();const l=U.modal;if(!l)return;const a={holderSelector:".bogos-mix-match-card",tempKey:()=>U.chosenKey(l.bundle.id,l.mixItem.id),apply:(t,e)=>{if(U.applyCardVariant(t,e),!t.classList.contains("bogos-mix-match-card-selected"))return;const{bundleEl:o,itemEl:n}=U.getModalItem(l);n&&U.applyItemVariant(o,n,e)}},r=Boolean(e.querySelector(".bogos-mix-item-select-variant-dropdown.opened"));if(U.handleVariantClick(i,e,a))return;if(r&&!i.closest(".bogos-mix-match-card-choose")||i.closest("a[href]"))return;const s=i.closest(".bogos-mix-match-card:not(.bogos-mix-match-card-skeleton)"),d=null==s?void 0:s.querySelector(".bogos-mix-match-card-choose");if(!d||d.disabled||l.choosing)return;const c=l.catalog.products.find(t=>String(t.id)===s.getAttribute("data-product-id"));if(!c)return;const u=null==(n=s.querySelector(".bogos-mix-item-select-variant-title"))?void 0:n.getAttribute("data-variant-id"),{bundleEl:b,itemEl:p}=U.getModalItem(l);l.choosing=!0,p?U.chooseProduct(b,p,c,u):U.setItemState(l.bundle.id,l.mixItem.id,U.buildState(c,u)),e.querySelectorAll(".bogos-mix-match-card-selected").forEach(t=>{var e;t.classList.remove("bogos-mix-match-card-selected"),t.removeAttribute("aria-current"),null==(e=t.querySelector(".bogos-mix-match-card-choose"))||e.removeAttribute("disabled")}),s.classList.add("bogos-mix-match-card-selected"),s.setAttribute("aria-current","true"),d.classList.add("bogos-mix-match-card-choose-added"),d.disabled=!0,setTimeout(()=>{U.modal===l&&U.closeModal()},U.MODAL_CHOSEN_DELAY_MS)},prefersReducedMotion:()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,afterTransition:(t,e,o,n)=>{let i=!1;const l=()=>{i||(i=!0,n())};t.addEventListener("transitionend",o=>{o.target!==t||e&&o.propertyName!==e||l()}),setTimeout(l,o)},closeModal:()=>{var t,e,o;const n=U.getModalHost(),i=U.modal;if(null==(t=null==i?void 0:i.observer)||t.disconnect(),U.modal=null,(null==i?void 0:i.choosing)&&(null==(o=null==(e=U.getModalItem(i).itemEl)?void 0:e.querySelector(".bogos-mix-item-title, .bogos-mix-item-empty-button"))||o.focus()),!n)return;n.classList.remove("sca-is-visible-fg");const l=n.querySelector(".bogos-mix-match-modal");l&&!U.prefersReducedMotion()?(U.afterTransition(l,"transform",U.MODAL_CLOSE_FALLBACK_MS,()=>{l.isConnected&&(n.innerHTML="")}),l.classList.add("bogos-mix-match-modal-closing")):n.innerHTML=""},toggleCarousel:(t,e)=>{const o=".bogos-mix-match-carousel:not(.bogos-mix-match-carousel-closing)";e.querySelector(o)?U.closeCarousel(e):(t.querySelectorAll(".bogos-mix-item-container.bogos-mix-item-expanded").forEach(t=>t!==e&&t.querySelector(o)&&U.closeCarousel(t)),U.openCarousel(t,e))},openCarousel:(t,e)=>{var o,n;const{bundle:i,mixItem:l,index:a}=U.getItemContext(t,e);if(!i||!l)return;const r=null!=(n=null==(o=document.querySelector("#bogos_mix_match_carousel"))?void 0:o.innerHTML)?n:'',s=document.createElement("div");s.innerHTML=FGSECOMAPP.helper.templateHTML.render(r,{bogos_mix_match_carousel_id:"bogos-mix-match-carousel-".concat(e.getAttribute("data-mix-match-uid")),bogos_mix_item_label:X.attrText(U.renderMixLabel(a,U.appearanceOf(i))),bogos_mix_match_carousel_cards:""});const d=s.firstElementChild,c=null==d?void 0:d.querySelector(".bogos-mix-match-carousel-track");if(!d||!c)return;const u={catalog:U.getCatalog(i,l),rendered:0,observer:null};U.carouselState.set(d,u),u.catalog.hasMore&&(c.innerHTML=''+U.renderSkeletons(U.CAROUSEL_SKELETONS,!1)),e.querySelectorAll(".bogos-mix-match-carousel-closing").forEach(t=>t.remove()),e.classList.add("bogos-mix-item-expanded"),U.setExpanded(e,!0),e.appendChild(d),U.appendCarouselCards(d),d.offsetHeight,d.classList.add("bogos-mix-match-carousel-open");const b="function"==typeof window.IntersectionObserver,p=U.CAROUSEL_PRELOAD_PX;c.addEventListener("scroll",X.debounce(()=>{U.updateCarouselNav(d);const t=c.querySelector(".bogos-mix-match-carousel-sentinel");!b&&t&&t.offsetLeft-c.scrollLeft<=c.clientWidth+p&&U.loadCarouselMore(d).then()},U.SCROLL_DEBOUNCE_MS),{passive:!0});const _=c.querySelector(".bogos-mix-match-carousel-sentinel");_&&b&&(u.observer=new IntersectionObserver(t=>{t.some(t=>t.isIntersecting)&&U.loadCarouselMore(d).then()},{root:c,rootMargin:"0px ".concat(p,"px 0px 0px")}),u.observer.observe(_));const g=c.querySelector(".bogos-mix-match-card-selected");g&&(c.scrollLeft=Math.max(0,g.offsetLeft-U.CAROUSEL_TRACK_PADDING)),U.updateCarouselNav(d)},closeCarousel:t=>{var e,o;const n=null==t?void 0:t.querySelector(".bogos-mix-match-carousel:not(.bogos-mix-match-carousel-closing)");if(U.setExpanded(t,!1),n&&(null==(o=null==(e=U.carouselState.get(n))?void 0:e.observer)||o.disconnect()),!n||U.prefersReducedMotion())return null==n||n.remove(),void U.toggleClass(t,"bogos-mix-item-expanded",!1);n.classList.add("bogos-mix-match-carousel-closing"),n.classList.remove("bogos-mix-match-carousel-open"),U.afterTransition(n,null,U.CAROUSEL_CLOSE_FALLBACK_MS,()=>{n.remove(),t.querySelector(".bogos-mix-match-carousel")||U.toggleClass(t,"bogos-mix-item-expanded",!1)})},loadCarouselMore:t=>h(null,null,function*(){var e;const o=U.carouselState.get(t);(null==(e=null==o?void 0:o.catalog)?void 0:e.hasMore)&&(yield U.loadMore(o.catalog),t.isConnected&&U.appendCarouselCards(t))}),appendCarouselCards:t=>{var e,o,n,i;const l=U.carouselState.get(t),a=null==t?void 0:t.querySelector(".bogos-mix-match-carousel-track");if(!l||!a)return;const r=null!=(e=t.closest(".bogos-mix-item-container"))?e:t.parentElement,s=null!=(n=null==(o=document.querySelector("#bogos_mix_match_carousel_card"))?void 0:o.innerHTML)?n:'',d="1"===(null==r?void 0:r.getAttribute("data-check-item"))?r.getAttribute("data-product-id"):"",c=l.catalog.products.slice(l.rendered).map(t=>U.renderCarouselCard(t,{template:s,currentProductId:d})).join("");l.rendered=l.catalog.products.length;const u=a.querySelector(".bogos-mix-match-carousel-sentinel"),b=null!=u?u:a.querySelector(".bogos-mix-match-card-skeleton");c&&(b?b.insertAdjacentHTML("beforebegin",c):a.insertAdjacentHTML("beforeend",c)),l.catalog.hasMore?u&&l.observer&&(l.observer.unobserve(u),l.observer.observe(u)):(null==(i=l.observer)||i.disconnect(),a.querySelectorAll(".bogos-mix-match-card-skeleton, .bogos-mix-match-carousel-sentinel").forEach(t=>t.remove())),U.updateCarouselNav(t)},renderCarouselCard:(t,e)=>{var o,n,i,l,a;const{template:r,currentProductId:s}=e,d=!X.empty(s)&&String(t.id)===String(s),c=U.resolveVariant(t);return FGSECOMAPP.helper.templateHTML.render(r,{bogos_product_id:t.id,bogos_mix_match_card_selected:d?"bogos-mix-match-card-selected":"",bogos_mix_match_card_pressed:d?"true":"false",bogos_mix_match_card_img:X.safeText(null!=(i=X.handleResizeGiftImage(null!=(n=null!=(o=null==c?void 0:c.thumbnail)?o:t.thumbnail)?n:"",!1))?i:""),bogos_mix_match_card_title:X.safeText(null!=(l=t.title)?l:""),bogos_mix_match_card_price:X.renderPrice(Number(null!=(a=null==c?void 0:c.price)?a:0))})},selectCarouselCard:(t,e,o)=>{var n,i;const l=U.carouselState.get(o.closest(".bogos-mix-match-carousel")),a=o.getAttribute("data-product-id"),r=null==(i=null==(n=null==l?void 0:l.catalog)?void 0:n.products)?void 0:i.find(t=>String(t.id)===a);r&&("1"===e.getAttribute("data-check-item")&&e.getAttribute("data-product-id")===a||U.chooseProduct(t,e,r))},syncCarouselSelection:t=>{const e="1"===t.getAttribute("data-check-item")?t.getAttribute("data-product-id"):"";t.querySelectorAll(".bogos-mix-match-carousel .bogos-mix-match-card:not(.bogos-mix-match-card-skeleton)").forEach(t=>{const o=!X.empty(e)&&t.getAttribute("data-product-id")===e;U.toggleClass(t,"bogos-mix-match-card-selected",o);const n=o?"true":"false";t.getAttribute("aria-pressed")!==n&&t.setAttribute("aria-pressed",n)})},scrollCarousel:(t,e)=>{const o=t.querySelector(".bogos-mix-match-carousel-track");o&&o.scrollBy({left:e*Math.max(.8*o.clientWidth,120),behavior:U.prefersReducedMotion()?"auto":"smooth"})},updateCarouselNav:t=>{const e=null==t?void 0:t.querySelector(".bogos-mix-match-carousel-track");e&&(U.setDisabled(t.querySelector(".bogos-mix-match-carousel-prev"),e.scrollLeft<=1),U.setDisabled(t.querySelector(".bogos-mix-match-carousel-next"),e.scrollLeft+e.clientWidth>=e.scrollWidth-1))},renderMinNotice:(t,e,o)=>{let n=t.querySelector(".bogos-mix-match-min-notice");o?(!n&&(null==e?void 0:e.parentElement)&&(n=document.createElement("div"),n.className="bogos-mix-match-min-notice",n.id="bogos-mix-match-min-notice-".concat(++H.seq),e.parentElement.insertBefore(n,e),e.setAttribute("aria-describedby",n.id)),n&&n.textContent!==o&&(n.textContent=o)):n&&(n.remove(),null==e||e.removeAttribute("aria-describedby"))},transformSelectedDataToMixItem:t=>{const e={};return t.forEach(t=>{var o;if(t.type===B.NARROW_TYPE.product){t.value.forEach(o=>{o.variants.forEach(n=>{n.mix_item_ids.forEach(i=>{var l,a,r,s,d;let c=null!=(l=e[i])?l:{},u=null!=(r=null==(a=null==c?void 0:c.value)?void 0:a[o.id])?r:{};e[i]={type:null==t?void 0:t.type,value:v(m({},null!=(s=c.value)?s:{}),{[o.id]:v(m({},o),{variants:[...null!=(d=null==u?void 0:u.variants)?d:[],v(m({},n),{price:X.convertMultiCurrency(n.price)})]})})}})})});for(const t in e)e[t].value=N.handleTransformProductData(Object.values(null!=(o=e[t].value)?o:{}))}else t.value.forEach(o=>{o.mix_item_ids.forEach(n=>{var i,l;e[n]={type:t.type,value:[...new Set([...null!=(l=null==(i=e[n])?void 0:i.value)?l:[],o.collection_id])]}})})}),e},convertDataMixMatch:t=>{var e,o,n,i,l,a,r,s,d,c;const u=null==(e=null==t?void 0:t.products)?void 0:e.find(t=>(null==t?void 0:t.type)===B.NARROW_TYPE.config),b=null==(o=null==u?void 0:u.value)?void 0:o.mix_type,p=b===U.MIX_TYPE.single,_=null==(n=null==t?void 0:t.products)?void 0:n.filter(t=>(null==t?void 0:t.type)!==B.NARROW_TYPE.config),g=U.transformSelectedDataToMixItem(_),h=U.normalizeBundle(t);let y=(Array.isArray(null==(i=null==u?void 0:u.value)?void 0:i.mix_items)?u.value.mix_items:[]).map((t,e)=>{var o,n;const{max_quantity:i,default_product:l,product_ids:a}=null!=(o=h.mix_items[e])?o:{},r=parseInt(t.min_quantity)||0;return{id:t.id,set_min:r>0,min_quantity:r>0?r:1,max_quantity:null!=i?i:null,default_product:null!=l?l:U.normalizeDefaultProduct(),selected:p?{}:null!=(n=U.sortByProductIds(g[t.id],a))?n:{type:B.NARROW_TYPE.product,value:[]}}});return v(m({},t),{discount:null!=(a=null==(l=t.discount)?void 0:l.map(t=>(N.convertDiscountMarket(t.discount),N.convertDiscountMarket(t.shipping_discount),t)))?a:[],checked:y.map(t=>t.id),mix_type:b,selected:p?{type:null==(r=null==t?void 0:t.products[0])?void 0:r.type,value:(null==(s=null==t?void 0:t.products[0])?void 0:s.type)===B.NARROW_TYPE.product?N.handleTransformProductData((f=null==t?void 0:t.products[0].value,f.map(t=>v(m({},t),{variants:t.variants.map(t=>v(m({},t),{price:X.convertMultiCurrency(t.price)}))})))):null==(c=null==(d=null==t?void 0:t.products[0])?void 0:d.value)?void 0:c.map(t=>t.collection_id)}:{},mix_items:y,layout:h.layout});var f},refreshStatesBundle:t=>{var e,o,n,i,l,a;const r=t.getAttribute("data-mix-match-id");let s=0,d=-1,c=0,u=!0,b=!0;const p={},_=null==(e=FGSECOMAPP.current_bundles_mix_match)?void 0:e.find(t=>{var e;return(null==(e=t.id)?void 0:e.toString())===(null==r?void 0:r.toString())});if(!_)return;const g=U.appearanceOf(_),{show_discount_on_button:m,show_discount_each_item:v}=g.content,h=[...t.querySelectorAll(".bogos-mix-item-container")],y=h.filter(t=>"1"===t.getAttribute("data-check-item"));let f="";h.forEach(t=>{const e=t.getAttribute("data-mix-id"),o=parseInt(t.getAttribute("data-quantity-variant")),n="1"===t.getAttribute("data-check-item"),i=parseFloat(t.getAttribute("data-item-original-price")),l=t.getAttribute("data-variant-id"),a=_.mix_items.findIndex(t=>String(e)===String(t.id)),r=_.mix_items[a];r&&(r.set_min&&u&&(u=n&&o>=r.min_quantity,u||(f=U.renderMinQuantityText(r.min_quantity,U.renderMixLabel(a,g),g))),n&&(U.syncStepper(t,r,o),p[e]={[l]:{quantity:o,price:i,variantId:l}},s+=i*o,c+=o))});const x=[...null==_?void 0:_.discount].sort((t,e)=>e.quantity-t.quantity).find(t=>c>=t.quantity),S="offer_".concat(r),E=()=>{var e;(null==(e=U.free_products)?void 0:e[S])&&(U.free_products[S]=[]);const o=t.querySelector(".bogos-mix-match-gift-items-container");o&&o.remove()},A=()=>{const e=t.querySelector(".bogos-mix-match-shipping-discount-container");e&&e.remove()};if(x&&u){const e=x.discount.value;switch(x.discount.type){case B.DISCOUNT_TYPE.percentage:d=s*(100-x.discount.value)/100;break;case B.DISCOUNT_TYPE.fixed_amount:d=Math.max(0,s-e);break;case B.DISCOUNT_TYPE.fixed_price:if(c-x.quantity>0){const t=[];Object.keys(p).forEach(e=>{p[e]&&Object.keys(p[e]).forEach(o=>{t.push({id:parseInt(o),quantity:parseInt(p[e][o].quantity),price:parseFloat(p[e][o].price)})})}),t.sort((t,e)=>e.price-t.price);let o=0,n=0;for(let e=0;e{const e=FGSECOMAPP.productsByID[t.id];t.variants.forEach(t=>{var o,i;const l=null==(o=null==e?void 0:e.variants)?void 0:o.find(e=>e.id===t.id),a=l?(null==l?void 0:l.price)/100:t.price;let r=parseFloat(a)*parseInt(null!=(i=t.quantity)?i:"1");l&&!(null==l?void 0:l.available)&&(r=0),n+=r})}),d=s,s+=n;break;default:d=s}((e,o)=>{const{discount:n,shipping_discount:i}=null!=o?o:{},l=n.type===B.DISCOUNT_TYPE.fixed_amount,a=n.type===B.DISCOUNT_TYPE.fixed_price,r=!X.empty(i),s=n.type===B.DISCOUNT_TYPE.percentage,d=n.type===B.DISCOUNT_TYPE.free_products;let c="";l&&(c=n.value?"(".concat(FGSECOMAPP.helper.templateHTML.render(X.safeMerchantHTML(J.convertIntegration("{{discountAmount}} OFF","customize.mix_match_discount_label","customize.mix_match.discount_text",!0),!0),{discountAmount:"".concat(X.renderPrice(n.value))}),")"):""),s&&(c=n.value?"(".concat(FGSECOMAPP.helper.templateHTML.render(X.safeMerchantHTML(J.convertIntegration("{{discountAmount}} OFF","customize.mix_match_discount_label","customize.mix_match.discount_text",!0),!0),{discountAmount:"".concat(n.value+"%")}),")"):""),d?(()=>{var e,o,n,i,l,a;const r=t.querySelector(".bogos-mix-match-gift-items-container");if(r&&r.remove(),(null==(e=U.free_products)?void 0:e[S].length)>0){const e=null!=(n=null==(o=document.querySelector("bogos_mix_match_widget_gift_items_section"))?void 0:o.innerHTML)?n:'
{{ bogos_gift_items_header }}
{{ bogos_gift_items_list }}
',r=null!=(l=null==(i=document.querySelector("bogos_mix_match_widget_gift_item_section"))?void 0:i.innerHTML)?l:'
{{ bogos_product_title }}
{{ bogos_product_title }}
{{ bogos_integration_judgeme }} {{ bogos_integration_trustoo }} {{ bogos_integration_yotpo }}
{{ bogos_variant_title }}
{{ bogos_variant_out_stock }}
x{{ bogos_product_quantity }}
{{ bogos_product_discount_price }} {{ bogos_product_original_price }}
',s=null==(a=U.free_products)?void 0:P(a[S].map(t=>{var e;const o=null!=(e=FGSECOMAPP.productsByID[t.id])?e:{},n=N.renderAppReviewEl(t.id),i=N.renderAppReviewEl(t.id,B.APP_REVIEW.trustoo),l=N.renderAppReviewEl(t.id,B.APP_REVIEW.yotpo);return t.variants.map(e=>{var a,s,d,c,u;const b=null==(a=null==o?void 0:o.variants)?void 0:a.find(t=>t.id===e.id),p=(null==b?void 0:b.price)?(null==b?void 0:b.price)/100:X.convertMultiCurrency(null==e?void 0:e.price);return FGSECOMAPP.helper.templateHTML.render(r,{bogos_product_img:X.safeText(null!=(s=e.thumbnail)?s:t.thumbnail),bogos_product_title:X.safeText(null!=(d=null==o?void 0:o.title)?d:t.title),bogos_variant_title:X.checkIsDefaultTitle(e.title)?"":X.safeText(null!=(c=null==b?void 0:b.title)?c:e.title),bogos_product_quantity:null!=(u=e.quantity)?u:1,bogos_product_original_price:X.renderPrice(p),bogos_product_discount_price:X.safeMerchantHTML(R.text(g,"free_price","FREE","customize.mix_match_free_price","customize.mix_match.free_price"),!0),bogos_out_stock_class:b&&(null==b?void 0:b.available)?"sca-d-none":"",bogos_variant_out_stock:b&&(null==b?void 0:b.available)?"":X.safeMerchantHTML(R.text(g,"out_stock_text","Out of stock!","customize.mix_match_out_stock_text","customize.mix_match.out_stock_text"),!0),bogos_integration_judgeme:n,bogos_integration_trustoo:i,bogos_integration_yotpo:l})})}),"flat")(),d=FGSECOMAPP.helper.templateHTML.render(e,{bogos_gift_items_header:X.safeMerchantHTML(R.text(g,"free_product_title","\ud83c\udf81 Free Gift","customize.mix_match_free_product_title","customize.mix_match.free_product_title"),!0),bogos_gift_items_list:s.join(" ")}),c=document.createElement("div");c.innerHTML=d;const u=c.firstElementChild,b=t.querySelector(".bogos-mix-match-widget-body");b&&b.appendChild(u);const p=115,_=t.querySelectorAll(".bogos-mix-item-container").length,m=p*(2+_)+40;if(!(p*(_+s.length)>m))return;t.querySelector(".bogos-mix-match-widget-body").setAttribute("style","max-height:".concat(m,"px;overflow-y:scroll;")),t.querySelector(".bogos-mix-match-widget-footer").classList.add("bogos-bundles-footer-box-shadow")}})():E(),r?(()=>{var e,o,n,i;const l=t.querySelector(".bogos-mix-match-shipping-discount-container");l&&l.remove();const a=null!=(o=null==(e=document.querySelector("#sca_mix_match_shipping_discount_section"))?void 0:e.innerHTML)?o:'
{{ bogos_shipping_discount_title }}
',{shipping_icon_path:r}=g.content,s=FGSECOMAPP.helper.templateHTML.render(a,{bogos_shipping_discount_title:X.safeMerchantHTML(J.convertIntegration(null!=(i=null==(n=null==x?void 0:x.shipping_discount)?void 0:n.label)?i:"","mix_match.".concat(_.id,".tiers.").concat(x.id,".shipping_label"),"mix_match.".concat(_.id,".tiers.").concat(x.id,".shipping_label")),!0),bogos_shipping_icon:X.safeText(null!=r?r:fgShippingIconsObj["shipping-icon-1.png"])}),d=document.createElement("div");d.innerHTML=s;const c=d.firstElementChild,u=t.querySelector(".bogos-mix-match-widget-body");u&&u.appendChild(c)})():A(),y.forEach(t=>{const e=parseFloat(t.getAttribute("data-item-original-price")),o=t.querySelector(".bogos-mix-item-discount-price"),i=t.querySelector(".bogos-mix-item-original-price");if(!o||!i)return;const r=N.calculateDiscountPrice(n,e);o.innerHTML="".concat(X.renderPrice(r));const s=(null==v||v)&&Number(r)!==Number(e);i.innerHTML=s?"".concat(X.renderPrice(e)):"",i.style.display=l||a?"none":""}),e.querySelector(".bogos-mix-match-total .bogos-mix-match-total-original-price").style.display="",e.querySelector(".bogos-mix-match-total-title").innerHTML=X.safeMerchantHTML(R.text(g,"total_price_text","Total bundle price","customize.mix_match_total_price","customize.mix_match.total_price_text",!0),!0)+"".concat(c?" ".concat(c):"",":"),e.querySelector(".bogos-mix-match-button-add").innerHTML=X.safeMerchantHTML(R.text(g,"button_text","Add bundle to cart","customize.mix_match_add_to_cart","customize.mix_match.button_text",!0),!0)+"".concat(null==m||m?" ".concat(c):""," "),e.querySelectorAll(".bogos-mix-match-badge-item").forEach(t=>{const e=t.getAttribute("data-discount-id");o.id.toString()===e.toString()?t.classList.add("success"):t.classList.remove("success")})})(t,x)}else q=t,y.forEach(t=>{const e=parseFloat(t.getAttribute("data-item-original-price")),o=t.querySelector(".bogos-mix-item-discount-price"),n=t.querySelector(".bogos-mix-item-original-price");o&&(o.innerHTML="".concat(X.renderPrice(e))),n&&(n.style.display="none")}),q.querySelector(".bogos-mix-match-total .bogos-mix-match-total-original-price").style.display="none",q.querySelector(".bogos-mix-match-total-title").innerHTML=X.safeMerchantHTML(R.text(g,"total_price_text","Total bundle price","customize.mix_match_total_price","customize.mix_match.total_price_text",!0),!0)+":",q.querySelector(".bogos-mix-match-button-add").innerHTML=X.safeMerchantHTML(R.text(g,"button_text","Add bundle to cart","customize.mix_match_add_to_cart","customize.mix_match.button_text"),!0),q.querySelectorAll(".bogos-mix-match-badge-item").forEach(t=>{t.classList.remove("success")}),E(),A();var q;d=d<0||d>=s?s:d,s=s.toFixed(null!=(i=null==(n=FGSECOMAPP.variables.Shopify)?void 0:n.fg_decimal)?i:2),d=d.toFixed(null!=(a=null==(l=FGSECOMAPP.variables.Shopify)?void 0:l.fg_decimal)?a:2),t.querySelector(".bogos-mix-match-total .bogos-mix-match-total-original-price").innerHTML=Number(s)!==Number(d)?"".concat(X.renderPrice(s)):"",t.querySelector(".bogos-mix-match-total .bogos-mix-match-total-discount-price").innerHTML="".concat(X.renderPrice(d)),y.forEach(t=>{const e="1"===t.getAttribute("data-mix-available");U.toggleClass(t.querySelector(".bogos-mix-match-quantity-container"),"sca-d-none",!e),U.toggleClass(t.querySelector(".bogos-mix-item-out-stock"),"sca-d-none",e),b&&(b=e)});const M=t.querySelector(".bogos-mix-match-button-add");M&&!M.classList.contains("bogos-bundles-adding")&&(M.disabled=!y.length||!u||!b),U.renderMinNotice(t,M,f),U.syncProgress(t,_,u?c:0)},getProgressRatio:(t,e)=>{const o=t.length-1;if(o<1||e<=t[0])return 0;if(e>=t[o])return 1;const n=t.findIndex(t=>e0?(e-t[n])/i:0))/o},syncProgress:(t,e,o)=>{var n;const i=t.querySelector(".bogos-mix-match-progress-container"),l=[...null!=(n=null==i?void 0:i.querySelectorAll(".bogos-mix-match-progress-item"))?n:[]];if(!l.length)return;const a=l.map(t=>{var o,n;return parseInt(null==(n=null==(o=e.discount)?void 0:o.find(e=>String(e.id)===t.getAttribute("data-discount-id")))?void 0:n.quantity)||0}),r=a.filter(t=>o>=t).length;l.forEach((t,e)=>{U.toggleClass(t,"success",eh(null,null,function*(){try{yield U.filter(e),U.render(t),U.renderEventQuery()}catch(o){console.warn("BOGOS track: mix & match init failed",o)}})},Y={productsTemp:{},sortSizes:(t=[])=>[...null!=t?t:[]].sort((t,e)=>{var o,n,i,l;const a="unlimited"===(null==t?void 0:t.type),r="unlimited"===(null==e?void 0:e.type);return a!==r?a?1:-1:a&&r?(null!=(o=null==t?void 0:t.id)?o:0)-(null!=(n=null==e?void 0:e.id)?n:0):(Number.isFinite(Number(null==t?void 0:t.quantity))?Number(t.quantity):Number.MAX_SAFE_INTEGER)-(Number.isFinite(Number(null==e?void 0:e.quantity))?Number(e.quantity):Number.MAX_SAFE_INTEGER)||(null!=(i=null==t?void 0:t.id)?i:0)-(null!=(l=null==e?void 0:e.id)?l:0)}),transformVariantsToSteps:t=>{const e={};t.forEach(t=>{t.variants.forEach(o=>{var n;(null!=(n=o.step_ids)?n:[]).forEach(n=>{e[n]||(e[n]={productsMap:{}}),e[n].productsMap[t.id]||(e[n].productsMap[t.id]=v(m({},t),{variants:[]})),e[n].productsMap[t.id].variants.push(v(m({},o),{price:X.convertMultiCurrency(o.price)}))})})});for(const o in e)e[o].products=N.handleTransformProductData(Object.values(e[o].productsMap)),delete e[o].productsMap;return e},convertData:t=>{var e,o,n,i,l,a,r;const s=null==(e=t.products)?void 0:e.find(t=>t.type===B.NARROW_TYPE.config),d=null==(o=t.products)?void 0:o.find(t=>t.type===B.NARROW_TYPE.product),c=Y.transformVariantsToSteps(null!=(n=null==d?void 0:d.value)?n:[]),u=(null!=(l=null==(i=null==s?void 0:s.value)?void 0:i.steps)?l:[]).map(t=>{var e,o;return v(m({},t),{has_max:0!==t.max_quantity,has_min:0!==t.min_quantity,products:null!=(o=null==(e=c[t.id])?void 0:e.products)?o:[]})});return v(m({},t),{steps:u,discount:Y.sortSizes(null!=(r=null==(a=t.discount)?void 0:a.map(t=>(N.convertDiscountMarket(t.discount),t)))?r:[])})},filterWithBlocks:t=>{var e,o,n,i,l;const a=null!=(o=null==(e=FGSECOMAPP.bundles)?void 0:e.filter(t=>t.type===B.BUNDLE_TYPE.bundle_product_page))?o:[],r={},{current_product:s}=null!=(n=FGSECOMAPP.variables.Shopify)?n:{},d=t?FGSECOMAPP.current_bundles_product_page:a,c=X.empty(null==s?void 0:s.id)?[]:null==d?void 0:d.filter(t=>{var e;return String(X.getIntShopifyId(null==(e=t.extra_info)?void 0:e.product_bundle_id))===String(s.id)}),{product_form_query:u}=null!=(i=FGSECOMAPP.QUERY_SELECTOR)?i:{};let b=t?[t]:document.querySelectorAll(null==(l=null==u?void 0:u.bundle_product_page)?void 0:l.join(","));return b.forEach(t=>{var e;const o=Number(t.getAttribute("data-offer-id"));let n=null;o&&(n=null==(e=null!=n?n:d)?void 0:e.filter(t=>t.id.toString()===o.toString())),null==n||n.forEach(t=>r[t.id]=m({},t)),o||c.forEach(t=>r[t.id]=t)}),b.length||c.forEach(t=>r[t.id]=t),Object.values(r)},filter:()=>h(null,null,function*(){const t=Y.filterWithBlocks();if(!t.length)return void(FGSECOMAPP.current_bundles_product_page=[]);const e=[],o=[];t.forEach(t=>{var n,i,l;null==(l=null==(i=null==(n=t.products)?void 0:n.find(t=>t.type===B.NARROW_TYPE.product))?void 0:i.value)||l.forEach(t=>{e.push(t.handle),o.push(t.id)})}),yield O.cacheProducts(e,{"sca-bundle-pp-search":"1"},()=>{console.info("BOGOS track: bpp:sync-quantity:".concat(Date.now()))},{handles:e,ids:o}),FGSECOMAPP.current_bundles_product_page=t.map(t=>Y.convertData(t))}),formatSizeLabel:(t,e)=>{var o,n,i,l;if(!t)return"";const a=null==(o=e.discount)?void 0:o.type,r=null!=(i=null==(n=e.discount)?void 0:n.value)?i:0;let s="";return a===B.DISCOUNT_TYPE.percentage?s="".concat(r,"%"):[B.DISCOUNT_TYPE.fixed_amount,B.DISCOUNT_TYPE.fixed_price].includes(a)&&(s=X.renderPrice(r)),FGSECOMAPP.helper.templateHTML.render(t,{quantity:null!=(l=e.quantity)?l:"",discount_amount:s})},renderSizeBadge:(t,e)=>{var o,n,i,l,a;const r=e.badge;if(!r)return"";if("image"===r.type&&(null==(o=r.image)?void 0:o.src))return'
');if("text"!==r.type||!r.text)return"";const s=null!=(a=(null!=(l=null==(i=null==(n=t.extra_info)?void 0:n.pack_select)?void 0:i.badge)?l:{}).display_style)?a:"default",d=X.safeMerchantHTML(J.convertIntegration(r.text,"bundle_product_page.".concat(t.id,".sizes.").concat(e.id,".badge_text")),!0);return'
\n ').concat(d,"\n
")},renderSizes:t=>{var e,o,n,i,l,a,r,s,d;const c=null!=(o=null==(e=document.querySelector("#bogos_bundle_pp_size_item"))?void 0:e.innerHTML)?o:'
{{ bogos_size_badge }} {{ bogos_size_image }}
{{ bogos_size_label }}
{{ bogos_size_discount_label }}
',u=null!=(l=null==(i=null==(n=t.extra_info)?void 0:n.pack_select)?void 0:i.label_style)?l:"",b=null!=(s=null==(r=null==(a=t.extra_info)?void 0:a.pack_select)?void 0:r.image_orientation)?s:"vertical",p=Y.sortSizes(null!=(d=t.discount)?d:[]),_=p.filter(t=>"unlimited"!==t.type),g=_.length?Math.max(..._.map(t=>{var e;return Number(null!=(e=t.quantity)?e:0)})):0;return p.map(e=>{var o,n,i,l;const a=!!e.image,r=a?''):"",s=X.safeMerchantHTML(J.convertIntegration(null!=(o=e.size_label)?o:"","bundle_product_page.".concat(t.id,".sizes.").concat(e.id,".size_label")),!0),d=X.safeMerchantHTML(J.convertIntegration(null!=(n=e.discount_label)?n:"","bundle_product_page.".concat(t.id,".sizes.").concat(e.id,".discount_label")),!0),p="unlimited"===e.type?v(m({},e),{quantity:"".concat(g,"+")}):e;return FGSECOMAPP.helper.templateHTML.render(c,{bogos_size_id:e.id,bogos_size_quantity:null!=(i=e.quantity)?i:"",bogos_size_type:null!=(l=e.type)?l:"base",bogos_size_label:Y.formatSizeLabel(s,p),bogos_size_discount_label:Y.formatSizeLabel(d,p),bogos_size_label_style:u,bogos_size_image:r,bogos_size_badge:Y.renderSizeBadge(t,e),bogos_size_has_image_class:a?"bogos-size-img-".concat(b):""})}).join("")},renderSelectVariantOptions:(t,e)=>{var o,n,i,l,a,r;const{type:s="variant"}=null!=(n=null==(o=FGSECOMAPP.fgAppearance)?void 0:o.select_variant)?n:{};if("variant"!==s)return Y.productsTemp[e]=m({},null!=(i=Y.productsTemp[e])?i:{}),Y.productsTemp[e][t.id]=t,k.queryProductDefault(t.id).then(),'
';const d=null!=(a=null==(l=document.querySelector("#bogos_bundle_pp_select_variant_option"))?void 0:l.innerHTML)?a:'
{{ bogos_variant_option_title }}
',c=null==(r=FGSECOMAPP.productsByID)?void 0:r[t.id];return t.variants.map(e=>{var o,n,i,l,a,r;const s=null==(o=null==c?void 0:c.variants)?void 0:o.find(t=>t.id===e.id),u=null!=(a=null!=(l=null!=(i=null==(n=null==s?void 0:s.featured_image)?void 0:n.src)?i:e.thumbnail)?l:t.thumbnail)?a:"";return FGSECOMAPP.helper.templateHTML.render(d,{bogos_variant_option_id:e.id,bogos_variant_option_price:e.price,bogos_variant_option_available:"1",bogos_variant_option_img:X.safeText(X.handleResizeProductImage(u,150)),bogos_variant_option_title:X.safeText(null!=(r=null==s?void 0:s.title)?r:e.title)})}).join("")},renderAddProductButtonContent:(t={},e)=>{var o,n,i;const l=X.safeMerchantHTML(J.convertIntegration(null!=(o=t.button_label)?o:"Add","bundle_product_page.".concat(e,".button_label")),!0),a=null!=(n=t.button_style)?n:"text_icon",r="cart"===(null!=(i=t.icon)?i:"plus")?'\n \n ':'\n \n ';return"icon"===a?r:"text"===a?"".concat(l,""):"".concat(r,"").concat(l,"")},openProductDetailModal:(t,e,o,n,i=null)=>{var l,a,r,s;const d=FGSECOMAPP.current_bundles_product_page.find(t=>String(t.id)===n.getAttribute("data-bundle-pp-id")),c=d.steps.find(t=>String(t.id)===o);if(!d||!c)return;const u=document.querySelector("#bogos-main-popup-product-detail-container");if(!u)return;const{type:b="variant"}=null!=(a=null==(l=FGSECOMAPP.fgAppearance)?void 0:l.select_variant)?a:{},p=()=>{var l,a,r,s,p,_,g,h,y,f,x,S,E,A,q,P,M,C,O,T,L,k,w,I,D,F,B,z,V,j,U,W;const Q=null!=(r=null==(a=null==(l=Y.productsTemp)?void 0:l[o])?void 0:a[t])?r:c.products.find(e=>parseInt(e.id)===parseInt(t));let K=null==(s=FGSECOMAPP.productsByID)?void 0:s[t];if(!K)return;(null==(p=null==Q?void 0:Q.variants)?void 0:p.length)&&(K=v(m({},K),{variants:K.variants.filter(t=>Q.variants.find(e=>e.id.toString()===t.id.toString()))}));const Z=null!=(g=null==(_=document.querySelector("#bogos_bundle_page_product_variant_item_section"))?void 0:_.innerHTML)?g:'
{{ bogos_variant_title }}
',J=null!=(y=null==(h=document.querySelector("#bogos_bundle_page_product_detail_modal_section"))?void 0:h.innerHTML)?y:'',$=null==i?void 0:i.getAttribute("data-variant-id"),tt=Math.max(1,parseInt(null!=(f=null==i?void 0:i.getAttribute("data-qty"))?f:"1")||1),et=null!=(x=K.variants.find(t=>String(t.id)===String($)))?x:K.variants[0],ot=String(et.id),nt=1===K.variants.length&&X.checkIsDefaultTitle(et.title),it="variant"===b?K.variants.map(t=>{var e,o,n;return FGSECOMAPP.helper.templateHTML.render(Z,{bogos_variant_title:X.checkIsDefaultTitle(t.title)?"":X.safeText(t.title),check_variant_active:String(t.id)===ot?"active":"",bogos_variant_id:t.id,bogos_variant_img:X.safeText(null!=(n=null!=(o=null==(e=t.featured_image)?void 0:e.src)?o:null==K?void 0:K.featured_image)?n:""),bogos_variant_price:t.price/G,bogos_variant_compare_price:t.compare_at_price?t.compare_at_price/G:"",bogos_variant_available:t.available?1:0})}).join(""):N.renderProductOptionWithValue(N.convertProductWithOptionsDefault(FGSECOMAPP.productsDefaultByID[t],N.convertProductWithOptions(null!=(A=null==(E=null==(S=Y.productsTemp)?void 0:S[o])?void 0:E[t])?A:K)),et.id),lt=null!=(P=null==(q=d.extra_info)?void 0:q.product_select)?P:{},at=null!=(C=null==(M=null==i?void 0:i.querySelector(".bogos-bundle-pp-add-btn"))?void 0:M.innerHTML)?C:Y.renderAddProductButtonContent(lt,d.id),rt=Y.appearanceOf(d),st=rt.color,dt="background:".concat(null!=(O=st.add_item_button_color)?O:"#303030",";color:").concat(null!=(T=st.add_item_button_text_color)?T:"#FFFFFF",";"),{thumbnail_gallery_position:ct,show_product_link:ut}=rt.content,bt="left"===ct?"left":"below",pt=null!=(k=null==(L=document.querySelector("#bogos_bundle_pp_product_thumb_section"))?void 0:L.innerHTML)?k:'',_t=(t=>{var e,o,n;const i=t=>"string"==typeof t&&t.startsWith("//")?"https:".concat(t):t,l=(null!=(e=null==t?void 0:t.images)?e:[]).filter(Boolean).map(i);if(X.empty(l)){const e=[null==t?void 0:t.featured_image,...(null!=(o=null==t?void 0:t.variants)?o:[]).map(t=>{var e,o;return null!=(o=null==(e=null==t?void 0:t.featured_image)?void 0:e.src)?o:null==t?void 0:t.thumbnail})].filter(Boolean).map(i);l.push(...new Set(e))}const a=t=>"".concat(t).split("?")[0],r=t=>{const e=i(t);return e?l.findIndex(t=>a(t)===a(e)):-1},s=r(null==t?void 0:t.featured_image),d={};return(null!=(n=null==t?void 0:t.variants)?n:[]).forEach(t=>{var e,o,n;const i=null==(e=null==t?void 0:t.featured_image)?void 0:e.position;let a=Number.isInteger(i)?i-1:-1;(a<0||a>=l.length)&&(a=r(null!=(n=null==(o=null==t?void 0:t.featured_image)?void 0:o.src)?n:null==t?void 0:t.thumbnail)),a<0&&(a=s),a>=0&&(d[t.id]=a)}),{images:l,indexByVariantId:d}})(K);_t.index=null!=(w=_t.indexByVariantId[null==et?void 0:et.id])?w:0;const gt=_t.images.length>1,mt=_t.images.map((t,e)=>FGSECOMAPP.helper.templateHTML.render(pt,{bogos_thumb_index:e,bogos_thumb_img:X.safeText(X.handleResizeProductImage(t,120)),check_thumb_active:e===_t.index?"active":"",bogos_thumb_selected:e===_t.index?"true":"false",bogos_thumb_label:"Image ".concat(e+1)})).join("");u.innerHTML=FGSECOMAPP.helper.templateHTML.render(J,{bogos_gallery_position_class:"bogos-gallery-".concat(bt),bogos_product_thumbs:mt,check_show_carousel:gt?"":"sca-d-none",check_show_img_nav:gt?"":"sca-d-none",check_show_product_link:null==ut||ut?"":"sca-d-none",bogos_product_img:X.safeText(null!=(B=null!=(F=null!=(D=_t.images[_t.index])?D:null==(I=null==et?void 0:et.featured_image)?void 0:I.src)?F:null==K?void 0:K.featured_image)?B:""),bogos_product_title:X.safeText(K.title),bogos_product_price:X.renderPrice(et.price/G),check_show_variant_items:nt?"sca-d-none":"",bogos_variant_items_list:it,bogos_check_disable_add:!1!==(null==et?void 0:et.available)?"":"disabled",bogos_product_description:null!=(z=K.description)?z:"",check_show_description:(null!=(V=K.description)?V:"").trim()?"":"sca-d-none",bogos_variant_id:et.id,bogos_product_id:K.id,bogos_variant_quantity:1,bogos_product_price_data:et.price/G,bogos_product_compare_price_data:et.compare_at_price?et.compare_at_price/G:"",bogos_variant_title:X.checkIsDefaultTitle(et.title)?"":X.safeText(et.title),bogos_product_add_btn:at,bogos_product_add_btn_style:dt,bogos_about_product:X.safeMerchantHTML(R.text(rt,"go_to_product_text","Go to product page","customize.bundle_product_page.go_to_product_text"),!0),bogos_product_url:X.safeText(X.routeLink((null==K?void 0:K.handle)?"/products/".concat(K.handle):e?"/products/".concat(e):"/"))}),u.classList.add("sca-is-visible-fg"),H.dialog.watch(u);const vt=u.querySelector(".bogos-product-detail-modal"),ht=u.querySelector(".bogos-product-add-btn"),yt=null==vt?void 0:vt.querySelector(".bogos-product-quantity-input");yt&&(yt.value=String(tt)),null==(j=null==vt?void 0:vt.querySelector(".bogos-product-modal-close-btn"))||j.addEventListener("click",()=>{u.classList.remove("sca-is-visible-fg")});const ft=vt?((t,e)=>{var o,n;let i=null;const l=o=>{if(X.empty(e.images))return;const n=Math.min(Math.max(o,0),e.images.length-1),l=e.index;e.index=n;const a=t.querySelector(".bogos-product-img");if(a){const t=n===l?0:n>l?1:-1;((t,e,o)=>{var n,l;const a=t.parentElement,r=null==(l=null==(n=window.matchMedia)?void 0:n.call(window,"(prefers-reduced-motion: reduce)"))?void 0:l.matches;if(!a||!o||r)return void(t.src=e);null==i||i();const s=t.cloneNode(!1);s.classList.remove("bogos-product-img"),s.classList.add("bogos-product-img-outgoing"),a.appendChild(s),t.src=e,t.style.transition="none",t.style.transform="translateX(".concat(100*o,"%)"),t.style.opacity="0",t.offsetWidth,t.style.transition="",t.style.transform="translateX(0)",t.style.opacity="1",s.style.transform="translateX(".concat(100*-o,"%)"),s.style.opacity="0";let d=!1;const c=()=>{d||(d=!0,clearTimeout(u),s.remove(),t.style.transition="",t.style.transform="",t.style.opacity="",i===c&&(i=null))},u=setTimeout(c,400);t.addEventListener("transitionend",c,{once:!0}),i=c})(a,e.images[n],t)}t.querySelectorAll(".bogos-product-thumb").forEach(e=>{const o=parseInt(e.getAttribute("data-index"))===n;e.classList.toggle("active",o),e.setAttribute("aria-pressed",o?"true":"false"),o&&(e=>{const o=t.querySelector(".bogos-product-carousel");if(!o||!e)return;const n=o.getBoundingClientRect(),i=e.getBoundingClientRect();if(o.scrollWidth>o.clientWidth+1){const t=i.left-n.left-(n.width-i.width)/2;o.scrollTo({left:o.scrollLeft+t,behavior:"auto"})}else if(o.scrollHeight>o.clientHeight+1){const t=i.top-n.top-(n.height-i.height)/2;o.scrollTo({top:o.scrollTop+t,behavior:"auto"})}})(e)})};t.querySelectorAll(".bogos-product-thumb").forEach(t=>{t.addEventListener("click",()=>l(parseInt(t.getAttribute("data-index"))))}),null==(o=t.querySelector(".bogos-product-img-prev"))||o.addEventListener("click",()=>l(e.index-1)),null==(n=t.querySelector(".bogos-product-img-next"))||n.addEventListener("click",()=>l(e.index+1));const a=t.querySelector(".bogos-product-img-container");if(a){const t=40;let o=0,n=0,i=!1;a.addEventListener("touchstart",t=>{i=1===t.touches.length,i&&(o=t.touches[0].clientX,n=t.touches[0].clientY)},{passive:!0}),a.addEventListener("touchend",a=>{if(!i)return;i=!1;const r=a.changedTouches[0];if(!r)return;const s=r.clientX-o,d=r.clientY-n;Math.abs(s){i=!1},{passive:!0})}return(o,n)=>{var i;const a=null==(i=e.indexByVariantId)?void 0:i[o];if(void 0!==a)return void l(a);const r=t.querySelector(".bogos-product-img");r&&n&&(r.src=n)}})(vt,_t):()=>{};if("variant"===b)null==vt||vt.querySelectorAll(".bogos-variant-item").forEach(t=>{t.addEventListener("click",()=>{var e;null==(e=vt.querySelector(".bogos-variant-item.active"))||e.classList.remove("active"),t.classList.add("active"),ft(t.dataset.variantId,t.dataset.img);const o=vt.querySelector(".bogos-product-price");o&&(o.textContent=X.renderPrice(t.dataset.variantPrice)),ht&&(ht.disabled="0"===t.dataset.checkVariantAvailable,ht.dataset.variantId=t.dataset.variantId,ht.dataset.price=t.dataset.variantPrice,ht.dataset.variantTitle=t.dataset.variantTitle)})});else{const e=null==(W=null==(U=Y.productsTemp)?void 0:U[o])?void 0:W[t];null==vt||vt.querySelectorAll(".bogos-select-option-custom-item").forEach(t=>{t.addEventListener("click",()=>{var o;const n=null==ht?void 0:ht.getAttribute("data-variant-id"),{selectedVariant:i,newOptions:l}=N.handleValidVariantOption(t,n,e,vt);if(!i)return N.handleInvalidVariantOption(e,l,vt),void(ht&&(ht.disabled=!0));const a=!i.available;ht&&(ht.disabled=a,ht.setAttribute("data-variant-id",String(i.id)),ht.setAttribute("data-price",String(i.price)),ht.setAttribute("data-variant-title",X.checkIsDefaultTitle(i.title)?"":i.title));const r=vt.querySelector(".bogos-product-price");r&&(r.textContent=X.renderPrice(i.price)),ft(i.id,null!=(o=null==i?void 0:i.thumbnail)?o:null==K?void 0:K.thumbnail)})})}const xt=()=>{var t,e;let o=0;n.querySelectorAll(".bogos-bundle-pp-item").forEach(t=>{var e;o+=parseInt(null!=(e=t.getAttribute("data-qty"))?e:"0")});const i=(null!=(t=d.discount)?t:[]).filter(t=>!t.type||"base"===t.type),l=(null!=(e=d.discount)?e:[]).find(t=>"unlimited"===t.type),a=i.reduce((t,e)=>{var o;return Math.max(t,null!=(o=e.quantity)?o:0)},0);return l?1/0:Math.max(0,a-o)},St=null==vt?void 0:vt.querySelector(".bogos-product-quantity");if(St&&ht){const t=St.querySelector(".bogos-minus-quantity-btn"),e=St.querySelector(".bogos-plus-quantity-btn"),o=St.querySelector(".bogos-product-quantity-input"),n=()=>{const n=xt();let i=parseInt(o.value)||1;n>0&&i>n&&(i=n,o.value=i),t.disabled=i<=1,e.disabled=i>=n,n<=0&&(ht.disabled=!0),ht.dataset.quantityVariant=String(i)};n(),e.addEventListener("click",()=>{const t=xt(),e=(parseInt(o.value)||1)+1;o.value=Math.min(e,t),n()}),t.addEventListener("click",()=>{o.value=Math.max(1,(parseInt(o.value)||1)-1),n()}),o.addEventListener("change",()=>{const t=parseInt(o.value),e=xt();let i=isNaN(t)||t<1?1:t;e>0&&(i=Math.min(i,e)),o.value=i,n()})}ht&&ht.addEventListener("click",()=>{var e,i,l,a;const r=String(ht.dataset.variantId),s=ht.dataset.price,c=xt(),b=Math.min(parseInt(null!=(e=ht.dataset.quantityVariant)?e:1),c);if(b<=0)return void u.classList.remove("sca-is-visible-fg");let p=n.querySelector('.bogos-bundle-pp-item[data-step-id="'.concat(o,'"][data-product-id="').concat(t,'"][data-variant-id="').concat(r,'"]'));if(!p&&(p=n.querySelector('.bogos-bundle-pp-item[data-step-id="'.concat(o,'"][data-product-id="').concat(t,'"]')),p)){p.dataset.variantId=r,p.dataset.price=s;const t=p.querySelector(".bogos-bundle-pp-select-variant-title"),e=ht.dataset.variantTitle;t&&e&&(t.textContent=e)}if(!p)return void u.classList.remove("sca-is-visible-fg");const _=parseInt(null!=(i=p.dataset.qty)?i:0)+b;p.dataset.qty=String(_);const g=p.querySelector(".bogos-bundle-pp-qty-value");g&&(g.value=_),null==(l=p.querySelector(".bogos-bundle-pp-add-btn"))||l.classList.add("sca-d-none"),null==(a=p.querySelector(".bogos-bundle-pp-qty-control"))||a.classList.remove("sca-d-none"),Y.refreshStates(n,d),u.classList.remove("sca-is-visible-fg")})},_=!!(null==(r=FGSECOMAPP.productsByID)?void 0:r[t]),g=!!(null==(s=FGSECOMAPP.productsDefaultByID)?void 0:s[t]);("variant"===b?_:_&&g)?p():(u.innerHTML='
',u.classList.add("sca-is-visible-fg"),"variant"===b?O.cacheProducts([e],{"sca-bundle-pp-search":"1"},null,{handles:[e],ids:[t]}).then(()=>{p()}):_&&!g?k.queryProductDefault(t).then(()=>{p()}):O.cacheProducts([e],{"sca-bundle-pp-search":"1"},null,{handles:[e],ids:[t]}).then(()=>{k.queryProductDefault(t).then(()=>{p()})}))},renderStepItems:(t,e={},o)=>{var n,i,l,a,r,s,d,c;const u=null!=(n=t.product_style)?n:"text_only",b="vertical"===u,p="horizontal"===u,_="product"===t.display_type,g=b||p,h=b?null!=(l=null==(i=document.querySelector("#bogos_bundle_pp_v_card"))?void 0:i.innerHTML)?l:'
{{ bogos_title }}
{{ bogos_title }}
{{ bogos_variant_title }}
{{ bogos_selected_variant_title }}
{{ bogos_variant_options }}
':p?null!=(r=null==(a=document.querySelector("#bogos_bundle_pp_h_card"))?void 0:a.innerHTML)?r:'
{{ bogos_title }}
{{ bogos_title }}
{{ bogos_variant_title }}
{{ bogos_selected_variant_title }}
{{ bogos_variant_options }}
':null!=(d=null==(s=document.querySelector("#bogos_bundle_pp_text_card"))?void 0:s.innerHTML)?d:'
{{ bogos_title }} {{ bogos_variant_title }}
{{ bogos_selected_variant_title }}
{{ bogos_variant_options }}
',y="bogos-card-".concat(null!=(c=t.card_style)?c:"minimal"),f=Y.renderAddProductButtonContent(e,o);return _?t.products.map(e=>{var o,n,i,l,a,r,s,d,c,u;const b=null==(o=FGSECOMAPP.productsByID)?void 0:o[e.id],p=(null!=(n=e.variants)?n:[]).filter(t=>{var e,o,n,i;const l=null==(e=null==b?void 0:b.variants)?void 0:e.find(e=>e.id===t.id);return null!=(i=null!=(n=null!=(o=null==l?void 0:l.available)?o:null==t?void 0:t.available)?n:null==t?void 0:t.availableForSale)&&i}),_=v(m({},e),{variants:p});if(!p.length)return"";const x=p[0],S=null==(i=null==b?void 0:b.variants)?void 0:i.find(t=>t.id===x.id),E=1===p.length&&X.checkIsDefaultTitle(x.title),A=g?X.handleResizeProductImage(null!=(d=null!=(s=null!=(r=null!=(a=null==(l=null==S?void 0:S.featured_image)?void 0:l.src)?a:null==x?void 0:x.thumbnail)?r:null==b?void 0:b.featured_image)?s:e.thumbnail)?d:"",150):"";return FGSECOMAPP.helper.templateHTML.render(h,{bogos_product_id:e.id,bogos_handle:X.safeText(null!=(c=e.handle)?c:""),bogos_step_id:t.id,bogos_variant_id:x.id,bogos_price:x.price,bogos_available:"1",bogos_title:X.safeText(e.title),bogos_img:X.safeText(A),bogos_hide_variant_title:"sca-d-none",bogos_variant_title:"",bogos_hide_variant_dropdown:E?"bogos-bundle-pp-variant-placeholder":"",bogos_selected_variant_title:E?" ":X.safeText(null!=(u=null==S?void 0:S.title)?u:x.title),bogos_variant_options:Y.renderSelectVariantOptions(_,t.id),bogos_add_btn_content:f,bogos_card_style_class:y})}).join(""):P(t.products,"flatMap")(e=>{var o,n;const i=null==(o=FGSECOMAPP.productsByID)?void 0:o[e.id];return(null!=(n=e.variants)?n:[]).filter(t=>{var e,o,n,l;const a=null==(e=null==i?void 0:i.variants)?void 0:e.find(e=>e.id===t.id);return null==(l=null!=(n=null!=(o=null==a?void 0:a.available)?o:null==t?void 0:t.available)?n:null==t?void 0:t.availableForSale)||l}).map(o=>{var n,l,a,r,s,d,c,u;const b=null==(n=null==i?void 0:i.variants)?void 0:n.find(t=>t.id===o.id),p=X.checkIsDefaultTitle(o.title),_=g?X.handleResizeProductImage(null!=(d=null!=(s=null!=(r=null!=(a=null==(l=null==b?void 0:b.featured_image)?void 0:l.src)?a:null==i?void 0:i.featured_image)?r:null==o?void 0:o.thumbnail)?s:e.thumbnail)?d:"",150):"";return FGSECOMAPP.helper.templateHTML.render(h,{bogos_product_id:e.id,bogos_handle:X.safeText(null!=(c=e.handle)?c:""),bogos_step_id:t.id,bogos_variant_id:o.id,bogos_price:o.price,bogos_available:"1",bogos_title:X.safeText(e.title),bogos_img:X.safeText(_),bogos_hide_variant_title:p?"bogos-bundle-pp-variant-placeholder":"",bogos_variant_title:p?" ":X.safeText(null!=(u=null==b?void 0:b.title)?u:o.title),bogos_hide_variant_dropdown:"sca-d-none",bogos_selected_variant_title:"",bogos_variant_options:"",bogos_add_btn_content:f,bogos_card_style_class:y})})}).join("")},getLayout:t=>{var e,o;return"tabs"===(null==(o=null==(e=null==t?void 0:t.extra_info)?void 0:e.product_select)?void 0:o.layout)?"tabs":"accordion"},renderTabs:t=>{var e,o,n,i,l,a;const r=null!=(o=null==(e=document.querySelector("#bogos_bundle_pp_tab_item"))?void 0:e.innerHTML)?o:'
{{ bogos_step_title }} {{ bogos_step_count_inner }}
',s=null!=(l=(null!=(i=null==(n=t.extra_info)?void 0:n.product_select)?i:{}).quantity_indicator)?l:"none";return(null!=(a=t.steps)?a:[]).map((e,o)=>{var n;let i="";const l=e.has_max?"/".concat(e.max_quantity):"",a='0'.concat(l);return"number_in_dot"===s||"small_number"===s?i=a:"number_in_round_brackets"===s&&(i="(".concat(a,")")),FGSECOMAPP.helper.templateHTML.render(r,{bogos_step_id:e.id,bogos_step_title:X.safeMerchantHTML(J.convertIntegration(null!=(n=e.title)?n:"","bundle_product_page.".concat(t.id,".steps.").concat(e.id,".title")),!0),bogos_tab_active_class:0===o?"bogos-active":"",bogos_step_qty_indicator:s,bogos_step_count_hidden:"sca-d-none",bogos_step_count_inner:i})}).join("")},renderSteps:t=>{var e,o,n,i,l,a;const r=null!=(o=null==(e=document.querySelector("#bogos_bundle_pp_step_container"))?void 0:e.innerHTML)?o:'
{{ bogos_step_title }} {{ bogos_step_count_inner }}
{{ bogos_step_items }}
',s=Y.getLayout(t),d=null!=(i=null==(n=t.extra_info)?void 0:n.product_select)?i:{},c=null!=(l=d.quantity_indicator)?l:"none";return(null!=(a=t.steps)?a:[]).map((e,o)=>{var n,i,l;const a=null!=(n=e.products_per_row)?n:{},u=Q(a);let b="";const p=e.has_max?"/".concat(e.max_quantity):"",_='0'.concat(p);"number_in_dot"===c||"small_number"===c?b=_:"number_in_round_brackets"===c&&(b="(".concat(_,")"));const g=FGSECOMAPP.helper.templateHTML.render(r,{bogos_step_id:e.id,bogos_step_title:X.safeMerchantHTML(J.convertIntegration(null!=(i=e.title)?i:"","bundle_product_page.".concat(t.id,".steps.").concat(e.id,".title")),!0),bogos_step_min:e.min_quantity,bogos_step_max:e.max_quantity,bogos_step_has_max:e.has_max?"1":"0",bogos_step_has_min:e.has_min?"1":"0",bogos_step_style:null!=(l=e.product_style)?l:"horizontal",bogos_step_grid_style:u,bogos_step_qty_indicator:c,bogos_step_count_hidden:"sca-d-none",bogos_step_count_inner:b,bogos_step_items:Y.renderStepItems(e,d,t.id)});return"tabs"===s&&0===o?g.replace('bogos-bundle-pp-step"','bogos-bundle-pp-step bogos-active"'):g}).join("")},appearanceOf:t=>{var e,o;return R.resolve(t,"bundle_product_page",null!=(o=null==(e=FGSECOMAPP.fgAppearance)?void 0:e.bundle_product_page)?o:{},N.widgetStyle)},formatStyleVars:t=>{var e,o;const{active_item_background:n}=null!=(o=null==(e=FGSECOMAPP.fgAppearance.select_variant)?void 0:e.color)?o:{},i=Y.appearanceOf(t).color,l={"--bogos-bpp-default-tab-bg":i.default_tab_background,"--bogos-bpp-default-tab-text":i.default_tab_text,"--bogos-bpp-default-tab-border":i.default_tab_border,"--bogos-bpp-active-tab-bg":i.active_tab_background,"--bogos-bpp-active-tab-text":i.active_tab_text,"--bogos-bpp-active-tab-border":i.active_tab_border,"--bogos-bpp-badge-bg":i.badge_background_color,"--bogos-bpp-badge-text":i.badge_text_color,"--bogos-bpp-size-list-label":i.size_list_label_color,"--bogos-bpp-product-card-bg":i.product_card_background,"--bogos-bpp-product-name":i.product_name_color,"--bogos-bpp-variant-name":i.variant_name_color,"--bogos-bpp-section-name":i.section_name_color,"--bogos-bpp-section-border":i.section_border_color,"--bogos-bpp-quantity":i.quantity_color,"--bogos-bpp-discount-price":i.discount_price_color,"--bogos-bpp-original-price":i.original_price_color,"--bogos-bpp-total-price-text":i.total_price_text_color,"--bogos-bpp-add-item-btn":i.add_item_button_color,"--bogos-bpp-add-item-btn-text":i.add_item_button_text_color,"--bogos-bpp-add-bundle-btn":i.add_bundle_button_color,"--bogos-bpp-add-bundle-btn-text":i.add_bundle_button_text_color,"--bogos-active-variant":n};return Object.entries(l).filter(([,t])=>!X.empty(t)).map(([t,e])=>"".concat(t,":").concat(e)).join(";")},getAddBundleButtonLabel:t=>X.safeMerchantHTML(R.text(Y.appearanceOf(t),"cart_button_text","Add bundle to cart","customize.bundle_product_page.cart_button_text"),!0),getAddBundleCountdownLabel:(t,e,o,n)=>{var i;const l=Y.appearanceOf(n),a=l.content,r=Y.getAddBundleButtonLabel(n);if(!a.show_countdown_on_button||e)return r;const s=[...o].sort((t,e)=>{var o,n;return(null!=(o=t.quantity)?o:0)-(null!=(n=e.quantity)?n:0)}).find(e=>{var o;return(null!=(o=e.quantity)?o:0)>t});if(!s)return r;const d=Math.max(0,(null!=(i=s.quantity)?i:0)-t);if(d<=0)return r;const c=R.text(l,"countdown_message","Added {{amount_added}} items, {{amount_left}} to go","customize.bundle_product_page.countdown_message");return FGSECOMAPP.helper.templateHTML.render(X.safeMerchantHTML(c,!0),{amount_added:t,amount_left:d})},renderBundles:t=>{var e,o,n,i;const l=null!=(o=null==(e=document.querySelector("#bogos_bundle_pp_section_frame"))?void 0:e.innerHTML)?o:'
{{ bogos_bundle_pp_sizes_title }}
{{ bogos_bundle_pp_sizes }}
{{ bogos_bundle_pp_tabs }}
{{ bogos_bundle_pp_steps }}
',a=null!=(i=null==(n=document.querySelector("#bogos_bundle_pp_footer"))?void 0:n.innerHTML)?i:'
{{ bogos_total_label }}
{{ bogos_total_price_init }}
';return(null!=t?t:FGSECOMAPP.current_bundles_product_page).map(t=>{var e,o,n,i,r,s;const d=Y.appearanceOf(t),c=Y.formatStyleVars(t),u=FGSECOMAPP.helper.templateHTML.render(a,{bogos_total_label:X.safeMerchantHTML(R.text(d,"total_price_text","Total bundle price","customize.bundle_product_page.total_price_text"),!0)+":",bogos_total_price_init:X.renderPrice(0),bogos_add_btn_text:Y.getAddBundleButtonLabel(t)}),b=Y.getLayout(t),p=null!=(o=null==(e=t.extra_info)?void 0:e.pack_select)?o:{},_=null!=(n=p.products_per_row)?n:{},g=null!=(i=p.text_alignment)?i:"left",m=null!=(r={left:"flex-start",center:"center",right:"flex-end"}[g])?r:"flex-start",v=[Q(_),"--bogos-text-align:".concat(g),"--bogos-size-align:".concat(m)].filter(Boolean).join(";"),h=X.safeMerchantHTML(J.convertIntegration(null!=(s=p.title)?s:"","bundle_product_page.".concat(t.id,".pack_select_title")),!0);return FGSECOMAPP.helper.templateHTML.render(l,{bogos_bundle_pp_id:t.id,bogos_bundle_pp_layout:b,bogos_bundle_pp_style:c,bogos_bundle_pp_sizes:Y.renderSizes(t),bogos_bundle_pp_sizes_style:v,bogos_bundle_pp_sizes_title:h?'
'.concat(h,"
"):"",bogos_bundle_pp_tabs:"tabs"===b?Y.renderTabs(t):"",bogos_bundle_pp_steps:Y.renderSteps(t),bogos_bundle_pp_footer:u})}).join("")},render:()=>{var t,e,o,n;const{product_form_query:i}=null!=(t=FGSECOMAPP.QUERY_SELECTOR)?t:{};let l=document.querySelectorAll(null==(e=null==i?void 0:i.bundle_product_page)?void 0:e.join(","));const a=!(null==(o=FGSECOMAPP.current_bundles_product_page)?void 0:o.length);let r=[];if(a||console.info("BOGOS track: bundle product page render"),l.forEach(t=>{const e=Y.filterWithBlocks(t),o=!e.length,n=t.querySelector("#bogos-bundle-page-preview-mode");n&&o?N.renderEmpty(n):o||(t.innerHTML=Y.renderBundles(e),r.push(...e))}),a)return;if(!l.length){const t=Y.renderBundles(),e=[...null==i?void 0:i.integration,...null==i?void 0:i.default].filter(Boolean).join(","),o=document.querySelector(e),n=document.createElement("div");n.id="bogos-bundle-product-page-view",n.innerHTML=t,null==o||o.appendChild(n),r.push(...FGSECOMAPP.current_bundles_product_page)}const{bundle_product_page:s,default:d}=B.BUNDLE_TYPE;X.empty(r)||(r=Object.values(Object.assign({},...r.map(t=>({[t.id]:t})))),w.sessionViews(r,s,d).then()),(null!=(n=FGSECOMAPP.current_bundles_product_page)?n:[]).forEach(t=>{const e=document.querySelector('.bogos-bundle-pp-widget[data-bundle-pp-id="'.concat(t.id,'"]'));e&&Y.refreshStates(e,t)})},resetSelection:(t,e)=>{t&&(t.querySelectorAll(".bogos-bundle-pp-item").forEach(t=>{t.setAttribute("data-qty","0");const e=t.querySelector(".bogos-bundle-pp-qty-value");e&&(e.value="0")}),Y.refreshStates(t,e))},refreshStates:(t,e)=>{var o,n,i,l,a;if(!e)return;H.init(t);const r={};let s=0,d=0;t.querySelectorAll(".bogos-bundle-pp-item").forEach(t=>{var e,o,n;const i=parseInt(null!=(e=t.getAttribute("data-qty"))?e:"0"),l=t.getAttribute("data-step-id"),a=parseFloat(null!=(o=t.getAttribute("data-price"))?o:"0");i>0&&(r[l]=(null!=(n=r[l])?n:0)+i,s+=i,d+=a*i);const c=t.querySelector(".bogos-bundle-pp-add-btn"),u=t.querySelector(".bogos-bundle-pp-qty-control");c&&c.classList.toggle("sca-d-none",i>0),u&&u.classList.toggle("sca-d-none",0===i)}),t.querySelectorAll(".bogos-bundle-pp-step").forEach(e=>{var o,n;const i=e.getAttribute("data-step-id"),l="1"===e.getAttribute("data-step-has-max"),a=parseInt(null!=(o=e.getAttribute("data-step-max"))?o:"0"),s=null!=(n=r[i])?n:0,d=e.querySelector(".bogos-bundle-pp-step-qty-current");d&&(d.textContent=s),e.setAttribute("data-step-quantity",s);const c=e.querySelector(".bogos-bundle-pp-step-count");if(c&&d&&c.classList.toggle("sca-d-none",0===s),l&&a>0){const t=s>=a;e.querySelectorAll(".bogos-bundle-pp-plus").forEach(e=>{e.disabled=t,e.dataset.disabledByStep=t?"1":"",t?e.classList.add("bogos-bundle-pp-max-reached"):e.classList.remove("bogos-bundle-pp-max-reached")}),e.querySelectorAll(".bogos-bundle-pp-add-btn").forEach(e=>{e.disabled=t,e.dataset.disabledByStep=t?"1":""})}else e.querySelectorAll(".bogos-bundle-pp-plus, .bogos-bundle-pp-add-btn").forEach(t=>{t.dataset.disabledByStep=""});const u=t.querySelector('.bogos-bundle-pp-tab-item[data-tab-step-id="'.concat(i,'"]'));if(u){const t=u.querySelector(".bogos-bundle-pp-tab-count"),e=u.querySelector(".bogos-bundle-pp-tab-qty-current");e&&(e.textContent=s),t&&e&&t.classList.toggle("sca-d-none",0===s)}});let c=!0;t.querySelectorAll(".bogos-bundle-pp-step").forEach(t=>{var e,o;const n="1"===t.getAttribute("data-step-has-min"),i=parseInt(null!=(e=t.getAttribute("data-step-min"))?e:"0"),l=parseInt(null!=(o=t.getAttribute("data-step-quantity"))?o:"0");n&&l!t.type||"base"===t.type),b=(null!=(n=e.discount)?n:[]).find(t=>"unlimited"===t.type),p=u.reduce((t,e)=>{var o;return Math.max(t,null!=(o=e.quantity)?o:0)},0);let _=null;if(c){const t=u.find(t=>t.quantity===s);_=null!=(i=null!=t?t:!t&&s>p&&s>0?b:null)?i:null}const g=!b&&p>0&&s>=p;t.querySelectorAll(".bogos-bundle-pp-plus, .bogos-bundle-pp-add-btn").forEach(t=>{g?(t.disabled=!0,t.classList.add("bogos-bundle-pp-max-reached")):"1"!==t.dataset.disabledByStep&&(t.classList.remove("bogos-bundle-pp-max-reached"),t.disabled=!1)}),t.querySelectorAll(".bogos-bundle-pp-size-item").forEach(t=>{const e=parseInt(t.getAttribute("data-size-id"));t.classList.toggle("bogos-active",(null==_?void 0:_.id)===e)});let m=d;if(_){const t=_.discount;switch(null==t?void 0:t.type){case B.DISCOUNT_TYPE.percentage:m=d*(1-t.value/100);break;case B.DISCOUNT_TYPE.fixed_amount:m=Math.max(0,d-t.value);break;case B.DISCOUNT_TYPE.fixed_price:m=t.value}}const v=null!=(a=null==(l=FGSECOMAPP.variables.Shopify)?void 0:l.fg_decimal)?a:2;d=parseFloat(d.toFixed(v)),m=parseFloat(m.toFixed(v));const h=t.querySelector(".bogos-bundle-pp-total-original"),y=t.querySelector(".bogos-bundle-pp-total-discount");if(y&&(y.innerHTML=X.renderPrice(m)),h){const t=_&&d>m;h.innerHTML=t?X.renderPrice(d):""}const f=t.querySelector(".bogos-bundle-pp-btn-add");f&&(f.disabled=!(_&&c),f.classList.contains("bogos-bundles-adding")||(f.innerHTML=Y.getAddBundleCountdownLabel(s,_,u,e)))},renderEventQuery:()=>{document.querySelectorAll(".bogos-bundle-pp-widget").forEach(t=>{var e;const o=t.getAttribute("data-bundle-pp-id"),n=null==(e=FGSECOMAPP.current_bundles_product_page)?void 0:e.find(t=>t.id.toString()===o);if(!n)return;const i=t.querySelector(".bogos-bundle-pp-footer");if(i){const e=window.matchMedia("(max-width: 767px)");let o=null;const n=()=>{if(!e.matches)return t.classList.remove("bogos-footer-pinned"),void t.style.removeProperty("--bogos-footer-h");if(!t.classList.contains("bogos-footer-pinned")){const e=i.offsetHeight,o=parseFloat(getComputedStyle(t).rowGap)||0;e&&t.style.setProperty("--bogos-footer-h",e+o+"px")}const o=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,l=o.bottom>0&&o.topn;t.classList.toggle("bogos-footer-pinned",l)},l=()=>{o||(o=requestAnimationFrame(()=>{o=null,n()}))};window.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",n),n()}const l=t.querySelector(".bogos-bundle-pp-tabs-nav"),a=t.querySelector(".bogos-bundle-pp-tabs-wrap");if(l&&a){const t=()=>{const{scrollLeft:t,scrollWidth:e,clientWidth:o}=l,n=e-o>1;a.classList.toggle("bogos-no-overflow",!n),a.classList.toggle("bogos-scroll-start",t<=1),a.classList.toggle("bogos-scroll-end",t+o>=e-1)};l.addEventListener("scroll",t,{passive:!0}),"undefined"!=typeof ResizeObserver?new ResizeObserver(t).observe(l):window.addEventListener("resize",t),t()}t.addEventListener("click",e=>h(null,null,function*(){var o,i,l,a,r,s,d,c,u,b,p,_,g,m;const v=e.target;if(v.closest(".bogos-bundle-pp-item-name")){const e=v.closest(".bogos-bundle-pp-item");if(!e)return;return void Y.openProductDetailModal(e.dataset.productId,e.dataset.productHandle,e.dataset.stepId,t,e)}if(v.closest(".bogos-bundle-pp-tab-item")){const e=v.closest(".bogos-bundle-pp-tab-item"),o=e.getAttribute("data-tab-step-id");if(!o)return;return t.querySelectorAll(".bogos-bundle-pp-tab-item").forEach(t=>{t.classList.toggle("bogos-active",t===e)}),t.querySelectorAll(".bogos-bundle-pp-step").forEach(t=>{t.classList.toggle("bogos-active",t.getAttribute("data-step-id")===o)}),void e.scrollIntoView({inline:"center",block:"nearest",behavior:"smooth"})}if(v.closest(".bogos-bundle-pp-step-header")){if("tabs"===t.getAttribute("data-layout"))return;const e=v.closest(".bogos-bundle-pp-step");if(e){const t=e.querySelector(".bogos-bundle-pp-step-items"),o=!e.classList.contains("bogos-bundle-pp-step-collapsed");t&&(o?(t.style.maxHeight=t.scrollHeight+"px",requestAnimationFrame(()=>{t.style.maxHeight="0px"})):t.style.maxHeight=t.scrollHeight+"px"),e.classList.toggle("bogos-bundle-pp-step-collapsed")}return}if(v.closest(".bogos-bundle-pp-add-btn")){const e=v.matches(".bogos-bundle-pp-add-btn");if(null==e?void 0:e.disabled)return;const o=v.closest(".bogos-bundle-pp-item");if(!o)return;o.setAttribute("data-qty","1");const i=o.querySelector(".bogos-bundle-pp-qty-value");i&&(i.value="1"),Y.refreshStates(t,n)}if(v.matches(".bogos-bundle-pp-plus")&&!v.disabled){const e=v.closest(".bogos-bundle-pp-item");if(!e)return;const i=parseInt(null!=(o=e.getAttribute("data-qty"))?o:"0")+1;e.setAttribute("data-qty",i),e.querySelector(".bogos-bundle-pp-qty-value").value=i,Y.refreshStates(t,n)}if(v.matches(".bogos-bundle-pp-minus")){const e=v.closest(".bogos-bundle-pp-item");if(!e)return;const o=parseInt(null!=(i=e.getAttribute("data-qty"))?i:"0");if(o<=0)return;const l=o-1;e.setAttribute("data-qty",l),e.querySelector(".bogos-bundle-pp-qty-value").value=l,Y.refreshStates(t,n)}if(v.closest(".bogos-bundle-pp-select-variant-title-contain")){const t=v.closest(".bogos-bundle-pp-select-variant-dropdown");if(!t)return;const{type:e="variant"}=null!=(a=null==(l=FGSECOMAPP.fgAppearance)?void 0:l.select_variant)?a:{};if("variant"!==e&&!t.querySelector(".bogos-select-option-name-container")){const e=t.querySelector(".bogos-bundle-pp-select-variant-options"),o=v.closest(".bogos-bundle-pp-item"),n=null==o?void 0:o.dataset.productId,i=null==o?void 0:o.dataset.stepId,l=null==(s=null==(r=Y.productsTemp)?void 0:r[i])?void 0:s[n];if(e&&l){(null==(d=FGSECOMAPP.productsDefaultByID)?void 0:d[n])||(yield k.queryProductDefault(n));const t=N.convertProductWithOptionsDefault(FGSECOMAPP.productsDefaultByID[n],N.convertProductWithOptions(l));e.innerHTML=N.renderProductOptionWithValue(t,o.dataset.variantId)}}t.classList.toggle("opened")}if(v.closest(".bogos-bundle-pp-select-variant-option")){const e=v.closest(".bogos-bundle-pp-select-variant-option"),o=v.closest(".bogos-bundle-pp-select-variant-dropdown"),i=v.closest(".bogos-bundle-pp-item");if(!e||!i)return;const l=e.getAttribute("data-variant-id"),a=parseFloat(null!=(c=e.getAttribute("data-price"))?c:"0"),r=null!=(u=e.getAttribute("data-img"))?u:"",s="1"===e.getAttribute("data-available"),d=parseInt(null!=(b=i.getAttribute("data-qty"))?b:"0");i.setAttribute("data-variant-id",l),i.setAttribute("data-price",a),i.setAttribute("data-available",s?"1":"0"),i.setAttribute("data-qty",d);const p=i.querySelector(".bogos-bundle-pp-qty-value");p&&(p.value=d);const _=i.querySelector(".bogos-bundle-pp-item-img");_&&r&&_.setAttribute("src",r);const g=i.querySelector(".bogos-bundle-pp-product-price");g&&(g.innerHTML=X.renderPrice(a));const m=i.querySelector(".bogos-bundle-pp-select-variant-title");m&&(m.textContent=e.textContent.trim()),o&&o.classList.remove("opened"),Y.refreshStates(t,n)}if(v.closest(".bogos-select-option-custom-item")){const e=v.closest(".bogos-select-option-custom-item"),o=v.closest(".bogos-bundle-pp-item"),i=v.closest(".bogos-bundle-pp-select-variant-dropdown");if(!e||!o)return;const l=o.dataset.productId,a=null==(_=null==(p=Y.productsTemp)?void 0:p[o.dataset.stepId])?void 0:_[l],r=o.dataset.variantId,{selectedVariant:s,newOptions:d}=N.handleValidVariantOption(e,r,a,i);if(!s)return void N.handleInvalidVariantOption(a,d,i);o.dataset.variantId=s.id,o.dataset.price=s.price,o.dataset.available=!1!==s.available?"1":"0";const c=o.querySelector(".bogos-bundle-pp-item-img");c&&(c.src=null!=(m=null!=(g=null==s?void 0:s.thumbnail)?g:null==a?void 0:a.thumbnail)?m:"");const u=o.querySelector(".bogos-bundle-pp-select-variant-title");return u&&(u.textContent=X.checkIsDefaultTitle(s.title)?"":s.title),i&&i.classList.remove("opened"),void Y.refreshStates(t,n)}v.closest(".bogos-bundle-pp-select-variant-dropdown")||t.querySelectorAll(".bogos-bundle-pp-select-variant-dropdown.opened").forEach(t=>t.classList.remove("opened"))})),t.addEventListener("change",e=>{const o=e.target;if(!o.classList.contains("bogos-bundle-pp-qty-value"))return;const i=o.closest(".bogos-bundle-pp-item");if(!i)return;const l=Math.max(0,o.value||0);o.value=l,i.setAttribute("data-qty",l),Y.refreshStates(t,n)});const r=document.querySelector("#bogos-main-popup-product-detail-container");r&&!r._bundlePPCloseListened&&(r._bundlePPCloseListened=!0,r.addEventListener("click",t=>{t.target===r&&r.classList.remove("sca-is-visible-fg")}));const s=t.querySelector(".bogos-bundle-pp-btn-add");s&&s.addEventListener("click",function(){return h(this,null,function*(){var e,o,i,l,a,r,s,d;this.disabled=!0,this.classList.add("bogos-bundles-adding"),H.status.busy(this);const c=[];t.querySelectorAll(".bogos-bundle-pp-item").forEach(t=>{var e,o;const n=parseInt(null!=(e=t.getAttribute("data-qty"))?e:"0");if(n<=0)return;const i=parseFloat(null!=(o=t.getAttribute("data-price"))?o:"0"),l=t.getAttribute("data-step-id"),a=null!=l&&""!==l?Number(l):null;c.push({i:String(t.getAttribute("data-variant-id")),q:n,p:i,s_i:a})});const u=X.getIntShopifyId(null==(e=n.extra_info)?void 0:e.product_bundle_variant_id);if(!u)return console.warn("BOGOS track: bundle product page - missing product_bundle_id variant"),this.disabled=!1,this.classList.remove("bogos-bundles-adding"),void H.status.idle(this);const{currency:b}=null!=(o=FGSECOMAPP.variables.Shopify)?o:{},p=parseFloat(null==b?void 0:b.rate)||1,_="BPP_".concat(n.id,"_").concat(Math.random().toString(36).substring(8));let g=null;try{const e=yield L.add_items_trigger([{id:u,quantity:1}],{_bogos_trigger_id:String(n.id),_bogos_trigger:_,_bogos_trigger_type:B.BUNDLE_TYPE.bundle_product_page,_bogos_bundle_config:JSON.stringify(c),_bogos_bundle_currency_rate:String(p)},B.BUNDLE_TYPE.bundle_product_page);if(null==(l=null==(i=this.parentElement)?void 0:i.querySelector(":scope > .bogos-bundle-error"))||l.remove(),e.ok){yield J.renderCart({item_count:1}),yield null==(a=L.dispatch_add_event)?void 0:a.call(L,e,[{id:u,quantity:1}]);const{bundle_product_page:o,default:i}=B.BUNDLE_TYPE;return w.addToCart([{id:n.id}],o,i).then(),document.dispatchEvent(new CustomEvent(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_BUNDLE_ADDED,{detail:{items:c}})),this.classList.remove("bogos-bundles-adding"),H.status.done(this),void Y.resetSelection(t,n)}{const t=yield e.json(),o=document.createElement("div");o.classList.add("bogos-bundle-error"),o.textContent=null!=(s=null!=(r=null==t?void 0:t.description)?r:null==t?void 0:t.message)?s:"Something went wrong!",null==(d=this.parentElement)||d.insertBefore(o,this),g=o.textContent}}catch(m){console.error("BOGOS track: bundle product page add failed",m)}this.disabled=!1,this.classList.remove("bogos-bundles-adding"),null===g?H.status.idle(this):H.status.done(this,g)})})})},init:t=>h(null,null,function*(){try{yield Y.filter(),Y.render(),Y.renderEventQuery()}catch(t){console.warn("BOGOS track: bundle product page init failed",t)}})},W={productsTemp:{},getTemplate:(t,e)=>{var o,n;return null!=(n=null==(o=document.querySelector(t))?void 0:o.innerHTML)?n:e},renderSelectVariantOptions:t=>{var e,o;const{type:n="variant"}=null!=(o=null==(e=FGSECOMAPP.fgAppearance)?void 0:e.select_variant)?o:{};return"variant"!==n?(W.productsTemp[t.id]=t,k.queryProductDefault(t.id).then(),'
'):Y.renderSelectVariantOptions(t)},defByCurrentProduct:t=>{var e;const{current_product:o}=null!=(e=FGSECOMAPP.variables.Shopify)?e:{};if(!(null==o?void 0:o.id))return[];const n=String(o.id);return t.filter(t=>{var e,o,i,l;if(String(null!=(o=X.getIntShopifyId(null==(e=t.extra_info)?void 0:e.product_bundle_id))?o:"")===n)return!1;const a=null==(i=t.products)?void 0:i.find(t=>t.type===B.NARROW_TYPE.product);return(null!=(l=null==a?void 0:a.value)?l:[]).some(t=>String(t.id)===n)})},filterWithBlocks:t=>{var e,o,n;const i=(null!=(e=FGSECOMAPP.bundles)?e:[]).filter(t=>{var e;return t.type===B.BUNDLE_TYPE.bundle_product_page&&!1!==(null==(e=t.extra_info)?void 0:e.show_widget_on_child_products)});if(!i.length)return[];if(t){const e=Number(t.getAttribute("data-offer-id"));return e?i.filter(t=>String(t.id)===String(e)):W.defByCurrentProduct(i)}const{product_form_query:l}=null!=(o=FGSECOMAPP.QUERY_SELECTOR)?o:{},a=document.querySelectorAll(null==(n=null==l?void 0:l.bundle_product_page_widget)?void 0:n.join(","));if(!a.length)return W.defByCurrentProduct(i);const r=W.defByCurrentProduct(i),s={};return a.forEach(t=>{const e=Number(t.getAttribute("data-offer-id"));e?i.filter(t=>String(t.id)===String(e)).forEach(t=>s[t.id]=t):r.forEach(t=>s[t.id]=t)}),Object.values(s)},filter:()=>h(null,null,function*(){const t=W.filterWithBlocks();if(FGSECOMAPP.current_bundles_child_widget=t,!t.length)return;const e=[],o=[],n=new Set;t.forEach(t=>{var i,l,a,r,s,d;null==(a=null==(l=null==(i=t.products)?void 0:i.find(t=>t.type===B.NARROW_TYPE.product))?void 0:l.value)||a.forEach(t=>{t.handle&&e.push(t.handle),t.id&&o.push(t.id)});const c=(null!=(s=null==(r=t.extra_info)?void 0:r.widget_redirect_link)?s:"").trim(),u=X.getIntShopifyId(null==(d=t.extra_info)?void 0:d.product_bundle_id);!c&&u&&n.add(u)}),yield Promise.all([e.length?O.cacheProducts(e,{"sca-bpp-child-search":"1"},()=>{},{handles:e,ids:o}):Promise.resolve(),...Array.from(n).map(t=>k.queryProductDefault(t))])}),styleVarsOf:t=>{var e,o;const n=null!=(e=t.content)?e:{},i=null!=(o=t.color)?o:{};return{"--bogos-per-desktop":n.child_products_per_row_desktop,"--bogos-per-mobile":n.child_products_per_row_mobile,"--bogos-bg":i.child_widget_background_color,"--bogos-border":i.child_widget_border_color,"--bogos-title":i.child_widget_title_color,"--bogos-tag-bg":i.child_label_background_color,"--bogos-tag-text":i.child_label_text_color,"--bogos-product-name":i.child_product_name_color,"--bogos-variant-name":i.child_variant_name_color,"--bogos-bpp-variant-name":i.child_variant_name_color,"--bogos-redirect-text":i.child_redirect_button_text_color}},applyCardVars:t=>{t.querySelectorAll(".bogos-bpp-child-widget-card[data-bundle-id]").forEach(t=>{var e;const o=(null!=(e=FGSECOMAPP.bundles)?e:[]).find(e=>String(e.id)===t.getAttribute("data-bundle-id")),n=Y.appearanceOf(o);n.custom&&R.setVars(t,W.styleVarsOf(n))})},formatStyleVars:t=>{var e,o;const{active_item_background:n}=null!=(o=null==(e=FGSECOMAPP.fgAppearance.select_variant)?void 0:e.color)?o:{},i=v(m({},W.styleVarsOf(t)),{"--bogos-active-variant":n});return Object.entries(i).filter(([,t])=>null!=t&&""!==t).map(([t,e])=>"".concat(t,":").concat(e)).join(";")},renderProductCell:(t,e)=>{var o,n,i,l,a,r,s,d,c,u,b,p,_,g,h,y,f,x,S;const E=!1!==(null!=(o=e.content)?o:{}).child_show_product_variant_name,A=null==(n=FGSECOMAPP.productsByID)?void 0:n[t.id],q=(null!=(i=t.variants)?i:[]).filter(t=>{var e,o,n,i;const l=null==(e=null==A?void 0:A.variants)?void 0:e.find(e=>String(e.id)===String(t.id));return null==(i=null!=(n=null!=(o=null==l?void 0:l.available)?o:null==t?void 0:t.available)?n:null==t?void 0:t.availableForSale)||i});if(!q.length)return"";const P=q[0],M=null==(l=null==A?void 0:A.variants)?void 0:l.find(t=>String(t.id)===String(P.id)),C=null!=(d=null!=(s=null!=(r=null==(a=null==M?void 0:M.featured_image)?void 0:a.src)?r:P.thumbnail)?s:t.thumbnail)?d:"",O=null!=(u=null!=(c=null==M?void 0:M.title)?c:P.title)?u:"",T=null!=(p=null!=(b=P.price)?b:null==M?void 0:M.price)?p:0,L=null==(h=null!=(g=null!=(_=null==M?void 0:M.available)?_:null==P?void 0:P.available)?g:null==P?void 0:P.availableForSale)||h,k=q.length<=1&&(!O||(null!=(f=null==(y=X.checkIsDefaultTitle)?void 0:y.call(X,O))?f:"Default Title"===O)),w=v(m({},t),{variants:q}),I=!k&&q.length>1?W.renderSelectVariantOptions(w):"";let D="";if(E&&!k)if(q.length>1){const t=W.getTemplate("#bogos_bpp_child_widget_variant_dropdown",'
{{ bogos_variant_title }}
{{ bogos_variant_options }}
');D=FGSECOMAPP.helper.templateHTML.render(t,{bogos_variant_title:X.safeText(O),bogos_variant_options:I})}else D='
'.concat(X.safeText(O),"
");const F=E?'
'.concat(X.safeText(null!=(x=t.title)?x:""),"
").concat(D):"",G=W.getTemplate("#bogos_bpp_child_widget_cell",'
{{ bogos_product_name_block }}
');return FGSECOMAPP.helper.templateHTML.render(G,{bogos_product_id:t.id,bogos_variant_id:null!=(S=P.id)?S:"",bogos_variant_price:T,bogos_variant_available:L?"1":"0",bogos_product_image:X.safeText(C),bogos_product_name_block:F})},renderBundleCard:(t,e)=>{var o,n,i,l,a,r,s,d,c,u,b,p,_,g,h,y;const f=null!=(o=e.content)?o:{},x=null==(n=t.products)?void 0:n.find(t=>t.type===B.NARROW_TYPE.product),S=N.handleTransformProductData(null!=(i=null==x?void 0:x.value)?i:[]),E=(null!=(a=null==(l=t.extra_info)?void 0:l.widget_redirect_link)?a:"").trim(),A=X.getIntShopifyId(null==(r=t.extra_info)?void 0:r.product_bundle_id),q=A?null==(d=null==(s=FGSECOMAPP.productsDefaultByID)?void 0:s[A])?void 0:d.handle:"",P=(null!=(u=null==(c=t.extra_info)?void 0:c.product_bundle_handle)?u:"").trim(),M=q||P,C=E||(M?"/products/".concat(M):""),O=R.text(e,"child_redirect_button_label","Go to bundle","customize.bundle_product_page.child_redirect_button_label"),T=!1!==f.child_show_discount_label,L=Y.sortSizes(null!=(b=t.discount)?b:[]),k=L.filter(t=>"unlimited"!==t.type),w=k.length?Math.max(...k.map(t=>{var e;return Number(null!=(e=t.quantity)?e:0)})):0,I=T?L.map(t=>{var e,o;const n=[null!=(e=t.size_label)?e:"",null!=(o=t.discount_label)?o:""].filter(t=>t&&t.trim()).join(" ");if(!n)return"";const i="unlimited"===t.type?v(m({},t),{quantity:"".concat(w,"+")}):t,l=Y.formatSizeLabel(X.safeMerchantHTML(n,!0),i);return l?''.concat(l,""):""}).join(""):"",D=I?'
'.concat(I,"
"):"",F=S.map(o=>W.renderProductCell(o,e,t.id)).filter(Boolean).join(""),G=W.getTemplate("#bogos_bpp_child_widget_redirect",' {{ bogos_child_redirect_label }} '),H=C?FGSECOMAPP.helper.templateHTML.render(G,{bogos_child_redirect_url:X.safeLink(C),bogos_child_redirect_label:X.safeMerchantHTML(O,!0)}):"",z=W.getTemplate("#bogos_bpp_child_widget_card",'
{{ bogos_bundle_title }}
{{ bogos_child_redirect }}
{{ bogos_child_tags }}
');return FGSECOMAPP.helper.templateHTML.render(z,{bogos_bundle_id:t.id,bogos_bundle_title:null!=(h=X.safeText(null==(_=null==(p=FGSECOMAPP.productsDefaultByID)?void 0:p[A])?void 0:_.title))?h:X.safeMerchantHTML(null!=(g=t.sub_title)?g:"",!0),bogos_child_redirect:H,bogos_child_tags:D,bogos_child_products:F,bogos_child_style:null!=(y=f.child_widget_style)?y:"filled_background"})},renderAll:t=>{var e;const o=null!=(e=null!=t?t:FGSECOMAPP.current_bundles_child_widget)?e:[];if(!o.length)return"";const n=Y.appearanceOf(1===o.length?o[0]:null),i=W.formatStyleVars(n),l=o.map(t=>W.renderBundleCard(t,Y.appearanceOf(t))).join(""),a=W.getTemplate("#bogos_bpp_child_widget_wrap",'
{{ bogos_child_cards }}
');return FGSECOMAPP.helper.templateHTML.render(a,{bogos_child_style_vars:i,bogos_child_cards:l})},renderEventQuery:t=>{W.applyCardVars(t),H.init(t),t.querySelectorAll(".bogos-bpp-child-widget-card").forEach(t=>{const e=t.querySelector(".bogos-bpp-child-widget-track"),o=t.querySelector(".bogos-bpp-child-widget-prev"),n=t.querySelector(".bogos-bpp-child-widget-next");if(!e||!o||!n)return;let i=1,l=0,a=0,r=0;const s=()=>{e.querySelectorAll(".bogos-bpp-child-widget-spacer").forEach(t=>t.remove());const t=e.querySelectorAll(".bogos-bpp-child-widget-cell"),o=t.length;if(0===o)return i=1,l=0,void(a=0);const n=parseFloat(getComputedStyle(e).columnGap)||8,r=t[0].getBoundingClientRect().width;l=r+n,i=Math.max(1,Math.round((e.clientWidth+n)/l)),a=Math.ceil(o/i);const s=o%i;if(s>0&&a>1){const t=i-s;for(let o=0;o{if(a<=1||l<=0)return o.hidden=!0,void(n.hidden=!0);r=Math.round(e.scrollLeft/(i*l)),r<0&&(r=0),r>a-1&&(r=a-1),o.hidden=r<=0,n.hidden=r>=a-1},c=t=>{a<=1||l<=0||(r=Math.max(0,Math.min(a-1,t)),e.scrollTo({left:r*i*l,behavior:"smooth"}))};o.addEventListener("click",()=>c(r-1)),n.addEventListener("click",()=>c(r+1)),e.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",()=>{s(),d()}),s(),d()});const e=t=>{const e=t.querySelector(".bogos-bundle-pp-select-variant-title-contain"),o=t.querySelector(".bogos-bundle-pp-select-variant-options");if(!e||!o)return;const n=e.getBoundingClientRect();o.style.position="fixed",o.style.top="".concat(n.bottom+4,"px"),o.style.left="".concat(n.left,"px"),o.style.zIndex="9999"},o=t=>{(t=>{const e=t.querySelector(".bogos-bundle-pp-select-variant-options");e&&(e.style.position="",e.style.top="",e.style.left="",e.style.zIndex="")})(t),t.classList.remove("opened")},n=()=>{t.querySelectorAll(".bogos-bundle-pp-select-variant-dropdown.opened").forEach(o)};t.addEventListener("click",i=>h(null,null,function*(){var l,a,r,s,d,c,u,b,p;const _=i.target,g=_.closest(".bogos-bundle-pp-select-variant-title-contain");if(g&&t.contains(g)){const t=g.closest(".bogos-bundle-pp-select-variant-dropdown");if(!t)return;const o=t.classList.contains("opened");if(n(),o)return;const{type:i="variant"}=null!=(a=null==(l=FGSECOMAPP.fgAppearance)?void 0:l.select_variant)?a:{};if("variant"!==i&&!t.querySelector(".bogos-select-option-name-container")){const e=_.closest(".bogos-bpp-child-widget-cell"),o=null==e?void 0:e.dataset.productId,n=null==(r=W.productsTemp)?void 0:r[o],i=t.querySelector(".bogos-bundle-pp-select-variant-options");if(n&&i){(null==(s=FGSECOMAPP.productsDefaultByID)?void 0:s[o])||(yield k.queryProductDefault(o));const t=N.convertProductWithOptionsDefault(FGSECOMAPP.productsDefaultByID[o],N.convertProductWithOptions(n));i.innerHTML=N.renderProductOptionWithValue(t,e.dataset.variantId)}}return t.classList.add("opened"),void e(t)}const m=_.closest(".bogos-bundle-pp-select-variant-option");if(m&&t.contains(m)){const t=m.closest(".bogos-bpp-child-widget-cell"),e=m.closest(".bogos-bundle-pp-select-variant-dropdown");if(!t||!e)return;const n=m.getAttribute("data-variant-id"),i=null!=(d=m.getAttribute("data-price"))?d:"",l=null!=(c=m.getAttribute("data-img"))?c:"",a="1"===m.getAttribute("data-available");t.setAttribute("data-variant-id",null!=n?n:""),t.setAttribute("data-price",i),t.setAttribute("data-available",a?"1":"0");const r=t.querySelector(".bogos-bpp-child-widget-cell-img");r&&l&&r.setAttribute("src",l);const s=t.querySelector(".bogos-bundle-pp-select-variant-title");return s&&(s.textContent=m.textContent.trim()),void o(e)}const v=_.closest(".bogos-select-option-custom-item");if(v&&t.contains(v)){const t=v.closest(".bogos-bpp-child-widget-cell"),e=v.closest(".bogos-bundle-pp-select-variant-dropdown");if(!t||!e)return;const n=t.dataset.productId,i=null==(u=W.productsTemp)?void 0:u[n];if(!i)return;const l=t.dataset.variantId,{selectedVariant:a,newOptions:r}=N.handleValidVariantOption(v,l,i,e);if(!a)return void N.handleInvalidVariantOption(i,r,e);t.dataset.variantId=a.id,t.dataset.price=a.price,t.dataset.available=!1!==a.available?"1":"0";const s=t.querySelector(".bogos-bpp-child-widget-cell-img"),d=null!=(p=null!=(b=null==a?void 0:a.thumbnail)?b:null==i?void 0:i.thumbnail)?p:"";s&&d&&(s.src=X.handleResizeProductImage(d,150));const c=t.querySelector(".bogos-bundle-pp-select-variant-title");return c&&(c.textContent=X.checkIsDefaultTitle(a.title)?"":a.title),void o(e)}_.closest(".bogos-bundle-pp-select-variant-dropdown")||n()}));const i=()=>{t.querySelectorAll(".bogos-bundle-pp-select-variant-dropdown.opened").forEach(e)};window.addEventListener("scroll",i,{passive:!0,capture:!0}),window.addEventListener("resize",i)},render:()=>{var t,e,o,n,i;const{product_form_query:l}=null!=(t=FGSECOMAPP.QUERY_SELECTOR)?t:{},a=document.querySelectorAll(null==(e=null==l?void 0:l.bundle_product_page_widget)?void 0:e.join(",")),r=null!=(o=FGSECOMAPP.current_bundles_child_widget)?o:[];if(a.forEach(t=>{const e=W.filterWithBlocks(t),o=t.querySelector("#bogos-bpp-child-widget-preview-mode");e.length?(t.innerHTML=W.renderAll(e),W.renderEventQuery(t)):o&&N.renderEmpty(o)}),a.length)return;if(!r.length)return;const s=[...null!=(n=null==l?void 0:l.integration)?n:[],...null!=(i=null==l?void 0:l.default)?i:[]].filter(Boolean).join(",");if(!s)return;const d=document.querySelector(s);if(!d)return;const c=document.createElement("div");c.id="bogos-bpp-child-widget-view",c.innerHTML=W.renderAll(r),d.appendChild(c),W.renderEventQuery(c)},init:t=>h(null,null,function*(){try{yield W.filter(),W.render()}catch(t){console.warn("BOGOS track: bpp child widget init failed",t)}})},Q=t=>Object.entries({"--bogos-per-mobile":null==t?void 0:t.mobile,"--bogos-per-compact":null==t?void 0:t.compact,"--bogos-per-full":null==t?void 0:t.full_width}).filter(([,t])=>null!=t&&""!==t).map(([t,e])=>"".concat(t,":").concat(e)).join(";"),K=t=>{var e,o,n;const i=null!=(n=null==(o=null==(e=FGSECOMAPP.fgAppearance)?void 0:e.select_variant)?void 0:o.color)?n:{},l=t?{"--bogos-sv-active-item-bg":i.active_item_background}:{"--bogos-sv-default-tab-bg":i.default_tab_background,"--bogos-sv-default-tab-text":i.default_tab_text,"--bogos-sv-active-tab-bg":i.active_tab_background,"--bogos-sv-active-tab-text":i.active_tab_text,"--bogos-sv-active-tab-border":i.active_tab_border,"--bogos-sv-active-item-bg":i.active_item_background};return Object.entries(l).filter(([,t])=>!X.empty(t)).map(([t,e])=>"".concat(t,":").concat(e)).join(";")},X=v(m(v(m({},I),{routeLink:null!=(M=null==I?void 0:I.routeLink)?M:t=>t}),function(){const t=t=>{try{const{protocol:e}=new URL(t,window.location.href);return"https:"===e||"http:"===e?E((t=>X.routeLink(t))(t)):"#"}catch(e){return"#"}};return{safeText:E,safeMerchantHTML:(e,o=!1)=>{if("string"!=typeof e||!e.includes("<"))return E(e);const n=document.createElement("template");n.innerHTML=e;const i=e=>Array.from(e.childNodes).forEach(e=>{if(e.nodeType===Node.COMMENT_NODE)return e.remove();if(e.nodeType!==Node.ELEMENT_NODE)return;const n=e.localName;return S.includes(n)?e.remove():y.includes(n)?(Array.from(e.attributes).forEach(({name:i,value:l})=>{o&&(f.includes(i)||"a"===n&&x.includes(i)&&("href"!==i||"#"!==t(l)))||e.removeAttribute(i)}),void i(e)):e.replaceWith(document.createTextNode(e.textContent))});return i(n.content),o?n.innerHTML:n.innerHTML.replace(/"/g,""").replace(/'/g,"'")},safeLink:t,attrText:A}}()),{convertVariantAddBundle:t=>({id:t.id-0,title:t.title.trim(),price:t.price,quantity:1,thumbnail:t.thumbnail})}),Z=m({},D),J=v(m({},T),{APP_REVIEW_OPTION:{bundle:"bundle",gift_slider:"gift_slider"},syncStarRating:t=>h(null,null,function*(){const e=()=>{};yield J.syncRatingProducts([...new Set(t)],J.APP_REVIEW_OPTION.bundle),yield J.syncRatingProducts([...new Set(t)],J.APP_REVIEW_OPTION.bundle,e,B.APP_REVIEW.trustoo),yield J.syncRatingProducts([...new Set(t)],J.APP_REVIEW_OPTION.bundle,e,B.APP_REVIEW.yotpo)})}),$={processing:!1,createGlobalVariables:()=>{var t;(null==(t=window.BOGOS_CORE)?void 0:t.helper)&&(BOGOS_CORE.helper.bundle={}),document.addEventListener(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_BUNDLE_INIT,()=>{X.debounce(()=>h(null,null,function*(){$.processing||($.processing=!0,yield N.init(FGSECOMAPP.CUSTOM_EVENTS.BOGOS_BUNDLE_INIT).then(),$.processing=!1)}),250)()})},cssLink:()=>{var t;const e=document.querySelector("#bogos-bundle-style");let o=null==e?void 0:e.getAttribute("data-url");const n=null!=(t=null==e?void 0:e.parentNode)?t:document.body;if(!o)return;if(document.querySelector('[href*="'.concat(o,'"]')))return;const i=document.createElement("link");i.rel="stylesheet",i.type="text/css",i.media="all",i.href=o,n.insertBefore(i,n.firstChild)},init:()=>h(null,null,function*(){$.createGlobalVariables(),$.cssLink(),yield N.init("init")})};$.init().then()}()})();