clarity-js 0.8.43 → 0.8.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(){"use strict";var t=Object.freeze({__proto__:null,get queue(){return Wt},get start(){return Bt},get stop(){return Zt},get track(){return Rt}}),e=Object.freeze({__proto__:null,get check(){return te},get compute(){return ne},get data(){return Lt},get start(){return $t},get stop(){return re},get trigger(){return ee}}),n=Object.freeze({__proto__:null,get compute(){return le},get data(){return ae},get log(){return se},get reset(){return de},get start(){return ue},get stop(){return ce},get updates(){return oe}}),r=Object.freeze({__proto__:null,get callback(){return Oe},get callbacks(){return pe},get clear(){return Te},get consent(){return _e},get consentv2(){return Se},get data(){return fe},get electron(){return he},get id(){return ke},get metadata(){return we},get save(){return Me},get shortid(){return Ne},get start(){return ye},get stop(){return be}}),a=Object.freeze({__proto__:null,get data(){return Re},get envelope(){return He},get start(){return Le},get stop(){return Ue}}),o={projectId:null,delay:1e3,lean:!1,lite:!1,track:!0,content:!0,drop:[],mask:[],unmask:[],regions:[],cookies:[],fraud:!0,checksum:[],report:null,upload:null,fallback:null,upgrade:null,action:null,dob:null,delayDom:!1,throttleDom:!0,conversions:!1,includeSubdomains:!0};function i(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}var u=0;function c(){return performance.now()+performance.timeOrigin}function s(t){void 0===t&&(t=null);var e=0===u?c():u,n=t&&t.timeStamp>0?t.timeStamp:performance.now(),r=t&&t.view?t.view.performance.timeOrigin:performance.timeOrigin;return Math.max(Math.round(n+r-e),0)}var l="0.8.43";var d=/\S/gi,f=255,p=!0,h=null,v=null,g=null;function m(t,e,n,r,a){if(void 0===r&&(r=!1),t){if("input"==e&&("checkbox"===a||"radio"===a))return t;switch(n){case 0:return t;case 1:switch(e){case"*T":case"value":case"placeholder":case"click":return function(t){var e=-1,n=0,r=!1,a=!1,o=!1,i=null;S();for(var u=0;u<t.length;u++){var c=t.charCodeAt(u);if(r=r||c>=48&&c<=57,a=a||64===c,o=9===c||10===c||13===c||32===c,0===u||u===t.length-1||o){if(r||a){null===i&&(i=t.split(""));var s=t.substring(e+1,o?u:u+1);s=p&&null!==g?s.match(g)?s:k(s,"▪","▫"):w(s),i.splice(e+1-n,s.length,s),n+=s.length-1}o&&(r=!1,a=!1,e=u)}}return i?i.join(""):t}(t);case"input":case"change":return _(t)}return t;case 2:case 3:switch(e){case"*T":case"data-":return r?b(t):w(t);case"src":case"srcset":case"title":case"alt":case"href":case"xlink:href":return 3===n?"src"===e&&(null==t?void 0:t.startsWith("blob:"))?"blob:":"":t;case"value":case"click":case"input":case"change":return _(t);case"placeholder":return w(t)}break;case 4:switch(e){case"*T":case"data-":return r?b(t):w(t);case"value":case"input":case"click":case"change":return Array(5).join("•");case"checksum":return""}break;case 5:switch(e){case"*T":case"data-":return k(t,"▪","▫");case"value":case"input":case"click":case"change":return Array(5).join("•");case"checksum":case"src":case"srcset":case"alt":case"title":return""}}}return t}function y(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=!1);var r=t;if(e)r="".concat("https://").concat("Electron");else{var a=o.drop;if(a&&a.length>0&&t&&t.indexOf("?")>0){var i=t.split("?"),u=i[0],c=i[1];r=u+"?"+c.split("&").map((function(t){return a.some((function(e){return 0===t.indexOf("".concat(e,"="))}))?"".concat(t.split("=")[0],"=").concat("*na*"):t})).join("&")}}return n&&(r=r.substring(0,f)),r}function b(t){var e=t.trim();if(e.length>0){var n=e[0],r=t.indexOf(n),a=t.substr(0,r),o=t.substr(r+e.length);return"".concat(a).concat(e.length.toString(36)).concat(o)}return t}function w(t){return t.replace(d,"•")}function k(t,e,n){return S(),t?t.replace(v,e).replace(h,n):t}function _(t){for(var e=5*(Math.floor(t.length/5)+1),n="",r=0;r<e;r++)n+=r>0&&r%5==0?" ":"•";return n}function S(){if(p&&null===h)try{h=new RegExp("\\p{N}","gu"),v=new RegExp("\\p{L}","gu"),g=new RegExp("\\p{Sc}","gu")}catch(t){p=!1}}var E=[],I=null;function T(){}var O=[];function M(){}function x(){}function C(){}function N(){}function j(){}var z=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:I,event:N,hashText:M,keys:O,log:T,observe:function(){},register:j,reset:function(){},sheetAdoptionState:[],sheetUpdateState:[],start:function(){},state:E,stop:function(){},track:C,trigger:x}),A=null,P=!0;function q(){var t,e=null===(t=window.google_tag_data)||void 0===t?void 0:t.ics;if(null==e?void 0:e.getConsentState){var n=e.getConsentState("analytics_storage");Se(function(t){var e={ad_Storage:1===t.ad_Storage?"granted":"denied",analytics_Storage:1===t.analytics_Storage?"granted":"denied"};return e}({ad_Storage:e.getConsentState("ad_storage"),analytics_Storage:n}),2)}}function D(t){L(t.analytics_Storage?1:0),A=t}function R(){L(2)}function L(t){se(36,t.toString())}function U(t){A=t,Qt(47)}function H(){var t;if(P&&(Qt(47),P=!1,!o.track)){var e=null===(t=window.google_tag_data)||void 0===t?void 0:t.ics;(null==e?void 0:e.usedUpdate)&&q()}}var X=Object.freeze({__proto__:null,compute:H,config:D,consent:R,get data(){return A},start:function(){var t,e=null===(t=window.google_tag_data)||void 0===t?void 0:t.ics;P=!0,(null==e?void 0:e.addListener)&&e.addListener(["ad_storage","analytics_storage"],q)},stop:function(){P=!0},trackConsentv2:U}),V=null;function Y(t,e){fn()&&t&&"string"==typeof t&&t.length<255&&(V=e&&"string"==typeof e&&e.length<255?{key:t,value:e}:{value:t},Qt(24))}var B,W=null,Z=null;function J(t){t in W||(W[t]=0),t in Z||(Z[t]=0),W[t]++,Z[t]++}function G(t,e){null!==e&&(t in W||(W[t]=0),t in Z||(Z[t]=0),W[t]+=e,Z[t]+=e)}function F(t,e){null!==e&&!1===isNaN(e)&&(t in W||(W[t]=0),(e>W[t]||0===W[t])&&(Z[t]=e,W[t]=e))}function K(t,e,n){return window.setTimeout(Ye(t),e,n)}function Q(t){return window.clearTimeout(t)}var $=0,tt=0,et=null;function nt(){et&&Q(et),et=K(rt,tt),$=s()}function rt(){var t=s();B={gap:t-$},Qt(25),B.gap<3e5?et=K(rt,tt):sn&&(Y("clarity","suspend"),Pn(),["mousemove","touchstart"].forEach((function(t){return We(document,t,pn)})),["resize","scroll","pageshow"].forEach((function(t){return We(window,t,pn)})))}var at=Object.freeze({__proto__:null,get data(){return B},reset:nt,start:function(){tt=6e4,$=0},stop:function(){Q(et),$=0,tt=0}}),ot=null;function it(t){fn()&&o.lean&&(o.lean=!1,ot={key:t},Oe(),Me(),o.upgrade&&o.upgrade(t),Qt(3),o.lite)}var ut=Object.freeze({__proto__:null,get data(){return ot},start:function(){!o.lean&&o.upgrade&&o.upgrade("Config"),ot=null},stop:function(){ot=null},upgrade:it});function ct(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,u)}c((r=r.apply(t,e||[])).next())}))}function st(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}var lt=null;function dt(t,e){pt(t,"string"==typeof e?[e]:e)}function ft(t,e,n,r){return void 0===e&&(e=null),void 0===n&&(n=null),void 0===r&&(r=null),ct(this,void 0,void 0,(function(){var a,o;return st(this,(function(i){switch(i.label){case 0:return o={},[4,gt(t)];case 1:return o.userId=i.sent(),o.userHint=r||((u=t)&&u.length>=5?"".concat(u.substring(0,2)).concat(k(u.substring(2),"*","*")):k(u,"*","*")),pt("userId",[(a=o).userId]),pt("userHint",[a.userHint]),pt("userType",[mt(t)]),e&&(pt("sessionId",[e]),a.sessionId=e),n&&(pt("pageId",[n]),a.pageId=n),[2,a]}var u}))}))}function pt(t,e){if(fn()&&t&&e&&"string"==typeof t&&t.length<255){for(var n=(t in lt?lt[t]:[]),r=0;r<e.length;r++)"string"==typeof e[r]&&e[r].length<255&&n.push(e[r]);lt[t]=n}}function ht(){Qt(34)}function vt(){lt={}}function gt(t){return ct(this,void 0,void 0,(function(){var e;return st(this,(function(n){switch(n.label){case 0:return n.trys.push([0,4,,5]),crypto&&t?[4,crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t))]:[3,2];case 1:return e=n.sent(),[2,Array.prototype.map.call(new Uint8Array(e),(function(t){return("00"+t.toString(16)).slice(-2)})).join("")];case 2:return[2,""];case 3:return[3,5];case 4:return n.sent(),[2,""];case 5:return[2]}}))}))}function mt(t){return t&&t.indexOf("@")>0?"email":"string"}var yt="CompressionStream"in window;function bt(t){return ct(this,void 0,void 0,(function(){var e,n;return st(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),yt?(e=new ReadableStream({start:function(e){return ct(this,void 0,void 0,(function(){return st(this,(function(n){return e.enqueue(t),e.close(),[2]}))}))}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip")),n=Uint8Array.bind,[4,wt(e)]):[3,2];case 1:return[2,new(n.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[3,4];case 3:return r.sent(),[3,4];case 4:return[2,null]}}))}))}function wt(t){return ct(this,void 0,void 0,(function(){var e,n,r,a,o;return st(this,(function(i){switch(i.label){case 0:e=t.getReader(),n=[],r=!1,a=[],i.label=1;case 1:return r?[3,3]:[4,e.read()];case 2:return o=i.sent(),r=o.done,a=o.value,r?[2,n]:(n.push.apply(n,a),[3,1]);case 3:return[2,n]}}))}))}var kt=null;function _t(t){try{if(!kt)return;var e=function(t){try{return JSON.parse(t)}catch(t){return[]}}(t);e.forEach((function(t){kt(t)}))}catch(t){}}var St=[z,n,Object.freeze({__proto__:null,compute:ht,get data(){return lt},identify:ft,reset:vt,set:dt,start:function(){vt()},stop:function(){vt()}}),e,z,X,r,a,t,at,ut,z];function Et(){W={},Z={},J(5),St.forEach((function(t){return Ye(t.start)()}))}function It(){St.slice().reverse().forEach((function(t){return Ye(t.stop)()})),W={},Z={}}function Tt(){ht(),le(),Qt(0),ne(),H()}function Ot(t,e,n){return"".concat(t,"=").concat(m(e,0===t.indexOf("data-")?"data-":t,n))}var Mt=[],xt=1,Ct=null;function Nt(){Mt=[],function(t){var e=[t];for(;e.length>0;){for(var n=null,r=null,a=null,o=e.shift(),i=o.firstChild,u=o.parentElement?o.parentElement:o.parentNode?o.parentNode:null;i;)e.push(i),i=i.nextSibling;switch(o.nodeType){case Node.DOCUMENT_TYPE_NODE:var c=o;r="*D",n={name:c.name,publicId:c.publicId,systemId:c.systemId};break;case Node.TEXT_NODE:a=o.nodeValue,r=Ct.get(u)?"*T":r;break;case Node.ELEMENT_NODE:var s=o;n=jt(s),r=["NOSCRIPT","SCRIPT","STYLE"].indexOf(s.tagName)<0?s.tagName:r}zt(o,u,{tag:r,attributes:n,value:a})}}(document),function(t){ct(this,void 0,void 0,(function(){var e,n,r,a,o,i,u,c,l,d,f,p,h;return st(this,(function(v){switch(e=s(),n=[e,t],t){case 8:r=I,n.push(r.width),n.push(r.height),r.width,r.height,Wt(n);break;case 43:if((a=Mt).length>0){for(o=0,i=a;o<i.length;o++)for(u=i[o],c=u.metadata.privacy,l=u.data,d=0,f=["tag","attributes","value"];d<f.length;d++)if(l[p=f[d]])switch(p){case"tag":n.push(u.id),u.parent&&n.push(u.parent),u.previous&&n.push(u.previous),n.push(l[p]);break;case"attributes":for(h in l[p])void 0!==l[p][h]&&n.push(Ot(h,l[p][h],c));break;case"value":n.push(m(l[p],l.tag,c))}Wt(function(t){for(var e=[],n={},r=0,a=null,o=0;o<t.length;o++)if("string"==typeof t[o]){var i=t[o],u=n[i]||-1;u>=0?a?a.push(u):(a=[u],e.push(a),r++):(a=null,e.push(i),n[i]=r++)}else a=null,e.push(t[o]),r++;return e}(n),!0)}}return[2]}))}))}(43)}function jt(t){var e={},n=t.attributes;if(n&&n.length>0)for(var r=0;r<n.length;r++)e[n[r].name]=n[r].value;return e}function zt(t,e,n){if(t&&n&&n.tag){var r=function(t){return null===t?null:Ct.has(t)?Ct.get(t):(Ct.set(t,xt),xt++)}(t),a=e?Ct.get(e):null,o=t.previousSibling?Ct.get(t.previousSibling):null;Mt.push({id:r,parent:a,previous:o,children:[],data:n,selector:null,hash:null,region:null,metadata:{active:!0,suspend:!1,privacy:5,position:null,fraud:null,size:null}})}}var At,Pt,qt,Dt,Rt,Lt,Ut=0,Ht=0,Xt=null,Vt=0,Yt=!1;function Bt(){Dt=!0,Ut=0,Ht=0,Yt=!1,Vt=0,At=[],Pt=[],qt={},Rt=null}function Wt(t,e){if(void 0===e&&(e=!0),Dt){var n=s(),r=t.length>1?t[1]:null,a=JSON.stringify(t);switch(o.lean?!Yt&&Ht+a.length>10485760&&(Yt=!0):Yt=!1,r){case 5:if(Yt)break;Ut+=a.length;case 37:case 6:case 43:case 45:case 46:case 44:case 51:if(Yt)break;Ht+=a.length,At.push(a);break;default:Pt.push(a)}J(25);var i=function(){var t=!1===o.lean&&Ut>0?100:Re.sequence*o.delay;return"string"==typeof o.upload?Math.max(Math.min(t,3e4),100):o.delay}();n-Vt>2*i&&(Q(Xt),Xt=null),e&&null===Xt&&(25!==r&&nt(),Xt=K(Jt,i),Vt=n,te(Ht))}}function Zt(){Q(Xt),Jt(!0),Ut=0,Ht=0,Yt=!1,Vt=0,At=[],Pt=[],qt={},Rt=null,Dt=!1}function Jt(t){return void 0===t&&(t=!1),ct(this,void 0,void 0,(function(){var e,n,r,a,i,u,c,s;return st(this,(function(l){switch(l.label){case 0:return Dt?(Xt=null,(e=!1===o.lean&&Ht>0&&(Ht<1048576||Re.sequence>0))&&F(1,1),Tt(),n=!0===t,Re?(r=JSON.stringify(He(n)),a="[".concat(Pt.join(),"]"),i=e?"[".concat(At.join(),"]"):"",n&&i.length>0&&r.length+a.length+i.length>65536&&(i=""),u=function(t){return t.p.length>0?'{"e":'.concat(t.e,',"a":').concat(t.a,',"p":').concat(t.p,"}"):'{"e":'.concat(t.e,',"a":').concat(t.a,"}")}({e:r,a:a,p:i}),n?(s=null,[3,3]):[3,1]):[2]):[2];case 1:return[4,bt(u)];case 2:s=l.sent(),l.label=3;case 3:return G(2,(c=s)?c.length:u.length),Gt(u,c,Re.sequence,n),Pt=[],e&&(At=[],Ht=0,Ut=0,Yt=!1),[2]}}))}))}function Gt(t,e,n,r){if(void 0===r&&(r=!1),"string"==typeof o.upload){var a=o.upload,i=!1;if(r&&navigator&&navigator.sendBeacon)try{(i=navigator.sendBeacon.bind(navigator)(a,t))&&Kt(n)}catch(t){}if(!1===i){n in qt?qt[n].attempts++:qt[n]={data:t,attempts:1};var u=new XMLHttpRequest;u.open("POST",a,!0),u.timeout=15e3,u.ontimeout=function(){Ve(new Error("".concat("Timeout"," : ").concat(a)))},null!==n&&(u.onreadystatechange=function(){Ye(Ft)(u,n)}),u.withCredentials=!0,e?(u.setRequestHeader("Accept","application/x-clarity-gzip"),u.send(e)):u.send(t)}}else if(o.upload){(0,o.upload)(t),Kt(n)}}function Ft(t,e){var n=qt[e];t&&4===t.readyState&&n&&((t.status<200||t.status>208)&&n.attempts<=1?t.status>=400&&t.status<500?ee(6):(0===t.status&&(o.upload=o.fallback?o.fallback:o.upload),Rt={sequence:e,attempts:n.attempts,status:t.status},Qt(2),Gt(n.data,null,e)):(Rt={sequence:e,attempts:n.attempts,status:t.status},n.attempts>1&&Qt(2),200===t.status&&t.responseText&&function(t){for(var e=t&&t.length>0?t.split("\n"):[],n=0,r=e;n<r.length;n++){var a=r[n],i=a&&a.length>0?a.split(/ (.*)/):[""];switch(i[0]){case"END":ee(6);break;case"UPGRADE":it("Auto");break;case"ACTION":o.action&&i.length>1&&o.action(i[1]);break;case"EXTRACT":case"MODULE":i.length>1&&i[1];break;case"SIGNAL":i.length>1&&_t(i[1]);break;case"SNAPSHOT":o.lean=!1,Nt()}}}(t.responseText),0===t.status&&(Gt(n.data,null,e,!0),ee(3)),t.status>=200&&t.status<=208&&Kt(e),delete qt[e]))}function Kt(t){1===t&&(Me(),Oe())}function Qt(t){var e=[s(),t];switch(t){case 4:var n=E;n&&n.data&&((e=[n.time,n.event]).push(n.data.visible),e.push(n.data.docWidth),e.push(n.data.docHeight),e.push(n.data.screenWidth),e.push(n.data.screenHeight),e.push(n.data.scrollX),e.push(n.data.scrollY),e.push(n.data.pointerX),e.push(n.data.pointerY),e.push(n.data.activityTime),e.push(n.data.scrollTime),e.push(n.data.pointerTime),e.push(n.data.moveX),e.push(n.data.moveY),e.push(n.data.moveTime),e.push(n.data.downX),e.push(n.data.downY),e.push(n.data.downTime),e.push(n.data.upX),e.push(n.data.upY),e.push(n.data.upTime),e.push(n.data.pointerPrevX),e.push(n.data.pointerPrevY),e.push(n.data.pointerPrevTime),e.push(n.data.modules),Wt(e,!1));break;case 25:e.push(B.gap),Wt(e);break;case 35:e.push(Lt.check),Wt(e,!1);break;case 3:e.push(ot.key),Wt(e);break;case 2:e.push(Rt.sequence),e.push(Rt.attempts),e.push(Rt.status),Wt(e,!1);break;case 24:V.key&&e.push(V.key),e.push(V.value),Wt(e);break;case 34:var r=Object.keys(lt);if(r.length>0){for(var a=0,o=r;a<o.length;a++){var i=o[a];e.push(i),e.push(lt[i])}vt(),Wt(e,!1)}break;case 0:var u=Object.keys(Z);if(u.length>0){for(var c=0,l=u;c<l.length;c++){var d=l[c],f=parseInt(d,10);e.push(f),e.push(Math.round(Z[d]))}Z={},Wt(e,!1)}break;case 1:var p=Object.keys(oe);if(p.length>0){for(var h=0,v=p;h<v.length;h++){var g=v[h];f=parseInt(g,10);e.push(f),e.push(oe[g])}de(),Wt(e,!1)}break;case 36:var m=Object.keys(I);if(m.length>0){for(var y=0,b=m;y<b.length;y++){var w=b[y];f=parseInt(w,10);e.push(f),e.push([].concat.apply([],I[w]))}Wt(e,!1)}break;case 40:O.forEach((function(t){e.push(t);var n=[];for(var r in I[t]){var a=parseInt(r,10);n.push(a),n.push(I[t][r])}e.push(n)})),Wt(e,!1);break;case 47:e.push(A.source),e.push(A.ad_Storage),e.push(A.analytics_Storage),Wt(e,!1)}}function $t(){Lt={check:0}}function te(t){if(0===Lt.check){var e=Lt.check;e=Re.sequence>=128?1:e,e=Re.pageNum>=128?7:e,e=s()>72e5?2:e,(e=t>10485760?2:e)!==Lt.check&&ee(e)}}function ee(t){Lt.check=t,5!==t&&(Te(),Pn())}function ne(){0!==Lt.check&&Qt(35)}function re(){Lt=null}var ae=null,oe=null,ie=!1;function ue(){ae={},oe={},ie=!1}function ce(){ae={},oe={},ie=!1}function se(t,e){if(e&&(e="".concat(e),t in ae||(ae[t]=[]),ae[t].indexOf(e)<0)){if(ae[t].length>128)return void(ie||(ie=!0,ee(5)));ae[t].push(e),t in oe||(oe[t]=[]),oe[t].push(e)}}function le(){Qt(1)}function de(){oe={},ie=!1}var fe=null,pe=[],he=0,ve=null,ge=null,me={source:1,ad_Storage:"denied",analytics_Storage:"denied"};function ye(){var t,e,n;ve=null;var r=navigator&&"userAgent"in navigator?navigator.userAgent:"",a=null!==(n="undefined"!=typeof Intl&&(null===(e=null===(t=null===Intl||void 0===Intl?void 0:Intl.DateTimeFormat())||void 0===t?void 0:t.resolvedOptions())||void 0===e?void 0:e.timeZone))&&void 0!==n?n:"",i=(new Date).getTimezoneOffset().toString(),u=window.location.ancestorOrigins?Array.from(window.location.ancestorOrigins).toString():"",c=document&&document.title?document.title:"";he=r.indexOf("Electron")>0?1:0;var s=function(){var t={session:Ne(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},e=Ae("_clsk",!o.includeSubdomains);if(e){var n=e.includes("^")?e.split("^"):e.split("|");n.length>=5&&t.ts-je(n[1])<18e5&&(t.session=n[0],t.count=je(n[2])+1,t.upgrade=je(n[3]),t.upload=n.length>=6?"".concat("https://").concat(n[5],"/").concat(n[4]):"".concat("https://").concat(n[4]))}return t}(),l=ze(),d=o.projectId||function(t,e){void 0===e&&(e=null);for(var n,r=5381,a=r,o=0;o<t.length;o+=2)r=(r<<5)+r^t.charCodeAt(o),o+1<t.length&&(a=(a<<5)+a^t.charCodeAt(o+1));return n=Math.abs(r+11579*a),(e?n%Math.pow(2,e):n).toString(36)}(location.host);fe={projectId:d,userId:l.id,sessionId:s.session,pageNum:s.count},o.lean=o.track&&null!==s.upgrade?0===s.upgrade:o.lean,o.upload=o.track&&"string"==typeof o.upload&&s.upload&&s.upload.length>"https://".length?s.upload:o.upload,se(0,r),se(3,c),se(1,y(location.href,!!he)),se(2,document.referrer),se(15,function(){var t=Ne();if(o.track&&xe(window,"sessionStorage")){var e=sessionStorage.getItem("_cltk");t=e||t,sessionStorage.setItem("_cltk",t)}return t}()),se(16,document.documentElement.lang),se(17,document.dir),se(26,"".concat(window.devicePixelRatio)),se(28,l.dob.toString()),se(29,l.version.toString()),se(33,u),se(34,a),se(35,i),F(0,s.ts),F(1,0),F(35,he);var f,p=null===window||void 0===window?void 0:window.Zone;p&&"__symbol__"in p&&F(39,1),navigator&&(se(9,navigator.language),F(33,navigator.hardwareConcurrency),F(32,navigator.maxTouchPoints),F(34,Math.round(navigator.deviceMemory)),(f=navigator.userAgentData)&&f.getHighEntropyValues?f.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((function(t){var e;se(22,t.platform),se(23,t.platformVersion),null===(e=t.brands)||void 0===e||e.forEach((function(t){se(24,t.name+"~"+t.version)})),se(25,t.model),F(27,t.mobile?1:0)})):se(22,navigator.platform)),screen&&(F(14,Math.round(screen.width)),F(15,Math.round(screen.height)),F(16,Math.round(screen.colorDepth)));for(var h=0,v=o.cookies;h<v.length;h++){var g=v[h],m=Ae(g);m&&dt(g,m)}null===ge&&(ge={source:0,ad_Storage:o.track?"granted":"denied",analytics_Storage:o.track?"granted":"denied"}),D(Ee(ge)),Ce(l)}function be(){ve=null,fe=null,pe.forEach((function(t){t.called=!1}))}function we(t,e,n,r){void 0===e&&(e=!0),void 0===n&&(n=!1),void 0===r&&(r=!1);var a=o.lean?0:1,i=!1;fe&&(a||!1===e)&&(t(fe,!o.lean,r?ge:void 0),i=!0),!n&&i||pe.push({callback:t,wait:e,recall:n,called:i,consentInfo:r})}function ke(){return fe?[fe.userId,fe.sessionId,fe.pageNum].join("."):""}function _e(t){void 0===t&&(t=!0),t?(Se({ad_Storage:"granted",analytics_Storage:"granted"}),R()):Se()}function Se(t,e){var n;void 0===t&&(t=me),void 0===e&&(e=1);var r={source:null!==(n=t.source)&&void 0!==n?n:e,ad_Storage:Ie(t.ad_Storage,null==ge?void 0:ge.ad_Storage),analytics_Storage:Ie(t.analytics_Storage,null==ge?void 0:ge.analytics_Storage)};if(!ge||r.ad_Storage!==ge.ad_Storage||r.analytics_Storage!==ge.analytics_Storage){ge=r,Oe(!0);var a=Ee(ge);if(!a.analytics_Storage&&o.track)return o.track=!1,qe("_clsk","",-Number.MAX_VALUE),qe("_clck","",-Number.MAX_VALUE),Pn(),void window.setTimeout(An,250);fn()&&a.analytics_Storage&&(o.track=!0,Ce(ze(),1),Me()),U(a),R()}}function Ee(t){var e;return{source:null!==(e=t.source)&&void 0!==e?e:0,ad_Storage:"granted"===t.ad_Storage?1:0,analytics_Storage:"granted"===t.analytics_Storage?1:0}}function Ie(t,e){return void 0===e&&(e="denied"),"string"==typeof t?t.toLowerCase():e}function Te(){qe("_clsk","",0)}function Oe(t){void 0===t&&(t=!1),function(t,e){void 0===e&&(e=!1);if(pe.length>0)for(var n=0;n<pe.length;n++){var r=pe[n];r.callback&&(!r.called&&!e||r.consentInfo&&e)&&(!r.wait||t)&&(r.callback(fe,!o.lean,r.consentInfo?ge:void 0),r.called=!0,r.recall||(pe.splice(n,1),n--))}}(o.lean?0:1,t)}function Me(){if(fe&&o.track){var t=Math.round(Date.now()),e=o.upload&&"string"==typeof o.upload?o.upload.replace("https://",""):"",n=o.lean?0:1;qe("_clsk",[fe.sessionId,t,fe.pageNum,n,e].join("^"),1)}}function xe(t,e){try{return!!t[e]}catch(t){return!1}}function Ce(t,e){void 0===e&&(e=null),e=null===e?t.consent:e;var n=Math.ceil((Date.now()+31536e6)/864e5),r=0===t.dob?null===o.dob?0:o.dob:t.dob;(null===t.expiry||Math.abs(n-t.expiry)>=1||t.consent!==e||t.dob!==r)&&qe("_clck",[fe.userId,2,n.toString(36),e,r].join("^"),365)}function Ne(){var t=Math.floor(Math.random()*Math.pow(2,32));return window&&window.crypto&&window.crypto.getRandomValues&&Uint32Array&&(t=window.crypto.getRandomValues(new Uint32Array(1))[0]),t.toString(36)}function je(t,e){return void 0===e&&(e=10),parseInt(t,e)}function ze(){var t={id:Ne(),version:0,expiry:null,consent:0,dob:0},e=Ae("_clck",!o.includeSubdomains);if(e&&e.length>0){var n=e.includes("^")?e.split("^"):e.split("|");n.length>1&&(t.version=je(n[1])),n.length>2&&(t.expiry=je(n[2],36)),n.length>3&&1===je(n[3])&&(t.consent=1),n.length>4&&je(n[1])>1&&(t.dob=je(n[4])),o.track=o.track||1===t.consent,t.id=o.track?n[0]:t.id}return t}function Ae(t,e){var n;if(void 0===e&&(e=!1),xe(document,"cookie")){var r=document.cookie.split(";");if(r)for(var a=0;a<r.length;a++){var o=r[a].split("=");if(o.length>1&&o[0]&&o[0].trim()===t){for(var i=Pe(o[1]),u=i[0],c=i[1];u;)u=(n=Pe(c))[0],c=n[1];return e?c.endsWith("".concat("~","1"))?c.substring(0,c.length-2):null:c}}}return null}function Pe(t){try{var e=decodeURIComponent(t);return[e!=t,e]}catch(t){}return[!1,t]}function qe(t,e,n){if((o.track||""==e)&&(navigator&&navigator.cookieEnabled||xe(document,"cookie"))){var r=function(t){return encodeURIComponent(t)}(e),a=new Date;a.setDate(a.getDate()+n);var i=a?"expires="+a.toUTCString():"",u="".concat(t,"=").concat(r).concat(";").concat(i).concat(";path=/");try{if(null===ve){for(var c=location.hostname?location.hostname.split("."):[],s=c.length-1;s>=0;s--)if(ve=".".concat(c[s]).concat(ve||""),s<c.length-1&&(document.cookie="".concat(u).concat(";").concat("domain=").concat(ve),Ae(t)===e))return;ve=""}}catch(t){ve=""}document.cookie=ve?"".concat(u).concat(";").concat("domain=").concat(ve):u}}var De,Re=null;function Le(){var t=fe;Re={version:l,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0,applicationPlatform:0,url:""}}function Ue(){Re=null}function He(t){return Re.start=Re.start+Re.duration,Re.duration=s()-Re.start,Re.sequence++,Re.upload=t&&"sendBeacon"in navigator?1:0,Re.end=t?1:0,Re.applicationPlatform=0,Re.url=y(location.href,!1,!0),[Re.version,Re.sequence,Re.start,Re.duration,Re.projectId,Re.userId,Re.sessionId,Re.pageNum,Re.upload,Re.end,Re.applicationPlatform,Re.url]}function Xe(){De=[]}function Ve(t){if(De&&-1===De.indexOf(t.message)){var e=o.report;if(e&&e.length>0&&Re){var n={v:Re.version,p:Re.projectId,u:Re.userId,s:Re.sessionId,n:Re.pageNum};t.message&&(n.m=t.message),t.stack&&(n.e=t.stack);var r=new XMLHttpRequest;r.open("POST",e,!0),r.send(JSON.stringify(n)),De.push(t.message)}}return t}function Ye(t){return function(){var e=performance.now();try{t.apply(this,arguments)}catch(t){throw Ve(t)}var n=performance.now()-e;G(4,n),n>30&&(J(7),F(6,n),t.dn&&"".concat(t.dn,"-").concat(n))}}var Be=new Map;function We(t,e,n,r,a){void 0===r&&(r=!1),void 0===a&&(a=!0),n=Ye(n);try{t[i("addEventListener")](e,n,{capture:r,passive:a}),function(t){return Be.has(t)}(t)||Be.set(t,[]),Be.get(t).push({event:e,listener:n,options:{capture:r,passive:a}})}catch(t){}}function Ze(){Be.forEach((function(t,e){!function(t,e){t.forEach((function(t){try{e[i("removeEventListener")](t.event,t.listener,{capture:t.options.capture,passive:t.options.passive})}catch(t){}})),Be.delete(e)}(t,e)})),Be=new Map}var Je=null,Ge=null,Fe=null,Ke=0;function Qe(){return!(Ke++>20)}function $e(){Ke=0,Fe!==en()&&(Pn(),window.setTimeout(tn,250))}function tn(){An(),F(29,1)}function en(){return location.href?location.href.replace(location.hash,""):location.href}var nn=[],rn=null,an=null,on=null;function un(){nn=[],rn=null,an=null}function cn(){var t=nn.shift();t&&(rn=t,t.task().then((function(){t.id===ke()&&(t.resolve(),rn=null,cn())})).catch((function(e){t.id===ke()&&(e&&(e.name,e.message,e.stack),rn=null,cn())})))}var sn=!1;function ln(){sn=!0,u=c(),un(),Ze(),Xe(),Fe=en(),Ke=0,We(window,"popstate",$e),null===Je&&(Je=history.pushState,history.pushState=function(){Je.apply(this,arguments),fn()&&Qe()&&$e()}),null===Ge&&(Ge=history.replaceState,history.replaceState=function(){Ge.apply(this,arguments),fn()&&Qe()&&$e()})}function dn(){Fe=null,Ke=0,Xe(),Ze(),un(),u=0,sn=!1}function fn(){return sn}function pn(){An(),Y("clarity","restart")}var hn=null;function vn(){hn=null}function gn(t){hn={fetchStart:Math.round(t.fetchStart),connectStart:Math.round(t.connectStart),connectEnd:Math.round(t.connectEnd),requestStart:Math.round(t.requestStart),responseStart:Math.round(t.responseStart),responseEnd:Math.round(t.responseEnd),domInteractive:Math.round(t.domInteractive),domComplete:Math.round(t.domComplete),loadEventStart:Math.round(t.loadEventStart),loadEventEnd:Math.round(t.loadEventEnd),redirectCount:Math.round(t.redirectCount),size:t.transferSize?t.transferSize:0,type:t.type,protocol:t.nextHopProtocol,encodedSize:t.encodedBodySize?t.encodedBodySize:0,decodedSize:t.decodedBodySize?t.decodedBodySize:0},function(t){ct(this,void 0,void 0,(function(){var e,n;return st(this,(function(r){return e=s(),n=[e,t],29===t&&(n.push(hn.fetchStart),n.push(hn.connectStart),n.push(hn.connectEnd),n.push(hn.requestStart),n.push(hn.responseStart),n.push(hn.responseEnd),n.push(hn.domInteractive),n.push(hn.domComplete),n.push(hn.loadEventStart),n.push(hn.loadEventEnd),n.push(hn.redirectCount),n.push(hn.size),n.push(hn.type),n.push(hn.protocol),n.push(hn.encodedSize),n.push(hn.decodedSize),vn(),Wt(n)),[2]}))}))}(29)}var mn,yn=0,bn=1/0,wn=0,kn=0,_n=[],Sn=new Map,En=function(){return yn||0},In=function(){if(!_n.length)return-1;var t=Math.min(_n.length-1,Math.floor((En()-kn)/50));return _n[t].latency},Tn=function(){kn=En(),_n.length=0,Sn.clear()},On=function(t){if(t.interactionId&&!(t.duration<40)){!function(t){"interactionCount"in performance?yn=performance.interactionCount:t.interactionId&&(bn=Math.min(bn,t.interactionId),wn=Math.max(wn,t.interactionId),yn=wn?(wn-bn)/7+1:0)}(t);var e=_n[_n.length-1],n=Sn.get(t.interactionId);if(n||_n.length<10||t.duration>(null==e?void 0:e.latency)){if(n)t.duration>n.latency&&(n.latency=t.duration);else{var r={id:t.interactionId,latency:t.duration};Sn.set(r.id,r),_n.push(r)}_n.sort((function(t,e){return e.latency-t.latency})),_n.length>10&&_n.splice(10).forEach((function(t){return Sn.delete(t.id)}))}}},Mn=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint","event"];function xn(){try{mn&&mn.disconnect(),mn=new PerformanceObserver(Ye(Cn));for(var t=0,e=Mn;t<e.length;t++){var n=e[t];PerformanceObserver.supportedEntryTypes.indexOf(n)>=0&&("layout-shift"===n&&G(9,0),mn.observe({type:n,buffered:!0}))}}catch(t){}}function Cn(t){!function(t){for(var e=(!("visibilityState"in document)||"visible"===document.visibilityState),n=0;n<t.length;n++){var r=t[n];switch(r.entryType){case"navigation":gn(r);break;case"resource":var a=r.name;se(4,jn(a)),a!==o.upload&&a!==o.fallback||F(28,r.duration);break;case"longtask":J(7);break;case"first-input":e&&F(10,r.processingStart-r.startTime);break;case"event":e&&"PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&(On(r),se(37,In().toString()));break;case"layout-shift":e&&!r.hadRecentInput&&G(9,1e3*r.value);break;case"largest-contentful-paint":e&&F(8,r.startTime)}}}(t.getEntries())}var Nn=null;function jn(t){return Nn||(Nn=document.createElement("a")),Nn.href=t,Nn.host}var zn=[z,z,z,Object.freeze({__proto__:null,start:function(){vn(),function(){navigator&&navigator.connection&&se(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?We(window,"load",K.bind(this,xn,0)):xn())}()},stop:function(){mn&&mn.disconnect(),mn=null,Tn(),Nn=null,vn()}}),z];function An(t){void 0===t&&(t=null),function(){try{var t=navigator&&"globalPrivacyControl"in navigator&&1==navigator.globalPrivacyControl;return!1===sn&&"undefined"!=typeof Promise&&window.MutationObserver&&document.createTreeWalker&&"now"in Date&&"now"in performance&&"undefined"!=typeof WeakMap&&!t}catch(t){return!1}}()&&(!function(t){if(null===t||sn)return!1;for(var e in t)e in o&&(o[e]=t[e])}(t),ln(),Et(),zn.forEach((function(t){return Ye(t.start)()})),null===t&&Ln())}function Pn(){fn()&&(zn.slice().reverse().forEach((function(t){return Ye(t.stop)()})),It(),dn(),void 0!==Dn&&(Dn[Rn]=function(){(Dn[Rn].q=Dn[Rn].q||[]).push(arguments),"start"===arguments[0]&&Dn[Rn].q.unshift(Dn[Rn].q.pop())&&Ln()}))}var qn=Object.freeze({__proto__:null,consent:_e,consentv2:Se,dlog:se,event:Y,hashText:M,identify:ft,maxMetric:F,measure:Ye,metadata:we,pause:function(){fn()&&(Y("clarity","pause"),null===an&&(an=new Promise((function(t){on=t}))))},queue:Wt,register:j,resume:function(){fn()&&(an&&(on(),an=null,null===rn&&cn()),Y("clarity","resume"))},schedule:function(t,e){return void 0===e&&(e=0),ct(this,void 0,void 0,(function(){var n,r,a;return st(this,(function(o){for(n=0,r=nn;n<r.length;n++)if(r[n].task===t)return[2];return a=new Promise((function(n){nn[1===e?"unshift":"push"]({task:t,resolve:n,id:ke()})})),null===rn&&null===an&&cn(),[2,a]}))}))},set:dt,signal:function(t){kt=t},start:An,stop:Pn,time:s,upgrade:it,version:l}),Dn=window,Rn="clarity";function Ln(){if(void 0!==Dn){if(Dn[Rn]&&Dn[Rn].v)return console.warn("Error CL001: Multiple Clarity tags detected.");var t=Dn[Rn]&&Dn[Rn].q||[];for(Dn[Rn]=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return qn[t].apply(qn,e)},Dn[Rn].v=l;t.length>0;)Dn[Rn].apply(Dn,t.shift())}}Ln()}();
1
+ !function(){"use strict";var t=Object.freeze({__proto__:null,get queue(){return Yt},get start(){return Vt},get stop(){return Bt},get track(){return qt}}),e=Object.freeze({__proto__:null,get check(){return Qt},get compute(){return te},get data(){return Dt},get start(){return Kt},get stop(){return ee},get trigger(){return $t}}),n=Object.freeze({__proto__:null,get compute(){return ce},get data(){return ne},get log(){return ue},get reset(){return se},get start(){return oe},get stop(){return ie},get updates(){return re}}),r=Object.freeze({__proto__:null,get compute(){return be},get config(){return ge},get consent(){return ve},get data(){return le},get start(){return fe},get stop(){return pe},get trackConsentv2(){return ye}}),a=Object.freeze({__proto__:null,get callback(){return Pe},get callbacks(){return ke},get clear(){return ze},get consent(){return xe},get consentv2(){return Ce},get data(){return we},get electron(){return _e},get id(){return Me},get metadata(){return Te},get save(){return Ae},get shortid(){return De},get start(){return Ie},get stop(){return Oe}}),o=Object.freeze({__proto__:null,get data(){return He},get envelope(){return Ye},get start(){return Xe},get stop(){return Ve}}),i={projectId:null,delay:1e3,lean:!1,lite:!1,track:!0,content:!0,drop:[],mask:[],unmask:[],regions:[],cookies:[],fraud:!0,checksum:[],report:null,upload:null,fallback:null,upgrade:null,action:null,dob:null,delayDom:!1,throttleDom:!0,conversions:!1,includeSubdomains:!0};function u(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}var c=0;function s(){return performance.now()+performance.timeOrigin}function l(t){void 0===t&&(t=null);var e=0===c?s():c,n=t&&t.timeStamp>0?t.timeStamp:performance.now(),r=t&&t.view?t.view.performance.timeOrigin:performance.timeOrigin;return Math.max(Math.round(n+r-e),0)}var d="0.8.44";var f=/\S/gi,p=255,h=!0,g=null,v=null,m=null;function y(t,e,n,r,a){if(void 0===r&&(r=!1),t){if("input"==e&&("checkbox"===a||"radio"===a))return t;switch(n){case 0:return t;case 1:switch(e){case"*T":case"value":case"placeholder":case"click":return function(t){var e=-1,n=0,r=!1,a=!1,o=!1,i=null;E();for(var u=0;u<t.length;u++){var c=t.charCodeAt(u);if(r=r||c>=48&&c<=57,a=a||64===c,o=9===c||10===c||13===c||32===c,0===u||u===t.length-1||o){if(r||a){null===i&&(i=t.split(""));var s=t.substring(e+1,o?u:u+1);s=h&&null!==m?s.match(m)?s:_(s,"▪","▫"):k(s),i.splice(e+1-n,s.length,s),n+=s.length-1}o&&(r=!1,a=!1,e=u)}}return i?i.join(""):t}(t);case"input":case"change":return S(t)}return t;case 2:case 3:switch(e){case"*T":case"data-":return r?w(t):k(t);case"src":case"srcset":case"title":case"alt":case"href":case"xlink:href":return 3===n?"src"===e&&(null==t?void 0:t.startsWith("blob:"))?"blob:":"":t;case"value":case"click":case"input":case"change":return S(t);case"placeholder":return k(t)}break;case 4:switch(e){case"*T":case"data-":return r?w(t):k(t);case"value":case"input":case"click":case"change":return Array(5).join("•");case"checksum":return""}break;case 5:switch(e){case"*T":case"data-":return _(t,"▪","▫");case"value":case"input":case"click":case"change":return Array(5).join("•");case"checksum":case"src":case"srcset":case"alt":case"title":return""}}}return t}function b(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=!1);var r=t;if(e)r="".concat("https://").concat("Electron");else{var a=i.drop;if(a&&a.length>0&&t&&t.indexOf("?")>0){var o=t.split("?"),u=o[0],c=o[1];r=u+"?"+c.split("&").map((function(t){return a.some((function(e){return 0===t.indexOf("".concat(e,"="))}))?"".concat(t.split("=")[0],"=").concat("*na*"):t})).join("&")}}return n&&(r=r.substring(0,p)),r}function w(t){var e=t.trim();if(e.length>0){var n=e[0],r=t.indexOf(n),a=t.substr(0,r),o=t.substr(r+e.length);return"".concat(a).concat(e.length.toString(36)).concat(o)}return t}function k(t){return t.replace(f,"•")}function _(t,e,n){return E(),t?t.replace(v,e).replace(g,n):t}function S(t){for(var e=5*(Math.floor(t.length/5)+1),n="",r=0;r<e;r++)n+=r>0&&r%5==0?" ":"•";return n}function E(){if(h&&null===g)try{g=new RegExp("\\p{N}","gu"),v=new RegExp("\\p{L}","gu"),m=new RegExp("\\p{Sc}","gu")}catch(t){h=!1}}var I=[],O=null;function T(){}var M=[];function x(){}function C(){}function j(){}function N(){}function z(){}var P=Object.freeze({__proto__:null,checkDocumentStyles:function(t){},compute:function(){},data:O,event:N,hashText:x,keys:M,log:T,observe:function(){},register:z,reset:function(){},sheetAdoptionState:[],sheetUpdateState:[],start:function(){},state:I,stop:function(){},track:j,trigger:C}),A=null;function q(t,e){gn()&&t&&"string"==typeof t&&t.length<255&&(A=e&&"string"==typeof e&&e.length<255?{key:t,value:e}:{value:t},Ft(24))}var D,R=null,L=null;function U(t){t in R||(R[t]=0),t in L||(L[t]=0),R[t]++,L[t]++}function H(t,e){null!==e&&(t in R||(R[t]=0),t in L||(L[t]=0),R[t]+=e,L[t]+=e)}function X(t,e){null!==e&&!1===isNaN(e)&&(t in R||(R[t]=0),(e>R[t]||0===R[t])&&(L[t]=e,R[t]=e))}function V(t,e,n){return window.setTimeout(Ze(t),e,n)}function Y(t){return window.clearTimeout(t)}var B=0,W=0,Z=null;function J(){Z&&Y(Z),Z=V(G,W),B=l()}function G(){var t=l();D={gap:t-B},Ft(25),D.gap<3e5?Z=V(G,W):fn&&(q("clarity","suspend"),Rn(),["mousemove","touchstart"].forEach((function(t){return Ge(document,t,vn)})),["resize","scroll","pageshow"].forEach((function(t){return Ge(window,t,vn)})))}var F=Object.freeze({__proto__:null,get data(){return D},reset:J,start:function(){W=6e4,B=0},stop:function(){Y(Z),B=0,W=0}}),K=null;function Q(t){gn()&&i.lean&&(i.lean=!1,K={key:t},Pe(),Ae(),i.upgrade&&i.upgrade(t),Ft(3),i.lite)}var $=Object.freeze({__proto__:null,get data(){return K},start:function(){!i.lean&&i.upgrade&&i.upgrade("Config"),K=null},stop:function(){K=null},upgrade:Q});function tt(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,u)}c((r=r.apply(t,e||[])).next())}))}function et(t,e){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}var nt=null;function rt(t,e){ot(t,"string"==typeof e?[e]:e)}function at(t,e,n,r){return void 0===e&&(e=null),void 0===n&&(n=null),void 0===r&&(r=null),tt(this,void 0,void 0,(function(){var a,o;return et(this,(function(i){switch(i.label){case 0:return o={},[4,ct(t)];case 1:return o.userId=i.sent(),o.userHint=r||((u=t)&&u.length>=5?"".concat(u.substring(0,2)).concat(_(u.substring(2),"*","*")):_(u,"*","*")),ot("userId",[(a=o).userId]),ot("userHint",[a.userHint]),ot("userType",[st(t)]),e&&(ot("sessionId",[e]),a.sessionId=e),n&&(ot("pageId",[n]),a.pageId=n),[2,a]}var u}))}))}function ot(t,e){if(gn()&&t&&e&&"string"==typeof t&&t.length<255){for(var n=(t in nt?nt[t]:[]),r=0;r<e.length;r++)"string"==typeof e[r]&&e[r].length<255&&n.push(e[r]);nt[t]=n}}function it(){Ft(34)}function ut(){nt={}}function ct(t){return tt(this,void 0,void 0,(function(){var e;return et(this,(function(n){switch(n.label){case 0:return n.trys.push([0,4,,5]),crypto&&t?[4,crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t))]:[3,2];case 1:return e=n.sent(),[2,Array.prototype.map.call(new Uint8Array(e),(function(t){return("00"+t.toString(16)).slice(-2)})).join("")];case 2:return[2,""];case 3:return[3,5];case 4:return n.sent(),[2,""];case 5:return[2]}}))}))}function st(t){return t&&t.indexOf("@")>0?"email":"string"}var lt="CompressionStream"in window;function dt(t){return tt(this,void 0,void 0,(function(){var e,n;return et(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),lt?(e=new ReadableStream({start:function(e){return tt(this,void 0,void 0,(function(){return et(this,(function(n){return e.enqueue(t),e.close(),[2]}))}))}}).pipeThrough(new TextEncoderStream).pipeThrough(new window.CompressionStream("gzip")),n=Uint8Array.bind,[4,ft(e)]):[3,2];case 1:return[2,new(n.apply(Uint8Array,[void 0,r.sent()]))];case 2:return[3,4];case 3:return r.sent(),[3,4];case 4:return[2,null]}}))}))}function ft(t){return tt(this,void 0,void 0,(function(){var e,n,r,a,o;return et(this,(function(i){switch(i.label){case 0:e=t.getReader(),n=[],r=!1,a=[],i.label=1;case 1:return r?[3,3]:[4,e.read()];case 2:return o=i.sent(),r=o.done,a=o.value,r?[2,n]:(n.push.apply(n,a),[3,1]);case 3:return[2,n]}}))}))}function pt(t,e){try{return!!t[e]}catch(t){return!1}}function ht(t){try{var e=decodeURIComponent(t);return[e!=t,e]}catch(t){}return[!1,t]}var gt=null,vt="^";function mt(t,e){var n;if(void 0===e&&(e=!1),pt(document,"cookie")){var r=document.cookie.split(";");if(r)for(var a=0;a<r.length;a++){var o=r[a].split("=");if(o.length>1&&o[0]&&o[0].trim()===t){for(var i=ht(o[1]),u=i[0],c=i[1];u;)u=(n=ht(c))[0],c=n[1];return e?c.endsWith("".concat("~","1"))?c.substring(0,c.length-2):null:c}}}return null}function yt(t,e,n){if((i.track||""==e)&&(navigator&&navigator.cookieEnabled||pt(document,"cookie"))){var r=function(t){return encodeURIComponent(t)}(e),a=new Date;a.setDate(a.getDate()+n);var o=a?"expires="+a.toUTCString():"",u="".concat(t,"=").concat(r).concat(";").concat(o).concat(";path=/");try{if(null===gt){for(var c=location.hostname?location.hostname.split("."):[],s=c.length-1;s>=0;s--)if(gt=".".concat(c[s]).concat(gt||""),s<c.length-1&&(document.cookie="".concat(u).concat(";").concat("domain=").concat(gt),mt(t)===e))return;gt=""}}catch(t){gt=""}document.cookie=gt?"".concat(u).concat(";").concat("domain=").concat(gt):u}}var bt=null;function wt(t){try{if(!bt)return;var e=function(t){try{return JSON.parse(t)}catch(t){return[]}}(t);e.forEach((function(t){bt(t)}))}catch(t){}}var kt=[P,n,Object.freeze({__proto__:null,compute:it,get data(){return nt},identify:at,reset:ut,set:rt,start:function(){ut()},stop:function(){ut()}}),e,P,Object.freeze({__proto__:null,COOKIE_SEP:vt,getCookie:mt,setCookie:yt,start:function(){gt=null},stop:function(){gt=null}}),r,a,o,t,F,$,P];function _t(){R={},L={},U(5),kt.forEach((function(t){return Ze(t.start)()}))}function St(){kt.slice().reverse().forEach((function(t){return Ze(t.stop)()})),R={},L={}}function Et(){it(),ce(),Ft(0),te(),be()}function It(t,e,n){return"".concat(t,"=").concat(y(e,0===t.indexOf("data-")?"data-":t,n))}var Ot=[],Tt=1,Mt=null;function xt(){Ot=[],function(t){var e=[t];for(;e.length>0;){for(var n=null,r=null,a=null,o=e.shift(),i=o.firstChild,u=o.parentElement?o.parentElement:o.parentNode?o.parentNode:null;i;)e.push(i),i=i.nextSibling;switch(o.nodeType){case Node.DOCUMENT_TYPE_NODE:var c=o;r="*D",n={name:c.name,publicId:c.publicId,systemId:c.systemId};break;case Node.TEXT_NODE:a=o.nodeValue,r=Mt.get(u)?"*T":r;break;case Node.ELEMENT_NODE:var s=o;n=Ct(s),r=["NOSCRIPT","SCRIPT","STYLE"].indexOf(s.tagName)<0?s.tagName:r}jt(o,u,{tag:r,attributes:n,value:a})}}(document),function(t){tt(this,void 0,void 0,(function(){var e,n,r,a,o,i,u,c,s,d,f,p,h;return et(this,(function(g){switch(e=l(),n=[e,t],t){case 8:r=O,n.push(r.width),n.push(r.height),r.width,r.height,Yt(n);break;case 43:if((a=Ot).length>0){for(o=0,i=a;o<i.length;o++)for(u=i[o],c=u.metadata.privacy,s=u.data,d=0,f=["tag","attributes","value"];d<f.length;d++)if(s[p=f[d]])switch(p){case"tag":n.push(u.id),u.parent&&n.push(u.parent),u.previous&&n.push(u.previous),n.push(s[p]);break;case"attributes":for(h in s[p])void 0!==s[p][h]&&n.push(It(h,s[p][h],c));break;case"value":n.push(y(s[p],s.tag,c))}Yt(function(t){for(var e=[],n={},r=0,a=null,o=0;o<t.length;o++)if("string"==typeof t[o]){var i=t[o],u=n[i]||-1;u>=0?a?a.push(u):(a=[u],e.push(a),r++):(a=null,e.push(i),n[i]=r++)}else a=null,e.push(t[o]),r++;return e}(n),!0)}}return[2]}))}))}(43)}function Ct(t){var e={},n=t.attributes;if(n&&n.length>0)for(var r=0;r<n.length;r++)e[n[r].name]=n[r].value;return e}function jt(t,e,n){if(t&&n&&n.tag){var r=function(t){return null===t?null:Mt.has(t)?Mt.get(t):(Mt.set(t,Tt),Tt++)}(t),a=e?Mt.get(e):null,o=t.previousSibling?Mt.get(t.previousSibling):null;Ot.push({id:r,parent:a,previous:o,children:[],data:n,selector:null,hash:null,region:null,metadata:{active:!0,suspend:!1,privacy:5,position:null,fraud:null,size:null}})}}var Nt,zt,Pt,At,qt,Dt,Rt=0,Lt=0,Ut=null,Ht=0,Xt=!1;function Vt(){At=!0,Rt=0,Lt=0,Xt=!1,Ht=0,Nt=[],zt=[],Pt={},qt=null}function Yt(t,e){if(void 0===e&&(e=!0),At){var n=l(),r=t.length>1?t[1]:null,a=JSON.stringify(t);switch(i.lean?!Xt&&Lt+a.length>10485760&&(Xt=!0):Xt=!1,r){case 5:if(Xt)break;Rt+=a.length;case 37:case 6:case 43:case 45:case 46:case 44:case 51:if(Xt)break;Lt+=a.length,Nt.push(a);break;default:zt.push(a)}U(25);var o=function(){var t=!1===i.lean&&Rt>0?100:He.sequence*i.delay;return"string"==typeof i.upload?Math.max(Math.min(t,3e4),100):i.delay}();n-Ht>2*o&&(Y(Ut),Ut=null),e&&null===Ut&&(25!==r&&J(),Ut=V(Wt,o),Ht=n,Qt(Lt))}}function Bt(){Y(Ut),Wt(!0),Rt=0,Lt=0,Xt=!1,Ht=0,Nt=[],zt=[],Pt={},qt=null,At=!1}function Wt(t){return void 0===t&&(t=!1),tt(this,void 0,void 0,(function(){var e,n,r,a,o,u,c,s;return et(this,(function(l){switch(l.label){case 0:return At?(Ut=null,(e=!1===i.lean&&Lt>0&&(Lt<1048576||He.sequence>0))&&X(1,1),Et(),n=!0===t,He?(r=JSON.stringify(Ye(n)),a="[".concat(zt.join(),"]"),o=e?"[".concat(Nt.join(),"]"):"",n&&o.length>0&&r.length+a.length+o.length>65536&&(o=""),u=function(t){return t.p.length>0?'{"e":'.concat(t.e,',"a":').concat(t.a,',"p":').concat(t.p,"}"):'{"e":'.concat(t.e,',"a":').concat(t.a,"}")}({e:r,a:a,p:o}),n?(s=null,[3,3]):[3,1]):[2]):[2];case 1:return[4,dt(u)];case 2:s=l.sent(),l.label=3;case 3:return H(2,(c=s)?c.length:u.length),Zt(u,c,He.sequence,n),zt=[],e&&(Nt=[],Lt=0,Rt=0,Xt=!1),[2]}}))}))}function Zt(t,e,n,r){if(void 0===r&&(r=!1),"string"==typeof i.upload){var a=i.upload,o=!1;if(r&&navigator&&navigator.sendBeacon)try{(o=navigator.sendBeacon.bind(navigator)(a,t))&&Gt(n)}catch(t){}if(!1===o){n in Pt?Pt[n].attempts++:Pt[n]={data:t,attempts:1};var u=new XMLHttpRequest;u.open("POST",a,!0),u.timeout=15e3,u.ontimeout=function(){We(new Error("".concat("Timeout"," : ").concat(a)))},null!==n&&(u.onreadystatechange=function(){Ze(Jt)(u,n)}),u.withCredentials=!0,e?(u.setRequestHeader("Accept","application/x-clarity-gzip"),u.send(e)):u.send(t)}}else if(i.upload){(0,i.upload)(t),Gt(n)}}function Jt(t,e){var n=Pt[e];t&&4===t.readyState&&n&&((t.status<200||t.status>208)&&n.attempts<=1?t.status>=400&&t.status<500?$t(6):(0===t.status&&(i.upload=i.fallback?i.fallback:i.upload),qt={sequence:e,attempts:n.attempts,status:t.status},Ft(2),Zt(n.data,null,e)):(qt={sequence:e,attempts:n.attempts,status:t.status},n.attempts>1&&Ft(2),200===t.status&&t.responseText&&function(t){for(var e=t&&t.length>0?t.split("\n"):[],n=0,r=e;n<r.length;n++){var a=r[n],o=a&&a.length>0?a.split(/ (.*)/):[""];switch(o[0]){case"END":$t(6);break;case"UPGRADE":Q("Auto");break;case"ACTION":i.action&&o.length>1&&i.action(o[1]);break;case"EXTRACT":case"MODULE":o.length>1&&o[1];break;case"SIGNAL":o.length>1&&wt(o[1]);break;case"SNAPSHOT":i.lean=!1,xt()}}}(t.responseText),0===t.status&&(Zt(n.data,null,e,!0),$t(3)),t.status>=200&&t.status<=208&&Gt(e),delete Pt[e]))}function Gt(t){1===t&&(Ae(),Pe())}function Ft(t){var e=[l(),t];switch(t){case 4:var n=I;n&&n.data&&((e=[n.time,n.event]).push(n.data.visible),e.push(n.data.docWidth),e.push(n.data.docHeight),e.push(n.data.screenWidth),e.push(n.data.screenHeight),e.push(n.data.scrollX),e.push(n.data.scrollY),e.push(n.data.pointerX),e.push(n.data.pointerY),e.push(n.data.activityTime),e.push(n.data.scrollTime),e.push(n.data.pointerTime),e.push(n.data.moveX),e.push(n.data.moveY),e.push(n.data.moveTime),e.push(n.data.downX),e.push(n.data.downY),e.push(n.data.downTime),e.push(n.data.upX),e.push(n.data.upY),e.push(n.data.upTime),e.push(n.data.pointerPrevX),e.push(n.data.pointerPrevY),e.push(n.data.pointerPrevTime),e.push(n.data.modules),Yt(e,!1));break;case 25:e.push(D.gap),Yt(e);break;case 35:e.push(Dt.check),Yt(e,!1);break;case 3:e.push(K.key),Yt(e);break;case 2:e.push(qt.sequence),e.push(qt.attempts),e.push(qt.status),Yt(e,!1);break;case 24:A.key&&e.push(A.key),e.push(A.value),Yt(e);break;case 34:var r=Object.keys(nt);if(r.length>0){for(var a=0,o=r;a<o.length;a++){var i=o[a];e.push(i),e.push(nt[i])}ut(),Yt(e,!1)}break;case 0:var u=Object.keys(L);if(u.length>0){for(var c=0,s=u;c<s.length;c++){var d=s[c],f=parseInt(d,10);e.push(f),e.push(Math.round(L[d]))}L={},Yt(e,!1)}break;case 1:var p=Object.keys(re);if(p.length>0){for(var h=0,g=p;h<g.length;h++){var v=g[h];f=parseInt(v,10);e.push(f),e.push(re[v])}se(),Yt(e,!1)}break;case 36:var m=Object.keys(O);if(m.length>0){for(var y=0,b=m;y<b.length;y++){var w=b[y];f=parseInt(w,10);e.push(f),e.push([].concat.apply([],O[w]))}Yt(e,!1)}break;case 40:M.forEach((function(t){e.push(t);var n=[];for(var r in O[t]){var a=parseInt(r,10);n.push(a),n.push(O[t][r])}e.push(n)})),Yt(e,!1);break;case 47:e.push(le.source),e.push(le.ad_Storage),e.push(le.analytics_Storage),Yt(e,!1)}}function Kt(){Dt={check:0}}function Qt(t){if(0===Dt.check){var e=Dt.check;e=He.sequence>=128?1:e,e=He.pageNum>=128?7:e,e=l()>72e5?2:e,(e=t>10485760?2:e)!==Dt.check&&$t(e)}}function $t(t){Dt.check=t,5!==t&&(ze(),Rn())}function te(){0!==Dt.check&&Ft(35)}function ee(){Dt=null}var ne=null,re=null,ae=!1;function oe(){ne={},re={},ae=!1}function ie(){ne={},re={},ae=!1}function ue(t,e){if(e&&(e="".concat(e),t in ne||(ne[t]=[]),ne[t].indexOf(e)<0)){if(ne[t].length>128)return void(ae||(ae=!0,$t(5)));ne[t].push(e),t in re||(re[t]=[]),re[t].push(e)}}function ce(){Ft(1)}function se(){re={},ae=!1}var le=null,de=!0;function fe(){var t,e=null===(t=window.google_tag_data)||void 0===t?void 0:t.ics;de=!0,(null==e?void 0:e.addListener)&&e.addListener(["ad_storage","analytics_storage"],he)}function pe(){de=!0}function he(){var t,e=null===(t=window.google_tag_data)||void 0===t?void 0:t.ics;if(null==e?void 0:e.getConsentState){var n=e.getConsentState("analytics_storage");Ce(function(t){var e={ad_Storage:1===t.ad_Storage?"granted":"denied",analytics_Storage:1===t.analytics_Storage?"granted":"denied"};return e}({ad_Storage:e.getConsentState("ad_storage"),analytics_Storage:n}),2)}}function ge(t){me(t.analytics_Storage?1:0),le=t}function ve(){me(2)}function me(t){ue(36,t.toString())}function ye(t){le=t,Ft(47)}function be(){var t;if(de&&(Ft(47),de=!1,!i.track)){var e=null===(t=window.google_tag_data)||void 0===t?void 0:t.ics;(null==e?void 0:e.usedUpdate)&&he()}}var we=null,ke=[],_e=0,Se=null,Ee={source:1,ad_Storage:"denied",analytics_Storage:"denied"};function Ie(){var t,e,n,r=navigator&&"userAgent"in navigator?navigator.userAgent:"",a=null!==(n="undefined"!=typeof Intl&&(null===(e=null===(t=null===Intl||void 0===Intl?void 0:Intl.DateTimeFormat())||void 0===t?void 0:t.resolvedOptions())||void 0===e?void 0:e.timeZone))&&void 0!==n?n:"",o=(new Date).getTimezoneOffset().toString(),u=window.location.ancestorOrigins?Array.from(window.location.ancestorOrigins).toString():"",c=document&&document.title?document.title:"";_e=r.indexOf("Electron")>0?1:0;var s=function(){var t={session:De(),ts:Math.round(Date.now()),count:1,upgrade:null,upload:""},e=mt("_clsk",!i.includeSubdomains);if(e){var n=e.includes("^")?e.split("^"):e.split("|");n.length>=5&&t.ts-Re(n[1])<18e5&&(t.session=n[0],t.count=Re(n[2])+1,t.upgrade=Re(n[3]),t.upload=n.length>=6?"".concat("https://").concat(n[5],"/").concat(n[4]):"".concat("https://").concat(n[4]))}return t}(),l=Le(),d=i.projectId||function(t,e){void 0===e&&(e=null);for(var n,r=5381,a=r,o=0;o<t.length;o+=2)r=(r<<5)+r^t.charCodeAt(o),o+1<t.length&&(a=(a<<5)+a^t.charCodeAt(o+1));return n=Math.abs(r+11579*a),(e?n%Math.pow(2,e):n).toString(36)}(location.host);we={projectId:d,userId:l.id,sessionId:s.session,pageNum:s.count},i.lean=i.track&&null!==s.upgrade?0===s.upgrade:i.lean,i.upload=i.track&&"string"==typeof i.upload&&s.upload&&s.upload.length>"https://".length?s.upload:i.upload,ue(0,r),ue(3,c),ue(1,b(location.href,!!_e)),ue(2,document.referrer),ue(15,function(){var t=De();if(i.track&&pt(window,"sessionStorage")){var e=sessionStorage.getItem("_cltk");t=e||t,sessionStorage.setItem("_cltk",t)}return t}()),ue(16,document.documentElement.lang),ue(17,document.dir),ue(26,"".concat(window.devicePixelRatio)),ue(28,l.dob.toString()),ue(29,l.version.toString()),ue(33,u),ue(34,a),ue(35,o),X(0,s.ts),X(1,0),X(35,_e);var f,p=null===window||void 0===window?void 0:window.Zone;p&&"__symbol__"in p&&X(39,1),navigator&&(ue(9,navigator.language),X(33,navigator.hardwareConcurrency),X(32,navigator.maxTouchPoints),X(34,Math.round(navigator.deviceMemory)),(f=navigator.userAgentData)&&f.getHighEntropyValues?f.getHighEntropyValues(["model","platform","platformVersion","uaFullVersion"]).then((function(t){var e;ue(22,t.platform),ue(23,t.platformVersion),null===(e=t.brands)||void 0===e||e.forEach((function(t){ue(24,t.name+"~"+t.version)})),ue(25,t.model),X(27,t.mobile?1:0)})):ue(22,navigator.platform)),screen&&(X(14,Math.round(screen.width)),X(15,Math.round(screen.height)),X(16,Math.round(screen.colorDepth)));for(var h=0,g=i.cookies;h<g.length;h++){var v=g[h],m=mt(v);m&&rt(v,m)}null===Se&&(Se={source:0,ad_Storage:i.track?"granted":"denied",analytics_Storage:i.track?"granted":"denied"}),ge(je(Se)),qe(l)}function Oe(){we=null,ke.forEach((function(t){t.called=!1}))}function Te(t,e,n,r){void 0===e&&(e=!0),void 0===n&&(n=!1),void 0===r&&(r=!1);var a=i.lean?0:1,o=!1;we&&(a||!1===e)&&(t(we,!i.lean,r?Se:void 0),o=!0),!n&&o||ke.push({callback:t,wait:e,recall:n,called:o,consentInfo:r})}function Me(){return we?[we.userId,we.sessionId,we.pageNum].join("."):""}function xe(t){void 0===t&&(t=!0),t?(Ce({ad_Storage:"granted",analytics_Storage:"granted"}),ve()):Ce()}function Ce(t,e){var n;void 0===t&&(t=Ee),void 0===e&&(e=1);var r={source:null!==(n=t.source)&&void 0!==n?n:e,ad_Storage:Ne(t.ad_Storage,null==Se?void 0:Se.ad_Storage),analytics_Storage:Ne(t.analytics_Storage,null==Se?void 0:Se.analytics_Storage)};if(!Se||r.ad_Storage!==Se.ad_Storage||r.analytics_Storage!==Se.analytics_Storage){Se=r,Pe(!0);var a=je(Se);if(!a.analytics_Storage&&i.track)return i.track=!1,ze(!0),Rn(),void window.setTimeout(Dn,250);gn()&&a.analytics_Storage&&(i.track=!0,qe(Le(),1),Ae()),ye(a),ve()}}function je(t){var e;return{source:null!==(e=t.source)&&void 0!==e?e:0,ad_Storage:"granted"===t.ad_Storage?1:0,analytics_Storage:"granted"===t.analytics_Storage?1:0}}function Ne(t,e){return void 0===e&&(e="denied"),"string"==typeof t?t.toLowerCase():e}function ze(t){void 0===t&&(t=!1),yt("_clsk","",-Number.MAX_VALUE),t&&yt("_clck","",-Number.MAX_VALUE)}function Pe(t){void 0===t&&(t=!1),function(t,e){void 0===e&&(e=!1);if(ke.length>0)for(var n=0;n<ke.length;n++){var r=ke[n];r.callback&&(!r.called&&!e||r.consentInfo&&e)&&(!r.wait||t)&&(r.callback(we,!i.lean,r.consentInfo?Se:void 0),r.called=!0,r.recall||(ke.splice(n,1),n--))}}(i.lean?0:1,t)}function Ae(){if(we&&i.track){var t=Math.round(Date.now()),e=i.upload&&"string"==typeof i.upload?i.upload.replace("https://",""):"",n=i.lean?0:1;yt("_clsk",[we.sessionId,t,we.pageNum,n,e].join(vt),1)}}function qe(t,e){void 0===e&&(e=null),e=null===e?t.consent:e;var n=Math.ceil((Date.now()+31536e6)/864e5),r=0===t.dob?null===i.dob?0:i.dob:t.dob;(null===t.expiry||Math.abs(n-t.expiry)>=1||t.consent!==e||t.dob!==r)&&yt("_clck",[we.userId,2,n.toString(36),e,r].join(vt),365)}function De(){var t=Math.floor(Math.random()*Math.pow(2,32));return window&&window.crypto&&window.crypto.getRandomValues&&Uint32Array&&(t=window.crypto.getRandomValues(new Uint32Array(1))[0]),t.toString(36)}function Re(t,e){return void 0===e&&(e=10),parseInt(t,e)}function Le(){var t={id:De(),version:0,expiry:null,consent:0,dob:0},e=mt("_clck",!i.includeSubdomains);if(e&&e.length>0){var n=e.includes("^")?e.split("^"):e.split("|");n.length>1&&(t.version=Re(n[1])),n.length>2&&(t.expiry=Re(n[2],36)),n.length>3&&1===Re(n[3])&&(t.consent=1),n.length>4&&Re(n[1])>1&&(t.dob=Re(n[4])),i.track=i.track||1===t.consent,t.id=i.track?n[0]:t.id}return t}var Ue,He=null;function Xe(){var t=we;He={version:d,sequence:0,start:0,duration:0,projectId:t.projectId,userId:t.userId,sessionId:t.sessionId,pageNum:t.pageNum,upload:0,end:0,applicationPlatform:0,url:""}}function Ve(){He=null}function Ye(t){return He.start=He.start+He.duration,He.duration=l()-He.start,He.sequence++,He.upload=t&&"sendBeacon"in navigator?1:0,He.end=t?1:0,He.applicationPlatform=0,He.url=b(location.href,!1,!0),[He.version,He.sequence,He.start,He.duration,He.projectId,He.userId,He.sessionId,He.pageNum,He.upload,He.end,He.applicationPlatform,He.url]}function Be(){Ue=[]}function We(t){if(Ue&&-1===Ue.indexOf(t.message)){var e=i.report;if(e&&e.length>0&&He){var n={v:He.version,p:He.projectId,u:He.userId,s:He.sessionId,n:He.pageNum};t.message&&(n.m=t.message),t.stack&&(n.e=t.stack);var r=new XMLHttpRequest;r.open("POST",e,!0),r.send(JSON.stringify(n)),Ue.push(t.message)}}return t}function Ze(t){return function(){var e=performance.now();try{t.apply(this,arguments)}catch(t){throw We(t)}var n=performance.now()-e;H(4,n),n>30&&(U(7),X(6,n),t.dn&&"".concat(t.dn,"-").concat(n))}}var Je=new Map;function Ge(t,e,n,r,a){void 0===r&&(r=!1),void 0===a&&(a=!0),n=Ze(n);try{t[u("addEventListener")](e,n,{capture:r,passive:a}),function(t){return Je.has(t)}(t)||Je.set(t,[]),Je.get(t).push({event:e,listener:n,options:{capture:r,passive:a}})}catch(t){}}function Fe(){Je.forEach((function(t,e){!function(t,e){t.forEach((function(t){try{e[u("removeEventListener")](t.event,t.listener,{capture:t.options.capture,passive:t.options.passive})}catch(t){}})),Je.delete(e)}(t,e)})),Je=new Map}var Ke=null,Qe=null,$e=null,tn=0;function en(){return!(tn++>20)}function nn(){tn=0,$e!==an()&&(Rn(),window.setTimeout(rn,250))}function rn(){Dn(),X(29,1)}function an(){return location.href?location.href.replace(location.hash,""):location.href}var on=[],un=null,cn=null,sn=null;function ln(){on=[],un=null,cn=null}function dn(){var t=on.shift();t&&(un=t,t.task().then((function(){t.id===Me()&&(t.resolve(),un=null,dn())})).catch((function(e){t.id===Me()&&(e&&(e.name,e.message,e.stack),un=null,dn())})))}var fn=!1;function pn(){fn=!0,c=s(),ln(),Fe(),Be(),$e=an(),tn=0,Ge(window,"popstate",nn),null===Ke&&(Ke=history.pushState,history.pushState=function(){Ke.apply(this,arguments),gn()&&en()&&nn()}),null===Qe&&(Qe=history.replaceState,history.replaceState=function(){Qe.apply(this,arguments),gn()&&en()&&nn()})}function hn(){$e=null,tn=0,Be(),Fe(),ln(),c=0,fn=!1}function gn(){return fn}function vn(){Dn(),q("clarity","restart")}var mn=null;function yn(){mn=null}function bn(t){mn={fetchStart:Math.round(t.fetchStart),connectStart:Math.round(t.connectStart),connectEnd:Math.round(t.connectEnd),requestStart:Math.round(t.requestStart),responseStart:Math.round(t.responseStart),responseEnd:Math.round(t.responseEnd),domInteractive:Math.round(t.domInteractive),domComplete:Math.round(t.domComplete),loadEventStart:Math.round(t.loadEventStart),loadEventEnd:Math.round(t.loadEventEnd),redirectCount:Math.round(t.redirectCount),size:t.transferSize?t.transferSize:0,type:t.type,protocol:t.nextHopProtocol,encodedSize:t.encodedBodySize?t.encodedBodySize:0,decodedSize:t.decodedBodySize?t.decodedBodySize:0},function(t){tt(this,void 0,void 0,(function(){var e,n;return et(this,(function(r){return e=l(),n=[e,t],29===t&&(n.push(mn.fetchStart),n.push(mn.connectStart),n.push(mn.connectEnd),n.push(mn.requestStart),n.push(mn.responseStart),n.push(mn.responseEnd),n.push(mn.domInteractive),n.push(mn.domComplete),n.push(mn.loadEventStart),n.push(mn.loadEventEnd),n.push(mn.redirectCount),n.push(mn.size),n.push(mn.type),n.push(mn.protocol),n.push(mn.encodedSize),n.push(mn.decodedSize),yn(),Yt(n)),[2]}))}))}(29)}var wn,kn=0,_n=1/0,Sn=0,En=0,In=[],On=new Map,Tn=function(){return kn||0},Mn=function(){if(!In.length)return-1;var t=Math.min(In.length-1,Math.floor((Tn()-En)/50));return In[t].latency},xn=function(){En=Tn(),In.length=0,On.clear()},Cn=function(t){if(t.interactionId&&!(t.duration<40)){!function(t){"interactionCount"in performance?kn=performance.interactionCount:t.interactionId&&(_n=Math.min(_n,t.interactionId),Sn=Math.max(Sn,t.interactionId),kn=Sn?(Sn-_n)/7+1:0)}(t);var e=In[In.length-1],n=On.get(t.interactionId);if(n||In.length<10||t.duration>(null==e?void 0:e.latency)){if(n)t.duration>n.latency&&(n.latency=t.duration);else{var r={id:t.interactionId,latency:t.duration};On.set(r.id,r),In.push(r)}In.sort((function(t,e){return e.latency-t.latency})),In.length>10&&In.splice(10).forEach((function(t){return On.delete(t.id)}))}}},jn=["navigation","resource","longtask","first-input","layout-shift","largest-contentful-paint","event"];function Nn(){try{wn&&wn.disconnect(),wn=new PerformanceObserver(Ze(zn));for(var t=0,e=jn;t<e.length;t++){var n=e[t];PerformanceObserver.supportedEntryTypes.indexOf(n)>=0&&("layout-shift"===n&&H(9,0),wn.observe({type:n,buffered:!0}))}}catch(t){}}function zn(t){!function(t){for(var e=(!("visibilityState"in document)||"visible"===document.visibilityState),n=0;n<t.length;n++){var r=t[n];switch(r.entryType){case"navigation":bn(r);break;case"resource":var a=r.name;ue(4,An(a)),a!==i.upload&&a!==i.fallback||X(28,r.duration);break;case"longtask":U(7);break;case"first-input":e&&X(10,r.processingStart-r.startTime);break;case"event":e&&"PerformanceEventTiming"in window&&"interactionId"in PerformanceEventTiming.prototype&&(Cn(r),ue(37,Mn().toString()));break;case"layout-shift":e&&!r.hadRecentInput&&H(9,1e3*r.value);break;case"largest-contentful-paint":e&&X(8,r.startTime)}}}(t.getEntries())}var Pn=null;function An(t){return Pn||(Pn=document.createElement("a")),Pn.href=t,Pn.host}var qn=[P,P,P,Object.freeze({__proto__:null,start:function(){yn(),function(){navigator&&navigator.connection&&ue(27,navigator.connection.effectiveType),window.PerformanceObserver&&PerformanceObserver.supportedEntryTypes&&("complete"!==document.readyState?Ge(window,"load",V.bind(this,Nn,0)):Nn())}()},stop:function(){wn&&wn.disconnect(),wn=null,xn(),Pn=null,yn()}}),P];function Dn(t){void 0===t&&(t=null),function(){try{var t=navigator&&"globalPrivacyControl"in navigator&&1==navigator.globalPrivacyControl;return!1===fn&&"undefined"!=typeof Promise&&window.MutationObserver&&document.createTreeWalker&&"now"in Date&&"now"in performance&&"undefined"!=typeof WeakMap&&!t}catch(t){return!1}}()&&(!function(t){if(null===t||fn)return!1;for(var e in t)e in i&&(i[e]=t[e])}(t),pn(),_t(),qn.forEach((function(t){return Ze(t.start)()})),null===t&&Xn())}function Rn(){gn()&&(qn.slice().reverse().forEach((function(t){return Ze(t.stop)()})),St(),hn(),void 0!==Un&&(Un[Hn]=function(){(Un[Hn].q=Un[Hn].q||[]).push(arguments),"start"===arguments[0]&&Un[Hn].q.unshift(Un[Hn].q.pop())&&Xn()}))}var Ln=Object.freeze({__proto__:null,consent:xe,consentv2:Ce,dlog:ue,event:q,hashText:x,identify:at,maxMetric:X,measure:Ze,metadata:Te,pause:function(){gn()&&(q("clarity","pause"),null===cn&&(cn=new Promise((function(t){sn=t}))))},queue:Yt,register:z,resume:function(){gn()&&(cn&&(sn(),cn=null,null===un&&dn()),q("clarity","resume"))},schedule:function(t,e){return void 0===e&&(e=0),tt(this,void 0,void 0,(function(){var n,r,a;return et(this,(function(o){for(n=0,r=on;n<r.length;n++)if(r[n].task===t)return[2];return a=new Promise((function(n){on[1===e?"unshift":"push"]({task:t,resolve:n,id:Me()})})),null===un&&null===cn&&dn(),[2,a]}))}))},set:rt,signal:function(t){bt=t},start:Dn,stop:Rn,time:l,upgrade:Q,version:d}),Un=window,Hn="clarity";function Xn(){if(void 0!==Un){if(Un[Hn]&&Un[Hn].v)return console.warn("Error CL001: Multiple Clarity tags detected.");var t=Un[Hn]&&Un[Hn].q||[];for(Un[Hn]=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return Ln[t].apply(Ln,e)},Un[Hn].v=d;t.length>0;)Un[Hn].apply(Un,t.shift())}}Xn()}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-js",
3
- "version": "0.8.43",
3
+ "version": "0.8.44",
4
4
  "description": "An analytics library that uses web page interactions to generate aggregated insights",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -1,2 +1,2 @@
