this._renderBoundaries[2]&&(this._renderBoundaries[2]=p+2*d),u+2*d>this._renderBoundaries[3]&&(this._renderBoundaries[3]=u+2*d)}},_colorize:function(){var e=this._renderBoundaries[0],t=this._renderBoundaries[1],a=this._renderBoundaries[2]-e,i=this._renderBoundaries[3]-t,n=this._width,s=this._height,r=this._opacity,o=this._maxOpacity,l=this._minOpacity,c=this._useGradientOpacity;e<0&&(e=0),t<0&&(t=0),e+a>n&&(a=n-e),t+i>s&&(i=s-t);for(var d=this.shadowCtx.getImageData(e,t,a,i),m=d.data,p=m.length,u=this._palette,h=3;h0?r:b>0,t},getDataURL:function(){return this.canvas.toDataURL()}},i}(),i=function(){var t=!1;return"canvas2d"===e["defaultRenderer"]&&(t=a),t}(),n={merge:function(){for(var e={},t=arguments.length,a=0;a(Object(s["openBlock"])(),Object(s["createElementBlock"])("span",{class:Object(s["normalizeClass"])(["btn-flat",{visActive:t.key===e.heatmapType,["heatmapType"+t.key]:!0}]),onClick:a=>e.changeHeatmapType(t.key),key:t.key},Object(s["toDisplayString"])(t.name),11,d))),128)),Object(s["createElementVNode"])("h4",m,Object(s["toDisplayString"])(e.translate("HeatmapSessionRecording_DeviceType")),1),(Object(s["openBlock"])(!0),Object(s["createElementBlock"])(s["Fragment"],null,Object(s["renderList"])(e.deviceTypesWithSamples,t=>(Object(s["openBlock"])(),Object(s["createElementBlock"])("span",{class:Object(s["normalizeClass"])(["btn-flat",{visActive:t.key===e.deviceType,["deviceType"+t.key]:!0}]),title:t.tooltip,onClick:a=>e.changeDeviceType(t.key),key:t.key},[Object(s["createElementVNode"])("img",{height:"15",src:t.logo,alt:`${e.translate("DevicesDetection_Device")} ${t.name}`},null,8,u),Object(s["createTextVNode"])(),Object(s["createElementVNode"])("span",h,Object(s["toDisplayString"])(t.numSamples),1)],10,p))),128)),Object(s["createElementVNode"])("div",g,[Object(s["createElementVNode"])("h4",null,Object(s["toDisplayString"])(e.translate("Installation_Legend")),1),Object(s["createElementVNode"])("div",b,[v,Object(s["createElementVNode"])("img",{class:"gradient",alt:"gradient",src:e.gradientImgData},null,8,O),j])]),Object(s["createElementVNode"])("div",f,[Object(s["createElementVNode"])("span",{style:{"margin-left":"2.5rem","margin-right":"13.5px"},textContent:Object(s["toDisplayString"])(e.translate("HeatmapSessionRecording_Width"))},null,8,y),Object(s["createVNode"])(P,{uicontrol:"select",name:"iframewidth","model-value":e.customIframeWidth,"onUpdate:modelValue":t[0]||(t[0]=t=>{e.customIframeWidth=t,e.changeIframeWidth(e.customIframeWidth,!0)}),options:e.iframeWidthOptions},null,8,["model-value","options"])])]),Object(s["createElementVNode"])("div",S,[Object(s["createElementVNode"])("div",H,[Object(s["createElementVNode"])("div",_,null,512),E]),Object(s["withDirectives"])(Object(s["createElementVNode"])("div",{class:"hsrLoadingOuter",style:Object(s["normalizeStyle"])([{height:"400px"},{width:e.iframeWidth+"px"}])},[V,Object(s["createElementVNode"])("div",N,[Object(s["createElementVNode"])("div",R,Object(s["toDisplayString"])(e.translate("General_Loading")),1)])],4),[[s["vShow"],e.isLoading]]),Object(s["withDirectives"])(Object(s["createElementVNode"])("div",{class:"aboveFoldLine",title:e.translate("HeatmapSessionRecording_AvgAboveFoldDescription"),style:Object(s["normalizeStyle"])({width:e.iframeWidth+"px",top:e.avgFold+"px"})},[Object(s["createElementVNode"])("div",null,Object(s["toDisplayString"])(e.translate("HeatmapSessionRecording_AvgAboveFoldTitle",e.avgFold)),1)],12,w),[[s["vShow"],e.avgFold]]),e.embedUrl?(Object(s["openBlock"])(),Object(s["createElementBlock"])("iframe",{key:0,id:"recordingPlayer",ref:"recordingPlayer",sandbox:"allow-scripts allow-same-origin",referrerpolicy:"no-referrer",onLoad:t[1]||(t[1]=t=>e.onLoaded()),height:"400",src:e.embedUrl,width:e.iframeWidth},null,40,k)):Object(s["createCommentVNode"])("",!0)],512),Object(s["withDirectives"])(Object(s["createElementVNode"])("div",x,[Object(s["createVNode"])(A,{style:{display:"block !important"},loading:e.isLoading,onClick:t[2]||(t[2]=t=>e.deleteScreenshot()),value:e.translate("HeatmapSessionRecording_DeleteScreenshot")},null,8,["loading","value"])],512),[[s["vShow"],e.showDeleteScreenshot]]),Object(s["createElementVNode"])("div",C,[Object(s["createElementVNode"])("h2",null,Object(s["toDisplayString"])(e.translate("HeatmapSessionRecording_DeleteHeatmapScreenshotConfirm")),1),Object(s["createElementVNode"])("input",{role:"yes",type:"button",value:e.translate("General_Yes")},null,8,D),Object(s["createElementVNode"])("input",{role:"no",type:"button",value:e.translate("General_No")},null,8,T)],512),Object(s["createVNode"])(B,{ref:"tooltip","click-count":e.clickCount,"click-rate":e.clickRate,"is-moves":1===e.heatmapType},null,8,["click-count","click-rate","is-moves"])])}var P=a("246e"),A=a.n(P),B=a("19dc"),U=a("a5a2");
+/**
+ * Copyright (C) InnoCraft Ltd - All rights reserved.
+ *
+ * NOTICE: All information contained herein is, and remains the property of InnoCraft Ltd.
+ * The intellectual and technical concepts contained herein are protected by trade secret
+ * or copyright law. Redistribution of this information or reproduction of this material is
+ * strictly forbidden unless prior written permission is obtained from InnoCraft Ltd.
+ *
+ * You shall use this code only in accordance with the license agreement obtained from
+ * InnoCraft Ltd.
+ *
+ * @link https://www.innocraft.com/
+ * @license For license details see https://www.innocraft.com/license
+ */
+function F(e){return e&&e.contentWindow?e.contentWindow:e&&e.contentDocument&&e.contentDocument.defaultView?e.contentDocument.defaultView:void 0}
+/**
+ * Copyright (C) InnoCraft Ltd - All rights reserved.
+ *
+ * NOTICE: All information contained herein is, and remains the property of InnoCraft Ltd.
+ * The intellectual and technical concepts contained herein are protected by trade secret
+ * or copyright law. Redistribution of this information or reproduction of this material is
+ * strictly forbidden unless prior written permission is obtained from InnoCraft Ltd.
+ *
+ * You shall use this code only in accordance with the license agreement obtained from
+ * InnoCraft Ltd.
+ *
+ * @link https://www.innocraft.com/
+ * @license For license details see https://www.innocraft.com/license
+ */function L(e,t){let a=null;return(i,n)=>(a&&(a.abort(),a=null),a=new AbortController,B["AjaxHelper"].post(Object.assign(Object.assign({},i),{},{method:e}),n,Object.assign(Object.assign({},t),{},{abortController:a})).finally(()=>{a=null}))}const I={class:"tooltip-item"},W={class:"tooltip-label"},q={class:"tooltip-value"},z={class:"tooltip-item"},$={class:"tooltip-label"},G={class:"tooltip-value"};function J(e,t,a,i,n,r){return Object(s["withDirectives"])((Object(s["openBlock"])(),Object(s["createElementBlock"])("div",{ref:"tooltipRef",class:"tooltip",style:Object(s["normalizeStyle"])(e.tooltipStyle)},[Object(s["createElementVNode"])("div",I,[Object(s["createElementVNode"])("span",W,Object(s["toDisplayString"])(e.getClickCountTranslation),1),Object(s["createElementVNode"])("span",q,Object(s["toDisplayString"])(e.getClickCount),1)]),Object(s["createElementVNode"])("div",z,[Object(s["createElementVNode"])("span",$,Object(s["toDisplayString"])(e.getClickRateTranslation),1),Object(s["createElementVNode"])("span",G,Object(s["toDisplayString"])(e.getClickRate),1)])],4)),[[s["vShow"],e.visible]])}var X=Object(s["defineComponent"])({props:{clickCount:{type:Number,required:!0},clickRate:{type:Number,required:!0},isMoves:{type:Boolean,required:!1,default:!1}},setup(){const e=Object(s["reactive"])({visible:!1,position:{top:0,left:0}}),t=Object(s["ref"])(null),a=Object(s["computed"])(()=>({top:e.position.top+"px",left:e.position.left+"px",position:"absolute",zIndex:1e3}));function i(a){const i=window.scrollY||document.documentElement.scrollTop,n=window.scrollX||document.documentElement.scrollLeft;e.position.top=a.clientY+i+10,e.position.left=a.clientX+n+10,e.visible=!0,Object(s["nextTick"])(()=>{const s=t.value;if(s){const{innerWidth:t,innerHeight:r}=window,o=s.getBoundingClientRect();o.right>t&&(e.position.left=a.clientX+n-o.width-10),o.bottom>r&&(e.position.top=a.clientY+i-o.height-10);const l=s.getBoundingClientRect();l.left<0&&(e.position.left=n+10),l.top<0&&(e.position.top=i+10)}})}function n(){e.visible=!1}return Object.assign(Object.assign({},Object(s["toRefs"])(e)),{},{tooltipRef:t,show:i,hide:n,tooltipStyle:a,translate:B["translate"]})},computed:{getClickCount(){return B["NumberFormatter"].formatNumber(this.clickCount)},getClickRate(){return B["NumberFormatter"].formatPercent(this.clickRate)},getClickCountTranslation(){const e=this.isMoves?"HeatmapSessionRecording_Moves":"HeatmapSessionRecording_Clicks";return Object(B["translate"])(e)},getClickRateTranslation(){const e=this.isMoves?"HeatmapSessionRecording_MoveRate":"HeatmapSessionRecording_ClickRate";return Object(B["translate"])(e)}}});X.render=J;var Y=X;const{$:K}=window,Q=1,Z=2,ee=3;let te=32e3;const ae=String(window.navigator.userAgent).toLowerCase();function ie(e,t,a){const i=K(e);i.css("height","400px");const n=a.getIframeHeight();i.css("height",n+"px"),K(t).css("height",n+"px").css("width",i.width()+"px").empty();const s=Math.ceil(n/te);for(let r=1;r<=s;r+=1){let e=te;r===s&&(e=n%te),K(t).append(``),K(t).find("#heatmap"+r).css({height:e+"px"})}return s}function ne(e,t,a,i){const n=K(t);n.css("height","400px");const s=a.getIframeHeight();n.css("height",s+"px");const r=1e3,o=s/r,l=i.reduce((e,t)=>e+parseInt(t.value,10),0),c=[];let d=0,m=null,p=100,u=0;function h(e,t,a,i,n){return i+(e-t)/(a-t)*(n-i)}function g(e,t,a){if(t===a||!t&&!a)return[255,255,0];const i=h(e,t,a,0,255),n=(a-t)/5;return i>204?[255,h(e,a-n,a,255,0),0]:i>153?[h(e,a-2*n,a-n,0,255),255,0]:i>102?[0,255,h(e,a-3*n,a-2*n,255,0)]:i>51?[0,h(e,a-4*n,a-3*n,0,255),255]:[h(e,t,a-4*n,255,0),0,255]}if(i.forEach(e=>{const t=parseInt(e.value,10),a=parseInt(e.label,10),i=Math.round(a*o);m&&m.position===i?d+=t:(0!==l&&(p=(l-d)/l*100),d+=t,m={percentageValue:10*parseFloat(p.toFixed(1)),position:u,percent:p.toFixed(1)},c.push(m)),u=i}),c.length){const e=c.some(e=>0===e.position);e||c.unshift({percent:"100.0",percentageValue:1e3,position:0})}else c.push({percent:"0",percentageValue:0,position:0});let b=0;const v=1e3;c&&c.length&&c[0]&&(b=c[c.length-1].percentageValue);const O=n.width();let j=null;for(let f=0;f`)}K(".scrollHeatmapLeaf",e).tooltip({track:!0,items:"*",tooltipClass:"heatmapTooltip",show:!1,hide:!1}),K(".legend-area .min").text((b/10).toFixed(1)+"%"),K(".legend-area .max").text((v/10).toFixed(1)+"%")}function se(e,t,a,i){const n=ie(e,t,a),s=document.createElement("canvas");s.width=100,s.height=10;const r=document.querySelector(".legend-area .min"),o=document.querySelector(".legend-area .max"),l=document.querySelector(".legend-area .gradient"),c=s.getContext("2d");let d={};function m(e){if(r.innerHTML=""+e.min,o.innerHTML=""+e.max,e.gradient&&e.gradient!==d){d=e.gradient;const t=c.createLinearGradient(0,0,100,1);Object.keys(d).forEach(e=>{t.addColorStop(parseFloat(e),d[e])}),c.fillStyle=t,c.fillRect(0,0,100,10),l.src=s.toDataURL()}}const p=[];for(let u=1;u<=n;u+=1){const e={min:i.min,max:i.max,data:[]},t={container:document.getElementById("heatmap"+u),radius:10,maxOpacity:.5,minOpacity:0,blur:.75};if(1===u&&(t.onExtremaChange=m),i&&i.data&&i.data.length>=2e4?t.radius=8:i&&i.data&&i.data.length>=2e3&&(t.radius=9),1===n)e.data=i.data;else{const t=(u-1)*te,a=t+te-1;i.data.forEach(i=>{if(i.y>=t&&i.y<=a){const a=Object.assign(Object.assign({},i),{},{y:i.y-t});e.data.push(a)}})}const a=A.a.create(t);a.setData(e),p.push(a)}return p}ae.match(/(iPod|iPhone|iPad|Android|IEMobile|Windows Phone)/i)?te=2e3:(ae.indexOf("msie ")>0||ae.indexOf("trident/")>0||ae.indexOf("edge")>0)&&(te=8e3);var re=Object(s["defineComponent"])({props:{idSiteHsr:{type:Number,required:!0},deviceTypes:{type:Array,required:!0},heatmapTypes:{type:Array,required:!0},breakpointMobile:{type:Number,required:!0},breakpointTablet:{type:Number,required:!0},offsetAccuracy:{type:Number,required:!0},heatmapPeriod:{type:String,required:!0},heatmapDate:{type:String,required:!0},url:{type:String,required:!0},isActive:Boolean,numSamples:{type:Object,required:!0},excludedElements:{type:String,required:!0},createdDate:{type:String,required:!0},desktopPreviewSize:{type:Number,required:!0},iframeResolutionsValues:{type:Object,required:!0}},components:{Field:U["Field"],SaveButton:U["SaveButton"],Tooltip:Y},data(){return{isLoading:!1,iframeWidth:this.desktopPreviewSize,customIframeWidth:this.desktopPreviewSize,avgFold:0,heatmapType:this.heatmapTypes[0].key,deviceType:this.deviceTypes[0].key,iframeResolutions:this.iframeResolutionsValues,actualNumSamples:this.numSamples,dataCoordinates:[],currentElement:null,totalClicks:0,tooltipShowTimeoutId:null,clickCount:0,clickRate:0}},setup(e){const t=Object(s["ref"])(null);let a=null;const i=new Promise(e=>{a=e});let n=null;const r=t=>(n||(n=F(t).recordingFrame,n.excludeElements(e.excludedElements),n.addClass("html","piwikHeatmap"),n.addClass("html","matomoHeatmap"),n.addWorkaroundForSharepointHeatmaps()),n),o=Object(s["ref"])(null),l=(e,t,a,i)=>{o.value=se(e,t,a,i)};return{iframeLoadedPromise:i,onLoaded:a,getRecordedHeatmap:L("HeatmapSessionRecording.getRecordedHeatmap"),getRecordedHeatmapMetadata:L("HeatmapSessionRecording.getRecordedHeatmapMetadata"),getRecordingIframe:r,heatmapInstances:o,renderHeatmap:l,tooltip:t}},created(){-1===this.iframeResolutions.indexOf(this.breakpointMobile)&&this.iframeResolutions.push(this.breakpointMobile),-1===this.iframeResolutions.indexOf(this.breakpointTablet)&&this.iframeResolutions.push(this.breakpointTablet),this.iframeResolutions=this.iframeResolutions.sort((e,t)=>e-t),this.fetchHeatmap(),B["Matomo"].postEvent("hidePeriodSelector")},watch:{isLoading(){if(!0===this.isLoading)return;const e=window.document.getElementById("heatmapContainer");e&&(e.addEventListener("mouseleave",e=>{this.tooltipShowTimeoutId&&(clearTimeout(this.tooltipShowTimeoutId),this.tooltipShowTimeoutId=null),this.currentElement=null,this.handleTooltip(e,0,0,"hide");const t=window.document.getElementById("highlightDiv");t&&(t.hidden=!0)}),e.addEventListener("mousemove",e=>{this.handleMouseMove(e)}))}},beforeUnmount(){this.removeScrollHeatmap()},methods:{removeScrollHeatmap(){const e=this.$refs.iframeRecordingContainer;K(e).find(".scrollHeatmapLeaf").remove()},deleteScreenshot(){B["Matomo"].helper.modalConfirm(this.$refs.confirmDeleteHeatmapScreenshot,{yes:()=>{this.isLoading=!0,B["AjaxHelper"].fetch({method:"HeatmapSessionRecording.deleteHeatmapScreenshot",idSiteHsr:this.idSiteHsr}).then(()=>{this.isLoading=!1,window.location.reload()})}})},fetchHeatmap(){if(this.removeScrollHeatmap(),this.heatmapInstances){const e=this.heatmapInstances;e.forEach(e=>{e.setData({max:1,min:0,data:[]})})}this.isLoading=!0,this.avgFold=0;const e=B["MatomoUrl"].parsed.value.segment?decodeURIComponent(B["MatomoUrl"].parsed.value.segment):void 0,t={idSiteHsr:this.idSiteHsr,heatmapType:this.heatmapType,deviceType:this.deviceType,period:this.heatmapPeriod,date:this.heatmapDate,filter_limit:-1,segment:e},a=this.getRecordedHeatmap(t),i=this.getRecordedHeatmapMetadata(t);Promise.all([a,i,this.iframeLoadedPromise]).then(e=>{const t=this.$refs.recordingPlayer,a=this.getRecordingIframe(t);ie(this.$refs.recordingPlayer,this.$refs.heatmapContainer,a),this.removeScrollHeatmap();const i=e[0],n=e[1];if(Array.isArray(n)&&n[0]?[this.actualNumSamples]=n:this.actualNumSamples=n,this.isLoading=!1,this.isScrollHeatmapType)ne(this.$refs.iframeRecordingContainer,t,a,i);else{var s;const e={min:0,max:0,data:[]};for(let t=0;t{null!==e&&void 0!==e&&e.value&&parseInt(e.value,10)>1&&(t+=1)}),t/e.data.length>=.1&&e.data.length>120?e.max=2:e.max=1}else{const t=10,a={};if(e.data.forEach(i=>{if(!i||!i.value)return;let n=parseInt(i.value,10);n>e.max&&(e.max=n),n>t&&(n=t);const s=""+n;s in a?a[s]+=1:a[s]=0}),e.max>t){let i=0;for(let n=t;n>1;n-=1){const t=""+n;if(t in a&&(i+=a[t]),i/e.data.length>=.2){e.max=n;break}}if(e.max>t){e.max=5;for(let t=5;t>0;t-=1){const i=""+t;if(i in a){e.max=t;break}}}}}if(this.renderHeatmap(this.$refs.recordingPlayer,this.$refs.heatmapContainer,a,e),null!==(s=this.actualNumSamples)&&void 0!==s&&s["avg_fold_device_"+this.deviceType]){const e=this.actualNumSamples["avg_fold_device_"+this.deviceType],t=a.getIframeHeight();t&&(this.avgFold=parseInt(""+e/100*t,10))}}}).finally(()=>{this.isLoading=!1})},changeDeviceType(e){this.deviceType=e,this.deviceType===Q?this.changeIframeWidth(this.desktopPreviewSize,!1):this.deviceType===Z?this.changeIframeWidth(this.breakpointTablet||960,!1):this.deviceType===ee&&this.changeIframeWidth(this.breakpointMobile||600,!1)},changeIframeWidth(e,t){this.iframeWidth=e,this.customIframeWidth=this.iframeWidth,this.totalClicks=0,this.dataCoordinates=[],this.fetchHeatmap(),t&&B["Matomo"].helper.lazyScrollToContent()},changeHeatmapType(e){this.heatmapType=e,this.totalClicks=0,this.clickCount=0,this.clickRate=0,this.dataCoordinates=[],this.fetchHeatmap()},handleMouseMove(e){const t=window.document.getElementById("highlightDiv");if(!t)return;this.tooltipShowTimeoutId&&(clearTimeout(this.tooltipShowTimeoutId),this.tooltipShowTimeoutId=null,this.currentElement=null),t.hidden||this.handleTooltip(e,0,0,"move");const a=this.lookUpRecordedElementAtEventLocation(e);if(!a||a===this.currentElement)return;this.handleTooltip(e,0,0,"hide"),t.hidden=!0;const i=a.getBoundingClientRect();let n=0;this.dataCoordinates.forEach(e=>{e.yi.bottom||e.xi.right||(n+=parseInt(e.value,10))}),this.tooltipShowTimeoutId=setTimeout(()=>{this.currentElement=a,t.hidden=!1;const i=this.totalClicks?Math.round(n/this.totalClicks*1e4)/100:0,s=a.getBoundingClientRect();t.style.top=s.top+"px",t.style.left=s.left+"px",t.style.width=s.width+"px",t.style.height=s.height+"px",this.handleTooltip(e,n,i,"show"),this.tooltipShowTimeoutId=null},100)},lookUpRecordedElementAtEventLocation(e){const t=e.target;if(!t)return null;const a=window.document.getElementById("recordingPlayer");if(!a)return null;const i=a.contentWindow?a.contentWindow.document:a.contentDocument;if(!i)return null;const n=t.getBoundingClientRect();return i.elementFromPoint(e.clientX-n.left,e.clientY-n.top)},handleTooltip(e,t,a,i){this.tooltip&&("show"===i?(this.clickCount=t,this.clickRate=a,this.tooltip.show(e)):"move"===i?this.tooltip.show(e):this.tooltip.hide())}},computed:{isScrollHeatmapType(){return 3===this.heatmapType},tokenAuth(){return B["MatomoUrl"].parsed.value.token_auth},embedUrl(){return"?"+B["MatomoUrl"].stringify({module:"HeatmapSessionRecording",action:"embedPage",idSite:B["Matomo"].idSite,idSiteHsr:this.idSiteHsr,token_auth:this.tokenAuth||void 0})},iframeWidthOptions(){return this.iframeResolutions.map(e=>({key:e,value:e+"px"}))},recordedSamplesSince(){const e=Object(B["translate"])("HeatmapSessionRecording_HeatmapXRecordedSamplesSince",`${this.actualNumSamples.nb_samples_device_all}`,this.createdDate),t=Object(B["externalLink"])("https://matomo.org/faq/heatmap-session-recording/troubleshooting-heatmaps/"),a=Object(B["translate"])("HeatmapSessionRecording_HeatmapTroubleshoot",t,"