UNPKG

@salla.sa/twilight-components

Version:
11 lines 959 kB
var __awaiter=this&&this.__awaiter||function(t,e,i,n){function r(t){return t instanceof i?t:new i((function(e){e(t)}))}return new(i||(i=Promise))((function(i,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function s(t){try{l(n["throw"](t))}catch(t){a(t)}}function l(t){t.done?i(t.value):r(t.value).then(o,s)}l((n=n.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,r,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(t){return function(e){return l([t,e])}}function l(s){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,s[0]&&(i=0)),i)try{if(n=1,r&&(a=s[0]&2?r["return"]:s[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;if(r=0,a)s=[s[0]&2,a.value];switch(s[0]){case 0:case 1:a=s;break;case 4:i.label++;return{value:s[1],done:false};case 5:i.label++;r=s[1];s=[0];continue;case 7:s=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){i=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(s[0]===6&&i.label<a[1]){i.label=a[1];a=s;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(s);break}if(a[2])i.ops.pop();i.trys.pop();continue}s=e.call(t,i)}catch(t){s=[6,t];r=0}finally{n=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(t,e,i){if(i||arguments.length===2)for(var n=0,r=e.length,a;n<r;n++){if(a||!(n in e)){if(!a)a=Array.prototype.slice.call(e,0,n);a[n]=e[n]}}return t.concat(a||Array.prototype.slice.call(e))};var _0; /*! * Crafted with ❤ by Salla */import{r as registerInstance,c as createEvent,h,H as Host,g as getElement,a as getDefaultExportFromCjs,F as Fragment,d as global,e as browser$1,B as Buffer,n as nextTick,i as isBuffer$1,f as getAugmentedNamespace}from"./index-BrMYHkA5.js";import{a as anime}from"./anime.es-CgtvEd63.js";import{A as ArrowDownIcon,S as SpecialDiscountIcon}from"./special-discount-yRO-ZESF.js";import{C as CheckCircleIcon}from"./check-B-rij7Or.js";import{H as Helper}from"./Helper-BrCHOtZG.js";import{a as arrowLeft}from"./arrow-left-BedNk7k1.js";import{M as MailIcon}from"./mail-DmgxDvXL.js";import{w as whatsapp$1}from"./whatsapp2-DWksgowB.js";import{f as facebook,t as twitter}from"./twitter-Dz7o69vX.js";import{C as CameraIcon}from"./camera-C6jIkM-X.js";var PendingOrdersIcon='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="30" height="32" viewBox="0 0 30 32">\n<title>cart</title>\n<path d="M15.426 28.084c0-1.412-0.85-2.684-2.156-3.226-1.305-0.54-2.807-0.241-3.805 0.758-0.999 0.998-1.298 2.5-0.758 3.805 0.54 1.303 1.815 2.155 3.226 2.155 1.928-0.003 3.49-1.564 3.492-3.492h0.001zM10.597 28.084h0.001c0-0.54 0.326-1.027 0.825-1.235 0.498-0.206 1.074-0.091 1.455 0.29 0.383 0.382 0.497 0.957 0.29 1.456-0.208 0.5-0.695 0.825-1.235 0.825-0.355 0-0.695-0.142-0.944-0.391-0.251-0.251-0.392-0.591-0.392-0.946h-0.001l0.001 0.001zM28.23 28.084c0-1.412-0.85-2.684-2.155-3.226-1.305-0.54-2.807-0.241-3.806 0.758s-1.297 2.5-0.756 3.805c0.54 1.303 1.813 2.155 3.226 2.155 1.927-0.003 3.49-1.564 3.491-3.492zM23.401 28.084c0-0.54 0.326-1.027 0.825-1.235 0.5-0.206 1.075-0.091 1.457 0.29s0.497 0.957 0.289 1.456c-0.206 0.5-0.693 0.825-1.233 0.825-0.738 0-1.337-0.599-1.337-1.337l-0.001 0.001zM1.953 0.234l-0.342-0.059c-0.29-0.064-0.594-0.004-0.839 0.166-0.247 0.169-0.414 0.436-0.463 0.734-0.050 0.3 0.023 0.607 0.201 0.85s0.444 0.402 0.738 0.44l0.341 0.059c1.825 0.324 3.248 1.794 3.548 3.662l1.981 12.369h-0.001c0.218 1.387 0.913 2.651 1.96 3.563s2.379 1.412 3.754 1.41h14.242c0.601 0 1.088-0.498 1.088-1.112s-0.487-1.112-1.088-1.112h-14.242c-1.679-0.001-3.139-1.183-3.525-2.854h11.463c1.614 0.004 3.188-0.518 4.493-1.49 1.305-0.973 2.271-2.346 2.762-3.918l1.298-4.136c0.145-0.455 0.065-0.953-0.213-1.336-0.278-0.385-0.72-0.608-1.187-0.602h-20.467l-0.181-1.141c-0.218-1.367-0.849-2.631-1.802-3.615-0.954-0.983-2.184-1.64-3.518-1.878h-0.001zM26.946 9.096l-0.993 3.169v-0.001c-0.353 1.122-1.044 2.101-1.975 2.796s-2.056 1.067-3.208 1.067h-11.833l-1.125-7.042 19.134 0.011z"></path>\n</svg>\n';var WalletIcon$1='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n';var sallaAddProductButtonCss=":host{display:block}salla-add-product-button[width=wide]{width:100%}";var SallaAddProductButton=function(){function t(t){var e=this;registerInstance(this,t);this.success=createEvent(this,"success");this.failed=createEvent(this,"failed");this.hostAttributes={};this.productStatus="sale";this.productType="product";this.selectedOptions=[];this.buyNowText=salla.lang.get("pages.products.buy_now");salla.lang.onLoaded((function(){e.buyNowText=salla.lang.get("pages.products.buy_now")}))}t.prototype.getLabel=function(){if(this.productStatus==="sale"&&this.supportStickyBar&&window.innerWidth<=768&&this.showQuickBuy&&this.isApplePayActive){return PendingOrdersIcon}if(this.productStatus==="sale"&&this.productType==="booking"){return salla.lang.get("pages.cart.book_now")}if(this.productStatus==="sale"){return salla.lang.get("pages.cart.add_to_cart")}if(this.productType!=="donating"){return salla.lang.get("pages.products.out_of_stock")}return salla.lang.get("pages.products.donation_exceed")};t.prototype.addProductToCart=function(t){var e=this;var i;if(this.productType==="booking"){t.preventDefault();return this.addBookingProduct()}if(this.hostAttributes.type==="submit"){return false}t.preventDefault();(i=this.btn)===null||i===void 0?void 0:i.disable();var n=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd"}).reduce((function(t,e){var i=e[0],n=e[1];return n?(t[i]=n,t):t}),{});return salla.cart.addItem(n).then((function(t){var i;e.selectedOptions=[];(i=e.btn)===null||i===void 0?void 0:i.enable();e.success.emit(t)})).catch((function(t){var i;e.failed.emit(t);(i=e.btn)===null||i===void 0?void 0:i.enable()}))};t.prototype.addBookingProduct=function(){var t=this;if(salla.config.isGuest()){salla.auth.api.setAfterLoginEvent("booking::add",this.productId);salla.event.dispatch("login::open");return}return salla.booking.add(this.productId).then((function(e){return t.success.emit(e)})).catch((function(e){return t.failed.emit(e)}))};t.prototype.getBtnAttributes=function(){for(var t=0;t<this.host.attributes.length;t++){if(!["id","class"].includes(this.host.attributes[t].name)){this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value}}return this.hostAttributes};t.prototype.getQuickBuyBtnAttributes=function(){return Object.assign(Object.assign({},this.getBtnAttributes()),{type:this.supportStickyBar&&window.innerWidth<=768?"plain":this.productType=="donating"?"donate":"buy"})};t.prototype.miniCheckoutWidget=function(){var t=salla.config.get("store.id");if(!t){return}return h("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user")},products:[this.productId],api:salla.config.get("store.api"),outline:true,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},h("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},h("span",{innerHTML:WalletIcon$1}),this.buyNowText))};t.prototype.componentWillLoad=function(){var t=this;return salla.onReady().then((function(){var e,i,n;document.documentElement.classList.add("hydrated");t.showQuickBuy=t.quickBuy&&salla.config.get("store.settings.buy_now")&&t.productStatus=="sale"&&t.productType!=="booking";t.isApplePayActive=((e=window.ApplePaySession)===null||e===void 0?void 0:e.canMakePayments())&&((i=salla.config.get("store.settings.payments"))===null||i===void 0?void 0:i.includes("apple_pay"))&&salla.config.get("store.settings.is_salla_gateway",false);t.passedLabel=t.host.innerHTML.replace("\x3c!----\x3e","").trim();if(!!t.passedLabel&&window.innerWidth>=768){return(n=t.btn)===null||n===void 0?void 0:n.setText(t.passedLabel)}if(t.host.getAttribute("type")==="submit"&&t.supportStickyBar){window.addEventListener("resize",(function(){var e;return(e=t.btn)===null||e===void 0?void 0:e.setText(window.innerWidth>=768&&!!t.passedLabel?t.passedLabel:t.getLabel())}))}}))};t.prototype.render=function(){var t=this;var e;if((e=this.host.closest(".swiper-slide"))===null||e===void 0?void 0:e.classList.contains("swiper-slide-duplicate")){return""}if(this.hasSubscribedOptions){return h(Host,null,h("salla-product-availability",Object.assign({},this.getBtnAttributes(),{"is-subscribed":true}),h("span",{class:"s-hidden"},h("slot",null))))}if(this.productStatus==="out-and-notify"&&this.channels||this.hasOutOfStockOption){return h(Host,null,h("salla-product-availability",Object.assign({},this.getBtnAttributes()),h("span",{class:"s-hidden"},h("slot",null))))}return h(Host,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},h("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},h("salla-button",Object.assign({color:this.productStatus==="sale"?"primary":"light",type:"button",fill:this.productStatus==="sale"?"solid":"outline",ref:function(e){return t.btn=e},onClick:function(e){return t.addProductToCart(e)},disabled:this.productStatus!=="sale"},this.getBtnAttributes(),{"loader-position":"center"}),h("slot",null)),this.showQuickBuy&&!!document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?h("salla-quick-buy",Object.assign({},this.getQuickBuyBtnAttributes())):"")};t.prototype.componentDidLoad=function(){var t=this;if(!this.notifyOptionsAvailability){return}salla.event.on("product-options::change",(function(e){return __awaiter(t,void 0,void 0,(function(){var t,i,n,r,a,o;var s=this;return __generator(this,(function(l){switch(l.label){case 0:if(!["thumbnail","color","single-option"].includes(e.option.type)){return[2]}this.hasSubscribedOptions=false;n=this;return[4,(t=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||t===void 0?void 0:t.getSelectedOptions()];case 1:n.selectedOptions=l.sent();r=this;return[4,(i=document.querySelector('salla-product-options[product-id="'.concat(this.productId,'"]')))===null||i===void 0?void 0:i.hasOutOfStockOption()];case 2:r.hasOutOfStockOption=l.sent();a=salla.storage.get("product-".concat(this.productId,"-subscribed-options"));if(!a&&!this.subscribedOptions||!this.hasOutOfStockOption){return[2]}if(salla.config.isGuest()){o=a?a.map((function(t){return t.split(",").map((function(t){return parseInt(t)}))})):[];this.hasSubscribedOptions=o.length>0&&o.some((function(t){return t.every((function(t){return s.selectedOptions.some((function(e){return e.id===t}))}))}))}else{this.hasSubscribedOptions=this.subscribedOptions&&this.subscribedOptions!=="null"&&this.subscribedOptions!=="[]"?JSON.parse(this.subscribedOptions).some((function(t){return t.every((function(t){return s.selectedOptions.some((function(e){return e.id===t}))}))})):false}return[2]}}))}))}))};t.prototype.componentDidRender=function(){var t=this;var e,i;if(!!this.passedLabel&&(!this.supportStickyBar||window.innerWidth>=768)){(e=this.btn)===null||e===void 0?void 0:e.setText(this.passedLabel);return}(i=this.btn)===null||i===void 0?void 0:i.setText(this.getLabel());salla.lang.onLoaded((function(){var e;return(e=t.btn)===null||e===void 0?void 0:e.setText(t.getLabel())}))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaAddProductButton.style=sallaAddProductButtonCss;var infoIcon='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>info</title>\n<path d="M16 13.333c-0.737 0-1.333 0.596-1.333 1.333v9.333c0 0.737 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333v-9.333c0-0.737-0.596-1.333-1.333-1.333zM16 7.987c-0.737 0-1.333 0.596-1.333 1.333v0.013c0 0.737 0.596 1.327 1.333 1.327s1.333-0.603 1.333-1.34-0.596-1.333-1.333-1.333zM16 0c-8.823 0-16 7.177-16 16s7.177 16 16 16 16-7.177 16-16-7.177-16-16-16zM16 29.333c-7.352 0-13.333-5.981-13.333-13.333s5.981-13.333 13.333-13.333 13.333 5.981 13.333 13.333-5.981 13.333-13.333 13.333z"></path>\n</svg>\n';var shoppingBag='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>shopping-bag2</title>\n<path d="M29.2 8.133c0 0 0-0.133-0.133-0.133 0 0 0-0.133-0.133-0.133l-4-5.333c-0.133-0.4-0.533-0.533-0.933-0.533h-16c-0.4 0-0.8 0.133-1.067 0.533l-4 5.333c0 0 0 0.133-0.133 0.133 0 0 0 0.133-0.133 0.133 0 0.267 0 0.4 0 0.533v18.667c0 2.267 1.733 4 4 4h18.667c2.267 0 4-1.733 4-4v-18.667c0-0.133 0-0.267-0.133-0.533zM8.667 4.667h14.667l2 2.667h-18.667l2-2.667zM25.333 28.667h-18.667c-0.8 0-1.333-0.533-1.333-1.333v-17.333h21.333v17.333c0 0.8-0.533 1.333-1.333 1.333zM21.333 12.667c-0.8 0-1.333 0.533-1.333 1.333 0 2.267-1.733 4-4 4s-4-1.733-4-4c0-0.8-0.533-1.333-1.333-1.333s-1.333 0.533-1.333 1.333c0 3.733 2.933 6.667 6.667 6.667s6.667-2.933 6.667-6.667c0-0.8-0.533-1.333-1.333-1.333z"></path>\n</svg>\n';var sallaBottomAlertCss=":host{display:block}";var SallaBottomAlert=function(){function t(t){var e=this;registerInstance(this,t);this.storeId=salla.config.get("store.id");this.template=salla.config.get("store.template");this.loading=false;this.templateData={};this.defaultMessage=salla.lang.get("common.elements.experimental_and_available_store");this.defaultActionLabel=salla.lang.get("common.elements.know_more");this.storeFeatures=salla.lang.get("common.elements.store_features");this.storeDetails=salla.lang.get("common.elements.store_details");this.storePrice=salla.lang.getWithDefault("common.elements.store_price","سعر المتجر");this.theDeveloper=salla.lang.get("common.elements.the_developer");this.templateInformation=salla.lang.get("common.elements.template_information");this.buyTheTemplate=salla.lang.get("common.elements.buy_the_template");this.isRtl=salla.config.get("theme.is_rtl",true);this.type="popup";salla.lang.onLoaded((function(){e.defaultMessage=salla.lang.get("common.elements.experimental_and_available_store");e.defaultActionLabel=salla.lang.get("common.elements.know_more");e.storeFeatures=salla.lang.get("common.elements.store_features");e.storeDetails=salla.lang.get("common.elements.store_details");e.templateInformation=salla.lang.get("common.elements.template_information");e.buyTheTemplate=salla.lang.get("common.elements.buy_the_template");salla.helpers.setNested(salla.lang.messages["ar.trans"],"common.elements.store_price","سعر المتجر");salla.helpers.setNested(salla.lang.messages["en.trans"],"common.elements.store_price","Store Price");salla.helpers.setNested(salla.lang.messages["ar.trans"],"common.elements.the_developer","المطور");salla.helpers.setNested(salla.lang.messages["en.trans"],"common.elements.the_developer","the developer");setTimeout((function(){e.storePrice=salla.lang.get("common.elements.store_price");e.theDeveloper=salla.lang.get("common.elements.the_developer")}),100)}))}t.prototype.open=function(){var t=this;return this.modal.open().then((function(){return t.handleTemplateRequest()}))};t.prototype.getDefaultMessage=function(){return this.isRtl?this.defaultMessage.substring(0,this.defaultMessage.lastIndexOf(" ")):this.defaultMessage.split(" ").slice(0,-2).join(" ")};t.prototype.handleTemplateRequest=function(){var t=this;if(Object.keys(this.templateData).length){return}this.modal.loading();return salla.api.request("/store/template",{},"get",{"Store-Identifier":this.storeId}).then((function(e){t.modal.setTitle(t.templateInformation);t.templateData=e.data;t.modal.stopLoading()})).catch((function(){t.modal.close()}))};t.prototype.handleAction=function(){if(this.type==="link"){window.location.href=this.actionUrl}if(this.type==="popup"){this.open()}};t.prototype.popup=function(){var t=this;var e,i,n,r,a,o,s,l,u,c,f,d,p,v,g,_,m;return h("salla-modal",{class:"s-bottom-alert-modal",ref:function(e){return t.modal=e},"no-padding":true},Object.keys(this.templateData).length?[h("div",{class:"s-bottom-alert-modal-inner s-scrollbar"},Array.isArray((e=this.templateData)===null||e===void 0?void 0:e.screenshots)&&((n=(i=this.templateData)===null||i===void 0?void 0:i.screenshots)===null||n===void 0?void 0:n.length)?h("div",{class:"s-bottom-alert-modal-cover"},h("img",{src:(r=this.templateData)===null||r===void 0?void 0:r.screenshots[0],alt:""})):"",h("div",{class:{"s-bottom-alert-modal-content":true,"s-bottom-alert-modal-content-extra-padding":this.templateData.price}},((a=this.templateData)===null||a===void 0?void 0:a.description)?[h("div",{class:"s-bottom-alert-modal-content-title"},this.storeDetails),h("div",{class:"s-bottom-alert-modal-content-description",innerHTML:(o=this.templateData)===null||o===void 0?void 0:o.description}),h("hr",null)]:"",((s=this.templateData)===null||s===void 0?void 0:s.features)?[h("div",{class:"s-bottom-alert-modal-content-title"},this.storeFeatures),h("div",{class:"s-bottom-alert-modal-content-features",innerHTML:(l=this.templateData)===null||l===void 0?void 0:l.features})]:"",Array.isArray((u=this.templateData)===null||u===void 0?void 0:u.screenshots)&&((f=(c=this.templateData)===null||c===void 0?void 0:c.screenshots)===null||f===void 0?void 0:f.length)>1?h("salla-slider",{id:"template-screenshots",type:"carousel",class:"s-bottom-alert-modal-content-screenshots"},h("div",{slot:"items"},(d=this.templateData)===null||d===void 0?void 0:d.screenshots.map((function(t){return h("div",{class:"s-bottom-alert-modal-content-screenshot"},h("img",{src:t,alt:""}))})))):"",((p=this.templateData)===null||p===void 0?void 0:p.extra_info)?h("div",{class:"s-bottom-alert-modal-content-description",innerHTML:(v=this.templateData)===null||v===void 0?void 0:v.description}):""),((g=this.templateData)===null||g===void 0?void 0:g.link)?h("div",{class:"s-bottom-alert-modal-content-footer"},this.templateData.price&&h("div",{class:"s-bottom-alert-modal-price-wrapper"},h("div",null,this.storePrice),h("div",{class:"s-bottom-alert-modal-price-wrapper-amount",innerHTML:salla.money((_=this.templateData)===null||_===void 0?void 0:_.price)})),h("salla-button",{color:"primary",size:"medium",width:"wide",href:(m=this.templateData)===null||m===void 0?void 0:m.link},h("i",{innerHTML:shoppingBag}),this.buyTheTemplate)):"")]:"")};t.prototype.render=function(){var t=this;var e=this.template&&typeof this.template==="object"&&Object.keys(this.template).length>0;var i=e&&this.template.developer;var n=i!==undefined;var r=n&&(i===null||i===void 0?void 0:i.name);var a=null;return h(Host,{key:"54afc00bdffa94ff3717f2ba6ddd2ed82534cb4a",class:"s-bottom-alert-wrapper"},h("div",{key:"634f4f43d9ffada203efa37f1e4e56b5afc61c99",class:"s-bottom-alert-content"},h("div",{key:"83796d918d9773926cee99cb6891f5c5a9e1151f",class:"s-bottom-alert-icon"},this.icon?h("i",{class:this.icon}):h("i",{innerHTML:infoIcon})),h("div",{key:"e4f4e9f715868c07c5c425085542ada70aa6f76b",class:"s-bottom-alert-message"},this.message?this.message:e?h("span",null,this.getDefaultMessage()," ",h("a",{href:"#",class:{"s-bottom-alert-message-highlight":true,"s-bottom-alert-message-link":a},target:"","aria-label":"Developer"},r?r:this.theDeveloper)," ",h("span",{class:"s-bottom-alert-message-splitter"},"|")," ",this.storePrice,":"," ",h("span",{class:"s-bottom-alert-message-highlight",innerHTML:salla.money(this.template.price)})):this.defaultMessage),this.type!=="banner"&&h("div",{key:"82e089d7d9a5975cac5476e4dd1adf196b4492fe",class:"s-bottom-alert-action"},h("salla-button",{key:"29f693dfd29da4f8d11e519729738fcd5aaad974",href:this.actionUrl,size:"medium",onClick:function(){return t.handleAction()},width:"normal"},this.actionLabel||this.defaultActionLabel)),this.type==="popup"&&this.popup()))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaBottomAlert.style=sallaBottomAlertCss;var ArrowLeftIcon='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>keyboard_arrow_left</title>\n<path d="M20.563 22.104l-1.875 1.875-8-8 8-8 1.875 1.875-6.125 6.125z"></path>\n</svg>\n';var ArrowRightIcon='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>keyboard_arrow_right</title>\n<path d="M11.438 22.479l6.125-6.125-6.125-6.125 1.875-1.875 8 8-8 8z"></path>\n</svg>\n';var sallaBreadcrumbCss=":host{display:block}";var SallaBreadcrumb=function(){function t(t){registerInstance(this,t);var e,i;this.sessionStorageKey="breadcrumb_snapshot";this.itemSlot=((e=this.host.querySelector('[slot="item"]'))===null||e===void 0?void 0:e.outerHTML)||'<li class="s-breadcrumb-item"><a href={url}>{title}</a></li>';this.iconSlot=(i=this.host.querySelector('[slot="icon"]'))===null||i===void 0?void 0:i.outerHTML}t.prototype.componentWillLoad=function(){var t=this;return new Promise((function(t){return salla.onReady((function(){return salla.lang.onLoaded(t)}))})).then((function(){if(salla.url.is_page("index")){throw new Error("salla-breadcrumb:: breadcrumb not supported on home page")}})).then((function(){if(!salla.config.get("theme.settings.is_breadcrumbs_enabled",true)){throw new Error("salla-breadcrumb:: merchant disabled the feature")}})).then((function(){var e;var i=salla.config.get("page");if(!i||!i.slug){salla.logger.error('salla-breadcrumbs:: page object not existed on salla.config.get("page")!');t.breadcrumbs=[];return}var n=t.getSessionBreadcrumbs();if(i.slug==="product.single"&&n&&n.length>0){n.push({title:i.title,url:i.url});t.breadcrumbs=t.setBreadcrumbsFromArray(n);t.storeBreadcrumbSnapshot()}else if(n&&n.length>0){if(t.isNewPage(i,n)){t.breadcrumbs=t.generateBreadcrumbs(i);t.storeBreadcrumbSnapshot()}else{t.breadcrumbs=t.setBreadcrumbsFromArray(n)}}else{t.breadcrumbs=t.generateBreadcrumbs(i);t.storeBreadcrumbSnapshot()}if((e=t.breadcrumbs)===null||e===void 0?void 0:e.length){t.breadcrumbs[t.breadcrumbs.length-1].is_last=true}return t.breadcrumbs})).catch((function(e){salla.logger.error("salla-breadcrumb:: unexpected error!",e);t.breadcrumbs=[]}))};t.prototype.getSessionBreadcrumbs=function(){if(new URLSearchParams(window.location.search).get("from")==="search-bar"){return[]}return JSON.parse(sessionStorage.getItem(this.sessionStorageKey)||"[]")};t.prototype.isNewPage=function(t,e){var i=e[e.length-1];return(i===null||i===void 0?void 0:i.url)!==t.url};t.prototype.setBreadcrumbsFromArray=function(t){return t.map((function(e,i){return Object.assign(Object.assign({},e),{is_last:i===t.length-1})}))};t.prototype.sanitizeBreadcrumbTitle=function(t,e){if(e===void 0){e=1}if(!t.includes("|")){return t.trim()}return t.split("|").map((function(t){return t.trim()}))[e]};t.prototype.generateBreadcrumbs=function(t){var e,i;var n=[];if(t.slug==="product.single"){var r=this.getSessionBreadcrumbs();if(r.length>0&&((e=r[1])===null||e===void 0?void 0:e.url)===((i=t.parent)===null||i===void 0?void 0:i.url)){return this.setBreadcrumbsFromArray(__spreadArray(__spreadArray([],r,true),[t],false))}}var a=t;while(a){if(a.title){n.unshift({title:a.title,url:a.url})}a=a.parent}if(t.slug.includes("customer")&&t.slug!=="customer.profile"){n.unshift({title:salla.lang.get("common.titles.profile"),url:salla.url.get("profile")})}if(t.slug.includes("blog")){n.unshift({title:salla.lang.get("blocks.footer.blog"),url:salla.url.get("blog")})}if(t.slug==="brands.single"){n.unshift({title:salla.lang.get("common.titles.brands"),url:salla.url.get("brands")})}if(!t.title&&t.slug==="loyalty"){n.unshift({title:salla.lang.get("common.titles.loyalty_program"),url:salla.url.get("loyalty")})}n.unshift({title:salla.lang.get("common.titles.home"),url:salla.url.get("")});return n};t.prototype.storeBreadcrumbSnapshot=function(){try{var t=salla.config.get("page");if((t===null||t===void 0?void 0:t.slug)==="product.single"){return}var e=__spreadArray([],this.breadcrumbs,true);var i=e.length-1;if(i>=0){e[i].url=window.location.href}var n=JSON.stringify(e);sessionStorage.setItem(this.sessionStorageKey,n)}catch(t){salla.logger.error("salla-breadcrumb:: Failed to store breadcrumb snapshot in sessionStorage.",t)}};t.prototype.render=function(){var t=this;if(this.breadcrumbs.length<=1){salla.log("salla-breadcrumb:: There is no breadcrumbs!");return null}return h("ol",{class:{"s-breadcrumb-wrapper":true,"s-breadcrumb-dark":salla.url.is_page("loyalty"),"s-breadcrumb-primary-reverse":salla.config.get("page.slug").includes("customer")}},this.breadcrumbs.map((function(e){var i=salla.config.get("page.slug")==="product.single";var n=i&&e.is_last?e.title:t.sanitizeBreadcrumbTitle(e.title);var r=t.itemSlot.replace(/\{url\}/g,e.url).replace(/\{title\}/g,n);return[h("div",{class:"s-breadcrumb-slot",innerHTML:r}),t.getArrowDomForItem(e)]})))};t.prototype.getArrowDomForItem=function(t){if(t.is_last){return""}var e=this.iconSlot||(salla.config.get("theme.is_rtl",true)?ArrowLeftIcon:ArrowRightIcon);return h("li",{class:"s-breadcrumb-arrow"},h("div",{class:{"s-breadcrumb-icon-slot":true,"s-breadcrumb-default-icon":!this.iconSlot},innerHTML:e}))};t.prototype.componentDidRender=function(){var t,e,i;this.host.querySelectorAll(".s-breadcrumb-slot").forEach((function(t){return t.replaceWith(t.firstChild)}));this.host.querySelectorAll(".s-breadcrumb-icon-slot.s-breadcrumb-default-icon").forEach((function(t){return t.replaceWith(t.querySelector("svg"))}));(t=this.host.querySelector('[slot="item"]'))===null||t===void 0?void 0:t.remove();(e=this.host.querySelector('[slot="icon"]'))===null||e===void 0?void 0:e.remove();var n=(i=this.host.querySelectorAll(".s-breadcrumb-item")[this.breadcrumbs.length-1])===null||i===void 0?void 0:i.querySelector("a");n&&n.replaceWith(n.firstChild)};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaBreadcrumb.style=sallaBreadcrumbCss;var sallaButtonCss="";var SallaButton=function(){function t(t){registerInstance(this,t);this.hostAttributes={};this.shape="btn";this.color="primary";this.fill="solid";this.size="medium";this.width="normal";this.loading=false;this.disabled=false;this.loaderPosition="after";this.type="button"}t.prototype.load=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(this.loaderPosition=="center")this.text.classList.add("s-button-hide");this.host.setAttribute("loading","");return[2,this.host]}))}))};t.prototype.stop=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.host.removeAttribute("loading");this.host.querySelector("button").removeAttribute("loading");if(this.loaderPosition=="center")this.text.classList.remove("s-button-hide");return[2,this.host]}))}))};t.prototype.setText=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.text.innerHTML=t;return[2,this.host]}))}))};t.prototype.disable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.host.setAttribute("disabled","");return[2,this.host]}))}))};t.prototype.enable=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.host.removeAttribute("disabled");return[2,this.host]}))}))};t.prototype.getBtnAttributes=function(){for(var t=0;t<this.host.attributes.length;t++){if(!["color","fill","size","width","id"].includes(this.host.attributes[t].name)){this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value}}this.hostAttributes.type=this.hostAttributes.type||this.type;this.hostAttributes.class+=" s-button-element s-button-"+this.shape+" s-button-"+(this.fill=="none"?"fill-none":this.fill)+(this.size!="medium"?" s-button-"+this.size:"")+(this.width!="normal"?" s-button-"+this.width:"")+(this.shape=="link"?" s-button-"+this.color+"-link":"")+(this.shape!="link"&&this.fill!="outline"?" s-button-"+this.color:"")+(this.fill=="outline"?" s-button-"+this.color+"-outline":"")+(this.disabled?" s-button-disabled ":"")+(this.shape=="icon"?" s-button-loader-center":" s-button-loader-"+this.loaderPosition);return this.hostAttributes};t.prototype.button=function(){var t=this;return h("button",Object.assign({},this.getBtnAttributes(),{disabled:this.disabled}),h("span",{class:"s-button-text",ref:function(e){return t.text=e}},h("slot",null)),this.loading?h("span",{class:"s-button-loader"}):"")};t.prototype.render=function(){var t;return((t=this.host.closest(".swiper-slide"))===null||t===void 0?void 0:t.classList.contains("swiper-slide-duplicate"))?"":h(Host,{class:"s-button-wrap"},this.href?h("a",{href:this.href},this.button()):this.button())};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaButton.style=sallaButtonCss;var sallaCartSummaryCss="";var SallaCartSummary=function(){function t(t){var e=this;registerInstance(this,t);this.cartSummaryCount=salla.storage.get("cart.summary.count")||0;this.cartSummaryTotal=salla.storage.get("cart.summary.total")||0;this.cartLabel=salla.config.get("user.language_code")==="ar"?"السلة":"Cart";salla.cart.event.onUpdated((function(t){e.cartSummaryCount=t.count||0;e.cartSummaryTotal=t.total||0}))}t.prototype.animateToCart=function(t){return __awaiter(this,void 0,void 0,(function(){var e,i,n,r,a,o,s,l,u,c,f,d;return __generator(this,(function(h){document.querySelectorAll(".s-cart-thumb").forEach((function(t){return t.remove()}));if(!(t===null||t===void 0?void 0:t.src)){salla.log("Failed to get the img element");return[2]}e=this.host.querySelector("#s-cart-icon"),i=e.getBoundingClientRect(),n=i.top+window.scrollY,r=i.left+window.scrollX;a=t.getBoundingClientRect(),o=t.offsetWidth+"px",s=t.offsetHeight+"px",l=a.top,u=a.left;c=document.createElement("img");c.src=t.getAttribute("src");c.className="s-cart-thumb";c.setAttribute("style","object-fit:cover; width:"+o+"; height:"+s+"; top:"+l+"px; left:"+u+"px;z-index:99999999; ");document.body.append(c);f=document.querySelector(".s-cart-thumb");e.classList.remove("animated","rubberBand");d=new anime.timeline;d.add({targets:f,width:[150,30],height:[150,30],top:[l,window.scrollY>0?n-window.scrollY-40:n-40],left:[u,r],borderRadius:["20%","50%"],easing:"easeOutExpo",duration:1200},"+=200").add({targets:f,width:[30,0],height:[30,0],opacity:[1,0],easing:"easeOutExpo",top:[window.scrollY>0?n-window.scrollY-40:n-40,window.scrollY>0?n-window.scrollY+10:n+10],left:[r,r+10]},"-=500").add({complete:function(){e.classList.add("animated","rubberBand");f.remove()}},"-=1700");return[2]}))}))};t.prototype.componentWillLoad=function(){return new Promise((function(t){return salla.onReady(t)}))};t.prototype.render=function(){return h(Host,{key:"f536afae4840b08133a82698fab4b4df6d479e14"},h("a",{key:"26185bdeec4028f6fe936e5a0970fec799761bdd",class:"s-cart-summary-wrapper",href:salla.url.get("cart")},h("div",{key:"817fb77ac1feedd59d23b35a53648382aa3e300c",id:"s-cart-icon"},h("slot",{key:"3d0601960d662d63988b44f1745d222c43f8ecd7",name:"icon"},h("i",{key:"27da6c6fe8da8bd634fad5e39b9b62ec061694b1",class:"s-cart-summary-icon",innerHTML:PendingOrdersIcon}))),h("span",{key:"e1a63ea518c783207d85a657778fb739bc1f386f",class:"s-cart-summary-count"},salla.helpers.number(this.cartSummaryCount)),h("p",{key:"4133fd68ef50ff54609718274f3daa2f87511a3b",class:"s-cart-summary-content"},this.showCartLabel&&h("span",{key:"ec133e448903ec65c42cc7ec35984ca90bbb9a1c",class:"s-cart-summary-label"},this.cartLabel),h("b",{key:"c0e06bab8d8032e37e4059dfce54135f89a6a8d3",class:"s-cart-summary-total",innerHTML:salla.money(this.cartSummaryTotal)}))))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();SallaCartSummary.style=sallaCartSummaryCss;var vanillaPicker$1={exports:{}}; /*! * vanilla-picker v2.12.3 * https://vanilla-picker.js.org * * Copyright 2017-2024 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate) * Released under the ISC license. */var vanillaPicker=vanillaPicker$1.exports;var hasRequiredVanillaPicker;function requireVanillaPicker(){if(hasRequiredVanillaPicker)return vanillaPicker$1.exports;hasRequiredVanillaPicker=1;(function(t,e){(function(e,i){t.exports=i()})(vanillaPicker,(function(){var t=function(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}};var e=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(t,n.key,n)}}return function(e,i,n){if(i)t(e.prototype,i);if(n)t(e,n);return e}}();var i=function(){function t(t,e){var i=[];var n=true;var r=false;var a=undefined;try{for(var o=t[Symbol.iterator](),s;!(n=(s=o.next()).done);n=true){i.push(s.value);if(e&&i.length===e)break}}catch(t){r=true;a=t}finally{try{if(!n&&o["return"])o["return"]()}finally{if(r)throw a}}return i}return function(e,i){if(Array.isArray(e)){return e}else if(Symbol.iterator in Object(e)){return t(e,i)}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}}}();String.prototype.startsWith=String.prototype.startsWith||function(t){return this.indexOf(t)===0};String.prototype.padStart=String.prototype.padStart||function(t,e){var i=this;while(i.length<t){i=e+i}return i};var n={cb:"0f8ff",tqw:"aebd7",q:"-ffff",qmrn:"7fffd4",zr:"0ffff",bg:"5f5dc",bsq:"e4c4",bck:"---",nch:"ebcd",b:"--ff",bvt:"8a2be2",brwn:"a52a2a",brw:"deb887",ctb:"5f9ea0",hrt:"7fff-",chcT:"d2691e",cr:"7f50",rnw:"6495ed",crns:"8dc",crms:"dc143c",cn:"-ffff",Db:"--8b",Dcn:"-8b8b",Dgnr:"b8860b",Dgr:"a9a9a9",Dgrn:"-64-",Dkhk:"bdb76b",Dmgn:"8b-8b",Dvgr:"556b2f",Drng:"8c-",Drch:"9932cc",Dr:"8b--",Dsmn:"e9967a",Dsgr:"8fbc8f",DsTb:"483d8b",DsTg:"2f4f4f",Dtrq:"-ced1",Dvt:"94-d3",ppnk:"1493",pskb:"-bfff",mgr:"696969",grb:"1e90ff",rbrc:"b22222",rwht:"af0",stg:"228b22",chs:"-ff",gnsb:"dcdcdc",st:"8f8ff",g:"d7-",gnr:"daa520",gr:"808080",grn:"-8-0",grnw:"adff2f",hnw:"0fff0",htpn:"69b4",nnr:"cd5c5c",ng:"4b-82",vr:"0",khk:"0e68c",vnr:"e6e6fa",nrb:"0f5",wngr:"7cfc-",mnch:"acd",Lb:"add8e6",Lcr:"08080",Lcn:"e0ffff",Lgnr:"afad2",Lgr:"d3d3d3",Lgrn:"90ee90",Lpnk:"b6c1",Lsmn:"a07a",Lsgr:"20b2aa",Lskb:"87cefa",LsTg:"778899",Lstb:"b0c4de",Lw:"e0",m:"-ff-",mgrn:"32cd32",nn:"af0e6",mgnt:"-ff",mrn:"8--0",mqm:"66cdaa",mmb:"--cd",mmrc:"ba55d3",mmpr:"9370db",msg:"3cb371",mmsT:"7b68ee","":"-fa9a",mtr:"48d1cc",mmvt:"c71585",mnLb:"191970",ntc:"5fffa",mstr:"e4e1",mccs:"e4b5",vjw:"dead",nv:"--80",c:"df5e6",v:"808-0",vrb:"6b8e23",rng:"a5-",rngr:"45-",rch:"da70d6",pgnr:"eee8aa",pgrn:"98fb98",ptrq:"afeeee",pvtr:"db7093",ppwh:"efd5",pchp:"dab9",pr:"cd853f",pnk:"c0cb",pm:"dda0dd",pwrb:"b0e0e6",prp:"8-080",cc:"663399",r:"--",sbr:"bc8f8f",rb:"4169e1",sbrw:"8b4513",smn:"a8072",nbr:"4a460",sgrn:"2e8b57",ssh:"5ee",snn:"a0522d",svr:"c0c0c0",skb:"87ceeb",sTb:"6a5acd",sTgr:"708090",snw:"afa",n:"-ff7f",stb:"4682b4",tn:"d2b48c",t:"-8080",thst:"d8bfd8",tmT:"6347",trqs:"40e0d0",vt:"ee82ee",whT:"5deb3",wht:"",hts:"5f5f5",w:"-",wgrn:"9acd32"};function r(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;var i=e>0?t.toFixed(e).replace(/0+$/,"").replace(/\.$/,""):t.toString();return i||"0"}var a=function(){function a(e,n,r,o){t(this,a);var s=this;function l(t){if(t.startsWith("hsl")){var e=t.match(/([\-\d\.e]+)/g).map(Number),n=i(e,4),r=n[0],o=n[1],l=n[2],u=n[3];if(u===undefined){u=1}r/=360;o/=100;l/=100;s.hsla=[r,o,l,u]}else if(t.startsWith("rgb")){var c=t.match(/([\-\d\.e]+)/g).map(Number),f=i(c,4),d=f[0],h=f[1],p=f[2],v=f[3];if(v===undefined){v=1}s.rgba=[d,h,p,v]}else{if(t.startsWith("#")){s.rgba=a.hexToRgb(t)}else{s.rgba=a.nameToRgb(t)||a.hexToRgb(t)}}}if(e===undefined);else if(Array.isArray(e)){this.rgba=e}else if(r===undefined){var u=e&&""+e;if(u){l(u.toLowerCase())}}else{this.rgba=[e,n,r,o===undefined?1:o]}}e(a,[{key:"printRGB",value:function t(e){var i=e?this.rgba:this.rgba.slice(0,3),n=i.map((function(t,e){return r(t,e===3?3:0)}));return e?"rgba("+n+")":"rgb("+n+")"}},{key:"printHSL",value:function t(e){var i=[360,100,100,1],n=["","%","%",""];var a=e?this.hsla:this.hsla.slice(0,3),o=a.map((function(t,e){return r(t*i[e],e===3?3:1)+n[e]}));return e?"hsla("+o+")":"hsl("+o+")"}},{key:"printHex",value:function t(e){var i=this.hex;return e?i:i.substring(0,7)}},{key:"rgba",get:function t(){if(this._rgba){return this._rgba}if(!this._hsla){throw new Error("No color is set")}return this._rgba=a.hslToRgb(this._hsla)},set:function t(e){if(e.length===3){e[3]=1}this._rgba=e;this._hsla=null}},{key:"rgbString",get:function t(){return this.printRGB()}},{key:"rgbaString",get:function t(){return this.printRGB(true)}},{key:"hsla",get:function t(){if(this._hsla){return this._hsla}if(!this._rgba){throw new Error("No color is set")}return this._hsla=a.rgbToHsl(this._rgba)},set:function t(e){if(e.length===3){e[3]=1}this._hsla=e;this._rgba=null}},{key:"hslString",get:function t(){return this.printHSL()}},{key:"hslaString",get:function t(){return this.printHSL(true)}},{key:"hex",get:function t(){var e=this.rgba,i=e.map((function(t,e){return e<3?t.toString(16):Math.round(t*255).toString(16)}));return"#"+i.map((function(t){return t.padStart(2,"0")})).join("")},set:function t(e){this.rgba=a.hexToRgb(e)}}],[{key:"hexToRgb",value:function t(e){var i=(e.startsWith("#")?e.slice(1):e).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!i.match(/^([0-9a-fA-F]{8})$/)){throw new Error("Unknown hex color; "+e)}var n=i.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(t){return parseInt(t,16)}));n[3]=n[3]/255;return n}},{key:"nameToRgb",value:function t(e){var i=e.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),r=n[i];return r===undefined?r:a.hexToRgb(r.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function t(e){var n=i(e,4),r=n[0],a=n[1],o=n[2],s=n[3];r/=255;a/=255;o/=255;var l=Math.max(r,a,o),u=Math.min(r,a,o);var c=void 0,f=void 0,d=(l+u)/2;if(l===u){c=f=0}else{var h=l-u;f=d>.5?h/(2-l-u):h/(l+u);switch(l){case r:c=(a-o)/h+(a<o?6:0);break;case a:c=(o-r)/h+2;break;case o:c=(r-a)/h+4;break}c/=6}return[c,f,d,s]}},{key:"hslToRgb",value:function t(e){var n=i(e,4),r=n[0],a=n[1],o=n[2],s=n[3];var l=void 0,u=void 0,c=void 0;if(a===0){l=u=c=o}else{var f=function t(e,i,n){if(n<0)n+=1;if(n>1)n-=1;if(n<1/6)return e+(i-e)*6*n;if(n<1/2)return i;if(n<2/3)return e+(i-e)*(2/3-n)*6;return e};var d=o<.5?o*(1+a):o+a-o*a,h=2*o-d;l=f(h,d,r+1/3);u=f(h,d,r);c=f(h,d,r-1/3)}var p=[l*255,u*255,c*255].map(Math.round);p[3]=s;return p}}]);return a}();var o=function(){function i(){t(this,i);this._events=[]}e(i,[{key:"add",value:function t(e,i,n){e.addEventListener(i,n,false);this._events.push({target:e,type:i,handler:n})}},{key:"remove",value:function t(e,n,r){this._events=this._events.filter((function(t){var a=true;if(e&&e!==t.target){a=false}if(n&&n!==t.type){a=false}if(r&&r!==t.handler){a=false}if(a){i._doRemove(t.target,t.type,t.handler)}return!a}))}},{key:"destroy",value:function t(){this._events.forEach((function(t){return i._doRemove(t.target,t.type,t.handler)}));this._events=[]}}],[{key:"_doRemove",value:function t(e,i,n){e.removeEventListener(i,n,false)}}]);return i}();function s(t){var e=document.createElement("div");e.innerHTML=t;return e.firstElementChild}function l(t,e,i){var n=false;function r(t,e,i){return Math.max(e,Math.min(t,i))}function a(t,a,o){if(o){n=true}if(!n){return}t.preventDefault();var s=e.getBoundingClientRect(),l=s.width,u=s.height,c=a.clientX,f=a.clientY;var d=r(c-s.left,0,l),h=r(f-s.top,0,u);i(d/l,h/u)}function o(t,e){var i=t.buttons===undefined?t.which:t.buttons;if(i===1){a(t,t,e)}else{n=false}}function s(t,e){if(t.touches.length===1){a(t,t.touches[0],e)}else{n=false}}t.add(e,"mousedown",(function(t){o(t,true)}));t.add(e,"touchstart",(function(t){s(t,true)}));t.add(window,"mousemove",o);t.add(e,"touchmove",s);t.add(window,"mouseup",(function(t){n=false}));t.add(e,"touchend",(function(t){n=false}));t.add(e,"touchcancel",(function(t){n=false}))}var u="linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em";var c=360;var f="keydown",d="mousedown",h="focusin";function p(t,e){return(e||document).querySelector(t)}function v(t){t.preventDefault();t.stopPropagation()}function g(t,e,i,n,r){t.add(e,f,(function(t){if(i.indexOf(t.key)>=0){n(t)}}))}var _=function(){function i(e){t(this,i);this.settings={popup:"right",layout:"default",alpha:true,editor:true,editorFormat:"hex",cancelButton:false,defaultColor:"#0cf"};this._events=new o;this.onChange=null;this.onDone=null;this.onOpen=null;this.onClose=null;this.setOptions(e)}e(i,[{key:"setOptions",value:function t(e){var i=this;if(!e){return}var n=this.settings;function r(t,e,i){for(var n in t){e[n]=t[n]}}if(e instanceof HTMLElement){n.parent=e}else{if(n.parent&&e.parent&&n.parent!==e.parent){this._events.remove(n.parent);this._popupInited=false}r(e,n);if(e.onChange){this.onChange=e.onChange}if(e.onDone){this.onDone=e.onDone}if(e.onOpen){this.onOpen=e.onOpen}if(e.onClose){this.onClose=e.onClose}var a=e.color||e.colour;if(a){this._setColor(a)}}var o=n.parent;if(o&&n.popup&&!this._popupInited){var s=function t(e){return i.openHandler(e)};this._events.add(o,"click",s);g(this._events,o,[" ","Spacebar","Enter"],s);this._popupInited=true}else if(e.parent&&!n.popup){this.show()}}},{key:"openHandler",value:function t(e){if(this.show()){e&&e.preventDefault();this.settings.parent.style.pointerEvents="none";var i=e&&e.type===f?this._domEdit:this.domElement;setTimeout((function(){return i.focus()}),100);if(this.onOpen){this.onOpen(this.colour)}}}},{key:"closeHandler",value:function t(e){var i=e&&e.type;var n=false;if(!e){n=true}else if(i===d||i===h){var r=(this.__containedEvent||0)+100;if(e.timeStamp>r){n=true}}else{v(e);n=true}if(n&&this.hide()){this.settings.parent.style.pointerEvents="";if(i!==d){this.settings.parent.focus()}if(this.onClose){this.onClose(this.colour)}}}},{key:"movePopup",value:function t(e,i){this.closeHandler();this.setOptions(e);if(i){this.openHandler()}}},{key:"setColor",value:function t(e,i){this._setColor(e,{silent:i})}},{key:"_setColor",value:function t(e,i){if(typeof e==="string"){e=e.trim()}if(!e){return}i=i||{};var n=void 0;try{n=new a(e)}catch(t){if(i.failSilently){return}throw t}if(!this.settings.alpha){var r=n.hsla;r[3]=1;n.hsla=r}this.colour=this.color=n;this._setHSLA(null,null,null,null,i)}},{key:"setColour",value:function t(e,i){this.setColor(e,i)}},{key:"show",value:function t(){var e=this.settings.parent;if(!e){return false}if(this.domElement){var i=this._toggleDOM(true);this._setPosition();return i}var n=this.settings.template||'<div class="picker_wrapper" tabindex="-1"><div class="picker_arrow"></div><div class="picker_hue picker_slider"><div class="picker_selector"></div></div><div class="picker_sl"><div class="picker_selector"></div></div><div class="picker_alpha picker_slider"><div class="picker_selector"></div></div><div class="picker_editor"><input aria-label="Type a color name or hex value"/></div><div class="picker_sample"></div><div class="picker_done"><button>Ok</button></div><div class="picker_cancel"><button>Cancel</button></div></div>';var r=s(n);this.domElement=r;this._domH=p(".picker_hue",r);this._domSL=p(".picker_sl",r);this._domA=p(".picker_alpha",r);this._domEdit=p(".picker_editor input",r);this._domSample=p(".picker_sample",r);this._domOkay=p(".picker_done button",r);this._domCancel=p(".picker_cancel button",r);r.classList.add("layout_"+this.settings.layout);if(!this.settings.alpha){r.classList.add("no_alpha")}if(!this.settings.editor){r.classList.add("no_editor")}if(!this.settings.cancelButton){r.classList.add("no_cancel")}this._ifPopup((function(){return r.classList.add("popup")}));this._setPosition();if(this.colour){this._updateUI()}else{this._setColor(this.settings.defaultColor)}this._bindEvents();return true}},{key:"hide",value:function t(){return this._toggleDOM(false)}},{key:"destroy",value:function t(){this._events.destroy();if(this.domElement){this.settings.parent.removeChild(this.domElement)}}},{key:"_bindEvents",value:function t(){var e=this;var i=this,n=this.domElement,r=this._events;function a(t,e,i){r.add(t,e,i)}a(n,"click",(function(t){return t.preventDefault()}));l(r,this._domH,(function(t,e){return i._setHSLA(t)}));l(r,this._domSL,(function(t,e){return i._setHSLA(null,t,1-e)}));if(this.settings.alpha){l(r,this._domA,(function(t,e){return i._setHSLA(null,null,null,1-e)}))}var o=this._domEdit;{a(o,"input",(function(t){i._setColor(this.value,{fromEditor:true,failSilently:true})}));a(o,"focus",(function(t){var e=this;if(e.selectionStart===e.selectionEnd){e.select()}}))}this._ifPopup((function(){var t=function t(i){return e.closeHandler(i)};a(window,d,t);a(window,h,t);g(r,n,["Esc","Escape"],t);var i=function t(i){e.__containedEvent=i.timeStamp};a(n,d,i);a(n,h,i);a(e._domCancel,"click",t)}));var s=function t(i){e._ifPopup((function(){return e.closeHandler(i)}));if(e.onDone){e.onDone(e.colour)}};a(this._domOkay,"click",s);g(r,n,["Enter"],s)}},{key:"_setPosition",value:function t(){var e=this.settings.parent,i=this.domElement;if(e!==i.parentNode){e.appendChild(i)}this._ifPopup((function(t){if(getComputedStyle(e).position==="static"){e.style.position="relative"}var n=t===true?"popup_right":"popup_"+t;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(t){if(t===n){i.classList.add(t)}else{i.classList.remove(t)}}));i.classList.add(n)}))}},{key:"_setHSLA",value:function t(e,i,n,r,a){a=a||{};var o=this.colour,s=o.hsla;[e,i,n,r].forEach((function(t,e){if(t||t===0){s[e]=t}}));o.hsla=s;this._updateUI(a);if(this.onChange&&!a.silent){this.onChange(o)}}},{key:"_updateUI",value:function t(e){if(!this.domElement){return}e=e||{};var i=this.colour,n=i.hsla,r="hsl("+n[0]*c+", 100%, 50%)",a=i.hslString,o=i.hslaString;var s=this._domH,l=this._domSL,f=this._domA,d=p(".picker_selector",s),h=p(".picker_selector",l),v=p(".picker_selector",f);function g(t,e,i){e.style.left=i*100+"%"}function _(t,e,i){e.style.top=i*100+"%"}g(s,d,n[0]);this._domSL.style.backgroundColor=this._domH.style.color=r;g(l,h,n[1]);_(l,h,1-n[2]);l.style.color=a;_(f,v,1-n[3]);var m=a,b=m.replace("hsl","hsla").replace(")",", 0)"),w="linear-gradient("+[m,b]+")";this._domA.style.background=w+", "+u;if(!e.fromEditor){var y=this.settings.editorFormat,x=this.settings.alpha;var E=void 0;switch(y){case"rgb":E=i.printRGB(x);break;case"hsl":E=i.printHSL(x);break;default:E=i.printHex(x)}this._domEdit.value=E}this._domSample.style.color=o}},{key:"_ifPopup",value:function t(e,i){if(this.settings.parent&&this.settings.popup){e&&e(this.settings.popup)}else{i&&i()}}},{key:"_toggleDOM",value:function t(e){var i=this.domElement;if(!i){return false}var n=e?"":"none",r=i.style.display!==n;if(r){i.style.display=n}return r}}]);return i}();{var m=document.createElement("style");m.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%