1
- let version = "0.8.43";
1
+ let version = "0.8.44";
2
2
  export default version;
@@ -0,0 +1,90 @@
1
+ import { Constant } from "@clarity-types/data";
2
+ import config from "@src/core/config";
3
+ import { decodeCookieValue, encodeCookieValue, supported } from "@src/data/util";
4
+
5
+ let rootDomain = null;
6
+ export const COOKIE_SEP = Constant.Caret;
7
+
8
+ export function start() {
9
+ rootDomain = null;
10
+ }
11
+
12
+ export function stop() {
13
+ rootDomain = null;
14
+ }
15
+
16
+ export function getCookie(key: string, limit = false): string {
17
+ if (supported(document, Constant.Cookie)) {
18
+ let cookies: string[] = document.cookie.split(Constant.Semicolon);
19
+ if (cookies) {
20
+ for (let i = 0; i < cookies.length; i++) {
21
+ let pair: string[] = cookies[i].split(Constant.Equals);
22
+ if (pair.length > 1 && pair[0] && pair[0].trim() === key) {
23
+ // Some browsers automatically url encode cookie values if they are not url encoded.
24
+ // We therefore encode and decode cookie values ourselves.
25
+ // For backwards compatability we need to consider 3 cases:
26
+ // * Cookie was previously not encoded by Clarity and browser did not encode it
27
+ // * Cookie was previously not encoded by Clarity and browser encoded it once or more
28
+ // * Cookie was previously encoded by Clarity and browser did not encode it
29
+ let [isEncoded, decodedValue] = decodeCookieValue(pair[1]);
30
+
31
+ while (isEncoded) {
32
+ [isEncoded, decodedValue] = decodeCookieValue(decodedValue);
33
+ }
34
+
35
+ // If we are limiting cookies, check if the cookie value is limited
36
+ if (limit) {
37
+ return decodedValue.endsWith(`${Constant.Tilde}1`) ? decodedValue.substring(0, decodedValue.length - 2) : null;
38
+ }
39
+
40
+ return decodedValue;
41
+ }
42
+ }
43
+ }
44
+ }
45
+ return null;
46
+ }
47
+
48
+ export function setCookie(key: string, value: string, time: number): void {
49
+ // only write cookies if we are currently in a cookie writing mode (and they are supported)
50
+ // OR if we are trying to write an empty cookie (i.e. clear the cookie value out)
51
+ if ((config.track || value == Constant.Empty) && ((navigator && navigator.cookieEnabled) || supported(document, Constant.Cookie))) {
52
+ // Some browsers automatically url encode cookie values if they are not url encoded.
53
+ // We therefore encode and decode cookie values ourselves.
54
+ let encodedValue = encodeCookieValue(value);
55
+
56
+ let expiry = new Date();
57
+ expiry.setDate(expiry.getDate() + time);
58
+ let expires = expiry ? Constant.Expires + expiry.toUTCString() : Constant.Empty;
59
+ let cookie = `${key}=${encodedValue}${Constant.Semicolon}${expires}${Constant.Path}`;
60
+ try {
61
+ // Attempt to get the root domain only once and fall back to writing cookie on the current domain.
62
+ if (rootDomain === null) {
63
+ let hostname = location.hostname ? location.hostname.split(Constant.Dot) : [];
64
+ // Walk backwards on a domain and attempt to set a cookie, until successful
65
+ for (let i = hostname.length - 1; i >= 0; i--) {
66
+ rootDomain = `.${hostname[i]}${rootDomain ? rootDomain : Constant.Empty}`;
67
+ // We do not wish to attempt writing a cookie on the absolute last part of the domain, e.g. .com or .net.
68
+ // So we start attempting after second-last part, e.g. .domain.com (PASS) or .co.uk (FAIL)
69
+ if (i < hostname.length - 1) {
70
+ // Write the cookie on the current computed top level domain
71
+ document.cookie = `${cookie}${Constant.Semicolon}${Constant.Domain}${rootDomain}`;
72
+ // Once written, check if the cookie exists and its value matches exactly with what we intended to set
73
+ // Checking for exact value match helps us eliminate a corner case where the cookie may already be present with a different value
74
+ // If the check is successful, no more action is required and we can return from the function since rootDomain cookie is already set
75
+ // If the check fails, continue with the for loop until we can successfully set and verify the cookie
76
+ if (getCookie(key) === value) {
77
+ return;
78
+ }
79
+ }
80
+ }
81
+ // Finally, if we were not successful and gone through all the options, play it safe and reset rootDomain to be empty
82
+ // This forces our code to fall back to always writing cookie to the current domain
83
+ rootDomain = Constant.Empty;
84
+ }
85
+ } catch {
86
+ rootDomain = Constant.Empty;
87
+ }
88
+ document.cookie = rootDomain ? `${cookie}${Constant.Semicolon}${Constant.Domain}${rootDomain}` : cookie;
89
+ }
90
+ }
package/src/data/index.ts CHANGED
@@ -13,6 +13,7 @@ import * as upgrade from "@src/data/upgrade";
13
13
  import * as upload from "@src/data/upload";
