flusterduck 0.3.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # flusterduck
2
2
 
3
- Lightweight browser SDK for UX friction monitoring. Detects rage clicks, dead clicks, form abandonment, navigation loops, and 20+ other behavioral signals automatically. No configuration required beyond your publishable key.
3
+ Lightweight browser SDK for UX friction monitoring. Detects and classifies rage clicks, dead clicks, form abandonment, navigation loops, and 20+ other behavioral signals locally in the browser. No configuration required beyond your publishable key.
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,7 +11,7 @@ npm install flusterduck
11
11
  Or load via script tag:
12
12
 
13
13
  ```html
14
- <script async src="https://flusterduck.com/d.js" data-key="fd_pub_..."></script>
14
+ <script async src="https://cdn.jsdelivr.net/npm/flusterduck@0/dist/d.global.js" data-key="fd_pub_..."></script>
15
15
  ```
16
16
 
17
17
  ## Basic usage
@@ -51,7 +51,7 @@ init({
51
51
  // Only track a fraction of sessions (0-1)
52
52
  sampleRate: 0.5,
53
53
 
54
- // Cookieless mode: session ID stored in sessionStorage
54
+ // Cookieless mode: memory-only session ID, no Flusterduck cookie
55
55
  cookieless: false,
56
56
 
57
57
  // Respect DoNotTrack and GlobalPrivacyControl (default: true)
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ // `npx flusterduck <args>` resolves THIS package (the SDK), not the CLI. The CLI
3
+ // is published separately as `flusterduck-cli`. To make the intuitive
4
+ // `npx flusterduck init` just work, this thin launcher hands the arguments off
5
+ // to the real CLI via npx. Importing the SDK in code is unaffected.
6
+ import { spawnSync } from 'node:child_process';
7
+
8
+ const args = process.argv.slice(2);
9
+ const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx';
10
+
11
+ const result = spawnSync(npx, ['-y', 'flusterduck-cli@latest', ...args], {
12
+ stdio: 'inherit',
13
+ });
14
+
15
+ if (result.error) {
16
+ console.error(
17
+ 'Could not start the Flusterduck CLI. Run it directly with:\n npx flusterduck-cli ' +
18
+ args.join(' '),
19
+ );
20
+ process.exit(1);
21
+ }
22
+
23
+ process.exit(result.status ?? 0);
package/dist/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Config, SDKEvent } from './types';
1
+ import type { Config, EmittedSignal, SDKEvent } from './types';
2
2
  import { enqueue, flush } from './queue';
3
3
  export declare function init(cfg: Config): void;
4
4
  export declare function signal(name: string, data?: {
@@ -10,6 +10,12 @@ export declare function track(name: string, metadata?: Record<string, unknown>):
10
10
  export declare function identify(segment: Record<string, string>): void;
11
11
  export declare function setConsent(consented: boolean): void;
12
12
  export declare function optOut(): void;
13
+ /**
14
+ * Subscribe to friction signals as they are detected. The listener runs
15
+ * synchronously the instant a signal fires (before it is batched/sent). Returns
16
+ * an unsubscribe function. Works whether or not `onSignal` was passed to init.
17
+ */
18
+ export declare function onSignal(listener: (signal: EmittedSignal) => void): () => void;
13
19
  export declare function destroy(): void;
14
20
  export { enqueue, flush };
15
21
  export type { Config, SDKEvent };
package/dist/d.global.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{function t(t){return(...e)=>{try{return t(...e)}catch{}}}function e(t){return e=>{try{t(e)}catch{}}}var n="_fd_s",o=/^[0-9a-f]{32}$/;function r(){c(n,"",-1)}function i(){const t=new Uint8Array(16);crypto.getRandomValues(t);let e="";for(const n of t)e+=n.toString(16).padStart(2,"0");return e}function c(t,e,n){const o=new Date;o.setTime(o.getTime()+864e5*n);const r="https:"===location.protocol?";Secure":"";document.cookie=`${t}=${encodeURIComponent(e)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var s=/^[:\d]|--|^(ember|react|ng-|__)/;function a(t){if(!t||t===document.documentElement)return"html";const e=t.getAttribute("data-fd");if(e)return`[data-fd="${u(e)}"]`;if(t.id&&!s.test(t.id)&&t.id.length<64)return"#"+u(t.id);const n=[];let o=t,r=0;for(;o&&o!==document.body&&r<5;){let t=o.tagName.toLowerCase();const e=o.getAttribute("name"),i=o.getAttribute("role"),c=o.getAttribute("type");e&&e.length<64?t+=`[name="${u(e)}"]`:i?t+=`[role="${u(i)}"]`:!c||"input"!==t&&"button"!==t||(t+=`[type="${u(c)}"]`);const s=o.parentElement;if(s){const e=s.children;let n=0,r=0;for(let t=0;t<e.length;t++){const i=e[t];i&&i.tagName===o.tagName&&(n++,i===o&&(r=n))}n>1&&(t+=`:nth-of-type(${r})`)}n.unshift(t);const a=n.join(" > ");try{if(1===document.querySelectorAll(a).length)return a}catch(t){}o=s,r++}return n.join(" > ")}function u(t){return"undefined"!=typeof CSS&&CSS.escape?CSS.escape(t):t.replace(/([^\w-])/g,"\\$1")}var l=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,d=/^(INPUT|TEXTAREA|SELECT)$/;function f(t){try{const e=t.getAttribute("aria-label");if(e)return e.trim().slice(0,60);if(!d.test(t.tagName)){const e=(t.textContent??"").trim().replace(/\s+/g," ").slice(0,60);if(e&&!l.test(e))return e}const n=t.getAttribute("placeholder");if(n)return n.trim().slice(0,60);const o=t.getAttribute("title");if(o)return o.trim().slice(0,60);const r=t.getAttribute("alt");return r?r.trim().slice(0,60):""}catch{return""}}function p(t,e){if(t.hasAttribute("data-fd-ignore"))return!0;if(t.closest("[data-fd-ignore]"))return!0;for(const n of e)try{if(t.matches(n)||t.closest(n))return!0}catch(t){}return!1}function h(t,e){return t&&e.includes(t)?t:null}function m(t){const e=t.tagName.toLowerCase();if("input"!==e&&"button"!==e)return null;const n=t.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function w(t){return t.top<window.innerHeight&&t.bottom>0&&t.left<window.innerWidth&&t.right>0}function _(t){if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t.tagName))return!0;const e=t.getAttribute("role");return!(!e||!/^(button|link|tab|menuitem|checkbox|radio)$/.test(e))}var v=6e4,g="application/json",b=[],y=null,M="",k=7e3,T=50,D=null,x={domMode:"off",compression:"auto"},A=!1,E=null,S=!1;function O(t){E=t}function $(t){S=t}var U=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),N=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),R=new Set(["value","text","label","email","name","phone","address","password","token","secret","cookie","session","jwt","auth","credential","card","cc","cvv","ssn"]),C=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,L=e(()=>{"hidden"===document.visibilityState&&B()}),j=t(()=>B());function I(t){S||b.length>=100||(b.push(t),b.length>=T?B():y||(y=setTimeout(B,k)))}function B(){(async()=>{if(A)return;if(!b.length||!D)return;A=!0,y&&(clearTimeout(y),y=null);const t=b;b=[];const e={v:1,sid:D.sid,key:D.key,url:D.url,page:D.page,ts:Date.now(),ua:D.ua,vw:D.vw,vh:D.vh,environment:D.environment,...D.segment?{segment:D.segment}:{},dom_mode:x.domMode},n=t.map(t=>((t,e,n)=>{const o=t.d??{},r=(t=>"pv"===t?"pageview":"sig"===t?"signal":N.has(t)?t:"custom_signal")(t.t),i={type:r,ts:t.ts,page:"string"==typeof o.page?o.page.slice(0,2048):e},c=F(o.el,o.element,o.target);if("signal"===r){i.signal_type=F(o.s,o.signal_type,o.name)?.slice(0,128),c&&(i.element=c.slice(0,2048));const t=c?((t,e)=>{if("off"===e)return null;try{const n=document.querySelector(t);return n?((t,e)=>{if("off"===e)return null;if("metadata"===e)return(t=>({mode:"metadata",selector:a(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),attributes:{disabled:!0===t.disabled,required:!0===t.required,ariaDisabled:"true"===t.getAttribute("aria-disabled"),ariaExpanded:h(t.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:h(t.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:m(t)}}))(t);const n=(t=>{try{const e=t.getBoundingClientRect(),n=getComputedStyle(t),o=t.parentElement,r=[];if(o)for(let e=0;e<o.children.length&&r.length<6;e++){const n=o.children[e];if(!n||n===t)continue;const i=n.getBoundingClientRect();r.push({selector:a(n),tag:n.tagName.toLowerCase(),box:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)},interactive:_(n)})}const i=[];try{const e=t.getAnimations();for(const t of e)"animationName"in t&&i.push(t.animationName)}catch{}return{selector:a(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),parent:o?a(o):"",box:{x:Math.round(e.x),y:Math.round(e.y),w:Math.round(e.width),h:Math.round(e.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:!0===t.disabled},inView:w(e),animations:i,siblings:r}}catch{return null}})(t);return n?{mode:"snapshot",...n}:null})(n,e):null}catch{return null}})(c,n):null;t&&(i.dom=t),i.signal_type&&E&&E(i.signal_type)}const s=(t=>{const e=Object.create(null);for(const n of Object.keys(t)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;const o=X(t[n],n);void 0!==o&&(e[n.slice(0,64)]=o)}if(t.meta&&"object"==typeof t.meta&&!Array.isArray(t.meta)){const n=X(t.meta,"meta");n&&"object"==typeof n&&!Array.isArray(n)&&Object.assign(e,n)}return e})(o);return Object.keys(s).length&&(i.metadata=s),i})(t,D.page,x.domMode));let o=[];try{for(const t of n){const n=[...o,t];if(JSON.stringify({...e,events:n}).length>v)if(o.length>0)await z({...e,events:o}),o=[t];else{const n={...e,events:[t]};JSON.stringify(n).length<=v&&await z(n),o=[]}else o=n}o.length>0&&await z({...e,events:o})}catch{}finally{A=!1}})()}function P(t){if(D)for(const e of Object.keys(t))U.has(e)&&(D[e]=t[e])}async function z(t){const e=JSON.stringify(t),n=await(async(t,e)=>{const n=(new TextEncoder).encode(t);if(n.byteLength>v)return null;if("off"!==e){const e=await(async t=>{const e=globalThis.CompressionStream;if("function"!=typeof e)return null;try{const n=(t=>{const e=(new TextEncoder).encode(t),n=new Blob([e],{type:g});if("function"==typeof n.stream)return n.stream();const o=globalThis.ReadableStream;return"function"!=typeof o?null:new o({start(t){t.enqueue(e),t.close()}})})(t);if(!n)return null;const o=new e("gzip"),r=n.pipeThrough(o).getReader(),i=[];let c=0;for(;;){const t=await r.read();if(t.done)break;if(c+=t.value.byteLength,c>v)return null;const e=new Uint8Array(t.value.byteLength);e.set(t.value),i.push(e)}const s=new Uint8Array(c);let a=0;for(const t of i)s.set(t,a),a+=t.byteLength;return s.buffer}catch{return null}})(t);if(e&&e.byteLength<=v)return{beaconBody:new Blob([e],{type:"application/json; encoding=gzip"}),fetchBody:new Uint8Array(e),headers:{"Content-Type":g,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:g}),fetchBody:t,headers:{"Content-Type":g}}})(e,x.compression);n&&q(n,0)}function q(t,e,n=M){if(n){if(navigator.sendBeacon&&navigator.sendBeacon(n,t.beaconBody))return;try{fetch(n,{method:"POST",body:t.fetchBody,headers:t.headers,keepalive:!0}).catch(()=>{e<3&&setTimeout(()=>q(t,e+1,n),1e3*(e+1))})}catch{}}}function X(t,e="",n=0){if(!(n>4||(t=>t.replace(/([a-z])([A-Z])/g,"$1\0$2").toLowerCase().split(/[\x00_\-.\s]+/).some(t=>R.has(t)))(e))){if(null===t||"boolean"==typeof t)return t;if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t){if(C.test(t))return;return t.slice(0,500)}if(Array.isArray(t))return t.slice(0,20).map(t=>X(t,e,n+1)).filter(t=>void 0!==t);if("object"==typeof t){const e=Object.create(null);for(const o of Object.keys(t).slice(0,40)){if("__proto__"===o||"constructor"===o||"prototype"===o)continue;const r=X(t[o],o,n+1);void 0!==r&&(e[o.slice(0,64)]=r)}return e}}}function F(...t){for(const e of t)if("string"==typeof e&&e)return e}function J(t){return"off"===t?"off":"auto"}function Z(t,e){for(const n of e){const e=V(n.pattern);if(e&&e.test(t))return n.label}return(t=>t.replace(/\/\d+/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:id"))(t)}var H=/^[a-zA-Z0-9/:._*\-]+$/;function V(t){if(t.length>200)return null;if(!H.test(t))return null;const e=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+e+"$")}catch{return null}}var W=[".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"]'],Y=[],G=3,K=2e3,Q=[],tt=[],et=0,nt=new Map,ot=new Map,rt=!1,it=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,Q))return;if((t=>{const e=t.tagName;return"VIDEO"===e||"AUDIO"===e||(!!t.hasAttribute("ondblclick")||(!!t.hasAttribute("data-dbl")||"spinbutton"===t.getAttribute("role")))})(e))return;const n=Date.now(),o=t.clientX,r=t.clientY;for(;Y.length&&n-Y[0].t>K;)Y.shift();Y.push({t:n,x:o,y:r});const i=tt.length>=3?2:G;if(Y.length<i)return;const c=Y.slice(-i);for(let t=0;t<c.length-1;t++)for(let e=t+1;e<c.length;e++){const n=c[t],o=c[e],r=o.x-n.x,i=o.y-n.y;if(r*r+i*i>64)return}const s=(c[c.length-1].t-c[0].t)/1e3,u=s>0?c.length/s:c.length,l=Math.round(100*Math.min(1,(c.length-i)/i+u/10))/100,d=((t,e,n)=>{const o=Math.min(4,(t.length-e)/5*4),r=Math.min(4,n/10*4);let i=2;if(t.length>=2){let e=0,n=0;for(let o=0;o<t.length-1;o++)for(let r=o+1;r<t.length;r++){const i=t[o],c=t[r],s=c.x-i.x,a=c.y-i.y;e+=Math.sqrt(s*s+a*a),n++}i=Math.max(0,2-e/n/8*2)}return Math.round(Math.min(10,Math.max(0,o+r+i)))})(c,i,u),h=a(e),m=f(e);tt.push({selector:h,ts:n});const w=tt.length,_=(t=>{const e=(t-et)/6e4;return e<=0?0:Math.round(tt.length/e*10)/10})(n),v=nt.get(h)??0,g=v+1,b=ot.get(h)??0,y=b>0&&n-b<1e4;nt.set(h,g),ot.set(h,n);const M=v>=1,k=(()=>{try{const t=e.getBoundingClientRect();if(0===t.width&&0===t.height)return null;const n=c.reduce((t,e)=>t+e.x,0)/c.length,o=c.reduce((t,e)=>t+e.y,0)/c.length,r=t.top+t.height/2;return{click_dx:Math.round(n-(t.left+t.width/2)),click_dy:Math.round(o-r),el_w:Math.round(t.width),el_h:Math.round(t.height)}}catch{return null}})();I({t:"sig",ts:n,d:{s:"rage_click",el:h,...m?{el_label:m}:{},cnt:c.length,vel:Math.round(10*u)/10,intensity:l,quality:d,burst_seq:w,burst_rate_per_min:_,repeated_target:M,hot_repeat:y,...k??{}}}),M&&I({t:"sig",ts:n,d:{s:"rage_click_repeat_target",el:h,...m?{el_label:m}:{},total_hits:g,burst_count:g,burst_seq:w}}),Y=Y.slice(-(i-1))}),ct=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,st=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,at=/^(A|BUTTON|LABEL)$/,ut=[],lt=null,dt=new Map,ft=e(t=>{lt={x:t.clientX,y:t.clientY}}),pt=e(t=>{if(0!==t.button)return;if(0===t.detail)return;const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,ut))return;if((()=>{const t=window.getSelection();return null!==t&&t.toString().length>0})())return;const n=(t=>{if(!lt)return!1;const e=t.clientX-lt.x,n=t.clientY-lt.y;return Math.sqrt(e*e+n*n)>5})(t);if(lt=null,n)return;if((t=>{if(ct.test(t.tagName))return!0;const e=t.getAttribute("role");if(e&&st.test(e))return!0;if(t.hasAttribute("contenteditable"))return!0;if(t.hasAttribute("tabindex")&&"-1"!==t.getAttribute("tabindex"))return!0;if(t.hasAttribute("onclick")||t.hasAttribute("onmousedown")||t.hasAttribute("onmouseup"))return!0;const n=t.parentElement;return!(!n||!at.test(n.tagName))||!!t.closest('a, button, [role="button"], label, [onclick]')})(e))return;const o=((t,e,n)=>{let o=t;for(let r=0;r<5&&o;r++){const r=o.parentElement;if(!r)break;const i=r.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]');let c=null,s=1/0;for(let o=0;o<i.length;o++){const r=i[o];if(!r||r===t)continue;const a=mt(e,n,r);a<s&&(s=a,c=r)}if(c&&s<100)return c;o=r}return null})(e,t.clientX,t.clientY),r=o?ht(t.clientX,t.clientY,o):null,i=a(e),c=(dt.get(i)??0)+1;dt.set(i,c);const s=c>=2,u=(t=>{try{return window.getComputedStyle(t).cursor.slice(0,20)}catch{return""}})(e),l=(t=>{try{const e=window.getComputedStyle(t);return"pointer"===e.cursor&&"none"!==e.pointerEvents}catch{return!1}})(e),d=f(e),h=o?f(o):"";I({t:"sig",ts:Date.now(),d:{s:"dead_click",el:i,...d?{el_label:d}:{},near:o?a(o):"",...h?{near_label:h}:{},dist:r?Math.round(r.dist):-1,...r?{click_dx:Math.round(r.dx),click_dy:Math.round(r.dy)}:{},cursor:u,...l?{looks_interactive:!0}:{},...s?{repeated:!0,repeat_cnt:c}:{}}})});function ht(t,e,n){const o=n.getBoundingClientRect(),r=t-Math.max(o.left,Math.min(t,o.right)),i=e-Math.max(o.top,Math.min(e,o.bottom));return{dist:Math.sqrt(r*r+i*i),dx:r,dy:i}}function mt(t,e,n){return ht(t,e,n).dist}var wt=null,_t=3e3,vt=[],gt="click",bt=0,yt=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,Mt=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,kt=e(t=>{const e=t.target;if(!e)return;if(p(e,vt))return;const n=e.getAttribute("role");if(!(yt.test(e.tagName)||n&&Mt.test(n)))return;const o=Date.now();if(o-bt>50&&(gt="click",bt=o),wt){if(wt.el===e||wt.el.contains(e)){const t=o-wt.ts;return t>=_t&&I({t:"sig",ts:o,d:{s:"speed_frustration",el:wt.selector,delay:t,interaction_type:gt,observed_delay_ms:t}}),void xt()}xt()}const r=a(e);let i=!1;const c=new MutationObserver(t=>{for(const n of t){if("childList"===n.type&&(n.addedNodes.length>0||n.removedNodes.length>0))return i=!0,void xt();if("attributes"===n.type&&n.target instanceof Element&&(n.target===e||e.contains(n.target)||n.target.contains(e)))return i=!0,void xt()}}),s=e.parentElement||document.body;c.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});const u=setTimeout(()=>{!i&&wt&&(wt.observer.disconnect(),wt={...wt,timeout:null})},_t+500);wt={el:e,selector:r,ts:o,observer:c,timeout:u}}),Tt=e(t=>{t.target&&("Enter"!==t.key&&" "!==t.key||(gt="keydown",bt=Date.now()))}),Dt=e(()=>{gt="touch",bt=Date.now()});function xt(){wt&&(wt.observer.disconnect(),wt.timeout&&clearTimeout(wt.timeout),wt=null)}var At=800,Et=2e3,St=0,Ot=0,$t=0,Ut=0,Nt=0,Rt=0,Ct=0,Lt=0,jt=[],It=0,Bt=null,Pt=e(t=>{const e=Date.now();e-St<16||(St=e,Bt&&clearTimeout(Bt),Bt=setTimeout(()=>zt(),150),((t,e,n)=>{if(0===Ut)return Ot=t,$t=e,Ut=n,void(Lt=n);const o=(n-Ut)/1e3;if(0===o)return;const r=t-Ot,i=e-$t;if(Math.abs(r)<2&&Math.abs(i)<2)return;const c=Math.sqrt(r*r+i*i),s=c/o;jt.length>=100&&(jt=jt.slice(-50)),jt.push(s),It+=c;const a=Math.sign(r),u=Math.sign(i);if(c>=5&&(0!==Nt&&0!==a&&a!==Nt||0!==Rt&&0!==u&&u!==Rt)&&Ct++,Nt=a||Nt,Rt=u||Rt,Ot=t,$t=e,Ut=n,n-Lt>Et){if(Ct>=3){const t=jt.reduce((t,e)=>t+e,0)/jt.length;t>=At&&I({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(t),rev:Ct,distance_px:Math.round(It)}})}zt(),Lt=n}})(t.clientX,t.clientY,e))});function zt(){Ct=0,jt=[],It=0,Nt=0,Rt=0,Ut=0,Ot=0,$t=0,St=0,Bt=null}var qt=[],Xt=[],Ft=3e4,Jt=1e4,Zt=.5,Ht=[],Vt=0,Wt=0,Yt=!1,Gt=0,Kt=e(()=>{Yt||(Yt=!0,requestAnimationFrame(()=>{Yt=!1,(()=>{const t=Date.now(),e=window.scrollY;if((Gt=document.documentElement.scrollHeight-window.innerHeight)<=0)return;const n=e/Gt,o=e>Vt?"down":"up";if(t-Wt<100)return void(Vt=e);for(;Ht.length&&t-Ht[0].ts>Jt;)Ht.shift();Ht.length>=100&&(Ht=Ht.slice(-50)),Ht.push({depth:n,ts:t,direction:o}),Vt=e,Wt=t;let r=0,i=1,c=0,s=!1,a=0,u=0,l=0,d=1,f=0;for(let t=1;t<Ht.length;t++)Ht[t].direction!==Ht[t-1].direction&&f++;for(let t=0;t<Ht.length;t++){const e=Ht[t],n=e.depth;if(n>r&&(r=n),n>=Zt&&(s||(a=e.ts,l=n),s=!0),s&&n<i&&(i=n,u=e.ts,d=n),s&&i<.25&&n>=Zt){if(u-a<200){s=!1,i=1,a=e.ts,l=n;continue}c++,s=!1,i=1}}if(c>=1){const e=Math.max(u-a,1),n=100*Math.abs(l-d),o=Math.round(n/e*1e3);I({t:"sig",ts:t,d:{s:"scroll_bounce",depth:Math.round(100*r)/100,rev:c+1,vel:o,dir_changes:f}}),Ht=[]}})()}))}),Qt=["textarea",'[role="textbox"]',"[contenteditable]"],te=new Map,ee=new Map,ne=new Set,oe=null,re=0,ie=5e3,ce=[],se=e(t=>{const e=t.target;if(!e||!pe(e))return;if(p(e,ce))return;if((t=>{if("TEXTAREA"===t.tagName)return!0;for(const e of Qt)try{if(t.matches(e))return!0}catch{return!1}return!1})(e))return;const n=Date.now();te.set(e,n),ee.set(e,n);const o=e.closest("form");o&&o!==oe&&(oe=o,re=o.querySelectorAll("input, select, textarea").length)}),ae=e(t=>{const e=t.target;if(!e||!pe(e))return;const n=te.get(e),o=ee.get(e);te.delete(e),ee.delete(e);const r=Date.now();if(!(void 0!==o&&r-o<50)&&void 0!==n){const t=r-n;if(t>=ie){const n=f(e);I({t:"sig",ts:r,d:{s:"form_hesitation",el:a(e),...n?{el_label:n}:{},pause:t}})}}const i=e.getAttribute("name")||e.getAttribute("id")||a(e);(t=>"value"in t&&t.value.length>0)(e)&&ne.add(i)}),ue=e(()=>{ne.clear(),oe=null}),le=t(fe),de=null;function fe(){if(ne.size>0&&oe){const t=re||ne.size,e=Math.round(ne.size/t*100)/100;I({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:ne.size,total:t,field_count:t,completion_rate:e}}),ne.clear(),oe=null}}function pe(t){const e=t.tagName;return"INPUT"===e||"SELECT"===e||"TEXTAREA"===e}var he=null,me=null,we=/flusterduck\.com|\/v1\/ingest/,_e=e(t=>{const e=t.message||"Unknown error";var n;I({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:Me(e,200),ep:"",status:0,error_category:(n=e,ge.test(n)?"network":"script"),url:location.pathname}})}),ve=e(t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"");I({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:Me(e,200),ep:"",status:0,error_category:be(t.reason),url:location.pathname}})}),ge=/fetch|network|cors|timeout/i;function be(t){if(t instanceof TypeError&&ge.test(t.message))return"network";if("undefined"!=typeof Response&&t instanceof Response)return"network";const e=t instanceof Error?t.message:String(t??"");return ge.test(e)?"network":"unhandled_promise"}function ye(t){try{return new URL(t,location.origin).pathname}catch{const e=t.indexOf("?"),n=t.indexOf("#"),o=Math.min(e>=0?e:t.length,n>=0?n:t.length);return t.slice(0,o)||"/"}}function Me(t,e){let n=t.length>e?t.slice(0,e):t;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,t=>{try{return new URL(t).origin+new URL(t).pathname}catch{return"[URL]"}}),n}var ke=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],Te=['[class*="map"]',"canvas",".gallery","[data-zoom]"],De=null,xe=0,Ae=1,Ee=0,Se=0,Oe=0,$e=0,Ue=0,Ne=null,Re=[],Ce=e(t=>{const e=t.touches[0];1===t.touches.length&&e?(De={x:e.clientX,y:e.clientY,ts:Date.now()},xe=0):2===t.touches.length&&(xe=Pe(t.touches),De=null)}),Le=e(t=>{if(xe>0){const e=t.touches.length>=2?Pe(t.touches):(()=>{const e=t.changedTouches[0],n=t.changedTouches[1];if(!e||!n)return 0;const o=e.clientX-n.clientX,r=e.clientY-n.clientY;return Math.sqrt(o*o+r*r)})();e>0&&(Ae=Math.round(e/xe*100)/100),xe=0}if(!De)return;if(1!==t.changedTouches.length)return;const e=t.changedTouches[0];if(!e)return;const n=e.clientX-De.x,o=e.clientY-De.y,r=Date.now()-De.ts,i=document.elementFromPoint(e.clientX,e.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&((t,e,n)=>{if(p(t,Re))return;const o=((t,e,n)=>{const o=(t.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])');let r=null,i=21;for(let t=0;t<o.length;t++){const c=o[t];if(!c)continue;const s=c.getBoundingClientRect(),a=Math.max(s.left,Math.min(e,s.right)),u=Math.max(s.top,Math.min(n,s.bottom)),l=Math.sqrt((e-a)**2+(n-u)**2);l<i&&l>0&&(i=l,r=c)}return r})(t,e,n);if(!o)return;const r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(e,r.right)),c=Math.max(r.top,Math.min(n,r.bottom)),s=Math.sqrt((e-i)**2+(n-c)**2);if(s>0&&s<=20){const t=`${Math.round(r.width)}x${Math.round(r.height)}`;I({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:a(o),dist:Math.round(s),size:t}})}})(i,e.clientX,e.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&((t,e,n)=>{if(Math.abs(n)>Math.abs(e))return;if(!t)return;if(ke.some(e=>{try{return t.matches(e)||t.closest(e)}catch{return!1}}))return;if(!ke.some(t=>{try{return null!==document.querySelector(t)}catch{return!1}}))return;const o=e>0?"right":"left";I({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:o}})})(i,n,o),De=null}),je=e(()=>{const t=Date.now();if(t-Se>3e4&&(Ee=0,Se=t),++Ee>=2){const e=document.activeElement||document.body;!Te.some(t=>{try{return e.matches(t)||e.closest(t)}catch{return!1}})&&t-Oe>200&&(Oe=t,I({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:Ee,pinch_scale:Ae}})),Ee=0,Ae=1}}),Ie=e(()=>{const t=Date.now(),e=screen.orientation?.type||"unknown";t-Ue>3e4&&($e=0,Ue=t),e!==Ne&&($e++,Ne=e),$e>=3&&(I({t:"sig",ts:t,d:{s:"orientation_thrash",cnt:$e,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}),$e=0)}),Be=e(()=>{const t=window.visualViewport;if(t&&t.scale>1.1){const e=Date.now();if(e-Se>3e4&&(Ee=0,Se=e),++Ee>=2&&e-Oe>200){const n=Math.round(100*t.scale)/100;Oe=e,I({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:Ee,pinch_scale:n}}),Ee=0,Ae=1}}});function Pe(t){const e=t[0],n=t[1];if(!e||!n)return 0;const o=e.clientX-n.clientX,r=e.clientY-n.clientY;return Math.sqrt(o*o+r*r)}var ze=[],qe=null,Xe=0,Fe=0,Je="",Ze=[],He=[],Ve=e(t=>{const e=Date.now(),n=t.target;n&&p(n,He)||("Tab"===t.key?((t,e,n)=>{for(;ze.length&&t-ze[0].ts>5e3;)ze.shift();ze.length>=50&&(ze=ze.slice(-25));const o=e?a(e):"";if(ze.push({ts:t,el:o,shift:n}),ze.length>=10){const e=ze.map(t=>t.el).filter(Boolean),n=(t=>{let e=0;for(let n=1;n<t.length;n++)t[n].shift!==t[n-1].shift&&e++;return e})(ze);I({t:"sig",ts:t,d:{s:"tab_thrash",cnt:ze.length,els:e,direction_changes:n}}),ze=[]}if(!e)return;const r=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');if(r){const n=a(e);r===qe?t-Fe<=3e3?(Xe++,Je=n,Xe>=5&&(I({t:"sig",ts:t,d:{s:"focus_trap",container:a(r),attempts:Xe,trapped_element:Je}}),Xe=0,Je="",qe=null)):(Fe=t,Xe=1,Je=n):(qe=r,Fe=t,Xe=1,Je=n)}})(e,n,t.shiftKey):"Escape"===t.key?((t,e)=>{if(!e)return;const n=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');if(n&&n===qe){if(t-Fe>3e3)return Fe=t,Xe=1,void(Je=a(e));Xe++,Je=a(e),Xe>=5&&(I({t:"sig",ts:t,d:{s:"focus_trap",container:a(n),attempts:Xe,trapped_element:Je}}),Xe=0,Je="",qe=null)}})(e,t.target):"ArrowDown"!==t.key&&"ArrowUp"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key||((t,e)=>{if(!e)return;const n=e.closest('[role="listbox"]')||e.closest('[role="menu"]')||e.closest('[role="tree"]')||e.closest("select");if(!n)return;for(;Ze.length&&t-Ze[0].ts>5e3;)Ze.shift();Ze.length>=50&&(Ze=Ze.slice(-25)),Ze.push({ts:t,container:n});const o=Ze.filter(t=>t.container===n);o.length>=15&&(I({t:"sig",ts:t,d:{s:"keyboard_nav_frustration",container:a(n),keys:o.length}}),Ze=[])})(e,t.target))}),We=0,Ye=0,Ge=null,Ke=0,Qe=!1,tn=0,en=0,nn=null,on=0,rn=e(()=>{Qe||(Qe=!0,requestAnimationFrame(()=>{Qe=!1,(()=>{const t=Date.now(),e=window.scrollY,n=e-Ye;if(Math.abs(n)<2)return void(Ye=e);const o=n>0?"down":"up";Ge&&o!==Ge&&(t-Ke>3e3&&(We=0,Ke=t),++We>=4)&&Math.abs(n)>100&&(t-en>1e4&&(tn=0,en=t),tn++,I({t:"sig",ts:t,d:{s:"scroll_hijack",rev:We,source:null!==nn&&t-on<=2e3?nn:"wheel",repeated:tn>=2}}),We=0),Ge=o,Ye=e})()}))}),cn=e(()=>{nn="wheel",on=Date.now()}),sn=e(()=>{nn="touch",on=Date.now()});function an(){We=0,Ye=0,Ge=null,Ke=0,Qe=!1,tn=0,en=0,nn=null,on=0}var un=0,ln=0,dn=!1,fn=e(()=>{dn||(dn=!0,requestAnimationFrame(()=>{dn=!1;const t=document.documentElement.scrollHeight-window.innerHeight;if(t>0){const e=window.scrollY/t;e>un&&(un=e,0===ln&&(ln=Date.now()))}}))}),pn=null,hn=null;function mn(){if(un>.05){const t=Date.now(),e=ln>0?Math.max(0,t-ln):0;I({t:"sig",ts:t,d:{s:"scroll_depth_abandon",depth:Math.round(100*un)/100,max_depth:Math.round(100*un),dwell_ms:e}})}}var wn="",_n=0,vn=0,gn=0,bn=0,yn=0,Mn=null,kn=0,Tn=!1,Dn=e(t=>{if("mouseenter"!==t.type)return;const e=t.target;if(!e)return;const n=a(e),o=Date.now();(n!==wn||o-vn>1500)&&(wn=n,vn=o,_n=0),(_n+=1)<4||(I({t:"sig",ts:o,d:{s:"thrash_hover",el:n,cnt:_n,window_ms:1500}}),_n=0,vn=o)}),xn=e(()=>{const t=Date.now(),e=Sn(),n=yn||e,o=Math.abs(e-n)/Math.max(n,1);yn=e,o<.15||((!gn||t-gn>5e3)&&(gn=t,bn=0),(bn+=1)<3||(I({t:"sig",ts:t,d:{s:"viewport_thrashing",cnt:bn,area_delta:Math.round(1e3*o)/1e3}}),bn=0,gn=t))}),An=e(()=>{En()});function En(){On();const t=kn+=1;Mn=setTimeout(()=>{I({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:15e3,cycle:t}})},15e3)}function Sn(){return Math.max(1,window.innerWidth*window.innerHeight)}function On(){Mn&&(clearTimeout(Mn),Mn=null)}var $n=["[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"]'],Un=/\b(help|faq|support|tooltip|hint|guide|explain|learn.?more)\b/i,Nn=[],Rn=[],Cn=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,Rn))return;if(!(t=>{let e=t;for(let t=0;t<3&&e;t++){if(Ln(e))return!0;if(jn(e))return!0;e=e.parentElement}return!1})(e))return;const n=Date.now();for(;Nn.length&&n-Nn[0].t>6e4;)Nn.shift();const o=a(e);if(Nn.push({t:n,el:o}),Nn.length<3)return;const r=new Set(Nn.map(t=>t.el)).size,i=f(e);I({t:"sig",ts:n,d:{s:"help_hunt",cnt:Nn.length,unique_els:r,el:o,...i?{el_label:i}:{},window_ms:6e4}}),Nn=[]});function Ln(t){for(const e of $n)try{if(t.matches(e))return!0}catch{}return!1}function jn(t){const e=t.id??"",n=t.className??"";return Un.test("string"==typeof n?`${e} ${n}`:e)}var In=/^(close|dismiss|modal-close|dialog-close|sheet-close|drawer-close)$/i,Bn=/\b(close|dismiss|no\s*thanks?|maybe\s*later|skip|got\s*it|hide\s*this|don.?t\s*show)\b/i,Pn=[],zn=new Map,qn=[],Xn=e(t=>{if(0!==t.button)return;const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,qn))return;if(!(t=>{let e=t;for(let t=0;t<4&&e;t++){if(Fn(e))return!0;e=e.parentElement}return!1})(e))return;const n=Date.now(),o=a(e),r=f(e);Pn.push({t:n,el:o});const i=(zn.get(o)??0)+1;zn.set(o,i);const c=Pn.length,s=(()=>{try{const n=e.getBoundingClientRect();return 0===n.width&&0===n.height?null:{click_dx:Math.round(t.clientX-(n.left+n.width/2)),click_dy:Math.round(t.clientY-(n.top+n.height/2)),el_w:Math.round(n.width),el_h:Math.round(n.height)}}catch{return null}})();I({t:"sig",ts:n,d:{s:"close_click",el:o,...r?{el_label:r}:{},session_cnt:c,element_cnt:i,repeated:i>1,container:Jn(e),...s??{}}})});function Fn(t){const e=t.getAttribute("data-dismiss")??"",n=t.getAttribute("data-close")??"";if(e||n)return!0;const o=t.getAttribute("aria-label")??t.getAttribute("title")??"";if(o&&Bn.test(o))return!0;const r="string"==typeof t.className?t.className:"";if(In.test(t.id??"")||In.test(r))return!0;const i=(t.textContent??"").trim().slice(0,60);if(i&&Bn.test(i))return!0;if("BUTTON"===t.tagName&&t.closest('[role="dialog"], [role="alertdialog"], dialog, .modal, .drawer, .sheet, .overlay, .popup, [data-modal], [data-dialog]')){const e=(t.textContent??"").trim();if("×"===e||"✕"===e||"✗"===e||"X"===e||"x"===e)return!0}return!1}function Jn(t){const e=[['[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(const[n,o]of e)try{if(t.closest(n))return o}catch{}return"unknown"}var Zn=null,Hn=[],Vn=e(t=>{if(0!==t.button)return;const e=t.composedPath&&t.composedPath()[0]||t.target;e&&(p(e,Hn)||(Zn=(t=>"A"===t.tagName||null!==t.closest('a, [role="link"], nav'))(e)?null:{el:a(e),label:f(e),t:Date.now()}))}),Wn=e(t=>{"Escape"===t.key&&Gn("escape")}),Yn=e(()=>{Gn("back_nav")});function Gn(t){if(!Zn)return;const e=Date.now()-Zn.t;e>1500||I({t:"sig",ts:Date.now(),d:{s:"close_click_reversal",reversal:t,el:Zn.el,...Zn.label?{el_label:Zn.label}:{},elapsed_ms:e}}),Zn=null}var Kn=/^(checkbox|radio)$/,Qn=/^(checkbox|radio|switch|tab|option|menuitemcheckbox|menuitemradio)$/,to=new Map,eo=[],no=e(t=>{const e=t.target;e&&(p(e,eo)||(t=>"SELECT"===t.tagName||("INPUT"===t.tagName?Kn.test(t.type??""):Qn.test(t.getAttribute("role")??"")))(e)&&ro(e))}),oo=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,eo))return;const n=e.getAttribute("role")??"";Qn.test(n)&&"INPUT"!==e.tagName&&ro(e)});function ro(t){const e=a(t),n=Date.now();let o=to.get(e);for(o||(o=[],to.set(e,o));o.length&&n-o[0].t>1e4;)o.shift();if(o.push({t:n}),o.length<3)return;const r=f(t);I({t:"sig",ts:n,d:{s:"filter_spiral",el:e,...r?{el_label:r}:{},cnt:o.length,window_ms:1e4}}),to.delete(e)}var io=[],co=e(t=>{const e=t.target;if(e){const t=e.tagName;if("INPUT"===t||"TEXTAREA"===t)return;if(e.isContentEditable)return}const n=window.getSelection();if(!n||n.toString().length<2)return;const o=Date.now();for(;io.length&&o-io[0].t>15e3;)io.shift();io.push({t:o}),io.length<3||(I({t:"sig",ts:o,d:{s:"copy_frustration",cnt:io.length,window_ms:15e3}}),io=[])}),so=[],ao=0,uo=null,lo=null;function fo(){ao=Date.now(),so=[]}function po(){const t=window.getSelection();if(!t||t.isCollapsed)return;if(t.toString().length<5)return;const e=t.anchorNode?.parentElement;if(e){const t=e.tagName;if("INPUT"===t||"TEXTAREA"===t||e.isContentEditable)return}const n=Date.now();if(n-ao<2e3)return;for(;so.length&&n-so[0].t>15e3;)so.shift();const o=so[so.length-1];o&&n-o.t<500||(so.push({t:n}),so.length<4||(I({t:"sig",ts:n,d:{s:"text_select_frustration",cnt:so.length,window_ms:15e3}}),so=[]))}var ho=6e4,mo="_fd_sess",wo={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},_o={low:1,medium:2,high:3,critical:4},vo=[],go=null,bo=!1,yo=new Map,Mo={totalSignals:0,pagesWithFrustration:0},ko="",To=null,Do=null,xo=null,Ao=null;function Eo(t){bo&&So(t,Date.now())}function So(t,e){yo.has(t)||yo.set(t,[]);const n=yo.get(t);n.push(e),n.length>20&&n.shift()}function Oo(t){let e="",n=0;for(const[o,r]of t)(r>n||r===n&&o<e)&&(e=o,n=r);return{type:e,count:n}}function $o(t){if(!bo)return;if("frustration_burst"===t)return;const e=Date.now();(t=>{const e=t-ho;let n=0;for(;n<vo.length&&vo[n].ts<e;)n++;n>0&&(vo=vo.slice(n))})(e),0===vo.length&&(go=null),vo.push({type:t,ts:e}),So(t,e);const{distinctTypes:n,totalWeight:o,typeCounts:r}=(()=>{const t=new Map;let e=0;for(const n of vo)t.set(n.type,(t.get(n.type)??0)+1),e+=wo[n.type]??10;return{distinctTypes:new Set(t.keys()),totalWeight:e,typeCounts:t}})(),i=((t,e,n)=>Oo(n).count>=3&&t>=3?"critical":t>=4&&e>=70?"high":t>=3&&e>=40?"medium":t>=2&&e>=20?"low":null)(n.size,o,r);i&&(null!==go&&_o[i]<=_o[go]||(go=i,((t,e,n,o)=>{const r=Oo(o),i=(()=>{const t=[],e=Date.now()-ho,n=[];for(const[t,o]of yo.entries())for(const r of o)r>=e&&n.push({type:t,ts:r});n.sort((t,e)=>t.ts-e.ts);for(let e=0;e<n.length;e++)if("rage_click"===n[e].type)for(let o=e+1;o<n.length;o++)if("form_validation_loop"===n[o].type&&n[o].ts-n[e].ts<=3e4){t.push("rage_then_form_loop");break}for(let e=0;e<n.length;e++)if("dead_click"===n[e].type)for(let o=e+1;o<n.length;o++){const r=n[o].type;if(("popstate"===r||"hashchange"===r)&&n[o].ts-n[e].ts<=1e4){t.push("dead_then_bail");break}}for(let e=0;e<n.length;e++)if("form_validation_loop"===n[e].type)for(let o=e+1;o<n.length;o++)if(("visibilitychange"===n[o].type||"pagehide"===n[o].type)&&n[o].ts-n[e].ts<=2e4){t.push("form_loop_then_abandon");break}return t})();I({t:"sig",ts:Date.now(),d:{s:"frustration_burst",level:t,page:ko||void 0,distinct_types:e.size,total_weight:n,signals:Array.from(e).sort(),window_ms:ho,dominant:r.type,repeat_count:r.count,sequences:i,session_total_signals:Mo.totalSignals,session_pages_with_frustration:Mo.pagesWithFrustration}}),Mo.totalSignals+=vo.length,Mo.pagesWithFrustration+=1,(()=>{try{sessionStorage.setItem(mo,JSON.stringify(Mo))}catch{}})()})(i,n,o,r)))}var Uo=3e4,No=[],Ro="",Co=!1,Lo=e(()=>{Io(location.pathname+location.search+location.hash)}),jo=e(()=>{Io(location.pathname+location.search+location.hash)});function Io(t){const e=Date.now();if(Ro&&Ro!==t){const t=No[No.length-1];t&&t.path===Ro&&null===t.leftAt&&(t.leftAt=e)}for(;No.length&&e-No[0].ts>Uo;)No.shift();t!==Ro&&(No.push({path:t,ts:e,leftAt:null}),Ro=t),No.length<5||Co||(t=>{const e=No.filter(e=>t-e.ts<=Uo),n=e.filter(t=>null!==t.leftAt),o=new Set(e.map(t=>t.path));if(o.size<5)return;if(0===n.length)return;if(n.some(t=>t.leftAt-t.ts>=5e3))return;if(new Set(n.map(t=>t.path)).size<5)return;const r=n.map(t=>t.leftAt-t.ts),i=Math.round(r.reduce((t,e)=>t+e,0)/r.length),c=Math.max(...r),s=e.map(t=>t.path).slice(-8);Co=!0,I({t:"sig",ts:t,d:{s:"navigation_confusion",page_count:o.size,window_ms:Uo,avg_dwell_ms:i,pages:s,max_dwell_ms:c}})})(e)}var Bo=[],Po=!1,zo="none",qo=0,Xo=0,Fo=0,Jo=!1,Zo=e(()=>{Po||(Po=!0,requestAnimationFrame(Wo))}),Ho=e(t=>{if(!Jo)return;const e=Date.now();if(e-Fo>3e3)return void(Jo=!1);if(window.scrollY+t.clientY>Xo+.1*window.innerHeight)return;const n=window.innerHeight,o=Math.round(qo-Xo),r=Math.round(o/n*100),i=t.target instanceof Element?t.target:null,c=i?a(i):"",s=i?f(i):"";Jo=!1,qo=window.scrollY,zo="none",Bo=[],I({t:"sig",ts:e,d:{s:"scroll_to_click_confusion",reversal_depth_px:o,click_el:c,...s?{click_el_label:s}:{},scroll_back_pct:r}})});function Vo(){Bo=[],zo="none",qo=0,Xo=0,Fo=0,Jo=!1,Po=!1}function Wo(){Po=!1;const t=Date.now(),e=window.scrollY,n=window.innerHeight,o=Bo[Bo.length-1];if(o&&t-o.ts<50)return;if(Bo.push({y:e,ts:t}),Bo.length>60&&(Bo=Bo.slice(-40)),!o)return;const r=e-o.y;if(!(Math.abs(r)<2)){if("down"==(r>0?"down":"up"))return"down"!==zo&&Jo&&(Jo=!1),e>qo&&(qo=e),void(zo="down");Jo&&t-Fo>3e3&&(Jo=!1),"down"===zo&&qo-e>=.3*n&&!Jo&&(Xo=e,Fo=t,Jo=!0),zo="up"}}var Yo=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,Go=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Ko=/^(A|BUTTON|LABEL)$/,Qo=new Map,tr=[],er=null,nr=e(t=>{er={x:t.clientX,y:t.clientY}}),or=e(t=>{if(0!==t.button)return;if(0===t.detail)return;const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,tr))return;if((()=>{const t=window.getSelection();return null!==t&&t.toString().length>0})())return;if((t=>{if(!er)return!1;const e=t.clientX-er.x,n=t.clientY-er.y;return Math.sqrt(e*e+n*n)>5})(t))return;if((t=>{if(Yo.test(t.tagName))return!0;const e=t.getAttribute("role");if(e&&Go.test(e))return!0;if(t.hasAttribute("contenteditable"))return!0;if(t.hasAttribute("tabindex")&&"-1"!==t.getAttribute("tabindex"))return!0;if(t.hasAttribute("onclick")||t.hasAttribute("onmousedown")||t.hasAttribute("onmouseup"))return!0;const n=t.parentElement;return!(!n||!Ko.test(n.tagName))||!!t.closest('a, button, [role="button"], label, [onclick]')})(e))return;const{row:n,col:o}=((t,e)=>{const n=Math.min(3,Math.floor(t/window.innerWidth*4));return{row:Math.min(3,Math.floor(e/window.innerHeight*4)),col:n}})(t.clientX,t.clientY),r=((t,e)=>4*t+e)(n,o),i=Date.now(),c=a(e),s=(Qo.get(r)??[]).filter(t=>i-t.ts<9e4);if(s.push({ts:i,selector:c}),Qo.set(r,s),s.length>=3){const t=new Map;for(const e of s)t.set(e.selector,(t.get(e.selector)??0)+1);let e="",c=0;for(const[n,o]of t)o>c&&(c=o,e=n);const a=new Set,u=[];for(const t of s)if(!a.has(t.selector)&&(a.add(t.selector),u.push(t.selector),u.length>=5))break;const l=(()=>{try{const t=e?document.querySelector(e):null;return t?f(t):""}catch{return""}})();I({t:"sig",ts:i,d:{s:"dead_click_trap_zone",zone_row:n,zone_col:o,cnt:s.length,dominant_el:e,...l?{dominant_el_label:l}:{},elements:u,window_ms:9e4}}),Qo.set(r,[])}}),rr=12e4,ir=new Map,cr=[],sr=null,ar=e(t=>{const e=t.target;e&&mr(e)}),ur=e(t=>{const e=t.target;if(!e||!fr(e))return;if(p(e,cr))return;const n=a(e);ir.has(n)||dr(e)&&hr(e,n)});function lr(t){const e=t.tagName.toLowerCase();return"select"===e?"select":"textarea"===e?"textarea":"input"===e?t.type||"text":e}function dr(t){const e=t.getAttribute("aria-invalid");if("true"===e||""===e)return!0;if("validity"in t&&t.validity&&!t.validity.valid)return!0;try{return t.matches(":invalid")}catch{return!1}}function fr(t){const e=t.tagName;return"INPUT"===e||"SELECT"===e||"TEXTAREA"===e}function pr(t){t.el.removeEventListener("input",t.inputHandler),t.el.removeEventListener("change",t.changeHandler)}function hr(t,n){const o=(t=>e(e=>{_r(t)}))(n),r=(t=>e(e=>{_r(t)}))(n);t.addEventListener("input",o,{passive:!0}),t.addEventListener("change",r,{passive:!0});const i={cycles:0,lastTs:Date.now(),phase:"invalid",inputHandler:o,changeHandler:r,el:t};return ir.set(n,i),i}function mr(t){if(!fr(t))return;if(p(t,cr))return;const e=Date.now();(t=>{for(const[e,n]of ir)t-n.lastTs>rr&&(pr(n),ir.delete(e))})(e);const n=a(t),o=ir.get(n);if(!o)return void hr(t,n);const r=o.lastTs;o.lastTs=e,"edited"===o.phase?(o.cycles+=1,o.phase="invalid",o.cycles>=3&&(I({t:"sig",ts:e,d:{s:"form_validation_loop",el:n,...f(t)?{el_label:f(t)}:{},cycles:o.cycles,window_ms:rr,field_type:lr(t)}}),pr(o),ir.delete(n))):"invalid"===o.phase&&e-r>500&&(o.cycles+=1,o.cycles>=3&&(I({t:"sig",ts:e,d:{s:"form_validation_loop",el:n,...f(t)?{el_label:f(t)}:{},cycles:o.cycles,window_ms:rr,field_type:lr(t)}}),pr(o),ir.delete(n)))}function wr(t){if(!fr(t))return;const e=Date.now(),n=a(t),o=ir.get(n);return o?e-o.lastTs>rr?(pr(o),void ir.delete(n)):void("invalid"===o.phase&&(o.phase="edited",o.lastTs=e)):void 0}function _r(t){const e=Date.now(),n=ir.get(t);if(n){if(e-n.lastTs>rr)return pr(n),void ir.delete(t);if(n.lastTs=e,dr(n.el))return n.cycles+=1,void(n.cycles>=3&&(I({t:"sig",ts:e,d:{s:"form_validation_loop",el:t,...f(n.el)?{el_label:f(n.el)}:{},cycles:n.cycles,window_ms:rr,field_type:lr(n.el)}}),pr(n),ir.delete(t)));"invalid"===n.phase&&(n.phase="edited")}}function vr(t){for(const e of t){if("attributes"!==e.type)continue;if("aria-invalid"!==e.attributeName)continue;const t=e.target;if(!fr(t))continue;if(p(t,cr))continue;const n=e.oldValue,o="true"===n||""===n,r=dr(t);r&&!o?mr(t):!r&&o&&wr(t)}}var gr=null,br=null,yr=[],Mr=0,kr=new Map;function Tr(){for(const t of yr)try{const e=document.querySelectorAll(t);for(let t=0;t<e.length;t++)Dr(e[t])}catch{}}function Dr(t){kr.has(t)||(kr.set(t,{firstSeenTs:0,emitted:!1}),gr.observe(t))}function xr(t){for(const e of t)for(let t=0;t<e.addedNodes.length;t++){const n=e.addedNodes[t];if(n instanceof Element)for(const t of yr)try{n.matches(t)&&Dr(n);const e=n.querySelectorAll(t);for(let t=0;t<e.length;t++)Dr(e[t])}catch{}}}function Ar(t){const e=Date.now();for(const n of t){const t=kr.get(n.target);if(t&&!t.emitted&&n.isIntersecting&&n.intersectionRatio>=.5){t.firstSeenTs||(t.firstSeenTs=e),t.emitted=!0;const o=n.boundingClientRect,r=n.rootBounds?.height??window.innerHeight,i=o.top<.5*r?"above_fold":"below_fold",c=a(n.target),s=f(n.target);I({t:"sig",ts:e,d:{s:"element_impression",el:c,...s?{el_label:s}:{},visible_pct:Math.round(100*n.intersectionRatio),time_to_visible_ms:Math.round(e-Mr),viewport_position:i}})}}}var Er=new Map,Sr=[],Or=e(t=>{const e=t.target;if(!e||!(t=>{if("TEXTAREA"===t.tagName)return!0;if("INPUT"===t.tagName){const e=t.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(e)}return!1})(e))return;if(p(e,Sr))return;const n=Date.now(),o=e.value??"",r=a(e);let i=Er.get(r);if(i){if(n-i.lastTs>6e4)return i.lastValue=o,i.cycles=0,i.phase="typing",void(i.lastTs=n);if(i.lastTs=n,"typing"===i.phase&&i.lastValue.length-o.length>=3)i.phase="deleted";else if("deleted"===i.phase&&o.length>i.lastValue.length&&(i.cycles++,i.phase="typing",i.cycles>=2)){const t=f(e);return I({t:"sig",ts:n,d:{s:"input_correction",el:r,...t?{el_label:t}:{},cycles:i.cycles,field_type:$r(e)}}),void Er.delete(r)}i.lastValue=o}else Er.set(r,{lastValue:o,cycles:0,phase:"typing",lastTs:n})});function $r(t){return"TEXTAREA"===t.tagName?"textarea":t.type?.toLowerCase()||"text"}var Ur=null,Nr=2e3,Rr=[],Cr=new Map,Lr=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,Rr))return;if(!(t=>{if(/^(A|BUTTON|SELECT)$/.test(t.tagName))return!0;const e=t.getAttribute("role")??"";if(/^(button|link|tab|menuitem|option|checkbox|radio)$/.test(e))return!0;try{const e=window.getComputedStyle(t);return"pointer"===e.cursor&&"none"!==e.pointerEvents}catch{return!1}})(e))return;const n=a(e);if(Ur?.selector===n)return;Br();const o=Date.now();if(o-(Cr.get(n)??0)<3e4)return;const r=o,i=setTimeout(()=>{const t=Date.now(),o=f(e);Cr.set(n,t),Ur=null,I({t:"sig",ts:t,d:{s:"hover_dwell",el:n,...o?{el_label:o}:{},dwell_ms:Math.round(t-r)}})},Nr);Ur={el:e,selector:n,startTs:r,timer:i}}),jr=e(t=>{if(!Ur)return;const e=t.target;if(e!==Ur.el&&!Ur.el.contains(e))return;const n=t.relatedTarget;n&&Ur.el.contains(n)||Br()}),Ir=e(Br);function Br(){Ur&&(clearTimeout(Ur.timer),Ur=null)}var Pr=0,zr=0,qr=null,Xr=t(e=>{if(e.clientY>20)return;const n=Date.now();n-Pr<3e3||n-zr<6e4||(qr&&clearTimeout(qr),qr=setTimeout(t(()=>{const t=Date.now();zr=t,qr=null,I({t:"sig",ts:t,d:{s:"exit_intent",method:"top_chrome",time_on_page_ms:Math.round(t-Pr)}})}),500))}),Fr=null,Jr=null,Zr=null,Hr=0;function Vr(t,e,n){return t<=e?"good":t<=n?"needs_improvement":"poor"}function Wr(){if(Zr){if(Zr.disconnect(),Zr=null,Hr>0){const t=Math.round(1e3*Hr)/1e3;I({t:"sig",ts:Date.now(),d:{s:"cls",value:t,rating:Vr(Hr,.1,.25)}})}Hr=0}}var Yr=[],Gr=e(t=>{const e=t.target;if(!e||!(t=>{if("TEXTAREA"===t.tagName)return!0;if("INPUT"===t.tagName){const e=t.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(e)}return!1})(e))return;if(p(e,Yr))return;const n=e.value??"";setTimeout(()=>{if((e.value??"")!==n)return;const t=a(e),o=f(e);I({t:"sig",ts:Date.now(),d:{s:"paste_blocked",el:t,...o?{el_label:o}:{},field_type:Kr(e)}})},100)});function Kr(t){return"TEXTAREA"===t.tagName?"textarea":t.type?.toLowerCase()||"text"}var Qr=!1,ti=null,ei=null;function ni(e){if(Qr)return;if(!e.key)return;if(e.key.startsWith("fd_sec_"))return;if(!e.key.startsWith("fd_pub_"))return;if(!1!==e.respectDoNotTrack&&("1"===navigator.doNotTrack||navigator.globalPrivacyControl))return void(ei=e);if(void 0!==e.sampleRate&&e.sampleRate<1&&Math.random()>e.sampleRate)return void(ei=e);ei=e,Qr=!0;const r=(t=>{if(t)return i();const e=(()=>{const t=document.cookie.match(new RegExp("(?:^|; )_fd_s=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null})();if(e&&o.test(e))return e;const r=i();return c(n,r,30),r})(e.cookieless??!1),s=(t=>{if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}})(e.endpoint)??"https://api.flusterduck.com/v1/ingest",a=Z(location.pathname,e.pageRules??[]),u="metadata"===(l=e.domMode)||"snapshot"===l?l:"off";var l;((t,e,n,o,r)=>{var i;M=t,D=Object.assign(Object.create(null),e),x={domMode:(i=r?.domMode,"metadata"===i||"snapshot"===i?i:"off"),compression:J(r?.compression)},k=Math.max(500,Math.min(n??7e3,1e4)),T=Math.max(1,Math.min(o??50,100)),document.addEventListener("visibilitychange",L),window.addEventListener("pagehide",j)})(s,{sid:r,key:e.key,url:location.origin+location.pathname,page:a,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:u,compression:e.compression});const d=ui(location.pathname,e.ignorePages??[]);d&&$(!0);const f=document.referrer;let p="";if(f)try{p=new URL(f).origin+new URL(f).pathname}catch{p=""}d||I({t:"pv",ts:Date.now(),d:{ref:p}});const h=e.ignoreElements??[],m=t=>{const n=e.signals?.[t];return!1!==n?.enabled};if(m("rageClick")&&((t,e)=>{rt||(rt=!0,G=t?.threshold??3,K=t?.windowMs??2e3,Q=[...W,...e??[]],et=Date.now(),Y=[],tt=[],nt.clear(),ot.clear(),document.addEventListener("click",it,{capture:!0,passive:!0}))})(e.signals?.rageClick,h),m("deadClick")&&(t=>{ut=t??[],document.addEventListener("mousedown",ft,{capture:!0,passive:!0}),document.addEventListener("click",pt,{capture:!0,passive:!0})})(h),m("speedFrustration")){const t=e.signals?.speedFrustration;((t,e)=>{_t=t?.delayMs??3e3,vt=e??[],document.addEventListener("click",kt,{capture:!0,passive:!0}),document.addEventListener("keydown",Tt,{capture:!0,passive:!0}),document.addEventListener("touchstart",Dt,{capture:!0,passive:!0})})(t?{delayMs:t.windowMs}:void 0,h)}if(!1!==e.trackMouse&&m("thrashCursor")){const t=e.signals?.thrashCursor;w=t?{velocityThreshold:t.threshold,windowMs:t.windowMs}:void 0,At=w?.velocityThreshold??800,Et=w?.windowMs??2e3,document.addEventListener("mousemove",Pt,{passive:!0})}var w,_;if(m("loopNav")&&(t=>{Ft=t?.windowMs??3e4})(e.signals?.loopNav),m("scrollBounce")&&(Jt=1e4,Zt=.5,window.addEventListener("scroll",Kt,{passive:!0})),!1!==e.trackForms){if(m("formHesitation")||m("formAbandon")){const n=e.signals?.formHesitation;((e,n)=>{ie=e?.pauseMs??5e3,ce=n??[],document.addEventListener("focusin",se,{capture:!0,passive:!0}),document.addEventListener("focusout",ae,{capture:!0,passive:!0}),document.addEventListener("submit",ue,{capture:!0,passive:!0}),window.addEventListener("pagehide",le),de=t(()=>{"hidden"===document.visibilityState&&fe()}),document.addEventListener("visibilitychange",de)})(n?{pauseMs:n.threshold}:void 0,h)}m("formValidationLoop")&&(t=>{cr=t??[],document.addEventListener("invalid",ar,{capture:!0,passive:!0}),document.addEventListener("input",ur,{capture:!0,passive:!0}),document.addEventListener("change",ur,{capture:!0,passive:!0}),(sr=new MutationObserver(vr)).observe(document.body,{subtree:!0,attributeFilter:["aria-invalid"],attributes:!0,attributeOldValue:!0})})(h)}if(m("errorEncounter")&&(window.addEventListener("error",_e),window.addEventListener("unhandledrejection",ve),he||(he=window.fetch,me=function(t,e){let n;try{n=he.call(this,t,e)}catch(t){throw t}return n.then(e=>{try{if(e.status>=400){const n="string"==typeof t?t:t instanceof URL?t.pathname:t.url;we.test(n)||I({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${e.status} ${e.statusText}`,ep:ye(n),status:e.status,error_category:"network",url:location.pathname}})}}catch{}return e},e=>{try{const n="string"==typeof t?t:t instanceof URL?t.href:t.url;we.test(n)||I({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:Me(e instanceof Error?e.message:"Fetch failed",200),ep:"string"==typeof t?ye(t):"",status:0,error_category:"network",url:location.pathname}})}catch{}throw e})},window.fetch=me)),("ontouchstart"in window||navigator.maxTouchPoints>0)&&(t=>{Re=t??[],document.addEventListener("touchstart",Ce,{passive:!0}),document.addEventListener("touchend",Le,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",je,{passive:!0}),window.addEventListener("orientationchange",Ie,{passive:!0})),window.visualViewport?.addEventListener("resize",Be)})(h),(m("tabThrash")||m("focusTrap")||m("keyboardNavFrustration"))&&(t=>{He=t??[],document.addEventListener("keydown",Ve,{capture:!0,passive:!0})})(h),m("scrollHijack")&&(window.addEventListener("wheel",cn,{passive:!0}),window.addEventListener("touchmove",sn,{passive:!0}),window.addEventListener("scroll",rn,{passive:!0})),m("scrollDepthAbandon")&&(window.addEventListener("scroll",fn,{passive:!0}),hn=t(mn),window.addEventListener("pagehide",hn),pn=t(()=>{"hidden"===document.visibilityState&&mn()}),document.addEventListener("visibilitychange",pn)),m("advancedHeuristics")&&(Tn||(Tn=!0,yn=Sn(),En(),document.addEventListener("mouseenter",Dn,!0),document.addEventListener("mouseleave",Dn,!0),document.addEventListener("click",An,{capture:!0,passive:!0}),document.addEventListener("keydown",An,{capture:!0,passive:!0}),document.addEventListener("scroll",An,{passive:!0}),window.addEventListener("resize",xn,{passive:!0}))),m("helpHunt")&&(t=>{Rn=t??[],document.addEventListener("click",Cn,{capture:!0,passive:!0})})(h),m("closeClick")&&(t=>{qn=t??[],document.addEventListener("click",Xn,{capture:!0,passive:!0})})(h),m("closeClickReversal")&&(t=>{Hn=t??[],document.addEventListener("click",Vn,{capture:!0,passive:!0}),document.addEventListener("keydown",Wn,{capture:!0,passive:!0}),window.addEventListener("popstate",Yn)})(h),m("filterSpiral")&&(t=>{eo=t??[],document.addEventListener("change",no,{capture:!0,passive:!0}),document.addEventListener("click",oo,{capture:!0,passive:!0})})(h),m("copyFrustration")&&document.addEventListener("copy",co,{capture:!0,passive:!0}),m("textSelectFrustration")&&(uo=t(po),lo=t(fo),document.addEventListener("selectionchange",uo),document.addEventListener("copy",lo,{capture:!0,passive:!0}),document.addEventListener("cut",lo,{capture:!0,passive:!0})),m("deadClickTrapZone")&&(t=>{tr=t??[],document.addEventListener("mousedown",nr,{capture:!0,passive:!0}),document.addEventListener("click",or,{capture:!0,passive:!0})})(h),(t=>{vo=[],go=null,bo=!0,yo=new Map,ko=t??"",(()=>{try{const t=sessionStorage.getItem(mo);if(t){const e=JSON.parse(t);Mo={totalSignals:"number"==typeof e.totalSignals?e.totalSignals:0,pagesWithFrustration:"number"==typeof e.pagesWithFrustration?e.pagesWithFrustration:0}}}catch{}})(),O($o),To=()=>Eo("popstate"),Do=()=>Eo("hashchange"),xo=()=>{"hidden"===document.visibilityState&&Eo("visibilitychange")},Ao=()=>Eo("pagehide"),window.addEventListener("popstate",To),window.addEventListener("hashchange",Do),document.addEventListener("visibilitychange",xo),window.addEventListener("pagehide",Ao)})(a),m("navigationConfusion")&&(No=[],Co=!1,Ro=location.pathname+location.search+location.hash,window.addEventListener("popstate",Lo),window.addEventListener("hashchange",jo)),m("scrollToClickConfusion")&&(Bo=[],zo="none",qo=0,Xo=0,Fo=0,Jo=!1,Po=!1,window.addEventListener("scroll",Zo,{passive:!0}),window.addEventListener("click",Ho,{capture:!0})),m("elementImpression")&&(_=e.elementImpressionSelectors,yr=_?.length?_:["[data-fd-impression]"],Mr=Date.now(),"undefined"!=typeof IntersectionObserver&&(gr=new IntersectionObserver(t(Ar),{threshold:[0,.5,1]}),Tr(),(br=new MutationObserver(t(xr))).observe(document.body,{childList:!0,subtree:!0}))),!1!==e.trackForms&&m("inputCorrection")&&(t=>{Sr=t??[],document.addEventListener("input",Or,{capture:!0,passive:!0})})(h),!1!==e.trackForms&&m("pasteBlocked")&&(t=>{Yr=t??[],document.addEventListener("paste",Gr,{capture:!0,passive:!0})})(h),m("hoverDwell")){const t=e.signals?.hoverDwell;((t,e)=>{Nr=t?.dwellMs??2e3,Rr=e??[],document.addEventListener("mouseover",Lr,{passive:!0}),document.addEventListener("mouseout",jr,{passive:!0}),document.addEventListener("click",Ir,{capture:!0,passive:!0})})(t?.threshold?{dwellMs:t.threshold}:void 0,h)}m("exitIntent")&&(Pr=Date.now(),zr=0,document.addEventListener("mouseleave",Xr)),m("performanceVitals")&&(()=>{if("undefined"!=typeof PerformanceObserver){try{(Fr=new PerformanceObserver(t(t=>{const e=t.getEntries(),n=e[e.length-1];if(!n)return;const o=Math.round(n.startTime);I({t:"sig",ts:Date.now(),d:{s:"lcp",value_ms:o,rating:Vr(o,2500,4e3)}})}))).observe({type:"largest-contentful-paint",buffered:!0})}catch{Fr=null}try{(Jr=new PerformanceObserver(t(t=>{for(const e of t.getEntries()){const t=e;if(!t.interactionId)continue;const n=Math.round(t.duration);n<200||I({t:"sig",ts:Date.now(),d:{s:"slow_interaction",value_ms:n,rating:Vr(n,200,500)}})}}))).observe({type:"event",buffered:!1,durationThreshold:200})}catch{Jr=null}try{(Zr=new PerformanceObserver(t(t=>{for(const e of t.getEntries())e.hadRecentInput||(Hr+=e.value)}))).observe({type:"layout-shift",buffered:!0})}catch{Zr=null}}})(),ti=function(t){let e=location.href;function n(){const n=location.href;n!==e&&(e=n,t(n,location.pathname))}const o=history.pushState,r=history.replaceState,i=function(...t){o.apply(this,t),n()},c=function(...t){r.apply(this,t),n()};return history.pushState=i,history.replaceState=c,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),()=>{history.pushState===i&&(history.pushState=o),history.replaceState===c&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}(t((n,o)=>{B(),Ht=[],Vt=0,Wt=0,Yt=!1,te.clear(),ee.clear(),ne.clear(),oe=null,re=0,un=0,ln=0,dn=!1,xt(),En(),kn=0,Nn=[],Pn=[],zn.clear(),Zn=null,to.clear(),io=[],so=[],ao=0,Qo.clear(),(()=>{for(const t of ir.values())pr(t);ir.clear()})(),dt.clear(),an(),Vo(),No=[],Co=!1,Ro=location.pathname+location.search+location.hash,kr.clear(),gr&&Tr(),Er.clear(),Br(),Cr.clear(),Pr=Date.now(),zr=0,qr&&(clearTimeout(qr),qr=null),(()=>{if(Wr(),"undefined"!=typeof PerformanceObserver)try{(Zr=new PerformanceObserver(t(t=>{for(const e of t.getEntries())e.hadRecentInput||(Hr+=e.value)}))).observe({type:"layout-shift",buffered:!1})}catch{Zr=null}})(),Io(o),(t=>{ko=t})(o);const r=Z(o,e.pageRules??[]),i=ui(o,e.ignorePages??[]);$(i),P({page:r,url:n}),(t=>{const e=Date.now(),n=t.indexOf("#"),o=-1===n?t:t.slice(0,n),r=-1===n?"":t.slice(n);for(;qt.length&&e-qt[0].ts>Ft;)qt.shift();for(;Xt.length&&e-Xt[0].ts>Ft;)Xt.shift();if(qt.length>=100&&(qt=qt.slice(-50)),Xt.length>=100&&(Xt=Xt.slice(-50)),qt.push({path:t,ts:e}),r){Xt.push({path:t,ts:e});const n=Xt.filter(t=>{const e=t.path.indexOf("#");return(-1===e?t.path:t.path.slice(0,e))===o}),r=new Set(n.map(t=>{const e=t.path.indexOf("#");return-1===e?"":t.path.slice(e)}));if(r.size>=3&&n.length>r.size){const t=n.slice(-5).map(t=>t.path);return I({t:"sig",ts:e,d:{s:"loop_nav",loop_type:"hash",pages:Array.from(r).map(t=>o+t),path_sequence:t}}),void(Xt=Xt.filter(t=>{const e=t.path.indexOf("#");return(-1===e?t.path:t.path.slice(0,e))!==o}))}}if(qt.length<4)return;let i=!1;const c=[];for(let e=0;e<qt.length-1;e++)if(qt[e].path===t){const t=qt.slice(e,qt.length),n=new Set(t.map(t=>t.path));if(n.size>=2){c.push(...Array.from(n)),i=!0;break}}i&&(I({t:"sig",ts:e,d:{s:"loop_nav",loop_type:"path",pages:c,path_sequence:qt.slice(-5).map(t=>t.path)}}),qt=[{path:t,ts:e}],Xt=Xt.filter(t=>{const e=t.path.indexOf("#");return(-1===e?t.path:t.path.slice(0,e))!==o}))})(o),i||I({t:"pv",ts:Date.now(),d:{ref:""}})}))}function oi(t,e){if(!Qr)return;if("string"!=typeof t||!t||t.length>128)return;let n;try{n=JSON.stringify(e?.metadata??{})}catch{return}if(n.length>2048)return;const o=JSON.parse(n);I({t:"sig",ts:Date.now(),d:{s:t.slice(0,128),el:"string"==typeof e?.element?e.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(e?.weight??15,100))}})}function ri(t,e={}){if(!Qr)return;if("string"!=typeof t||!/^[a-z0-9_.-]{1,120}$/i.test(t))return;let n;try{n=JSON.stringify(e??{})}catch{return}n.length>2048||I({t:"custom_signal",ts:Date.now(),d:{business_event:t.slice(0,120),meta:JSON.parse(n)}})}function ii(t){if(!Qr)return;if(!t||"object"!=typeof t)return;const e=Object.create(null);let n=0;for(const o of Object.keys(t)){if(n>=20)break;"__proto__"!==o&&"constructor"!==o&&"prototype"!==o&&(e[o.slice(0,64)]=String(t[o]).slice(0,256),n++)}P({segment:e})}function ci(t){t&&ei&&!Qr?ni(ei):t||(ai(),r())}function si(){ai(),r()}function ai(){Qr&&(rt&&(rt=!1,document.removeEventListener("click",it,{capture:!0,passive:!0}),Y=[],tt=[],nt.clear(),ot.clear()),document.removeEventListener("mousedown",ft,{capture:!0}),document.removeEventListener("click",pt,{capture:!0}),lt=null,dt.clear(),document.removeEventListener("click",kt,{capture:!0}),document.removeEventListener("keydown",Tt,{capture:!0}),document.removeEventListener("touchstart",Dt,{capture:!0}),xt(),document.removeEventListener("mousemove",Pt),Bt&&clearTimeout(Bt),zt(),qt=[],Xt=[],window.removeEventListener("scroll",Kt),Ht=[],Yt=!1,document.removeEventListener("focusin",se,{capture:!0}),document.removeEventListener("focusout",ae,{capture:!0}),document.removeEventListener("submit",ue,{capture:!0}),window.removeEventListener("pagehide",le),de&&(document.removeEventListener("visibilitychange",de),de=null),te.clear(),ee.clear(),ne.clear(),oe=null,window.removeEventListener("error",_e),window.removeEventListener("unhandledrejection",ve),he&&me&&window.fetch===me&&(window.fetch=he),he=null,me=null,document.removeEventListener("touchstart",Ce),document.removeEventListener("touchend",Le),document.removeEventListener("gesturechange",je),window.removeEventListener("orientationchange",Ie),window.visualViewport?.removeEventListener("resize",Be),De=null,xe=0,Ae=1,Ee=0,Se=0,Oe=0,$e=0,Ue=0,Ne=null,document.removeEventListener("keydown",Ve,{capture:!0}),ze=[],Ze=[],qe=null,Xe=0,Fe=0,Je="",He=[],window.removeEventListener("wheel",cn),window.removeEventListener("touchmove",sn),window.removeEventListener("scroll",rn),an(),window.removeEventListener("scroll",fn),hn&&(window.removeEventListener("pagehide",hn),hn=null),pn&&(document.removeEventListener("visibilitychange",pn),pn=null),un=0,ln=0,dn=!1,Tn&&(Tn=!1,document.removeEventListener("mouseenter",Dn,!0),document.removeEventListener("mouseleave",Dn,!0),document.removeEventListener("click",An,{capture:!0}),document.removeEventListener("keydown",An,{capture:!0}),document.removeEventListener("scroll",An),window.removeEventListener("resize",xn),On(),wn="",_n=0,vn=0,bn=0,gn=0,kn=0),document.removeEventListener("click",Cn,{capture:!0}),Nn=[],document.removeEventListener("click",Xn,{capture:!0}),Pn=[],zn.clear(),document.removeEventListener("click",Vn,{capture:!0}),document.removeEventListener("keydown",Wn,{capture:!0}),window.removeEventListener("popstate",Yn),Zn=null,document.removeEventListener("change",no,{capture:!0}),document.removeEventListener("click",oo,{capture:!0}),to.clear(),document.removeEventListener("copy",co,{capture:!0}),io=[],uo&&(document.removeEventListener("selectionchange",uo),uo=null),lo&&(document.removeEventListener("copy",lo,{capture:!0}),document.removeEventListener("cut",lo,{capture:!0}),lo=null),so=[],ao=0,document.removeEventListener("mousedown",nr,{capture:!0}),document.removeEventListener("click",or,{capture:!0}),er=null,Qo.clear(),(()=>{document.removeEventListener("invalid",ar,{capture:!0}),document.removeEventListener("input",ur,{capture:!0}),document.removeEventListener("change",ur,{capture:!0}),sr&&(sr.disconnect(),sr=null);for(const t of ir.values())pr(t);ir.clear()})(),bo=!1,vo=[],go=null,yo=new Map,O(null),To&&(window.removeEventListener("popstate",To),To=null),Do&&(window.removeEventListener("hashchange",Do),Do=null),xo&&(document.removeEventListener("visibilitychange",xo),xo=null),Ao&&(window.removeEventListener("pagehide",Ao),Ao=null),window.removeEventListener("popstate",Lo),window.removeEventListener("hashchange",jo),No=[],Co=!1,Ro="",window.removeEventListener("scroll",Zo),window.removeEventListener("click",Ho,{capture:!0}),Vo(),gr&&(gr.disconnect(),gr=null),br&&(br.disconnect(),br=null),kr.clear(),document.removeEventListener("input",Or,{capture:!0}),Er.clear(),document.removeEventListener("mouseover",Lr),document.removeEventListener("mouseout",jr),document.removeEventListener("click",Ir,{capture:!0}),Br(),Cr.clear(),document.removeEventListener("mouseleave",Xr),qr&&(clearTimeout(qr),qr=null),Fr&&(Fr.disconnect(),Fr=null),Jr&&(Jr.disconnect(),Jr=null),Wr(),document.removeEventListener("paste",Gr,{capture:!0}),B(),S=!1,document.removeEventListener("visibilitychange",L),window.removeEventListener("pagehide",j),y&&(clearTimeout(y),y=null),ti&&(ti(),ti=null),Qr=!1)}function ui(t,e){for(const n of e)if(n)if(n.endsWith("*")){if(t.startsWith(n.slice(0,-1)))return!0}else if(n.startsWith("*")){if(t.endsWith(n.slice(1)))return!0}else if(t===n)return!0;return!1}function li(t){if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}}(()=>{try{const t=window;if(t.flusterduck)return;const e=document.currentScript;if(!e)return;const n=e.getAttribute("data-key");if(!n)return;const o={key:n,environment:e.getAttribute("data-env")||void 0,endpoint:li(e.getAttribute("data-endpoint")),debug:"true"===e.getAttribute("data-debug"),cookieless:"true"===e.getAttribute("data-cookieless"),respectDoNotTrack:"false"!==e.getAttribute("data-dnt")},r=e.getAttribute("data-dom-mode");"metadata"!==r&&"snapshot"!==r||(o.domMode=r),"off"===e.getAttribute("data-compression")&&(o.compression="off");const i=e.getAttribute("data-sample");if(i){const t=parseFloat(i);isNaN(t)||(o.sampleRate=Math.max(0,Math.min(t,1)))}const c=e.getAttribute("data-segment");if(c&&c.length<2048)try{const t=JSON.parse(c);if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.create(null);for(const n of Object.keys(t))"__proto__"!==n&&"constructor"!==n&&"prototype"!==n&&(e[n]=String(t[n]));o.segment=e}}catch{}ni(o),t.flusterduck=Object.freeze({init:ni,signal:oi,track:ri,identify:ii,setConsent:ci,optOut:si,destroy:ai})}catch{}})()})();
1
+ "use strict";(()=>{function t(t){return(...e)=>{try{return t(...e)}catch{}}}function e(t){return e=>{try{t(e)}catch{}}}var n="_fd_s",o=/^[0-9a-f]{32}$/;function r(){s(n,"",-1)}function i(){const t=new Uint8Array(16);crypto.getRandomValues(t);let e="";for(const n of t)e+=n.toString(16).padStart(2,"0");return e}function s(t,e,n){const o=new Date;o.setTime(o.getTime()+864e5*n);const r="https:"===location.protocol?";Secure":"";document.cookie=`${t}=${encodeURIComponent(e)};path=/;expires=${o.toUTCString()};SameSite=Lax${r}`}var c=/^[:\d]|--|^(ember|react|ng-|__)/;function a(t){if(!t||t===document.documentElement)return"html";const e=t.getAttribute("data-fd");if(e)return`[data-fd="${u(e)}"]`;if(t.id&&!c.test(t.id)&&t.id.length<64)return"#"+u(t.id);const n=[];let o=t,r=0;for(;o&&o!==document.body&&r<5;){let t=o.tagName.toLowerCase();const e=o.getAttribute("name"),i=o.getAttribute("role"),s=o.getAttribute("type");e&&e.length<64?t+=`[name="${u(e)}"]`:i?t+=`[role="${u(i)}"]`:!s||"input"!==t&&"button"!==t||(t+=`[type="${u(s)}"]`);const c=o.parentElement;if(c){const e=c.children;let n=0,r=0;for(let t=0;t<e.length;t++){const i=e[t];i&&i.tagName===o.tagName&&(n++,i===o&&(r=n))}n>1&&(t+=`:nth-of-type(${r})`)}n.unshift(t);const a=n.join(" > ");try{if(1===document.querySelectorAll(a).length)return a}catch(t){}o=c,r++}return n.join(" > ")}function u(t){return"undefined"!=typeof CSS&&CSS.escape?CSS.escape(t):t.replace(/([^\w-])/g,"\\$1")}var l=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,f=/^(INPUT|TEXTAREA|SELECT)$/;function d(t){try{const e=t.getAttribute("aria-label");if(e)return e.trim().slice(0,60);if(!f.test(t.tagName)){const e=(t.textContent??"").trim().replace(/\s+/g," ").slice(0,60);if(e&&!l.test(e))return e}const n=t.getAttribute("placeholder");if(n)return n.trim().slice(0,60);const o=t.getAttribute("title");if(o)return o.trim().slice(0,60);const r=t.getAttribute("alt");return r?r.trim().slice(0,60):""}catch{return""}}function p(t,e){if(t.hasAttribute("data-fd-ignore"))return!0;if(t.closest("[data-fd-ignore]"))return!0;for(const n of e)try{if(t.matches(n)||t.closest(n))return!0}catch(t){}return!1}function h(t,e){return t&&e.includes(t)?t:null}function w(t){const e=t.tagName.toLowerCase();if("input"!==e&&"button"!==e)return null;const n=t.getAttribute("type");return n&&/^[a-z0-9_-]{1,32}$/i.test(n)?n.toLowerCase():null}function m(t){return t.top<window.innerHeight&&t.bottom>0&&t.left<window.innerWidth&&t.right>0}function _(t){if(/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/.test(t.tagName))return!0;const e=t.getAttribute("role");return!(!e||!/^(button|link|tab|menuitem|checkbox|radio)$/.test(e))}var v=6e4,g="application/json",y=[],b=null,M="",k=7e3,T=50,D=null,x={domMode:"off",compression:"auto"},A=!1,E=null,S=!1,O=new WeakMap;function $(t){E=t}var U=new Set;function N(t){return U.add(t),()=>{U.delete(t)}}function R(t){S=t}var C=new Set(["sid","key","url","page","ua","vw","vh","segment","environment"]),j=new Set(["click","move","scroll","keyboard","form_focus","form_blur","form_submit","touch","navigation","error","signal","pageview","custom_signal","performance","visibility","sdk_error"]),L=new Set(["value","text","label","email","name","phone","address","password","token","secret","cookie","session","jwt","auth","credential","card","cc","cvv","ssn"]),I=/(?:[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\b(?:\d[ -]*?){13,19}\b)/i,B=e(()=>{"hidden"===document.visibilityState&&q()}),P=t(()=>q());function z(t){S||y.length>=100||((t=>{if("sig"!==t.t||!U.size)return;const e=t.d??{},n="string"==typeof e.s?e.s:"";if(!n)return;const o={name:n,element:"string"==typeof e.el?e.el:"",weight:"number"==typeof e.w?e.w:0,meta:e.meta&&"object"==typeof e.meta?e.meta:{},ts:t.ts};for(const t of U)try{t(o)}catch{}})(t),(t=>{if(!E||"sig"!==t.t)return;const e=V(t.d?.s,t.d?.signal_type,t.d?.name);if(e)try{E(e.slice(0,128),t.ts)}catch{}})(t),y.push(t),y.length>=T?q():b||(b=setTimeout(q,k)))}function q(){(async()=>{if(A)return;if(!y.length||!D)return;A=!0,b&&(clearTimeout(b),b=null);const t=y;y=[];const e={v:1,sid:D.sid,key:D.key,url:D.url,page:D.page,ts:Date.now(),ua:D.ua,vw:D.vw,vh:D.vh,environment:D.environment,...D.segment?{segment:D.segment}:{},dom_mode:x.domMode},n=[];let o={source:[],events:[]};try{for(const r of t){const t=Z(r,D.page,x.domMode),i=[...o.events,t];JSON.stringify({...e,events:i}).length>v?o.events.length>0?(n.push(o),o={source:[r],events:[t]}):(JSON.stringify({...e,events:[t]}).length<=v&&n.push({source:[r],events:[t]}),o={source:[],events:[]}):(o.source.push(r),o.events=i)}o.events.length>0&&n.push(o);for(const t of n)J({...e,events:t.events}).then(e=>{e||X(t.source)}).catch(()=>X(t.source))}catch(t){}finally{A=!1}})()}function X(t){const e=t.filter(t=>{const e=O.get(t)??0;return!(e>=3||(O.set(t,e+1),0))});if(!e.length)return;const n=[...e,...y];y=n.length>100?n.slice(-100):n,b||(b=setTimeout(q,k))}function F(t){if(D)for(const e of Object.keys(t))C.has(e)&&(D[e]=t[e])}async function J(t){const e=JSON.stringify(t),n=await(async(t,e)=>{const n=(new TextEncoder).encode(t);if(n.byteLength>v)return null;if("off"!==e){const e=await(async t=>{const e=globalThis.CompressionStream;if("function"!=typeof e)return null;try{const n=(t=>{const e=(new TextEncoder).encode(t),n=new Blob([e],{type:g});if("function"==typeof n.stream)return n.stream();const o=globalThis.ReadableStream;return"function"!=typeof o?null:new o({start(t){t.enqueue(e),t.close()}})})(t);if(!n)return null;const o=new e("gzip"),r=n.pipeThrough(o).getReader(),i=[];let s=0;for(;;){const t=await r.read();if(t.done)break;if(s+=t.value.byteLength,s>v)return null;const e=new Uint8Array(t.value.byteLength);e.set(t.value),i.push(e)}const c=new Uint8Array(s);let a=0;for(const t of i)c.set(t,a),a+=t.byteLength;return c.buffer}catch{return null}})(t);if(e&&e.byteLength<=v)return{beaconBody:new Blob([e],{type:"application/json; encoding=gzip"}),fetchBody:new Uint8Array(e),headers:{"Content-Type":g,"Content-Encoding":"gzip"}}}return{beaconBody:new Blob([n],{type:g}),fetchBody:t,headers:{"Content-Type":g}}})(e,x.compression);return!n||(async(t,e=M)=>{if(!e)return!0;try{if(navigator.sendBeacon&&navigator.sendBeacon(e,t.beaconBody))return!0}catch{}try{return await fetch(e,{method:"POST",body:t.fetchBody,headers:t.headers,keepalive:!0}),!0}catch{return!1}})(n)}function Z(t,e,n){const o=t.d??{},r=(t=>"pv"===t?"pageview":"sig"===t?"signal":j.has(t)?t:"custom_signal")(t.t),i={type:r,ts:t.ts,page:"string"==typeof o.page?o.page.slice(0,2048):e},s=V(o.el,o.element,o.target);if("signal"===r){i.signal_type=V(o.s,o.signal_type,o.name)?.slice(0,128),s&&(i.element=s.slice(0,2048));const t=s?((t,e)=>{if("off"===e)return null;try{const n=document.querySelector(t);return n?((t,e)=>{if("off"===e)return null;if("metadata"===e)return(t=>({mode:"metadata",selector:a(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),attributes:{disabled:!0===t.disabled,required:!0===t.required,ariaDisabled:"true"===t.getAttribute("aria-disabled"),ariaExpanded:h(t.getAttribute("aria-expanded"),["true","false"]),ariaInvalid:h(t.getAttribute("aria-invalid"),["true","false","grammar","spelling"]),type:w(t)}}))(t);const n=(t=>{try{const e=t.getBoundingClientRect(),n=getComputedStyle(t),o=t.parentElement,r=[];if(o)for(let e=0;e<o.children.length&&r.length<6;e++){const n=o.children[e];if(!n||n===t)continue;const i=n.getBoundingClientRect();r.push({selector:a(n),tag:n.tagName.toLowerCase(),box:{x:Math.round(i.x),y:Math.round(i.y),w:Math.round(i.width),h:Math.round(i.height)},interactive:_(n)})}const i=[];try{const e=t.getAnimations();for(const t of e)"animationName"in t&&i.push(t.animationName)}catch{}return{selector:a(t),tag:t.tagName.toLowerCase(),role:t.getAttribute("role"),parent:o?a(o):"",box:{x:Math.round(e.x),y:Math.round(e.y),w:Math.round(e.width),h:Math.round(e.height)},styles:{opacity:n.opacity,cursor:n.cursor,pointerEvents:n.pointerEvents,display:n.display,visibility:n.visibility,disabled:!0===t.disabled},inView:m(e),animations:i,siblings:r}}catch{return null}})(t);return n?{mode:"snapshot",...n}:null})(n,e):null}catch{return null}})(s,n):null;t&&(i.dom=t)}const c=(t=>{const e=Object.create(null);for(const n of Object.keys(t)){if(["s","signal_type","name","el","element","target","dom","page","meta"].includes(n))continue;const o=H(t[n],n);void 0!==o&&(e[n.slice(0,64)]=o)}if(t.meta&&"object"==typeof t.meta&&!Array.isArray(t.meta)){const n=H(t.meta,"meta");n&&"object"==typeof n&&!Array.isArray(n)&&Object.assign(e,n)}return e})(o);return Object.keys(c).length&&(i.metadata=c),i}function H(t,e="",n=0){if(!(n>4||(t=>t.replace(/([a-z])([A-Z])/g,"$1\0$2").toLowerCase().split(/[\x00_\-.\s]+/).some(t=>L.has(t)))(e))){if(null===t||"boolean"==typeof t)return t;if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t){if(I.test(t))return;return t.slice(0,500)}if(Array.isArray(t))return t.slice(0,20).map(t=>H(t,e,n+1)).filter(t=>void 0!==t);if("object"==typeof t){const e=Object.create(null);for(const o of Object.keys(t).slice(0,40)){if("__proto__"===o||"constructor"===o||"prototype"===o)continue;const r=H(t[o],o,n+1);void 0!==r&&(e[o.slice(0,64)]=r)}return e}}}function V(...t){for(const e of t)if("string"==typeof e&&e)return e}function W(t){return"off"===t?"off":"auto"}function Y(t,e){for(const n of e){const e=K(n.pattern);if(e&&e.test(t))return n.label}return(t=>t.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"))(t)}var G=/^[a-zA-Z0-9/:._*\-]+$/;function K(t){if(t.length>200)return null;if(!G.test(t))return null;const e=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/:\w+/g,"[^/]+");try{return new RegExp("^"+e+"$")}catch{return null}}var Q=[".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"]'],tt=[],et=3,nt=2e3,ot=24,rt=[],it=[],st=0,ct=new Map,at=new Map,ut=!1,lt=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,rt))return;if((t=>{const e=t.tagName;return"VIDEO"===e||"AUDIO"===e||(!!t.hasAttribute("ondblclick")||(!!t.hasAttribute("data-dbl")||"spinbutton"===t.getAttribute("role")))})(e))return;const n=Date.now(),o=t.clientX,r=t.clientY;for(;tt.length&&n-tt[0].t>nt;)tt.shift();tt.push({t:n,x:o,y:r});const i=it.length>=3?2:et;if(tt.length<i)return;const s=tt.slice(-i);for(let t=0;t<s.length-1;t++)for(let e=t+1;e<s.length;e++){const n=s[t],o=s[e],r=o.x-n.x,i=o.y-n.y;if(r*r+i*i>ot*ot)return}const c=(s[s.length-1].t-s[0].t)/1e3,u=c>0?s.length/c:s.length,l=Math.round(100*Math.min(1,(s.length-i)/i+u/10))/100,f=((t,e,n)=>{const o=Math.min(4,(t.length-e)/5*4),r=Math.min(4,n/10*4);let i=2;if(t.length>=2){let e=0,n=0;for(let o=0;o<t.length-1;o++)for(let r=o+1;r<t.length;r++){const i=t[o],s=t[r],c=s.x-i.x,a=s.y-i.y;e+=Math.sqrt(c*c+a*a),n++}i=Math.max(0,2-e/n/ot*2)}return Math.round(Math.min(10,Math.max(0,o+r+i)))})(s,i,u),h=a(e),w=d(e);it.push({selector:h,ts:n});const m=it.length,_=(t=>{const e=(t-st)/6e4;return e<=0?0:Math.round(it.length/e*10)/10})(n),v=ct.get(h)??0,g=v+1,y=at.get(h)??0,b=y>0&&n-y<1e4;ct.set(h,g),at.set(h,n);const M=v>=1,k=(()=>{try{const t=e.getBoundingClientRect();if(0===t.width&&0===t.height)return null;const n=s.reduce((t,e)=>t+e.x,0)/s.length,o=s.reduce((t,e)=>t+e.y,0)/s.length,r=t.top+t.height/2;return{click_dx:Math.round(n-(t.left+t.width/2)),click_dy:Math.round(o-r),el_w:Math.round(t.width),el_h:Math.round(t.height)}}catch{return null}})();z({t:"sig",ts:n,d:{s:"rage_click",el:h,...w?{el_label:w}:{},cnt:s.length,vel:Math.round(10*u)/10,intensity:l,quality:f,burst_seq:m,burst_rate_per_min:_,repeated_target:M,hot_repeat:b,...k??{}}}),M&&z({t:"sig",ts:n,d:{s:"rage_click_repeat_target",el:h,...w?{el_label:w}:{},total_hits:g,burst_count:g,burst_seq:m}}),tt=tt.slice(-(i-1))});function ft(){ut&&(ut=!1,document.removeEventListener("click",lt,{capture:!0,passive:!0}),tt=[],it=[],ct.clear(),at.clear())}var dt=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,pt=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,ht=/^(A|BUTTON|LABEL)$/,wt=[],mt=null,_t=new Map,vt=e(t=>{mt={x:t.clientX,y:t.clientY}}),gt=e(t=>{if(0!==t.button)return;if(0===t.detail)return;const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,wt))return;if((()=>{const t=window.getSelection();return null!==t&&t.toString().length>0})())return;const n=(t=>{if(!mt)return!1;const e=t.clientX-mt.x,n=t.clientY-mt.y;return Math.sqrt(e*e+n*n)>5})(t);if(mt=null,n)return;if((t=>{if(dt.test(t.tagName))return!0;const e=t.getAttribute("role");if(e&&pt.test(e))return!0;if(t.hasAttribute("contenteditable"))return!0;if(t.hasAttribute("tabindex")&&"-1"!==t.getAttribute("tabindex"))return!0;if(t.hasAttribute("onclick")||t.hasAttribute("onmousedown")||t.hasAttribute("onmouseup"))return!0;const n=t.parentElement;return!(!n||!ht.test(n.tagName))||!!t.closest('a, button, [role="button"], label, [onclick]')})(e))return;const o=((t,e,n)=>{let o=t;for(let r=0;r<5&&o;r++){const r=o.parentElement;if(!r)break;const i=r.querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]');let s=null,c=1/0;for(let o=0;o<i.length;o++){const r=i[o];if(!r||r===t)continue;const a=kt(e,n,r);a<c&&(c=a,s=r)}if(s&&c<100)return s;o=r}return null})(e,t.clientX,t.clientY),r=o?Mt(t.clientX,t.clientY,o):null,i=a(e),s=(_t.get(i)??0)+1;_t.set(i,s);const c=s>=2,u=(t=>{try{return window.getComputedStyle(t).cursor.slice(0,20)}catch{return""}})(e),l=(t=>{try{const e=window.getComputedStyle(t);return"pointer"===e.cursor&&"none"!==e.pointerEvents}catch{return!1}})(e),f=d(e),h=o?d(o):"";z({t:"sig",ts:Date.now(),d:{s:"dead_click",el:i,...f?{el_label:f}:{},near:o?a(o):"",...h?{near_label:h}:{},dist:r?Math.round(r.dist):-1,...r?{click_dx:Math.round(r.dx),click_dy:Math.round(r.dy)}:{},cursor:u,...l?{looks_interactive:!0}:{},...c?{repeated:!0,repeat_cnt:s}:{}}})});function yt(){document.removeEventListener("mousedown",vt,{capture:!0}),document.removeEventListener("click",gt,{capture:!0}),mt=null,_t.clear()}function bt(){_t.clear()}function Mt(t,e,n){const o=n.getBoundingClientRect(),r=t-Math.max(o.left,Math.min(t,o.right)),i=e-Math.max(o.top,Math.min(e,o.bottom));return{dist:Math.sqrt(r*r+i*i),dx:r,dy:i}}function kt(t,e,n){return Mt(t,e,n).dist}var Tt=null,Dt=3e3,xt=[],At="click",Et=0,St=/^(A|BUTTON|INPUT|SELECT|TEXTAREA)$/,Ot=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton)$/,$t=e(t=>{const e=t.target;if(!e)return;if(p(e,xt))return;const n=e.getAttribute("role");if(!(St.test(e.tagName)||n&&Ot.test(n)))return;const o=Date.now();if(o-Et>50&&(At="click",Et=o),Tt){if(Tt.el===e||Tt.el.contains(e)){const t=o-Tt.ts;return t>=Dt&&z({t:"sig",ts:o,d:{s:"speed_frustration",el:Tt.selector,delay:t,interaction_type:At,observed_delay_ms:t}}),void jt()}jt()}const r=a(e);let i=!1;const s=new MutationObserver(t=>{for(const n of t){if("childList"===n.type&&(n.addedNodes.length>0||n.removedNodes.length>0))return i=!0,void jt();if("attributes"===n.type&&n.target instanceof Element&&(n.target===e||e.contains(n.target)||n.target.contains(e)))return i=!0,void jt()}}),c=e.parentElement||document.body;s.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-hidden","disabled"]});const u=setTimeout(()=>{!i&&Tt&&(Tt.observer.disconnect(),Tt={...Tt,timeout:null})},Dt+500);Tt={el:e,selector:r,ts:o,observer:s,timeout:u}}),Ut=e(t=>{t.target&&("Enter"!==t.key&&" "!==t.key||(At="keydown",Et=Date.now()))}),Nt=e(()=>{At="touch",Et=Date.now()});function Rt(){document.removeEventListener("click",$t,{capture:!0}),document.removeEventListener("keydown",Ut,{capture:!0}),document.removeEventListener("touchstart",Nt,{capture:!0}),jt()}function Ct(){jt()}function jt(){Tt&&(Tt.observer.disconnect(),Tt.timeout&&clearTimeout(Tt.timeout),Tt=null)}var Lt=800,It=2e3,Bt=0,Pt=0,zt=0,qt=0,Xt=0,Ft=0,Jt=0,Zt=0,Ht=[],Vt=0,Wt=null,Yt=e(t=>{const e=Date.now();e-Bt<16||(Bt=e,Wt&&clearTimeout(Wt),Wt=setTimeout(()=>Kt(),150),((t,e,n)=>{if(0===qt)return Pt=t,zt=e,qt=n,void(Zt=n);const o=(n-qt)/1e3;if(0===o)return;const r=t-Pt,i=e-zt;if(Math.abs(r)<2&&Math.abs(i)<2)return;const s=Math.sqrt(r*r+i*i),c=s/o;Ht.length>=100&&(Ht=Ht.slice(-50)),Ht.push(c),Vt+=s;const a=Math.sign(r),u=Math.sign(i);if(s>=5&&(0!==Xt&&0!==a&&a!==Xt||0!==Ft&&0!==u&&u!==Ft)&&Jt++,Xt=a||Xt,Ft=u||Ft,Pt=t,zt=e,qt=n,n-Zt>It){if(Jt>=3){const t=Ht.reduce((t,e)=>t+e,0)/Ht.length;t>=Lt&&z({t:"sig",ts:n,d:{s:"thrash_cursor",vel:Math.round(t),rev:Jt,distance_px:Math.round(Vt)}})}Kt(),Zt=n}})(t.clientX,t.clientY,e))});function Gt(){document.removeEventListener("mousemove",Yt),Wt&&clearTimeout(Wt),Kt()}function Kt(){Jt=0,Ht=[],Vt=0,Xt=0,Ft=0,qt=0,Pt=0,zt=0,Bt=0,Wt=null}var Qt=[],te=[],ee=3e4;function ne(){Qt=[],te=[]}var oe=1e4,re=.5,ie=[],se=0,ce=0,ae=!1,ue=0,le=e(()=>{ae||(ae=!0,requestAnimationFrame(()=>{ae=!1,(()=>{const t=Date.now(),e=window.scrollY;if((ue=document.documentElement.scrollHeight-window.innerHeight)<=0)return;const n=e/ue,o=e>se?"down":"up";if(t-ce<100)return void(se=e);for(;ie.length&&t-ie[0].ts>oe;)ie.shift();ie.length>=100&&(ie=ie.slice(-50)),ie.push({depth:n,ts:t,direction:o}),se=e,ce=t;let r=0,i=1,s=0,c=!1,a=0,u=0,l=0,f=1,d=0;for(let t=1;t<ie.length;t++)ie[t].direction!==ie[t-1].direction&&d++;for(let t=0;t<ie.length;t++){const e=ie[t],n=e.depth;if(n>r&&(r=n),n>=re&&(c||(a=e.ts,l=n),c=!0),c&&n<i&&(i=n,u=e.ts,f=n),c&&i<.25&&n>=re){if(u-a<200){c=!1,i=1,a=e.ts,l=n;continue}s++,c=!1,i=1}}if(s>=1){const e=Math.max(u-a,1),n=100*Math.abs(l-f),o=Math.round(n/e*1e3);z({t:"sig",ts:t,d:{s:"scroll_bounce",depth:Math.round(100*r)/100,rev:s+1,vel:o,dir_changes:d}}),ie=[]}})()}))});function fe(t){oe=t?.windowMs??1e4,re=t?.depthThreshold??.5,window.addEventListener("scroll",le,{passive:!0})}function de(){window.removeEventListener("scroll",le),ie=[],ae=!1}function pe(){ie=[],se=0,ce=0,ae=!1}var he=["textarea",'[role="textbox"]',"[contenteditable]"],we=new Map,me=new Map,_e=new Set,ve=null,ge=0,ye=5e3,be=[],Me=e(t=>{const e=t.target;if(!e||!Oe(e))return;if(p(e,be))return;if((t=>{if("TEXTAREA"===t.tagName)return!0;for(const e of he)try{if(t.matches(e))return!0}catch{return!1}return!1})(e))return;const n=Date.now();we.set(e,n),me.set(e,n);const o=e.closest("form");o&&o!==ve&&(ve=o,ge=o.querySelectorAll("input, select, textarea").length)}),ke=e(t=>{const e=t.target;if(!e||!Oe(e))return;const n=we.get(e),o=me.get(e);we.delete(e),me.delete(e);const r=Date.now();if(!(void 0!==o&&r-o<50)&&void 0!==n){const t=r-n;if(t>=ye){const n=d(e);z({t:"sig",ts:r,d:{s:"form_hesitation",el:a(e),...n?{el_label:n}:{},pause:t}})}}const i=e.getAttribute("name")||e.getAttribute("id")||a(e);(t=>"value"in t&&t.value.length>0)(e)&&_e.add(i)}),Te=e(()=>{_e.clear(),ve=null}),De=t(Se),xe=null;function Ae(){document.removeEventListener("focusin",Me,{capture:!0}),document.removeEventListener("focusout",ke,{capture:!0}),document.removeEventListener("submit",Te,{capture:!0}),window.removeEventListener("pagehide",De),xe&&(document.removeEventListener("visibilitychange",xe),xe=null),we.clear(),me.clear(),_e.clear(),ve=null}function Ee(){Se(),we.clear(),me.clear(),_e.clear(),ve=null,ge=0}function Se(){if(_e.size>0&&ve){const t=ge||_e.size,e=Math.round(_e.size/t*100)/100;z({t:"sig",ts:Date.now(),d:{s:"form_abandon",filled:_e.size,total:t,field_count:t,completion_rate:e}}),_e.clear(),ve=null}}function Oe(t){const e=t.tagName;return"INPUT"===e||"SELECT"===e||"TEXTAREA"===e}var $e=null,Ue=null,Ne=/flusterduck\.com|\/v1\/ingest/,Re=e(t=>{const e=t.message||"Unknown error";var n;z({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"js_error",msg:ze(e,200),ep:"",status:0,error_category:(n=e,Ie.test(n)?"network":"script"),url:location.pathname}})}),Ce=e(t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason??"");z({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"unhandled_rejection",msg:ze(e,200),ep:"",status:0,error_category:Be(t.reason),url:location.pathname}})});function je(){window.addEventListener("error",Re),window.addEventListener("unhandledrejection",Ce),$e||($e=window.fetch,Ue=function(t,e){let n;try{n=$e.call(this,t,e)}catch(t){throw t}return n.then(e=>{try{if(e.status>=400){const n="string"==typeof t?t:t instanceof URL?t.pathname:t.url;Ne.test(n)||z({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:`${e.status} ${e.statusText}`,ep:Pe(n),status:e.status,error_category:"network",url:location.pathname}})}}catch{}return e},e=>{try{const n="string"==typeof t?t:t instanceof URL?t.href:t.url;Ne.test(n)||z({t:"sig",ts:Date.now(),d:{s:"error_encounter",type:"network_error",msg:ze(e instanceof Error?e.message:"Fetch failed",200),ep:"string"==typeof t?Pe(t):"",status:0,error_category:"network",url:location.pathname}})}catch{}throw e})},window.fetch=Ue)}function Le(){window.removeEventListener("error",Re),window.removeEventListener("unhandledrejection",Ce),$e&&Ue&&window.fetch===Ue&&(window.fetch=$e),$e=null,Ue=null}var Ie=/fetch|network|cors|timeout/i;function Be(t){if(t instanceof TypeError&&Ie.test(t.message))return"network";if("undefined"!=typeof Response&&t instanceof Response)return"network";const e=t instanceof Error?t.message:String(t??"");return Ie.test(e)?"network":"unhandled_promise"}function Pe(t){try{return new URL(t,location.origin).pathname}catch{const e=t.indexOf("?"),n=t.indexOf("#"),o=Math.min(e>=0?e:t.length,n>=0?n:t.length);return t.slice(0,o)||"/"}}function ze(t,e){let n=t.length>e?t.slice(0,e):t;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,t=>{try{return new URL(t).origin+new URL(t).pathname}catch{return"[URL]"}}),n}var qe=[".carousel",".slider",".swiper","[data-swipeable]",".drawer"],Xe=['[class*="map"]',"canvas",".gallery","[data-zoom]"],Fe=null,Je=0,Ze=1,He=0,Ve=0,We=0,Ye=0,Ge=0,Ke=null,Qe=[],tn=e(t=>{const e=t.touches[0];1===t.touches.length&&e?(Fe={x:e.clientX,y:e.clientY,ts:Date.now()},Je=0):2===t.touches.length&&(Je=cn(t.touches),Fe=null)}),en=e(t=>{if(Je>0){const e=t.touches.length>=2?cn(t.touches):(()=>{const e=t.changedTouches[0],n=t.changedTouches[1];if(!e||!n)return 0;const o=e.clientX-n.clientX,r=e.clientY-n.clientY;return Math.sqrt(o*o+r*r)})();e>0&&(Ze=Math.round(e/Je*100)/100),Je=0}if(!Fe)return;if(1!==t.changedTouches.length)return;const e=t.changedTouches[0];if(!e)return;const n=e.clientX-Fe.x,o=e.clientY-Fe.y,r=Date.now()-Fe.ts,i=document.elementFromPoint(e.clientX,e.clientY);Math.abs(n)<10&&Math.abs(o)<10&&r<300&&i&&((t,e,n)=>{if(p(t,Qe))return;const o=((t,e,n)=>{const o=(t.parentElement||document.body).querySelectorAll('a, button, input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])');let r=null,i=21;for(let t=0;t<o.length;t++){const s=o[t];if(!s)continue;const c=s.getBoundingClientRect(),a=Math.max(c.left,Math.min(e,c.right)),u=Math.max(c.top,Math.min(n,c.bottom)),l=Math.sqrt((e-a)**2+(n-u)**2);l<i&&l>0&&(i=l,r=s)}return r})(t,e,n);if(!o)return;const r=o.getBoundingClientRect(),i=Math.max(r.left,Math.min(e,r.right)),s=Math.max(r.top,Math.min(n,r.bottom)),c=Math.sqrt((e-i)**2+(n-s)**2);if(c>0&&c<=20){const t=`${Math.round(r.width)}x${Math.round(r.height)}`;z({t:"sig",ts:Date.now(),d:{s:"tap_miss",el:a(o),dist:Math.round(c),size:t}})}})(i,e.clientX,e.clientY),r<500&&(Math.abs(n)>50||Math.abs(o)>50)&&((t,e,n)=>{if(Math.abs(n)>Math.abs(e))return;if(!t)return;if(qe.some(e=>{try{return t.matches(e)||t.closest(e)}catch{return!1}}))return;if(!qe.some(t=>{try{return null!==document.querySelector(t)}catch{return!1}}))return;const o=e>0?"right":"left";z({t:"sig",ts:Date.now(),d:{s:"swipe_miss",dir:o}})})(i,n,o),Fe=null}),nn=e(()=>{const t=Date.now();if(t-Ve>3e4&&(He=0,Ve=t),++He>=2){const e=document.activeElement||document.body;!Xe.some(t=>{try{return e.matches(t)||e.closest(t)}catch{return!1}})&&t-We>200&&(We=t,z({t:"sig",ts:t,d:{s:"pinch_zoom",cnt:He,pinch_scale:Ze}})),He=0,Ze=1}}),on=e(()=>{const t=Date.now(),e=screen.orientation?.type||"unknown";t-Ge>3e4&&(Ye=0,Ge=t),e!==Ke&&(Ye++,Ke=e),Ye>=3&&(z({t:"sig",ts:t,d:{s:"orientation_thrash",cnt:Ye,orientation:window.innerWidth>window.innerHeight?"landscape":"portrait"}}),Ye=0)}),rn=e(()=>{const t=window.visualViewport;if(t&&t.scale>1.1){const e=Date.now();if(e-Ve>3e4&&(He=0,Ve=e),++He>=2&&e-We>200){const n=Math.round(100*t.scale)/100;We=e,z({t:"sig",ts:e,d:{s:"pinch_zoom",cnt:He,pinch_scale:n}}),He=0,Ze=1}}});function sn(){document.removeEventListener("touchstart",tn),document.removeEventListener("touchend",en),document.removeEventListener("gesturechange",nn),window.removeEventListener("orientationchange",on),window.visualViewport?.removeEventListener("resize",rn),Fe=null,Je=0,Ze=1,He=0,Ve=0,We=0,Ye=0,Ge=0,Ke=null}function cn(t){const e=t[0],n=t[1];if(!e||!n)return 0;const o=e.clientX-n.clientX,r=e.clientY-n.clientY;return Math.sqrt(o*o+r*r)}var an=[],un=null,ln=0,fn=0,dn="",pn=[],hn=[],wn=e(t=>{const e=Date.now(),n=t.target;n&&p(n,hn)||("Tab"===t.key?((t,e,n)=>{for(;an.length&&t-an[0].ts>5e3;)an.shift();an.length>=50&&(an=an.slice(-25));const o=e?a(e):"";if(an.push({ts:t,el:o,shift:n}),an.length>=10){const e=an.map(t=>t.el).filter(Boolean),n=(t=>{let e=0;for(let n=1;n<t.length;n++)t[n].shift!==t[n-1].shift&&e++;return e})(an);z({t:"sig",ts:t,d:{s:"tab_thrash",cnt:an.length,els:e,direction_changes:n}}),an=[]}if(!e)return;const r=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');if(r){const n=a(e);r===un?t-fn<=3e3?(ln++,dn=n,ln>=5&&(z({t:"sig",ts:t,d:{s:"focus_trap",container:a(r),attempts:ln,trapped_element:dn}}),ln=0,dn="",un=null)):(fn=t,ln=1,dn=n):(un=r,fn=t,ln=1,dn=n)}})(e,n,t.shiftKey):"Escape"===t.key?((t,e)=>{if(!e)return;const n=e.closest('[role="dialog"]')||e.closest('[role="menu"]')||e.closest(".modal")||e.closest('[aria-modal="true"]');if(n&&n===un){if(t-fn>3e3)return fn=t,ln=1,void(dn=a(e));ln++,dn=a(e),ln>=5&&(z({t:"sig",ts:t,d:{s:"focus_trap",container:a(n),attempts:ln,trapped_element:dn}}),ln=0,dn="",un=null)}})(e,t.target):"ArrowDown"!==t.key&&"ArrowUp"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key||((t,e)=>{if(!e)return;const n=e.closest('[role="listbox"]')||e.closest('[role="menu"]')||e.closest('[role="tree"]')||e.closest("select");if(!n)return;for(;pn.length&&t-pn[0].ts>5e3;)pn.shift();pn.length>=50&&(pn=pn.slice(-25)),pn.push({ts:t,container:n});const o=pn.filter(t=>t.container===n);o.length>=15&&(z({t:"sig",ts:t,d:{s:"keyboard_nav_frustration",container:a(n),keys:o.length}}),pn=[])})(e,t.target))});function mn(){document.removeEventListener("keydown",wn,{capture:!0}),an=[],pn=[],un=null,ln=0,fn=0,dn="",hn=[]}var _n=0,vn=0,gn=null,yn=0,bn=!1,Mn=0,kn=0,Tn=null,Dn=0,xn=e(()=>{bn||(bn=!0,requestAnimationFrame(()=>{bn=!1,(()=>{const t=Date.now(),e=window.scrollY,n=e-vn;if(Math.abs(n)<2)return void(vn=e);const o=n>0?"down":"up";gn&&o!==gn&&(t-yn>3e3&&(_n=0,yn=t),++_n>=4)&&Math.abs(n)>100&&(t-kn>1e4&&(Mn=0,kn=t),Mn++,z({t:"sig",ts:t,d:{s:"scroll_hijack",rev:_n,source:null!==Tn&&t-Dn<=2e3?Tn:"wheel",repeated:Mn>=2}}),_n=0),gn=o,vn=e})()}))}),An=e(()=>{Tn="wheel",Dn=Date.now()}),En=e(()=>{Tn="touch",Dn=Date.now()});function Sn(){window.addEventListener("wheel",An,{passive:!0}),window.addEventListener("touchmove",En,{passive:!0}),window.addEventListener("scroll",xn,{passive:!0})}function On(){window.removeEventListener("wheel",An),window.removeEventListener("touchmove",En),window.removeEventListener("scroll",xn),$n()}function $n(){_n=0,vn=0,gn=null,yn=0,bn=!1,Mn=0,kn=0,Tn=null,Dn=0}var Un=0,Nn=0,Rn=!1,Cn=e(()=>{Rn||(Rn=!0,requestAnimationFrame(()=>{Rn=!1;const t=document.documentElement.scrollHeight-window.innerHeight;if(t>0){const e=window.scrollY/t;e>Un&&(Un=e,0===Nn&&(Nn=Date.now()))}}))}),jn=null,Ln=null;function In(){window.addEventListener("scroll",Cn,{passive:!0}),Ln=t(zn),window.addEventListener("pagehide",Ln),jn=t(()=>{"hidden"===document.visibilityState&&zn()}),document.addEventListener("visibilitychange",jn)}function Bn(){window.removeEventListener("scroll",Cn),Ln&&(window.removeEventListener("pagehide",Ln),Ln=null),jn&&(document.removeEventListener("visibilitychange",jn),jn=null),Un=0,Nn=0,Rn=!1}function Pn(){Un=0,Nn=0,Rn=!1}function zn(){if(Un>.05){const t=Date.now(),e=Nn>0?Math.max(0,t-Nn):0;z({t:"sig",ts:t,d:{s:"scroll_depth_abandon",depth:Math.round(100*Un)/100,max_depth:Math.round(100*Un),dwell_ms:e}})}}var qn="",Xn=0,Fn=0,Jn=0,Zn=0,Hn=0,Vn=null,Wn=0,Yn=!1,Gn=e(t=>{if("mouseenter"!==t.type)return;const e=t.target;if(!e)return;const n=a(e),o=Date.now();(n!==qn||o-Fn>1500)&&(qn=n,Fn=o,Xn=0),(Xn+=1)<4||(z({t:"sig",ts:o,d:{s:"thrash_hover",el:n,cnt:Xn,window_ms:1500}}),Xn=0,Fn=o)}),Kn=e(()=>{const t=Date.now(),e=oo(),n=Hn||e,o=Math.abs(e-n)/Math.max(n,1);Hn=e,o<.15||((!Jn||t-Jn>5e3)&&(Jn=t,Zn=0),(Zn+=1)<3||(z({t:"sig",ts:t,d:{s:"viewport_thrashing",cnt:Zn,area_delta:Math.round(1e3*o)/1e3}}),Zn=0,Jn=t))}),Qn=e(()=>{no()});function to(){Yn||(Yn=!0,Hn=oo(),no(),document.addEventListener("mouseenter",Gn,!0),document.addEventListener("mouseleave",Gn,!0),document.addEventListener("click",Qn,{capture:!0,passive:!0}),document.addEventListener("keydown",Qn,{capture:!0,passive:!0}),document.addEventListener("scroll",Qn,{passive:!0}),window.addEventListener("resize",Kn,{passive:!0}))}function eo(){Yn&&(Yn=!1,document.removeEventListener("mouseenter",Gn,!0),document.removeEventListener("mouseleave",Gn,!0),document.removeEventListener("click",Qn,{capture:!0}),document.removeEventListener("keydown",Qn,{capture:!0}),document.removeEventListener("scroll",Qn),window.removeEventListener("resize",Kn),ro(),qn="",Xn=0,Fn=0,Zn=0,Jn=0,Wn=0)}function no(){ro();const t=Wn+=1;Vn=setTimeout(()=>{z({t:"sig",ts:Date.now(),d:{s:"user_confusion_idle",idle_ms:15e3,cycle:t}})},15e3)}function oo(){return Math.max(1,window.innerWidth*window.innerHeight)}function ro(){Vn&&(clearTimeout(Vn),Vn=null)}var io=["[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"]'],so=/\b(help|faq|support|tooltip|hint|guide|explain|learn.?more)\b/i,co=[],ao=[],uo=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,ao))return;if(!(t=>{let e=t;for(let t=0;t<3&&e;t++){if(po(e))return!0;if(ho(e))return!0;e=e.parentElement}return!1})(e))return;const n=Date.now();for(;co.length&&n-co[0].t>6e4;)co.shift();const o=a(e);if(co.push({t:n,el:o}),co.length<3)return;const r=new Set(co.map(t=>t.el)).size,i=d(e);z({t:"sig",ts:n,d:{s:"help_hunt",cnt:co.length,unique_els:r,el:o,...i?{el_label:i}:{},window_ms:6e4}}),co=[]});function lo(){document.removeEventListener("click",uo,{capture:!0}),co=[]}function fo(){co=[]}function po(t){for(const e of io)try{if(t.matches(e))return!0}catch{}return!1}function ho(t){const e=t.id??"",n=t.className??"";return so.test("string"==typeof n?`${e} ${n}`:e)}var wo=/^(close|dismiss|modal-close|dialog-close|sheet-close|drawer-close)$/i,mo=/\b(close|dismiss|no\s*thanks?|maybe\s*later|skip|got\s*it|hide\s*this|don.?t\s*show)\b/i,_o=[],vo=new Map,go=[],yo=e(t=>{if(0!==t.button)return;const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,go))return;if(!(t=>{let e=t;for(let t=0;t<4&&e;t++){if(ko(e))return!0;e=e.parentElement}return!1})(e))return;const n=Date.now(),o=a(e),r=d(e);_o.push({t:n,el:o});const i=(vo.get(o)??0)+1;vo.set(o,i);const s=_o.length,c=(()=>{try{const n=e.getBoundingClientRect();return 0===n.width&&0===n.height?null:{click_dx:Math.round(t.clientX-(n.left+n.width/2)),click_dy:Math.round(t.clientY-(n.top+n.height/2)),el_w:Math.round(n.width),el_h:Math.round(n.height)}}catch{return null}})();z({t:"sig",ts:n,d:{s:"close_click",el:o,...r?{el_label:r}:{},session_cnt:s,element_cnt:i,repeated:i>1,container:To(e),...c??{}}})});function bo(){document.removeEventListener("click",yo,{capture:!0}),_o=[],vo.clear()}function Mo(){_o=[],vo.clear()}function ko(t){const e=t.getAttribute("data-dismiss")??"",n=t.getAttribute("data-close")??"";if(e||n)return!0;const o=t.getAttribute("aria-label")??t.getAttribute("title")??"";if(o&&mo.test(o))return!0;const r="string"==typeof t.className?t.className:"";if(wo.test(t.id??"")||wo.test(r))return!0;const i=(t.textContent??"").trim().slice(0,60);if(i&&mo.test(i))return!0;if("BUTTON"===t.tagName&&t.closest('[role="dialog"], [role="alertdialog"], dialog, .modal, .drawer, .sheet, .overlay, .popup, [data-modal], [data-dialog]')){const e=(t.textContent??"").trim();if("×"===e||"✕"===e||"✗"===e||"X"===e||"x"===e)return!0}return!1}function To(t){const e=[['[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(const[n,o]of e)try{if(t.closest(n))return o}catch{}return"unknown"}var Do=null,xo=[],Ao=e(t=>{if(0!==t.button)return;const e=t.composedPath&&t.composedPath()[0]||t.target;e&&(p(e,xo)||(Do=(t=>"A"===t.tagName||null!==t.closest('a, [role="link"], nav'))(e)?null:{el:a(e),label:d(e),t:Date.now()}))}),Eo=e(t=>{"Escape"===t.key&&Uo("escape")}),So=e(()=>{Uo("back_nav")});function Oo(){document.removeEventListener("click",Ao,{capture:!0}),document.removeEventListener("keydown",Eo,{capture:!0}),window.removeEventListener("popstate",So),Do=null}function $o(){Do=null}function Uo(t){if(!Do)return;const e=Date.now()-Do.t;e>1500||z({t:"sig",ts:Date.now(),d:{s:"close_click_reversal",reversal:t,el:Do.el,...Do.label?{el_label:Do.label}:{},elapsed_ms:e}}),Do=null}var No=/^(checkbox|radio)$/,Ro=/^(checkbox|radio|switch|tab|option|menuitemcheckbox|menuitemradio)$/,Co=new Map,jo=[],Lo=e(t=>{const e=t.target;e&&(p(e,jo)||(t=>"SELECT"===t.tagName||("INPUT"===t.tagName?No.test(t.type??""):Ro.test(t.getAttribute("role")??"")))(e)&&zo(e))}),Io=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,jo))return;const n=e.getAttribute("role")??"";Ro.test(n)&&"INPUT"!==e.tagName&&zo(e)});function Bo(){document.removeEventListener("change",Lo,{capture:!0}),document.removeEventListener("click",Io,{capture:!0}),Co.clear()}function Po(){Co.clear()}function zo(t){const e=a(t),n=Date.now();let o=Co.get(e);for(o||(o=[],Co.set(e,o));o.length&&n-o[0].t>1e4;)o.shift();if(o.push({t:n}),o.length<3)return;const r=d(t);z({t:"sig",ts:n,d:{s:"filter_spiral",el:e,...r?{el_label:r}:{},cnt:o.length,window_ms:1e4}}),Co.delete(e)}var qo=[],Xo=e(t=>{const e=t.target;if(e){const t=e.tagName;if("INPUT"===t||"TEXTAREA"===t)return;if(e.isContentEditable)return}const n=window.getSelection();if(!n||n.toString().length<2)return;const o=Date.now();for(;qo.length&&o-qo[0].t>15e3;)qo.shift();qo.push({t:o}),qo.length<3||(z({t:"sig",ts:o,d:{s:"copy_frustration",cnt:qo.length,window_ms:15e3}}),qo=[])});function Fo(){document.addEventListener("copy",Xo,{capture:!0,passive:!0})}function Jo(){document.removeEventListener("copy",Xo,{capture:!0}),qo=[]}function Zo(){qo=[]}var Ho=[],Vo=0,Wo=null,Yo=null;function Go(){Wo=t(er),Yo=t(tr),document.addEventListener("selectionchange",Wo),document.addEventListener("copy",Yo,{capture:!0,passive:!0}),document.addEventListener("cut",Yo,{capture:!0,passive:!0})}function Ko(){Wo&&(document.removeEventListener("selectionchange",Wo),Wo=null),Yo&&(document.removeEventListener("copy",Yo,{capture:!0}),document.removeEventListener("cut",Yo,{capture:!0}),Yo=null),Ho=[],Vo=0}function Qo(){Ho=[],Vo=0}function tr(){Vo=Date.now(),Ho=[]}function er(){const t=window.getSelection();if(!t||t.isCollapsed)return;if(t.toString().length<5)return;const e=t.anchorNode?.parentElement;if(e){const t=e.tagName;if("INPUT"===t||"TEXTAREA"===t||e.isContentEditable)return}const n=Date.now();if(n-Vo<2e3)return;for(;Ho.length&&n-Ho[0].t>15e3;)Ho.shift();const o=Ho[Ho.length-1];o&&n-o.t<500||(Ho.push({t:n}),Ho.length<4||(z({t:"sig",ts:n,d:{s:"text_select_frustration",cnt:Ho.length,window_ms:15e3}}),Ho=[]))}var nr=6e4,or="_fd_sess",rr={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},ir={low:1,medium:2,high:3,critical:4},sr=[],cr=null,ar=!1,ur=new Map,lr={totalSignals:0,pagesWithFrustration:0},fr="",dr=null,pr=null,hr=null,wr=null;function mr(t){ar&&_r(t,Date.now())}function _r(t,e){ur.has(t)||ur.set(t,[]);const n=ur.get(t);n.push(e),n.length>20&&n.shift()}function vr(t){let e="",n=0;for(const[o,r]of t)(r>n||r===n&&o<e)&&(e=o,n=r);return{type:e,count:n}}function gr(t,e){if(!ar)return;if("frustration_burst"===t)return;const n=e??Date.now();(t=>{const e=t-nr;let n=0;for(;n<sr.length&&sr[n].ts<e;)n++;n>0&&(sr=sr.slice(n))})(n),0===sr.length&&(cr=null),sr.push({type:t,ts:n}),_r(t,n);const{distinctTypes:o,totalWeight:r,typeCounts:i}=(()=>{const t=new Map;let e=0;for(const n of sr)t.set(n.type,(t.get(n.type)??0)+1),e+=rr[n.type]??10;return{distinctTypes:new Set(t.keys()),totalWeight:e,typeCounts:t}})(),s=((t,e,n)=>vr(n).count>=3&&t>=3?"critical":t>=4&&e>=70?"high":t>=3&&e>=40?"medium":t>=2&&e>=20?"low":null)(o.size,r,i);s&&(null!==cr&&ir[s]<=ir[cr]||(cr=s,((t,e,n,o)=>{const r=vr(o),i=(()=>{const t=[],e=Date.now()-nr,n=[];for(const[t,o]of ur.entries())for(const r of o)r>=e&&n.push({type:t,ts:r});n.sort((t,e)=>t.ts-e.ts);for(let e=0;e<n.length;e++)if("rage_click"===n[e].type)for(let o=e+1;o<n.length;o++)if("form_validation_loop"===n[o].type&&n[o].ts-n[e].ts<=3e4){t.push("rage_then_form_loop");break}for(let e=0;e<n.length;e++)if("dead_click"===n[e].type)for(let o=e+1;o<n.length;o++){const r=n[o].type;if(("popstate"===r||"hashchange"===r)&&n[o].ts-n[e].ts<=1e4){t.push("dead_then_bail");break}}for(let e=0;e<n.length;e++)if("form_validation_loop"===n[e].type)for(let o=e+1;o<n.length;o++)if(("visibilitychange"===n[o].type||"pagehide"===n[o].type)&&n[o].ts-n[e].ts<=2e4){t.push("form_loop_then_abandon");break}return t})();z({t:"sig",ts:Date.now(),d:{s:"frustration_burst",level:t,page:fr||void 0,distinct_types:e.size,total_weight:n,signals:Array.from(e).sort(),window_ms:nr,dominant:r.type,repeat_count:r.count,sequences:i,session_total_signals:lr.totalSignals,session_pages_with_frustration:lr.pagesWithFrustration}}),lr.totalSignals+=sr.length,lr.pagesWithFrustration+=1,(()=>{try{sessionStorage.setItem(or,JSON.stringify(lr))}catch{}})()})(s,o,r,i)))}function yr(){ar=!1,sr=[],cr=null,ur=new Map,$(null),dr&&(window.removeEventListener("popstate",dr),dr=null),pr&&(window.removeEventListener("hashchange",pr),pr=null),hr&&(document.removeEventListener("visibilitychange",hr),hr=null),wr&&(window.removeEventListener("pagehide",wr),wr=null)}var br=3e4,Mr=[],kr="",Tr=!1,Dr=e(()=>{Or(location.pathname+location.search+location.hash)}),xr=e(()=>{Or(location.pathname+location.search+location.hash)});function Ar(){Mr=[],Tr=!1,kr=location.pathname+location.search+location.hash,window.addEventListener("popstate",Dr),window.addEventListener("hashchange",xr)}function Er(){window.removeEventListener("popstate",Dr),window.removeEventListener("hashchange",xr),Mr=[],Tr=!1,kr=""}function Sr(){Mr=[],Tr=!1,kr=location.pathname+location.search+location.hash}function Or(t){const e=Date.now();if(kr&&kr!==t){const t=Mr[Mr.length-1];t&&t.path===kr&&null===t.leftAt&&(t.leftAt=e)}for(;Mr.length&&e-Mr[0].ts>br;)Mr.shift();t!==kr&&(Mr.push({path:t,ts:e,leftAt:null}),kr=t),Mr.length<5||Tr||(t=>{const e=Mr.filter(e=>t-e.ts<=br),n=e.filter(t=>null!==t.leftAt),o=new Set(e.map(t=>t.path));if(o.size<5)return;if(0===n.length)return;if(n.some(t=>t.leftAt-t.ts>=5e3))return;if(new Set(n.map(t=>t.path)).size<5)return;const r=n.map(t=>t.leftAt-t.ts),i=Math.round(r.reduce((t,e)=>t+e,0)/r.length),s=Math.max(...r),c=e.map(t=>t.path).slice(-8);Tr=!0,z({t:"sig",ts:t,d:{s:"navigation_confusion",page_count:o.size,window_ms:br,avg_dwell_ms:i,pages:c,max_dwell_ms:s}})})(e)}var $r=[],Ur=!1,Nr="none",Rr=0,Cr=0,jr=0,Lr=!1,Ir=e(()=>{Ur||(Ur=!0,requestAnimationFrame(Xr))}),Br=e(t=>{if(!Lr)return;const e=Date.now();if(e-jr>3e3)return void(Lr=!1);if(window.scrollY+t.clientY>Cr+.1*window.innerHeight)return;const n=window.innerHeight,o=Math.round(Rr-Cr),r=Math.round(o/n*100),i=t.target instanceof Element?t.target:null,s=i?a(i):"",c=i?d(i):"";Lr=!1,Rr=window.scrollY,Nr="none",$r=[],z({t:"sig",ts:e,d:{s:"scroll_to_click_confusion",reversal_depth_px:o,click_el:s,...c?{click_el_label:c}:{},scroll_back_pct:r}})});function Pr(){$r=[],Nr="none",Rr=0,Cr=0,jr=0,Lr=!1,Ur=!1,window.addEventListener("scroll",Ir,{passive:!0}),window.addEventListener("click",Br,{capture:!0})}function zr(){window.removeEventListener("scroll",Ir),window.removeEventListener("click",Br,{capture:!0}),qr()}function qr(){$r=[],Nr="none",Rr=0,Cr=0,jr=0,Lr=!1,Ur=!1}function Xr(){Ur=!1;const t=Date.now(),e=window.scrollY,n=window.innerHeight,o=$r[$r.length-1];if(o&&t-o.ts<50)return;if($r.push({y:e,ts:t}),$r.length>60&&($r=$r.slice(-40)),!o)return;const r=e-o.y;if(!(Math.abs(r)<2)){if("down"==(r>0?"down":"up"))return"down"!==Nr&&Lr&&(Lr=!1),e>Rr&&(Rr=e),void(Nr="down");Lr&&t-jr>3e3&&(Lr=!1),"down"===Nr&&Rr-e>=.3*n&&!Lr&&(Cr=e,jr=t,Lr=!0),Nr="up"}}var Fr=/^(A|BUTTON|INPUT|SELECT|TEXTAREA|DETAILS|SUMMARY)$/,Jr=/^(button|link|tab|menuitem|checkbox|radio|switch|option|combobox|slider|spinbutton|textbox)$/,Zr=/^(A|BUTTON|LABEL)$/,Hr=new Map,Vr=[],Wr=null,Yr=e(t=>{Wr={x:t.clientX,y:t.clientY}}),Gr=e(t=>{if(0!==t.button)return;if(0===t.detail)return;const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,Vr))return;if((()=>{const t=window.getSelection();return null!==t&&t.toString().length>0})())return;if((t=>{if(!Wr)return!1;const e=t.clientX-Wr.x,n=t.clientY-Wr.y;return Math.sqrt(e*e+n*n)>5})(t))return;if((t=>{if(Fr.test(t.tagName))return!0;const e=t.getAttribute("role");if(e&&Jr.test(e))return!0;if(t.hasAttribute("contenteditable"))return!0;if(t.hasAttribute("tabindex")&&"-1"!==t.getAttribute("tabindex"))return!0;if(t.hasAttribute("onclick")||t.hasAttribute("onmousedown")||t.hasAttribute("onmouseup"))return!0;const n=t.parentElement;return!(!n||!Zr.test(n.tagName))||!!t.closest('a, button, [role="button"], label, [onclick]')})(e))return;const{row:n,col:o}=((t,e)=>{const n=Math.min(3,Math.floor(t/window.innerWidth*4));return{row:Math.min(3,Math.floor(e/window.innerHeight*4)),col:n}})(t.clientX,t.clientY),r=((t,e)=>4*t+e)(n,o),i=Date.now(),s=a(e),c=(Hr.get(r)??[]).filter(t=>i-t.ts<9e4);if(c.push({ts:i,selector:s}),Hr.set(r,c),c.length>=3){const t=new Map;for(const e of c)t.set(e.selector,(t.get(e.selector)??0)+1);let e="",s=0;for(const[n,o]of t)o>s&&(s=o,e=n);const a=new Set,u=[];for(const t of c)if(!a.has(t.selector)&&(a.add(t.selector),u.push(t.selector),u.length>=5))break;const l=(()=>{try{const t=e?document.querySelector(e):null;return t?d(t):""}catch{return""}})();z({t:"sig",ts:i,d:{s:"dead_click_trap_zone",zone_row:n,zone_col:o,cnt:c.length,dominant_el:e,...l?{dominant_el_label:l}:{},elements:u,window_ms:9e4}}),Hr.set(r,[])}});function Kr(){document.removeEventListener("mousedown",Yr,{capture:!0}),document.removeEventListener("click",Gr,{capture:!0}),Wr=null,Hr.clear()}function Qr(){Hr.clear()}var ti=12e4,ei=new Map,ni=[],oi=null,ri=e(t=>{const e=t.target;e&&pi(e)}),ii=e(t=>{const e=t.target;if(!e||!li(e))return;if(p(e,ni))return;const n=a(e);ei.has(n)||ui(e)&&di(e,n)});function si(){document.removeEventListener("invalid",ri,{capture:!0}),document.removeEventListener("input",ii,{capture:!0}),document.removeEventListener("change",ii,{capture:!0}),oi&&(oi.disconnect(),oi=null);for(const t of ei.values())fi(t);ei.clear()}function ci(){for(const t of ei.values())fi(t);ei.clear()}function ai(t){const e=t.tagName.toLowerCase();return"select"===e?"select":"textarea"===e?"textarea":"input"===e?t.type||"text":e}function ui(t){const e=t.getAttribute("aria-invalid");if("true"===e||""===e)return!0;if("validity"in t&&t.validity&&!t.validity.valid)return!0;try{return t.matches(":invalid")}catch{return!1}}function li(t){const e=t.tagName;return"INPUT"===e||"SELECT"===e||"TEXTAREA"===e}function fi(t){t.el.removeEventListener("input",t.inputHandler),t.el.removeEventListener("change",t.changeHandler)}function di(t,n){const o=(t=>e(e=>{wi(t)}))(n),r=(t=>e(e=>{wi(t)}))(n);t.addEventListener("input",o,{passive:!0}),t.addEventListener("change",r,{passive:!0});const i={cycles:0,lastTs:Date.now(),phase:"invalid",inputHandler:o,changeHandler:r,el:t};return ei.set(n,i),i}function pi(t){if(!li(t))return;if(p(t,ni))return;const e=Date.now();(t=>{for(const[e,n]of ei)t-n.lastTs>ti&&(fi(n),ei.delete(e))})(e);const n=a(t),o=ei.get(n);if(!o)return void di(t,n);const r=o.lastTs;o.lastTs=e,"edited"===o.phase?(o.cycles+=1,o.phase="invalid",o.cycles>=3&&(z({t:"sig",ts:e,d:{s:"form_validation_loop",el:n,...d(t)?{el_label:d(t)}:{},cycles:o.cycles,window_ms:ti,field_type:ai(t)}}),fi(o),ei.delete(n))):"invalid"===o.phase&&e-r>500&&(o.cycles+=1,o.cycles>=3&&(z({t:"sig",ts:e,d:{s:"form_validation_loop",el:n,...d(t)?{el_label:d(t)}:{},cycles:o.cycles,window_ms:ti,field_type:ai(t)}}),fi(o),ei.delete(n)))}function hi(t){if(!li(t))return;const e=Date.now(),n=a(t),o=ei.get(n);return o?e-o.lastTs>ti?(fi(o),void ei.delete(n)):void("invalid"===o.phase&&(o.phase="edited",o.lastTs=e)):void 0}function wi(t){const e=Date.now(),n=ei.get(t);if(n){if(e-n.lastTs>ti)return fi(n),void ei.delete(t);if(n.lastTs=e,ui(n.el))return n.cycles+=1,void(n.cycles>=3&&(z({t:"sig",ts:e,d:{s:"form_validation_loop",el:t,...d(n.el)?{el_label:d(n.el)}:{},cycles:n.cycles,window_ms:ti,field_type:ai(n.el)}}),fi(n),ei.delete(t)));"invalid"===n.phase&&(n.phase="edited")}}function mi(t){for(const e of t){if("attributes"!==e.type)continue;if("aria-invalid"!==e.attributeName)continue;const t=e.target;if(!li(t))continue;if(p(t,ni))continue;const n=e.oldValue,o="true"===n||""===n,r=ui(t);r&&!o?pi(t):!r&&o&&hi(t)}}var _i=null,vi=null,gi=[],yi=0,bi=new Map;function Mi(){_i&&(_i.disconnect(),_i=null),vi&&(vi.disconnect(),vi=null),bi.clear()}function ki(){bi.clear(),_i&&Ti()}function Ti(){for(const t of gi)try{const e=document.querySelectorAll(t);for(let t=0;t<e.length;t++)Di(e[t])}catch{}}function Di(t){bi.has(t)||(bi.set(t,{firstSeenTs:0,emitted:!1}),_i.observe(t))}function xi(t){for(const e of t)for(let t=0;t<e.addedNodes.length;t++){const n=e.addedNodes[t];if(n instanceof Element)for(const t of gi)try{n.matches(t)&&Di(n);const e=n.querySelectorAll(t);for(let t=0;t<e.length;t++)Di(e[t])}catch{}}}function Ai(t){const e=Date.now();for(const n of t){const t=bi.get(n.target);if(t&&!t.emitted&&n.isIntersecting&&n.intersectionRatio>=.5){t.firstSeenTs||(t.firstSeenTs=e),t.emitted=!0;const o=n.boundingClientRect,r=n.rootBounds?.height??window.innerHeight,i=o.top<.5*r?"above_fold":"below_fold",s=a(n.target),c=d(n.target);z({t:"sig",ts:e,d:{s:"element_impression",el:s,...c?{el_label:c}:{},visible_pct:Math.round(100*n.intersectionRatio),time_to_visible_ms:Math.round(e-yi),viewport_position:i}})}}}var Ei=new Map,Si=[],Oi=e(t=>{const e=t.target;if(!e||!(t=>{if("TEXTAREA"===t.tagName)return!0;if("INPUT"===t.tagName){const e=t.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(e)}return!1})(e))return;if(p(e,Si))return;const n=Date.now(),o=e.value??"",r=a(e);let i=Ei.get(r);if(i){if(n-i.lastTs>6e4)return i.lastValue=o,i.cycles=0,i.phase="typing",void(i.lastTs=n);if(i.lastTs=n,"typing"===i.phase&&i.lastValue.length-o.length>=3)i.phase="deleted";else if("deleted"===i.phase&&o.length>i.lastValue.length&&(i.cycles++,i.phase="typing",i.cycles>=2)){const t=d(e);return z({t:"sig",ts:n,d:{s:"input_correction",el:r,...t?{el_label:t}:{},cycles:i.cycles,field_type:Ni(e)}}),void Ei.delete(r)}i.lastValue=o}else Ei.set(r,{lastValue:o,cycles:0,phase:"typing",lastTs:n})});function $i(){document.removeEventListener("input",Oi,{capture:!0}),Ei.clear()}function Ui(){Ei.clear()}function Ni(t){return"TEXTAREA"===t.tagName?"textarea":t.type?.toLowerCase()||"text"}var Ri=null,Ci=2e3,ji=[],Li=new Map,Ii=e(t=>{const e=t.composedPath&&t.composedPath()[0]||t.target;if(!e)return;if(p(e,ji))return;if(!(t=>{if(/^(A|BUTTON|SELECT)$/.test(t.tagName))return!0;const e=t.getAttribute("role")??"";if(/^(button|link|tab|menuitem|option|checkbox|radio)$/.test(e))return!0;try{const e=window.getComputedStyle(t);return"pointer"===e.cursor&&"none"!==e.pointerEvents}catch{return!1}})(e))return;const n=a(e);if(Ri?.selector===n)return;Xi();const o=Date.now();if(o-(Li.get(n)??0)<3e4)return;const r=o,i=setTimeout(()=>{const t=Date.now(),o=d(e);Li.set(n,t),Ri=null,z({t:"sig",ts:t,d:{s:"hover_dwell",el:n,...o?{el_label:o}:{},dwell_ms:Math.round(t-r)}})},Ci);Ri={el:e,selector:n,startTs:r,timer:i}}),Bi=e(t=>{if(!Ri)return;const e=t.target;if(e!==Ri.el&&!Ri.el.contains(e))return;const n=t.relatedTarget;n&&Ri.el.contains(n)||Xi()}),Pi=e(Xi);function zi(){document.removeEventListener("mouseover",Ii),document.removeEventListener("mouseout",Bi),document.removeEventListener("click",Pi,{capture:!0}),Xi(),Li.clear()}function qi(){Xi(),Li.clear()}function Xi(){Ri&&(clearTimeout(Ri.timer),Ri=null)}var Fi=0,Ji=0,Zi=null,Hi=t(e=>{if(e.clientY>20)return;const n=Date.now();n-Fi<3e3||n-Ji<6e4||(Zi&&clearTimeout(Zi),Zi=setTimeout(t(()=>{const t=Date.now();Ji=t,Zi=null,z({t:"sig",ts:t,d:{s:"exit_intent",method:"top_chrome",time_on_page_ms:Math.round(t-Fi)}})}),500))});function Vi(){Fi=Date.now(),Ji=0,document.addEventListener("mouseleave",Hi)}function Wi(){document.removeEventListener("mouseleave",Hi),Zi&&(clearTimeout(Zi),Zi=null)}function Yi(){Fi=Date.now(),Ji=0,Zi&&(clearTimeout(Zi),Zi=null)}var Gi=null,Ki=null,Qi=null,ts=0;function es(t,e,n){return t<=e?"good":t<=n?"needs_improvement":"poor"}function ns(){if("undefined"!=typeof PerformanceObserver){try{(Gi=new PerformanceObserver(t(t=>{const e=t.getEntries(),n=e[e.length-1];if(!n)return;const o=Math.round(n.startTime);z({t:"sig",ts:Date.now(),d:{s:"lcp",value_ms:o,rating:es(o,2500,4e3)}})}))).observe({type:"largest-contentful-paint",buffered:!0})}catch{Gi=null}try{(Ki=new PerformanceObserver(t(t=>{for(const e of t.getEntries()){const t=e;if(!t.interactionId)continue;const n=Math.round(t.duration);n<200||z({t:"sig",ts:Date.now(),d:{s:"slow_interaction",value_ms:n,rating:es(n,200,500)}})}}))).observe({type:"event",buffered:!1,durationThreshold:200})}catch{Ki=null}try{(Qi=new PerformanceObserver(t(t=>{for(const e of t.getEntries())e.hadRecentInput||(ts+=e.value)}))).observe({type:"layout-shift",buffered:!0})}catch{Qi=null}}}function os(){if(Qi){if(Qi.disconnect(),Qi=null,ts>0){const t=Math.round(1e3*ts)/1e3;z({t:"sig",ts:Date.now(),d:{s:"cls",value:t,rating:es(ts,.1,.25)}})}ts=0}}function rs(){Gi&&(Gi.disconnect(),Gi=null),Ki&&(Ki.disconnect(),Ki=null),os()}function is(){if(os(),"undefined"!=typeof PerformanceObserver)try{(Qi=new PerformanceObserver(t(t=>{for(const e of t.getEntries())e.hadRecentInput||(ts+=e.value)}))).observe({type:"layout-shift",buffered:!1})}catch{Qi=null}}var ss=[],cs=e(t=>{const e=t.target;if(!e||!(t=>{if("TEXTAREA"===t.tagName)return!0;if("INPUT"===t.tagName){const e=t.type?.toLowerCase()??"text";return/^(text|email|search|url|tel|number|password)$/.test(e)}return!1})(e))return;if(p(e,ss))return;const n=e.value??"";setTimeout(()=>{if((e.value??"")!==n)return;const t=a(e),o=d(e);z({t:"sig",ts:Date.now(),d:{s:"paste_blocked",el:t,...o?{el_label:o}:{},field_type:us(e)}})},100)});function as(){document.removeEventListener("paste",cs,{capture:!0})}function us(t){return"TEXTAREA"===t.tagName?"textarea":t.type?.toLowerCase()||"text"}var ls=!1,fs=null,ds=null,ps=[],hs="__flusterduck_instance__",ws=`fd_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,ms=[];function _s(e){if(ls)return;if(!e.key)return;if(e.key.startsWith("fd_sec_"))return;if(!e.key.startsWith("fd_pub_"))return;if(!1!==e.respectDoNotTrack&&("1"===navigator.doNotTrack||navigator.globalPrivacyControl))return void(ds=e);if(void 0!==e.sampleRate&&e.sampleRate<1&&Math.random()>e.sampleRate)return void(ds=e);if(!(()=>{const t=window;return!(t[hs]&&t[hs]!==ws||(t[hs]=ws,0))})())return void(ds=e);ds=e,ls=!0,"function"==typeof e.onSignal&&ps.push(N(e.onSignal)),e.emitSignalEvents&&ps.push(N(ks));const r=(t=>{if(t)return i();const e=(()=>{const t=document.cookie.match(new RegExp("(?:^|; )_fd_s=([^;]*)"));return t?.[1]?decodeURIComponent(t[1]):null})();if(e&&o.test(e))return e;const r=i();return s(n,r,30),r})(e.cookieless??!1),c=(t=>{if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}})(e.endpoint)??"https://api.flusterduck.com/v1/ingest",a=Y(location.pathname,e.pageRules??[]),u="metadata"===(l=e.domMode)||"snapshot"===l?l:"off";var l;((t,e,n,o,r)=>{var i;M=t,D=Object.assign(Object.create(null),e),x={domMode:(i=r?.domMode,"metadata"===i||"snapshot"===i?i:"off"),compression:W(r?.compression)},k=Math.max(500,Math.min(n??7e3,1e4)),T=Math.max(1,Math.min(o??50,100)),document.removeEventListener("visibilitychange",B),window.removeEventListener("pagehide",P),document.addEventListener("visibilitychange",B),window.addEventListener("pagehide",P)})(c,{sid:r,key:e.key,url:location.origin+location.pathname,page:a,ua:navigator.userAgent.slice(0,200),vw:window.innerWidth,vh:window.innerHeight,segment:e.segment,environment:e.environment},e.batchInterval,e.batchMaxSize,{domMode:u,compression:e.compression});const f=Ds(location.pathname,e.ignorePages??[]);f&&R(!0);const d=document.referrer;let p="";if(d)try{p=new URL(d).origin+new URL(d).pathname}catch{p=""}f||z({t:"pv",ts:Date.now(),d:{ref:p}});const h=e.ignoreElements??[];ms=[];for(const n of function(e,n,o){const r=t=>{const n=e.signals?.[t];return!1!==n?.enabled},i=!1!==e.trackForms;return[{when:()=>r("rageClick"),start:()=>((t,e)=>{ut||(ut=!0,et=t?.threshold??3,nt=t?.windowMs??2e3,ot=t?.radius&&t.radius>0?t.radius:24,rt=[...Q,...e??[]],st=Date.now(),tt=[],it=[],ct.clear(),at.clear(),document.addEventListener("click",lt,{capture:!0,passive:!0}))})(e.signals?.rageClick,n),stop:ft},{when:()=>r("deadClick"),start:()=>(t=>{wt=t??[],document.addEventListener("mousedown",vt,{capture:!0,passive:!0}),document.addEventListener("click",gt,{capture:!0,passive:!0})})(n),stop:yt,reset:bt},{when:()=>r("speedFrustration"),start:()=>{const t=e.signals?.speedFrustration;((t,e)=>{Dt=t?.delayMs??3e3,xt=e??[],document.addEventListener("click",$t,{capture:!0,passive:!0}),document.addEventListener("keydown",Ut,{capture:!0,passive:!0}),document.addEventListener("touchstart",Nt,{capture:!0,passive:!0})})(t?{delayMs:t.windowMs}:void 0,n)},stop:Rt,reset:Ct},{when:()=>!1!==e.trackMouse&&r("thrashCursor"),start:()=>{const t=e.signals?.thrashCursor;var n;n=t?{velocityThreshold:t.threshold,windowMs:t.windowMs}:void 0,Lt=n?.velocityThreshold??800,It=n?.windowMs??2e3,document.addEventListener("mousemove",Yt,{passive:!0})},stop:Gt},{when:()=>r("loopNav"),start:()=>{return t=e.signals?.loopNav,void(ee=t?.windowMs??3e4);var t},stop:ne},{when:()=>r("scrollBounce"),start:fe,stop:de,reset:pe},{when:()=>i&&(r("formHesitation")||r("formAbandon")),start:()=>{const o=e.signals?.formHesitation;((e,n)=>{ye=e?.pauseMs??5e3,be=n??[],document.addEventListener("focusin",Me,{capture:!0,passive:!0}),document.addEventListener("focusout",ke,{capture:!0,passive:!0}),document.addEventListener("submit",Te,{capture:!0,passive:!0}),window.addEventListener("pagehide",De),xe=t(()=>{"hidden"===document.visibilityState&&Se()}),document.addEventListener("visibilitychange",xe)})(o?{pauseMs:o.threshold}:void 0,n)},stop:Ae,reset:Ee},{when:()=>i&&r("formValidationLoop"),start:()=>(t=>{ni=t??[],document.addEventListener("invalid",ri,{capture:!0,passive:!0}),document.addEventListener("input",ii,{capture:!0,passive:!0}),document.addEventListener("change",ii,{capture:!0,passive:!0}),(oi=new MutationObserver(mi)).observe(document.body,{subtree:!0,attributeFilter:["aria-invalid"],attributes:!0,attributeOldValue:!0})})(n),stop:si,reset:ci},{when:()=>r("errorEncounter"),start:je,stop:Le},{when:()=>"ontouchstart"in window||navigator.maxTouchPoints>0,start:()=>(t=>{Qe=t??[],document.addEventListener("touchstart",tn,{passive:!0}),document.addEventListener("touchend",en,{passive:!0}),"ontouchstart"in window&&(document.addEventListener("gesturechange",nn,{passive:!0}),window.addEventListener("orientationchange",on,{passive:!0})),window.visualViewport?.addEventListener("resize",rn)})(n),stop:sn},{when:()=>r("tabThrash")||r("focusTrap")||r("keyboardNavFrustration"),start:()=>(t=>{hn=t??[],document.addEventListener("keydown",wn,{capture:!0,passive:!0})})(n),stop:mn},{when:()=>r("scrollHijack"),start:Sn,stop:On,reset:$n},{when:()=>r("scrollDepthAbandon"),start:In,stop:Bn,reset:Pn},{when:()=>r("advancedHeuristics"),start:to,stop:eo,reset:()=>{no(),Wn=0}},{when:()=>r("helpHunt"),start:()=>(t=>{ao=t??[],document.addEventListener("click",uo,{capture:!0,passive:!0})})(n),stop:lo,reset:fo},{when:()=>r("closeClick"),start:()=>(t=>{go=t??[],document.addEventListener("click",yo,{capture:!0,passive:!0})})(n),stop:bo,reset:Mo},{when:()=>r("closeClickReversal"),start:()=>(t=>{xo=t??[],document.addEventListener("click",Ao,{capture:!0,passive:!0}),document.addEventListener("keydown",Eo,{capture:!0,passive:!0}),window.addEventListener("popstate",So)})(n),stop:Oo,reset:$o},{when:()=>r("filterSpiral"),start:()=>(t=>{jo=t??[],document.addEventListener("change",Lo,{capture:!0,passive:!0}),document.addEventListener("click",Io,{capture:!0,passive:!0})})(n),stop:Bo,reset:Po},{when:()=>r("copyFrustration"),start:Fo,stop:Jo,reset:Zo},{when:()=>r("textSelectFrustration"),start:Go,stop:Ko,reset:Qo},{when:()=>r("deadClickTrapZone"),start:()=>(t=>{Vr=t??[],document.addEventListener("mousedown",Yr,{capture:!0,passive:!0}),document.addEventListener("click",Gr,{capture:!0,passive:!0})})(n),stop:Kr,reset:Qr},{when:()=>!0,start:()=>(t=>{sr=[],cr=null,ar=!0,ur=new Map,fr=t??"",(()=>{try{const t=sessionStorage.getItem(or);if(t){const e=JSON.parse(t);lr={totalSignals:"number"==typeof e.totalSignals?e.totalSignals:0,pagesWithFrustration:"number"==typeof e.pagesWithFrustration?e.pagesWithFrustration:0}}}catch{}})(),$(gr),dr=()=>mr("popstate"),pr=()=>mr("hashchange"),hr=()=>{"hidden"===document.visibilityState&&mr("visibilitychange")},wr=()=>mr("pagehide"),window.addEventListener("popstate",dr),window.addEventListener("hashchange",pr),document.addEventListener("visibilitychange",hr),window.addEventListener("pagehide",wr)})(o),stop:yr},{when:()=>r("navigationConfusion"),start:Ar,stop:Er,reset:Sr},{when:()=>r("scrollToClickConfusion"),start:Pr,stop:zr,reset:qr},{when:()=>r("elementImpression"),start:()=>{return n=e.elementImpressionSelectors,gi=n?.length?n:["[data-fd-impression]"],yi=Date.now(),void("undefined"!=typeof IntersectionObserver&&(_i=new IntersectionObserver(t(Ai),{threshold:[0,.5,1]}),Ti(),(vi=new MutationObserver(t(xi))).observe(document.body,{childList:!0,subtree:!0})));var n},stop:Mi,reset:ki},{when:()=>i&&r("inputCorrection"),start:()=>(t=>{Si=t??[],document.addEventListener("input",Oi,{capture:!0,passive:!0})})(n),stop:$i,reset:Ui},{when:()=>i&&r("pasteBlocked"),start:()=>(t=>{ss=t??[],document.addEventListener("paste",cs,{capture:!0,passive:!0})})(n),stop:as},{when:()=>r("hoverDwell"),start:()=>{const t=e.signals?.hoverDwell;((t,e)=>{Ci=t?.dwellMs??2e3,ji=e??[],document.addEventListener("mouseover",Ii,{passive:!0}),document.addEventListener("mouseout",Bi,{passive:!0}),document.addEventListener("click",Pi,{capture:!0,passive:!0})})(t?.threshold?{dwellMs:t.threshold}:void 0,n)},stop:zi,reset:qi},{when:()=>r("exitIntent"),start:Vi,stop:Wi,reset:Yi},{when:()=>r("performanceVitals"),start:ns,stop:rs,reset:is}]}(e,h,a))n.when()&&(n.start(),ms.push({stop:n.stop,reset:n.reset}));fs=function(t){let e=location.href;function n(){const n=location.href;n!==e&&(e=n,t(n,location.pathname))}const o=history.pushState,r=history.replaceState,i=function(...t){o.apply(this,t),n()},s=function(...t){r.apply(this,t),n()};return history.pushState=i,history.replaceState=s,window.addEventListener("popstate",n),window.addEventListener("hashchange",n),()=>{history.pushState===i&&(history.pushState=o),history.replaceState===s&&(history.replaceState=r),window.removeEventListener("popstate",n),window.removeEventListener("hashchange",n)}}(t((t,n)=>{for(const t of ms)t.reset?.();q(),Or(n),(t=>{fr=t})(n);const o=Y(n,e.pageRules??[]),r=Ds(n,e.ignorePages??[]);R(r),F({page:o,url:t}),(t=>{const e=Date.now(),n=t.indexOf("#"),o=-1===n?t:t.slice(0,n),r=-1===n?"":t.slice(n);for(;Qt.length&&e-Qt[0].ts>ee;)Qt.shift();for(;te.length&&e-te[0].ts>ee;)te.shift();if(Qt.length>=100&&(Qt=Qt.slice(-50)),te.length>=100&&(te=te.slice(-50)),Qt.push({path:t,ts:e}),r){te.push({path:t,ts:e});const n=te.filter(t=>{const e=t.path.indexOf("#");return(-1===e?t.path:t.path.slice(0,e))===o}),r=new Set(n.map(t=>{const e=t.path.indexOf("#");return-1===e?"":t.path.slice(e)}));if(r.size>=3&&n.length>r.size){const t=n.slice(-5).map(t=>t.path);return z({t:"sig",ts:e,d:{s:"loop_nav",loop_type:"hash",pages:Array.from(r).map(t=>o+t),path_sequence:t}}),void(te=te.filter(t=>{const e=t.path.indexOf("#");return(-1===e?t.path:t.path.slice(0,e))!==o}))}}if(Qt.length<4)return;let i=!1;const s=[];for(let e=0;e<Qt.length-1;e++)if(Qt[e].path===t){const t=Qt.slice(e,Qt.length),n=new Set(t.map(t=>t.path));if(n.size>=2){s.push(...Array.from(n)),i=!0;break}}i&&(z({t:"sig",ts:e,d:{s:"loop_nav",loop_type:"path",pages:s,path_sequence:Qt.slice(-5).map(t=>t.path)}}),Qt=[{path:t,ts:e}],te=te.filter(t=>{const e=t.path.indexOf("#");return(-1===e?t.path:t.path.slice(0,e))!==o}))})(n),r||z({t:"pv",ts:Date.now(),d:{ref:""}})}))}function vs(t,e){if(!ls)return;if("string"!=typeof t||!t||t.length>128)return;let n;try{n=JSON.stringify(e?.metadata??{})}catch{return}if(n.length>2048)return;const o=JSON.parse(n);z({t:"sig",ts:Date.now(),d:{s:t.slice(0,128),el:"string"==typeof e?.element?e.element.slice(0,256):"",meta:o,w:Math.max(0,Math.min(e?.weight??15,100))}})}function gs(t,e={}){if(!ls)return;if("string"!=typeof t||!/^[a-z0-9_.-]{1,120}$/i.test(t))return;let n;try{n=JSON.stringify(e??{})}catch{return}n.length>2048||z({t:"custom_signal",ts:Date.now(),d:{business_event:t.slice(0,120),meta:JSON.parse(n)}})}function ys(t){if(!ls)return;if(!t||"object"!=typeof t)return;const e=Object.create(null);let n=0;for(const o of Object.keys(t)){if(n>=20)break;"__proto__"!==o&&"constructor"!==o&&"prototype"!==o&&(e[o.slice(0,64)]=String(t[o]).slice(0,256),n++)}F({segment:e})}function bs(t){t&&ds&&!ls?_s(ds):t||(Ts(),r())}function Ms(){Ts(),r()}function ks(t){if("undefined"!=typeof window&&"undefined"!=typeof CustomEvent)try{window.dispatchEvent(new CustomEvent("flusterduck:signal",{detail:t}))}catch{}}function Ts(){if(ls){for(const t of ps)t();ps=[];for(const t of ms)t.stop();ms=[],q(),S=!1,document.removeEventListener("visibilitychange",B),window.removeEventListener("pagehide",P),b&&(clearTimeout(b),b=null),fs&&(fs(),fs=null),(()=>{const t=window;t[hs]===ws&&delete t[hs]})(),ls=!1}}function Ds(t,e){for(const n of e)if(n)if(n.endsWith("*")){if(t.startsWith(n.slice(0,-1)))return!0}else if(n.startsWith("*")){if(t.endsWith(n.slice(1)))return!0}else if(t===n)return!0;return!1}function xs(t){if(t)try{const e=new URL(t),n="http:"===e.protocol&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(e.hostname);if("https:"!==e.protocol&&!n)return;return e.origin+e.pathname}catch{return}}(()=>{try{const t=window;if(t.flusterduck)return;const e=document.currentScript;if(!e)return;const n=e.getAttribute("data-key");if(!n)return;const o={key:n,environment:e.getAttribute("data-env")||void 0,endpoint:xs(e.getAttribute("data-endpoint")),debug:"true"===e.getAttribute("data-debug"),cookieless:"true"===e.getAttribute("data-cookieless"),respectDoNotTrack:"false"!==e.getAttribute("data-dnt")},r=e.getAttribute("data-dom-mode");"metadata"!==r&&"snapshot"!==r||(o.domMode=r),"off"===e.getAttribute("data-compression")&&(o.compression="off");const i=e.getAttribute("data-sample");if(i){const t=parseFloat(i);isNaN(t)||(o.sampleRate=Math.max(0,Math.min(t,1)))}const s=e.getAttribute("data-segment");if(s&&s.length<2048)try{const t=JSON.parse(s);if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.create(null);for(const n of Object.keys(t))"__proto__"!==n&&"constructor"!==n&&"prototype"!==n&&(e[n]=String(t[n]));o.segment=e}}catch{}_s(o),t.flusterduck=Object.freeze({init:_s,signal:vs,track:gs,identify:ys,setConsent:bs,optOut:Ms,destroy:Ts})}catch{}})()})();