flusterduck 0.4.0 → 0.5.0

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.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- function y(e){return((...t)=>{try{return e(...t)}catch{}})}function f(e){return t=>{try{e(t)}catch{}}}var En="_fd_s";var Ma=/^[0-9a-f]{32}$/;function zo(e){if(e)return qo();let t=ka(En);if(t&&Ma.test(t))return t;let n=qo();return Xo(En,n,30),n}function bn(){Xo(En,"",-1)}function qo(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function ka(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function Xo(e,t,n){let r=new Date;r.setTime(r.getTime()+n*864e5);let o=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${r.toUTCString()};SameSite=Lax${o}`}var xa=/^[:\d]|--|^(ember|react|ng-|__)/;function p(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${Ne(t)}"]`;if(e.id&&!xa.test(e.id)&&e.id.length<64)return"#"+Ne(e.id);let n=[],r=e,o=0;for(;r&&r!==document.body&&o<5;){let i=r.tagName.toLowerCase(),s=r.getAttribute("name"),a=r.getAttribute("role"),c=r.getAttribute("type");s&&s.length<64?i+=`[name="${Ne(s)}"]`:a?i+=`[role="${Ne(a)}"]`:c&&(i==="input"||i==="button")&&(i+=`[type="${Ne(c)}"]`);let d=r.parentElement;if(d){let g=d.children,w=0,E=0;for(let b=0;b<g.length;b++){let m=g[b];m&&m.tagName===r.tagName&&(w++,m===r&&(E=w))}w>1&&(i+=`:nth-of-type(${E})`)}n.unshift(i);let l=n.join(" > ");try{if(document.querySelectorAll(l).length===1)return l}catch{}r=d,o++}return n.join(" > ")}function Ne(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}var Pe=60,Aa=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,Da=/^(INPUT|TEXTAREA|SELECT)$/;function h(e){try{let t=e.getAttribute("aria-label");if(t)return t.trim().slice(0,Pe);if(!Da.test(e.tagName)){let i=(e.textContent??"").trim().replace(/\s+/g," ").slice(0,Pe);if(i&&!Aa.test(i))return i}let n=e.getAttribute("placeholder");if(n)return n.trim().slice(0,Pe);let r=e.getAttribute("title");if(r)return r.trim().slice(0,Pe);let o=e.getAttribute("alt");return o?o.trim().slice(0,Pe):""}catch{return""}}function v(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function Yo(e,t){if(t==="off")return null;if(t==="metadata")return Ra(e);let n=Ia(e);return n?{mode:"snapshot",...n}:null}function Ra(e){return{mode:"metadata",selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:$o(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:$o(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:Oa(e)}}}function Ia(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),r=e.parentElement,o=[];if(r)for(let s=0;s<r.children.length&&o.length<6;s++){let a=r.children[s];if(!a||a===e)continue;let c=a.getBoundingClientRect();o.push({selector:p(a),tag:a.tagName.toLowerCase(),box:{x:Math.round(c.x),y:Math.round(c.y),w:Math.round(c.width),h:Math.round(c.height)},interactive:Pa(a)})}let i=[];try{let s=e.getAnimations();for(let a of s)"animationName"in a&&i.push(a.animationName)}catch{}return{selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:r?p(r):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:Na(t),animations:i,siblings:o}}catch{return null}}function $o(e,t){return e&&t.includes(e)?e:null}function Oa(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function Na(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function Pa(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var Ko=7e3,Ha=500,Fa=1e4,Go=50,Zo=100,Ba=3,He=6e4,Ct="application/json",Wa="application/json; encoding=gzip",ue=[],Z=null,Qo="",Jo=Ko,ei=Go,S=null,Mt={domMode:"off",compression:"auto"},yn=!1,Sn=null,Tn=!1;function Ln(e){Sn=e}var kt=new Set;function ti(e){return kt.add(e),()=>{kt.delete(e)}}function Va(e){if(e.t!=="sig"||!kt.size)return;let t=typeof e.d?.s=="string"?e.d.s:"";if(t)for(let n of kt)try{n(t,e.ts)}catch{}}function Cn(e){Tn=e}var Ua=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),qa=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),za=new Set(["value","text","label","email","name","phone","address","password","token","secret","cookie","session","jwt","auth","credential","card","cc","cvv","ssn"]);function Xa(e){return e.replace(/([a-z])([A-Z])/g,"$1\0$2").toLowerCase().split(/[\x00_\-.\s]+/).some(n=>za.has(n))}var $a=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,ni=f(ja),ri=y(()=>ne());function oi(e,t,n,r,o){Qo=e,S=Object.assign(Object.create(null),t),Mt={domMode:nl(o?.domMode),compression:rl(o?.compression)},Jo=Math.max(Ha,Math.min(n??Ko,Fa)),ei=Math.max(1,Math.min(r??Go,Zo)),document.addEventListener("visibilitychange",ni),window.addEventListener("pagehide",ri)}function u(e){Tn||ue.length>=Zo||(Va(e),ue.push(e),ue.length>=ei?ne():Z||(Z=setTimeout(ne,Jo)))}function ne(){Ya()}async function Ya(){if(yn||!ue.length||!S)return;yn=!0,Z&&(clearTimeout(Z),Z=null);let e=ue;ue=[];let t={v:1,sid:S.sid,key:S.key,url:S.url,page:S.page,ts:Date.now(),ua:S.ua,vw:S.vw,vh:S.vh,environment:S.environment,...S.segment?{segment:S.segment}:{},dom_mode:Mt.domMode},n=e.map(o=>Qa(o,S.page,Mt.domMode)),r=[];try{for(let o of n){let i=[...r,o];if(JSON.stringify({...t,events:i}).length>He)if(r.length>0)await _n({...t,events:r}),r=[o];else{let a={...t,events:[o]};JSON.stringify(a).length<=He?await _n(a):console.warn("[flusterduck] event dropped: serialized size exceeds limit. Reduce metadata payload size."),r=[]}else r=i}r.length>0&&await _n({...t,events:r})}catch{}finally{yn=!1}}function Mn(e){if(S)for(let t of Object.keys(e))Ua.has(t)&&(S[t]=e[t])}function ii(){ne(),Tn=!1,document.removeEventListener("visibilitychange",ni),window.removeEventListener("pagehide",ri),Z&&(clearTimeout(Z),Z=null)}function ja(){document.visibilityState==="hidden"&&ne()}async function _n(e){let t=JSON.stringify(e),n=await Ka(t,Mt.compression);n&&si(n,0)}async function Ka(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>He)return null;if(t!=="off"){let o=await Ga(e);if(o&&o.byteLength<=He)return{beaconBody:new Blob([o],{type:Wa}),fetchBody:new Uint8Array(o),headers:{"Content-Type":Ct,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:Ct}),fetchBody:e,headers:{"Content-Type":Ct}}}async function Ga(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=Za(e);if(!n)return null;let r=new t("gzip"),i=n.pipeThrough(r).getReader(),s=[],a=0;for(;;){let l=await i.read();if(l.done)break;if(a+=l.value.byteLength,a>He)return null;let g=new Uint8Array(l.value.byteLength);g.set(l.value),s.push(g)}let c=new Uint8Array(a),d=0;for(let l of s)c.set(l,d),d+=l.byteLength;return c.buffer}catch{return null}}function Za(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:Ct});if(typeof n.stream=="function")return n.stream();let r=globalThis.ReadableStream;return typeof r!="function"?null:new r({start(o){o.enqueue(t),o.close()}})}function si(e,t,n=Qo){if(n&&!(navigator.sendBeacon&&navigator.sendBeacon(n,e.beaconBody)))try{fetch(n,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}).catch(()=>{t<Ba&&setTimeout(()=>si(e,t+1,n),1e3*(t+1))})}catch{}}function Qa(e,t,n){let r=e.d??{},o=Ja(e.t),i={type:o,ts:e.ts,page:typeof r.page=="string"?r.page.slice(0,2048):t},s=jo(r.el,r.element,r.target);if(o==="signal"){i.signal_type=jo(r.s,r.signal_type,r.name)?.slice(0,128),s&&(i.element=s.slice(0,2048));let c=s?tl(s,n):null;c&&(i.dom=c),i.signal_type&&Sn&&Sn(i.signal_type)}let a=el(r);return Object.keys(a).length&&(i.metadata=a),i}function Ja(e){return e==="pv"?"pageview":e==="sig"?"signal":qa.has(e)?e:"custom_signal"}function el(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let r=xt(e[n],n);r!==void 0&&(t[n.slice(0,64)]=r)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=xt(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function xt(e,t="",n=0){if(!(n>4)&&!Xa(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return $a.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(o=>xt(o,t,n+1)).filter(o=>o!==void 0);if(typeof e=="object"){let r=Object.create(null);for(let o of Object.keys(e).slice(0,40)){if(o==="__proto__"||o==="constructor"||o==="prototype")continue;let i=xt(e[o],o,n+1);i!==void 0&&(r[o.slice(0,64)]=i)}return r}}}function tl(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?Yo(n,t):null}catch{return null}}function jo(...e){for(let t of e)if(typeof t=="string"&&t)return t}function nl(e){return e==="metadata"||e==="snapshot"?e:"off"}function rl(e){return e==="off"?"off":"auto"}function ai(e){let t=location.href;function n(){let a=location.href;a!==t&&(t=a,e(a,location.pathname))}let r=history.pushState,o=history.replaceState,i=function(...a){r.apply(this,a),n()},s=function(...a){o.apply(this,a),n()};return history.pushState=i,history.replaceState=s,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=r),history.replaceState===s&&(history.replaceState=o),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function kn(e,t){for(let n of t){let r=il(n.pattern);if(r&&r.test(e))return n.label}return sl(e)}var ol=/^[a-zA-Z0-9/:._*\-]+$/;function il(e){if(e.length>200||!ol.test(e))return null;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function sl(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id")}var al=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],B=[],li=3,ci=2e3,ui=24,At=ui,di=[],de=[],fi=0,Dt=new Map,Rt=new Map,ll=1e4,It=!1,pi=f(cl);function xn(e,t){It||(It=!0,li=e?.threshold??3,ci=e?.windowMs??2e3,At=e?.radius&&e.radius>0?e.radius:ui,di=[...al,...t??[]],fi=Date.now(),B=[],de=[],Dt.clear(),Rt.clear(),document.addEventListener("click",pi,{capture:!0,passive:!0}))}function An(){It&&(It=!1,document.removeEventListener("click",pi,{capture:!0,passive:!0}),B=[],de=[],Dt.clear(),Rt.clear())}function cl(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,di)||pl(t))return;let n=Date.now(),r=e.clientX,o=e.clientY;for(;B.length&&n-B[0].t>ci;)B.shift();B.push({t:n,x:r,y:o});let i=ul();if(B.length<i)return;let s=B.slice(-i);for(let M=0;M<s.length-1;M++)for(let Oe=M+1;Oe<s.length;Oe++){let St=s[M],Tt=s[Oe],Lt=Tt.x-St.x,ce=Tt.y-St.y;if(Lt*Lt+ce*ce>At*At)return}let a=s[0].t,d=(s[s.length-1].t-a)/1e3,l=d>0?s.length/d:s.length,g=(s.length-i)/i+l/10,w=Math.round(Math.min(1,g)*100)/100,E=fl(s,i,l),b=p(t),m=h(t);de.push({selector:b,ts:n});let $=de.length,_t=dl(n),Wo=Dt.get(b)??0,vn=Wo+1,Vo=Rt.get(b)??0,La=Vo>0&&n-Vo<ll;Dt.set(b,vn),Rt.set(b,n);let Uo=Wo>=1,Ca=(()=>{try{let M=t.getBoundingClientRect();if(M.width===0&&M.height===0)return null;let Oe=s.reduce((ce,wn)=>ce+wn.x,0)/s.length,St=s.reduce((ce,wn)=>ce+wn.y,0)/s.length,Tt=M.left+M.width/2,Lt=M.top+M.height/2;return{click_dx:Math.round(Oe-Tt),click_dy:Math.round(St-Lt),el_w:Math.round(M.width),el_h:Math.round(M.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"rage_click",el:b,...m?{el_label:m}:{},cnt:s.length,vel:Math.round(l*10)/10,intensity:w,quality:E,burst_seq:$,burst_rate_per_min:_t,repeated_target:Uo,hot_repeat:La,...Ca??{}}}),Uo&&u({t:"sig",ts:n,d:{s:"rage_click_repeat_target",el:b,...m?{el_label:m}:{},total_hits:vn,burst_count:vn,burst_seq:$}}),B=B.slice(-(i-1))}function ul(){return de.length>=3?2:li}function dl(e){let t=(e-fi)/6e4;return t<=0?0:Math.round(de.length/t*10)/10}function fl(e,t,n){let r=e.length-t,o=Math.min(4,r/5*4),s=Math.min(4,n/10*4),a=2;if(e.length>=2){let d=0,l=0;for(let w=0;w<e.length-1;w++)for(let E=w+1;E<e.length;E++){let b=e[w],m=e[E],$=m.x-b.x,_t=m.y-b.y;d+=Math.sqrt($*$+_t*_t),l++}let g=d/l;a=Math.max(0,2-g/At*2)}let c=o+s+a;return Math.round(Math.min(10,Math.max(0,c)))}function pl(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick")||e.hasAttribute("data-dbl")||e.getAttribute("role")==="spinbutton")}var ml=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,gl=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,hl=/^(A|BUTTON|LABEL)$/,vl=20,mi=[],fe=null,wl=5,Ot=new Map,gi=f(El),hi=f(_l);function El(e){fe={x:e.clientX,y:e.clientY}}function Dn(e){mi=e??[],document.addEventListener("mousedown",gi,{capture:!0,passive:!0}),document.addEventListener("click",hi,{capture:!0,passive:!0})}function Rn(){document.removeEventListener("mousedown",gi,{capture:!0}),document.removeEventListener("click",hi,{capture:!0}),fe=null,Ot.clear()}function In(){Ot.clear()}function bl(e){try{return window.getComputedStyle(e).cursor.slice(0,vl)}catch{return""}}function yl(e){try{let t=window.getComputedStyle(e);return t.cursor==="pointer"&&t.pointerEvents!=="none"}catch{return!1}}function _l(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,mi)||Cl())return;let n=Ml(e);if(fe=null,n||Sl(t))return;let r=Tl(t,e.clientX,e.clientY),o=r?vi(e.clientX,e.clientY,r):null,i=p(t),a=(Ot.get(i)??0)+1;Ot.set(i,a);let c=a>=2,d=bl(t),l=yl(t),g=h(t),w=r?h(r):"";u({t:"sig",ts:Date.now(),d:{s:"dead_click",el:i,...g?{el_label:g}:{},near:r?p(r):"",...w?{near_label:w}:{},dist:o?Math.round(o.dist):-1,...o?{click_dx:Math.round(o.dx),click_dy:Math.round(o.dy)}:{},cursor:d,...l?{looks_interactive:!0}:{},...c?{repeated:!0,repeat_cnt:a}:{}}})}function Sl(e){if(ml.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&gl.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&hl.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Tl(e,t,n){let r=e;for(let o=0;o<5&&r;o++){let i=r.parentElement;if(!i)break;let s=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),a=null,c=1/0;for(let d=0;d<s.length;d++){let l=s[d];if(!l||l===e)continue;let g=Ll(t,n,l);g<c&&(c=g,a=l)}if(a&&c<100)return a;r=i}return null}function vi(e,t,n){let r=n.getBoundingClientRect(),o=Math.max(r.left,Math.min(e,r.right)),i=Math.max(r.top,Math.min(t,r.bottom)),s=e-o,a=t-i;return{dist:Math.sqrt(s*s+a*a),dx:s,dy:a}}function Ll(e,t,n){return vi(e,t,n).dist}function Cl(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Ml(e){if(!fe)return!1;let t=e.clientX-fe.x,n=e.clientY-fe.y;return Math.sqrt(t*t+n*n)>wl}var T=null,On=3e3,wi=[],Nt="click",Pt=0,kl=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,xl=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,Ei=f(Rl),bi=f(Al),yi=f(Dl);function Nn(e,t){On=e?.delayMs??3e3,wi=t??[],document.addEventListener("click",Ei,{capture:!0,passive:!0}),document.addEventListener("keydown",bi,{capture:!0,passive:!0}),document.addEventListener("touchstart",yi,{capture:!0,passive:!0})}function Pn(){document.removeEventListener("click",Ei,{capture:!0}),document.removeEventListener("keydown",bi,{capture:!0}),document.removeEventListener("touchstart",yi,{capture:!0}),pe()}function Hn(){pe()}function Al(e){e.target&&(e.key!=="Enter"&&e.key!==" "||(Nt="keydown",Pt=Date.now()))}function Dl(){Nt="touch",Pt=Date.now()}function Rl(e){let t=e.target;if(!t||v(t,wi))return;let n=t.getAttribute("role");if(!kl.test(t.tagName)&&!(n&&xl.test(n)))return;let r=Date.now();if(r-Pt>50&&(Nt="click",Pt=r),T){if(T.el===t||T.el.contains(t)){let d=r-T.ts;d>=On&&u({t:"sig",ts:r,d:{s:"speed_frustration",el:T.selector,delay:d,interaction_type:Nt,observed_delay_ms:d}}),pe();return}pe()}let o=p(t),i=!1,s=new MutationObserver(d=>{for(let l of d){if(l.type==="childList"&&(l.addedNodes.length>0||l.removedNodes.length>0)){i=!0,pe();return}if(l.type==="attributes"&&l.target instanceof Element&&(l.target===t||t.contains(l.target)||l.target.contains(t))){i=!0,pe();return}}}),a=t.parentElement||document.body;s.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let c=setTimeout(()=>{!i&&T&&(T.observer.disconnect(),T={...T,timeout:null})},On+500);T={el:t,selector:o,ts:r,observer:s,timeout:c}}function pe(){T&&(T.observer.disconnect(),T.timeout&&clearTimeout(T.timeout),T=null)}var Il=100,Ol=5,_i=800,Si=2e3,Nl=3,Bn=0,Pl=16,Ht=0,Ft=0,Fe=0,Be=0,We=0,Bt=0,Fn=0,re=[],Wn=0,me=null,Ti=f(Hl);function Vn(e){_i=e?.velocityThreshold??800,Si=e?.windowMs??2e3,document.addEventListener("mousemove",Ti,{passive:!0})}function Un(){document.removeEventListener("mousemove",Ti),me&&clearTimeout(me),qn()}function Hl(e){let t=Date.now();t-Bn<Pl||(Bn=t,me&&clearTimeout(me),me=setTimeout(()=>qn(),150),Fl(e.clientX,e.clientY,t))}function Fl(e,t,n){if(Fe===0){Ht=e,Ft=t,Fe=n,Fn=n;return}let r=(n-Fe)/1e3;if(r===0)return;let o=e-Ht,i=t-Ft;if(Math.abs(o)<2&&Math.abs(i)<2)return;let s=Math.sqrt(o*o+i*i),a=s/r;re.length>=Il&&(re=re.slice(-50)),re.push(a),Wn+=s;let c=Math.sign(o),d=Math.sign(i);if(s>=Ol&&(Be!==0&&c!==0&&c!==Be||We!==0&&d!==0&&d!==We)&&Bt++,Be=c||Be,We=d||We,Ht=e,Ft=t,Fe=n,n-Fn>Si){if(Bt>=Nl){let l=re.reduce((g,w)=>g+w,0)/re.length;l>=_i&&u({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(l),rev:Bt,distance_px:Math.round(Wn)}})}qn(),Fn=n}}function qn(){Bt=0,re=[],Wn=0,Be=0,We=0,Fe=0,Ht=0,Ft=0,Bn=0,me=null}var Li=100,Ci=5,Bl=3,L=[],k=[],zn=3e4;function Xn(e){zn=e?.windowMs??3e4}function $n(){L=[],k=[]}function Yn(e){let t=Date.now(),n=e.indexOf("#"),r=n===-1?e:e.slice(0,n),o=n===-1?"":e.slice(n);for(;L.length&&t-L[0].ts>zn;)L.shift();for(;k.length&&t-k[0].ts>zn;)k.shift();if(L.length>=Li&&(L=L.slice(-50)),k.length>=Li&&(k=k.slice(-50)),L.push({path:e,ts:t}),o){k.push({path:e,ts:t});let a=k.filter(d=>{let l=d.path.indexOf("#");return(l===-1?d.path:d.path.slice(0,l))===r}),c=new Set(a.map(d=>{let l=d.path.indexOf("#");return l===-1?"":d.path.slice(l)}));if(c.size>=Bl&&a.length>c.size){let d=a.slice(-Ci).map(l=>l.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"hash",pages:Array.from(c).map(l=>r+l),path_sequence:d}}),k=k.filter(l=>{let g=l.path.indexOf("#");return(g===-1?l.path:l.path.slice(0,g))!==r});return}}if(L.length<4)return;let i=!1,s=[];for(let a=0;a<L.length-1;a++)if(L[a].path===e){let c=L.slice(a,L.length),d=new Set(c.map(l=>l.path));if(d.size>=2){s.push(...Array.from(d)),i=!0;break}}if(i){let a=L.slice(-Ci).map(c=>c.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"path",pages:s,path_sequence:a}}),L=[{path:e,ts:t}],k=k.filter(c=>{let d=c.path.indexOf("#");return(d===-1?c.path:c.path.slice(0,d))!==r})}}var Wl=100,Mi=1e4,Kn=.5,C=[],Wt=0,Gn=0,Ve=!1,jn=0,ki=f(Vl);function Zn(e){Mi=e?.windowMs??1e4,Kn=e?.depthThreshold??.5,window.addEventListener("scroll",ki,{passive:!0})}function Qn(){window.removeEventListener("scroll",ki),C=[],Ve=!1}function Jn(){C=[],Wt=0,Gn=0,Ve=!1}function Vl(){Ve||(Ve=!0,requestAnimationFrame(()=>{Ve=!1,Ul()}))}function Ul(){let e=Date.now(),t=window.scrollY;if(jn=document.documentElement.scrollHeight-window.innerHeight,jn<=0)return;let n=t/jn,r=t>Wt?"down":"up";if(e-Gn<100){Wt=t;return}for(;C.length&&e-C[0].ts>Mi;)C.shift();C.length>=Wl&&(C=C.slice(-50)),C.push({depth:n,ts:e,direction:r}),Wt=t,Gn=e;let o=0,i=1,s=0,a=!1,c=0,d=0,l=0,g=1,w=0;for(let E=1;E<C.length;E++)C[E].direction!==C[E-1].direction&&w++;for(let E=0;E<C.length;E++){let b=C[E],m=b.depth;if(m>o&&(o=m),m>=Kn&&(a||(c=b.ts,l=m),a=!0),a&&m<i&&(i=m,d=b.ts,g=m),a&&i<.25&&m>=Kn){if(d-c<200){a=!1,i=1,c=b.ts,l=m;continue}s++,a=!1,i=1}}if(s>=1){let E=Math.max(d-c,1),b=Math.abs(l-g)*100,m=Math.round(b/E*1e3);u({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(o*100)/100,rev:s+1,vel:m,dir_changes:w}}),C=[]}}var ql=["textarea",'[role="textbox"]',"[contenteditable]"],qe=new Map,ze=new Map,Y=new Set,oe=null,er=0,xi=5e3,Ai=[],zl=50,Di=f(Xl),Ri=f($l),Ii=f(Yl),Oi=y(Ni),Ue=null;function tr(e,t){xi=e?.pauseMs??5e3,Ai=t??[],document.addEventListener("focusin",Di,{capture:!0,passive:!0}),document.addEventListener("focusout",Ri,{capture:!0,passive:!0}),document.addEventListener("submit",Ii,{capture:!0,passive:!0}),window.addEventListener("pagehide",Oi),Ue=y(()=>{document.visibilityState==="hidden"&&Ni()}),document.addEventListener("visibilitychange",Ue)}function nr(){document.removeEventListener("focusin",Di,{capture:!0}),document.removeEventListener("focusout",Ri,{capture:!0}),document.removeEventListener("submit",Ii,{capture:!0}),window.removeEventListener("pagehide",Oi),Ue&&(document.removeEventListener("visibilitychange",Ue),Ue=null),qe.clear(),ze.clear(),Y.clear(),oe=null}function rr(){qe.clear(),ze.clear(),Y.clear(),oe=null,er=0}function Xl(e){let t=e.target;if(!t||!Pi(t)||v(t,Ai)||jl(t))return;let n=Date.now();qe.set(t,n),ze.set(t,n);let r=t.closest("form");r&&r!==oe&&(oe=r,er=r.querySelectorAll("input, select, textarea").length)}function $l(e){let t=e.target;if(!t||!Pi(t))return;let n=qe.get(t),r=ze.get(t);qe.delete(t),ze.delete(t);let o=Date.now();if(!(r!==void 0&&o-r<zl)&&n!==void 0){let a=o-n;if(a>=xi){let c=h(t);u({t:"sig",ts:o,d:{s:"form_hesitation",el:p(t),...c?{el_label:c}:{},pause:a}})}}let s=t.getAttribute("name")||t.getAttribute("id")||p(t);Kl(t)&&Y.add(s)}function Yl(){Y.clear(),oe=null}function Ni(){if(Y.size>0&&oe){let e=er||Y.size,t=Math.round(Y.size/e*100)/100;u({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:Y.size,total:e,field_count:e,completion_rate:t}}),Y.clear(),oe=null}}function Pi(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function jl(e){if(e.tagName==="TEXTAREA")return!0;for(let t of ql)try{if(e.matches(t))return!0}catch{return!1}return!1}function Kl(e){return"value"in e?e.value.length>0:!1}var ge=null,Xe=null,Hi=/flusterduck\.com|\/v1\/ingest/,Bi=f(Ql),Wi=f(Jl);function ir(){window.addEventListener("error",Bi),window.addEventListener("unhandledrejection",Wi),ec()}function sr(){window.removeEventListener("error",Bi),window.removeEventListener("unhandledrejection",Wi),tc()}var or=/fetch|network|cors|timeout/i;function Gl(e){return or.test(e)?"network":"script"}function Zl(e){if(e instanceof TypeError&&or.test(e.message)||typeof Response<"u"&&e instanceof Response)return"network";let t=e instanceof Error?e.message:String(e??"");return or.test(t)?"network":"unhandled_promise"}function Ql(e){let t=e.message||"Unknown error";u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:ar(t,200),ep:"",status:0,error_category:Gl(t),url:location.pathname}})}function Jl(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:ar(t,200),ep:"",status:0,error_category:Zl(e.reason),url:location.pathname}})}function ec(){ge||(ge=window.fetch,Xe=function(t,n){let r;try{r=ge.call(this,t,n)}catch(o){throw o}return r.then(o=>{try{if(o.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;Hi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${o.status} ${o.statusText}`,ep:Fi(i),status:o.status,error_category:"network",url:location.pathname}})}}catch{}return o},o=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;Hi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:ar(o instanceof Error?o.message:"Fetch failed",200),ep:typeof t=="string"?Fi(t):"",status:0,error_category:"network",url:location.pathname}})}catch{}throw o})},window.fetch=Xe)}function tc(){ge&&Xe&&window.fetch===Xe&&(window.fetch=ge),ge=null,Xe=null}function Fi(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),r=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,r)||"/"}}function ar(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,r=>{try{return new URL(r).origin+new URL(r).pathname}catch{return"[URL]"}}),n}var Vi=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],nc=['[class*="map"]',"canvas",".gallery","[data-zoom]"],Q=null,ve=0,$e=1,I=0,Ye=0,je=0,he=0,lr=0,cr=null,Ui=[],qi=f(rc),zi=f(oc),Xi=f(ac),$i=f(uc),Yi=f(lc);function ur(e){Ui=e??[],document.addEventListener("touchstart",qi,{passive:!0}),document.addEventListener("touchend",zi,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",Xi,{passive:!0}),window.addEventListener("orientationchange",$i,{passive:!0})),window.visualViewport?.addEventListener("resize",Yi)}function dr(){document.removeEventListener("touchstart",qi),document.removeEventListener("touchend",zi),document.removeEventListener("gesturechange",Xi),window.removeEventListener("orientationchange",$i),window.visualViewport?.removeEventListener("resize",Yi),Q=null,ve=0,$e=1,I=0,Ye=0,je=0,he=0,lr=0,cr=null}function ji(e){let t=e[0],n=e[1];if(!t||!n)return 0;let r=t.clientX-n.clientX,o=t.clientY-n.clientY;return Math.sqrt(r*r+o*o)}function rc(e){let t=e.touches[0];e.touches.length===1&&t?(Q={x:t.clientX,y:t.clientY,ts:Date.now()},ve=0):e.touches.length===2&&(ve=ji(e.touches),Q=null)}function oc(e){if(ve>0){let s=e.touches.length>=2?ji(e.touches):(()=>{let a=e.changedTouches[0],c=e.changedTouches[1];if(!a||!c)return 0;let d=a.clientX-c.clientX,l=a.clientY-c.clientY;return Math.sqrt(d*d+l*l)})();s>0&&($e=Math.round(s/ve*100)/100),ve=0}if(!Q||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-Q.x,r=t.clientY-Q.y,o=Date.now()-Q.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(r)<10&&o<300&&i&&ic(i,t.clientX,t.clientY),o<500&&(Math.abs(n)>50||Math.abs(r)>50)&&sc(i,n,r),Q=null}function ic(e,t,n){if(v(e,Ui))return;let r=dc(e,t,n);if(!r)return;let o=r.getBoundingClientRect(),i=Math.max(o.left,Math.min(t,o.right)),s=Math.max(o.top,Math.min(n,o.bottom)),a=Math.sqrt((t-i)**2+(n-s)**2);if(a>0&&a<=20){let c=`${Math.round(o.width)}x${Math.round(o.height)}`;u({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:p(r),dist:Math.round(a),size:c}})}}function sc(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||Vi.some(s=>{try{return e.matches(s)||e.closest(s)}catch{return!1}})||!Vi.some(s=>{try{return document.querySelector(s)!==null}catch{return!1}}))return;let i=t>0?"right":"left";u({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function ac(){let e=Date.now();if(e-Ye>3e4&&(I=0,Ye=e),I++,I>=2){let t=document.activeElement||document.body;!nc.some(r=>{try{return t.matches(r)||t.closest(r)}catch{return!1}})&&e-je>200&&(je=e,u({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:I,pinch_scale:$e}})),I=0,$e=1}}function lc(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();if(t-Ye>3e4&&(I=0,Ye=t),I++,I>=2&&t-je>200){let n=Math.round(e.scale*100)/100;je=t,u({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:I,pinch_scale:n}}),I=0,$e=1}}}function cc(){return window.innerWidth>window.innerHeight?"landscape":"portrait"}function uc(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-lr>3e4&&(he=0,lr=e),t!==cr&&(he++,cr=t),he>=3&&(u({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:he,orientation:cc()}}),he=0)}function dc(e,t,n){let o=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,s=21;for(let a=0;a<o.length;a++){let c=o[a];if(!c)continue;let d=c.getBoundingClientRect(),l=Math.max(d.left,Math.min(t,d.right)),g=Math.max(d.top,Math.min(n,d.bottom)),w=Math.sqrt((t-l)**2+(n-g)**2);w<s&&w>0&&(s=w,i=c)}return i}var x=[],we=null,A=0,Ee=0,V="",W=[],fr=[],fc=10,pc=5e3,Ki=5,Gi=3e3,mc=15,gc=5e3,Zi=f(hc);function pr(e){fr=e??[],document.addEventListener("keydown",Zi,{capture:!0,passive:!0})}function mr(){document.removeEventListener("keydown",Zi,{capture:!0}),x=[],W=[],we=null,A=0,Ee=0,V="",fr=[]}function hc(e){let t=Date.now(),n=e.target;n&&v(n,fr)||(e.key==="Tab"?wc(t,n,e.shiftKey):e.key==="Escape"?Ec(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&bc(t,e.target))}function vc(e){let t=0;for(let n=1;n<e.length;n++)e[n].shift!==e[n-1].shift&&t++;return t}function wc(e,t,n){for(;x.length&&e-x[0].ts>pc;)x.shift();x.length>=50&&(x=x.slice(-25));let r=t?p(t):"";if(x.push({ts:e,el:r,shift:n}),x.length>=fc){let i=x.map(a=>a.el).filter(Boolean),s=vc(x);u({t:"sig",ts:e,d:{s:"tab_thrash",cnt:x.length,els:i,direction_changes:s}}),x=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(o){let i=p(t);o===we?e-Ee<=Gi?(A++,V=i,A>=Ki&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(o),attempts:A,trapped_element:V}}),A=0,V="",we=null)):(Ee=e,A=1,V=i):(we=o,Ee=e,A=1,V=i)}}function Ec(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(n&&n===we){if(e-Ee>Gi){Ee=e,A=1,V=p(t);return}A++,V=p(t),A>=Ki&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(n),attempts:A,trapped_element:V}}),A=0,V="",we=null)}}function bc(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;W.length&&e-W[0].ts>gc;)W.shift();W.length>=50&&(W=W.slice(-25)),W.push({ts:e,container:n});let r=W.filter(o=>o.container===n);r.length>=mc&&(u({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:p(n),keys:r.length}}),W=[])}var be=0,Vt=0,Ut=null,gr=0,qt=!1,zt=0,hr=0,yc=1e4,_c=2,Sc=4,Tc=3e3,Ke=null,Xt=0,Lc=2e3,Qi=f(kc),Ji=f(Cc),es=f(Mc);function vr(){window.addEventListener("wheel",Ji,{passive:!0}),window.addEventListener("touchmove",es,{passive:!0}),window.addEventListener("scroll",Qi,{passive:!0})}function wr(){window.removeEventListener("wheel",Ji),window.removeEventListener("touchmove",es),window.removeEventListener("scroll",Qi),$t()}function $t(){be=0,Vt=0,Ut=null,gr=0,qt=!1,zt=0,hr=0,Ke=null,Xt=0}function Cc(){Ke="wheel",Xt=Date.now()}function Mc(){Ke="touch",Xt=Date.now()}function kc(){qt||(qt=!0,requestAnimationFrame(()=>{qt=!1,xc()}))}function xc(){let e=Date.now(),t=window.scrollY,n=t-Vt;if(Math.abs(n)<2){Vt=t;return}let r=n>0?"down":"up";if(Ut&&r!==Ut&&(e-gr>Tc&&(be=0,gr=e),be++,be>=Sc&&Math.abs(n)>100)){let i=e-Xt,s=Ke!==null&&i<=Lc?Ke:"wheel";e-hr>yc&&(zt=0,hr=e),zt++;let a=zt>=_c;u({t:"sig",ts:e,d:{s:"scroll_hijack",rev:be,source:s,repeated:a}}),be=0}Ut=r,Vt=t}var ie=0,ye=0,Ge=!1,ns=f(Ac),Ze=null,Qe=null;function Er(){window.addEventListener("scroll",ns,{passive:!0}),Qe=y(ts),window.addEventListener("pagehide",Qe),Ze=y(()=>{document.visibilityState==="hidden"&&ts()}),document.addEventListener("visibilitychange",Ze)}function br(){window.removeEventListener("scroll",ns),Qe&&(window.removeEventListener("pagehide",Qe),Qe=null),Ze&&(document.removeEventListener("visibilitychange",Ze),Ze=null),ie=0,ye=0,Ge=!1}function yr(){ie=0,ye=0,Ge=!1}function Ac(){Ge||(Ge=!0,requestAnimationFrame(()=>{Ge=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>ie&&(ie=t,ye===0&&(ye=Date.now()))}}))}function ts(){if(ie>.05){let e=Date.now(),t=ye>0?Math.max(0,e-ye):0;u({t:"sig",ts:e,d:{s:"scroll_depth_abandon",depth:Math.round(ie*100)/100,max_depth:Math.round(ie*100),dwell_ms:t}})}}var rs=1500,os=15e3,Dc=5e3,Rc=.15,_r="",_e=0,Yt=0,Je=0,Se=0,Sr=0,jt=null,Kt=0,Gt=!1,Zt=f(Oc),is=f(Nc),Te=f(Ic);function Tr(){Gt||(Gt=!0,Sr=ss(),et(),document.addEventListener("mouseenter",Zt,!0),document.addEventListener("mouseleave",Zt,!0),document.addEventListener("click",Te,{capture:!0,passive:!0}),document.addEventListener("keydown",Te,{capture:!0,passive:!0}),document.addEventListener("scroll",Te,{passive:!0}),window.addEventListener("resize",is,{passive:!0}))}function Lr(){Gt&&(Gt=!1,document.removeEventListener("mouseenter",Zt,!0),document.removeEventListener("mouseleave",Zt,!0),document.removeEventListener("click",Te,{capture:!0}),document.removeEventListener("keydown",Te,{capture:!0}),document.removeEventListener("scroll",Te),window.removeEventListener("resize",is),as(),_r="",_e=0,Yt=0,Se=0,Je=0,Kt=0)}function et(){as(),Kt+=1;let e=Kt;jt=setTimeout(()=>{u({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:os,cycle:e}})},os)}function Cr(){Kt=0}function Ic(){et()}function Oc(e){if(e.type!=="mouseenter")return;let t=e.target;if(!t)return;let n=p(t),r=Date.now();(n!==_r||r-Yt>rs)&&(_r=n,Yt=r,_e=0),_e+=1,!(_e<4)&&(u({t:"sig",ts:r,d:{s:"thrash_hover",el:n,cnt:_e,window_ms:rs}}),_e=0,Yt=r)}function Nc(){let e=Date.now(),t=ss(),n=Sr||t,r=Math.abs(t-n)/Math.max(n,1);Sr=t,!(r<Rc)&&((!Je||e-Je>Dc)&&(Je=e,Se=0),Se+=1,!(Se<3)&&(u({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:Se,area_delta:Math.round(r*1e3)/1e3}}),Se=0,Je=e))}function ss(){return Math.max(1,window.innerWidth*window.innerHeight)}function as(){jt&&(clearTimeout(jt),jt=null)}var ls=6e4,Pc=3,Hc=["[data-help]","[data-tooltip]","[data-faq]","[aria-describedby]",'[aria-label*="help" i]','[aria-label*="support" i]','[title*="help" i]','a[href*="/help"]','a[href*="/faq"]','a[href*="/support"]','a[href*="help."]',"details > summary",'[role="tooltip"]'],Fc=/\b(help|faq|support|tooltip|hint|guide|explain|learn.?more)\b/i,U=[],cs=[],us=f(Bc);function Mr(e){cs=e??[],document.addEventListener("click",us,{capture:!0,passive:!0})}function kr(){document.removeEventListener("click",us,{capture:!0}),U=[]}function xr(){U=[]}function Bc(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,cs)||!Wc(t))return;let n=Date.now();for(;U.length&&n-U[0].t>ls;)U.shift();let r=p(t);if(U.push({t:n,el:r}),U.length<Pc)return;let o=new Set(U.map(s=>s.el)).size,i=h(t);u({t:"sig",ts:n,d:{s:"help_hunt",cnt:U.length,unique_els:o,el:r,...i?{el_label:i}:{},window_ms:ls}}),U=[]}function Wc(e){let t=e;for(let n=0;n<3&&t;n++){if(Vc(t)||Uc(t))return!0;t=t.parentElement}return!1}function Vc(e){for(let t of Hc)try{if(e.matches(t))return!0}catch{}return!1}function Uc(e){let t=e.id??"",n=e.className??"",r=typeof n=="string"?`${t} ${n}`:t;return Fc.test(r)}var ds=/^(close|dismiss|modal-close|dialog-close|sheet-close|drawer-close)$/i,fs=/\b(close|dismiss|no\s*thanks?|maybe\s*later|skip|got\s*it|hide\s*this|don.?t\s*show)\b/i,Qt=[],Jt=new Map,ps=[],ms=f(qc);function Ar(e){ps=e??[],document.addEventListener("click",ms,{capture:!0,passive:!0})}function Dr(){document.removeEventListener("click",ms,{capture:!0}),Qt=[],Jt.clear()}function Rr(){Qt=[],Jt.clear()}function qc(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,ps)||!zc(t))return;let n=Date.now(),r=p(t),o=h(t);Qt.push({t:n,el:r});let s=(Jt.get(r)??0)+1;Jt.set(r,s);let a=Qt.length,c=(()=>{try{let d=t.getBoundingClientRect();return d.width===0&&d.height===0?null:{click_dx:Math.round(e.clientX-(d.left+d.width/2)),click_dy:Math.round(e.clientY-(d.top+d.height/2)),el_w:Math.round(d.width),el_h:Math.round(d.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"close_click",el:r,...o?{el_label:o}:{},session_cnt:a,element_cnt:s,repeated:s>1,container:$c(t),...c??{}}})}function zc(e){let t=e;for(let n=0;n<4&&t;n++){if(Xc(t))return!0;t=t.parentElement}return!1}function Xc(e){let t=e.getAttribute("data-dismiss")??"",n=e.getAttribute("data-close")??"";if(t||n)return!0;let r=e.getAttribute("aria-label")??e.getAttribute("title")??"";if(r&&fs.test(r))return!0;let o=e.id??"",i=typeof e.className=="string"?e.className:"";if(ds.test(o)||ds.test(i))return!0;let s=(e.textContent??"").trim().slice(0,60);if(s&&fs.test(s))return!0;if(e.tagName==="BUTTON"&&e.closest('[role="dialog"], [role="alertdialog"], dialog, .modal, .drawer, .sheet, .overlay, .popup, [data-modal], [data-dialog]')){let c=(e.textContent??"").trim();if(c==="\xD7"||c==="\u2715"||c==="\u2717"||c==="X"||c==="x")return!0}return!1}function $c(e){let t=[['[role="dialog"], dialog',"dialog"],['[role="alertdialog"]',"alert_dialog"],[".modal, [data-modal]","modal"],[".drawer, [data-drawer], .sheet, [data-sheet]","drawer"],[".toast, [data-toast], .notification, [data-notification]","toast"],['.banner, [data-banner], [role="banner"]',"banner"],[".cookie, [data-cookie], .consent, [data-consent]","consent"],[".popup, [data-popup], .overlay, [data-overlay]","popup"]];for(let[n,r]of t)try{if(e.closest(n))return r}catch{}return"unknown"}var Yc=1500,O=null,gs=[],hs=f(jc),vs=f(Kc),ws=f(Gc);function Ir(e){gs=e??[],document.addEventListener("click",hs,{capture:!0,passive:!0}),document.addEventListener("keydown",vs,{capture:!0,passive:!0}),window.addEventListener("popstate",ws)}function Or(){document.removeEventListener("click",hs,{capture:!0}),document.removeEventListener("keydown",vs,{capture:!0}),window.removeEventListener("popstate",ws),O=null}function Nr(){O=null}function jc(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(t&&!v(t,gs)){if(Zc(t)){O=null;return}O={el:p(t),label:h(t),t:Date.now()}}}function Kc(e){e.key==="Escape"&&Es("escape")}function Gc(){Es("back_nav")}function Es(e){if(!O)return;let t=Date.now()-O.t;if(t>Yc){O=null;return}u({t:"sig",ts:Date.now(),d:{s:"close_click_reversal",reversal:e,el:O.el,...O.label?{el_label:O.label}:{},elapsed_ms:t}}),O=null}function Zc(e){return e.tagName==="A"?!0:e.closest('a, [role="link"], nav')!==null}var bs=1e4,Qc=3,Jc=/^(checkbox|radio)$/,ys=/^(checkbox|radio|switch|tab|option|menuitemcheckbox|menuitemradio)$/,tt=new Map,Pr=[],_s=f(eu),Ss=f(tu);function Hr(e){Pr=e??[],document.addEventListener("change",_s,{capture:!0,passive:!0}),document.addEventListener("click",Ss,{capture:!0,passive:!0})}function Fr(){document.removeEventListener("change",_s,{capture:!0}),document.removeEventListener("click",Ss,{capture:!0}),tt.clear()}function Br(){tt.clear()}function eu(e){let t=e.target;t&&(v(t,Pr)||nu(t)&&Ts(t))}function tu(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Pr))return;let n=t.getAttribute("role")??"";ys.test(n)&&t.tagName!=="INPUT"&&Ts(t)}function Ts(e){let t=p(e),n=Date.now(),r=tt.get(t);for(r||(r=[],tt.set(t,r));r.length&&n-r[0].t>bs;)r.shift();if(r.push({t:n}),r.length<Qc)return;let o=h(e);u({t:"sig",ts:n,d:{s:"filter_spiral",el:t,...o?{el_label:o}:{},cnt:r.length,window_ms:bs}}),tt.delete(t)}function nu(e){return e.tagName==="SELECT"?!0:e.tagName==="INPUT"?Jc.test(e.type??""):ys.test(e.getAttribute("role")??"")}var Ls=15e3,ru=3,j=[],Cs=f(ou);function Wr(){document.addEventListener("copy",Cs,{capture:!0,passive:!0})}function Vr(){document.removeEventListener("copy",Cs,{capture:!0}),j=[]}function Ur(){j=[]}function ou(e){let t=e.target;if(t){let o=t.tagName;if(o==="INPUT"||o==="TEXTAREA"||t.isContentEditable)return}let n=window.getSelection();if(!n||n.toString().length<2)return;let r=Date.now();for(;j.length&&r-j[0].t>Ls;)j.shift();j.push({t:r}),!(j.length<ru)&&(u({t:"sig",ts:r,d:{s:"copy_frustration",cnt:j.length,window_ms:Ls}}),j=[])}var Ms=15e3,iu=4,su=5,au=500,lu=2e3,D=[],en=0,nt=null,se=null;function qr(){nt=y(uu),se=y(cu),document.addEventListener("selectionchange",nt),document.addEventListener("copy",se,{capture:!0,passive:!0}),document.addEventListener("cut",se,{capture:!0,passive:!0})}function zr(){nt&&(document.removeEventListener("selectionchange",nt),nt=null),se&&(document.removeEventListener("copy",se,{capture:!0}),document.removeEventListener("cut",se,{capture:!0}),se=null),D=[],en=0}function Xr(){D=[],en=0}function cu(){en=Date.now(),D=[]}function uu(){let e=window.getSelection();if(!e||e.isCollapsed||e.toString().length<su)return;let n=e.anchorNode?.parentElement;if(n){let i=n.tagName;if(i==="INPUT"||i==="TEXTAREA"||n.isContentEditable)return}let r=Date.now();if(r-en<lu)return;for(;D.length&&r-D[0].t>Ms;)D.shift();let o=D[D.length-1];o&&r-o.t<au||(D.push({t:r}),!(D.length<iu)&&(u({t:"sig",ts:r,d:{s:"text_select_frustration",cnt:D.length,window_ms:Ms}}),D=[]))}var $r=6e4,du=20,xs="_fd_sess",fu={rage_click:25,dead_click:15,speed_frustration:20,thrash_cursor:10,loop_nav:20,scroll_bounce:12,form_hesitation:10,form_abandon:25,error_encounter:30,user_confusion_idle:15,thrash_hover:8,viewport_thrashing:10,scroll_depth_abandon:15,scroll_hijack:12,tab_thrash:15,focus_trap:20,help_hunt:18,close_click:12,close_click_reversal:20,filter_spiral:15,copy_frustration:12,text_select_frustration:10},pu=10,ks={low:1,medium:2,high:3,critical:4},q=[],Le=null,nn=!1,Me=new Map,Ce={totalSignals:0,pagesWithFrustration:0},Yr="",rt=null,ot=null,it=null,st=null;function tn(e){nn&&As(e,Date.now())}function mu(){try{let e=sessionStorage.getItem(xs);if(e){let t=JSON.parse(e);Ce={totalSignals:typeof t.totalSignals=="number"?t.totalSignals:0,pagesWithFrustration:typeof t.pagesWithFrustration=="number"?t.pagesWithFrustration:0}}}catch{}}function gu(){try{sessionStorage.setItem(xs,JSON.stringify(Ce))}catch{}}function hu(){let e=[],n=Date.now()-$r,r=[];for(let[o,i]of Me.entries())for(let s of i)s>=n&&r.push({type:o,ts:s});r.sort((o,i)=>o.ts-i.ts);for(let o=0;o<r.length;o++)if(r[o].type==="rage_click"){for(let i=o+1;i<r.length;i++)if(r[i].type==="form_validation_loop"&&r[i].ts-r[o].ts<=3e4){e.push("rage_then_form_loop");break}}for(let o=0;o<r.length;o++)if(r[o].type==="dead_click")for(let i=o+1;i<r.length;i++){let s=r[i].type;if((s==="popstate"||s==="hashchange")&&r[i].ts-r[o].ts<=1e4){e.push("dead_then_bail");break}}for(let o=0;o<r.length;o++)if(r[o].type==="form_validation_loop"){for(let i=o+1;i<r.length;i++)if((r[i].type==="visibilitychange"||r[i].type==="pagehide")&&r[i].ts-r[o].ts<=2e4){e.push("form_loop_then_abandon");break}}return e}function As(e,t){Me.has(e)||Me.set(e,[]);let n=Me.get(e);n.push(t),n.length>du&&n.shift()}function vu(e){let t=e-$r,n=0;for(;n<q.length&&q[n].ts<t;)n++;n>0&&(q=q.slice(n))}function wu(){let e=new Map,t=0;for(let n of q)e.set(n.type,(e.get(n.type)??0)+1),t+=fu[n.type]??pu;return{distinctTypes:new Set(e.keys()),totalWeight:t,typeCounts:e}}function Ds(e){let t="",n=0;for(let[r,o]of e)(o>n||o===n&&r<t)&&(t=r,n=o);return{type:t,count:n}}function Eu(e,t,n){return Ds(n).count>=3&&e>=3?"critical":e>=4&&t>=70?"high":e>=3&&t>=40?"medium":e>=2&&t>=20?"low":null}function bu(e,t,n,r){let o=Ds(r),i=hu();u({t:"sig",ts:Date.now(),d:{s:"frustration_burst",level:e,page:Yr||void 0,distinct_types:t.size,total_weight:n,signals:Array.from(t).sort(),window_ms:$r,dominant:o.type,repeat_count:o.count,sequences:i,session_total_signals:Ce.totalSignals,session_pages_with_frustration:Ce.pagesWithFrustration}}),Ce.totalSignals+=q.length,Ce.pagesWithFrustration+=1,gu()}function yu(e){if(!nn||e==="frustration_burst")return;let t=Date.now();vu(t),q.length===0&&(Le=null),q.push({type:e,ts:t}),As(e,t);let{distinctTypes:n,totalWeight:r,typeCounts:o}=wu(),i=Eu(n.size,r,o);i&&(Le!==null&&ks[i]<=ks[Le]||(Le=i,bu(i,n,r,o)))}function jr(e){Yr=e}function Kr(e){q=[],Le=null,nn=!0,Me=new Map,Yr=e??"",mu(),Ln(yu),rt=()=>tn("popstate"),ot=()=>tn("hashchange"),it=()=>{document.visibilityState==="hidden"&&tn("visibilitychange")},st=()=>tn("pagehide"),window.addEventListener("popstate",rt),window.addEventListener("hashchange",ot),document.addEventListener("visibilitychange",it),window.addEventListener("pagehide",st)}function Gr(){nn=!1,q=[],Le=null,Me=new Map,Ln(null),rt&&(window.removeEventListener("popstate",rt),rt=null),ot&&(window.removeEventListener("hashchange",ot),ot=null),it&&(document.removeEventListener("visibilitychange",it),it=null),st&&(window.removeEventListener("pagehide",st),st=null)}var _u=8,Zr=3e4,Qr=5,Su=5e3,N=[],J="",at=!1,Rs=f(Lu),Is=f(Cu);function Jr(){N=[],at=!1,J=location.pathname+location.search+location.hash,window.addEventListener("popstate",Rs),window.addEventListener("hashchange",Is)}function eo(){window.removeEventListener("popstate",Rs),window.removeEventListener("hashchange",Is),N=[],at=!1,J=""}function to(){N=[],at=!1,J=location.pathname+location.search+location.hash}function lt(e){let t=Date.now();if(J&&J!==e){let n=N[N.length-1];n&&n.path===J&&n.leftAt===null&&(n.leftAt=t)}for(;N.length&&t-N[0].ts>Zr;)N.shift();e!==J&&(N.push({path:e,ts:t,leftAt:null}),J=e),!(N.length<Qr)&&(at||Tu(t))}function Tu(e){let t=N.filter(l=>e-l.ts<=Zr),n=t.filter(l=>l.leftAt!==null),r=new Set(t.map(l=>l.path));if(r.size<Qr||n.length===0||n.some(l=>l.leftAt-l.ts>=Su)||new Set(n.map(l=>l.path)).size<Qr)return;let s=n.map(l=>l.leftAt-l.ts),a=Math.round(s.reduce((l,g)=>l+g,0)/s.length),c=Math.max(...s),d=t.map(l=>l.path).slice(-_u);at=!0,u({t:"sig",ts:e,d:{s:"navigation_confusion",page_count:r.size,window_ms:Zr,avg_dwell_ms:a,pages:d,max_dwell_ms:c}})}function Lu(){let e=location.pathname+location.search+location.hash;lt(e)}function Cu(){let e=location.pathname+location.search+location.hash;lt(e)}var Mu=.3,Os=3e3,K=[],ct=!1,ae="none",le=0,ut=0,dt=0,P=!1,Ns=f(ku),Ps=f(Au);function no(){K=[],ae="none",le=0,ut=0,dt=0,P=!1,ct=!1,window.addEventListener("scroll",Ns,{passive:!0}),window.addEventListener("click",Ps,{capture:!0})}function ro(){window.removeEventListener("scroll",Ns),window.removeEventListener("click",Ps,{capture:!0}),rn()}function rn(){K=[],ae="none",le=0,ut=0,dt=0,P=!1,ct=!1}function ku(){ct||(ct=!0,requestAnimationFrame(xu))}function xu(){ct=!1;let e=Date.now(),t=window.scrollY,n=window.innerHeight,r=K[K.length-1];if(r&&e-r.ts<50||(K.push({y:t,ts:e}),K.length>60&&(K=K.slice(-40)),!r))return;let o=t-r.y;if(Math.abs(o)<2)return;if((o>0?"down":"up")==="down"){ae!=="down"&&P&&(P=!1),t>le&&(le=t),ae="down";return}if(P&&e-dt>Os&&(P=!1),ae==="down"){let s=le-t,a=n*Mu;s>=a&&!P&&(ut=t,dt=e,P=!0)}ae="up"}function Au(e){if(!P)return;let t=Date.now();if(t-dt>Os){P=!1;return}if(window.scrollY+e.clientY>ut+window.innerHeight*.1)return;let r=window.innerHeight,o=Math.round(le-ut),i=Math.round(o/r*100),s=e.target instanceof Element?e.target:null,a=s?p(s):"",c=s?h(s):"";P=!1,le=window.scrollY,ae="none",K=[],u({t:"sig",ts:t,d:{s:"scroll_to_click_confusion",reversal_depth_px:o,click_el:a,...c?{click_el_label:c}:{},scroll_back_pct:i}})}var Du=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,Ru=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Iu=/^(A|BUTTON|LABEL)$/,Ou=3,Hs=9e4,Nu=5,ft=new Map,Fs=[],pt=null,Pu=5,Bs=f(Hu),Ws=f(qu);function Hu(e){pt={x:e.clientX,y:e.clientY}}function oo(e){Fs=e??[],document.addEventListener("mousedown",Bs,{capture:!0,passive:!0}),document.addEventListener("click",Ws,{capture:!0,passive:!0})}function io(){document.removeEventListener("mousedown",Bs,{capture:!0}),document.removeEventListener("click",Ws,{capture:!0}),pt=null,ft.clear()}function so(){ft.clear()}function Fu(e,t){let n=Math.min(3,Math.floor(e/window.innerWidth*4));return{row:Math.min(3,Math.floor(t/window.innerHeight*4)),col:n}}function Bu(e,t){return e*4+t}function Wu(e){if(Du.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&Ru.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&Iu.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Vu(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Uu(e){if(!pt)return!1;let t=e.clientX-pt.x,n=e.clientY-pt.y;return Math.sqrt(t*t+n*n)>Pu}function qu(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Fs)||Vu()||Uu(e)||Wu(t))return;let{row:n,col:r}=Fu(e.clientX,e.clientY),o=Bu(n,r),i=Date.now(),s=p(t),c=(ft.get(o)??[]).filter(d=>i-d.ts<Hs);if(c.push({ts:i,selector:s}),ft.set(o,c),c.length>=Ou){let d=new Map;for(let m of c)d.set(m.selector,(d.get(m.selector)??0)+1);let l="",g=0;for(let[m,$]of d)$>g&&(g=$,l=m);let w=new Set,E=[];for(let m of c)if(!w.has(m.selector)&&(w.add(m.selector),E.push(m.selector),E.length>=Nu))break;let b=(()=>{try{let m=l?document.querySelector(l):null;return m?h(m):""}catch{return""}})();u({t:"sig",ts:i,d:{s:"dead_click_trap_zone",zone_row:n,zone_col:r,cnt:c.length,dominant_el:l,...b?{dominant_el_label:b}:{},elements:E,window_ms:Hs}}),ft.set(o,[])}}var ao=3,ke=12e4,_=new Map,sn=[],mt=null,Vs=f(ju),on=f(Ku);function co(e){sn=e??[],document.addEventListener("invalid",Vs,{capture:!0,passive:!0}),document.addEventListener("input",on,{capture:!0,passive:!0}),document.addEventListener("change",on,{capture:!0,passive:!0}),mt=new MutationObserver(Gu),mt.observe(document.body,{subtree:!0,attributeFilter:["aria-invalid"],attributes:!0,attributeOldValue:!0})}function uo(){document.removeEventListener("invalid",Vs,{capture:!0}),document.removeEventListener("input",on,{capture:!0}),document.removeEventListener("change",on,{capture:!0}),mt&&(mt.disconnect(),mt=null);for(let e of _.values())ee(e);_.clear()}function fo(){for(let e of _.values())ee(e);_.clear()}function lo(e){let t=e.tagName.toLowerCase();return t==="select"?"select":t==="textarea"?"textarea":t==="input"?e.type||"text":t}function po(e){let t=e.getAttribute("aria-invalid");if(t==="true"||t==="")return!0;if("validity"in e){let n=e;if(n.validity&&!n.validity.valid)return!0}try{return e.matches(":invalid")}catch{return!1}}function an(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function zu(e){for(let[t,n]of _)e-n.lastTs>ke&&(ee(n),_.delete(t))}function ee(e){e.el.removeEventListener("input",e.inputHandler),e.el.removeEventListener("change",e.changeHandler)}function Xu(e){return f(t=>{zs(e)})}function $u(e){return f(t=>{zs(e)})}function Us(e,t){let n=Xu(t),r=$u(t);e.addEventListener("input",n,{passive:!0}),e.addEventListener("change",r,{passive:!0});let o={cycles:0,lastTs:Date.now(),phase:"invalid",inputHandler:n,changeHandler:r,el:e};return _.set(t,o),o}function qs(e){if(!an(e)||v(e,sn))return;let t=Date.now();zu(t);let n=p(e),r=_.get(n);if(!r){Us(e,n);return}let o=r.lastTs;r.lastTs=t,r.phase==="edited"?(r.cycles+=1,r.phase="invalid",r.cycles>=ao&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:ke,field_type:lo(e)}}),ee(r),_.delete(n))):r.phase==="invalid"&&t-o>500&&(r.cycles+=1,r.cycles>=ao&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:ke,field_type:lo(e)}}),ee(r),_.delete(n)))}function Yu(e){if(!an(e))return;let t=Date.now(),n=p(e),r=_.get(n);if(r){if(t-r.lastTs>ke){ee(r),_.delete(n);return}r.phase==="invalid"&&(r.phase="edited",r.lastTs=t)}}function zs(e){let t=Date.now(),n=_.get(e);if(n){if(t-n.lastTs>ke){ee(n),_.delete(e);return}if(n.lastTs=t,po(n.el)){n.cycles+=1,n.cycles>=ao&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:e,...h(n.el)?{el_label:h(n.el)}:{},cycles:n.cycles,window_ms:ke,field_type:lo(n.el)}}),ee(n),_.delete(e));return}n.phase==="invalid"&&(n.phase="edited")}}function ju(e){let t=e.target;t&&qs(t)}function Ku(e){let t=e.target;if(!t||!an(t)||v(t,sn))return;let n=p(t);_.has(n)||po(t)&&Us(t,n)}function Gu(e){for(let t of e){if(t.type!=="attributes"||t.attributeName!=="aria-invalid")continue;let n=t.target;if(!an(n)||v(n,sn))continue;let r=t.oldValue,o=r==="true"||r==="",i=po(n);i&&!o?qs(n):!i&&o&&Yu(n)}}var xe=null,gt=null,go=[],Xs=0,ht=new Map;function ho(e){go=e?.length?e:["[data-fd-impression]"],Xs=Date.now(),!(typeof IntersectionObserver>"u")&&(xe=new IntersectionObserver(y(Qu),{threshold:[0,.5,1]}),$s(),gt=new MutationObserver(y(Zu)),gt.observe(document.body,{childList:!0,subtree:!0}))}function vo(){xe&&(xe.disconnect(),xe=null),gt&&(gt.disconnect(),gt=null),ht.clear()}function wo(){ht.clear(),xe&&$s()}function $s(){for(let e of go)try{let t=document.querySelectorAll(e);for(let n=0;n<t.length;n++)mo(t[n])}catch{}}function mo(e){ht.has(e)||(ht.set(e,{firstSeenTs:0,emitted:!1}),xe.observe(e))}function Zu(e){for(let t of e)for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];if(r instanceof Element)for(let o of go)try{r.matches(o)&&mo(r);let i=r.querySelectorAll(o);for(let s=0;s<i.length;s++)mo(i[s])}catch{}}}function Qu(e){let t=Date.now();for(let n of e){let r=ht.get(n.target);if(!(!r||r.emitted)&&n.isIntersecting&&n.intersectionRatio>=.5){r.firstSeenTs||(r.firstSeenTs=t),r.emitted=!0;let o=n.boundingClientRect,i=n.rootBounds?.height??window.innerHeight,s=o.top<i*.5?"above_fold":"below_fold",a=p(n.target),c=h(n.target);u({t:"sig",ts:t,d:{s:"element_impression",el:a,...c?{el_label:c}:{},visible_pct:Math.round(n.intersectionRatio*100),time_to_visible_ms:Math.round(t-Xs),viewport_position:s}})}}}var Ju=2,ed=3,td=6e4,vt=new Map,Ys=[],js=f(nd);function Eo(e){Ys=e??[],document.addEventListener("input",js,{capture:!0,passive:!0})}function bo(){document.removeEventListener("input",js,{capture:!0}),vt.clear()}function yo(){vt.clear()}function nd(e){let t=e.target;if(!t||!rd(t)||v(t,Ys))return;let n=Date.now(),r=t.value??"",o=p(t),i=vt.get(o);if(!i){vt.set(o,{lastValue:r,cycles:0,phase:"typing",lastTs:n});return}if(n-i.lastTs>td){i.lastValue=r,i.cycles=0,i.phase="typing",i.lastTs=n;return}i.lastTs=n;let s=i.lastValue.length-r.length;if(i.phase==="typing"&&s>=ed)i.phase="deleted";else if(i.phase==="deleted"&&r.length>i.lastValue.length&&(i.cycles++,i.phase="typing",i.cycles>=Ju)){let a=h(t);u({t:"sig",ts:n,d:{s:"input_correction",el:o,...a?{el_label:a}:{},cycles:i.cycles,field_type:od(t)}}),vt.delete(o);return}i.lastValue=r}function rd(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function od(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var Ks=2e3,id=3e4,z=null,Gs=Ks,Zs=[],ln=new Map,Qs=f(sd),Js=f(ad),ea=f(wt);function _o(e,t){Gs=e?.dwellMs??Ks,Zs=t??[],document.addEventListener("mouseover",Qs,{passive:!0}),document.addEventListener("mouseout",Js,{passive:!0}),document.addEventListener("click",ea,{capture:!0,passive:!0})}function So(){document.removeEventListener("mouseover",Qs),document.removeEventListener("mouseout",Js),document.removeEventListener("click",ea,{capture:!0}),wt(),ln.clear()}function To(){wt(),ln.clear()}function sd(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Zs)||!ld(t))return;let n=p(t);if(z?.selector===n)return;wt();let r=Date.now();if(r-(ln.get(n)??0)<id)return;let o=r,i=setTimeout(()=>{let s=Date.now(),a=h(t);ln.set(n,s),z=null,u({t:"sig",ts:s,d:{s:"hover_dwell",el:n,...a?{el_label:a}:{},dwell_ms:Math.round(s-o)}})},Gs);z={el:t,selector:n,startTs:o,timer:i}}function ad(e){if(!z)return;let t=e.target;if(t!==z.el&&!z.el.contains(t))return;let n=e.relatedTarget;n&&z.el.contains(n)||wt()}function wt(){z&&(clearTimeout(z.timer),z=null)}function ld(e){let t=e.tagName;if(/^(A|BUTTON|SELECT)$/.test(t))return!0;let n=e.getAttribute("role")??"";if(/^(button|link|tab|menuitem|option|checkbox|radio)$/.test(n))return!0;try{let r=window.getComputedStyle(e);return r.cursor==="pointer"&&r.pointerEvents!=="none"}catch{return!1}}var cd=20,ud=500,dd=3e3,fd=6e4,cn=0,un=0,X=null,ta=y(pd);function Lo(){cn=Date.now(),un=0,document.addEventListener("mouseleave",ta)}function Co(){document.removeEventListener("mouseleave",ta),X&&(clearTimeout(X),X=null)}function Mo(){cn=Date.now(),un=0,X&&(clearTimeout(X),X=null)}function pd(e){if(e.clientY>cd)return;let t=Date.now();t-cn<dd||t-un<fd||(X&&clearTimeout(X),X=setTimeout(y(()=>{let n=Date.now();un=n,X=null,u({t:"sig",ts:n,d:{s:"exit_intent",method:"top_chrome",time_on_page_ms:Math.round(n-cn)}})}),ud))}var md=2500,gd=4e3,na=200,hd=500,vd=.1,wd=.25,De=null,Re=null,G=null,Ae=0;function ko(e,t,n){return e<=t?"good":e<=n?"needs_improvement":"poor"}function xo(){if(!(typeof PerformanceObserver>"u")){try{De=new PerformanceObserver(y(e=>{let t=e.getEntries(),n=t[t.length-1];if(!n)return;let r=Math.round(n.startTime);u({t:"sig",ts:Date.now(),d:{s:"lcp",value_ms:r,rating:ko(r,md,gd)}})})),De.observe({type:"largest-contentful-paint",buffered:!0})}catch{De=null}try{Re=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;if(!n.interactionId)continue;let r=Math.round(n.duration);r<na||u({t:"sig",ts:Date.now(),d:{s:"slow_interaction",value_ms:r,rating:ko(r,na,hd)}})}})),Re.observe({type:"event",buffered:!1,durationThreshold:200})}catch{Re=null}try{G=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Ae+=n.value)}})),G.observe({type:"layout-shift",buffered:!0})}catch{G=null}}}function ra(){if(G){if(G.disconnect(),G=null,Ae>0){let e=Math.round(Ae*1e3)/1e3;u({t:"sig",ts:Date.now(),d:{s:"cls",value:e,rating:ko(Ae,vd,wd)}})}Ae=0}}function Ao(){De&&(De.disconnect(),De=null),Re&&(Re.disconnect(),Re=null),ra()}function Do(){if(ra(),!(typeof PerformanceObserver>"u"))try{G=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Ae+=n.value)}})),G.observe({type:"layout-shift",buffered:!1})}catch{G=null}}var oa=[],ia=f(Ed);function Ro(e){oa=e??[],document.addEventListener("paste",ia,{capture:!0,passive:!0})}function Io(){document.removeEventListener("paste",ia,{capture:!0})}function Ed(e){let t=e.target;if(!t||!bd(t)||v(t,oa))return;let n=t.value??"";setTimeout(()=>{if((t.value??"")!==n)return;let o=p(t),i=h(t);u({t:"sig",ts:Date.now(),d:{s:"paste_blocked",el:o,...i?{el_label:i}:{},field_type:yd(t)}})},100)}function bd(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function yd(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var _d="https://api.flusterduck.com/v1/ingest",te=!1,dn=null,Ie=null,Et="__flusterduck_instance__",Oo=`fd_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;function Sd(){let e=window;return e[Et]&&e[Et]!==Oo?(console.warn("[flusterduck] Another SDK instance is already active on this page. Skipping init to avoid double tracking. Load the SDK either via npm or via the script tag, not both."),!1):(e[Et]=Oo,!0)}function Td(){let e=window;e[Et]===Oo&&delete e[Et]}var bt=[];function Ld(e,t,n){let r=i=>e.signals?.[i]?.enabled!==!1,o=e.trackForms!==!1;return[{when:()=>r("rageClick"),start:()=>xn(e.signals?.rageClick,t),stop:An},{when:()=>r("deadClick"),start:()=>Dn(t),stop:Rn,reset:In},{when:()=>r("speedFrustration"),start:()=>{let i=e.signals?.speedFrustration;Nn(i?{delayMs:i.windowMs}:void 0,t)},stop:Pn,reset:Hn},{when:()=>e.trackMouse!==!1&&r("thrashCursor"),start:()=>{let i=e.signals?.thrashCursor;Vn(i?{velocityThreshold:i.threshold,windowMs:i.windowMs}:void 0)},stop:Un},{when:()=>r("loopNav"),start:()=>Xn(e.signals?.loopNav),stop:$n},{when:()=>r("scrollBounce"),start:Zn,stop:Qn,reset:Jn},{when:()=>o&&(r("formHesitation")||r("formAbandon")),start:()=>{let i=e.signals?.formHesitation;tr(i?{pauseMs:i.threshold}:void 0,t)},stop:nr,reset:rr},{when:()=>o&&r("formValidationLoop"),start:()=>co(t),stop:uo,reset:fo},{when:()=>r("errorEncounter"),start:ir,stop:sr},{when:()=>"ontouchstart"in window||navigator.maxTouchPoints>0,start:()=>ur(t),stop:dr},{when:()=>r("tabThrash")||r("focusTrap")||r("keyboardNavFrustration"),start:()=>pr(t),stop:mr},{when:()=>r("scrollHijack"),start:vr,stop:wr,reset:$t},{when:()=>r("scrollDepthAbandon"),start:Er,stop:br,reset:yr},{when:()=>r("advancedHeuristics"),start:Tr,stop:Lr,reset:()=>{et(),Cr()}},{when:()=>r("helpHunt"),start:()=>Mr(t),stop:kr,reset:xr},{when:()=>r("closeClick"),start:()=>Ar(t),stop:Dr,reset:Rr},{when:()=>r("closeClickReversal"),start:()=>Ir(t),stop:Or,reset:Nr},{when:()=>r("filterSpiral"),start:()=>Hr(t),stop:Fr,reset:Br},{when:()=>r("copyFrustration"),start:Wr,stop:Vr,reset:Ur},{when:()=>r("textSelectFrustration"),start:qr,stop:zr,reset:Xr},{when:()=>r("deadClickTrapZone"),start:()=>oo(t),stop:io,reset:so},{when:()=>!0,start:()=>Kr(n),stop:Gr},{when:()=>r("navigationConfusion"),start:Jr,stop:eo,reset:to},{when:()=>r("scrollToClickConfusion"),start:no,stop:ro,reset:rn},{when:()=>r("elementImpression"),start:()=>ho(e.elementImpressionSelectors),stop:vo,reset:wo},{when:()=>o&&r("inputCorrection"),start:()=>Eo(t),stop:bo,reset:yo},{when:()=>o&&r("pasteBlocked"),start:()=>Ro(t),stop:Io},{when:()=>r("hoverDwell"),start:()=>{let i=e.signals?.hoverDwell;_o(i?.threshold?{dwellMs:i.threshold}:void 0,t)},stop:So,reset:To},{when:()=>r("exitIntent"),start:Lo,stop:Co,reset:Mo},{when:()=>r("performanceVitals"),start:xo,stop:Ao,reset:Do}]}function Cd(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function aa(e){if(te||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&Rd()){Ie=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){Ie=e;return}if(!Sd()){Ie=e;return}Ie=e,te=!0;let t=zo(e.cookieless??!1),n=Cd(e.endpoint)??_d,r=kn(location.pathname,e.pageRules??[]),o=Id(e.domMode);oi(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:r,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:o,compression:e.compression});let i=sa(location.pathname,e.ignorePages??[]);i&&Cn(!0);let s=document.referrer,a="";if(s)try{a=new URL(s).origin+new URL(s).pathname}catch{a=""}i||u({t:"pv",ts:Date.now(),d:{ref:a}});let c=e.ignoreElements??[];bt=[];for(let d of Ld(e,c,r))d.when()&&(d.start(),bt.push({stop:d.stop,reset:d.reset}));dn=ai(y((d,l)=>{ne();for(let E of bt)E.reset?.();lt(l),jr(l);let g=kn(l,e.pageRules??[]),w=sa(l,e.ignorePages??[]);Cn(w),Mn({page:g,url:d}),Yn(l),w||u({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:r})}function Md(e,t){if(!te||typeof e!="string"||!e||e.length>128)return;let n;try{let o=t?.metadata??{};n=JSON.stringify(o)}catch{return}if(n.length>2048)return;let r=JSON.parse(n);u({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:r,w:Math.max(0,Math.min(t?.weight??15,100))}})}function kd(e,t={}){if(!te||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||u({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function xd(e){if(!te||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let r of Object.keys(e)){if(n>=20)break;r==="__proto__"||r==="constructor"||r==="prototype"||(t[r.slice(0,64)]=String(e[r]).slice(0,256),n++)}Mn({segment:t})}function Ad(e){e&&Ie&&!te?aa(Ie):e||(No(),bn())}function Dd(){No(),bn()}function No(){if(te){for(let e of bt)e.stop();bt=[],ii(),dn&&(dn(),dn=null),Td(),te=!1}}function Rd(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Id(e){return e==="metadata"||e==="snapshot"?e:"off"}function sa(e,t){for(let n of t)if(n){if(n.endsWith("*")){if(e.startsWith(n.slice(0,-1)))return!0}else if(n.startsWith("*")){if(e.endsWith(n.slice(1)))return!0}else if(e===n)return!0}return!1}var da=.1,fa=.01,pa=3e4,ma=50,ga=1e4,Od=500,Nd=3e4,Pd=6e4,la=10,Hd=new Set(["$rageclick","$dead_click","$exception","$identify","$create_alias","$groupidentify","$survey_sent","$survey_dismissed","$feature_flag_called"]),Fd=/(sign(ed)?[\s_-]?up|check(ed)?[\s_-]?out|purchase|subscri|payment|paid|upgrade|convert|trial|onboard.*complete|order[\s_-]?(placed|completed))/i,Bd=/^\$\$?(heatmap|scroll)/,ha=["rage_click","rage_click_repeat_target","dead_click","error_encounter","form_validation_loop","thrash_cursor"],gn=!1,fn=null,pn=null,yt=null,H=null,mn=null,va=da,wa=fa,Ea=new Set,ba=new Set(ha),ya=pa,Fo=ma,_a=ga,R=[],hn=0,F=[];function ca(e,t){return e===void 0||Number.isNaN(e)?t:Math.max(0,Math.min(e,1))}function Wd(e){gn||(gn=!0,va=ca(e?.baselineSampleRate,da),wa=ca(e?.scrollSampleRate,fa),Ea=new Set(e?.conversionEvents??[]),ba=new Set(e?.criticalSignals?.length?e.criticalSignals:ha),ya=e?.bufferWindowMs&&e.bufferWindowMs>0?e.bufferWindowMs:pa,Fo=e?.bufferMaxEvents&&e.bufferMaxEvents>0?e.bufferMaxEvents:ma,_a=e?.boostWindowMs&&e.boostWindowMs>0?e.boostWindowMs:ga,R=[],hn=0,F=[],pn=ti(jd),ua()||(fn=setInterval(()=>{ua()&&Bo()},Od),setTimeout(()=>Bo(),Nd)))}function Vd(){gn&&(gn=!1,Bo(),pn&&(pn(),pn=null),yt&&mn&&yt.capture.__fd_wrapped&&(yt.capture=mn),yt=null,H=null,mn=null,R=[],F=[],hn=0)}function Bo(){fn&&(clearInterval(fn),fn=null)}function ua(){try{let e=window.posthog;if(!e||typeof e.capture!="function"||e.__loaded!==!0)return!1;if(e.capture.__fd_wrapped)return!0;mn=e.capture,H=e.capture.bind(e);let n=(r,o,i)=>{try{return qd(r,o,i)}catch{return H?H(r,o,i):void 0}};return n.__fd_wrapped=!0,e.capture=n,yt=e,!0}catch{return!1}}function Ud(e){return Hd.has(e)?"critical":Ea.has(e)||Fd.test(e)?"conversion":Bd.test(e)?"scroll":"baseline"}function qd(e,t,n){if(!H)return;if(typeof e!="string"||!e)return H(e,t,n);let r=Date.now(),o=Ud(e);if(o==="critical"||o==="conversion")return H(e,Ho(t,r),n);if(r<hn)return H(e,{...Ho(t,r),fd_boosted:!0},n);if(zd(o==="scroll"?wa:va))return H(e,Ho(t,r),n);Yd({name:e,properties:t,ts:r})}function zd(e){if(e>=1)return!0;if(e<=0)return!1;let t=Xd();return t?$d(t)%1e4/1e4<e:Math.random()<e}var Po="";function Xd(){try{let e=window.posthog;if(e?.get_distinct_id){let t=e.get_distinct_id();if(typeof t=="string"&&t)return t}}catch{}return Po||(Po=Math.random().toString(36).slice(2)),Po}function $d(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Ho(e,t){return Ta(t),F.length?{...e,fd_recent_signals:F.map(n=>n.name),fd_signal_count:F.length}:e??{}}function Yd(e){R.push(e),Sa(e.ts)}function Sa(e){let t=e-ya;for(;R.length&&R[0].ts<t;)R.shift();R.length>Fo&&(R=R.slice(-Fo))}function Ta(e){let t=e-Pd;F=F.filter(n=>n.ts>=t),F.length>la&&(F=F.slice(-la))}function jd(e,t){if(F.push({name:e,ts:t}),Ta(t),!ba.has(e)||(hn=t+_a,!H||!R.length))return;Sa(t);let n=R;R=[];for(let r of n)try{H(r.name,{...r.properties,fd_recovered:!0,fd_recovered_reason:e,fd_original_ts:r.ts},{timestamp:new Date(r.ts)})}catch{}}export{No as destroy,Vd as destroyPostHogTrigger,xd as identify,aa as init,Wd as initPostHogTrigger,Dd as optOut,Ad as setConsent,Md as signal,kd as track};
1
+ function y(e){return((...t)=>{try{return e(...t)}catch{}})}function f(e){return t=>{try{e(t)}catch{}}}var Sn="_fd_s";var Ma=/^[0-9a-f]{32}$/;function Zo(e){if(e)return Go();let t=xa(Sn);if(t&&Ma.test(t))return t;let n=Go();return Qo(Sn,n,30),n}function _n(){Qo(Sn,"",-1)}function Go(){let e=new Uint8Array(16);crypto.getRandomValues(e);let t="";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}function xa(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null}function Qo(e,t,n){let r=new Date;r.setTime(r.getTime()+n*864e5);let o=location.protocol==="https:"?";Secure":"";document.cookie=`${e}=${encodeURIComponent(t)};path=/;expires=${r.toUTCString()};SameSite=Lax${o}`}var Aa=/^[:\d]|--|^(ember|react|ng-|__)/;function p(e){if(!e||e===document.documentElement)return"html";let t=e.getAttribute("data-fd");if(t)return`[data-fd="${He(t)}"]`;if(e.id&&!Aa.test(e.id)&&e.id.length<64)return"#"+He(e.id);let n=[],r=e,o=0;for(;r&&r!==document.body&&o<5;){let i=r.tagName.toLowerCase(),s=r.getAttribute("name"),a=r.getAttribute("role"),c=r.getAttribute("type");s&&s.length<64?i+=`[name="${He(s)}"]`:a?i+=`[role="${He(a)}"]`:c&&(i==="input"||i==="button")&&(i+=`[type="${He(c)}"]`);let d=r.parentElement;if(d){let g=d.children,w=0,E=0;for(let b=0;b<g.length;b++){let m=g[b];m&&m.tagName===r.tagName&&(w++,m===r&&(E=w))}w>1&&(i+=`:nth-of-type(${E})`)}n.unshift(i);let l=n.join(" > ");try{if(document.querySelectorAll(l).length===1)return l}catch{}r=d,o++}return n.join(" > ")}function He(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):e.replace(/([^\w-])/g,"\\$1")}var Fe=60,Da=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,Ra=/^(INPUT|TEXTAREA|SELECT)$/;function h(e){try{let t=e.getAttribute("aria-label");if(t)return t.trim().slice(0,Fe);if(!Ra.test(e.tagName)){let i=(e.textContent??"").trim().replace(/\s+/g," ").slice(0,Fe);if(i&&!Da.test(i))return i}let n=e.getAttribute("placeholder");if(n)return n.trim().slice(0,Fe);let r=e.getAttribute("title");if(r)return r.trim().slice(0,Fe);let o=e.getAttribute("alt");return o?o.trim().slice(0,Fe):""}catch{return""}}function v(e,t){if(e.hasAttribute("data-fd-ignore")||e.closest("[data-fd-ignore]"))return!0;for(let n of t)try{if(e.matches(n)||e.closest(n))return!0}catch{}return!1}function ei(e,t){if(t==="off")return null;if(t==="metadata")return Ia(e);let n=Oa(e);return n?{mode:"snapshot",...n}:null}function Ia(e){return{mode:"metadata",selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),attributes:{disabled:e.disabled===!0,required:e.required===!0,ariaDisabled:e.getAttribute("aria-disabled")==="true",ariaExpanded:Jo(e.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:Jo(e.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:Na(e)}}}function Oa(e){try{let t=e.getBoundingClientRect(),n=getComputedStyle(e),r=e.parentElement,o=[];if(r)for(let s=0;s<r.children.length&&o.length<6;s++){let a=r.children[s];if(!a||a===e)continue;let c=a.getBoundingClientRect();o.push({selector:p(a),tag:a.tagName.toLowerCase(),box:{x:Math.round(c.x),y:Math.round(c.y),w:Math.round(c.width),h:Math.round(c.height)},interactive:Ha(a)})}let i=[];try{let s=e.getAnimations();for(let a of s)"animationName"in a&&i.push(a.animationName)}catch{}return{selector:p(e),tag:e.tagName.toLowerCase(),role:e.getAttribute("role"),parent:r?p(r):"",box:{x:Math.round(t.x),y:Math.round(t.y),w:Math.round(t.width),h:Math.round(t.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:e.disabled===!0},inView:Pa(t),animations:i,siblings:o}}catch{return null}}function Jo(e,t){return e&&t.includes(e)?e:null}function Na(e){let t=e.tagName.toLowerCase();if(t!=="input"&&t!=="button")return null;let n=e.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function Pa(e){return e.top<window.innerHeight&&e.bottom>0&&e.left<window.innerWidth&&e.right>0}function Ha(e){let t=e.tagName;if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t))return!0;let n=e.getAttribute("role");return!!(n&&/^(button|link|tab|menuitem|checkbox|radio)$/.test(n))}var ri=7e3,Fa=500,Ba=1e4,oi=50,Be=100,Wa=3,We=6e4,xt="application/json",Ua="application/json; encoding=gzip",j=[],B=null,ii="",xn=ri,si=oi,_=null,At={domMode:"off",compression:"auto"},Tn=!1,Ln=null,An=!1,ti=new WeakMap;function Dn(e){Ln=e}var Dt=new Set;function fe(e){return Dt.add(e),()=>{Dt.delete(e)}}function Va(e){if(e.t!=="sig"||!Dt.size)return;let t=e.d??{},n=typeof t.s=="string"?t.s:"";if(!n)return;let r={name:n,element:typeof t.el=="string"?t.el:"",weight:typeof t.w=="number"?t.w:0,meta:t.meta&&typeof t.meta=="object"?t.meta:{},ts:e.ts};for(let o of Dt)try{o(r)}catch{}}function qa(e){if(!Ln||e.t!=="sig")return;let t=Mn(e.d?.s,e.d?.signal_type,e.d?.name);if(t)try{Ln(t.slice(0,128),e.ts)}catch{}}function Rn(e){An=e}var za=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),$a=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),Xa=new Set(["value","text","label","email","name","phone","address","password","token","secret","cookie","session","jwt","auth","credential","card","cc","cvv","ssn"]);function Ya(e){return e.replace(/([a-z])([A-Z])/g,"$1\0$2").toLowerCase().split(/[\x00_\-.\s]+/).some(n=>Xa.has(n))}var ja=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,Cn=f(Ga),kn=y(()=>J());function ai(e,t,n,r,o){ii=e,_=Object.assign(Object.create(null),t),At={domMode:sl(o?.domMode),compression:al(o?.compression)},xn=Math.max(Fa,Math.min(n??ri,Ba)),si=Math.max(1,Math.min(r??oi,Be)),document.removeEventListener("visibilitychange",Cn),window.removeEventListener("pagehide",kn),document.addEventListener("visibilitychange",Cn),window.addEventListener("pagehide",kn)}function u(e){An||j.length>=Be||(Va(e),qa(e),j.push(e),j.length>=si?J():B||(B=setTimeout(J,xn)))}function J(){Ka()}async function Ka(){if(Tn||!j.length||!_)return;Tn=!0,B&&(clearTimeout(B),B=null);let e=j;j=[];let t={v:1,sid:_.sid,key:_.key,url:_.url,page:_.page,ts:Date.now(),ua:_.ua,vw:_.vw,vh:_.vh,environment:_.environment,..._.segment?{segment:_.segment}:{},dom_mode:At.domMode},n=[],r={source:[],events:[]};try{for(let o of e){let i=nl(o,_.page,At.domMode),s=[...r.events,i];JSON.stringify({...t,events:s}).length>We?r.events.length>0?(n.push(r),r={source:[o],events:[i]}):(JSON.stringify({...t,events:[i]}).length<=We?n.push({source:[o],events:[i]}):console.warn("[flusterduck] event dropped: serialized size exceeds limit. Reduce metadata payload size."),r={source:[],events:[]}):(r.source.push(o),r.events=s)}r.events.length>0&&n.push(r);for(let o of n)Za({...t,events:o.events}).then(i=>{i||ni(o.source)}).catch(()=>ni(o.source))}catch(o){console.error("[flusterduck] batch serialization failed, events dropped:",o instanceof Error?o.message:"unknown error")}finally{Tn=!1}}function ni(e){let t=e.filter(r=>{let o=ti.get(r)??0;return o>=Wa?!1:(ti.set(r,o+1),!0)});if(!t.length)return;let n=[...t,...j];n.length>Be?(console.warn(`[flusterduck] event queue overflow, dropped ${n.length-Be} oldest events`),j=n.slice(-Be)):j=n,B||(B=setTimeout(J,xn))}function In(e){if(_)for(let t of Object.keys(e))za.has(t)&&(_[t]=e[t])}function li(){J(),An=!1,document.removeEventListener("visibilitychange",Cn),window.removeEventListener("pagehide",kn),B&&(clearTimeout(B),B=null)}function Ga(){document.visibilityState==="hidden"&&J()}async function Za(e){let t=JSON.stringify(e),n=await Qa(t,At.compression);return n?tl(n):!0}async function Qa(e,t){let n=new TextEncoder().encode(e);if(n.byteLength>We)return null;if(t!=="off"){let o=await Ja(e);if(o&&o.byteLength<=We)return{beaconBody:new Blob([o],{type:Ua}),fetchBody:new Uint8Array(o),headers:{"Content-Type":xt,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:xt}),fetchBody:e,headers:{"Content-Type":xt}}}async function Ja(e){let t=globalThis.CompressionStream;if(typeof t!="function")return null;try{let n=el(e);if(!n)return null;let r=new t("gzip"),i=n.pipeThrough(r).getReader(),s=[],a=0;for(;;){let l=await i.read();if(l.done)break;if(a+=l.value.byteLength,a>We)return null;let g=new Uint8Array(l.value.byteLength);g.set(l.value),s.push(g)}let c=new Uint8Array(a),d=0;for(let l of s)c.set(l,d),d+=l.byteLength;return c.buffer}catch{return null}}function el(e){let t=new TextEncoder().encode(e),n=new Blob([t],{type:xt});if(typeof n.stream=="function")return n.stream();let r=globalThis.ReadableStream;return typeof r!="function"?null:new r({start(o){o.enqueue(t),o.close()}})}async function tl(e,t=ii){if(!t)return!0;try{if(navigator.sendBeacon&&navigator.sendBeacon(t,e.beaconBody))return!0}catch{}try{return await fetch(t,{method:"POST",body:e.fetchBody,headers:e.headers,keepalive:!0}),!0}catch{return!1}}function nl(e,t,n){let r=e.d??{},o=rl(e.t),i={type:o,ts:e.ts,page:typeof r.page=="string"?r.page.slice(0,2048):t},s=Mn(r.el,r.element,r.target);if(o==="signal"){i.signal_type=Mn(r.s,r.signal_type,r.name)?.slice(0,128),s&&(i.element=s.slice(0,2048));let c=s?il(s,n):null;c&&(i.dom=c)}let a=ol(r);return Object.keys(a).length&&(i.metadata=a),i}function rl(e){return e==="pv"?"pageview":e==="sig"?"signal":$a.has(e)?e:"custom_signal"}function ol(e){let t=Object.create(null);for(let n of Object.keys(e)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;let r=Rt(e[n],n);r!==void 0&&(t[n.slice(0,64)]=r)}if(e.meta&&typeof e.meta=="object"&&!Array.isArray(e.meta)){let n=Rt(e.meta,"meta");n&&typeof n=="object"&&!Array.isArray(n)&&Object.assign(t,n)}return t}function Rt(e,t="",n=0){if(!(n>4)&&!Ya(t)){if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e=="string")return ja.test(e)?void 0:e.slice(0,500);if(Array.isArray(e))return e.slice(0,20).map(o=>Rt(o,t,n+1)).filter(o=>o!==void 0);if(typeof e=="object"){let r=Object.create(null);for(let o of Object.keys(e).slice(0,40)){if(o==="__proto__"||o==="constructor"||o==="prototype")continue;let i=Rt(e[o],o,n+1);i!==void 0&&(r[o.slice(0,64)]=i)}return r}}}function il(e,t){if(t==="off")return null;try{let n=document.querySelector(e);return n?ei(n,t):null}catch{return null}}function Mn(...e){for(let t of e)if(typeof t=="string"&&t)return t}function sl(e){return e==="metadata"||e==="snapshot"?e:"off"}function al(e){return e==="off"?"off":"auto"}function ci(e){let t=location.href;function n(){let a=location.href;a!==t&&(t=a,e(a,location.pathname))}let r=history.pushState,o=history.replaceState,i=function(...a){r.apply(this,a),n()},s=function(...a){o.apply(this,a),n()};return history.pushState=i,history.replaceState=s,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),function(){history.pushState===i&&(history.pushState=r),history.replaceState===s&&(history.replaceState=o),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}function On(e,t){for(let n of t){let r=cl(n.pattern);if(r&&r.test(e))return n.label}return ul(e)}var ll=/^[a-zA-Z0-9/:._*\-]+$/;function cl(e){if(e.length>200||!ll.test(e))return null;let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+t+"$")}catch{return null}}function ul(e){return e.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/gi,"/:id")}var dl=[".carousel-arrow",".slick-arrow",".swiper-button-next",".swiper-button-prev","[data-carousel]",'button[aria-label*="next"]','button[aria-label*="prev"]','button[aria-label*="slide"]',".quantity-btn",".qty-btn",'input[type="number"]'],W=[],ui=3,di=2e3,fi=24,It=fi,pi=[],pe=[],mi=0,Ot=new Map,Nt=new Map,fl=1e4,Pt=!1,gi=f(pl);function Nn(e,t){Pt||(Pt=!0,ui=e?.threshold??3,di=e?.windowMs??2e3,It=e?.radius&&e.radius>0?e.radius:fi,pi=[...dl,...t??[]],mi=Date.now(),W=[],pe=[],Ot.clear(),Nt.clear(),document.addEventListener("click",gi,{capture:!0,passive:!0}))}function Pn(){Pt&&(Pt=!1,document.removeEventListener("click",gi,{capture:!0,passive:!0}),W=[],pe=[],Ot.clear(),Nt.clear())}function pl(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,pi)||vl(t))return;let n=Date.now(),r=e.clientX,o=e.clientY;for(;W.length&&n-W[0].t>di;)W.shift();W.push({t:n,x:r,y:o});let i=ml();if(W.length<i)return;let s=W.slice(-i);for(let k=0;k<s.length-1;k++)for(let Pe=k+1;Pe<s.length;Pe++){let Ct=s[k],kt=s[Pe],Mt=kt.x-Ct.x,de=kt.y-Ct.y;if(Mt*Mt+de*de>It*It)return}let a=s[0].t,d=(s[s.length-1].t-a)/1e3,l=d>0?s.length/d:s.length,g=(s.length-i)/i+l/10,w=Math.round(Math.min(1,g)*100)/100,E=hl(s,i,l),b=p(t),m=h(t);pe.push({selector:b,ts:n});let Y=pe.length,Lt=gl(n),Yo=Ot.get(b)??0,bn=Yo+1,jo=Nt.get(b)??0,Ca=jo>0&&n-jo<fl;Ot.set(b,bn),Nt.set(b,n);let Ko=Yo>=1,ka=(()=>{try{let k=t.getBoundingClientRect();if(k.width===0&&k.height===0)return null;let Pe=s.reduce((de,yn)=>de+yn.x,0)/s.length,Ct=s.reduce((de,yn)=>de+yn.y,0)/s.length,kt=k.left+k.width/2,Mt=k.top+k.height/2;return{click_dx:Math.round(Pe-kt),click_dy:Math.round(Ct-Mt),el_w:Math.round(k.width),el_h:Math.round(k.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"rage_click",el:b,...m?{el_label:m}:{},cnt:s.length,vel:Math.round(l*10)/10,intensity:w,quality:E,burst_seq:Y,burst_rate_per_min:Lt,repeated_target:Ko,hot_repeat:Ca,...ka??{}}}),Ko&&u({t:"sig",ts:n,d:{s:"rage_click_repeat_target",el:b,...m?{el_label:m}:{},total_hits:bn,burst_count:bn,burst_seq:Y}}),W=W.slice(-(i-1))}function ml(){return pe.length>=3?2:ui}function gl(e){let t=(e-mi)/6e4;return t<=0?0:Math.round(pe.length/t*10)/10}function hl(e,t,n){let r=e.length-t,o=Math.min(4,r/5*4),s=Math.min(4,n/10*4),a=2;if(e.length>=2){let d=0,l=0;for(let w=0;w<e.length-1;w++)for(let E=w+1;E<e.length;E++){let b=e[w],m=e[E],Y=m.x-b.x,Lt=m.y-b.y;d+=Math.sqrt(Y*Y+Lt*Lt),l++}let g=d/l;a=Math.max(0,2-g/It*2)}let c=o+s+a;return Math.round(Math.min(10,Math.max(0,c)))}function vl(e){let t=e.tagName;return!!(t==="VIDEO"||t==="AUDIO"||e.hasAttribute("ondblclick")||e.hasAttribute("data-dbl")||e.getAttribute("role")==="spinbutton")}var wl=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,El=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,bl=/^(A|BUTTON|LABEL)$/,yl=20,hi=[],me=null,Sl=5,Ht=new Map,vi=f(_l),wi=f(Cl);function _l(e){me={x:e.clientX,y:e.clientY}}function Hn(e){hi=e??[],document.addEventListener("mousedown",vi,{capture:!0,passive:!0}),document.addEventListener("click",wi,{capture:!0,passive:!0})}function Fn(){document.removeEventListener("mousedown",vi,{capture:!0}),document.removeEventListener("click",wi,{capture:!0}),me=null,Ht.clear()}function Bn(){Ht.clear()}function Tl(e){try{return window.getComputedStyle(e).cursor.slice(0,yl)}catch{return""}}function Ll(e){try{let t=window.getComputedStyle(e);return t.cursor==="pointer"&&t.pointerEvents!=="none"}catch{return!1}}function Cl(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,hi)||Al())return;let n=Dl(e);if(me=null,n||kl(t))return;let r=Ml(t,e.clientX,e.clientY),o=r?Ei(e.clientX,e.clientY,r):null,i=p(t),a=(Ht.get(i)??0)+1;Ht.set(i,a);let c=a>=2,d=Tl(t),l=Ll(t),g=h(t),w=r?h(r):"";u({t:"sig",ts:Date.now(),d:{s:"dead_click",el:i,...g?{el_label:g}:{},near:r?p(r):"",...w?{near_label:w}:{},dist:o?Math.round(o.dist):-1,...o?{click_dx:Math.round(o.dx),click_dy:Math.round(o.dy)}:{},cursor:d,...l?{looks_interactive:!0}:{},...c?{repeated:!0,repeat_cnt:a}:{}}})}function kl(e){if(wl.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&El.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&bl.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function Ml(e,t,n){let r=e;for(let o=0;o<5&&r;o++){let i=r.parentElement;if(!i)break;let s=i.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]'),a=null,c=1/0;for(let d=0;d<s.length;d++){let l=s[d];if(!l||l===e)continue;let g=xl(t,n,l);g<c&&(c=g,a=l)}if(a&&c<100)return a;r=i}return null}function Ei(e,t,n){let r=n.getBoundingClientRect(),o=Math.max(r.left,Math.min(e,r.right)),i=Math.max(r.top,Math.min(t,r.bottom)),s=e-o,a=t-i;return{dist:Math.sqrt(s*s+a*a),dx:s,dy:a}}function xl(e,t,n){return Ei(e,t,n).dist}function Al(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Dl(e){if(!me)return!1;let t=e.clientX-me.x,n=e.clientY-me.y;return Math.sqrt(t*t+n*n)>Sl}var T=null,Wn=3e3,bi=[],Ft="click",Bt=0,Rl=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,Il=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,yi=f(Pl),Si=f(Ol),_i=f(Nl);function Un(e,t){Wn=e?.delayMs??3e3,bi=t??[],document.addEventListener("click",yi,{capture:!0,passive:!0}),document.addEventListener("keydown",Si,{capture:!0,passive:!0}),document.addEventListener("touchstart",_i,{capture:!0,passive:!0})}function Vn(){document.removeEventListener("click",yi,{capture:!0}),document.removeEventListener("keydown",Si,{capture:!0}),document.removeEventListener("touchstart",_i,{capture:!0}),ge()}function qn(){ge()}function Ol(e){e.target&&(e.key!=="Enter"&&e.key!==" "||(Ft="keydown",Bt=Date.now()))}function Nl(){Ft="touch",Bt=Date.now()}function Pl(e){let t=e.target;if(!t||v(t,bi))return;let n=t.getAttribute("role");if(!Rl.test(t.tagName)&&!(n&&Il.test(n)))return;let r=Date.now();if(r-Bt>50&&(Ft="click",Bt=r),T){if(T.el===t||T.el.contains(t)){let d=r-T.ts;d>=Wn&&u({t:"sig",ts:r,d:{s:"speed_frustration",el:T.selector,delay:d,interaction_type:Ft,observed_delay_ms:d}}),ge();return}ge()}let o=p(t),i=!1,s=new MutationObserver(d=>{for(let l of d){if(l.type==="childList"&&(l.addedNodes.length>0||l.removedNodes.length>0)){i=!0,ge();return}if(l.type==="attributes"&&l.target instanceof Element&&(l.target===t||t.contains(l.target)||l.target.contains(t))){i=!0,ge();return}}}),a=t.parentElement||document.body;s.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});let c=setTimeout(()=>{!i&&T&&(T.observer.disconnect(),T={...T,timeout:null})},Wn+500);T={el:t,selector:o,ts:r,observer:s,timeout:c}}function ge(){T&&(T.observer.disconnect(),T.timeout&&clearTimeout(T.timeout),T=null)}var Hl=100,Fl=5,Ti=800,Li=2e3,Bl=3,$n=0,Wl=16,Wt=0,Ut=0,Ue=0,Ve=0,qe=0,Vt=0,zn=0,oe=[],Xn=0,he=null,Ci=f(Ul);function Yn(e){Ti=e?.velocityThreshold??800,Li=e?.windowMs??2e3,document.addEventListener("mousemove",Ci,{passive:!0})}function jn(){document.removeEventListener("mousemove",Ci),he&&clearTimeout(he),Kn()}function Ul(e){let t=Date.now();t-$n<Wl||($n=t,he&&clearTimeout(he),he=setTimeout(()=>Kn(),150),Vl(e.clientX,e.clientY,t))}function Vl(e,t,n){if(Ue===0){Wt=e,Ut=t,Ue=n,zn=n;return}let r=(n-Ue)/1e3;if(r===0)return;let o=e-Wt,i=t-Ut;if(Math.abs(o)<2&&Math.abs(i)<2)return;let s=Math.sqrt(o*o+i*i),a=s/r;oe.length>=Hl&&(oe=oe.slice(-50)),oe.push(a),Xn+=s;let c=Math.sign(o),d=Math.sign(i);if(s>=Fl&&(Ve!==0&&c!==0&&c!==Ve||qe!==0&&d!==0&&d!==qe)&&Vt++,Ve=c||Ve,qe=d||qe,Wt=e,Ut=t,Ue=n,n-zn>Li){if(Vt>=Bl){let l=oe.reduce((g,w)=>g+w,0)/oe.length;l>=Ti&&u({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(l),rev:Vt,distance_px:Math.round(Xn)}})}Kn(),zn=n}}function Kn(){Vt=0,oe=[],Xn=0,Ve=0,qe=0,Ue=0,Wt=0,Ut=0,$n=0,he=null}var ki=100,Mi=5,ql=3,L=[],M=[],Gn=3e4;function Zn(e){Gn=e?.windowMs??3e4}function Qn(){L=[],M=[]}function Jn(e){let t=Date.now(),n=e.indexOf("#"),r=n===-1?e:e.slice(0,n),o=n===-1?"":e.slice(n);for(;L.length&&t-L[0].ts>Gn;)L.shift();for(;M.length&&t-M[0].ts>Gn;)M.shift();if(L.length>=ki&&(L=L.slice(-50)),M.length>=ki&&(M=M.slice(-50)),L.push({path:e,ts:t}),o){M.push({path:e,ts:t});let a=M.filter(d=>{let l=d.path.indexOf("#");return(l===-1?d.path:d.path.slice(0,l))===r}),c=new Set(a.map(d=>{let l=d.path.indexOf("#");return l===-1?"":d.path.slice(l)}));if(c.size>=ql&&a.length>c.size){let d=a.slice(-Mi).map(l=>l.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"hash",pages:Array.from(c).map(l=>r+l),path_sequence:d}}),M=M.filter(l=>{let g=l.path.indexOf("#");return(g===-1?l.path:l.path.slice(0,g))!==r});return}}if(L.length<4)return;let i=!1,s=[];for(let a=0;a<L.length-1;a++)if(L[a].path===e){let c=L.slice(a,L.length),d=new Set(c.map(l=>l.path));if(d.size>=2){s.push(...Array.from(d)),i=!0;break}}if(i){let a=L.slice(-Mi).map(c=>c.path);u({t:"sig",ts:t,d:{s:"loop_nav",loop_type:"path",pages:s,path_sequence:a}}),L=[{path:e,ts:t}],M=M.filter(c=>{let d=c.path.indexOf("#");return(d===-1?c.path:c.path.slice(0,d))!==r})}}var zl=100,xi=1e4,tr=.5,C=[],qt=0,nr=0,ze=!1,er=0,Ai=f($l);function rr(e){xi=e?.windowMs??1e4,tr=e?.depthThreshold??.5,window.addEventListener("scroll",Ai,{passive:!0})}function or(){window.removeEventListener("scroll",Ai),C=[],ze=!1}function ir(){C=[],qt=0,nr=0,ze=!1}function $l(){ze||(ze=!0,requestAnimationFrame(()=>{ze=!1,Xl()}))}function Xl(){let e=Date.now(),t=window.scrollY;if(er=document.documentElement.scrollHeight-window.innerHeight,er<=0)return;let n=t/er,r=t>qt?"down":"up";if(e-nr<100){qt=t;return}for(;C.length&&e-C[0].ts>xi;)C.shift();C.length>=zl&&(C=C.slice(-50)),C.push({depth:n,ts:e,direction:r}),qt=t,nr=e;let o=0,i=1,s=0,a=!1,c=0,d=0,l=0,g=1,w=0;for(let E=1;E<C.length;E++)C[E].direction!==C[E-1].direction&&w++;for(let E=0;E<C.length;E++){let b=C[E],m=b.depth;if(m>o&&(o=m),m>=tr&&(a||(c=b.ts,l=m),a=!0),a&&m<i&&(i=m,d=b.ts,g=m),a&&i<.25&&m>=tr){if(d-c<200){a=!1,i=1,c=b.ts,l=m;continue}s++,a=!1,i=1}}if(s>=1){let E=Math.max(d-c,1),b=Math.abs(l-g)*100,m=Math.round(b/E*1e3);u({t:"sig",ts:e,d:{s:"scroll_bounce",depth:Math.round(o*100)/100,rev:s+1,vel:m,dir_changes:w}}),C=[]}}var Yl=["textarea",'[role="textbox"]',"[contenteditable]"],Xe=new Map,Ye=new Map,K=new Set,ie=null,sr=0,Di=5e3,Ri=[],jl=50,Ii=f(Kl),Oi=f(Gl),Ni=f(Zl),Pi=y(ur),$e=null;function ar(e,t){Di=e?.pauseMs??5e3,Ri=t??[],document.addEventListener("focusin",Ii,{capture:!0,passive:!0}),document.addEventListener("focusout",Oi,{capture:!0,passive:!0}),document.addEventListener("submit",Ni,{capture:!0,passive:!0}),window.addEventListener("pagehide",Pi),$e=y(()=>{document.visibilityState==="hidden"&&ur()}),document.addEventListener("visibilitychange",$e)}function lr(){document.removeEventListener("focusin",Ii,{capture:!0}),document.removeEventListener("focusout",Oi,{capture:!0}),document.removeEventListener("submit",Ni,{capture:!0}),window.removeEventListener("pagehide",Pi),$e&&(document.removeEventListener("visibilitychange",$e),$e=null),Xe.clear(),Ye.clear(),K.clear(),ie=null}function cr(){ur(),Xe.clear(),Ye.clear(),K.clear(),ie=null,sr=0}function Kl(e){let t=e.target;if(!t||!Hi(t)||v(t,Ri)||Ql(t))return;let n=Date.now();Xe.set(t,n),Ye.set(t,n);let r=t.closest("form");r&&r!==ie&&(ie=r,sr=r.querySelectorAll("input, select, textarea").length)}function Gl(e){let t=e.target;if(!t||!Hi(t))return;let n=Xe.get(t),r=Ye.get(t);Xe.delete(t),Ye.delete(t);let o=Date.now();if(!(r!==void 0&&o-r<jl)&&n!==void 0){let a=o-n;if(a>=Di){let c=h(t);u({t:"sig",ts:o,d:{s:"form_hesitation",el:p(t),...c?{el_label:c}:{},pause:a}})}}let s=t.getAttribute("name")||t.getAttribute("id")||p(t);Jl(t)&&K.add(s)}function Zl(){K.clear(),ie=null}function ur(){if(K.size>0&&ie){let e=sr||K.size,t=Math.round(K.size/e*100)/100;u({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:K.size,total:e,field_count:e,completion_rate:t}}),K.clear(),ie=null}}function Hi(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function Ql(e){if(e.tagName==="TEXTAREA")return!0;for(let t of Yl)try{if(e.matches(t))return!0}catch{return!1}return!1}function Jl(e){return"value"in e?e.value.length>0:!1}var ve=null,je=null,Fi=/flusterduck\.com|\/v1\/ingest/,Wi=f(nc),Ui=f(rc);function fr(){window.addEventListener("error",Wi),window.addEventListener("unhandledrejection",Ui),oc()}function pr(){window.removeEventListener("error",Wi),window.removeEventListener("unhandledrejection",Ui),ic()}var dr=/fetch|network|cors|timeout/i;function ec(e){return dr.test(e)?"network":"script"}function tc(e){if(e instanceof TypeError&&dr.test(e.message)||typeof Response<"u"&&e instanceof Response)return"network";let t=e instanceof Error?e.message:String(e??"");return dr.test(t)?"network":"unhandled_promise"}function nc(e){let t=e.message||"Unknown error";u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:mr(t,200),ep:"",status:0,error_category:ec(t),url:location.pathname}})}function rc(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason??"");u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:mr(t,200),ep:"",status:0,error_category:tc(e.reason),url:location.pathname}})}function oc(){ve||(ve=window.fetch,je=function(t,n){let r;try{r=ve.call(this,t,n)}catch(o){throw o}return r.then(o=>{try{if(o.status>=400){let i=typeof t=="string"?t:t instanceof URL?t.pathname:t.url;Fi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${o.status} ${o.statusText}`,ep:Bi(i),status:o.status,error_category:"network",url:location.pathname}})}}catch{}return o},o=>{try{let i=typeof t=="string"?t:t instanceof URL?t.href:t.url;Fi.test(i)||u({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:mr(o instanceof Error?o.message:"Fetch failed",200),ep:typeof t=="string"?Bi(t):"",status:0,error_category:"network",url:location.pathname}})}catch{}throw o})},window.fetch=je)}function ic(){ve&&je&&window.fetch===je&&(window.fetch=ve),ve=null,je=null}function Bi(e){try{return new URL(e,location.origin).pathname}catch{let t=e.indexOf("?"),n=e.indexOf("#"),r=Math.min(t>=0?t:e.length,n>=0?n:e.length);return e.slice(0,r)||"/"}}function mr(e,t){let n=e.length>t?e.slice(0,t):e;return n=n.replace(/(?:token|key|secret|password|auth|bearer|jwt|session|cookie|credential)[=:]\s*\S+/gi,"[REDACTED]"),n=n.replace(/https?:\/\/[^\s]*[?&][^\s]*/g,r=>{try{return new URL(r).origin+new URL(r).pathname}catch{return"[URL]"}}),n}var Vi=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],sc=['[class*="map"]',"canvas",".gallery","[data-zoom]"],ee=null,Ee=0,Ke=1,I=0,Ge=0,Ze=0,we=0,gr=0,hr=null,qi=[],zi=f(ac),$i=f(lc),Xi=f(dc),Yi=f(mc),ji=f(fc);function vr(e){qi=e??[],document.addEventListener("touchstart",zi,{passive:!0}),document.addEventListener("touchend",$i,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",Xi,{passive:!0}),window.addEventListener("orientationchange",Yi,{passive:!0})),window.visualViewport?.addEventListener("resize",ji)}function wr(){document.removeEventListener("touchstart",zi),document.removeEventListener("touchend",$i),document.removeEventListener("gesturechange",Xi),window.removeEventListener("orientationchange",Yi),window.visualViewport?.removeEventListener("resize",ji),ee=null,Ee=0,Ke=1,I=0,Ge=0,Ze=0,we=0,gr=0,hr=null}function Ki(e){let t=e[0],n=e[1];if(!t||!n)return 0;let r=t.clientX-n.clientX,o=t.clientY-n.clientY;return Math.sqrt(r*r+o*o)}function ac(e){let t=e.touches[0];e.touches.length===1&&t?(ee={x:t.clientX,y:t.clientY,ts:Date.now()},Ee=0):e.touches.length===2&&(Ee=Ki(e.touches),ee=null)}function lc(e){if(Ee>0){let s=e.touches.length>=2?Ki(e.touches):(()=>{let a=e.changedTouches[0],c=e.changedTouches[1];if(!a||!c)return 0;let d=a.clientX-c.clientX,l=a.clientY-c.clientY;return Math.sqrt(d*d+l*l)})();s>0&&(Ke=Math.round(s/Ee*100)/100),Ee=0}if(!ee||e.changedTouches.length!==1)return;let t=e.changedTouches[0];if(!t)return;let n=t.clientX-ee.x,r=t.clientY-ee.y,o=Date.now()-ee.ts,i=document.elementFromPoint(t.clientX,t.clientY);Math.abs(n)<10&&Math.abs(r)<10&&o<300&&i&&cc(i,t.clientX,t.clientY),o<500&&(Math.abs(n)>50||Math.abs(r)>50)&&uc(i,n,r),ee=null}function cc(e,t,n){if(v(e,qi))return;let r=gc(e,t,n);if(!r)return;let o=r.getBoundingClientRect(),i=Math.max(o.left,Math.min(t,o.right)),s=Math.max(o.top,Math.min(n,o.bottom)),a=Math.sqrt((t-i)**2+(n-s)**2);if(a>0&&a<=20){let c=`${Math.round(o.width)}x${Math.round(o.height)}`;u({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:p(r),dist:Math.round(a),size:c}})}}function uc(e,t,n){if(Math.abs(n)>Math.abs(t)||!e||Vi.some(s=>{try{return e.matches(s)||e.closest(s)}catch{return!1}})||!Vi.some(s=>{try{return document.querySelector(s)!==null}catch{return!1}}))return;let i=t>0?"right":"left";u({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:i}})}function dc(){let e=Date.now();if(e-Ge>3e4&&(I=0,Ge=e),I++,I>=2){let t=document.activeElement||document.body;!sc.some(r=>{try{return t.matches(r)||t.closest(r)}catch{return!1}})&&e-Ze>200&&(Ze=e,u({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:I,pinch_scale:Ke}})),I=0,Ke=1}}function fc(){let e=window.visualViewport;if(e&&e.scale>1.1){let t=Date.now();if(t-Ge>3e4&&(I=0,Ge=t),I++,I>=2&&t-Ze>200){let n=Math.round(e.scale*100)/100;Ze=t,u({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:I,pinch_scale:n}}),I=0,Ke=1}}}function pc(){return window.innerWidth>window.innerHeight?"landscape":"portrait"}function mc(){let e=Date.now(),t=screen.orientation?.type||"unknown";e-gr>3e4&&(we=0,gr=e),t!==hr&&(we++,hr=t),we>=3&&(u({t:"sig",ts:e,d:{s:"orientation_thrash",cnt:we,orientation:pc()}}),we=0)}function gc(e,t,n){let o=(e.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])'),i=null,s=21;for(let a=0;a<o.length;a++){let c=o[a];if(!c)continue;let d=c.getBoundingClientRect(),l=Math.max(d.left,Math.min(t,d.right)),g=Math.max(d.top,Math.min(n,d.bottom)),w=Math.sqrt((t-l)**2+(n-g)**2);w<s&&w>0&&(s=w,i=c)}return i}var x=[],be=null,A=0,ye=0,V="",U=[],Er=[],hc=10,vc=5e3,Gi=5,Zi=3e3,wc=15,Ec=5e3,Qi=f(bc);function br(e){Er=e??[],document.addEventListener("keydown",Qi,{capture:!0,passive:!0})}function yr(){document.removeEventListener("keydown",Qi,{capture:!0}),x=[],U=[],be=null,A=0,ye=0,V="",Er=[]}function bc(e){let t=Date.now(),n=e.target;n&&v(n,Er)||(e.key==="Tab"?Sc(t,n,e.shiftKey):e.key==="Escape"?_c(t,e.target):(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="ArrowLeft"||e.key==="ArrowRight")&&Tc(t,e.target))}function yc(e){let t=0;for(let n=1;n<e.length;n++)e[n].shift!==e[n-1].shift&&t++;return t}function Sc(e,t,n){for(;x.length&&e-x[0].ts>vc;)x.shift();x.length>=50&&(x=x.slice(-25));let r=t?p(t):"";if(x.push({ts:e,el:r,shift:n}),x.length>=hc){let i=x.map(a=>a.el).filter(Boolean),s=yc(x);u({t:"sig",ts:e,d:{s:"tab_thrash",cnt:x.length,els:i,direction_changes:s}}),x=[]}if(!t)return;let o=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(o){let i=p(t);o===be?e-ye<=Zi?(A++,V=i,A>=Gi&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(o),attempts:A,trapped_element:V}}),A=0,V="",be=null)):(ye=e,A=1,V=i):(be=o,ye=e,A=1,V=i)}}function _c(e,t){if(!t)return;let n=t.closest('[role="dialog"]')||t.closest('[role="menu"]')||t.closest(".modal")||t.closest('[aria-modal="true"]');if(n&&n===be){if(e-ye>Zi){ye=e,A=1,V=p(t);return}A++,V=p(t),A>=Gi&&(u({t:"sig",ts:e,d:{s:"focus_trap",container:p(n),attempts:A,trapped_element:V}}),A=0,V="",be=null)}}function Tc(e,t){if(!t)return;let n=t.closest('[role="listbox"]')||t.closest('[role="menu"]')||t.closest('[role="tree"]')||t.closest("select");if(!n)return;for(;U.length&&e-U[0].ts>Ec;)U.shift();U.length>=50&&(U=U.slice(-25)),U.push({ts:e,container:n});let r=U.filter(o=>o.container===n);r.length>=wc&&(u({t:"sig",ts:e,d:{s:"keyboard_nav_frustration",container:p(n),keys:r.length}}),U=[])}var Se=0,zt=0,$t=null,Sr=0,Xt=!1,Yt=0,_r=0,Lc=1e4,Cc=2,kc=4,Mc=3e3,Qe=null,jt=0,xc=2e3,Ji=f(Rc),es=f(Ac),ts=f(Dc);function Tr(){window.addEventListener("wheel",es,{passive:!0}),window.addEventListener("touchmove",ts,{passive:!0}),window.addEventListener("scroll",Ji,{passive:!0})}function Lr(){window.removeEventListener("wheel",es),window.removeEventListener("touchmove",ts),window.removeEventListener("scroll",Ji),Kt()}function Kt(){Se=0,zt=0,$t=null,Sr=0,Xt=!1,Yt=0,_r=0,Qe=null,jt=0}function Ac(){Qe="wheel",jt=Date.now()}function Dc(){Qe="touch",jt=Date.now()}function Rc(){Xt||(Xt=!0,requestAnimationFrame(()=>{Xt=!1,Ic()}))}function Ic(){let e=Date.now(),t=window.scrollY,n=t-zt;if(Math.abs(n)<2){zt=t;return}let r=n>0?"down":"up";if($t&&r!==$t&&(e-Sr>Mc&&(Se=0,Sr=e),Se++,Se>=kc&&Math.abs(n)>100)){let i=e-jt,s=Qe!==null&&i<=xc?Qe:"wheel";e-_r>Lc&&(Yt=0,_r=e),Yt++;let a=Yt>=Cc;u({t:"sig",ts:e,d:{s:"scroll_hijack",rev:Se,source:s,repeated:a}}),Se=0}$t=r,zt=t}var se=0,_e=0,Je=!1,rs=f(Oc),et=null,tt=null;function Cr(){window.addEventListener("scroll",rs,{passive:!0}),tt=y(ns),window.addEventListener("pagehide",tt),et=y(()=>{document.visibilityState==="hidden"&&ns()}),document.addEventListener("visibilitychange",et)}function kr(){window.removeEventListener("scroll",rs),tt&&(window.removeEventListener("pagehide",tt),tt=null),et&&(document.removeEventListener("visibilitychange",et),et=null),se=0,_e=0,Je=!1}function Mr(){se=0,_e=0,Je=!1}function Oc(){Je||(Je=!0,requestAnimationFrame(()=>{Je=!1;let e=document.documentElement.scrollHeight-window.innerHeight;if(e>0){let t=window.scrollY/e;t>se&&(se=t,_e===0&&(_e=Date.now()))}}))}function ns(){if(se>.05){let e=Date.now(),t=_e>0?Math.max(0,e-_e):0;u({t:"sig",ts:e,d:{s:"scroll_depth_abandon",depth:Math.round(se*100)/100,max_depth:Math.round(se*100),dwell_ms:t}})}}var os=1500,is=15e3,Nc=5e3,Pc=.15,xr="",Te=0,Gt=0,nt=0,Le=0,Ar=0,Zt=null,Qt=0,Jt=!1,en=f(Fc),ss=f(Bc),Ce=f(Hc);function Dr(){Jt||(Jt=!0,Ar=as(),rt(),document.addEventListener("mouseenter",en,!0),document.addEventListener("mouseleave",en,!0),document.addEventListener("click",Ce,{capture:!0,passive:!0}),document.addEventListener("keydown",Ce,{capture:!0,passive:!0}),document.addEventListener("scroll",Ce,{passive:!0}),window.addEventListener("resize",ss,{passive:!0}))}function Rr(){Jt&&(Jt=!1,document.removeEventListener("mouseenter",en,!0),document.removeEventListener("mouseleave",en,!0),document.removeEventListener("click",Ce,{capture:!0}),document.removeEventListener("keydown",Ce,{capture:!0}),document.removeEventListener("scroll",Ce),window.removeEventListener("resize",ss),ls(),xr="",Te=0,Gt=0,Le=0,nt=0,Qt=0)}function rt(){ls(),Qt+=1;let e=Qt;Zt=setTimeout(()=>{u({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:is,cycle:e}})},is)}function Ir(){Qt=0}function Hc(){rt()}function Fc(e){if(e.type!=="mouseenter")return;let t=e.target;if(!t)return;let n=p(t),r=Date.now();(n!==xr||r-Gt>os)&&(xr=n,Gt=r,Te=0),Te+=1,!(Te<4)&&(u({t:"sig",ts:r,d:{s:"thrash_hover",el:n,cnt:Te,window_ms:os}}),Te=0,Gt=r)}function Bc(){let e=Date.now(),t=as(),n=Ar||t,r=Math.abs(t-n)/Math.max(n,1);Ar=t,!(r<Pc)&&((!nt||e-nt>Nc)&&(nt=e,Le=0),Le+=1,!(Le<3)&&(u({t:"sig",ts:e,d:{s:"viewport_thrashing",cnt:Le,area_delta:Math.round(r*1e3)/1e3}}),Le=0,nt=e))}function as(){return Math.max(1,window.innerWidth*window.innerHeight)}function ls(){Zt&&(clearTimeout(Zt),Zt=null)}var cs=6e4,Wc=3,Uc=["[data-help]","[data-tooltip]","[data-faq]","[aria-describedby]",'[aria-label*="help" i]','[aria-label*="support" i]','[title*="help" i]','a[href*="/help"]','a[href*="/faq"]','a[href*="/support"]','a[href*="help."]',"details > summary",'[role="tooltip"]'],Vc=/\b(help|faq|support|tooltip|hint|guide|explain|learn.?more)\b/i,q=[],us=[],ds=f(qc);function Or(e){us=e??[],document.addEventListener("click",ds,{capture:!0,passive:!0})}function Nr(){document.removeEventListener("click",ds,{capture:!0}),q=[]}function Pr(){q=[]}function qc(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,us)||!zc(t))return;let n=Date.now();for(;q.length&&n-q[0].t>cs;)q.shift();let r=p(t);if(q.push({t:n,el:r}),q.length<Wc)return;let o=new Set(q.map(s=>s.el)).size,i=h(t);u({t:"sig",ts:n,d:{s:"help_hunt",cnt:q.length,unique_els:o,el:r,...i?{el_label:i}:{},window_ms:cs}}),q=[]}function zc(e){let t=e;for(let n=0;n<3&&t;n++){if($c(t)||Xc(t))return!0;t=t.parentElement}return!1}function $c(e){for(let t of Uc)try{if(e.matches(t))return!0}catch{}return!1}function Xc(e){let t=e.id??"",n=e.className??"",r=typeof n=="string"?`${t} ${n}`:t;return Vc.test(r)}var fs=/^(close|dismiss|modal-close|dialog-close|sheet-close|drawer-close)$/i,ps=/\b(close|dismiss|no\s*thanks?|maybe\s*later|skip|got\s*it|hide\s*this|don.?t\s*show)\b/i,tn=[],nn=new Map,ms=[],gs=f(Yc);function Hr(e){ms=e??[],document.addEventListener("click",gs,{capture:!0,passive:!0})}function Fr(){document.removeEventListener("click",gs,{capture:!0}),tn=[],nn.clear()}function Br(){tn=[],nn.clear()}function Yc(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,ms)||!jc(t))return;let n=Date.now(),r=p(t),o=h(t);tn.push({t:n,el:r});let s=(nn.get(r)??0)+1;nn.set(r,s);let a=tn.length,c=(()=>{try{let d=t.getBoundingClientRect();return d.width===0&&d.height===0?null:{click_dx:Math.round(e.clientX-(d.left+d.width/2)),click_dy:Math.round(e.clientY-(d.top+d.height/2)),el_w:Math.round(d.width),el_h:Math.round(d.height)}}catch{return null}})();u({t:"sig",ts:n,d:{s:"close_click",el:r,...o?{el_label:o}:{},session_cnt:a,element_cnt:s,repeated:s>1,container:Gc(t),...c??{}}})}function jc(e){let t=e;for(let n=0;n<4&&t;n++){if(Kc(t))return!0;t=t.parentElement}return!1}function Kc(e){let t=e.getAttribute("data-dismiss")??"",n=e.getAttribute("data-close")??"";if(t||n)return!0;let r=e.getAttribute("aria-label")??e.getAttribute("title")??"";if(r&&ps.test(r))return!0;let o=e.id??"",i=typeof e.className=="string"?e.className:"";if(fs.test(o)||fs.test(i))return!0;let s=(e.textContent??"").trim().slice(0,60);if(s&&ps.test(s))return!0;if(e.tagName==="BUTTON"&&e.closest('[role="dialog"], [role="alertdialog"], dialog, .modal, .drawer, .sheet, .overlay, .popup, [data-modal], [data-dialog]')){let c=(e.textContent??"").trim();if(c==="\xD7"||c==="\u2715"||c==="\u2717"||c==="X"||c==="x")return!0}return!1}function Gc(e){let t=[['[role="dialog"], dialog',"dialog"],['[role="alertdialog"]',"alert_dialog"],[".modal, [data-modal]","modal"],[".drawer, [data-drawer], .sheet, [data-sheet]","drawer"],[".toast, [data-toast], .notification, [data-notification]","toast"],['.banner, [data-banner], [role="banner"]',"banner"],[".cookie, [data-cookie], .consent, [data-consent]","consent"],[".popup, [data-popup], .overlay, [data-overlay]","popup"]];for(let[n,r]of t)try{if(e.closest(n))return r}catch{}return"unknown"}var Zc=1500,O=null,hs=[],vs=f(Qc),ws=f(Jc),Es=f(eu);function Wr(e){hs=e??[],document.addEventListener("click",vs,{capture:!0,passive:!0}),document.addEventListener("keydown",ws,{capture:!0,passive:!0}),window.addEventListener("popstate",Es)}function Ur(){document.removeEventListener("click",vs,{capture:!0}),document.removeEventListener("keydown",ws,{capture:!0}),window.removeEventListener("popstate",Es),O=null}function Vr(){O=null}function Qc(e){if(e.button!==0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(t&&!v(t,hs)){if(tu(t)){O=null;return}O={el:p(t),label:h(t),t:Date.now()}}}function Jc(e){e.key==="Escape"&&bs("escape")}function eu(){bs("back_nav")}function bs(e){if(!O)return;let t=Date.now()-O.t;if(t>Zc){O=null;return}u({t:"sig",ts:Date.now(),d:{s:"close_click_reversal",reversal:e,el:O.el,...O.label?{el_label:O.label}:{},elapsed_ms:t}}),O=null}function tu(e){return e.tagName==="A"?!0:e.closest('a, [role="link"], nav')!==null}var ys=1e4,nu=3,ru=/^(checkbox|radio)$/,Ss=/^(checkbox|radio|switch|tab|option|menuitemcheckbox|menuitemradio)$/,ot=new Map,qr=[],_s=f(ou),Ts=f(iu);function zr(e){qr=e??[],document.addEventListener("change",_s,{capture:!0,passive:!0}),document.addEventListener("click",Ts,{capture:!0,passive:!0})}function $r(){document.removeEventListener("change",_s,{capture:!0}),document.removeEventListener("click",Ts,{capture:!0}),ot.clear()}function Xr(){ot.clear()}function ou(e){let t=e.target;t&&(v(t,qr)||su(t)&&Ls(t))}function iu(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,qr))return;let n=t.getAttribute("role")??"";Ss.test(n)&&t.tagName!=="INPUT"&&Ls(t)}function Ls(e){let t=p(e),n=Date.now(),r=ot.get(t);for(r||(r=[],ot.set(t,r));r.length&&n-r[0].t>ys;)r.shift();if(r.push({t:n}),r.length<nu)return;let o=h(e);u({t:"sig",ts:n,d:{s:"filter_spiral",el:t,...o?{el_label:o}:{},cnt:r.length,window_ms:ys}}),ot.delete(t)}function su(e){return e.tagName==="SELECT"?!0:e.tagName==="INPUT"?ru.test(e.type??""):Ss.test(e.getAttribute("role")??"")}var Cs=15e3,au=3,G=[],ks=f(lu);function Yr(){document.addEventListener("copy",ks,{capture:!0,passive:!0})}function jr(){document.removeEventListener("copy",ks,{capture:!0}),G=[]}function Kr(){G=[]}function lu(e){let t=e.target;if(t){let o=t.tagName;if(o==="INPUT"||o==="TEXTAREA"||t.isContentEditable)return}let n=window.getSelection();if(!n||n.toString().length<2)return;let r=Date.now();for(;G.length&&r-G[0].t>Cs;)G.shift();G.push({t:r}),!(G.length<au)&&(u({t:"sig",ts:r,d:{s:"copy_frustration",cnt:G.length,window_ms:Cs}}),G=[])}var Ms=15e3,cu=4,uu=5,du=500,fu=2e3,D=[],rn=0,it=null,ae=null;function Gr(){it=y(mu),ae=y(pu),document.addEventListener("selectionchange",it),document.addEventListener("copy",ae,{capture:!0,passive:!0}),document.addEventListener("cut",ae,{capture:!0,passive:!0})}function Zr(){it&&(document.removeEventListener("selectionchange",it),it=null),ae&&(document.removeEventListener("copy",ae,{capture:!0}),document.removeEventListener("cut",ae,{capture:!0}),ae=null),D=[],rn=0}function Qr(){D=[],rn=0}function pu(){rn=Date.now(),D=[]}function mu(){let e=window.getSelection();if(!e||e.isCollapsed||e.toString().length<uu)return;let n=e.anchorNode?.parentElement;if(n){let i=n.tagName;if(i==="INPUT"||i==="TEXTAREA"||n.isContentEditable)return}let r=Date.now();if(r-rn<fu)return;for(;D.length&&r-D[0].t>Ms;)D.shift();let o=D[D.length-1];o&&r-o.t<du||(D.push({t:r}),!(D.length<cu)&&(u({t:"sig",ts:r,d:{s:"text_select_frustration",cnt:D.length,window_ms:Ms}}),D=[]))}var Jr=6e4,gu=20,As="_fd_sess",hu={rage_click:25,dead_click:15,speed_frustration:20,thrash_cursor:10,loop_nav:20,scroll_bounce:12,form_hesitation:10,form_abandon:25,error_encounter:30,user_confusion_idle:15,thrash_hover:8,viewport_thrashing:10,scroll_depth_abandon:15,scroll_hijack:12,tab_thrash:15,focus_trap:20,help_hunt:18,close_click:12,close_click_reversal:20,filter_spiral:15,copy_frustration:12,text_select_frustration:10},vu=10,xs={low:1,medium:2,high:3,critical:4},z=[],ke=null,sn=!1,xe=new Map,Me={totalSignals:0,pagesWithFrustration:0},eo="",st=null,at=null,lt=null,ct=null;function on(e){sn&&Ds(e,Date.now())}function wu(){try{let e=sessionStorage.getItem(As);if(e){let t=JSON.parse(e);Me={totalSignals:typeof t.totalSignals=="number"?t.totalSignals:0,pagesWithFrustration:typeof t.pagesWithFrustration=="number"?t.pagesWithFrustration:0}}}catch{}}function Eu(){try{sessionStorage.setItem(As,JSON.stringify(Me))}catch{}}function bu(){let e=[],n=Date.now()-Jr,r=[];for(let[o,i]of xe.entries())for(let s of i)s>=n&&r.push({type:o,ts:s});r.sort((o,i)=>o.ts-i.ts);for(let o=0;o<r.length;o++)if(r[o].type==="rage_click"){for(let i=o+1;i<r.length;i++)if(r[i].type==="form_validation_loop"&&r[i].ts-r[o].ts<=3e4){e.push("rage_then_form_loop");break}}for(let o=0;o<r.length;o++)if(r[o].type==="dead_click")for(let i=o+1;i<r.length;i++){let s=r[i].type;if((s==="popstate"||s==="hashchange")&&r[i].ts-r[o].ts<=1e4){e.push("dead_then_bail");break}}for(let o=0;o<r.length;o++)if(r[o].type==="form_validation_loop"){for(let i=o+1;i<r.length;i++)if((r[i].type==="visibilitychange"||r[i].type==="pagehide")&&r[i].ts-r[o].ts<=2e4){e.push("form_loop_then_abandon");break}}return e}function Ds(e,t){xe.has(e)||xe.set(e,[]);let n=xe.get(e);n.push(t),n.length>gu&&n.shift()}function yu(e){let t=e-Jr,n=0;for(;n<z.length&&z[n].ts<t;)n++;n>0&&(z=z.slice(n))}function Su(){let e=new Map,t=0;for(let n of z)e.set(n.type,(e.get(n.type)??0)+1),t+=hu[n.type]??vu;return{distinctTypes:new Set(e.keys()),totalWeight:t,typeCounts:e}}function Rs(e){let t="",n=0;for(let[r,o]of e)(o>n||o===n&&r<t)&&(t=r,n=o);return{type:t,count:n}}function _u(e,t,n){return Rs(n).count>=3&&e>=3?"critical":e>=4&&t>=70?"high":e>=3&&t>=40?"medium":e>=2&&t>=20?"low":null}function Tu(e,t,n,r){let o=Rs(r),i=bu();u({t:"sig",ts:Date.now(),d:{s:"frustration_burst",level:e,page:eo||void 0,distinct_types:t.size,total_weight:n,signals:Array.from(t).sort(),window_ms:Jr,dominant:o.type,repeat_count:o.count,sequences:i,session_total_signals:Me.totalSignals,session_pages_with_frustration:Me.pagesWithFrustration}}),Me.totalSignals+=z.length,Me.pagesWithFrustration+=1,Eu()}function Lu(e,t){if(!sn||e==="frustration_burst")return;let n=t??Date.now();yu(n),z.length===0&&(ke=null),z.push({type:e,ts:n}),Ds(e,n);let{distinctTypes:r,totalWeight:o,typeCounts:i}=Su(),s=_u(r.size,o,i);s&&(ke!==null&&xs[s]<=xs[ke]||(ke=s,Tu(s,r,o,i)))}function to(e){eo=e}function no(e){z=[],ke=null,sn=!0,xe=new Map,eo=e??"",wu(),Dn(Lu),st=()=>on("popstate"),at=()=>on("hashchange"),lt=()=>{document.visibilityState==="hidden"&&on("visibilitychange")},ct=()=>on("pagehide"),window.addEventListener("popstate",st),window.addEventListener("hashchange",at),document.addEventListener("visibilitychange",lt),window.addEventListener("pagehide",ct)}function ro(){sn=!1,z=[],ke=null,xe=new Map,Dn(null),st&&(window.removeEventListener("popstate",st),st=null),at&&(window.removeEventListener("hashchange",at),at=null),lt&&(document.removeEventListener("visibilitychange",lt),lt=null),ct&&(window.removeEventListener("pagehide",ct),ct=null)}var Cu=8,oo=3e4,io=5,ku=5e3,N=[],te="",ut=!1,Is=f(xu),Os=f(Au);function so(){N=[],ut=!1,te=location.pathname+location.search+location.hash,window.addEventListener("popstate",Is),window.addEventListener("hashchange",Os)}function ao(){window.removeEventListener("popstate",Is),window.removeEventListener("hashchange",Os),N=[],ut=!1,te=""}function lo(){N=[],ut=!1,te=location.pathname+location.search+location.hash}function dt(e){let t=Date.now();if(te&&te!==e){let n=N[N.length-1];n&&n.path===te&&n.leftAt===null&&(n.leftAt=t)}for(;N.length&&t-N[0].ts>oo;)N.shift();e!==te&&(N.push({path:e,ts:t,leftAt:null}),te=e),!(N.length<io)&&(ut||Mu(t))}function Mu(e){let t=N.filter(l=>e-l.ts<=oo),n=t.filter(l=>l.leftAt!==null),r=new Set(t.map(l=>l.path));if(r.size<io||n.length===0||n.some(l=>l.leftAt-l.ts>=ku)||new Set(n.map(l=>l.path)).size<io)return;let s=n.map(l=>l.leftAt-l.ts),a=Math.round(s.reduce((l,g)=>l+g,0)/s.length),c=Math.max(...s),d=t.map(l=>l.path).slice(-Cu);ut=!0,u({t:"sig",ts:e,d:{s:"navigation_confusion",page_count:r.size,window_ms:oo,avg_dwell_ms:a,pages:d,max_dwell_ms:c}})}function xu(){let e=location.pathname+location.search+location.hash;dt(e)}function Au(){let e=location.pathname+location.search+location.hash;dt(e)}var Du=.3,Ns=3e3,Z=[],ft=!1,le="none",ce=0,pt=0,mt=0,P=!1,Ps=f(Ru),Hs=f(Ou);function co(){Z=[],le="none",ce=0,pt=0,mt=0,P=!1,ft=!1,window.addEventListener("scroll",Ps,{passive:!0}),window.addEventListener("click",Hs,{capture:!0})}function uo(){window.removeEventListener("scroll",Ps),window.removeEventListener("click",Hs,{capture:!0}),an()}function an(){Z=[],le="none",ce=0,pt=0,mt=0,P=!1,ft=!1}function Ru(){ft||(ft=!0,requestAnimationFrame(Iu))}function Iu(){ft=!1;let e=Date.now(),t=window.scrollY,n=window.innerHeight,r=Z[Z.length-1];if(r&&e-r.ts<50||(Z.push({y:t,ts:e}),Z.length>60&&(Z=Z.slice(-40)),!r))return;let o=t-r.y;if(Math.abs(o)<2)return;if((o>0?"down":"up")==="down"){le!=="down"&&P&&(P=!1),t>ce&&(ce=t),le="down";return}if(P&&e-mt>Ns&&(P=!1),le==="down"){let s=ce-t,a=n*Du;s>=a&&!P&&(pt=t,mt=e,P=!0)}le="up"}function Ou(e){if(!P)return;let t=Date.now();if(t-mt>Ns){P=!1;return}if(window.scrollY+e.clientY>pt+window.innerHeight*.1)return;let r=window.innerHeight,o=Math.round(ce-pt),i=Math.round(o/r*100),s=e.target instanceof Element?e.target:null,a=s?p(s):"",c=s?h(s):"";P=!1,ce=window.scrollY,le="none",Z=[],u({t:"sig",ts:t,d:{s:"scroll_to_click_confusion",reversal_depth_px:o,click_el:a,...c?{click_el_label:c}:{},scroll_back_pct:i}})}var Nu=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,Pu=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Hu=/^(A|BUTTON|LABEL)$/,Fu=3,Fs=9e4,Bu=5,gt=new Map,Bs=[],ht=null,Wu=5,Ws=f(Uu),Us=f(Yu);function Uu(e){ht={x:e.clientX,y:e.clientY}}function fo(e){Bs=e??[],document.addEventListener("mousedown",Ws,{capture:!0,passive:!0}),document.addEventListener("click",Us,{capture:!0,passive:!0})}function po(){document.removeEventListener("mousedown",Ws,{capture:!0}),document.removeEventListener("click",Us,{capture:!0}),ht=null,gt.clear()}function mo(){gt.clear()}function Vu(e,t){let n=Math.min(3,Math.floor(e/window.innerWidth*4));return{row:Math.min(3,Math.floor(t/window.innerHeight*4)),col:n}}function qu(e,t){return e*4+t}function zu(e){if(Nu.test(e.tagName))return!0;let t=e.getAttribute("role");if(t&&Pu.test(t)||e.hasAttribute("contenteditable")||e.hasAttribute("tabindex")&&e.getAttribute("tabindex")!=="-1"||e.hasAttribute("onclick")||e.hasAttribute("onmousedown")||e.hasAttribute("onmouseup"))return!0;let n=e.parentElement;return!!(n&&Hu.test(n.tagName)||e.closest('a, button, [role="button"], label, [onclick]'))}function $u(){let e=window.getSelection();return e!==null&&e.toString().length>0}function Xu(e){if(!ht)return!1;let t=e.clientX-ht.x,n=e.clientY-ht.y;return Math.sqrt(t*t+n*n)>Wu}function Yu(e){if(e.button!==0||e.detail===0)return;let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Bs)||$u()||Xu(e)||zu(t))return;let{row:n,col:r}=Vu(e.clientX,e.clientY),o=qu(n,r),i=Date.now(),s=p(t),c=(gt.get(o)??[]).filter(d=>i-d.ts<Fs);if(c.push({ts:i,selector:s}),gt.set(o,c),c.length>=Fu){let d=new Map;for(let m of c)d.set(m.selector,(d.get(m.selector)??0)+1);let l="",g=0;for(let[m,Y]of d)Y>g&&(g=Y,l=m);let w=new Set,E=[];for(let m of c)if(!w.has(m.selector)&&(w.add(m.selector),E.push(m.selector),E.length>=Bu))break;let b=(()=>{try{let m=l?document.querySelector(l):null;return m?h(m):""}catch{return""}})();u({t:"sig",ts:i,d:{s:"dead_click_trap_zone",zone_row:n,zone_col:r,cnt:c.length,dominant_el:l,...b?{dominant_el_label:b}:{},elements:E,window_ms:Fs}}),gt.set(o,[])}}var go=3,Ae=12e4,S=new Map,cn=[],vt=null,Vs=f(Qu),ln=f(Ju);function vo(e){cn=e??[],document.addEventListener("invalid",Vs,{capture:!0,passive:!0}),document.addEventListener("input",ln,{capture:!0,passive:!0}),document.addEventListener("change",ln,{capture:!0,passive:!0}),vt=new MutationObserver(ed),vt.observe(document.body,{subtree:!0,attributeFilter:["aria-invalid"],attributes:!0,attributeOldValue:!0})}function wo(){document.removeEventListener("invalid",Vs,{capture:!0}),document.removeEventListener("input",ln,{capture:!0}),document.removeEventListener("change",ln,{capture:!0}),vt&&(vt.disconnect(),vt=null);for(let e of S.values())ne(e);S.clear()}function Eo(){for(let e of S.values())ne(e);S.clear()}function ho(e){let t=e.tagName.toLowerCase();return t==="select"?"select":t==="textarea"?"textarea":t==="input"?e.type||"text":t}function bo(e){let t=e.getAttribute("aria-invalid");if(t==="true"||t==="")return!0;if("validity"in e){let n=e;if(n.validity&&!n.validity.valid)return!0}try{return e.matches(":invalid")}catch{return!1}}function un(e){let t=e.tagName;return t==="INPUT"||t==="SELECT"||t==="TEXTAREA"}function ju(e){for(let[t,n]of S)e-n.lastTs>Ae&&(ne(n),S.delete(t))}function ne(e){e.el.removeEventListener("input",e.inputHandler),e.el.removeEventListener("change",e.changeHandler)}function Ku(e){return f(t=>{$s(e)})}function Gu(e){return f(t=>{$s(e)})}function qs(e,t){let n=Ku(t),r=Gu(t);e.addEventListener("input",n,{passive:!0}),e.addEventListener("change",r,{passive:!0});let o={cycles:0,lastTs:Date.now(),phase:"invalid",inputHandler:n,changeHandler:r,el:e};return S.set(t,o),o}function zs(e){if(!un(e)||v(e,cn))return;let t=Date.now();ju(t);let n=p(e),r=S.get(n);if(!r){qs(e,n);return}let o=r.lastTs;r.lastTs=t,r.phase==="edited"?(r.cycles+=1,r.phase="invalid",r.cycles>=go&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:Ae,field_type:ho(e)}}),ne(r),S.delete(n))):r.phase==="invalid"&&t-o>500&&(r.cycles+=1,r.cycles>=go&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:n,...h(e)?{el_label:h(e)}:{},cycles:r.cycles,window_ms:Ae,field_type:ho(e)}}),ne(r),S.delete(n)))}function Zu(e){if(!un(e))return;let t=Date.now(),n=p(e),r=S.get(n);if(r){if(t-r.lastTs>Ae){ne(r),S.delete(n);return}r.phase==="invalid"&&(r.phase="edited",r.lastTs=t)}}function $s(e){let t=Date.now(),n=S.get(e);if(n){if(t-n.lastTs>Ae){ne(n),S.delete(e);return}if(n.lastTs=t,bo(n.el)){n.cycles+=1,n.cycles>=go&&(u({t:"sig",ts:t,d:{s:"form_validation_loop",el:e,...h(n.el)?{el_label:h(n.el)}:{},cycles:n.cycles,window_ms:Ae,field_type:ho(n.el)}}),ne(n),S.delete(e));return}n.phase==="invalid"&&(n.phase="edited")}}function Qu(e){let t=e.target;t&&zs(t)}function Ju(e){let t=e.target;if(!t||!un(t)||v(t,cn))return;let n=p(t);S.has(n)||bo(t)&&qs(t,n)}function ed(e){for(let t of e){if(t.type!=="attributes"||t.attributeName!=="aria-invalid")continue;let n=t.target;if(!un(n)||v(n,cn))continue;let r=t.oldValue,o=r==="true"||r==="",i=bo(n);i&&!o?zs(n):!i&&o&&Zu(n)}}var De=null,wt=null,So=[],Xs=0,Et=new Map;function _o(e){So=e?.length?e:["[data-fd-impression]"],Xs=Date.now(),!(typeof IntersectionObserver>"u")&&(De=new IntersectionObserver(y(nd),{threshold:[0,.5,1]}),Ys(),wt=new MutationObserver(y(td)),wt.observe(document.body,{childList:!0,subtree:!0}))}function To(){De&&(De.disconnect(),De=null),wt&&(wt.disconnect(),wt=null),Et.clear()}function Lo(){Et.clear(),De&&Ys()}function Ys(){for(let e of So)try{let t=document.querySelectorAll(e);for(let n=0;n<t.length;n++)yo(t[n])}catch{}}function yo(e){Et.has(e)||(Et.set(e,{firstSeenTs:0,emitted:!1}),De.observe(e))}function td(e){for(let t of e)for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];if(r instanceof Element)for(let o of So)try{r.matches(o)&&yo(r);let i=r.querySelectorAll(o);for(let s=0;s<i.length;s++)yo(i[s])}catch{}}}function nd(e){let t=Date.now();for(let n of e){let r=Et.get(n.target);if(!(!r||r.emitted)&&n.isIntersecting&&n.intersectionRatio>=.5){r.firstSeenTs||(r.firstSeenTs=t),r.emitted=!0;let o=n.boundingClientRect,i=n.rootBounds?.height??window.innerHeight,s=o.top<i*.5?"above_fold":"below_fold",a=p(n.target),c=h(n.target);u({t:"sig",ts:t,d:{s:"element_impression",el:a,...c?{el_label:c}:{},visible_pct:Math.round(n.intersectionRatio*100),time_to_visible_ms:Math.round(t-Xs),viewport_position:s}})}}}var rd=2,od=3,id=6e4,bt=new Map,js=[],Ks=f(sd);function Co(e){js=e??[],document.addEventListener("input",Ks,{capture:!0,passive:!0})}function ko(){document.removeEventListener("input",Ks,{capture:!0}),bt.clear()}function Mo(){bt.clear()}function sd(e){let t=e.target;if(!t||!ad(t)||v(t,js))return;let n=Date.now(),r=t.value??"",o=p(t),i=bt.get(o);if(!i){bt.set(o,{lastValue:r,cycles:0,phase:"typing",lastTs:n});return}if(n-i.lastTs>id){i.lastValue=r,i.cycles=0,i.phase="typing",i.lastTs=n;return}i.lastTs=n;let s=i.lastValue.length-r.length;if(i.phase==="typing"&&s>=od)i.phase="deleted";else if(i.phase==="deleted"&&r.length>i.lastValue.length&&(i.cycles++,i.phase="typing",i.cycles>=rd)){let a=h(t);u({t:"sig",ts:n,d:{s:"input_correction",el:o,...a?{el_label:a}:{},cycles:i.cycles,field_type:ld(t)}}),bt.delete(o);return}i.lastValue=r}function ad(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function ld(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var Gs=2e3,cd=3e4,$=null,Zs=Gs,Qs=[],dn=new Map,Js=f(ud),ea=f(dd),ta=f(yt);function xo(e,t){Zs=e?.dwellMs??Gs,Qs=t??[],document.addEventListener("mouseover",Js,{passive:!0}),document.addEventListener("mouseout",ea,{passive:!0}),document.addEventListener("click",ta,{capture:!0,passive:!0})}function Ao(){document.removeEventListener("mouseover",Js),document.removeEventListener("mouseout",ea),document.removeEventListener("click",ta,{capture:!0}),yt(),dn.clear()}function Do(){yt(),dn.clear()}function ud(e){let t=e.composedPath&&e.composedPath()[0]||e.target;if(!t||v(t,Qs)||!fd(t))return;let n=p(t);if($?.selector===n)return;yt();let r=Date.now();if(r-(dn.get(n)??0)<cd)return;let o=r,i=setTimeout(()=>{let s=Date.now(),a=h(t);dn.set(n,s),$=null,u({t:"sig",ts:s,d:{s:"hover_dwell",el:n,...a?{el_label:a}:{},dwell_ms:Math.round(s-o)}})},Zs);$={el:t,selector:n,startTs:o,timer:i}}function dd(e){if(!$)return;let t=e.target;if(t!==$.el&&!$.el.contains(t))return;let n=e.relatedTarget;n&&$.el.contains(n)||yt()}function yt(){$&&(clearTimeout($.timer),$=null)}function fd(e){let t=e.tagName;if(/^(A|BUTTON|SELECT)$/.test(t))return!0;let n=e.getAttribute("role")??"";if(/^(button|link|tab|menuitem|option|checkbox|radio)$/.test(n))return!0;try{let r=window.getComputedStyle(e);return r.cursor==="pointer"&&r.pointerEvents!=="none"}catch{return!1}}var pd=20,md=500,gd=3e3,hd=6e4,fn=0,pn=0,X=null,na=y(vd);function Ro(){fn=Date.now(),pn=0,document.addEventListener("mouseleave",na)}function Io(){document.removeEventListener("mouseleave",na),X&&(clearTimeout(X),X=null)}function Oo(){fn=Date.now(),pn=0,X&&(clearTimeout(X),X=null)}function vd(e){if(e.clientY>pd)return;let t=Date.now();t-fn<gd||t-pn<hd||(X&&clearTimeout(X),X=setTimeout(y(()=>{let n=Date.now();pn=n,X=null,u({t:"sig",ts:n,d:{s:"exit_intent",method:"top_chrome",time_on_page_ms:Math.round(n-fn)}})}),md))}var wd=2500,Ed=4e3,ra=200,bd=500,yd=.1,Sd=.25,Ie=null,Oe=null,Q=null,Re=0;function No(e,t,n){return e<=t?"good":e<=n?"needs_improvement":"poor"}function Po(){if(!(typeof PerformanceObserver>"u")){try{Ie=new PerformanceObserver(y(e=>{let t=e.getEntries(),n=t[t.length-1];if(!n)return;let r=Math.round(n.startTime);u({t:"sig",ts:Date.now(),d:{s:"lcp",value_ms:r,rating:No(r,wd,Ed)}})})),Ie.observe({type:"largest-contentful-paint",buffered:!0})}catch{Ie=null}try{Oe=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;if(!n.interactionId)continue;let r=Math.round(n.duration);r<ra||u({t:"sig",ts:Date.now(),d:{s:"slow_interaction",value_ms:r,rating:No(r,ra,bd)}})}})),Oe.observe({type:"event",buffered:!1,durationThreshold:200})}catch{Oe=null}try{Q=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Re+=n.value)}})),Q.observe({type:"layout-shift",buffered:!0})}catch{Q=null}}}function oa(){if(Q){if(Q.disconnect(),Q=null,Re>0){let e=Math.round(Re*1e3)/1e3;u({t:"sig",ts:Date.now(),d:{s:"cls",value:e,rating:No(Re,yd,Sd)}})}Re=0}}function Ho(){Ie&&(Ie.disconnect(),Ie=null),Oe&&(Oe.disconnect(),Oe=null),oa()}function Fo(){if(oa(),!(typeof PerformanceObserver>"u"))try{Q=new PerformanceObserver(y(e=>{for(let t of e.getEntries()){let n=t;n.hadRecentInput||(Re+=n.value)}})),Q.observe({type:"layout-shift",buffered:!1})}catch{Q=null}}var ia=[],sa=f(_d);function Bo(e){ia=e??[],document.addEventListener("paste",sa,{capture:!0,passive:!0})}function Wo(){document.removeEventListener("paste",sa,{capture:!0})}function _d(e){let t=e.target;if(!t||!Td(t)||v(t,ia))return;let n=t.value??"";setTimeout(()=>{if((t.value??"")!==n)return;let o=p(t),i=h(t);u({t:"sig",ts:Date.now(),d:{s:"paste_blocked",el:o,...i?{el_label:i}:{},field_type:Ld(t)}})},100)}function Td(e){if(e.tagName==="TEXTAREA")return!0;if(e.tagName==="INPUT"){let t=e.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(t)}return!1}function Ld(e){return e.tagName==="TEXTAREA"?"textarea":e.type?.toLowerCase()||"text"}var Cd="https://api.flusterduck.com/v1/ingest",re=!1,mn=null,Ne=null,ue=[],St="__flusterduck_instance__",Uo=`fd_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;function kd(){let e=window;return e[St]&&e[St]!==Uo?(console.warn("[flusterduck] Another SDK instance is already active on this page. Skipping init to avoid double tracking. Load the SDK either via npm or via the script tag, not both."),!1):(e[St]=Uo,!0)}function Md(){let e=window;e[St]===Uo&&delete e[St]}var _t=[];function xd(e,t,n){let r=i=>e.signals?.[i]?.enabled!==!1,o=e.trackForms!==!1;return[{when:()=>r("rageClick"),start:()=>Nn(e.signals?.rageClick,t),stop:Pn},{when:()=>r("deadClick"),start:()=>Hn(t),stop:Fn,reset:Bn},{when:()=>r("speedFrustration"),start:()=>{let i=e.signals?.speedFrustration;Un(i?{delayMs:i.windowMs}:void 0,t)},stop:Vn,reset:qn},{when:()=>e.trackMouse!==!1&&r("thrashCursor"),start:()=>{let i=e.signals?.thrashCursor;Yn(i?{velocityThreshold:i.threshold,windowMs:i.windowMs}:void 0)},stop:jn},{when:()=>r("loopNav"),start:()=>Zn(e.signals?.loopNav),stop:Qn},{when:()=>r("scrollBounce"),start:rr,stop:or,reset:ir},{when:()=>o&&(r("formHesitation")||r("formAbandon")),start:()=>{let i=e.signals?.formHesitation;ar(i?{pauseMs:i.threshold}:void 0,t)},stop:lr,reset:cr},{when:()=>o&&r("formValidationLoop"),start:()=>vo(t),stop:wo,reset:Eo},{when:()=>r("errorEncounter"),start:fr,stop:pr},{when:()=>"ontouchstart"in window||navigator.maxTouchPoints>0,start:()=>vr(t),stop:wr},{when:()=>r("tabThrash")||r("focusTrap")||r("keyboardNavFrustration"),start:()=>br(t),stop:yr},{when:()=>r("scrollHijack"),start:Tr,stop:Lr,reset:Kt},{when:()=>r("scrollDepthAbandon"),start:Cr,stop:kr,reset:Mr},{when:()=>r("advancedHeuristics"),start:Dr,stop:Rr,reset:()=>{rt(),Ir()}},{when:()=>r("helpHunt"),start:()=>Or(t),stop:Nr,reset:Pr},{when:()=>r("closeClick"),start:()=>Hr(t),stop:Fr,reset:Br},{when:()=>r("closeClickReversal"),start:()=>Wr(t),stop:Ur,reset:Vr},{when:()=>r("filterSpiral"),start:()=>zr(t),stop:$r,reset:Xr},{when:()=>r("copyFrustration"),start:Yr,stop:jr,reset:Kr},{when:()=>r("textSelectFrustration"),start:Gr,stop:Zr,reset:Qr},{when:()=>r("deadClickTrapZone"),start:()=>fo(t),stop:po,reset:mo},{when:()=>!0,start:()=>no(n),stop:ro},{when:()=>r("navigationConfusion"),start:so,stop:ao,reset:lo},{when:()=>r("scrollToClickConfusion"),start:co,stop:uo,reset:an},{when:()=>r("elementImpression"),start:()=>_o(e.elementImpressionSelectors),stop:To,reset:Lo},{when:()=>o&&r("inputCorrection"),start:()=>Co(t),stop:ko,reset:Mo},{when:()=>o&&r("pasteBlocked"),start:()=>Bo(t),stop:Wo},{when:()=>r("hoverDwell"),start:()=>{let i=e.signals?.hoverDwell;xo(i?.threshold?{dwellMs:i.threshold}:void 0,t)},stop:Ao,reset:Do},{when:()=>r("exitIntent"),start:Ro,stop:Io,reset:Oo},{when:()=>r("performanceVitals"),start:Po,stop:Ho,reset:Fo}]}function Ad(e){if(e)try{let t=new URL(e),n=t.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t.hostname);return t.protocol!=="https:"&&!n?void 0:t.origin+t.pathname}catch{return}}function la(e){if(re||!e.key)return;if(e.key.startsWith("fd_sec_")){console.error("[flusterduck] Secret key detected in browser. Use a publishable key (fd_pub_) instead. Aborting.");return}if(!e.key.startsWith("fd_pub_"))return;if(e.respectDoNotTrack!==!1&&Fd()){Ne=e;return}if(e.sampleRate!==void 0&&e.sampleRate<1&&Math.random()>e.sampleRate){Ne=e;return}if(!kd()){Ne=e;return}Ne=e,re=!0,typeof e.onSignal=="function"&&ue.push(fe(e.onSignal)),e.emitSignalEvents&&ue.push(fe(Hd));let t=Zo(e.cookieless??!1),n=Ad(e.endpoint)??Cd,r=On(location.pathname,e.pageRules??[]),o=Bd(e.domMode);ai(n,{sid:t,key:e.key,url:location.origin+location.pathname,page:r,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:o,compression:e.compression});let i=aa(location.pathname,e.ignorePages??[]);i&&Rn(!0);let s=document.referrer,a="";if(s)try{a=new URL(s).origin+new URL(s).pathname}catch{a=""}i||u({t:"pv",ts:Date.now(),d:{ref:a}});let c=e.ignoreElements??[];_t=[];for(let d of xd(e,c,r))d.when()&&(d.start(),_t.push({stop:d.stop,reset:d.reset}));mn=ci(y((d,l)=>{for(let E of _t)E.reset?.();J(),dt(l),to(l);let g=On(l,e.pageRules??[]),w=aa(l,e.ignorePages??[]);Rn(w),In({page:g,url:d}),Jn(l),w||u({t:"pv",ts:Date.now(),d:{ref:""}})})),e.debug&&console.warn("[flusterduck] initialized",{sid:t.slice(0,6)+"...",endpoint:n,page:r})}function Dd(e,t){if(!re||typeof e!="string"||!e||e.length>128)return;let n;try{let o=t?.metadata??{};n=JSON.stringify(o)}catch{return}if(n.length>2048)return;let r=JSON.parse(n);u({t:"sig",ts:Date.now(),d:{s:e.slice(0,128),el:typeof t?.element=="string"?t.element.slice(0,256):"",meta:r,w:Math.max(0,Math.min(t?.weight??15,100))}})}function Rd(e,t={}){if(!re||typeof e!="string"||!/^[a-z0-9_.-]{1,120}$/i.test(e))return;let n;try{n=JSON.stringify(t??{})}catch{return}n.length>2048||u({t:"custom_signal",ts:Date.now(),d:{business_event:e.slice(0,120),meta:JSON.parse(n)}})}function Id(e){if(!re||!e||typeof e!="object")return;let t=Object.create(null),n=0;for(let r of Object.keys(e)){if(n>=20)break;r==="__proto__"||r==="constructor"||r==="prototype"||(t[r.slice(0,64)]=String(e[r]).slice(0,256),n++)}In({segment:t})}function Od(e){e&&Ne&&!re?la(Ne):e||(Vo(),_n())}function Nd(){Vo(),_n()}function Pd(e){let t=fe(e);return ue.push(t),()=>{t(),ue=ue.filter(n=>n!==t)}}function Hd(e){if(!(typeof window>"u"||typeof CustomEvent>"u"))try{window.dispatchEvent(new CustomEvent("flusterduck:signal",{detail:e}))}catch{}}function Vo(){if(re){for(let e of ue)e();ue=[];for(let e of _t)e.stop();_t=[],li(),mn&&(mn(),mn=null),Md(),re=!1}}function Fd(){return!!(navigator.doNotTrack==="1"||navigator.globalPrivacyControl)}function Bd(e){return e==="metadata"||e==="snapshot"?e:"off"}function aa(e,t){for(let n of t)if(n){if(n.endsWith("*")){if(e.startsWith(n.slice(0,-1)))return!0}else if(n.startsWith("*")){if(e.endsWith(n.slice(1)))return!0}else if(e===n)return!0}return!1}var fa=.1,pa=.01,ma=3e4,ga=50,ha=1e4,Wd=500,Ud=3e4,Vd=6e4,ca=10,qd=new Set(["$rageclick","$dead_click","$exception","$identify","$create_alias","$groupidentify","$survey_sent","$survey_dismissed","$feature_flag_called"]),zd=/(sign(ed)?[\s_-]?up|check(ed)?[\s_-]?out|purchase|subscri|payment|paid|upgrade|convert|trial|onboard.*complete|order[\s_-]?(placed|completed))/i,$d=/^\$\$?(heatmap|scroll)/,va=["rage_click","rage_click_repeat_target","dead_click","error_encounter","form_validation_loop","thrash_cursor"],wn=!1,gn=null,hn=null,Tt=null,H=null,vn=null,wa=fa,Ea=pa,ba=new Set,ya=new Set(va),Sa=ma,$o=ga,_a=ha,R=[],En=0,F=[];function ua(e,t){return e===void 0||Number.isNaN(e)?t:Math.max(0,Math.min(e,1))}function Xd(e){wn||(wn=!0,wa=ua(e?.baselineSampleRate,fa),Ea=ua(e?.scrollSampleRate,pa),ba=new Set(e?.conversionEvents??[]),ya=new Set(e?.criticalSignals?.length?e.criticalSignals:va),Sa=e?.bufferWindowMs&&e.bufferWindowMs>0?e.bufferWindowMs:ma,$o=e?.bufferMaxEvents&&e.bufferMaxEvents>0?e.bufferMaxEvents:ga,_a=e?.boostWindowMs&&e.boostWindowMs>0?e.boostWindowMs:ha,R=[],En=0,F=[],hn=fe(ef),da()||(gn=setInterval(()=>{da()&&Xo()},Wd),setTimeout(()=>Xo(),Ud)))}function Yd(){wn&&(wn=!1,Xo(),hn&&(hn(),hn=null),Tt&&vn&&Tt.capture.__fd_wrapped&&(Tt.capture=vn),Tt=null,H=null,vn=null,R=[],F=[],En=0)}function Xo(){gn&&(clearInterval(gn),gn=null)}function da(){try{let e=window.posthog;if(!e||typeof e.capture!="function"||e.__loaded!==!0)return!1;if(e.capture.__fd_wrapped)return!0;vn=e.capture,H=e.capture.bind(e);let n=(r,o,i)=>{try{return Kd(r,o,i)}catch{return H?H(r,o,i):void 0}};return n.__fd_wrapped=!0,e.capture=n,Tt=e,!0}catch{return!1}}function jd(e){return qd.has(e)?"critical":ba.has(e)||zd.test(e)?"conversion":$d.test(e)?"scroll":"baseline"}function Kd(e,t,n){if(!H)return;if(typeof e!="string"||!e)return H(e,t,n);let r=Date.now(),o=jd(e);if(o==="critical"||o==="conversion")return H(e,zo(t,r),n);if(r<En)return H(e,{...zo(t,r),fd_boosted:!0},n);if(Gd(o==="scroll"?Ea:wa))return H(e,zo(t,r),n);Jd({name:e,properties:t,ts:r})}function Gd(e){if(e>=1)return!0;if(e<=0)return!1;let t=Zd();return t?Qd(t)%1e4/1e4<e:Math.random()<e}var qo="";function Zd(){try{let e=window.posthog;if(e?.get_distinct_id){let t=e.get_distinct_id();if(typeof t=="string"&&t)return t}}catch{}return qo||(qo=Math.random().toString(36).slice(2)),qo}function Qd(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function zo(e,t){return La(t),F.length?{...e,fd_recent_signals:F.map(n=>n.name),fd_signal_count:F.length}:e??{}}function Jd(e){R.push(e),Ta(e.ts)}function Ta(e){let t=e-Sa;for(;R.length&&R[0].ts<t;)R.shift();R.length>$o&&(R=R.slice(-$o))}function La(e){let t=e-Vd;F=F.filter(n=>n.ts>=t),F.length>ca&&(F=F.slice(-ca))}function ef({name:e,ts:t}){if(F.push({name:e,ts:t}),La(t),!ya.has(e)||(En=t+_a,!H||!R.length))return;Ta(t);let n=R;R=[];for(let r of n)try{H(r.name,{...r.properties,fd_recovered:!0,fd_recovered_reason:e,fd_original_ts:r.ts},{timestamp:new Date(r.ts)})}catch{}}export{Vo as destroy,Yd as destroyPostHogTrigger,Id as identify,la as init,Xd as initPostHogTrigger,Pd as onSignal,Nd as optOut,Od as setConsent,Dd as signal,Rd as track};
package/dist/queue.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { SDKEvent, QueueMeta, QueueOptions } from './types';
2
- export declare function setCorrelatorHook(fn: ((signalType: string) => void) | null): void;
3
- type SignalListener = (signalType: string, ts: number) => void;
1
+ import type { SDKEvent, EmittedSignal, QueueMeta, QueueOptions } from './types';
2
+ export declare function setCorrelatorHook(fn: ((signalType: string, ts?: number) => void) | null): void;
3
+ type SignalListener = (signal: EmittedSignal) => void;
4
4
  export declare function subscribeSignals(fn: SignalListener): () => void;
5
5
  export declare function setQueuePaused(val: boolean): void;
6
6
  export declare function initQueue(ep: string, meta: QueueMeta, interval?: number, maxSize?: number, options?: QueueOptions): void;
@@ -1,4 +1,4 @@
1
- export declare function onSignal(type: string): void;
1
+ export declare function onSignal(type: string, ts?: number): void;
2
2
  export declare function setFrustrationCorrelatorPage(page: string): void;
3
3
  export declare function initFrustrationCorrelator(page?: string): void;
4
4
  export declare function destroyFrustrationCorrelator(): void;
package/dist/types.d.ts CHANGED
@@ -21,6 +21,25 @@ export interface Config {
21
21
  ignoreElements?: string[];
22
22
  ignorePages?: string[];
23
23
  elementImpressionSelectors?: string[];
24
+ /** Called synchronously the moment a friction signal is detected, before it is batched/sent. */
25
+ onSignal?: (signal: EmittedSignal) => void;
26
+ /** Also dispatch a `flusterduck:signal` CustomEvent on window for each detected signal. Off by default. */
27
+ emitSignalEvents?: boolean;
28
+ }
29
+ /**
30
+ * A friction signal at the moment it fires, surfaced to `onSignal` and the
31
+ * `flusterduck:signal` window event. The payload is a signal name, the CSS
32
+ * selector of the element involved, a 0-100 weight, detector `meta`, and a
33
+ * timestamp. Flusterduck's own detectors never put PII, form values, or page
34
+ * text in here (built-in signals carry an empty `meta`); a host-emitted
35
+ * `signal(name, { metadata })` relays whatever the host itself supplied.
36
+ */
37
+ export interface EmittedSignal {
38
+ name: string;
39
+ element: string;
40
+ weight: number;
41
+ meta: Record<string, unknown>;
42
+ ts: number;
24
43
  }
25
44
  export interface SignalOpts {
26
45
  enabled?: boolean;
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "flusterduck",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Lightweight UX confusion monitoring SDK",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",
10
+ "bin": {
11
+ "flusterduck": "./bin/flusterduck.mjs"
12
+ },
10
13
  "exports": {
11
14
  ".": {
12
15
  "types": "./dist/index.d.ts",
@@ -20,6 +23,7 @@
20
23
  "sideEffects": false,
21
24
  "files": [
22
25
  "dist",
26
+ "bin",
23
27
  "LICENSE.md"
24
28
  ],
25
29
  "publishConfig": {