14
14
  import * as variable from "@src/data/variable";
15
15
  import * as extract from "@src/data/extract";
16
+ import * as cookie from "@src/data/cookie";
16
17
  export { event } from "@src/data/custom";
17
18
  export { consent, consentv2, metadata } from "@src/data/metadata";
18
19
  export { upgrade } from "@src/data/upgrade";
@@ -21,7 +22,7 @@ export { signal } from "@src/data/signal";
21
22
  export { max as maxMetric } from "@src/data/metric";
22
23
  export { log as dlog } from "@src/data/dimension";
23
24
 
24
- const modules: Module[] = [baseline, dimension, variable, limit, summary, consent, metadata, envelope, upload, ping, upgrade, extract];
25
+ const modules: Module[] = [baseline, dimension, variable, limit, summary, cookie, consent, metadata, envelope, upload, ping, upgrade, extract];
25
26
 
26
27
  export function start(): void {
27
28
  // Metric needs to be initialized before we can start measuring. so metric is not wrapped in measure
@@ -1,25 +1,24 @@
1
- import { Time } from "@clarity-types/core";
2
- import { BooleanFlag, Constant, Dimension, Metadata, MetadataCallback, MetadataCallbackOptions, Metric, Session, User, Setting, ConsentState, ConsentSource, ConsentData } from "@clarity-types/data";
1
+ import { Constant as CoreConstant, Time } from "@clarity-types/core";
2
+ import { BooleanFlag, ConsentData, ConsentSource, ConsentState, Constant, Dimension, Metadata, MetadataCallback, MetadataCallbackOptions, Metric, Session, Setting, User } from "@clarity-types/data";
3
3
  import * as clarity from "@src/clarity";
4
4
  import * as core from "@src/core";
5
5
  import config from "@src/core/config";
6
6
  import hash from "@src/core/hash";
7
7
  import * as scrub from "@src/core/scrub";
8
+ import * as trackConsent from "@src/data/consent";
9
+ import { COOKIE_SEP, getCookie, setCookie } from "@src/data/cookie";
8
10
  import * as dimension from "@src/data/dimension";
9
11
  import * as metric from "@src/data/metric";
12
+ import { supported } from "@src/data/util";
10
13
  import { set } from "@src/data/variable";
11
- import * as trackConsent from "@src/data/consent";
12
- import { Constant as CoreConstant } from "@clarity-types/core";
13
14
 
14
15
  export let data: Metadata = null;
15
16
  export let callbacks: MetadataCallbackOptions[] = [];
16
17
  export let electron = BooleanFlag.False;
17
- let rootDomain = null;
18
18
  let consentStatus: ConsentState = null;
19
19
  let defaultStatus: ConsentState = { source: ConsentSource.API, ad_Storage: Constant.Denied, analytics_Storage: Constant.Denied };
20
20
 
21
21
  export function start(): void {
22
- rootDomain = null;
23
22
  const ua = navigator && "userAgent" in navigator ? navigator.userAgent : Constant.Empty;
24
23
  const timezone = (typeof Intl !== 'undefined' && Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone) ?? '';
25
24
  const timezoneOffset = new Date().getTimezoneOffset().toString();
@@ -114,7 +113,6 @@ function userAgentData(): void {
114
113
  }
115
114
 
116
115
  export function stop(): void {
117
- rootDomain = null;
118
116
  data = null;
119
117
  callbacks.forEach(cb => { cb.called = false; });
120
118
  }
@@ -171,8 +169,7 @@ export function consentv2(consentState: ConsentState = defaultStatus, source: nu
171
169
 
172
170
  if (!consentData.analytics_Storage && config.track) {
173
171
  config.track = false;
174
- setCookie(Constant.SessionKey, Constant.Empty, -Number.MAX_VALUE);
175
- setCookie(Constant.CookieKey, Constant.Empty, -Number.MAX_VALUE);
172
+ clear(true);
176
173
  clarity.stop();
177
174
  window.setTimeout(clarity.start, Setting.RestartDelay);
178
175
  return;
@@ -202,9 +199,14 @@ function normalizeConsent(value: unknown, fallback: string = Constant.Denied): s
202
199
  return typeof value === 'string' ? value.toLowerCase() : fallback;
203
200
  }
204
201
 
205
- export function clear(): void {
202
+ export function clear(all: boolean = false): void {
206
203
  // Clear any stored information in the cookie that tracks session information so we can restart fresh the next time
207
- setCookie(Constant.SessionKey, Constant.Empty, 0);
204
+ setCookie(Constant.SessionKey, Constant.Empty, -Number.MAX_VALUE);
205
+
206
+ // Clear user cookie as well if all flag is set
207
+ if (all) {
208
+ setCookie(Constant.CookieKey, Constant.Empty, -Number.MAX_VALUE);
209
+ }
208
210
  }
209
211
 
210
212
  function tab(): string {
@@ -227,7 +229,7 @@ export function save(): void {
227
229
  let ts = Math.round(Date.now());
228
230
  let upload = config.upload && typeof config.upload === Constant.String ? (config.upload as string).replace(Constant.HTTPS, Constant.Empty) : Constant.Empty;
229
231
  let upgrade = config.lean ? BooleanFlag.False : BooleanFlag.True;
230
- setCookie(Constant.SessionKey, [data.sessionId, ts, data.pageNum, upgrade, upload].join(Constant.Caret), Setting.SessionExpire);
232
+ setCookie(Constant.SessionKey, [data.sessionId, ts, data.pageNum, upgrade, upload].join(COOKIE_SEP), Setting.SessionExpire);
231
233
  }
232
234
 
233
235
  function processCallback(upgrade: BooleanFlag, consentUpdate: boolean = false): void {
@@ -250,10 +252,6 @@ function processCallback(upgrade: BooleanFlag, consentUpdate: boolean = false):
250
252
  }
251
253
  }
252
254
 
253
- function supported(target: Window | Document, api: string): boolean {
254
- try { return !!target[api]; } catch { return false; }
255
- }
256
-
257
255
  function track(u: User, consent: BooleanFlag = null): void {
258
256
  // If consent is not explicitly specified, infer it from the user object
259
257
  consent = consent === null ? u.consent : consent;
@@ -266,7 +264,7 @@ function track(u: User, consent: BooleanFlag = null): void {
266
264
  // To avoid cookie churn, write user id cookie only once every day
267
265
  if (u.expiry === null || Math.abs(end - u.expiry) >= Setting.CookieInterval || u.consent !== consent || u.dob !== dob) {
268
266
  let cookieParts = [data.userId, Setting.CookieVersion, end.toString(36), consent, dob];
269
- setCookie(Constant.CookieKey, cookieParts.join(Constant.Caret), Setting.Expire);
267
+ setCookie(Constant.CookieKey, cookieParts.join(COOKIE_SEP), Setting.Expire);
270
268
  }
271
269
  }
272
270
 
@@ -321,91 +319,3 @@ function user(): User {
321
319
  return output;
322
320
  }
323
321
 
324
- function getCookie(key: string, limit = false): string {
325
- if (supported(document, Constant.Cookie)) {
326
- let cookies: string[] = document.cookie.split(Constant.Semicolon);
327
- if (cookies) {
328
- for (let i = 0; i < cookies.length; i++) {
329
- let pair: string[] = cookies[i].split(Constant.Equals);
330
- if (pair.length > 1 && pair[0] && pair[0].trim() === key) {
331
- // Some browsers automatically url encode cookie values if they are not url encoded.
332
- // We therefore encode and decode cookie values ourselves.
333
- // For backwards compatability we need to consider 3 cases:
334
- // * Cookie was previously not encoded by Clarity and browser did not encode it
335
- // * Cookie was previously not encoded by Clarity and browser encoded it once or more
336
- // * Cookie was previously encoded by Clarity and browser did not encode it
337
- let [isEncoded, decodedValue] = decodeCookieValue(pair[1]);
338
-
339
- while (isEncoded) {
340
- [isEncoded, decodedValue] = decodeCookieValue(decodedValue);
341
- }
342
-
343
- // If we are limiting cookies, check if the cookie value is limited
344
- if (limit) {
345
- return decodedValue.endsWith(`${Constant.Tilde}1`)
346
- ? decodedValue.substring(0, decodedValue.length - 2)
347
- : null;
348
- }
349
-
350
- return decodedValue;
351
- }
352
- }
353
- }
354
- }
355
- return null;
356
- }
357
-
358
- function decodeCookieValue(value: string): [boolean, string] {
359
- try {
360
- let decodedValue = decodeURIComponent(value);
361
- return [decodedValue != value, decodedValue];
362
- }
363
- catch {
364
- }
365
-
366
- return [false, value];
367
- }
368
-
369
- function encodeCookieValue(value: string): string {
370
- return encodeURIComponent(value);
371
- }
372
-
373
- function setCookie(key: string, value: string, time: number): void {
374
- // only write cookies if we are currently in a cookie writing mode (and they are supported)
375
- // OR if we are trying to write an empty cookie (i.e. clear the cookie value out)
376
- if ((config.track || value == Constant.Empty) && ((navigator && navigator.cookieEnabled) || supported(document, Constant.Cookie))) {
377
- // Some browsers automatically url encode cookie values if they are not url encoded.
378
- // We therefore encode and decode cookie values ourselves.
379
- let encodedValue = encodeCookieValue(value);
380
-
381
- let expiry = new Date();
382
- expiry.setDate(expiry.getDate() + time);
383
- let expires = expiry ? Constant.Expires + expiry.toUTCString() : Constant.Empty;
384
- let cookie = `${key}=${encodedValue}${Constant.Semicolon}${expires}${Constant.Path}`;
385
- try {
386
- // Attempt to get the root domain only once and fall back to writing cookie on the current domain.
387
- if (rootDomain === null) {
388
- let hostname = location.hostname ? location.hostname.split(Constant.Dot) : [];
389
- // Walk backwards on a domain and attempt to set a cookie, until successful
390
- for (let i = hostname.length - 1; i >= 0; i--) {
391
- rootDomain = `.${hostname[i]}${rootDomain ? rootDomain : Constant.Empty}`;
392
- // We do not wish to attempt writing a cookie on the absolute last part of the domain, e.g. .com or .net.
393
- // So we start attempting after second-last part, e.g. .domain.com (PASS) or .co.uk (FAIL)
394
- if (i < hostname.length - 1) {
395
- // Write the cookie on the current computed top level domain
396
- document.cookie = `${cookie}${Constant.Semicolon}${Constant.Domain}${rootDomain}`;
397
- // Once written, check if the cookie exists and its value matches exactly with what we intended to set
398
- // Checking for exact value match helps us eliminate a corner case where the cookie may already be present with a different value
399
- // If the check is successful, no more action is required and we can return from the function since rootDomain cookie is already set
400
- // If the check fails, continue with the for loop until we can successfully set and verify the cookie
401
- if (getCookie(key) === value) { return; }
402
- }
403
- }
404
- // Finally, if we were not successful and gone through all the options, play it safe and reset rootDomain to be empty
405
- // This forces our code to fall back to always writing cookie to the current domain
406
- rootDomain = Constant.Empty;
407
- }
408
- } catch { rootDomain = Constant.Empty; }
409
- document.cookie = rootDomain ? `${cookie}${Constant.Semicolon}${Constant.Domain}${rootDomain}` : cookie;
410
- }
411
- }
@@ -0,0 +1,18 @@
1
+ export function supported(target: Window | Document, api: string): boolean {
2
+ try { return !!target[api]; } catch { return false; }
3
+ }
4
+
5
+ export function encodeCookieValue(value: string): string {
6
+ return encodeURIComponent(value);
7
+ }
8
+
9
+ export function decodeCookieValue(value: string): [boolean, string] {
10
+ try {
11
+ let decodedValue = decodeURIComponent(value);
12
+ return [decodedValue != value, decodedValue];
13
+ }
14
+ catch {
15
+ }
16
+
17
+ return [false, value];
18
+ }