!function(e,t){if("function"==typeof define&&define.amd)define([],t);else if("undefined"!=typeof exports)t();else{t(),e.unknown={}}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n-1};function E(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function S(e){return"string"!=typeof e&&(e=String(e)),e}function _(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return y&&(t[Symbol.iterator]=function(){return t}),t}function T(e){this.map={},e instanceof T?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function M(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function B(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function x(e){var t=new FileReader,n=B(t);return t.readAsArrayBuffer(e),n}function P(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function A(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:m&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:g&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:p&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():v&&m&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=P(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):v&&(ArrayBuffer.prototype.isPrototypeOf(e)||w(e))?this._bodyArrayBuffer=P(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):p&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},m&&(this.blob=function(){var e=M(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=M(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(x)}),this.text=function(){var e,t,n,o=M(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=B(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),o=0;o-1?o:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var r=/([?&])_=[^&]*/;if(r.test(this.url))this.url=this.url.replace(r,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function k(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),o=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(o),decodeURIComponent(i))}})),t}function j(e,t){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new T(t.headers),this.url=t.url||"",this._initBody(e)}O.prototype.clone=function(){return new O(this,{body:this._bodyInit})},A.call(O.prototype),A.call(j.prototype),j.prototype.clone=function(){return new j(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new T(this.headers),url:this.url})},j.error=function(){var e=new j(null,{status:0,statusText:""});return e.type="error",e};var I=[301,302,303,307,308];j.redirect=function(e,t){if(-1===I.indexOf(t))throw new RangeError("Invalid status code");return new j(null,{status:t,headers:{location:e}})};var R=f.DOMException;try{new R}catch(e){(R=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),R.prototype.constructor=R}function L(e,t){return new Promise((function(n,i){var r=new O(e,t);if(r.signal&&r.signal.aborted)return i(new R("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var e,t,o={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new T,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),o=n.shift().trim();if(o){var i=n.join(":").trim();t.append(o,i)}})),t)};o.url="responseURL"in s?s.responseURL:o.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;setTimeout((function(){n(new j(i,o))}),0)},s.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},s.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},s.onabort=function(){setTimeout((function(){i(new R("Aborted","AbortError"))}),0)},s.open(r.method,function(e){try{return""===e&&f.location.href?f.location.href:e}catch(t){return e}}(r.url),!0),"include"===r.credentials?s.withCredentials=!0:"omit"===r.credentials&&(s.withCredentials=!1),"responseType"in s&&(m?s.responseType="blob":v&&r.headers.get("Content-Type")&&-1!==r.headers.get("Content-Type").indexOf("application/octet-stream")&&(s.responseType="arraybuffer")),!t||"object"!==o(t.headers)||t.headers instanceof T?r.headers.forEach((function(e,t){s.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){s.setRequestHeader(e,S(t.headers[e]))})),r.signal&&(r.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&r.signal.removeEventListener("abort",a)}),s.send(void 0===r._bodyInit?null:r._bodyInit)}))}function C(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))}function U(e){return new this((function(t,n){if(!e||void 0===e.length)return n(new TypeError(o(e)+" "+e+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);var r=i.length;function s(e,n){if(n&&("object"===o(n)||"function"==typeof n)){var a=n.then;if("function"==typeof a)return void a.call(n,(function(t){s(e,t)}),(function(n){i[e]={status:"rejected",reason:n},0==--r&&t(i)}))}i[e]={status:"fulfilled",value:n},0==--r&&t(i)}for(var a=0;at&&in}},{key:"findEdgeElements",value:function(){var e=this.innerSection,t=this.options,n=t.isPageGenerator,o=t.window.document,i=o.body,r=o.body.clientWidth,s=0,a=[];a=n?i.getElementsByTagName("main").item(0).getElementsByClassName("widget"):i.getElementsByClassName("block-inner");for(var l=0;lh&&(r=h,this.leftEdgeElement=u),f&&sy&&(this.leftEdgeElement=e),s0?e:0;a&&console.log("Pixel ratio:",this.pixelRatio),this.leftMargin=o,this.topMargin=S,this.width=n,this.height=t,l.style.left="".concat(o,"px"),l.style.width="".concat(n,"px"),l.style.height="".concat(t,"px"),l.style.top="".concat(S,"px")}},{key:"addPointToStorage",value:function(e,t,n){var o=this.leftMargin,i=this.topMargin,r=this.pixelRatio,s=this.height,l=this.width,u=t-o,d=n-i;u<0||d<0||u>l||d>s||!r||(a&&"click"===e&&(console.log("addPointToStorage:",u,d,o,i,l,s),console.log("with pixelRatio:",Math.round(u*r),Math.round(d*r))),this.singleSessionStorage[e].push({x:Math.round(u*r),y:Math.round(d*r)}))}},{key:"setMaxScroll",value:function(){var e=this.displayMode,t=this.currentMaxScrollMobile,n=this.currentMaxScrollDesktop,o=this.height,i=this.options.window,r=Math.floor(c(i)+i.innerHeight),s=Math.floor(o),l=r>s?s:r;e&&tthis.sendTimestamp){var t=this.storage.shift();this.request.send(t).then((function(){e.errorCount=0})).catch((function(n){console.error(n);var o=e.options.error;e.errorCount+=1,e.errorCount=I&&(C=e,L=R.apply(void 0,arguments)),L}),k=function(e){var t,n,o=e.type,i=e.pageX,r=e.pageY,s=e.clientX,l=e.clientY,u=c(window),d=function(e){return e.scrollX||e.document.scrollLeft||e.document.body.scrollLeft||0}(window);if(null==i||null==r){var h=document,f=h.documentElement,p=f.clientLeft,y=f.clientTop,m=h.body,g=m.clientLeft,v=m.clientTop;t=s+d-(p||g||0),n=l+u-(y||v||0)}else t=i,n=r;B.isPointInBoundaries({x:t,y:n})&&("mousemove"!==o||B.isMobileModeOn&&x?"click"===o&&(B.addPointToStorage(o,t,n),a&&(console.log("mouse click event",t,n),console.log("SIZE:","heatmapDiv.width:",T.style.width,"window.outerWidth",window.outerWidth,"heatmapDiv.style.height",T.style.height,"window.outerHeight",window.outerHeight))):O(o,t,n))},j=function(){B.isPopupOpened&&B.updateHeatmapDivBoundaries()};B.init(document.body.firstElementChild),window.addEventListener("preview.popup.shown",(function(e){return setTimeout((function(){return function(e){var t=e.detail,n=t.id||t.data.id,o=document.getElementById("popup-".concat(n));B.addDataToStorage();var i=l?o.getElementsByClassName("lightbox-content")[0]:o.getElementsByClassName("popup-inner")[0];B.popupId=n,B.isPopupOpened=!0,B.popupElement=i,a&&(T.style.zIndex=10500001),setTimeout((function(){(D=i.parentElement).addEventListener("scroll",j),B.updateHeatmapDivBoundaries()}),500)}(e)}))})),window.addEventListener("preview.popup.hide",(function(e){return setTimeout((function(){return D.removeEventListener("scroll",j),B.addDataToStorage(),a&&(T.style.zIndex=1),B.popupId=!1,B.isPopupOpened=!1,void setTimeout((function(){B.updateHeatmapDivBoundaries()}),l?1:200)}))})),window.addEventListener("resize",d(B.updateHeatmapDivBoundaries.bind(B),350)),window.addEventListener("scroll",d(function(){B.setMaxScroll()}.bind(this),100)),window.document.addEventListener("mousemove",k,!0),window.document.addEventListener("click",k,!0),a&&window.addEventListener("keyup",(function(e){"h"===e.key?T.style.opacity=0:"s"===e.key&&(T.style.opacity=.3)})),window.addEventListener("beforeunload",A.bind(this)),window.addEventListener("unload",A.bind(this))}var I,R,L,C}"complete"===document.readyState||"loaded"===document.readyState?$():window.addEventListener?window.addEventListener("load",$):window.attachEvent?window.attachEvent("onreadystatechange",(function(){"complete"===document.readyState&&$()})):console.error("Unsupported browser")}));