1"use strict";function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_toPropertyKey(n.key),n)}}function _createClass(t,e,r){return e&&_defineProperties(t.prototype,e),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _callSuper(t,e,r){return e=_getPrototypeOf(e),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(e,r||[],_getPrototypeOf(t).constructor):e.apply(t,r))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _inherits(t,e){if("function"!=typeof e&&null!==e)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 e="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(t){if(null===t||!_isNativeFunction(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return _construct(t,arguments,_getPrototypeOf(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,t)},_wrapNativeSuper(t)}function _construct(t,e,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&_setPrototypeOf(i,r.prototype),i}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _isNativeFunction(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}customElements.get("product-info")||customElements.define("product-info",function(t){function e(){var t;return _classCallCheck(this,e),_defineProperty(t=_callSuper(this,e),"cartUpdateUnsubscriber",void 0),_defineProperty(t,"variantChangeUnsubscriber",void 0),t.input=t.querySelector(".quantity__input"),t.currentVariant=t.querySelector(".product-variant-id"),t.variantSelects=t.querySelector("variant-radios"),t.submitButton=t.querySelector('[type="submit"]'),t.init(),t}return _inherits(e,_wrapNativeSuper(HTMLElement)),_createClass(e,[{key:"init",value:function(){this.variantSelects&&this.variantSelects.addEventListener("change",(function(){var t=Math.floor(1e6*Math.random()+1);document.querySelectorAll(".js-vimeo").forEach((function(e){var r=e.src;e.src=r+"?rand="+t}))}))}},{key:"connectedCallback",value:function(){var t=this;this.input&&(this.quantityForm=this.querySelector(".product-form__quantity"),this.quantityForm&&(this.setQuantityBoundries(),this.refreshPromoMessage(),this.dataset.originalSection||(this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,this.fetchQuantityRules.bind(this))),this.variantChangeUnsubscriber=subscribe(PUB_SUB_EVENTS.variantChange,(function(e){var r=t.dataset.originalSection?t.dataset.originalSection:t.dataset.section;e.data.sectionId===r&&(t.updateQuantityRules(e.data.sectionId,e.data.html),t.setQuantityBoundries(),t.refreshPromoMessage())})),this.quantityUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.quantityUpdate,(function(){t.refreshPromoMessage()})),this._onQuantityChange=function(){return t.refreshPromoMessage()},document.addEventListener("quantity:change",this._onQuantityChange,{passive:!0}),this._onCartEvents=function(){return t.refreshPromoMessage()},["cart:updated","cart:change","cart:refresh","cart:requestComplete"].forEach((function(e){document.addEventListener(e,t._onCartEvents,{passive:!0})}
1))))}},{key:"disconnectedCallback",value:function(){var t=this;this.cartUpdateUnsubscriber&&this.cartUpdateUnsubscriber(),this.variantChangeUnsubscriber&&this.variantChangeUnsubscriber(),this.quantityUpdateUnsubscriber&&this.quantityUpdateUnsubscriber(),this._onQuantityChange&&document.removeEventListener("quantity:change",this._onQuantityChange),this._onCartEvents&&["cart:updated","cart:change","cart:refresh","cart:requestComplete"].forEach((function(e){document.removeEventListener(e,t._onCartEvents)}))}},{key:"setQuantityBoundries",value:function(){var t={cartQuantity:this.input.dataset.cartQuantity?parseInt(this.input.dataset.cartQuantity):0,min:this.input.dataset.min?parseInt(this.input.dataset.min):1,max:this.input.dataset.max?parseInt(this.input.dataset.max):null,step:this.input.step?parseInt(this.input.step):1},e=t.min,r=null===t.max?t.max:t.max-t.cartQuantity;null!==r&&(e=Math.min(e,r)),t.cartQuantity>=t.min&&(e=Math.min(e,t.step)),this.input.min=e,this.input.max=r,this.input.value=e,publish(PUB_SUB_EVENTS.quantityUpdate,void 0)}},{key:"getPromoContainers",value:function(){return Array.from(document.querySelectorAll(".promo-progress"))}},{key:"getPromoTiersFromDom",value:function(t){try{var e,r=(null==t||null===(e=t.dataset)||void 0===e?void 0:e.tiers)||"[]",n=JSON.parse(r)||[];return this.normalizeTiers(n)}catch(t){return[]}}},{key:"parseDiscountTiers",value:function(t){return(t||[]).map((function(t){var e=Number(t.quantityRequiredForDiscount),r=null!=t.percentualDiscount?Number(t.percentualDiscount):null;return Number.isNaN(e)||e<=0||null===r||Number.isNaN(r)||r<=0?null:{required:e,discount:r,type:"discount"}})).filter(Boolean).sort((function(t,e){return t.required-e.required}))}},{key:"parseGiftTiers",value:function(t){return(t||[]).map((function(t){var e=Number(t.quantityRequiredToBeGifted),r=null!=t.quantityToBeGifted?Number(t.quantityToBeGifted):1;return Number.isNaN(e)||e<=0?null:{required:e,gifted:!Number.isNaN(r)&&r>0?r:1,type:"gift"}})).filter(Boolean).sort((function(t,e){return t.required-e.required}))}},{key:"normalizeTiers",value:function(t){var e=this.parseDiscountTiers(t);return e.length?e:this.parseGiftTiers(t)}},{key:"isDiscountMode",value:function(t){return(null==t?void 0:t.some((function(t){return"discount"===t.type&&(t.discount||0)>0})))||!1}},{key:"computeDiscountMessage",value:function(t,e){if(null==e||!e.length)return"";for(var r=null,n=null,i=0;i<e.length;i++){var o=e[i];t<o.required&&!r&&(r=o),t>=o.required&&(n=o)}if(r){var a=r.required-t,u=Math.round(Number(r.discount||0));return"Adicione mais ".concat(a," unidade").concat(1!==a?"s":""," para desbloquear ").concat(u,"% OFF")}if(n&&(n.discount||0)>0){var s=Math.round(Number(n.discount||0));return"Você já desbloqueou a promoção máxima (".concat(s,"% OFF)")}return""}},{key:"computeGiftMessage",value:function(t,e){if(null==e||!e.length)return"";for(var r=null,n=null,i=0;i<e.length;i++){var o=e[i];t<o.required&&!r&&(r=o),t>=o.required&&(n=o)}if(r){var a=r.required-t,u=1===r.gifted?"uma":String(r.gifted);return"Adicione mais ".concat(a," unidade").concat(1!==a?"s":""," e ganhe ").concat(u," de graça")}if(n&&(n.gifted||0)>0){var s=1===n.gifted?"uma":String(n.gifted);return"Você já desbloqueou a promoção máxima (".concat(s," grátis)")}return""}},{key:"computePromoMessage",value:function(t,e){return e&&e.length?this.isDiscountMode(e)?this.computeDiscountMessage(t,e):this.computeGiftMessage(t,e):""}},{key:"getCurrentProductId",value:function(t){var e,r=null==t||null===(e=t.dataset)||void 0===e?void 0:e.productId;return r?parseInt(r,10):null}},{key:"refreshPromoMessage",value:function(){var t=this,e=this.getPromoContainers();e&&e.length&&e.forEach((function(e){var r=t.getPromoTiersFromDom(e),n=t.getCurrentProductId(e);fetch("/cart.js",{headers:{Accept:"application/json","Cache-Control":"max-age=5"},credentials:"same-origin"}).then((function(t){return t.json()})).then((function(i){var o=n&&Array.isArray(null==i?void 0:i.items)?i.items.filter((function(t){return parseInt(t.product_id,10)===n})).reduce((function(t,e){return t+(parseInt(e.quantity,10)||0)}),0):0,a=t.computePromoMessage(o,r);a&&(e.textContent=a)})).catch((function(){}))}))}},{key:"fetchQuantityRules",value:function(){var t=this;this.currentVariant&&this.currentVariant.value&&(this.querySelector(".quantity__rules-cart .loading-overlay").classList.remove("hidden"),fetch("".concat(this.dataset.url,"?variant=").concat(this.currentVariant.value,"§ion_id=").concat(this.dataset.section)).then((function(t){return t.text()})).then((function(e){var r=(new DOMParser).parseFromString(e,"text/html");t.updateQuantityRules(t.dataset.section,r),t.setQuantityBoundries(),t.refreshPromoMessage()})).catch((function(t){console.error(t)})).finally((function(){t.querySelector(".quantity__rules-cart .loading-overlay").classList.add("hidden")})))}},{key:"updateQuantityRules",value:function(t,e){for(var r=e.getElementById("Quantity-Form-".concat(t)),n=0,i=[".quantity__input",".quantity__rules",".quantity__label"];n<i.length;n++){var o=i[n],a=this.quantityForm.querySelector(o),u=r.querySelector(o);if(a&&u)if(".quantity__input"===o)for(var s=0,c=["data-cart-quantity","data-min","data-max","step"];s<c.length;s++){var l=c[s],f=u.getAttribute(l);null!==f&&a.setAttribute(l,f)}else a.innerHTML=u.innerHTML}this.refreshPromoMessage()}}])}()); 2//# sourceMappingURL=product-info.js.map
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.