@incodetech/tri-sdk 0.5.0 → 0.5.1-rc.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.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"t",{value:!0});class t{constructor(){this.i=!1}static get instance(){return t.o||(t.o=new t),t.o}get DEBUG(){return this.i}set DEBUG(t){this.i=t}warn(t,n,...e){this.i&&this.u("warn",t,n,...e)}error(t,n,...e){this.i&&this.u("error",t,n,...e)}info(t,n,...e){this.i&&this.u("info",t,n,...e)}fatal(t,n,e,...i){this.u(t,n,e,...i)}u(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 I(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function x(t,n){return!t||(t[n]?.enabled??!1)}function S(){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(R))},i.async=!0,i.src=t,r.appendChild(i)})}(t)).then(M)}const z="API key required";var L="3.12.9";const R="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function O(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 q=O("localStorage"),B=O("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(z);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===R){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(L):t)}(String(t),n))}(s,r),P)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(R):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};q.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=q.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(q.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 x(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),x(o,"click")&&e(document,"click",r),x(o,"dblclick")&&e(document,"dblclick",r),x(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"):S())??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 x(o,"paste")&&e(document,"paste",r),x(o,"cut")&&e(document,"cut",r),x(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 x(o,"submit")&&e(document,"submit",r),x(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=S();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 x(o,"orientationchange")&&e(window,"orientationchange",r),x(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 x(o,"motion")&&e(window,"devicemotion",m),x(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),x(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="started",rt="collection-disabled",st="init-failed",ct={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function at(){const t={};for(const n of W)t[n]=dt(n,void 0,!0);return t}function ut(t){const n={};for(const e of W)n[e]=dt(e,void 0,t[Q[e].layer]??!1);return n}function lt(t){const n={};for(const e of W){const i=t[e];n[e]=dt(e,i,i?.enabled??!1)}return n}function dt(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 ht(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ft=function(t,n=30){if(!t)return!0;const e=ht(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function pt(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 mt="__tri",wt=`${mt}_activity_token`,yt=`${mt}_activity_id`,vt=`${mt}_activity_status`,bt="__tri_activity_lock";class gt{constructor(t){this.context=t,this.l=null,this.h=null,this.p=null,this.m=null,this.v=!1}getToken(){return this.l}getActivityId(){return this.h??""}isActive(){return"ACTIVE"===this.p&&null!==this.l}async start(){return this.v=!0,this.m||(this.m=this.k()),this.m}async stop(){this.v=!1,this.T(null),this.m=null,this.l&&await this.context.stopActivity(),this._(null)}async refresh(){if(!this.v)return;const t=this.l;await pt(bt,async()=>{if(this.l&&this.l!==t&&!ft(this.l)&&"ACTIVE"===this.p)return;const n=this.I();n&&n.token!==t&&!ft(n.token)&&"ACTIVE"===n.activityStatus?this._(n):(this.S(),await this.A())})}async k(){try{if(this.l&&!ft(this.l))return;await pt(bt,async()=>{await this.A()})}finally{this.m=null}}async A(){const t=this.I();if(t&&!ft(t.token)&&"ACTIVE"===t.activityStatus)return void this._(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this._(e),this.M(e)}I(){const[t,n,e]=[q.get(wt),q.get(yt),q.get(vt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}M(t){q.set(wt,t.token),q.set(yt,t.activityId),q.set(vt,t.activityStatus)}S(){this.T(null),this._(null)}T(t){if(!t)return q.remove(wt),q.remove(yt),void q.remove(vt);q.set(wt,t.token),q.set(yt,t.activityId),q.set(vt,t.activityStatus)}_(t){if(!t)return this.l=null,this.h=null,void(this.p=null);this.l=t.token,this.h=t.activityId,this.p=t.activityStatus}}const kt=[401,403,409],Tt=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 _t(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:Tt[t.name]}const It=new Array(256);for(let t=0;t<256;t++)It[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return It[t[0]]+It[t[1]]+It[t[2]]+It[t[3]]+"-"+It[t[4]]+It[t[5]]+"-"+It[t[6]]+It[t[7]]+"-"+It[t[8]]+It[t[9]]+"-"+It[t[10]]+It[t[11]]+It[t[12]]+It[t[13]]+It[t[14]]+It[t[15]]}function Et(){return crypto.randomUUID()}function At(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function Mt(){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 Dt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Et;if("function"==typeof crypto.getRandomValues)return At}return Mt}();function Ct(){return Dt()}class Pt{constructor(t,n){this.D=t,this.C=n,this.P=[],this.L=null,this.R=[],this.$=null,this.v=!1,this.U=!0,this.O=0,this.q=0,this.B=t.flush.intervalMs}push(t){if(this.v){if(this.P.length<this.j()?this.P.push(t):this.H(t),this.U)return this.P.length>=this.D.flush.size?(d(this.L),this.L=null,void this.flush("capacity")):void this.N()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.v&&this.C.isActivityActive())try{if("lifecycle"===t)return void this.F();if(0===this.P.length)return;const e=this.X(t);this.C.ingest(e,!1).then(t=>this.K(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.P.length>0&&this.N()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.v||(this.v=!0,this.U="undefined"==typeof navigator||navigator.onLine)}stop(){if(!this.v)return Promise.resolve();d(this.L),this.L=null,d(this.$),this.$=null;const t=this.F();return this.v=!1,t}onConnectionChange(){const t="undefined"==typeof navigator||navigator.onLine;if(t!==this.U){if(this.U=t,!this.U)return d(this.L),this.L=null,d(this.$),void(this.$=null);this.P.length>0&&this.N(),this.R.length>0&&this.V()}}N(){this.v&&this.U&&null===this.L&&(this.L=l(()=>{this.L=null,this.flush("interval")},this.B))}V(){this.v&&this.U&&null===this.$&&(this.$=l(()=>{this.$=null,this.Y()},this.B))}Y(){if(!this.v||!this.U||0===this.R.length||!this.C.isActivityActive())return;const t=this.R.shift();this.C.ingest(t.batch,!1).then(n=>this.J(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.R.length>0&&this.V()})}G(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.V()}K(t,n){t.ok?this.Z():this.W(t)&&this.G(n,1)}J(t,e){if(t.ok)return this.Z(),void(this.R.length>0&&this.V());if(this.W(t)){if(e.attempts>=3)return this.tt(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.R.length>0&&this.V());this.tt(),this.G(e.batch,e.attempts+1)}else this.R.length>0&&this.V()}tt(){this.O++,this.O%this.D.flush.backoffFailureThreshold===0&&(this.B=Math.min(2*this.B,this.D.flush.maxIntervalMs))}Z(){this.O=0,this.B=this.D.flush.intervalMs}j(){return this.D.queue.size*(this.U?1:2)}async F(){if(!this.C.isActivityActive())return Promise.resolve();const t=[];for(const e of this.R)t.push(this.C.ingest(e.batch,!0).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.R=[],this.P.length>0){const e=this.X("lifecycle");t.push(this.C.ingest(e,!0).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}H(t){const n=_t(t);for(let e=0;e<this.P.length;e++)if(_t(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)}}X(t){const n="lifecycle"===t?this.P.splice(-this.D.flush.size):this.P.splice(0,this.D.flush.size);return{activityId:"",batchId:Ct(),batchSequence:this.q++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.5.0",sdkPlatform:"web",tabId:this.C.getTabId(),events:n}}W(t){if(t.ok)return!1;switch(t.kind){case"timeout":case"server":case"rate_limited":return!0;default:return!1}}}const zt="tri:bcast:";const Lt="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(`${zt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>q.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=Ct(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${zt}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{q.set(n,t),q.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(){}},Rt="__tri_tabId";class $t{constructor(t){this.context=t,this.nt="",this.v=!1,this.et=null,this.it=null,this.ot=null,this.rt=new Map,this.st=-1,this.ct=null}async start(){this.v||(this.v=!0,this.nt=this.ut(),this.lt(),this.dt({type:"hello",tabId:this.nt,ts:Date.now()}),this.ht(),this.ft("active"),this.wt())}stop(){this.v&&(this.v=!1,this.ft("inactive"),this.dt({type:"bye",tabId:this.nt,ts:Date.now()}),this.yt(this.vt()),this.bt(),this.gt(),this.kt())}getTabId(){return this.nt}queryTabsNumber(){return this.rt.size+1}lt(){try{this.et=new Lt("__tri_tab_channel"),this.ct=this.Tt.bind(this),this.et.addEventListener("message",this.ct)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}kt(){try{if(!this.et)return;this.ct&&this.et.removeEventListener("message",this.ct),this.et.close()}catch{}finally{this.et=null,this.ct=null}}ht(){this.it=setInterval(()=>{const t=Date.now();this.dt({type:"heartbeat",tabId:this.nt,ts:t})},1e3)}bt(){null!=this.it&&(clearInterval(this.it),this.it=null)}wt(){null!=this.ot&&clearTimeout(this.ot),this.ot=setTimeout(()=>{this.ot=null;const t=this.vt()+1;t!==this.st&&(this.st=t,this.yt(t))},1e3)}gt(){null!=this.ot&&(clearTimeout(this.ot),this.ot=null)}dt(t){try{if(!this.et)return;this.et.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}Tt(t){const{type:n,tabId:e}=t.data;if(e===this.nt)return;const i=Date.now();"hello"===n?(this.dt({type:"ack",tabId:this.nt,ts:i,to:e}),this.rt.set(e,i)):"heartbeat"===n||"ack"===n?this.rt.set(e,i):"bye"===n&&this.rt.delete(e)}yt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.nt,timestamp:Date.now(),value:t})}ft(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.nt,timestamp:Date.now(),value:t})}ut(){const t=B.get(Rt);if(t)return t;const n=Ct();return B.set(Rt,n),n}vt(t=Date.now()){let n=0;for(const[e,i]of this.rt.entries())t-i>=3e3?this.rt.delete(e):n++;return n}}const Ut=globalThis.CompressionStream,Ot=globalThis.Response,qt=globalThis.Blob,Bt=new TextEncoder;let jt=null;async function Ht(t){const e=await async function(t){if("function"!=typeof Ut)return null;try{const n=Bt.encode(t),e=new qt([n]).stream().pipeThrough(new Ut("gzip"));return await new Ot(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===jt){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)})}(()=>Promise.resolve().then(function(){return require("./chunks/browser-BS2-bItW.cjs")}),1e4);jt=t,t.then(n=>{null===n&&l(()=>{jt===t&&(jt=null)},1e4)})}return jt}();if(null===e)return null;const{gzipSync:i}=e,o=i(Bt.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 Nt(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 Ft="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Xt{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 Kt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Vt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Yt=255;function Jt(t,n,e,i=nt){const o=t.tagName.toLowerCase(),r=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),s=function(t,n,e){const i=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),o={},r=t.id;r&&!_("id",i)&&(o.id=r);const s=t.getAttribute("autocomplete");s&&!_("autocomplete",i)&&(o.autocomplete=s);const c=t.getAttribute("aria-invalid");c&&!_("aria-invalid",i)&&(o.ariaInvalid=c);const a=t.getAttribute("tabindex");a&&!_("tabindex",i)&&(o.tabIndex=parseInt(a,10));const u=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);u&&!_("data-testid",i)&&(o.testId=u);const l=t.hasAttribute("readonly");l&&!_("readonly",i)&&(o.readOnly=l);const d=t.hasAttribute("required");d&&!_("required",i)&&(o.required=d);const h=t.getAttribute("contenteditable");h&&!_("contenteditable",i)&&(o.contentEditable="true"===h||""===h);const f=t.getAttribute("href");f&&!_("href",i)&&(o.href={...n?{}:{url:e(f)},external:I(f)});const p=t.getAttribute("role");p&&!_("role",i)&&(o.role=p);const m=t.getAttribute("type");m&&!_("type",i)&&(o.type=m);const w=t.getAttribute("name");w&&!_("name",i)&&(o.name=w);const y=t.getAttribute("placeholder");!y||n||_("placeholder",i)||(o.placeholder=y);const v=Array.from(t.classList).slice(0,5);v.length>0&&!_("class",i)&&(o.classes=v);const b=t.getAttribute("alt");return!b||n||_("alt",i)||(o.alt=b),Object.keys(o).length?o:null}(t,n,i);return{tagName:o,frame:e,...s?{attributes:s}:{},...r?{nth:r}:{}}}function Gt(t,n){let e=0;const i=[];return function(t){return Kt.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&&Vt.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 Zt(t){return t>=20}function Qt(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 Wt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function tn(t,n=!1){if(n)return null;const e=en(t,"labelledby");if(e)return{text:rn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=on(t);if(i)return{text:rn(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?nn(n):null}(t);if(o)return{text:rn(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?nn(n):null}(t);if(r)return{text:rn(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:rn(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:rn(c),resolutionMethod:"title",confidence:"low"};const a=en(t,"describedby");if(a)return{text:rn(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=nn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function nn(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,Yt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=nn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Yt))break}return rn(e)}function en(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=on(n)??nn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function on(t){return t?.getAttribute("aria-label")?.trim()??null}function rn(t){return t.length>Yt?t.slice(0,Yt)+"...":t}function sn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class cn{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 an(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===Ft)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 Ft(s,{method:t,headers:Nt({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||!kt.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 Ht(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 gt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Pt(ct,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new $t({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{elementLevel:n,sanitizeUrl:e=nt}=t,i=n||"redact",o=new cn(6),r=new cn(6);return{resolve:function(t){if(!t||k(t)||"off"===i)return null;let n=o.get(t);if(n||(n=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),o.set(t,n)),"ignore"===n.redaction.level)return null;const s="redact"===n.redaction.level||"redact"===i||T(t);let c=r.get(t);return c||(c=function(t,n,i,o){const r=getComputedStyle(t),s=sn(t),c=function(t,n,e=!1,i=nt){const o=[],r=[];for(let s=t.length-1;s>=0;s--){const c=t[s],a=e||s<=n,u=s+1,l=Jt(c,a,sn(c),i),{score:d,reasons:h}=Gt(c,u);if(o.push(l),!Zt(d))continue;const f=tn(c,a);r.push({...l,...f?{label:f}:{},depth:u,score:d,reasons:h})}return{ancestors:o,interactiveCandidates:r.reverse()}}(n,o,i,e),a=Jt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:o}=Gt(t,0);return{interactive:Zt(i),...o.length>0?{reasons:o}:{},disabled:Wt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Qt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let l=null;return i||(l=u.interactive?tn(t):null),{tagName:a.tagName,frame:a.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:a.attributes,nth:a.nth,...l?{label:l}:{},ancestors:c.ancestors,interactiveCandidates:c.interactiveCandidates,interactivity:u}}(t,n.chain,s,n.redaction.index),r.set(t,c)),c}}}({elementLevel:s.capture?.element,sanitizeUrl:s.sanitizeUrl}),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 Xt({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 un=class t{constructor(){this._t=0,this.It=null,this.xt=et}static get instance(){return t.o||(t.o=new t),t.o}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.`),st;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:at()}:void 0!==t.collectors?{sdk:o,collectors:lt(t.collectors)}:{sdk:o,collectors:ut(t.layers)}}(t);if(!e)return this.xt=st,st;n.DEBUG=e.sdk.DEBUG;const i=await an(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.xt=rt,rt):"init-failed"===i.status?(this.xt=st,st):(this.It=i.managers,this.xt=it,!1!==t.autostart?this.start():it)}catch(t){return n.warn("setup()","failed:",t),this.xt=st,st}}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._t;return await this.k(t),this.xt}async stop(){n.warn("stop()","called");const t=this.It;return t?(++this._t,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.It=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 k(t){const e=this.It;if(e){try{if(await e.activityManager.start(),t!==this._t)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this._t)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this._t&&(this.xt=it))}t===this._t&&(this.xt=ot)}}async linkInterview(t){if(this.xt!==ot||!this.It)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),!1;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),!1;try{return(await this.It.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),!1}}};un.o=null;const ln=un.instance;exports.createSession=async function(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()}},exports.default=ln;
1
+ "use strict";Object.defineProperty(exports,"t",{value:!0});class t{constructor(){this.i=!1}static get instance(){return t.o||(t.o=new t),t.o}get DEBUG(){return this.i}set DEBUG(t){this.i=t}warn(t,n,...e){this.i&&this.u("warn",t,n,...e)}error(t,n,...e){this.i&&this.u("error",t,n,...e)}info(t,n,...e){this.i&&this.u("info",t,n,...e)}fatal(t,n,e,...i){this.u(t,n,e,...i)}u(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 I(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function x(t,n){return!t||(t[n]?.enabled??!1)}function S(){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(R))},i.async=!0,i.src=t,r.appendChild(i)})}(t)).then(M)}const z="API key required";var L="3.12.9";const R="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function O(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 q=O("localStorage"),B=O("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(z);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===R){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(L):t)}(String(t),n))}(s,r),P)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(R):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};q.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=q.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(q.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 x(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),x(o,"click")&&e(document,"click",r),x(o,"dblclick")&&e(document,"dblclick",r),x(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"):S())??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 x(o,"paste")&&e(document,"paste",r),x(o,"cut")&&e(document,"cut",r),x(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 x(o,"submit")&&e(document,"submit",r),x(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=S();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 x(o,"orientationchange")&&e(window,"orientationchange",r),x(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 x(o,"motion")&&e(window,"devicemotion",m),x(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),x(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="started",rt="collection-disabled",st="init-failed",ct={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function at(){const t={};for(const n of W)t[n]=dt(n,void 0,!0);return t}function ut(t){const n={};for(const e of W)n[e]=dt(e,void 0,t[Q[e].layer]??!1);return n}function lt(t){const n={};for(const e of W){const i=t[e];n[e]=dt(e,i,i?.enabled??!1)}return n}function dt(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 ht(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ft=function(t,n=30){if(!t)return!0;const e=ht(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function pt(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 mt="__tri",wt=`${mt}_activity_token`,yt=`${mt}_activity_id`,vt=`${mt}_activity_status`,bt="__tri_activity_lock";class gt{constructor(t){this.context=t,this.l=null,this.h=null,this.p=null,this.m=null,this.v=!1}getToken(){return this.l}getActivityId(){return this.h??""}isActive(){return"ACTIVE"===this.p&&null!==this.l}async start(){return this.v=!0,this.m||(this.m=this.k()),this.m}async stop(){this.v=!1,this.T(null),this.m=null,this.l&&await this.context.stopActivity(),this._(null)}async refresh(){if(!this.v)return;const t=this.l;await pt(bt,async()=>{if(this.l&&this.l!==t&&!ft(this.l)&&"ACTIVE"===this.p)return;const n=this.I();n&&n.token!==t&&!ft(n.token)&&"ACTIVE"===n.activityStatus?this._(n):(this.S(),await this.A())})}async k(){try{if(this.l&&!ft(this.l))return;await pt(bt,async()=>{await this.A()})}finally{this.m=null}}async A(){const t=this.I();if(t&&!ft(t.token)&&"ACTIVE"===t.activityStatus)return void this._(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this._(e),this.M(e)}I(){const[t,n,e]=[q.get(wt),q.get(yt),q.get(vt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}M(t){q.set(wt,t.token),q.set(yt,t.activityId),q.set(vt,t.activityStatus)}S(){this.T(null),this._(null)}T(t){if(!t)return q.remove(wt),q.remove(yt),void q.remove(vt);q.set(wt,t.token),q.set(yt,t.activityId),q.set(vt,t.activityStatus)}_(t){if(!t)return this.l=null,this.h=null,void(this.p=null);this.l=t.token,this.h=t.activityId,this.p=t.activityStatus}}const kt=[401,403,409],Tt=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 _t(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:Tt[t.name]}const It=new Array(256);for(let t=0;t<256;t++)It[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return It[t[0]]+It[t[1]]+It[t[2]]+It[t[3]]+"-"+It[t[4]]+It[t[5]]+"-"+It[t[6]]+It[t[7]]+"-"+It[t[8]]+It[t[9]]+"-"+It[t[10]]+It[t[11]]+It[t[12]]+It[t[13]]+It[t[14]]+It[t[15]]}function Et(){return crypto.randomUUID()}function At(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function Mt(){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 Dt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Et;if("function"==typeof crypto.getRandomValues)return At}return Mt}();function Ct(){return Dt()}class Pt{constructor(t,n){this.D=t,this.C=n,this.P=[],this.L=null,this.R=[],this.$=null,this.v=!1,this.U=!0,this.O=0,this.q=0,this.B=t.flush.intervalMs}push(t){if(this.v){if(this.P.length<this.j()?this.P.push(t):this.H(t),this.U)return this.P.length>=this.D.flush.size?(d(this.L),this.L=null,void this.flush("capacity")):void this.N()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.v&&this.C.isActivityActive())try{if("lifecycle"===t)return void this.F();if(0===this.P.length)return;const e=this.X(t);this.C.ingest(e,!1).then(t=>this.K(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.P.length>0&&this.N()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.v||(this.v=!0,this.U="undefined"==typeof navigator||navigator.onLine)}stop(){if(!this.v)return Promise.resolve();d(this.L),this.L=null,d(this.$),this.$=null;const t=this.F();return this.v=!1,t}onConnectionChange(){const t="undefined"==typeof navigator||navigator.onLine;if(t!==this.U){if(this.U=t,!this.U)return d(this.L),this.L=null,d(this.$),void(this.$=null);this.P.length>0&&this.N(),this.R.length>0&&this.V()}}N(){this.v&&this.U&&null===this.L&&(this.L=l(()=>{this.L=null,this.flush("interval")},this.B))}V(){this.v&&this.U&&null===this.$&&(this.$=l(()=>{this.$=null,this.Y()},this.B))}Y(){if(!this.v||!this.U||0===this.R.length||!this.C.isActivityActive())return;const t=this.R.shift();this.C.ingest(t.batch,!1).then(n=>this.J(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.R.length>0&&this.V()})}G(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.V()}K(t,n){t.ok?this.Z():this.W(t)&&this.G(n,1)}J(t,e){if(t.ok)return this.Z(),void(this.R.length>0&&this.V());if(this.W(t)){if(e.attempts>=3)return this.tt(),n.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",e.batch.batchId),void(this.R.length>0&&this.V());this.tt(),this.G(e.batch,e.attempts+1)}else this.R.length>0&&this.V()}tt(){this.O++,this.O%this.D.flush.backoffFailureThreshold===0&&(this.B=Math.min(2*this.B,this.D.flush.maxIntervalMs))}Z(){this.O=0,this.B=this.D.flush.intervalMs}j(){return this.D.queue.size*(this.U?1:2)}async F(){if(!this.C.isActivityActive())return Promise.resolve();const t=[];for(const e of this.R)t.push(this.C.ingest(e.batch,!0).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.R=[],this.P.length>0){const e=this.X("lifecycle");t.push(this.C.ingest(e,!0).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}H(t){const n=_t(t);for(let e=0;e<this.P.length;e++)if(_t(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)}}X(t){const n="lifecycle"===t?this.P.splice(-this.D.flush.size):this.P.splice(0,this.D.flush.size);return{activityId:"",batchId:Ct(),batchSequence:this.q++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.5.1-rc.0",sdkPlatform:"web",tabId:this.C.getTabId(),events:n}}W(t){if(t.ok)return!1;switch(t.kind){case"timeout":case"server":case"rate_limited":return!0;default:return!1}}}const zt="tri:bcast:";const Lt="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(`${zt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>q.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=Ct(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${zt}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{q.set(n,t),q.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(){}},Rt="__tri_tabId";class $t{constructor(t){this.context=t,this.nt="",this.v=!1,this.et=null,this.it=null,this.ot=null,this.rt=new Map,this.st=-1,this.ct=null}async start(){this.v||(this.v=!0,this.nt=this.ut(),this.lt(),this.dt({type:"hello",tabId:this.nt,ts:Date.now()}),this.ht(),this.ft("active"),this.wt())}stop(){this.v&&(this.v=!1,this.ft("inactive"),this.dt({type:"bye",tabId:this.nt,ts:Date.now()}),this.yt(this.vt()),this.bt(),this.gt(),this.kt())}getTabId(){return this.nt}queryTabsNumber(){return this.rt.size+1}lt(){try{this.et=new Lt("__tri_tab_channel"),this.ct=this.Tt.bind(this),this.et.addEventListener("message",this.ct)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}kt(){try{if(!this.et)return;this.ct&&this.et.removeEventListener("message",this.ct),this.et.close()}catch{}finally{this.et=null,this.ct=null}}ht(){this.it=setInterval(()=>{const t=Date.now();this.dt({type:"heartbeat",tabId:this.nt,ts:t})},1e3)}bt(){null!=this.it&&(clearInterval(this.it),this.it=null)}wt(){null!=this.ot&&clearTimeout(this.ot),this.ot=setTimeout(()=>{this.ot=null;const t=this.vt()+1;t!==this.st&&(this.st=t,this.yt(t))},1e3)}gt(){null!=this.ot&&(clearTimeout(this.ot),this.ot=null)}dt(t){try{if(!this.et)return;this.et.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}Tt(t){const{type:n,tabId:e}=t.data;if(e===this.nt)return;const i=Date.now();"hello"===n?(this.dt({type:"ack",tabId:this.nt,ts:i,to:e}),this.rt.set(e,i)):"heartbeat"===n||"ack"===n?this.rt.set(e,i):"bye"===n&&this.rt.delete(e)}yt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.nt,timestamp:Date.now(),value:t})}ft(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.nt,timestamp:Date.now(),value:t})}ut(){const t=B.get(Rt);if(t)return t;const n=Ct();return B.set(Rt,n),n}vt(t=Date.now()){let n=0;for(const[e,i]of this.rt.entries())t-i>=3e3?this.rt.delete(e):n++;return n}}const Ut=globalThis.CompressionStream,Ot=globalThis.Response,qt=globalThis.Blob,Bt=new TextEncoder;let jt=null;async function Ht(t){const e=await async function(t){if("function"!=typeof Ut)return null;try{const n=Bt.encode(t),e=new qt([n]).stream().pipeThrough(new Ut("gzip"));return await new Ot(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===jt){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)})}(()=>Promise.resolve().then(function(){return require("./chunks/browser-BS2-bItW.cjs")}),1e4);jt=t,t.then(n=>{null===n&&l(()=>{jt===t&&(jt=null)},1e4)})}return jt}();if(null===e)return null;const{gzipSync:i}=e,o=i(Bt.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 Nt(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 Ft="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Xt{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 Kt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Vt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Yt=255;function Jt(t,n,e,i=nt){const o=t.tagName.toLowerCase(),r=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),s=function(t,n,e){const i=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),o={},r=t.id;r&&!_("id",i)&&(o.id=r);const s=t.getAttribute("autocomplete");s&&!_("autocomplete",i)&&(o.autocomplete=s);const c=t.getAttribute("aria-invalid");c&&!_("aria-invalid",i)&&(o.ariaInvalid=c);const a=t.getAttribute("tabindex");a&&!_("tabindex",i)&&(o.tabIndex=parseInt(a,10));const u=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);u&&!_("data-testid",i)&&(o.testId=u);const l=t.hasAttribute("readonly");l&&!_("readonly",i)&&(o.readOnly=l);const d=t.hasAttribute("required");d&&!_("required",i)&&(o.required=d);const h=t.getAttribute("contenteditable");h&&!_("contenteditable",i)&&(o.contentEditable="true"===h||""===h);const f=t.getAttribute("href");f&&!_("href",i)&&(o.href={...n?{}:{url:e(f)},external:I(f)});const p=t.getAttribute("role");p&&!_("role",i)&&(o.role=p);const m=t.getAttribute("type");m&&!_("type",i)&&(o.type=m);const w=t.getAttribute("name");w&&!_("name",i)&&(o.name=w);const y=t.getAttribute("placeholder");!y||n||_("placeholder",i)||(o.placeholder=y);const v=Array.from(t.classList).slice(0,5);v.length>0&&!_("class",i)&&(o.classes=v);const b=t.getAttribute("alt");return!b||n||_("alt",i)||(o.alt=b),Object.keys(o).length?o:null}(t,n,i);return{tagName:o,frame:e,...s?{attributes:s}:{},...r?{nth:r}:{}}}function Gt(t,n){let e=0;const i=[];return function(t){return Kt.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&&Vt.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 Zt(t){return t>=20}function Qt(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 Wt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function tn(t,n=!1){if(n)return null;const e=en(t,"labelledby");if(e)return{text:rn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=on(t);if(i)return{text:rn(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?nn(n):null}(t);if(o)return{text:rn(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?nn(n):null}(t);if(r)return{text:rn(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:rn(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:rn(c),resolutionMethod:"title",confidence:"low"};const a=en(t,"describedby");if(a)return{text:rn(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=nn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function nn(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,Yt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=nn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Yt))break}return rn(e)}function en(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=on(n)??nn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function on(t){return t?.getAttribute("aria-label")?.trim()??null}function rn(t){return t.length>Yt?t.slice(0,Yt)+"...":t}function sn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class cn{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 an(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===Ft)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 Ft(s,{method:t,headers:Nt({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||!kt.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 Ht(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 gt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Pt(ct,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new $t({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{elementLevel:n,sanitizeUrl:e=nt}=t,i=n||"redact",o=new cn(6),r=new cn(6);return{resolve:function(t){if(!t||k(t)||"off"===i)return null;let n=o.get(t);if(n||(n=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;if(g(t))e=t.host;else{if(t.nodeType!==Node.ELEMENT_NODE)break;e=t}}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),o.set(t,n)),"ignore"===n.redaction.level)return null;const s="redact"===n.redaction.level||"redact"===i||T(t);let c=r.get(t);return c||(c=function(t,n,i,o){const r=getComputedStyle(t),s=sn(t),c=function(t,n,e=!1,i=nt){const o=[],r=[];for(let s=t.length-1;s>=0;s--){const c=t[s],a=e||s<=n,u=s+1,l=Jt(c,a,sn(c),i),{score:d,reasons:h}=Gt(c,u);if(o.push(l),!Zt(d))continue;const f=tn(c,a);r.push({...l,...f?{label:f}:{},depth:u,score:d,reasons:h})}return{ancestors:o,interactiveCandidates:r.reverse()}}(n,o,i,e),a=Jt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:o}=Gt(t,0);return{interactive:Zt(i),...o.length>0?{reasons:o}:{},disabled:Wt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Qt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let l=null;return i||(l=u.interactive?tn(t):null),{tagName:a.tagName,frame:a.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:a.attributes,nth:a.nth,...l?{label:l}:{},ancestors:c.ancestors,interactiveCandidates:c.interactiveCandidates,interactivity:u}}(t,n.chain,s,n.redaction.index),r.set(t,c)),c}}}({elementLevel:s.capture?.element,sanitizeUrl:s.sanitizeUrl}),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 Xt({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 un=class t{constructor(){this._t=0,this.It=null,this.xt=et}static get instance(){return t.o||(t.o=new t),t.o}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.`),st;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:at()}:void 0!==t.collectors?{sdk:o,collectors:lt(t.collectors)}:{sdk:o,collectors:ut(t.layers)}}(t);if(!e)return this.xt=st,st;n.DEBUG=e.sdk.DEBUG;const i=await an(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.xt=rt,rt):"init-failed"===i.status?(this.xt=st,st):(this.It=i.managers,this.xt=it,!1!==t.autostart?this.start():it)}catch(t){return n.warn("setup()","failed:",t),this.xt=st,st}}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._t;return await this.k(t),this.xt}async stop(){n.warn("stop()","called");const t=this.It;return t?(++this._t,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.It=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 k(t){const e=this.It;if(e){try{if(await e.activityManager.start(),t!==this._t)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this._t)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this._t&&(this.xt=it))}t===this._t&&(this.xt=ot)}}async linkInterview(t){if(this.xt!==ot||!this.It)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),!1;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),!1;try{return(await this.It.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),!1}}};un.o=null;const ln=un.instance;exports.createSession=async function(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()}},exports.default=ln;
package/dist/tri.esm.js CHANGED
@@ -1 +1 @@
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 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")}function T(t){return!!t&&t.hasAttribute("data-tri-redact")}function _(t,n){return n?.includes(t.toLowerCase())??!1}function I(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function x(t,n){return!t||(t[n]?.enabled??!1)}function S(){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(R))},i.async=!0,i.src=t,r.appendChild(i)})}(t)).then(M)}const z="API key required";var L="3.12.9";const R="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(z);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===R){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(L):t)}(String(t),n))}(s,r),P)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(R):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 x(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),x(o,"click")&&e(document,"click",r),x(o,"dblclick")&&e(document,"dblclick",r),x(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"):S())??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 x(o,"paste")&&e(document,"paste",r),x(o,"cut")&&e(document,"cut",r),x(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 x(o,"submit")&&e(document,"submit",r),x(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,l=!1;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=!1,u(),function(e){const i=A("end"),o=i&&E(i,n),r=S();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,u())}),m=a(t=>{0===t.button&&(c=!1,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(l=!0,u())}),y=a(t=>{"Shift"===t.key&&(l=!1,o&&h("keyboard"))}),v=a(()=>{c=!1}),g=a(()=>{"hidden"===document.visibilityState&&(c=!1,l=!1,o&&h("timeout"))}),b=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",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 x(o,"orientationchange")&&e(window,"orientationchange",r),x(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=!1;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 x(o,"motion")&&e(window,"devicemotion",m),x(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),x(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:!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="started",rt="collection-disabled",st="init-failed",ct={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function at(){const t={};for(const n of W)t[n]=dt(n,void 0,!0);return t}function lt(t){const n={};for(const e of W)n[e]=dt(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]=dt(e,i,i?.enabled??!1)}return n}function dt(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 ht(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ft=function(t,n=30){if(!t)return!0;const e=ht(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function pt(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 mt="__tri",wt=`${mt}_activity_token`,yt=`${mt}_activity_id`,vt=`${mt}_activity_status`,gt="__tri_activity_lock";class bt{constructor(t){this.context=t,this.l=null,this.u=null,this.h=null,this.p=null,this.m=!1}getToken(){return this.l}getActivityId(){return this.u??""}isActive(){return"ACTIVE"===this.h&&null!==this.l}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.l&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.l;await pt(gt,async()=>{if(this.l&&this.l!==t&&!ft(this.l)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!ft(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.I(),await this.S())})}async v(){try{if(this.l&&!ft(this.l))return;await pt(gt,async()=>{await this.S()})}finally{this.p=null}}async S(){const t=this._();if(t&&!ft(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(wt),O.get(yt),O.get(vt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.I(),null)}A(t){O.set(wt,t.token),O.set(yt,t.activityId),O.set(vt,t.activityStatus)}I(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(wt),O.remove(yt),void O.remove(vt);O.set(wt,t.token),O.set(yt,t.activityId),O.set(vt,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 kt=[401,403,409],Tt=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 _t(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:Tt[t.name]}const It=new Array(256);for(let t=0;t<256;t++)It[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return It[t[0]]+It[t[1]]+It[t[2]]+It[t[3]]+"-"+It[t[4]]+It[t[5]]+"-"+It[t[6]]+It[t[7]]+"-"+It[t[8]]+It[t[9]]+"-"+It[t[10]]+It[t[11]]+It[t[12]]+It[t[13]]+It[t[14]]+It[t[15]]}function Et(){return crypto.randomUUID()}function At(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function Mt(){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 Dt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Et;if("function"==typeof crypto.getRandomValues)return At}return Mt}();function Ct(){return Dt()}class Pt{constructor(t,n){this.M=t,this.D=n,this.C=[],this.P=null,this.L=[],this.R=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.R),this.R=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.R),void(this.R=null);this.C.length>0&&this.H(),this.L.length>0&&this.K()}}H(){this.m&&this.$&&null===this.P&&(this.P=u(()=>{this.P=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.R&&(this.R=u(()=>{this.R=null,this.V()},this.O))}V(){if(!this.m||!this.$||0===this.L.length||!this.D.isActivityActive())return;const t=this.L.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.L.length>0&&this.K()})}J(t,e){this.L.length>=5&&(this.L.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.L.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.L.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.L.length>0&&this.K());this.W(),this.J(e.batch,e.attempts+1)}else this.L.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.L)t.push(this.D.ingest(e.batch,!0).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.L=[],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=_t(t);for(let e=0;e<this.C.length;e++)if(_t(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:Ct(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.5.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 zt="tri:bcast:";const Lt="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(`${zt}${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=Ct(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${zt}${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(){}},Rt="__tri_tabId";class $t{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.lt(),this.ut({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.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 Lt("__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(Rt);if(t)return t;const n=Ct();return q.set(Rt,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 Ut=globalThis.CompressionStream,Bt=globalThis.Response,Ot=globalThis.Blob,qt=new TextEncoder;let jt=null;async function Ht(t){const e=await async function(t){if("function"!=typeof Ut)return null;try{const n=qt.encode(t),e=new Ot([n]).stream().pipeThrough(new Ut("gzip"));return await new Bt(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===jt){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-DlFgHpoC.js"),1e4);jt=t,t.then(n=>{null===n&&u(()=>{jt===t&&(jt=null)},1e4)})}return jt}();if(null===e)return null;const{gzipSync:i}=e,o=i(qt.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 Nt(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 Ft="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Xt{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 Kt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Vt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Yt=255;function Jt(t,n,e,i=nt){const o=t.tagName.toLowerCase(),r=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),s=function(t,n,e){const i=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),o={},r=t.id;r&&!_("id",i)&&(o.id=r);const s=t.getAttribute("autocomplete");s&&!_("autocomplete",i)&&(o.autocomplete=s);const c=t.getAttribute("aria-invalid");c&&!_("aria-invalid",i)&&(o.ariaInvalid=c);const a=t.getAttribute("tabindex");a&&!_("tabindex",i)&&(o.tabIndex=parseInt(a,10));const l=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);l&&!_("data-testid",i)&&(o.testId=l);const u=t.hasAttribute("readonly");u&&!_("readonly",i)&&(o.readOnly=u);const d=t.hasAttribute("required");d&&!_("required",i)&&(o.required=d);const h=t.getAttribute("contenteditable");h&&!_("contenteditable",i)&&(o.contentEditable="true"===h||""===h);const f=t.getAttribute("href");f&&!_("href",i)&&(o.href={...n?{}:{url:e(f)},external:I(f)});const p=t.getAttribute("role");p&&!_("role",i)&&(o.role=p);const m=t.getAttribute("type");m&&!_("type",i)&&(o.type=m);const w=t.getAttribute("name");w&&!_("name",i)&&(o.name=w);const y=t.getAttribute("placeholder");!y||n||_("placeholder",i)||(o.placeholder=y);const v=Array.from(t.classList).slice(0,5);v.length>0&&!_("class",i)&&(o.classes=v);const g=t.getAttribute("alt");return!g||n||_("alt",i)||(o.alt=g),Object.keys(o).length?o:null}(t,n,i);return{tagName:o,frame:e,...s?{attributes:s}:{},...r?{nth:r}:{}}}function Gt(t,n){let e=0;const i=[];return function(t){return Kt.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&&Vt.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 Zt(t){return t>=20}function Qt(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 Wt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function tn(t,n=!1){if(n)return null;const e=en(t,"labelledby");if(e)return{text:rn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=on(t);if(i)return{text:rn(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?nn(n):null}(t);if(o)return{text:rn(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?nn(n):null}(t);if(r)return{text:rn(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:rn(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:rn(c),resolutionMethod:"title",confidence:"low"};const a=en(t,"describedby");if(a)return{text:rn(a),resolutionMethod:"aria-describedby",confidence:"low"};const l=nn(t);return l?{text:l,resolutionMethod:"text-content",confidence:"low"}:null}function nn(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,Yt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=nn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Yt))break}return rn(e)}function en(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=on(n)??nn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function on(t){return t?.getAttribute("aria-label")?.trim()??null}function rn(t){return t.length>Yt?t.slice(0,Yt)+"...":t}function sn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class cn{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 an(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===Ft)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,l=!1;a=u(()=>{l=!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 Ft(s,{method:t,headers:Nt({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?l?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return l?{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||!kt.includes(a.status)||!1===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 Ht(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: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:!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:()=>l?.getToken()??null,refresh:async()=>l?.refresh()??Promise.resolve(),getActivityId:()=>l?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};l=new bt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Pt(ct,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>l?.isActive()??!1});const p=r.tab;f=new $t({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{elementLevel:n,sanitizeUrl:e=nt}=t,i=n||"redact",o=new cn(6),r=new cn(6);return{resolve:function(t){if(!t||k(t)||"off"===i)return null;let n=o.get(t);if(n||(n=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),o.set(t,n)),"ignore"===n.redaction.level)return null;const s="redact"===n.redaction.level||"redact"===i||T(t);let c=r.get(t);return c||(c=function(t,n,i,o){const r=getComputedStyle(t),s=sn(t),c=function(t,n,e=!1,i=nt){const o=[],r=[];for(let s=t.length-1;s>=0;s--){const c=t[s],a=e||s<=n,l=s+1,u=Jt(c,a,sn(c),i),{score:d,reasons:h}=Gt(c,l);if(o.push(u),!Zt(d))continue;const f=tn(c,a);r.push({...u,...f?{label:f}:{},depth:l,score:d,reasons:h})}return{ancestors:o,interactiveCandidates:r.reverse()}}(n,o,i,e),a=Jt(t,i,s,e),l=function(t,n,e){const{score:i,reasons:o}=Gt(t,0);return{interactive:Zt(i),...o.length>0?{reasons:o}:{},disabled:Wt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Qt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let u=null;return i||(u=l.interactive?tn(t):null),{tagName:a.tagName,frame:a.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:a.attributes,nth:a.nth,...u?{label:u}:{},ancestors:c.ancestors,interactiveCandidates:c.interactiveCandidates,interactivity:l}}(t,n.chain,s,n.redaction.index),r.set(t,c)),c}}}({elementLevel:s.capture?.element,sanitizeUrl:s.sanitizeUrl}),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 Xt({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 ln=class t{constructor(){this.Tt=0,this._t=null,this.It=et}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if(this.It!==et)return n.fatal("error","setup()",`cannot set up from state '${this.It}' — call reset() (or reload) first. Ignoring.`),st;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:at()}:void 0!==t.collectors?{sdk:o,collectors:ut(t.collectors)}:{sdk:o,collectors:lt(t.layers)}}(t);if(!e)return this.It=st,st;n.DEBUG=e.sdk.DEBUG;const i=await an(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.It=rt,rt):"init-failed"===i.status?(this.It=st,st):(this._t=i.managers,this.It=it,!1!==t.autostart?this.start():it)}catch(t){return n.warn("setup()","failed:",t),this.It=st,st}}async start(){if(this.It===et)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.It;if(this.It!==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=it,this.xt(t)):Promise.resolve(this.It)}async reset(){const t=this.stop();return this.It=et,this._t=null,t.then(()=>this.It)}async xt(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}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=it))}t===this.Tt&&(this.It=ot)}}async linkInterview(t){if(this.It!==ot||!this._t)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),!1;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),!1;try{return(await this._t.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),!1}}};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=u(()=>{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()}}ln.i=null;const dn=ln.instance;export{un as createSession,dn 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 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 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 I(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function x(t,n){return!t||(t[n]?.enabled??!1)}function S(){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(R))},i.async=!0,i.src=t,r.appendChild(i)})}(t)).then(M)}const z="API key required";var L="3.12.9";const R="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(z);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===R){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(L):t)}(String(t),n))}(s,r),P)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(R):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 x(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),x(o,"click")&&e(document,"click",r),x(o,"dblclick")&&e(document,"dblclick",r),x(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"):S())??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 x(o,"paste")&&e(document,"paste",r),x(o,"cut")&&e(document,"cut",r),x(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 x(o,"submit")&&e(document,"submit",r),x(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,l=!1;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=!1,u(),function(e){const i=A("end"),o=i&&E(i,n),r=S();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,u())}),m=a(t=>{0===t.button&&(c=!1,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(l=!0,u())}),y=a(t=>{"Shift"===t.key&&(l=!1,o&&h("keyboard"))}),v=a(()=>{c=!1}),b=a(()=>{"hidden"===document.visibilityState&&(c=!1,l=!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),()=>{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",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))}),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 x(o,"orientationchange")&&e(window,"orientationchange",r),x(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=!1;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 x(o,"motion")&&e(window,"devicemotion",m),x(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),x(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:!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="started",rt="collection-disabled",st="init-failed",ct={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function at(){const t={};for(const n of W)t[n]=dt(n,void 0,!0);return t}function lt(t){const n={};for(const e of W)n[e]=dt(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]=dt(e,i,i?.enabled??!1)}return n}function dt(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 ht(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ft=function(t,n=30){if(!t)return!0;const e=ht(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function pt(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 mt="__tri",wt=`${mt}_activity_token`,yt=`${mt}_activity_id`,vt=`${mt}_activity_status`,bt="__tri_activity_lock";class gt{constructor(t){this.context=t,this.l=null,this.u=null,this.h=null,this.p=null,this.m=!1}getToken(){return this.l}getActivityId(){return this.u??""}isActive(){return"ACTIVE"===this.h&&null!==this.l}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.l&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.l;await pt(bt,async()=>{if(this.l&&this.l!==t&&!ft(this.l)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!ft(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.I(),await this.S())})}async v(){try{if(this.l&&!ft(this.l))return;await pt(bt,async()=>{await this.S()})}finally{this.p=null}}async S(){const t=this._();if(t&&!ft(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(wt),O.get(yt),O.get(vt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.I(),null)}A(t){O.set(wt,t.token),O.set(yt,t.activityId),O.set(vt,t.activityStatus)}I(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(wt),O.remove(yt),void O.remove(vt);O.set(wt,t.token),O.set(yt,t.activityId),O.set(vt,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 kt=[401,403,409],Tt=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 _t(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:Tt[t.name]}const It=new Array(256);for(let t=0;t<256;t++)It[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return It[t[0]]+It[t[1]]+It[t[2]]+It[t[3]]+"-"+It[t[4]]+It[t[5]]+"-"+It[t[6]]+It[t[7]]+"-"+It[t[8]]+It[t[9]]+"-"+It[t[10]]+It[t[11]]+It[t[12]]+It[t[13]]+It[t[14]]+It[t[15]]}function Et(){return crypto.randomUUID()}function At(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function Mt(){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 Dt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Et;if("function"==typeof crypto.getRandomValues)return At}return Mt}();function Ct(){return Dt()}class Pt{constructor(t,n){this.M=t,this.D=n,this.C=[],this.P=null,this.L=[],this.R=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.R),this.R=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.R),void(this.R=null);this.C.length>0&&this.H(),this.L.length>0&&this.K()}}H(){this.m&&this.$&&null===this.P&&(this.P=u(()=>{this.P=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.R&&(this.R=u(()=>{this.R=null,this.V()},this.O))}V(){if(!this.m||!this.$||0===this.L.length||!this.D.isActivityActive())return;const t=this.L.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.L.length>0&&this.K()})}J(t,e){this.L.length>=5&&(this.L.shift(),n.warn("Transport","retry queue full — oldest batch evicted")),this.L.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.L.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.L.length>0&&this.K());this.W(),this.J(e.batch,e.attempts+1)}else this.L.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.L)t.push(this.D.ingest(e.batch,!0).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.L=[],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=_t(t);for(let e=0;e<this.C.length;e++)if(_t(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:Ct(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.5.1-rc.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 zt="tri:bcast:";const Lt="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(`${zt}${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=Ct(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${zt}${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(){}},Rt="__tri_tabId";class $t{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.lt(),this.ut({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.ut({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}lt(){try{this.nt=new Lt("__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.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)}bt(){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(Rt);if(t)return t;const n=Ct();return q.set(Rt,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 Ut=globalThis.CompressionStream,Bt=globalThis.Response,Ot=globalThis.Blob,qt=new TextEncoder;let jt=null;async function Ht(t){const e=await async function(t){if("function"!=typeof Ut)return null;try{const n=qt.encode(t),e=new Ot([n]).stream().pipeThrough(new Ut("gzip"));return await new Bt(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===jt){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-DlFgHpoC.js"),1e4);jt=t,t.then(n=>{null===n&&u(()=>{jt===t&&(jt=null)},1e4)})}return jt}();if(null===e)return null;const{gzipSync:i}=e,o=i(qt.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 Nt(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 Ft="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Xt{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 Kt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Vt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Yt=255;function Jt(t,n,e,i=nt){const o=t.tagName.toLowerCase(),r=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),s=function(t,n,e){const i=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),o={},r=t.id;r&&!_("id",i)&&(o.id=r);const s=t.getAttribute("autocomplete");s&&!_("autocomplete",i)&&(o.autocomplete=s);const c=t.getAttribute("aria-invalid");c&&!_("aria-invalid",i)&&(o.ariaInvalid=c);const a=t.getAttribute("tabindex");a&&!_("tabindex",i)&&(o.tabIndex=parseInt(a,10));const l=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);l&&!_("data-testid",i)&&(o.testId=l);const u=t.hasAttribute("readonly");u&&!_("readonly",i)&&(o.readOnly=u);const d=t.hasAttribute("required");d&&!_("required",i)&&(o.required=d);const h=t.getAttribute("contenteditable");h&&!_("contenteditable",i)&&(o.contentEditable="true"===h||""===h);const f=t.getAttribute("href");f&&!_("href",i)&&(o.href={...n?{}:{url:e(f)},external:I(f)});const p=t.getAttribute("role");p&&!_("role",i)&&(o.role=p);const m=t.getAttribute("type");m&&!_("type",i)&&(o.type=m);const w=t.getAttribute("name");w&&!_("name",i)&&(o.name=w);const y=t.getAttribute("placeholder");!y||n||_("placeholder",i)||(o.placeholder=y);const v=Array.from(t.classList).slice(0,5);v.length>0&&!_("class",i)&&(o.classes=v);const b=t.getAttribute("alt");return!b||n||_("alt",i)||(o.alt=b),Object.keys(o).length?o:null}(t,n,i);return{tagName:o,frame:e,...s?{attributes:s}:{},...r?{nth:r}:{}}}function Gt(t,n){let e=0;const i=[];return function(t){return Kt.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&&Vt.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 Zt(t){return t>=20}function Qt(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 Wt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function tn(t,n=!1){if(n)return null;const e=en(t,"labelledby");if(e)return{text:rn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=on(t);if(i)return{text:rn(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?nn(n):null}(t);if(o)return{text:rn(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?nn(n):null}(t);if(r)return{text:rn(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:rn(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:rn(c),resolutionMethod:"title",confidence:"low"};const a=en(t,"describedby");if(a)return{text:rn(a),resolutionMethod:"aria-describedby",confidence:"low"};const l=nn(t);return l?{text:l,resolutionMethod:"text-content",confidence:"low"}:null}function nn(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,Yt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=nn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Yt))break}return rn(e)}function en(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=on(n)??nn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function on(t){return t?.getAttribute("aria-label")?.trim()??null}function rn(t){return t.length>Yt?t.slice(0,Yt)+"...":t}function sn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class cn{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 an(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===Ft)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,l=!1;a=u(()=>{l=!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 Ft(s,{method:t,headers:Nt({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?l?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return l?{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||!kt.includes(a.status)||!1===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 Ht(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: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:!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:()=>l?.getToken()??null,refresh:async()=>l?.refresh()??Promise.resolve(),getActivityId:()=>l?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};l=new gt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Pt(ct,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>l?.isActive()??!1});const p=r.tab;f=new $t({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{elementLevel:n,sanitizeUrl:e=nt}=t,i=n||"redact",o=new cn(6),r=new cn(6);return{resolve:function(t){if(!t||k(t)||"off"===i)return null;let n=o.get(t);if(n||(n=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;if(g(t))e=t.host;else{if(t.nodeType!==Node.ELEMENT_NODE)break;e=t}}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),o.set(t,n)),"ignore"===n.redaction.level)return null;const s="redact"===n.redaction.level||"redact"===i||T(t);let c=r.get(t);return c||(c=function(t,n,i,o){const r=getComputedStyle(t),s=sn(t),c=function(t,n,e=!1,i=nt){const o=[],r=[];for(let s=t.length-1;s>=0;s--){const c=t[s],a=e||s<=n,l=s+1,u=Jt(c,a,sn(c),i),{score:d,reasons:h}=Gt(c,l);if(o.push(u),!Zt(d))continue;const f=tn(c,a);r.push({...u,...f?{label:f}:{},depth:l,score:d,reasons:h})}return{ancestors:o,interactiveCandidates:r.reverse()}}(n,o,i,e),a=Jt(t,i,s,e),l=function(t,n,e){const{score:i,reasons:o}=Gt(t,0);return{interactive:Zt(i),...o.length>0?{reasons:o}:{},disabled:Wt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Qt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let u=null;return i||(u=l.interactive?tn(t):null),{tagName:a.tagName,frame:a.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:a.attributes,nth:a.nth,...u?{label:u}:{},ancestors:c.ancestors,interactiveCandidates:c.interactiveCandidates,interactivity:l}}(t,n.chain,s,n.redaction.index),r.set(t,c)),c}}}({elementLevel:s.capture?.element,sanitizeUrl:s.sanitizeUrl}),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 Xt({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 ln=class t{constructor(){this.Tt=0,this._t=null,this.It=et}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if(this.It!==et)return n.fatal("error","setup()",`cannot set up from state '${this.It}' — call reset() (or reload) first. Ignoring.`),st;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:at()}:void 0!==t.collectors?{sdk:o,collectors:ut(t.collectors)}:{sdk:o,collectors:lt(t.layers)}}(t);if(!e)return this.It=st,st;n.DEBUG=e.sdk.DEBUG;const i=await an(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.It=rt,rt):"init-failed"===i.status?(this.It=st,st):(this._t=i.managers,this.It=it,!1!==t.autostart?this.start():it)}catch(t){return n.warn("setup()","failed:",t),this.It=st,st}}async start(){if(this.It===et)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.It;if(this.It!==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=it,this.xt(t)):Promise.resolve(this.It)}async reset(){const t=this.stop();return this.It=et,this._t=null,t.then(()=>this.It)}async xt(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}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=it))}t===this.Tt&&(this.It=ot)}}async linkInterview(t){if(this.It!==ot||!this._t)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),!1;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),!1;try{return(await this._t.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),!1}}};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=u(()=>{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()}}ln.i=null;const dn=ln.instance;export{un as createSession,dn as default};
package/dist/tri.umd.js CHANGED
@@ -1 +1 @@
1
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).IncodeTRI={})}(this,function(t){"use strict";class n{constructor(){this.T=!1}static get instance(){return n.S||(n.S=new n),n.S}get DEBUG(){return this.T}set DEBUG(t){this.T=t}warn(t,n,...e){this.T&&this._("warn",t,n,...e)}error(t,n,...e){this.T&&this._("error",t,n,...e)}info(t,n,...e){this.T&&this._("info",t,n,...e)}fatal(t,n,e,...i){this._(t,n,e,...i)}_(t,n,e,...i){const r=n?`[${n}]`:"",o=console?.[t];o&&o(`[IncodeTRI]${r} ${e}`,...i)}}const e=n.instance;function i(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.addEventListener(r,e,{capture:!0,passive:!0})}function r(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.removeEventListener(r,e,{capture:!0})}const o=globalThis.setTimeout.bind(globalThis),s=globalThis.clearTimeout.bind(globalThis);function a(t,n){try{return t()}catch(t){e.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){e.warn("utils","safeAsync swallowed error:",t)}}function u(t){return n=>a(()=>t(n))}function l(t){return(...n)=>{try{t(...n)}catch(t){e.warn("utils","safeTimer swallowed error:",t)}}}function f(t,n){return o(l(t),n)}function h(t){if(null!==t)try{s(t)}catch(t){e.warn("utils","safeClearTimeout swallowed error:",t)}}const d=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),v=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function w(t,n){const e=t,i=t.responseStart>0,r=p(t.domainLookupEnd-t.domainLookupStart,i),o=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),a=p(t.responseStart-t.requestStart,i),c=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,f=i?t.decodedBodySize:null,h=i&&t.nextHopProtocol||null,v=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,m=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(y=t.initiatorType,d.has(y)?y:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:r,tcpConnectMs:o,tlsHandshakeMs:s,ttfbMs:a,responseDownloadMs:c,transferSize:u,encodedBodySize:l,decodedBodySize:f,nextHopProtocol:h,deliveryType:v,responseStatus:m};var y}function m(){}const y=2e3;function g(t){return!!t&&t.nodeType===Node.TEXT_NODE}function b(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function k(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function T(t){return!!t&&t.hasAttribute("data-tri-ignore")}function S(t){return!!t&&t.hasAttribute("data-tri-redact")}function I(t,n){return n?.includes(t.toLowerCase())??!1}function x(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function _(t,n){return!t||(t[n]?.enabled??!1)}function M(){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&&!T(t)&&!S(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)?g(i)?i.parentElement:i instanceof Element?i:null:null;var i}function z(){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 U(t){return function(t,n){const e=document,i="securitypolicyviolation";let r;const o=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(r=n,s())};e.addEventListener(i,o);const s=()=>e.removeEventListener(i,o);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(),r)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"),r=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},o=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{r(),n()},i.onerror=()=>{r(),e(new Error(R))},i.async=!0,i.src=t,o.appendChild(i)})}(t)).then(z)}const L="API key required";var P="3.12.9";const R="Failed to load the JS script of the agent",$="9319",O={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()&&a(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&a(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const j=B("localStorage"),q=B("sessionStorage"),F="__tri_fingerprint";let H=null,N=null;async function Z(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:r}=function(t,n){const e={},i={};for(const[r,o]of Object.entries(t))n.includes(r)?e[r]=o:i[r]=o;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),o=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:O.scriptUrl,[a,c]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",r=n,o),()=>i.removeEventListener("visibilitychange",r,o));var i,r,o;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!o||"string"!=typeof o)throw new Error(L);return function(t,n){const e=[],[i,r]=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,r)=>{let o;const s=r instanceof Error?r.message:"";if(s===D||s===C)n.exclude(),o=0;else if(s===$)n.exclude();else if(s===R){const e=Date.now()-t.getTime()<50,r=n.current();r&&e&&!i.has(r)&&(i.add(r),o=0),n.postpone()}else n.postpone();const a=n.current();return void 0===a?void 0:[a,null!=o?o:t.getTime()+e()-Date.now()]}]}(t);let o;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,a=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),c=n(t);return c.then(()=>a(),a),c.catch(t=>{if(null!=o||(o=t),e.length>=5)throw o;const n=r(i,t);if(!n)throw o;const[a,c]=n;return(u=c,new Promise(t=>setTimeout(t,u))).then(()=>s(a));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(P):t)}(String(t),n))}(s,o),U)}).catch(t=>{throw c(),function(t){return t instanceof Error&&t.message===$?new Error(R):t}(t)}).then(([t,n])=>(c(),t.load({...r,ldi:{attempts:n,visibilityStates:a}})))}({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};j.set(F,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"},G={focusin:"in",focusout:"out"};function K(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const V=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Y={mouse:"mouse",touch:"touch",pen:"pen"},J={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Q(t,n,e,i,r){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:r}}const W={fingerprint:{create:function(t){let n=!1;return c(async()=>{const e=await async function(t){const n=function(){const t=j.get(F);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(j.remove(F),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=Z(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,e){const o=u(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:Y[e.pointerType]??"unknown",phase:J[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 _(e,"pointer")&&(i(document,"pointerdown",o),i(document,"pointerup",o)),_(e,"click")&&i(document,"click",o),_(e,"dblclick")&&i(document,"dblclick",o),_(e,"contextmenu")&&i(document,"contextmenu",o),()=>{r(document,"pointerdown",o),r(document,"pointerup",o),r(document,"click",o),r(document,"dblclick",o),r(document,"contextmenu",o)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,e=null;const o=u(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 a(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 a(t)):(n=s(i),void a(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 a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(document,"pointermove",o),()=>{r(document,"pointermove",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=u(n=>{const e=function(n){const e=n;return{name:"focus",type:G[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return i(document,"focusin",n),i(document,"focusout",n),()=>{r(document,"focusin",n),r(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=u(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!!K(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 K(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return i(document,"input",n),function(){r(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:e}=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 r=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,r),r}const r=n.get(e);return void 0!==r?(n.delete(e),r):++t},reset:function(){n.clear()}}}(),o=u(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:V.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=u(()=>{e()});return i(document,"keydown",o),i(document,"keyup",o),i(window,"blur",s),()=>{r(document,"keydown",o),r(document,"keyup",o),r(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",e){const o=u(e=>{const i=function(e){const i=e,r=e.type,o=("paste"===e.type?i.clipboardData?.getData("text/plain"):M())??null,s=E(i.target,n);return{name:"clipboard",type:r,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:o?.length??0,...s&&o?{content:o}:{}}}(e);t.push(i)});return _(e,"paste")&&i(document,"paste",o),_(e,"cut")&&i(document,"cut",o),_(e,"copy")&&i(document,"copy",o),()=>{r(document,"paste",o),r(document,"cut",o),r(document,"copy",o)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,e){const o=u(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 _(e,"submit")&&i(document,"submit",o),_(e,"invalid")&&i(document,"invalid",o),()=>{r(document,"submit",o),r(document,"invalid",o)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=u(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return i(document,"change",n),()=>{r(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let e=!1,o=0,s=null,a=!1,c=!1;function l(){s&&(clearTimeout(s),s=null)}function f(){l(),a||c||(s=setTimeout(()=>{s=null,e&&h("timeout")},250))}function h(i){e&&(e=!1,l(),function(e){const i=A("end"),r=i&&E(i,n),o=M();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:!0,element:t.resolveElement(i),length:o?.length??0,...r&&o?{content:o}:{}})}(i))}const d=u(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!e&&!n)return e=!0,o=Date.now(),t.push({name:"selection",phase:"start",timestamp:o,element:t.resolveElement(A("start"))}),void f();e&&n?h("collapse"):e&&f()}),v=u(t=>{0===t.button&&(a=!0,l())}),p=u(t=>{0===t.button&&(a=!1,e&&h("pointer"))}),w=u(t=>{"Shift"===t.key&&(c=!0,l())}),m=u(t=>{"Shift"===t.key&&(c=!1,e&&h("keyboard"))}),y=u(()=>{a=!1}),g=u(()=>{"hidden"===document.visibilityState&&(a=!1,c=!1,e&&h("timeout"))}),b=u(()=>{a=!1,e&&h("pointer")});return i(document,"selectionchange",d),i(document,"pointerdown",v),i(document,"pointerup",p),i(document,"keydown",w),i(document,"keyup",m),i(document,"contextmenu",y),i(document,"visibilitychange",g),i(document,"dragend",b),()=>{l(),r(document,"selectionchange",d),r(document,"pointerdown",v),r(document,"pointerup",p),r(document,"keydown",w),r(document,"keyup",m),r(document,"contextmenu",y),r(document,"visibilitychange",g),r(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=u(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 i(document,"visibilitychange",n),()=>{r(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function e(e){t.push(e),n=e.to??""}const o=u(()=>{const[n]=performance.getEntriesByType("navigation");var i;e(Q("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(i=n).fetchStart,domainLookupStart:i.domainLookupStart,domainLookupEnd:i.domainLookupEnd,connectStart:i.connectStart,connectEnd:i.connectEnd,requestStart:i.requestStart,responseStart:i.responseStart,responseEnd:i.responseEnd,domInteractive:i.domInteractive,domContentLoadedEventStart:i.domContentLoadedEventStart,domContentLoadedEventEnd:i.domContentLoadedEventEnd,domComplete:i.domComplete,loadEventStart:i.loadEventStart,loadEventEnd:i.loadEventEnd,redirectCount:i.redirectCount,transferSize:i.transferSize,encodedBodySize:i.encodedBodySize,decodedBodySize:i.decodedBodySize}:void 0))}),s=u(i=>{const r=i;if(null===r.navigationType)return;const o=t.sanitizeUrl(location.href);o!==n&&e(Q("change",r.navigationType,{from:n,to:o},performance.timeOrigin))}),c=u(()=>f("traverse")),l=u(()=>f("hashchange"));function f(i){const r=t.sanitizeUrl(location.href);"hashchange"===i&&r===n||e(Q("change",i,{from:n,to:r},performance.timeOrigin))}const h=history.pushState,d=history.replaceState,v=function(...t){const n=h.apply(this,t);return a(()=>f("push")),n},p=function(...t){const n=d.apply(this,t);return a(()=>f("replace")),n};return window.navigation?i(window.navigation,"currententrychange",s):(history.pushState=v,history.replaceState=p,i(window,"popstate",c),i(window,"hashchange",l)),"complete"===document.readyState?o(new Event("load")):i(window,"load",o),()=>{window.navigation?r(window.navigation,"currententrychange",s):(history.pushState===v&&(history.pushState=h),history.replaceState===p&&(history.replaceState=d),r(window,"popstate",c),r(window,"hashchange",l)),r(window,"load",o)}},layer:"session"},networkconnection:{create:function(t){const n=u(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return i(window,"online",n),i(window,"offline",n),()=>{r(window,"online",n),r(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void a(t)):(n=s(e),void a(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 a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"scroll",o),()=>{r(window,"scroll",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(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 a(t)):(n=s(e),void a(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 a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"resize",o),()=>{r(window,"resize",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,e){const o=u(n=>{const e=a(n,"orientation");t.push(e)}),s=u(n=>{const e=a(n,"ratiochange");t.push(e)});function a(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 _(e,"orientationchange")&&i(window,"orientationchange",o),_(e,"devicepixelratiochange")&&i(window,"devicepixelratiochange",s),()=>{r(window,"orientationchange",o),r(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,e){let o=null,s=null,a=null,c=null,f=!1;function d(){c&&h(c),c=setTimeout(l(()=>{v(),c=null}),y)}function v(){o&&(t.push(o),o=null),s&&(t.push(s),s=null),a&&(t.push(a),a=null)}const p=u(n=>{const e=n,i=e.timeStamp,r=e.acceleration,s=e.accelerationIncludingGravity,a=e.rotationRate;if(!r&&!s&&!a||null===r?.x&&null===r?.y&&null===r?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===a?.alpha&&null===a?.beta&&null===a?.gamma)return;if(!o)return o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();if(o.samples.ts.length>=50)return t.push(o),o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();const c=o.samples;c.ax.push(r?.x??0),c.ay.push(r?.y??0),c.az.push(r?.z??0),c.agx.push(s?.x??0),c.agy.push(s?.y??0),c.agz.push(s?.z??0),c.rrAlpha.push(a?.alpha??0),c.rrBeta.push(a?.beta??0),c.rrGamma.push(a?.gamma??0),c.ts.push(i),d()}),w=u(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,r=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();const o=s.samples;o.alpha.push(e.alpha??0),o.beta.push(e.beta??0),o.gamma.push(e.gamma??0),o.compassHeading.push(r),o.ts.push(i),d()}),m=u(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return a?a.samples.ts.length>=50?(t.push(a),a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d()):(a.samples.lux.push(e),a.samples.ts.push(i),void d()):(a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d())});return _(e,"motion")&&i(window,"devicemotion",p),_(e,"orientation")&&("ondeviceorientationabsolute"in window?(f=!0,i(window,"deviceorientationabsolute",w)):i(window,"deviceorientation",w)),_(e,"light")&&i(window,"devicelight",m),function(){r(window,"devicemotion",p),r(window,f?"deviceorientationabsolute":"deviceorientation",w),r(window,"devicelight",m),c&&(h(c),c=null),v()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var n;const i=function(t,n,i,r=v){if("undefined"==typeof PerformanceObserver)return m;let o=null;try{o=new PerformanceObserver(e=>{for(const o of e.getEntries()){const e=o;r.has(e.initiatorType)&&(n(e.name)||t(w(e,i)))}}),o.observe({type:"resource",buffered:!0})}catch{return e.warn("network-request","PerformanceObserver failed to start"),m}return function(){o?.disconnect(),o=null}}(function(n){a(()=>t.push(n))},(n=t.ignoredOrigins,function(t){try{return n.has(new URL(t).origin)}catch{return!1}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=a(()=>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"}},tt=Object.keys(W),nt=[/^[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 et(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 nt)if(n.test(t))return!0;return!1}(t)?":param":t).join("/");const r=n.origin+n.pathname+i;return r.length>2048?r.slice(0,2048):r}catch{return""}}const it="idle",rt="ready",ot="started",st="collection-disabled",at="init-failed",ct={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ut(){const t={};for(const n of tt)t[n]=ht(n,void 0,!0);return t}function lt(t){const n={};for(const e of tt)n[e]=ht(e,void 0,t[W[e].layer]??!1);return n}function ft(t){const n={};for(const e of tt){const i=t[e];n[e]=ht(e,i,i?.enabled??!1)}return n}function ht(t,n,e){const i=W[t]?.events??[];if(0===i.length)return{enabled:e};const r=n?.events,o={};for(const t of i)o[t]={enabled:r?.[t]??!0};return{enabled:e,events:o}}function dt(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const vt=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 pt(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 wt="__tri",mt=`${wt}_activity_token`,yt=`${wt}_activity_id`,gt=`${wt}_activity_status`,bt="__tri_activity_lock";class kt{constructor(t){this.context=t,this.M=null,this.A=null,this.D=null,this.C=null,this.U=!1}getToken(){return this.M}getActivityId(){return this.A??""}isActive(){return"ACTIVE"===this.D&&null!==this.M}async start(){return this.U=!0,this.C||(this.C=this.L()),this.C}async stop(){this.U=!1,this.P(null),this.C=null,this.M&&await this.context.stopActivity(),this.R(null)}async refresh(){if(!this.U)return;const t=this.M;await pt(bt,async()=>{if(this.M&&this.M!==t&&!vt(this.M)&&"ACTIVE"===this.D)return;const n=this.$();n&&n.token!==t&&!vt(n.token)&&"ACTIVE"===n.activityStatus?this.R(n):(this.O(),await this.B())})}async L(){try{if(this.M&&!vt(this.M))return;await pt(bt,async()=>{await this.B()})}finally{this.C=null}}async B(){const t=this.$();if(t&&!vt(t.token)&&"ACTIVE"===t.activityStatus)return void this.R(t);t&&this.O();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.R(e),this.j(e)}$(){const[t,n,e]=[j.get(mt),j.get(yt),j.get(gt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.O(),null)}j(t){j.set(mt,t.token),j.set(yt,t.activityId),j.set(gt,t.activityStatus)}O(){this.P(null),this.R(null)}P(t){if(!t)return j.remove(mt),j.remove(yt),void j.remove(gt);j.set(mt,t.token),j.set(yt,t.activityId),j.set(gt,t.activityStatus)}R(t){if(!t)return this.M=null,this.A=null,void(this.D=null);this.M=t.token,this.A=t.activityId,this.D=t.activityStatus}}const Tt=[401,403,409],St=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 It(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:St[t.name]}const xt=new Array(256);for(let t=0;t<256;t++)xt[t]=(t+256).toString(16).slice(1);const _t=new Uint8Array(16);function Mt(t){return xt[t[0]]+xt[t[1]]+xt[t[2]]+xt[t[3]]+"-"+xt[t[4]]+xt[t[5]]+"-"+xt[t[6]]+xt[t[7]]+"-"+xt[t[8]]+xt[t[9]]+"-"+xt[t[10]]+xt[t[11]]+xt[t[12]]+xt[t[13]]+xt[t[14]]+xt[t[15]]}function Et(){return crypto.randomUUID()}function At(){return crypto.getRandomValues(_t),_t[6]=15&_t[6]|64,_t[8]=63&_t[8]|128,Mt(_t)}function zt(){for(let t=0;t<16;t++)_t[t]=256*Math.random()|0;return _t[6]=15&_t[6]|64,_t[8]=63&_t[8]|128,Mt(_t)}const Dt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Et;if("function"==typeof crypto.getRandomValues)return At}return zt}();function Ct(){return Dt()}class Ut{constructor(t,n){this.q=t,this.F=n,this.H=[],this.N=null,this.X=[],this.K=null,this.U=!1,this.V=!0,this.Y=0,this.J=0,this.W=t.flush.intervalMs}push(t){if(this.U){if(this.H.length<this.tt()?this.H.push(t):this.nt(t),this.V)return this.H.length>=this.q.flush.size?(h(this.N),this.N=null,void this.flush("capacity")):void this.et()}else e.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.U&&this.F.isActivityActive())try{if("lifecycle"===t)return void this.it();if(0===this.H.length)return;const n=this.rt(t);this.F.ingest(n,!1).then(t=>this.ot(t,n)).catch(()=>{e.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.H.length>0&&this.et()}catch(t){e.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.U||(this.U=!0,this.V="undefined"==typeof navigator||navigator.onLine)}stop(){if(!this.U)return Promise.resolve();h(this.N),this.N=null,h(this.K),this.K=null;const t=this.it();return this.U=!1,t}onConnectionChange(){const t="undefined"==typeof navigator||navigator.onLine;if(t!==this.V){if(this.V=t,!this.V)return h(this.N),this.N=null,h(this.K),void(this.K=null);this.H.length>0&&this.et(),this.X.length>0&&this.st()}}et(){this.U&&this.V&&null===this.N&&(this.N=f(()=>{this.N=null,this.flush("interval")},this.W))}st(){this.U&&this.V&&null===this.K&&(this.K=f(()=>{this.K=null,this.ct()},this.W))}ct(){if(!this.U||!this.V||0===this.X.length||!this.F.isActivityActive())return;const t=this.X.shift();this.F.ingest(t.batch,!1).then(n=>this.ut(n,t)).catch(()=>{e.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.X.length>0&&this.st()})}lt(t,n){this.X.length>=5&&(this.X.shift(),e.warn("Transport","retry queue full — oldest batch evicted")),this.X.push({batch:t,attempts:n}),this.st()}ot(t,n){t.ok?this.ft():this.ht(t)&&this.lt(n,1)}ut(t,n){if(t.ok)return this.ft(),void(this.X.length>0&&this.st());if(this.ht(t)){if(n.attempts>=3)return this.dt(),e.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",n.batch.batchId),void(this.X.length>0&&this.st());this.dt(),this.lt(n.batch,n.attempts+1)}else this.X.length>0&&this.st()}dt(){this.Y++,this.Y%this.q.flush.backoffFailureThreshold===0&&(this.W=Math.min(2*this.W,this.q.flush.maxIntervalMs))}ft(){this.Y=0,this.W=this.q.flush.intervalMs}tt(){return this.q.queue.size*(this.V?1:2)}async it(){if(!this.F.isActivityActive())return Promise.resolve();const t=[];for(const n of this.X)t.push(this.F.ingest(n.batch,!0).catch(()=>{e.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.X=[],this.H.length>0){const n=this.rt("lifecycle");t.push(this.F.ingest(n,!0).catch(()=>{e.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}nt(t){const n=It(t);for(let e=0;e<this.H.length;e++)if(It(this.H[e])<n){for(let t=e;t<this.H.length-1;t++)this.H[t]=this.H[t+1];return this.H.length-=1,void this.H.push(t)}}rt(t){const n="lifecycle"===t?this.H.splice(-this.q.flush.size):this.H.splice(0,this.q.flush.size);return{activityId:"",batchId:Ct(),batchSequence:this.J++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.5.0",sdkPlatform:"web",tabId:this.F.getTabId(),events:n}}ht(t){if(t.ok)return!1;switch(t.kind){case"timeout":case"server":case"rate_limited":return!0;default:return!1}}}const Lt="tri:bcast:";const Pt="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(`${Lt}${this.channelName}:`))return;if(null===t.newValue)return;let n;a(()=>j.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)a(()=>t(e))},this.channelName=t,this.senderId=Ct(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Lt}${this.channelName}:${this.senderId}:${this.seq++}`;a(()=>{j.set(n,t),j.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){e.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(){}},Rt="__tri_tabId";class $t{constructor(t){this.context=t,this.vt="",this.U=!1,this.wt=null,this.yt=null,this.gt=null,this.bt=new Map,this.kt=-1,this.Tt=null}async start(){this.U||(this.U=!0,this.vt=this.St(),this.It(),this.xt({type:"hello",tabId:this.vt,ts:Date.now()}),this._t(),this.Mt("active"),this.Et())}stop(){this.U&&(this.U=!1,this.Mt("inactive"),this.xt({type:"bye",tabId:this.vt,ts:Date.now()}),this.At(this.zt()),this.Dt(),this.Ct(),this.Ut())}getTabId(){return this.vt}queryTabsNumber(){return this.bt.size+1}It(){try{this.wt=new Pt("__tri_tab_channel"),this.Tt=this.Lt.bind(this),this.wt.addEventListener("message",this.Tt)}catch(t){e.warn("TabManager","failed to open broadcast channel:",t)}}Ut(){try{if(!this.wt)return;this.Tt&&this.wt.removeEventListener("message",this.Tt),this.wt.close()}catch{}finally{this.wt=null,this.Tt=null}}_t(){this.yt=setInterval(()=>{const t=Date.now();this.xt({type:"heartbeat",tabId:this.vt,ts:t})},1e3)}Dt(){null!=this.yt&&(clearInterval(this.yt),this.yt=null)}Et(){null!=this.gt&&clearTimeout(this.gt),this.gt=setTimeout(()=>{this.gt=null;const t=this.zt()+1;t!==this.kt&&(this.kt=t,this.At(t))},1e3)}Ct(){null!=this.gt&&(clearTimeout(this.gt),this.gt=null)}xt(t){try{if(!this.wt)return;this.wt.postMessage(t)}catch{e.warn("TabManager","failed to broadcast message:",t)}}Lt(t){const{type:n,tabId:e}=t.data;if(e===this.vt)return;const i=Date.now();"hello"===n?(this.xt({type:"ack",tabId:this.vt,ts:i,to:e}),this.bt.set(e,i)):"heartbeat"===n||"ack"===n?this.bt.set(e,i):"bye"===n&&this.bt.delete(e)}At(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.vt,timestamp:Date.now(),value:t})}Mt(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.vt,timestamp:Date.now(),value:t})}St(){const t=q.get(Rt);if(t)return t;const n=Ct();return q.set(Rt,n),n}zt(t=Date.now()){let n=0;for(const[e,i]of this.bt.entries())t-i>=3e3?this.bt.delete(e):n++;return n}}const Ot=globalThis.CompressionStream,Bt=globalThis.Response,jt=globalThis.Blob,qt=new TextEncoder;let Ft=null;async function Ht(t){const n=await async function(t){if("function"!=typeof Ot)return null;try{const n=qt.encode(t),e=new jt([n]).stream().pipeThrough(new Ot("gzip"));return await new Bt(e).arrayBuffer()}catch(t){return e.warn("compression","Native gzip failed:",t),null}}(t);return null!==n?n:async function(t){try{const n=await function(){if(null===Ft){const t=function(t,n=1e4){let i=null;const r=new Promise(t=>{i=f(()=>{e.warn("import",`Import timed out after ${n}ms`),t(null)},n)}),o=Promise.resolve().then(t).catch(t=>(e.warn("import","Import failed:",t),null));return Promise.race([o,r]).finally(()=>{h(i)})}(()=>Promise.resolve().then(function(){return Mi}),1e4);Ft=t,t.then(n=>{null===n&&f(()=>{Ft===t&&(Ft=null)},1e4)})}return Ft}();if(null===n)return null;const{gzipSync:i}=n,r=i(qt.encode(t));return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}catch(t){return e.warn("compression","fflate gzip failed:",t),null}}(t)}function Nt(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 Zt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Xt{constructor(t){this.context=t}stop(){}async report(t,n){const i={name:t,metadata:n,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const r=await this.context.reportEvent(i);if(r.ok)return r;e.warn("EventReport","Failed to report event:",t,n,"with result:",r)}catch(i){e.warn("EventReport","Failed to report event:",t,n,"with error:",i)}}}const Gt=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,i=et){const r=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,r=0,o=0;for(let i=0;i<e;i++){o++;const e=n[i];if(b(e,t.tagName)&&r++,e===t)break}return{siblings:i,ofType:r,child:o}}(t),s=function(t,n,e){const i=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),r={},o=t.id;o&&!I("id",i)&&(r.id=o);const s=t.getAttribute("autocomplete");s&&!I("autocomplete",i)&&(r.autocomplete=s);const a=t.getAttribute("aria-invalid");a&&!I("aria-invalid",i)&&(r.ariaInvalid=a);const c=t.getAttribute("tabindex");c&&!I("tabindex",i)&&(r.tabIndex=parseInt(c,10));const u=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);u&&!I("data-testid",i)&&(r.testId=u);const l=t.hasAttribute("readonly");l&&!I("readonly",i)&&(r.readOnly=l);const f=t.hasAttribute("required");f&&!I("required",i)&&(r.required=f);const h=t.getAttribute("contenteditable");h&&!I("contenteditable",i)&&(r.contentEditable="true"===h||""===h);const d=t.getAttribute("href");d&&!I("href",i)&&(r.href={...n?{}:{url:e(d)},external:x(d)});const v=t.getAttribute("role");v&&!I("role",i)&&(r.role=v);const p=t.getAttribute("type");p&&!I("type",i)&&(r.type=p);const w=t.getAttribute("name");w&&!I("name",i)&&(r.name=w);const m=t.getAttribute("placeholder");!m||n||I("placeholder",i)||(r.placeholder=m);const y=Array.from(t.classList).slice(0,5);y.length>0&&!I("class",i)&&(r.classes=y);const g=t.getAttribute("alt");return!g||n||I("alt",i)||(r.alt=g),Object.keys(r).length?r:null}(t,n,i);return{tagName:r,frame:e,...s?{attributes:s}:{},...o?{nth:o}:{}}}function Jt(t,n){let e=0;const i=[];return function(t){return Gt.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 Qt(t){return t>=20}function Wt(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 tn(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function nn(t,n=!1){if(n)return null;const e=rn(t,"labelledby");if(e)return{text:sn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=on(t);if(i)return{text:sn(i),resolutionMethod:"aria-label",confidence:"high"};const r=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?en(n):null}(t);if(r)return{text:sn(r),resolutionMethod:"html-for",confidence:"high"};const o=function(t){const n=t.closest("label");return n?en(n):null}(t);if(o)return{text:sn(o),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:sn(s),resolutionMethod:"placeholder",confidence:"low"};const a=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(a)return{text:sn(a),resolutionMethod:"title",confidence:"low"};const c=rn(t,"describedby");if(c)return{text:sn(c),resolutionMethod:"aria-describedby",confidence:"low"};const u=en(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function en(t,n=0){if(n>8)return"";if(g(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=en(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return sn(e)}function rn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const r=i.split(/\s+/),o=[];for(const t of r){const n=document.getElementById(t);if(!n)continue;const e=on(n)??en(n);e.length&&o.push(e)}return o.length?o.join(" "):null}function on(t){return t?.getAttribute("aria-label")?.trim()??null}function sn(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function an(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class cn{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 un(t,n){const{collectors:o,sdk:s}=t;let a=null,c=null,l=null,d=null;try{a=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||e.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const n=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function r(t,r,o){if(void 0===Zt)return{ok:!1,kind:"network"};const s=e?`${e}${r}`:r,a=new AbortController;let c=null,u=!1;c=f(()=>{u=!0,a.abort()},n);const l=o?.signal;let d,v=()=>{};if(l)if(l.aborted)a.abort();else{const t=()=>a.abort();l.addEventListener("abort",t,{once:!0}),v=()=>l.removeEventListener("abort",t)}if(null!=o&&"body"in o&&null!=o.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}}}(o.body);if(!t.ok)return h(c),v(),{ok:!1,kind:"serialize"};d=t.body}try{const n=await Zt(s,{method:t,headers:Nt({token:o?.token,profileId:o?.profileId,contentType:o?.contentType,contentEncoding:o?.contentEncoding,api:i,hasBody:void 0!==d,customHeaders:o?.customHeaders}),body:d,signal:a.signal,keepalive:o?.keepalive});if(!n.ok)return 429===(p=n.status)?{ok:!1,kind:"rate_limited",status:p}:p>=400&&p<500?{ok:!1,kind:"client",status:p}:{ok:!1,kind:"server",status:p};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 a.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"}:a.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{h(c),v()}var p}return{post:async function(t,n){return r("POST",t,n)},get:async function(t,n){return r("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:n,refresh:i}=t;let r=null;return{withAuth:async function(t,o){if(r){const n=await r;if(n)return t(n)}const s=n()??"",a=await t(s);if((c=a).ok||"client"!==c.kind||!Tt.includes(c.status)||!1===o?.refreshable)return a;var c;const u=await(r||(r=async function(){try{return await i(),n()}catch(t){return e.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{r=null}),r));return u&&u!==s?t(u):a}}}(t),r=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(e,o){return i.withAuth(async i=>{const{events:s,...a}=e,c={...a,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 Ht(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(c,s)}catch{return{ok:!1,kind:"serialize"}}return n.post("/events/capture",{body:u.body,token:i,keepalive:o,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...r()})},{refreshable:!o})},reportEvent:async function(t){return i.withAuth(e=>n.post("/events/report-event",{body:t,token:e,contentType:"json",...r()}))},startActivity:async function(){return n.post("/events/start-activity",{token:t.getSdkToken(),...r()})},stopActivity:async function(){return i.withAuth(t=>n.post("/events/end-activity",{token:t,keepalive:!0,...r()}),{refreshable:!1})},collectionStatus:async function(){return n.get("/sdk/collection-status",{token:t.getSdkToken(),...r()})},linkInterview:async function(t){return i.withAuth(e=>n.post("/events/link-interview",{token:e,contentType:"json",...r(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>n.getProfileId(),getToken:()=>c?.getToken()??null,refresh:async()=>c?.refresh()??Promise.resolve(),getActivityId:()=>c?.getActivityId()??""});const t=await a.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};c=new kt({startActivity:()=>a.api.startActivity(),stopActivity:()=>a.api.stopActivity()}),l=new Ut(ct,{ingest:(t,n)=>a.api.ingest(t,n),getTabId:()=>d?.getTabId()??"unknown",isActivityActive:()=>c?.isActive()??!1});const v=o.tab;d=new $t({push:t=>l?.push(t),events:{state:v.enabled&&v.events.state.enabled,count:v.enabled&&v.events.count.enabled}});const p=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function e(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const o=u(()=>t.onConnectionChange());return{start:function(){i(document,"visibilitychange",n),i(window,"pagehide",e),i(window,"online",o),i(window,"offline",o)},stop:function(){r(document,"visibilitychange",n),r(window,"pagehide",e),r(window,"online",o),r(window,"offline",o)}}}({flush:()=>l?.flush("lifecycle"),stopActivity:async()=>c?.stop(),stopTab:()=>d?.stop(),getShouldSkipStopActivity:()=>(d?.queryTabsNumber()??0)>1,onConnectionChange:()=>l?.onConnectionChange()}),w=function(t={}){const{elementLevel:n,sanitizeUrl:e=et}=t,i=n||"redact",r=new cn(6),o=new cn(6);return{resolve:function(t){if(!t||T(t)||"off"===i)return null;let n=r.get(t);if(n||(n=function(t){if(!t||T(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(T(e))return{chain:[],redaction:{level:"ignore",index:-1}};S(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||b(e,"body"))break;e=k(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),r.set(t,n)),"ignore"===n.redaction.level)return null;const s="redact"===n.redaction.level||"redact"===i||S(t);let a=o.get(t);return a||(a=function(t,n,i,r){const o=getComputedStyle(t),s=an(t),a=function(t,n,e=!1,i=et){const r=[],o=[];for(let s=t.length-1;s>=0;s--){const a=t[s],c=e||s<=n,u=s+1,l=Yt(a,c,an(a),i),{score:f,reasons:h}=Jt(a,u);if(r.push(l),!Qt(f))continue;const d=nn(a,c);o.push({...l,...d?{label:d}:{},depth:u,score:f,reasons:h})}return{ancestors:r,interactiveCandidates:o.reverse()}}(n,r,i,e),c=Yt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:r}=Jt(t,0);return{interactive:Qt(i),...r.length>0?{reasons:r}:{},disabled:tn(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Wt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,s);let l=null;return i||(l=u.interactive?nn(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:a.ancestors,interactiveCandidates:a.interactiveCandidates,interactivity:u}}(t,n.chain,s,n.redaction.index),o.set(t,a)),a}}}({elementLevel:s.capture?.element,sanitizeUrl:s.sanitizeUrl}),m=new Set;try{m.add(new URL(s.api.url).origin)}catch{}const y=function(t,n,e="on"){const i=new Map;function r(r){if(i.has(r))return;const o=W[r];if(!o||!function(t,n){return n[t]?.enabled??!1}(r,n))return;const s=n[r],a=o.create(t,e,s&&"events"in s?s.events:void 0);i.set(r,a)}return{start:r,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 tt)r(t)}}}({push:t=>l?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:m},o,s.capture?.content),g=new Xt({getActivityId:()=>c?.getActivityId()??"",reportEvent:t=>a.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:a,activityManager:c,transportManager:l,tabManager:d,lifecycleManager:p,collectorManager:y,eventReportManager:g}}}catch(t){return e.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let ln=class t{constructor(){this.Pt=0,this.Rt=null,this.$t=it}static get instance(){return t.S||(t.S=new t),t.S}async setup(t){if(this.$t!==it)return e.fatal("error","setup()",`cannot set up from state '${this.$t}' — call reset() (or reload) first. Ignoring.`),at;try{const n=function(t){if("undefined"==typeof document)return e.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return e.fatal("error","SDK","token is required."),null;if(!t.apiURL)return e.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:n,content:i}=t.capture??{},r={token:t.token,capture:{element:n??"redact",content:i??"off"},api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(o=t.sanitizeUrl,o?function(t){return a(()=>o(t,et))??et(t)}:et),DEBUG:t.DEBUG??!1};var o;return void 0===t.collectors&&void 0===t.layers?{sdk:r,collectors:ut()}:void 0!==t.collectors?{sdk:r,collectors:ft(t.collectors)}:{sdk:r,collectors:lt(t.layers)}}(t);if(!n)return this.$t=at,at;e.DEBUG=n.sdk.DEBUG;const i=await un(n,{getProfileId:()=>null});return"collection-disabled"===i.status?(e.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.$t=st,st):"init-failed"===i.status?(this.$t=at,at):(this.Rt=i.managers,this.$t=rt,!1!==t.autostart?this.start():rt)}catch(t){return e.warn("setup()","failed:",t),this.$t=at,at}}async start(){if(this.$t===it)return e.warn("start()","start() requires a prior successful setup() — ignoring."),this.$t;if(this.$t!==rt)return e.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.$t;this.$t="starting";const t=++this.Pt;return await this.L(t),this.$t}async stop(){e.warn("stop()","called");const t=this.Rt;return t?(++this.Pt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.$t=rt,this.Ot(t)):Promise.resolve(this.$t)}async reset(){const t=this.stop();return this.$t=it,this.Rt=null,t.then(()=>this.$t)}async Ot(t){return await function(t){let n=null;const e=new Promise(t=>{n=f(t,2e3)});return Promise.race([t.finally(()=>h(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.$t}async L(t){const n=this.Rt;if(n){try{if(await n.activityManager.start(),t!==this.Pt)return;if(n.transportManager.start(),await n.tabManager.start(),t!==this.Pt)return;n.lifecycleManager.start(),n.collectorManager.autocapture()}catch(n){return e.warn("start()","failed during monitoring start:",n),void(t===this.Pt&&(this.$t=rt))}t===this.Pt&&(this.$t=ot)}}async linkInterview(t){if(this.$t!==ot||!this.Rt)return e.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),!1;if(!t)return e.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),!1;try{return(await this.Rt.falconServiceManager.api.linkInterview(t)).ok}catch(t){return e.warn("linkInterview()","failed:",t),!1}}};ln.S=null;const fn=ln.instance;var hn={},dn=Uint8Array,vn=Uint16Array,pn=Int32Array,wn=new dn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),mn=new dn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),yn=new dn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gn=function(t,n){for(var e=new vn(31),i=0;i<31;++i)e[i]=n+=1<<t[i-1];var r=new pn(e[30]);for(i=1;i<30;++i)for(var o=e[i];o<e[i+1];++o)r[o]=o-e[i]<<5|i;return{b:e,r:r}},bn=gn(wn,2),kn=bn.b,Tn=bn.r;kn[28]=258,Tn[258]=28;for(var Sn=gn(mn,0),In=Sn.b,xn=Sn.r,_n=new vn(32768),Mn=0;Mn<32768;++Mn){var En=(43690&Mn)>>1|(21845&Mn)<<1;_n[Mn]=((65280&(En=(61680&(En=(52428&En)>>2|(13107&En)<<2))>>4|(3855&En)<<4))>>8|(255&En)<<8)>>1}var An=function(t,n,e){for(var i=t.length,r=0,o=new vn(n);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new vn(n);for(r=1;r<n;++r)a[r]=a[r-1]+o[r-1]<<1;if(e){s=new vn(1<<n);var c=15-n;for(r=0;r<i;++r)if(t[r])for(var u=r<<4|t[r],l=n-t[r],f=a[t[r]-1]++<<l,h=f|(1<<l)-1;f<=h;++f)s[_n[f]>>c]=u}else for(s=new vn(i),r=0;r<i;++r)t[r]&&(s[r]=_n[a[t[r]-1]++]>>15-t[r]);return s},zn=new dn(288);for(Mn=0;Mn<144;++Mn)zn[Mn]=8;for(Mn=144;Mn<256;++Mn)zn[Mn]=9;for(Mn=256;Mn<280;++Mn)zn[Mn]=7;for(Mn=280;Mn<288;++Mn)zn[Mn]=8;var Dn=new dn(32);for(Mn=0;Mn<32;++Mn)Dn[Mn]=5;var Cn=An(zn,9,0),Un=An(zn,9,1),Ln=An(Dn,5,0),Pn=An(Dn,5,1),Rn=function(t){for(var n=t[0],e=1;e<t.length;++e)t[e]>n&&(n=t[e]);return n},$n=function(t,n,e){var i=n/8|0;return(t[i]|t[i+1]<<8)>>(7&n)&e},On=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},Bn=function(t){return(t+7)/8|0},jn=function(t,n,e){return(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length),new dn(t.subarray(n,e))},qn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Fn=function(t,n,e){var i=new Error(n||qn[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Fn),!e)throw i;return i},Hn=function(t,n,e,i){var r=t.length,o=i?i.length:0;if(!r||n.f&&!n.l)return e||new dn(0);var s=!e,a=s||2!=n.i,c=n.i;s&&(e=new dn(3*r));var u=function(t){var n=e.length;if(t>n){var i=new dn(Math.max(2*n,t));i.set(e),e=i}},l=n.f||0,f=n.p||0,h=n.b||0,d=n.l,v=n.d,p=n.m,w=n.n,m=8*r;do{if(!d){l=$n(t,f,1);var y=$n(t,f+1,3);if(f+=3,!y){var g=t[(z=Bn(f)+4)-4]|t[z-3]<<8,b=z+g;if(b>r){c&&Fn(0);break}a&&u(h+g),e.set(t.subarray(z,b),h),n.b=h+=g,n.p=f=8*b,n.f=l;continue}if(1==y)d=Un,v=Pn,p=9,w=5;else if(2==y){var k=$n(t,f,31)+257,T=$n(t,f+10,15)+4,S=k+$n(t,f+5,31)+1;f+=14;for(var I=new dn(S),x=new dn(19),_=0;_<T;++_)x[yn[_]]=$n(t,f+3*_,7);f+=3*T;var M=Rn(x),E=(1<<M)-1,A=An(x,M,1);for(_=0;_<S;){var z,D=A[$n(t,f,E)];if(f+=15&D,(z=D>>4)<16)I[_++]=z;else{var C=0,U=0;for(16==z?(U=3+$n(t,f,3),f+=2,C=I[_-1]):17==z?(U=3+$n(t,f,7),f+=3):18==z&&(U=11+$n(t,f,127),f+=7);U--;)I[_++]=C}}var L=I.subarray(0,k),P=I.subarray(k);p=Rn(L),w=Rn(P),d=An(L,p,1),v=An(P,w,1)}else Fn(1);if(f>m){c&&Fn(0);break}}a&&u(h+131072);for(var R=(1<<p)-1,$=(1<<w)-1,O=f;;O=f){var B=(C=d[On(t,f)&R])>>4;if((f+=15&C)>m){c&&Fn(0);break}if(C||Fn(2),B<256)e[h++]=B;else{if(256==B){O=f,d=null;break}var j=B-254;B>264&&(j=$n(t,f,(1<<(H=wn[_=B-257]))-1)+kn[_],f+=H);var q=v[On(t,f)&$],F=q>>4;if(q||Fn(3),f+=15&q,P=In[F],F>3){var H=mn[F];P+=On(t,f)&(1<<H)-1,f+=H}if(f>m){c&&Fn(0);break}a&&u(h+131072);var N=h+j;if(h<P){var Z=o-P,X=Math.min(P,N);for(Z+h<0&&Fn(3);h<X;++h)e[h]=i[Z+h]}for(;h<N;++h)e[h]=e[h-P]}}n.l=d,n.p=O,n.b=h,n.f=l,d&&(l=1,n.m=p,n.d=v,n.n=w)}while(!l);return h!=e.length&&s?jn(e,0,h):e.subarray(0,h)},Nn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8},Zn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8,t[i+2]|=e>>16},Xn=function(t,n){for(var e=[],i=0;i<t.length;++i)t[i]&&e.push({s:i,f:t[i]});var r=e.length,o=e.slice();if(!r)return{t:Wn,l:0};if(1==r){var s=new dn(e[0].s+1);return s[e[0].s]=1,{t:s,l:1}}e.sort(function(t,n){return t.f-n.f}),e.push({s:-1,f:25001});var a=e[0],c=e[1],u=0,l=1,f=2;for(e[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=r-1;)a=e[e[u].f<e[f].f?u++:f++],c=e[u!=l&&e[u].f<e[f].f?u++:f++],e[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=o[0].s;for(i=1;i<r;++i)o[i].s>h&&(h=o[i].s);var d=new vn(h+1),v=Gn(e[l-1],d,0);if(v>n){i=0;var p=0,w=v-n,m=1<<w;for(o.sort(function(t,n){return d[n.s]-d[t.s]||t.f-n.f});i<r;++i){var y=o[i].s;if(!(d[y]>n))break;p+=m-(1<<v-d[y]),d[y]=n}for(p>>=w;p>0;){var g=o[i].s;d[g]<n?p-=1<<n-d[g]++-1:++i}for(;i>=0&&p;--i){var b=o[i].s;d[b]==n&&(--d[b],++p)}v=n}return{t:new dn(d),l:v}},Gn=function(t,n,e){return-1==t.s?Math.max(Gn(t.l,n,e+1),Gn(t.r,n,e+1)):n[t.s]=e},Kn=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new vn(++n),i=0,r=t[0],o=1,s=function(t){e[i++]=t},a=1;a<=n;++a)if(t[a]==r&&a!=n)++o;else{if(!r&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(r),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(r);o=1,r=t[a]}return{c:e.subarray(0,i),n:n}},Vn=function(t,n){for(var e=0,i=0;i<n.length;++i)e+=t[i]*n[i];return e},Yn=function(t,n,e){var i=e.length,r=Bn(n+2);t[r]=255&i,t[r+1]=i>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<i;++o)t[r+o+4]=e[o];return 8*(r+4+i)},Jn=function(t,n,e,i,r,o,s,a,c,u,l){Nn(n,l++,e),++r[256];for(var f=Xn(r,15),h=f.t,d=f.l,v=Xn(o,15),p=v.t,w=v.l,m=Kn(h),y=m.c,g=m.n,b=Kn(p),k=b.c,T=b.n,S=new vn(19),I=0;I<y.length;++I)++S[31&y[I]];for(I=0;I<k.length;++I)++S[31&k[I]];for(var x=Xn(S,7),_=x.t,M=x.l,E=19;E>4&&!_[yn[E-1]];--E);var A,z,D,C,U=u+5<<3,L=Vn(r,zn)+Vn(o,Dn)+s,P=Vn(r,h)+Vn(o,p)+s+14+3*E+Vn(S,_)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&U<=L&&U<=P)return Yn(n,l,t.subarray(c,c+u));if(Nn(n,l,1+(P<L)),l+=2,P<L){A=An(h,d,0),z=h,D=An(p,w,0),C=p;var R=An(_,M,0);for(Nn(n,l,g-257),Nn(n,l+5,T-1),Nn(n,l+10,E-4),l+=14,I=0;I<E;++I)Nn(n,l+3*I,_[yn[I]]);l+=3*E;for(var $=[y,k],O=0;O<2;++O){var B=$[O];for(I=0;I<B.length;++I)Nn(n,l,R[q=31&B[I]]),l+=_[q],q>15&&(Nn(n,l,B[I]>>5&127),l+=B[I]>>12)}}else A=Cn,z=zn,D=Ln,C=Dn;for(I=0;I<a;++I){var j=i[I];if(j>255){var q;Zn(n,l,A[257+(q=j>>18&31)]),l+=z[q+257],q>7&&(Nn(n,l,j>>23&31),l+=wn[q]);var F=31&j;Zn(n,l,D[F]),l+=C[F],F>3&&(Zn(n,l,j>>5&8191),l+=mn[F])}else Zn(n,l,A[j]),l+=z[j]}return Zn(n,l,A[256]),l+z[256]},Qn=new pn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Wn=new dn(0),te=function(t,n,e,i,r,o){var s=o.z||t.length,a=new dn(i+s+5*(1+Math.ceil(s/7e3))+r),c=a.subarray(i,a.length-r),u=o.l,l=7&(o.r||0);if(n){l&&(c[0]=o.r>>3);for(var f=Qn[n-1],h=f>>13,d=8191&f,v=(1<<e)-1,p=o.p||new vn(32768),w=o.h||new vn(v+1),m=Math.ceil(e/3),y=2*m,g=function(n){return(t[n]^t[n+1]<<m^t[n+2]<<y)&v},b=new pn(25e3),k=new vn(288),T=new vn(32),S=0,I=0,x=o.i||0,_=0,M=o.w||0,E=0;x+2<s;++x){var A=g(x),z=32767&x,D=w[A];if(p[z]=D,w[A]=z,M<=x){var C=s-x;if((S>7e3||_>24576)&&(C>423||!u)){l=Jn(t,c,0,b,k,T,I,_,E,x-E,l),_=S=I=0,E=x;for(var U=0;U<286;++U)k[U]=0;for(U=0;U<30;++U)T[U]=0}var L=2,P=0,R=d,$=z-D&32767;if(C>2&&A==g(x-$))for(var O=Math.min(h,C)-1,B=Math.min(32767,x),j=Math.min(258,C);$<=B&&--R&&z!=D;){if(t[x+L]==t[x+L-$]){for(var q=0;q<j&&t[x+q]==t[x+q-$];++q);if(q>L){if(L=q,P=$,q>O)break;var F=Math.min($,q-2),H=0;for(U=0;U<F;++U){var N=x-$+U&32767,Z=N-p[N]&32767;Z>H&&(H=Z,D=N)}}}$+=(z=D)-(D=p[z])&32767}if(P){b[_++]=268435456|Tn[L]<<18|xn[P];var X=31&Tn[L],G=31&xn[P];I+=wn[X]+mn[G],++k[257+X],++T[G],M=x+L,++S}else b[_++]=t[x],++k[t[x]]}}for(x=Math.max(x,M);x<s;++x)b[_++]=t[x],++k[t[x]];l=Jn(t,c,u,b,k,T,I,_,E,x-E,l),u||(o.r=7&l|c[l/8|0]<<3,l-=7,o.h=w,o.p=p,o.i=x,o.w=M)}else{for(x=o.w||0;x<s+u;x+=65535){var K=x+65535;K>=s&&(c[l/8|0]=u,K=s),l=Yn(c,l+1,t.subarray(x,K))}o.i=s}return jn(a,0,i+Bn(l)+r)},ne=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var e=n,i=9;--i;)e=(1&e&&-306674912)^e>>>1;t[n]=e}return t}(),ee=function(){var t=-1;return{p:function(n){for(var e=t,i=0;i<n.length;++i)e=ne[255&e^n[i]]^e>>>8;t=e},d:function(){return~t}}},ie=function(){var t=1,n=0;return{p:function(e){for(var i=t,r=n,o=0|e.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s<a;++s)r+=i+=e[s];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}t=i,n=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},re=function(t,n,e,i,r){if(!r&&(r={l:1},n.dictionary)){var o=n.dictionary.subarray(-32768),s=new dn(o.length+t.length);s.set(o),s.set(t,o.length),t=s,r.w=o.length}return te(t,null==n.level?6:n.level,null==n.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+n.mem,e,i,r)},oe=function(t,n){var e={};for(var i in t)e[i]=t[i];for(var i in n)e[i]=n[i];return e},se=function(t,n,e){for(var i=t(),r=t.toString(),o=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<i.length;++s){var a=i[s],c=o[s];if("function"==typeof a){n+=";"+c+"=";var u=a.toString();if(a.prototype)if(-1!=u.indexOf("[native code]")){var l=u.indexOf(" ",8)+1;n+=u.slice(l,u.indexOf("(",l))}else for(var f in n+=u,a.prototype)n+=";"+c+".prototype."+f+"="+a.prototype[f].toString();else n+=u}else e[c]=a}return n},ae=[],ce=function(t,n,e,i){if(!ae[e]){for(var r="",o={},s=t.length-1,a=0;a<s;++a)r=se(t[a],r,o);ae[e]={c:se(t[s],r,o),e:o}}var c=oe({},ae[e].e);return function(t,n,e,i,r){var o=new Worker(hn[n]||(hn[n]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(t){var n=t.data,e=n.$e$;if(e){var i=new Error(e[0]);i.code=e[1],i.stack=e[2],r(i,null)}else r(null,n)},o.postMessage(e,i),o}(ae[e].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+n.toString()+"}",e,c,function(t){var n=[];for(var e in t)t[e].buffer&&n.push((t[e]=new t[e].constructor(t[e])).buffer);return n}(c),i)},ue=function(){return[dn,vn,pn,wn,mn,yn,kn,In,Un,Pn,_n,qn,An,Rn,$n,On,Bn,jn,Fn,Hn,Oe,pe,we]},le=function(){return[dn,vn,pn,wn,mn,yn,Tn,xn,Cn,zn,Ln,Dn,_n,Qn,Wn,An,Nn,Zn,Xn,Gn,Kn,Vn,Yn,Jn,Bn,jn,te,re,Le,pe]},fe=function(){return[Ie,Me,Se,ee,ne]},he=function(){return[xe,_e]},de=function(){return[Ee,Se,ie]},ve=function(){return[Ae]},pe=function(t){return postMessage(t,[t.buffer])},we=function(t){return t&&{out:t.size&&new dn(t.size),dictionary:t.dictionary}},me=function(t,n,e,i,r,o){var s=ce(e,i,r,function(t,n){s.terminate(),o(t,n)});return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},ye=function(t){return t.ondata=function(t,n){return postMessage([t,n],[t.buffer])},function(n){n.data.length?(t.push(n.data[0],n.data[1]),postMessage([n.data[0].length])):t.flush()}},ge=function(t,n,e,i,r,o,s){var a,c=ce(t,i,r,function(t,e){t?(c.terminate(),n.ondata.call(n,t)):Array.isArray(e)?1==e.length?(n.queuedSize-=e[0],n.ondrain&&n.ondrain(e[0])):(e[1]&&c.terminate(),n.ondata.call(n,t,e[0],e[1])):s(e)});c.postMessage(e),n.queuedSize=0,n.push=function(t,e){n.ondata||Fn(5),a&&n.ondata(Fn(4,0,1),null,!!e),n.queuedSize+=t.length,c.postMessage([t,a=e],[t.buffer])},n.terminate=function(){c.terminate()},o&&(n.flush=function(){c.postMessage([])})},be=function(t,n){return t[n]|t[n+1]<<8},ke=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},Te=function(t,n){return ke(t,n)+4294967296*ke(t,n+4)},Se=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},Ie=function(t,n){var e=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&Se(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),e){t[3]=8;for(var i=0;i<=e.length;++i)t[i+10]=e.charCodeAt(i)}},xe=function(t){31==t[0]&&139==t[1]&&8==t[2]||Fn(6,"invalid gzip data");var n=t[3],e=10;4&n&&(e+=2+(t[10]|t[11]<<8));for(var i=(n>>3&1)+(n>>4&1);i>0;i-=!t[e++]);return e+(2&n)},_e=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},Me=function(t){return 10+(t.filename?t.filename.length+1:0)},Ee=function(t,n){var e=n.level,i=0==e?0:e<6?1:9==e?3:2;if(t[0]=120,t[1]=i<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var r=ie();r.p(n.dictionary),Se(t,2,r.d())}},Ae=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&Fn(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&Fn(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function ze(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var De=function(){function t(t,n){if("function"==typeof t&&(n=t,t={}),this.ondata=n,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new dn(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return t.prototype.p=function(t,n){this.ondata(re(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,n){this.ondata||Fn(5),this.s.l&&Fn(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new dn(-32768&e);i.set(this.b.subarray(0,this.s.z)),this.b=i}var r=this.b.length-this.s.z;this.b.set(t.subarray(0,r),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(r),32768),this.s.z=t.length-r+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=1&n,(this.s.z>this.s.w+8191||n)&&(this.p(this.b,n||!1),this.s.w=this.s.i,this.s.i-=2)},t.prototype.flush=function(){this.ondata||Fn(5),this.s.l&&Fn(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},t}(),Ce=function(){return function(t,n){ge([le,function(){return[ye,De]}],this,ze.call(this,t,n),function(t){var n=new De(t.data);onmessage=ye(n)},6,1)}}();function Ue(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[le],function(t){return pe(Le(t.data[0],t.data[1]))},0,e)}function Le(t,n){return re(t,n||{},0,0)}var Pe=function(){function t(t,n){"function"==typeof t&&(n=t,t={}),this.ondata=n;var e=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:e?e.length:0},this.o=new dn(32768),this.p=new dn(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||Fn(5),this.d&&Fn(4),this.p.length){if(t.length){var n=new dn(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length),this.p=n}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||!1);var n=this.s.b,e=Hn(this.p,this.s,this.o);this.ondata(jn(e,n,this.s.b),this.d),this.o=jn(e,this.s.b-32768),this.s.b=this.o.length,this.p=jn(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}(),Re=function(){return function(t,n){ge([ue,function(){return[ye,Pe]}],this,ze.call(this,t,n),function(t){var n=new Pe(t.data);onmessage=ye(n)},7,0)}}();function $e(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[ue],function(t){return pe(Oe(t.data[0],we(t.data[1])))},1,e)}function Oe(t,n){return Hn(t,{i:2},n&&n.out,n&&n.dictionary)}var Be=function(){function t(t,n){this.c=ee(),this.l=0,this.v=1,De.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,De.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=re(t,this.o,this.v&&Me(this.o),n&&8,this.s);this.v&&(Ie(e,this.o),this.v=0),n&&(Se(e,e.length-8,this.c.d()),Se(e,e.length-4,this.l)),this.ondata(e,n)},t.prototype.flush=function(){De.prototype.flush.call(this)},t}(),je=function(){return function(t,n){ge([le,fe,function(){return[ye,De,Be]}],this,ze.call(this,t,n),function(t){var n=new Be(t.data);onmessage=ye(n)},8,1)}}();function qe(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[le,fe,function(){return[Fe]}],function(t){return pe(Fe(t.data[0],t.data[1]))},2,e)}function Fe(t,n){n||(n={});var e=ee(),i=t.length;e.p(t);var r=re(t,n,Me(n),8),o=r.length;return Ie(r,n),Se(r,o-8,e.d()),Se(r,o-4,i),r}var He=function(){function t(t,n){this.v=1,this.r=0,Pe.call(this,t,n)}return t.prototype.push=function(t,n){if(Pe.prototype.e.call(this,t),this.r+=t.length,this.v){var e=this.p.subarray(this.v-1),i=e.length>3?xe(e):4;if(i>e.length){if(!n)return}else this.v>1&&this.onmember&&this.onmember(this.r-e.length);this.p=e.subarray(i),this.v=0}Pe.prototype.c.call(this,n),!this.s.f||this.s.l||n||(this.v=Bn(this.s.p)+9,this.s={i:0},this.o=new dn(0),this.push(new dn(0),n))},t}(),Ne=function(){return function(t,n){var e=this;ge([ue,he,function(){return[ye,Pe,He]}],this,ze.call(this,t,n),function(t){var n=new He(t.data);n.onmember=function(t){return postMessage(t)},onmessage=ye(n)},9,0,function(t){return e.onmember&&e.onmember(t)})}}();function Ze(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[ue,he,function(){return[Xe]}],function(t){return pe(Xe(t.data[0],t.data[1]))},3,e)}function Xe(t,n){var e=xe(t);return e+8>t.length&&Fn(6,"invalid gzip data"),Hn(t.subarray(e,-8),{i:2},n&&n.out||new dn(_e(t)),n&&n.dictionary)}var Ge=function(){function t(t,n){this.c=ie(),this.v=1,De.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),De.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=re(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(Ee(e,this.o),this.v=0),n&&Se(e,e.length-4,this.c.d()),this.ondata(e,n)},t.prototype.flush=function(){De.prototype.flush.call(this)},t}(),Ke=function(){return function(t,n){ge([le,de,function(){return[ye,De,Ge]}],this,ze.call(this,t,n),function(t){var n=new Ge(t.data);onmessage=ye(n)},10,1)}}();function Ve(t,n){n||(n={});var e=ie();e.p(t);var i=re(t,n,n.dictionary?6:2,4);return Ee(i,n),Se(i,i.length-4,e.d()),i}var Ye=function(){function t(t,n){Pe.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(Pe.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(Ae(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&Fn(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Pe.prototype.c.call(this,n)},t}(),Je=function(){return function(t,n){ge([ue,ve,function(){return[ye,Pe,Ye]}],this,ze.call(this,t,n),function(t){var n=new Ye(t.data);onmessage=ye(n)},11,0)}}();function Qe(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[ue,ve,function(){return[We]}],function(t){return pe(We(t.data[0],we(t.data[1])))},5,e)}function We(t,n){return Hn(t.subarray(Ae(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}var ti=function(){function t(t,n){this.o=ze.call(this,t,n)||{},this.G=He,this.I=Pe,this.Z=Ye}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e){t.ondata(n,e)}},t.prototype.push=function(t,n){if(this.ondata||Fn(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new dn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,n),this.p=null)}},t}(),ni=function(){function t(t,n){ti.call(this,t,n),this.queuedSize=0,this.G=Ne,this.I=Re,this.Z=Je}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e,i){t.ondata(n,e,i)},this.s.ondrain=function(n){t.queuedSize-=n,t.ondrain&&t.ondrain(n)}},t.prototype.push=function(t,n){this.queuedSize+=t.length,ti.prototype.push.call(this,t,n)},t}(),ei=function(t,n,e,i){for(var r in t){var o=t[r],s=n+r,a=i;Array.isArray(o)&&(a=oe(i,o[1]),o=o[0]),o instanceof dn?e[s]=[o,a]:(e[s+="/"]=[new dn(0),a],ei(o,s,e,i))}},ii="undefined"!=typeof TextEncoder&&new TextEncoder,ri="undefined"!=typeof TextDecoder&&new TextDecoder,oi=0;try{ri.decode(Wn,{stream:!0}),oi=1}catch(t){}var si=function(t){for(var n="",e=0;;){var i=t[e++],r=(i>127)+(i>223)+(i>239);if(e+r>t.length)return{s:n,r:jn(t,e-1)};r?3==r?(i=((15&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i)):n+=String.fromCharCode(1&r?(31&i)<<6|63&t[e++]:(15&i)<<12|(63&t[e++])<<6|63&t[e++]):n+=String.fromCharCode(i)}},ai=function(){function t(t){this.ondata=t,oi?this.t=new TextDecoder:this.p=Wn}return t.prototype.push=function(t,n){if(this.ondata||Fn(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:!0}),n),void(n&&(this.t.decode().length&&Fn(8),this.t=null));this.p||Fn(4);var e=new dn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=si(e),r=i.s,o=i.r;n?(o.length&&Fn(8),this.p=null):this.p=o,this.ondata(r,n)},t}(),ci=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||Fn(5),this.d&&Fn(4),this.ondata(ui(t),this.d=n||!1)},t}();function ui(t,n){if(n){for(var e=new dn(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(ii)return ii.encode(t);var r=t.length,o=new dn(t.length+(t.length>>1)),s=0,a=function(t){o[s++]=t};for(i=0;i<r;++i){if(s+5>o.length){var c=new dn(s+8+(r-i<<1));c.set(o),o=c}var u=t.charCodeAt(i);u<128||n?a(u):u<2048?(a(192|u>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++i))>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|63&u)):(a(224|u>>12),a(128|u>>6&63),a(128|63&u))}return jn(o,0,s)}function li(t,n){if(n){for(var e="",i=0;i<t.length;i+=16384)e+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return e}if(ri)return ri.decode(t);var r=si(t),o=r.s;return(e=r.r).length&&Fn(8),o}var fi=function(t){return 1==t?3:t<6?2:9==t?1:0},hi=function(t,n){return n+30+be(t,n+26)+be(t,n+28)},di=function(t,n,e){var i=be(t,n+28),r=li(t.subarray(n+46,n+46+i),!(2048&be(t,n+8))),o=n+46+i,s=ke(t,n+20),a=e&&4294967295==s?vi(t,o):[s,ke(t,n+24),ke(t,n+42)],c=a[0],u=a[1],l=a[2];return[be(t,n+10),c,u,r,o+be(t,n+30)+be(t,n+32),l]},vi=function(t,n){for(;1!=be(t,n);n+=4+be(t,n+2));return[Te(t,n+12),Te(t,n+4),Te(t,n+20)]},pi=function(t){var n=0;if(t)for(var e in t){var i=t[e].length;i>65535&&Fn(9),n+=i+4}return n},wi=function(t,n,e,i,r,o,s,a){var c=i.length,u=e.extra,l=a&&a.length,f=pi(u);Se(t,n,null!=s?33639248:67324752),n+=4,null!=s&&(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag<<1|(o<0&&8),t[n++]=r&&8,t[n++]=255&e.compression,t[n++]=e.compression>>8;var h=new Date(null==e.mtime?Date.now():e.mtime),d=h.getFullYear()-1980;if((d<0||d>119)&&Fn(10),Se(t,n,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),n+=4,-1!=o&&(Se(t,n,e.crc),Se(t,n+4,o<0?-o-2:o),Se(t,n+8,e.size)),Se(t,n+12,c),Se(t,n+14,f),n+=16,null!=s&&(Se(t,n,l),Se(t,n+6,e.attrs),Se(t,n+10,s),n+=14),t.set(i,n),n+=c,f)for(var v in u){var p=u[v],w=p.length;Se(t,n,+v),Se(t,n+2,w),t.set(p,n+4),n+=4+w}return l&&(t.set(a,n),n+=l),n},mi=function(t,n,e,i,r){Se(t,n,101010256),Se(t,n+8,e),Se(t,n+10,e),Se(t,n+12,i),Se(t,n+16,r)},yi=function(){function t(t){this.filename=t,this.c=ee(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||Fn(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}(),gi=function(){function t(t,n){var e=this;n||(n={}),yi.call(this,t),this.d=new De(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=fi(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){yi.prototype.push.call(this,t,n)},t}(),bi=function(){function t(t,n){var e=this;n||(n={}),yi.call(this,t),this.d=new Ce(n,function(t,n,i){e.ondata(t,n,i)}),this.compression=8,this.flag=fi(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){yi.prototype.push.call(this,t,n)},t}(),ki=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||Fn(5),2&this.d)this.ondata(Fn(4+8*(1&this.d),0,1),null,!1);else{var e=ui(t.filename),i=e.length,r=t.comment,o=r&&ui(r),s=i!=t.filename.length||o&&r.length!=o.length,a=i+pi(t.extra)+30;i>65535&&this.ondata(Fn(11,0,1),null,!1);var c=new dn(a);wi(c,0,t,e,s,-1);var u=[c],l=function(){for(var t=0,e=u;t<e.length;t++)n.ondata(null,e[t],!1);u=[]},f=this.d;this.d=0;var h=this.u.length,d=oe(t,{f:e,u:s,o:o,t:function(){t.terminate&&t.terminate()},r:function(){if(l(),f){var t=n.u[h+1];t?t.r():n.d=1}f=1}}),v=0;t.ondata=function(e,i,r){if(e)n.ondata(e,i,r),n.terminate();else if(v+=i.length,u.push(i),r){var o=new dn(16);Se(o,0,134695760),Se(o,4,t.crc),Se(o,8,v),Se(o,12,t.size),u.push(o),d.c=v,d.b=a+v+16,d.crc=t.crc,d.size=t.size,f&&d.r(),f=1}else f&&l()},this.u.push(d)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata(Fn(4+8*(1&this.d),0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var t=0,n=0,e=0,i=0,r=this.u;i<r.length;i++)e+=46+(c=r[i]).f.length+pi(c.extra)+(c.o?c.o.length:0);for(var o=new dn(e+22),s=0,a=this.u;s<a.length;s++){var c;wi(o,t,c=a[s],c.f,c.u,-c.c-2,n,c.o),t+=46+c.f.length+pi(c.extra)+(c.o?c.o.length:0),n+=c.b}mi(o,t,this.u.length,e,n),this.ondata(null,o,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,n=this.u;t<n.length;t++)n[t].t();this.d=2},t}(),Ti=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}(),Si=function(){function t(){var t=this;this.i=new Pe(function(n,e){t.ondata(null,n,e)})}return t.prototype.push=function(t,n){try{this.i.push(t,n)}catch(t){this.ondata(t,null,n)}},t.compression=8,t}(),Ii=function(){function t(t,n){var e=this;n<32e4?this.i=new Pe(function(t,n){e.ondata(null,t,n)}):(this.i=new Re(function(t,n,i){e.ondata(t,n,i)}),this.terminate=this.i.terminate)}return t.prototype.push=function(t,n){this.i.terminate&&(t=jn(t,0)),this.i.push(t,n)},t.compression=8,t}(),xi=function(){function t(t){this.onfile=t,this.k=[],this.o={0:Ti},this.p=Wn}return t.prototype.push=function(t,n){var e=this;if(this.onfile||Fn(5),this.p||Fn(4),this.c>0){var i=Math.min(this.c,t.length),r=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),(t=t.subarray(i)).length)return this.push(t,n)}else{var o=0,s=0,a=void 0,c=void 0;this.p.length?t.length?((c=new dn(this.p.length+t.length)).set(this.p),c.set(t,this.p.length)):c=this.p:c=t;for(var u=c.length,l=this.c,f=l&&this.d,h=function(){var t,n=ke(c,s);if(67324752==n){o=1,a=s,d.d=null,d.c=0;var i=be(c,s+6),r=be(c,s+8),f=2048&i,h=8&i,v=be(c,s+26),p=be(c,s+28);if(u>s+30+v+p){var w=[];d.k.unshift(w),o=2;var m,y=ke(c,s+18),g=ke(c,s+22),b=li(c.subarray(s+30,s+=30+v),!f);4294967295==y?(t=h?[-2]:vi(c,s),y=t[0],g=t[1]):h&&(y=-1),s+=p,d.c=y;var k={name:b,compression:r,start:function(){if(k.ondata||Fn(5),y){var t=e.o[r];t||k.ondata(Fn(14,"unknown compression type "+r,1),null,!1),(m=y<0?new t(b):new t(b,y,g)).ondata=function(t,n,e){k.ondata(t,n,e)};for(var n=0,i=w;n<i.length;n++)m.push(i[n],!1);e.k[0]==w&&e.c?e.d=m:m.push(Wn,!0)}else k.ondata(null,Wn,!0)},terminate:function(){m&&m.terminate&&m.terminate()}};y>=0&&(k.size=y,k.originalSize=g),d.onfile(k)}return"break"}if(l){if(134695760==n)return a=s+=12+(-2==l&&8),o=3,d.c=0,"break";if(33639248==n)return a=s-=4,o=3,d.c=0,"break"}},d=this;s<u-4&&"break"!==h();++s);if(this.p=Wn,l<0){var v=c.subarray(0,o?a-12-(-2==l&&8)-(134695760==ke(c,a-16)&&4):s);f?f.push(v,!!o):this.k[+(2==o)].push(v)}if(2&o)return this.push(c.subarray(s),n);this.p=c.subarray(s)}n&&(this.c&&Fn(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),_i="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()},Mi=Object.freeze({__proto__:null,AsyncCompress:je,AsyncDecompress:ni,AsyncDeflate:Ce,AsyncGunzip:Ne,AsyncGzip:je,AsyncInflate:Re,AsyncUnzipInflate:Ii,AsyncUnzlib:Je,AsyncZipDeflate:bi,AsyncZlib:Ke,Compress:Be,DecodeUTF8:ai,Decompress:ti,Deflate:De,EncodeUTF8:ci,FlateErrorCode:{UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14},Gunzip:He,Gzip:Be,Inflate:Pe,Unzip:xi,UnzipInflate:Si,UnzipPassThrough:Ti,Unzlib:Ye,Zip:ki,ZipDeflate:gi,ZipPassThrough:yi,Zlib:Ge,compress:qe,compressSync:Fe,decompress:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),31==t[0]&&139==t[1]&&8==t[2]?Ze(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?$e(t,n,e):Qe(t,n,e)},decompressSync:function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?Xe(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Oe(t,n):We(t,n)},deflate:Ue,deflateSync:Le,gunzip:Ze,gunzipSync:Xe,gzip:qe,gzipSync:Fe,inflate:$e,inflateSync:Oe,strFromU8:li,strToU8:ui,unzip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&Fn(7);var i=[],r=function(){for(var t=0;t<i.length;++t)i[t]()},o={},s=function(t,n){_i(function(){e(t,n)})};_i(function(){s=e});for(var a=t.length-22;101010256!=ke(t,a);--a)if(!a||t.length-a>65558)return s(Fn(13,0,1),null),r;var c=be(t,a+8);if(c){var u=c,l=ke(t,a+16),f=4294967295==l||65535==u;if(f){var h=ke(t,a-12);(f=101075792==ke(t,h))&&(u=c=ke(t,h+32),l=ke(t,h+48))}for(var d=n&&n.filter,v=function(n){var e=di(t,l,f),a=e[0],u=e[1],h=e[2],v=e[3],p=e[4],w=hi(t,e[5]);l=p;var m=function(t,n){t?(r(),s(t,null)):(n&&(o[v]=n),--c||s(null,o))};if(!d||d({name:v,size:u,originalSize:h,compression:a}))if(a)if(8==a){var y=t.subarray(w,w+u);if(h<524288||u>.8*h)try{m(null,Oe(y,{out:new dn(h)}))}catch(t){m(t,null)}else i.push($e(y,{size:h},m))}else m(Fn(14,"unknown compression type "+a,1),null);else m(null,jn(t,w,w+u));else m(null,null)},p=0;p<u;++p)v()}else s(null,{});return r},unzipSync:function(t,n){for(var e={},i=t.length-22;101010256!=ke(t,i);--i)(!i||t.length-i>65558)&&Fn(13);var r=be(t,i+8);if(!r)return{};var o=ke(t,i+16),s=4294967295==o||65535==r;if(s){var a=ke(t,i-12);(s=101075792==ke(t,a))&&(r=ke(t,a+32),o=ke(t,a+48))}for(var c=n&&n.filter,u=0;u<r;++u){var l=di(t,o,s),f=l[0],h=l[1],d=l[2],v=l[3],p=l[4],w=hi(t,l[5]);o=p,c&&!c({name:v,size:h,originalSize:d,compression:f})||(f?8==f?e[v]=Oe(t.subarray(w,w+h),{out:new dn(d)}):Fn(14,"unknown compression type "+f):e[v]=jn(t,w,w+h))}return e},unzlib:Qe,unzlibSync:We,zip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&Fn(7);var i={};ei(t,"",i,n);var r=Object.keys(i),o=r.length,s=0,a=0,c=o,u=new Array(o),l=[],f=function(){for(var t=0;t<l.length;++t)l[t]()},h=function(t,n){_i(function(){e(t,n)})};_i(function(){h=e});var d=function(){var t=new dn(a+22),n=s,e=a-s;a=0;for(var i=0;i<c;++i){var r=u[i];try{var o=r.c.length;wi(t,a,r,r.f,r.u,o);var l=30+r.f.length+pi(r.extra),f=a+l;t.set(r.c,f),wi(t,s,r,r.f,r.u,o,a,r.m),s+=16+l+(r.m?r.m.length:0),a=f+o}catch(t){return h(t,null)}}mi(t,s,u.length,e,n),h(null,t)};o||d();for(var v=function(t){var n=r[t],e=i[n],c=e[0],v=e[1],p=ee(),w=c.length;p.p(c);var m=ui(n),y=m.length,g=v.comment,b=g&&ui(g),k=b&&b.length,T=pi(v.extra),S=0==v.level?0:8,I=function(e,i){if(e)f(),h(e,null);else{var r=i.length;u[t]=oe(v,{size:w,crc:p.d(),c:i,f:m,m:b,u:y!=n.length||b&&g.length!=k,compression:S}),s+=30+y+T+r,a+=76+2*(y+T)+(k||0)+r,--o||d()}};if(y>65535&&I(Fn(11,0,1),null),S)if(w<16e4)try{I(null,Le(c,v))}catch(t){I(t,null)}else l.push(Ue(c,v,I));else I(null,c)},p=0;p<c;++p)v(p);return f},zipSync:function(t,n){n||(n={});var e={},i=[];ei(t,"",e,n);var r=0,o=0;for(var s in e){var a=e[s],c=a[0],u=a[1],l=0==u.level?0:8,f=(S=ui(s)).length,h=u.comment,d=h&&ui(h),v=d&&d.length,p=pi(u.extra);f>65535&&Fn(11);var w=l?Le(c,u):c,m=w.length,y=ee();y.p(c),i.push(oe(u,{size:c.length,crc:y.d(),c:w,f:S,m:d,u:f!=s.length||d&&h.length!=v,o:r,compression:l})),r+=30+f+p+m,o+=76+2*(f+p)+(v||0)+m}for(var g=new dn(o+22),b=r,k=o-r,T=0;T<i.length;++T){var S;wi(g,(S=i[T]).o,S,S.f,S.u,S.c.length);var I=30+S.f.length+pi(S.extra);g.set(S.c,S.o+I),wi(g,r,S,S.f,S.u,S.c.length,S.o,S.m),r+=16+I+(S.m?S.m.length:0)}return mi(g,r,i.length,k,b),g},zlib:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[le,de,function(){return[Ve]}],function(t){return pe(Ve(t.data[0],t.data[1]))},4,e)},zlibSync:Ve});t.createSession=async function(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,r=new AbortController;let o=null,s=!1,a=()=>{};i&&(o=f(()=>{s=!0,r.abort()},i));const c=n?.signal;if(c)if(c.aborted)r.abort();else{const t=()=>r.abort();c.addEventListener("abort",t,{once:!0}),a=()=>c.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:r.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{h(o),a()}},t.default=fn,Object.defineProperty(t,"Bt",{value:!0})});
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).IncodeTRI={})}(this,function(t){"use strict";class n{constructor(){this.T=!1}static get instance(){return n.S||(n.S=new n),n.S}get DEBUG(){return this.T}set DEBUG(t){this.T=t}warn(t,n,...e){this.T&&this._("warn",t,n,...e)}error(t,n,...e){this.T&&this._("error",t,n,...e)}info(t,n,...e){this.T&&this._("info",t,n,...e)}fatal(t,n,e,...i){this._(t,n,e,...i)}_(t,n,e,...i){const r=n?`[${n}]`:"",o=console?.[t];o&&o(`[IncodeTRI]${r} ${e}`,...i)}}const e=n.instance;function i(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.addEventListener(r,e,{capture:!0,passive:!0})}function r(t,n,e){let i=t,r=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),r="change"}i.removeEventListener(r,e,{capture:!0})}const o=globalThis.setTimeout.bind(globalThis),s=globalThis.clearTimeout.bind(globalThis);function a(t,n){try{return t()}catch(t){e.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){e.warn("utils","safeAsync swallowed error:",t)}}function u(t){return n=>a(()=>t(n))}function l(t){return(...n)=>{try{t(...n)}catch(t){e.warn("utils","safeTimer swallowed error:",t)}}}function f(t,n){return o(l(t),n)}function h(t){if(null!==t)try{s(t)}catch(t){e.warn("utils","safeClearTimeout swallowed error:",t)}}const d=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),v=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function w(t,n){const e=t,i=t.responseStart>0,r=p(t.domainLookupEnd-t.domainLookupStart,i),o=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),a=p(t.responseStart-t.requestStart,i),c=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,f=i?t.decodedBodySize:null,h=i&&t.nextHopProtocol||null,v=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,m=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(y=t.initiatorType,d.has(y)?y:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:r,tcpConnectMs:o,tlsHandshakeMs:s,ttfbMs:a,responseDownloadMs:c,transferSize:u,encodedBodySize:l,decodedBodySize:f,nextHopProtocol:h,deliveryType:v,responseStatus:m};var y}function m(){}const y=2e3;function g(t){return!!t&&t.nodeType===Node.TEXT_NODE}function b(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function k(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function T(t){return!!t&&t.hasAttribute("data-tri-ignore")}function S(t){return!!t&&t.hasAttribute("data-tri-redact")}function I(t,n){return n?.includes(t.toLowerCase())??!1}function x(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function _(t,n){return!t||(t[n]?.enabled??!1)}function M(){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&&!T(t)&&!S(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)?g(i)?i.parentElement:i instanceof Element?i:null:null;var i}function z(){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 U(t){return function(t,n){const e=document,i="securitypolicyviolation";let r;const o=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(r=n,s())};e.addEventListener(i,o);const s=()=>e.removeEventListener(i,o);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(),r)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"),r=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},o=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{r(),n()},i.onerror=()=>{r(),e(new Error(R))},i.async=!0,i.src=t,o.appendChild(i)})}(t)).then(z)}const L="API key required";var P="3.12.9";const R="Failed to load the JS script of the agent",$="9319",O={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()&&a(()=>window[t].setItem(e,JSON.stringify(i)))},remove:function(e){n()&&a(()=>window[t].removeItem(e))},key:function(e){return n()?window[t].key(e):null},get length(){return n()?window[t].length:0}}}const j=B("localStorage"),q=B("sessionStorage"),F="__tri_fingerprint";let H=null,N=null;async function Z(t){try{const n=await function(t){return H||(H=function(t){var n,e;const{picked:i,rest:r}=function(t,n){const e={},i={};for(const[r,o]of Object.entries(t))n.includes(r)?e[r]=o:i[r]=o;return{picked:e,rest:i}}(t,["scriptUrlPattern","token","apiKey"]),o=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:O.scriptUrl,[a,c]=function(){const t=[],n=()=>{t.push({time:new Date,state:document.visibilityState})},e=((i=document).addEventListener("visibilitychange",r=n,o),()=>i.removeEventListener("visibilitychange",r,o));var i,r,o;return n(),[t,e]}();return Promise.resolve().then(()=>{if(!o||"string"!=typeof o)throw new Error(L);return function(t,n){const e=[],[i,r]=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,r)=>{let o;const s=r instanceof Error?r.message:"";if(s===D||s===C)n.exclude(),o=0;else if(s===$)n.exclude();else if(s===R){const e=Date.now()-t.getTime()<50,r=n.current();r&&e&&!i.has(r)&&(i.add(r),o=0),n.postpone()}else n.postpone();const a=n.current();return void 0===a?void 0:[a,null!=o?o:t.getTime()+e()-Date.now()]}]}(t);let o;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,a=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),c=n(t);return c.then(()=>a(),a),c.catch(t=>{if(null!=o||(o=t),e.length>=5)throw o;const n=r(i,t);if(!n)throw o;const[a,c]=n;return(u=c,new Promise(t=>setTimeout(t,u))).then(()=>s(a));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(P):t)}(String(t),n))}(s,o),U)}).catch(t=>{throw c(),function(t){return t instanceof Error&&t.message===$?new Error(R):t}(t)}).then(([t,n])=>(c(),t.load({...r,ldi:{attempts:n,visibilityStates:a}})))}({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};j.set(F,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"},G={focusin:"in",focusout:"out"};function K(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const V=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Y={mouse:"mouse",touch:"touch",pen:"pen"},J={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Q(t,n,e,i,r){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:r}}const W={fingerprint:{create:function(t){let n=!1;return c(async()=>{const e=await async function(t){const n=function(){const t=j.get(F);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(j.remove(F),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=Z(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,e){const o=u(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:Y[e.pointerType]??"unknown",phase:J[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 _(e,"pointer")&&(i(document,"pointerdown",o),i(document,"pointerup",o)),_(e,"click")&&i(document,"click",o),_(e,"dblclick")&&i(document,"dblclick",o),_(e,"contextmenu")&&i(document,"contextmenu",o),()=>{r(document,"pointerdown",o),r(document,"pointerup",o),r(document,"click",o),r(document,"dblclick",o),r(document,"contextmenu",o)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,e=null;const o=u(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 a(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 a(t)):(n=s(i),void a(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 a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(document,"pointermove",o),()=>{r(document,"pointermove",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=u(n=>{const e=function(n){const e=n;return{name:"focus",type:G[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return i(document,"focusin",n),i(document,"focusout",n),()=>{r(document,"focusin",n),r(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=u(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!!K(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 K(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return i(document,"input",n),function(){r(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:e}=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 r=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,r),r}const r=n.get(e);return void 0!==r?(n.delete(e),r):++t},reset:function(){n.clear()}}}(),o=u(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:V.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=u(()=>{e()});return i(document,"keydown",o),i(document,"keyup",o),i(window,"blur",s),()=>{r(document,"keydown",o),r(document,"keyup",o),r(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",e){const o=u(e=>{const i=function(e){const i=e,r=e.type,o=("paste"===e.type?i.clipboardData?.getData("text/plain"):M())??null,s=E(i.target,n);return{name:"clipboard",type:r,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:o?.length??0,...s&&o?{content:o}:{}}}(e);t.push(i)});return _(e,"paste")&&i(document,"paste",o),_(e,"cut")&&i(document,"cut",o),_(e,"copy")&&i(document,"copy",o),()=>{r(document,"paste",o),r(document,"cut",o),r(document,"copy",o)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,e){const o=u(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 _(e,"submit")&&i(document,"submit",o),_(e,"invalid")&&i(document,"invalid",o),()=>{r(document,"submit",o),r(document,"invalid",o)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=u(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return i(document,"change",n),()=>{r(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let e=!1,o=0,s=null,a=!1,c=!1;function l(){s&&(clearTimeout(s),s=null)}function f(){l(),a||c||(s=setTimeout(()=>{s=null,e&&h("timeout")},250))}function h(i){e&&(e=!1,l(),function(e){const i=A("end"),r=i&&E(i,n),o=M();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:!0,element:t.resolveElement(i),length:o?.length??0,...r&&o?{content:o}:{}})}(i))}const d=u(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!e&&!n)return e=!0,o=Date.now(),t.push({name:"selection",phase:"start",timestamp:o,element:t.resolveElement(A("start"))}),void f();e&&n?h("collapse"):e&&f()}),v=u(t=>{0===t.button&&(a=!0,l())}),p=u(t=>{0===t.button&&(a=!1,e&&h("pointer"))}),w=u(t=>{"Shift"===t.key&&(c=!0,l())}),m=u(t=>{"Shift"===t.key&&(c=!1,e&&h("keyboard"))}),y=u(()=>{a=!1}),g=u(()=>{"hidden"===document.visibilityState&&(a=!1,c=!1,e&&h("timeout"))}),b=u(()=>{a=!1,e&&h("pointer")});return i(document,"selectionchange",d),i(document,"pointerdown",v),i(document,"pointerup",p),i(document,"keydown",w),i(document,"keyup",m),i(document,"contextmenu",y),i(document,"visibilitychange",g),i(document,"dragend",b),()=>{l(),r(document,"selectionchange",d),r(document,"pointerdown",v),r(document,"pointerup",p),r(document,"keydown",w),r(document,"keyup",m),r(document,"contextmenu",y),r(document,"visibilitychange",g),r(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=u(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 i(document,"visibilitychange",n),()=>{r(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function e(e){t.push(e),n=e.to??""}const o=u(()=>{const[n]=performance.getEntriesByType("navigation");var i;e(Q("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(i=n).fetchStart,domainLookupStart:i.domainLookupStart,domainLookupEnd:i.domainLookupEnd,connectStart:i.connectStart,connectEnd:i.connectEnd,requestStart:i.requestStart,responseStart:i.responseStart,responseEnd:i.responseEnd,domInteractive:i.domInteractive,domContentLoadedEventStart:i.domContentLoadedEventStart,domContentLoadedEventEnd:i.domContentLoadedEventEnd,domComplete:i.domComplete,loadEventStart:i.loadEventStart,loadEventEnd:i.loadEventEnd,redirectCount:i.redirectCount,transferSize:i.transferSize,encodedBodySize:i.encodedBodySize,decodedBodySize:i.decodedBodySize}:void 0))}),s=u(i=>{const r=i;if(null===r.navigationType)return;const o=t.sanitizeUrl(location.href);o!==n&&e(Q("change",r.navigationType,{from:n,to:o},performance.timeOrigin))}),c=u(()=>f("traverse")),l=u(()=>f("hashchange"));function f(i){const r=t.sanitizeUrl(location.href);"hashchange"===i&&r===n||e(Q("change",i,{from:n,to:r},performance.timeOrigin))}const h=history.pushState,d=history.replaceState,v=function(...t){const n=h.apply(this,t);return a(()=>f("push")),n},p=function(...t){const n=d.apply(this,t);return a(()=>f("replace")),n};return window.navigation?i(window.navigation,"currententrychange",s):(history.pushState=v,history.replaceState=p,i(window,"popstate",c),i(window,"hashchange",l)),"complete"===document.readyState?o(new Event("load")):i(window,"load",o),()=>{window.navigation?r(window.navigation,"currententrychange",s):(history.pushState===v&&(history.pushState=h),history.replaceState===p&&(history.replaceState=d),r(window,"popstate",c),r(window,"hashchange",l)),r(window,"load",o)}},layer:"session"},networkconnection:{create:function(t){const n=u(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return i(window,"online",n),i(window,"offline",n),()=>{r(window,"online",n),r(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void a(t)):(n=s(e),void a(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 a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"scroll",o),()=>{r(window,"scroll",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,e=null;const o=u(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void a(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 a(t)):(n=s(e),void a(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 a(t){e&&clearTimeout(e),e=setTimeout(()=>{n&&(t.push(n),n=null),e=null},y)}return i(window,"resize",o),()=>{r(window,"resize",o),e&&(clearTimeout(e),e=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,e){const o=u(n=>{const e=a(n,"orientation");t.push(e)}),s=u(n=>{const e=a(n,"ratiochange");t.push(e)});function a(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 _(e,"orientationchange")&&i(window,"orientationchange",o),_(e,"devicepixelratiochange")&&i(window,"devicepixelratiochange",s),()=>{r(window,"orientationchange",o),r(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,e){let o=null,s=null,a=null,c=null,f=!1;function d(){c&&h(c),c=setTimeout(l(()=>{v(),c=null}),y)}function v(){o&&(t.push(o),o=null),s&&(t.push(s),s=null),a&&(t.push(a),a=null)}const p=u(n=>{const e=n,i=e.timeStamp,r=e.acceleration,s=e.accelerationIncludingGravity,a=e.rotationRate;if(!r&&!s&&!a||null===r?.x&&null===r?.y&&null===r?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===a?.alpha&&null===a?.beta&&null===a?.gamma)return;if(!o)return o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();if(o.samples.ts.length>=50)return t.push(o),o={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[r?.x??0],ay:[r?.y??0],az:[r?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[a?.alpha??0],rrBeta:[a?.beta??0],rrGamma:[a?.gamma??0],ts:[i]}},void d();const c=o.samples;c.ax.push(r?.x??0),c.ay.push(r?.y??0),c.az.push(r?.z??0),c.agx.push(s?.x??0),c.agy.push(s?.y??0),c.agz.push(s?.z??0),c.rrAlpha.push(a?.alpha??0),c.rrBeta.push(a?.beta??0),c.rrGamma.push(a?.gamma??0),c.ts.push(i),d()}),w=u(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,r=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:f||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[r],ts:[i]}},void d();const o=s.samples;o.alpha.push(e.alpha??0),o.beta.push(e.beta??0),o.gamma.push(e.gamma??0),o.compassHeading.push(r),o.ts.push(i),d()}),m=u(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return a?a.samples.ts.length>=50?(t.push(a),a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d()):(a.samples.lux.push(e),a.samples.ts.push(i),void d()):(a={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void d())});return _(e,"motion")&&i(window,"devicemotion",p),_(e,"orientation")&&("ondeviceorientationabsolute"in window?(f=!0,i(window,"deviceorientationabsolute",w)):i(window,"deviceorientation",w)),_(e,"light")&&i(window,"devicelight",m),function(){r(window,"devicemotion",p),r(window,f?"deviceorientationabsolute":"deviceorientation",w),r(window,"devicelight",m),c&&(h(c),c=null),v()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var n;const i=function(t,n,i,r=v){if("undefined"==typeof PerformanceObserver)return m;let o=null;try{o=new PerformanceObserver(e=>{for(const o of e.getEntries()){const e=o;r.has(e.initiatorType)&&(n(e.name)||t(w(e,i)))}}),o.observe({type:"resource",buffered:!0})}catch{return e.warn("network-request","PerformanceObserver failed to start"),m}return function(){o?.disconnect(),o=null}}(function(n){a(()=>t.push(n))},(n=t.ignoredOrigins,function(t){try{return n.has(new URL(t).origin)}catch{return!1}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=a(()=>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"}},tt=Object.keys(W),nt=[/^[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 et(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 nt)if(n.test(t))return!0;return!1}(t)?":param":t).join("/");const r=n.origin+n.pathname+i;return r.length>2048?r.slice(0,2048):r}catch{return""}}const it="idle",rt="ready",ot="started",st="collection-disabled",at="init-failed",ct={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ut(){const t={};for(const n of tt)t[n]=ht(n,void 0,!0);return t}function lt(t){const n={};for(const e of tt)n[e]=ht(e,void 0,t[W[e].layer]??!1);return n}function ft(t){const n={};for(const e of tt){const i=t[e];n[e]=ht(e,i,i?.enabled??!1)}return n}function ht(t,n,e){const i=W[t]?.events??[];if(0===i.length)return{enabled:e};const r=n?.events,o={};for(const t of i)o[t]={enabled:r?.[t]??!0};return{enabled:e,events:o}}function dt(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const vt=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 pt(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 wt="__tri",mt=`${wt}_activity_token`,yt=`${wt}_activity_id`,gt=`${wt}_activity_status`,bt="__tri_activity_lock";class kt{constructor(t){this.context=t,this.M=null,this.A=null,this.D=null,this.C=null,this.U=!1}getToken(){return this.M}getActivityId(){return this.A??""}isActive(){return"ACTIVE"===this.D&&null!==this.M}async start(){return this.U=!0,this.C||(this.C=this.L()),this.C}async stop(){this.U=!1,this.P(null),this.C=null,this.M&&await this.context.stopActivity(),this.R(null)}async refresh(){if(!this.U)return;const t=this.M;await pt(bt,async()=>{if(this.M&&this.M!==t&&!vt(this.M)&&"ACTIVE"===this.D)return;const n=this.$();n&&n.token!==t&&!vt(n.token)&&"ACTIVE"===n.activityStatus?this.R(n):(this.O(),await this.B())})}async L(){try{if(this.M&&!vt(this.M))return;await pt(bt,async()=>{await this.B()})}finally{this.C=null}}async B(){const t=this.$();if(t&&!vt(t.token)&&"ACTIVE"===t.activityStatus)return void this.R(t);t&&this.O();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.R(e),this.j(e)}$(){const[t,n,e]=[j.get(mt),j.get(yt),j.get(gt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.O(),null)}j(t){j.set(mt,t.token),j.set(yt,t.activityId),j.set(gt,t.activityStatus)}O(){this.P(null),this.R(null)}P(t){if(!t)return j.remove(mt),j.remove(yt),void j.remove(gt);j.set(mt,t.token),j.set(yt,t.activityId),j.set(gt,t.activityStatus)}R(t){if(!t)return this.M=null,this.A=null,void(this.D=null);this.M=t.token,this.A=t.activityId,this.D=t.activityStatus}}const Tt=[401,403,409],St=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 It(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:St[t.name]}const xt=new Array(256);for(let t=0;t<256;t++)xt[t]=(t+256).toString(16).slice(1);const _t=new Uint8Array(16);function Mt(t){return xt[t[0]]+xt[t[1]]+xt[t[2]]+xt[t[3]]+"-"+xt[t[4]]+xt[t[5]]+"-"+xt[t[6]]+xt[t[7]]+"-"+xt[t[8]]+xt[t[9]]+"-"+xt[t[10]]+xt[t[11]]+xt[t[12]]+xt[t[13]]+xt[t[14]]+xt[t[15]]}function Et(){return crypto.randomUUID()}function At(){return crypto.getRandomValues(_t),_t[6]=15&_t[6]|64,_t[8]=63&_t[8]|128,Mt(_t)}function zt(){for(let t=0;t<16;t++)_t[t]=256*Math.random()|0;return _t[6]=15&_t[6]|64,_t[8]=63&_t[8]|128,Mt(_t)}const Dt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Et;if("function"==typeof crypto.getRandomValues)return At}return zt}();function Ct(){return Dt()}class Ut{constructor(t,n){this.q=t,this.F=n,this.H=[],this.N=null,this.X=[],this.K=null,this.U=!1,this.V=!0,this.Y=0,this.J=0,this.W=t.flush.intervalMs}push(t){if(this.U){if(this.H.length<this.tt()?this.H.push(t):this.nt(t),this.V)return this.H.length>=this.q.flush.size?(h(this.N),this.N=null,void this.flush("capacity")):void this.et()}else e.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.U&&this.F.isActivityActive())try{if("lifecycle"===t)return void this.it();if(0===this.H.length)return;const n=this.rt(t);this.F.ingest(n,!1).then(t=>this.ot(t,n)).catch(()=>{e.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.H.length>0&&this.et()}catch(t){e.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.U||(this.U=!0,this.V="undefined"==typeof navigator||navigator.onLine)}stop(){if(!this.U)return Promise.resolve();h(this.N),this.N=null,h(this.K),this.K=null;const t=this.it();return this.U=!1,t}onConnectionChange(){const t="undefined"==typeof navigator||navigator.onLine;if(t!==this.V){if(this.V=t,!this.V)return h(this.N),this.N=null,h(this.K),void(this.K=null);this.H.length>0&&this.et(),this.X.length>0&&this.st()}}et(){this.U&&this.V&&null===this.N&&(this.N=f(()=>{this.N=null,this.flush("interval")},this.W))}st(){this.U&&this.V&&null===this.K&&(this.K=f(()=>{this.K=null,this.ct()},this.W))}ct(){if(!this.U||!this.V||0===this.X.length||!this.F.isActivityActive())return;const t=this.X.shift();this.F.ingest(t.batch,!1).then(n=>this.ut(n,t)).catch(()=>{e.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.X.length>0&&this.st()})}lt(t,n){this.X.length>=5&&(this.X.shift(),e.warn("Transport","retry queue full — oldest batch evicted")),this.X.push({batch:t,attempts:n}),this.st()}ot(t,n){t.ok?this.ft():this.ht(t)&&this.lt(n,1)}ut(t,n){if(t.ok)return this.ft(),void(this.X.length>0&&this.st());if(this.ht(t)){if(n.attempts>=3)return this.dt(),e.warn("Transport","batch dropped after MAX_RETRY_ATTEMPTS",n.batch.batchId),void(this.X.length>0&&this.st());this.dt(),this.lt(n.batch,n.attempts+1)}else this.X.length>0&&this.st()}dt(){this.Y++,this.Y%this.q.flush.backoffFailureThreshold===0&&(this.W=Math.min(2*this.W,this.q.flush.maxIntervalMs))}ft(){this.Y=0,this.W=this.q.flush.intervalMs}tt(){return this.q.queue.size*(this.V?1:2)}async it(){if(!this.F.isActivityActive())return Promise.resolve();const t=[];for(const n of this.X)t.push(this.F.ingest(n.batch,!0).catch(()=>{e.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.X=[],this.H.length>0){const n=this.rt("lifecycle");t.push(this.F.ingest(n,!0).catch(()=>{e.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}nt(t){const n=It(t);for(let e=0;e<this.H.length;e++)if(It(this.H[e])<n){for(let t=e;t<this.H.length-1;t++)this.H[t]=this.H[t+1];return this.H.length-=1,void this.H.push(t)}}rt(t){const n="lifecycle"===t?this.H.splice(-this.q.flush.size):this.H.splice(0,this.q.flush.size);return{activityId:"",batchId:Ct(),batchSequence:this.J++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.5.1-rc.0",sdkPlatform:"web",tabId:this.F.getTabId(),events:n}}ht(t){if(t.ok)return!1;switch(t.kind){case"timeout":case"server":case"rate_limited":return!0;default:return!1}}}const Lt="tri:bcast:";const Pt="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(`${Lt}${this.channelName}:`))return;if(null===t.newValue)return;let n;a(()=>j.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)a(()=>t(e))},this.channelName=t,this.senderId=Ct(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Lt}${this.channelName}:${this.senderId}:${this.seq++}`;a(()=>{j.set(n,t),j.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){e.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(){}},Rt="__tri_tabId";class $t{constructor(t){this.context=t,this.vt="",this.U=!1,this.wt=null,this.yt=null,this.gt=null,this.bt=new Map,this.kt=-1,this.Tt=null}async start(){this.U||(this.U=!0,this.vt=this.St(),this.It(),this.xt({type:"hello",tabId:this.vt,ts:Date.now()}),this._t(),this.Mt("active"),this.Et())}stop(){this.U&&(this.U=!1,this.Mt("inactive"),this.xt({type:"bye",tabId:this.vt,ts:Date.now()}),this.At(this.zt()),this.Dt(),this.Ct(),this.Ut())}getTabId(){return this.vt}queryTabsNumber(){return this.bt.size+1}It(){try{this.wt=new Pt("__tri_tab_channel"),this.Tt=this.Lt.bind(this),this.wt.addEventListener("message",this.Tt)}catch(t){e.warn("TabManager","failed to open broadcast channel:",t)}}Ut(){try{if(!this.wt)return;this.Tt&&this.wt.removeEventListener("message",this.Tt),this.wt.close()}catch{}finally{this.wt=null,this.Tt=null}}_t(){this.yt=setInterval(()=>{const t=Date.now();this.xt({type:"heartbeat",tabId:this.vt,ts:t})},1e3)}Dt(){null!=this.yt&&(clearInterval(this.yt),this.yt=null)}Et(){null!=this.gt&&clearTimeout(this.gt),this.gt=setTimeout(()=>{this.gt=null;const t=this.zt()+1;t!==this.kt&&(this.kt=t,this.At(t))},1e3)}Ct(){null!=this.gt&&(clearTimeout(this.gt),this.gt=null)}xt(t){try{if(!this.wt)return;this.wt.postMessage(t)}catch{e.warn("TabManager","failed to broadcast message:",t)}}Lt(t){const{type:n,tabId:e}=t.data;if(e===this.vt)return;const i=Date.now();"hello"===n?(this.xt({type:"ack",tabId:this.vt,ts:i,to:e}),this.bt.set(e,i)):"heartbeat"===n||"ack"===n?this.bt.set(e,i):"bye"===n&&this.bt.delete(e)}At(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.vt,timestamp:Date.now(),value:t})}Mt(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.vt,timestamp:Date.now(),value:t})}St(){const t=q.get(Rt);if(t)return t;const n=Ct();return q.set(Rt,n),n}zt(t=Date.now()){let n=0;for(const[e,i]of this.bt.entries())t-i>=3e3?this.bt.delete(e):n++;return n}}const Ot=globalThis.CompressionStream,Bt=globalThis.Response,jt=globalThis.Blob,qt=new TextEncoder;let Ft=null;async function Ht(t){const n=await async function(t){if("function"!=typeof Ot)return null;try{const n=qt.encode(t),e=new jt([n]).stream().pipeThrough(new Ot("gzip"));return await new Bt(e).arrayBuffer()}catch(t){return e.warn("compression","Native gzip failed:",t),null}}(t);return null!==n?n:async function(t){try{const n=await function(){if(null===Ft){const t=function(t,n=1e4){let i=null;const r=new Promise(t=>{i=f(()=>{e.warn("import",`Import timed out after ${n}ms`),t(null)},n)}),o=Promise.resolve().then(t).catch(t=>(e.warn("import","Import failed:",t),null));return Promise.race([o,r]).finally(()=>{h(i)})}(()=>Promise.resolve().then(function(){return Mi}),1e4);Ft=t,t.then(n=>{null===n&&f(()=>{Ft===t&&(Ft=null)},1e4)})}return Ft}();if(null===n)return null;const{gzipSync:i}=n,r=i(qt.encode(t));return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}catch(t){return e.warn("compression","fflate gzip failed:",t),null}}(t)}function Nt(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 Zt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Xt{constructor(t){this.context=t}stop(){}async report(t,n){const i={name:t,metadata:n,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const r=await this.context.reportEvent(i);if(r.ok)return r;e.warn("EventReport","Failed to report event:",t,n,"with result:",r)}catch(i){e.warn("EventReport","Failed to report event:",t,n,"with error:",i)}}}const Gt=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,i=et){const r=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,r=0,o=0;for(let i=0;i<e;i++){o++;const e=n[i];if(b(e,t.tagName)&&r++,e===t)break}return{siblings:i,ofType:r,child:o}}(t),s=function(t,n,e){const i=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),r={},o=t.id;o&&!I("id",i)&&(r.id=o);const s=t.getAttribute("autocomplete");s&&!I("autocomplete",i)&&(r.autocomplete=s);const a=t.getAttribute("aria-invalid");a&&!I("aria-invalid",i)&&(r.ariaInvalid=a);const c=t.getAttribute("tabindex");c&&!I("tabindex",i)&&(r.tabIndex=parseInt(c,10));const u=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);u&&!I("data-testid",i)&&(r.testId=u);const l=t.hasAttribute("readonly");l&&!I("readonly",i)&&(r.readOnly=l);const f=t.hasAttribute("required");f&&!I("required",i)&&(r.required=f);const h=t.getAttribute("contenteditable");h&&!I("contenteditable",i)&&(r.contentEditable="true"===h||""===h);const d=t.getAttribute("href");d&&!I("href",i)&&(r.href={...n?{}:{url:e(d)},external:x(d)});const v=t.getAttribute("role");v&&!I("role",i)&&(r.role=v);const p=t.getAttribute("type");p&&!I("type",i)&&(r.type=p);const w=t.getAttribute("name");w&&!I("name",i)&&(r.name=w);const m=t.getAttribute("placeholder");!m||n||I("placeholder",i)||(r.placeholder=m);const y=Array.from(t.classList).slice(0,5);y.length>0&&!I("class",i)&&(r.classes=y);const g=t.getAttribute("alt");return!g||n||I("alt",i)||(r.alt=g),Object.keys(r).length?r:null}(t,n,i);return{tagName:r,frame:e,...s?{attributes:s}:{},...o?{nth:o}:{}}}function Jt(t,n){let e=0;const i=[];return function(t){return Gt.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 Qt(t){return t>=20}function Wt(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 tn(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function nn(t,n=!1){if(n)return null;const e=rn(t,"labelledby");if(e)return{text:sn(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=on(t);if(i)return{text:sn(i),resolutionMethod:"aria-label",confidence:"high"};const r=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?en(n):null}(t);if(r)return{text:sn(r),resolutionMethod:"html-for",confidence:"high"};const o=function(t){const n=t.closest("label");return n?en(n):null}(t);if(o)return{text:sn(o),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:sn(s),resolutionMethod:"placeholder",confidence:"low"};const a=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(a)return{text:sn(a),resolutionMethod:"title",confidence:"low"};const c=rn(t,"describedby");if(c)return{text:sn(c),resolutionMethod:"aria-describedby",confidence:"low"};const u=en(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function en(t,n=0){if(n>8)return"";if(g(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=en(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return sn(e)}function rn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const r=i.split(/\s+/),o=[];for(const t of r){const n=document.getElementById(t);if(!n)continue;const e=on(n)??en(n);e.length&&o.push(e)}return o.length?o.join(" "):null}function on(t){return t?.getAttribute("aria-label")?.trim()??null}function sn(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function an(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class cn{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 un(t,n){const{collectors:o,sdk:s}=t;let a=null,c=null,l=null,d=null;try{a=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||e.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const n=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function r(t,r,o){if(void 0===Zt)return{ok:!1,kind:"network"};const s=e?`${e}${r}`:r,a=new AbortController;let c=null,u=!1;c=f(()=>{u=!0,a.abort()},n);const l=o?.signal;let d,v=()=>{};if(l)if(l.aborted)a.abort();else{const t=()=>a.abort();l.addEventListener("abort",t,{once:!0}),v=()=>l.removeEventListener("abort",t)}if(null!=o&&"body"in o&&null!=o.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}}}(o.body);if(!t.ok)return h(c),v(),{ok:!1,kind:"serialize"};d=t.body}try{const n=await Zt(s,{method:t,headers:Nt({token:o?.token,profileId:o?.profileId,contentType:o?.contentType,contentEncoding:o?.contentEncoding,api:i,hasBody:void 0!==d,customHeaders:o?.customHeaders}),body:d,signal:a.signal,keepalive:o?.keepalive});if(!n.ok)return 429===(p=n.status)?{ok:!1,kind:"rate_limited",status:p}:p>=400&&p<500?{ok:!1,kind:"client",status:p}:{ok:!1,kind:"server",status:p};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 a.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"}:a.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{h(c),v()}var p}return{post:async function(t,n){return r("POST",t,n)},get:async function(t,n){return r("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:n,refresh:i}=t;let r=null;return{withAuth:async function(t,o){if(r){const n=await r;if(n)return t(n)}const s=n()??"",a=await t(s);if((c=a).ok||"client"!==c.kind||!Tt.includes(c.status)||!1===o?.refreshable)return a;var c;const u=await(r||(r=async function(){try{return await i(),n()}catch(t){return e.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{r=null}),r));return u&&u!==s?t(u):a}}}(t),r=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(e,o){return i.withAuth(async i=>{const{events:s,...a}=e,c={...a,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 Ht(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(c,s)}catch{return{ok:!1,kind:"serialize"}}return n.post("/events/capture",{body:u.body,token:i,keepalive:o,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...r()})},{refreshable:!o})},reportEvent:async function(t){return i.withAuth(e=>n.post("/events/report-event",{body:t,token:e,contentType:"json",...r()}))},startActivity:async function(){return n.post("/events/start-activity",{token:t.getSdkToken(),...r()})},stopActivity:async function(){return i.withAuth(t=>n.post("/events/end-activity",{token:t,keepalive:!0,...r()}),{refreshable:!1})},collectionStatus:async function(){return n.get("/sdk/collection-status",{token:t.getSdkToken(),...r()})},linkInterview:async function(t){return i.withAuth(e=>n.post("/events/link-interview",{token:e,contentType:"json",...r(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>n.getProfileId(),getToken:()=>c?.getToken()??null,refresh:async()=>c?.refresh()??Promise.resolve(),getActivityId:()=>c?.getActivityId()??""});const t=await a.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};c=new kt({startActivity:()=>a.api.startActivity(),stopActivity:()=>a.api.stopActivity()}),l=new Ut(ct,{ingest:(t,n)=>a.api.ingest(t,n),getTabId:()=>d?.getTabId()??"unknown",isActivityActive:()=>c?.isActive()??!1});const v=o.tab;d=new $t({push:t=>l?.push(t),events:{state:v.enabled&&v.events.state.enabled,count:v.enabled&&v.events.count.enabled}});const p=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function e(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const o=u(()=>t.onConnectionChange());return{start:function(){i(document,"visibilitychange",n),i(window,"pagehide",e),i(window,"online",o),i(window,"offline",o)},stop:function(){r(document,"visibilitychange",n),r(window,"pagehide",e),r(window,"online",o),r(window,"offline",o)}}}({flush:()=>l?.flush("lifecycle"),stopActivity:async()=>c?.stop(),stopTab:()=>d?.stop(),getShouldSkipStopActivity:()=>(d?.queryTabsNumber()??0)>1,onConnectionChange:()=>l?.onConnectionChange()}),w=function(t={}){const{elementLevel:n,sanitizeUrl:e=et}=t,i=n||"redact",r=new cn(6),o=new cn(6);return{resolve:function(t){if(!t||T(t)||"off"===i)return null;let n=r.get(t);if(n||(n=function(t){if(!t||T(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(T(e))return{chain:[],redaction:{level:"ignore",index:-1}};S(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||b(e,"body"))break;if(k(t))e=t.host;else{if(t.nodeType!==Node.ELEMENT_NODE)break;e=t}}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),r.set(t,n)),"ignore"===n.redaction.level)return null;const s="redact"===n.redaction.level||"redact"===i||S(t);let a=o.get(t);return a||(a=function(t,n,i,r){const o=getComputedStyle(t),s=an(t),a=function(t,n,e=!1,i=et){const r=[],o=[];for(let s=t.length-1;s>=0;s--){const a=t[s],c=e||s<=n,u=s+1,l=Yt(a,c,an(a),i),{score:f,reasons:h}=Jt(a,u);if(r.push(l),!Qt(f))continue;const d=nn(a,c);o.push({...l,...d?{label:d}:{},depth:u,score:f,reasons:h})}return{ancestors:r,interactiveCandidates:o.reverse()}}(n,r,i,e),c=Yt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:r}=Jt(t,0);return{interactive:Qt(i),...r.length>0?{reasons:r}:{},disabled:tn(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Wt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,s);let l=null;return i||(l=u.interactive?nn(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:a.ancestors,interactiveCandidates:a.interactiveCandidates,interactivity:u}}(t,n.chain,s,n.redaction.index),o.set(t,a)),a}}}({elementLevel:s.capture?.element,sanitizeUrl:s.sanitizeUrl}),m=new Set;try{m.add(new URL(s.api.url).origin)}catch{}const y=function(t,n,e="on"){const i=new Map;function r(r){if(i.has(r))return;const o=W[r];if(!o||!function(t,n){return n[t]?.enabled??!1}(r,n))return;const s=n[r],a=o.create(t,e,s&&"events"in s?s.events:void 0);i.set(r,a)}return{start:r,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 tt)r(t)}}}({push:t=>l?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:m},o,s.capture?.content),g=new Xt({getActivityId:()=>c?.getActivityId()??"",reportEvent:t=>a.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:a,activityManager:c,transportManager:l,tabManager:d,lifecycleManager:p,collectorManager:y,eventReportManager:g}}}catch(t){return e.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let ln=class t{constructor(){this.Pt=0,this.Rt=null,this.$t=it}static get instance(){return t.S||(t.S=new t),t.S}async setup(t){if(this.$t!==it)return e.fatal("error","setup()",`cannot set up from state '${this.$t}' — call reset() (or reload) first. Ignoring.`),at;try{const n=function(t){if("undefined"==typeof document)return e.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return e.fatal("error","SDK","token is required."),null;if(!t.apiURL)return e.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:n,content:i}=t.capture??{},r={token:t.token,capture:{element:n??"redact",content:i??"off"},api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(o=t.sanitizeUrl,o?function(t){return a(()=>o(t,et))??et(t)}:et),DEBUG:t.DEBUG??!1};var o;return void 0===t.collectors&&void 0===t.layers?{sdk:r,collectors:ut()}:void 0!==t.collectors?{sdk:r,collectors:ft(t.collectors)}:{sdk:r,collectors:lt(t.layers)}}(t);if(!n)return this.$t=at,at;e.DEBUG=n.sdk.DEBUG;const i=await un(n,{getProfileId:()=>null});return"collection-disabled"===i.status?(e.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.$t=st,st):"init-failed"===i.status?(this.$t=at,at):(this.Rt=i.managers,this.$t=rt,!1!==t.autostart?this.start():rt)}catch(t){return e.warn("setup()","failed:",t),this.$t=at,at}}async start(){if(this.$t===it)return e.warn("start()","start() requires a prior successful setup() — ignoring."),this.$t;if(this.$t!==rt)return e.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.$t;this.$t="starting";const t=++this.Pt;return await this.L(t),this.$t}async stop(){e.warn("stop()","called");const t=this.Rt;return t?(++this.Pt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.$t=rt,this.Ot(t)):Promise.resolve(this.$t)}async reset(){const t=this.stop();return this.$t=it,this.Rt=null,t.then(()=>this.$t)}async Ot(t){return await function(t){let n=null;const e=new Promise(t=>{n=f(t,2e3)});return Promise.race([t.finally(()=>h(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.$t}async L(t){const n=this.Rt;if(n){try{if(await n.activityManager.start(),t!==this.Pt)return;if(n.transportManager.start(),await n.tabManager.start(),t!==this.Pt)return;n.lifecycleManager.start(),n.collectorManager.autocapture()}catch(n){return e.warn("start()","failed during monitoring start:",n),void(t===this.Pt&&(this.$t=rt))}t===this.Pt&&(this.$t=ot)}}async linkInterview(t){if(this.$t!==ot||!this.Rt)return e.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),!1;if(!t)return e.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),!1;try{return(await this.Rt.falconServiceManager.api.linkInterview(t)).ok}catch(t){return e.warn("linkInterview()","failed:",t),!1}}};ln.S=null;const fn=ln.instance;var hn={},dn=Uint8Array,vn=Uint16Array,pn=Int32Array,wn=new dn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),mn=new dn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),yn=new dn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gn=function(t,n){for(var e=new vn(31),i=0;i<31;++i)e[i]=n+=1<<t[i-1];var r=new pn(e[30]);for(i=1;i<30;++i)for(var o=e[i];o<e[i+1];++o)r[o]=o-e[i]<<5|i;return{b:e,r:r}},bn=gn(wn,2),kn=bn.b,Tn=bn.r;kn[28]=258,Tn[258]=28;for(var Sn=gn(mn,0),In=Sn.b,xn=Sn.r,_n=new vn(32768),Mn=0;Mn<32768;++Mn){var En=(43690&Mn)>>1|(21845&Mn)<<1;_n[Mn]=((65280&(En=(61680&(En=(52428&En)>>2|(13107&En)<<2))>>4|(3855&En)<<4))>>8|(255&En)<<8)>>1}var An=function(t,n,e){for(var i=t.length,r=0,o=new vn(n);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new vn(n);for(r=1;r<n;++r)a[r]=a[r-1]+o[r-1]<<1;if(e){s=new vn(1<<n);var c=15-n;for(r=0;r<i;++r)if(t[r])for(var u=r<<4|t[r],l=n-t[r],f=a[t[r]-1]++<<l,h=f|(1<<l)-1;f<=h;++f)s[_n[f]>>c]=u}else for(s=new vn(i),r=0;r<i;++r)t[r]&&(s[r]=_n[a[t[r]-1]++]>>15-t[r]);return s},zn=new dn(288);for(Mn=0;Mn<144;++Mn)zn[Mn]=8;for(Mn=144;Mn<256;++Mn)zn[Mn]=9;for(Mn=256;Mn<280;++Mn)zn[Mn]=7;for(Mn=280;Mn<288;++Mn)zn[Mn]=8;var Dn=new dn(32);for(Mn=0;Mn<32;++Mn)Dn[Mn]=5;var Cn=An(zn,9,0),Un=An(zn,9,1),Ln=An(Dn,5,0),Pn=An(Dn,5,1),Rn=function(t){for(var n=t[0],e=1;e<t.length;++e)t[e]>n&&(n=t[e]);return n},$n=function(t,n,e){var i=n/8|0;return(t[i]|t[i+1]<<8)>>(7&n)&e},On=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},Bn=function(t){return(t+7)/8|0},jn=function(t,n,e){return(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length),new dn(t.subarray(n,e))},qn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Fn=function(t,n,e){var i=new Error(n||qn[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Fn),!e)throw i;return i},Hn=function(t,n,e,i){var r=t.length,o=i?i.length:0;if(!r||n.f&&!n.l)return e||new dn(0);var s=!e,a=s||2!=n.i,c=n.i;s&&(e=new dn(3*r));var u=function(t){var n=e.length;if(t>n){var i=new dn(Math.max(2*n,t));i.set(e),e=i}},l=n.f||0,f=n.p||0,h=n.b||0,d=n.l,v=n.d,p=n.m,w=n.n,m=8*r;do{if(!d){l=$n(t,f,1);var y=$n(t,f+1,3);if(f+=3,!y){var g=t[(z=Bn(f)+4)-4]|t[z-3]<<8,b=z+g;if(b>r){c&&Fn(0);break}a&&u(h+g),e.set(t.subarray(z,b),h),n.b=h+=g,n.p=f=8*b,n.f=l;continue}if(1==y)d=Un,v=Pn,p=9,w=5;else if(2==y){var k=$n(t,f,31)+257,T=$n(t,f+10,15)+4,S=k+$n(t,f+5,31)+1;f+=14;for(var I=new dn(S),x=new dn(19),_=0;_<T;++_)x[yn[_]]=$n(t,f+3*_,7);f+=3*T;var M=Rn(x),E=(1<<M)-1,A=An(x,M,1);for(_=0;_<S;){var z,D=A[$n(t,f,E)];if(f+=15&D,(z=D>>4)<16)I[_++]=z;else{var C=0,U=0;for(16==z?(U=3+$n(t,f,3),f+=2,C=I[_-1]):17==z?(U=3+$n(t,f,7),f+=3):18==z&&(U=11+$n(t,f,127),f+=7);U--;)I[_++]=C}}var L=I.subarray(0,k),P=I.subarray(k);p=Rn(L),w=Rn(P),d=An(L,p,1),v=An(P,w,1)}else Fn(1);if(f>m){c&&Fn(0);break}}a&&u(h+131072);for(var R=(1<<p)-1,$=(1<<w)-1,O=f;;O=f){var B=(C=d[On(t,f)&R])>>4;if((f+=15&C)>m){c&&Fn(0);break}if(C||Fn(2),B<256)e[h++]=B;else{if(256==B){O=f,d=null;break}var j=B-254;B>264&&(j=$n(t,f,(1<<(H=wn[_=B-257]))-1)+kn[_],f+=H);var q=v[On(t,f)&$],F=q>>4;if(q||Fn(3),f+=15&q,P=In[F],F>3){var H=mn[F];P+=On(t,f)&(1<<H)-1,f+=H}if(f>m){c&&Fn(0);break}a&&u(h+131072);var N=h+j;if(h<P){var Z=o-P,X=Math.min(P,N);for(Z+h<0&&Fn(3);h<X;++h)e[h]=i[Z+h]}for(;h<N;++h)e[h]=e[h-P]}}n.l=d,n.p=O,n.b=h,n.f=l,d&&(l=1,n.m=p,n.d=v,n.n=w)}while(!l);return h!=e.length&&s?jn(e,0,h):e.subarray(0,h)},Nn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8},Zn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8,t[i+2]|=e>>16},Xn=function(t,n){for(var e=[],i=0;i<t.length;++i)t[i]&&e.push({s:i,f:t[i]});var r=e.length,o=e.slice();if(!r)return{t:Wn,l:0};if(1==r){var s=new dn(e[0].s+1);return s[e[0].s]=1,{t:s,l:1}}e.sort(function(t,n){return t.f-n.f}),e.push({s:-1,f:25001});var a=e[0],c=e[1],u=0,l=1,f=2;for(e[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=r-1;)a=e[e[u].f<e[f].f?u++:f++],c=e[u!=l&&e[u].f<e[f].f?u++:f++],e[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=o[0].s;for(i=1;i<r;++i)o[i].s>h&&(h=o[i].s);var d=new vn(h+1),v=Gn(e[l-1],d,0);if(v>n){i=0;var p=0,w=v-n,m=1<<w;for(o.sort(function(t,n){return d[n.s]-d[t.s]||t.f-n.f});i<r;++i){var y=o[i].s;if(!(d[y]>n))break;p+=m-(1<<v-d[y]),d[y]=n}for(p>>=w;p>0;){var g=o[i].s;d[g]<n?p-=1<<n-d[g]++-1:++i}for(;i>=0&&p;--i){var b=o[i].s;d[b]==n&&(--d[b],++p)}v=n}return{t:new dn(d),l:v}},Gn=function(t,n,e){return-1==t.s?Math.max(Gn(t.l,n,e+1),Gn(t.r,n,e+1)):n[t.s]=e},Kn=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new vn(++n),i=0,r=t[0],o=1,s=function(t){e[i++]=t},a=1;a<=n;++a)if(t[a]==r&&a!=n)++o;else{if(!r&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(r),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(r);o=1,r=t[a]}return{c:e.subarray(0,i),n:n}},Vn=function(t,n){for(var e=0,i=0;i<n.length;++i)e+=t[i]*n[i];return e},Yn=function(t,n,e){var i=e.length,r=Bn(n+2);t[r]=255&i,t[r+1]=i>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o<i;++o)t[r+o+4]=e[o];return 8*(r+4+i)},Jn=function(t,n,e,i,r,o,s,a,c,u,l){Nn(n,l++,e),++r[256];for(var f=Xn(r,15),h=f.t,d=f.l,v=Xn(o,15),p=v.t,w=v.l,m=Kn(h),y=m.c,g=m.n,b=Kn(p),k=b.c,T=b.n,S=new vn(19),I=0;I<y.length;++I)++S[31&y[I]];for(I=0;I<k.length;++I)++S[31&k[I]];for(var x=Xn(S,7),_=x.t,M=x.l,E=19;E>4&&!_[yn[E-1]];--E);var A,z,D,C,U=u+5<<3,L=Vn(r,zn)+Vn(o,Dn)+s,P=Vn(r,h)+Vn(o,p)+s+14+3*E+Vn(S,_)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&U<=L&&U<=P)return Yn(n,l,t.subarray(c,c+u));if(Nn(n,l,1+(P<L)),l+=2,P<L){A=An(h,d,0),z=h,D=An(p,w,0),C=p;var R=An(_,M,0);for(Nn(n,l,g-257),Nn(n,l+5,T-1),Nn(n,l+10,E-4),l+=14,I=0;I<E;++I)Nn(n,l+3*I,_[yn[I]]);l+=3*E;for(var $=[y,k],O=0;O<2;++O){var B=$[O];for(I=0;I<B.length;++I)Nn(n,l,R[q=31&B[I]]),l+=_[q],q>15&&(Nn(n,l,B[I]>>5&127),l+=B[I]>>12)}}else A=Cn,z=zn,D=Ln,C=Dn;for(I=0;I<a;++I){var j=i[I];if(j>255){var q;Zn(n,l,A[257+(q=j>>18&31)]),l+=z[q+257],q>7&&(Nn(n,l,j>>23&31),l+=wn[q]);var F=31&j;Zn(n,l,D[F]),l+=C[F],F>3&&(Zn(n,l,j>>5&8191),l+=mn[F])}else Zn(n,l,A[j]),l+=z[j]}return Zn(n,l,A[256]),l+z[256]},Qn=new pn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Wn=new dn(0),te=function(t,n,e,i,r,o){var s=o.z||t.length,a=new dn(i+s+5*(1+Math.ceil(s/7e3))+r),c=a.subarray(i,a.length-r),u=o.l,l=7&(o.r||0);if(n){l&&(c[0]=o.r>>3);for(var f=Qn[n-1],h=f>>13,d=8191&f,v=(1<<e)-1,p=o.p||new vn(32768),w=o.h||new vn(v+1),m=Math.ceil(e/3),y=2*m,g=function(n){return(t[n]^t[n+1]<<m^t[n+2]<<y)&v},b=new pn(25e3),k=new vn(288),T=new vn(32),S=0,I=0,x=o.i||0,_=0,M=o.w||0,E=0;x+2<s;++x){var A=g(x),z=32767&x,D=w[A];if(p[z]=D,w[A]=z,M<=x){var C=s-x;if((S>7e3||_>24576)&&(C>423||!u)){l=Jn(t,c,0,b,k,T,I,_,E,x-E,l),_=S=I=0,E=x;for(var U=0;U<286;++U)k[U]=0;for(U=0;U<30;++U)T[U]=0}var L=2,P=0,R=d,$=z-D&32767;if(C>2&&A==g(x-$))for(var O=Math.min(h,C)-1,B=Math.min(32767,x),j=Math.min(258,C);$<=B&&--R&&z!=D;){if(t[x+L]==t[x+L-$]){for(var q=0;q<j&&t[x+q]==t[x+q-$];++q);if(q>L){if(L=q,P=$,q>O)break;var F=Math.min($,q-2),H=0;for(U=0;U<F;++U){var N=x-$+U&32767,Z=N-p[N]&32767;Z>H&&(H=Z,D=N)}}}$+=(z=D)-(D=p[z])&32767}if(P){b[_++]=268435456|Tn[L]<<18|xn[P];var X=31&Tn[L],G=31&xn[P];I+=wn[X]+mn[G],++k[257+X],++T[G],M=x+L,++S}else b[_++]=t[x],++k[t[x]]}}for(x=Math.max(x,M);x<s;++x)b[_++]=t[x],++k[t[x]];l=Jn(t,c,u,b,k,T,I,_,E,x-E,l),u||(o.r=7&l|c[l/8|0]<<3,l-=7,o.h=w,o.p=p,o.i=x,o.w=M)}else{for(x=o.w||0;x<s+u;x+=65535){var K=x+65535;K>=s&&(c[l/8|0]=u,K=s),l=Yn(c,l+1,t.subarray(x,K))}o.i=s}return jn(a,0,i+Bn(l)+r)},ne=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var e=n,i=9;--i;)e=(1&e&&-306674912)^e>>>1;t[n]=e}return t}(),ee=function(){var t=-1;return{p:function(n){for(var e=t,i=0;i<n.length;++i)e=ne[255&e^n[i]]^e>>>8;t=e},d:function(){return~t}}},ie=function(){var t=1,n=0;return{p:function(e){for(var i=t,r=n,o=0|e.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s<a;++s)r+=i+=e[s];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}t=i,n=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},re=function(t,n,e,i,r){if(!r&&(r={l:1},n.dictionary)){var o=n.dictionary.subarray(-32768),s=new dn(o.length+t.length);s.set(o),s.set(t,o.length),t=s,r.w=o.length}return te(t,null==n.level?6:n.level,null==n.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+n.mem,e,i,r)},oe=function(t,n){var e={};for(var i in t)e[i]=t[i];for(var i in n)e[i]=n[i];return e},se=function(t,n,e){for(var i=t(),r=t.toString(),o=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<i.length;++s){var a=i[s],c=o[s];if("function"==typeof a){n+=";"+c+"=";var u=a.toString();if(a.prototype)if(-1!=u.indexOf("[native code]")){var l=u.indexOf(" ",8)+1;n+=u.slice(l,u.indexOf("(",l))}else for(var f in n+=u,a.prototype)n+=";"+c+".prototype."+f+"="+a.prototype[f].toString();else n+=u}else e[c]=a}return n},ae=[],ce=function(t,n,e,i){if(!ae[e]){for(var r="",o={},s=t.length-1,a=0;a<s;++a)r=se(t[a],r,o);ae[e]={c:se(t[s],r,o),e:o}}var c=oe({},ae[e].e);return function(t,n,e,i,r){var o=new Worker(hn[n]||(hn[n]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(t){var n=t.data,e=n.$e$;if(e){var i=new Error(e[0]);i.code=e[1],i.stack=e[2],r(i,null)}else r(null,n)},o.postMessage(e,i),o}(ae[e].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+n.toString()+"}",e,c,function(t){var n=[];for(var e in t)t[e].buffer&&n.push((t[e]=new t[e].constructor(t[e])).buffer);return n}(c),i)},ue=function(){return[dn,vn,pn,wn,mn,yn,kn,In,Un,Pn,_n,qn,An,Rn,$n,On,Bn,jn,Fn,Hn,Oe,pe,we]},le=function(){return[dn,vn,pn,wn,mn,yn,Tn,xn,Cn,zn,Ln,Dn,_n,Qn,Wn,An,Nn,Zn,Xn,Gn,Kn,Vn,Yn,Jn,Bn,jn,te,re,Le,pe]},fe=function(){return[Ie,Me,Se,ee,ne]},he=function(){return[xe,_e]},de=function(){return[Ee,Se,ie]},ve=function(){return[Ae]},pe=function(t){return postMessage(t,[t.buffer])},we=function(t){return t&&{out:t.size&&new dn(t.size),dictionary:t.dictionary}},me=function(t,n,e,i,r,o){var s=ce(e,i,r,function(t,n){s.terminate(),o(t,n)});return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},ye=function(t){return t.ondata=function(t,n){return postMessage([t,n],[t.buffer])},function(n){n.data.length?(t.push(n.data[0],n.data[1]),postMessage([n.data[0].length])):t.flush()}},ge=function(t,n,e,i,r,o,s){var a,c=ce(t,i,r,function(t,e){t?(c.terminate(),n.ondata.call(n,t)):Array.isArray(e)?1==e.length?(n.queuedSize-=e[0],n.ondrain&&n.ondrain(e[0])):(e[1]&&c.terminate(),n.ondata.call(n,t,e[0],e[1])):s(e)});c.postMessage(e),n.queuedSize=0,n.push=function(t,e){n.ondata||Fn(5),a&&n.ondata(Fn(4,0,1),null,!!e),n.queuedSize+=t.length,c.postMessage([t,a=e],[t.buffer])},n.terminate=function(){c.terminate()},o&&(n.flush=function(){c.postMessage([])})},be=function(t,n){return t[n]|t[n+1]<<8},ke=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},Te=function(t,n){return ke(t,n)+4294967296*ke(t,n+4)},Se=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},Ie=function(t,n){var e=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&Se(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),e){t[3]=8;for(var i=0;i<=e.length;++i)t[i+10]=e.charCodeAt(i)}},xe=function(t){31==t[0]&&139==t[1]&&8==t[2]||Fn(6,"invalid gzip data");var n=t[3],e=10;4&n&&(e+=2+(t[10]|t[11]<<8));for(var i=(n>>3&1)+(n>>4&1);i>0;i-=!t[e++]);return e+(2&n)},_e=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},Me=function(t){return 10+(t.filename?t.filename.length+1:0)},Ee=function(t,n){var e=n.level,i=0==e?0:e<6?1:9==e?3:2;if(t[0]=120,t[1]=i<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var r=ie();r.p(n.dictionary),Se(t,2,r.d())}},Ae=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&Fn(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&Fn(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function ze(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var De=function(){function t(t,n){if("function"==typeof t&&(n=t,t={}),this.ondata=n,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new dn(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return t.prototype.p=function(t,n){this.ondata(re(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,n){this.ondata||Fn(5),this.s.l&&Fn(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new dn(-32768&e);i.set(this.b.subarray(0,this.s.z)),this.b=i}var r=this.b.length-this.s.z;this.b.set(t.subarray(0,r),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(r),32768),this.s.z=t.length-r+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=1&n,(this.s.z>this.s.w+8191||n)&&(this.p(this.b,n||!1),this.s.w=this.s.i,this.s.i-=2)},t.prototype.flush=function(){this.ondata||Fn(5),this.s.l&&Fn(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},t}(),Ce=function(){return function(t,n){ge([le,function(){return[ye,De]}],this,ze.call(this,t,n),function(t){var n=new De(t.data);onmessage=ye(n)},6,1)}}();function Ue(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[le],function(t){return pe(Le(t.data[0],t.data[1]))},0,e)}function Le(t,n){return re(t,n||{},0,0)}var Pe=function(){function t(t,n){"function"==typeof t&&(n=t,t={}),this.ondata=n;var e=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:e?e.length:0},this.o=new dn(32768),this.p=new dn(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||Fn(5),this.d&&Fn(4),this.p.length){if(t.length){var n=new dn(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length),this.p=n}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||!1);var n=this.s.b,e=Hn(this.p,this.s,this.o);this.ondata(jn(e,n,this.s.b),this.d),this.o=jn(e,this.s.b-32768),this.s.b=this.o.length,this.p=jn(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}(),Re=function(){return function(t,n){ge([ue,function(){return[ye,Pe]}],this,ze.call(this,t,n),function(t){var n=new Pe(t.data);onmessage=ye(n)},7,0)}}();function $e(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[ue],function(t){return pe(Oe(t.data[0],we(t.data[1])))},1,e)}function Oe(t,n){return Hn(t,{i:2},n&&n.out,n&&n.dictionary)}var Be=function(){function t(t,n){this.c=ee(),this.l=0,this.v=1,De.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,De.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=re(t,this.o,this.v&&Me(this.o),n&&8,this.s);this.v&&(Ie(e,this.o),this.v=0),n&&(Se(e,e.length-8,this.c.d()),Se(e,e.length-4,this.l)),this.ondata(e,n)},t.prototype.flush=function(){De.prototype.flush.call(this)},t}(),je=function(){return function(t,n){ge([le,fe,function(){return[ye,De,Be]}],this,ze.call(this,t,n),function(t){var n=new Be(t.data);onmessage=ye(n)},8,1)}}();function qe(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[le,fe,function(){return[Fe]}],function(t){return pe(Fe(t.data[0],t.data[1]))},2,e)}function Fe(t,n){n||(n={});var e=ee(),i=t.length;e.p(t);var r=re(t,n,Me(n),8),o=r.length;return Ie(r,n),Se(r,o-8,e.d()),Se(r,o-4,i),r}var He=function(){function t(t,n){this.v=1,this.r=0,Pe.call(this,t,n)}return t.prototype.push=function(t,n){if(Pe.prototype.e.call(this,t),this.r+=t.length,this.v){var e=this.p.subarray(this.v-1),i=e.length>3?xe(e):4;if(i>e.length){if(!n)return}else this.v>1&&this.onmember&&this.onmember(this.r-e.length);this.p=e.subarray(i),this.v=0}Pe.prototype.c.call(this,n),!this.s.f||this.s.l||n||(this.v=Bn(this.s.p)+9,this.s={i:0},this.o=new dn(0),this.push(new dn(0),n))},t}(),Ne=function(){return function(t,n){var e=this;ge([ue,he,function(){return[ye,Pe,He]}],this,ze.call(this,t,n),function(t){var n=new He(t.data);n.onmember=function(t){return postMessage(t)},onmessage=ye(n)},9,0,function(t){return e.onmember&&e.onmember(t)})}}();function Ze(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[ue,he,function(){return[Xe]}],function(t){return pe(Xe(t.data[0],t.data[1]))},3,e)}function Xe(t,n){var e=xe(t);return e+8>t.length&&Fn(6,"invalid gzip data"),Hn(t.subarray(e,-8),{i:2},n&&n.out||new dn(_e(t)),n&&n.dictionary)}var Ge=function(){function t(t,n){this.c=ie(),this.v=1,De.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),De.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=re(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(Ee(e,this.o),this.v=0),n&&Se(e,e.length-4,this.c.d()),this.ondata(e,n)},t.prototype.flush=function(){De.prototype.flush.call(this)},t}(),Ke=function(){return function(t,n){ge([le,de,function(){return[ye,De,Ge]}],this,ze.call(this,t,n),function(t){var n=new Ge(t.data);onmessage=ye(n)},10,1)}}();function Ve(t,n){n||(n={});var e=ie();e.p(t);var i=re(t,n,n.dictionary?6:2,4);return Ee(i,n),Se(i,i.length-4,e.d()),i}var Ye=function(){function t(t,n){Pe.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(Pe.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(Ae(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&Fn(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Pe.prototype.c.call(this,n)},t}(),Je=function(){return function(t,n){ge([ue,ve,function(){return[ye,Pe,Ye]}],this,ze.call(this,t,n),function(t){var n=new Ye(t.data);onmessage=ye(n)},11,0)}}();function Qe(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[ue,ve,function(){return[We]}],function(t){return pe(We(t.data[0],we(t.data[1])))},5,e)}function We(t,n){return Hn(t.subarray(Ae(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}var ti=function(){function t(t,n){this.o=ze.call(this,t,n)||{},this.G=He,this.I=Pe,this.Z=Ye}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e){t.ondata(n,e)}},t.prototype.push=function(t,n){if(this.ondata||Fn(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new dn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,n),this.p=null)}},t}(),ni=function(){function t(t,n){ti.call(this,t,n),this.queuedSize=0,this.G=Ne,this.I=Re,this.Z=Je}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e,i){t.ondata(n,e,i)},this.s.ondrain=function(n){t.queuedSize-=n,t.ondrain&&t.ondrain(n)}},t.prototype.push=function(t,n){this.queuedSize+=t.length,ti.prototype.push.call(this,t,n)},t}(),ei=function(t,n,e,i){for(var r in t){var o=t[r],s=n+r,a=i;Array.isArray(o)&&(a=oe(i,o[1]),o=o[0]),o instanceof dn?e[s]=[o,a]:(e[s+="/"]=[new dn(0),a],ei(o,s,e,i))}},ii="undefined"!=typeof TextEncoder&&new TextEncoder,ri="undefined"!=typeof TextDecoder&&new TextDecoder,oi=0;try{ri.decode(Wn,{stream:!0}),oi=1}catch(t){}var si=function(t){for(var n="",e=0;;){var i=t[e++],r=(i>127)+(i>223)+(i>239);if(e+r>t.length)return{s:n,r:jn(t,e-1)};r?3==r?(i=((15&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i)):n+=String.fromCharCode(1&r?(31&i)<<6|63&t[e++]:(15&i)<<12|(63&t[e++])<<6|63&t[e++]):n+=String.fromCharCode(i)}},ai=function(){function t(t){this.ondata=t,oi?this.t=new TextDecoder:this.p=Wn}return t.prototype.push=function(t,n){if(this.ondata||Fn(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:!0}),n),void(n&&(this.t.decode().length&&Fn(8),this.t=null));this.p||Fn(4);var e=new dn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=si(e),r=i.s,o=i.r;n?(o.length&&Fn(8),this.p=null):this.p=o,this.ondata(r,n)},t}(),ci=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||Fn(5),this.d&&Fn(4),this.ondata(ui(t),this.d=n||!1)},t}();function ui(t,n){if(n){for(var e=new dn(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(ii)return ii.encode(t);var r=t.length,o=new dn(t.length+(t.length>>1)),s=0,a=function(t){o[s++]=t};for(i=0;i<r;++i){if(s+5>o.length){var c=new dn(s+8+(r-i<<1));c.set(o),o=c}var u=t.charCodeAt(i);u<128||n?a(u):u<2048?(a(192|u>>6),a(128|63&u)):u>55295&&u<57344?(a(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++i))>>18),a(128|u>>12&63),a(128|u>>6&63),a(128|63&u)):(a(224|u>>12),a(128|u>>6&63),a(128|63&u))}return jn(o,0,s)}function li(t,n){if(n){for(var e="",i=0;i<t.length;i+=16384)e+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return e}if(ri)return ri.decode(t);var r=si(t),o=r.s;return(e=r.r).length&&Fn(8),o}var fi=function(t){return 1==t?3:t<6?2:9==t?1:0},hi=function(t,n){return n+30+be(t,n+26)+be(t,n+28)},di=function(t,n,e){var i=be(t,n+28),r=li(t.subarray(n+46,n+46+i),!(2048&be(t,n+8))),o=n+46+i,s=ke(t,n+20),a=e&&4294967295==s?vi(t,o):[s,ke(t,n+24),ke(t,n+42)],c=a[0],u=a[1],l=a[2];return[be(t,n+10),c,u,r,o+be(t,n+30)+be(t,n+32),l]},vi=function(t,n){for(;1!=be(t,n);n+=4+be(t,n+2));return[Te(t,n+12),Te(t,n+4),Te(t,n+20)]},pi=function(t){var n=0;if(t)for(var e in t){var i=t[e].length;i>65535&&Fn(9),n+=i+4}return n},wi=function(t,n,e,i,r,o,s,a){var c=i.length,u=e.extra,l=a&&a.length,f=pi(u);Se(t,n,null!=s?33639248:67324752),n+=4,null!=s&&(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag<<1|(o<0&&8),t[n++]=r&&8,t[n++]=255&e.compression,t[n++]=e.compression>>8;var h=new Date(null==e.mtime?Date.now():e.mtime),d=h.getFullYear()-1980;if((d<0||d>119)&&Fn(10),Se(t,n,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),n+=4,-1!=o&&(Se(t,n,e.crc),Se(t,n+4,o<0?-o-2:o),Se(t,n+8,e.size)),Se(t,n+12,c),Se(t,n+14,f),n+=16,null!=s&&(Se(t,n,l),Se(t,n+6,e.attrs),Se(t,n+10,s),n+=14),t.set(i,n),n+=c,f)for(var v in u){var p=u[v],w=p.length;Se(t,n,+v),Se(t,n+2,w),t.set(p,n+4),n+=4+w}return l&&(t.set(a,n),n+=l),n},mi=function(t,n,e,i,r){Se(t,n,101010256),Se(t,n+8,e),Se(t,n+10,e),Se(t,n+12,i),Se(t,n+16,r)},yi=function(){function t(t){this.filename=t,this.c=ee(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||Fn(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}(),gi=function(){function t(t,n){var e=this;n||(n={}),yi.call(this,t),this.d=new De(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=fi(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){yi.prototype.push.call(this,t,n)},t}(),bi=function(){function t(t,n){var e=this;n||(n={}),yi.call(this,t),this.d=new Ce(n,function(t,n,i){e.ondata(t,n,i)}),this.compression=8,this.flag=fi(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){yi.prototype.push.call(this,t,n)},t}(),ki=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||Fn(5),2&this.d)this.ondata(Fn(4+8*(1&this.d),0,1),null,!1);else{var e=ui(t.filename),i=e.length,r=t.comment,o=r&&ui(r),s=i!=t.filename.length||o&&r.length!=o.length,a=i+pi(t.extra)+30;i>65535&&this.ondata(Fn(11,0,1),null,!1);var c=new dn(a);wi(c,0,t,e,s,-1);var u=[c],l=function(){for(var t=0,e=u;t<e.length;t++)n.ondata(null,e[t],!1);u=[]},f=this.d;this.d=0;var h=this.u.length,d=oe(t,{f:e,u:s,o:o,t:function(){t.terminate&&t.terminate()},r:function(){if(l(),f){var t=n.u[h+1];t?t.r():n.d=1}f=1}}),v=0;t.ondata=function(e,i,r){if(e)n.ondata(e,i,r),n.terminate();else if(v+=i.length,u.push(i),r){var o=new dn(16);Se(o,0,134695760),Se(o,4,t.crc),Se(o,8,v),Se(o,12,t.size),u.push(o),d.c=v,d.b=a+v+16,d.crc=t.crc,d.size=t.size,f&&d.r(),f=1}else f&&l()},this.u.push(d)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata(Fn(4+8*(1&this.d),0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var t=0,n=0,e=0,i=0,r=this.u;i<r.length;i++)e+=46+(c=r[i]).f.length+pi(c.extra)+(c.o?c.o.length:0);for(var o=new dn(e+22),s=0,a=this.u;s<a.length;s++){var c;wi(o,t,c=a[s],c.f,c.u,-c.c-2,n,c.o),t+=46+c.f.length+pi(c.extra)+(c.o?c.o.length:0),n+=c.b}mi(o,t,this.u.length,e,n),this.ondata(null,o,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,n=this.u;t<n.length;t++)n[t].t();this.d=2},t}(),Ti=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}(),Si=function(){function t(){var t=this;this.i=new Pe(function(n,e){t.ondata(null,n,e)})}return t.prototype.push=function(t,n){try{this.i.push(t,n)}catch(t){this.ondata(t,null,n)}},t.compression=8,t}(),Ii=function(){function t(t,n){var e=this;n<32e4?this.i=new Pe(function(t,n){e.ondata(null,t,n)}):(this.i=new Re(function(t,n,i){e.ondata(t,n,i)}),this.terminate=this.i.terminate)}return t.prototype.push=function(t,n){this.i.terminate&&(t=jn(t,0)),this.i.push(t,n)},t.compression=8,t}(),xi=function(){function t(t){this.onfile=t,this.k=[],this.o={0:Ti},this.p=Wn}return t.prototype.push=function(t,n){var e=this;if(this.onfile||Fn(5),this.p||Fn(4),this.c>0){var i=Math.min(this.c,t.length),r=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),(t=t.subarray(i)).length)return this.push(t,n)}else{var o=0,s=0,a=void 0,c=void 0;this.p.length?t.length?((c=new dn(this.p.length+t.length)).set(this.p),c.set(t,this.p.length)):c=this.p:c=t;for(var u=c.length,l=this.c,f=l&&this.d,h=function(){var t,n=ke(c,s);if(67324752==n){o=1,a=s,d.d=null,d.c=0;var i=be(c,s+6),r=be(c,s+8),f=2048&i,h=8&i,v=be(c,s+26),p=be(c,s+28);if(u>s+30+v+p){var w=[];d.k.unshift(w),o=2;var m,y=ke(c,s+18),g=ke(c,s+22),b=li(c.subarray(s+30,s+=30+v),!f);4294967295==y?(t=h?[-2]:vi(c,s),y=t[0],g=t[1]):h&&(y=-1),s+=p,d.c=y;var k={name:b,compression:r,start:function(){if(k.ondata||Fn(5),y){var t=e.o[r];t||k.ondata(Fn(14,"unknown compression type "+r,1),null,!1),(m=y<0?new t(b):new t(b,y,g)).ondata=function(t,n,e){k.ondata(t,n,e)};for(var n=0,i=w;n<i.length;n++)m.push(i[n],!1);e.k[0]==w&&e.c?e.d=m:m.push(Wn,!0)}else k.ondata(null,Wn,!0)},terminate:function(){m&&m.terminate&&m.terminate()}};y>=0&&(k.size=y,k.originalSize=g),d.onfile(k)}return"break"}if(l){if(134695760==n)return a=s+=12+(-2==l&&8),o=3,d.c=0,"break";if(33639248==n)return a=s-=4,o=3,d.c=0,"break"}},d=this;s<u-4&&"break"!==h();++s);if(this.p=Wn,l<0){var v=c.subarray(0,o?a-12-(-2==l&&8)-(134695760==ke(c,a-16)&&4):s);f?f.push(v,!!o):this.k[+(2==o)].push(v)}if(2&o)return this.push(c.subarray(s),n);this.p=c.subarray(s)}n&&(this.c&&Fn(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),_i="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()},Mi=Object.freeze({__proto__:null,AsyncCompress:je,AsyncDecompress:ni,AsyncDeflate:Ce,AsyncGunzip:Ne,AsyncGzip:je,AsyncInflate:Re,AsyncUnzipInflate:Ii,AsyncUnzlib:Je,AsyncZipDeflate:bi,AsyncZlib:Ke,Compress:Be,DecodeUTF8:ai,Decompress:ti,Deflate:De,EncodeUTF8:ci,FlateErrorCode:{UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14},Gunzip:He,Gzip:Be,Inflate:Pe,Unzip:xi,UnzipInflate:Si,UnzipPassThrough:Ti,Unzlib:Ye,Zip:ki,ZipDeflate:gi,ZipPassThrough:yi,Zlib:Ge,compress:qe,compressSync:Fe,decompress:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),31==t[0]&&139==t[1]&&8==t[2]?Ze(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?$e(t,n,e):Qe(t,n,e)},decompressSync:function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?Xe(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Oe(t,n):We(t,n)},deflate:Ue,deflateSync:Le,gunzip:Ze,gunzipSync:Xe,gzip:qe,gzipSync:Fe,inflate:$e,inflateSync:Oe,strFromU8:li,strToU8:ui,unzip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&Fn(7);var i=[],r=function(){for(var t=0;t<i.length;++t)i[t]()},o={},s=function(t,n){_i(function(){e(t,n)})};_i(function(){s=e});for(var a=t.length-22;101010256!=ke(t,a);--a)if(!a||t.length-a>65558)return s(Fn(13,0,1),null),r;var c=be(t,a+8);if(c){var u=c,l=ke(t,a+16),f=4294967295==l||65535==u;if(f){var h=ke(t,a-12);(f=101075792==ke(t,h))&&(u=c=ke(t,h+32),l=ke(t,h+48))}for(var d=n&&n.filter,v=function(n){var e=di(t,l,f),a=e[0],u=e[1],h=e[2],v=e[3],p=e[4],w=hi(t,e[5]);l=p;var m=function(t,n){t?(r(),s(t,null)):(n&&(o[v]=n),--c||s(null,o))};if(!d||d({name:v,size:u,originalSize:h,compression:a}))if(a)if(8==a){var y=t.subarray(w,w+u);if(h<524288||u>.8*h)try{m(null,Oe(y,{out:new dn(h)}))}catch(t){m(t,null)}else i.push($e(y,{size:h},m))}else m(Fn(14,"unknown compression type "+a,1),null);else m(null,jn(t,w,w+u));else m(null,null)},p=0;p<u;++p)v()}else s(null,{});return r},unzipSync:function(t,n){for(var e={},i=t.length-22;101010256!=ke(t,i);--i)(!i||t.length-i>65558)&&Fn(13);var r=be(t,i+8);if(!r)return{};var o=ke(t,i+16),s=4294967295==o||65535==r;if(s){var a=ke(t,i-12);(s=101075792==ke(t,a))&&(r=ke(t,a+32),o=ke(t,a+48))}for(var c=n&&n.filter,u=0;u<r;++u){var l=di(t,o,s),f=l[0],h=l[1],d=l[2],v=l[3],p=l[4],w=hi(t,l[5]);o=p,c&&!c({name:v,size:h,originalSize:d,compression:f})||(f?8==f?e[v]=Oe(t.subarray(w,w+h),{out:new dn(d)}):Fn(14,"unknown compression type "+f):e[v]=jn(t,w,w+h))}return e},unzlib:Qe,unzlibSync:We,zip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&Fn(7);var i={};ei(t,"",i,n);var r=Object.keys(i),o=r.length,s=0,a=0,c=o,u=new Array(o),l=[],f=function(){for(var t=0;t<l.length;++t)l[t]()},h=function(t,n){_i(function(){e(t,n)})};_i(function(){h=e});var d=function(){var t=new dn(a+22),n=s,e=a-s;a=0;for(var i=0;i<c;++i){var r=u[i];try{var o=r.c.length;wi(t,a,r,r.f,r.u,o);var l=30+r.f.length+pi(r.extra),f=a+l;t.set(r.c,f),wi(t,s,r,r.f,r.u,o,a,r.m),s+=16+l+(r.m?r.m.length:0),a=f+o}catch(t){return h(t,null)}}mi(t,s,u.length,e,n),h(null,t)};o||d();for(var v=function(t){var n=r[t],e=i[n],c=e[0],v=e[1],p=ee(),w=c.length;p.p(c);var m=ui(n),y=m.length,g=v.comment,b=g&&ui(g),k=b&&b.length,T=pi(v.extra),S=0==v.level?0:8,I=function(e,i){if(e)f(),h(e,null);else{var r=i.length;u[t]=oe(v,{size:w,crc:p.d(),c:i,f:m,m:b,u:y!=n.length||b&&g.length!=k,compression:S}),s+=30+y+T+r,a+=76+2*(y+T)+(k||0)+r,--o||d()}};if(y>65535&&I(Fn(11,0,1),null),S)if(w<16e4)try{I(null,Le(c,v))}catch(t){I(t,null)}else l.push(Ue(c,v,I));else I(null,c)},p=0;p<c;++p)v(p);return f},zipSync:function(t,n){n||(n={});var e={},i=[];ei(t,"",e,n);var r=0,o=0;for(var s in e){var a=e[s],c=a[0],u=a[1],l=0==u.level?0:8,f=(S=ui(s)).length,h=u.comment,d=h&&ui(h),v=d&&d.length,p=pi(u.extra);f>65535&&Fn(11);var w=l?Le(c,u):c,m=w.length,y=ee();y.p(c),i.push(oe(u,{size:c.length,crc:y.d(),c:w,f:S,m:d,u:f!=s.length||d&&h.length!=v,o:r,compression:l})),r+=30+f+p+m,o+=76+2*(f+p)+(v||0)+m}for(var g=new dn(o+22),b=r,k=o-r,T=0;T<i.length;++T){var S;wi(g,(S=i[T]).o,S,S.f,S.u,S.c.length);var I=30+S.f.length+pi(S.extra);g.set(S.c,S.o+I),wi(g,r,S,S.f,S.u,S.c.length,S.o,S.m),r+=16+I+(S.m?S.m.length:0)}return mi(g,r,i.length,k,b),g},zlib:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&Fn(7),me(t,n,[le,de,function(){return[Ve]}],function(t){return pe(Ve(t.data[0],t.data[1]))},4,e)},zlibSync:Ve});t.createSession=async function(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,r=new AbortController;let o=null,s=!1,a=()=>{};i&&(o=f(()=>{s=!0,r.abort()},i));const c=n?.signal;if(c)if(c.aborted)r.abort();else{const t=()=>r.abort();c.addEventListener("abort",t,{once:!0}),a=()=>c.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:r.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{h(o),a()}},t.default=fn,Object.defineProperty(t,"Bt",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incodetech/tri-sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.1-rc.0",
4
4
  "type": "module",
5
5
  "main": "./dist/tri.cjs.js",
6
6
  "module": "./dist/tri.esm.js",