!function(){function e(e){return e&&e.__esModule?e.default:e}class t{static merge(e,i,r){for(let o in i)!i.hasOwnProperty(o)||null!=r&&-1===r.indexOf(o)||("[object Object]"===Object.prototype.toString.call(i[o])?e[o]=t.merge(e[o],i[o]):void 0!==i[o]&&(e[o]=i[o]));return e}static extend(){let e={},i=function(i){for(let r in i)i.hasOwnProperty(r)&&("[object Object]"===Object.prototype.toString.call(i[r])?e[r]=t.extend(e[r],i[r]):void 0!==i[r]&&(e[r]=i[r]))};for(let e=0;e0);return!r&&Array.isArray(e)&&e.length>0?t.isElement(e[0]):r}static isInPage(e){return e!==document.body&&document.body.contains(e)}static isHidden(e){return 0===e.offsetHeight||0===e.offsetWidth||null===e.offsetParent||"none"===window.getComputedStyle(e).display||1===e.offsetHeight&&1===e.offsetWidth}static isMinSize(e,t=1,i=1){const r=e.getBoundingClientRect();return!(r.width>t||r.height>t)}static isScrolledIntoView(e){let t=e.getBoundingClientRect(),i=t.top,r=t.bottom;return i>=0&&r<=window.innerHeight}static matches(e,t){return Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),i=t.length;--i>=0&&t.item(i)!==this;);return i>-1}),e.matches(t)}static matchesIncludeParent(e,i){return!(!e||!t.matches(e,i)&&null==t.findParent(e,i))}static findParent(e,i){if("function"==typeof e.closest)return e.closest(i)||null;for(;e;){if(t.matches(e,i))return e;e=e.parentElement}return null}static findInnerDimensions(e){let t=getComputedStyle(e),i=e.clientWidth,r=e.clientHeight;return r-=parseFloat(t.paddingTop)+parseFloat(t.paddingBottom),i-=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight),{height:r,width:i}}static getCalculatedPosition(e){const t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,o=window.pageXOffset||i.scrollLeft||t.scrollLeft,n=e.getBoundingClientRect();return{top:n.top+r,left:n.left+o,right:n.left+o+n.width,bottom:n.top+r+n.height}}static findElementContainsText(e,i,r=document){return t.findElementContainsRegex(e,new RegExp(i),r)}static findElementContainsRegex(e,t,i=document){let r=i.querySelectorAll(e);return Array.prototype.filter.call(r,(function(e){return t.test(e.textContent)}))}static escapeRegex(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}static readCookie(e){e+="=";for(let t=document.cookie.split(/;\s*/),i=t.length-1;i>=0;i--)if(!t[i].indexOf(e))return t[i].replace(e,"")}static writeCookie(e,t,i,r="/"){let o=new Date;o.setDate(o.getDate()+i);let n=null==i?"":"; expires="+o.toUTCString();document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+n+(r?"; path="+r:"")+";"}static removeCookie(e,t="/"){document.cookie=e+"=; Path="+t+"; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"}static addStyleElement(e,t){t&&"head"!=t||(t=document.head||document.getElementsByTagName("head")[0]);let i=document.createElement("style");return i.appendChild(document.createTextNode(e)),t.appendChild(i),i}static addScriptElement(e,t){t&&"head"!=t||(t=document.head||document.getElementsByTagName("head")[0]);let i=document.createElement("script");return i.appendChild(document.createTextNode(e)),t.appendChild(i),i}static objectKeys(e){if(!Object.keys){let t,i=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&i.push(t);return i}return Object.keys(e)}static hasQueryParam(e,t){return-1!==e.indexOf(t)}static getQueryParam(e,t){let i=new RegExp("[?&]"+t+"=([^&#]*)","i").exec(e);return i?decodeURIComponent(i[1]):null}static getQueryParams(e){let t={},i=document.createElement("a");i.href=e;let r=i.search.substring(1).split("&");for(let e=0;eencodeURIComponent(t)+"="+encodeURIComponent(e[t]))).join("&")}static debounced(e,t){let i;return function(...r){i&&clearTimeout(i),i=setTimeout((()=>{t(...r),i=null}),e)}}static throttled(e,t){let i=0;return function(...r){const o=(new Date).getTime();if(!(o-i-1||e.indexOf("FBAV")>-1||e.indexOf("Instagram")>-1}static isFacebook(e){return e.indexOf("FBAN")>-1||e.indexOf("FBAV")>-1}static isInstagram(e){return e.indexOf("Instagram")>-1}static isIOS(e){return(e=e.toLowerCase()).indexOf("iphone")>-1||e.indexOf("ipad")>-1}static isAndroid(e){return(e=e.toLowerCase()).indexOf("android")>-1}static isMobile(e){return this.isAndroid(e)||this.isIOS(e)}static getImageSize(e){return new Promise(((t,i)=>{const r=new Image;r.onload=()=>{t({width:r.width,height:r.height})},r.onerror=i,r.src=e}))}static convertSizeToUnit(e,t,o){let n=e.width/t,a=e.height/t;switch(o){case"mm":return{width:Number((n*i*10).toFixed(2)),height:Number((a*i*10).toFixed(2))};case"cm":return{width:Number((n*i).toFixed(2)),height:Number((a*i).toFixed(2))};case"m":return{width:Number((n*i/100).toFixed(2)),height:Number((a*i/100).toFixed(2))};case"inch":return{width:Number(n.toFixed(2)),height:Number(a.toFixed(2))};case"feet":return{width:Number((n/r).toFixed(2)),height:Number((a/r).toFixed(2))}}return null}}const i=2.54,r=12;var o=t;var n=class{supports(){return"XMLHttpRequest"in window&&"JSON"in window&&"Promise"in window}parse(e){let t;if("text"!==this.settings.responseType&&""!==this.settings.responseType){let t=e.response;if("json"===this.settings.responseType&&"string"==typeof t)try{t=JSON.parse(t)}catch(e){}return{data:t,xhr:e}}try{t=JSON.parse(e.responseText)}catch(i){t=e.responseText}return{data:t,xhr:e}}param(e){if("string"==typeof e||"[object FormData]"===Object.prototype.toString.call(e)||"[object File]"===Object.prototype.toString.call(e)||"[object Blob]"===Object.prototype.toString.call(e))return e;if(/application\/json/i.test(this.settings.headers["Content-type"])||"[object Array]"===Object.prototype.toString.call(e))return JSON.stringify(e);let t=[];for(let i in e)e.hasOwnProperty(i)&&t.push(encodeURIComponent(i)+"="+encodeURIComponent(e[i]));return t.join("&")}addQueryParams(e){if(this.settings.queryParams){let t=[];for(let e in this.settings.queryParams)this.settings.queryParams.hasOwnProperty(e)&&t.push(e+"="+this.settings.queryParams[e]);if(t.length>0){let i=t.join("&");return-1===e.indexOf("?")?e+"?"+i:e+"&"+i}}return e}xhr(e){const t=new XMLHttpRequest,i=new Promise(((i,r)=>{t.onreadystatechange=()=>{if(4!==t.readyState)return;let e=this.parse(t);t.status>=200&&t.status<300?i(e):r(e)},e=this.addQueryParams(e),t.open(this.settings.method,e,!0,this.settings.username,this.settings.password),t.responseType=this.settings.responseType;for(let e in this.settings.headers)this.settings.headers.hasOwnProperty(e)&&t.setRequestHeader(e,this.settings.headers[e]);this.settings.timeout&&(t.timeout=this.settings.timeout,t.ontimeout=e=>{r({status:408,statusText:"Request timeout"})}),this.settings.withCredentials&&(t.withCredentials=!0),this.settings.onProgress&&(t.upload.onprogress=this.settings.onProgress),t.send(this.param(this.settings.data))}));return i.cancel=()=>{t.abort()},i}constructor(e,t){if(!this.supports())throw"This browser is not supported";return this.settings=o.extend({method:"GET",username:null,password:null,data:{},queryParams:{},headers:{"Content-type":"application/x-www-form-urlencoded"},responseType:"text",timeout:null,withCredentials:!1,onProgress:null},t||{}),this.xhr(e)}},a={};!function(e,t){"use strict";"function"==typeof define&&define.amd?define(t):a?a=t():e.log=t()}(a,(function(){"use strict";var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function o(e,t){var i=e[t];if("function"==typeof i.bind)return i.bind(e);try{return Function.prototype.bind.call(i,e)}catch(t){return function(){return Function.prototype.apply.apply(i,[e,arguments])}}}function n(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(t,i){for(var o=0;o=0&&i<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+i;if(n=i,!1!==o&&function(e){var i=(r[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=i)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+i+";"}catch(e){}}}(i),a.call(s,i,e),typeof console===t&&i(a.debug("[translate] "+t+" response",e.data),s.update(e.data),s.translations))).catch((e=>(a.error("[translate] "+t+" error",e),s.translations))),s.ready}static update(e){s.translations=o.extend(s.translations,e),s.updated()}static updated(){const e=new CustomEvent(s.event,{detail:{},cancelable:!0,bubbles:!0});window.dispatchEvent(e)}static onUpdated(e){window.addEventListener(s.event,e)}}s.locale=window.Shopify&&window.Shopify.locale?window.Shopify.locale:document.documentElement.lang,s.translations={},s.ready=Promise.resolve(!0),s.event="cloudlift.translate",s.api="";var l=s,c={};!function(){function e(e,t,i){return e.call.apply(e.bind,arguments)}function t(e,t,i){if(!e)throw Error();if(2=t.f?n():e.fonts.load(function(e){return x(e)+" "+e.f+"00 300px "+w(e.c)}(t.a),t.h).then((function(e){1<=e.length?o():setTimeout(a,25)}),(function(){n()}))}()})),n=null,a=new Promise((function(e,i){n=setTimeout(i,t.f)}));Promise.race([a,o]).then((function(){n&&(clearTimeout(n),n=null),t.g(t.a)}),(function(){t.j(t.a)}))};var T={D:"serif",C:"sans-serif"},A=null;function F(){if(null===A){var e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);A=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))}return A}function D(e,t,i){for(var r in T)if(T.hasOwnProperty(r)&&t===e.f[T[r]]&&i===e.f[T[r]])return!0;return!1}function N(e){var t,o=e.g.a.offsetWidth,n=e.h.a.offsetWidth;(t=o===e.f.serif&&n===e.f["sans-serif"])||(t=F()&&D(e,o,n)),t?r()-e.A>=e.w?F()&&D(e,o,n)&&(null===e.u||e.u.hasOwnProperty(e.a.c))?j(e,e.v):j(e,e.B):function(e){setTimeout(i((function(){N(this)}),e),50)}(e):j(e,e.v)}function j(e,t){setTimeout(i((function(){l(this.g.a),l(this.h.a),l(this.j.a),l(this.m.a),t(this.a)}),e),0)}function R(e,t,i){this.c=e,this.a=t,this.f=0,this.m=this.j=!1,this.s=i}$.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=r(),N(this)};var V=null;function z(e){0==--e.f&&e.j&&(e.m?((e=e.a).g&&p(e.f,[e.a.c("wf","active")],[e.a.c("wf","loading"),e.a.c("wf","inactive")]),S(e,"active")):I(e.a))}function q(e){this.j=e,this.a=new P,this.h=0,this.f=this.g=!0}function H(e,t,r,o,n){var a=0==--e.h;(e.f||e.g)&&setTimeout((function(){var e=n||null,s=o||{};if(0===r.length&&a)I(t.a);else{t.f+=r.length,a&&(t.j=a);var l,c=[];for(l=0;l{for(let r of e){let e=this.getFont(r);if(e&&!e.loaded)switch(e.type){case 0:e.loaded=!0;break;case 1:let o=this.addGoogleFontStyle(e,r);-1===i.indexOf(o)&&i.push(o);break;case 2:let n=this.addFvd(e,r);-1===t.indexOf(n)&&t.push(n)}}return t.length>0||i.length>0?this.loadFontsByFamilies(t,i):Promise.resolve(!0)})),this._loadQueue}static loadFontsByFamilies(e,t){return new Promise(((i,r)=>{const o={timeout:3e3};if(e&&e.length){let t=e.map((e=>e.substring(0,e.indexOf(":"))));o.custom={families:e,urls:[this.fontCss(t)]}}t&&t.length&&(o.google={families:t}),o.active=()=>{i()},o.inactive=()=>{i()},o.fontactive=(e,t)=>{let i=p.getFont(e);i?i.loaded=!0:p.fonts.push({name:e,loaded:!0})},o.fontinactive=(e,t)=>{let i=p.getFont(e);a.warn("[live-options] failed to load font",i),i.loaded=!0},c.load(o)}))}static fontPreview(e){let t=o.extend(p.apiParams,{name:e});return p.api+"/preview?"+o.buildQueryParams(t)}static fontCss(e){let t=o.extend(p.apiParams,{names:e.join(",")});return p.api+"/css?"+o.buildQueryParams(t)}}p.fonts=[],p.api="",p.apiParams={};var d=p;class u{static getInstance(e){return u._instance||(u._instance=new u(e)),u._instance}fakeProduct(e){this.isProduct=()=>!0,this.getHandleFromUrl=()=>e}isAdmin(){return null!=document.getElementById("admin_bar_iframe")}isProduct(){return-1!==window.location.pathname.indexOf("/products/")||this.isProductPreview()}isProductPreview(){return-1!==window.location.pathname.indexOf("/products_preview")}getDiscountUrl(e,t){return"/discount/"+e+(t?"?redirect="+t:"")}getDiscountCode(){return o.readCookie("discount_code")}saveDiscountCode(e){return o.writeCookie("discount_code",e,null,"/")}removeDiscountCode(){return o.removeCookie("discount_code")}getCustomerId(){return window.theme&&window.theme.customerId?window.theme.customerId:window.meta&&window.meta.page&&window.meta.page.customerId?window.meta.page.customerId:window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page&&window.ShopifyAnalytics.meta.page.customerId?window.ShopifyAnalytics.meta.page.customerId:null}getHandleFromUrl(e=location.pathname){window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root&&"/"!==window.Shopify.routes.root&&(e=e.replace(window.Shopify.routes.root,"/"));let t=e.replace(/\/$/,"").split("/"),i=("products"==t[t.length-2]||"products_preview"===t.pop())&&t[t.length-1].replace(/(.*)?\?.*$/,"$1");return decodeURIComponent(i).toLowerCase()}tryGetProduct(){return this.isProduct()?this.getProduct():new Promise(((e,t)=>{e(null)}))}async tryGetProductMap(){return this.isTheme("Dawn")&&await this.parseOfferJsonElements(),this.isProduct()&&await this.getProduct(),u.products}parseOfferJsonElements(){document.querySelectorAll('.featured-product form[id^="product_form_"]').forEach((e=>{e.setAttribute("id",e.getAttribute("id").replace("product_form_","product-form-installment-featured--")),a.debug("updated featured product form id: ",e,e.id)}));let e=document.querySelectorAll('script[type="application/ld+json"]'),t=[];if(e.length>0)for(let i=0;inew n(e.url+".js",{method:"GET",responseType:"json"}).then((e=>{let r=e.data;u.products[i]=r,t(r)})).catch((i=>{a.error("failed to fetch product: ",e.url,i),t(null)})))))}}catch(e){a.debug("error parsing ProductOffer: ",r,e)}}return Promise.all(t)}parseProductJsonElements(){let e=document.querySelectorAll('[id^="ProductJson-"]');if(0===e.length&&(e=document.querySelectorAll('[data-product-json], [data-section-type="dynamic-featured-product"]')),e.length>0)for(let t=0;t{t(u.products[e])}));let i,r=e+"."+t;return u.products[r]?new Promise(((e,t)=>{e(u.products[r])})):(e?i=this.settings.api+this.settings.path.products.replace("{handle}",e).replace("{view}",t):this.isProductPreview()&&(i=window.location.href.replace("products_preview","products_preview."+t)),new n(i,{method:"GET",responseType:"json"}).then((e=>{let i=e.data;return"json"===t&&(i=e.data.product),r=i.handle+"."+t,u.products[r]=i,i})).catch((e=>{throw e})))}isTheme(e){if(window.Shopify&&window.Shopify.theme){const t=window.Shopify.theme.theme_store_id;if("Dawn"===e&&(887===t||1368===t||1363===t||1356===t||1431===t||1434===t||1499===t||1500===t||1567===t||1864===t||1841===t||1891===t||2699===t))return!0;if("Expanse"===e&&902===t)return!0;if(window.Shopify.theme.name&&-1!==window.Shopify.theme.name.toLowerCase().indexOf(e.toLowerCase()))return!0}return!1}isThemeEditor(){return window.Shopify&&window.Shopify.designMode}onThemeSectionEvent(e,t){return document.addEventListener("shopify:section:"+e,t)}findProductForms(e=document){return e.querySelectorAll('form[action*="/cart/add"]')}findProductFormBestMatch(e,t){let i="#product_form_"+e,r=document.querySelector(i);if(r&&null!=r.querySelector("shopify-payment-terms")&&(r=null),r&&document.querySelector(`[data-product-form="${e}"]`)&&(r=null),r&&this.isProductFormInstallment(r)&&(r=null),r&&this.isTheme("Dawn")){let t=document.querySelector('[data-type="add-to-cart-form"]');t&&(t.dataset.productForm=e.toString(),r=null)}if(r&&t.srcEl&&t.srcEl.closest(".shopify-app-block")&&(r=null),!r){let i=null;if(t&&t.srcEl){let e=t.srcEl.parentNode;for(;e;){if(i=this.findProductForms(e),i.length){t.parentEl=e;break}e=e.parentNode}}if(null!=i&&0!==i.length||(i=this.findProductForms()),1===i.length)return i[0];if(i.length>1)for(let t=0;t1){let e=i.closest("form");if(e&&this.isProductFormInstallment(e))continue;if(i.disabled)continue}return i}}if(e.elements instanceof HTMLFormControlsCollection){let t=e.id;if(t)return t}}return null}findProductFormVariantId(e){let t=this.findProductFormVariantIdEl(e);return t?t.value:null}onVariantIdChange(e,t){let i=this.findProductFormVariantIdEl(e);if(i)if(o.isNodeList(i))for(let e=0;et(e,r.value)))}else i.addEventListener("change",(e=>t(e,i.value)))}findProductFormQuantityEl(e,t){return null!=e?e.querySelector("[name=quantity]")||(t?t.querySelector("[name=quantity]"):null):null}findProductFormQuantity(e,t){let i=this.findProductFormQuantityEl(e,t);return null!=i?parseInt(i.value):1}getFormProperties(e){const t=new FormData(e);return Array.from(t.keys()).reduce(((e,i)=>{if(-1!==i.indexOf("properties")){let r=i.indexOf("["),o=i.indexOf("]");if(-1!==r&&-1!==o){let n=i.substring(r+1,o);if(e.hasOwnProperty(n)){let r=t.getAll(i);e[n]=r[r.length-1]}else e[n]=t.get(i)}}return e}),{})}findExpressPaymentButtons(e=document){return e.querySelectorAll('.shopify-payment-button, [data-shopify="payment-button"]')}findExpressDynamicCheckoutCart(e=document){return e.querySelectorAll('#dynamic-checkout-cart, [data-shopify="dynamic-checkout-cart"]')}isExpressPaymentButton(e){return o.matchesIncludeParent(e,'.shopify-payment-button, [data-shopify="payment-button"]')}onProductFormSubmit(e,t,i,r,n=["[data-live-validate]"]){let s="[type=submit],.add_to_cart,.add-to-cart,.product-addToCart,.addToCart,.addtocart-js";this.isTheme("Dawn")&&(s=s.replace("[type=submit]","[type=submit]:not(.quick-add__submit)"));let l=t.querySelectorAll(n.join(","));if(l.length&&(r=!1),!r){e.addEventListener("submit",i);let t=e.querySelectorAll(s);for(let e=0;e{t.target&&o.matchesIncludeParent(t.target,e)&&i(t)}),{capture:!0})}}onCartFormSubmit(e,t,i=["[data-live-checkout]"]){let r='form[action="/cart"], form[action$="/cart"], form[action*="/cart?"], form[action="/checkout"], form[action$="/checkout"], form[action*="/checkout?"]';if(i.push('a[href="/checkout"], a[href$="/checkout"], a[href*="/checkout?"], button[onclick*="/checkout"]'),t){document.addEventListener("submit",(t=>{t.target&&o.matches(t.target,r)&&e(t)}),{capture:!0});const t=i.join(",");document.addEventListener("click",(i=>{i.target&&(o.matches(i.target,t)||null!=o.findParent(i.target,t))&&e(i)}),{capture:!0})}else{let t=document.querySelectorAll(r);if(t.length)for(let i=0;i{e(t)}))}let o=document.querySelectorAll(i.join(","));for(let t=0;t(this.cache=e,e)))}getItemLine(e,t){for(let i=0;ie.items))}removeItem(e){return this.updateItem(e,this.toItem(null,0))}removeItemById(e){return this.updateItemById(this.toItem(e,0))}updateItem(e,t){return this._cartChange({line:e,quantity:t.quantity,properties:t.properties})}updateItemById(e){return this._cartChange(e)}updateItemQuantitiesById(e){return this._cartUpdate({updates:e})}setNote(e){return this._cartUpdate({note:e})}setAttributes(e){return this._cartUpdate({attributes:e})}clear(){return this._cartClear()}_cart(){return this._cartRequest("/cart.js",{method:"GET"})}_cartAdd(e){return this._cartRequest("/cart/add.js",{method:"POST",data:e})}_cartUpdate(e){return this._cartRequest("/cart/update.js",{method:"POST",data:e})}_cartChange(e){return this._cartRequest("/cart/change.js",{method:"POST",data:e})}_cartClear(){return this._cartRequest("/cart/clear.js",{method:"POST"})}_cartRequest(e,t){let i=o.extend(this.settings.requestOptions,t),r=this.settings.api+e;return new n(r,i).then((e=>(a.debug("[shopify-cart] "+r+" response",e.data),e.data))).catch((e=>{throw a.error("[shopify-cart] "+r+" error",e),e.data}))}constructor(e){this.cache=null,this.settings=o.extend({api:"",requestOptions:{responseType:"json",headers:{"Content-type":"application/json"}}},e||{})}}var g=m;class f{static register(e){return this.listeners.push(e),this.patched||this._patch(),()=>{let t=this.listeners.indexOf(e);-1!==t&&this.listeners.splice(t,1),0===this.listeners.length&&this._unpatch()}}static _callListeners(e){for(let t=0;t{"object"==typeof e&&e.pathname&&(e=e.pathname+e.search),f._callListeners({method:t,url:e})})),i}),this.patched=!0}static _unpatch(){f.originalOpen&&(XMLHttpRequest.prototype.open=f.originalOpen),f.originalFetch&&(window.fetch=f.originalFetch),this.patched=!1}}f.patched=!1,f.listeners=[];var v=f; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */const y=new WeakMap,_=e=>(...t)=>{const i=e(...t);return y.set(i,!0),i},w=e=>"function"==typeof e&&y.has(e),b="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,x=(e,t,i=null,r=null)=>{for(;t!==i;){const i=t.nextSibling;e.insertBefore(t,r),t=i}},C=(e,t,i=null)=>{for(;t!==i;){const i=t.nextSibling;e.removeChild(t),t=i}},E={},I={},S=`{{lit-${String(Math.random()).slice(2)}}}`,P=`\x3c!--${S}--\x3e`,O=new RegExp(`${S}|${P}`),M="$lit$";class L{constructor(e,t){this.parts=[],this.element=t;const i=[],r=[],o=document.createTreeWalker(t.content,133,null,!1);let n=0,a=-1,s=0;const{strings:l,values:{length:c}}=e;for(;s0;){const t=l[s],i=A.exec(t)[2],r=i.toLowerCase()+M,o=e.getAttribute(r);e.removeAttribute(r);const n=o.split(O);this.parts.push({type:"attribute",index:a,name:i,strings:n}),s+=n.length-1}}"TEMPLATE"===e.tagName&&(r.push(e),o.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(S)>=0){const r=e.parentNode,o=t.split(O),n=o.length-1;for(let t=0;t{const i=e.length-t.length;return i>=0&&e.slice(i)===t},$=e=>-1!==e.index,T=()=>document.createComment(""),A=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class F{update(e){let t=0;for(const i of this.__parts)void 0!==i&&i.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=b?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],i=this.template.parts,r=document.createTreeWalker(e,133,null,!1);let o,n=0,a=0,s=r.nextNode();for(;ne}),N=` ${S} `;class j{getHTML(){const e=this.strings.length-1;let t="",i=!1;for(let r=0;r-1||i)&&-1===e.indexOf("--\x3e",o+1);const n=A.exec(e);t+=null===n?e+(i?N:P):e.substr(0,n.index)+n[1]+n[2]+M+n[3]+S}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==D&&(t=D.createHTML(t)),e.innerHTML=t,e}constructor(e,t,i,r){this.strings=e,this.values=t,this.type=i,this.processor=r}}const R=e=>null===e||!("object"==typeof e||"function"==typeof e),V=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class z{_createPart(){return new q(this)}_getValue(){const e=this.strings,t=e.length-1,i=this.parts;if(1===t&&""===e[0]&&""===e[1]){const e=i[0].value;if("symbol"==typeof e)return String(e);if("string"==typeof e||!V(e))return e}let r="";for(let o=0;o{try{const e={get capture(){return Y=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}})();class G{setValue(e){this.__pendingValue=e}commit(){for(;w(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=E,e(this)}if(this.__pendingValue===E)return;const e=this.__pendingValue,t=this.value,i=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive),r=null!=e&&(null==t||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),r&&(this.__options=Q(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=E}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}constructor(e,t,i){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=i,this.__boundHandleEvent=e=>this.handleEvent(e)}}const Q=e=>e&&(Y?{capture:e.capture,passive:e.passive,once:e.once}:e.capture);const X=new class{handleAttributeExpressions(e,t,i,r){const o=t[0];if("."===o){return new U(e,t.slice(1),i).parts}if("@"===o)return[new G(e,t.slice(1),r.eventContext)];if("?"===o)return[new B(e,t.slice(1),i)];return new z(e,t,i).parts}handleTextExpression(e){return new H(e)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */function Z(e){let t=J.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},J.set(e.type,t));let i=t.stringsArray.get(e.strings);if(void 0!==i)return i;const r=e.strings.join(S);return i=t.keyString.get(r),void 0===i&&(i=new L(e,e.getTemplateElement()),t.keyString.set(r,i)),t.stringsArray.set(e.strings,i),i}const J=new Map,K=new WeakMap,ee=(e,t,i)=>{let r=K.get(t);void 0===r&&(C(t,t.firstChild),K.set(t,r=new H(Object.assign({templateFactory:Z},i))),r.appendInto(t)),r.setValue(e),r.commit()};"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const te=(e,...t)=>new j(e,t,"html",X); /**! * tippy.js v6.3.7 * (c) 2017-2021 atomiks * MIT License */ function ie(e){return e?(e.nodeName||"").toLowerCase():null}function re(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function oe(e){return e instanceof re(e).Element||e instanceof Element}function ne(e){return e instanceof re(e).HTMLElement||e instanceof HTMLElement}function ae(e){return"undefined"!=typeof ShadowRoot&&(e instanceof re(e).ShadowRoot||e instanceof ShadowRoot)}var se={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var i=t.styles[e]||{},r=t.attributes[e]||{},o=t.elements[e];ne(o)&&ie(o)&&(Object.assign(o.style,i),Object.keys(r).forEach((function(e){var t=r[e];!1===t?o.removeAttribute(e):o.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow),function(){Object.keys(t.elements).forEach((function(e){var r=t.elements[e],o=t.attributes[e]||{},n=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:i[e]).reduce((function(e,t){return e[t]="",e}),{});ne(r)&&ie(r)&&(Object.assign(r.style,n),Object.keys(o).forEach((function(e){r.removeAttribute(e)})))}))}},requires:["computeStyles"]},le=Math.max,ce=Math.min,pe=Math.round;function de(){var e=navigator.userAgentData;return null!=e&&e.brands?e.brands.map((function(e){return e.brand+"/"+e.version})).join(" "):navigator.userAgent}function ue(){return!/^((?!chrome|android).)*safari/i.test(de())}function he(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=!1);var r=e.getBoundingClientRect(),o=1,n=1;t&&ne(e)&&(o=e.offsetWidth>0&&pe(r.width)/e.offsetWidth||1,n=e.offsetHeight>0&&pe(r.height)/e.offsetHeight||1);var a=(oe(e)?re(e):window).visualViewport,s=!ue()&&i,l=(r.left+(s&&a?a.offsetLeft:0))/o,c=(r.top+(s&&a?a.offsetTop:0))/n,p=r.width/o,d=r.height/n;return{width:p,height:d,top:c,right:l+p,bottom:c+d,left:l,x:l,y:c}}function me(e){var t=re(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function ge(e){return((oe(e)?e.ownerDocument:e.document)||window.document).documentElement}function fe(e){return he(ge(e)).left+me(e).scrollLeft}function ve(e){return re(e).getComputedStyle(e)}function ye(e){var t=ve(e),i=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(i+o+r)}function _e(e,t,i){void 0===i&&(i=!1);var r,o,n=ne(t),a=ne(t)&&function(e){var t=e.getBoundingClientRect(),i=pe(t.width)/e.offsetWidth||1,r=pe(t.height)/e.offsetHeight||1;return 1!==i||1!==r}(t),s=ge(t),l=he(e,a,i),c={scrollLeft:0,scrollTop:0},p={x:0,y:0};return(n||!n&&!i)&&(("body"!==ie(t)||ye(s))&&(c=(r=t)!==re(r)&&ne(r)?{scrollLeft:(o=r).scrollLeft,scrollTop:o.scrollTop}:me(r)),ne(t)?((p=he(t,!0)).x+=t.clientLeft,p.y+=t.clientTop):s&&(p.x=fe(s))),{x:l.left+c.scrollLeft-p.x,y:l.top+c.scrollTop-p.y,width:l.width,height:l.height}}function we(e){var t=he(e),i=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-i)<=1&&(i=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:i,height:r}}function be(e){return"html"===ie(e)?e:e.assignedSlot||e.parentNode||(ae(e)?e.host:null)||ge(e)}function xe(e){return["html","body","#document"].indexOf(ie(e))>=0?e.ownerDocument.body:ne(e)&&ye(e)?e:xe(be(e))}function Ce(e,t){var i;void 0===t&&(t=[]);var r=xe(e),o=r===(null==(i=e.ownerDocument)?void 0:i.body),n=re(r),a=o?[n].concat(n.visualViewport||[],ye(r)?r:[]):r,s=t.concat(a);return o?s:s.concat(Ce(be(a)))}function Ee(e){return["table","td","th"].indexOf(ie(e))>=0}function Ie(e){return ne(e)&&"fixed"!==ve(e).position?e.offsetParent:null}function Se(e){for(var t=re(e),i=Ie(e);i&&Ee(i)&&"static"===ve(i).position;)i=Ie(i);return i&&("html"===ie(i)||"body"===ie(i)&&"static"===ve(i).position)?t:i||function(e){var t=/firefox/i.test(de());if(/Trident/i.test(de())&&ne(e)&&"fixed"===ve(e).position)return null;var i=be(e);for(ae(i)&&(i=i.host);ne(i)&&["html","body"].indexOf(ie(i))<0;){var r=ve(i);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return i;i=i.parentNode}return null}(e)||t}var Pe="top",Oe="bottom",Me="right",Le="left",ke="auto",$e=[Pe,Oe,Me,Le],Te="start",Ae="end",Fe="clippingParents",De="viewport",Ne="popper",je="reference",Re=$e.reduce((function(e,t){return e.concat([t+"-"+Te,t+"-"+Ae])}),[]),Ve=[].concat($e,[ke]).reduce((function(e,t){return e.concat([t,t+"-"+Te,t+"-"+Ae])}),[]),ze=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function qe(e){var t=new Map,i=new Set,r=[];function o(e){i.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!i.has(e)){var r=t.get(e);r&&o(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){i.has(e.name)||o(e)})),r}function He(e){var t=qe(e);return ze.reduce((function(e,i){return e.concat(t.filter((function(e){return e.phase===i})))}),[])}function Be(e){var t=e.reduce((function(e,t){var i=e[t.name];return e[t.name]=i?Object.assign({},i,t,{options:Object.assign({},i.options,t.options),data:Object.assign({},i.data,t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}var Ue={placement:"bottom",modifiers:[],strategy:"absolute"};function We(){for(var e=arguments.length,t=new Array(e),i=0;i=0?"x":"y"}function Je(e){var t,i=e.reference,r=e.element,o=e.placement,n=o?Qe(o):null,a=o?Xe(o):null,s=i.x+i.width/2-r.width/2,l=i.y+i.height/2-r.height/2;switch(n){case Pe:t={x:s,y:i.y-r.height};break;case Oe:t={x:s,y:i.y+i.height};break;case Me:t={x:i.x+i.width,y:l};break;case Le:t={x:i.x-r.width,y:l};break;default:t={x:i.x,y:i.y}}var c=n?Ze(n):null;if(null!=c){var p="y"===c?"height":"width";switch(a){case Te:t[c]=t[c]-(i[p]/2-r[p]/2);break;case Ae:t[c]=t[c]+(i[p]/2-r[p]/2)}}return t}var Ke={top:"auto",right:"auto",bottom:"auto",left:"auto"};function et(e){var t,i=e.popper,r=e.popperRect,o=e.placement,n=e.variation,a=e.offsets,s=e.position,l=e.gpuAcceleration,c=e.adaptive,p=e.roundOffsets,d=e.isFixed,u=a.x,h=void 0===u?0:u,m=a.y,g=void 0===m?0:m,f="function"==typeof p?p({x:h,y:g}):{x:h,y:g};h=f.x,g=f.y;var v=a.hasOwnProperty("x"),y=a.hasOwnProperty("y"),_=Le,w=Pe,b=window;if(c){var x=Se(i),C="clientHeight",E="clientWidth";if(x===re(i)&&"static"!==ve(x=ge(i)).position&&"absolute"===s&&(C="scrollHeight",E="scrollWidth"),o===Pe||(o===Le||o===Me)&&n===Ae)w=Oe,g-=(d&&x===b&&b.visualViewport?b.visualViewport.height:x[C])-r.height,g*=l?1:-1;if(o===Le||(o===Pe||o===Oe)&&n===Ae)_=Me,h-=(d&&x===b&&b.visualViewport?b.visualViewport.width:x[E])-r.width,h*=l?1:-1}var I,S=Object.assign({position:s},c&&Ke),P=!0===p?function(e){var t=e.x,i=e.y,r=window.devicePixelRatio||1;return{x:pe(t*r)/r||0,y:pe(i*r)/r||0}}({x:h,y:g}):{x:h,y:g};return h=P.x,g=P.y,l?Object.assign({},S,((I={})[w]=y?"0":"",I[_]=v?"0":"",I.transform=(b.devicePixelRatio||1)<=1?"translate("+h+"px, "+g+"px)":"translate3d("+h+"px, "+g+"px, 0)",I)):Object.assign({},S,((t={})[w]=y?g+"px":"",t[_]=v?h+"px":"",t.transform="",t))}var tt={left:"right",right:"left",bottom:"top",top:"bottom"};function it(e){return e.replace(/left|right|bottom|top/g,(function(e){return tt[e]}))}var rt={start:"end",end:"start"};function ot(e){return e.replace(/start|end/g,(function(e){return rt[e]}))}function nt(e,t){var i=re(e),r=ge(e),o=i.visualViewport,n=r.clientWidth,a=r.clientHeight,s=0,l=0;if(o){n=o.width,a=o.height;var c=ue();(c||!c&&"fixed"===t)&&(s=o.offsetLeft,l=o.offsetTop)}return{width:n,height:a,x:s+fe(e),y:l}}function at(e){var t,i=ge(e),r=me(e),o=null==(t=e.ownerDocument)?void 0:t.body,n=le(i.scrollWidth,i.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=le(i.scrollHeight,i.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),s=-r.scrollLeft+fe(e),l=-r.scrollTop;return"rtl"===ve(o||i).direction&&(s+=le(i.clientWidth,o?o.clientWidth:0)-n),{width:n,height:a,x:s,y:l}}function st(e,t){var i=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(i&&ae(i)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function lt(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function ct(e,t,i){return t===De?lt(nt(e,i)):oe(t)?function(e,t){var i=he(e,!1,"fixed"===t);return i.top=i.top+e.clientTop,i.left=i.left+e.clientLeft,i.bottom=i.top+e.clientHeight,i.right=i.left+e.clientWidth,i.width=e.clientWidth,i.height=e.clientHeight,i.x=i.left,i.y=i.top,i}(t,i):lt(at(ge(e)))}function pt(e,t,i,r){var o="clippingParents"===t?function(e){var t=Ce(be(e)),i=["absolute","fixed"].indexOf(ve(e).position)>=0&&ne(e)?Se(e):e;return oe(i)?t.filter((function(e){return oe(e)&&st(e,i)&&"body"!==ie(e)})):[]}(e):[].concat(t),n=[].concat(o,[i]),a=n[0],s=n.reduce((function(t,i){var o=ct(e,i,r);return t.top=le(o.top,t.top),t.right=ce(o.right,t.right),t.bottom=ce(o.bottom,t.bottom),t.left=le(o.left,t.left),t}),ct(e,a,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function dt(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function ut(e,t){return t.reduce((function(t,i){return t[i]=e,t}),{})}function ht(e,t){void 0===t&&(t={});var i=t,r=i.placement,o=void 0===r?e.placement:r,n=i.strategy,a=void 0===n?e.strategy:n,s=i.boundary,l=void 0===s?Fe:s,c=i.rootBoundary,p=void 0===c?De:c,d=i.elementContext,u=void 0===d?Ne:d,h=i.altBoundary,m=void 0!==h&&h,g=i.padding,f=void 0===g?0:g,v=dt("number"!=typeof f?f:ut(f,$e)),y=u===Ne?je:Ne,_=e.rects.popper,w=e.elements[m?y:u],b=pt(oe(w)?w:w.contextElement||ge(e.elements.popper),l,p,a),x=he(e.elements.reference),C=Je({reference:x,element:_,strategy:"absolute",placement:o}),E=lt(Object.assign({},_,C)),I=u===Ne?E:x,S={top:b.top-I.top+v.top,bottom:I.bottom-b.bottom+v.bottom,left:b.left-I.left+v.left,right:I.right-b.right+v.right},P=e.modifiersData.offset;if(u===Ne&&P){var O=P[o];Object.keys(S).forEach((function(e){var t=[Me,Oe].indexOf(e)>=0?1:-1,i=[Pe,Oe].indexOf(e)>=0?"y":"x";S[e]+=O[i]*t}))}return S}function mt(e,t){void 0===t&&(t={});var i=t,r=i.placement,o=i.boundary,n=i.rootBoundary,a=i.padding,s=i.flipVariations,l=i.allowedAutoPlacements,c=void 0===l?Ve:l,p=Xe(r),d=p?s?Re:Re.filter((function(e){return Xe(e)===p})):$e,u=d.filter((function(e){return c.indexOf(e)>=0}));0===u.length&&(u=d);var h=u.reduce((function(t,i){return t[i]=ht(e,{placement:i,boundary:o,rootBoundary:n,padding:a})[Qe(i)],t}),{});return Object.keys(h).sort((function(e,t){return h[e]-h[t]}))}function gt(e,t,i){return le(e,ce(t,i))}function ft(e,t,i){var r=gt(e,t,i);return r>i?i:r}var vt=function(e,t){return dt("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:ut(e,$e))};function yt(e,t,i){return void 0===i&&(i={x:0,y:0}),{top:e.top-t.height-i.y,right:e.right-t.width+i.x,bottom:e.bottom-t.height+i.y,left:e.left-t.width-i.x}}function _t(e){return[Pe,Me,Oe,Le].some((function(t){return e[t]>=0}))}var wt=Ye({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,i=e.instance,r=e.options,o=r.scroll,n=void 0===o||o,a=r.resize,s=void 0===a||a,l=re(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return n&&c.forEach((function(e){e.addEventListener("scroll",i.update,Ge)})),s&&l.addEventListener("resize",i.update,Ge),function(){n&&c.forEach((function(e){e.removeEventListener("scroll",i.update,Ge)})),s&&l.removeEventListener("resize",i.update,Ge)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,i=e.name;t.modifiersData[i]=Je({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,i=e.options,r=i.gpuAcceleration,o=void 0===r||r,n=i.adaptive,a=void 0===n||n,s=i.roundOffsets,l=void 0===s||s,c={placement:Qe(t.placement),variation:Xe(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:o,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,et(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:a,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,et(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},se,{name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,i=e.options,r=e.name,o=i.offset,n=void 0===o?[0,0]:o,a=Ve.reduce((function(e,i){return e[i]=function(e,t,i){var r=Qe(e),o=[Le,Pe].indexOf(r)>=0?-1:1,n="function"==typeof i?i(Object.assign({},t,{placement:e})):i,a=n[0],s=n[1];return a=a||0,s=(s||0)*o,[Le,Me].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(i,t.rects,n),e}),{}),s=a[t.placement],l=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},{name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,i=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=i.mainAxis,n=void 0===o||o,a=i.altAxis,s=void 0===a||a,l=i.fallbackPlacements,c=i.padding,p=i.boundary,d=i.rootBoundary,u=i.altBoundary,h=i.flipVariations,m=void 0===h||h,g=i.allowedAutoPlacements,f=t.options.placement,v=Qe(f),y=l||(v===f||!m?[it(f)]:function(e){if(Qe(e)===ke)return[];var t=it(e);return[ot(e),t,ot(t)]}(f)),_=[f].concat(y).reduce((function(e,i){return e.concat(Qe(i)===ke?mt(t,{placement:i,boundary:p,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:g}):i)}),[]),w=t.rects.reference,b=t.rects.popper,x=new Map,C=!0,E=_[0],I=0;I<_.length;I++){var S=_[I],P=Qe(S),O=Xe(S)===Te,M=[Pe,Oe].indexOf(P)>=0,L=M?"width":"height",k=ht(t,{placement:S,boundary:p,rootBoundary:d,altBoundary:u,padding:c}),$=M?O?Me:Le:O?Oe:Pe;w[L]>b[L]&&($=it($));var T=it($),A=[];if(n&&A.push(k[P]<=0),s&&A.push(k[$]<=0,k[T]<=0),A.every((function(e){return e}))){E=S,C=!1;break}x.set(S,A)}if(C)for(var F=function(e){var t=_.find((function(t){var i=x.get(t);if(i)return i.slice(0,e).every((function(e){return e}))}));if(t)return E=t,"break"},D=m?3:1;D>0;D--){if("break"===F(D))break}t.placement!==E&&(t.modifiersData[r]._skip=!0,t.placement=E,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},{name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,i=e.options,r=e.name,o=i.mainAxis,n=void 0===o||o,a=i.altAxis,s=void 0!==a&&a,l=i.boundary,c=i.rootBoundary,p=i.altBoundary,d=i.padding,u=i.tether,h=void 0===u||u,m=i.tetherOffset,g=void 0===m?0:m,f=ht(t,{boundary:l,rootBoundary:c,padding:d,altBoundary:p}),v=Qe(t.placement),y=Xe(t.placement),_=!y,w=Ze(v),b="x"===w?"y":"x",x=t.modifiersData.popperOffsets,C=t.rects.reference,E=t.rects.popper,I="function"==typeof g?g(Object.assign({},t.rects,{placement:t.placement})):g,S="number"==typeof I?{mainAxis:I,altAxis:I}:Object.assign({mainAxis:0,altAxis:0},I),P=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(x){if(n){var M,L="y"===w?Pe:Le,k="y"===w?Oe:Me,$="y"===w?"height":"width",T=x[w],A=T+f[L],F=T-f[k],D=h?-E[$]/2:0,N=y===Te?C[$]:E[$],j=y===Te?-E[$]:-C[$],R=t.elements.arrow,V=h&&R?we(R):{width:0,height:0},z=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},q=z[L],H=z[k],B=gt(0,C[$],V[$]),U=_?C[$]/2-D-B-q-S.mainAxis:N-B-q-S.mainAxis,W=_?-C[$]/2+D+B+H+S.mainAxis:j+B+H+S.mainAxis,Y=t.elements.arrow&&Se(t.elements.arrow),G=Y?"y"===w?Y.clientTop||0:Y.clientLeft||0:0,Q=null!=(M=null==P?void 0:P[w])?M:0,X=T+W-Q,Z=gt(h?ce(A,T+U-Q-G):A,T,h?le(F,X):F);x[w]=Z,O[w]=Z-T}if(s){var J,K="x"===w?Pe:Le,ee="x"===w?Oe:Me,te=x[b],ie="y"===b?"height":"width",re=te+f[K],oe=te-f[ee],ne=-1!==[Pe,Le].indexOf(v),ae=null!=(J=null==P?void 0:P[b])?J:0,se=ne?re:te-C[ie]-E[ie]-ae+S.altAxis,pe=ne?te+C[ie]+E[ie]-ae-S.altAxis:oe,de=h&&ne?ft(se,te,pe):gt(h?se:re,te,h?pe:oe);x[b]=de,O[b]=de-te}t.modifiersData[r]=O}},requiresIfExists:["offset"]},{name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,i=e.state,r=e.name,o=e.options,n=i.elements.arrow,a=i.modifiersData.popperOffsets,s=Qe(i.placement),l=Ze(s),c=[Le,Me].indexOf(s)>=0?"height":"width";if(n&&a){var p=vt(o.padding,i),d=we(n),u="y"===l?Pe:Le,h="y"===l?Oe:Me,m=i.rects.reference[c]+i.rects.reference[l]-a[l]-i.rects.popper[c],g=a[l]-i.rects.reference[l],f=Se(n),v=f?"y"===l?f.clientHeight||0:f.clientWidth||0:0,y=m/2-g/2,_=p[u],w=v-d[c]-p[h],b=v/2-d[c]/2+y,x=gt(_,b,w),C=l;i.modifiersData[r]=((t={})[C]=x,t.centerOffset=x-b,t)}},effect:function(e){var t=e.state,i=e.options.element,r=void 0===i?"[data-popper-arrow]":i;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&st(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,i=e.name,r=t.rects.reference,o=t.rects.popper,n=t.modifiersData.preventOverflow,a=ht(t,{elementContext:"reference"}),s=ht(t,{altBoundary:!0}),l=yt(a,r),c=yt(s,o,n),p=_t(l),d=_t(c);t.modifiersData[i]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":d})}}]}),bt="tippy-box",xt="tippy-content",Ct="tippy-backdrop",Et="tippy-arrow",It="tippy-svg-arrow",St={passive:!0,capture:!0},Pt=function(){return document.body};function Ot(e,t,i){if(Array.isArray(e)){var r=e[t];return null==r?Array.isArray(i)?i[t]:i:r}return e}function Mt(e,t){var i={}.toString.call(e);return 0===i.indexOf("[object")&&i.indexOf(t+"]")>-1}function Lt(e,t){return"function"==typeof e?e.apply(void 0,t):e}function kt(e,t){return 0===t?e:function(r){clearTimeout(i),i=setTimeout((function(){e(r)}),t)};var i}function $t(e){return[].concat(e)}function Tt(e,t){-1===e.indexOf(t)&&e.push(t)}function At(e){return e.split("-")[0]}function Ft(e){return[].slice.call(e)}function Dt(e){return Object.keys(e).reduce((function(t,i){return void 0!==e[i]&&(t[i]=e[i]),t}),{})}function Nt(){return document.createElement("div")}function jt(e){return["Element","Fragment"].some((function(t){return Mt(e,t)}))}function Rt(e){return Mt(e,"MouseEvent")}function Vt(e){return!(!e||!e._tippy||e._tippy.reference!==e)}function zt(e){return jt(e)?[e]:function(e){return Mt(e,"NodeList")}(e)?Ft(e):Array.isArray(e)?e:Ft(document.querySelectorAll(e))}function qt(e,t){e.forEach((function(e){e&&(e.style.transitionDuration=t+"ms")}))}function Ht(e,t){e.forEach((function(e){e&&e.setAttribute("data-state",t)}))}function Bt(e){var t,i=$t(e)[0];return null!=i&&null!=(t=i.ownerDocument)&&t.body?i.ownerDocument:document}function Ut(e,t,i){var r=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(t){e[r](t,i)}))}function Wt(e,t){for(var i=t;i;){var r;if(e.contains(i))return!0;i=null==i.getRootNode||null==(r=i.getRootNode())?void 0:r.host}return!1}var Yt={isTouch:!1},Gt=0;function Qt(){Yt.isTouch||(Yt.isTouch=!0,window.performance&&document.addEventListener("mousemove",Xt))}function Xt(){var e=performance.now();e-Gt<20&&(Yt.isTouch=!1,document.removeEventListener("mousemove",Xt)),Gt=e}function Zt(){var e=document.activeElement;if(Vt(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}var Jt=!!("undefined"!=typeof window&&"undefined"!=typeof document)&&!!window.msCrypto;var Kt={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},ei=Object.assign({appendTo:Pt,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},Kt,{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),ti=Object.keys(ei);function ii(e){var t=(e.plugins||[]).reduce((function(t,i){var r,o=i.name,n=i.defaultValue;o&&(t[o]=void 0!==e[o]?e[o]:null!=(r=ei[o])?r:n);return t}),{});return Object.assign({},e,t)}function ri(e,t){var i=Object.assign({},t,{content:Lt(t.content,[e])},t.ignoreAttributes?{}:function(e,t){return(t?Object.keys(ii(Object.assign({},ei,{plugins:t}))):ti).reduce((function(t,i){var r=(e.getAttribute("data-tippy-"+i)||"").trim();if(!r)return t;if("content"===i)t[i]=r;else try{t[i]=JSON.parse(r)}catch(e){t[i]=r}return t}),{})}(e,t.plugins));return i.aria=Object.assign({},ei.aria,i.aria),i.aria={expanded:"auto"===i.aria.expanded?t.interactive:i.aria.expanded,content:"auto"===i.aria.content?t.interactive?null:"describedby":i.aria.content},i}var oi=function(){return"innerHTML"};function ni(e,t){e[oi()]=t}function ai(e){var t=Nt();return!0===e?t.className=Et:(t.className=It,jt(e)?t.appendChild(e):ni(t,e)),t}function si(e,t){jt(t.content)?(ni(e,""),e.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?ni(e,t.content):e.textContent=t.content)}function li(e){var t=e.firstElementChild,i=Ft(t.children);return{box:t,content:i.find((function(e){return e.classList.contains(xt)})),arrow:i.find((function(e){return e.classList.contains(Et)||e.classList.contains(It)})),backdrop:i.find((function(e){return e.classList.contains(Ct)}))}}function ci(e){var t=Nt(),i=Nt();i.className=bt,i.setAttribute("data-state","hidden"),i.setAttribute("tabindex","-1");var r=Nt();function o(i,r){var o=li(t),n=o.box,a=o.content,s=o.arrow;r.theme?n.setAttribute("data-theme",r.theme):n.removeAttribute("data-theme"),"string"==typeof r.animation?n.setAttribute("data-animation",r.animation):n.removeAttribute("data-animation"),r.inertia?n.setAttribute("data-inertia",""):n.removeAttribute("data-inertia"),n.style.maxWidth="number"==typeof r.maxWidth?r.maxWidth+"px":r.maxWidth,r.role?n.setAttribute("role",r.role):n.removeAttribute("role"),i.content===r.content&&i.allowHTML===r.allowHTML||si(a,e.props),r.arrow?s?i.arrow!==r.arrow&&(n.removeChild(s),n.appendChild(ai(r.arrow))):n.appendChild(ai(r.arrow)):s&&n.removeChild(s)}return r.className=xt,r.setAttribute("data-state","hidden"),si(r,e.props),t.appendChild(i),i.appendChild(r),o(e.props,e.props),{popper:t,onUpdate:o}}ci.$$tippy=!0;var pi=1,di=[],ui=[];function hi(e,t){var i,r,o,n,a,s,l,c,p=ri(e,Object.assign({},ei,ii(Dt(t)))),d=!1,u=!1,h=!1,m=!1,g=[],f=kt(Y,p.interactiveDebounce),v=pi++,y=(c=p.plugins).filter((function(e,t){return c.indexOf(e)===t})),_={id:v,reference:e,popper:Nt(),popperInstance:null,props:p,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:y,clearDelayTimeouts:function(){clearTimeout(i),clearTimeout(r),cancelAnimationFrame(o)},setProps:function(t){if(_.state.isDestroyed)return;T("onBeforeUpdate",[_,t]),U();var i=_.props,r=ri(e,Object.assign({},i,Dt(t),{ignoreAttributes:!0}));_.props=r,B(),i.interactiveDebounce!==r.interactiveDebounce&&(D(),f=kt(Y,r.interactiveDebounce));i.triggerTarget&&!r.triggerTarget?$t(i.triggerTarget).forEach((function(e){e.removeAttribute("aria-expanded")})):r.triggerTarget&&e.removeAttribute("aria-expanded");F(),$(),x&&x(i,r);_.popperInstance&&(Z(),K().forEach((function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})));T("onAfterUpdate",[_,t])},setContent:function(e){_.setProps({content:e})},show:function(){var e=_.state.isVisible,t=_.state.isDestroyed,i=!_.state.isEnabled,r=Yt.isTouch&&!_.props.touch,o=Ot(_.props.duration,0,ei.duration);if(e||t||i||r)return;if(O().hasAttribute("disabled"))return;if(T("onShow",[_],!1),!1===_.props.onShow(_))return;_.state.isVisible=!0,P()&&(b.style.visibility="visible");$(),V(),_.state.isMounted||(b.style.transition="none");if(P()){var n=L();qt([n.box,n.content],0)}s=function(){var e;if(_.state.isVisible&&!m){if(m=!0,b.offsetHeight,b.style.transition=_.props.moveTransition,P()&&_.props.animation){var t=L(),i=t.box,r=t.content;qt([i,r],o),Ht([i,r],"visible")}A(),F(),Tt(ui,_),null==(e=_.popperInstance)||e.forceUpdate(),T("onMount",[_]),_.props.animation&&P()&&function(e,t){q(e,t)}(o,(function(){_.state.isShown=!0,T("onShown",[_])}))}},function(){var e,t=_.props.appendTo,i=O();e=_.props.interactive&&t===Pt||"parent"===t?i.parentNode:Lt(t,[i]);e.contains(b)||e.appendChild(b);_.state.isMounted=!0,Z()}()},hide:function(){var e=!_.state.isVisible,t=_.state.isDestroyed,i=!_.state.isEnabled,r=Ot(_.props.duration,1,ei.duration);if(e||t||i)return;if(T("onHide",[_],!1),!1===_.props.onHide(_))return;_.state.isVisible=!1,_.state.isShown=!1,m=!1,d=!1,P()&&(b.style.visibility="hidden");if(D(),z(),$(!0),P()){var o=L(),n=o.box,a=o.content;_.props.animation&&(qt([n,a],r),Ht([n,a],"hidden"))}A(),F(),_.props.animation?P()&&function(e,t){q(e,(function(){!_.state.isVisible&&b.parentNode&&b.parentNode.contains(b)&&t()}))}(r,_.unmount):_.unmount()},hideWithInteractivity:function(e){M().addEventListener("mousemove",f),Tt(di,f),f(e)},enable:function(){_.state.isEnabled=!0},disable:function(){_.hide(),_.state.isEnabled=!1},unmount:function(){_.state.isVisible&&_.hide();if(!_.state.isMounted)return;J(),K().forEach((function(e){e._tippy.unmount()})),b.parentNode&&b.parentNode.removeChild(b);ui=ui.filter((function(e){return e!==_})),_.state.isMounted=!1,T("onHidden",[_])},destroy:function(){if(_.state.isDestroyed)return;_.clearDelayTimeouts(),_.unmount(),U(),delete e._tippy,_.state.isDestroyed=!0,T("onDestroy",[_])}};if(!p.render)return _;var w=p.render(_),b=w.popper,x=w.onUpdate;b.setAttribute("data-tippy-root",""),b.id="tippy-"+_.id,_.popper=b,e._tippy=_,b._tippy=_;var C=y.map((function(e){return e.fn(_)})),E=e.hasAttribute("aria-expanded");return B(),F(),$(),T("onCreate",[_]),p.showOnCreate&&ee(),b.addEventListener("mouseenter",(function(){_.props.interactive&&_.state.isVisible&&_.clearDelayTimeouts()})),b.addEventListener("mouseleave",(function(){_.props.interactive&&_.props.trigger.indexOf("mouseenter")>=0&&M().addEventListener("mousemove",f)})),_;function I(){var e=_.props.touch;return Array.isArray(e)?e:[e,0]}function S(){return"hold"===I()[0]}function P(){var e;return!(null==(e=_.props.render)||!e.$$tippy)}function O(){return l||e}function M(){var e=O().parentNode;return e?Bt(e):document}function L(){return li(b)}function k(e){return _.state.isMounted&&!_.state.isVisible||Yt.isTouch||n&&"focus"===n.type?0:Ot(_.props.delay,e?0:1,ei.delay)}function $(e){void 0===e&&(e=!1),b.style.pointerEvents=_.props.interactive&&!e?"":"none",b.style.zIndex=""+_.props.zIndex}function T(e,t,i){var r;(void 0===i&&(i=!0),C.forEach((function(i){i[e]&&i[e].apply(i,t)})),i)&&(r=_.props)[e].apply(r,t)}function A(){var t=_.props.aria;if(t.content){var i="aria-"+t.content,r=b.id;$t(_.props.triggerTarget||e).forEach((function(e){var t=e.getAttribute(i);if(_.state.isVisible)e.setAttribute(i,t?t+" "+r:r);else{var o=t&&t.replace(r,"").trim();o?e.setAttribute(i,o):e.removeAttribute(i)}}))}}function F(){!E&&_.props.aria.expanded&&$t(_.props.triggerTarget||e).forEach((function(e){_.props.interactive?e.setAttribute("aria-expanded",_.state.isVisible&&e===O()?"true":"false"):e.removeAttribute("aria-expanded")}))}function D(){M().removeEventListener("mousemove",f),di=di.filter((function(e){return e!==f}))}function N(t){if(!Yt.isTouch||!h&&"mousedown"!==t.type){var i=t.composedPath&&t.composedPath()[0]||t.target;if(!_.props.interactive||!Wt(b,i)){if($t(_.props.triggerTarget||e).some((function(e){return Wt(e,i)}))){if(Yt.isTouch)return;if(_.state.isVisible&&_.props.trigger.indexOf("click")>=0)return}else T("onClickOutside",[_,t]);!0===_.props.hideOnClick&&(_.clearDelayTimeouts(),_.hide(),u=!0,setTimeout((function(){u=!1})),_.state.isMounted||z())}}}function j(){h=!0}function R(){h=!1}function V(){var e=M();e.addEventListener("mousedown",N,!0),e.addEventListener("touchend",N,St),e.addEventListener("touchstart",R,St),e.addEventListener("touchmove",j,St)}function z(){var e=M();e.removeEventListener("mousedown",N,!0),e.removeEventListener("touchend",N,St),e.removeEventListener("touchstart",R,St),e.removeEventListener("touchmove",j,St)}function q(e,t){var i=L().box;function r(e){e.target===i&&(Ut(i,"remove",r),t())}if(0===e)return t();Ut(i,"remove",a),Ut(i,"add",r),a=r}function H(t,i,r){void 0===r&&(r=!1),$t(_.props.triggerTarget||e).forEach((function(e){e.addEventListener(t,i,r),g.push({node:e,eventType:t,handler:i,options:r})}))}function B(){var e;S()&&(H("touchstart",W,{passive:!0}),H("touchend",G,{passive:!0})),(e=_.props.trigger,e.split(/\s+/).filter(Boolean)).forEach((function(e){if("manual"!==e)switch(H(e,W),e){case"mouseenter":H("mouseleave",G);break;case"focus":H(Jt?"focusout":"blur",Q);break;case"focusin":H("focusout",Q)}}))}function U(){g.forEach((function(e){var t=e.node,i=e.eventType,r=e.handler,o=e.options;t.removeEventListener(i,r,o)})),g=[]}function W(e){var t,i=!1;if(_.state.isEnabled&&!X(e)&&!u){var r="focus"===(null==(t=n)?void 0:t.type);n=e,l=e.currentTarget,F(),!_.state.isVisible&&Rt(e)&&di.forEach((function(t){return t(e)})),"click"===e.type&&(_.props.trigger.indexOf("mouseenter")<0||d)&&!1!==_.props.hideOnClick&&_.state.isVisible?i=!0:ee(e),"click"===e.type&&(d=!i),i&&!r&&te(e)}}function Y(e){var t=e.target,i=O().contains(t)||b.contains(t);if("mousemove"!==e.type||!i){var r=K().concat(b).map((function(e){var t,i=null==(t=e._tippy.popperInstance)?void 0:t.state;return i?{popperRect:e.getBoundingClientRect(),popperState:i,props:p}:null})).filter(Boolean);(function(e,t){var i=t.clientX,r=t.clientY;return e.every((function(e){var t=e.popperRect,o=e.popperState,n=e.props.interactiveBorder,a=At(o.placement),s=o.modifiersData.offset;if(!s)return!0;var l="bottom"===a?s.top.y:0,c="top"===a?s.bottom.y:0,p="right"===a?s.left.x:0,d="left"===a?s.right.x:0,u=t.top-r+l>n,h=r-t.bottom-c>n,m=t.left-i+p>n,g=i-t.right-d>n;return u||h||m||g}))})(r,e)&&(D(),te(e))}}function G(e){X(e)||_.props.trigger.indexOf("click")>=0&&d||(_.props.interactive?_.hideWithInteractivity(e):te(e))}function Q(e){_.props.trigger.indexOf("focusin")<0&&e.target!==O()||_.props.interactive&&e.relatedTarget&&b.contains(e.relatedTarget)||te(e)}function X(e){return!!Yt.isTouch&&S()!==e.type.indexOf("touch")>=0}function Z(){J();var t=_.props,i=t.popperOptions,r=t.placement,o=t.offset,n=t.getReferenceClientRect,a=t.moveTransition,l=P()?li(b).arrow:null,c=n?{getBoundingClientRect:n,contextElement:n.contextElement||O()}:e,p={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var t=e.state;if(P()){var i=L().box;["placement","reference-hidden","escaped"].forEach((function(e){"placement"===e?i.setAttribute("data-placement",t.placement):t.attributes.popper["data-popper-"+e]?i.setAttribute("data-"+e,""):i.removeAttribute("data-"+e)})),t.attributes.popper={}}}},d=[{name:"offset",options:{offset:o}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!a}},p];P()&&l&&d.push({name:"arrow",options:{element:l,padding:3}}),d.push.apply(d,(null==i?void 0:i.modifiers)||[]),_.popperInstance=wt(c,b,Object.assign({},i,{placement:r,onFirstUpdate:s,modifiers:d}))}function J(){_.popperInstance&&(_.popperInstance.destroy(),_.popperInstance=null)}function K(){return Ft(b.querySelectorAll("[data-tippy-root]"))}function ee(e){_.clearDelayTimeouts(),e&&T("onTrigger",[_,e]),V();var t=k(!0),r=I(),o=r[0],n=r[1];Yt.isTouch&&"hold"===o&&n&&(t=n),t?i=setTimeout((function(){_.show()}),t):_.show()}function te(e){if(_.clearDelayTimeouts(),T("onUntrigger",[_,e]),_.state.isVisible){if(!(_.props.trigger.indexOf("mouseenter")>=0&&_.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0&&d)){var t=k(!1);t?r=setTimeout((function(){_.state.isVisible&&_.hide()}),t):o=requestAnimationFrame((function(){_.hide()}))}}else z()}}function mi(e,t){void 0===t&&(t={});var i=ei.plugins.concat(t.plugins||[]);document.addEventListener("touchstart",Qt,St),window.addEventListener("blur",Zt);var r=Object.assign({},t,{plugins:i}),o=zt(e).reduce((function(e,t){var i=t&&hi(t,r);return i&&e.push(i),e}),[]);return jt(e)?o[0]:o}mi.defaultProps=ei,mi.setDefaultProps=function(e){Object.keys(e).forEach((function(t){ei[t]=e[t]}))},mi.currentInput=Yt;Object.assign({},se,{effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow)}});mi.setDefaultProps({render:ci});var gi=mi; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */const fi=new WeakMap,vi=_((e=>t=>{if(!(t instanceof H))throw new Error("unsafeHTML can only be used in text bindings");const i=fi.get(t);if(void 0!==i&&R(e)&&e===i.value&&t.value===i.fragment)return;const r=document.createElement("template");r.innerHTML=e;const o=document.importNode(r.content,!0);t.setValue(o),fi.set(t,{value:e,fragment:o})})),yi=(e,t)=>{const i=e.startNode.parentNode,r=void 0===t?e.endNode:t.startNode,o=i.insertBefore(T(),r);i.insertBefore(T(),r);const n=new H(e.options);return n.insertAfterNode(o),n},_i=(e,t)=>(e.setValue(t),e.commit(),e),wi=(e,t,i)=>{const r=e.startNode.parentNode,o=i?i.startNode:e.endNode,n=t.endNode.nextSibling;n!==o&&x(r,t.startNode,n,o)},bi=e=>{C(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},xi=(e,t,i)=>{const r=new Map;for(let o=t;o<=i;o++)r.set(e[o],o);return r},Ci=new WeakMap,Ei=new WeakMap,Ii=_(((e,t,i)=>{let r;return void 0===i?i=t:void 0!==t&&(r=t),t=>{if(!(t instanceof H))throw new Error("repeat can only be used in text bindings");const o=Ci.get(t)||[],n=Ei.get(t)||[],a=[],s=[],l=[];let c,p,d=0;for(const t of e)l[d]=r?r(t,d):d,s[d]=i(t,d),d++;let u=0,h=o.length-1,m=0,g=s.length-1;for(;u<=h&&m<=g;)if(null===o[u])u++;else if(null===o[h])h--;else if(n[u]===l[m])a[m]=_i(o[u],s[m]),u++,m++;else if(n[h]===l[g])a[g]=_i(o[h],s[g]),h--,g--;else if(n[u]===l[g])a[g]=_i(o[u],s[g]),wi(t,o[u],a[g+1]),u++,g--;else if(n[h]===l[m])a[m]=_i(o[h],s[m]),wi(t,o[h],o[u]),h--,m++;else if(void 0===c&&(c=xi(l,m,g),p=xi(n,u,h)),c.has(n[u]))if(c.has(n[h])){const e=p.get(l[m]),i=void 0!==e?o[e]:null;if(null===i){const e=yi(t,o[u]);_i(e,s[m]),a[m]=e}else a[m]=_i(i,s[m]),wi(t,i,o[u]),o[e]=null;m++}else bi(o[h]),h--;else bi(o[u]),u++;for(;m<=g;){const e=yi(t,a[g+1]);_i(e,s[m]),a[m++]=e}for(;u<=h;){const e=o[u++];null!==e&&bi(e)}Ci.set(t,a),Ei.set(t,l)}})); /** * @license * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ class Si{add(e){this.classes.add(e),this.changed=!0}remove(e){this.classes.delete(e),this.changed=!0}commit(){if(this.changed){let e="";this.classes.forEach((t=>e+=t+" ")),this.element.setAttribute("class",e)}}constructor(e){this.classes=new Set,this.changed=!1,this.element=e;const t=(e.getAttribute("class")||"").split(/\s+/);for(const e of t)this.classes.add(e)}}const Pi=new WeakMap,Oi=_((e=>t=>{if(!(t instanceof q)||t instanceof W||"class"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `classMap` directive must be used in the `class` attribute and must be the only part in the attribute.");const{committer:i}=t,{element:r}=i;let o=Pi.get(t);void 0===o&&(r.setAttribute("class",i.strings.join(" ")),Pi.set(t,o=new Set));const n=r.classList||new Si(r);o.forEach((t=>{t in e||(n.remove(t),o.delete(t))}));for(const t in e){const i=e[t];i!=o.has(t)&&(i?(n.add(t),o.add(t)):(n.remove(t),o.delete(t)))}"function"==typeof n.commit&&n.commit()})),Mi=new WeakMap,Li=_((e=>t=>{if(!(t instanceof q)||t instanceof W||"style"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=t,{style:r}=i.element;let o=Mi.get(t);void 0===o&&(r.cssText=i.strings.join(" "),Mi.set(t,o=new Set)),o.forEach((t=>{t in e||(o.delete(t),-1===t.indexOf("-")?r[t]=null:r.removeProperty(t))}));for(const t in e)o.add(t),-1===t.indexOf("-")?r[t]=e[t]:r.setProperty(t,e[t])})),ki=new WeakMap,$i=_((e=>t=>{if(!(t instanceof H))throw new Error("cache can only be used in text bindings");let i=ki.get(t);void 0===i&&(i=new WeakMap,ki.set(t,i));const r=t.value;if(r instanceof F){if(e instanceof j&&r.template===t.options.templateFactory(e))return void t.setValue(e);{let e=i.get(r.template);void 0===e&&(e={instance:r,nodes:document.createDocumentFragment()},i.set(r.template,e)),x(e.nodes,t.startNode.nextSibling,t.endNode)}}if(e instanceof j){const r=t.options.templateFactory(e),o=i.get(r);void 0!==o&&(t.setValue(o.nodes),t.commit(),t.value=o.instance)}t.setValue(e)})),Ti=new WeakMap,Ai=_((e=>t=>{const i=Ti.get(t);if(void 0===e&&t instanceof q){if(void 0!==i||!Ti.has(t)){const e=t.committer.name;t.committer.element.removeAttribute(e)}}else e!==i&&t.setValue(e);Ti.set(t,e)})),Fi=_((e=>t=>{let i;if(t instanceof G||t instanceof H)throw new Error("The `live` directive is not allowed on text or event bindings");if(t instanceof B)Di(t.strings),i=t.element.hasAttribute(t.name),t.value=i;else{const{element:r,name:o,strings:n}=t.committer;if(Di(n),t instanceof W){if(i=r[o],i===e)return}else t instanceof q&&(i=r.getAttribute(o));if(i===String(e))return}t.setValue(e)})),Di=e=>{if(2!==e.length||""!==e[0]||""!==e[1])throw new Error("`live` bindings can only contain a single expression")};class Ni{add(e){this.classes.add(e),this.commit()}remove(e){this.classes.delete(e),this.commit()}commit(){let e="";this.classes.forEach((t=>e+=t+" ")),this.element.setAttribute("class",e)}constructor(e){this.classes=new Set,this.element=e;const t=(e.getAttribute("class")||"").split(/\s+/);for(const e of t)this.classes.add(e)}}let ji=!1;function Ri(e){return ji?new Ni(e):e.classList||new Ni(e)}function Vi(e=1){return new Promise((t=>0==--e?requestAnimationFrame((()=>t())):t(Vi(e))))}function zi(e){let t=e;for(;t=t.parentNode||t.host;)if(t instanceof HTMLElement)return t;return null}function qi(e,t,i=!0){return new Promise((r=>{const o=new MutationObserver((async()=>{o.disconnect(),i&&await Vi(),r()}));o.observe(e,{attributes:!0,attributeFilter:["class"]}),t&&t()}))}function Hi(e){let t=function(e){const t=[];let i=e.startNode.nextSibling;for(;i!==e.endNode;)t.push(i),i=i.nextSibling;return t}(e),i=t.filter((e=>{return!("#text"===(t=e).nodeName&&!(null===(i=t.nodeValue)||void 0===i?void 0:i.trim()));var t,i}));if(1!=i.length)throw new Error(`lit-transition directive expects exactly one child node,\n but was passed ${i.map((e=>e.nodeName)).join(", ")}`);return i[0]}const Bi=new WeakMap;function Ui(e,t){return Bi.set(e,t),e}function Wi(e,t){const i=zi(e);if(i){if("absolute"===(()=>{const e=document.createElement("div"),r=Ri(e),o=i.shadowRoot||i;var n;n=t,Array.isArray(n)?n.forEach((e=>r.add(e))):r.add(n),o.appendChild(e);const a=window.getComputedStyle(e).position;return o.removeChild(e),a})()){return"relative"===window.getComputedStyle(i).position}}return!1}function Yi(e){const t=e.getBoundingClientRect();let i=0,r=0;{let t=e.offsetParent;for(;e&&e!==document&&!(e instanceof DocumentFragment)&&e!==t;)i+=e.offsetTop-(e.scrollTop||0),r+=e.offsetLeft-(e.scrollLeft||0),e=zi(e)}return{left:r,top:i,width:t.width,height:t.height}}let Gi;function Qi(e=!document.hidden){Gi=e}Qi(),document.addEventListener("visibilitychange",(()=>Qi()),!1);const Xi=new WeakMap;function Zi(e){return function(t,i){return async r=>{if(!(r instanceof H))throw new Error("The `transition` directive can only be used on nodes");t||(t=te`
`),"string"!=typeof t&&"number"!=typeof t||(t=te`
${t}
`);const o=(n=t,Bi.get(n));var n;const{enter:a,leave:s,onEnter:l,onLeave:c,onAfterEnter:p,onAfterLeave:d,mode:u="in-out"}=i;let h=Xi.get(r);function m(e){const t=new H(r.options);return t.appendIntoPart(r),t.setValue(e),t.commit(),t}function g(e){const{startNode:t,endNode:i}=e;try{t&&e.clear()}catch(i){}t&&t.parentNode&&t.parentNode.removeChild(t),i&&i.parentNode&&i.parentNode.removeChild(i)}if(!Gi)return h&&h.last&&g(h.last),c&&await c(),d&&await d(),l&&await l(),h&&(h.last=m(t)),void(p&&await p());async function f(t){l&&await l(),a&&await e.transition(t,a,i),p&&await p()}async function v(t){c&&await c(),s&&await e.transition(t,s,i),g(t),d&&await d()}if(h||Xi.set(r,h={children:new Map,styles:new Map,transition:i}),e.init&&e.init({transition:i,data:h,add:m,remove:g}),h.last&&o&&o===h.name)h.last.setValue(t),h.last.commit();else if(h.name=o,"in-out"===u){const e=h.last;await f(h.last=m(t)),e&&await v(e)}else if("out-in"===u){const e=h.last;e&&await v(e),await f(h.last=m(t))}else h.last&&v(h.last),await f(h.last=m(t))}}}var Ji,Ki,er,tr;function ir(e={}){const{css:t,duration:i,enter:r={},leave:o={},mode:n=Ji.Both,onAfterEnter:a,onAfterLeave:s,onEnter:l,onLeave:c,skipHidden:p=!0}=e;return{duration:i,skipHidden:p,css:te``,enter:0!=r&&(Array.isArray(r)||"string"==typeof r?{active:r}:Object.assign({active:"enter-active",from:"enter-from",to:"enter-to"},r)),leave:0!=o&&(Array.isArray(o)||"string"==typeof o?{active:o,lock:false}:Object.assign({active:"leave-active",from:"leave-from",to:"leave-to",lock:false},o)),onEnter:l,onLeave:c,onAfterEnter:a,onAfterLeave:s,mode:n}}function rr(e,t){const i=t();for(let e in i)t[e]=i[e];return Object.defineProperty(t,"name",{get:()=>e}),t}function or(e,t){for(var i in t)try{t[i].constructor==Object?e[i]=or(e[i],t[i]):e[i]=t[i]}catch(r){e[i]=t[i]}return e}(Ki=Ji||(Ji={})).InOut="in-out",Ki.OutIn="out-in",Ki.Both="both",(tr=er||(er={}))[tr.None=0]="None",tr[tr.Lock=1]="Lock",tr.Auto="auto";const nr=rr("fade",(function(e={}){const{duration:t=500,ease:i="ease-out",opacity:r=0}=e;return or({enter:{active:"fade-enter-active",from:"fade-enter-from",to:"fade-enter-to"},leave:{active:"fade-leave-active",from:"fade-leave-from",to:"fade-leave-to",lock:!0},css:`\n .fade-leave-active {\n position: fixed;\n transition: opacity ${t}ms ${i}, transform ${t}ms ${i};\n }\n .fade-enter-active {\n transition: opacity ${t}ms ${i}, transform ${t}ms ${i};\n }\n .fade-enter-from, .fade-leave-to {\n opacity: ${r};\n }\n .fade-enter-to, .fade-leave-from {\n opacity: 1;\n }\n `},e)})),ar={async transition(e,t,i){const{duration:r=i.duration,active:o,from:n,to:a,lock:s}=t,l=Hi(e);if(!l)return;let c;s&&(s!==er.Auto||o&&Wi(l,o))&&(c=Yi(l)),await new Promise((async e=>{const t=Ri(l),i=e=>Array.isArray(e)?e.forEach((e=>t.add(e))):t.add(e),s=e=>Array.isArray(e)?e.forEach((e=>t.remove(e))):t.remove(e);var p,d;function u(t){if(t){if(t.target!==l)return;t.preventDefault(),t.stopPropagation()}["transitionend","transitioncancel","animationend","animationcancel"].filter((e=>!t||e!==t.type)).forEach((e=>l.removeEventListener(e,u))),o&&s(o),n&&s(n),a&&s(a),e()}c&&(d=c,(p=l).style.marginLeft="0px",p.style.marginTop="0px",p.style.left=d.left+"px",p.style.top=d.top+"px",p.style.width=d.width+"px",p.style.height=d.height+"px");const h={once:!0};r?setTimeout(u,r):(l.addEventListener("transitionrun",(function(){l.addEventListener("transitionend",u,h),l.addEventListener("transitioncancel",u,h)}),h),l.addEventListener("animationstart",(function(){l.addEventListener("animationend",u,h),l.addEventListener("animationcancel",u,h)}),h)),n&&await qi(l,(()=>i(n))),o&&await qi(l,(()=>i(o))),n&&s(n),a&&i(a)}))},init({data:e,remove:t,add:i,transition:r}){if(e._cssSource!==r.css&&(e.css&&t(e.css),r.css)){e._cssSource=r.css;let t=r.css;t="string"==typeof t?te``:t,e.css=i(t)}}},sr=(rr("land",(function(e={}){const{duration:t=500,ease:i="ease-out",opacity:r=0}=e;return or({enter:{active:"land1-enter-active",from:"land1-enter-from",to:"land1-enter-to"},leave:{active:"land1-leave-active",from:"land1-leave-from",to:"land1-leave-to"},mode:"both",css:`\n .land1-enter-active {\n transform-origin: 50% 50%;\n transition: transform ${t}ms ${i}, opacity ${t}ms ${i};\n }\n .land1-leave-active {\n transform-origin: 50% 50%;\n position: absolute;\n transition: transform ${t}ms ${i}, opacity ${t}ms ${i};\n }\n .land1-enter-from {\n opacity: ${r};\n transform: translate(0px, 0px) scale(3);\n }\n .land1-leave-to {\n transform: translate(0px, 100px);\n opacity: ${r};\n }`},e)})),rr("slide",(function(e={}){const{left:t,right:i,up:r,down:o}=e;let n={};t&&(n={x:"-100%",x1:"100%"}),i&&(n={x:"100%",x1:"-100%"}),r&&(n={y:"100%",y1:"-100%"}),o&&(n={y:"-100%",y1:"100%"});let{mode:a,duration:s=500,x:l="100%",y:c="0%",x1:p="",y1:d="",ease:u="ease-out",leavePosition:h="",opacity:m=0}=Object.assign(Object.assign({},n),e);return p=p||l,d=d||c,or({enter:{active:"slide-enter-active",from:"slide-enter-from"},leave:{active:"slide-leave-active",to:"slide-leave-to",lock:er.Auto},css:`\n .slide-enter-active {\n transition: transform ${s}ms ${u}, opacity ${s}ms ${u};\n }\n .slide-leave-active {\n position: ${h||(a!==Ji.OutIn?"absolute":"initial")};\n transition: transform ${s}ms ${u}, opacity ${s}ms ${u};\n }\n .slide-leave-to {\n opacity: ${m};\n transform: translate(${l}, ${c});\n }\n .slide-enter-from {\n opacity: ${m};\n transform: translate(${p}, ${d});\n }`,mode:a},e)})),_((function(e,t=nr){return"function"==typeof t&&(t=t()),Zi(ar)(e,ir(t))}))),lr="${{amount}}";function cr(e,t){"string"==typeof e&&(e=e.replace(".",""));let i="";const r=/\{\{\s*(\w+)\s*\}\}/,o=t||lr;function n(e,t=2,i=",",r="."){if(isNaN(e)||null==e)return 0;const o=(e=(e/100).toFixed(t)).split(".");return o[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${i}`)+(o[1]?r+o[1]:"")}switch(o.match(r)[1]){case"amount":i=n(e,2);break;case"amount_no_decimals":i=n(e,0);break;case"amount_with_comma_separator":i=n(e,2,".",",");break;case"amount_no_decimals_with_comma_separator":i=n(e,0,".",",")}return o.replace(r,i)}const pr={OPTIONS:"_cl_options",ID:"_cl_options_id",PRICE:"_cl_options_price",PRICE_BASE:"_cl_options_price_base",CURRENCY:"_cl_options_currency",WEIGHT:"_cl_options_weight",QUANTITY_ID:"_cl_options_quantity_id",QUANTITY_DISCOUNT:"_cl_options_quantity_discount",VALIDATE:!0},dr={cartItem:!0,cartItemPreview:!0,cartItemPreviewViews:!0,cartItemPrice:!0,cartItemPriceOptions:!0,cartItemEdit:!1,cartItemClOptions:!0,cartItemPriceRemove:!0,cartCount:!0,cartTotal:!0,cartFormCapture:!0,cartDiscount:!1,cartPriceRegex:!1,checkoutDomain:!1,productFormCapture:!0,productFormDisabled:!1,productPrice:!0,productPriceAll:!1,productVariantHide:!0,productVariantFilter:!0,productVariantObserver:!1,productVariantHistory:!1,productVariantHistoryPush:!0,productVariantHistoryReplace:!0,productLinkAvailable:!1,productPriceTimeout:!1,productPriceObserver:!1,productItemUpdate:!0,productItemModal:!1,productOptionsClear:!1,productOptionsEmptyId:!1,productCropOverlay:!0,productSKU:!1,productQuickView:!1,amountNoDecimals:!1,themeGallery:!1,themeGalleryTimeout:!1,previewHiddenExclude:!1,tooltipBody:!0,currencyFormat:!0,priceVisible:!0,priceVisibleCustomer:!1,previewCdnSize:!0,previewExportLog:!0,previewExportRequired:!1},ur={currency:"",currencyConvert:!1,currencyFactor:1,moneyFormat:"$ {{amount}}",moneyFormatWithCurrency:"${{amount}} USD",priceVariant:!1,priceVariantValue:.01,priceVariantId:"",priceProductHandle:""},hr=e=>{if(1!==ur.currencyFactor)if(e*=ur.currencyFactor,ur.priceVariant){let t=Math.round(e/ur.priceVariantValue);e=ur.priceVariantValue*t,e=Math.round(100*e)/100}else e=ur.currencyFactor>100&&e>100?100*Math.ceil(e/100):Math.ceil(e);return e},mr={NONE:0,CODE:1,AUTO:2},gr={ABSOLUTE:1,PERCENTAGE:2,LETTER:3,FORMULA:4},fr={EXPORT:!1,FORMULA:!1,QUANTITY:!1},vr=e=>e&&-1!==e.indexOf("//cdn.shopify.com/"),yr=(e,t="200x")=>"small"===e?"100x":"medium"===e?"200x":"large"===e?"400x":t,_r=(e,t)=>{if(vr(e)){let i=e.substring(e.lastIndexOf(".")+1);return"svg"===i?e:e.replace("."+i,"")+"_"+t+"."+i}return e};class wr{}wr.templates={};var br=wr;var xr=class{upload(e,t){const i=[],r=[];for(let o=0;o{this._getSignedUrl(a).then((s=>{const l={method:"PUT",headers:{"Content-type":a.mimeType},data:a._file};0===o&&(l.onProgress=t);const c=new n(s.upload,l);r.push(c),c.then((t=>{a.url=s.download,a.path=s.path;let i=parseInt(t.xhr.getResponseHeader("x-goog-stored-content-length"));isNaN(i)||a.meta&&(a.meta.contentLength=i),e(a)})).catch((e=>{i(e)}))})).catch((e=>{i(e)}))})))}let o=Promise.all(i).then((e=>(a.info(e),e)));return o.cancel=()=>{for(let e=0;ee.data))}constructor(e){this.settings=o.extend({api:"",path:"/api/storage",queryParams:{}},e||{})}};var Cr=class{findToken(){let e=o.readCookie("token");e&&(this.settings.queryParams.token=e)}blobToFile(e,t){return new File([e],t,{lastModified:(new Date).getTime(),type:e.type})}fromBlob(e,t){return{name:t,size:e.size,mimeType:e.type,meta:{},_file:e}}fromNative(e){return{name:e.name?e.name:"",size:e.size,mimeType:e.type,meta:{},_file:e}}saveFile(e){return this.settings.queryParams.token||this.findToken(),this.settings.origin&&(e.origin=this.settings.origin),new n(this.settings.api+this.settings.path,{method:"POST",responseType:"json",headers:{"Content-type":"application/json"},data:e,queryParams:this.settings.queryParams}).then((e=>{if(!this.settings.queryParams.token&&e.data.token){let t=e.data.token;o.writeCookie("token",t,10,"/"),this.settings.queryParams.token=t}return e.data})).catch((e=>{throw e}))}removeFile(e){return Promise.resolve()}exportFailed(e){return"object"==typeof e&&(e.xhr&&(e.xhr={url:e.xhr._url,status:e.xhr.status,statusText:e.xhr.statusText}),e=JSON.stringify(e,Object.getOwnPropertyNames(e))),new n(this.settings.api+this.settings.path+"/export",{method:"POST",responseType:"text",headers:{"Content-type":"application/json"},data:e,queryParams:this.settings.queryParams}).then((e=>e.data)).catch((e=>{throw e}))}constructor(e){this.settings=o.extend({api:"",path:"/api/upload",queryParams:{}},e||{}),this.findToken()}};class Er{static getInstance(e){return Er._instance||(Er._instance=new Er(e)),Er._instance}controller(e,t,i,r){let n={files:[],inputs:[],onValidate:e=>{i.dispatchEvent(new CustomEvent("option:crop:apply",{detail:e,cancelable:!0,bubbles:!0}));let t=!0;return e.required&&0===n.files.length&&(e.errors.push(l.get("product.options.validity.upload.required")),t=!1),t},onChange:(e,t,i,a,s)=>{let c=e.target;if(c.value&&c.files.length>0){const e=c.files;let i=[];for(let r=0;ra)return c.value="",t.errors=t.errors||[],t.errors.push(l.get("product.options.validity.upload.max",{max:n})),void c.dispatchEvent(new CustomEvent("options:render",{detail:t,cancelable:!0,bubbles:!0}));i.push(this._fileMeta.fromNative(o))}let p=o.findParent(c,".cl-po--upload"),d=p.querySelector("progress");d.max=100,d.value=0,d.style.display="block",this.upload(i,(e=>{if(e.lengthComputable){let t=e.loaded/e.total*100;t>d.value&&(d.value=t)}})).then((e=>{d.style.display="none";for(let e=0;e{alert(e.error),d.style.display="none",c.value=""}))}},update:(e,t,i)=>{if(e.value){if(0===n.inputs.length){n.files.push({url:e.value,name:"file"+e.value.substring(e.value.lastIndexOf(".")),meta:{}});let t=document.createElement("input");t.type="hidden",t.name="properties["+e.name+"]",t.value=e.value,e.value=this._corsUrl(e.value),i&&t.setAttribute("form",i),document.querySelector('[data-option="'+e.name+'"] .cl-po--upload').appendChild(t),n.inputs.push(t)}}else if(n.inputs.length>0){for(let e=0;e{for(let t=0;t{t.dispatchEvent(new CustomEvent("option:crop",{detail:e,cancelable:!0,bubbles:!0}))}};return this._migrateDimensionParams(e),n}controllerLift(e,t,i,r,o){let n={option:e,selector:`.cl-po--upload-lift-${e.id}`,container:null,field:null,urls:[],onValidate:e=>{if(e._controller._cropConfig)return n.updateCrop(),!1;let t=!0;if(e.required&&0===n.urls.length)e.errors.push(l.get("product.options.validity.upload.required")),t=!1;else if(n.field)return n.field.validate();return t},syncValue:()=>{let e="";for(let t=0;t{n.container=document.querySelector(n.selector),n.container&&(n.container.addEventListener("upload:added",(async e=>{var t=e.detail;const i=n.option.params;let r=i.variant||"original";t.url&&t.meta.variant===r&&(n.urls.push(t.url),n.syncValue(),i.optionDimension&&this._dimensionUpdate(n.option,o(i.optionDimension),this._corsUrl(t.url)))})),n.container.addEventListener("upload:removed",(e=>{var t=e.detail;let i=n.option.params.variant||"original";if(t?.url&&t.meta.variant===i){let e=n.urls.indexOf(t.url);-1!==e&&(n.urls.splice(e,1),n.syncValue())}})))},watchCrop:(t,i)=>{e._controller.optionChanged&&t.removeEventListener("option:changed",e._controller.optionChanged);const r=()=>{let r=i(e.params.optionDimension);r&&(a.debug("init crop dimension based on option",r),o(r,!0),e._controller.optionChanged=t=>{t.detail.name===e.params.optionDimension&&(a.debug("updating crop dimension based on option",r),o(t.detail))},t.addEventListener("option:changed",e._controller.optionChanged),n.container.addEventListener("upload:removed",(t=>{e._controller._cropConfig&&e._controller.updateCrop()})))},o=(t,i=!1)=>{if(t._controller&&t._controller.x&&t._controller.y&&(!t.errors||0===t.errors.length)){void 0===e._controller._cropRatio&&(e._controller._cropRatio=-1);let r,o=e._controller._cropRatio;if(r=e._controller.field.config.imageEditorPintura?Math.round(t._controller.x/t._controller.y*1e4)/1e4:Math.round(t._controller.y/t._controller.x*1e4)/1e4,o!==r){e._controller._cropRatioCurrent=r;let t={imageSizeValidate:!0,imageEditorCropRestrict:!0,imageEditorCropRatios:[{label:"Dimension",value:r}]};a.debug("updating upload-lift crop dimension",t),e._controller._cropConfig=t,!i&&e.value||e._controller.updateCrop()}else delete e._controller._cropConfig}};n.field._upload?r():n.field.element.addEventListener("upload:ready",r)},updateCrop:()=>{e._controller._cropRatio=e._controller._cropRatioCurrent,e._controller.field.updateConfig(e._controller._cropConfig),delete e._controller._cropConfig},update:(e,t)=>{e.value?0===n.urls.length&&e._controller.ready.then((()=>{if(e.value){let t=e.value.split(",");e._controller.field.restore(t),e.value=""}})):n.urls.length>0&&e._controller.field&&e._controller.field.clearFiles()},crop:(e,t)=>{e._controller._cropConfig?e._controller.updateCrop():!e.params.cropEdit||e._layer&&e._layer.params.crop?t.dispatchEvent(new CustomEvent("option:crop",{detail:e,cancelable:!0,bubbles:!0})):e._controller.field.editFile()}};n.ready=new Promise(((e,t)=>{n.onReady=e}));return i.addEventListener("options:rendered",(r=>{const a=()=>{let r=window.Cloudlift.upload.App;if(r.fields.length>0)for(let t=0;t{e._controller.onReady(n.field)})),this._migrateDimensionParams(e),e.params.optionDimension&&e.params.dimensionCrop&&n.watchCrop(i,o)}}n.field||(n.notfound=!0)};let s=()=>{setTimeout((()=>{window.Cloudlift.upload.App?n.field||a():s()}),300)};window.Cloudlift&&window.Cloudlift.upload&&(window.Cloudlift.upload.App?a():s());window.addEventListener("cloudlift.upload.ready",(e=>{window.Cloudlift.upload.App?n.field||a():s()}),{once:!0}),n.watchUploads()}),{once:!0}),n}_corsUrl(e){return e=(e=e.replace("https://upload.dev.cloudlift.app/s/dev","https://storage.googleapis.com/cloudlift-app-cloud-dev-upload")).replace("https://upload.cloudlift.app/s","https://storage.googleapis.com/cloudlift-app-cloud-prod-upload")}_migrateDimensionParams(e){let t=e.params;t.optionCrop&&(t.optionDimension=t.optionCrop,t.dimensionCrop=!0,delete t.optionCrop)}async _dimensionUpdate(e,t,i){let r=e.params;if(t&&r.dimensionUpdate){let n=!1;e._layer?.params.crop&&(e._layer.params.crop=!1,n=!0);let a=await o.getImageSize(i);const s=Math.round(a.width/a.height*100)/100;r.dimensionRatio&&(t.params.ratio=s),r.dimensionCrop&&"upload-lift"===e.type&&void 0===e._controller._cropRatio&&(e._controller.field.config.imageEditorPintura?e._controller._cropRatio=s:e._controller._cropRatio=Math.round(a.height/a.width*100)/100),r.dimensionUnit&&(a=o.convertSizeToUnit(a,r.dimensionDpi||72,r.dimensionUnit)),t._controller.xInput=String(a.width),t._controller.yInput=String(a.height),n&&(e._layer.params.crop=!0,r.dimensionCrop&&(e._layer._autoCrop=!1)),t._controller.onChange(null,t,!0)}}upload(e,t){try{let i=this._provider.upload(e,t);const r=new Promise(((e,t)=>{i.then((i=>{for(let e=0;e{const r=[];for(let e=1;ee)))}Promise.all(r).then((i=>{i.unshift(t),e(i)}))})).catch((e=>{t(e)}))})),i.catch((e=>{t(e)}))}));return r.cancel=()=>{i.cancel()},r}catch(e){return Promise.reject(e)}}constructor(e){this.settings=o.extend({api:"",queryParams:{}},e||{}),this._fileMeta=new Cr({api:this.settings.api,queryParams:this.settings.queryParams,origin:4}),this._provider=new xr({api:this.settings.api,queryParams:this.settings.queryParams})}}var Ir=Er;class Sr{static getProductOption(e,t){for(let i=0;i0){let t=this.getProductOption(e,r.options);if(null!=t)return t}}return null}static hasEditLayer(e,t){return e&&t&&t!==Sr.editLayer}static isEditLayer(e,t,i){return!!t&&(!i||!(e.name!==i&&!e.name.startsWith(i+"_")))}static isCropLayer(e,t,i){return!(!t||e.name!==i)}static hasRefRect(e){return e.params.refRect&&(e.params.autoScale||e.params.autoPos)}static getRefDimensions(e,t){return Sr.hasRefRect(e)?{width:e.params.refWidth||t.config.width-100,height:e.params.refHeight||t.config.height-100}:{width:t.config.width,height:t.config.height}}static getRefCoordinates(e,t){return Sr.hasRefRect(e)?{x:void 0!==e.params.refX?e.params.refX:50,y:void 0!==e.params.refY?e.params.refY:50,angle:void 0!==e.params.refAngle?e.params.refAngle:0}:e.params.autoPos?{x:0,y:0,angle:0}:{x:0|e.params.x,y:0|e.params.y,angle:0}}static getDimensions(e,t=!1){return t?{height:e.getScaledWidth(),width:e.getScaledHeight()}:{width:e.getScaledWidth(),height:e.getScaledHeight()}}static center(e,t,i,r){this.centerHorizontal(e,t,i,r),this.centerVertical(e,t,i,r)}static centerHorizontal(e,t,i,r){let o=i.x+r.width/2-t.width/2;e.left=parseFloat(o.toFixed(2))}static centerVertical(e,t,i,r){let o=i.y+r.height/2-t.height/2;e.top=parseFloat(o.toFixed(2))}}Sr.editLayer="_";var Pr=Sr;var Or,Mr=class{static moveX(e,t){e._object.left+=t,this.updateMoving(e)}static moveY(e,t){e._object.top+=t,this.updateMoving(e)}static scale(e,t){e._object.scaleX+=t,e._object.scaleY+=t,this.updateScaling(e)}static rotate(){}static center(e,t){let i=Pr.getDimensions(e._object),r=Pr.getRefCoordinates(e,e._context),o=Pr.getRefDimensions(e,e._context);"h"===t?Pr.centerHorizontal(e._object,i,r,o):"v"===t?Pr.centerVertical(e._object,i,r,o):Pr.center(e._object,i,r,o),this.updateMoving(e)}static updateMoving(e){e._canvas&&(e._canvas.fire("object:moving",{target:e._object}),e._canvas.fire("object:modified",{target:e._object}),e._canvas.requestRenderAll())}static updateScaling(e){e._canvas&&(e._canvas.fire("object:scaling",{target:e._object}),e._canvas.fire("object:modified",{target:e._object}),e._canvas.requestRenderAll())}},Lr={};Or=function(){var e=function(){},t={},i={},r={};function o(e,t){if(e){var o=r[e];if(i[e]=t,o)for(;o.length;)o[0](e,t),o.splice(0,1)}}function n(t,i){t.call&&(t={success:t}),i.length?(t.error||e)(i):(t.success||e)(t)}function a(t,i,r,o){var n,s,l=document,c=r.async,p=(r.numRetries||0)+1,d=r.before||e,u=t.replace(/[\?|#].*$/,""),h=t.replace(/^(css|img)!/,"");o=o||0,/(^css!|\.css$)/.test(u)?((s=l.createElement("link")).rel="stylesheet",s.href=h,(n="hideFocus"in s)&&s.relList&&(n=0,s.rel="preload",s.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(u)?(s=l.createElement("img")).src=h:((s=l.createElement("script")).src=t,s.async=void 0===c||c),s.onload=s.onerror=s.onbeforeload=function(e){var l=e.type[0];if(n)try{s.sheet.cssText.length||(l="e")}catch(e){18!=e.code&&(l="e")}if("e"==l){if((o+=1){e(Lr).ready(t,(()=>{i(t)}))}))}static isDefined(t){return e(Lr).isDefined(t)}static loadOnce(e,t,i={async:!0}){return kr.isDefined(t)?kr.isReady(t):kr.load(e,t,i)}}var $r=kr;function Tr(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Ar{init(){this.images=[],this.imagesPaged=[],this.imagesHide=!0,this.page=1,this.cache={},this.searchQuery="",this.fuse=null,this.searchLists=!0,this.category=null,this.categoryDefault=null,this.checkExternalImage()}initUI(){if(this.categoryCount=this.option.values?.length||0,this.image&&this.categoryCount--,this.searchHide=0===this.categoryCount,this.pageSize=this.option.params.librarySize||20,!this.category&&this.categoryCount>0&&(1!==this.categoryCount||this.config.editorMode?!0!==this.option.params.categoryGrid&&this.onCategoryChange(null,this.option.values[0]):(this.categoryDefault=this.option.values[0],this.onCategoryChange(null,this.categoryDefault))),this.option.params.optionUpload){let e=this.getOption(this.option.params.optionUpload);this._uploadEvents=e!==this.optionUpload,this.optionUpload=e,void 0!==this.option.params.uploadHide&&this.config.productForm.addEventListener("options:rendered",(e=>{let t=document.querySelector(`[data-option="${this.option.params.optionUpload}"]`);t&&(t.style.display=this.option.params.uploadHide?"none":"")}),{once:!0})}}pageImages(){this.imagesPaged=[],this.page=0,this.imagesHide=!1,this.categoryHide=!0===this.option.params.categoryGrid||null!==this.categoryDefault,this.onMoreImages()}onImageChange(e,t){this.removeImage(),this.category&&this.category.price&&!t.price&&0!==t.price&&(t.price=this.category.price),this.image=t,this.option.values.push(t);let i=t.img;"function"==typeof window.clLibraryGetImage&&(i=window.clLibraryGetImage(t)),this.option.value=i,this.popupOpen&&this._popup.set("close",!0),this.optionUpload&&this.syncUploadLiftImage(i),this.onChange(this.option)}removeImage(){if(this.image){let e=this.option.values.indexOf(this.image);-1!==e&&this.option.values.splice(e,1),this.image=null}this.option.value=""}restoreImage(){let e={id:this.option._imageId,img:this._corsUrl(this.option.value)};this.onImageChange(null,e)}_corsUrl(e){return e=(e=e.replace("https://upload.dev.cloudlift.app/s/dev","https://storage.googleapis.com/cloudlift-app-cloud-dev-upload")).replace("https://upload.cloudlift.app/s","https://storage.googleapis.com/cloudlift-app-cloud-prod-upload")}isSelected(e,t){return this.image===t}conditionValue(e){return this.category?.value||""}onValidate(e){return!(e.required&&!this.image)||(e.errors.push(l.get("product.options.validity.valueMissing")),!1)}showCategories(){this.categoryHide=!1,this.imagesHide=!0,this.renderOptions()}async onCategoryChange(e,t){a.debug("library category changed",e),this.category=t,this.searchQuery="",this.images=await this.getImages(this.category),this.pageImages()}async onMoreImages(){this.page++;let e=(this.page-1)*this.pageSize,t=e+this.pageSize;this.hasMoreImages=tt))}catch(e){a.debug("error loading images using function",e)}}checkExternalImage(){let e;if(-1!==window.location.search.indexOf("library.")){let t=new URLSearchParams(window.location.search);e={},t.forEach(((t,i)=>{i.startsWith("library.")&&(e[i.replace("library.","")]=t)}))}else"object"==typeof window.clLibraryImage&&(e=window.clLibraryImage);e?.img&&setTimeout((()=>{this.onImageChange(null,e)}))}async onSearch(e){if(a.debug("library search changed",e),this.searchQuery=e.target.value,!this.fuse&&this.searchLists){let e=await this.fetchAllOptionsLists();if(e.length){await $r.loadOnce(["https://cdn.jsdelivr.net/npm/fuse.js@6.6.2/dist/fuse.basic.min.js"],"fuse-search",{async:!1});const t={threshold:.4,ignoreLocation:!0,includeScore:!0,keys:[{name:"text",weight:2},{name:"value",weight:1}]};this.fuse=new Fuse(e,t)}else this.searchLists=!1}if(this.searchLists){let e=this.fuse.search(this.searchQuery);console.debug("search results:",e),this.images=e.map((function(e){return e.item}))}else this.images=[];""===this.searchQuery&&this.categoryDefault?this.onCategoryChange(null,this.categoryDefault):(this.category=null,this.pageImages())}async getImages(e){let t=[];return e.list&&(t=await this.fetchOptionList(e.list)),t}async fetchAllOptionsLists(){let e=[];for(const t of this.option.values)t.list&&e.push(this.fetchOptionList(t.list));return Promise.all(e).then((e=>e.flat()))}async fetchOptionList(e){if(this.cache[e])return this.cache[e];let t=(await new n(this.settings.api+this.settings.path+"/"+e,{method:"GET",responseType:"json",headers:{"Content-type":"application/json"},queryParams:this.settings.queryParams})).data;return this.cache[e]=t,t}libraryStyleMap(e={}){return this.option.params.popup&&!this.popupOpen&&(e.display="none"),this.option.params.libraryCols&&(e["--library-grid-cols"]=this.option.params.libraryCols),this.option.params.libraryColsM&&(e["--library-grid-cols-m"]=this.option.params.libraryColsM),this.option.params.libraryColsH&&(e["--library-grid-cols-h"]=this.option.params.libraryColsH+"px"),e}async openPopup(){if(this._popupEl)this.renderPopup();else{this._popupEl=document.createElement("div");let e=[this.settings.assets+"/static/lib/ldcover/ldcv.full.min.css",this.settings.assets+"/static/lib/ldcover/ldcv.min.js"];await $r.loadOnce(e,"popup",{async:!1});const t=`[data-option="${this.option.name}"] .cl-po--library`;this._libraryEl=this.config.wrapper.querySelector(t)||document.querySelector(t),this.renderPopup(),document.body.appendChild(this._popupEl),this._popup=new ldCover({root:this._popupEl.querySelector(".ldcv"),lock:!1}),this._popup.on("toggle.on",(()=>{this.popupOpen=!0,this._libraryEl.style.display=""}))}this._popup.get().then((e=>{this.popupOpen=!1})),this._popup.toggle()}renderOptions(){this.config.productForm.dispatchEvent(new CustomEvent("options:render",{detail:this.option,cancelable:!0,bubbles:!0}))}renderPopup(){const e={id:this.config.uuid,className:"popup fade"+(this.option.params.popupFull?" full":"")};ee(br.templates["library-popup"](this._libraryEl,e,(e=>{this._popup.set("close",!0)})),this._popupEl)}crop(){this._fileCrop?(this._syncUpload=!0,this._syncCrop=!0,this.image._img=this.image._preview,this.image._preview=this._preview,this.optionUpload._controller?._cropConfig?this.optionUpload._controller.updateCrop():this._fileCrop.edit()):this.config.productForm.dispatchEvent(new CustomEvent("option:crop",{detail:this.option,cancelable:!0,bubbles:!0}))}syncUploadLiftImage(e){if(this.optionUpload._controller?.field){let t=this.optionUpload._controller.field;a.debug("library image upload-lift sync",t,e),this.image._preview=this._preview,this._uploadEvents&&(delete this._uploadEvents,this.optionUpload._controller.field.element.addEventListener("upload:added",(e=>{if(this._syncUpload&&this.image){let i=e.detail;if("original"===i.meta.variant){this.image._preview=i.url;let e=t._upload._pond.getFile();e&&e.edit&&(this._fileCrop=e),this._updateCropOriginal||(this._updateCropOriginal=this.optionUpload._controller.updateCrop,this.optionUpload._controller.updateCrop=()=>{this._syncUpload=!0,this._syncCrop=!0,this._updateCropOriginal()}),this.onChange(this.option),delete this._syncUpload,delete this._syncCrop}}})),this.optionUpload._controller.field.element.addEventListener("upload:removed",(e=>{!this._syncUpload&&this.image&&(this.removeImage(),delete this._fileCrop,this.onChange(this.option))})),this.optionUpload._controller.field.element.addEventListener("upload:editor:cancel",(e=>{this._syncUpload&&this.image&&(this.image._img&&(this.image._preview=this.image._img,delete this.image._img),this._syncCrop||this.removeImage(),this.onChange(this.option),delete this._syncUpload,delete this._syncCrop)}))),this._syncUpload=!0,this._syncCrop=!1;const i=()=>{this.optionUpload._controller.field.uploadFile(e).then((e=>{a.debug("library image upload-lift complete",e)}))};this.optionUpload._controller.field._upload?.isReady()?i():this.optionUpload._controller.field.element.addEventListener("upload:ready",(()=>i()),{once:!0})}}constructor(e,t){Tr(this,"_preview","data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPgo8c3ZnIHdpZHRoPSI0MHB4IiBoZWlnaHQ9IjQwcHgiIHZpZXdCb3g9IjAgMCA0MCA0MCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjEuNDE0MjE7IiB4PSIwcHgiIHk9IjBweCI+CiAgICA8ZGVmcz4KICAgICAgICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWwogICAgICAgICAgICBALXdlYmtpdC1rZXlmcmFtZXMgc3BpbiB7CiAgICAgICAgICAgICAgZnJvbSB7CiAgICAgICAgICAgICAgICAtd2Via2l0LXRyYW5zZm9ybTogcm90YXRlKDBkZWcpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRvIHsKICAgICAgICAgICAgICAgIC13ZWJraXQtdHJhbnNmb3JtOiByb3RhdGUoLTM1OWRlZykKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgQGtleWZyYW1lcyBzcGluIHsKICAgICAgICAgICAgICBmcm9tIHsKICAgICAgICAgICAgICAgIHRyYW5zZm9ybTogcm90YXRlKDBkZWcpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRvIHsKICAgICAgICAgICAgICAgIHRyYW5zZm9ybTogcm90YXRlKC0zNTlkZWcpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHN2ZyB7CiAgICAgICAgICAgICAgICAtd2Via2l0LXRyYW5zZm9ybS1vcmlnaW46IDUwJSA1MCU7CiAgICAgICAgICAgICAgICAtd2Via2l0LWFuaW1hdGlvbjogc3BpbiAxLjVzIGxpbmVhciBpbmZpbml0ZTsKICAgICAgICAgICAgICAgIC13ZWJraXQtYmFja2ZhY2UtdmlzaWJpbGl0eTogaGlkZGVuOwogICAgICAgICAgICAgICAgYW5pbWF0aW9uOiBzcGluIDEuNXMgbGluZWFyIGluZmluaXRlOwogICAgICAgICAgICB9CiAgICAgICAgXV0+PC9zdHlsZT4KICAgIDwvZGVmcz4KICAgIDxnIGlkPSJvdXRlciI+CiAgICAgICAgPGc+CiAgICAgICAgICAgIDxwYXRoIGQ9Ik0yMCwwQzIyLjIwNTgsMCAyMy45OTM5LDEuNzg4MTMgMjMuOTkzOSwzLjk5MzlDMjMuOTkzOSw2LjE5OTY4IDIyLjIwNTgsNy45ODc4MSAyMCw3Ljk4NzgxQzE3Ljc5NDIsNy45ODc4MSAxNi4wMDYxLDYuMTk5NjggMTYuMDA2MSwzLjk5MzlDMTYuMDA2MSwxLjc4ODEzIDE3Ljc5NDIsMCAyMCwwWiIgc3R5bGU9ImZpbGw6YmxhY2s7Ii8+CiAgICAgICAgPC9nPgogICAgICAgIDxnPgogICAgICAgICAgICA8cGF0aCBkPSJNNS44NTc4Niw1Ljg1Nzg2QzcuNDE3NTgsNC4yOTgxNSA5Ljk0NjM4LDQuMjk4MTUgMTEuNTA2MSw1Ljg1Nzg2QzEzLjA2NTgsNy40MTc1OCAxMy4wNjU4LDkuOTQ2MzggMTEuNTA2MSwxMS41MDYxQzkuOTQ2MzgsMTMuMDY1OCA3LjQxNzU4LDEzLjA2NTggNS44NTc4NiwxMS41MDYxQzQuMjk4MTUsOS45NDYzOCA0LjI5ODE1LDcuNDE3NTggNS44NTc4Niw1Ljg1Nzg2WiIgc3R5bGU9ImZpbGw6cmdiKDIxMCwyMTAsMjEwKTsiLz4KICAgICAgICA8L2c+CiAgICAgICAgPGc+CiAgICAgICAgICAgIDxwYXRoIGQ9Ik0yMCwzMi4wMTIyQzIyLjIwNTgsMzIuMDEyMiAyMy45OTM5LDMzLjgwMDMgMjMuOTkzOSwzNi4wMDYxQzIzLjk5MzksMzguMjExOSAyMi4yMDU4LDQwIDIwLDQwQzE3Ljc5NDIsNDAgMTYuMDA2MSwzOC4yMTE5IDE2LjAwNjEsMzYuMDA2MUMxNi4wMDYxLDMzLjgwMDMgMTcuNzk0MiwzMi4wMTIyIDIwLDMyLjAxMjJaIiBzdHlsZT0iZmlsbDpyZ2IoMTMwLDEzMCwxMzApOyIvPgogICAgICAgIDwvZz4KICAgICAgICA8Zz4KICAgICAgICAgICAgPHBhdGggZD0iTTI4LjQ5MzksMjguNDkzOUMzMC4wNTM2LDI2LjkzNDIgMzIuNTgyNCwyNi45MzQyIDM0LjE0MjEsMjguNDkzOUMzNS43MDE5LDMwLjA1MzYgMzUuNzAxOSwzMi41ODI0IDM0LjE0MjEsMzQuMTQyMUMzMi41ODI0LDM1LjcwMTkgMzAuMDUzNiwzNS43MDE5IDI4LjQ5MzksMzQuMTQyMUMyNi45MzQyLDMyLjU4MjQgMjYuOTM0MiwzMC4wNTM2IDI4LjQ5MzksMjguNDkzOVoiIHN0eWxlPSJmaWxsOnJnYigxMDEsMTAxLDEwMSk7Ii8+CiAgICAgICAgPC9nPgogICAgICAgIDxnPgogICAgICAgICAgICA8cGF0aCBkPSJNMy45OTM5LDE2LjAwNjFDNi4xOTk2OCwxNi4wMDYxIDcuOTg3ODEsMTcuNzk0MiA3Ljk4NzgxLDIwQzcuOTg3ODEsMjIuMjA1OCA2LjE5OTY4LDIzLjk5MzkgMy45OTM5LDIzLjk5MzlDMS43ODgxMywyMy45OTM5IDAsMjIuMjA1OCAwLDIwQzAsMTcuNzk0MiAxLjc4ODEzLDE2LjAwNjEgMy45OTM5LDE2LjAwNjFaIiBzdHlsZT0iZmlsbDpyZ2IoMTg3LDE4NywxODcpOyIvPgogICAgICAgIDwvZz4KICAgICAgICA8Zz4KICAgICAgICAgICAgPHBhdGggZD0iTTUuODU3ODYsMjguNDkzOUM3LjQxNzU4LDI2LjkzNDIgOS45NDYzOCwyNi45MzQyIDExLjUwNjEsMjguNDkzOUMxMy4wNjU4LDMwLjA1MzYgMTMuMDY1OCwzMi41ODI0IDExLjUwNjEsMzQuMTQyMUM5Ljk0NjM4LDM1LjcwMTkgNy40MTc1OCwzNS43MDE5IDUuODU3ODYsMzQuMTQyMUM0LjI5ODE1LDMyLjU4MjQgNC4yOTgxNSwzMC4wNTM2IDUuODU3ODYsMjguNDkzOVoiIHN0eWxlPSJmaWxsOnJnYigxNjQsMTY0LDE2NCk7Ii8+CiAgICAgICAgPC9nPgogICAgICAgIDxnPgogICAgICAgICAgICA8cGF0aCBkPSJNMzYuMDA2MSwxNi4wMDYxQzM4LjIxMTksMTYuMDA2MSA0MCwxNy43OTQyIDQwLDIwQzQwLDIyLjIwNTggMzguMjExOSwyMy45OTM5IDM2LjAwNjEsMjMuOTkzOUMzMy44MDAzLDIzLjk5MzkgMzIuMDEyMiwyMi4yMDU4IDMyLjAxMjIsMjBDMzIuMDEyMiwxNy43OTQyIDMzLjgwMDMsMTYuMDA2MSAzNi4wMDYxLDE2LjAwNjFaIiBzdHlsZT0iZmlsbDpyZ2IoNzQsNzQsNzQpOyIvPgogICAgICAgIDwvZz4KICAgICAgICA8Zz4KICAgICAgICAgICAgPHBhdGggZD0iTTI4LjQ5MzksNS44NTc4NkMzMC4wNTM2LDQuMjk4MTUgMzIuNTgyNCw0LjI5ODE1IDM0LjE0MjEsNS44NTc4NkMzNS43MDE5LDcuNDE3NTggMzUuNzAxOSw5Ljk0NjM4IDM0LjE0MjEsMTEuNTA2MUMzMi41ODI0LDEzLjA2NTggMzAuMDUzNiwxMy4wNjU4IDI4LjQ5MzksMTEuNTA2MUMyNi45MzQyLDkuOTQ2MzggMjYuOTM0Miw3LjQxNzU4IDI4LjQ5MzksNS44NTc4NloiIHN0eWxlPSJmaWxsOnJnYig1MCw1MCw1MCk7Ii8+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4K"),this.onChange=e,this.getOption=t,this.config=null,this.option=null,this.settings=Ar.settings,this.settings.api=-1===this.settings.api.indexOf("local")?this.settings.api.replace("api.","assets."):this.settings.api}}Ar.settings={assets:"",api:"",path:"/api/list",queryParams:{}};var Fr=Ar;const Dr=(e,t)=>{if(e){let i={};i.used=t.value.length,i.min=t.params.min?t.params.min:0,i.max=t.params.max?t.params.max:1e3,i.left=i.max-i.used;for(let t in i)i.hasOwnProperty(t)&&(e=e.replace(new RegExp("{"+t+"}","g"),i[t]));return e}},Nr=e=>e?e.replace(/\\n/g,"\n"):e,jr=(e,t,i)=>{if(dr.priceVisible&&e){let r;return r=t?t.replace(new RegExp("{price}","g"),e):`(+ ${e})`,i&&(-1!==r.indexOf("-")?r=r.replace("-","").replace("+","-"):-1!==r.indexOf("==")&&(r=r.replace("==","").replace("+",""))),r}return""},Rr=e=>{if(e.values){let t=e._controller&&e._controller.multiSelect,i=t?[]:null;for(let r=0;re?e.text?e.text:e.value||"":"",zr=(e,t,i,r=!1)=>{let o=Vr(t);if(e.params.valuePriceText){let r=qr(e,t,i);r&&(o+=" "+r)}return r&&(o=(e=>e.replace(/(<([^>]+)>)/gi,""))(o)),o},qr=(e,t,i)=>{if(!0===t.disabled){let e=l.get("product.options.disabled",null,"_");if("_"!==e)return`(${e})`}if(t.price&&i)return jr(Hr(e,t,i),e.params.priceTemplate,e.params.priceRelative)},Hr=(e,t,i)=>{if(t.price&&i){let r=t.price;if(e.params.priceRelative)for(let o=0;o{let o="";if(e.params.imgTooltip&&(o+=`${o}`),e.params.imgText||(o+=zr(e,t,i,r)),""!==o.trim())return o};const Ur={mode:"both",enter:{active:"cl-po--fade-enter-active",from:"cl-po--fade-enter-from",to:"cl-po--fade-enter-to"},leave:{active:"cl-po--fade-leave-active",from:"cl-po--fade-leave-from",to:"cl-po--fade-leave-to"},duration:500},Wr=()=>{let e=document.createElement("input");return e.type="color",e.value="!","color"===e.type&&"!"!==e.value},Yr=(e,t,i={})=>((t.disabled||e._variantOption&&!1===t.available)&&(i["cl-po--disabled"]=!0),i),Gr=(e,t={})=>(t["cl-po--invalid"]=e.errors&&e.errors.length>0,e._editor&&e._layer.params.collapse&&(t["cl-po--b-radius-0"]=!0),t),Qr=(e,t,i={})=>(e.params.size?i["cl-po--"+e.params.size]=!0:t&&(i["cl-po--"+t]=!0),e.params.shape&&(i["cl-po--"+e.params.shape]=!0),i),Xr=(e,t,i,r)=>{t.params.toggle&&t.value===i.value&&(e.preventDefault(),e.stopImmediatePropagation(),t.value="",r(t))},Zr=(e,t={})=>(e.params.minWidth&&e.params.minWidth>0&&(t.minWidth=e.params.minWidth+"px"),t),Jr=(e,t={})=>(e.params.btnColor&&(t.color=e.params.btnColor),e.params.btnBgColor&&(t.backgroundColor=e.params.btnBgColor),t),Kr=(e,t,i=300)=>0===(i=e.params.debounce||i)?t:o.debounced(i,t),eo=e=>e.params.name?e.params.name:e.params.exclude?"_"+e.name:`properties[${e.name}]`,to=(e,t="noop")=>e.params.autocomplete?e.params.autocomplete:t,io=(e,t)=>{if(e.params.optionFont){let i=t(e.params.optionFont);if(i&&i.value){let e=i.value,t=d.getFont(e);if(t)return t.loaded||d.loadFontsByName([e]),e}}return null},ro=(e,t,i)=>{if(e.target.value){let i=[];if("uppercase"===t.params.textTransform?e.target.value=e.target.value.toUpperCase():"lowercase"===t.params.textTransform&&(e.target.value=e.target.value.toLowerCase()),t.params.rowsMax){let i=e.target.value.split("\n");i.length>t.params.rowsMax&&(i.length=t.params.rowsMax,e.target.value=i.join("\n"))}if(t.params.max&&e.target.value.length>t.params.max&&(e.target.value=e.target.value.substring(0,t.params.max)),t.params.textClean){if(!t._textClean)try{t._textClean=new RegExp(t.params.textClean,t.params.textCleanFlags||"ug")}catch(e){a.error("failed to compile textClean pattern for option: ",t.params.textClean,t,e)}t._textClean&&t._textClean.test(e.target.value)&&(e.target.value=e.target.value.replaceAll(t._textClean,""),i.push(l.get("product.options.validity.textClean",null,t.params.validationMsg||"Input not allowed")))}i.length&&(t.errors=i,t._error=!0)}return oo(e,t,i)},oo=(e,t,i)=>(t.value=e.target.value,i(t)),no=e=>{let t=[];return e._layer.params.editor.font&&t.push("font:"+(e._editor.fontFamily||"")),e._layer.params.editor.style&&(t.push("weight:"+(e._editor.fontWeight||"normal")),t.push("style:"+(e._editor.fontStyle||"normal"))),e._layer.params.editor.align&&t.push("align:"+(e._editor.textAlign||"left")),e._layer.params.editor.size&&t.push("size:"+(e._editor.fontSize||"normal")),e._layer.params.editor.color&&t.push("color:"+(e._editor.color||"#000000")),t.join(",")},ao=(e,t,i)=>({multiSelect:!0,onValidate:e=>{let t=e.value?e.value.split(",").length:0;return e.params.minSelect&&te.params.maxSelect?(e.errors.push(l.get("product.options.validity.selectMax",{max:e.params.maxSelect})),!1):!(e.required&&!e.value)||(e.errors.push(l.get("product.options.validity.valueMissing")),!1)},onChange:(e,t)=>{let r=document.querySelector("#"+t.id);if(r){let e=document.querySelectorAll('[id^="'+t.id+'"]'),o=[];for(let t=0;t{if(String(t.value).trim()===String(e.value).trim())return!0;if(e.value&&-1!==e.value.indexOf(t.value)){if(-1!==e.value.split(",").indexOf(t.value))return!0}return!1}});br.templates.hidden=(e,t,i)=>te` `,br.templates["value-formula"]=(e,t,i)=>te` ${br.templates.hidden(e,t,i)}} `;const so=e=>te` ${e._layer.params.collapseLabel?te`${e._layer.params.collapseLabel}`:null} `;br.templates.text=(e,t,i)=>te` ro(t,e,i)))} ?required=${e.required} minlength=${Ai(e.params.min)} maxlength=${Ai(e.params.max)} pattern=${Ai(e.params.pattern||void 0)} placeholder=${Ai(e.params.placeholder)} autocomplete="${to(e)}" form=${Ai(t.productFormLink)} style=${Li({textTransform:e.params.textTransform})}> ${e._editor?e._layer.params.collapse?te`${co(so(e),br.templates.text_editor(e,t,i),!1,"cl-po--edit")}`:te`${br.templates.text_editor(e,t,i)}`:null} `,br.templates.textarea=(e,t,i,r,o)=>te` ${e._editor?e._layer.params.collapse?te`${co(so(e),br.templates.text_editor(e,t,i),!1,"cl-po--edit")}`:te`${br.templates.text_editor(e,t,i)}`:null} ${e.params.textUsage?te`
`:null} `,br.templates.text_editor=(e,t,i)=>te`
${br.templates.hidden({id:e.id+"_editor",name:"_"+e.name+"_editor",params:{},value:no(e)},t)} ${e._layer.params.editor.font?te`
${br.templates.font({id:e.id+"_font",name:e.name+"_font",params:{name:e.name+"_font"},value:e._editor.fontFamily},t,(t=>{e._editor.fontFamily=t.value,i(e)}))}
`:null} ${e._layer.params.editor.style?te`
{e._editor.fontWeight="bold"===e._editor.fontWeight?"normal":"bold",i(e)}} class="cl-po--swatch cl-po--swatch-button ${"bold"===e._editor.fontWeight?"selected":""}" data-tippy-content="${l.get("product.options.text.style.bold")}" data-tippy-placement="bottom">
{e._editor.fontStyle="italic"===e._editor.fontStyle?"normal":"italic",i(e)}} class="cl-po--swatch cl-po--swatch-button ${"italic"===e._editor.fontStyle?"selected":""}" data-tippy-content="${l.get("product.options.text.style.italic")}" data-tippy-placement="bottom">
`:null} ${e._layer.params.editor.align?te`
{e._editor.textAlign="left",i(e)}} class="cl-po--swatch cl-po--swatch-button ${"left"===e._editor.textAlign?"selected":""}" data-tippy-content="${l.get("product.options.text.align.left")}" data-tippy-placement="bottom">
{e._editor.textAlign="center",i(e)}} class="cl-po--swatch cl-po--swatch-button ${"center"===e._editor.textAlign?"selected":""}" data-tippy-content="${l.get("product.options.text.align.center")}" data-tippy-placement="bottom">
{e._editor.textAlign="right",i(e)}} class="cl-po--swatch cl-po--swatch-button ${"right"===e._editor.textAlign?"selected":""}" data-tippy-content="${l.get("product.options.text.align.right")}" data-tippy-placement="bottom">
`:null} ${e._layer.params.editor.size?te`
{e._editor.fontSize=Math.max(e._layer.params.fontSizeMin||1,e._editor.fontSize-(e._layer.params.fontSizeStep||1)),i(e)}} class="cl-po--swatch cl-po--swatch-button">
{e._editor.fontSize=Math.min(e._layer.params.fontSizeMax||1e5,e._editor.fontSize+(e._layer.params.fontSizeStep||1)),i(e)}} class="cl-po--swatch cl-po--swatch-button">
`:null} ${e._layer.params.editor.color?te`
${br.templates.color({id:e.id+"_color",name:e.name+"_color",params:{name:e.name+"_color"},value:e._editor.color||"#000000"},t,(t=>{e._editor.color=t.value,i(e)}))} ${Wr()?te`
${br.templates.color_input({id:e.id+"_color",name:e.name+"_color",params:{name:e.name+"_color"},value:e._editor.color||"#000000"},t,(t=>{e._editor.color=t.value,i(e)}))}
`:null}
`:null}
`,br.templates.date=(e,t,i)=>{let r=void 0===e._controller;if(e._controller=e._controller||{setup:()=>{if(e._controller.native=(()=>{let e=document.createElement("input");return e.setAttribute("type","date"),e.setAttribute("value","a"),"a"!==e.value})(),e._controller.native)e._controller.ready=Promise.resolve();else{let i=[t.assets+"/static/lib/dateinput/dateinput.min.js"];e._controller.ready=$r.loadOnce(i,"option-date",{async:!1})}},onValidate:()=>{let t=e._controller.dateEl,i=t.checkValidity(),r=!1,o=!1;if(i&&!e._controller.native){if(t.min){let e=new Date(t.min+"T00:00:00");t.valueAsDatee&&(i=!1,o=!0)}}if(!i){if(t.validity.rangeUnderflow||r){let i=t.min,r=new Date(i+"T00:00:00");r.setDate(r.getDate()-1),i=e._controller.format(r,e.params.dateFormat||"yyyy-mm-dd"),e.errors.push(l.get("product.options.validity.dateMin",{min:i}))}else if(t.validity.rangeOverflow||o){let i=t.max,r=new Date(i+"T00:00:00");r.setDate(r.getDate()+1),i=e._controller.format(r,e.params.dateFormat||"yyyy-mm-dd"),e.errors.push(l.get("product.options.validity.dateMax",{max:i}))}else e.errors.push(l.get("product.options.validity.valueMissing"));return!1}return!0},onChange:(e,t)=>{t._controller.mapDateValue(t),i(t)},mapDateValue:e=>{if(e._controller.dateEl.value)if(e.params.dateFormat){let t=e._controller.dateEl.valueAsDate,i=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds());e._controller.el.value=e._controller.format(i,e.params.dateFormat)}else e._controller.el.value=e._controller.dateEl.value;else e._controller.el.value="";e.value=e._controller.el.value},mapOptionValue:()=>{if(e.value&&e.value!==e._controller.el.value){let t,i=e.params.dateFormat;if(i&&"yyyy-mm-dd"!==i){let r;if(-1!==i.indexOf("/")?r=i.startsWith("yyyy")?/(?\d{4})\/(?\d{2})\/(?\d{2})/:/(?\d{2})\/(?\d{2})\/(?\d{4})/:-1!==i.indexOf(".")&&(r=i.startsWith("dd")?/(?\d{2})\.(?\d{2})\.(?\d{4})/:/(?\d{2})\.(?\d{2})\.(?\d{4})/),r){let i=r.exec(e.value);i&&(t=new Date(i.groups.year,i.groups.month-1,i.groups.day))}}else t=new Date(e.value+"T00:00:00");if(t)return e._controller.dateEl.valueAsDate=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())),!0}return!1},format:(e,t)=>(-1!==t.indexOf("mmmm")?t=t.replace("mmmm",e.toLocaleString("default",{month:"long"})):-1!==t.indexOf("mmm")&&(t=t.replace("mmm",e.toLocaleString("default",{month:"short"}))),t=(t=(t=(t=t.replace("yyyy",e.getFullYear())).replace("yy",e.getFullYear().toString().substr(-2))).replace("mm",("0"+(e.getMonth()+1)).slice(-2))).replace("dd",("0"+e.getDate()).slice(-2))),init:(e,t)=>{t&&(e._controller.options=t),e._controller.ready.then((()=>{if(e._controller.el=document.querySelector("#"+e.id),e._controller.dateEl=document.querySelector("#"+e.id+"-date"),!e._controller.native){if(window.navigator&&window.navigator.language){let t=navigator.language,i=t.substr(0,2);e._controller.dateEl.setAttribute("lang",t),"en"!==i&&e._controller.dateEl.setAttribute("data-first-day","mo")}e.params.dateFormat&&e._controller.dateEl.setAttribute("data-date-format",e.params.dateFormat)}e._controller.mapOptionValue(),e._controller.initMinMax(e)}))},initMinMax:e=>{const r=!isNaN(e.params.maxDays)&&null!=e.params.maxDays,o=!isNaN(e.params.minDays)&&null!=e.params.minDays;if(o||r){const n=t=>{r&&(t=>{if(t.setDate(t.getDate()+e.params.maxDays),e.params.maxDate){let i=new Date(e.params.maxDate+"T00:00:00");t>i&&(t=i)}e._controller.dateEl.max=e._controller.format(t,"yyyy-mm-dd"),e._controller.dateEl.valueAsDate&&e._controller.dateEl.valueAsDate>t&&(e._controller.dateEl.valueAsDate=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())),e._controller.mapDateValue(e))})(new Date(t.getTime())),o&&(t=>{if(t.setDate(t.getDate()+e.params.minDays),e.params.minDate){let i=new Date(e.params.minDate+"T00:00:00");t{let r=t.detail;r.name===e.params.optionDate&&r._controller&&r._controller.dateEl&&(n(r._controller.dateEl.valueAsDate),i(e))},t.productForm.addEventListener("option:changed",e._controller.optionChanged)}n(a)}else if(e._controller.dateEl.min){let t=new Date(e._controller.dateEl.min+"T00:00:00");(!e.value||e._controller.dateEl.valueAsDate&&e._controller.dateEl.valueAsDate{let o=r.detail;t.productForm.removeEventListener("options:rendered",i),e._controller.init(e,o.config.options)};t.productForm.addEventListener("options:rendered",i)}else t.editorMode?e._controller.init(e):e._controller.mapOptionValue()&&e._controller.initMinMax(e);return te` e._controller.onChange(t,e)} ?required=${e.required} min=${Ai(null!=e.params.minDate?e.params.minDate:void 0)} max=${Ai(null!=e.params.maxDate?e.params.maxDate:void 0)}> `},br.templates.number=(e,t,i)=>e.params.numberSteps?te`
{e.value=Math.max((parseFloat(e.value)||0)-(e.params.numberStep||1),e.params.min||0),i(e)}}>- oo(t,e,i)))} ?required=${e.required} step="any" min=${Ai(e.params.min)} max=${Ai(e.params.max)} placeholder=${Ai(e.params.placeholder)} autocomplete="${to(e)}" form=${Ai(t.productFormLink)}> {e.value=Math.min((parseFloat(e.value)||0)+(e.params.numberStep||1),e.params.max||Number.MAX_SAFE_INTEGER),i(e)}}>+
`:te` oo(t,e,i)))} ?required=${e.required} step="any" min=${Ai(e.params.min)} max=${Ai(e.params.max)} placeholder=${Ai(e.params.placeholder)} autocomplete="${to(e)}" form=${Ai(t.productFormLink)}> `,br.templates.dimension=(e,t,i)=>{let r=void 0===e._controller;if(e._controller=e._controller||{x:0,y:0,area:0,xInput:"",yInput:"",xEl:null,yEl:null,onValidate:e=>!e.required||e.value&&e._controller.x>0&&(e.params.onlyX||e._controller.y>0)?(e._controller.validateDimension(e,e.errors,!e._controller.xInput,!e._controller.yInput),!e.errors.length):(e.errors.push(l.get("product.options.validity.valueMissing")),!1),validateDimension:(e,t,i=!1,r=!1)=>{let o=e._controller.x,n=e._controller.y;if(e.params.bigX&&oe&&"#"===e[0]?e.substring(1):e;!i&&e.params.minX&&oe.params.maxX&&t.push(l.get(a(e.params.maxXKey)||"{label} must be at most {max} {addon}",{label:e.params.labelX,max:e.params.maxX,addon:e.params.addonX})),e.params.maxY&&n>e.params.maxY&&t.push(l.get(a(e.params.maxYKey)||"{label} must be at most {max} {addon}",{label:e.params.labelY,max:e.params.maxY,addon:e.params.addonY}))},optionValue:e=>(e.params.valueTemplate||"{x}x{y}").replace(new RegExp("{x}","g"),e._controller.x).replace(new RegExp("{y}","g"),e._controller.y).replace(new RegExp("{area}","g"),e._controller.area.toFixed(2)),onChange:(e,r,o=!1)=>{let n=r._controller;o||(n.xEl=n.xEl||document.querySelector("#"+r.id+"-x"),n.yEl=n.yEl||document.querySelector("#"+r.id+"-y"),null!=r.params.ratio&&(n.xEl.value!==n.xInput?n.yEl.value=parseFloat(n.xEl.value/r.params.ratio).toFixed(2):n.xEl.value=parseFloat(n.yEl.value*r.params.ratio).toFixed(2)),n.xInput=n.xEl.value,n.yInput=n.yEl.value);const s=e=>e?e.replaceAll(",","."):"0";if(n.x=parseFloat(s(n.xInput))||0,n.y=parseFloat(s(n.yInput))||0,r.params.steps){let e=r.params.steps;n.x%e!=0&&(n.x=Math.round(n.x/e)*e),n.y%e!=0&&(n.y=Math.round(n.y/e)*e),(isNaN(r.params.rounding)||null===r.params.rounding)&&(r.params.rounding=0)}if(!isNaN(r.params.rounding)&&null!==r.params.rounding){let t=null==e;if(0!==n.x){let e=n.x.toFixed(r.params.rounding);n.x=parseFloat(e),t?n.xInput=e:(n.xInputBlur=()=>{n.xInput=e,n.xEl.value=n.xInput,delete n.xInputBlur},n.xEl.addEventListener("blur",(e=>{n.xInputBlur&&n.xInputBlur()}),{once:!0}))}if(0!==n.y){let e=n.y.toFixed(r.params.rounding);n.y=parseFloat(e),t?n.yInput=e:(n.yInputBlur=()=>{n.yInput=e,n.yEl.value=n.yInput,delete n.yInputBlur},n.yEl.addEventListener("blur",(e=>{n.yInputBlur&&n.yInputBlur()}),{once:!0}))}n.blurInterval||!n.xInputBlur&&!n.yInputBlur||(n.blurInterval=setInterval((()=>{n.xInputBlur&&document.activeElement!==n.xEl&&n.xInputBlur(),n.yInputBlur&&document.activeElement!==n.yEl&&n.yInputBlur(),n.xInputBlur||n.yInputBlur||(clearInterval(n.blurInterval),delete n.blurInterval)}),500))}if(r.params.areaCalc)try{if(!r._areaFunction)try{r._areaFunction=Function('"use strict";return (function(x,y){ return ('+r.params.areaCalc+") })")()}catch(e){a.error("failed to parse areaCalc: ",r.params.areaCalc,e),t.editorMode&&(r.errors=r.errors||[],r.errors.push(e))}r._areaFunction&&(n.area=r._areaFunction(n.x,n.y),n.area||(n.area=0))}catch(e){a.error("failed to calculate area with areaCalc: ",r.params.areaCalc,e),t.editorMode&&(r.errors=r.errors||[],r.errors.push(e))}else n.area=n.x*n.y;let l=[];n.validateDimension(r,l,!n.xInput,!n.yInput),l.length&&(r.errors=l,r._error=!0),r.value=n.optionValue(r),r.values||(r.values=[]);let c="";if(r.list&&r.values.length&&(c="var lookup=function(x,y,t){return option._controller.lookup(option,x,y,t)};",r.params.priceFormula||(r.values[0].values?r.params.priceFormula="lookup(x, y)":r.params.priceFormula="lookup(area) * area")),r.params.priceFormula)if(r.values.length&&r.values[0]._calc)r.values[0].value=r.value;else{let e="var x=option._controller.x;var y=option._controller.y;var area=option._controller.area;"+c;-1===r.params.priceFormula.indexOf("return")?e+="return ("+r.params.priceFormula+")":e+=r.params.priceFormula;let t={value:r.value,text:"",priceType:gr.FORMULA,priceFormula:e,_calc:!0};r.values.unshift(t)}else r.values.unshift({value:r.value,text:""});i(r)},lookup:(e,t,i,r)=>{"string"==typeof i&&(r=i,i=null);for(let o=e.values.length-1;o>=1;o--){let n=e.values[o],s=parseFloat(n.value);if(t>=s){if(r&&n.text!==r)continue;if(!i||!n.values?.length)return a.info("[live-options] price list lookup:",t,"match:",s,"price:",n.price),n.price;for(let e=n.values.length-1;e>=0;e--){let r=n.values[e],o=parseFloat(r.value);if(i>=o)return a.info("[live-options] price list lookup:",t,i,"match:",s,o,"price: ",r.price),r.price}}}return a.warn("[live-options] price list lookup:",t,"no match"),0},restore:e=>{if(e.value&&e.value!==e._controller.optionValue(e)){let t=(e.params.valueTemplate||"{x}x{y}").replace(".","\\.").replace("*","\\*").replace(new RegExp("{x}","g"),"(?.*)").replace(new RegExp("{y}","g"),"(?.*)").replace(new RegExp("{area}","g"),"(?.*)"),i=new RegExp(t,"g").exec(e.value);if(i&&i.groups)return void 0!==i.groups.x&&(e._controller.xInput=i.groups.x),void 0!==i.groups.y&&(e._controller.yInput=i.groups.y),e._controller.onChange(null,e,!0),!0}return!1},init:(e,t)=>{isNaN(e.params.valueX)||null===e.params.valueX||(e._controller.xInput=String(e.params.valueX)),isNaN(e.params.valueY)||null===e.params.valueY||(e._controller.yInput=String(e.params.valueY)),e.value&&e._controller.restore(e)||(e._controller.xInput||e._controller.yInput)&&e._controller.onChange(null,e,!0)},stepDec(e,t){let i=e._controller[t],r=e.params.numberStep||1,o=isNaN(e.params.rounding)||null===e.params.rounding?null:e.params.rounding,n=Math.round(i/r);const a=Math.pow(10,-10);Math.abs(i-n*r){t.productForm.removeEventListener("options:rendered",i),e._controller.init(e)};t.productForm.addEventListener("options:rendered",i)}else e.value&&!e._controller.xEl&&e._controller.restore(e);const o=te`e._controller.onChange(t,e)))} ?required=${e.required} form=${Ai(t.productFormLink)}>`,n=te`e._controller.onChange(t,e)))} ?required=${e.required&&!e.params.onlyX} form=${Ai(t.productFormLink)}>`;return te`
${e.params.labelX?te``:null}
${e.params.numberSteps?te`
{e._controller.stepDec(e,"x")}}>- ${o} {e._controller.stepInc(e,"x")}}>+
`:o} ${e.params.addonX?te`${e.params.addonX}`:null}
${e.params.labelY?te``:null}
${e.params.numberSteps?te`
{e._controller.stepDec(e,"y")}}>- ${n} {e._controller.stepInc(e,"y")}}>+
`:n} ${e.params.addonY?te`${e.params.addonY}`:null}
`},br.templates.color=(e,t,i)=>te` ${Wr()?te` oo(t,e,i)} ?required=${e.required} minlength=${Ai(e.params.min)} maxlength=${Ai(e.params.max)} placeholder=${Ai(e.params.placeholder)} form=${Ai(t.productFormLink)}> `:br.templates.color_input(e,t,i)} `,br.templates.color_input=(e,t,i)=>te` oo(t,e,i)} ?required=${e.required} pattern="#[0-9A-Fa-f]{6}" placeholder=${Ai(e.params.placeholder)} autocomplete="${to(e,"color")}" form=${Ai(t.productFormLink)}> `,br.templates["color-swatch"]=(e,t,i)=>e.params.multiSelect?(e._controller=e._controller||ao(0,0,i),te`
${Ii(e.values||[],(e=>e.value),((i,r)=>te` ${e.params.items&&(r+1)%e.params.items==0?te`
`:null} `))}
`):te`
${Ii(e.values||[],(e=>e.value),((r,o)=>te` ${e.params.items&&(o+1)%e.params.items==0?te`
`:null} `))}
`,br.templates["color-img-swatch"]=(e,t,i)=>br.templates["img-swatch"](e,t,i),br.templates["img-swatch"]=(e,t,i)=>e.params.multiSelect?(e._controller=e._controller||ao(0,0,i),te`
${Ii(e.values||[],(e=>e.value),((i,r)=>te` ${e.params.items&&(r+1)%e.params.items==0?te`
`:null} `))}
`):te`
${Ii(e.values||[],(e=>e.value),((r,o)=>te` ${e.params.items&&(o+1)%e.params.items==0?te`
`:null} `))}
`,br.templates["button-swatch"]=(e,t,i)=>e.params.multiSelect?(e._controller=e._controller||ao(0,0,i),te`
${Ii(e.values||[],(e=>e.value),((i,r)=>te` ${e.params.items&&(r+1)%e.params.items==0?te`
`:null} `))}
`):te`
${Ii(e.values||[],(e=>e.value),((r,o)=>te` ${e.params.items&&(o+1)%e.params.items==0?te`
`:null} `))}
`;const lo=(e,t,i)=>{const r={quantity:1,quantityEl:null,quantityElOption:!1,quantityId:"",quantityDiscount:"",discount:0,discountType:gr.ABSOLUTE,onValidate:e=>{if(e.params.quantityId){let i=e.params.quantityId;-1!==i.indexOf("{random}")&&(i=i.replace("{random}",String(Math.floor(1e3*Math.random()+1)))),-1!==i.indexOf("{product}")&&(i=i.replace("{product}",String(t.product.id))),-1!==i.indexOf("{variant}")&&(i=i.replace("{variant}",String(t.productForm.id.value))),r.quantityId=i}return!0},onChange:(e,t)=>{r.quantity=parseInt(t.value),r.syncEl(),r.selectDiscount(t),i(t)},selectDiscount:e=>{if(e.values)for(let t=0;t{r.quantityEl.value=r.quantity},syncValue:e=>{if(r.quantity=parseInt(r.quantityEl.value)||1,e.value="",r.discount=0,e.values)for(let t=0;t=t&&i._discount>r.discount&&(e.value=i.value)}}r.selectDiscount(e)},quantityDiscountText(e,t,i,o,n,a=""){const s=r.calcQuantityDiscountVars(e,t,i,o,n);return`${e.params.textDiscountBuy||"Buy:"} ${t}${a}`+(e.params.discountTemplate||"{price} {compare} {discount}").replace(new RegExp("{compareP}","g"),`${cr(100*s.price,ur.moneyFormat)}`).replace(new RegExp("{compare}","g"),`${cr(100*s.total,ur.moneyFormat)}`).replace(new RegExp("{priceP}","g"),`${cr(100*s.productFinal,ur.moneyFormat)}`).replace(new RegExp("{price}","g"),`${cr(100*s.totalFinal,ur.moneyFormat)}`).replace(new RegExp("{discountP}","g"),`${s.productSave}`).replace(new RegExp("{discount}","g"),`${s.totalSave}`)},optionValueDiscountText(e,t,i){let o=parseInt(t.value),n="+",a=e.values.indexOf(t);if(e.values.length>a+1){parseInt(e.values[a+1].value)===o+1&&(n="")}return r.quantityDiscountText(e,o,t._discount,t.priceType,i,n)},calcQuantityDiscountVars(e,t,i,r,o){let n,a,s,l,c=o.price.final-o.price.variantTotal,p=t*c;if(r===gr.PERCENTAGE)n=c-c*(i/100),s=n*t,a=`${e.params.textDiscountSave||"Save:"} ${i}%`,l=a;else{ur.currencyConvert&&(i=hr(i));let e=Math.min(i,c);n=c-e,a="-"+cr(100*e,ur.moneyFormat);let r=e*t;s=p-r,l="-"+cr(100*r,ur.moneyFormat)}return{price:c,total:p,productFinal:n,productSave:a,totalFinal:s,totalSave:l}},updatePriceElements(e,t){if(r._priceElList&&r._priceElList.length)for(let e=0;e{const t=void 0!==e.dataset.livePriceQuantitySingle?"productFinal":"totalFinal";let r=cr(100*i[t],ur.moneyFormat);e.dataset.liveFormat&&(e.dataset.liveFormat=r),e.innerHTML=r}))}},init:e=>{let o=[];if(e.values)for(let t=0;t{r.syncValue(e),i(e)}));else if(!r.quantityElOption){r.quantityElOption=!0;const i=o=>{t.productForm.removeEventListener("options:rendered",i),r.quantityEl=document.querySelector("#"+e.id+"-quantity"),r.quantityEl.value="1",r.syncValue(e)};t.productForm.addEventListener("options:rendered",i)}}e.params.selectedQuantity&&!t.editorMode&&setTimeout((()=>{r.quantity=parseInt(e.params.selectedQuantity),r.syncEl(e),r.syncValue(e),i(e)}))}};return r.init(e),r};br.templates["quantity-discount"]=(e,t,i)=>fr.QUANTITY?(e._controller=e._controller||lo(e,t,i),t.editorMode&&e._controller.init(e),e._controller.updatePriceElements(e,t),te` ${Ii(e.values||[],((i,r)=>te` `))} ${!1!==e.params.discountLine&&e._controller.discount&&e._controller.quantity!==parseInt(e.value)?te` `:null} ${e._controller.quantityElOption?te`
{e._controller.quantity--,e._controller.syncEl(e),e._controller.syncValue(e),i(e)}}>- {e._controller.syncValue(e),i(e)}}> {e._controller.quantity++,e._controller.syncEl(e),e._controller.syncValue(e),i(e)}}>+
`:null} `):te``;br.templates.personalize=(e,t,i)=>e.params.btnCheckbox?te` ${Ii(e.values||[],((i,r)=>0===r?te` `:te``))} `:te`
${Ii(e.values||[],((r,o)=>te` ${e.params.items&&(o+1)%e.params.items==0?te`
`:null} `))}
`,br.templates.download=(e,t,i)=>te`
`,br.templates.radio=(e,t,i)=>te` ${Ii(e.values||[],(e=>e.value),((r,o)=>te` `))} `,br.templates.checkbox=(e,t,i)=>(e._controller=e._controller||ao(0,0,i),te` ${Ii(e.values||[],(e=>e.value),((r,o)=>te` `))} `),br.templates.select=(e,t,i)=>{let r=e.params.groupDelimiter?((e,t)=>{let i=[],r=null;const o={};for(let n=0;n1){const e=s[0];r&&e===r.groupLabel||(o.hasOwnProperty(e)?r=o[e]:(r={groupLabel:e,values:[]},i.push(r),o[e]=r)),a._text||(a._text=a.text,a.text=s[1]),r.values.push(a)}else i.push(a)}return i})(e.values,e.params.groupDelimiter):null;const o=(t,i)=>te` `;return te` ${e._editor?e._layer.params.collapse?te`${co(so(e),br.templates.text_editor(e,t,i),!1,"cl-po--edit")}`:te`${br.templates.text_editor(e,t,i)}`:null} `},br.templates.font=(e,t,i)=>{let r;r=e.params.fontFamilies&&e.params.fontFamilies.length?e.params.fontFamilies:d.fonts.map((e=>e.name)),e.params.fontSortAlpha&&r.sort(((e,t)=>e.localeCompare(t))),e.values=r.map((e=>({value:e,text:" ",img:d.fontPreview(e)})));let o="dropdown";return e.params.fontSwatch&&(e.params.grow=!0,e.params.items=e.params.fontSwatchItems||3,o="img-swatch"),te`
${br.templates[o](e,t,i)}
`},br.templates.dropdown=(e,t,i)=>{let r=void 0===e._controller;if(e._controller=e._controller||{setup:()=>{let i=[t.assets+"/static/lib/choicesjs/choices.min.css",t.assets+"/static/lib/choicesjs/choices.min.js"];e._controller.ready=$r.loadOnce(i,"option-dropdown",{async:!1})},mapValues:e=>{let t=e.values?e.values.map((t=>{let i=e.value==t.value;return!i&&e.value&&e._controller.multiSelect&&(i=e._controller.isSelected(e,t)),{value:t.value,label:zr(e,t,ur.moneyFormat),customProperties:t.img,selected:i,disabled:!0===t.disabled}})):[];return e.value||e.params.multiSelect?e._controller._empty&&delete e._controller._empty:(t.unshift({value:"",label:e.params.textValueSelect||"",selected:!0}),e._controller._empty=!0),t},init:e=>{e._controller.ready.then((()=>{let t=document.querySelector("#"+e.id);if(e.params.multiSelect){e._controller.optionEl=t,e._controller.selectEl=document.querySelector("#"+e.id+"-select");const r=ao();Object.assign(e._controller,r),e._controller.onChange=(e,t)=>{let r=t._controller.instance.getValue(!0).join(",");t._controller.optionEl.value=r,t.value=r,i(t)}}else e._controller.selectEl=t;const r=e=>{let t=`${e.label}`;return e.customProperties?` ${t}`:t};e._controller.instance=new Choices(e._controller.selectEl,{choices:e._controller.mapValues(e),itemSelectText:"",noResultsText:"",noChoicesText:"",removeItemButton:!!e.params.multiSelect,maxItemCount:e.params.maxSelect?e.params.maxSelect:-1,maxItemText:e.params.maxSelect?l.get("product.options.validity.selectMax",{max:e.params.maxSelect}):"",searchPlaceholderValue:e.params.textSearchValues||"",searchEnabled:e.params.searchValues||!1,searchChoices:e.params.searchValues||!1,fuseOptions:window.clDropdownFuseOptions||{},shouldSort:!1,callbackOnCreateTemplates:function(t){return{item:(t,i,o)=>{let n=Choices.defaults.templates.item.apply(this,[t,i,o]),a=r(i);return e.params.multiSelect?(n.innerHTML=n.innerHTML.replace(i.label,a),n.lastElementChild.innerHTML="X"):n.innerHTML=a,""===i.value&&n.classList.add("cl-po--placeholder"),n},choice:(e,t,i)=>{let o=Choices.defaults.templates.choice.apply(this,[e,t,i]);return o.innerHTML=r(t),t.disabled&&o.classList.add("cl-po--disabled"),""===t.value&&o.classList.add("cl-po--placeholder"),o}}}})}))},updateChoices:e=>{e._controller.instance&&(e.value&&e.params.multiSelect&&e._controller.instance.clearStore(),e._controller.instance.setChoices(e._controller.mapValues(e),"value","label",!0))},update:e=>{e._controller.instance&&(e.params.multiSelect?e._controller.optionEl&&e.value!==e._controller.optionEl.value&&e._controller.instance.setChoiceByValue(e.value.split(",")):e._controller.selectEl&&e.value!==e._controller.selectEl.value&&e._controller.instance.setChoiceByValue(e.value))}},t.productForm)if(r){e._controller.setup();const i=()=>{t.productForm.removeEventListener("options:rendered",i),e._controller.init(e)};t.productForm.addEventListener("options:rendered",i)}else if(t.editorMode)e._controller.multiSelect!==e.params.multiSelect?(delete e._controller.multiSelect,e._controller.init(e)):e._controller.updateChoices(e);else{if(e._controller.update(e),e.params.valuePriceText){let t=Rr(e);t&&(t._priceFunction||t.priceType===gr.PERCENTAGE)&&e._controller.updateChoices(e)}e._variantOption&&e._controller.updateChoices(e),e.value&&e._controller._empty&&(e._controller.updateChoices(e),delete e._controller._empty)}return e.params.multiSelect?te` `:te` `};const co=(e,t,i,r="")=>te`
(e=>{let t=e.currentTarget,i=-1!==t.className.indexOf("open"),r=t.nextElementSibling;i||(r.style.maxHeight=r.scrollHeight+100+"px",setTimeout((()=>{r.style.maxHeight&&(r.style.maxHeight=null)}),500)),t.classList.toggle("cl-po--open")})(e)}>${e}
${t}
`;br.templates.group=(e,t,i,r,o)=>{const n=te`
${e.params.groupLayout?te` `:null} ${e.options&&e.options.length>0?te` ${uo(e.options,t,i,r,o)} `:null}
`;return e.params.collapse?co(vi(e.params.collapseLabel),n,e.params.collapseOpen):n},br.templates.html=(e,t,i)=>te` ${vi(e.params.html.replace(new RegExp("{product}","g"),t.product.id))} `,br.templates.layer_editor=(e,t,i)=>te` ${e._layer.params.collapseLabel?te`${e._layer.params.collapseLabel}`:null}
${e._layer.params.editor.scale?te`
{Mr.scale(e._layer,-(e._layer.params.editor.scaleStep||.1))}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.scaleDown",null,"Scale down")}" data-tippy-placement="bottom">
{Mr.scale(e._layer,e._layer.params.editor.scaleStep||.1)}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.scaleUp",null,"Scale up")}" data-tippy-placement="bottom">
`:null} ${e._layer.params.editor.center?te`
{Mr.center(e._layer,"h")}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.centerH",null,"Center horizontal")}" data-tippy-placement="bottom">
{Mr.center(e._layer,"v")}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.centerV",null,"Center vertical")}" data-tippy-placement="bottom">
{Mr.center(e._layer)}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.center",null,"Center")}" data-tippy-placement="bottom">
`:null} ${e._layer.params.editor.move?te`
{Mr.moveX(e._layer,-(e._layer.params.editor.moveStep||50))}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.moveLeft",null,"Move left")}" data-tippy-placement="bottom">
{Mr.moveX(e._layer,e._layer.params.editor.moveStep||50)}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.moveRight",null,"Move right")}" data-tippy-placement="bottom">
{Mr.moveY(e._layer,-(e._layer.params.editor.moveStep||50))}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.moveUp",null,"Move up")}" data-tippy-placement="bottom">
{Mr.moveY(e._layer,e._layer.params.editor.moveStep||50)}} class="cl-po--swatch cl-po--swatch-button" data-tippy-content="${l.get("product.options.layer.moveDown",null,"Move down")}" data-tippy-placement="bottom">
`:null}
`,br.templates.upload=(e,t,i,r,o)=>{let n=void 0===e._controller;return e._controller=e._controller||Ir.getInstance().controller(e,t.product,t.productForm,o),n||e._controller.update(e,t.productForm,t.productFormLink),te`
${e.value&&e._layer&&e._layer.params.crop?te` `:null}
${Ii(e._controller.files,(r=>te`
${r.name} e._controller.remove(e,t.productForm,r,i)}>×
`))}
${e.value&&e._layer&&e._layer&&e._layer.params.layerEditor?te`${br.templates.layer_editor(e,t,i)}`:null}
`},br.templates["upload-lift"]=(e,t,i,r,o)=>{if(e.params.uuid){e._controller&&(e._controller.field&&e._controller.field.config.uuid!==e.params.uuid?(e._controller.field.destroy(),delete e._controller):t.editorMode&&e._controller.notfound&&delete e._controller);let r=void 0===e._controller;e._controller=e._controller||Ir.getInstance().controllerLift(e,t.product,t.productForm,i,o),r||e._controller.update(e,t.productForm),e._controller.option=e;let n=e._layer&&e._layer.params.cropLabel?e._layer.params.cropLabel:e.params.cropLabel;return te`
${e.value&&(e._layer&&e._layer.params.crop||e._controller._cropConfig||e.params.cropEdit)?te` `:null} ${e.value&&e._layer&&e._layer.params.layerEditor?te`${br.templates.layer_editor(e,t,i)}`:null}
`}return null},br.templates.library=(e,t,i,r,o)=>{let n=void 0===e._controller;return e._controller=e._controller||new Fr(i,o),e._controller.option=e,e._controller.config=t,n?e._controller.init():e.value&&!e._controller.image&&-1!==e.value.indexOf("http")&&e._controller.restoreImage(),(n||t.editorMode)&&e._controller.initUI(),te` ${e.params.popup?te`
`:null} ${e._controller.image?te`
${e._controller.image.id?te``:null} ${e._layer?.params.crop||e._controller._fileCrop?te`
e._controller.crop()}> ${(e._layer||e._controller.optionUpload?._layer)?.params.cropLabel?te`${(e._layer||e._controller.optionUpload?._layer)?.params.cropLabel}`:null}
`:null} ${e._layer?.params.layerEditor?te`${br.templates.layer_editor(e,t,i)}`:null}
`:null}
${e._controller.categoryCount>0?te`
${l.get("product.options.library.categories.label",null,"Categories")}
`:null} ${e.params.categoryGrid?te`
${Ii(e.values||[],(e=>e.value),((t,i)=>te` ${e._controller.image!==t?te`
e._controller.onCategoryChange(i,t)}> ${t.img?te`${zr(e,t,ur.moneyFormat)}`:null} ${vi(zr(e,t,ur.moneyFormat))}
`:null} `))}
`:te`
${Ii(e.values||[],(e=>e.value),((t,i)=>te` ${e._controller.image!==t?te`
e._controller.onCategoryChange(i,t)}> ${vi(zr(e,t,ur.moneyFormat))}
`:null} `))}
`}
${!e._controller.imagesHide&&e._controller.categoryHide?te`
e._controller.showCategories()}> ${l.get("product.options.library.categories.button",null,"Show categories")}
`:null}
${Ii(e._controller.imagesPaged||[],(e=>e.value),((t,i)=>te`
e._controller.onImageChange(i,t)}> ${t.img?te`${zr(e,t,ur.moneyFormat)}`:null}
`))}
${e._controller.searchQuery&&0===e._controller.imagesPaged.length?te`

${l.get("product.options.library.search.empty",null,"No results found")}

`:null} ${e._controller.hasMoreImages?te`
e._controller.onMoreImages()}> ${l.get("product.options.library.images.button",null,"More images")}
`:null}
`},br.templates["library-popup"]=(e,t,i)=>te`
${e}
`;const po=e=>te` ${vi(e.label)} ${e.value&&e.params.labelValueText?te` ${Vr(Rr(e))}`:null} ${e._priceText?te` ${vi(jr(e._priceText,e.params.priceTemplate))}`:null} ${e.params.info?te``:null} `,uo=(e,t,i,r,o)=>te` ${Ii(e,(e=>e.name),((e,n)=>te` ${$i(e.visible?te`
${e.label?(e=>"text"===e.type||"textarea"===e.type||"number"===e.type||"select"===e.type)(e)?te``:te`
${po(e)}
`:null} ${br.templates[e.type]?te` ${br.templates[e.type](e,t,i,r,o)} `:null} ${e.params.help?te`
${vi(e.params.help)}
`:null} ${sr(e.errors&&e.errors.length>0?Ui(te`
${Ii(e.errors,((t,i)=>te`
r(i,e,t)}>${t}
`))}
`,`${e.id}-errors`):Ui(te``,"noop"),Ur)}
`:null)} `))} `;var ho=(e,t,i,r,o,n)=>te`
${e.length>0?te` ${uo(e,t,i,r,n)} ${t.editorMode?te`

`:null} `:null} ${t.idLink?te` `:null}
`;var mo=(e,t,i,r,o,n)=>te`
${e}
${r.visible?t:null}
${i}
`,go={};!function(e){"use strict";var t=e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype,i=e.Blob&&function(){try{return Boolean(new Blob)}catch(e){return!1}}(),r=i&&e.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(e){return!1}}(),o=e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,n=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,a=(i||o)&&e.atob&&e.ArrayBuffer&&e.Uint8Array&&function(e){var t,a,s,l,c,p,d,u,h;if(!(t=e.match(n)))throw new Error("invalid data URI");for(a=t[2]?t[1]:"text/plain"+(t[3]||";charset=US-ASCII"),s=!!t[4],l=e.slice(t[0].length),c=s?atob(l):decodeURIComponent(l),p=new ArrayBuffer(c.length),d=new Uint8Array(p),u=0;ute`
`;class vo{evaluateConditions(e,t,i){let r=1===t?"OR":"AND",o=a.getLevel();o<=a.levels.TRACE&&a.debug("====> evaluating conditions for: "+i+" in mode "+r,e);let n=!1;if(e.length)for(let i=0;i evaluated conditions for: "+i+" in mode "+r,n),!!n}evaluateCondition(e,t){return"options"===e.data?this.evaluateOptionCondition(e,t.options):"product"===e.data?this.evaluateProductCondition(e,t.product):"variant"===e.data&&this.evaluateVariantCondition(e,t.variant)}evaluateOptionCondition(e,t){for(let i=0;i0){if(this.evaluateOptionCondition(e,r.options))return!0}}return!1}evaluateVariantCondition(e,t){if(t)switch(e.field){case"variant":if(e.variants)for(let i=0;i=0?t.tags.split(", "):[t.tags]}for(let t=0;t-1;case"!contains":return-1===i.toString().toLowerCase().trim().indexOf(t.toString().toLowerCase().trim());case"empty":return!i;case"!empty":return!!i;case"=":return parseFloat(i)===parseFloat(t);case"!=":return parseFloat(i)!==parseFloat(t);case">":return parseFloat(i)>parseFloat(t);case">=":return parseFloat(i)>=parseFloat(t);case"<":return parseFloat(i)n.height||a.width>n.width)&&(i?(c?(p=Math.max(d,u),r.interactive&&(d>u?e.lockMovementX=!0:e.lockMovementY=!0)):p=Math.min(d,u),e.scaleX=p,e.scaleY=p):(e.scaleY=u,e.scaleX=d),e.setCoords(),a=Pr.getDimensions(e)),1!==p&&t.type}if(r.autoPos&&!t._interactive)if(0!==o.angle?e.angle=o.angle:0!==e.angle&&(e.angle=0),r.autoCenter)Pr.center(e,a,o,n);else{if(r.autoCenterH)Pr.centerHorizontal(e,a,o,n);else if(e.left=o.x,"text"===t.type&&!r.textBox)if("center"===r.textAlign)Pr.centerHorizontal(e,a,o,n);else if("right"===r.textAlign){let t=o.x+n.width-a.width;e.left=parseFloat(t.toFixed(2))}if(r.autoCenterV?Pr.centerVertical(e,a,o,n):e.top=o.y,0!==e.angle&&(r.autoCenterH||r.autoCenterV)){let i=new fabric.Rect({left:o.x,top:o.y,width:n.width,height:n.height,angle:e.angle}),a=r.autoCenterH?"center":"left",s=r.autoCenterV?"center":"top";"text"!==t.type||r.textBox||("center"===r.textAlign?a="center":"right"===r.textAlign&&(a="right"));let l=i.getPointByOrigin(a,s);e.setPositionByOrigin(l,a,s)}}}_addRefRect(e,t,i,r){if(Pr.isEditLayer(t,i.editorMode,i.editLayer)&&!i.cropMode)if(Pr.hasRefRect(t)){let e=this._getRefRect(t,i);r.add(e),r.uniformScaling=!1}else r.uniformScaling=!0}_getRefRect(e,t){let i=e._objectRef||new fabric.Rect,r=!("upload"===e.type&&e.params.crop);r||i.setControlsVisibility({mtr:!1});let o={visible:!0,lockUniScaling:!1,lockRotation:!r,lockMovementX:!1,lockMovementY:!1,lockScalingX:!1,lockScalingY:!1,hasControls:!0,lockScalingFlip:!0,selectable:!0,evented:!0};return o.left=void 0!==e.params.refX?e.params.refX:50,o.top=void 0!==e.params.refY?e.params.refY:50,o.width=e.params.refWidth||t.config.width-100,o.height=e.params.refHeight||t.config.height-100,o.scaleX=1,o.scaleY=1,o.angle=r&&void 0!==e.params.refAngle?e.params.refAngle:0,o.fill="#139cf6",o.opacity=.5,o._layerRef=e,i.setOptions(o),e._objectRef=i,i}_getImageUrl(e,t,i){if(i.cdnSize&&vr(e)){let r=Pr.getRefDimensions(t,i),o=Math.max(r.width,r.height),n=r.width>r.height;o=200*Math.ceil(o/200);let a=Math.min(3e3,o);return _r(e,n?a+"x":"x"+a)}return e}};var wo=e=>{const t=e.Image.filters,i=e.util.createClass;t.SwapColor=i(t.BaseFilter,{type:"SwapColor",fragmentSource:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec4 colorSource;\n uniform vec4 colorDestination;\n uniform float tolerance;\n varying vec2 vTexCoord;\n\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec3 sourceRGB = colorSource.rgb;\n vec3 destRGB = colorDestination.rgb;\n\n float colorDistance = length(sourceRGB - color.rgb);\n bool colorMatch = colorDistance < tolerance && color.a > 0.0;\n\n // Adjust the tolerance for alpha channel\n if (colorMatch && abs(colorSource.a - color.a) > 0.1) {\n colorMatch = false;\n }\n\n gl_FragColor = colorMatch ? vec4(destRGB, color.a) : color;\n }\n ",colorSource:"rgb(255, 0, 0)",colorDestination:"rgb(0, 255, 0)",tolerance:.1,applyTo2d:function(t){var i,r=t.imageData.data,o=r.length,n=new e.Color(this.colorSource).getSource(),a=new e.Color(this.colorDestination).getSource();if(this.tolerance<=.1)for(i=0;i0&&(r[i]=a[0],r[i+1]=a[1],r[i+2]=a[2])}},getUniformLocations:function(e,t){return{uColorSource:e.getUniformLocation(t,"colorSource"),uColorDestination:e.getUniformLocation(t,"colorDestination"),uTolerance:e.getUniformLocation(t,"tolerance")}},sendUniformData:function(t,i){var r=new e.Color(this.colorSource).getSource(),o=new e.Color(this.colorDestination).getSource();r[0]/=255,r[1]/=255,r[2]/=255,o[0]/=255,o[1]/=255,o[2]/=255,t.uniform4fv(i.uColorSource,r),t.uniform4fv(i.uColorDestination,o),t.uniform1f(i.uTolerance,this.tolerance)},isNeutralState:function(){return this.colorSource===this.colorDestination},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{colorSource:this.colorSource,colorDestination:this.colorDestination})}}),e.Image.filters.SwapColor.fromObject=e.Image.filters.BaseFilter.fromObject};var bo=class extends _o{render(e,t,i){e._object&&e._object.clipPath&&delete e._object.clipPath;let r={...e.params};if(e.params.option&&e.params.interactive){let i=Pr.getProductOption(e.params.option,t.options);i&&(i._layer=e)}if(e.params.optionColor){let i=Pr.getProductOption(e.params.optionColor,t.options);if(i&&i.value)if("color"===i.type)r.color=i.value;else if(i.values&&i.values.length){let e=i.values.filter((e=>e.value===i.value));e.length&&(r.color=e[0].color)}}return t.cropMode&&e.params.crop&&"upload"===e.type&&(r.autoScaleOverlay=!0),this._getImage(e,t,i,r).then((o=>{if(this._addRefRect(o,e,t,i),null==o)return o;r.color&&r.color!==e._color&&(this._colorize(o,r.color),e._color=r.color);let n=this._getOptions(e,t,r);return o.set(n),n.hasControls&&!Pr.isEditLayer(e,t.editorMode,t.editLayer)&&o.setControlsVisibility({mt:!1,mb:!1,ml:!1,mr:!1,bl:!n.lockScalingX,br:!n.lockScalingX,tl:!n.lockScalingY,tr:!n.lockScalingY,mtr:!n.lockRotation}),this._applyAutoParams(o,e,t,r),i.add(o),e._object=o,e._object}))}_getOptions(e,t,i=e.params){let r=super._getOptions(e,t,i);return i.opacity&&(r.opacity=i.opacity),r}_getImage(e,t,i,r=e.params){return e._object?Promise.resolve(e._object):new Promise(((i,o)=>{if(r.url&&-1!==r.url.indexOf(".svg"))fabric.loadSVGFromURL(r.url,((e,t)=>{void 0===e&&(a.warn("layer url not found: ",r.url),i(null));let o=fabric.util.groupSVGElements(e,t);i(o)}),null,{crossOrigin:"anonymous"});else{let o=this._getImageUrl(e.params.url,e,t);fabric.Image.fromURL(o,(e=>{if(void 0===e)return a.warn("layer url not found: ",r.url),void i(null);i(e)}),{crossOrigin:"anonymous"})}}))}_colorize(e,t){if("group"===e.type){let i=e.getObjects();for(let e=0;ee.value===i.value));if(e.length){let t=e[0];t.color&&(a.color=t.color),t.img&&a.textPattern&&!a.urlPattern&&(a.urlPattern=t.img)}}}if(e.params.textShadow&&e.params.optionTextShadowColor){let i=Pr.getProductOption(e.params.optionTextShadowColor,t.options);if(i&&i.value)if("color"===i.type)a.textShadowColor=i.value;else if(i.values&&i.values.length){let e=i.values.filter((e=>e.value===i.value));e.length&&(a.textShadowColor=e[0].color)}}if(e.params.textStroke&&e.params.optionTextStrokeColor){let i=Pr.getProductOption(e.params.optionTextStrokeColor,t.options);if(i&&i.value)if("color"===i.type)a.textStrokeColor=i.value;else if(i.values&&i.values.length){let e=i.values.filter((e=>e.value===i.value));e.length&&(a.textStrokeColor=e[0].color)}}if(a.textVertical){let e=[];for(let t=0;t{fabric.Image.fromURL(i.urlPattern,(o=>{if(void 0===o)return a.warn("text layer urlPattern not found: ",i.url),void r(null);t._pattern=new fabric.Pattern({source:o._element,repeat:"repeat",offsetY:i.patternOffsetY||0,offsetX:i.patternOffsetX||0}),t._pattern._url=i.urlPattern,e.set("fill",t._pattern),r(t._object)}),{crossOrigin:"anonymous"})}))}_degreeToRadian(e){return e*Math.PI/180}_describeEllipse([e,t],[i,r],[o,n],a){o=this._degreeToRadian(o),n=this._degreeToRadian(n),a=this._degreeToRadian(a);const s=([[e,t],[i,r]],[o,n])=>[e*o+t*n,i*o+r*n],l=([e,t],[i,r])=>[e+i,t+r];n%=2*Math.PI;const c=(p=a,[[Math.cos(p),-Math.sin(p)],[Math.sin(p),Math.cos(p)]]);var p;const[d,u]=l(s(c,[i*Math.cos(o),r*Math.sin(o)]),[e,t]),[h,m]=l(s(c,[i*Math.cos(o+n),r*Math.sin(o+n)]),[e,t]),g=n>Math.PI?1:0,f=n>0?1:0;return"M "+d+" "+u+" A "+[i,r,a/(2*Math.PI)*360,g,f,h,m].join(" ")}};var Co=class extends _o{render(e,t,i){if(e.params.maskLayers&&e.params.maskLayers.length>0){i.clipPath&&delete i.clipPath;let r=[];return i.forEachObject((o=>{o._layer&&this._isMaskedLayer(e.params.maskLayers,o._layer.name)&&r.push(this._getClipPath(e,t,i,o).then((e=>{e?o.clipPath=e:delete o.clipPath,o.dirty=!0})))})),Promise.all(r)}return this._getClipPath(e,t,i).then((r=>(r?(t.mask=!0,i.clipPath=r,e._object=r):(delete i.clipPath,delete e._object),r)))}_isMaskedLayer(e,t){if(-1!==e.indexOf(t))return!0;for(let i=0;i{fabric.loadSVGFromURL(e.params.url,((i,r)=>{if(i){let e=fabric.util.groupSVGElements(i,r);t(e)}else a.warn("svg mask not found",e.params.url),t(null)}))})),n.then((i=>{if(i){o._url=e.params.url,o.width=i.width,o.height=i.height;let n=e.params.padding||3;if(e.params.maskLayers&&0!==e.params.maskLayers.length?r&&(o.scaleX=(r.width-n)/i.width,o.scaleY=(r.height-n)/i.height):(o.scaleX=(t.config.width-n)/i.width,o.scaleY=(t.config.height-n)/i.height),e.params.ratio||!0){let e=Math.min(o.scaleX,o.scaleY);o.scaleX=e,o.scaleY=e}r&&(o.left=-i.width*o.scaleX/2,o.top=-i.height*o.scaleY/2),i.setOptions(o)}return i}))}a.warn("svg mask missing url",e)}return Promise.resolve(n)}};var Eo=class extends bo{_findProductUrl(e,t){let i=t.product;if(e.params.imgPos){let t=parseInt(e.params.imgPos);if(!isNaN(t)&&i.images.length>t-1)return i.images[t-1]}if(e.params.variant&&t.variantId)for(let e=0;e{let n=this._getImageUrl(i,e,t);fabric.Image.fromURL(n,(t=>{void 0===t&&(a.warn("product url not found: ",i),r(null)),e._url=i,r(t)}),{crossOrigin:"anonymous"})}))}else a.warn("missing product in render context");return Promise.resolve(null)}};var Io=class extends bo{_getImage(e,t,i,r=e.params){if(r.option){let o=Pr.getProductOption(r.option,t.options);if(o){if(o._layer=e,o.value){let n=o.value;if(o.params.multiple||-1!==n.indexOf(",")||r.fileIndex){let e=n.split(","),t=r.fileIndex||e.length;if(t-=1,!(e.length>t))return Promise.resolve(null);n=e[t]}let s=!1;if(e.params.layerEditor?e._context||(e._context=t,e._canvas=i,s=!0):e._context&&(delete e._context,s=!0),r.crop&&o.params.optionDimension&&o.params.dimensionCrop){let i=Pr.getProductOption(o.params.optionDimension,t.options);if(i&&i.visible&&i._controller&&i._controller.x&&i._controller.y&&(!i.errors||0===i.errors.length)){let r=Pr.getRefDimensions(e,t),o=Math.round(r.width/r.height*100)/100,n=Math.round(i._controller.x/i._controller.y*100)/100;o!==n&&(e._cropWidth=e._cropWidth||e.params.refWidth||t.config.width,e._cropHeight=e._cropHeight||e.params.refHeight||t.config.height,n>1?(e.params.refWidth=e._cropWidth,e.params.refHeight=e._cropWidth/n):(e.params.refHeight=e._cropHeight,e.params.refWidth=e._cropHeight*n),e.params.refRect=!0,e.params.refX=t.config.width/2-e.params.refWidth/2,e.params.refY=t.config.height/2-e.params.refHeight/2,!1!==e._autoCrop?t.autoCrop=e:delete e._autoCrop,dr.productCropOverlay=!1)}}return s&&t.productForm&&t.productForm.dispatchEvent(new CustomEvent("options:render",{detail:o,cancelable:!0,bubbles:!0})),!e._object||e._url!==n||!isNaN(e.params.rotate)&&e._rotate!==e.params.rotate||e.params.filters&&e._filters&&e._filters.length!==e.params.filters.length?new Promise(((i,o)=>{e._interactive&&(delete e._interactive,delete e._interactiveScaled),e.params.crop&&(t.autoCrop=e);const s=o=>{if(void 0===o&&(a.warn("upload url not found: ",n),i(null)),e._url=n,e._rotate=0,e.params.autoRotate){let i=Pr.getRefDimensions(e,t),r=o;r.widthi.height?e._rotate=90:r.width>r.height&&i.width{this._applyFilters(t,e).then((()=>{i(t)}))}))}else this._applyFilters(o,e).then((()=>{i(o)}))};-1!==n.indexOf(".svg")?fabric.loadSVGFromURL(n,((o,l)=>{void 0===o&&(a.warn("upload url not found: ",n),i(null));let c=fabric.util.groupSVGElements(o,l);(r.color||r.optionColor)&&(delete e._color,i(c));let p=Math.max(t.config.width/c.viewBoxWidth,t.config.height/c.viewBoxHeight),d=c.toDataURL({multiplier:Math.min(10,p),format:"png"});fabric.Image.fromURL(d,(e=>{s(e)}))}),null,{crossOrigin:"anonymous"}):fabric.Image.fromURL(n,s,{crossOrigin:"anonymous"})})):(e.params.autoRotate&&0!==e._rotate&&r.canvasRotate&&(t.canvasRotate=-1*e._rotate),Promise.resolve(e._object))}}else a.warn("no upload option found for layer",e)}else a.warn("missing option for layer",e);return Promise.resolve(null)}_applyFilters(e,t){let i=Promise.resolve(null);if(t.params.filters&&t.params.filters.length){let r=[...t.params.filters];if(e.width>fabric.textureSize||e.height>fabric.textureSize){let t=Math.max(e.height,e.width);fabric.textureSize=t>4096?t:4096}if(!t.params.urlFilter||t._urlFilterImage&&t._urlFilter===t.params.urlFilter||(i=i.then((()=>new Promise(((e,i)=>{fabric.Image.fromURL(t.params.urlFilter,(i=>{i&&(t._urlFilter=t.params.urlFilter,t._urlFilterImage=i),e()}),{crossOrigin:"anonymous"})}))))),t.params.urlFilter&&-1!==r.indexOf("pattern")&&(i=i.then((()=>new Promise(((i,r)=>{let o=t._urlFilterImage.getElement(),n=e.getScaledWidth(),a=e.getScaledHeight(),s=new fabric.Rect({width:n,height:a});s.set("fill",new fabric.Pattern({source:o,repeat:"repeat"}));let l=s.toDataURL();fabric.Image.fromURL(l,(e=>{e&&(t._urlFilterImagePattern=e),i()}))})))),-1!==r.indexOf("removeWhite")&&(i=i.then((()=>new Promise(((i,r)=>{e.applyFilters([new fabric.Image.filters.RemoveColor({threshold:.2})]),fabric.Image.fromURL(e.toDataURL(),(e=>{e&&(t._urlFilterImageBlend=e,t._removeWhiteSkip=!0),i()}))})))))),-1!==r.indexOf("removeBg")&&t.params.removeBgKey){let r=e.getSrc(!1),o=r.substring(r.lastIndexOf(".")).toLowerCase();".jpg"!==o&&".jpeg"!==o&&".png"!==o||(i=i.then((()=>new Promise(((i,o)=>{new n("https://api.remove.bg/v1.0/removebg",{method:"POST",responseType:"blob",headers:{"X-API-Key":t.params.removeBgKey,"Content-type":"application/x-www-form-urlencoded"},data:{image_url:r,size:t.params.removeBgSize||window.clRemoveBgSize||"auto",type:"auto"}}).then((r=>{const o=URL.createObjectURL(r.data);let n=new Image;n.onload=()=>{e.setElement(n),t._removeBg=!0,i()},n.src=o})).catch((e=>{a.error(e),i()}))})))))}i.then((()=>{e.filters||(e.filters=[]);for(let i=0;i(e._sort||100)>(t._sort||100)?1:-1)),t._filters=[...r],e.applyFilters()}))}return i}};var So=class extends bo{_getImage(e,t,i,r=e.params){let o=r.text||"";if(r.option){let e=Pr.getProductOption(r.option,t.options);e&&e.value&&(o=e.value)}if(o){let i=a.getLevel();if(i<=a.levels.DEBUG&&console.time("====> QR RENDER"),e._object&&e._qrText===o)return i<=a.levels.DEBUG&&console.timeEnd("====> QR RENDER"),Promise.resolve(e._object);{let n=[t.assets+"/static/lib/easyqrcodejs/easy.qrcode.min.js"];return $r.loadOnce(n,"qrcode",{async:!1}).then((()=>new Promise(((n,s)=>{let l=(t,r)=>{i<=a.levels.DEBUG&&console.timeEnd("====> QR RENDER"),fabric.Image.fromURL(r,(t=>{if(void 0===t)return a.warn("qr image invalid"),void n(null);e._qrText=o,n(t)}))};if(e._qrDiv||(e._qrDiv=document.createElement("div")),t.editorMode&&e._qrCode&&(e._qrCode.clear(),delete e._qrCode),e._qrCode)e._qrCode._htOption.onRenderingEnd=l,e._qrCode._oDrawing._htOption.onRenderingEnd=l,e._qrCode.makeCode(o);else{let i=Math.min(t.config.width/2,1e3),n={text:o,width:i,height:i,onRenderingEnd:l};r.url&&(n.logo=r.url,n.crossOrigin="anonymous"),e._qrCode=new QRCode(e._qrDiv,n)}}))))}}return Promise.resolve(null)}};class Po{}Po.renderers={},Po.renderers.overlay=new bo,Po.renderers.text=new xo,Po.renderers.mask=new Co,Po.renderers.product=new Eo,Po.renderers.upload=new Io,Po.renderers.qrcode=new So;var Oo=Po;var Mo=class{destroy(){this.element.removeChild(this._wrapper)}render(){ee((this.settings.product,this.config.uuid,te`
`),this._wrapper)}_renderContext(){return{config:this.previewConfig,options:this.config.options,product:this.settings.product,assets:this.settings.assets,productForm:this._productForm,variantId:this.settings.variantId,editorMode:this.settings.editorMode,editLayer:this.settings.editLayer,cropMode:this.settings.cropMode,cropLayer:this.settings.cropLayer,mask:!1,cdnSize:dr.previewCdnSize}}renderPreview(){let e=()=>{let e=a.getLevel();e<=a.levels.DEBUG&&console.time("====> RENDER PREVIEW "+this.previewConfig.position);let t=this._renderContext(),i=null;if(!this.static){let e=this._canvas.getActiveObject();this._canvas.discardActiveObject(),e&&(i=e._layer)}return this._rotateGroup&&this._rotateGroup.forEachObject((e=>{this._rotateGroup.remove(e)})),this._canvas.clear(),this._renderLayers(this.previewConfig.layers,t).then((()=>(this._canvas.clipPath&&!t.mask&&delete this._canvas.clipPath,i?this.selectLayer(i.name,!1):Pr.hasEditLayer(this.settings.editorMode,this.settings.editLayer)&&this.selectLayer(this.settings.editLayer,!1),void 0!==t.canvasRotate&&(this._rotateGroup=new fabric.Group(this._canvas.getObjects()),this._rotateGroup.rotate(t.canvasRotate),this._rotateGroup.setCoords()),this._canvas.renderAll(),e<=a.levels.DEBUG&&console.timeEnd("====> RENDER PREVIEW "+this.previewConfig.position),this._responsiveCanvasHeight(),this._syncThemeGallery(),this._triggerEvent("preview:rendered",this),t)))};return null==this._renderQueue&&(this._renderQueue=Promise.resolve()),this._renderQueue=this._renderQueue.then((()=>this._loadUsedFonts())).then((()=>e())),this._renderQueue}downloadBlob(e,t){const i=URL.createObjectURL(e),r=document.createElement("a");r.href=i,r.download=t||"download";const o=function(e){setTimeout((()=>{URL.revokeObjectURL(i),this.removeEventListener("click",o)}),150)};return r.addEventListener("click",o,!1),r.click(),r}export(t,i,r,o,n="jpeg",s=.8,l=!0){if(this._canvas){let p=a.getLevel();p<=a.levels.DEBUG&&console.time("====> EXPORT PREVIEW");let u,h=!1,m=0;if(this._canvas.forEachObject((e=>{e._layer&&(e.visible?!0===e._layer.params[o]?(e.visible=!1,e._visible=!0,h=!0):"product"!==e._layer.type&&m++:e._layer.params.exportOnly&&(e.visible=e._layer._visibleCondition,e._visible=!1,!0===e._layer.params[o]&&(e.visible=!1),h=!0))})),l&&0===m)return a.debug("==> no visible layers - skipping export"),h&&this._canvas.forEachObject((e=>{void 0!==e._visible&&(e.visible=e._visible,delete e._visible)})),null;if(this._canvas.renderAll(),"svg"===n){let e={width:t.width,height:t.height};i&&(e.viewBox={x:i.x,y:i.y,width:i.width,height:i.height});let o=this._canvas.toSVG(e);if(dr.previewCdnSize){let e,t=/xlink:href="([^"]+)"/g,i=[];for(;e=t.exec(o);)-1!==e[1].indexOf("cdn.shopify.com")&&i.push(e[1]);for(const e of i){let t=e.replace(/_x\d+\./,".").replace(/_\d+x\./,".");t!==e&&(a.debug("SVG export removed size from CDN url: ",e,t),o=o.replace(e,t))}}var c=[];for(let e=0;e`@import url("${e}");`)).join("\n")}\n ]]>`,t=o.indexOf("");o=o.substring(0,t)+e+o.substring(t)}u=r?new Blob([o],{type:"image/svg+xml"}):o}else{let o={multiplier:t.width/this._canvas.getWidth(),format:n,quality:s};i&&(o.left=i.x/o.multiplier,o.top=i.y/o.multiplier,o.width=i.width/o.multiplier,o.height=i.height/o.multiplier);let a=this._canvas.toDataURL(o);u=r?e(go)(a):a}return h&&(this._canvas.forEachObject((e=>{void 0!==e._visible&&(e.visible=e._visible,delete e._visible)})),this._canvas.renderAll()),p<=a.levels.DEBUG&&console.timeEnd("====> EXPORT PREVIEW"),u}return null}exportLayer(t,i,r="jpeg",o=.8){let n=this._canvas.getObjects();for(let s=0;s0&&this.selectLayer(e,t,o.layers))return!0;if(o.name===e&&o._object&&(Pr.isEditLayer(o,this.settings.editorMode,this.settings.editLayer)&&(this._canvas.preserveObjectStacking=!1,delete o._interactive),this._canvas.contains(o._object)))return this._canvas.setActiveObject(o._object),t&&this._canvas.renderAll(),!0}return!1}deSelect(e=!0){this._canvas.discardActiveObject(),this.settings.editorMode&&!this._canvas.preserveObjectStacking&&(this._canvas.preserveObjectStacking=!0),e&&this._canvas.renderAll()}_init(){this._wrapper=document.createElement("div"),this._wrapper.className=this.settings.classNamePrefix+"--preview-wrapper",this._wrapper.setAttribute("id",this.config.uuid+"_preview"),this._wrapper.style.width="100%",this.settings.position?(this.element.insertAdjacentElement(this.settings.position,this._wrapper),this.element!==this._wrapper.parentNode&&(this.element=this._wrapper.parentNode)):this.element.appendChild(this._wrapper),this.render(),this._preview=this._wrapper.querySelector("."+this.settings.classNamePrefix+"--preview"),this._preview.classList.add("cl-hide");let e=this._wrapper.querySelector("."+this.settings.classNamePrefix+"--canvas");this.static=this._isStatic(),fabric.devicePixelRatio<2&&(fabric.devicePixelRatio=2),window.clPreviewRatio&&(fabric.devicePixelRatio=parseInt(window.clPreviewRatio)),fabric.Object.NUM_FRACTION_DIGITS=8,fabric.enableGLFiltering=!1,window.clPreviewGLFilter&&(fabric.enableGLFiltering=!0),this.static?(this._canvas=new fabric.StaticCanvas(e),this.settings.zoom?.enabled&&this._watchZoom()):(fabric.isTouchSupported&&this._patchCanvasTouchScroll(),this._updateCanvasControls(),this._canvas=new fabric.Canvas(e,{selection:!1,preserveObjectStacking:!0,allowTouchScrolling:!0}),this._subscribeCanvasEvents()),this._setDimensions(),this.renderPreview().then((()=>{this._watchFormChanges(),this._watchWindowResize(),this._watchWindowScroll(),this._preview.classList.remove("cl-hide")})).catch((e=>{a.error("[live-options] failed render preview",e)}))}_setDimensions(){let e=this._canvas.getZoom();1!==e&&this._canvas.setZoom(1);let t=fabric.devicePixelRatio,i=this.previewConfig.width*this.previewConfig.height,r=window.clPreviewMaxRetina||9e6;t>1&&i>r&&o.isMobile(o.getAgent())&&(this._canvas.enableRetinaScaling=!1),this._canvas.setDimensions({width:this.previewConfig.width,height:this.previewConfig.height}),1!==e&&this._resizeCanvas()}_renderLayers(e,t){let i=Promise.resolve();for(let r=0;rthis._renderLayer(o,t)))}return i}_renderLayer(e,t){let i=!0;if(e.conditions&&e.conditions.length&&(i=this.conditionsEngine.evaluateConditions(e.conditions,e.conditionMode||yo.MODE.AND,"layer.name="+e.name)),this.settings.editorMode&&this.visibleEditor.hasOwnProperty(e.name)&&(i=this.visibleEditor[e.name]),this.visible[e.name]=i,e.params.preload&&"overlay"===e.type&&(e._visible=i,i=!0),e.params.exportOnly&&(e._visible=Pr.isEditLayer(e,this.settings.editorMode,this.settings.editLayer),e._visibleCondition=i,i=!0),i){if(a.debug("rendering layer: ",e),e.layers&&e.layers.length>0)return this._renderLayers(e.layers,t);let i=Oo.renderers[e.type];if(i)return i.render(e,t,this._canvas)}return Promise.resolve()}_loadUsedFonts(){let e=[];for(let t=0;t0?d.loadFontsByName(e):Promise.resolve(!0)}_isStatic(){if(this.settings.editorMode)return!1;for(let e=0;ethis._optionChanged(e))),this._productForm.addEventListener("option:crop",(e=>this._optionCrop(e))),this._productForm.addEventListener("option:export",(e=>this._optionExport(e))),this._productForm.addEventListener("option:variant_changed",(e=>this._variantChanged(e)))):a.warn("product-preview no productForm found for config: "+this.config.uuid)}_subscribeCanvasEvents(){let e=a.getLevel();this._canvas.on("object:modified",(t=>{let i=t.target;if(e<=a.levels.TRACE&&a.debug("object:modified",i),i._layer){let t=i._layer,r=t.params;r.x=Math.round(i.left),r.y=Math.round(i.top),e<=a.levels.TRACE&&a.debug("=> layer x,y = ",r.x,r.y),r.crop?(r.scaleX=i.scaleX,r.scaleY=i.scaleY):(r.scaleX=parseFloat(i.scaleX.toFixed(3)),r.scaleY=parseFloat(i.scaleY.toFixed(3))),0!==i.angle&&(r.angle=Math.round(i.angle)),t._editor&&(o.merge(t._editor,t.params,["x","y","scaleX","scaleY","angle"]),this._productForm&&this._productForm.dispatchEvent(new CustomEvent("options:render",{detail:null,cancelable:!0,bubbles:!0}))),this._triggerEvent("layer:changed",t)}else if(i._layerRef){let e=i._layerRef.params;if(e.refX=Math.round(i.left),e.refY=Math.round(i.top),e.refWidth=Math.round(i.getScaledWidth()),e.refHeight=Math.round(i.getScaledHeight()),0!==i.angle){e.refAngle=Math.round(i.angle);let t=4;(e.refAngle<=t||e.refAngle>=360-t)&&(e.refAngle=0)}else e.refAngle=0;a.debug("updated layer rectRef params",e),this._triggerEvent("layer:changed",i._layerRef),this.renderPreview()}})),this._canvas.on("object:moving",(t=>{let i=t.target;if(e<=a.levels.TRACE&&a.debug("object:moving",i),i._layer){let t=i._layer,r=t.params,o=Pr.isCropLayer(t,this.settings.cropLayer,this.settings.cropLayer);if(o||r.interactive&&!Pr.isEditLayer(t,this.settings.editorMode,this.settings.editLayer)){t._interactive=!0;let n={x:0,y:0},s={x:this.previewConfig.width,y:this.previewConfig.height},l={width:this.previewConfig.width,height:this.previewConfig.height};Pr.hasRefRect(t)&&(n.x=r.refX,n.y=r.refY,s.x=r.refX+r.refWidth,s.y=r.refY+r.refHeight,l.width=r.refWidth,l.height=r.refHeight);let c=i.getBoundingRect(!0,!0);if(e<=a.levels.TRACE&&a.debug("boundingRect = ",c),r.interactiveBox||o){let e=r.autoScaleOverlay||o;e&&t._interactiveScaled&&(c.width reset object.left = ",i.left)):c.left>s.x&&(0!==i.angle?i.setPositionByOrigin({x:s.x+c.width/2,y:i.getCenterPoint().y},"center","center"):i.left=s.x,e<=a.levels.TRACE&&a.debug("=> reset object.left = ",i.left)),c.top reset object.top = ",i.left)):c.top>s.y&&(0!==i.angle?i.setPositionByOrigin({x:i.getCenterPoint().x,y:s.y+c.height/2},"center","center"):i.top=s.y,e<=a.levels.TRACE&&a.debug("=> reset object.top = ",i.left))}}}));const t=t=>{let i=t.target;if(e<=a.levels.TRACE&&a.debug("object:scaling",i),i._layer){let r=i._layer,o=r.params;if(o.interactive&&!Pr.isEditLayer(r,this.settings.editorMode,this.settings.editLayer)&&(r._interactive=!0,r._interactiveScaled=!0,o.resizable&&(i.lockMovementX=!1,i.lockMovementY=!1),o.interactiveBox)){let n={x:0,y:0},s={x:this.previewConfig.width,y:this.previewConfig.height};Pr.hasRefRect(r)&&(n.x=o.refX,n.y=o.refY,s.x=o.refX+o.refWidth,s.y=o.refY+o.refHeight);let l=i.getBoundingRect(!0,!0);e<=a.levels.TRACE&&a.debug("boundingRect = ",l);let c=null,p=20;if(t.transform&&t.transform.corner&&("tr"==t.transform.corner?(n.x-=p,s.y+=p):"tl"==t.transform.corner?(s.x+=p,s.y+=p):"br"==t.transform.corner?(n.x-=p,n.y-=p):"bl"==t.transform.corner&&(s.x+=p,n.y-=p)),Math.floor(l.left)s.x){let e=s.x-l.left;c=e/(l.width/i.scaleX),0!==i.angle?i.setPositionByOrigin({x:s.x-e+l.width/2,y:i.getCenterPoint().y},"center","center"):i.left=s.x-e}if(Math.floor(l.top)s.y){let e=s.y-l.top;c=e/(l.height/i.scaleY),0!==i.angle?i.setPositionByOrigin({x:i.getCenterPoint().x,y:s.y-e+l.height/2},"center","center"):i.top=s.y-e}null!=c&&(i.scaleX=c,i.scaleY=c,i.setCoords(),this._canvas.requestRenderAll(),e<=a.levels.TRACE&&a.debug("=> reset object.scale = ",c))}}};this._canvas.on("object:scaling",t),this._canvas.on("object:scaled",t),this._canvas.on("selection:created",(t=>{let i=t.selected?t.selected[0]:null;e<=a.levels.TRACE&&a.debug("selection:created",i),i._layer?this._triggerEvent("layer:selected",i._layer):i._layerRef&&this._triggerEvent("layer:selected",i._layerRef)})),this._canvas.on("selection:updated",(t=>{let i=t.selected?t.selected[0]:null;e<=a.levels.TRACE&&a.debug("selection:updated",i),i._layer?this._triggerEvent("layer:selected",i._layer):i._layerRef&&this._triggerEvent("layer:selected",i._layerRef)})),this._canvas.on("selection:cleared",(t=>{e<=a.levels.TRACE&&a.debug("selection:cleared")}))}_variantChanged(e){this.settings.variantId=e.detail.variantId,this._clearVisibleEditor(),this.renderPreview().then((t=>{this.static||!this.settings.cropMode&&t.autoCrop&&this._optionCrop(e,t.autoCrop)}))}_optionChanged(e){let t=e.detail;this._clearVisibleEditor(),this.renderPreview().then((i=>{this.static||(!this.settings.cropMode&&i.autoCrop?this._optionCrop(e,i.autoCrop):t._layer&&t._layer.params.interactive&&this.selectLayer(t._layer.name,!1))}))}_optionCrop(e,t){let i=e.detail;if(this.active){if(!t){let e=this._canvas.getObjects();for(let r=0;rthis._canvas.getZoom()){s=Math.min(s,2);let e=n.x+o.width/2,t=n.y+o.height/2,i=-e*s+this._canvas.getWidth()/2,r=-t*s+this._canvas.getHeight()/2;this._canvas.setViewportTransform([s,0,0,s,i,r])}r.width=e.refWidth,r.height=e.refHeight}if(this._cropEl=document.createElement("div"),!1!==window.clCropHelp){this._cropEl.classList.add("cl-po--crop-help"),"ontouchstart"in window||navigator.msMaxTouchPoints?this._cropEl.classList.add("touch"):this._cropEl.classList.add("cursor");const e=()=>{this._cropEl&&(this._cropEl.classList.remove("cl-po--crop-help"),this._canvas.off("object:moving",e),window.clCropHelp=!1)};this._canvas.on("object:moving",e),setTimeout(e,9e3)}const s=()=>{t._interactive=!0,t._interactiveScaled=!0,this._canvas.fire("object:modified",{target:t._object}),this._optionCrop({detail:i},t)};this._productForm.addEventListener("option:crop:apply",(e=>{this.settings.cropMode&&s()}),{once:!0}),ee(fo((e=>{let i=t._object;t._interactiveScaled=!0;let o=Math.min(r.width,r.height)/10,n=o/i.width;if(e)i.scaleX+=n,i.scaleY+=n,i.left-=o/2,i.top-=o/2;else{if(i.scaleX-=n,i.scaleY-=n,t.params.autoScaleOverlay&&(Math.round(i.getScaledWidth()){t.params.rotate=t.params.rotate|t._rotate|0,t.params.rotate+=e,t.params.rotate=t.params.rotate%360,this.renderPreview()}),(()=>{o.merge(t.params,n),o.merge(t,a),this._optionCrop({detail:i})}),s),this._cropEl),this._wrapper.appendChild(this._cropEl),this._highlight(!0);let l=this._wrapper.getBoundingClientRect();l.top<0&&window.scrollTo&&window.scrollTo(l.left,l.top+window.scrollY-50)}this._canvas.discardActiveObject(),this.renderPreview().then((()=>{this.settings.cropMode&&this.selectLayer(this.settings.cropLayer)}))}}_optionExport(e){let t=e.detail,i=this.previewConfig;if(t.params.exportView&&t.params.exportView!==i.name)return;let r=!(!i.exportConfig.crop||!i.exportConfig.cropConfig.width)&&i.exportConfig.cropConfig,o=i.exportConfig.originalFormat||"png",n=this.export({width:i.width,height:i.height},r,!0,"excludeOriginal",o,.8,!1);n&&this.downloadBlob(n,(t.params.exportName||i.name)+"."+o)}_clearVisibleEditor(){this.settings.editorMode&&(this.visibleEditor={})}_optionLayerUpdate(e){if(e._layer&&e._layer._object){let t=this._canvas.getObjects().indexOf(e._layer._object);return this._canvas.remove(e._layer._object),this._renderLayer(e._layer).then((e=>{this._canvas.moveTo(e,t)}))}}_watchWindowResize(){let e=o.debounced(200,(e=>{this._resizeCanvas(),this.settings.stickyMode&&this._stickyPreview(!0)}));this._resizeCanvas(),window.addEventListener("resize",e)}_watchWindowScroll(){let e=!1;window.addEventListener("scroll",(()=>{e||(this.settings.sticky||this._highlightEl)&&(window.requestAnimationFrame((()=>{this.settings.sticky&&this._stickyPreview(),this._highlightEl&&this._highlight(!0),e=!1})),e=!0)})),this.settings.sticky&&window.addEventListener("preview:active",(()=>this._stickyPreview()))}_getContainerWidth(){let e=this._wrapper.offsetWidth,t=this._wrapper;for(;0===e&&t.parentNode;)t=t.parentNode,t.offsetWidth>0&&(e=o.findInnerDimensions(t).width);return e}_responsiveCanvasHeight(){if(!this.settings.cropMode){let e=0;this._canvas.forEachObject((t=>{if(t.visible&&t._layer&&t._layer.params.responsive){let i=t.getBoundingRect(),r=i.top+i.height;r>e&&(e=r)}}));let t=this.previewConfig.height*this._canvas.getZoom();e>0&&ethis.settings.maxHeight&&(o.height=this.settings.maxHeight,o.width=o.height*e,i=o.width/this._canvas.getWidth(),r=this._canvas.getZoom()*i),this._canvas.setDimensions(o),this._canvas.setZoom(r)}this._highlightEl&&this._highlight(!0)}_highlight(e){if(dr.productCropOverlay&&!o.findParent(this.element,".cl-po--popup-preview")||(e=!1),!e&&this._highlightEl&&(document.body.removeChild(this._highlightEl),delete this._highlightEl,document.body.classList.remove("cl-highlight")),e){let e=!1;this._highlightEl||(this._highlightEl=document.createElement("div"),this._highlightEl.className="cl-po--preview-highlight",e=!0);let t=o.getCalculatedPosition(this._wrapper);const i=20,r=t.right-t.left+i,n=t.bottom-t.top+i;this._highlightEl.style.display="block",this._highlightEl.style.position="absolute",this._highlightEl.style.width=`${r}px`,this._highlightEl.style.height=`${n}px`,this._highlightEl.style.top=t.top-i/2+"px",this._highlightEl.style.left=t.left-i/2+"px",e&&(document.body.appendChild(this._highlightEl),document.body.classList.add("cl-highlight"))}}_stickyPreview(e=!1){let t=this._canvas.lowerCanvasEl,i=t.getBoundingClientRect(),r=this._stickyMaxTop||0;if(i.top>r||!this.active||this.settings.cropMode||this.settings.zoomMode||0===i.width||0===i.height)this.settings.stickyMode&&(a.debug("----\x3e sticky end",t),this.element.removeEventListener("layer:changed",this._syncSticky),this.element.removeEventListener("preview:rendered",this._syncSticky),document.body.removeChild(this._stickyEl),delete this._stickyEl,delete this._stickyImgEl,delete this._stickyTarget,delete this._stickyMaxTop,this.settings.stickyMode=!1);else{let r,n,s=!1,l=window.clStickyMobileSize||this.settings.stickyMobileSize||25;this._stickyTarget=this._stickyTarget||document.querySelector("#"+this.config.uuid);let c=this._stickyTarget.getBoundingClientRect();if(c.top>i.bottom&&window.innerWidth<=768&&(s=!0,r=window.innerHeight/100*l,n="overlay"===this.settings.stickyMobile?r:0),this.settings.stickyMode){let t=this._stickyEl.getBoundingClientRect();if(c.bottom>0){let e=t.height-c.bottom;this._stickyEl.style.top=e>0?-1*e+"px":"0px"}else this._stickyEl.style.top=-1*(t.height+5)+"px";e&&(s?(this._stickyEl.classList.add("mobile"),this._stickyEl.classList.add(this.settings.stickyMobile),this._stickyEl.style.removeProperty("left"),this._stickyEl.style.removeProperty("width"),this._stickyImgEl.style.maxHeight=r+"px",this._stickyMaxTop=-1*(i.height-n)):(this._stickyEl.classList.remove("mobile"),this._stickyImgEl.style.removeProperty("height"),this._stickyEl.style.left=i.left+"px",this._stickyEl.style.width=i.width+"px"))}else if(a.trace("---\x3e sticky check"+c.bottom+" > "+i.bottom),c.bottom>i.bottom){if(s){if(i.bottom>n)return;this._stickyMaxTop=-1*(i.height-n)}this._stickyEl=document.createElement("div"),this._stickyEl.className="cl-po--preview-sticky",this._stickyEl.style.position="fixed",this._stickyImgEl=document.createElement("img"),s?(this._stickyEl.classList.add("mobile"),this._stickyEl.classList.add(this.settings.stickyMobile),this._stickyImgEl.style.maxHeight=r+"px"):(this._stickyEl.style.left=i.left+"px",this._stickyEl.style.width=i.width+"px"),this._stickyEl.style.top="0px",this._stickyEl.addEventListener("click",(e=>{let i=o.getCalculatedPosition(t);window.scroll({top:i.top-50,behavior:"smooth"})})),this._stickyEl.appendChild(this._stickyImgEl),this._syncSticky(),document.body.appendChild(this._stickyEl),this.element.addEventListener("layer:changed",this._syncSticky),this.element.addEventListener("preview:rendered",this._syncSticky),this.settings.stickyMode=!0,a.debug("--\x3e sticky start",this._stickyEl,this._stickyTarget)}}}_syncThemeGallery(){if(dr.themeGallery&&!this.settings.editorMode){if(this.shopifyStore.isTheme("Dawn")){let e=o.findParent(this.element,"media-gallery");if(e&&e.setActiveMedia){let t=o.findParent(this.element,".product__media-item");if(t&&t.dataset.mediaId){this.element.scrollIntoView=function(){},e.setActiveMedia(t.dataset.mediaId,!0);let i=o.findParent(this.element,".slider");return void(i&&i.scrollTo&&(i.scrollLeft=0))}}}try{if(!1!==this._themeGalleryImgEl){if(this._themeGalleryVariant&&this.settings.variantId!==this._themeGalleryVariant)return void(this._themeGalleryVariant=this.settings.variantId);if(!this._themeGalleryImgEl)if(void 0===this.previewConfig.views||this.previewConfig.gallery&&!0!==this.config.previewConfig.galleryConfig.hideThumbnails)this._themeGalleryImgEl=!1;else{let t;if(this.settings.product.media&&this.settings.product.media.length){var e=0;for(let t=0;ti.params.imgPos-1&&(e=i.params.imgPos-1):i.params.variant&&delete this._themeGalleryVariant;break}}t=this.settings.product.media[e]}if(t){let e,i=o.pathBaseName(t.src,!1);if(this.settings.selectorThumbnail&&(e=document.querySelectorAll(this.settings.selectorThumbnail),a.debug("found "+e.length+" gallery thumbnails with selector: ",this.settings.selectorThumbnail,e)),!e||0===e.length){e=[];let t=document.querySelectorAll('img[src*="'+i+'"], img[data-src*="'+i+'"], img[data-srcset*="'+i+'"]');if(t.length>0)for(let i=0;ithis._themeGalleryImgEl.click()),300):this._themeGalleryImgEl.click(),e&&setTimeout((()=>window.dispatchEvent(new Event("resize"))),500)}}}catch(e){a.error("error syncing theme gallery ",e)}}}_triggerEvent(e,t){const i=new CustomEvent(e,{detail:t,cancelable:!0,bubbles:!0});this.element.dispatchEvent(i)}_patchCanvasTouchScroll(){window.clCanvasTouchStart||(window.clCanvasTouchStart=fabric.Canvas.prototype._onTouchStart,fabric.util.object.extend(fabric.Canvas.prototype,{_onTouchStart:function(e){var t=this.findTarget(e);(!this.allowTouchScrolling||t||this.isDrawingMode)&&window.clCanvasTouchStart.call(this,e)}}))}_updateCanvasControls(){var e="#b2ccff";const t=e=>("#"===e.charAt(0)&&(e="%23"+e.substring(1)),"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath d='M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm4.82-4.924a7 7 0 1 0-1.852 1.266l-.975-1.755A5 5 0 1 1 17 12h-3l2.82 5.076z' fill='"+e+"'/%3E%3C/svg%3E"),i=(e,t,i,o,n)=>{e.save(),e.translate(t,i),e.rotate(fabric.util.degreesToRadians(o.angle)),e.drawImage(r,-n/2,-n/2,n,n),e.restore()};var r=document.createElement("img");r.src=t(e),r.dataset.fill=e,fabric.Object.prototype.controls.mtr=new fabric.Control({x:0,y:-.5,offsetY:-40,cursorStyle:"crosshair",actionHandler:fabric.controlsUtils.rotationWithSnapping,actionName:"rotate",render:function(e,o,n,a,s){const l=1.5*s.cornerSize;r.dataset.fill!=e.fillStyle&&(r.onload=function(){i(e,o,n,s,l)},r.dataset.fill=e.fillStyle,r.src=t(e.fillStyle)),i(e,o,n,!1,l)},cornerSize:28,withConnection:!0})}_watchZoom(){let e=this._canvas.getElement(),t=e.parentElement;this.settings.zoom.factor>fabric.devicePixelRatio&&(fabric.devicePixelRatio=Math.min(4,this.settings.zoom.factor));const i=i=>{if(!this.settings.zoomMode){t.style.width=e.style.width,t.style.height=e.style.height;let i=this._canvas.enableRetinaScaling?fabric.devicePixelRatio:1,r=e.width/i*this.settings.zoom.factor,o=e.height/i*this.settings.zoom.factor,n=t.offsetWidth,s=t.offsetHeight;this._zoomCalc={xRatio:(t.offsetWidth-r)/n,yRatio:(t.offsetHeight-o)/s,offset:t.getBoundingClientRect()},e.style.width=r+"px",e.style.height=r+"px",t.classList.add("cl-po--zoom"),this.settings.zoomMode=!0,a.debug("----\x3e zoom start",e,this._zoomCalc)}let r,o;if("touchstart"==i.type||"touchmove"==i.type){let e=i.touches[0]||i.changedTouches[0];r=e.pageX-this._zoomCalc.offset.left,o=e.pageY-this._zoomCalc.offset.top,i.preventDefault()}else r=i.pageX-this._zoomCalc.offset.left,o=i.pageY-this._zoomCalc.offset.top;e.style.left=r*this._zoomCalc.xRatio+"px",e.style.top=o*this._zoomCalc.yRatio+"px"},r=i=>{t.classList.remove("cl-po--zoom"),e.style.width=t.style.width,e.style.height=t.style.height,t.style.width="",t.style.height="",e.style.left="",e.style.top="",this.settings.zoomMode=!1,a.debug("----\x3e zoom end",e)};e.addEventListener("mousemove",i),e.addEventListener("mouseleave",r),fabric.isTouchSupported&&this.settings.zoom.mobile&&(e.addEventListener("touchstart",i),e.addEventListener("touchmove",i),e.addEventListener("touchend",r))}constructor(e,t,i,r,n){Tr(this,"_syncSticky",(()=>{let e={format:"png",multiplier:this.previewConfig.width/this._canvas.getWidth()};this._stickyImgEl.src=this._canvas.toDataURL(e),this._canvas.requestRenderAll()}));let s={api:"https://api.cloudlift.app",assets:"https://assets.cloudlift.app",queryParams:{},selector:".cl-preview",selectorThumbnail:"",position:"",classNamePrefix:"cl-po",product:{},variantId:null,editorMode:!1,editLayer:Pr.editLayer,cropMode:!1,cropLayer:"",sticky:!1,stickyMobile:"overlay",stickyMobileSize:25,stickyMode:!1,maxHeight:0,zoom:{enabled:!1,factor:2,mobile:!0},zoomMode:!1};this.config=e,this.previewConfig=t,this.active=!0,this.settings=o.extend(s,n||{}),this.visible={},this.visibleEditor={},this.shopifyStore=h.getInstance(),this._productForm=i,this.conditionsEngine=r,null!==this.settings.selector&&(o.isElement(this.settings.selector)?this.element=this.settings.selector:this.element=document.querySelector(this.settings.selector)),null!=this.element?(a.info("--\x3e new product-preview: ",this.element),this.resources=[this.settings.assets+"/static/lib/fabricjs/fabric.min.js"],this.ready=$r.loadOnce(this.resources,"product-preview",{async:!1}).then((()=>this._init()))):a.warn("no elements with selector found: ",this.settings.selector)}};class Lo{static generateId(){return Date.now().toString()}static getItem(e){return Lo.storage.hasOwnProperty(e)||(Lo.storage[e]=Lo.parseItem(e)),Lo.storage[e]}static storeItem(e,t){Lo.storage[e]=t,window.localStorage&&localStorage.setItem(Lo.keyPrefix+e,JSON.stringify(t))}static parseItem(e){if(window.localStorage){let t=localStorage.getItem(Lo.keyPrefix+e);if(t)return JSON.parse(t)}return{}}}Lo.storage={},Lo.keyPrefix="cl_";var ko=Lo;var $o=class{_init(){let e=[],t=null,i=document.querySelector("[data-live-variant-options-ids]");i&&(!dr.productVariantObserver&&i.hasAttribute("data-variant-observer")&&(dr.productVariantObserver=!0),t=JSON.parse(i.textContent));for(let i=0;ii&&o.merge(n,this.config.variantOptions[i]),this.settings.variant.id?n.value=this.settings.variant["option"+r.position]:n.value=r.values[0];let s=n.values.length>0,l=[];for(let e=0;ee&&n.values[e].img&&(i.img=n.values[e].img)),l.push(i)}n.values=l,e.push(n)}this.config.variantOptions=e,this.settings.editorMode||this.resolveThemeElements()}resolveThemeElements(e=!1){for(let t=0;tnull===e.closest(".cl-po--option"))));const o=e=>{if(e.length===r.values.length){for(let t=0;tnull===e.closest(".cl-po--option"))));let n=[];for(let e=0;ethis.config.variantOptions.filter((e=>e._themeEl)).map((e=>o.isNodeList(e._themeEl)?e._themeEl[0]:e._themeEl));let t=null,i=e();if(i.length&&(t=i[0].closest('variant-selects, [data-block-type="variant-picker"]'),!t))for(t=i[0].parentNode;t!==document.body;){let e=!0;for(let r=0;r{for(const r of t)if("childList"===r.type&&r.removedNodes.length)for(let t=0;t-1||t.some((e=>e.contains(o))))return a.trace("variant option removed",o),this.resolveThemeElements(!0),void(i=e())}}})),a.debug("watching variant elements",t),this.observer.observe(t.parentNode,{subtree:!0,childList:!0}))}syncVariantChanges(e){if(e._themeEl){const t=t=>{if(e._variantOption.valuesIds){let i=e._variantOption.values.indexOf(t);if(-1!==i)return e._variantOption.valuesIds[i]}return t},i=(e,i)=>e.value==i||this._decode&&this._decodeValue(e.value)==i||this._idMatch&&e.value==t(i);if(o.isNodeList(e._themeEl))for(let t=0;ti&&(t=o,i=a)}}this.settings.variant=t||this.settings.product.variants[0];for(let e=0;e{if(window.Shopify){function t(){setTimeout((function(){window.ShopifyXR.addModels([e]),window.ShopifyXR.setupXRElements()}),1e3)}window.ShopifyXR?t():window.Shopify.loadFeatures([{name:"shopify-xr",version:"1.0",onLoad:t}])}for(var i,r=e.sources.length-1;r>=0&&"glb"!==(i=e.sources[r]).format;r--);return te`
${!1!==window.clGalleryXR?te``:null}`};var Ao=(e,t)=>te` `;var Fo=class{destroy(){if(this._previews)for(let e=0;e{requestAnimationFrame((()=>{t.slide.querySelector("img")&&(t.slide.style.aspectRatio="")}))})),this.settings.galleryConfig.hideThumbnails)this._splideThumbnails={go:e=>{this._splideMain.go(e),this._selectPreview(e)}},this._splideMain.mount();else{let e="left"===this.settings.galleryConfig.layout||"right"===this.settings.galleryConfig.layout?"ttb":"ltr",t="sequential",i=1;if(this._wrapper.offsetWidth){let e=window.innerWidth>768?100:66;i=Math.ceil(this._wrapper.offsetWidth/e),i=Math.max(i-2,1),this.media.length>i&&(t="nearby")}this._splideThumbnails=new Splide(this._wrapper.querySelector("."+this.settings.classNamePrefix+"--gallery-thumbnails"),{keyboard:"focused",lazyLoad:t,preloadPages:i,autoWidth:!0,fixedHeight:100,height:"ttb"===e?window.innerWidth>768?600:200:0,direction:e,rewind:this.settings.galleryConfig.arrows,gap:3,arrows:this.settings.galleryConfig.arrowsThumbnails,pagination:this.settings.galleryConfig.paginationThumbnails,isNavigation:!0,breakpoints:{600:{fixedHeight:66}}}),this._splideThumbnails.mount(),this._splideMain.sync(this._splideThumbnails).mount(),this._splideThumbnails.on("moved",((e,t)=>{this._selectPreview(e)}))}let t=[];for(let i=0;i{if(n.element.addEventListener("preview:rendered",(()=>{requestAnimationFrame((()=>{n.element.closest(".splide__slide").style.aspectRatio=""}))}),{once:!0}),n._thumbnailEl){const e=e=>{let t={format:"png",multiplier:200/n._canvas.getHeight()};n._thumbnailEl.src=n._canvas.toDataURL(t),n._canvas.requestRenderAll()};n.element.addEventListener("layer:changed",e),n.element.addEventListener("preview:rendered",e)}}))),this._previews.push(n)}else a.warn("[live-options] gallery - missing media image for view: ",r)}return this._watchFormChanges(),this._splideMain.options.drag&&!this._isStatic(e)&&this._watchPreviewChanges(),this.settings.editorMode&&window.clProductGalleryPosition?(this.selectPreview(window.clProductGalleryPosition),delete window.clProductGalleryPosition):isNaN(this.settings.galleryConfig.position)?this._selectVariantThumbnail(this._getVariantById(this.settings.variantId)):this.selectPreview(this.settings.galleryConfig.position),!this._preview&&this._previews.length&&(this._preview=this._previews[0]),Promise.all(t)}_filterProductMedia(e){this.media=this.settings.product.media.filter((e=>-1===this.settings.galleryConfig.exclude.indexOf(e.position))),this.settings.galleryConfig.hideThumbnails&&(this.media=this.media.filter((t=>{for(let i=0;ie){let t=this.media[e];!this.settings.galleryConfig.previewActive&&this._preview&&(this._preview.active=!1);for(let e=0;ethis._optionChanged(e))),this._productForm.addEventListener("option:crop",(e=>this._optionChanged(e))),this._productForm.addEventListener("option:variant_changed",(e=>this._variantChanged(e))))}_watchPreviewChanges(){this.element.addEventListener("preview:rendered",(e=>this._checkInteractive(e))),this.element.addEventListener("preview:active",(e=>this._checkInteractive(e)))}_variantChanged(e){this.settings.variantId=e.detail.variantId,this._selectVariantThumbnail(this._getVariantById(this.settings.variantId))}_optionChanged(e){let t=e.detail,i=-1,r=-1,o=this._getMediaPosition(this._splideMain.index);for(let e=0;e0)for(let t=0;t0&&(i=r.offsetWidth);i&&(e=Math.round(i/t)+"px")}}}a.debug("--\x3e product-gallery loader minHeight:",e),this._loader=document.createElement("div"),this._loader.className="cl-po--gallery-loader",this._loader.style.minHeight=e,this._loader.innerHTML='
',this.element.insertBefore(this._loader,this._wrapper),this._wrapper.style.opacity="0";const i=e=>{this._preview!==e.detail&&this._preview||(this._removeLoader(),this.element.removeEventListener("preview:rendered",i))};this.element.addEventListener("preview:rendered",i)}_removeLoader(){this._wrapper.style.opacity="1",this._loader&&(this.element.removeChild(this._loader),this._loader=null)}_triggerEvent(e,t){const i=new CustomEvent(e,{detail:t,cancelable:!0,bubbles:!0});this.element.dispatchEvent(i)}constructor(e,t,i,r){this.config=e,this.settings=o.extend({api:"https://api.cloudlift.app",assets:"https://assets.cloudlift.app",queryParams:{},selector:".cl-gallery",position:"",sticky:!1,stickyMobile:"overlay",zoom:null,maxHeight:0,classNamePrefix:"cl-po",product:{},variantId:null,galleryConfig:{exclude:[],hideThumbnails:!1,hideThumbnailsMobile:!1,layout:"bottom",arrows:!1,arrowsThumbnails:!1,pagination:!1,paginationMobile:!1,paginationThumbnails:!1,previewActive:!1,loader:!1,maxWidth:2500,width:0}},r||{}),window.clGallery&&(this.settings.galleryConfig=o.extend(this.settings.galleryConfig,window.clGallery)),this._previews=[],this.media=[],this._productForm=t,this.conditionsEngine=i,null!==this.settings.selector&&(o.isElement(this.settings.selector)?this.element=this.settings.selector:this.element=document.querySelector(this.settings.selector)),null!=this.element?(a.info("--\x3e new product-gallery: ",this.element),this.resources=[this.settings.assets+"/static/lib/splidejs/splide.min.js",this.settings.assets+"/static/lib/splidejs/splide.min.css"],this.ready=$r.loadOnce(this.resources,"product-gallery",{async:!1}).then((()=>this._init()))):a.warn("no elements with selector found: ",this.settings.selector)}};var Do=class{translate(){try{let e=JSON.stringify(this.config.options);this.config.variantOption&&(e+=JSON.stringify(this.config.variantOptions));let t=e.indexOf("#");if(-1!==t){let i=/^#[0-9A-F]{6}$/i;for(;-1!==t;){let r=e.substr(t,7);if(!i.test(r))break;a.trace("[config-translate] skipping color:",r),t=e.indexOf("#",t+1)}}-1!==t?(this._translateOptions(this.config.options),this.config.variantOption&&this._translateOptions(this.config.variantOptions,!0),this.config.preview&&this._translatePreview(this.config.previewConfig),a.debug("[config-translate] translated options")):a.debug("[config-translate] skipped options translation")}catch(e){a.debug("[config-translate] error in translation",e)}}_translateOptions(e,t=!1){for(let i=0;ithis.render())):(this.config.previewConfig=e,this._initPreview())}updateCss(e){this.removeCss(),this._style=o.addStyleElement(e,this.settings.styleSelector)}removeCss(){this._style&&this._style.parentNode.removeChild(this._style)}updateJs(e){this.removeJs(),e=`window.addEventListener('options:rendered',function(e){ ${e} },{once:true});`,this._script=o.addScriptElement(e)}removeJs(){this._script&&this._script.parentNode.removeChild(this._script)}validate(){let e=this._validateOptions(this.config.options);if(a.debug("validated product-options: ",this.config,e),dr.productOptionsEmptyId){let e=this.getValues();this.settings.idLink=Object.values(e).some((e=>""!==e))}return this.render(),e}render(){let e=[];try{this._evaluateOptionValue(this.config.options),this._evaluateOptionConditions(this.config.options),this._evaluateOptionPrice(this.config.options),this._variantIdOption&&e.push(this._variantIdOption),this._variantOptions&&this.config.variantOptions.length&&e.push(...this.config.variantOptions);const t={uuid:this.config.uuid,editorMode:this.settings.editorMode,price:this.price,product:this.settings.product,productForm:this._productForm,productFormLink:this._productFormLink,wrapper:this._wrapper,assets:this.settings.assets,idLink:this.settings.idLink};e.push(...this.config.options),ee(ho(e,t,this._optionValueChanged.bind(this),this._clearOptionError.bind(this),this.validate.bind(this),this._getOption.bind(this)),this._wrapper),this._triggerEvent("options:rendered",this),this._initTooltips()}catch(t){a.error("failed to render product options",e,t)}}getValues(e={},t=this.config.options){for(let i=0;ithis.render())),this._watchFormSubmit(),this._watchVariantChanges(),this.config.preview&&this._initPreview(),o.hasQueryParam(window.location.href,"item")&&this._restoreCartItem()):a.warn("product-options no product form found for element: ",this.element,this.config)}_variantsInCurrency(){let e=[],t={};ur.priceVariant&&e.push(this.shopifyStore.getProduct(ur.priceProductHandle||"product-options").then((e=>{ur.priceVariantValue=e.price/100})).catch((()=>!0)));const i=i=>{let r=i.priceVariant,o=r.handle;!o&&r.title&&(o=r.title.substring(0,r.title.indexOf("-")).trim().replaceAll(" ","-").toLowerCase()),o&&(t[o]=t[o]||this.shopifyStore.getProduct(o),e.push(t[o].then((e=>{if(e.variants)for(let t=0;t1&&(i.hasOwnProperty("_price")||(i._price=i.price),i.price=i._price*i.priceVariant.quantity),i.disabled=!o.available);break}}})).catch((e=>{a.warn("missing linked product for optionValue: ",i,e),dr.productLinkAvailable&&(i.disabled=!0)}))))},r=e=>{let t=e.values;if(e.list&&this.settings.lists&&this.settings.lists.hasOwnProperty(e.list)&&(t=this.settings.lists[e.list]),t)for(let e=0;e1&&(this._variantOptions=new $o(this.config,this._productFormParentEl||this._productForm,{product:this.settings.product,variant:this._getVariantById(e),editorMode:this.settings.editorMode}),dr.productVariantFilter&&this._variantOptions.filterVariantValues()),this.settings.editorMode))if(this._variantIdOption={name:"id",id:"option_"+this.settings.product.id+"_id",value:e,params:{name:"id",info:"Only shown in the App to test conditional options based on the selected variant."},visible:!0},1===this.settings.product.variants.length||this.config.variantOption)this._variantIdOption.type="hidden";else{this._variantIdOption.label="Variant",this._variantIdOption.type="select",this._variantIdOption.values=[];for(let e=0;ethis._onVariantChange(e))),this._productFormParentEl&&this.shopifyStore.onVariantIdChange(this._productFormParentEl,((e,t)=>this._onVariantChange(e,t))),dr.productVariantHistory&&(dr.productVariantHistoryPush&&this._watchVariantHistory("pushState"),dr.productVariantHistoryReplace&&this._watchVariantHistory("replaceState")),null!==this._variantId}_watchVariantHistory(e){if("function"==typeof window.history[e]){const t=window.history[e],i=this._productForm;window.history[e]=function(e){return setTimeout((function(){i.dispatchEvent(new Event("change"))}),300),t.apply(window.history,arguments)}}}_onVariantChange(e,t){if(t||(t=this.shopifyStore.findProductFormVariantId(this._productFormParentEl||this._productForm)),t!==this._variantId){if(this._variantId=t,delete this.conditionsEngine.data.variant,this._variantId){let e=this._getVariantById(this._variantId);e&&(this.conditionsEngine.data.variant=e),this._clearVisibleEditor(),this._triggerEvent("option:variant_changed",{variantId:this._variantId})}this.render()}}_getVariantById(e){if(this.settings.product.variants&&this.settings.product.variants.length>0)for(let t=0;t1&&this._variantOptions.filterVariantValues(),this._variantOptions.syncVariantChanges(e),this._variantIdOption&&t&&(this._variantIdOption.value=t.id.toString(),this._onVariantChange(null,this._variantIdOption.value))}_clearVisibleEditor(){this.settings.editorMode&&(this.visibleEditor={})}_clearOptionError(e,t,i){const r=t.errors.indexOf(i);r>-1&&t.errors.splice(r,1),this.render()}_generateOptionIds(e,t,i=0){for(let r=0;r0&&(i=i.filter((e=>!o.isHidden(e)&&!this._wrapper.contains(e)))),0===i.length&&(a.debug("no productPrice elements found for price:",t),dr.amountNoDecimals&&(t=cr(e,"{{ amount_no_decimals }}"),a.debug("trying fallback {{ amount_no_decimals }} price: ",t),i=o.findElementContainsRegex("*",new RegExp(`^.{0,50}${t}.{0,50}$`,"s")),i.length>0&&(i=i.filter((e=>!o.isHidden(e)&&!this._wrapper.contains(e)))))),i.length)if(a.debug("found "+i.length+" productPrice elements",i),dr.productPriceAll)this._priceElList=i.filter((e=>{for(let t=0;t{let t=e+100*this.price.total,i=cr(t,ur.moneyFormat);if(this._priceElList&&this._priceElList.length)for(let e=0;et()),1e3),this._variantCompareAtPrice){let e=document.querySelectorAll('[data-live-price-compare="'+this.settings.product.id+'"]');if(e.length){let t=cr(this._variantCompareAtPrice+100*this.price.total,ur.moneyFormat);for(let i=0;i{if(this._priceElList&&this._priceElList.length){a.trace("observer priceEl for removed nodes",this._priceElList);let t=!1;for(let i=0;i0){if(1===r.removedNodes.length&&1!==r.removedNodes[0].nodeType&&3!==r.removedNodes[0].nodeType)continue;const e=Array.from(r.removedNodes);for(let i=0;i-1||e.some((e=>e.contains(o)))){a.debug("priceEl was removed:",o),t=!0;break}}}if(t)break}t&&(a.debug("-> triggering patchProductTotal"),this._patchProductPriceTotal())}})),this._priceElObserver.observe(document.body,{subtree:!0,childList:!0}))}}_patchProductWeightTotal(){if((0!==this.price.weight||this._weightElList&&this._weightElList.length)&&(this._weightElList&&0!==this._weightElList.length||(this._weightElList=document.querySelectorAll('[data-live-weight="'+this.settings.product.id+'"]')),this._weightElList&&this._weightElList.length))for(let e=0;e{e>0&&(t.priceVariant.quantity=0,t.price=0,this.render())})),t.quantityInput&&!isNaN(t.priceVariant.quantity)&&(t.hasOwnProperty("_price")||(!dr.productLinkAvailable&&t.priceVariant.quantity>1&&(t.price=parseFloat(t.priceVariant.price)),t._price=t.price),t.price=t._price*t.priceVariant.quantity)),r&&(this.settings.priceWeight&&t.weight&&(this.price.weight+=t.weight),this.settings.sku&&t.sku&&this.price.sku.push(t.sku),t.priceVariant&&(this.price.variants.push(t.priceVariant),t.priceVariantQuantity&&(t.priceVariant.quantity=-1),t.price&&(this.price.variantTotal+=t.price)),t.price)){let e,r,o=t.price;t.priceVariant||ur.currencyConvert&&(r=o,this.price.totalBase+=r,o=hr(r)),this.price.options.hasOwnProperty(i.name)?(e=this.price.options[i.name],e.price+=o,e.priceBase&&(e.priceBase+=r)):e={option:i,price:o,priceBase:r},this.price.total+=o,e.priceText=cr(100*e.price,ur.moneyFormat),i.label&&i.params.labelPriceText&&(i._priceText=e.priceText),t.priceVariant||(this.price.options[i.name]=e)}}i.options&&i.options.length&&this._evaluateOptionPriceTotal(i.options)}}}_priceValueFormula(e,t,i=!0){let r=0,o=t.priceFormula;try{if(!t._priceFunction)try{-1===o.indexOf("return")&&(o="return ( "+o+" )"),t._priceFunction=Function('"use strict";return (function(option, value, price, options){ '+o+" })")()}catch(i){a.error("failed to parse optionValue.priceFormula: ",t,o,i),this.settings.editorMode&&(e.errors=e.errors||[],-1===e.errors.indexOf(i.message)&&e.errors.push(i.message))}if(t._priceFunction&&(this._priceFunctionUtil=this._priceFunctionUtil||{option:e=>this._getOption(e),value:e=>{const t=this._getOption(e);return t?t.value:""},price:e=>{if(this.price.options.hasOwnProperty(e)){let t=this.price.options[e];return t.priceBase||t.price}return 0},controller:e=>{const t=this._getOption(e);return t&&t._controller?t._controller:{}},variant:e=>this._getVariantById(e||this._variantId),weight:(e,t,i)=>{const r=this._getOption(e);if(r)for(let e=0;e{const i=this._getOption(e);i&&(i.errors=i.errors||[],t=l.translate(t),-1===i.errors.indexOf(t)&&i.errors.push(t),i._errorFormula=!0)}},r=t._priceFunction(e,t.value,t._price,this._priceFunctionUtil),i&&(r?"number"!=typeof r&&(r=parseFloat(r),isNaN(r)&&(r=0)):r=0,r>0&&e.params.priceFormulaDeductVP))){let e=this._getVariantById(this._variantId);e?.price&&(r=Math.max(r-e.price/100,0))}}catch(t){a.error("failed to calculate price with priceFormula: ",o,t),this.settings.editorMode&&(e.errors=e.errors||[],-1===e.errors.indexOf(t.message)&&e.errors.push(t.message))}return r}_watchFormSubmit(){this._productFormSubmit=!1,this._handleCartAdd(),this.shopifyStore.onProductFormSubmit(this._productForm,this._productFormParentEl||this._productForm,(e=>this._handleFormSubmit(e)),dr.productFormCapture),(this._productFormParentEl||this._productForm).addEventListener("keypress",(e=>{if(e.target&&"INPUT"===e.target.tagName){13===(e.keyCode||e.which)&&(e.preventDefault(),e.target.blur())}}))}_handleFormSubmit(e){if(!this._productFormSubmit){if(this._productFormSubmit=!0,!this.validate())return this._productFormSubmit=!1,e.preventDefault(),void e.stopImmediatePropagation();let t=this._hasExportPreviews(),i=0!==this.price.total||this.price.variants.length>0;this._buyNowCapture=!0;let r=t||i||this._itemKey||this._buyNowCapture&&this.shopifyStore.isExpressPaymentButton(e.target);r&&(e.preventDefault(),e.stopImmediatePropagation(),this._productFormEvent=e,this._triggerFormDisabled(!0),this._triggerEvent("options:submit_prevent"));let o=[];if(t){let e=Promise.resolve(),t=this._getPreviews();for(let i=0;inew Promise((function(t,i){setTimeout(i.bind(null,e),1e3)})),n=!1;e=e.then((()=>{let e=Promise.reject();for(let i=0;i<3;i++)e=e.catch((e=>{e&&(n=!0,a.warn("[live-options] preview export error",e),i>1&&(e.try=i),dr.previewExportLog&&this._upload._fileMeta.exportFailed(e));try{return this._exportPreview(r,t)}catch(e){return e.sync=!0,Promise.reject(e)}})).catch(o);return e.finally((()=>{i.removeChild(t)})),e})).then((()=>{n&&this._upload._fileMeta.exportFailed({success:!0})})).catch((e=>{if(e&&(a.error("[live-options] preview final failed",e),e.failed=!0,dr.previewExportLog&&this._upload._fileMeta.exportFailed(e),e.upload&&(alert(e.error),dr.previewExportRequired=!0)),dr.previewExportRequired)return this._productFormSubmit=!1,Promise.reject()}))}}o.push(e)}if(i){const e=ko.generateId();let t=Promise.resolve();if(this.price.variants.length)for(let e=0;ethis.shopifyCart.addItem(o))).catch((e=>{let t="Live Product Options: "+(e.description||"")+"\n**please check the linked products on options**";this.shopifyStore.isThemeEditor()?alert(t):console.error(t)}))}let r=this.price.total-this.price.variantTotal;if(r>0){let i=Math.round(100*r),o={};o[pr.ID]=e;for(const e in this.price.options)if(this.price.options.hasOwnProperty(e)){const t=this.price.options[e];let i=t.priceText.replace(/(<([^>]+)>)/gi,"");o[t.option.name]=i,t.priceBase&&(o["_"+t.option.name]=t.priceBase)}if(this._setFormProperty(pr.ID,e),this._setFormProperty(pr.PRICE,i),ur.currencyConvert&&(this._setFormProperty(pr.CURRENCY,ur.currency),this._setFormProperty(pr.PRICE_BASE,Math.round(100*this.price.totalBase))),this.settings.priceDraft)ko.storeItem(e,{properties:o});else if(ur.priceVariantId){let e=r/ur.priceVariantValue,i=(this._productFormParentEl||this._productForm).querySelector('[name="quantity"]');i&&i.value&&(e*=i.value),e=Math.round(e);let n=this.shopifyCart.toItem(ur.priceVariantId,e,o),a=(this._productFormParentEl||this._productForm).querySelector('input[name="selling_plan"]');a&&a.value&&(n.selling_plan=parseInt(a.value)),pr.VALIDATE=!1,t=t.then((()=>this.shopifyCart.addItem(n))).catch((e=>{alert("Live Product Options: "+(e.description||"")+"\n**please check the Price settings in the app**")}))}else alert("Live Product Options: missing price options product\n**please check the Price settings in the app**")}else i=!1;o.push(t)}if(i||(this._removeFormProperty(pr.ID),this._removeFormProperty(pr.PRICE),this._removeFormProperty(pr.PRICE_BASE),this._removeFormProperty(pr.CURRENCY)),this.settings.priceWeight&&this.price.weight>0?this._setFormProperty(pr.WEIGHT,this.price.weight):this._removeFormProperty(pr.WEIGHT),this.settings.sku&&this.sku?this._setFormProperty(this.settings.skuProp,this.sku):this._removeFormProperty(this.settings.skuProp),r||"cloudlift.cart"!==e.type||(r=!0),r)return Promise.all(o).then((()=>{if(this._itemKey&&-1!==this._itemKey.indexOf(this._variantId)){const t=()=>this.shopifyCart.updateItemById({id:this._itemKey,quantity:this.shopifyStore.findProductFormQuantity(this._productFormParentEl||this._productForm),properties:this.shopifyStore.getFormProperties(this._productForm)}).then((()=>{"function"==typeof window.clOnCartUpdate?window.clOnCartUpdate():window.location.href=this.shopifyStore.settings.api+"/cart"}));if(dr.productItemModal){let i="product.options.item.modal.",r=document.createElement("dialog");return r.className="cl-po--dialog",r.innerHTML=`\n
\n

${l.get(i+"title")}

\n
\n \n \n
\n
`,void 0!==window.dialogPolyfill&&(window.dialogPolyfill.registerDialog(r),r.style.height="auto"),this._wrapper.appendChild(r),r.showModal(),r.addEventListener("close",(()=>{"update"===r.returnValue?t():"cloudlift.cart"===e.type?(delete this._itemKey,delete this._productFormSubmit,this._handleFormSubmit(e)):this._triggerFormEvent()})),!0}if(dr.productItemUpdate)return t()}return this.shopifyStore.isExpressPaymentButton(e.target)&&(e=new CustomEvent("cloudlift.cart",{detail:{onSuccess:()=>{const e=new CustomEvent("cloudlift.checkout",{detail:{},cancelable:!0,bubbles:!1});window.dispatchEvent(e)}},cancelable:!0,bubbles:!1})),"cloudlift.cart"===e.type?this.shopifyCart.addItem({id:this._variantId,quantity:this.shopifyStore.findProductFormQuantity(this._productFormParentEl||this._productForm),properties:this.shopifyStore.getFormProperties(this._productForm)}).then((()=>(this._productFormSubmit=!1,e.detail&&"function"==typeof e.detail.onSuccess?e.detail.onSuccess():window.location.href=this.shopifyStore.settings.api+"/cart",!0))):(this._triggerFormEvent(),setTimeout((()=>{pr.VALIDATE=!0}),5e3),this._triggerEvent("options:submit"),!0)})).catch((e=>(a.error("[live-options] submit handler error",e),this._triggerFormDisabled(!1),!1)));setTimeout((()=>{this._triggerEvent("options:submit"),this._productFormSubmit=!1,this._triggerFormDisabled(!1)}),300)}return Promise.resolve(!1)}_handleCartAdd(){let e=document.querySelectorAll("[data-live-cart-add]");if(e.length){a.debug("found manual cart add btn",e);for(let t=0;t{i.dataset.liveCartAdd&&this.settings.product.id.toString()!==i.dataset.liveCartAdd||(e.preventDefault(),e.stopImmediatePropagation(),this._productFormSubmit=!1,this._handleFormSubmit(new CustomEvent("cloudlift.cart",{detail:{},cancelable:!0,bubbles:!1})))}),{capture:!0})}}}_setFormProperty(e,t){let i;this._formInputs?this._formInputs.hasOwnProperty(e)&&(i=this._formInputs[e]):this._formInputs={},i?i.value=t:(i=document.createElement("input"),i.type="hidden",i.name="properties["+e+"]",i.value=t,this._productForm.appendChild(i)),this._formInputs[e]=i}_removeFormProperty(e){if(this._formInputs&&this._formInputs.hasOwnProperty(e)){let t=this._formInputs[e];t.parentNode.removeChild(t),delete this._formInputs[e]}}_triggerFormEvent(){if(this._triggerFormDisabled(!1),this._productFormEvent){let e=this._productFormEvent;e.target||e.currentTarget?"click"===e.type?e.target&&e.target.click?e.target.click():e.currentTarget&&e.currentTarget.click?e.currentTarget.click():"BUTTON"===e.target.parentNode.tagName&&e.target.parentNode.click():"submit"===e.type&&e.target.submit():(a.error("missing event target - manual form submit"),this._productForm.submit()),this._productFormEvent=null,this._productFormSubmit=!1}this._optionValuesClear&&setTimeout((()=>{this.setValues(this._optionValuesClear),this.render(),this._renderPreview()}),1e3)}_triggerFormDisabled(e){if(dr.productFormDisabled)if(e){if(this._productFormEvent){let e=this._productFormEvent.target||this._productFormEvent.currentTarget;e&&("BUTTON"===e.tagName?this._btnDisabled=e:this._btnDisabled=e.closest("button"),this._btnDisabled&&this._btnDisabled.setAttribute("disabled","disabled"))}}else this._btnDisabled&&(this._btnDisabled.removeAttribute("disabled"),delete this._btnDisabled)}_getControllers(e={},t=this.config.options){for(let i=0;i{this._preview=this._gallery._preview})),this._gallery.element.addEventListener("preview:active",(()=>{this._preview=this._gallery._preview})))):this._preview=new Mo(this.config,this.config.previewConfig,this._productForm,this.conditionsEngine,{api:this.settings.api,assets:this.settings.assets,selector:this.settings.selectorPreview,selectorThumbnail:this.settings.selectorThumbnail,position:this.settings.positionPreview,sticky:this.settings.stickyPreview,stickyMobile:this.settings.stickyPreviewMobile,stickyMobileSize:this.settings.stickyPreviewMobileSize,zoom:this.settings.previewZoom,maxHeight:this.settings.maxHeightPreview,product:this.settings.product,variantId:this._variantId,editorMode:this.settings.editorMode})}_renderPreview(){this.config.preview&&(this._gallery&&this._gallery.ready?this._gallery.ready.then((()=>this._gallery._previews.forEach((e=>e.renderPreview())))):this._preview&&this._preview.ready&&this._preview.ready.then((()=>this._preview.renderPreview())))}_destroyPreview(){this._gallery?(this._gallery.destroy(),delete this._gallery):this._preview&&this._preview.destroy(),delete this._preview}_getPreviews(){return this._gallery?this._gallery._previews:this._preview?[this._preview]:[]}_isExportPreview(e){let t=e.previewConfig.export&&(e.previewConfig.exportConfig.thumbnail||e.previewConfig.exportConfig.original||fr.EXPORT&&e.previewConfig.exports&&e.previewConfig.exports.length);if(!t)for(let t=0;t0)return this._upload.upload(i,(e=>{if(e.lengthComputable){let i=e.loaded/e.total*100;i>t.value&&(t.value=i)}})).then((e=>{for(let t=0;t0){this._tippyInstances||(this._tippyInstances=[]);for(let t=0;t"),n="ontouchstart"in window;if(r=r.trim(),r){const e={allowHTML:!0,maxWidth:350,interactive:o,appendTo:dr.tooltipBody?document.body:"parent"};n&&(e.trigger="click",e.onShow=e=>{setTimeout((function(){e.hide()}),window.clTooltipDuration||3e3)}),this._tippyInstances.push(gi(i,e))}i.classList.add("init")}}}_initPersonalize(e){e._controller={onValidate:e=>!e.required||e.value===e.values[0].value||(e.value=e.values[0].value,this.render(),e.params.popup?this._onPersonalizeChanged(e):e.params.validationMsg&&e.errors.push(e.params.validationMsg),!1),onChange:(e,t)=>{this._optionValueChanged(t),this._onPersonalizeChanged(t)}};let t=[...this.config.options];t.splice(this.config.options.indexOf(e),1),t=t.filter((e=>"personalize"!==e.type));let i=[];if(e.params.pExclude){let r=e.params.pExclude.split(",");t=t.filter((e=>-1===r.indexOf(e.name)||(i.push(e),!1)))}let r=[];r.push(e),e.values&&0!==e.values.length||(e.values=[{value:""}]);let o={data:"options",field:e.name,operator:"equals",value:e.values[0].value};if(r.push({name:"group_personalize",type:"group",value:"",required:!1,conditions:[o],params:{collapseOpen:!1,collapseLabel:"",collapse:!1},options:t,id:"option_group_personalize",visible:!1}),this.settings.editorMode&&e.params.popup&&(e.params.popup=!1),e.params.popup&&(this._productFormLinkForce=!0),this.config.preview){e.params.popup&&(this.config.preview=!1);const t=(e,t)=>{for(let i=0;i{const t=()=>{let t={id:this.config.uuid,product:this.settings.product,className:"fade"+(e.params.popupFull?" full":""),option:e,visible:this.config.options[1].visible},i=this.settings.selectorPreview;if(!o.isElement(i)){if(i=document.createElement("img"),i.className="cl-po--gallery-img",this._variantId)for(let e=0;e{this._productFormSubmit=!1;let t=document.querySelector("[data-live-cart-add-popup]");if(t)window.addEventListener("options:submit",(e=>{this._popupClose=!0,this._popup.set("close",!0)}),{once:!0}),t.click();else{let e;"function"==typeof window.clOnCartUpdate&&(e=()=>{this._popup.set("close",!0),window.clOnCartUpdate()}),this._handleFormSubmit(new CustomEvent("cloudlift.cart",{detail:{onSuccess:e},cancelable:!0,bubbles:!1}))}}),(e=>{this._popup.set("close",!0)})),this._popupEl)};this._popupEl?t():(this._popupEl=document.createElement("div"),this._popupPriceEl=document.createElement("span"),this._priceElList?(o.isNodeList(this._priceElList)&&(this._priceElList=Array.prototype.slice.call(this._priceElList)),this._priceElList.push(this._popupPriceEl)):this._priceElList=[this._popupPriceEl],t(),this._personalizeGroupEl.style.display="",document.body.appendChild(this._popupEl),this._popup=new ldCover({root:this._popupEl.querySelector(".ldcv"),lock:!1}),this._popup.on("toggle.on",(()=>{if(this._preview)this._renderPreview();else{if(window.innerWidth<=768)this.settings.maxHeightPreview=Math.floor(window.innerHeight/4),25!==this.settings.stickyPreviewMobileSize&&(this.settings.maxHeightPreview=Math.floor(window.innerHeight*(this.settings.stickyPreviewMobileSize/100)));else{let e=this.config.previewConfig.gallery&&"bottom"===this.config.previewConfig.galleryConfig.layout;this.settings.maxHeightPreview=e?550:660}this._initPreview()}this.render()}))),this._popup.get().then((i=>{this._popupClose?delete this._popupClose:(e.value=e.values[1].value,this.render(),this._renderPreview(),t())})),this._popup.toggle()}))}else this._popup&&this._popup.set(!1,!0)}_destroyTooltips(){if(null!=this._tippyInstances)for(let e=0;e{for(let i=0;i1){let e=this.shopifyStore.findProductFormQuantityEl(this._productFormParentEl||this._productForm);e&&(e.value=r.quantity)}dr.productItemModal&&"function"!=typeof HTMLDialogElement&&(this._dialogPolyfill=$r.loadOnce([this.settings.assets+"/static/lib/dialog/dialog-polyfill.min.js",this.settings.assets+"/static/lib/dialog/dialog-polyfill.min.css"],"dialog",{async:!1})),this._itemKey=e,this._personalizeOption&&this._onPersonalizeChanged(this._personalizeOption);break}}}))}_lookupCartQuantity(e){return new Promise(((t,i)=>{setTimeout((()=>{this.shopifyCart.getCart(!0).then((i=>{let r=0;for(let t=0;tthis._init())):this._init()):a.warn("no elements with selector found: ",this.settings.selector)}};var jo=class{setup(e=!1){e&&(h.products={}),this.destroy(),this.shopifyStore.parseProductJsonElements(),this.shopifyStore.tryGetProductMap().then((e=>{for(let t=0;t evaluating options-config:",i.uuid),0===i.targetMode){let t=[{data:"product",field:"product",products:[i.product]}];for(let r in e)if(e.hasOwnProperty(r)){let o=e[r];this._evaluateProductTargeting(i,o,t,1)}}else if(0===i.conditionMode){if(this.shopifyStore.isProduct()){let t=e[this.shopifyStore.getHandleFromUrl()+".js"];t&&this._evaluateProductTargeting(i,t,[],0)}}else if(i.conditions.length>0)for(let t in e)if(e.hasOwnProperty(t)){let r=e[t];this._evaluateProductTargeting(i,r,i.conditions,i.conditionMode)}}0===this.products.length?this.shopifyStore.isThemeEditor()&&!this.config.lazy&&this._evaluateThemeEditor(e):setTimeout((()=>{this._compatible()}),1e3)})),this.config.setup&&this.config.configs.length>0&&(this._watch||(this._watchCartItems(),this._watchFormSubmit(),dr.productQuickView&&this._watchQuickView(),this._watch=!0))}destroy(){for(;this.products.length;){this.products.pop().destroy()}}async _evaluateProductTargeting(e,t,i,r){this.conditionsEngine.data.product=t;let o=this.conditionsEngine.evaluateConditions(i,r,"config.uuid="+e.uuid);if(o){this.config.lazy&&(this._lazyFetch&&await this._lazyFetch,this._lazyFetch=this._getConfigLazy(e),await this._lazyFetch);let i="#product_form_"+t.id;i+=', [data-product-form="'+t.id+'"]',o=this._createProductOptions(e,t,i),o||(o=this._createProductOptions(e,t)),o||a.error("no container found options-config:",e.uuid,t)}a.debug("--\x3e evaluated options-config:",e.uuid,t,o)}async _getConfigLazy(e){const t=-1===this.config.api.indexOf("local")?this.config.api.replace("api.","assets."):this.config.api,i=await new n(t+"/api/assets/options.json",{method:"GET",responseType:"json",queryParams:{shop:this.config.shop,config:e.uuid}});if(i.data?.configs){let t=i.data;for(let i=0;i\n .cl-block { padding: 10px;border-radius: 3px;background-color: rgb(55, 167, 220, 1); border: 2px solid #000;margin-bottom: 10px;opacity: 0.75; position: relative; }\n .cl-block span { font-size:14px; display: block; margin-bottom:5px; }\n .cl-block a, .cl-block span { color:#fff; }\n .cl-block a.live { font-size:20px;font-weight:bold;line-height: 1;text-shadow: 1px 1px 1px black;text-decoration: none; }\n .cl-block a.link { font-weight:bold;text-shadow: 1px 1px 1px black; }\n .cl-block .live-close { position: absolute; right:7px; top:0px; font-size:20px; cursor:pointer; }\n \n \n Live Product Options\n Custom product options will appear here. ${e?"":"(only shown in editor)"}`;return e?r+="NEXT: save the theme & continue with the setup in the app.":i||(r+='To change the location visit: Product Options App Block'),n.innerHTML=r,void n.querySelector(".live-close").addEventListener("click",(e=>{n.parentElement.removeChild(n),o.writeCookie(t,"0",30,"/")}))}}}_createProductOptions(e,t,i){for(let i=0;i MERGING options with existing productOptions for product.id: "+t.id,e.options),r._generateOptionIds(e.options,"option_"+t.id+"_",r.config.options.length),r._translate&&(r._translate.config=e,r._translate.translate()),r.config.options.push(...e.options),r._wrapper&&r.render(),!0}i||(i='form[action*="/cart/add"]:not([id*=instal])');let r=1===this.config.locationMode?this.config.selector:"",n=1===this.config.locationMode?this.config.position:void 0,s=this._findOrCreateContainer(r,t,i);if(this._autoPosition&&(n=this._autoPosition,delete this._autoPosition),s){let i,r=JSON.parse(JSON.stringify(e)),a=1===this.config.previewLocationMode?this.config.previewSelector:"",l=1===this.config.previewLocationMode?this.config.previewPosition:void 0;i=o.isNodeList(s)?s:[s];for(let e=0;et&&(r=t.querySelectorAll(e),r.length>0)?(a.debug("using container in form with provided selector:",i,e,r),!0):(r=document.querySelectorAll(e),r.length>0&&(a.debug("using container with provided selector:",e,r),!0));if(e)return n(e,o)?r:(a.debug("no container found with selector:",e),null);if(r=document.querySelector('[data-live-options="'+t.id+'"]'),null!=r)return a.debug("using default container with selector: [data-live-options]"),r;if(this.config.autoSelector&&n(this.config.autoSelector,o))return this.config.autoSelectorPosition&&(this._autoPosition=this.config.autoSelectorPosition),r;if(o){let e=o.querySelector("[type=submit],.add_to_cart,.btn.add-to-cart");return r=document.createElement("div"),r.className="inject",r.style.width="100%",e?e.parentNode.insertBefore(r,e):o.insertBefore(r,o.firstChild),a.debug("injected container into form:",o),r}return null}_findOrCreatePreviewContainer(e,t,i){let r;if(!e&&this.shopifyStore.isTheme("Dawn")&&(this.config.autoPreviewSelector||this.config.autoGallerySelector||(i.previewConfig.gallery?document.querySelector(".product media-gallery")?this.config.autoGallerySelector=".product media-gallery":this.config.autoGallerySelector=".product slider-component":this.config.autoPreviewSelector='.product slider-component:not([class*="thumb"]) ul li:first-child')),r=this._checkPersonalizeContainer(i),r)return r;const n=e=>{let i=document.querySelectorAll(e);if(i.length>0){if(i.length>1)for(let n=0;no.params.imgPos-1&&(r=o.params.imgPos-1);break}}e=t.media[r]}else t.featured_image&&(e={src:t.featured_image});if(e){let t=this.config.previewImgParent,i=this.config.previewImgParentSelector,n=o.pathBaseName(e.src,!1),s=[];if(this.config.previewImgMainSelector&&(s=document.querySelectorAll(this.config.previewImgMainSelector),s.length&&dr.previewHiddenExclude&&(s=Array.prototype.filter.call(s,(function(e){return!o.isHidden(e)})))),0===s.length&&(s=document.querySelectorAll('img[src*="'+n+'"], img[data-src*="'+n+'"], img[data-srcset*="'+n+'"]')),s.length>0){if(a.debug("found main product images:",s),1===s.length)r=s[0];else{let e=Number.MAX_VALUE,t=-1;for(let i=0;it&&(t=l,r=a)}}let e;if(a.debug("selected auto preview img:",r),i&&(e=o.findParent(r,i)),null!=e)r=e,a.debug("using auto preview container with parent selector:",i,r);else if(r){1===t&&(r.parentElement&&null!==r.parentElement.getAttribute("data-zoom")||-1!==r.parentElement.id.indexOf("Zoom")||-1!==r.parentElement.className.indexOf("modal"))&&(t=2);for(let e=0;ethis._handleFormSubmit(e)),dr.cartFormCapture),window.addEventListener("cloudlift.checkout",(e=>{delete this.shopifyCart.cache,this._processCartItems().then((()=>{this._handleFormSubmit(e)}))}))}_handleFormSubmit(e){if(!e.submitter||!e.submitter.name||"update"!==e.submitter.name)if(this._draftCheckout){if(e.preventDefault(),e.stopImmediatePropagation(),this._checkoutRequest)return void a.warn("checkout is processing");try{let t;e.target&&("FORM"===e.target.tagName?t=e.target:e.target!==window&&(t=o.findParent(e.target,"form")));let i=this._getCheckout(t),r=Promise.reject(),s=e=>new Promise((function(t,i){setTimeout(i.bind(null,e),1e3)}));for(let e=0;e<3;e++)r=r.catch((t=>{let r={shop:this.config.shop};return e>0&&(r.retry=e),this._checkoutRequest=new n(this.config.api+"/api/checkout",{method:"POST",data:{checkout:i},responseType:"json",headers:{"Content-type":"application/json"},queryParams:r}),t&&a.warn("[live-options-api] checkout error",t),this._checkoutRequest})).catch(s);r=r.then((e=>{a.debug("[live-options-api] checkout response",e.data),dr.checkoutDomain&&(e.data.url=e.data.url.replace(/^.*\/\/[^\/]+/,"")),window.location.href=e.data.url})).catch((e=>{e.xhr&&0===e.xhr.status||(a.error("[live-options-api] checkout error",e),window.location.href=this.shopifyStore.settings.api+"/checkout")})),"function"==typeof r.finally&&r.finally((()=>{delete this._checkoutRequest}))}catch(e){a.error("[live-options] checkout error",e),window.location.href=this.shopifyStore.settings.api+"/checkout"}}else if(!this.config.priceDraft&&this._discountCheckout){if(this._discountRequest)return void delete this._checkoutRequest;e.preventDefault(),e.stopImmediatePropagation();try{let t=this._getCheckout(null);this._discountRequest=new n(this.config.api+"/api/checkout/discount/quantity",{method:"POST",data:{checkout:t},responseType:"json",headers:{"Content-type":"application/json"},queryParams:{shop:this.config.shop}}),this._discountRequest.then((t=>{var i=t.data;let r=document.querySelector('[name="discount"]');if(!r){let t;e.target&&("FORM"===e.target.tagName?t=e.target:e.target!==window&&(t=o.findParent(e.target,"form"))),t&&(r=document.createElement("input"),r.type="hidden",r.name="discount",t.appendChild(r))}var n=!1;r&&(r.value=i.code,e.submitter&&e.submitter.click&&(n=!0,e.submitter.click())),n||(window.location.href=this.shopifyStore.settings.api+"/checkout?discount="+i.code),a.debug("[live-options-api] checkout discount response",t.data)})).catch((e=>{a.error("[live-options-api] checkout discount error",e),window.location.href=this.shopifyStore.settings.api+"/checkout"}))}catch(e){a.error("[live-options] checkout discount error",e),window.location.href=this.shopifyStore.settings.api+"/checkout"}}else"cloudlift.checkout"===e.type&&(window.location.href=this.shopifyStore.settings.api+"/checkout")}_getCheckout(e){let t=[],i={};for(let e=0;e{if(-1!==i.indexOf("attributes")){let r=i.indexOf("["),o=i.indexOf("]");if(-1!==r&&-1!==o){let n=i.substring(r+1,o);if(e.hasOwnProperty(n)){let r=t.getAll(i);e[n]=r[r.length-1]}else e[n]=t.get(i)}}else"note"===i&&(r=t.get(i));return e}),{})}return{items:t,options:i,optionsTitle:this.config.priceDraftTitle,optionsShipping:!0===this.config.priceDraftShipping,optionsTaxable:!0!==this.config.priceDraftTaxFree,note:r,attributes:o,discount:0===this._discount.type||this._discountCheckout?null:this._discount,currency:this._cart.currency,country:window.Shopify?window.Shopify.country:void 0,total:this._cartTotal,customerId:this.shopifyStore.getCustomerId()}}_getDiscount(){let e={type:mr.NONE};for(let t=0;te)))}}this._processCartItems();let e=o.debounced(1e3,(()=>this._processCartItems()));this._processPending=0;v.register((t=>{if(/.*cart.*/.test(t.url)){if((t.method&&"POST"===t.method.toString().toUpperCase()||-1!==t.url.indexOf("/cart/add")||-1!==t.url.indexOf("/cart/change"))&&delete this.shopifyCart.cache,this._processPending++,this._processPending>2)return this._processPending=0,void a.warn("[live-options] cart process skipped to avoid endless loop");e()}}));setTimeout((()=>e()),2e3)}_processCartItems(){return this.shopifyCart.getCart(!0).then((e=>{this._processPending=0,this._cart=e,this._cartCount=0,this._cartTotal=0,this._draftCheckout=!1,this._discountCheckout=!1;for(let t=0;t{let i=t.key,r=this.shopifyCart.getItemLine(e,t);return this.shopifyCart.updateItem(r,{quantity:t.quantity,properties:t.properties}).then((e=>{let t=document.querySelector('[data-live-item-key="'+i+'"]');t&&(t.dataset.liveItemKey=e.items[r-1].key)}))})))}}t.properties.hasOwnProperty(pr.WEIGHT)&&(this._draftCheckout=!0)}else if(t.properties.hasOwnProperty(pr.ID)&&pr.VALIDATE&&!this._validateCartItemOptionsPrice(e,t))return!1;let i=0,s=!1;t.properties[pr.ID]&&t.properties.hasOwnProperty(pr.OPTIONS)&&t.properties[pr.PRICE]&&(i=parseInt(t.properties[pr.PRICE]),this.config.priceDraft&&(n=t.original_line_price+i*t.quantity),s=i>0);let c=null;t.properties.hasOwnProperty(pr.QUANTITY_ID)&&(c=this._processCartQuantityDiscount(e,t,i),null!=c&&(n=c,this._discountCheckout=!0,s=!0,this.config.priceDraft?this._draftCheckout=!0:n-=i*t.quantity));let p=this._resolveCartItemEl(e,t);0===p.length&&a.warn("[live-options] missing cart item element for: ",t);for(let n=0;n0){let t=e[e.length-1],r=document.createElement("span");r.className="cl-prop",r.innerHTML=t.textContent.replace(i,''+l.get("product.options.file.link")+""),t.parentNode.replaceChild(r,t)}}}let p=d.querySelector("[data-live-item-edit]");if(!p&&dr.cartItemEdit){let e,i="afterend",r=[];for(let i in t.properties)if(t.properties.hasOwnProperty(i)){if("_"===i.charAt(0))continue;let n=o.findElementContainsRegex("*",new RegExp(`${o.escapeRegex(i)}.*${o.escapeRegex(t.properties[i])}`,"s"),d);if(n.length>0)if(r.length){for(let t=n.length-1;t>=0;t--){const i=n[t];if(-1!==r.indexOf(i)){e=i;break}}if(e)break}else r.push(...n)}if(!e&&r.length&&(e=r[r.length-1]),e||(e=d.querySelector('a[href*="/cart/change"]'),i="beforebegin"),null!=e){a.debug("---\x3e adding editBtn: "+i,e),p=document.createElement("a"),p.style.padding="5px 10px",p.style.border="1px solid #d1d5db",p.style.borderRadius="3px",p.innerText=l.get("product.options.item.edit"),p.dataset.liveItemEdit="1";let t=document.createElement("div");t.style.padding="10px 0",t.appendChild(p),e.insertAdjacentElement(i,t)}}if(p){a.debug("---\x3e using editBtn element",p);let e=t.url+"&item="+t.key;"A"===p.tagName?p.href=e:p.addEventListener("click",(()=>window.location.href=e))}if(dr.cartItemClOptions)for(let e in t.properties)if(t.properties.hasOwnProperty(e)&&e.startsWith(pr.OPTIONS)&&-1!==d.innerHTML.indexOf(e)){let i=o.findElementContainsRegex("*",new RegExp(`${e}.*${t.properties[e]}`,"s"),d);if(i.length>0){let r=i[i.length-1],o=!0;for(let e in t.properties)if(t.properties.hasOwnProperty(e)&&-1!==r.innerHTML.indexOf(e)){o=!1;break}if(o)r.parentNode.removeChild(r);else{let i=String(t.properties[e]),o=r.innerHTML.indexOf(e),n=r.innerHTML.indexOf(i)+i.length;r.innerHTML=r.innerHTML.replace(r.innerHTML.slice(o,n),"")}}}if(s){const e=ur.moneyFormat,r=this.shopifyStore.trimMoneyFormatAmount(ur.moneyFormat),o=(e,t=!1)=>this._findPriceEl("*",e,r,d,t),n=(t,i,r,o)=>{let n=d.querySelector(r);(o||n)&&(i.classList.contains("cl-price-lt")?n||(n=i.parentNode.querySelector(".cl-price-d")):i.classList.add("cl-price-lt"),n||(n=document.createElement("span"),i.parentNode.insertBefore(n,i.nextSibling)),n.classList.add("cl-price-d"),n.innerHTML=cr(t,e))},s=(e,t)=>{if(e.classList.contains("cl-price-lt")){e.classList.remove("cl-price-lt");let i=d.querySelector(t);i?i.innerHTML="":(i=e.parentNode.querySelector(".cl-price-d"),i&&i.parentNode.removeChild(i))}};let l=d.querySelector("[data-live-item-final-price]");!l&&dr.cartItemPrice&&(l=o(t.final_price)),l&&(a.debug("---\x3e found item.final_price element",l),l.innerHTML=cr(t.final_price+i,e),null!=c?n(c/t.quantity,l,"[data-live-item-final-price-discount]",!1):s(l,"[data-live-item-final-price-discount]")),l=d.querySelector("[data-live-item-original-price]"),!l&&dr.cartItemPrice&&(l=o(t.original_price)),l&&(a.debug("---\x3e found item.original_price element",l),l.innerHTML=cr(t.original_price+i,e));let p=Array.from(d.querySelectorAll("[data-live-item-final-line-price]"));0===p.length&&dr.cartItemPrice&&(l=o(t.final_line_price,!0),l&&p.push(l)),p.length&&p.forEach((r=>{a.debug("---\x3e found item.final_line_price element",r),r.innerHTML=cr(t.final_line_price+i*t.quantity,e),null!=c?n(c,r,"[data-live-item-final-line-price-discount]",!0):s(r,"[data-live-item-final-line-price-discount]")})),l=d.querySelector("[data-live-item-original-line-price]"),!l&&dr.cartItemPrice&&(l=o(t.original_line_price)),l&&(a.debug("---\x3e found item.original_line_price element",l),l.innerHTML=cr(t.original_line_price+i*t.quantity,e))}if(t.properties[pr.ID])if(t.properties.hasOwnProperty(pr.OPTIONS)){if(dr.cartItemPriceOptions){let i;if(i=this.config.priceDraft?ko.getItem(t.properties[pr.ID]):this._findCartItemByProperty(e,pr.ID,t.properties[pr.ID],t.key),null!=i&&i.properties)for(let e in i.properties)if("_"!==e.charAt(0)&&i.properties.hasOwnProperty(e)&&t.properties.hasOwnProperty(e)){let r=o.findElementContainsRegex("*",new RegExp(`${o.escapeRegex(e)}.*${o.escapeRegex(t.properties[e])}`,"s"),d);if(r.length>0){let o=r[r.length-1],n=e.replace(/^[^a-zA-Z]+|[^\w]+/g,"");const s="p"+n.charAt(0).toUpperCase()+n.slice(1);if(!o.dataset[s]){a.debug("--\x3e found element to display options price for property: "+e,o);let r=t.properties[e];-1!==r.indexOf("&")&&-1!==o.innerHTML.indexOf("&")&&(r=r.replace(/&/g,"&")),o.innerHTML=o.innerHTML.replace(r,r+" | "+i.properties[e]),o.dataset[s]="1"}}}}}else dr.cartItemPriceRemove&&d.parentNode&&d.parentNode.removeChild(d)}else t.properties.hasOwnProperty(pr.OPTIONS)&&a.debug("--\x3e no cart item node found for item: ",t)}}}return this._cartCount+=r,this._cartTotal+=n,!0}_processCartQuantityDiscount(e,t,i){let r,o=0,n=t.properties[pr.QUANTITY_ID];for(let t=0;t=t&&a removing cartItem",t),this.shopifyCart.removeItem(this.shopifyCart.getItemLine(e,t)).then((()=>window.location.reload())),!1;if(t.properties.hasOwnProperty(pr.PRICE)){let r=parseInt(t.properties[pr.PRICE]),o=r*t.quantity;if(o!==i.original_line_price){if(ur.currencyConvert){if(t.properties.hasOwnProperty(pr.CURRENCY)&&t.properties[pr.CURRENCY]!==ur.currency){let e=parseInt(t.properties[pr.PRICE_BASE]);ur.priceVariantValue=i.original_price/100,e=hr(e),o=e*t.quantity,t.properties[pr.CURRENCY]=ur.currency,this._convertOptionsPriceProperties(i.properties)}}else{let e={};e[pr.ID]=i.properties[pr.ID],i.properties=e}let n=Math.round(o/i.original_price),a=Math.round(i.original_price*n/t.quantity),s=Promise.resolve();return a!==r&&(t.properties[pr.PRICE]=String(a),s=this.shopifyCart.updateItem(this.shopifyCart.getItemLine(e,t),{quantity:t.quantity,properties:t.properties})),s.then((()=>this.shopifyCart.updateItem(this.shopifyCart.getItemLine(e,i),{quantity:n,properties:i.properties}))).then((()=>{window.location.reload()})),!1}}return!0}_resolveCartItemEl(e,t){let i=[],r=['[data-live-item-key="'+t.key+'"]','[data-line-item-key="'+t.key+'"]','[data-cart-item-key="'+t.key+'"]',".cart_item_"+t.id];for(let e=0;e0){for(let r=0;r1)for(let r=0;r "+this._cartCount,r),r.innerText=this._cartCount}if(dr.cartCount&&t!==this._cartCount){let i=o.findElementContainsRegex("*",new RegExp(`^.{0,3}${t}.{0,3}$`,"s"));if(this.shopifyStore.isTheme("Dawn")){let e=document.querySelector("#cart-notification-button");e&&(e.innerHTML=e.innerHTML.replace(t,this._cartCount))}const r=this.shopifyStore.trimMoneyFormatAmount(ur.moneyFormat);let n=cr(e.total_price,r);for(let e=0;e "+this._cartCount,r),r.innerHTML=r.innerHTML.replace(t,this._cartCount)}}}}_patchCartTotal(e){if(this.config.priceDraft||this._discountCheckout){let t=e.total_price,i=[],r=e.original_total_price!==this._cartTotal;this.config.priceDraft&&r&&(this._draftCheckout=!0),this._cartTotal-=e.total_discount;let n=cr(this._cartTotal,ur.moneyFormatWithCurrency),s=["[data-live-cart-total]",".totals__subtotal-value",".totals__total-value"];for(let e=0;e "+this._cartTotal,r),r.innerHTML=n}if(dr.cartTotal&&r){let e=this.shopifyStore.trimMoneyFormatAmount(ur.moneyFormat),i=this._findPriceEl('form[action*="/cart"]:not(form[action*="/cart/add"]) *, form[action*="/checkout"] *',t,e);i&&(o.findParent(i,"[data-live-item-key]")||(a.debug("---\x3e found cart.total_price element",i),i.innerHTML=n))}if(this._draftCheckout&&(this._checkoutBtns=this.shopifyStore.findExpressDynamicCheckoutCart(),this._checkoutBtns.length))for(let e=0;e{this._discountInput.loading=!1,e.data?(this._discount=e.data,this._discount.valid=!0,this._discountInput.code="",window.localStorage&&localStorage.setItem("cl_discount",JSON.stringify(this._discount)),this.shopifyStore.saveDiscountCode(this._discount.code),this._discountInput.success=l.get("product.options.discount.valid")):this._discountInput.error=l.get("product.options.discount.invalid"),this._renderDiscount(),a.debug("[live-options-api] checkout discount response",e.data)})).catch((e=>{this._discountInput.loading=!1,this._discountInput.error="Please try again",this._renderDiscount(),a.error("[live-options-api] checkout discount error",e)}))}_renderDiscount(){var e,t,i,r,o;ee((e=this._discount,t=this._discountInput,i=this._applyDiscount.bind(this),r=this._removeDiscount.bind(this),o=e=>{this._discountInput.code=e.target.value,this._discountInput.error&&(this._discountInput.error="",this._renderDiscount())},te` ${e.type!==mr.AUTO?te`
o(e)} />
${t.error?te`

${t.error}

`:null} ${e.valid?te`
${e.code}
${t.success?te`

${t.success}

`:null}
`:null}
`:null} `),this._discountEl)}_findPriceEl(e,t,i,r,n){let s,l=cr(t,i);s=0===t||dr.cartPriceRegex?o.findElementContainsRegex(e,new RegExp(`[^0-9]${l}[^0-9]`,"s"),r):o.findElementContainsText(e,l,r),0===s.length&&(a.debug("no price elements found for price:",l,r),dr.amountNoDecimals&&(l=cr(t,"{{ amount_no_decimals }}"),a.debug("fallback {{ amount_no_decimals }} price: ",l,r),s=o.findElementContainsText("*",l,r)));const c=e=>!(-1!==e.className.indexOf("cl-price")||n&&o.isHidden(e));if(s.length){let e=s[s.length-1];if(c(e))return e;for(let t=s.length-2;t>=0;t--){let i=s[t];if(!i.contains(e)){if(c(i))return i;e=i}}a.warn("found price element with cl-price - ignoring update",l,r)}return null}_convertOptionsPriceProperties(e){for(let t in e)if("_"!==t.charAt(0)&&e.hasOwnProperty(t)&&e.hasOwnProperty("_"+t)){let i=parseInt(e["_"+t]);i=hr(i),e[t]=cr(100*i,ur.moneyFormat).replace(/(<([^>]+)>)/gi,"")}}_watchQuickView(){let e=["[data-live-quick-view]",".quick-add__submit"].join(",");document.addEventListener("click",(t=>{t.target&&o.matchesIncludeParent(t.target,e)&&setTimeout((()=>{this.setup(!0)}),1e3)}),{capture:!0})}_compatible(){const e=e=>`[Live Product Options] found incompatible app: ${e} \n**Please reach out to our app support to check your theme**`,t=t=>this.shopifyStore.isThemeEditor()?alert(e(t)):console.error(e(t));"undefined"!=typeof cst_money_formate?t("Customify"):null!==document.querySelector('script[src*="options.ymq"]')?t("YMQ Product Options"):null!==document.querySelector('script[src*="customily"]')&&t("Customily")}constructor(e){this.config=e,this.products=[];let t={};if(l.locale&&String.prototype.startsWith&&window.location.pathname.toLowerCase().startsWith("/"+l.locale.toLowerCase())&&(t.api="/"+l.locale.toLowerCase()),window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root&&"/"!==window.Shopify.routes.root){let e=window.Shopify.routes.root;t.api="/"===e[e.length-1]?e.substr(0,e.length-1):e}if(this.shopifyStore=h.getInstance({api:t.api}),this.shopifyCart=g.getInstance(t),this.conditionsEngine=new yo,this.currency=ur,this.config.theme)for(let e in this.config.theme)this.config.theme.hasOwnProperty(e)&&(dr[e]=this.config.theme[e]);this.config.themeId&&window.Shopify&&window.Shopify.theme&&window.Shopify.theme.id&&this.config.themeId!==window.Shopify.theme.id.toString()&&(a.debug("--\x3e theme.id config does not match - reseting custom selectors ",this.config.themeId,window.Shopify.theme.id.toString()),delete this.config.previewImgMainSelector,delete this.config.previewImgThumbnailSelector,delete this.config.itemImgParentSelector),this.shopifyStore.isTheme("Dawn")&&(dr.themeGallery=void 0===this.config.theme.themeGallery||this.config.theme.themeGallery,dr.productPriceObserver=!0,this.config.itemImgParentSelector=".cart-notification, .cart-item"),window.theme&&window.theme.settings&&window.theme.settings.superScriptPrice&&(dr.amountNoDecimals=!0);for(let e in this.config.currencyFormats)if(this.config.currencyFormats.hasOwnProperty(e)){let t=this.config.currencyFormats[e];-1!==t.indexOf("&")&&(t=o.decodeHtml(t)),"moneyWithCurrencyFormat"===e&&(e="moneyFormatWithCurrency"),ur[e]=t}if(void 0!==window.clPriceDraft&&(this.config.priceDraft=window.clPriceDraft),ur.priceVariant=!this.config.priceDraft,ur.priceVariantId=this.config.priceVariantId,ur.priceVariantValue=this.config.priceVariantValue,ur.priceProductHandle=this.config.priceProductHandle,ur.currencyConvert=window.theme&&Array.isArray(window.theme.currencies)?window.theme.currencies.length>1:this.config.currencyConvert,window.Shopify&&window.Shopify.currency&&(ur.currency=window.Shopify.currency.active,ur.currencyConvert)){let e=parseFloat(window.Shopify.currency.rate);isNaN(e)||1===e||(ur.currencyFactor=e)}if(ur.currencyConvert||-1===ur.moneyFormat.indexOf("<")||-1===ur.moneyFormat.indexOf(">")||(dr.currencyFormat=!1),dr.currencyFormat&&window.theme&&window.theme.moneyFormat&&(ur.moneyFormat=window.theme.moneyFormat,ur.moneyFormatWithCurrency=window.theme.moneyFormatWithCurrency||window.theme.moneyFormat),dr.priceVisibleCustomer&&this.config.setup&&(dr.priceVisible=null!==this.shopifyStore.getCustomerId()),e.extensions){let t=e.extensions.split(",");for(let e=0;e waiting for DOMContentLoaded"),document.addEventListener("DOMContentLoaded",(()=>this.setup()),!1)),this.shopifyStore.onThemeSectionEvent("load",(e=>{this.setup()})))}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */const Ro=(e=!1)=>{if(!e&&"content"in document.createElement("template"))return;const t=document.implementation.createHTMLDocument("template"),i=t.body,r={enumerable:!0,configurable:!0},o=Document.prototype.createElement;Document.prototype.createElement=function(e,n){const a=o.call(this,e,n);return"TEMPLATE"===a.tagName&&(e=>{const o=t.createDocumentFragment();Object.defineProperties(e,{content:Object.assign(Object.assign({},r),{get:()=>o}),innerHTML:Object.assign(Object.assign({},r),{set:function(e){i.innerHTML=e,C(o,o.firstChild),x(o,i.firstChild)}})})})(a),a}};let Vo=()=>{Ro();const e=window.Cloudlift.options.config;a.setDefaultLevel(a.levels.ERROR);let t=a.getLevel();a.setLevel(void 0!==e.log?e.log:t),a.debug("got config",e),window.addEventListener("cloudlift.options.ready",(e=>{a.debug("resources loaded")}));const i=-1===e.api.indexOf("local")?e.api.replace("api.","assets."):e.api;d.fonts=e.fonts,d.api=i+"/api/font",d.apiParams.shop=e.shop,l.translations=e.i18n||{},e.setup?window.clTranslate?l.translations=o.extend(l.translations,window.clTranslate):(l.api=i+"/api/assets/"+e.app+"/translate/{locale}?shop="+e.shop,l.event+="."+e.app,l.locale&&e.locale&&l.locale!=e.locale&&l.fetch(l.locale)):(window.Translate=l,window.FontLoader=d),window.Cloudlift.options.lib={ProductOptions:No,ProductPreview:Mo},l.ready.then((()=>{window.Cloudlift.options.App=new jo(e)}))};"Promise"in window&&"assign"in Object&&String.prototype.startsWith&&Array.prototype.flat?Vo():e(Lr)(window.Cloudlift.options.config.assets+"/static/lib/core-js/core-js.min.js",Vo)}();