@incodetech/tri-sdk 0.4.0-rc.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tri.esm.js CHANGED
@@ -1 +1 @@
1
- class t{constructor(){this.t=0}static get instance(){return t.i||(t.i=new t),t.i}get DEBUG(){return this.t}set DEBUG(t){this.t=t}warn(t,n,...e){this.t&&this.o("warn",t,n,...e)}error(t,n,...e){this.t&&this.o("error",t,n,...e)}info(t,n,...e){this.t&&this.o("info",t,n,...e)}fatal(t,n,e,...i){this.o(t,n,e,...i)}o(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:1,passive:1})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function l(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function u(t,n){return o(l(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),l=i?t.transferSize:null,u=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:l,encodedBodySize:u,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function g(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function b(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return t?t.hasAttribute("data-tri-ignore"):0}function T(t){return t?t.hasAttribute("data-tri-redact"):0}function _(t,n){return n?.includes(t.toLowerCase())??0}function I(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function S(t,n){return t?t[n]?.enabled??0:1}function x(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||k(t)||T(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(L))},i.async=1,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function B(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&s(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&s(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const O=B("localStorage"),q=B("sessionStorage"),j="__tri_fingerprint";let H=null,N=null;async function F(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:o}=function(t,n){const e={},i={};for(const[o,r]of Object.entries(t))n.includes(o)?e[o]=r:i[o]=r;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),r=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:U.scriptUrl,[c,a]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",o=n,r),()=>i.removeEventListener("visibilitychange",o,r));var i,o,r;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!r||"string"!=typeof r)throw new Error(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===P)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(l=a,new Promise(t=>setTimeout(t,l))).then(()=>s(c));var l})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),C)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};O.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=0;return c(async()=>{const e=await async function(t){const n=function(){const t=O.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(O.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return V(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):x())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=0,r=0,s=null,c=0,l=0;function u(){s&&(clearTimeout(s),s=null)}function d(){u(),c||l||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=0,u(),function(e){const i=A("end"),o=i&&E(i,n),r=x();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=1,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=1,u())}),m=a(t=>{0===t.button&&(c=0,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(l=1,u())}),y=a(t=>{"Shift"===t.key&&(l=0,o&&h("keyboard"))}),v=a(()=>{c=0}),g=a(()=>{"hidden"===document.visibilityState&&(c=0,l=0,o&&h("timeout"))}),b=a(()=>{c=0,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",g),e(document,"dragend",b),()=>{u(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",g),i(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),l=a(()=>d("traverse")),u=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",l),e(window,"hashchange",u)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",l),i(window,"hashchange",u)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,u=null,h=0;function f(){u&&d(u),u=setTimeout(l(()=>{p(),u=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=1,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),u&&(d(u),u=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:1})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function it(){const t={};for(const n of W)t[n]=st(n,void 0,1);return t}function ot(t){const n={};for(const e of W)n[e]=st(e,void 0,t[Q[e].layer]??0);return n}function rt(t){const n={};for(const e of W){const i=t[e];n[e]=st(e,i,i?.enabled??0)}return n}function st(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??1};return{enabled:e,events:r}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const at=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function lt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const ut="__tri",dt=`${ut}_activity_token`,ht=`${ut}_activity_id`,ft=`${ut}_activity_status`,pt="__tri_activity_lock";class mt{constructor(t){this.context=t,this.l=null,this.u=null,this.h=null,this.p=null,this.m=0}getToken(){return this.l}getActivityId(){return this.u??""}isActive(){return"ACTIVE"===this.h&&null!==this.l}async start(){return this.m=1,this.p||(this.p=this.v()),this.p}async stop(){this.m=0,this.k(null),this.p=null,this.l&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.l;await lt(pt,async()=>{if(this.l&&this.l!==t&&!at(this.l)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!at(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.I(),await this.S())})}async v(){try{if(this.l&&!at(this.l))return;await lt(pt,async()=>{await this.S()})}finally{this.p=null}}async S(){const t=this._();if(t&&!at(t.token)&&"ACTIVE"===t.activityStatus)return void this.T(t);t&&this.I();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.T(e),this.A(e)}_(){const[t,n,e]=[O.get(dt),O.get(ht),O.get(ft)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.I(),null)}A(t){O.set(dt,t.token),O.set(ht,t.activityId),O.set(ft,t.activityStatus)}I(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(dt),O.remove(ht),void O.remove(ft);O.set(dt,t.token),O.set(ht,t.activityId),O.set(ft,t.activityStatus)}T(t){if(!t)return this.l=null,this.u=null,void(this.h=null);this.l=t.token,this.u=t.activityId,this.h=t.activityStatus}}const wt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function vt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const gt=new Array(256);for(let t=0;t<256;t++)gt[t]=(t+256).toString(16).slice(1);const bt=new Uint8Array(16);function kt(t){return gt[t[0]]+gt[t[1]]+gt[t[2]]+gt[t[3]]+"-"+gt[t[4]]+gt[t[5]]+"-"+gt[t[6]]+gt[t[7]]+"-"+gt[t[8]]+gt[t[9]]+"-"+gt[t[10]]+gt[t[11]]+gt[t[12]]+gt[t[13]]+gt[t[14]]+gt[t[15]]}function Tt(){return crypto.randomUUID()}function _t(){return crypto.getRandomValues(bt),bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}function It(){for(let t=0;t<16;t++)bt[t]=256*Math.random()|0;return bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}const St=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Tt;if("function"==typeof crypto.getRandomValues)return _t}return It}();function xt(){return St()}class Et{constructor(t,n){this.M=t,this.D=n,this.P=[],this.C=null,this.R=[],this.L=null,this.m=0,this.$=1,this.U=0,this.B=0,this.O=t.flush.intervalMs}push(t){if(this.m){if(this.P.length<this.q()?this.P.push(t):this.j(t),this.$)return this.P.length>=this.M.flush.size?(d(this.C),this.C=null,void this.flush("capacity")):void this.H()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.m&&this.D.isActivityActive())try{if("lifecycle"===t)return void this.N();if(0===this.P.length)return;const e=this.F(t);this.D.ingest(e,0).then(t=>this.X(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.P.length>0&&this.H()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.m||(this.m=1,this.$="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.m)return Promise.resolve();d(this.C),this.C=null,d(this.L),this.L=null;const t=this.N();return this.m=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.$){if(this.$=t,!this.$)return d(this.C),this.C=null,d(this.L),void(this.L=null);this.P.length>0&&this.H(),this.R.length>0&&this.K()}}H(){this.m&&this.$&&null===this.C&&(this.C=u(()=>{this.C=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.L&&(this.L=u(()=>{this.L=null,this.V()},this.O))}V(){if(!this.m||!this.$||0===this.R.length||!this.D.isActivityActive())return;const t=this.R.shift();this.D.ingest(t.batch,0).then(n=>this.Y(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.R.length>0&&this.K()})}J(t,e){this.R.length>=5&&(this.R.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.R.push({batch:t,attempts:e}),this.K()}X(t,n){t.ok?this.G():this.Z(t)&&this.J(n,1)}Y(t,e){if(t.ok)return this.G(),void(this.R.length>0&&this.K());if(this.Z(t)){if(e.attempts>=3)return this.W(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.R.length>0&&this.K());this.W(),this.J(e.batch,e.attempts+1)}else this.R.length>0&&this.K()}W(){this.U++,this.U%this.M.flush.backoffFailureThreshold===0&&(this.O=Math.min(2*this.O,this.M.flush.maxIntervalMs))}G(){this.U=0,this.O=this.M.flush.intervalMs}q(){return this.M.queue.size*(this.$?1:2)}async N(){if(!this.D.isActivityActive())return Promise.resolve();const t=[];for(const e of this.R)t.push(this.D.ingest(e.batch,1).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.R=[],this.P.length>0){const e=this.F("lifecycle");t.push(this.D.ingest(e,1).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}j(t){const n=vt(t);for(let e=0;e<this.P.length;e++)if(vt(this.P[e])<n){for(let t=e;t<this.P.length-1;t++)this.P[t]=this.P[t+1];return this.P.length-=1,void this.P.push(t)}}F(t){const n="lifecycle"===t?this.P.splice(-this.M.flush.size):this.P.splice(0,this.M.flush.size);return{activityId:"",batchId:xt(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.0-rc.0",sdkPlatform:"web",tabId:this.D.getTabId(),events:n}}Z(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const Mt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>O.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=xt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{O.set(n,t),O.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.tt="",this.m=0,this.nt=null,this.et=null,this.it=null,this.ot=new Map,this.rt=-1,this.st=null}async start(){this.m||(this.m=1,this.tt=this.ct(),this.lt(),this.ut({type:"hello",tabId:this.tt,ts:Date.now()}),this.dt(),this.ht("active"),this.ft())}stop(){this.m&&(this.m=0,this.ht("inactive"),this.ut({type:"bye",tabId:this.tt,ts:Date.now()}),this.wt(this.yt()),this.vt(),this.gt(),this.bt())}getTabId(){return this.tt}queryTabsNumber(){return this.ot.size+1}lt(){try{this.nt=new Mt("__tri_tab_channel"),this.st=this.kt.bind(this),this.nt.addEventListener("message",this.st)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}bt(){try{if(!this.nt)return;this.st&&this.nt.removeEventListener("message",this.st),this.nt.close()}catch{}finally{this.nt=null,this.st=null}}dt(){this.et=setInterval(()=>{const t=Date.now();this.ut({type:"heartbeat",tabId:this.tt,ts:t})},1e3)}vt(){null!=this.et&&(clearInterval(this.et),this.et=null)}ft(){null!=this.it&&clearTimeout(this.it),this.it=setTimeout(()=>{this.it=null;const t=this.yt()+1;t!==this.rt&&(this.rt=t,this.wt(t))},1e3)}gt(){null!=this.it&&(clearTimeout(this.it),this.it=null)}ut(t){try{if(!this.nt)return;this.nt.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}kt(t){const{type:n,tabId:e}=t.data;if(e===this.tt)return;const i=Date.now();"hello"===n?(this.ut({type:"ack",tabId:this.tt,ts:i,to:e}),this.ot.set(e,i)):"heartbeat"===n||"ack"===n?this.ot.set(e,i):"bye"===n&&this.ot.delete(e)}wt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.tt,timestamp:Date.now(),value:t})}ht(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.tt,timestamp:Date.now(),value:t})}ct(){const t=q.get(Dt);if(t)return t;const n=xt();return q.set(Dt,n),n}yt(t=Date.now()){let n=0;for(const[e,i]of this.ot.entries())t-i>=3e3?this.ot.delete(e):n++;return n}}const Ct=globalThis.CompressionStream,Rt=globalThis.Response,zt=globalThis.Blob,Lt=new TextEncoder;let $t=null;async function Ut(t){const e=await async function(t){if("function"!=typeof Ct)return null;try{const n=Lt.encode(t),e=new zt([n]).stream().pipeThrough(new Ct("gzip"));return await new Rt(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===$t){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=u(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>import("./chunks/browser-8Za96B1X.js"),1e4);$t=t,t.then(n=>{null===n&&u(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===e)return null;const{gzipSync:i}=e,o=i(Lt.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Bt(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Ot="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class qt{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const jt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Ft(t,n,e){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(g(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const l=t.hasAttribute("readonly");l&&!_("readonly",e)&&(i.readOnly=l);const u=t.hasAttribute("required");u&&!_("required",e)&&(i.required=u);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:I(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return jt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return g(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Kt(t){return t>=20}function Vt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Yt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Jt(t,n=0){if(n)return null;const e=Zt(t,"labelledby");if(e)return{text:Wt(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Qt(t);if(i)return{text:Wt(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Gt(n):null}(t);if(o)return{text:Wt(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?Gt(n):null}(t);if(r)return{text:Wt(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:Wt(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:Wt(c),resolutionMethod:"title",confidence:"low"};const a=Zt(t,"describedby");if(a)return{text:Wt(a),resolutionMethod:"aria-describedby",confidence:"low"};const l=Gt(t);return l?{text:l,resolutionMethod:"text-content",confidence:"low"}:null}function Gt(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Gt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return Wt(e)}function Zt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=Qt(n)??Gt(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function Qt(t){return t?.getAttribute("aria-label")?.trim()??null}function Wt(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function tn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class nn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function en(t,o){const{collectors:r,sdk:s}=t;let c=null,l=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Ot)return{ok:0,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,l=0;a=u(()=>{l=1,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:1}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(r.body);if(!t.ok)return d(a),p(),{ok:0,kind:"serialize"};f=t.body}try{const n=await Ot(s,{method:t,headers:Bt({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:0,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:0,kind:"client",status:m}:{ok:0,kind:"server",status:m};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return c.signal.aborted?l?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return l?{ok:0,kind:"timeout"}:c.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!wt.includes(a.status)||0==r?.refreshable)return c;var a;const l=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return l&&l!==s?t(l):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let l;try{l=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ut(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:0,kind:"serialize"}}return e.post("/events/capture",{body:l.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===l.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:1,...o()}),{refreshable:0})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>l?.getToken()??null,refresh:async()=>l?.refresh()??Promise.resolve(),getActivityId:()=>l?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};l=new mt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Et(et,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>l?.isActive()??0});const p=r.tab;f=new Pt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>l?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new nn(6),i=new nn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||g(e,"body"))break;e=b(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=tn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Ft(r,s,tn(r)),{score:l,reasons:u}=Xt(r,c);if(e.push(a),!Kt(l))continue;const d=Jt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:l,reasons:u})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Ft(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Xt(t,0);return{interactive:Kt(i),...o.length>0?{reasons:o}:{},disabled:Yt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Vt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let l=null;return e||(l=a.interactive?Jt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...l?{label:l}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??0}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new qt({getActivityId:()=>l?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:l,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this.Tt=0,this.M=null,this._t=null,this.It="idle"}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if("idle"!==this.It)return n.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??0};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:it()}:void 0!==t.collectors?{sdk:o,collectors:rt(t.collectors)}:{sdk:o,collectors:ot(t.layers)}}(t);if(!e)return"init-failed";n.DEBUG=e.sdk.DEBUG;const i=await en(e,{getProfileId:()=>this.St()});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.M=e,this._t=i.managers,this.It="ready",this.xt(e.sdk.profileId),"ready")}catch(t){return n.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.It)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.It;if("ready"!==this.It)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.It;this.It="starting";const t=++this.Tt;return await this.v(t),this.It}async stop(){n.warn("stop()","called");const t=this._t;return t?(++this.Tt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.It="ready",this.Et(t)):Promise.resolve(this.It)}async reset(){const t=this.stop();return this.It="idle",this.M=null,this._t=null,O.remove("__tri_profile_id"),t.then(()=>this.It)}async Et(t){return await function(t){let n=null;const e=new Promise(t=>{n=u(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.It}reportEvent(t,e){"started"===this.It?this._t?c(()=>this._t.eventReportManager.report(t,e)):n.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):n.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.It?this.M?.sdk&&(this.M.sdk.profileId=t,this.xt(t)):n.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.It||!this._t)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this._t.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),0}}St(){return this.M?.sdk?.profileId??O.get("__tri_profile_id")??null}xt(t){t&&O.set("__tri_profile_id",t)}async v(t){const e=this._t;if(e){try{if(await e.activityManager.start(),t!==this.Tt)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this.Tt)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this.Tt&&(this.It="ready"))}t===this.Tt&&(this.It="started")}}};async function rn(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=0,c=()=>{};i&&(r=u(()=>{s=1,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:1}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}}on.i=null;const sn=on.instance;export{rn as createSession,sn as default};
1
+ class t{constructor(){this.t=!1}static get instance(){return t.i||(t.i=new t),t.i}get DEBUG(){return this.t}set DEBUG(t){this.t=t}warn(t,n,...e){this.t&&this.o("warn",t,n,...e)}error(t,n,...e){this.t&&this.o("error",t,n,...e)}info(t,n,...e){this.t&&this.o("info",t,n,...e)}fatal(t,n,e,...i){this.o(t,n,e,...i)}o(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:!0,passive:!0})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:!0})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function u(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function l(t,n){return o(u(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:u,encodedBodySize:l,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function b(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function g(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return!!t&&t.hasAttribute("data-tri-ignore")}function T(t){return!!t&&t.hasAttribute("data-tri-redact")}function _(t,n){return n?.includes(t.toLowerCase())??!1}function x(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function S(t,n){return!t||(t[n]?.enabled??!1)}function I(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"!==n&&!k(t)&&!T(t)}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",C="The endpoint parameter is not a valid URL";function P(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(C);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(L))},i.async=!0,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function B(t){function n(){return globalThis.window&&globalThis.window[t]&&void 0!==globalThis.window[t]}return{get:function(e){if(!n())return null;try{const n=window[t].getItem(e)??"null";return"null"===n?null:JSON.parse(n)}catch{return null}},set:function(e,i){n()&&s(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&s(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const O=B("localStorage"),q=B("sessionStorage"),j="__tri_fingerprint";let H=null,N=null;async function F(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:o}=function(t,n){const e={},i={};for(const[o,r]of Object.entries(t))n.includes(o)?e[o]=r:i[o]=r;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),r=null!==(n=i.apiKey)&&void 0!==n?n:i.token,s=null!==(e=function(t,n){return function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}(t,n)?t[n]:void 0}(t,"scriptUrlPattern"))&&void 0!==e?e:U.scriptUrl,[c,a]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",o=n,r),()=>i.removeEventListener("visibilitychange",o,r));var i,o,r;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!r||"string"!=typeof r)throw new Error(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===C)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(u=a,new Promise(t=>setTimeout(t,u))).then(()=>s(c));var u})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),P)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:!0});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};O.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=!1;return c(async()=>{const e=await async function(t){const n=function(){const t=O.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(O.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=!0}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??!1,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return!0;const n=t.target;return!!V(n)&&function(t){try{return t.matches(":-webkit-autofill")}catch{return!1}}(n)}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):I())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=!1,r=0,s=null,c=!1,u=!1;function l(){s&&(clearTimeout(s),s=null)}function d(){l(),c||u||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=!1,l(),function(e){const i=A("end"),o=i&&E(i,n),r=I();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:!0,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=!0,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=!0,l())}),m=a(t=>{0===t.button&&(c=!1,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(u=!0,l())}),y=a(t=>{"Shift"===t.key&&(u=!1,o&&h("keyboard"))}),v=a(()=>{c=!1}),b=a(()=>{"hidden"===document.visibilityState&&(c=!1,u=!1,o&&h("timeout"))}),g=a(()=>{c=!1,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",b),e(document,"dragend",g),()=>{l(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",b),i(document,"dragend",g)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),u=a(()=>d("traverse")),l=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",u),e(window,"hashchange",l)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",u),i(window,"hashchange",l)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,l=null,h=!1;function f(){l&&d(l),l=setTimeout(u(()=>{p(),l=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),l&&(d(l),l=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:!0})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return!1}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??!1,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return!0;return!1}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et="idle",it="ready",ot="collection-disabled",rt="init-failed",st={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ct(){const t={};for(const n of W)t[n]=lt(n,void 0,!0);return t}function at(t){const n={};for(const e of W)n[e]=lt(e,void 0,t[Q[e].layer]??!1);return n}function ut(t){const n={};for(const e of W){const i=t[e];n[e]=lt(e,i,i?.enabled??!1)}return n}function lt(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??!0};return{enabled:e,events:r}}function dt(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ht=function(t,n=30){if(!t)return!0;const e=dt(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function ft(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const pt="__tri",mt=`${pt}_activity_token`,wt=`${pt}_activity_id`,yt=`${pt}_activity_status`,vt="__tri_activity_lock";class bt{constructor(t){this.context=t,this.u=null,this.l=null,this.h=null,this.p=null,this.m=!1}getToken(){return this.u}getActivityId(){return this.l??""}isActive(){return"ACTIVE"===this.h&&null!==this.u}async start(){return this.m=!0,this.p||(this.p=this.v()),this.p}async stop(){this.m=!1,this.k(null),this.p=null,this.u&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.u;await ft(vt,async()=>{if(this.u&&this.u!==t&&!ht(this.u)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!ht(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.S(),await this.I())})}async v(){try{if(this.u&&!ht(this.u))return;await ft(vt,async()=>{await this.I()})}finally{this.p=null}}async I(){const t=this._();if(t&&!ht(t.token)&&"ACTIVE"===t.activityStatus)return void this.T(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.T(e),this.A(e)}_(){const[t,n,e]=[O.get(mt),O.get(wt),O.get(yt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}A(t){O.set(mt,t.token),O.set(wt,t.activityId),O.set(yt,t.activityStatus)}S(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(mt),O.remove(wt),void O.remove(yt);O.set(mt,t.token),O.set(wt,t.activityId),O.set(yt,t.activityStatus)}T(t){if(!t)return this.u=null,this.l=null,void(this.h=null);this.u=t.token,this.l=t.activityId,this.h=t.activityStatus}}const gt=[401,403,409],kt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function Tt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:kt[t.name]}const _t=new Array(256);for(let t=0;t<256;t++)_t[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return _t[t[0]]+_t[t[1]]+_t[t[2]]+_t[t[3]]+"-"+_t[t[4]]+_t[t[5]]+"-"+_t[t[6]]+_t[t[7]]+"-"+_t[t[8]]+_t[t[9]]+"-"+_t[t[10]]+_t[t[11]]+_t[t[12]]+_t[t[13]]+_t[t[14]]+_t[t[15]]}function It(){return crypto.randomUUID()}function Et(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function At(){for(let t=0;t<16;t++)xt[t]=256*Math.random()|0;return xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}const Mt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return It;if("function"==typeof crypto.getRandomValues)return Et}return At}();function Dt(){return Mt()}class Ct{constructor(t,n){this.M=t,this.D=n,this.C=[],this.P=null,this.R=[],this.L=null,this.m=!1,this.$=!0,this.U=0,this.B=0,this.O=t.flush.intervalMs}push(t){if(this.m){if(this.C.length<this.q()?this.C.push(t):this.j(t),this.$)return this.C.length>=this.M.flush.size?(d(this.P),this.P=null,void this.flush("capacity")):void this.H()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.m&&this.D.isActivityActive())try{if("lifecycle"===t)return void this.N();if(0===this.C.length)return;const e=this.F(t);this.D.ingest(e,!1).then(t=>this.X(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.C.length>0&&this.H()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.m||(this.m=!0,this.$="undefined"==typeof navigator||navigator.onLine)}stop(){if(!this.m)return Promise.resolve();d(this.P),this.P=null,d(this.L),this.L=null;const t=this.N();return this.m=!1,t}onConnectionChange(){const t="undefined"==typeof navigator||navigator.onLine;if(t!==this.$){if(this.$=t,!this.$)return d(this.P),this.P=null,d(this.L),void(this.L=null);this.C.length>0&&this.H(),this.R.length>0&&this.K()}}H(){this.m&&this.$&&null===this.P&&(this.P=l(()=>{this.P=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.L&&(this.L=l(()=>{this.L=null,this.V()},this.O))}V(){if(!this.m||!this.$||0===this.R.length||!this.D.isActivityActive())return;const t=this.R.shift();this.D.ingest(t.batch,!1).then(n=>this.Y(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.R.length>0&&this.K()})}J(t,e){this.R.length>=5&&(this.R.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.R.push({batch:t,attempts:e}),this.K()}X(t,n){t.ok?this.G():this.Z(t)&&this.J(n,1)}Y(t,e){if(t.ok)return this.G(),void(this.R.length>0&&this.K());if(this.Z(t)){if(e.attempts>=3)return this.W(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.R.length>0&&this.K());this.W(),this.J(e.batch,e.attempts+1)}else this.R.length>0&&this.K()}W(){this.U++,this.U%this.M.flush.backoffFailureThreshold===0&&(this.O=Math.min(2*this.O,this.M.flush.maxIntervalMs))}G(){this.U=0,this.O=this.M.flush.intervalMs}q(){return this.M.queue.size*(this.$?1:2)}async N(){if(!this.D.isActivityActive())return Promise.resolve();const t=[];for(const e of this.R)t.push(this.D.ingest(e.batch,!0).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.R=[],this.C.length>0){const e=this.F("lifecycle");t.push(this.D.ingest(e,!0).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}j(t){const n=Tt(t);for(let e=0;e<this.C.length;e++)if(Tt(this.C[e])<n){for(let t=e;t<this.C.length-1;t++)this.C[t]=this.C[t+1];return this.C.length-=1,void this.C.push(t)}}F(t){const n="lifecycle"===t?this.C.splice(-this.M.flush.size):this.C.splice(0,this.M.flush.size);return{activityId:"",batchId:Dt(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.0",sdkPlatform:"web",tabId:this.D.getTabId(),events:n}}Z(t){if(t.ok)return!1;switch(t.kind){case"timeout":case"server":case"rate_limited":return!0;default:return!1}}}const Pt="tri:bcast:";const Rt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return!1;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return!1}}()?class{constructor(t){this.seq=0,this.closed=!1,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${Pt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>O.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=Dt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Pt}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{O.set(n,t),O.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=!0,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},zt="__tri_tabId";class Lt{constructor(t){this.context=t,this.tt="",this.m=!1,this.nt=null,this.et=null,this.it=null,this.ot=new Map,this.rt=-1,this.st=null}async start(){this.m||(this.m=!0,this.tt=this.ct(),this.ut(),this.lt({type:"hello",tabId:this.tt,ts:Date.now()}),this.dt(),this.ht("active"),this.ft())}stop(){this.m&&(this.m=!1,this.ht("inactive"),this.lt({type:"bye",tabId:this.tt,ts:Date.now()}),this.wt(this.yt()),this.vt(),this.bt(),this.gt())}getTabId(){return this.tt}queryTabsNumber(){return this.ot.size+1}ut(){try{this.nt=new Rt("__tri_tab_channel"),this.st=this.kt.bind(this),this.nt.addEventListener("message",this.st)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}gt(){try{if(!this.nt)return;this.st&&this.nt.removeEventListener("message",this.st),this.nt.close()}catch{}finally{this.nt=null,this.st=null}}dt(){this.et=setInterval(()=>{const t=Date.now();this.lt({type:"heartbeat",tabId:this.tt,ts:t})},1e3)}vt(){null!=this.et&&(clearInterval(this.et),this.et=null)}ft(){null!=this.it&&clearTimeout(this.it),this.it=setTimeout(()=>{this.it=null;const t=this.yt()+1;t!==this.rt&&(this.rt=t,this.wt(t))},1e3)}bt(){null!=this.it&&(clearTimeout(this.it),this.it=null)}lt(t){try{if(!this.nt)return;this.nt.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}kt(t){const{type:n,tabId:e}=t.data;if(e===this.tt)return;const i=Date.now();"hello"===n?(this.lt({type:"ack",tabId:this.tt,ts:i,to:e}),this.ot.set(e,i)):"heartbeat"===n||"ack"===n?this.ot.set(e,i):"bye"===n&&this.ot.delete(e)}wt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.tt,timestamp:Date.now(),value:t})}ht(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.tt,timestamp:Date.now(),value:t})}ct(){const t=q.get(zt);if(t)return t;const n=Dt();return q.set(zt,n),n}yt(t=Date.now()){let n=0;for(const[e,i]of this.ot.entries())t-i>=3e3?this.ot.delete(e):n++;return n}}const $t=globalThis.CompressionStream,Ut=globalThis.Response,Bt=globalThis.Blob,Ot=new TextEncoder;let qt=null;async function jt(t){const e=await async function(t){if("function"!=typeof $t)return null;try{const n=Ot.encode(t),e=new Bt([n]).stream().pipeThrough(new $t("gzip"));return await new Ut(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===qt){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=l(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>import("./chunks/browser-DlFgHpoC.js"),1e4);qt=t,t.then(n=>{null===n&&l(()=>{qt===t&&(qt=null)},1e4)})}return qt}();if(null===e)return null;const{gzipSync:i}=e,o=i(Ot.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Ht(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Nt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Ft{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const Xt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Kt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Vt=255;function Yt(t,n,e){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(b(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const u=t.hasAttribute("readonly");u&&!_("readonly",e)&&(i.readOnly=u);const l=t.hasAttribute("required");l&&!_("required",e)&&(i.required=l);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:x(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Jt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Kt.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return!1;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Zt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Qt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function Wt(t,n=!1){if(n)return null;const e=nn(t,"labelledby");if(e)return{text:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=en(t);if(i)return{text:on(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?tn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?tn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:on(c),resolutionMethod:"title",confidence:"low"};const a=nn(t,"describedby");if(a)return{text:on(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=tn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function tn(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Vt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=tn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return on(e)}function nn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=en(n)??tn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function en(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function rn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class sn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,o){const{collectors:r,sdk:s}=t;let c=null,u=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Nt)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,u=!1;a=l(()=>{u=!0,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:!0}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:!0,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:!0,body:t};try{return{ok:!0,body:JSON.stringify(t)}}catch{return{ok:!1}}}(r.body);if(!t.ok)return d(a),p(),{ok:!1,kind:"serialize"};f=t.body}try{const n=await Nt(s,{method:t,headers:Ht({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:!1,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:!1,kind:"client",status:m}:{ok:!1,kind:"server",status:m};if(204===n.status)return{ok:!0,data:void 0,status:204};try{return{ok:!0,data:await n.json(),status:n.status}}catch{return c.signal.aborted?u?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return u?{ok:!1,kind:"timeout"}:c.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!gt.includes(a.status)||!1===r?.refreshable)return c;var a;const u=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return u&&u!==s?t(u):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await jt(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:!1,kind:"serialize"}}return e.post("/events/capture",{body:u.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:!0,...o()}),{refreshable:!1})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>u?.getToken()??null,refresh:async()=>u?.refresh()??Promise.resolve(),getActivityId:()=>u?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};u=new bt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Ct(st,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new Lt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>u?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new sn(6),i=new sn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||b(e,"body"))break;e=g(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=rn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Yt(r,s,rn(r)),{score:u,reasons:l}=Jt(r,c);if(e.push(a),!Gt(u))continue;const d=Wt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:u,reasons:l})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Yt(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Jt(t,0);return{interactive:Gt(i),...o.length>0?{reasons:o}:{},disabled:Qt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Zt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let u=null;return e||(u=a.interactive?Wt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...u?{label:u}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??!1}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new Ft({getActivityId:()=>u?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:u,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let an=class t{constructor(){this.Tt=0,this._t=null,this.xt=et}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if(this.xt!==et)return n.fatal("error","setup()",`cannot set up from state '${this.xt}' — call reset() (or reload) first. Ignoring.`),rt;try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??!1};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:ct()}:void 0!==t.collectors?{sdk:o,collectors:ut(t.collectors)}:{sdk:o,collectors:at(t.layers)}}(t);if(!e)return this.xt=rt,rt;n.DEBUG=e.sdk.DEBUG;const i=await cn(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.xt=ot,ot):"init-failed"===i.status?(this.xt=rt,rt):(this._t=i.managers,this.xt=it,it)}catch(t){return n.warn("setup()","failed:",t),this.xt=rt,rt}}async start(){if(this.xt===et)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.xt;if(this.xt!==it)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.xt;this.xt="starting";const t=++this.Tt;return await this.v(t),this.xt}async stop(){n.warn("stop()","called");const t=this._t;return t?(++this.Tt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.xt=it,this.St(t)):Promise.resolve(this.xt)}async reset(){const t=this.stop();return this.xt=et,this._t=null,t.then(()=>this.xt)}async St(t){return await function(t){let n=null;const e=new Promise(t=>{n=l(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.xt}async v(t){const e=this._t;if(e){try{if(await e.activityManager.start(),t!==this.Tt)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this.Tt)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this.Tt&&(this.xt=it))}t===this.Tt&&(this.xt="started")}}};async function un(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=!1,c=()=>{};i&&(r=l(()=>{s=!0,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:!0}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,expiresAt:null,tokenType:null,eventsCollectionEnabled:!1,error:{status:n.status,message:t}}}const i=await n.json();return{token:i.token,expiresAt:i.expiresAt,tokenType:i.tokenType,eventsCollectionEnabled:!0,error:null}}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}}an.i=null;const ln=an.instance;export{un as createSession,ln as default};