vendor: 5,007 bytes, lines 1-8
1/*! 2 * 3 * 4 * This file is auto generated by webpack. 5 * Do not edit this file directly. 6 * 7 * 8 */(function(){var __webpack_modules__={243:(function(){"use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_typeof(o)}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if(typeof r=="string")return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _iterableToArray(r){if(typeof Symbol!="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _arrayLikeToArray(r,a){(a==null||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&(_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _wrapNativeSuper=function(t2){if(t2===null||!_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _construct(t2,arguments,_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(Wrapper,t2)},_wrapNativeSuper(t)}function _construct(t,e,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_setPrototypeOf(p,r.prototype),p}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_isNativeReflectConstruct=function(){return!!t})()}function _isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_setPrototypeOf(t,e)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_getPrototypeOf(t)}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return _typeof(i)=="symbol"?i:i+""}function _toPrimitive(t,r){if(_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var sectionClass=(function(_HTMLElement){function sectionClass2(name,id){var _this;return _classCallCheck(this,sectionClass2),_this=_callSuper(this,sectionClass2),_defineProperty(_this,"initElements",function(){var _this2=this;this.elements=this.querySelectorAll("[id]");var self=this;
8this.elements.forEach(function(element){element.refresh=function(){self.refresh(element.id)},_this2[element.id]=element})}),_defineProperty(_this,"refresh",function(elementID,productUrl){var _this3=this,fetchUrl=productUrl||window.location.pathname;fetch("".concat(fetchUrl,"?section_id=").concat(this.id)).then(function(res){return res.text()}).then(function(htmlString){var trimmedHtml=htmlString.trim();if(!trimmedHtml||trimmedHtml===""||trimmedHtml.length===0){_this3.dispatchEvent(new CustomEvent("section:empty",{detail:{sectionId:_this3.id}})),_this3.onRefreshFinish(null);return}var newDom=document.createElement("div");if(elementID){var element=_this3.sectionElement.querySelector("#"+elementID);newDom.innerHTML=trimmedHtml,newDom=newDom.querySelector("#"+elementID),newDom&&element&&element.parentNode.replaceChild(newDom,element)}else{newDom.innerHTML=trimmedHtml;var sectionElement=newDom.querySelector("#"+_this3.id);sectionElement&&(_this3.innerHTML=sectionElement.innerHTML)}_this3.initElements(),_this3.onRefreshFinish(newDom)}).catch(function(error){console.error("[".concat(_this3.constructor.name,"] Error refreshing section ").concat(_this3.id,":"),error),_this3.dispatchEvent(new CustomEvent("section:error",{detail:{sectionId:_this3.id,error:error}}))})}),window.sections||(window.sections=[]),window.sections[name]?window.sections[name].id==_this.id||(Array.isArray(window.sections[name])?window.sections[name]=[].concat(_toConsumableArray(window.sections[name]),[_this]):window.sections[name]=[window.sections[name],_this]):window.sections[name]=_this,_this.sectionElement=document.querySelector("#shopify-section-"+id),_this.initElements(),_this}return _inherits(sectionClass2,_HTMLElement),_createClass(sectionClass2,[{key:"onRefreshFinish",value:function(sectionHtmlString){}}])})(_wrapNativeSuper(HTMLElement));function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r2){return Object.getOwnPropertyDescriptor(e,r2).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r2){hmacUtils_defineProperty(e,r2,t[r2])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r2){Object.defineProperty(e,r2,Object.getOwnPropertyDescriptor(t,r2))})}return e}function hmacUtils_defineProperty(e,r,t){return(r=hmacUtils_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function hmacUtils_typeof(o){"@babel/helpers - typeof";return hmacUtils_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},hmacUtils_typeof(o)}function hmacUtils_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function hmacUtils_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,hmacUtils_toPropertyKey(o.key),o)}}function hmacUtils_createClass(e,r,t){return r&&hmacUtils_defineProperties(e.prototype,r),t&&hmacUtils_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function hmacUtils_toPropertyKey(t){var i=hmacUtils_toPrimitive(t,"string");return hmacUtils_typeof(i)=="symbol"?i:i+""}function hmacUtils_toPrimitive(t,r){if(hmacUtils_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(hmacUtils_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var HmacUtils=(function(){function HmacUtils2(){hmacUtils_classCallCheck(this,HmacUtils2)}return hmacUtils_createClass(HmacUtils2,null,[{key:"parseHmacData",value:function(hmacData){var hmacObj;
8if(typeof hmacData=="string")try{var cleanedHmacString=hmacData.replace(/"/g,'"');hmacObj=JSON.parse(cleanedHmacString)}catch(e){throw console.error("Failed to parse HMAC string:",e),new Error("Invalid HMAC data format")}else if(hmacUtils_typeof(hmacData)==="object"&&hmacData!==null)hmacObj=_objectSpread({},hmacData);else throw new Error("HMAC data must be a string or object");var _hmacObj=hmacObj,timestamp=_hmacObj.timestamp,store=_hmacObj.store,hmac=_hmacObj.hmac;if(!timestamp||!store||!hmac)throw console.error("Missing required HMAC fields:",hmacObj),new Error("HMAC data is missing required fields");return{timestamp:String(timestamp),store:String(store),hmac:String(hmac)}}},{key:"formatHmacString",value:function(hmacData){var _this$parseHmacData=this.parseHmacData(hmacData),timestamp=_this$parseHmacData.timestamp,store=_this$parseHmacData.store,hmac=_this$parseHmacData.hmac,hmacPayload={timestamp:'"'.concat(timestamp,'"'),store:'"'.concat(store,'"'),hmac:'"'.concat(hmac,'"')};return'{"timestamp": '.concat(hmacPayload.timestamp,',"store":').concat(hmacPayload.store,',"hmac":').concat(hmacPayload.hmac,"}")}},{key:"createRequestBody",value:function(params,hmacData){var additionalData=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return _objectSpread(_objectSpread({},params),{},{hmac:this.formatHmacString(hmacData)},additionalData)}},{key:"initFromElement",value:function(element){var attributeName=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"data-hmac";try{var hmacString=element.getAttribute(attributeName);if(!hmacString)throw new Error("HMAC attribute '".concat(attributeName,"' not found"));var hmacData=this.parseHmacData(hmacString);return{hmacData:hmacData,hmac:hmacData.hmac}}catch(error){console.error("Error initializing HMAC from element:",error),console.error("HMAC string that failed to parse:",element==null?void 0:element.getAttribute(attributeName));var emptyHmac={timestamp:"",store:"",hmac:""};return{hmacData:emptyHmac,hmac:""}}}}])})(),hmacUtils=HmacUtils;function favoritesSync_typeof(o){"@babel/helpers - typeof";return favoritesSync_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},favoritesSync_typeof(o)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t2,e2,r2){t2[e2]=r2.value},i=typeof Symbol=="function"?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t2,e2,r2){return Object.defineProperty(t2,e2,{value:r2,enumerable:!0,configurable:!0,writable:!0}),t2[e2]}try{define({},"")}catch(t2){define=function(t3,e2,r2){return t3[e2]=r2}}function wrap(t2,e2,r2,n2){var i2=e2&&e2.prototype instanceof Generator?e2:Generator,a2=Object.create(i2.prototype),c2=new Context(n2||[]);return o(a2,"_invoke",{value:makeInvokeMethod(t2,r2,c2)}),a2}function tryCatch(t2,e2,r2){try{return{type:"normal",arg:t2.call(e2,r2)}}catch(t3){return{type:"throw",arg:t3}}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t2){["next","throw","return"].forEach(function(e2){define(t2,e2,function(t3){return this._invoke(e2,t3)})})}function AsyncIterator(t2,e2){function invoke(r3,o2,i2,a2){var c2=tryCatch(t2[r3],t2,o2);if(c2.type!=="throw"){var u2=c2.arg,h2=u2.value;return h2&&favoritesSync_typeof(h2)=="object"&&n.call(h2,"__await")?e2.resolve(h2.__await).then(function(t3){invoke("next",t3,i2,a2)},function(t3){invoke("throw",t3,i2,a2)}):e2.resolve(h2).then(function(t3){u2.value=t3,i2(u2)},function(t3){return invoke("throw",t3,i2,a2)})}a2(c2.arg)}var r2;o(this,"_invoke",{value:function(t3,n2){function callInvokeWithMethodAndArg(){return new e2(function(e3,r3){invoke(t3,n2,e3,r3)})}return r2=r2?r2.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(e2,r2,n2){var o2=h;return function(i2,a2){if(o2===f)throw Error("Generator is already running");if(o2===s){if(i2==="throw")throw a2;return{value:t,done:!0}}for(n2.method=i2,n2.arg=a2;;){var c2=n2.delegate;if(c2){var u2=maybeInvokeDelegate(c2,n2);if(u2){if(u2===y)continue;return u2}}if(n2.method==="next")n2.sent=n2._sent=n2.arg;else if(n2.method==="throw"){if(o2===h)throw o2=s,n2.arg;n2.dispatchException(n2.arg)}else n2.method==="return"&&n2.abrupt("return",n2.arg);o2=f;var p2=tryCatch(e2,r2,n2);if(p2.type==="normal"){if(o2=n2.done?s:l,p2.arg===y)continue;return{value:p2.arg,done:n2.done}}p2.type==="throw"&&(o2=s,n2.method="throw",n2.arg=p2.arg)}}}function maybeInvokeDelegate(e2,r2){var n2=r2.method,o2=e2.iterator[n2];if(o2===t)return r2.delegate=null,n2==="throw"&&e2.iterator.return&&
vendor: 16,877 bytes, line 8
8(r2.method="return",r2.arg=t,maybeInvokeDelegate(e2,r2),r2.method==="throw")||n2!=="return"&&(r2.method="throw",r2.arg=new TypeError("The iterator does not provide a '"+n2+"' method")),y;var i2=tryCatch(o2,e2.iterator,r2.arg);if(i2.type==="throw")return r2.method="throw",r2.arg=i2.arg,r2.delegate=null,y;var a2=i2.arg;return a2?a2.done?(r2[e2.resultName]=a2.value,r2.next=e2.nextLoc,r2.method!=="return"&&(r2.method="next",r2.arg=t),r2.delegate=null,y):a2:(r2.method="throw",r2.arg=new TypeError("iterator result is not an object"),r2.delegate=null,y)}function pushTryEntry(t2){var e2={tryLoc:t2[0]};1 in t2&&(e2.catchLoc=t2[1]),2 in t2&&(e2.finallyLoc=t2[2],e2.afterLoc=t2[3]),this.tryEntries.push(e2)}function resetTryEntry(t2){var e2=t2.completion||{};e2.type="normal",delete e2.arg,t2.completion=e2}function Context(t2){this.tryEntries=[{tryLoc:"root"}],t2.forEach(pushTryEntry,this),this.reset(!0)}function values(e2){if(e2||e2===""){var r2=e2[a];if(r2)return r2.call(e2);if(typeof e2.next=="function")return e2;if(!isNaN(e2.length)){var o2=-1,i2=function next(){for(;++o2<e2.length;)if(n.call(e2,o2))return next.value=e2[o2],next.done=!1,next;return next.value=t,next.done=!0,next};return i2.next=i2}}throw new TypeError(favoritesSync_typeof(e2)+" is not iterable")}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t2){var e2=typeof t2=="function"&&t2.constructor;return!!e2&&(e2===GeneratorFunction||(e2.displayName||e2.name)==="GeneratorFunction")},e.mark=function(t2){return Object.setPrototypeOf?Object.setPrototypeOf(t2,GeneratorFunctionPrototype):(t2.__proto__=GeneratorFunctionPrototype,define(t2,u,"GeneratorFunction")),t2.prototype=Object.create(g),t2},e.awrap=function(t2){return{__await:t2}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this}),e.AsyncIterator=AsyncIterator,e.async=function(t2,r2,n2,o2,i2){i2===void 0&&(i2=Promise);var a2=new AsyncIterator(wrap(t2,r2,n2,o2),i2);return e.isGeneratorFunction(r2)?a2:a2.next().then(function(t3){return t3.done?t3.value:a2.next()})},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this}),define(g,"toString",function(){return"[object Generator]"}),e.keys=function(t2){var e2=Object(t2),r2=[];for(var n2 in e2)r2.push(n2);return r2.reverse(),function next(){for(;r2.length;){var t3=r2.pop();if(t3 in e2)return next.value=t3,next.done=!1,next}return next.done=!0,next}},e.values=values,Context.prototype={constructor:Context,reset:function(e2){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e2)for(var r2 in this)r2.charAt(0)==="t"&&n.call(this,r2)&&!isNaN(+r2.slice(1))&&(this[r2]=t)},stop:function(){this.done=!0;var t2=this.tryEntries[0].completion;if(t2.type==="throw")throw t2.arg;return this.rval},dispatchException:function(e2){if(this.done)throw e2;var r2=this;function handle(n2,o3){return a2.type="throw",a2.arg=e2,r2.next=n2,o3&&(r2.method="next",r2.arg=t),!!o3}for(var o2=this.tryEntries.length-1;o2>=0;--o2){var i2=this.tryEntries[o2],a2=i2.completion;if(i2.tryLoc==="root")return handle("end");if(i2.tryLoc<=this.prev){var c2=n.call(i2,"catchLoc"),u2=n.call(i2,"finallyLoc");if(c2&&u2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0);if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}else if(c2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0)}else{if(!u2)throw Error("try statement without catch or finally");if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}}}},abrupt:function(t2,e2){for(var r2=this.tryEntries.length-1;r2>=0;--r2){var o2=this.tryEntries[r2];if(o2.tryLoc<=this.prev&&n.call(o2,"finallyLoc")&&this.prev<o2.finallyLoc){var i2=o2;break}}i2&&(t2==="break"||t2==="continue")&&i2.tryLoc<=e2&&e2<=i2.finallyLoc&&(i2=null);var a2=i2?i2.completion:{};return a2.type=t2,a2.arg=e2,i2?(this.method="next",this.next=i2.finallyLoc,y):this.complete(a2)},complete:function(t2,e2){if(t2.type==="throw")throw t2.arg;return t2.type==="break"||t2.type==="continue"?this.next=t2.arg:t2.type==="return"?(this.rval=this.arg=t2.arg,this.method="return",this.next="end"):t2.type==="normal"&&e2&&(this.next=e2),y},finish:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.finallyLoc===t2)return this.complete(r2.completion,r2.afterLoc),resetTryEntry(r2),y}},catch:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.tryLoc===t2){var n2=r2.completion;if(n2.type==="throw"){var o2=n2.arg;resetTryEntry(r2)}return o2}}throw Error("illegal catch attempt")},delegateYield:function(e2,r2,n2){return this.delegate={iterator:values(e2),resultName:r2,nextLoc:n2},this.method==="next"&&(this.arg=t),y}},e}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n2){return void e(n2)}i.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n2){asyncGeneratorStep(a,r,o,_next,_throw,"next",n2)}function _throw(n2){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n2)}_next(void 0)})}}function syncFavoritesWithServer(_x,_x2,_x3){return _syncFavoritesWithServer.apply(this,arguments)}function _syncFavoritesWithServer(){return _syncFavoritesWithServer=_asyncToGenerator(_regeneratorRuntime().mark(function _callee(customerId,beUrl,hmacData){var requestBody,response,data,cleanRecipes;return _regeneratorRuntime().wrap(function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(!(!customerId||!beUrl)){_context.next=2;break}return _context.abrupt("return",null);case 2:return _context.prev=2,requestBody=hmacUtils.createRequestBody({customerId:String(customerId),handle:"*"},hmacData),_context.next=6,fetch("".concat(beUrl,"/favourite-recipe"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(requestBody)});case 6:if(response=_context.sent,!response.ok){_context.next=17;break}return _context.next=10,response.json();case 10:if(data=_context.sent,!(data.recipes&&Array.isArray(data.recipes))){_context.next=15;break}return cleanRecipes=data.recipes.filter(function(handle){return handle!=="*"}),localStorage.setItem(window.sga.constants.FAVORITES_KEY,JSON.stringify(cleanRecipes)),_context.abrupt("return",cleanRecipes);case 15:_context.next=18;break;case 17:console.warn("Server sync failed with status: ".concat(response.status));case 18:return _context.abrupt("return",null);case 21:return _context.prev=21,_context.t0=_context.catch(2),console.error("Error syncing favorites:",_context.t0),_context.abrupt("return",null);case 25:case"end":return _context.stop()}},_callee,null,[[2,21]])})),_syncFavoritesWithServer.apply(this,arguments)}function getFavorites(){try{var favoritesJson=localStorage.getItem(window.sga.constants.FAVORITES_KEY);return favoritesJson?JSON.parse(favoritesJson):[]}catch(error){return console.error("Error reading favorites from localStorage:",error),[]}}function setFavorites(recipes){try{return localStorage.setItem(window.sga.constants.FAVORITES_KEY,JSON.stringify(recipes)),!0}catch(error){return console.error("Error writing favorites to localStorage:",error),!1}}function recipes_detail_typeof(o){"@babel/helpers - typeof";return recipes_detail_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},recipes_detail_typeof(o)}function recipes_detail_regeneratorRuntime(){"use strict";recipes_detail_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t2,e2,r2){t2[e2]=r2.value},i=typeof Symbol=="function"?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t2,e2,r2){return Object.defineProperty(t2,e2,{value:r2,enumerable:!0,configurable:!0,writable:!0}),t2[e2]}try{define({},"")}catch(t2){define=function(t3,e2,r2){return t3[e2]=r2}}function wrap(t2,e2,r2,n2){var i2=e2&&e2.prototype instanceof Generator?e2:Generator,a2=Object.create(i2.prototype),c2=new Context(n2||[]);return o(a2,"_invoke",{value:makeInvokeMethod(t2,r2,c2)}),a2}function tryCatch(t2,e2,r2){try{return{type:"normal",arg:t2.call(e2,r2)}}catch(t3){return{type:"throw",arg:t3}}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t2){["next","throw","return"].forEach(function(e2){define(t2,e2,function(t3){return this._invoke(e2,t3)})})}function AsyncIterator(t2,e2){function invoke(r3,o2,i2,a2){var c2=tryCatch(t2[r3],t2,o2);if(c2.type!=="throw"){var u2=c2.arg,h2=u2.value;return h2&&recipes_detail_typeof(h2)=="object"&&n.call(h2,"__await")?e2.resolve(h2.__await).then(function(t3){invoke("next",t3,i2,a2)},function(t3){invoke("throw",t3,i2,a2)}):e2.resolve(h2).then(function(t3){u2.value=t3,i2(u2)},function(t3){return invoke("throw",t3,i2,a2)})}a2(c2.arg)}var r2;o(this,"_invoke",{value:function(t3,n2){function callInvokeWithMethodAndArg(){return new e2(function(e3,r3){invoke(t3,n2,e3,r3)})}return r2=r2?r2.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(e2,r2,n2){var o2=h;return function(i2,a2){if(o2===f)throw Error("Generator is already running");if(o2===s){if(i2==="throw")throw a2;return{value:t,done:!0}}for(n2.method=i2,n2.arg=a2;;){var c2=n2.delegate;if(c2){var u2=maybeInvokeDelegate(c2,n2);if(u2){if(u2===y)continue;return u2}}if(n2.method==="next")n2.sent=n2._sent=n2.arg;else if(n2.method==="throw"){if(o2===h)throw o2=s,n2.arg;n2.dispatchException(n2.arg)}else n2.method==="return"&&n2.abrupt("return",n2.arg);o2=f;var p2=tryCatch(e2,r2,n2);if(p2.type==="normal"){if(o2=n2.done?s:l,p2.arg===y)continue;return{value:p2.arg,done:n2.done}}p2.type==="throw"&&(o2=s,n2.method="throw",n2.arg=p2.arg)}}}function maybeInvokeDelegate(e2,r2){var n2=r2.method,o2=e2.iterator[n2];if(o2===t)return r2.delegate=null,n2==="throw"&&e2.iterator.return&&(r2.method="return",r2.arg=t,maybeInvokeDelegate(e2,r2),r2.method==="throw")||n2!=="return"&&(r2.method="throw",r2.arg=new TypeError("The iterator does not provide a '"+n2+"' method")),y;var i2=tryCatch(o2,e2.iterator,r2.arg);if(i2.type==="throw")return r2.method="throw",r2.arg=i2.arg,r2.delegate=null,y;var a2=i2.arg;return a2?a2.done?(r2[e2.resultName]=a2.value,r2.next=e2.nextLoc,r2.method!=="return"&&(r2.method="next",r2.arg=t),r2.delegate=null,y):a2:(r2.method="throw",r2.arg=new TypeError("iterator result is not an object"),r2.delegate=null,y)}function pushTryEntry(t2){var e2={tryLoc:t2[0]};1 in t2&&(e2.catchLoc=t2[1]),2 in t2&&(e2.finallyLoc=t2[2],e2.afterLoc=t2[3]),this.tryEntries.push(e2)}function resetTryEntry(t2){var e2=t2.completion||{};e2.type="normal",delete e2.arg,t2.completion=e2}function Context(t2){this.tryEntries=[{tryLoc:"root"}],t2.forEach(pushTryEntry,this),this.reset(!0)}function values(e2){if(e2||e2===""){var r2=e2[a];if(r2)return r2.call(e2);if(typeof e2.next=="function")return e2;if(!isNaN(e2.length)){var o2=-1,i2=function next(){for(;++o2<e2.length;)if(n.call(e2,o2))return next.value=e2[o2],next.done=!1,next;return next.value=t,next.done=!0,next};return i2.next=i2}}throw new TypeError(recipes_detail_typeof(e2)+" is not iterable")}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t2){var e2=typeof t2=="function"&&t2.constructor;return!!e2&&(e2===GeneratorFunction||(e2.displayName||e2.name)==="GeneratorFunction")},e.mark=function(t2){return Object.setPrototypeOf?Object.setPrototypeOf(t2,GeneratorFunctionPrototype):(t2.__proto__=GeneratorFunctionPrototype,define(t2,u,"GeneratorFunction")),t2.prototype=Object.create(g),t2},e.awrap=function(t2){return{__await:t2}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this}),e.AsyncIterator=AsyncIterator,e.async=function(t2,r2,n2,o2,i2){i2===void 0&&(i2=Promise);var a2=new AsyncIterator(wrap(t2,r2,n2,o2),i2);return e.isGeneratorFunction(r2)?a2:a2.next().then(function(t3){return t3.done?t3.value:a2.next()})},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this}),define(g,"toString",function(){return"[object Generator]"}),e.keys=function(t2){var e2=Object(t2),r2=[];for(var n2 in e2)r2.push(n2);return r2.reverse(),function next(){for(;r2.length;){var t3=r2.pop();if(t3 in e2)return next.value=t3,next.done=!1,next}return next.done=!0,next}},e.values=values,Context.prototype={constructor:Context,reset:function(e2){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e2)for(var r2 in this)r2.charAt(0)==="t"&&n.call(this,r2)&&!isNaN(+r2.slice(1))&&(this[r2]=t)},stop:function(){this.done=!0;var t2=this.tryEntries[0].completion;if(t2.type==="throw")throw t2.arg;return this.rval},dispatchException:function(e2){if(this.done)throw e2;var r2=this;function handle(n2,o3){return a2.type="throw",a2.arg=e2,r2.next=n2,o3&&(r2.method="next",r2.arg=t),!!o3}for(var o2=this.tryEntries.length-1;o2>=0;--o2){var i2=this.tryEntries[o2],a2=i2.completion;if(i2.tryLoc==="root")return handle("end");if(i2.tryLoc<=this.prev){var c2=n.call(i2,"catchLoc"),u2=n.call(i2,"finallyLoc");if(c2&&u2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0);if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}else if(c2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0)}else{if(!u2)throw Error("try statement without catch or finally");if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}}}},abrupt:function(t2,e2){for(var r2=this.tryEntries.length-1;r2>=0;--r2){var o2=this.tryEntries[r2];if(o2.tryLoc<=this.prev&&n.call(o2,"finallyLoc")&&this.prev<o2.finallyLoc){var i2=o2;break}}i2&&(t2==="break"||t2==="continue")&&i2.tryLoc<=e2&&e2<=i2.finallyLoc&&(i2=null);var a2=i2?i2.completion:{};return a2.type=t2,a2.arg=e2,i2?(this.method="next",this.next=i2.finallyLoc,y):this.complete(a2)},complete:function(t2,e2){if(t2.type==="throw")throw t2.arg;return t2.type==="break"||t2.type==="continue"?this.next=t2.arg:t2.type==="return"?(this.rval=this.arg=t2.arg,this.method="return",this.next="end"):t2.type==="normal"&&e2&&(this.next=e2),y},finish:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.finallyLoc===t2)return this.complete(r2.completion,r2.afterLoc),resetTryEntry(r2),y}},catch:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.tryLoc===t2){var n2=r2.completion;if(n2.type==="throw"){var o2=n2.arg;resetTryEntry(r2)}return o2}}throw Error("illegal catch attempt")},delegateYield:function(e2,r2,n2){return this.delegate={iterator:values(e2),resultName:r2,nextLoc:n2},this.method==="next"&&(this.arg=t),y}},e}function recipes_detail_asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n2){return void e(n2)}i.done?t(u):Promise.resolve(u).then(r,o)}function recipes_detail_asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n2){recipes_detail_asyncGeneratorStep(a,r,o,_next,_throw,"next",n2)}function _throw(n2){recipes_detail_asyncGeneratorStep(a,r,o,_next,_throw,"throw",n2)}_next(void 0)})}}function recipes_detail_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function recipes_detail_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,recipes_detail_toPropertyKey(o.key),o)}}function recipes_detail_createClass(e,r,t){return r&&recipes_detail_defineProperties(e.prototype,r),t&&recipes_detail_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function recipes_detail_callSuper(t,o,e){return o=recipes_detail_getPrototypeOf(o
8),recipes_detail_possibleConstructorReturn(t,recipes_detail_isNativeReflectConstruct()?Reflect.construct(o,e||[],recipes_detail_getPrototypeOf(t).constructor):o.apply(t,e))}function recipes_detail_possibleConstructorReturn(t,e){if(e&&(recipes_detail_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return recipes_detail_assertThisInitialized(t)}function recipes_detail_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function recipes_detail_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(recipes_detail_isNativeReflectConstruct=function(){return!!t})()}function recipes_detail_getPrototypeOf(t){return recipes_detail_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},recipes_detail_getPrototypeOf(t)}function recipes_detail_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&recipes_detail_setPrototypeOf(t,e)}function recipes_detail_setPrototypeOf(t,e){return recipes_detail_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},recipes_detail_setPrototypeOf(t,e)}function recipes_detail_defineProperty(e,r,t){return(r=recipes_detail_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function recipes_detail_toPropertyKey(t){var i=recipes_detail_toPrimitive(t,"string");return recipes_detail_typeof(i)=="symbol"?i:i+""}function recipes_detail_toPrimitive(t,r){if(recipes_detail_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(recipes_detail_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var RecipesDetail=(function(_sectionClass){function RecipesDetail2(){var _this;recipes_detail_classCallCheck(this,RecipesDetail2),_this=recipes_detail_callSuper(this,RecipesDetail2,["recipes_detail"]);var sectionId=_this.getAttribute("data-section-id")||"recipes-detail";_this.sectionId=sectionId;var _HmacUtils$initFromEl=hmacUtils.initFromElement(_this),hmacData=_HmacUtils$initFromEl.hmacData,hmac=_HmacUtils$initFromEl.hmac;return _this.hmacData=hmacData,_this.hmac=hmac,_this.customerId=_this.getAttribute("data-customerid"),_this.recipeHandle=_this.getAttribute("data-recipe-handle"),_this.beUrl=_this.getAttribute("data-be-url"),_this.addToFavoritesButton=_this.querySelector("[data-add-to-favorites]"),_this.removeFromFavoritesButton=_this.querySelector("[data-remove-from-favorites]"),_this.addToFavoritesButton&&_this.addToFavoritesButton.addEventListener("click",function(e){_this.toggleFavorite(e)}),_this.removeFromFavoritesButton&&_this.removeFromFavoritesButton.addEventListener("click",function(e){_this.toggleFavorite(e)}),_this.fetchAndSyncFavorites().then(function(){_this.setInitialButtonState()}),_this.setupStickyBehavior(),_this}return recipes_detail_inherits(RecipesDetail2,_sectionClass),recipes_detail_createClass(RecipesDetail2,[{key:"fetchAndSyncFavorites",value:(function(){var _fetchAndSyncFavorites=recipes_detail_asyncToGenerator(recipes_detail_regeneratorRuntime().mark(function _callee(){return recipes_detail_regeneratorRuntime().wrap(function(_context){for(;;)switch(_context.prev=_context.next){case 0:return _context.next=2,syncFavoritesWithServer(this.customerId,this.beUrl,this.hmacData);case 2:case"end":return _context.stop()}},_callee,this)}));function fetchAndSyncFavorites(){return _fetchAndSyncFavorites.apply(this,arguments)}return fetchAndSyncFavorites})()},{key:"setupStickyBehavior",value:function(){var _this2=this;this.hasAttribute("data-sticky-enabled")&&(this.containerElement=this.closest("[data-recipes-container]"),this.containerElement&&(this.isSticky=!1,this.stickyOffset=parseInt(this.getAttribute("data-sticky-offset"),10)||RecipesDetail2.DEFAULT_STICKY_OFFSET,this.fixedLeftOffset=null,this.mediaQuery=window.matchMedia("(min-width: 1024px)"),this.handleMediaChange=function(e){e.matches?_this2.enableStickyBehavior():_this2.disableStickyBehavior()},this.mediaQuery.addEventListener?this.mediaQuery.addEventListener("change",this.handleMediaChange):this.mediaQuery.addListener(this.handleMediaChange),this.mediaQuery.matches?this.enableStickyBehavior():this.disableStickyBehavior()))}},{key:"enableStickyBehavior",value:function(){var _this3=this;this.isSticky&&this.resetSticky(),this.cleanupStickyBehavior(),requestAnimationFrame(function(){return _this3.initializeObservers()})}},{key:"disableStickyBehavior",value:function(){this.resetSticky(),this.cleanupStickyBehavior()}},{key:"cleanupStickyBehavior",value:function(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.handleScroll&&(window.removeEventListener("scroll",this.handleScroll),this.handleScroll=null),this.fixedLeftOffset=null,this.containerIsVisible=!1,this.rafPending=!1}},{key:"initializeObservers",value:function(){var _this4=this;this.recalculatePosition(),this.resizeObserver=new ResizeObserver(function(){return _this4.handleResize()}),this.resizeObserver.observe(this.containerElement),this.intersectionObserver=new IntersectionObserver(function(entries){var entry=entries[0];_this4.containerIsVisible=entry.isIntersecting},{rootMargin:"100px 0px"}),this.intersectionObserver.observe(this.containerElement),this.handleScroll=function(){_this4.containerIsVisible&&(_this4.rafPending||(_this4.rafPending=!0,requestAnimationFrame(function(){_this4.updateStickyPosition(),_this4.rafPending=!1})))},window.addEventListener("scroll",this.handleScroll,{passive:!0}),this.updateStickyPosition()}},{key:"recalculatePosition",value:function(){var elementRect=this.getBoundingClientRect();this.fixedLeftOffset=elementRect.left}},{key:"resetSticky",value:function(){this.style.position="",this.style.top="",this.style.left="",this.style.right="",this.isSticky=!1}},{key:"activateSticky",value:function(){this.style.position="fixed",this.style.left="".concat(this.fixedLeftOffset,"px"),this.style.right="auto",this.isSticky=!0}},{key:"handleResize",value:function(){var _this5=this;this.isSticky&&this.resetSticky(),requestAnimationFrame(function(){_this5.recalculatePosition(),_this5.updateStickyPosition()})}},{key:"updateStickyPosition",value:function(){if(this.fixedLeftOffset!==null){var scrollTop=window.pageYOffset||document.documentElement.scrollTop,containerTop=this.containerElement.offsetTop,containerBottom=containerTop+this.containerElement.offsetHeight,scrolledPastTop=scrollTop>containerTop-this.stickyOffset,scrolledPastBottom=scrollTop+this.stickyOffset+this.offsetHeight>=containerBottom;!this.isSticky&&scrolledPastTop&&this.activateSticky(),this.isSticky&&(scrolledPastTop?scrolledPastBottom?this.style.top="".concat(containerBottom-this.offsetHeight-scrollTop,"px"):this.style.top="".concat(this.stickyOffset,"px"):this.resetSticky())}}},{key:"disconnectedCallback",value:function(){this.cleanupStickyBehavior(),this.mediaQuery&&this.handleMediaChange&&(this.mediaQuery.removeEventListener?this.mediaQuery.removeEventListener("change",this.handleMediaChange):this.mediaQuery.removeListener(this.handleMediaChange))}},{key:"toggleFavorite",value:(function(){var _toggleFavorite=recipes_detail_asyncToGenerator(recipes_detail_regeneratorRuntime().mark(function _callee2(event){var _this6=this,clickedButton,isRemoving,newFavoriteState,favorites,originalHTML,requestBody,response;return recipes_detail_regeneratorRuntime().wrap(function(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:if(this.hmacData){_context2.next=2;break}throw new Error("HMAC data is missing or invalid");case 2:return clickedButton=event.currentTarget,isRemoving=clickedButton.hasAttribute("data-remove-from-favorites"),newFavoriteState=!isRemoving,favorites=getFavorites(),newFavoriteState?favorites.includes(this.recipeHandle)||(favorites.push(this.recipeHandle),setFavorites(favorites)):(favorites=favorites.filter(function(handle){return handle!==_this6.recipeHandle}),setFavorites(favorites)),this.toggleButtonState(newFavoriteState),originalHTML=clickedButton.innerHTML,clickedButton.disabled=!0,requestBody=hmacUtils.createRequestBody({customerId:String(this.customerId),handle:String(this.recipeHandle)},this.hmacData),_context2.prev=11,_context2.next=14,fetch("".concat(this.beUrl,"/favourite-recipe"),{method:isRemoving?"DELET
8E":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(requestBody)});case 14:if(response=_context2.sent,response.ok){_context2.next=18;break}throw this.toggleButtonState(isRemoving),new Error("Error ".concat(isRemoving?"removing from":"adding to"," favorites: ").concat(response.status));case 18:console.log("Successfully ".concat(isRemoving?"removed from":"added to"," favorites")),_context2.next=25;break;case 21:_context2.prev=21,_context2.t0=_context2.catch(11),console.error("Error:",_context2.t0),this.toggleButtonState(isRemoving);case 25:return _context2.prev=25,clickedButton&&(clickedButton.disabled=!1,clickedButton.innerHTML=originalHTML),_context2.finish(25);case 28:case"end":return _context2.stop()}},_callee2,this,[[11,21,25,28]])}));function toggleFavorite(_x){return _toggleFavorite.apply(this,arguments)}return toggleFavorite})()},{key:"setInitialButtonState",value:function(){var addButton=this.querySelector("[data-add-to-favorites]"),removeButton=this.querySelector("[data-remove-from-favorites]");if(addButton&&removeButton){var favorites=getFavorites(),isFavorite=favorites.includes(this.recipeHandle);if(favorites.length>0)this.toggleButtonState(isFavorite);else{var _isFavorite=removeButton.classList.contains("hidden")===!1;this.toggleButtonState(_isFavorite)}}}},{key:"toggleButtonState",value:function(isFavorite){var addButton=this.querySelector("[data-add-to-favorites]"),removeButton=this.querySelector("[data-remove-from-favorites]");isFavorite?(addButton&&addButton.classList.add("hidden"),removeButton&&removeButton.classList.remove("hidden")):(addButton&&addButton.classList.remove("hidden"),removeButton&&removeButton.classList.add("hidden"))}}])})(sectionClass);recipes_detail_defineProperty(RecipesDetail,"DEFAULT_STICKY_OFFSET",160),typeof window!="undefined"&&!customElements.get("recipes-detail")&&customElements.define("recipes-detail",RecipesDetail);var recipes_detail=null}),82:(function(){window.sga=window.sga||{},window.sga={breakpoints:{sm:600,md:769,lg:1024,xl:1280,xxl:1536},constants:{FAVORITES_KEY:"favorite_recipes"}}})},__webpack_module_cache__={};function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(cachedModule!==void 0)return cachedModule.exports;var module=__webpack_module_cache__[moduleId]={exports:{}};return __webpack_modules__[moduleId](module,module.exports,__webpack_require__),module.exports}(function(){"use strict";function formatMoney(cents){var fallback=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(!Number.isFinite(cents))return fallback;var shopify=window.Shopify;return typeof(shopify==null?void 0:shopify.formatMoney)!="function"?fallback:shopify.formatMoney(Math.round(cents))}window.globals={updateQuickFacts:function(quantity,rowData){var quickFactsElements=document.querySelectorAll("[data-quick-facts-item]");if(quickFactsElements!=null&&quickFactsElements.length){var fromAttribute="quickFactsItemValueFrom",toAttribute="quickFactsItemValueTo",getElementValue=function(element,attribute){var _element$dataset$attr,_element$dataset;return Number((_element$dataset$attr=element==null||(_element$dataset=element.dataset)===null||_element$dataset===void 0?void 0:_element$dataset[attribute])!==null&&_element$dataset$attr!==void 0?_element$dataset$attr:0)*Number(quantity)},updateElement=function(element,value){var _element$innerHTML$le;((_element$innerHTML$le=element==null?void 0:element.innerHTML.length)!==null&&_element$innerHTML$le!==void 0?_element$innerHTML$le:0)>0&&(element.innerHTML=value)};quickFactsElements.forEach(function(quickFact){var itemType=quickFact.dataset.quickFactsItem,fromValueElement=quickFact.querySelector("[data-quick-facts-item-value-from]"),toValueElement=quickFact.querySelector("[data-quick-facts-item-value-to]"),fromElement=quickFact.querySelector("[data-quick-facts-item-element-from]"),toElement=quickFact.querySelector("[data-quick-facts-item-element-to]");if(itemType==="packaging"&&(updateElement(fromElement,getElementValue(fromValueElement,fromAttribute)),updateElement(toElement,getElementValue(toValueElement,toAttribute))),itemType==="duration"){var durationFrom=getElementValue(fromValueElement,fromAttribute),durationTo=getElementValue(toValueElement,toAttribute);updateElement(fromElement,Math.floor(durationFrom)),updateElement(toElement,Math.floor(durationTo))}if(itemType==="price_per_dose"&&rowData){var durationSelector='[data-quick-facts-item="duration"]',durationElement=document.querySelector(durationSelector),durationFromElement=durationElement.querySelector("[data-quick-facts-item-value-from]"),durationToElement=durationElement.querySelector("[data-quick-facts-item-value-to]"),_durationFrom=getElementValue(durationFromElement,fromAttribute),_durationTo=getElementValue(durationToElement,toAttribute),totalPrice=Number(rowData.price_per_unit_raw)*Number(quantity);updateElement(fromElement,formatMoney(totalPrice/_durationFrom)),updateElement(toElement,formatMoney(totalPrice/_durationTo))}})}}};var _variables=__webpack_require__(82),scrollToElement=function(element){var options=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(element){var offset=-200,delay=50;setTimeout(function(){var elementPosition=element.getBoundingClientRect().top+window.scrollY+offset;window.scrollTo({behavior:"smooth",top:elementPosition})},delay)}},handleClick=function(event){var toggleShowMore=event.currentTarget,containerElement=toggleShowMore.closest("[data-toggle-container]"),contentWrapperElement=containerElement==null?void 0:containerElement.querySelector("[data-toggle-content-wrapper]"),contentElement=containerElement==null?void 0:containerElement.querySelector("[data-toggle-content]"),textInnerElement=toggleShowMore.querySelector("[data-toggle-read-more-text]");if(!(!textInnerElement||!containerElement||!contentWrapperElement||!contentElement)){var contentWrapperHeight="".concat(Number(containerElement.dataset.contentWrapperHeight),"px"),textHeight="".concat(contentElement.scrollHeight,"px"),textOldValue=textInnerElement.innerText,textNewValue=textInnerElement.dataset.toggleReadMoreText;contentWrapperElement.style.maxHeight=containerElement.classList.contains("open")?contentWrapperHeight:textHeight,containerElement.classList.toggle("open"),textInnerElement.innerHTML=textNewValue,textInnerElement.dataset.toggleReadMoreText=textOldValue,containerElement.classList.contains("open")||scrollToElement(containerElement)}};window.toggleContent=function(){var containerElements=document.querySelectorAll("[data-toggle-container]");
8containerElements.forEach(function(containerElement){var toggleShowMore=containerElement.querySelector("[data-toggle-read-more]"),contentElement=containerElement.querySelector("[data-toggle-content]"),contentWrapperElement=containerElement.querySelector("[data-toggle-content-wrapper]");if(!(!toggleShowMore||!contentElement||!contentWrapperElement)){var contentWrapperHeight=Number(containerElement.dataset.contentWrapperHeight),textHeight=contentElement.scrollHeight;containerElement.dataset.textHeight=textHeight;var isOpen=containerElement.classList.contains("open");contentWrapperElement.style.maxHeight=isOpen?"".concat(textHeight,"px"):"".concat(contentWrapperHeight,"px"),textHeight>contentWrapperHeight?(toggleShowMore.style.display="inline-flex",toggleShowMore.classList.contains("init")||(toggleShowMore.classList.add("init"),toggleShowMore.addEventListener("click",handleClick))):(toggleShowMore.style.display="none",containerElement.classList.remove("open"),contentWrapperElement.style.maxHeight="".concat(contentWrapperHeight,"px"))}})},document.addEventListener("DOMContentLoaded",function(){window.toggleContent()});var toggleContentResizeTimeout=null;window.addEventListener("resize",function(){toggleContentResizeTimeout&&window.clearTimeout(toggleContentResizeTimeout),toggleContentResizeTimeout=window.setTimeout(function(){window.toggleContent(),toggleContentResizeTimeout=null},150)});var recipes_detail=__webpack_require__(243),SUBSCRIPTION_WIDGET_SELECTOR="[data-subscription-widget]",PURCHASE_SELECTOR="[data-purchase-selector]",ONE_TIME_BUTTON_SELECTOR="[data-one-time]",SUBSCRIPTION_BUTTON_SELECTOR="[data-subscription]",SUBSCRIPTION_LABEL_VALUE="[data-subscription-label-value]",SUBSCRIPTION_WIDGET_WRAPPER_SELECTOR="[data-subscription-widget-wrapper]",FREQUENCY_DROPDOWN_SELECTOR="[data-frequency-dropdown]",FREQUENCY_SELECTED_SELECTOR="[data-frequency-selected]",FREQUENCY_SELECTED_VALUE_SELECTOR="[data-frequency-selected-value]",FREQUENCY_SELECTED_LABEL_SELECTOR="[data-frequency-selected-label]",FREQUENCY_SELECTED_LABEL_ALT_SELECTOR="[data-frequency-selected-label-alt]",FREQUENCY_OPTIONS_SELECTOR="[data-frequency-options]",FREQUENCY_OPTION_SELECTOR="[data-frequency-option]",QUANTITY_BREAKS_CONTAINER_SELECTOR="[data-quantity-breaks-container]",QUANTITY_DROPDOWN_SELECTOR="[data-quantity-dropdown]",QUANTITY_SELECTED_SELECTOR="[data-quantity-selected]",QUANTITY_SELECTED_TEXT_WRAPPER_SELECTOR="[data-quantity-selected-text-wrapper]",QUANTITY_SELECTED_PRICE_WRAPPER_SELECTOR="[data-quantity-selected-price-wrapper]",QUANTITY_OPTIONS_SELECTOR="[data-quantity-options]",QUANTITY_OPTION_SELECTOR="[data-quantity-option]",QUANTITY_MAIN_TEXT_SELECTOR="[data-quantity-main-text]",QUANTITY_SUB_TEXT_SELECTOR="[data-quantity-sub-text]",QUANTITY_PRICE_SELECTOR="[data-quantity-price]",QUANTITY_DISCOUNT_BADGE_SELECTOR="[data-quantity-discount-badge]",QUANTITY_SAVINGS_SELECTOR="[data-quantity-savings]",QUANTITY_SAVINGS_VALUE_SELECTOR="[data-quantity-savings-value]",QUANTITY_PRICE_WRAPPER_SELECTOR="[data-quantity-price-wrapper]",PRODUCT_PRICE_CONTAINER_SELECTOR="[data-product-detail-price]",PRODUCT_AVAILABILITY_CONTAINER_SELECTOR="[data-product-detail-availability]",PRODUCT_DETAIL_ACTION_TOP_SELECTOR="[data-product-detail-action-top]",PRODUCT_DETAIL_ACTION_BOTTOM_SELECTOR="[data-product-detail-action-bottom]",PRODUCT_DETAIL_ONE_TIME_AVAILABILITY_SELECTOR="[data-product-detail-one-time-availability]",PRODUCT_DELIVERY_INFO_CONTAINER_SELECTOR="[data-product-detail-delivery-info]",PRICE_VALUE_SELECTOR="[data-cart-price-value]",QUANTITY_INPUT_SELECTOR="[data-cart-quantity-input]",PRICE_WAS_SELECTOR="[data-cart-price-was-value]",DISCOUNT_PERCENT_SELECTOR="[data-cart-discount-percent-value]",SAVINGS_AMOUNT_SELECTOR="[data-cart-discount-value]",DISCOUNT_CONTAINER_SELECTOR="[data-cart-discount-element]",SELLING_PLAN_INPUT_SELECTOR="[data-selling-plan-input-id]",PRODUCT_ADD_TO_CART_SELECTOR="[data-product-add-to-cart]",QUANTITY_BASE_INPUT_SELECTOR="[data-quantity-input]",ACTIVE_CLASS="active",HIDDEN_CLASS="hidden",FREQUENCY_OPTION_ACTIVE_CLASS="sga-subscription-widget__frequency-dropdown__option--active",FREQUENCY_OPTIONS_ACTIVE_CLASS="sga-subscription-widget__frequency-dropdown__options--active",QUANTITY_OPTION_ACTIVE_CLASS="sga-subscription-widget__quantity-dropdown__option--active",QUANTITY_OPTIONS_ACTIVE_CLASS="sga-subscription-widget__quantity-dropdown__options--active";function getIntelligemsPrice(variantId){if(window.igData&&window.igData.price&&variantId){var itemPrice=window.igData.price.getPriceByVariantId(parseInt(variantId,10));if(itemPrice)return itemPrice*100}return null}function waitForIntelligems(callback){if(window.igData&&window.igData.price){callback();return}window.onIgReady?Array.isArray(window.onIgReady)?window.onIgReady.push(callback):window.onIgReady=[window.onIgReady,callback]:window.onIgReady=callback}function _typeof(o){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return _typeof(i)=="symbol"?i:i+""}function _toPrimitive(t,r){if(_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var SGASubscriptionWidget=(function(){function SGASubscriptionWidget2(element){var _this$frequencyDropdo,_this$frequencyDropdo2,_this$frequencyDropdo3,_this$frequencyDropdo4,_this$frequencyDropdo5,_this$frequencyOption,_this$quantityDropdow,_this$quantitySelecte,_this$quantitySelecte2,_this$quantityDropdow2,_this$quantityOptions,_this$quantityDropdow3,_this$mainProductPric,_this$mainProductPric2,_this$mainProductPric3,_this$mainProductPric4,_this$mainProductPric5;_classCallCheck(this,SGASubscriptionWidget2),this.widgetElement=element,this.savingsText=this.widgetElement.dataset.savingsText,this.productId=this.widgetElement.dataset.productId,this.oneTimeButton=this.widgetElement.querySelector(ONE_TIME_BUTTON_SELECTOR),this.subscriptionButton=this.widgetElement.querySelector(SUBSCRIPTION_BUTTON_SELECTOR),this.quantityBreaksContainer=this.widgetElement.querySelector(QUANTITY_BREAKS_CONTAINER_SELECTOR),this.subscriptionWidgetWrapper=this.widgetElement.querySelector(SUBSCRIPTION_WIDGET_WRAPPER_SELECTOR),this.subscriptionLabelValue=this.widgetElement.querySelector(SUBSCRIPTION_LABEL_VALUE),this.frequencyDropdownContainer=this.widgetElement.querySelector(FREQUENCY_DROPDOWN_SELECTOR),this.frequencySelectedDisplay=(_this$frequencyDropdo=this.frequencyDropdownContainer)===null||_this$frequencyDropdo===void 0?void 0:_this$frequencyDropdo.querySelector(FREQUENCY_SELECTED_SELECTOR),this.frequencySelectedValue=(_this$frequencyDropdo2=this.frequencyDropdownContainer)===null||_this$frequencyDropdo2===void 0?void 0:_this$frequencyDropdo2.querySelector(FREQUENCY_SELECTED_VALUE_SELECTOR),this.frequencySelectedLabel=(_this$frequencyDropdo3=this.frequencyDropdownContainer)===null||_this$frequencyDropdo3===void 0?void 0:_this$frequencyDropdo3.querySelector(FREQUENCY_SELECTED_LABEL_SELECTOR),this.frequencySelectedLabelAlt=(_this$frequencyDropdo4=this.frequencyDropdownContainer)===null||_this$frequencyDropdo4===void 0?void 0:_this$frequencyDropdo4.querySelector(FREQUENCY_SELECTED_LABEL_ALT_SELECTOR),this.frequencyOptionsContainer=(_this$frequencyDropdo5=this.frequencyDropdownContainer)===null||_this$frequencyDropdo5===void 0?void 0:_this$frequencyDropdo5.querySelector(FREQUENCY_OPTIONS_SELECTOR),this.frequencyOptions=((_this$frequencyOption=this.frequencyOptionsContainer)===null||_this$frequencyOption===void 0?void 0:_this$frequencyOption.querySelectorAll(FREQUENCY_OPTION_SELECTOR))||[],this.quantityDropdown=this.widgetElement.querySelector(QUANTITY_DROPDOWN_SELECTOR),this.quantitySelectedDisplay=(_this$quantityDropdow=this.quantityDropdown)===null||_this$quantityDropdow===void 0?void 0:_this$quantityDropdow.querySelector(QUANTITY_SELECTED_SELECTOR),this.quantitySelectedTextWrapper=(_this$quantitySelecte=this.quantitySelectedDisplay)===null||_this$quantitySelecte===void 0?void 0:_this$quantitySelecte.querySelector(QUANTITY_SELECTED_TEXT_WRAPPER_SELECTOR),this.quantitySelectedPriceWrapper=(_this$quantitySelecte2=this.quantitySelectedDisplay)===null||_this$quantitySelecte2===void 0?void 0:_this$quantitySelecte2.querySelector(QUANTITY_SELECTED_PRICE_WRAPPER_SELECTOR),this.quantityOptionsContainer=(_this$quantityDropdow2=this.quantityDropdown)===null||_this$quantityDropdow2===void 0?void 0:_this$quantityDropdow2.querySelector(QUANTITY_OPTIONS_SELECTOR),this.quantityOptions=((_this$quantityOptions=this.quantityOptionsContainer)===null||_this$quantityOptions===void 0?void 0:_this$quantityOptions.querySelectorAll(QUANTITY_OPTION_SELECTOR))||[],this.productPrice
8=parseFloat((_this$quantityDropdow3=this.quantityDropdown)===null||_this$quantityDropdow3===void 0?void 0:_this$quantityDropdow3.dataset.productPrice)||0,this.mainProductPriceContainer=document.querySelector(PRODUCT_PRICE_CONTAINER_SELECTOR),this.mainProductAvailabilityContainer=document.querySelector(PRODUCT_AVAILABILITY_CONTAINER_SELECTOR),this.mainProductDetailActionBottomContainer=document.querySelector(PRODUCT_DETAIL_ACTION_BOTTOM_SELECTOR),this.mainProductOneTimeAvailabilityContainer=document.querySelector(PRODUCT_DETAIL_ONE_TIME_AVAILABILITY_SELECTOR),this.mainProductDetailActionTopContainer=document.querySelector(PRODUCT_DETAIL_ACTION_TOP_SELECTOR),this.mainProductDeliveryInfoContainer=document.querySelector(PRODUCT_DELIVERY_INFO_CONTAINER_SELECTOR),this.mainPriceValueElement=(_this$mainProductPric=this.mainProductPriceContainer)===null||_this$mainProductPric===void 0?void 0:_this$mainProductPric.querySelector(PRICE_VALUE_SELECTOR),this.mainQuantityInputElement=document.querySelector(QUANTITY_INPUT_SELECTOR),this.mainPriceWasElement=(_this$mainProductPric2=this.mainProductPriceContainer)===null||_this$mainProductPric2===void 0?void 0:_this$mainProductPric2.querySelector(PRICE_WAS_SELECTOR),this.mainDiscountPercentElement=(_this$mainProductPric3=this.mainProductPriceContainer)===null||_this$mainProductPric3===void 0?void 0:_this$mainProductPric3.querySelector(DISCOUNT_PERCENT_SELECTOR),this.mainSavingsAmountElement=(_this$mainProductPric4=this.mainProductPriceContainer)===null||_this$mainProductPric4===void 0?void 0:_this$mainProductPric4.querySelector(SAVINGS_AMOUNT_SELECTOR),this.mainDiscountContainerElement=(_this$mainProductPric5=this.mainProductPriceContainer)===null||_this$mainProductPric5===void 0?void 0:_this$mainProductPric5.querySelector(DISCOUNT_CONTAINER_SELECTOR),this.sellingPlanInput=document.querySelector(SELLING_PLAN_INPUT_SELECTOR),this.mainProductQuantitySelector=document.querySelector("".concat(PRODUCT_ADD_TO_CART_SELECTOR," ").concat(QUANTITY_BASE_INPUT_SELECTOR)),this.init()}return _createClass(SGASubscriptionWidget2,[{key:"init",value:function(){var _this=this;waitForIntelligems(function(){var intelliGemsPrice=getIntelligemsPrice(_this.productId);intelliGemsPrice&&(_this.productPrice=intelliGemsPrice,_this.updateQuantityOptionsWithIntelligemsPrice())}),this.oneTimeButton&&this.subscriptionButton&&(this.oneTimeButton.addEventListener("click",function(){return _this.selectPurchaseType("one-time")}),this.subscriptionButton.addEventListener("click",function(){return _this.selectPurchaseType("subscription")}),!this.oneTimeButton.classList.contains(ACTIVE_CLASS)&&!this.subscriptionButton.classList.contains(ACTIVE_CLASS)&&this.oneTimeButton.classList.add(ACTIVE_CLASS),this._hideMainProductQuantitySelector(this.subscriptionButton.classList.contains(ACTIVE_CLASS)&&this.mainProductQuantitySelector),this.updateVisibility());var initialFrequencyDiscount=0,initialSellingPlanId="";if(this.frequencyDropdownContainer&&this.frequencySelectedDisplay&&this.frequencyOptions&&this.frequencyOptions.length>0){this.frequencySelectedDisplay.addEventListener("click",function(event){return _this.toggleDropdown(event,_this.frequencyOptionsContainer)}),this.frequencyOptions.forEach(function(option){option.addEventListener("click",function(event){return _this.selectFrequencyOption(event)})});var activeFrequencyOption=this.frequencyOptionsContainer.querySelector(".".concat(FREQUENCY_OPTION_ACTIVE_CLASS));activeFrequencyOption?(this.frequencySelectedValue&&(this.frequencySelectedValue.textContent=activeFrequencyOption.dataset.sellingPlanName,this.frequencySelectedLabelAlt&&(this.frequencySelectedLabelAlt.textContent=activeFrequencyOption.dataset.sellingPlanLabelAlt),this.frequencySelectedLabel&&(this.frequencySelectedLabel.textContent=activeFrequencyOption.dataset.sellingPlanLabel)),this._setRadioChecked(activeFrequencyOption),initialFrequencyDiscount=parseFloat(activeFrequencyOption.dataset.discountPercentage)||0,initialSellingPlanId=activeFrequencyOption.dataset.sellingPlanId||""):this.sellingPlanInput&&this.subscriptionButton.classList.contains(ACTIVE_CLASS)&&(this.sellingPlanInput.value="")}else this.sellingPlanInput&&this.subscriptionButton.classList.contains(ACTIVE_CLASS)&&(this.sellingPlanInput.value="");var initialQuantity=1;if(this.quantityDropdown&&this.quantitySelectedDisplay&&this.quantityOptions&&this.quantityOptions.length>0){var _this$quantityOptions2;this.quantitySelectedDisplay.addEventListener("click",function(event){return _this.toggleDropdown(event,_this.quantityOptionsContainer)}),this.quantityOptions.forEach(function(option){option.addEventListener("click",function(event){return _this.selectQuantityOption(event)})});var activeQuantityOption=(_this$quantityOptions2=this.quantityOptionsContainer)===null||_this$quantityOptions2===void 0?void 0:_this$quantityOptions2.querySelector(".".concat(QUANTITY_OPTION_ACTIVE_CLASS));activeQuantityOption&&(initialQuantity=parseInt(activeQuantityOption.dataset.quantity)||1,this._setRadioChecked(activeQuantityOption))}
8document.addEventListener("click",function(event){return _this.handleClickOutside(event)}),this._updateMainProductQuantityInput(initialQuantity),this.sellingPlanInput&&this.subscriptionButton.classList.contains(ACTIVE_CLASS)&&(this.sellingPlanInput.value=initialSellingPlanId),this._updateMainProductPriceDisplay()}},{key:"_setRadioChecked",value:function(parentElement){var checked=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,radio=parentElement==null?void 0:parentElement.querySelector('input[type="radio"]');radio&&(radio.checked=checked)}},{key:"_hideMainProductQuantitySelector",value:function(hide){var _this$mainProductQuan,quantityInput=(_this$mainProductQuan=this.mainProductQuantitySelector)===null||_this$mainProductQuan===void 0?void 0:_this$mainProductQuan.closest("quantity-input");quantityInput&&(quantityInput.style.display=hide?"none":"")}},{key:"_updateMainProductPriceDisplay",value:function(){if(typeof Shopify.formatMoney=="function"){var isSubscriptionActive2=this.subscriptionButton&&this.subscriptionButton.classList.contains(ACTIVE_CLASS);if(isSubscriptionActive2){var activeQuantityOption=this.quantityOptionsContainer?this.quantityOptionsContainer.querySelector(".".concat(QUANTITY_OPTION_ACTIVE_CLASS)):null,newQuantity=parseInt(activeQuantityOption.dataset.quantity)||1,optionDiscountPercentageText=activeQuantityOption.querySelector(QUANTITY_DISCOUNT_BADGE_SELECTOR).textContent,optionDiscountPercentageValue=parseFloat(optionDiscountPercentageText.replace("%",""))||0,priceText=activeQuantityOption.querySelector(QUANTITY_PRICE_SELECTOR).textContent,savingsText=activeQuantityOption.querySelector(QUANTITY_SAVINGS_VALUE_SELECTOR).textContent,currentPrice=getIntelligemsPrice(this.productId)||this.productPrice,totalOldPrice=currentPrice*newQuantity;this.mainPriceValueElement&&(this.mainPriceValueElement.innerHTML=priceText),this.mainPriceWasElement&&(this.mainPriceWasElement.innerHTML=Shopify.formatMoney(totalOldPrice)),this.mainDiscountPercentElement&&(this.mainDiscountPercentElement.textContent=optionDiscountPercentageValue),this.mainSavingsAmountElement&&(this.mainSavingsAmountElement.innerHTML=savingsText),this.mainDiscountContainerElement&&this.mainDiscountContainerElement.classList.remove("!hidden");var pricePerUnitRaw=currentPrice-currentPrice*optionDiscountPercentageValue/100;window.globals.updateQuickFacts(newQuantity,{price_per_unit_raw:pricePerUnitRaw})}}}},{key:"_updateMainProductQuantityInput",value:function(quantity){this.mainQuantityInputElement&&(this.mainQuantityInputElement.value=quantity)}},{key:"_updateDiscountBadge",value:function(priceWrapperElement,totalDiscountPercentage){if(priceWrapperElement){var badgeEl=priceWrapperElement.querySelector(QUANTITY_DISCOUNT_BADGE_SELECTOR);badgeEl&&(totalDiscountPercentage>0?(badgeEl.textContent="-".concat(Math.round(totalDiscountPercentage),"%"),badgeEl.style.display="inline-block"):(badgeEl.textContent="",badgeEl.style.display="none"))}}},{key:"selectPurchaseType",value:function(type){var _this2=this;if(!(!this.oneTimeButton||!this.subscriptionButton)){var frequencyDiscountForQuantityUpdate=0,activeSellingPlanId="";if(type==="one-time"){var _this$mainProductAvai,_this$mainProductPric6,_this$mainProductDeta,_this$mainProductOneT,_this$mainProductDeta2,_this$mainProductDeli,_this$oneTimeButton,_this$subscriptionBut,_this$quantityBreaksC;(_this$mainProductAvai=this.mainProductAvailabilityContainer)===null||_this$mainProductAvai===void 0||_this$mainProductAvai.classList.add("!".concat(HIDDEN_CLASS)),(_this$mainProductPric6=this.mainProductPriceContainer)===null||_this$mainProductPric6===void 0||_this$mainProductPric6.classList.remove("!".concat(HIDDEN_CLASS)),(_this$mainProductDeta=this.mainProductDetailActionBottomContainer)===null||_this$mainProductDeta===void 0||_this$mainProductDeta.classList.remove("!".concat(HIDDEN_CLASS)),(_this$mainProductOneT=this.mainProductOneTimeAvailabilityContainer)===null||_this$mainProductOneT===void 0||_this$mainProductOneT.classList.remove("!".concat(HIDDEN_CLASS)),(_this$mainProductDeta2=this.mainProductDetailActionTopContainer)===null||_this$mainProductDeta2===void 0||_this$mainProductDeta2.classList.remove("isSubscription"),(_this$mainProductDeli=this.mainProductDeliveryInfoContainer)===null||_this$mainProductDeli===void 0||_this$mainProductDeli.classList.remove("!".concat(HIDDEN_CLASS)),(_this$oneTimeButton=this.oneTimeButton)===null||_this$oneTimeButton===void 0||_this$oneTimeButton.classList.add(ACTIVE_CLASS),(_this$subscriptionBut=this.subscriptionButton)===null||_this$subscriptionBut===void 0||_this$subscriptionBut.classList.remove(ACTIVE_CLASS),this._hideMainProductQuantitySelector(!this.mainProductQuantitySelector),this.sellingPlanInput&&(this.sellingPlanInput.value="");var selectedOneTimeRadio=(_this$quantityBreaksC=this.quantityBreaksContainer)===null||_this$quantityBreaksC===void 0?void 0:_this$quantityBreaksC.querySelector(".quantity-breaks__row.selected input");if(selectedOneTimeRadio){var selectedQuantity=selectedOneTimeRadio.dataset.lastInputValue||1;if(selectedQuantity){var quantityBreakRow=document.querySelector('.sga-subscription-widget__quantity-breaks-container [data-quantity-breaks-row][data-row-quantity="'.concat(selectedQuantity,'"]'));if(quantityBreakRow){var radioToSelect=quantityBreakRow.querySelector('input[type="radio"]');radioToSelect&&!radioToSelect.checked?(radioToSelect.checked=!0,radioToSelect.dispatchEvent(new Event("change",{bubbles:!0}))):radioToSelect&&radioToSelect.checked&&radioToSelect.dispatchEvent(new Event("change",{bubbles:!0}))}else selectedOneTimeRadio.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{quantityValue:selectedQuantity}}))}}else{var _defaultProductPriceD,defaultProductPriceJson=document.querySelector("[data-product-detail-price] [data-price-json]"),productQuantityInput=document.querySelector("[data-cart-quantity-input]"),quantity=productQuantityInput.dataset.lastInputValue||1;if(!defaultProductPriceJson)return;var defaultProductPriceData=JSON.parse(defaultProductPriceJson.textContent),currentPrice
8=getIntelligemsPrice(this.productId)||defaultProductPriceData.price_raw,formattedPrice=Shopify.formatMoney(currentPrice*quantity);document.querySelector("[data-cart-quantity-input]").value=quantity,document.querySelector("[data-product-detail-price] [data-cart-price-value]").innerHTML=formattedPrice,document.querySelector("[data-product-detail-price] [data-cart-price-was-value]").innerHTML=(_defaultProductPriceD=defaultProductPriceData.compare_at_price)!==null&&_defaultProductPriceD!==void 0?_defaultProductPriceD:null,document.querySelector("[data-product-detail-price] [data-cart-discount-percent-value]").innerHTML=defaultProductPriceData.discount_percent,document.querySelector("[data-product-detail-price] [data-cart-discount-value]").innerHTML=defaultProductPriceData.discount_amount,document.querySelector("[data-product-detail-price] [data-cart-discount-element]").classList.toggle("!hidden",!defaultProductPriceData.discount_amount),window.globals.updateQuickFacts(quantity,{price_per_unit_raw:currentPrice})}}else if(type==="subscription"){var _this$mainProductAvai2,_this$mainProductPric7,_this$mainProductDeta3,_this$mainProductOneT2,_this$mainProductDeta4,_this$mainProductDeli2,_this$subscriptionBut2,_this$oneTimeButton2,_this$quantityOptions3;(_this$mainProductAvai2=this.mainProductAvailabilityContainer)===null||_this$mainProductAvai2===void 0||_this$mainProductAvai2.classList.remove("!".concat(HIDDEN_CLASS)),(_this$mainProductPric7=this.mainProductPriceContainer)===null||_this$mainProductPric7===void 0||_this$mainProductPric7.classList.add("!".concat(HIDDEN_CLASS)),(_this$mainProductDeta3=this.mainProductDetailActionBottomContainer)===null||_this$mainProductDeta3===void 0||_this$mainProductDeta3.classList.add("!".concat(HIDDEN_CLASS)),(_this$mainProductOneT2=this.mainProductOneTimeAvailabilityContainer)===null||_this$mainProductOneT2===void 0||_this$mainProductOneT2.classList.add("!".concat(HIDDEN_CLASS)),(_this$mainProductDeta4=this.mainProductDetailActionTopContainer)===null||_this$mainProductDeta4===void 0||_this$mainProductDeta4.classList.add("isSubscription"),(_this$mainProductDeli2=this.mainProductDeliveryInfoContainer)===null||_this$mainProductDeli2===void 0||_this$mainProductDeli2.classList.add("!".concat(HIDDEN_CLASS)),(_this$subscriptionBut2=this.subscriptionButton)===null||_this$subscriptionBut2===void 0||_this$subscriptionBut2.classList.add(ACTIVE_CLASS),(_this$oneTimeButton2=this.oneTimeButton)===null||_this$oneTimeButton2===void 0||_this$oneTimeButton2.classList.remove(ACTIVE_CLASS),this._hideMainProductQuantitySelector(this.mainProductQuantitySelector);var activeFrequencyOption=this.frequencyOptionsContainer?this.frequencyOptionsContainer.querySelector(".".concat(FREQUENCY_OPTION_ACTIVE_CLASS)):null;activeFrequencyOption&&(frequencyDiscountForQuantityUpdate=parseFloat(activeFrequencyOption.dataset.discountPercentage)||0,activeSellingPlanId=activeFrequencyOption.dataset.sellingPlanId||""),this.sellingPlanInput.value=activeSellingPlanId;var activeSubQuantityOption=(_this$quantityOptions3=this.quantityOptionsContainer)===null||_this$quantityOptions3===void 0?void 0:_this$quantityOptions3.querySelector(".".concat(QUANTITY_OPTION_ACTIVE_CLASS));if(activeSubQuantityOption){var _this$quantityOptions4,selectedQuantityValue=activeSubQuantityOption.dataset.quantity,subQuantityOptionToActivate=(_this$quantityOptions4=this.quantityOptionsContainer)===null||_this$quantityOptions4===void 0?void 0:_this$quantityOptions4.querySelector("".concat(QUANTITY_OPTION_SELECTOR,'[data-quantity="').concat(selectedQuantityValue,'"]'));if(subQuantityOptionToActivate)this.quantityOptions.forEach(function(opt){opt.classList.remove(QUANTITY_OPTION_ACTIVE_CLASS),_this2._setRadioChecked(opt,!1)}),subQuantityOptionToActivate.classList.add(QUANTITY_OPTION_ACTIVE_CLASS),this._setRadioChecked(subQuantityOptionToActivate),this.updateSelectedQuantityDisplay(subQuantityOptionToActivate),this._updateMainProductQuantityInput(parseInt(selectedQuantityValue));else{var _this$quantityOptions5,firstSubQuantityOption=(_this$quantityOptions5=this.quantityOptionsContainer)===null||_this$quantityOptions5===void 0?void 0:_this$quantityOptions5.querySelector("".concat(QUANTITY_OPTION_SELECTOR,'[data-quantity="1"]'));this.quantityOptions.forEach(function(opt){opt.classList.remove(QUANTITY_OPTION_ACTIVE_CLASS);var optRadio=opt.querySelector('input[type="radio"]');optRadio&&(optRadio.checked=!1)}),firstSubQuantityOption.classList.add(QUANTITY_OPTION_ACTIVE_CLASS),this._setRadioChecked(firstSubQuantityOption),this.updateSelectedQuantityDisplay(firstSubQuantityOption),this._updateMainProductQuantityInput(1)}}}this.updateQuantityOptionsWithDiscount(frequencyDiscountForQuantityUpdate),this.updateVisibility(),this._updateMainProductPriceDisplay()}}},{key:"updateVisibility",value:function(){var isOneTimeActive=this.oneTimeButton&&this.oneTimeButton.classList.contains(ACTIVE_CLASS),isSubscriptionActive2=this.subscriptionButton&&this.subscriptionButton.classList.contains(ACTIVE_CLASS);!isSubscriptionActive2&&this.frequencyOptionsContainer&&this.frequencyOptionsContainer.classList.remove(FREQUENCY_OPTIONS_ACTIVE_CLASS),!isSubscriptionActive2&&this.quantityOptionsContainer&&this.quantityOptionsContainer.classList.remove(QUANTITY_OPTIONS_ACTIVE_CLASS),this.subscriptionWidgetWrapper&&this.subscriptionWidgetWrapper.classList.toggle(HIDDEN_CLASS,!isSubscriptionActive2),this.quantityBreaksContainer&&this.quantityBreaksContainer.classList.toggle(HIDDEN_CLASS,!isOneTimeActive)}},{key:"toggleDropdown",value:function(event,optionsContainer){optionsContainer&&(event.stopPropagation(),optionsContainer.classList.toggle(optionsContainer.classList.contains("sga-subscription-widget__quantity-dropdown__options")?QUANTITY_OPTIONS_ACTIVE_CLASS:FREQUENCY_OPTIONS_ACTIVE_CLASS))}},{key:"selectFrequencyOption",value:function(event){var _this3=this,selectedOption=event.currentTarget;this._setRadioChecked(selectedOption),this.frequencySelectedValue&&(this.frequencySelectedValue.textContent=selectedOption.dataset.sellingPlanName,this.frequencySelectedLabelAlt&&(this.frequencySelectedLabelAlt.textContent=selectedOption.dataset.sellingPlanLabelAlt),this.frequencySelectedLabel&&(this.frequencySelectedLabel.textContent=selectedOption.dataset.sellingPlanLabel)),this.frequencyOptions&&this.frequencyOptions.forEach(function(opt){opt.classList.remove(FREQUENCY_OPTION_ACTIVE_CLASS),_this3._setRadioChecked(opt,!1)}),selectedOption.classList.add(FREQUENCY_OPTION_ACTIVE_CLASS),this._setRadioChecked(selectedOption);var sellingPlanId=selectedOption.dataset.sellingPlanId||"";this.sellingPlanInput&&(this.sellingPlanInput.value=sellingPlanId),this.frequencyOptionsContainer&&this.frequencyOptionsContainer.classList.remove(FREQUENCY_OPTIONS_ACTIVE_CLASS);var newFrequencyDiscount=parseFloat(selectedOption.dataset.discountPercentage)||0;this.updateQuantityOptionsWithDiscount(newFrequencyDiscount),this._updateMainProductPriceDisplay(),this.subscriptionLabelValue.innerHTML=newFrequencyDiscount}},{key:"updateQuantityOptionsWithIntelligemsPrice",value:function(){var frequencyDiscountPercentage=0,activeFrequencyOption=this.frequencyOptionsContainer?this.frequencyOptionsContainer.querySelector(".".concat(FREQUENCY_OPTION_ACTIVE_CLASS)):null;activeFrequencyOption&&(frequencyDiscountPercentage=parseFloat(activeFrequencyOption.dataset.discountPercentage)||0),this.updateQuantityOptionsWithDiscount(frequencyDiscountPercentage),this.subscriptionButton&&this.subscriptionButton.classList.contains(ACTIVE_CLASS)&&this._updateMainProductPriceDisplay()}},{key:"updateQuantityOptionsWithDiscount",value:function(frequencyDiscountPercentage){var _this4=this;if(!(!this.quantityOptions||this.quantityOptions.length===0||typeof Shopify.formatMoney!="function")){this.quantityOptions.forEach(function(option){var quantity=parseInt(option.dataset.quantity),originalTotalForOption=_this4.productPrice*quantity,priceAfterFrequencyDiscount=originalTotalForOption*(1-frequencyDiscountPercentage/100),totalSavingsForOption=originalTotalForOption-priceAfterFrequencyDiscount,priceWrapper=option.querySelector(QUANTITY_PRICE_WRAPPER_SELECTOR),priceDisplay=priceWrapper==null?void 0:priceWrapper.querySelector(QUANTITY_PRICE_SELECTOR),savingsDisplay=priceWrapper==null?void 0:priceWrapper.querySelector(QUANTITY_SAVINGS_VALUE_SELECTOR),optionDiscountPercentageEl=priceWrapper==null?void 0:priceWrapper.querySelector(QUANTITY_DISCOUNT_BADGE_SELECTOR);optionDiscountPercentageEl&&(optionDiscountPercentageEl.innerHTML="".concat(frequencyDiscountPercentage,"%")),priceDisplay&&(priceDisplay.innerHTML=Shopify.formatMoney(priceAfterFrequencyDiscount)),savingsDisplay&&(totalSavingsForOption>0?savingsDisplay.innerHTML=Shopify.formatMoney(totalSavingsForOption):savingsDisplay.innerHTML=Shopify.formatMoney(0))});var activeQuantityOption=this.quantityOptionsContainer?this.quantityOptionsContainer.querySelector(".".concat(QUANTITY_OPTION_ACTIVE_CLASS)):null;activeQuantityOption&&this.updateSelectedQuantityDisplay(activeQuantityOption)}}},{key:"selectQuantityOption",value:function(event){var _this5=this,selectedOption=event.currentTarget,radioInput=selectedOption.querySelector('input[type="radio"]'),newQuantity=parseInt(selectedOption.dataset.quantity)||1,frequencyDiscountForQuantityUpdate=0,activeFrequencyOption=this.frequencyOptionsContainer?this.frequencyOptionsContainer.querySelector(".".concat(FREQUENCY_OPTION_ACTIVE_CLASS)):null;activeFrequencyOption&&(frequencyDiscountForQuantityUpdate=parseFloat(activeFrequencyOption.dataset.discountPercentage)||0),this.quantityOptions&&this.quantityOptions.forEach(function(opt){opt.classList.remove(QUANTITY_OPTION_ACTIVE_CLASS),_this5._setRadioChecked(opt,!1)}),selectedOption.classList.add(QUANTITY_OPTION_ACTIVE_CLASS),radioInput&&(radioInput.checked=!0),this.updateSelectedQuantityDisplay(selectedOption),this.quantityOptionsContainer&&this.quantityOptionsContainer.classList.remove(QUANTITY_OPTIONS_ACTIVE_CLASS),this._updateMainProductQuantityInput(newQuantity),this._updateMainProductPriceDisplay()}},{key:"updateSelectedQuantityDisplay",value:function(selectedQuantityOption){if(!(!this.quantitySelectedTextWrapper||!this.quantitySelectedPriceWrapper||typeof Shopify.formatMoney!="function")){var mainTextEl=this.quantitySelectedTextWrapper.querySelector(QUANTITY_MAIN_TEXT_SELECTOR),subTextEl=this.quantitySelectedTextWrapper.querySelector(QUANTITY_SUB_TEXT_SELECTOR),optionDiscountPercentageEl=this.quantitySelectedPriceWrapper.querySelector(QUANTITY_DISCOUNT_BADGE_SELECTOR),priceEl=this.quantitySelectedPriceWrapper.querySelector(QUANTITY_PRICE_SELECTOR),savingsEl=this.quantitySelectedPriceWrapper.querySelector(QUANTITY_SAVINGS_SELECTOR),optionMainText=selectedQuantityOption.querySelector(QUANTITY_MAIN_TEXT_SELECTOR).textContent,optionSubText=selectedQuantityOption.querySelector(QUANTITY_SUB_TEXT_SELECTOR).textContent,optionDiscountPercentageText=selectedQuantityOption.querySelector(QUANTITY_DISCOUNT_BADGE_SELECTOR).textContent,priceText=selectedQuantityOption.querySelector(QUANTITY_PRICE_SELECTOR).textContent,savingsText=selectedQuantityOption.querySelector(QUANTITY_SAVINGS_SELECTOR).textContent;mainTextEl&&(mainTextEl.textContent=optionMainText),subTextEl&&(subTextEl.textContent=optionSubText),optionDiscountPercentageEl&&(optionDiscountPercentageEl.textContent=optionDiscountPercentageText),priceEl&&(priceEl.textContent=priceText),savingsEl&&(savingsEl.textContent=savingsText)}}},{key:"handleClickOutside",value:function(event){this.frequencyOptionsContainer&&this.frequencyOptionsContainer.classList.contains(FREQUENCY_OPTIONS_ACTIVE_CLASS)&&this.frequencyDropdownContainer&&!this.frequencyDropdownContainer.contains(event.target)&&this.frequencyOptionsContainer.classList.remove(FREQUENCY_OPTIONS_ACTIVE_CLASS),this.quantityOptionsContainer&&this.quantityOptionsContainer.classList.contains(QUANTITY_OPTIONS_ACTIVE_CLASS)&&this.quantityDropdown&&!this.quantityDropdown.contains(event.target)&&this.quantityOptionsContainer.classList.remove(QUANTITY_OPTIONS_ACTIVE_CLASS)}}])})();function initSubscriptionWidget(){var subscriptionWidgets=document.querySelectorAll(SUBSCRIPTION_WIDGET_SELECTOR);
8subscriptionWidgets.forEach(function(widgetElement){new SGASubscriptionWidget(widgetElement)})}document.addEventListener("DOMContentLoaded",function(){return initSubscriptionWidget()}),document.addEventListener("on:variant:content:updated",function(){return initSubscriptionWidget()});function _quantity_breaks_typeof(o){"@babel/helpers - typeof";return _quantity_breaks_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_quantity_breaks_typeof(o)}function _quantity_breaks_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _quantity_breaks_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_quantity_breaks_toPropertyKey(o.key),o)}}function _quantity_breaks_createClass(e,r,t){return r&&_quantity_breaks_defineProperties(e.prototype,r),t&&_quantity_breaks_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _quantity_breaks_toPropertyKey(t){var i=_quantity_breaks_toPrimitive(t,"string");return _quantity_breaks_typeof(i)=="symbol"?i:i+""}function _quantity_breaks_toPrimitive(t,r){if(_quantity_breaks_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_quantity_breaks_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&(_quantity_breaks_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _wrapNativeSuper=function(t2){if(t2===null||!_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _construct(t2,arguments,_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(Wrapper,t2)},_wrapNativeSuper(t)}function _construct(t,e,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_setPrototypeOf(p,r.prototype),p}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_isNativeReflectConstruct=function(){return!!t})()}function _isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_setPrototypeOf(t,e)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_getPrototypeOf(t)}if(!customElements.get("sga-quantity-breaks")){var SgaQuantityBreaks=(function(_HTMLElement){function SgaQuantityBreaks2(){return _quantity_breaks_classCallCheck(this,SgaQuantityBreaks2),_callSuper(this,SgaQuantityBreaks2,arguments)}return _inherits(SgaQuantityBreaks2,_HTMLElement),_quantity_breaks_createClass(SgaQuantityBreaks2,[{
8key:"connectedCallback",value:function(){this.productId=this.getAttribute("data-product-id"),this.init()}},{key:"updateMainProductPrice",value:function(){var intelliGemsPrice=getIntelligemsPrice(this.productId);if(intelliGemsPrice){var productPriceElement=document.querySelector("[data-product-detail-price] [data-cart-price-value]");productPriceElement&&(productPriceElement.innerHTML=Shopify.formatMoney(intelliGemsPrice))}}},{key:"updateQuantityBreakPrices",value:function(){var intelliGemsPrice=getIntelligemsPrice(this.productId);intelliGemsPrice&&this.querySelectorAll("[data-quantity-breaks-json]").forEach(function(jsonElement,index){var rowData=JSON.parse(jsonElement.textContent),quantity=rowData.quantity,discountPercent=rowData.discount_percent||0,regularTotal=intelliGemsPrice*quantity,discountAmount=Math.floor(regularTotal*discountPercent/100),discountedTotal=regularTotal-discountAmount,pricePerUnit=discountPercent>0?Math.ceil(discountedTotal/quantity):intelliGemsPrice;rowData.price_per_unit_original_raw=index===0?null:intelliGemsPrice,rowData.price_per_unit_raw=pricePerUnit,rowData.total_price_raw=discountedTotal,rowData.savings_amount=discountAmount,jsonElement.textContent=JSON.stringify(rowData);var row=jsonElement.closest("[data-quantity-breaks-row]");if(row){var unitPriceElement=row.querySelector(".quantity-breaks__unit-price");if(unitPriceElement){var existingSup=unitPriceElement.querySelector("sup"),pieceText=existingSup?existingSup.textContent:"/kus",formattedPrice=Shopify.formatMoney(pricePerUnit);unitPriceElement.innerHTML=formattedPrice+"<sup>"+pieceText+"</sup>"}if(discountAmount>0){var savingsElement=row.querySelector(".quantity-breaks__savings .whitespace-nowrap");savingsElement&&(savingsElement.innerHTML=Shopify.formatMoney(discountAmount))}}})}},{key:"init",value:function(){var _this=this;waitForIntelligems(function(){_this.updateQuantityBreakPrices(),_this.updateMainProductPrice()}),this.querySelectorAll("[data-quantity-breaks-row]").forEach(function(row){row.onclick=null}),this.querySelectorAll('[name="quantity-option"]').forEach(function(radio){radio.onchange=null}),this.querySelectorAll("[data-quantity-breaks-row]").forEach(function(row){row.addEventListener("click",function(e){if(e.target.type!=="radio"){var radio=row.querySelector('[name="quantity-option"]'),label=row.querySelector("label");label&&radio&&(label.click(),radio.checked=!0,radio.dispatchEvent(new Event("change")))}})}),this.querySelectorAll('[name="quantity-option"]').forEach(function(radio){radio.addEventListener("change",function(e){var _e$detail,_e$detail2,quantity=((_e$detail=e.detail)===null||_e$detail===void 0?void 0:_e$detail.quantityValue)||parseInt(e.target.value),quantityBreaksRowElement=e.target.closest("[data-quantity-breaks-row]"),productForm=_this.closest("product-form")||_this.closest("[data-product-add-to-cart]"),quantityInputContainer=(productForm==null?void 0:productForm.querySelector("[data-quantity-input]"))||document.querySelector("[data-quantity-input]");if(quantityInputContainer){var quantityInputMinus=quantityInputContainer.querySelector('button[name="minus"]'),quantityInputPlus=quantityInputContainer.querySelector('button[name="plus"]'),quantityInput=quantityInputContainer.querySelector(".qty-input__input");if(quantityInputMinus&&(quantityInputMinus.disabled=quantity<=1),quantityInputPlus&&quantityInput){var max=Number(quantityInput.max)||0;quantityInputPlus.disabled=max>0&&quantity>=max}}var rowData=JSON.parse(quantityBreaksRowElement.querySelector("[data-quantity-breaks-json]").textContent),intelliGemsPrice=getIntelligemsPrice(_this.productId),basePrice=intelliGemsPrice||Number(rowData.price_per_unit_original_raw),totalPrice,regularPrice;if(intelliGemsPrice){var discountPercent=Number(rowData.discount_percent)||0,regularTotal=basePrice*Number(quantity),discountAmount=Math.floor(regularTotal*discountPercent/100),discountedTotal=regularTotal-discountAmount;totalPrice=Shopify.formatMoney(discountedTotal),regularPrice=rowData.price_per_unit_original_raw===null?"":Shopify.formatMoney(regularTotal)}else totalPrice=Shopify.formatMoney(Number(rowData.total_price_raw)),regularPrice=rowData.price_per_unit_original_raw===null?"":Shopify.formatMoney(Number(rowData.price_per_unit_original_raw)*Number(quantity));var savingsAmount=Shopify.formatMoney(rowData.savings_amount);document.querySelector("[data-cart-quantity-input]").value=quantity,document.querySelector("[data-product-detail-price] [data-cart-price-value]").innerHTML=totalPrice,document.querySelector("[data-product-detail-price] [data-cart-price-was-value]").innerHTML=regularPrice,document.querySelector("[data-product-detail-price] [data-cart-discount-percent-value]").innerHTML=rowData.discount_percent,document.querySelector("[data-product-detail-price] [data-cart-discount-value]").innerHTML=savingsAmount,document.querySelector("[data-product-detail-price] [data-cart-discount-element]").classList.toggle("!hidden",Number(rowData.index)===0),(_e$detail2=e.detail)!==null&&_e$detail2!==void 0&&_e$detail2.quantityValue||document.querySelectorAll(".quantity-breaks__row").forEach(function(row){var match=row.querySelector("#qty-".concat(quantity));row.classList.toggle("selected",!!match),row.querySelector("input").dataset.lastInputValue=quantity}
8),window.globals.updateQuickFacts(quantity,rowData)})});var firstRadio=this.querySelector('[name="quantity-option"]:checked');if(firstRadio){var firstRow=firstRadio.closest(".quantity-breaks__row");firstRow.classList.add("selected")}}}])})(_wrapNativeSuper(HTMLElement));customElements.define("sga-quantity-breaks",SgaQuantityBreaks)}function _product_card_mini_price_update_typeof(o){"@babel/helpers - typeof";return _product_card_mini_price_update_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_product_card_mini_price_update_typeof(o)}function _product_card_mini_price_update_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _product_card_mini_price_update_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_product_card_mini_price_update_toPropertyKey(o.key),o)}}function _product_card_mini_price_update_createClass(e,r,t){return r&&_product_card_mini_price_update_defineProperties(e.prototype,r),t&&_product_card_mini_price_update_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _product_card_mini_price_update_toPropertyKey(t){var i=_product_card_mini_price_update_toPrimitive(t,"string");return _product_card_mini_price_update_typeof(i)=="symbol"?i:i+""}function _product_card_mini_price_update_toPrimitive(t,r){if(_product_card_mini_price_update_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_product_card_mini_price_update_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _product_card_mini_price_update_callSuper(t,o,e){return o=_product_card_mini_price_update_getPrototypeOf(o),_product_card_mini_price_update_possibleConstructorReturn(t,_product_card_mini_price_update_isNativeReflectConstruct()?Reflect.construct(o,e||[],_product_card_mini_price_update_getPrototypeOf(t).constructor):o.apply(t,e))}function _product_card_mini_price_update_possibleConstructorReturn(t,e){if(e&&(_product_card_mini_price_update_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _product_card_mini_price_update_assertThisInitialized(t)}function _product_card_mini_price_update_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _product_card_mini_price_update_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_product_card_mini_price_update_setPrototypeOf(t,e)}function _product_card_mini_price_update_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _product_card_mini_price_update_wrapNativeSuper=function(t2){if(t2===null||!_product_card_mini_price_update_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _product_card_mini_price_update_construct(t2,arguments,_product_card_mini_price_update_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_product_card_mini_price_update_setPrototypeOf(Wrapper,t2)},_product_card_mini_price_update_wrapNativeSuper(t)}function _product_card_mini_price_update_construct(t,e,r){if(_product_card_mini_price_update_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_product_card_mini_price_update_setPrototypeOf(p,r.prototype),p}function _product_card_mini_price_update_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_product_card_mini_price_update_isNativeReflectConstruct=function(){return!!t})()}function _product_card_mini_price_update_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _product_card_mini_price_update_setPrototypeOf(t,e){return _product_card_mini_price_update_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_product_card_mini_price_update_setPrototypeOf(t,e)}function _product_card_mini_price_update_getPrototypeOf(t){return _product_card_mini_price_update_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_product_card_mini_price_update_getPrototypeOf(t)}var SgaProductCardMiniPriceUpdate=(function(_HTMLElement){function SgaProductCardMiniPriceUpdate2(){return _product_card_mini_price_update_classCallCheck(this,SgaProductCardMiniPriceUpdate2),_product_card_mini_price_update_callSuper(this,SgaProductCardMiniPriceUpdate2,arguments)}return _product_card_mini_price_update_inherits(SgaProductCardMiniPriceUpdate2,_HTMLElement),_product_card_mini_price_update_createClass(SgaProductCardMiniPriceUpdate2,[{key:"c
8onnectedCallback",value:function(){this.productId=this.getAttribute("data-product-id"),this.nextDiscount=parseFloat(this.getAttribute("data-next-discount"))||0,this.productId&&this.nextDiscount>0&&this.init()}},{key:"init",value:function(){var _this=this;waitForIntelligems(function(){_this.updateQuantityBreakPrices()})}},{key:"updateQuantityBreakPrices",value:function(){var intelliGemsPrice=getIntelligemsPrice(this.productId);if(intelliGemsPrice){var currentPriceElement=this.querySelector("[data-cart-price-value]"),wasPriceElement=this.querySelector("[data-cart-price-was-value]");if(!(!currentPriceElement||!wasPriceElement)){var discountMultiplier=(100-this.nextDiscount)/100,newPrice=intelliGemsPrice*discountMultiplier,formattedNewPrice=Shopify.formatMoney(newPrice),formattedOriginalPrice=Shopify.formatMoney(intelliGemsPrice);currentPriceElement.innerHTML=formattedNewPrice,wasPriceElement.innerHTML=formattedOriginalPrice}}}}])})(_product_card_mini_price_update_wrapNativeSuper(HTMLElement));customElements.get("sga-product-card-mini-price-update")||customElements.define("sga-product-card-mini-price-update",SgaProductCardMiniPriceUpdate);function _price_range_typeof(o){"@babel/helpers - typeof";return _price_range_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_price_range_typeof(o)}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r2){return Object.getOwnPropertyDescriptor(e,r2).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r2){_defineProperty(e,r2,t[r2])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r2){Object.defineProperty(e,r2,Object.getOwnPropertyDescriptor(t,r2))})}return e}function _defineProperty(e,r,t){return(r=_price_range_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(r){if(typeof Symbol!="undefined"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t2,e2,r2){t2[e2]=r2.value},i=typeof Symbol=="function"?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t2,e2,r2){return Object.defineProperty(t2,e2,{value:r2,enumerable:!0,configurable:!0,writable:!0}),t2[e2]}try{define({},"")}catch(t2){define=function(t3,e2,r2){return t3[e2]=r2}}function wrap(t2,e2,r2,n2){var i2=e2&&e2.prototype instanceof Generator?e2:Generator,a2=Object.create(i2.prototype),c2=new Context(n2||[]);return o(a2,"_invoke",{value:makeInvokeMethod(t2,r2,c2)}),a2}function tryCatch(t2,e2,r2){try{return{type:"normal",arg:t2.call(e2,r2)}}catch(t3){return{type:"throw",arg:t3}}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t2){["next","throw","return"].forEach(function(e2){define(t2,e2,function(t3){return this._invoke(e2,t3)})})}function AsyncIterator(t2,e2){function invoke(r3,o2,i2,a2){var c2=tryCatch(t2[r3],t2,o2);if(c2.type!=="throw"){var u2=c2.arg,h2=u2.value;return h2&&_price_range_typeof(h2)=="object"&&n.call(h2,"__await")?e2.resolve(h2.__await).then(function(t3){invoke("next",t3,i2,a2)},function(t3){invoke("throw",t3,i2,a2)}):e2.resolve(h2).then(function(t3){u2.value=t3,i2(u2)},function(t3){return invoke("throw",t3,i2,a2)})}a2(c2.arg)}var r2;o(this,"_invoke",{value:function(t3,n2){function callInvokeWithMethodAndArg(){return new e2(function(e3,r3){invoke(t3,n2,e3,r3)})}return r2=r2?r2.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(e2,r2,n2){var o2=h;return function(i2,a2){if(o2===f)throw Error("Generator is already running");if(o2===s){if(i2==="throw")throw a2;return{value:t,done:!0}}for(n2.method=i2,n2.arg=a2;;){var c2=n2.delegate;if(c2){var u2=maybeInvokeDelegate(c2,n2);if(u2){if(u2===y)continue;return u2}}if(n2.method==="next")n2.sent=n2._sent=n2.arg;else if(n2.method==="throw"){if(o2===h)throw o2=s,n2.arg;n2.dispatchException(n2.arg)}else n2.method==="return"&&n2.abrupt("return",n2.arg);o2=f;var p2=tryCatch(e2,r2,n2);if(p2.type==="normal"){if(o2=n2.done?s:l,p2.arg===y)continue;return{value:p2.arg,done:n2.done}}p2.type==="throw"&&(o2=s,n2.method="throw",n2.arg=p2.arg)}}}function maybeInvokeDelegate(e2,r2){var n2=r2.method,o2=e2.iterator[n2];if(o2===t)return r2.delegate=null,n2==="throw"&&e2.iterator.return&&
vendor: 7,591 bytes, line 8
8(r2.method="return",r2.arg=t,maybeInvokeDelegate(e2,r2),r2.method==="throw")||n2!=="return"&&(r2.method="throw",r2.arg=new TypeError("The iterator does not provide a '"+n2+"' method")),y;var i2=tryCatch(o2,e2.iterator,r2.arg);if(i2.type==="throw")return r2.method="throw",r2.arg=i2.arg,r2.delegate=null,y;var a2=i2.arg;return a2?a2.done?(r2[e2.resultName]=a2.value,r2.next=e2.nextLoc,r2.method!=="return"&&(r2.method="next",r2.arg=t),r2.delegate=null,y):a2:(r2.method="throw",r2.arg=new TypeError("iterator result is not an object"),r2.delegate=null,y)}function pushTryEntry(t2){var e2={tryLoc:t2[0]};1 in t2&&(e2.catchLoc=t2[1]),2 in t2&&(e2.finallyLoc=t2[2],e2.afterLoc=t2[3]),this.tryEntries.push(e2)}function resetTryEntry(t2){var e2=t2.completion||{};e2.type="normal",delete e2.arg,t2.completion=e2}function Context(t2){this.tryEntries=[{tryLoc:"root"}],t2.forEach(pushTryEntry,this),this.reset(!0)}function values(e2){if(e2||e2===""){var r2=e2[a];if(r2)return r2.call(e2);if(typeof e2.next=="function")return e2;if(!isNaN(e2.length)){var o2=-1,i2=function next(){for(;++o2<e2.length;)if(n.call(e2,o2))return next.value=e2[o2],next.done=!1,next;return next.value=t,next.done=!0,next};return i2.next=i2}}throw new TypeError(_price_range_typeof(e2)+" is not iterable")}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t2){var e2=typeof t2=="function"&&t2.constructor;return!!e2&&(e2===GeneratorFunction||(e2.displayName||e2.name)==="GeneratorFunction")},e.mark=function(t2){return Object.setPrototypeOf?Object.setPrototypeOf(t2,GeneratorFunctionPrototype):(t2.__proto__=GeneratorFunctionPrototype,define(t2,u,"GeneratorFunction")),t2.prototype=Object.create(g),t2},e.awrap=function(t2){return{__await:t2}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this}),e.AsyncIterator=AsyncIterator,e.async=function(t2,r2,n2,o2,i2){i2===void 0&&(i2=Promise);var a2=new AsyncIterator(wrap(t2,r2,n2,o2),i2);return e.isGeneratorFunction(r2)?a2:a2.next().then(function(t3){return t3.done?t3.value:a2.next()})},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this}),define(g,"toString",function(){return"[object Generator]"}),e.keys=function(t2){var e2=Object(t2),r2=[];for(var n2 in e2)r2.push(n2);return r2.reverse(),function next(){for(;r2.length;){var t3=r2.pop();if(t3 in e2)return next.value=t3,next.done=!1,next}return next.done=!0,next}},e.values=values,Context.prototype={constructor:Context,reset:function(e2){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e2)for(var r2 in this)r2.charAt(0)==="t"&&n.call(this,r2)&&!isNaN(+r2.slice(1))&&(this[r2]=t)},stop:function(){this.done=!0;var t2=this.tryEntries[0].completion;if(t2.type==="throw")throw t2.arg;return this.rval},dispatchException:function(e2){if(this.done)throw e2;var r2=this;function handle(n2,o3){return a2.type="throw",a2.arg=e2,r2.next=n2,o3&&(r2.method="next",r2.arg=t),!!o3}for(var o2=this.tryEntries.length-1;o2>=0;--o2){var i2=this.tryEntries[o2],a2=i2.completion;if(i2.tryLoc==="root")return handle("end");if(i2.tryLoc<=this.prev){var c2=n.call(i2,"catchLoc"),u2=n.call(i2,"finallyLoc");if(c2&&u2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0);if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}else if(c2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0)}else{if(!u2)throw Error("try statement without catch or finally");if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}}}},abrupt:function(t2,e2){for(var r2=this.tryEntries.length-1;r2>=0;--r2){var o2=this.tryEntries[r2];if(o2.tryLoc<=this.prev&&n.call(o2,"finallyLoc")&&this.prev<o2.finallyLoc){var i2=o2;break}}i2&&(t2==="break"||t2==="continue")&&i2.tryLoc<=e2&&e2<=i2.finallyLoc&&(i2=null);var a2=i2?i2.completion:{};return a2.type=t2,a2.arg=e2,i2?(this.method="next",this.next=i2.finallyLoc,y):this.complete(a2)},complete:function(t2,e2){if(t2.type==="throw")throw t2.arg;return t2.type==="break"||t2.type==="continue"?this.next=t2.arg:t2.type==="return"?(this.rval=this.arg=t2.arg,this.method="return",this.next="end"):t2.type==="normal"&&e2&&(this.next=e2),y},finish:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.finallyLoc===t2)return this.complete(r2.completion,r2.afterLoc),resetTryEntry(r2),y}},catch:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.tryLoc===t2){var n2=r2.completion;if(n2.type==="throw"){var o2=n2.arg;resetTryEntry(r2)}return o2}}throw Error("illegal catch attempt")},delegateYield:function(e2,r2,n2){return this.delegate={iterator:values(e2),resultName:r2,nextLoc:n2},this.method==="next"&&(this.arg=t),y}},e}function _createForOfIteratorHelper(r,e){var t=typeof Symbol!="undefined"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var _n=0,F=function(){};return{s:F,n:function(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]}},e:function(r2){throw r2},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r2=t.next();return a=r2.done,r2},e:function(r2){u=!0,o=r2},f:function(){try{a||t.return==null||t.return()}finally{if(u)throw o}}}}function _unsupportedIterableToArray(r,a){if(r){if(typeof r=="string")return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(a==null||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n2){return void e(n2)}i.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n2){asyncGeneratorStep(a,r,o,_next,_throw,"next",n2)}function _throw(n2){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n2)}_next(void 0)})}}function _price_range_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _price_range_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_price_range_toPropertyKey(o.key),o)}}function _price_range_createClass(e,r,t){return r&&_price_range_defineProperties(e.prototype,r),t&&_price_range_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _price_range_toPropertyKey(t){var i=_price_range_toPrimitive(t,"string");return _price_range_typeof(i)=="symbol"?i:i+""}function _price_range_toPrimitive(t,r){if(_price_range_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_price_range_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}
8function _price_range_callSuper(t,o,e){return o=_price_range_getPrototypeOf(o),_price_range_possibleConstructorReturn(t,_price_range_isNativeReflectConstruct()?Reflect.construct(o,e||[],_price_range_getPrototypeOf(t).constructor):o.apply(t,e))}function _price_range_possibleConstructorReturn(t,e){if(e&&(_price_range_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _price_range_assertThisInitialized(t)}function _price_range_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _price_range_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_price_range_setPrototypeOf(t,e)}function _price_range_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _price_range_wrapNativeSuper=function(t2){if(t2===null||!_price_range_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _price_range_construct(t2,arguments,_price_range_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_price_range_setPrototypeOf(Wrapper,t2)},_price_range_wrapNativeSuper(t)}function _price_range_construct(t,e,r){if(_price_range_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_price_range_setPrototypeOf(p,r.prototype),p}function _price_range_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_price_range_isNativeReflectConstruct=function(){return!!t})()}function _price_range_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _price_range_setPrototypeOf(t,e){return _price_range_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_price_range_setPrototypeOf(t,e)}function _price_range_getPrototypeOf(t){return _price_range_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_price_range_getPrototypeOf(t)}if(!customElements.get("price-range")){var PriceRange=(function(_HTMLElement){function PriceRange2(){var _this;return _price_range_classCallCheck(this,PriceRange2),_this=_price_range_callSuper(this,PriceRange2),window.initLazyScript(_this,_this.init.bind(_this)),_this}return _price_range_inherits(PriceRange2,_HTMLElement),_price_range_createClass(PriceRange2,[{key:"init",value:function(){this.minNumberInput=document.getElementById("price-range-number-min"),this.maxNumberInput=document.getElementById("price-range-number-max"),this.minSliderInput=document.getElementById("price-range-slider-min"),this.maxSliderInput=document.getElementById("price-range-slider-max"),this.minValue=Number(this.minNumberInput.min),this.maxValue=Number(this.maxNumberInput.max),this.timeout=null,this.addEventListener("input",this.handleInput.bind(this)),this.calculateRealPriceRange()}},{key:"handleInput",value:function(evt){var _this2=this;evt.detail!==void 0?(clearTimeout(this.timeout),this.timeout=setTimeout(function(){_this2.updateSliderInputs(evt),_this2.updateNumberInputs()},500)):(this.updateSliderInputs(evt),this.updateNumberInputs())}},{key:"updateNumberInputs",value:function(){this.minNumberInput.value=this.minSliderInput.value!==this.minNumberInput.min?this.minSliderInput.value:null,this.maxNumberInput.value=this.maxSliderInput.value!==this.maxNumberInput.max?this.maxSliderInput.value:null}},{key:"updateSliderInputs",value:function(evt){var minValue=parseInt(this.minNumberInput.value,10),maxValue=parseInt(this.maxNumberInput.value,10);minValue>maxValue-10&&(evt.target===this.minNumberInput?(this.maxSliderInput.value=minValue+10,maxValue===this.maxValue&&(this.minSli
8derInput.value=this.maxValue-10)):this.minSliderInput.value=maxValue-10),maxValue<minValue+10&&(evt.target===this.maxNumberInput?(this.minSliderInput.value=maxValue-10,minValue===this.minValue&&(this.maxSliderInput.value=10)):this.maxSliderInput.value=minValue+10),evt.target===this.minNumberInput&&(this.minSliderInput.value=minValue||Number(this.minNumberInput.min)),evt.target===this.maxNumberInput&&(this.maxSliderInput.value=maxValue||Number(this.maxNumberInput.max))}},{key:"calculateRealPriceRange",value:(function(){var _calculateRealPriceRange=_asyncToGenerator(_regeneratorRuntime().mark(function _callee2(){var _this3=this;return _regeneratorRuntime().wrap(function(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:waitForIntelligems(_asyncToGenerator(_regeneratorRuntime().mark(function _callee(){var searchTerms,products,realPrices,_iterator,_step,product,_iterator2,_step2,variant,variantId,originalPrice,intelligemsPrice,finalPrice,realMin,realMax;return _regeneratorRuntime().wrap(function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(searchTerms=_this3.getAttribute("data-search-terms")||"",_context.prev=1,!searchTerms){_context.next=8;break}return _context.next=5,_this3.getAllProductsFromSearch(searchTerms);case 5:_context.t0=_context.sent,_context.next=11;break;case 8:return _context.next=10,_this3.getAllProductsFromCollection();case 10:_context.t0=_context.sent;case 11:if(products=_context.t0,!(!products||products.length===0)){_context.next=14;break}return _context.abrupt("return");case 14:realPrices=[],_iterator=_createForOfIteratorHelper(products);try{for(_iterator.s();!(_step=_iterator.n()).done;)if(product=_step.value,product.variants&&product.variants.nodes){_iterator2=_createForOfIteratorHelper(product.variants.nodes);try{for(_iterator2.s();!(_step2=_iterator2.n()).done;)variant=_step2.value,variant.priceV2&&(variantId=variant.id.split("/").pop(),originalPrice=parseFloat(variant.priceV2.amount),intelligemsPrice=getIntelligemsPrice(variantId),finalPrice=void 0,intelligemsPrice?finalPrice=intelligemsPrice/100:finalPrice=originalPrice,realPrices.push(finalPrice))}catch(err){_iterator2.e(err)}finally{_iterator2.f()}}}catch(err){_iterator.e(err)}finally{_iterator.f()}realPrices.length>0&&(realMin=Math.min.apply(Math,realPrices),realMax=Math.max.apply(Math,realPrices),_this3.updatePriceRange(realMin,realMax)),_context.next=23;break;case 20:_context.prev=20,_context.t1=_context.catch(1),console.error("Error calculating real price range:",_context.t1);case 23:case"end":return _context.stop()}},_callee,null,[[1,20]])})));case 1:case"end":return _context2.stop()}},_callee2)}));function calculateRealPriceRange(){return _calculateRealPriceRange.apply(this,arguments)}return calculateRealPriceRange})()},{key:"fetchProductsWithPagination",value:(function(){var _fetchProductsWithPagination=_asyncToGenerator(_regeneratorRuntime().mark(function _callee3(query,getVariables,extractProducts){var _window$theme,storefrontToken,allProducts,hasNextPage,cursor,variables,response,data,result;return _regeneratorRuntime().wrap(function(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:storefrontToken=(_window$theme=window.theme)===null||_window$theme===void 0||(_window$theme=_window$theme.settings)===null||_window$theme===void 0?void 0:_window$theme.storefrontApiToken,allProducts=[],hasNextPage=!0,cursor=null,_context3.prev=4;case 5:if(!hasNextPage){_context3.next=23;break}return variables=getVariables(cursor),_context3.next=9,fetch("/api/2024-10/graphql.json",{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":storefrontToken},body:JSON.stringify({query:query,variables:variables})});case 9:return response=_context3.sent,_context3.next=12,response.json();case 12:if(data=_context3.sent,!data.errors){_context3.next=15;break}return _context3.abrupt("return",allProducts);case 15:if(result=extractProducts(data),result){_context3.next=18;break}return _context3.abrupt("return",allProducts);case 18:allProducts.push.apply(allProducts,_toConsumableArray(result.nodes)),hasNextPage=result.pageInfo.hasNextPage,cursor=result.pageInfo.endCursor,_context3.next=5;break;case 23:return _context3.abrupt("return",allProducts);case 26:return _context3.prev=26,_context3.t0=_context3.catch(4),_context3.abrupt("return",[]);case 29:case"end":return _context3.stop()}},_callee3,null,[[4,26]])}));function fetchProductsWithPagination(_x,_x2,_x3){return _fetchProductsWithPagination.apply(this,arguments)}return fetchProductsWithPagination})()},{key:"getAllProductsFromSearch",value:(function(){var _getAllProductsFromSearch=_asyncToGenerator(_regeneratorRuntime().mark(function _callee4(searchTerms){var query,getVariables,extractProducts;return _regeneratorRuntime().wrap(function(_context4){for(;;)switch(_context4.prev=_context4.next){case 0:return query="\n query searchProducts($query: String!, $first: Int!, $after: String) {\n search(query: $query, first: $first, after: $after, types: [PRODUCT]) {\n nodes {\n ... on Product {\n variants(first: 250) {\
8n nodes {\n id\n priceV2 {\n amount\n }\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n ",getVariables=function(cursor){return _objectSpread({query:searchTerms||"*",first:250},cursor&&{after:cursor})},extractProducts=function(data){return data.data.search},_context4.abrupt("return",this.fetchProductsWithPagination(query,getVariables,extractProducts));case 4:case"end":return _context4.stop()}},_callee4,this)}));function getAllProductsFromSearch(_x4){return _getAllProductsFromSearch.apply(this,arguments)}return getAllProductsFromSearch})()},{key:"getAllProductsFromCollection",value:(function(){var _getAllProductsFromCollection=_asyncToGenerator(_regeneratorRuntime().mark(function _callee5(){var _window$location$path,collectionHandle,query,getVariables,extractProducts;return _regeneratorRuntime().wrap(function(_context5){for(;;)switch(_context5.prev=_context5.next){case 0:if(collectionHandle=(_window$location$path=window.location.pathname.split("/collections/")[1])===null||_window$location$path===void 0?void 0:_window$location$path.split("/")[0],collectionHandle){_context5.next=3;break}return _context5.abrupt("return",[]);case 3:return query="\n query getCollectionProducts($handle: String!, $first: Int!, $after: String) {\n collectionByHandle(handle: $handle) {\n products(first: $first, after: $after) {\n nodes {\n variants(first: 250) {\n nodes {\n id\n priceV2 {\n amount\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n ",getVariables=function(cursor){return _objectSpread({handle:collectionHandle,first:250},cursor&&{after:cursor})},extractProducts=function(data){var _data$data$collection;return(_data$data$collection=data.data.collectionByHandle)===null||_data$data$collection===void 0?void 0:_data$data$collection.products},_context5.abrupt("return",this.fetchProductsWithPagination(query,getVariables,extractProducts));case 7:case"end":return _context5.stop()}},_callee5,this)}));function getAllProductsFromCollection(){return _getAllProductsFromCollection.apply(this,arguments)}return getAllProductsFromCollection})()},{key:"updatePriceRange",value:function(newMin,newMax){var currentMin=this.minValue,currentMax=this.maxValue,roundedMin=Math.floor(newMin),roundedMax=Math.ceil(newMax);(roundedMin!==currentMin||roundedMax!==currentMax)&&(this.minValue=roundedMin,this.maxValue=roundedMax,this.minNumberInput.setAttribute("min",roundedMin),this.minNumberInput.setAttribute("placeholder",roundedMin),this.minSliderInput.setAttribute("min",roundedMin),this.maxSliderInput.setAttribute("min",roundedMin),this.maxNumberInput.setAttribute("max",roundedMax),this.maxNumberInput.setAttribute("placeholder",roundedMax),this.maxSliderInput.setAttribute("max",roundedMax),this.minSliderInput.setAttribute("max",roundedMax),parseInt(this.minSliderInput.value)<roundedMin&&(this.minSliderInput.value=roundedMin),parseInt(this.maxSliderInput.value)>roundedMax&&(this.maxSliderInput.value=roundedMax,this.maxNumberInput.value=""))}}])})(_price_range_wrapNativeSuper(HTMLElement));customElements.define("price-range",PriceRange)}function _sga_price_typeof(o){"@babel/helpers - typeof";return _sga_price_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_sga_price_typeof(o)}function _sga_price_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _sga_price_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_sga_price_toPropertyKey(o.key),o)}}function _sga_price_createClass(e,r,t){return r&&_sga_price_defineProperties(e.prototype,r),t&&_sga_price_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _sga_price_toPropertyKey(t){var i=_sga_price_toPrimitive(t,"string");return _sga_price_typeof(i)=="symbol"?i:i+""}function _sga_price_toPrimitive(t,r){if(_sga_price_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_sga_price_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _sga_price_callSuper(t,o,e){return o=_sga_price_getPrototypeOf(o
8),_sga_price_possibleConstructorReturn(t,_sga_price_isNativeReflectConstruct()?Reflect.construct(o,e||[],_sga_price_getPrototypeOf(t).constructor):o.apply(t,e))}function _sga_price_possibleConstructorReturn(t,e){if(e&&(_sga_price_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _sga_price_assertThisInitialized(t)}function _sga_price_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _sga_price_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_sga_price_setPrototypeOf(t,e)}function _sga_price_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _sga_price_wrapNativeSuper=function(t2){if(t2===null||!_sga_price_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _sga_price_construct(t2,arguments,_sga_price_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_sga_price_setPrototypeOf(Wrapper,t2)},_sga_price_wrapNativeSuper(t)}function _sga_price_construct(t,e,r){if(_sga_price_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_sga_price_setPrototypeOf(p,r.prototype),p}function _sga_price_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_sga_price_isNativeReflectConstruct=function(){return!!t})()}function _sga_price_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _sga_price_setPrototypeOf(t,e){return _sga_price_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_sga_price_setPrototypeOf(t,e)}function _sga_price_getPrototypeOf(t){return _sga_price_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_sga_price_getPrototypeOf(t)}var SgaPrice=(function(_HTMLElement){function SgaPrice2(){return _sga_price_classCallCheck(this,SgaPrice2),_sga_price_callSuper(this,SgaPrice2,arguments)}return _sga_price_inherits(SgaPrice2,_HTMLElement),_sga_price_createClass(SgaPrice2,[{key:"connectedCallback",value:function(){this.variantId=this.getAttribute("data-variant-id"),this.variantId&&this.init()}},{key:"init",value:function(){var _this=this;waitForIntelligems(function(){_this.updateIntelligemsPrice()})}},{key:"formatPrice",value:function(priceInCents){return priceInCents==null?"":typeof Shopify!="undefined"&&typeof Shopify.formatMoney=="function"?Shopify.formatMoney(priceInCents):(Number(priceInCents)/100).toFixed(2)}},{key:"updateIntelligemsPrice",value:function(){var intelliGemsPrice=this.variantId?getIntelligemsPrice(this.variantId):null;if(intelliGemsPrice!=null){var currentPriceElement=this.querySelector("[data-cart-price-value]");currentPriceElement&&(currentPriceElement.innerHTML=this.formatPrice(intelliGemsPrice),typeof this.updateDiscountBlocks=="function"&&this.updateDiscountBlocks(intelliGemsPrice))}}}])})(_sga_price_wrapNativeSuper(HTMLElement));customElements.get("sga-price")||customElements.define("sga-price",SgaPrice);function _sga_variant_select_typeof(o){"@babel/helpers - typeof";return _sga_variant_select_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_sga_variant_select_typeof(o)}function _sga_variant_select_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _sga_variant_select_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_sga_variant_select_toPropertyKey(o.key),o)}}function _sga_variant_select_createClass(e,r,t){return r&&_sga_variant_select_defineProperties(e.prototype,r),t&&_sga_variant_select_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _sga_variant_select_toPropertyKey(t){var i=_sga_variant_select_toPrimitive(t,"string");return _sga_variant_select_typeof(i)=="symbol"?i:i+""}function _sga_variant_select_toPrimitive(t,r){if(_sga_variant_select_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_sga_variant_select_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _sga_variant_select_callSuper(t,o,e){return o=_sga_variant_select_getPrototypeOf(o
8),_sga_variant_select_possibleConstructorReturn(t,_sga_variant_select_isNativeReflectConstruct()?Reflect.construct(o,e||[],_sga_variant_select_getPrototypeOf(t).constructor):o.apply(t,e))}function _sga_variant_select_possibleConstructorReturn(t,e){if(e&&(_sga_variant_select_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _sga_variant_select_assertThisInitialized(t)}function _sga_variant_select_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _sga_variant_select_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_sga_variant_select_setPrototypeOf(t,e)}function _sga_variant_select_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _sga_variant_select_wrapNativeSuper=function(t2){if(t2===null||!_sga_variant_select_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _sga_variant_select_construct(t2,arguments,_sga_variant_select_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_sga_variant_select_setPrototypeOf(Wrapper,t2)},_sga_variant_select_wrapNativeSuper(t)}function _sga_variant_select_construct(t,e,r){if(_sga_variant_select_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_sga_variant_select_setPrototypeOf(p,r.prototype),p}function _sga_variant_select_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_sga_variant_select_isNativeReflectConstruct=function(){return!!t})()}function _sga_variant_select_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _sga_variant_select_setPrototypeOf(t,e){return _sga_variant_select_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_sga_variant_select_setPrototypeOf(t,e)}function _sga_variant_select_getPrototypeOf(t){return _sga_variant_select_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_sga_variant_select_getPrototypeOf(t)}if(!customElements.get("sga-variant-select")){var SgaVariantSelect=(function(_HTMLElement){function SgaVariantSelect2(){return _sga_variant_select_classCallCheck(this,SgaVariantSelect2),_sga_variant_select_callSuper(this,SgaVariantSelect2)}return _sga_variant_select_inherits(SgaVariantSelect2,_HTMLElement),_sga_variant_select_createClass(SgaVariantSelect2,[{key:"connectedCallback",value:function(){var _this=this;this.init(),waitForIntelligems(function(){_this.updateIntelligemsPrices()})}},{key:"disconnectedCallback",value:function(){this.cleanup(),this._initialized=!1}},{key:"init",value:function(){var _this2=this;this._initialized&&this.cleanup();var selected=this.querySelector("[data-sga-variant-select-selected]"),variants=this.querySelector("[data-sga-variant-select-variants]"),variantItems=this.querySelectorAll("[data-sga-variant-select-variants-item]");if(!(!selected||!variants||!variantItems.length)){this._selected=selected,this._variants=variants,this._variantItems=variantItems;var updateHiddenItems=function(){var _selected$querySelect,selectedContent=((_selected$querySelect=selected.querySelector(".sga-variant-select-content"))===null||_selected$querySelect===void 0?void 0:_selected$querySelect.outerHTML)||"";variantItems.forEach(function(item){var _item$querySelector,itemContent=((_item$querySelector=item.querySelector(".sga-variant-select-content"))===null||_item$querySelector===void 0?void 0:_item$querySelector.outerHTML)||"";itemContent===selectedContent?item.classList.add("hidden"):item.classList.remove("hidden")})};
8selected.onclick=null,variantItems.forEach(function(item){return item.onclick=null}),this._selectedClickHandler=function(e){selected.parentElement.classList.toggle("isOpen"),e.stopPropagation()},selected.addEventListener("click",this._selectedClickHandler),this._bodyClickHandler=function(e){_this2.contains(e.target)||selected.parentElement.classList.remove("isOpen")},document.body.addEventListener("click",this._bodyClickHandler),this._variantClickHandlers=[],variantItems.forEach(function(item){var handler=function(e){var variantContent=item.querySelector(".sga-variant-select-content"),selectedContentEl=selected.querySelector(".sga-variant-select-content");variantContent&&selectedContentEl&&(selectedContentEl.outerHTML=variantContent.outerHTML),selected.setAttribute("data-product-id",item.getAttribute("data-product-id")),selected.setAttribute("data-product-handle",item.getAttribute("data-product-handle")),selected.parentElement.classList.remove("isOpen"),e.stopPropagation(),updateHiddenItems(),_this2._updateIntelligemsPrice(selected);var event=new Event("change",{bubbles:!0});selected.dispatchEvent(event)};_this2._variantClickHandlers.push({item:item,handler:handler}),item.addEventListener("click",handler)}),updateHiddenItems(),this._initialized=!0}}},{key:"_updateIntelligemsPrice",value:function(element){if(element){var priceElement=element.querySelector("[data-sga-variant-price]");if(priceElement){var variantId=priceElement.getAttribute("data-variant-id");if(variantId){var intelliGemsPrice=getIntelligemsPrice(variantId);intelliGemsPrice&&(priceElement.innerHTML=Shopify.formatMoney(intelliGemsPrice))}}}}},{key:"updateIntelligemsPrices",value:function(){var _this3=this;!this._selected&&!this._variantItems||(this._selected&&this._updateIntelligemsPrice(this._selected),this._variantItems&&this._variantItems.forEach(function(item){_this3._updateIntelligemsPrice(item)}))}},{key:"cleanup",value:function(){this._bodyClickHandler&&(document.body.removeEventListener("click",this._bodyClickHandler),this._bodyClickHandler=null),this._selected&&this._selectedClickHandler&&(this._selected.removeEventListener("click",this._selectedClickHandler),this._selectedClickHandler=null),this._variantClickHandlers&&(this._variantClickHandlers.forEach(function(_ref){var item=_ref.item,handler=_ref.handler;item.removeEventListener("click",handler)}),this._variantClickHandlers=[]),this._selected=null,this._variants=null,this._variantItems=null}}])})(_sga_variant_select_wrapNativeSuper(HTMLElement));customElements.define("sga-variant-select",SgaVariantSelect)}function _sga_variant_picker_typeof(o){"@babel/helpers - typeof";return _sga_variant_picker_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_sga_variant_picker_typeof(o)}function _sga_variant_picker_regeneratorRuntime(){"use strict";_sga_variant_picker_regeneratorRuntime=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t2,e2,r2){t2[e2]=r2.value},i=typeof Symbol=="function"?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function define(t2,e2,r2){return Object.defineProperty(t2,e2,{value:r2,enumerable:!0,configurable:!0,writable:!0}),t2[e2]}try{define({},"")}catch(t2){define=function(t3,e2,r2){return t3[e2]=r2}}function wrap(t2,e2,r2,n2){var i2=e2&&e2.prototype instanceof Generator?e2:Generator,a2=Object.create(i2.prototype),c2=new Context(n2||[]);return o(a2,"_invoke",{value:makeInvokeMethod(t2,r2,c2)}),a2}function tryCatch(t2,e2,r2){try{return{type:"normal",arg:t2.call(e2,r2)}}catch(t3){return{type:"throw",arg:t3}}}e.wrap=wrap;var h="suspendedStart",l="suspendedYield",f="executing",s="completed",y={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,a,function(){return this});var d=Object.getPrototypeOf,v=d&&d(d(values([])));v&&v!==r&&n.call(v,a)&&(p=v);var g=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t2){["next","throw","return"].forEach(function(e2){define(t2,e2,function(t3){return this._invoke(e2,t3)})})}function AsyncIterator(t2,e2){function invoke(r3,o2,i2,a2){var c2=tryCatch(t2[r3],t2,o2);if(c2.type!=="throw"){var u2=c2.arg,h2=u2.value;return h2&&_sga_variant_picker_typeof(h2)=="object"&&n.call(h2,"__await")?e2.resolve(h2.__await).then(function(t3){invoke("next",t3,i2,a2)},function(t3){invoke("throw",t3,i2,a2)}):e2.resolve(h2).then(function(t3){u2.value=t3,i2(u2)},function(t3){return invoke("throw",t3,i2,a2)})}a2(c2.arg)}var r2;o(this,"_invoke",{value:function(t3,n2){function callInvokeWithMethodAndArg(){return new e2(function(e3,r3){invoke(t3,n2,e3,r3)})}return r2=r2?r2.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(e2,r2,n2){var o2=h;return function(i2,a2){if(o2===f)throw Error("Generator is already running");if(o2===s){if(i2==="throw")throw a2;return{value:t,done:!0}}for(n2.method=i2,n2.arg=a2;;){var c2=n2.delegate;if(c2){var u2=maybeInvokeDelegate(c2,n2);if(u2){if(u2===y)continue;return u2}}if(n2.method==="next")n2.sent=n2._sent=n2.arg;else if(n2.method==="throw"){if(o2===h)throw o2=s,n2.arg;n2.dispatchException(n2.arg)}else n2.method==="return"&&n2.abrupt("return",n2.arg);o2=f;var p2=tryCatch(e2,r2,n2);if(p2.type==="normal"){if(o2=n2.done?s:l,p2.arg===y)continue;return{value:p2.arg,done:n2.done}}p2.type==="throw"&&(o2=s,n2.method="throw",n2.arg=p2.arg)}}}function maybeInvokeDelegate(e2,r2){var n2=r2.method,o2=e2.iterator[n2];if(o2===t)return r2.delegate=null,n2==="throw"&&e2.iterator.return&&
vendor: 5,429 bytes, line 8
8(r2.method="return",r2.arg=t,maybeInvokeDelegate(e2,r2),r2.method==="throw")||n2!=="return"&&(r2.method="throw",r2.arg=new TypeError("The iterator does not provide a '"+n2+"' method")),y;var i2=tryCatch(o2,e2.iterator,r2.arg);if(i2.type==="throw")return r2.method="throw",r2.arg=i2.arg,r2.delegate=null,y;var a2=i2.arg;return a2?a2.done?(r2[e2.resultName]=a2.value,r2.next=e2.nextLoc,r2.method!=="return"&&(r2.method="next",r2.arg=t),r2.delegate=null,y):a2:(r2.method="throw",r2.arg=new TypeError("iterator result is not an object"),r2.delegate=null,y)}function pushTryEntry(t2){var e2={tryLoc:t2[0]};1 in t2&&(e2.catchLoc=t2[1]),2 in t2&&(e2.finallyLoc=t2[2],e2.afterLoc=t2[3]),this.tryEntries.push(e2)}function resetTryEntry(t2){var e2=t2.completion||{};e2.type="normal",delete e2.arg,t2.completion=e2}function Context(t2){this.tryEntries=[{tryLoc:"root"}],t2.forEach(pushTryEntry,this),this.reset(!0)}function values(e2){if(e2||e2===""){var r2=e2[a];if(r2)return r2.call(e2);if(typeof e2.next=="function")return e2;if(!isNaN(e2.length)){var o2=-1,i2=function next(){for(;++o2<e2.length;)if(n.call(e2,o2))return next.value=e2[o2],next.done=!1,next;return next.value=t,next.done=!0,next};return i2.next=i2}}throw new TypeError(_sga_variant_picker_typeof(e2)+" is not iterable")}return GeneratorFunction.prototype=GeneratorFunctionPrototype,o(g,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),o(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,u,"GeneratorFunction"),e.isGeneratorFunction=function(t2){var e2=typeof t2=="function"&&t2.constructor;return!!e2&&(e2===GeneratorFunction||(e2.displayName||e2.name)==="GeneratorFunction")},e.mark=function(t2){return Object.setPrototypeOf?Object.setPrototypeOf(t2,GeneratorFunctionPrototype):(t2.__proto__=GeneratorFunctionPrototype,define(t2,u,"GeneratorFunction")),t2.prototype=Object.create(g),t2},e.awrap=function(t2){return{__await:t2}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,c,function(){return this}),e.AsyncIterator=AsyncIterator,e.async=function(t2,r2,n2,o2,i2){i2===void 0&&(i2=Promise);var a2=new AsyncIterator(wrap(t2,r2,n2,o2),i2);return e.isGeneratorFunction(r2)?a2:a2.next().then(function(t3){return t3.done?t3.value:a2.next()})},defineIteratorMethods(g),define(g,u,"Generator"),define(g,a,function(){return this}),define(g,"toString",function(){return"[object Generator]"}),e.keys=function(t2){var e2=Object(t2),r2=[];for(var n2 in e2)r2.push(n2);return r2.reverse(),function next(){for(;r2.length;){var t3=r2.pop();if(t3 in e2)return next.value=t3,next.done=!1,next}return next.done=!0,next}},e.values=values,Context.prototype={constructor:Context,reset:function(e2){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(resetTryEntry),!e2)for(var r2 in this)r2.charAt(0)==="t"&&n.call(this,r2)&&!isNaN(+r2.slice(1))&&(this[r2]=t)},stop:function(){this.done=!0;var t2=this.tryEntries[0].completion;if(t2.type==="throw")throw t2.arg;return this.rval},dispatchException:function(e2){if(this.done)throw e2;var r2=this;function handle(n2,o3){return a2.type="throw",a2.arg=e2,r2.next=n2,o3&&(r2.method="next",r2.arg=t),!!o3}for(var o2=this.tryEntries.length-1;o2>=0;--o2){var i2=this.tryEntries[o2],a2=i2.completion;if(i2.tryLoc==="root")return handle("end");if(i2.tryLoc<=this.prev){var c2=n.call(i2,"catchLoc"),u2=n.call(i2,"finallyLoc");if(c2&&u2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0);if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}else if(c2){if(this.prev<i2.catchLoc)return handle(i2.catchLoc,!0)}else{if(!u2)throw Error("try statement without catch or finally");if(this.prev<i2.finallyLoc)return handle(i2.finallyLoc)}}}},abrupt:function(t2,e2){for(var r2=this.tryEntries.length-1;r2>=0;--r2){var o2=this.tryEntries[r2];if(o2.tryLoc<=this.prev&&n.call(o2,"finallyLoc")&&this.prev<o2.finallyLoc){var i2=o2;break}}i2&&(t2==="break"||t2==="continue")&&i2.tryLoc<=e2&&e2<=i2.finallyLoc&&(i2=null);var a2=i2?i2.completion:{};return a2.type=t2,a2.arg=e2,i2?(this.method="next",this.next=i2.finallyLoc,y):this.complete(a2)},complete:function(t2,e2){if(t2.type==="throw")throw t2.arg;return t2.type==="break"||t2.type==="continue"?this.next=t2.arg:t2.type==="return"?(this.rval=this.arg=t2.arg,this.method="return",this.next="end"):t2.type==="normal"&&e2&&(this.next=e2),y},finish:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.finallyLoc===t2)return this.complete(r2.completion,r2.afterLoc),resetTryEntry(r2),y}},catch:function(t2){for(var e2=this.tryEntries.length-1;e2>=0;--e2){var r2=this.tryEntries[e2];if(r2.tryLoc===t2){var n2=r2.completion;if(n2.type==="throw"){var o2=n2.arg;resetTryEntry(r2)}return o2}}throw Error("illegal catch attempt")},delegateYield:function(e2,r2,n2){return this.delegate={iterator:values(e2),resultName:r2,nextLoc:n2},this.method==="next"&&(this.arg=t),y}},e}function _sga_variant_picker_ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r2){return Object.getOwnPropertyDescriptor(e,r2).enumerable})),t.push.apply(t,o)}return t}function _sga_variant_picker_objectSpread(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};
8r%2?_sga_variant_picker_ownKeys(Object(t),!0).forEach(function(r2){_sga_variant_picker_defineProperty(e,r2,t[r2])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):_sga_variant_picker_ownKeys(Object(t)).forEach(function(r2){Object.defineProperty(e,r2,Object.getOwnPropertyDescriptor(t,r2))})}return e}function _sga_variant_picker_defineProperty(e,r,t){return(r=_sga_variant_picker_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _sga_variant_picker_asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n2){return void e(n2)}i.done?t(u):Promise.resolve(u).then(r,o)}function _sga_variant_picker_asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n2){_sga_variant_picker_asyncGeneratorStep(a,r,o,_next,_throw,"next",n2)}function _throw(n2){_sga_variant_picker_asyncGeneratorStep(a,r,o,_next,_throw,"throw",n2)}_next(void 0)})}}function _sga_variant_picker_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _sga_variant_picker_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_sga_variant_picker_toPropertyKey(o.key),o)}}function _sga_variant_picker_createClass(e,r,t){return r&&_sga_variant_picker_defineProperties(e.prototype,r),t&&_sga_variant_picker_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _sga_variant_picker_toPropertyKey(t){var i=_sga_variant_picker_toPrimitive(t,"string");return _sga_variant_picker_typeof(i)=="symbol"?i:i+""}function _sga_variant_picker_toPrimitive(t,r){if(_sga_variant_picker_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_sga_variant_picker_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _sga_variant_picker_callSuper(t,o,e){return o=_sga_variant_picker_getPrototypeOf(o),_sga_variant_picker_possibleConstructorReturn(t,_sga_variant_picker_isNativeReflectConstruct()?Reflect.construct(o,e||[],_sga_variant_picker_getPrototypeOf(t).constructor):o.apply(t,e))}function _sga_variant_picker_possibleConstructorReturn(t,e){if(e&&(_sga_variant_picker_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _sga_variant_picker_assertThisInitialized(t)}function _sga_variant_picker_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _sga_variant_picker_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_sga_variant_picker_setPrototypeOf(t,e)}function _sga_variant_picker_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _sga_variant_picker_wrapNativeSuper=function(t2){if(t2===null||!_sga_variant_picker_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _sga_variant_picker_construct(t2,arguments,_sga_variant_picker_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_sga_variant_picker_setPrototypeOf(Wrapper,t2)},_sga_variant_picker_wrapNativeSuper(t)}function _sga_variant_picker_construct(t,e,r){if(_sga_variant_picker_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_sga_variant_picker_setPrototypeOf(p,r.prototype),p}function _sga_variant_picker_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_sga_variant_picker_isNativeReflectConstruct=function(){return!!t})()}function _sga_variant_picker_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _sga_variant_picker_setPrototypeOf(t,e){return _sga_variant_picker_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_sga_variant_picker_setPrototypeOf(t,e)}function _sga_variant_picker_getPrototypeOf(t){return _sga_variant_picker_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_sga_variant_picker_getPrototypeOf(t)}if(!customElements.get("sga-variant-picker")){var VariantPicker=(function(_HTMLElement){function VariantPicker2(){var _this;return _sga_variant_picker_classCallCheck(this,VariantPicker2),_this=_
8sga_variant_picker_callSuper(this,VariantPicker2),_this.section=_this.closest(".js-product"),_this.productForm=_this.section.querySelector(".js-product-form-main"),_this.data=_this.getProductData(),_this.variant=_this.getSelectedVariant(),_this.addEventListener("change",_this.handleVariantChange.bind(_this)),_this}return _sga_variant_picker_inherits(VariantPicker2,_HTMLElement),_sga_variant_picker_createClass(VariantPicker2,[{key:"connectedCallback",value:function(){var _this2=this;waitForIntelligems(function(){_this2.updateIntelligemsPrices()})}},{key:"handleVariantChange",value:(function(){var _handleVariantChange=_sga_variant_picker_asyncToGenerator(_sga_variant_picker_regeneratorRuntime().mark(function _callee(evt){var _evt$target$value,_this$variant,_this3=this,pageOrigin,productHandle,productId,previousVariantId,_this$variant2,_this$data$variants,_this$variant3,_this$variant4,_this$variant5,_this$data,_this$variant6,_this$variant7,_this$variant8,_this$variant9,updateSuccess,variantFromData;return _sga_variant_picker_regeneratorRuntime().wrap(function(_context){for(;;)switch(_context.prev=_context.next){case 0:return pageOrigin=window.location.origin,productHandle=(_evt$target$value=evt.target.value)!==null&&_evt$target$value!==void 0?_evt$target$value:evt.target.dataset.productHandle,productId=Number(evt.target.dataset.productId),previousVariantId=(_this$variant=this.variant)===null||_this$variant===void 0?void 0:_this$variant.id,_context.prev=4,_context.next=7,this.fetchAndUpdateContent("".concat(pageOrigin,"/products/").concat(productHandle));case 7:if(updateSuccess=_context.sent,updateSuccess){_context.next=11;break}return console.error("[VariantPicker] Failed to update product content"),_context.abrupt("return");case 11:if(this.data=this.getProductData(),this.variant=this.getSelectedVariant(productId),(_this$variant2=this.variant)!==null&&_this$variant2!==void 0&&_this$variant2.id){_context.next=16;break}return console.warn("[VariantPicker] No valid variant data found for product ID:",productId),_context.abrupt("return");case 16:variantFromData=(_this$data$variants=this.data.variants)===null||_this$data$variants===void 0?void 0:_this$data$variants.find(function(v){return v.id===productId}),variantFromData&&(this.variant=_sga_variant_picker_objectSpread(_sga_variant_picker_objectSpread({},variantFromData),{},{inventory_policy:variantFromData.inventory_policy||"continue",inventory_quantity:variantFromData.inventory_quantity||0})),this.dispatchEvent(new CustomEvent("on:variant:change",{bubbles:!0,detail:{form:this.productForm,variant:this.variant,selectedOptions:((_this$variant3=this.variant)===null||_this$variant3===void 0?void 0:_this$variant3.options)||[]}})),window.toggleContent(),this.refreshTableWidgetSection(productHandle),window.estimatedCurrentProduct=void 0,window.estimatedProductsMetafields={},window.estimatedSelectedVariant=void 0,window.estimatedProductCollections=[],window.estimatedProductVariants=[],window.estimatedProductVariantQuantity={},window.estimatedProductVariantInventoryPolicy={},window.estimatedProductsMetafields[(_this$variant4=this.variant)===null||_this$variant4===void 0?void 0:_this$variant4.id]=((_this$variant5=this.variant)===null||_this$variant5===void 0||(_this$variant5=_this$variant5.metafields)===null||_this$variant5===void 0?void 0:_this$variant5.theme)||{},window.estimatedCurrentProduct=this.variant,window.estimatedProductCollections=(_this$data=this.data)===null||_this$data===void 0?void 0:_this$data.collections,window.estimatedProductVariants=(_this$variant6=this.variant)===null||_this$variant6===void 0?void 0:_this$variant6.variants,window.estimatedProductVariantQuantity[(_this$variant7=this.variant)===null||_this$variant7===void 0||(_this$variant7=_this$variant7.variants)===null||_this$variant7===void 0||(_this$variant7=_this$variant7[0])===null||_this$variant7===void 0?void 0:_this$variant7.id]=this.variant.inventory_quantity,window.estimatedProductVariantInventoryPolicy[(_this$variant8=this.variant)===null||_this$variant8===void 0||(_this$variant8=_this$variant8.variants)===null||_this$variant8===void 0||(_this$variant8=_this$variant8[0])===null||_this$variant8===void 0?void 0:_this$variant8.id]=this.variant.inventory_policy,window.estimatedSelectedVariant=(_this$variant9=this.variant)===null||_this$variant9===void 0||(_this$variant9=_this$variant9.variants)===null||_this$variant9===void 0?void 0:_this$variant9[0],_context.next=40;break;case 37:_context.prev=37,_context.t0=_context.catch(4),console.error("[VariantPicker] Error in handleVariantChange:",_context.t0);case 40:waitForIntelligems(function(){_this3.updateIntelligemsPrices()});case 41:case"end":return _context.stop()}}
8,_callee,this,[[4,37]])}));function handleVariantChange(_x){return _handleVariantChange.apply(this,arguments)}return handleVariantChange})()},{key:"refreshTableWidgetSection",value:function(productHandle){var pageOrigin=window.location.origin,sectionWrapper=document.querySelector('[id^="shopify-section-"].table-widget-section');if(sectionWrapper){var sectionId=sectionWrapper.id.replace("shopify-section-",""),url="".concat(pageOrigin,"/products/").concat(productHandle,"?section_id=").concat(sectionId);fetch(url).then(function(res){if(!res.ok)throw new Error("Section fetch failed: ".concat(res.status," ").concat(res.statusText));return res.text()}).then(function(html){var tmp=document.createElement("div");tmp.innerHTML=html.trim();var newSection=tmp.querySelector("#shopify-section-".concat(sectionId));newSection&&(sectionWrapper.innerHTML=newSection.innerHTML)}).catch(function(err){console.error("[VariantPicker] Error refreshing table widget section:",err)})}}},{key:"fetchAndUpdateContent",value:(function(){var _fetchAndUpdateContent=_sga_variant_picker_asyncToGenerator(_sga_variant_picker_regeneratorRuntime().mark(function _callee2(pageUrl){var productSection,templateSuffix,ajaxUrl,ajaxResponse,htmlText,parser,html,mainContent,oldMainContent,oldVariantPicker,newVariantPicker,currentUrl,currentParams,url,baseUrl,newUrl;return _sga_variant_picker_regeneratorRuntime().wrap(function(_context2){for(;;)switch(_context2.prev=_context2.next){case 0:if(_context2.prev=0,pageUrl){_context2.next=4;break}return console.error("[VariantPicker] No page URL provided for content update"),_context2.abrupt("return",!1);case 4:return productSection=this.closest(".js-product"),templateSuffix=productSection?productSection.dataset.template:"default",ajaxUrl="".concat(pageUrl,"?view=").concat(templateSuffix,"&add-assets=false&lazy-load=false"),_context2.next=9,fetch(ajaxUrl);case 9:if(ajaxResponse=_context2.sent,ajaxResponse.ok){_context2.next=13;break}return console.error("[VariantPicker] Error fetching content: ".concat(ajaxResponse.status," ").concat(ajaxResponse.statusText)),_context2.abrupt("return",!1);case 13:return _context2.next=15,ajaxResponse.text();case 15:if(htmlText=_context2.sent,parser=new DOMParser,html=parser.parseFromString(htmlText,"text/html"),mainContent=html.querySelector("#main-content"),mainContent){_context2.next=22;break}return console.error("[VariantPicker] Could not find #main-content in the fetched HTML"),_context2.abrupt("return",!1);case 22:if(oldMainContent=document.querySelector("#main-content"),oldMainContent){_context2.next=26;break}return console.error("[VariantPicker] Could not find existing #main-content in the DOM"),_context2.abrupt("return",!1);case 26:return oldVariantPicker=oldMainContent.querySelector("[data-sga-variant-picker]"),oldMainContent.innerHTML=mainContent.innerHTML,oldVariantPicker&&(newVariantPicker=oldMainContent.querySelector("[data-sga-variant-picker]"),newVariantPicker&&newVariantPicker.parentNode&&newVariantPicker.parentNode.replaceChild(oldVariantPicker,newVariantPicker)),this.reinitializeJudgeMe(),window.history&&window.history.replaceState&&(currentUrl=new URL(window.location.href),currentParams=new URLSearchParams(currentUrl.search),url=new URL(pageUrl),baseUrl="".concat(url.origin).concat(url.pathname),newUrl=new URL(baseUrl),newUrl.search=currentParams.toString(),window.history.replaceState({},"",newUrl.toString())),document.dispatchEvent(new CustomEvent("on:variant:content:updated",{bubbles:!0,detail:{pageUrl:pageUrl}})),_context2.abrupt("return",!0);case 35:return _context2.prev=35,_context2.t0=_context2.catch(0),console.error("[VariantPicker] Error in fetchAndUpdateContent:",_context2.t0),_context2.abrupt("return",!1);case 39:case"end":return _context2.stop()}},_callee2,this,[[0,35]])}));function fetchAndUpdateContent(_x2){return _fetchAndUpdateContent.apply(this,arguments)}return fetchAndUpdateContent})()},{key:"reinitializeJudgeMe",value:function(){window.jdgm&&(window.jdgm.setupMediaGallery||(window.jdgm.setupMediaGallery=function(widget){return widget}),window.jdgm._renderAndSetupReviewForm||(window.jdgm._renderAndSetupReviewForm=function(widget){return widget}),window.jdgm._setupQuestionsForm||(window.jdgm._setupQuestionsForm=function(widget){return widget}),window.jdgm._setupFormsSubmit||(window.jdgm._setupFormsSubmit=function(widget){return widget}),typeof window.jdgm.initializeWidgets=="function"&&window.jdgm.initializeWidgets(),typeof window.jdgm.initializeCarousel=="function"&&window.jdgm.initializeCarousel())}},{key:"getProductData",value:function(){try{var dataEl=this.querySelector('[type="application/json"]');if(!dataEl)return console.error("Variant Picker: No JSON data element found"),null;var data=JSON.parse(dataEl.textContent);return data.product||console.error("Variant Picker: Invalid product data structure",data),data}catch(error){return console.error("Variant Picker: Error parsing product data:",error),null}}},{key:"getSelectedVariant",value:function(productId){return productId?this.data.variants.find(function(variant){return variant.id===productId}):this.data.product}},{key:"updateIntelligemsPrices",value:function(){var priceElements=document.querySelectorAll("[data-variant-picker-price]");
8priceElements.forEach(function(priceElement){var variantId=priceElement.getAttribute("data-variant-id");if(variantId){var intelliGemsPrice=getIntelligemsPrice(variantId);intelliGemsPrice&&(priceElement.innerHTML=Shopify.formatMoney(intelliGemsPrice))}})}}])})(_sga_variant_picker_wrapNativeSuper(HTMLElement));customElements.define("sga-variant-picker",VariantPicker)}function getProductDetailPriceElement(){return document.querySelector("[data-product-detail-price]")}function setElementValue(selector,value){var parent=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,useTextContent=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,searchContext=parent||document,element=searchContext.querySelector(selector);element&&(useTextContent?element.textContent=value:element.innerHTML=value)}function toggleHiddenClass(element,hide){element&&(hide?element.classList.add("!hidden"):element.classList.remove("!hidden"))}function updateProductDetailPrice(_ref){var currentPrice=_ref.currentPrice,wasPrice=_ref.wasPrice,discountPercentage=_ref.discountPercentage,savingsAmount=_ref.savingsAmount,sellingPlanId=_ref.sellingPlanId,priceElement=getProductDetailPriceElement();if(!(!priceElement||typeof Shopify=="undefined"||typeof Shopify.formatMoney!="function")){if(setElementValue("[data-cart-price-value]",Shopify.formatMoney(currentPrice),priceElement),wasPrice!==void 0){var wasPriceFormatted=Shopify.formatMoney(wasPrice).trim(),currentPriceFormatted=Shopify.formatMoney(currentPrice).trim(),wasPriceValue=wasPriceFormatted!==currentPriceFormatted?Shopify.formatMoney(wasPrice):"";setElementValue("[data-cart-price-was-value]",wasPriceValue,priceElement)}var discountElement=priceElement.querySelector("[data-cart-discount-element]"),hasDiscount=savingsAmount>0&&discountPercentage!==void 0;if(toggleHiddenClass(discountElement,!hasDiscount),hasDiscount&&discountElement&&(setElementValue("[data-cart-discount-percent-value]",discountPercentage,discountElement,!0),setElementValue("[data-cart-discount-value]",Shopify.formatMoney(savingsAmount),discountElement)),sellingPlanId!==void 0){var sellingPlanInput=document.querySelector("[data-selling-plan-input-id]");sellingPlanInput&&(sellingPlanInput.value=sellingPlanId)}}}function resetProductDetailPrice(originalPrices){var priceElement=getProductDetailPriceElement();if(!(!priceElement||!originalPrices)){originalPrices.currentPrice&&setElementValue("[data-cart-price-value]",originalPrices.currentPrice,priceElement);var shouldShowWasPrice=originalPrices.wasPriceText&&originalPrices.currentPriceText&&originalPrices.wasPriceText!==originalPrices.currentPriceText,wasPriceValue=shouldShowWasPrice?originalPrices.wasPrice:"";setElementValue("[data-cart-price-was-value]",wasPriceValue,priceElement);var discountElement=priceElement.querySelector("[data-cart-discount-element]");discountElement&&(toggleHiddenClass(discountElement,originalPrices.discountElementHidden),originalPrices.discountPercent&&setElementValue("[data-cart-discount-percent-value]",originalPrices.discountPercent,discountElement,!0),originalPrices.discountValue&&setElementValue("[data-cart-discount-value]",originalPrices.discountValue,discountElement));var sellingPlanInput=document.querySelector("[data-selling-plan-input-id]");sellingPlanInput&&(sellingPlanInput.value="")}}function calculateSubscriptionDiscount(basePrice,selectedPlan){var discountedPrice=basePrice,discountPercentage=0;if(selectedPlan.price_adjustments&&selectedPlan.price_adjustments.length>0){var adjustment=selectedPlan.price_adjustments[0];if(adjustment.value_type==="percentage")discountPercentage=parseFloat(adjustment.value),discountedPrice=basePrice*(1-discountPercentage/100);else if(adjustment.value_type==="fixed_amount"){var discountAmount=parseFloat(adjustment.value);discountedPrice=basePrice-discountAmount,discountPercentage=discountAmount/basePrice*100}else adjustment.value_type==="price"&&(discountedPrice=parseFloat(adjustment.value),discountPercentage=(basePrice-discountedPrice)/basePrice*100)}return{discountedPrice:Math.round(discountedPrice),discountPercentage:Math.round(discountPercentage)}}function updateSubscriptionPriceBox(priceElements,basePrice,discountedPrice,discountPercentage){if(!(typeof Shopify=="undefined"||typeof Shopify.formatMoney!="function")){if(priceElements.old&&(priceElements.old.innerHTML=Shopify.formatMoney(basePrice)),priceElements.discounted){var supElement=priceElements.discounted.querySelector("sup"),formattedPrice=Shopify.formatMoney(discountedPrice);supElement?(priceElements.discounted.innerHTML=formattedPrice,priceElements.discounted.appendChild(supElement)):priceElements.discounted.innerHTML=formattedPrice}priceElements.discountPercentage&&(priceElements.discountPercentage.textContent="-".concat(discountPercentage,"%"))}}function updateSubscriptionPrice(basePrice,selectedPlan,priceElements){if(selectedPlan){var _calculateSubscriptio=calculateSubscriptionDiscount(basePrice,selectedPlan),discountedPrice=_calculateSubscriptio.discountedPrice,discountPercentage=_calculateSubscriptio.discountPercentage,savingsAmount=basePrice-discountedPrice,quantityInput=document.querySelector("[data-cart-quantity-input]"),quantity=quantityInput&&parseInt(quantityInput.value)||1;updateSubscriptionPriceBox(priceElements,basePrice,discountedPrice,discountPercentage),typeof Shopify!="undefined"&&typeof Shopify.formatMoney=="function"&&updateProductDetailPrice({currentPrice:discountedPrice*quantity,wasPrice:basePrice*quantity,discountPercentage:discountPercentage,savingsAmount:savingsAmount*quantity,sellingPlanId:selectedPlan.id})}}function updateSellingPlanInput(sellingPlanId){var sellingPlanInput=document.querySelector("[data-selling-plan-input-id]");sellingPlanInput&&(sellingPlanInput.value=sellingPlanId)}function isSubscriptionActive(){var purchaseWidget=document.querySelector("sga-purchase-widget");return purchaseWidget?purchaseWidget.getAttribute("data-active-variant")==="subscription":!1}function getSubscriptionPricing(quantity){var subscriptionWidget=document.querySelector("sga-purchase-widget-variant-subscription");if(!subscriptionWidget)return null;var sellingPlansDataElement=subscriptionWidget.querySelector("[data-selling-plans-data]"),nativeSelect=subscriptionWidget.querySelector('select[name="selling-plan"]');if(!sellingPlansDataElement||!nativeSelect)return null;var sellingPlansData;
8try{sellingPlansData=JSON.parse(sellingPlansDataElement.textContent)}catch(e){return console.error("Failed to parse selling plans data:",e),null}var basePrice=parseFloat(subscriptionWidget.dataset.productPrice),selectedPlanId=parseInt(nativeSelect.value);if(!selectedPlanId||!basePrice)return null;var selectedPlan=sellingPlansData.plans.find(function(plan){return plan.id===selectedPlanId});if(!selectedPlan)return null;var _calculateSubscriptio2=calculateSubscriptionDiscount(basePrice,selectedPlan),discountedPrice=_calculateSubscriptio2.discountedPrice,discountPercentage=_calculateSubscriptio2.discountPercentage,totalPrice=discountedPrice*Number(quantity),regularPrice=basePrice*Number(quantity),savingsAmount=regularPrice-totalPrice;return{totalPrice:totalPrice,regularPrice:regularPrice,savingsAmount:savingsAmount,discountPercentage:discountPercentage,pricePerUnit:discountedPrice,sellingPlanId:selectedPlanId}}window.globals=window.globals||{},window.globals.isSubscriptionActive=isSubscriptionActive,window.globals.getSubscriptionPricing=getSubscriptionPricing;function _purchase_widget_frequency_list_typeof(o){"@babel/helpers - typeof";return _purchase_widget_frequency_list_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_purchase_widget_frequency_list_typeof(o)}function _purchase_widget_frequency_list_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _purchase_widget_frequency_list_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_purchase_widget_frequency_list_toPropertyKey(o.key),o)}}function _purchase_widget_frequency_list_createClass(e,r,t){return r&&_purchase_widget_frequency_list_defineProperties(e.prototype,r),t&&_purchase_widget_frequency_list_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _purchase_widget_frequency_list_toPropertyKey(t){var i=_purchase_widget_frequency_list_toPrimitive(t,"string");return _purchase_widget_frequency_list_typeof(i)=="symbol"?i:i+""}function _purchase_widget_frequency_list_toPrimitive(t,r){if(_purchase_widget_frequency_list_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_purchase_widget_frequency_list_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _purchase_widget_frequency_list_callSuper(t,o,e){return o=_purchase_widget_frequency_list_getPrototypeOf(o),_purchase_widget_frequency_list_possibleConstructorReturn(t,_purchase_widget_frequency_list_isNativeReflectConstruct()?Reflect.construct(o,e||[],_purchase_widget_frequency_list_getPrototypeOf(t).constructor):o.apply(t,e))}function _purchase_widget_frequency_list_possibleConstructorReturn(t,e){if(e&&(_purchase_widget_frequency_list_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _purchase_widget_frequency_list_assertThisInitialized(t)}function _purchase_widget_frequency_list_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _purchase_widget_frequency_list_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_purchase_widget_frequency_list_setPrototypeOf(t,e)}function _purchase_widget_frequency_list_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _purchase_widget_frequency_list_wrapNativeSuper=function(t2){if(t2===null||!_purchase_widget_frequency_list_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _purchase_widget_frequency_list_construct(t2,arguments,_purchase_widget_frequency_list_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_purchase_widget_frequency_list_setPrototypeOf(Wrapper,t2)},_purchase_widget_frequency_list_wrapNativeSuper(t)}function _purchase_widget_frequency_list_construct(t,e,r){if(_purchase_widget_frequency_list_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_purchase_widget_frequency_list_setPrototypeOf(p,r.prototype),p}function _purchase_widget_frequency_list_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_purchase_widget_frequency_list_isNativeReflectConstruct=function(){return!!t})()}function _purchase_widget_frequency_list_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _purchase_widget_frequency_list_setPrototypeOf(t,e){return _purchase_widget_frequency_list_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_purchase_widget_frequency_list_setPrototypeOf(t,e)}function _purchase_widget_frequency_list_getPrototypeOf(t){return _purchase_widget_frequency_list_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_purchase_widget_frequency_list_getPrototypeOf(t)}if(!customElements.get("sga-purchase-widget-frequency-list")){var _SgaPurchaseWidgetFrequencyList=(function(_HTMLElement){function _SgaPurchaseWidgetFrequencyList2(){return _purchase_widget_frequency_list_classCallCheck(this,_SgaPurchaseWidgetFrequencyList2),_purchase_widget_frequency_list_callSuper(this,_SgaPurchaseWidgetFrequencyList2,arguments)}return _purchase_widget_frequency_list_inherits(_SgaPurchaseWidgetFrequencyList2,_HTMLElement),_purchase_widget_frequency_list_createClass(_SgaPurchaseWidgetFrequencyList2,[{key:"c
8onnectedCallback",value:function(){var _this=this;this.init(),waitForIntelligems(function(){_this.updateIntelligemsPrice()})}},{key:"init",value:function(){var _this2=this,priceContainer=document.querySelector("[data-subscription-price]"),sellingPlansDataElement=this.querySelector("[data-selling-plans-data]");if(!(!priceContainer||!sellingPlansDataElement)){this.priceElements={old:priceContainer.querySelector("[data-subscription-price-old]"),discounted:priceContainer.querySelector("[data-subscription-price-discounted]"),discountPercentage:priceContainer.querySelector("[data-subscription-price-discount-percentage]")};try{this.sellingPlansData=JSON.parse(sellingPlansDataElement.textContent)}catch(e){console.error("Failed to parse selling plans data:",e);return}this.productId=this.dataset.productId,this.basePrice=parseFloat(this.dataset.productPrice),this.frequencyItems=this.querySelectorAll("[data-frequency-item]"),this.frequencyItems.length&&(this.frequencyItems.forEach(function(item){item.addEventListener("click",function(e){return _this2.handleFrequencyClick(e)})}),this.purchaseWidget=this.closest("sga-purchase-widget"),this.purchaseWidget&&(this.boundVariantChangeHandler||(this.boundVariantChangeHandler=function(e){e.detail.variantType==="subscription"&&_this2.updateActiveFrequencyItem()}),this.purchaseWidget.addEventListener("purchase-widget-variant-changed",this.boundVariantChangeHandler)))}}},{key:"updateActiveFrequencyItem",value:function(){var activeItem=this.querySelector("[data-frequency-item].active");if(activeItem){var planId=parseInt(activeItem.dataset.sellingPlanId);updateSellingPlanInput(planId),this.updatePrice(planId),this.dispatchFrequencyChangeEvent(planId)}}},{key:"dispatchFrequencyChangeEvent",value:function(planId){var selectedPlan=this.sellingPlansData.plans.find(function(plan){return plan.id===planId});if(selectedPlan){var _calculateSubscriptio=calculateSubscriptionDiscount(this.basePrice,selectedPlan),discountPercentage=_calculateSubscriptio.discountPercentage;this.dispatchEvent(new CustomEvent("frequency-changed",{detail:{discountPercentage:discountPercentage},bubbles:!0}))}}},{key:"handleFrequencyClick",value:function(event){var clickedItem=event.currentTarget;this.frequencyItems.forEach(function(item){item.classList.remove("active")}),clickedItem.classList.add("active");var sellingPlanId=parseInt(clickedItem.dataset.sellingPlanId);updateSellingPlanInput(sellingPlanId),isSubscriptionActive()&&this.updatePrice(sellingPlanId),this.dispatchFrequencyChangeEvent(sellingPlanId)}},{key:"updatePrice",value:function(planId){var selectedPlan=this.sellingPlansData.plans.find(function(plan){return plan.id===planId});if(selectedPlan&&(updateSubscriptionPrice(this.basePrice,selectedPlan,this.priceElements),window.globals&&window.globals.updateQuickFacts)){var _calculateSubscriptio2=calculateSubscriptionDiscount(this.basePrice,selectedPlan),discountedPrice=_calculateSubscriptio2.discountedPrice,quantityInput=document.querySelector("[data-cart-quantity-input]"),quantity=quantityInput?parseInt(quantityInput.value):1;window.globals.updateQuickFacts(quantity,{price_per_unit_raw:discountedPrice})}}},{key:"updateIntelligemsPrice",value:function(){if(this.productId){var intelliGemsPrice=getIntelligemsPrice(this.productId);intelliGemsPrice&&(this.basePrice=intelliGemsPrice,isSubscriptionActive()&&this.updateActiveFrequencyItem())}}},{key:"disconnectedCallback",value:function(){this.purchaseWidget&&this.boundVariantChangeHandler&&this.purchaseWidget.removeEventListener("purchase-widget-variant-changed",this.boundVariantChangeHandler)}}])})(_purchase_widget_frequency_list_wrapNativeSuper(HTMLElement));customElements.define("sga-purchase-widget-frequency-list",_SgaPurchaseWidgetFrequencyList)}var _purchase_widget_frequency_list=null;function _purchase_widget_variant_subscription_typeof(o){"@babel/helpers - typeof";return _purchase_widget_variant_subscription_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_purchase_widget_variant_subscription_typeof(o)}function _purchase_widget_variant_subscription_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _purchase_widget_variant_subscription_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_purchase_widget_variant_subscription_toPropertyKey(o.key),o)}}function _purchase_widget_variant_subscription_createClass(e,r,t){return r&&_purchase_widget_variant_subscription_defineProperties(e.prototype,r),t&&_purchase_widget_variant_subscription_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _purchase_widget_variant_subscription_toPropertyKey(t){var i=_purchase_widget_variant_subscription_toPrimitive(t,"string");return _purchase_widget_variant_subscription_typeof(i)=="symbol"?i:i+""}function _purchase_widget_variant_subscription_toPrimitive(t,r){if(_purchase_widget_variant_subscription_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_purchase_widget_variant_subscription_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _purchase_widget_variant_subscription_callSuper(t,o,e){return o=_purchase_widget_variant_subscription_getPrototypeOf(o
8),_purchase_widget_variant_subscription_possibleConstructorReturn(t,_purchase_widget_variant_subscription_isNativeReflectConstruct()?Reflect.construct(o,e||[],_purchase_widget_variant_subscription_getPrototypeOf(t).constructor):o.apply(t,e))}function _purchase_widget_variant_subscription_possibleConstructorReturn(t,e){if(e&&(_purchase_widget_variant_subscription_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _purchase_widget_variant_subscription_assertThisInitialized(t)}function _purchase_widget_variant_subscription_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _purchase_widget_variant_subscription_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_purchase_widget_variant_subscription_setPrototypeOf(t,e)}function _purchase_widget_variant_subscription_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _purchase_widget_variant_subscription_wrapNativeSuper=function(t2){if(t2===null||!_purchase_widget_variant_subscription_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _purchase_widget_variant_subscription_construct(t2,arguments,_purchase_widget_variant_subscription_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_purchase_widget_variant_subscription_setPrototypeOf(Wrapper,t2)},_purchase_widget_variant_subscription_wrapNativeSuper(t)}function _purchase_widget_variant_subscription_construct(t,e,r){if(_purchase_widget_variant_subscription_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_purchase_widget_variant_subscription_setPrototypeOf(p,r.prototype),p}function _purchase_widget_variant_subscription_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_purchase_widget_variant_subscription_isNativeReflectConstruct=function(){return!!t})()}function _purchase_widget_variant_subscription_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _purchase_widget_variant_subscription_setPrototypeOf(t,e){return _purchase_widget_variant_subscription_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_purchase_widget_variant_subscription_setPrototypeOf(t,e)}function _purchase_widget_variant_subscription_getPrototypeOf(t){return _purchase_widget_variant_subscription_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_purchase_widget_variant_subscription_getPrototypeOf(t)}if(!customElements.get("sga-purchase-widget-variant-subscription")){var SgaPurchaseWidgetVariantSubscription=(function(_HTMLElement){function SgaPurchaseWidgetVariantSubscription2(){return _purchase_widget_variant_subscription_classCallCheck(this,SgaPurchaseWidgetVariantSubscription2),_purchase_widget_variant_subscription_callSuper(this,SgaPurchaseWidgetVariantSubscription2,arguments)}return _purchase_widget_variant_subscription_inherits(SgaPurchaseWidgetVariantSubscription2,_HTMLElement),_purchase_widget_variant_subscription_createClass(SgaPurchaseWidgetVariantSubscription2,[{key:"c
8onnectedCallback",value:function(){var _this=this;this.init(),waitForIntelligems(function(){_this.updateIntelligemsPrice()})}},{key:"init",value:function(){var _this2=this,priceContainer=this.querySelector("[data-subscription-price]"),sellingPlansDataElement=this.querySelector("[data-selling-plans-data]"),nativeSelect=this.querySelector('select[name="selling-plan"]');if(!(!priceContainer||!sellingPlansDataElement||!nativeSelect)){this.priceElements={old:priceContainer.querySelector("[data-subscription-price-old]"),discounted:priceContainer.querySelector("[data-subscription-price-discounted]"),discountPercentage:priceContainer.querySelector("[data-subscription-price-discount-percentage]")},this.purchaseWidget=this.closest("sga-purchase-widget");try{this.sellingPlansData=JSON.parse(sellingPlansDataElement.textContent)}catch(e){console.error("Failed to parse selling plans data:",e);return}this.productId=this.dataset.productId,this.basePrice=parseFloat(this.dataset.productPrice),this.nativeSelect=nativeSelect,nativeSelect.addEventListener("change",function(e){var selectedPlanId=parseInt(e.target.value);isSubscriptionActive()&&_this2.updatePrice(selectedPlanId)}),this.purchaseWidget&&this.purchaseWidget.addEventListener("purchase-widget-variant-changed",function(e){e.detail.variantType==="subscription"&&_this2.updateSelectedPlanPrice()}),this.updateSelectedPlanPrice()}}},{key:"updateSelectedPlanPrice",value:function(){if(isSubscriptionActive()){var selectedPlanId=parseInt(this.nativeSelect.value);selectedPlanId&&this.updatePrice(selectedPlanId)}}},{key:"updatePrice",value:function(planId){var selectedPlan=this.sellingPlansData.plans.find(function(plan){return plan.id===planId});if(selectedPlan&&(updateSubscriptionPrice(this.basePrice,selectedPlan,this.priceElements),window.globals&&window.globals.updateQuickFacts)){var _calculateSubscriptio=calculateSubscriptionDiscount(this.basePrice,selectedPlan),discountedPrice=_calculateSubscriptio.discountedPrice,quantityInput=document.querySelector("[data-cart-quantity-input]"),quantity=quantityInput?parseInt(quantityInput.value):1;window.globals.updateQuickFacts(quantity,{price_per_unit_raw:discountedPrice})}}},{key:"updateIntelligemsPrice",value:function(){if(this.productId){var intelliGemsPrice=getIntelligemsPrice(this.productId);intelliGemsPrice&&(this.basePrice=intelliGemsPrice,this.updateSelectedPlanPrice())}}}])})(_purchase_widget_variant_subscription_wrapNativeSuper(HTMLElement));customElements.define("sga-purchase-widget-variant-subscription",SgaPurchaseWidgetVariantSubscription)}function _purchase_widget_packages_typeof(o){"@babel/helpers - typeof";return _purchase_widget_packages_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_purchase_widget_packages_typeof(o)}function _purchase_widget_packages_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _purchase_widget_packages_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_purchase_widget_packages_toPropertyKey(o.key),o)}}function _purchase_widget_packages_createClass(e,r,t){return r&&_purchase_widget_packages_defineProperties(e.prototype,r),t&&_purchase_widget_packages_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _purchase_widget_packages_toPropertyKey(t){var i=_purchase_widget_packages_toPrimitive(t,"string");return _purchase_widget_packages_typeof(i)=="symbol"?i:i+""}function _purchase_widget_packages_toPrimitive(t,r){if(_purchase_widget_packages_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_purchase_widget_packages_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _purchase_widget_packages_callSuper(t,o,e){return o=_purchase_widget_packages_getPrototypeOf(o
8),_purchase_widget_packages_possibleConstructorReturn(t,_purchase_widget_packages_isNativeReflectConstruct()?Reflect.construct(o,e||[],_purchase_widget_packages_getPrototypeOf(t).constructor):o.apply(t,e))}function _purchase_widget_packages_possibleConstructorReturn(t,e){if(e&&(_purchase_widget_packages_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _purchase_widget_packages_assertThisInitialized(t)}function _purchase_widget_packages_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _purchase_widget_packages_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_purchase_widget_packages_setPrototypeOf(t,e)}function _purchase_widget_packages_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _purchase_widget_packages_wrapNativeSuper=function(t2){if(t2===null||!_purchase_widget_packages_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _purchase_widget_packages_construct(t2,arguments,_purchase_widget_packages_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_purchase_widget_packages_setPrototypeOf(Wrapper,t2)},_purchase_widget_packages_wrapNativeSuper(t)}function _purchase_widget_packages_construct(t,e,r){if(_purchase_widget_packages_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_purchase_widget_packages_setPrototypeOf(p,r.prototype),p}function _purchase_widget_packages_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_purchase_widget_packages_isNativeReflectConstruct=function(){return!!t})()}function _purchase_widget_packages_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _purchase_widget_packages_setPrototypeOf(t,e){return _purchase_widget_packages_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_purchase_widget_packages_setPrototypeOf(t,e)}function _purchase_widget_packages_getPrototypeOf(t){return _purchase_widget_packages_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_purchase_widget_packages_getPrototypeOf(t)}if(!customElements.get("sga-purchase-widget-packages")){var _SgaPurchaseWidgetPackages=(function(_HTMLElement){function _SgaPurchaseWidgetPackages2(){var _this;return _purchase_widget_packages_classCallCheck(this,_SgaPurchaseWidgetPackages2),_this=_purchase_widget_packages_callSuper(this,_SgaPurchaseWidgetPackages2),_this.handleSelectedClick=_this.handleSelectedClick.bind(_this),_this.handleOptionsClick=_this.handleOptionsClick.bind(_this),_this.handleOutsideClick=_this.handleOutsideClick.bind(_this),_this.handleFrequencyChange=_this.handleFrequencyChange.bind(_this),_this.abortController=new AbortController,_this._initialized=!1,_this}return _purchase_widget_packages_inherits(_SgaPurchaseWidgetPackages2,_HTMLElement),_purchase_widget_packages_createClass(_SgaPurchaseWidgetPackages2,[{key:"connectedCallback",value:function(){var _this2=this;this.init(),waitForIntelligems(function(){_this2.updateIntelligemsPrice()})}},{key:"init",value:function(){if(!this._initialized&&(this.dropdown=this.querySelector("[data-quantity-dropdown]"),this.selectedElement=this.querySelector("[data-quantity-selected]"),this.optionsList=this.querySelector("[data-quantity-options]"),this.options=this.querySelectorAll("[data-quantity-option]"),!(!this.dropdown||!this.selectedElement||!this.optionsList||!this.options.length))){this.isOpen=!1,this.productId=this.dropdown.dataset.productId,this.basePrice=parseFloat(this.dropdown.dataset.productPrice),this.dosesPerPackage=parseFloat(this.dropdown.dataset.dosesPerPackage),this.currentDiscountPercentage=parseFloat(this.dropdown.dataset.discountPercentage)||0;var signal=this.abortController.signal;this.selectedElement.addEventListener("click",this.handleSelectedClick,{signal:signal}),this.addEventListener("click",this.handleOptionsClick,{signal:signal}),document.addEventListener("click",this.handleOutsideClick,{signal:signal}),document.addEventListener("frequency-changed",this.handleFrequencyChange,{signal:signal}),this._initialized=!0}}},{key:"handleSelectedClick",value:function(event){this.toggleDropdown(event)}},{key:"handleOptionsClick",value:function(event){var option=event.target.closest("[data-quantity-option]");option&&this.contains(option)&&this.handleOptionClick(event,option)}},{key:"toggleDropdown",value:function(event){event.stopPropagation(),this.isOpen?this.closeDropdown():this.openDropdown()}},{key:"openDropdown",value:function(){this.isOpen=!0,this.optionsList.classList.add("sga-subscription-widget__quantity-dropdown__options--active")}},{key:"closeDropdown",value:function(){this.isOpen=!1,this.optionsList.classList.remove("sga-subscription-widget__quantity-dropdown__options--active")}},{key:"handleOptionClick",value:function(event,clickedOption){var allOptions=this.querySelectorAll("[data-quantity-option]");allOptions.forEach(function(opt){opt.classList.remove("sga-subscription-widget__quantity-dropdown__option--active");var radio=opt.querySelector('input[type="radio"]');radio&&(radio.checked=!1)}),clickedOption.classList.add("sga-subscription-widget__quantity-dropdown__option--active");var clickedRadio=clickedOption.querySelector('input[type="radio"]');clickedRadio&&(clickedRadio.checked=!0),this.updateSelectedDisplay(clickedOption);var quantity=parseInt(clickedOption.dataset.quantity);this.updateQuantityInput(quantity),this.updateProductPrice(quantity,this.currentDiscountPercentage),this.closeDropdown()}},{key:"updateSelectedDisplay",value:function(option){var optionMainText=option.querySelector("[data-quantity-main-text]"),optionSubText=option.querySelector("[data-quantity-sub-text]"),optionPrice=option.querySelector("[data-quantity-price]"),optionSavings=option.querySelector("[data-quantity-savings-value]"),optionDiscountBadge=option.querySelector("[data-quantity-discount-badge]"),selectedMainText=this.selectedElement.querySelector("[data-quantity-main-text]"),selectedSubText=this.selectedElement.querySelector("[data-quantity-sub-text]"),selectedPrice=this.selectedElement.querySelector("[data-quantity-price]"),selectedSavings=this.selectedElement.querySelector("[data-quantity-savings-value]"),selectedDiscountBadge=this.selectedElement.querySelector("[data-quantity-discount-badge]");selectedMainText&&optionMainText&&(selectedMainText.textContent=optionMainText.textContent),selectedSubText&&optionSubText&&(selectedSubText.textContent=optionSubText.textContent),selectedPrice&&optionPrice&&(selectedPrice.textContent=optionPrice.textContent),selectedSavings&&optionSavings&&(selectedSavings.textContent=optionSavings.textContent),selectedDiscountBadge&&optionDiscountBadge&&(selectedDiscountBadge.textContent=optionDiscountBadge.textContent)}},{key:"updateQuantityInput",value:function(quantity){var quantityInput=document.querySelector("[data-cart-quantity-input]");if(quantityInput&&(quantityInput.value=quantity),window.globals&&window.globals.updateQu
8ickFacts){var discountMultiplier=(100-this.currentDiscountPercentage)/100,pricePerUnitRaw=this.basePrice*discountMultiplier;window.globals.updateQuickFacts(quantity,{price_per_unit_raw:pricePerUnitRaw})}}},{key:"updateProductPrice",value:function(quantity,discountPercentage){if(!(!quantity||typeof Shopify=="undefined"||typeof Shopify.formatMoney!="function")){var discountMultiplier=(100-discountPercentage)/100,discountedUnitPrice=this.basePrice*discountMultiplier,discountedTotalPrice=discountedUnitPrice*quantity,regularTotalPrice=this.basePrice*quantity,savingsAmount=regularTotalPrice-discountedTotalPrice;updateProductDetailPrice({currentPrice:discountedTotalPrice,wasPrice:regularTotalPrice,discountPercentage:discountPercentage,savingsAmount:savingsAmount})}}},{key:"recalculateOptionsPrices",value:function(){var _this3=this,updateDiscountBadge=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,allOptions=this.querySelectorAll("[data-quantity-option]");allOptions.forEach(function(option){var quantity=parseInt(option.dataset.quantity),discountMultiplier=(100-_this3.currentDiscountPercentage)/100,discountedUnitPrice=_this3.basePrice*discountMultiplier,discountedTotalPrice=discountedUnitPrice*quantity,savingsAmount=_this3.basePrice*quantity-discountedTotalPrice,priceElement=option.querySelector("[data-quantity-price]"),savingsElement=option.querySelector("[data-quantity-savings-value]");if(priceElement&&typeof Shopify!="undefined"&&typeof Shopify.formatMoney=="function"&&(priceElement.textContent=Shopify.formatMoney(discountedTotalPrice)),savingsElement&&typeof Shopify!="undefined"&&typeof Shopify.formatMoney=="function"&&(savingsElement.textContent=Shopify.formatMoney(savingsAmount)),updateDiscountBadge){var discountBadge=option.querySelector("[data-quantity-discount-badge]");discountBadge&&(discountBadge.textContent="".concat(_this3.currentDiscountPercentage,"%"))}}),updateDiscountBadge&&this.dropdown&&(this.dropdown.dataset.discountPercentage=this.currentDiscountPercentage)}},{key:"updateActiveOptionDisplay",value:function(){var activeOption=this.querySelector("[data-quantity-option].sga-subscription-widget__quantity-dropdown__option--active");if(activeOption){this.updateSelectedDisplay(activeOption);var quantity=parseInt(activeOption.dataset.quantity);this.updateProductPrice(quantity,this.currentDiscountPercentage)}}},{key:"handleFrequencyChange",value:function(event){var discountPercentage=event.detail.discountPercentage;this.currentDiscountPercentage=discountPercentage,this.recalculateOptionsPrices(!0),this.updateActiveOptionDisplay()}},{key:"handleOutsideClick",value:function(event){!this.contains(event.target)&&this.isOpen&&this.closeDropdown()}},{key:"updateIntelligemsPrice",value:function(){if(this.productId){var intelliGemsPrice=getIntelligemsPrice(this.productId);intelliGemsPrice&&(this.basePrice=intelliGemsPrice,this.recalculateOptionsPrices(),this.updateActiveOptionDisplay())}}},{key:"disconnectedCallback",value:function(){this.abortController.abort(),this.abortController=new AbortController,this._initialized=!1}},{key:"destroy",value:function(){this.disconnectedCallback()}}])})(_purchase_widget_packages_wrapNativeSuper(HTMLElement));customElements.define("sga-purchase-widget-packages",_SgaPurchaseWidgetPackages)}var _purchase_widget_packages=null;function _purchase_widget_typeof(o){"@babel/helpers - typeof";return _purchase_widget_typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o2){return typeof o2}:function(o2){return o2&&typeof Symbol=="function"&&o2.constructor===Symbol&&o2!==Symbol.prototype?"symbol":typeof o2},_purchase_widget_typeof(o)}function _purchase_widget_classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _purchase_widget_defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_purchase_widget_toPropertyKey(o.key),o)}}function _purchase_widget_createClass(e,r,t){return r&&_purchase_widget_defineProperties(e.prototype,r),t&&_purchase_widget_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _purchase_widget_toPropertyKey(t){var i=_purchase_widget_toPrimitive(t,"string");return _purchase_widget_typeof(i)=="symbol"?i:i+""}function _purchase_widget_toPrimitive(t,r){if(_purchase_widget_typeof(t)!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var i=e.call(t,r||"default");if(_purchase_widget_typeof(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function _purchase_widget_callSuper(t,o,e){return o=_purchase_widget_getPrototypeOf(o
8),_purchase_widget_possibleConstructorReturn(t,_purchase_widget_isNativeReflectConstruct()?Reflect.construct(o,e||[],_purchase_widget_getPrototypeOf(t).constructor):o.apply(t,e))}function _purchase_widget_possibleConstructorReturn(t,e){if(e&&(_purchase_widget_typeof(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _purchase_widget_assertThisInitialized(t)}function _purchase_widget_assertThisInitialized(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _purchase_widget_inherits(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_purchase_widget_setPrototypeOf(t,e)}function _purchase_widget_wrapNativeSuper(t){var r=typeof Map=="function"?new Map:void 0;return _purchase_widget_wrapNativeSuper=function(t2){if(t2===null||!_purchase_widget_isNativeFunction(t2))return t2;if(typeof t2!="function")throw new TypeError("Super expression must either be null or a function");if(r!==void 0){if(r.has(t2))return r.get(t2);r.set(t2,Wrapper)}function Wrapper(){return _purchase_widget_construct(t2,arguments,_purchase_widget_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t2.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_purchase_widget_setPrototypeOf(Wrapper,t2)},_purchase_widget_wrapNativeSuper(t)}function _purchase_widget_construct(t,e,r){if(_purchase_widget_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_purchase_widget_setPrototypeOf(p,r.prototype),p}function _purchase_widget_isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t2){}return(_purchase_widget_isNativeReflectConstruct=function(){return!!t})()}function _purchase_widget_isNativeFunction(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch(n){return typeof t=="function"}}function _purchase_widget_setPrototypeOf(t,e){return _purchase_widget_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t2,e2){return t2.__proto__=e2,t2},_purchase_widget_setPrototypeOf(t,e)}function _purchase_widget_getPrototypeOf(t){return _purchase_widget_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t2){return t2.__proto__||Object.getPrototypeOf(t2)},_purchase_widget_getPrototypeOf(t)}if(!customElements.get("sga-purchase-widget")){var SgaPurchaseWidget=(function(_HTMLElement){function SgaPurchaseWidget2(){return _purchase_widget_classCallCheck(this,SgaPurchaseWidget2),_purchase_widget_callSuper(this,SgaPurchaseWidget2,arguments)}return _purchase_widget_inherits(SgaPurchaseWidget2,_HTMLElement),_purchase_widget_createClass(SgaPurchaseWidget2,[{key:"connectedCallback",value:function(){var _this=this;this.init(),waitForIntelligems(function(){_this.updateIntelligemsPrice()})}},{key:"init",value:function(){var _this2=this;if(this.variantItems=this.querySelectorAll("[data-variants-item]"),!!this.variantItems.length){this.subscriptionLayout=this.dataset.subscriptionLayout,this.mainProductSubscriptionAvailabilityContainer=document.querySelector("[data-product-detail-subscription-availability]"),this.mainProductOneTimeAvailabilityContainer=document.querySelector("[data-product-detail-one-time-availability]");var originalPricesElement=this.querySelector("[data-original-prices]");if(originalPricesElement)try{this.originalPrices=JSON.parse(originalPricesElement.textContent)}catch(e){console.error("Failed to parse original prices:",e)}var subscriptionVariant=this.querySelector("[data-product-id]");subscriptionVariant&&(this.productId=subscriptionVariant.dataset.productId),this.variantItems.forEach(function(item){item.addEventListener("click",function(e){return _this2.handleVariantClick(e)})})}}},{key:"resetToOriginalPrices",value:function(){resetProductDetailPrice(this.originalPrices)}},{key:"toggleQuantityInputVisibility",value:function(variantType){if(this.subscriptionLayout==="detailed"){var quantityInput=document.querySelector("quantity-input");quantityInput&&(variantType==="subscription"?quantityInput.classList.add("!hidden"):quantityInput.classList.remove("!hidden"))}}},{key:"resetQuantityInput",value:function(){var quantityInput=document.querySelector("[data-cart-quantity-input]");quantityInput&&(quantityInput.value="1",quantityInput.dispatchEvent(new Event("change",{bubbles:!0})));var quantityBreaksRows=document.querySelectorAll("[data-quantity-breaks-row]"),quantityBreaksQuantityFirstRow=quantityBreaksRows[0],firstRowInput=quantityBreaksQuantityFirstRow==null?void 0:quantityBreaksQuantityFirstRow.querySelector("input");firstRowInput&&(firstRowInput.checked=!0,firstRowInput.dispatchEvent(new Event("change",{bubbles:!0}
8))),window.globals&&window.globals.updateQuickFacts&&this.originalPrices&&this.originalPrices.price&&window.globals.updateQuickFacts(1,{price_per_unit_raw:this.originalPrices.price})}},{key:"handleVariantClick",value:function(event){var clickedItem=event.currentTarget;this.setActiveVariant(clickedItem)}},{key:"setActiveVariant",value:function(item){var variantType=item.getAttribute("data-variants-item"),currentVariantType=this.getAttribute("data-active-variant");currentVariantType!==variantType&&(this.variantItems.forEach(function(variantItem){variantItem.classList.remove("active")}),item.classList.add("active"),this.setAttribute("data-active-variant",variantType),this.mainProductSubscriptionAvailabilityContainer&&this.mainProductSubscriptionAvailabilityContainer.classList.toggle("!hidden",variantType==="one_time"),this.mainProductOneTimeAvailabilityContainer&&this.mainProductOneTimeAvailabilityContainer.classList.toggle("!hidden",variantType==="subscription"),this.toggleQuantityInputVisibility(variantType),this.resetQuantityInput(),variantType==="one_time"&&this.resetToOriginalPrices(),this.dispatchEvent(new CustomEvent("purchase-widget-variant-changed",{detail:{variantType:variantType},bubbles:!0})))}},{key:"updateIntelligemsPrice",value:function(){var _this$originalPrices$,_this$originalPrices;if(!(!this.productId||!this.originalPrices)){var intelliGemsPrice=getIntelligemsPrice(this.productId);if(intelliGemsPrice){var currentVariantType=this.getAttribute("data-active-variant"),wasPriceInCents=(_this$originalPrices$=(_this$originalPrices=this.originalPrices)===null||_this$originalPrices===void 0?void 0:_this$originalPrices.wasPriceRaw)!==null&&_this$originalPrices$!==void 0?_this$originalPrices$:null,formattedCurrent=Shopify.formatMoney(intelliGemsPrice),formattedWas=typeof wasPriceInCents=="number"&&wasPriceInCents>intelliGemsPrice?Shopify.formatMoney(wasPriceInCents):"";this.originalPrices.price=intelliGemsPrice,this.originalPrices.currentPrice=formattedCurrent,this.originalPrices.currentPriceText=formattedCurrent,this.originalPrices.wasPrice=formattedWas,this.originalPrices.wasPriceText=formattedWas,this.originalPrices.discountElementHidden=!formattedWas,this.originalPrices.discountPercent=formattedWas?Math.round((wasPriceInCents-intelliGemsPrice)/wasPriceInCents*100).toString():"0",this.originalPrices.discountValue=formattedWas?Shopify.formatMoney(wasPriceInCents-intelliGemsPrice):"",currentVariantType==="one_time"&&this.resetToOriginalPrices()}}}}])})(_purchase_widget_wrapNativeSuper(HTMLElement));customElements.define("sga-purchase-widget",SgaPurchaseWidget)}})()})(); 9//# sourceMappingURL=/cdn/shop/t/6/assets/bundle.js.map?v=168396941564625129501790238480
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.