var EasyWeekWidget=function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;n=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function s(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],i=!0,o=!1,a=void 0;try{for(var r,s=t[Symbol.iterator]();!(i=(r=s.next()).done)&&(n.push(r.value),!e||n.length!==e);i=!0);}catch(t){o=!0,a=t}finally{try{i||null==s.return||s.return()}finally{if(o)throw a}}return n}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n1&&(h="GTM".concat(v[1].split("'")[0]))}}this[d("gtm")]=h,this._trackers.push("gtm")}else n.gtm_tracking_id&&(this._initGtm(n.gtm_tracking_id),this[d("gtm")]=n.gtm_tracking_id,this._trackers.push("gtm"));if(n.ym_autodetect&&window.ym){for(var m in window)if(m.startsWith("yaCounter")){var f=parseInt(m.replace("yaCounter",""));f&&(this[d("ym")]=f,this._trackers.push("ym"))}}else n.ym_tracking_id&&(this._initYm(n.ym_tracking_id),this[d("ym")]=n.ym_tracking_id,this._trackers.push("ym"));if(n.roistat_autodetect)if(window.roistat)this[d("roistat")]=window.roistatProjectId,this._trackers.push("roistat");else{var _="function"==typeof window.onRoistatAllModulesLoaded&&window.onRoistatAllModulesLoaded;window.onRoistatAllModulesLoaded=function(){i[d("roistat")]=window.roistatProjectId,i._trackers.push("roistat"),_&&_()}}else n.roistat_tracking_id&&(window.onRoistatAllModulesLoaded=function(){i._trackers.push("roistat")},this._initRoistat(n.roistat_tracking_id),this[d("roistat")]=n.roistat_tracking_id);n.facebook_pixel_autodetect&&window.fbq?this._trackers.push("facebook"):n.facebook_pixel_tracking_id&&(this._initFacebook(n.facebook_pixel_tracking_id),this[d("facebook")]=n.facebook_pixel_tracking_id,this._trackers.push("facebook")),n.cookiebot_code&&(this._initCookiebot(n.cookiebot_code,!!n.gtm_tracking_id),this[d("cookiebot")]=n.cookiebot_code,this._trackers.push("cookiebot"))}return n(e,[{key:"track",value:function(t){for(var e=0;e {\n return `\n \n `\n }'),g=JSON.parse(h),u=new Function("return "+g)(),v=/instagram/i,m=/(https?:\/\/[^/]+)\/([^/]+)\/?([^/]+)?\/?([^/]+)?\/?(users|date)?/,f=/(https?:\/\/[^/]+)\/([^/]+)\/(?:team\/)([^/]+)?\/?([^/]+)\/?([^/]+)?/,_=/gift-card/i,p={text:"Book Now",showText:!1,color:"#fff",background:"#58B44B",textColor:"#000",textBackground:"#fff"},w="EWBookingWidget",y="EWBookingWidgetTrigger";return function(){function e(n){var i=n.url,o=n.button,r=n.logo,s=void 0===r||r,c=n.logoBackground,d=n.trigger;t(this,e),this.loaded=!1,this._setUrl(i),this.button=o,this._buttonProps=a(a({},p),o),this._logo=s,this._logoBackground=c,this._isLoading=!1,this.triggerSelector=".".concat(y).concat(d?", ".concat(d):""),this.isInstagram="undefined"!=typeof window&&v.test(window.navigator.userAgent),this.start=this.start.bind(this),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",this.start):this.start()}return n(e,[{key:"url",get:function(){var t=this;return(this._url.team?[this._url.domain,this._url.slug,"team",this._url.branchId,this._url.userId,this._url.productId]:this._url.giftCardId?[this._url.domain,this._url.slug,this._url.branchId,"gift-card",this._url.giftCardId]:[this._url.domain,this._url.slug,this._url.branchId,this._url.productId,this._url.postfix]).filter(Boolean).join("/")+(Object.keys(this._query).length?"?"+Object.keys(this._query).reduce((function(e,n){return null===t._query[n]||void 0===t._query[n]?e:e.concat("".concat(n,"=").concat(encodeURIComponent(t._query[n])))}),[]).join("&"):"")}},{key:"start",value:function(){this._buttonProps.position||(this._buttonProps.position=function(){try{return"rtl"===getComputedStyle(document.body).direction}catch(t){return!1}}()?"left":"right"),document.removeEventListener("DOMContentLoaded",this.start),this._toggleInstagramClass(this.isInstagram),this.button&&this.createTriggerButton(),this._autobind(),this._addListeners()}},{key:"show",value:function(t){var e=this;if(t="function"==typeof t?t:function(){return!1},clearTimeout(this._tm),this._toggleTriggerAnimation(!1),!this.loaded)return this._query.back_url="iframe",this._query.referrer=window.location.href,this.loadIframe((function(){return e.show(t)}));this.isInstagram&&(this._toggleScrolledClass(window.innerHeight===document.documentElement.clientHeight),this._toggleScrolledListener(!0)),this._lockBodyScroll(!0),this.container.removeAttribute("hidden"),this._tm=setTimeout((function(){e.container.classList.remove("".concat(w,"_hidden"))}),10),this._track({hitType:"event",eventAction:"Widget:Opened"}),this.container.focus(),t()}},{key:"setMain",value:function(){var t=this;this._url.branchId=null,this._url.productId=null,this._url.userId=null,this._url.team=!1,this._url.giftCardId=null,this.show((function(){t._track({hitType:"event",eventAction:"Site:Homepage:Selected"}),t.iframe.contentWindow.location.href=t.url}))}},{key:"setGiftCard",value:function(t,e){var n=this;this._url.branchId=e,this._url.giftCardId=t,this._url.productId=null,this._url.userId=null,this._url.team=!1,this.show((function(){n._track({hitType:"event",eventAction:"Site:Voucher:Selected"}),n.iframe.contentWindow.location.href=n.url}))}},{key:"setProduct",value:function(t,e,n){var i=this;this._url.branchId=e,this._url.productId=t,this._url.userId=n,this._url.team=!!n,this._url.giftCardId=null,this.show((function(){i._track({hitType:"event",eventAction:"Site:Service:Selected"}),i.iframe.contentWindow.location.href=i.url}))}},{key:"setBranch",value:function(t){var e=this;this._url.branchId=t,this._url.productId=null,this._url.userId=null,this._url.team=!1,this._url.giftCardId=null,this.show((function(){e._track({hitType:"event",eventAction:"Site:Location:Selected"}),e.iframe.contentWindow.location.href=e.url}))}},{key:"setUser",value:function(t,e){var n=this;this._url.branchId=e,this._url.userId=t,this._url.team=!0,this._url.giftCardId=null,this._url.productId=null,this.show((function(){n._track({hitType:"event",eventAction:"Site:User:Selected"}),n.iframe.contentWindow.location.href=n.url}))}},{key:"hide",value:function(){var t=this;clearTimeout(this._tm),this.container.classList.add("".concat(w,"_hidden")),this._tm=setTimeout((function(){t.container.setAttribute("hidden",""),t._track({hitType:"event",eventAction:"Widget:Closed"})}),200),this._lockBodyScroll(!1),this._toggleScrolledClass(!1),this._toggleScrolledListener(!1),this._toggleTriggerAnimation(!0)}},{key:"loadIframe",value:function(t){var e=this;if(!this._isLoading){this._isLoading=!0;var n=this._buttonProps,i=n.background,o=n.color,a=n.position,r="string"==typeof this._logo,s=!!this._logo,c=this._logoBackground||i;this._loader=this._h("DIV","EWBookingWidgetLoader",void 0,'
\n
\n ').concat(r?''):s?u("EWBookingWidgetLoader",o):"","\n
\n
")),document.body.appendChild(this._loader),this._lockBodyScroll(!0),this.container=this._h("DIV","".concat(w," ").concat(w,"_hidden"),{tabindex:"0",hidden:""},'
\n \n ')),document.body.appendChild(this.container),this.iframe=document.getElementById("EWBookingWidget");var d=setTimeout((function(){e._onLoad()}),5e3);this._onLoad=function(e){this._loader.remove(),delete this._loader,this._isLoading=!1,this.loaded=!0,this.iframe.removeEventListener("load",this._onLoad),clearTimeout(d),"function"==typeof t&&t()}.bind(this),this.iframe.addEventListener("load",this._onLoad)}}},{key:"createTriggerButton",value:function(){var t=this._buttonProps,e=t.text,n=t.showText,i=t.position,o=t.color,a=t.background,r=t.textColor,s=t.textBackground;this.button=this._h("A","".concat(y," ").concat(y,"_animate ").concat(y,"_").concat(i),{href:this.url},'').concat(e,'\n \n ')),document.body.appendChild(this.button)}},{key:"destroy",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];window.removeEventListener("message",this._onMessage),document.removeEventListener("click",this._onClick),clearTimeout(this._tm),this._lockBodyScroll(!1),this._toggleInstagramClass(!1),this._toggleScrolledClass(!1),this._toggleScrolledListener(!1),t&&(this.container&&this.container.remove(),this.button&&this.button.remove()),this._loader&&(this._loader.remove(),delete this.loader),this.iframe&&this.iframe.removeEventListener("load",this._onLoad),this.container=null,this.button=null,this.iframe=null,this.loaded=!1}},{key:"_h",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=document.createElement(t);for(var a in o.className=e,o.innerHTML=i,n)o.setAttribute(a,n[a]);return o}},{key:"_setUrl",value:function(t){var e=this,n=s(t.split("?"),2),i=n[0],o=n[1],a=f.test(i),r=_.test(i);if(a){var c=i.match(f);this._url={domain:c[1],slug:c[2],branchId:c[3],userId:c[4],productId:c[5],team:!0,postfix:""}}else if(r){var d=i.match(m);this._url={domain:d[1],slug:d[2],branchId:d[3],giftCardId:d[5],productId:null,team:!1,userId:null,postfix:null}}else{var l=i.match(m);this._url={domain:l[1],slug:l[2],branchId:l[3],productId:l[4],team:!1,userId:null,postfix:l[5]}}o?(this._query={},o.split("&").forEach((function(t){var n=s(t.split("="),2),i=n[0],o=n[1];e._query[i]=decodeURIComponent(o)}))):this._query={ref:"embed_widget"},location.search.replace("?","").split("&").forEach((function(t){var n=s(t.split("="),2),i=n[0],o=void 0===i?"":i,a=n[1];o.startsWith("utm_")&&void 0===e._query[o]&&(e._query[o]=a)}))}},{key:"_autobind",value:function(){this.show=this.show.bind(this),this.hide=this.hide.bind(this),this._onMessage=this._onMessage.bind(this),this._onClick=this._onClick.bind(this)}},{key:"_addListeners",value:function(){window.addEventListener("message",this._onMessage),document.addEventListener("click",this._onClick)}},{key:"_onMessage",value:function(t){if((t.origin===location.origin||0===this.url.indexOf(t.origin))&&t.data){var e=t.data,n=e.type,i=r(e,["type"]);switch(n){case"close":this.hide();break;case"trackers":this._initTrackers(i);break;case"track":this._track(i);break;case"redirect":this._redirect(i.url)}}}},{key:"_redirect",value:function(t){window.location.replace(t)}},{key:"_onClick",value:function(t){var e=t.target;e&&(e.matches(this.triggerSelector)||e.closest(this.triggerSelector))&&(t.preventDefault(),this.show())}},{key:"_lockBodyScroll",value:function(t){document.body.classList[t?"add":"remove"]("EWNoScroll")}},{key:"_toggleInstagramClass",value:function(t){document.documentElement.classList[t?"add":"remove"]("EWInstagram")}},{key:"_toggleScrolledClass",value:function(t){document.body.classList[t?"add":"remove"]("EWScrolled")}},{key:"_toggleScrolledListener",value:function(t){var e=this._toggleScrolledClass;window[t?"addEventListener":"removeEventListener"]("scroll",(function(){e(window.innerHeight===document.documentElement.clientHeight)}))}},{key:"_toggleTriggerAnimation",value:function(t){this.button&&this.button.classList[t?"add":"remove"]("".concat(y,"_animate"))}},{key:"_initTrackers",value:function(t){this.trackers=new l(t)}},{key:"_track",value:function(t){try{this.trackers&&this.trackers.track(t)}catch(t){console.log("Error tracking: ",t)}}}]),e}()}();