@incodetech/tri-sdk 0.4.1-rc.0 → 0.4.1
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 +1 -1
- package/dist/tri.esm.js +1 -1
- package/dist/tri.umd.js +1 -1
- package/package.json +1 -1
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 x(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function S(t,n){return!t||(t[n]?.enabled??!1)}function I(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"!==n&&!k(t)&&!T(t)}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",C="The endpoint parameter is not a valid URL";function P(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(C);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(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 S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??!1,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return!0;const n=t.target;return!!V(n)&&function(t){try{return t.matches(":-webkit-autofill")}catch{return!1}}(n)}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):I())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=!1,r=0,s=null,c=!1,u=!1;function l(){s&&(clearTimeout(s),s=null)}function d(){l(),c||u||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=!1,l(),function(e){const i=A("end"),o=i&&E(i,n),r=I();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:!0,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=!0,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=!0,l())}),m=a(t=>{0===t.button&&(c=!1,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(u=!0,l())}),y=a(t=>{"Shift"===t.key&&(u=!1,o&&h("keyboard"))}),v=a(()=>{c=!1}),b=a(()=>{"hidden"===document.visibilityState&&(c=!1,u=!1,o&&h("timeout"))}),g=a(()=>{c=!1,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",b),e(document,"dragend",g),()=>{l(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",b),i(document,"dragend",g)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),u=a(()=>d("traverse")),l=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",u),e(window,"hashchange",l)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",u),i(window,"hashchange",l)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,l=null,h=!1;function f(){l&&d(l),l=setTimeout(u(()=>{p(),l=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),l&&(d(l),l=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:!0})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return!1}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??!1,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return!0;return!1}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et="idle",it="ready",ot="collection-disabled",rt="init-failed",st={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ct(){const t={};for(const n of W)t[n]=lt(n,void 0,!0);return t}function at(t){const n={};for(const e of W)n[e]=lt(e,void 0,t[Q[e].layer]??!1);return n}function ut(t){const n={};for(const e of W){const i=t[e];n[e]=lt(e,i,i?.enabled??!1)}return n}function lt(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??!0};return{enabled:e,events:r}}function dt(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ht=function(t,n=30){if(!t)return!0;const e=dt(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function ft(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const pt="__tri",mt=`${pt}_activity_token`,wt=`${pt}_activity_id`,yt=`${pt}_activity_status`,vt="__tri_activity_lock";class bt{constructor(t){this.context=t,this.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 ft(vt,async()=>{if(this.l&&this.l!==t&&!ht(this.l)&&"ACTIVE"===this.p)return;const n=this.S();n&&n.token!==t&&!ht(n.token)&&"ACTIVE"===n.activityStatus?this._(n):(this.I(),await this.A())})}async k(){try{if(this.l&&!ht(this.l))return;await ft(vt,async()=>{await this.A()})}finally{this.m=null}}async A(){const t=this.S();if(t&&!ht(t.token)&&"ACTIVE"===t.activityStatus)return void this._(t);t&&this.I();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this._(e),this.M(e)}S(){const[t,n,e]=[q.get(mt),q.get(wt),q.get(yt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.I(),null)}M(t){q.set(mt,t.token),q.set(wt,t.activityId),q.set(yt,t.activityStatus)}I(){this.T(null),this._(null)}T(t){if(!t)return q.remove(mt),q.remove(wt),void q.remove(yt);q.set(mt,t.token),q.set(wt,t.activityId),q.set(yt,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 gt=[401,403,409],kt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function Tt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:kt[t.name]}const _t=new Array(256);for(let t=0;t<256;t++)_t[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return _t[t[0]]+_t[t[1]]+_t[t[2]]+_t[t[3]]+"-"+_t[t[4]]+_t[t[5]]+"-"+_t[t[6]]+_t[t[7]]+"-"+_t[t[8]]+_t[t[9]]+"-"+_t[t[10]]+_t[t[11]]+_t[t[12]]+_t[t[13]]+_t[t[14]]+_t[t[15]]}function It(){return crypto.randomUUID()}function Et(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function At(){for(let t=0;t<16;t++)xt[t]=256*Math.random()|0;return xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}const Mt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return It;if("function"==typeof crypto.getRandomValues)return Et}return At}();function Dt(){return Mt()}class Ct{constructor(t,n){this.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=Tt(t);for(let e=0;e<this.P.length;e++)if(Tt(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:Dt(),batchSequence:this.q++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.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 Pt="tri:bcast:";const zt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return!1;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return!1}}()?class{constructor(t){this.seq=0,this.closed=!1,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${Pt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>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=Dt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Pt}${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(){}},Lt="__tri_tabId";class Rt{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 zt("__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(Lt);if(t)return t;const n=Dt();return B.set(Lt,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 $t=globalThis.CompressionStream,Ut=globalThis.Response,Ot=globalThis.Blob,qt=new TextEncoder;let Bt=null;async function jt(t){const e=await async function(t){if("function"!=typeof $t)return null;try{const n=qt.encode(t),e=new Ot([n]).stream().pipeThrough(new $t("gzip"));return await new Ut(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===Bt){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);Bt=t,t.then(n=>{null===n&&l(()=>{Bt===t&&(Bt=null)},1e4)})}return Bt}();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 Ht(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Nt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Ft{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const Xt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Kt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Vt=255;function Yt(t,n,e,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:x(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 Jt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Kt.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return!1;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Zt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Qt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function Wt(t,n=!1){if(n)return null;const e=nn(t,"labelledby");if(e)return{text:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=en(t);if(i)return{text:on(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?tn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?tn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:on(c),resolutionMethod:"title",confidence:"low"};const a=nn(t,"describedby");if(a)return{text:on(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=tn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function tn(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Vt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=tn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return on(e)}function nn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=en(n)??tn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function en(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function rn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class sn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,o){const{collectors:r,sdk:s}=t;let c=null,u=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Nt)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,u=!1;a=l(()=>{u=!0,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:!0}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:!0,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:!0,body:t};try{return{ok:!0,body:JSON.stringify(t)}}catch{return{ok:!1}}}(r.body);if(!t.ok)return d(a),p(),{ok:!1,kind:"serialize"};f=t.body}try{const n=await Nt(s,{method:t,headers:Ht({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:!1,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:!1,kind:"client",status:m}:{ok:!1,kind:"server",status:m};if(204===n.status)return{ok:!0,data:void 0,status:204};try{return{ok:!0,data:await n.json(),status:n.status}}catch{return c.signal.aborted?u?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return u?{ok:!1,kind:"timeout"}:c.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!gt.includes(a.status)||!1===r?.refreshable)return c;var a;const u=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return u&&u!==s?t(u):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await jt(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:!1,kind:"serialize"}}return e.post("/events/capture",{body:u.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:!0,...o()}),{refreshable:!1})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>u?.getToken()??null,refresh:async()=>u?.refresh()??Promise.resolve(),getActivityId:()=>u?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};u=new bt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Ct(st,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new Rt({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 sn(6),r=new sn(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=rn(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=Yt(c,a,rn(c),i),{score:d,reasons:h}=Jt(c,u);if(o.push(l),!Gt(d))continue;const f=Wt(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=Yt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:o}=Jt(t,0);return{interactive:Gt(i),...o.length>0?{reasons:o}:{},disabled:Qt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Zt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let l=null;return i||(l=u.interactive?Wt(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 Ft({getActivityId:()=>u?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:u,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let an=class t{constructor(){this._t=0,this.xt=null,this.St=et}static get instance(){return t.o||(t.o=new t),t.o}async setup(t){if(this.St!==et)return n.fatal("error","setup()",`cannot set up from state '${this.St}' — call reset() (or reload) first. Ignoring.`),rt;try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??!1};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:ct()}:void 0!==t.collectors?{sdk:o,collectors:ut(t.collectors)}:{sdk:o,collectors:at(t.layers)}}(t);if(!e)return this.St=rt,rt;n.DEBUG=e.sdk.DEBUG;const i=await cn(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.St=ot,ot):"init-failed"===i.status?(this.St=rt,rt):(this.xt=i.managers,this.St=it,it)}catch(t){return n.warn("setup()","failed:",t),this.St=rt,rt}}async start(){if(this.St===et)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.St;if(this.St!==it)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.St;this.St="starting";const t=++this._t;return await this.k(t),this.St}async stop(){n.warn("stop()","called");const t=this.xt;return t?(++this._t,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.St=it,this.It(t)):Promise.resolve(this.St)}async reset(){const t=this.stop();return this.St=et,this.xt=null,t.then(()=>this.St)}async It(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.St}async k(t){const e=this.xt;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.St=it))}t===this._t&&(this.St="started")}}};an.o=null;const un=an.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=un;
|
|
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 x(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function S(t,n){return!t||(t[n]?.enabled??!1)}function I(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"!==n&&!k(t)&&!T(t)}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",C="The endpoint parameter is not a valid URL";function P(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(C);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(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 S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??!1,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return!0;const n=t.target;return!!V(n)&&function(t){try{return t.matches(":-webkit-autofill")}catch{return!1}}(n)}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):I())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=!1,r=0,s=null,c=!1,u=!1;function l(){s&&(clearTimeout(s),s=null)}function d(){l(),c||u||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=!1,l(),function(e){const i=A("end"),o=i&&E(i,n),r=I();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:!0,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=!0,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=!0,l())}),m=a(t=>{0===t.button&&(c=!1,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(u=!0,l())}),y=a(t=>{"Shift"===t.key&&(u=!1,o&&h("keyboard"))}),v=a(()=>{c=!1}),b=a(()=>{"hidden"===document.visibilityState&&(c=!1,u=!1,o&&h("timeout"))}),g=a(()=>{c=!1,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",b),e(document,"dragend",g),()=>{l(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",b),i(document,"dragend",g)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),u=a(()=>d("traverse")),l=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",u),e(window,"hashchange",l)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",u),i(window,"hashchange",l)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,l=null,h=!1;function f(){l&&d(l),l=setTimeout(u(()=>{p(),l=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),l&&(d(l),l=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:!0})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return!1}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??!1,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return!0;return!1}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et="idle",it="ready",ot="collection-disabled",rt="init-failed",st={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ct(){const t={};for(const n of W)t[n]=lt(n,void 0,!0);return t}function at(t){const n={};for(const e of W)n[e]=lt(e,void 0,t[Q[e].layer]??!1);return n}function ut(t){const n={};for(const e of W){const i=t[e];n[e]=lt(e,i,i?.enabled??!1)}return n}function lt(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??!0};return{enabled:e,events:r}}function dt(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ht=function(t,n=30){if(!t)return!0;const e=dt(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function ft(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const pt="__tri",mt=`${pt}_activity_token`,wt=`${pt}_activity_id`,yt=`${pt}_activity_status`,vt="__tri_activity_lock";class bt{constructor(t){this.context=t,this.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 ft(vt,async()=>{if(this.l&&this.l!==t&&!ht(this.l)&&"ACTIVE"===this.p)return;const n=this.S();n&&n.token!==t&&!ht(n.token)&&"ACTIVE"===n.activityStatus?this._(n):(this.I(),await this.A())})}async k(){try{if(this.l&&!ht(this.l))return;await ft(vt,async()=>{await this.A()})}finally{this.m=null}}async A(){const t=this.S();if(t&&!ht(t.token)&&"ACTIVE"===t.activityStatus)return void this._(t);t&&this.I();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this._(e),this.M(e)}S(){const[t,n,e]=[q.get(mt),q.get(wt),q.get(yt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.I(),null)}M(t){q.set(mt,t.token),q.set(wt,t.activityId),q.set(yt,t.activityStatus)}I(){this.T(null),this._(null)}T(t){if(!t)return q.remove(mt),q.remove(wt),void q.remove(yt);q.set(mt,t.token),q.set(wt,t.activityId),q.set(yt,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 gt=[401,403,409],kt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function Tt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:kt[t.name]}const _t=new Array(256);for(let t=0;t<256;t++)_t[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return _t[t[0]]+_t[t[1]]+_t[t[2]]+_t[t[3]]+"-"+_t[t[4]]+_t[t[5]]+"-"+_t[t[6]]+_t[t[7]]+"-"+_t[t[8]]+_t[t[9]]+"-"+_t[t[10]]+_t[t[11]]+_t[t[12]]+_t[t[13]]+_t[t[14]]+_t[t[15]]}function It(){return crypto.randomUUID()}function Et(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function At(){for(let t=0;t<16;t++)xt[t]=256*Math.random()|0;return xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}const Mt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return It;if("function"==typeof crypto.getRandomValues)return Et}return At}();function Dt(){return Mt()}class Ct{constructor(t,n){this.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=Tt(t);for(let e=0;e<this.P.length;e++)if(Tt(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:Dt(),batchSequence:this.q++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.1",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 Pt="tri:bcast:";const zt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return!1;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return!1}}()?class{constructor(t){this.seq=0,this.closed=!1,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${Pt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>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=Dt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Pt}${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(){}},Lt="__tri_tabId";class Rt{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 zt("__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(Lt);if(t)return t;const n=Dt();return B.set(Lt,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 $t=globalThis.CompressionStream,Ut=globalThis.Response,Ot=globalThis.Blob,qt=new TextEncoder;let Bt=null;async function jt(t){const e=await async function(t){if("function"!=typeof $t)return null;try{const n=qt.encode(t),e=new Ot([n]).stream().pipeThrough(new $t("gzip"));return await new Ut(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===Bt){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);Bt=t,t.then(n=>{null===n&&l(()=>{Bt===t&&(Bt=null)},1e4)})}return Bt}();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 Ht(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Nt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Ft{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const Xt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Kt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Vt=255;function Yt(t,n,e,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:x(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 Jt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Kt.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return!1;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Zt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Qt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function Wt(t,n=!1){if(n)return null;const e=nn(t,"labelledby");if(e)return{text:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=en(t);if(i)return{text:on(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?tn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?tn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:on(c),resolutionMethod:"title",confidence:"low"};const a=nn(t,"describedby");if(a)return{text:on(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=tn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function tn(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Vt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=tn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return on(e)}function nn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=en(n)??tn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function en(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function rn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class sn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,o){const{collectors:r,sdk:s}=t;let c=null,u=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Nt)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,u=!1;a=l(()=>{u=!0,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:!0}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:!0,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:!0,body:t};try{return{ok:!0,body:JSON.stringify(t)}}catch{return{ok:!1}}}(r.body);if(!t.ok)return d(a),p(),{ok:!1,kind:"serialize"};f=t.body}try{const n=await Nt(s,{method:t,headers:Ht({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:!1,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:!1,kind:"client",status:m}:{ok:!1,kind:"server",status:m};if(204===n.status)return{ok:!0,data:void 0,status:204};try{return{ok:!0,data:await n.json(),status:n.status}}catch{return c.signal.aborted?u?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return u?{ok:!1,kind:"timeout"}:c.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!gt.includes(a.status)||!1===r?.refreshable)return c;var a;const u=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return u&&u!==s?t(u):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await jt(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:!1,kind:"serialize"}}return e.post("/events/capture",{body:u.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:!0,...o()}),{refreshable:!1})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>u?.getToken()??null,refresh:async()=>u?.refresh()??Promise.resolve(),getActivityId:()=>u?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};u=new bt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Ct(st,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new Rt({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 sn(6),r=new sn(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=rn(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=Yt(c,a,rn(c),i),{score:d,reasons:h}=Jt(c,u);if(o.push(l),!Gt(d))continue;const f=Wt(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=Yt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:o}=Jt(t,0);return{interactive:Gt(i),...o.length>0?{reasons:o}:{},disabled:Qt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Zt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let l=null;return i||(l=u.interactive?Wt(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 Ft({getActivityId:()=>u?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:u,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let an=class t{constructor(){this._t=0,this.xt=null,this.St=et}static get instance(){return t.o||(t.o=new t),t.o}async setup(t){if(this.St!==et)return n.fatal("error","setup()",`cannot set up from state '${this.St}' — call reset() (or reload) first. Ignoring.`),rt;try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??!1};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:ct()}:void 0!==t.collectors?{sdk:o,collectors:ut(t.collectors)}:{sdk:o,collectors:at(t.layers)}}(t);if(!e)return this.St=rt,rt;n.DEBUG=e.sdk.DEBUG;const i=await cn(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.St=ot,ot):"init-failed"===i.status?(this.St=rt,rt):(this.xt=i.managers,this.St=it,it)}catch(t){return n.warn("setup()","failed:",t),this.St=rt,rt}}async start(){if(this.St===et)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.St;if(this.St!==it)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.St;this.St="starting";const t=++this._t;return await this.k(t),this.St}async stop(){n.warn("stop()","called");const t=this.xt;return t?(++this._t,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.St=it,this.It(t)):Promise.resolve(this.St)}async reset(){const t=this.stop();return this.St=et,this.xt=null,t.then(()=>this.St)}async It(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.St}async k(t){const e=this.xt;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.St=it))}t===this._t&&(this.St="started")}}};an.o=null;const un=an.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=un;
|
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 u(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function l(t,n){return o(u(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:u,encodedBodySize:l,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function b(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function g(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return!!t&&t.hasAttribute("data-tri-ignore")}function T(t){return!!t&&t.hasAttribute("data-tri-redact")}function _(t,n){return n?.includes(t.toLowerCase())??!1}function x(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function S(t,n){return!t||(t[n]?.enabled??!1)}function I(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"!==n&&!k(t)&&!T(t)}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",C="The endpoint parameter is not a valid URL";function P(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(C);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(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(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};O.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=!1;return c(async()=>{const e=await async function(t){const n=function(){const t=O.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(O.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=!0}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??!1,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return!0;const n=t.target;return!!V(n)&&function(t){try{return t.matches(":-webkit-autofill")}catch{return!1}}(n)}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):I())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=!1,r=0,s=null,c=!1,u=!1;function l(){s&&(clearTimeout(s),s=null)}function d(){l(),c||u||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=!1,l(),function(e){const i=A("end"),o=i&&E(i,n),r=I();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:!0,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=!0,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=!0,l())}),m=a(t=>{0===t.button&&(c=!1,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(u=!0,l())}),y=a(t=>{"Shift"===t.key&&(u=!1,o&&h("keyboard"))}),v=a(()=>{c=!1}),b=a(()=>{"hidden"===document.visibilityState&&(c=!1,u=!1,o&&h("timeout"))}),g=a(()=>{c=!1,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",b),e(document,"dragend",g),()=>{l(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",b),i(document,"dragend",g)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),u=a(()=>d("traverse")),l=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",u),e(window,"hashchange",l)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",u),i(window,"hashchange",l)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,l=null,h=!1;function f(){l&&d(l),l=setTimeout(u(()=>{p(),l=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),l&&(d(l),l=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:!0})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return!1}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??!1,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return!0;return!1}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et="idle",it="ready",ot="collection-disabled",rt="init-failed",st={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ct(){const t={};for(const n of W)t[n]=lt(n,void 0,!0);return t}function at(t){const n={};for(const e of W)n[e]=lt(e,void 0,t[Q[e].layer]??!1);return n}function ut(t){const n={};for(const e of W){const i=t[e];n[e]=lt(e,i,i?.enabled??!1)}return n}function lt(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??!0};return{enabled:e,events:r}}function dt(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ht=function(t,n=30){if(!t)return!0;const e=dt(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function ft(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const pt="__tri",mt=`${pt}_activity_token`,wt=`${pt}_activity_id`,yt=`${pt}_activity_status`,vt="__tri_activity_lock";class bt{constructor(t){this.context=t,this.u=null,this.l=null,this.h=null,this.p=null,this.m=!1}getToken(){return this.u}getActivityId(){return this.l??""}isActive(){return"ACTIVE"===this.h&&null!==this.u}async start(){return this.m=!0,this.p||(this.p=this.v()),this.p}async stop(){this.m=!1,this.k(null),this.p=null,this.u&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.u;await ft(vt,async()=>{if(this.u&&this.u!==t&&!ht(this.u)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!ht(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.S(),await this.I())})}async v(){try{if(this.u&&!ht(this.u))return;await ft(vt,async()=>{await this.I()})}finally{this.p=null}}async I(){const t=this._();if(t&&!ht(t.token)&&"ACTIVE"===t.activityStatus)return void this.T(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.T(e),this.A(e)}_(){const[t,n,e]=[O.get(mt),O.get(wt),O.get(yt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}A(t){O.set(mt,t.token),O.set(wt,t.activityId),O.set(yt,t.activityStatus)}S(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(mt),O.remove(wt),void O.remove(yt);O.set(mt,t.token),O.set(wt,t.activityId),O.set(yt,t.activityStatus)}T(t){if(!t)return this.u=null,this.l=null,void(this.h=null);this.u=t.token,this.l=t.activityId,this.h=t.activityStatus}}const gt=[401,403,409],kt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function Tt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:kt[t.name]}const _t=new Array(256);for(let t=0;t<256;t++)_t[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return _t[t[0]]+_t[t[1]]+_t[t[2]]+_t[t[3]]+"-"+_t[t[4]]+_t[t[5]]+"-"+_t[t[6]]+_t[t[7]]+"-"+_t[t[8]]+_t[t[9]]+"-"+_t[t[10]]+_t[t[11]]+_t[t[12]]+_t[t[13]]+_t[t[14]]+_t[t[15]]}function It(){return crypto.randomUUID()}function Et(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function At(){for(let t=0;t<16;t++)xt[t]=256*Math.random()|0;return xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}const Mt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return It;if("function"==typeof crypto.getRandomValues)return Et}return At}();function Dt(){return Mt()}class Ct{constructor(t,n){this.M=t,this.D=n,this.C=[],this.P=null,this.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=l(()=>{this.P=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.R&&(this.R=l(()=>{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=Tt(t);for(let e=0;e<this.C.length;e++)if(Tt(this.C[e])<n){for(let t=e;t<this.C.length-1;t++)this.C[t]=this.C[t+1];return this.C.length-=1,void this.C.push(t)}}F(t){const n="lifecycle"===t?this.C.splice(-this.M.flush.size):this.C.splice(0,this.M.flush.size);return{activityId:"",batchId:Dt(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.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 Pt="tri:bcast:";const zt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return!1;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return!1}}()?class{constructor(t){this.seq=0,this.closed=!1,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${Pt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>O.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=Dt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Pt}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{O.set(n,t),O.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=!0,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Lt="__tri_tabId";class Rt{constructor(t){this.context=t,this.tt="",this.m=!1,this.nt=null,this.et=null,this.it=null,this.ot=new Map,this.rt=-1,this.st=null}async start(){this.m||(this.m=!0,this.tt=this.ct(),this.ut(),this.lt({type:"hello",tabId:this.tt,ts:Date.now()}),this.dt(),this.ht("active"),this.ft())}stop(){this.m&&(this.m=!1,this.ht("inactive"),this.lt({type:"bye",tabId:this.tt,ts:Date.now()}),this.wt(this.yt()),this.vt(),this.bt(),this.gt())}getTabId(){return this.tt}queryTabsNumber(){return this.ot.size+1}ut(){try{this.nt=new zt("__tri_tab_channel"),this.st=this.kt.bind(this),this.nt.addEventListener("message",this.st)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}gt(){try{if(!this.nt)return;this.st&&this.nt.removeEventListener("message",this.st),this.nt.close()}catch{}finally{this.nt=null,this.st=null}}dt(){this.et=setInterval(()=>{const t=Date.now();this.lt({type:"heartbeat",tabId:this.tt,ts:t})},1e3)}vt(){null!=this.et&&(clearInterval(this.et),this.et=null)}ft(){null!=this.it&&clearTimeout(this.it),this.it=setTimeout(()=>{this.it=null;const t=this.yt()+1;t!==this.rt&&(this.rt=t,this.wt(t))},1e3)}bt(){null!=this.it&&(clearTimeout(this.it),this.it=null)}lt(t){try{if(!this.nt)return;this.nt.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}kt(t){const{type:n,tabId:e}=t.data;if(e===this.tt)return;const i=Date.now();"hello"===n?(this.lt({type:"ack",tabId:this.tt,ts:i,to:e}),this.ot.set(e,i)):"heartbeat"===n||"ack"===n?this.ot.set(e,i):"bye"===n&&this.ot.delete(e)}wt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.tt,timestamp:Date.now(),value:t})}ht(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.tt,timestamp:Date.now(),value:t})}ct(){const t=q.get(Lt);if(t)return t;const n=Dt();return q.set(Lt,n),n}yt(t=Date.now()){let n=0;for(const[e,i]of this.ot.entries())t-i>=3e3?this.ot.delete(e):n++;return n}}const $t=globalThis.CompressionStream,Ut=globalThis.Response,Bt=globalThis.Blob,Ot=new TextEncoder;let qt=null;async function jt(t){const e=await async function(t){if("function"!=typeof $t)return null;try{const n=Ot.encode(t),e=new Bt([n]).stream().pipeThrough(new $t("gzip"));return await new Ut(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===qt){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=l(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>import("./chunks/browser-DlFgHpoC.js"),1e4);qt=t,t.then(n=>{null===n&&l(()=>{qt===t&&(qt=null)},1e4)})}return qt}();if(null===e)return null;const{gzipSync:i}=e,o=i(Ot.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Ht(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Nt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Ft{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const Xt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Kt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Vt=255;function Yt(t,n,e,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:x(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 Jt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Kt.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return!1;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Zt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Qt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function Wt(t,n=!1){if(n)return null;const e=nn(t,"labelledby");if(e)return{text:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=en(t);if(i)return{text:on(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?tn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?tn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:on(c),resolutionMethod:"title",confidence:"low"};const a=nn(t,"describedby");if(a)return{text:on(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=tn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function tn(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Vt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=tn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return on(e)}function nn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=en(n)??tn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function en(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function rn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class sn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,o){const{collectors:r,sdk:s}=t;let c=null,u=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Nt)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,u=!1;a=l(()=>{u=!0,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:!0}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:!0,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:!0,body:t};try{return{ok:!0,body:JSON.stringify(t)}}catch{return{ok:!1}}}(r.body);if(!t.ok)return d(a),p(),{ok:!1,kind:"serialize"};f=t.body}try{const n=await Nt(s,{method:t,headers:Ht({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:!1,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:!1,kind:"client",status:m}:{ok:!1,kind:"server",status:m};if(204===n.status)return{ok:!0,data:void 0,status:204};try{return{ok:!0,data:await n.json(),status:n.status}}catch{return c.signal.aborted?u?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return u?{ok:!1,kind:"timeout"}:c.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!gt.includes(a.status)||!1===r?.refreshable)return c;var a;const u=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return u&&u!==s?t(u):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await jt(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:!1,kind:"serialize"}}return e.post("/events/capture",{body:u.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:!0,...o()}),{refreshable:!1})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>u?.getToken()??null,refresh:async()=>u?.refresh()??Promise.resolve(),getActivityId:()=>u?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};u=new bt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Ct(st,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new Rt({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 sn(6),r=new sn(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=rn(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=Yt(c,a,rn(c),i),{score:d,reasons:h}=Jt(c,u);if(o.push(l),!Gt(d))continue;const f=Wt(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=Yt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:o}=Jt(t,0);return{interactive:Gt(i),...o.length>0?{reasons:o}:{},disabled:Qt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Zt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let l=null;return i||(l=u.interactive?Wt(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 Ft({getActivityId:()=>u?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:u,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let an=class t{constructor(){this.Tt=0,this._t=null,this.xt=et}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if(this.xt!==et)return n.fatal("error","setup()",`cannot set up from state '${this.xt}' — call reset() (or reload) first. Ignoring.`),rt;try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??!1};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:ct()}:void 0!==t.collectors?{sdk:o,collectors:ut(t.collectors)}:{sdk:o,collectors:at(t.layers)}}(t);if(!e)return this.xt=rt,rt;n.DEBUG=e.sdk.DEBUG;const i=await cn(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.xt=ot,ot):"init-failed"===i.status?(this.xt=rt,rt):(this._t=i.managers,this.xt=it,it)}catch(t){return n.warn("setup()","failed:",t),this.xt=rt,rt}}async start(){if(this.xt===et)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.xt;if(this.xt!==it)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.xt;this.xt="starting";const t=++this.Tt;return await this.v(t),this.xt}async stop(){n.warn("stop()","called");const t=this._t;return t?(++this.Tt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.xt=it,this.St(t)):Promise.resolve(this.xt)}async reset(){const t=this.stop();return this.xt=et,this._t=null,t.then(()=>this.xt)}async St(t){return await function(t){let n=null;const e=new Promise(t=>{n=l(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.xt}async v(t){const e=this._t;if(e){try{if(await e.activityManager.start(),t!==this.Tt)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this.Tt)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this.Tt&&(this.xt=it))}t===this.Tt&&(this.xt="started")}}};async function un(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=!1,c=()=>{};i&&(r=l(()=>{s=!0,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:!0}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,expiresAt:null,tokenType:null,eventsCollectionEnabled:!1,error:{status:n.status,message:t}}}const i=await n.json();return{token:i.token,expiresAt:i.expiresAt,tokenType:i.tokenType,eventsCollectionEnabled:!0,error:null}}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}}an.i=null;const ln=an.instance;export{un as createSession,ln as default};
|
|
1
|
+
class t{constructor(){this.t=!1}static get instance(){return t.i||(t.i=new t),t.i}get DEBUG(){return this.t}set DEBUG(t){this.t=t}warn(t,n,...e){this.t&&this.o("warn",t,n,...e)}error(t,n,...e){this.t&&this.o("error",t,n,...e)}info(t,n,...e){this.t&&this.o("info",t,n,...e)}fatal(t,n,e,...i){this.o(t,n,e,...i)}o(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:!0,passive:!0})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:!0})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function u(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function l(t,n){return o(u(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),u=i?t.transferSize:null,l=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:u,encodedBodySize:l,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function b(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function g(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return!!t&&t.hasAttribute("data-tri-ignore")}function T(t){return!!t&&t.hasAttribute("data-tri-redact")}function _(t,n){return n?.includes(t.toLowerCase())??!1}function x(t){try{return new URL(t).origin!==window.location.origin}catch{return!1}}function S(t,n){return!t||(t[n]?.enabled??!1)}function I(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"!==n&&!k(t)&&!T(t)}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",C="The endpoint parameter is not a valid URL";function P(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),!1}catch(t){if(t instanceof Error&&"TypeError"===t.name)return!0;throw t}}(t))throw new Error(C);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(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(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};O.set(j,i)}(e.visitorId,e.requestId,i),{visitorId:e.visitorId,requestId:e.requestId}}catch{return null}}const X={apiKey:"5uYRiI0XM6p8k4124ELX",endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"},K={focusin:"in",focusout:"out"};function V(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement}const Y=new Set(["Shift","Control","Alt","Meta","Backspace","Delete","Enter","Tab","CapsLock","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),J={mouse:"mouse",touch:"touch",pen:"pen"},G={pointerdown:"down",pointerup:"up",click:"click",dblclick:"dblclick",contextmenu:"contextmenu"};function Z(t,n,e,i,o){return{name:"navigation",timestamp:Date.now(),phase:t,type:n,from:e.from,to:e.to,timeOrigin:i,timing:o}}const Q={fingerprint:{create:function(t){let n=!1;return c(async()=>{const e=await async function(t){const n=function(){const t=O.get(j);return t?"string"!=typeof t.visitorId||"number"!=typeof t.expiresAt||t.expiresAt<=Date.now()?(O.remove(j),null):{visitorId:t.visitorId,requestId:"string"==typeof t.requestId?t.requestId:""}:null}();return n?{visitorId:n.visitorId,requestId:n.requestId||null}:N||(N=F(t).finally(()=>{N=null}),N)}(X);!n&&e&&t.push({name:"fingerprint",deviceId:e.visitorId,requestId:e.requestId,timestamp:Date.now()})}),()=>{n=!0}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return S(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),S(o,"click")&&e(document,"click",r),S(o,"dblclick")&&e(document,"dblclick",r),S(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??!1,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return!0;const n=t.target;return!!V(n)&&function(t){try{return t.matches(":-webkit-autofill")}catch{return!1}}(n)}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):I())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return S(o,"paste")&&e(document,"paste",r),S(o,"cut")&&e(document,"cut",r),S(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return S(o,"submit")&&e(document,"submit",r),S(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=!1,r=0,s=null,c=!1,u=!1;function l(){s&&(clearTimeout(s),s=null)}function d(){l(),c||u||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=!1,l(),function(e){const i=A("end"),o=i&&E(i,n),r=I();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:!0,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=!0,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=!0,l())}),m=a(t=>{0===t.button&&(c=!1,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(u=!0,l())}),y=a(t=>{"Shift"===t.key&&(u=!1,o&&h("keyboard"))}),v=a(()=>{c=!1}),b=a(()=>{"hidden"===document.visibilityState&&(c=!1,u=!1,o&&h("timeout"))}),g=a(()=>{c=!1,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",b),e(document,"dragend",g),()=>{l(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",b),i(document,"dragend",g)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),u=a(()=>d("traverse")),l=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",u),e(window,"hashchange",l)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",u),i(window,"hashchange",l)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return S(o,"orientationchange")&&e(window,"orientationchange",r),S(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,l=null,h=!1;function f(){l&&d(l),l=setTimeout(u(()=>{p(),l=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return S(o,"motion")&&e(window,"devicemotion",m),S(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=!0,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),S(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),l&&(d(l),l=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:!0})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return!1}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??!1,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return!0;return!1}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et="idle",it="ready",ot="collection-disabled",rt="init-failed",st={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ct(){const t={};for(const n of W)t[n]=lt(n,void 0,!0);return t}function at(t){const n={};for(const e of W)n[e]=lt(e,void 0,t[Q[e].layer]??!1);return n}function ut(t){const n={};for(const e of W){const i=t[e];n[e]=lt(e,i,i?.enabled??!1)}return n}function lt(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??!0};return{enabled:e,events:r}}function dt(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const ht=function(t,n=30){if(!t)return!0;const e=dt(t);return!e||"number"!=typeof e.exp||1e3*e.exp<=Date.now()+1e3*n};async function ft(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const pt="__tri",mt=`${pt}_activity_token`,wt=`${pt}_activity_id`,yt=`${pt}_activity_status`,vt="__tri_activity_lock";class bt{constructor(t){this.context=t,this.u=null,this.l=null,this.h=null,this.p=null,this.m=!1}getToken(){return this.u}getActivityId(){return this.l??""}isActive(){return"ACTIVE"===this.h&&null!==this.u}async start(){return this.m=!0,this.p||(this.p=this.v()),this.p}async stop(){this.m=!1,this.k(null),this.p=null,this.u&&await this.context.stopActivity(),this.T(null)}async refresh(){if(!this.m)return;const t=this.u;await ft(vt,async()=>{if(this.u&&this.u!==t&&!ht(this.u)&&"ACTIVE"===this.h)return;const n=this._();n&&n.token!==t&&!ht(n.token)&&"ACTIVE"===n.activityStatus?this.T(n):(this.S(),await this.I())})}async v(){try{if(this.u&&!ht(this.u))return;await ft(vt,async()=>{await this.I()})}finally{this.p=null}}async I(){const t=this._();if(t&&!ht(t.token)&&"ACTIVE"===t.activityStatus)return void this.T(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this.T(e),this.A(e)}_(){const[t,n,e]=[O.get(mt),O.get(wt),O.get(yt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}A(t){O.set(mt,t.token),O.set(wt,t.activityId),O.set(yt,t.activityStatus)}S(){this.k(null),this.T(null)}k(t){if(!t)return O.remove(mt),O.remove(wt),void O.remove(yt);O.set(mt,t.token),O.set(wt,t.activityId),O.set(yt,t.activityStatus)}T(t){if(!t)return this.u=null,this.l=null,void(this.h=null);this.u=t.token,this.l=t.activityId,this.h=t.activityStatus}}const gt=[401,403,409],kt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function Tt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:kt[t.name]}const _t=new Array(256);for(let t=0;t<256;t++)_t[t]=(t+256).toString(16).slice(1);const xt=new Uint8Array(16);function St(t){return _t[t[0]]+_t[t[1]]+_t[t[2]]+_t[t[3]]+"-"+_t[t[4]]+_t[t[5]]+"-"+_t[t[6]]+_t[t[7]]+"-"+_t[t[8]]+_t[t[9]]+"-"+_t[t[10]]+_t[t[11]]+_t[t[12]]+_t[t[13]]+_t[t[14]]+_t[t[15]]}function It(){return crypto.randomUUID()}function Et(){return crypto.getRandomValues(xt),xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}function At(){for(let t=0;t<16;t++)xt[t]=256*Math.random()|0;return xt[6]=15&xt[6]|64,xt[8]=63&xt[8]|128,St(xt)}const Mt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return It;if("function"==typeof crypto.getRandomValues)return Et}return At}();function Dt(){return Mt()}class Ct{constructor(t,n){this.M=t,this.D=n,this.C=[],this.P=null,this.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=l(()=>{this.P=null,this.flush("interval")},this.O))}K(){this.m&&this.$&&null===this.R&&(this.R=l(()=>{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=Tt(t);for(let e=0;e<this.C.length;e++)if(Tt(this.C[e])<n){for(let t=e;t<this.C.length-1;t++)this.C[t]=this.C[t+1];return this.C.length-=1,void this.C.push(t)}}F(t){const n="lifecycle"===t?this.C.splice(-this.M.flush.size):this.C.splice(0,this.M.flush.size);return{activityId:"",batchId:Dt(),batchSequence:this.B++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.1",sdkPlatform:"web",tabId:this.D.getTabId(),events:n}}Z(t){if(t.ok)return!1;switch(t.kind){case"timeout":case"server":case"rate_limited":return!0;default:return!1}}}const Pt="tri:bcast:";const zt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return!1;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return!1}}()?class{constructor(t){this.seq=0,this.closed=!1,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${Pt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>O.remove(t.key));try{n=JSON.parse(t.newValue)}catch{return}const e={data:n};for(const t of this.listeners)s(()=>t(e))},this.channelName=t,this.senderId=Dt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Pt}${this.channelName}:${this.senderId}:${this.seq++}`;s(()=>{O.set(n,t),O.remove(n)})}addEventListener(t,n){this.listeners.add(n)}removeEventListener(t,n){this.listeners.delete(n)}close(){this.closed||(this.closed=!0,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Lt="__tri_tabId";class Rt{constructor(t){this.context=t,this.tt="",this.m=!1,this.nt=null,this.et=null,this.it=null,this.ot=new Map,this.rt=-1,this.st=null}async start(){this.m||(this.m=!0,this.tt=this.ct(),this.ut(),this.lt({type:"hello",tabId:this.tt,ts:Date.now()}),this.dt(),this.ht("active"),this.ft())}stop(){this.m&&(this.m=!1,this.ht("inactive"),this.lt({type:"bye",tabId:this.tt,ts:Date.now()}),this.wt(this.yt()),this.vt(),this.bt(),this.gt())}getTabId(){return this.tt}queryTabsNumber(){return this.ot.size+1}ut(){try{this.nt=new zt("__tri_tab_channel"),this.st=this.kt.bind(this),this.nt.addEventListener("message",this.st)}catch(t){n.warn("TabManager","failed to open broadcast channel:",t)}}gt(){try{if(!this.nt)return;this.st&&this.nt.removeEventListener("message",this.st),this.nt.close()}catch{}finally{this.nt=null,this.st=null}}dt(){this.et=setInterval(()=>{const t=Date.now();this.lt({type:"heartbeat",tabId:this.tt,ts:t})},1e3)}vt(){null!=this.et&&(clearInterval(this.et),this.et=null)}ft(){null!=this.it&&clearTimeout(this.it),this.it=setTimeout(()=>{this.it=null;const t=this.yt()+1;t!==this.rt&&(this.rt=t,this.wt(t))},1e3)}bt(){null!=this.it&&(clearTimeout(this.it),this.it=null)}lt(t){try{if(!this.nt)return;this.nt.postMessage(t)}catch{n.warn("TabManager","failed to broadcast message:",t)}}kt(t){const{type:n,tabId:e}=t.data;if(e===this.tt)return;const i=Date.now();"hello"===n?(this.lt({type:"ack",tabId:this.tt,ts:i,to:e}),this.ot.set(e,i)):"heartbeat"===n||"ack"===n?this.ot.set(e,i):"bye"===n&&this.ot.delete(e)}wt(t){this.context.events.count&&this.context.push({name:"tab",type:"count",tabId:this.tt,timestamp:Date.now(),value:t})}ht(t){this.context.events.state&&this.context.push({name:"tab",type:"state",tabId:this.tt,timestamp:Date.now(),value:t})}ct(){const t=q.get(Lt);if(t)return t;const n=Dt();return q.set(Lt,n),n}yt(t=Date.now()){let n=0;for(const[e,i]of this.ot.entries())t-i>=3e3?this.ot.delete(e):n++;return n}}const $t=globalThis.CompressionStream,Ut=globalThis.Response,Bt=globalThis.Blob,Ot=new TextEncoder;let qt=null;async function jt(t){const e=await async function(t){if("function"!=typeof $t)return null;try{const n=Ot.encode(t),e=new Bt([n]).stream().pipeThrough(new $t("gzip"));return await new Ut(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===qt){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=l(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>import("./chunks/browser-DlFgHpoC.js"),1e4);qt=t,t.then(n=>{null===n&&l(()=>{qt===t&&(qt=null)},1e4)})}return qt}();if(null===e)return null;const{gzipSync:i}=e,o=i(Ot.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Ht(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Nt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Ft{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const Xt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Kt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Vt=255;function Yt(t,n,e,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:x(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 Jt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Kt.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return!1;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Zt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Qt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function Wt(t,n=!1){if(n)return null;const e=nn(t,"labelledby");if(e)return{text:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=en(t);if(i)return{text:on(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?tn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?tn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:on(c),resolutionMethod:"title",confidence:"low"};const a=nn(t,"describedby");if(a)return{text:on(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=tn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function tn(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Vt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=tn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return on(e)}function nn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=en(n)??tn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function en(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function rn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class sn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,o){const{collectors:r,sdk:s}=t;let c=null,u=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Nt)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,u=!1;a=l(()=>{u=!0,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:!0}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:!0,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:!0,body:t};try{return{ok:!0,body:JSON.stringify(t)}}catch{return{ok:!1}}}(r.body);if(!t.ok)return d(a),p(),{ok:!1,kind:"serialize"};f=t.body}try{const n=await Nt(s,{method:t,headers:Ht({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:!1,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:!1,kind:"client",status:m}:{ok:!1,kind:"server",status:m};if(204===n.status)return{ok:!0,data:void 0,status:204};try{return{ok:!0,data:await n.json(),status:n.status}}catch{return c.signal.aborted?u?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return u?{ok:!1,kind:"timeout"}:c.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!gt.includes(a.status)||!1===r?.refreshable)return c;var a;const u=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return u&&u!==s?t(u):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await jt(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:!1,kind:"serialize"}}return e.post("/events/capture",{body:u.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:!0,...o()}),{refreshable:!1})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>u?.getToken()??null,refresh:async()=>u?.refresh()??Promise.resolve(),getActivityId:()=>u?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};u=new bt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Ct(st,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new Rt({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 sn(6),r=new sn(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=rn(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=Yt(c,a,rn(c),i),{score:d,reasons:h}=Jt(c,u);if(o.push(l),!Gt(d))continue;const f=Wt(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=Yt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:o}=Jt(t,0);return{interactive:Gt(i),...o.length>0?{reasons:o}:{},disabled:Qt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Zt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,r,s);let l=null;return i||(l=u.interactive?Wt(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 Ft({getActivityId:()=>u?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:u,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let an=class t{constructor(){this.Tt=0,this._t=null,this.xt=et}static get instance(){return t.i||(t.i=new t),t.i}async setup(t){if(this.xt!==et)return n.fatal("error","setup()",`cannot set up from state '${this.xt}' — call reset() (or reload) first. Ignoring.`),rt;try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??!1};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:ct()}:void 0!==t.collectors?{sdk:o,collectors:ut(t.collectors)}:{sdk:o,collectors:at(t.layers)}}(t);if(!e)return this.xt=rt,rt;n.DEBUG=e.sdk.DEBUG;const i=await cn(e,{getProfileId:()=>null});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.xt=ot,ot):"init-failed"===i.status?(this.xt=rt,rt):(this._t=i.managers,this.xt=it,it)}catch(t){return n.warn("setup()","failed:",t),this.xt=rt,rt}}async start(){if(this.xt===et)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.xt;if(this.xt!==it)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.xt;this.xt="starting";const t=++this.Tt;return await this.v(t),this.xt}async stop(){n.warn("stop()","called");const t=this._t;return t?(++this.Tt,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.xt=it,this.St(t)):Promise.resolve(this.xt)}async reset(){const t=this.stop();return this.xt=et,this._t=null,t.then(()=>this.xt)}async St(t){return await function(t){let n=null;const e=new Promise(t=>{n=l(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.xt}async v(t){const e=this._t;if(e){try{if(await e.activityManager.start(),t!==this.Tt)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this.Tt)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this.Tt&&(this.xt=it))}t===this.Tt&&(this.xt="started")}}};async function un(t,n){const e=n?.apiURL??"https://falcon-ingest-k8s.stage.incodetest.com",i=n?.timeout??1e4,o=new AbortController;let r=null,s=!1,c=()=>{};i&&(r=l(()=>{s=!0,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:!0}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,expiresAt:null,tokenType:null,eventsCollectionEnabled:!1,error:{status:n.status,message:t}}}const i=await n.json();return{token:i.token,expiresAt:i.expiresAt,tokenType:i.tokenType,eventsCollectionEnabled:!0,error:null}}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}}an.i=null;const ln=an.instance;export{un as createSession,ln as default};
|
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 x(t,n){return n?.includes(t.toLowerCase())??!1}function I(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="collection-disabled",st="init-failed",at={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ct(){const t={};for(const n of tt)t[n]=ft(n,void 0,!0);return t}function ut(t){const n={};for(const e of tt)n[e]=ft(e,void 0,t[W[e].layer]??!1);return n}function lt(t){const n={};for(const e of tt){const i=t[e];n[e]=ft(e,i,i?.enabled??!1)}return n}function ft(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 ht(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const dt=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 vt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const pt="__tri",wt=`${pt}_activity_token`,mt=`${pt}_activity_id`,yt=`${pt}_activity_status`,gt="__tri_activity_lock";class bt{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 vt(gt,async()=>{if(this.M&&this.M!==t&&!dt(this.M)&&"ACTIVE"===this.D)return;const n=this.$();n&&n.token!==t&&!dt(n.token)&&"ACTIVE"===n.activityStatus?this.R(n):(this.O(),await this.B())})}async L(){try{if(this.M&&!dt(this.M))return;await vt(gt,async()=>{await this.B()})}finally{this.C=null}}async B(){const t=this.$();if(t&&!dt(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(wt),j.get(mt),j.get(yt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.O(),null)}j(t){j.set(wt,t.token),j.set(mt,t.activityId),j.set(yt,t.activityStatus)}O(){this.P(null),this.R(null)}P(t){if(!t)return j.remove(wt),j.remove(mt),void j.remove(yt);j.set(wt,t.token),j.set(mt,t.activityId),j.set(yt,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 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 St(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:Tt[t.name]}const xt=new Array(256);for(let t=0;t<256;t++)xt[t]=(t+256).toString(16).slice(1);const It=new Uint8Array(16);function _t(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 Mt(){return crypto.randomUUID()}function Et(){return crypto.getRandomValues(It),It[6]=15&It[6]|64,It[8]=63&It[8]|128,_t(It)}function At(){for(let t=0;t<16;t++)It[t]=256*Math.random()|0;return It[6]=15&It[6]|64,It[8]=63&It[8]|128,_t(It)}const zt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Mt;if("function"==typeof crypto.getRandomValues)return Et}return At}();function Dt(){return zt()}class Ct{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=St(t);for(let e=0;e<this.H.length;e++)if(St(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:Dt(),batchSequence:this.J++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.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 Ut="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(`${Ut}${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=Dt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Ut}${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(){}},Pt="__tri_tabId";class Rt{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.xt(),this.It({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.It({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}xt(){try{this.wt=new Lt("__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.It({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)}It(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.It({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(Pt);if(t)return t;const n=Dt();return q.set(Pt,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 $t=globalThis.CompressionStream,Ot=globalThis.Response,Bt=globalThis.Blob,jt=new TextEncoder;let qt=null;async function Ft(t){const n=await async function(t){if("function"!=typeof $t)return null;try{const n=jt.encode(t),e=new Bt([n]).stream().pipeThrough(new $t("gzip"));return await new Ot(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===qt){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 _i}),1e4);qt=t,t.then(n=>{null===n&&f(()=>{qt===t&&(qt=null)},1e4)})}return qt}();if(null===n)return null;const{gzipSync:i}=n,r=i(jt.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 Ht(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Nt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Zt{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 Xt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Gt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Kt=255;function Vt(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&&!x("id",i)&&(r.id=o);const s=t.getAttribute("autocomplete");s&&!x("autocomplete",i)&&(r.autocomplete=s);const a=t.getAttribute("aria-invalid");a&&!x("aria-invalid",i)&&(r.ariaInvalid=a);const c=t.getAttribute("tabindex");c&&!x("tabindex",i)&&(r.tabIndex=parseInt(c,10));const u=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);u&&!x("data-testid",i)&&(r.testId=u);const l=t.hasAttribute("readonly");l&&!x("readonly",i)&&(r.readOnly=l);const f=t.hasAttribute("required");f&&!x("required",i)&&(r.required=f);const h=t.getAttribute("contenteditable");h&&!x("contenteditable",i)&&(r.contentEditable="true"===h||""===h);const d=t.getAttribute("href");d&&!x("href",i)&&(r.href={...n?{}:{url:e(d)},external:I(d)});const v=t.getAttribute("role");v&&!x("role",i)&&(r.role=v);const p=t.getAttribute("type");p&&!x("type",i)&&(r.type=p);const w=t.getAttribute("name");w&&!x("name",i)&&(r.name=w);const m=t.getAttribute("placeholder");!m||n||x("placeholder",i)||(r.placeholder=m);const y=Array.from(t.classList).slice(0,5);y.length>0&&!x("class",i)&&(r.classes=y);const g=t.getAttribute("alt");return!g||n||x("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 Yt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Gt.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 Jt(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:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=rn(t);if(i)return{text:on(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?nn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"html-for",confidence:"high"};const o=function(t){const n=t.closest("label");return n?nn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const a=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(a)return{text:on(a),resolutionMethod:"title",confidence:"low"};const c=en(t,"describedby");if(c)return{text:on(c),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(g(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Kt):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>=Kt))break}return on(e)}function en(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=rn(n)??nn(n);e.length&&o.push(e)}return o.length?o.join(" "):null}function rn(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Kt?t.slice(0,Kt)+"...":t}function sn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class an{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,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===Nt)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 Nt(s,{method:t,headers:Ht({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||!kt.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 Ft(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 bt({startActivity:()=>a.api.startActivity(),stopActivity:()=>a.api.stopActivity()}),l=new Ct(at,{ingest:(t,n)=>a.api.ingest(t,n),getTabId:()=>d?.getTabId()??"unknown",isActivityActive:()=>c?.isActive()??!1});const v=o.tab;d=new Rt({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 an(6),o=new an(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=sn(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=Vt(a,c,sn(a),i),{score:f,reasons:h}=Yt(a,u);if(r.push(l),!Jt(f))continue;const d=tn(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=Vt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:r}=Yt(t,0);return{interactive:Jt(i),...r.length>0?{reasons:r}:{},disabled:Wt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Qt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,s);let l=null;return i||(l=u.interactive?tn(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 Zt({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 un=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.`),st;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:ct()}:void 0!==t.collectors?{sdk:r,collectors:lt(t.collectors)}:{sdk:r,collectors:ut(t.layers)}}(t);if(!n)return this.$t=st,st;e.DEBUG=n.sdk.DEBUG;const i=await cn(n,{getProfileId:()=>null});return"collection-disabled"===i.status?(e.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.$t=ot,ot):"init-failed"===i.status?(this.$t=st,st):(this.Rt=i.managers,this.$t=rt,rt)}catch(t){return e.warn("setup()","failed:",t),this.$t=st,st}}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="started")}}};un.S=null;const ln=un.instance;var fn={},hn=Uint8Array,dn=Uint16Array,vn=Int32Array,pn=new hn([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]),wn=new hn([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]),mn=new hn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yn=function(t,n){for(var e=new dn(31),i=0;i<31;++i)e[i]=n+=1<<t[i-1];var r=new vn(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}},gn=yn(pn,2),bn=gn.b,kn=gn.r;bn[28]=258,kn[258]=28;for(var Tn=yn(wn,0),Sn=Tn.b,xn=Tn.r,In=new dn(32768),_n=0;_n<32768;++_n){var Mn=(43690&_n)>>1|(21845&_n)<<1;In[_n]=((65280&(Mn=(61680&(Mn=(52428&Mn)>>2|(13107&Mn)<<2))>>4|(3855&Mn)<<4))>>8|(255&Mn)<<8)>>1}var En=function(t,n,e){for(var i=t.length,r=0,o=new dn(n);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new dn(n);for(r=1;r<n;++r)a[r]=a[r-1]+o[r-1]<<1;if(e){s=new dn(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[In[f]>>c]=u}else for(s=new dn(i),r=0;r<i;++r)t[r]&&(s[r]=In[a[t[r]-1]++]>>15-t[r]);return s},An=new hn(288);for(_n=0;_n<144;++_n)An[_n]=8;for(_n=144;_n<256;++_n)An[_n]=9;for(_n=256;_n<280;++_n)An[_n]=7;for(_n=280;_n<288;++_n)An[_n]=8;var zn=new hn(32);for(_n=0;_n<32;++_n)zn[_n]=5;var Dn=En(An,9,0),Cn=En(An,9,1),Un=En(zn,5,0),Ln=En(zn,5,1),Pn=function(t){for(var n=t[0],e=1;e<t.length;++e)t[e]>n&&(n=t[e]);return n},Rn=function(t,n,e){var i=n/8|0;return(t[i]|t[i+1]<<8)>>(7&n)&e},$n=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},On=function(t){return(t+7)/8|0},Bn=function(t,n,e){return(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length),new hn(t.subarray(n,e))},jn=["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"],qn=function(t,n,e){var i=new Error(n||jn[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,qn),!e)throw i;return i},Fn=function(t,n,e,i){var r=t.length,o=i?i.length:0;if(!r||n.f&&!n.l)return e||new hn(0);var s=!e,a=s||2!=n.i,c=n.i;s&&(e=new hn(3*r));var u=function(t){var n=e.length;if(t>n){var i=new hn(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=Rn(t,f,1);var y=Rn(t,f+1,3);if(f+=3,!y){var g=t[(z=On(f)+4)-4]|t[z-3]<<8,b=z+g;if(b>r){c&&qn(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=Cn,v=Ln,p=9,w=5;else if(2==y){var k=Rn(t,f,31)+257,T=Rn(t,f+10,15)+4,S=k+Rn(t,f+5,31)+1;f+=14;for(var x=new hn(S),I=new hn(19),_=0;_<T;++_)I[mn[_]]=Rn(t,f+3*_,7);f+=3*T;var M=Pn(I),E=(1<<M)-1,A=En(I,M,1);for(_=0;_<S;){var z,D=A[Rn(t,f,E)];if(f+=15&D,(z=D>>4)<16)x[_++]=z;else{var C=0,U=0;for(16==z?(U=3+Rn(t,f,3),f+=2,C=x[_-1]):17==z?(U=3+Rn(t,f,7),f+=3):18==z&&(U=11+Rn(t,f,127),f+=7);U--;)x[_++]=C}}var L=x.subarray(0,k),P=x.subarray(k);p=Pn(L),w=Pn(P),d=En(L,p,1),v=En(P,w,1)}else qn(1);if(f>m){c&&qn(0);break}}a&&u(h+131072);for(var R=(1<<p)-1,$=(1<<w)-1,O=f;;O=f){var B=(C=d[$n(t,f)&R])>>4;if((f+=15&C)>m){c&&qn(0);break}if(C||qn(2),B<256)e[h++]=B;else{if(256==B){O=f,d=null;break}var j=B-254;B>264&&(j=Rn(t,f,(1<<(H=pn[_=B-257]))-1)+bn[_],f+=H);var q=v[$n(t,f)&$],F=q>>4;if(q||qn(3),f+=15&q,P=Sn[F],F>3){var H=wn[F];P+=$n(t,f)&(1<<H)-1,f+=H}if(f>m){c&&qn(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&&qn(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?Bn(e,0,h):e.subarray(0,h)},Hn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8},Nn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8,t[i+2]|=e>>16},Zn=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:Qn,l:0};if(1==r){var s=new hn(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 dn(h+1),v=Xn(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 hn(d),l:v}},Xn=function(t,n,e){return-1==t.s?Math.max(Xn(t.l,n,e+1),Xn(t.r,n,e+1)):n[t.s]=e},Gn=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new dn(++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}},Kn=function(t,n){for(var e=0,i=0;i<n.length;++i)e+=t[i]*n[i];return e},Vn=function(t,n,e){var i=e.length,r=On(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)},Yn=function(t,n,e,i,r,o,s,a,c,u,l){Hn(n,l++,e),++r[256];for(var f=Zn(r,15),h=f.t,d=f.l,v=Zn(o,15),p=v.t,w=v.l,m=Gn(h),y=m.c,g=m.n,b=Gn(p),k=b.c,T=b.n,S=new dn(19),x=0;x<y.length;++x)++S[31&y[x]];for(x=0;x<k.length;++x)++S[31&k[x]];for(var I=Zn(S,7),_=I.t,M=I.l,E=19;E>4&&!_[mn[E-1]];--E);var A,z,D,C,U=u+5<<3,L=Kn(r,An)+Kn(o,zn)+s,P=Kn(r,h)+Kn(o,p)+s+14+3*E+Kn(S,_)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&U<=L&&U<=P)return Vn(n,l,t.subarray(c,c+u));if(Hn(n,l,1+(P<L)),l+=2,P<L){A=En(h,d,0),z=h,D=En(p,w,0),C=p;var R=En(_,M,0);for(Hn(n,l,g-257),Hn(n,l+5,T-1),Hn(n,l+10,E-4),l+=14,x=0;x<E;++x)Hn(n,l+3*x,_[mn[x]]);l+=3*E;for(var $=[y,k],O=0;O<2;++O){var B=$[O];for(x=0;x<B.length;++x)Hn(n,l,R[q=31&B[x]]),l+=_[q],q>15&&(Hn(n,l,B[x]>>5&127),l+=B[x]>>12)}}else A=Dn,z=An,D=Un,C=zn;for(x=0;x<a;++x){var j=i[x];if(j>255){var q;Nn(n,l,A[257+(q=j>>18&31)]),l+=z[q+257],q>7&&(Hn(n,l,j>>23&31),l+=pn[q]);var F=31&j;Nn(n,l,D[F]),l+=C[F],F>3&&(Nn(n,l,j>>5&8191),l+=wn[F])}else Nn(n,l,A[j]),l+=z[j]}return Nn(n,l,A[256]),l+z[256]},Jn=new vn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Qn=new hn(0),Wn=function(t,n,e,i,r,o){var s=o.z||t.length,a=new hn(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=Jn[n-1],h=f>>13,d=8191&f,v=(1<<e)-1,p=o.p||new dn(32768),w=o.h||new dn(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 vn(25e3),k=new dn(288),T=new dn(32),S=0,x=0,I=o.i||0,_=0,M=o.w||0,E=0;I+2<s;++I){var A=g(I),z=32767&I,D=w[A];if(p[z]=D,w[A]=z,M<=I){var C=s-I;if((S>7e3||_>24576)&&(C>423||!u)){l=Yn(t,c,0,b,k,T,x,_,E,I-E,l),_=S=x=0,E=I;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(I-$))for(var O=Math.min(h,C)-1,B=Math.min(32767,I),j=Math.min(258,C);$<=B&&--R&&z!=D;){if(t[I+L]==t[I+L-$]){for(var q=0;q<j&&t[I+q]==t[I+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=I-$+U&32767,Z=N-p[N]&32767;Z>H&&(H=Z,D=N)}}}$+=(z=D)-(D=p[z])&32767}if(P){b[_++]=268435456|kn[L]<<18|xn[P];var X=31&kn[L],G=31&xn[P];x+=pn[X]+wn[G],++k[257+X],++T[G],M=I+L,++S}else b[_++]=t[I],++k[t[I]]}}for(I=Math.max(I,M);I<s;++I)b[_++]=t[I],++k[t[I]];l=Yn(t,c,u,b,k,T,x,_,E,I-E,l),u||(o.r=7&l|c[l/8|0]<<3,l-=7,o.h=w,o.p=p,o.i=I,o.w=M)}else{for(I=o.w||0;I<s+u;I+=65535){var K=I+65535;K>=s&&(c[l/8|0]=u,K=s),l=Vn(c,l+1,t.subarray(I,K))}o.i=s}return Bn(a,0,i+On(l)+r)},te=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}(),ne=function(){var t=-1;return{p:function(n){for(var e=t,i=0;i<n.length;++i)e=te[255&e^n[i]]^e>>>8;t=e},d:function(){return~t}}},ee=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}}},ie=function(t,n,e,i,r){if(!r&&(r={l:1},n.dictionary)){var o=n.dictionary.subarray(-32768),s=new hn(o.length+t.length);s.set(o),s.set(t,o.length),t=s,r.w=o.length}return Wn(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)},re=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},oe=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},se=[],ae=function(t,n,e,i){if(!se[e]){for(var r="",o={},s=t.length-1,a=0;a<s;++a)r=oe(t[a],r,o);se[e]={c:oe(t[s],r,o),e:o}}var c=re({},se[e].e);return function(t,n,e,i,r){var o=new Worker(fn[n]||(fn[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}(se[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)},ce=function(){return[hn,dn,vn,pn,wn,mn,bn,Sn,Cn,Ln,In,jn,En,Pn,Rn,$n,On,Bn,qn,Fn,$e,ve,pe]},ue=function(){return[hn,dn,vn,pn,wn,mn,kn,xn,Dn,An,Un,zn,In,Jn,Qn,En,Hn,Nn,Zn,Xn,Gn,Kn,Vn,Yn,On,Bn,Wn,ie,Ue,ve]},le=function(){return[Se,_e,Te,ne,te]},fe=function(){return[xe,Ie]},he=function(){return[Me,Te,ee]},de=function(){return[Ee]},ve=function(t){return postMessage(t,[t.buffer])},pe=function(t){return t&&{out:t.size&&new hn(t.size),dictionary:t.dictionary}},we=function(t,n,e,i,r,o){var s=ae(e,i,r,function(t,n){s.terminate(),o(t,n)});return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},me=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()}},ye=function(t,n,e,i,r,o,s){var a,c=ae(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||qn(5),a&&n.ondata(qn(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([])})},ge=function(t,n){return t[n]|t[n+1]<<8},be=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},ke=function(t,n){return be(t,n)+4294967296*be(t,n+4)},Te=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},Se=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&&Te(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]||qn(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)},Ie=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},_e=function(t){return 10+(t.filename?t.filename.length+1:0)},Me=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=ee();r.p(n.dictionary),Te(t,2,r.d())}},Ee=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&qn(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&qn(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function Ae(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var ze=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 hn(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(ie(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,n){this.ondata||qn(5),this.s.l&&qn(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new hn(-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||qn(5),this.s.l&&qn(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},t}(),De=function(){return function(t,n){ye([ue,function(){return[me,ze]}],this,Ae.call(this,t,n),function(t){var n=new ze(t.data);onmessage=me(n)},6,1)}}();function Ce(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ue],function(t){return ve(Ue(t.data[0],t.data[1]))},0,e)}function Ue(t,n){return ie(t,n||{},0,0)}var Le=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 hn(32768),this.p=new hn(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||qn(5),this.d&&qn(4),this.p.length){if(t.length){var n=new hn(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=Fn(this.p,this.s,this.o);this.ondata(Bn(e,n,this.s.b),this.d),this.o=Bn(e,this.s.b-32768),this.s.b=this.o.length,this.p=Bn(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}(),Pe=function(){return function(t,n){ye([ce,function(){return[me,Le]}],this,Ae.call(this,t,n),function(t){var n=new Le(t.data);onmessage=me(n)},7,0)}}();function Re(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ce],function(t){return ve($e(t.data[0],pe(t.data[1])))},1,e)}function $e(t,n){return Fn(t,{i:2},n&&n.out,n&&n.dictionary)}var Oe=function(){function t(t,n){this.c=ne(),this.l=0,this.v=1,ze.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,ze.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=ie(t,this.o,this.v&&_e(this.o),n&&8,this.s);this.v&&(Se(e,this.o),this.v=0),n&&(Te(e,e.length-8,this.c.d()),Te(e,e.length-4,this.l)),this.ondata(e,n)},t.prototype.flush=function(){ze.prototype.flush.call(this)},t}(),Be=function(){return function(t,n){ye([ue,le,function(){return[me,ze,Oe]}],this,Ae.call(this,t,n),function(t){var n=new Oe(t.data);onmessage=me(n)},8,1)}}();function je(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ue,le,function(){return[qe]}],function(t){return ve(qe(t.data[0],t.data[1]))},2,e)}function qe(t,n){n||(n={});var e=ne(),i=t.length;e.p(t);var r=ie(t,n,_e(n),8),o=r.length;return Se(r,n),Te(r,o-8,e.d()),Te(r,o-4,i),r}var Fe=function(){function t(t,n){this.v=1,this.r=0,Le.call(this,t,n)}return t.prototype.push=function(t,n){if(Le.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}Le.prototype.c.call(this,n),!this.s.f||this.s.l||n||(this.v=On(this.s.p)+9,this.s={i:0},this.o=new hn(0),this.push(new hn(0),n))},t}(),He=function(){return function(t,n){var e=this;ye([ce,fe,function(){return[me,Le,Fe]}],this,Ae.call(this,t,n),function(t){var n=new Fe(t.data);n.onmember=function(t){return postMessage(t)},onmessage=me(n)},9,0,function(t){return e.onmember&&e.onmember(t)})}}();function Ne(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ce,fe,function(){return[Ze]}],function(t){return ve(Ze(t.data[0],t.data[1]))},3,e)}function Ze(t,n){var e=xe(t);return e+8>t.length&&qn(6,"invalid gzip data"),Fn(t.subarray(e,-8),{i:2},n&&n.out||new hn(Ie(t)),n&&n.dictionary)}var Xe=function(){function t(t,n){this.c=ee(),this.v=1,ze.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),ze.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=ie(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(Me(e,this.o),this.v=0),n&&Te(e,e.length-4,this.c.d()),this.ondata(e,n)},t.prototype.flush=function(){ze.prototype.flush.call(this)},t}(),Ge=function(){return function(t,n){ye([ue,he,function(){return[me,ze,Xe]}],this,Ae.call(this,t,n),function(t){var n=new Xe(t.data);onmessage=me(n)},10,1)}}();function Ke(t,n){n||(n={});var e=ee();e.p(t);var i=ie(t,n,n.dictionary?6:2,4);return Me(i,n),Te(i,i.length-4,e.d()),i}var Ve=function(){function t(t,n){Le.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(Le.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(Ee(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&qn(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Le.prototype.c.call(this,n)},t}(),Ye=function(){return function(t,n){ye([ce,de,function(){return[me,Le,Ve]}],this,Ae.call(this,t,n),function(t){var n=new Ve(t.data);onmessage=me(n)},11,0)}}();function Je(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ce,de,function(){return[Qe]}],function(t){return ve(Qe(t.data[0],pe(t.data[1])))},5,e)}function Qe(t,n){return Fn(t.subarray(Ee(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}var We=function(){function t(t,n){this.o=Ae.call(this,t,n)||{},this.G=Fe,this.I=Le,this.Z=Ve}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||qn(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new hn(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}(),ti=function(){function t(t,n){We.call(this,t,n),this.queuedSize=0,this.G=He,this.I=Pe,this.Z=Ye}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,We.prototype.push.call(this,t,n)},t}(),ni=function(t,n,e,i){for(var r in t){var o=t[r],s=n+r,a=i;Array.isArray(o)&&(a=re(i,o[1]),o=o[0]),o instanceof hn?e[s]=[o,a]:(e[s+="/"]=[new hn(0),a],ni(o,s,e,i))}},ei="undefined"!=typeof TextEncoder&&new TextEncoder,ii="undefined"!=typeof TextDecoder&&new TextDecoder,ri=0;try{ii.decode(Qn,{stream:!0}),ri=1}catch(t){}var oi=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:Bn(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)}},si=function(){function t(t){this.ondata=t,ri?this.t=new TextDecoder:this.p=Qn}return t.prototype.push=function(t,n){if(this.ondata||qn(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:!0}),n),void(n&&(this.t.decode().length&&qn(8),this.t=null));this.p||qn(4);var e=new hn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=oi(e),r=i.s,o=i.r;n?(o.length&&qn(8),this.p=null):this.p=o,this.ondata(r,n)},t}(),ai=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||qn(5),this.d&&qn(4),this.ondata(ci(t),this.d=n||!1)},t}();function ci(t,n){if(n){for(var e=new hn(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(ei)return ei.encode(t);var r=t.length,o=new hn(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 hn(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 Bn(o,0,s)}function ui(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(ii)return ii.decode(t);var r=oi(t),o=r.s;return(e=r.r).length&&qn(8),o}var li=function(t){return 1==t?3:t<6?2:9==t?1:0},fi=function(t,n){return n+30+ge(t,n+26)+ge(t,n+28)},hi=function(t,n,e){var i=ge(t,n+28),r=ui(t.subarray(n+46,n+46+i),!(2048&ge(t,n+8))),o=n+46+i,s=be(t,n+20),a=e&&4294967295==s?di(t,o):[s,be(t,n+24),be(t,n+42)],c=a[0],u=a[1],l=a[2];return[ge(t,n+10),c,u,r,o+ge(t,n+30)+ge(t,n+32),l]},di=function(t,n){for(;1!=ge(t,n);n+=4+ge(t,n+2));return[ke(t,n+12),ke(t,n+4),ke(t,n+20)]},vi=function(t){var n=0;if(t)for(var e in t){var i=t[e].length;i>65535&&qn(9),n+=i+4}return n},pi=function(t,n,e,i,r,o,s,a){var c=i.length,u=e.extra,l=a&&a.length,f=vi(u);Te(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)&&qn(10),Te(t,n,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),n+=4,-1!=o&&(Te(t,n,e.crc),Te(t,n+4,o<0?-o-2:o),Te(t,n+8,e.size)),Te(t,n+12,c),Te(t,n+14,f),n+=16,null!=s&&(Te(t,n,l),Te(t,n+6,e.attrs),Te(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;Te(t,n,+v),Te(t,n+2,w),t.set(p,n+4),n+=4+w}return l&&(t.set(a,n),n+=l),n},wi=function(t,n,e,i,r){Te(t,n,101010256),Te(t,n+8,e),Te(t,n+10,e),Te(t,n+12,i),Te(t,n+16,r)},mi=function(){function t(t){this.filename=t,this.c=ne(),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||qn(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}(),yi=function(){function t(t,n){var e=this;n||(n={}),mi.call(this,t),this.d=new ze(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=li(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){mi.prototype.push.call(this,t,n)},t}(),gi=function(){function t(t,n){var e=this;n||(n={}),mi.call(this,t),this.d=new De(n,function(t,n,i){e.ondata(t,n,i)}),this.compression=8,this.flag=li(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){mi.prototype.push.call(this,t,n)},t}(),bi=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||qn(5),2&this.d)this.ondata(qn(4+8*(1&this.d),0,1),null,!1);else{var e=ci(t.filename),i=e.length,r=t.comment,o=r&&ci(r),s=i!=t.filename.length||o&&r.length!=o.length,a=i+vi(t.extra)+30;i>65535&&this.ondata(qn(11,0,1),null,!1);var c=new hn(a);pi(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=re(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 hn(16);Te(o,0,134695760),Te(o,4,t.crc),Te(o,8,v),Te(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(qn(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+vi(c.extra)+(c.o?c.o.length:0);for(var o=new hn(e+22),s=0,a=this.u;s<a.length;s++){var c;pi(o,t,c=a[s],c.f,c.u,-c.c-2,n,c.o),t+=46+c.f.length+vi(c.extra)+(c.o?c.o.length:0),n+=c.b}wi(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}(),ki=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}(),Ti=function(){function t(){var t=this;this.i=new Le(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}(),Si=function(){function t(t,n){var e=this;n<32e4?this.i=new Le(function(t,n){e.ondata(null,t,n)}):(this.i=new Pe(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=Bn(t,0)),this.i.push(t,n)},t.compression=8,t}(),xi=function(){function t(t){this.onfile=t,this.k=[],this.o={0:ki},this.p=Qn}return t.prototype.push=function(t,n){var e=this;if(this.onfile||qn(5),this.p||qn(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 hn(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=be(c,s);if(67324752==n){o=1,a=s,d.d=null,d.c=0;var i=ge(c,s+6),r=ge(c,s+8),f=2048&i,h=8&i,v=ge(c,s+26),p=ge(c,s+28);if(u>s+30+v+p){var w=[];d.k.unshift(w),o=2;var m,y=be(c,s+18),g=be(c,s+22),b=ui(c.subarray(s+30,s+=30+v),!f);4294967295==y?(t=h?[-2]:di(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||qn(5),y){var t=e.o[r];t||k.ondata(qn(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(Qn,!0)}else k.ondata(null,Qn,!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=Qn,l<0){var v=c.subarray(0,o?a-12-(-2==l&&8)-(134695760==be(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&&qn(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),Ii="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()},_i=Object.freeze({__proto__:null,AsyncCompress:Be,AsyncDecompress:ti,AsyncDeflate:De,AsyncGunzip:He,AsyncGzip:Be,AsyncInflate:Pe,AsyncUnzipInflate:Si,AsyncUnzlib:Ye,AsyncZipDeflate:gi,AsyncZlib:Ge,Compress:Oe,DecodeUTF8:si,Decompress:We,Deflate:ze,EncodeUTF8:ai,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:Fe,Gzip:Oe,Inflate:Le,Unzip:xi,UnzipInflate:Ti,UnzipPassThrough:ki,Unzlib:Ve,Zip:bi,ZipDeflate:yi,ZipPassThrough:mi,Zlib:Xe,compress:je,compressSync:qe,decompress:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),31==t[0]&&139==t[1]&&8==t[2]?Ne(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Re(t,n,e):Je(t,n,e)},decompressSync:function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?Ze(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?$e(t,n):Qe(t,n)},deflate:Ce,deflateSync:Ue,gunzip:Ne,gunzipSync:Ze,gzip:je,gzipSync:qe,inflate:Re,inflateSync:$e,strFromU8:ui,strToU8:ci,unzip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&qn(7);var i=[],r=function(){for(var t=0;t<i.length;++t)i[t]()},o={},s=function(t,n){Ii(function(){e(t,n)})};Ii(function(){s=e});for(var a=t.length-22;101010256!=be(t,a);--a)if(!a||t.length-a>65558)return s(qn(13,0,1),null),r;var c=ge(t,a+8);if(c){var u=c,l=be(t,a+16),f=4294967295==l||65535==u;if(f){var h=be(t,a-12);(f=101075792==be(t,h))&&(u=c=be(t,h+32),l=be(t,h+48))}for(var d=n&&n.filter,v=function(n){var e=hi(t,l,f),a=e[0],u=e[1],h=e[2],v=e[3],p=e[4],w=fi(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,$e(y,{out:new hn(h)}))}catch(t){m(t,null)}else i.push(Re(y,{size:h},m))}else m(qn(14,"unknown compression type "+a,1),null);else m(null,Bn(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!=be(t,i);--i)(!i||t.length-i>65558)&&qn(13);var r=ge(t,i+8);if(!r)return{};var o=be(t,i+16),s=4294967295==o||65535==r;if(s){var a=be(t,i-12);(s=101075792==be(t,a))&&(r=be(t,a+32),o=be(t,a+48))}for(var c=n&&n.filter,u=0;u<r;++u){var l=hi(t,o,s),f=l[0],h=l[1],d=l[2],v=l[3],p=l[4],w=fi(t,l[5]);o=p,c&&!c({name:v,size:h,originalSize:d,compression:f})||(f?8==f?e[v]=$e(t.subarray(w,w+h),{out:new hn(d)}):qn(14,"unknown compression type "+f):e[v]=Bn(t,w,w+h))}return e},unzlib:Je,unzlibSync:Qe,zip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&qn(7);var i={};ni(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){Ii(function(){e(t,n)})};Ii(function(){h=e});var d=function(){var t=new hn(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;pi(t,a,r,r.f,r.u,o);var l=30+r.f.length+vi(r.extra),f=a+l;t.set(r.c,f),pi(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)}}wi(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=ne(),w=c.length;p.p(c);var m=ci(n),y=m.length,g=v.comment,b=g&&ci(g),k=b&&b.length,T=vi(v.extra),S=0==v.level?0:8,x=function(e,i){if(e)f(),h(e,null);else{var r=i.length;u[t]=re(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&&x(qn(11,0,1),null),S)if(w<16e4)try{x(null,Ue(c,v))}catch(t){x(t,null)}else l.push(Ce(c,v,x));else x(null,c)},p=0;p<c;++p)v(p);return f},zipSync:function(t,n){n||(n={});var e={},i=[];ni(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=ci(s)).length,h=u.comment,d=h&&ci(h),v=d&&d.length,p=vi(u.extra);f>65535&&qn(11);var w=l?Ue(c,u):c,m=w.length,y=ne();y.p(c),i.push(re(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 hn(o+22),b=r,k=o-r,T=0;T<i.length;++T){var S;pi(g,(S=i[T]).o,S,S.f,S.u,S.c.length);var x=30+S.f.length+vi(S.extra);g.set(S.c,S.o+x),pi(g,r,S,S.f,S.u,S.c.length,S.o,S.m),r+=16+x+(S.m?S.m.length:0)}return wi(g,r,i.length,k,b),g},zlib:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ue,he,function(){return[Ke]}],function(t){return ve(Ke(t.data[0],t.data[1]))},4,e)},zlibSync:Ke});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=ln,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 x(t,n){return n?.includes(t.toLowerCase())??!1}function I(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="collection-disabled",st="init-failed",at={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function ct(){const t={};for(const n of tt)t[n]=ft(n,void 0,!0);return t}function ut(t){const n={};for(const e of tt)n[e]=ft(e,void 0,t[W[e].layer]??!1);return n}function lt(t){const n={};for(const e of tt){const i=t[e];n[e]=ft(e,i,i?.enabled??!1)}return n}function ft(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 ht(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const dt=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 vt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const pt="__tri",wt=`${pt}_activity_token`,mt=`${pt}_activity_id`,yt=`${pt}_activity_status`,gt="__tri_activity_lock";class bt{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 vt(gt,async()=>{if(this.M&&this.M!==t&&!dt(this.M)&&"ACTIVE"===this.D)return;const n=this.$();n&&n.token!==t&&!dt(n.token)&&"ACTIVE"===n.activityStatus?this.R(n):(this.O(),await this.B())})}async L(){try{if(this.M&&!dt(this.M))return;await vt(gt,async()=>{await this.B()})}finally{this.C=null}}async B(){const t=this.$();if(t&&!dt(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(wt),j.get(mt),j.get(yt)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.O(),null)}j(t){j.set(wt,t.token),j.set(mt,t.activityId),j.set(yt,t.activityStatus)}O(){this.P(null),this.R(null)}P(t){if(!t)return j.remove(wt),j.remove(mt),void j.remove(yt);j.set(wt,t.token),j.set(mt,t.activityId),j.set(yt,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 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 St(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:Tt[t.name]}const xt=new Array(256);for(let t=0;t<256;t++)xt[t]=(t+256).toString(16).slice(1);const It=new Uint8Array(16);function _t(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 Mt(){return crypto.randomUUID()}function Et(){return crypto.getRandomValues(It),It[6]=15&It[6]|64,It[8]=63&It[8]|128,_t(It)}function At(){for(let t=0;t<16;t++)It[t]=256*Math.random()|0;return It[6]=15&It[6]|64,It[8]=63&It[8]|128,_t(It)}const zt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Mt;if("function"==typeof crypto.getRandomValues)return Et}return At}();function Dt(){return zt()}class Ct{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=St(t);for(let e=0;e<this.H.length;e++)if(St(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:Dt(),batchSequence:this.J++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.1",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 Ut="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(`${Ut}${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=Dt(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${Ut}${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(){}},Pt="__tri_tabId";class Rt{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.xt(),this.It({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.It({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}xt(){try{this.wt=new Lt("__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.It({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)}It(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.It({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(Pt);if(t)return t;const n=Dt();return q.set(Pt,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 $t=globalThis.CompressionStream,Ot=globalThis.Response,Bt=globalThis.Blob,jt=new TextEncoder;let qt=null;async function Ft(t){const n=await async function(t){if("function"!=typeof $t)return null;try{const n=jt.encode(t),e=new Bt([n]).stream().pipeThrough(new $t("gzip"));return await new Ot(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===qt){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 _i}),1e4);qt=t,t.then(n=>{null===n&&f(()=>{qt===t&&(qt=null)},1e4)})}return qt}();if(null===n)return null;const{gzipSync:i}=n,r=i(jt.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 Ht(t){const n={Accept:"application/json"};return t?.hasBody&&("json"===t.contentType?n["Content-Type"]="application/json":"ndjson"===t.contentType&&(n["Content-Type"]="application/x-ndjson"),"gzip"===t.contentEncoding&&(n["Content-Encoding"]="gzip")),t?.token&&(n.Authorization=`Bearer ${t.token}`),t?.profileId&&(n["x-profile-id"]=t.profileId),t?.api?.version&&(n["x-api-version"]=t.api.version),t?.customHeaders&&Object.entries(t.customHeaders).forEach(([t,e])=>{n[t]=e}),n}const Nt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Zt{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 Xt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Gt=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Kt=255;function Vt(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&&!x("id",i)&&(r.id=o);const s=t.getAttribute("autocomplete");s&&!x("autocomplete",i)&&(r.autocomplete=s);const a=t.getAttribute("aria-invalid");a&&!x("aria-invalid",i)&&(r.ariaInvalid=a);const c=t.getAttribute("tabindex");c&&!x("tabindex",i)&&(r.tabIndex=parseInt(c,10));const u=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);u&&!x("data-testid",i)&&(r.testId=u);const l=t.hasAttribute("readonly");l&&!x("readonly",i)&&(r.readOnly=l);const f=t.hasAttribute("required");f&&!x("required",i)&&(r.required=f);const h=t.getAttribute("contenteditable");h&&!x("contenteditable",i)&&(r.contentEditable="true"===h||""===h);const d=t.getAttribute("href");d&&!x("href",i)&&(r.href={...n?{}:{url:e(d)},external:I(d)});const v=t.getAttribute("role");v&&!x("role",i)&&(r.role=v);const p=t.getAttribute("type");p&&!x("type",i)&&(r.type=p);const w=t.getAttribute("name");w&&!x("name",i)&&(r.name=w);const m=t.getAttribute("placeholder");!m||n||x("placeholder",i)||(r.placeholder=m);const y=Array.from(t.classList).slice(0,5);y.length>0&&!x("class",i)&&(r.classes=y);const g=t.getAttribute("alt");return!g||n||x("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 Yt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Gt.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 Jt(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:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=rn(t);if(i)return{text:on(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?nn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"html-for",confidence:"high"};const o=function(t){const n=t.closest("label");return n?nn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const a=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(a)return{text:on(a),resolutionMethod:"title",confidence:"low"};const c=en(t,"describedby");if(c)return{text:on(c),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(g(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Kt):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>=Kt))break}return on(e)}function en(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=rn(n)??nn(n);e.length&&o.push(e)}return o.length?o.join(" "):null}function rn(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Kt?t.slice(0,Kt)+"...":t}function sn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class an{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,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===Nt)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 Nt(s,{method:t,headers:Ht({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||!kt.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 Ft(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 bt({startActivity:()=>a.api.startActivity(),stopActivity:()=>a.api.stopActivity()}),l=new Ct(at,{ingest:(t,n)=>a.api.ingest(t,n),getTabId:()=>d?.getTabId()??"unknown",isActivityActive:()=>c?.isActive()??!1});const v=o.tab;d=new Rt({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 an(6),o=new an(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=sn(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=Vt(a,c,sn(a),i),{score:f,reasons:h}=Yt(a,u);if(r.push(l),!Jt(f))continue;const d=tn(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=Vt(t,i,s,e),u=function(t,n,e){const{score:i,reasons:r}=Yt(t,0);return{interactive:Jt(i),...r.length>0?{reasons:r}:{},disabled:Wt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Qt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,s);let l=null;return i||(l=u.interactive?tn(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 Zt({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 un=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.`),st;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:ct()}:void 0!==t.collectors?{sdk:r,collectors:lt(t.collectors)}:{sdk:r,collectors:ut(t.layers)}}(t);if(!n)return this.$t=st,st;e.DEBUG=n.sdk.DEBUG;const i=await cn(n,{getProfileId:()=>null});return"collection-disabled"===i.status?(e.fatal("warn","setup()","Collection is disabled for the provided API Key."),this.$t=ot,ot):"init-failed"===i.status?(this.$t=st,st):(this.Rt=i.managers,this.$t=rt,rt)}catch(t){return e.warn("setup()","failed:",t),this.$t=st,st}}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="started")}}};un.S=null;const ln=un.instance;var fn={},hn=Uint8Array,dn=Uint16Array,vn=Int32Array,pn=new hn([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]),wn=new hn([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]),mn=new hn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),yn=function(t,n){for(var e=new dn(31),i=0;i<31;++i)e[i]=n+=1<<t[i-1];var r=new vn(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}},gn=yn(pn,2),bn=gn.b,kn=gn.r;bn[28]=258,kn[258]=28;for(var Tn=yn(wn,0),Sn=Tn.b,xn=Tn.r,In=new dn(32768),_n=0;_n<32768;++_n){var Mn=(43690&_n)>>1|(21845&_n)<<1;In[_n]=((65280&(Mn=(61680&(Mn=(52428&Mn)>>2|(13107&Mn)<<2))>>4|(3855&Mn)<<4))>>8|(255&Mn)<<8)>>1}var En=function(t,n,e){for(var i=t.length,r=0,o=new dn(n);r<i;++r)t[r]&&++o[t[r]-1];var s,a=new dn(n);for(r=1;r<n;++r)a[r]=a[r-1]+o[r-1]<<1;if(e){s=new dn(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[In[f]>>c]=u}else for(s=new dn(i),r=0;r<i;++r)t[r]&&(s[r]=In[a[t[r]-1]++]>>15-t[r]);return s},An=new hn(288);for(_n=0;_n<144;++_n)An[_n]=8;for(_n=144;_n<256;++_n)An[_n]=9;for(_n=256;_n<280;++_n)An[_n]=7;for(_n=280;_n<288;++_n)An[_n]=8;var zn=new hn(32);for(_n=0;_n<32;++_n)zn[_n]=5;var Dn=En(An,9,0),Cn=En(An,9,1),Un=En(zn,5,0),Ln=En(zn,5,1),Pn=function(t){for(var n=t[0],e=1;e<t.length;++e)t[e]>n&&(n=t[e]);return n},Rn=function(t,n,e){var i=n/8|0;return(t[i]|t[i+1]<<8)>>(7&n)&e},$n=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},On=function(t){return(t+7)/8|0},Bn=function(t,n,e){return(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length),new hn(t.subarray(n,e))},jn=["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"],qn=function(t,n,e){var i=new Error(n||jn[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,qn),!e)throw i;return i},Fn=function(t,n,e,i){var r=t.length,o=i?i.length:0;if(!r||n.f&&!n.l)return e||new hn(0);var s=!e,a=s||2!=n.i,c=n.i;s&&(e=new hn(3*r));var u=function(t){var n=e.length;if(t>n){var i=new hn(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=Rn(t,f,1);var y=Rn(t,f+1,3);if(f+=3,!y){var g=t[(z=On(f)+4)-4]|t[z-3]<<8,b=z+g;if(b>r){c&&qn(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=Cn,v=Ln,p=9,w=5;else if(2==y){var k=Rn(t,f,31)+257,T=Rn(t,f+10,15)+4,S=k+Rn(t,f+5,31)+1;f+=14;for(var x=new hn(S),I=new hn(19),_=0;_<T;++_)I[mn[_]]=Rn(t,f+3*_,7);f+=3*T;var M=Pn(I),E=(1<<M)-1,A=En(I,M,1);for(_=0;_<S;){var z,D=A[Rn(t,f,E)];if(f+=15&D,(z=D>>4)<16)x[_++]=z;else{var C=0,U=0;for(16==z?(U=3+Rn(t,f,3),f+=2,C=x[_-1]):17==z?(U=3+Rn(t,f,7),f+=3):18==z&&(U=11+Rn(t,f,127),f+=7);U--;)x[_++]=C}}var L=x.subarray(0,k),P=x.subarray(k);p=Pn(L),w=Pn(P),d=En(L,p,1),v=En(P,w,1)}else qn(1);if(f>m){c&&qn(0);break}}a&&u(h+131072);for(var R=(1<<p)-1,$=(1<<w)-1,O=f;;O=f){var B=(C=d[$n(t,f)&R])>>4;if((f+=15&C)>m){c&&qn(0);break}if(C||qn(2),B<256)e[h++]=B;else{if(256==B){O=f,d=null;break}var j=B-254;B>264&&(j=Rn(t,f,(1<<(H=pn[_=B-257]))-1)+bn[_],f+=H);var q=v[$n(t,f)&$],F=q>>4;if(q||qn(3),f+=15&q,P=Sn[F],F>3){var H=wn[F];P+=$n(t,f)&(1<<H)-1,f+=H}if(f>m){c&&qn(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&&qn(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?Bn(e,0,h):e.subarray(0,h)},Hn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8},Nn=function(t,n,e){var i=n/8|0;t[i]|=e<<=7&n,t[i+1]|=e>>8,t[i+2]|=e>>16},Zn=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:Qn,l:0};if(1==r){var s=new hn(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 dn(h+1),v=Xn(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 hn(d),l:v}},Xn=function(t,n,e){return-1==t.s?Math.max(Xn(t.l,n,e+1),Xn(t.r,n,e+1)):n[t.s]=e},Gn=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new dn(++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}},Kn=function(t,n){for(var e=0,i=0;i<n.length;++i)e+=t[i]*n[i];return e},Vn=function(t,n,e){var i=e.length,r=On(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)},Yn=function(t,n,e,i,r,o,s,a,c,u,l){Hn(n,l++,e),++r[256];for(var f=Zn(r,15),h=f.t,d=f.l,v=Zn(o,15),p=v.t,w=v.l,m=Gn(h),y=m.c,g=m.n,b=Gn(p),k=b.c,T=b.n,S=new dn(19),x=0;x<y.length;++x)++S[31&y[x]];for(x=0;x<k.length;++x)++S[31&k[x]];for(var I=Zn(S,7),_=I.t,M=I.l,E=19;E>4&&!_[mn[E-1]];--E);var A,z,D,C,U=u+5<<3,L=Kn(r,An)+Kn(o,zn)+s,P=Kn(r,h)+Kn(o,p)+s+14+3*E+Kn(S,_)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&U<=L&&U<=P)return Vn(n,l,t.subarray(c,c+u));if(Hn(n,l,1+(P<L)),l+=2,P<L){A=En(h,d,0),z=h,D=En(p,w,0),C=p;var R=En(_,M,0);for(Hn(n,l,g-257),Hn(n,l+5,T-1),Hn(n,l+10,E-4),l+=14,x=0;x<E;++x)Hn(n,l+3*x,_[mn[x]]);l+=3*E;for(var $=[y,k],O=0;O<2;++O){var B=$[O];for(x=0;x<B.length;++x)Hn(n,l,R[q=31&B[x]]),l+=_[q],q>15&&(Hn(n,l,B[x]>>5&127),l+=B[x]>>12)}}else A=Dn,z=An,D=Un,C=zn;for(x=0;x<a;++x){var j=i[x];if(j>255){var q;Nn(n,l,A[257+(q=j>>18&31)]),l+=z[q+257],q>7&&(Hn(n,l,j>>23&31),l+=pn[q]);var F=31&j;Nn(n,l,D[F]),l+=C[F],F>3&&(Nn(n,l,j>>5&8191),l+=wn[F])}else Nn(n,l,A[j]),l+=z[j]}return Nn(n,l,A[256]),l+z[256]},Jn=new vn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Qn=new hn(0),Wn=function(t,n,e,i,r,o){var s=o.z||t.length,a=new hn(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=Jn[n-1],h=f>>13,d=8191&f,v=(1<<e)-1,p=o.p||new dn(32768),w=o.h||new dn(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 vn(25e3),k=new dn(288),T=new dn(32),S=0,x=0,I=o.i||0,_=0,M=o.w||0,E=0;I+2<s;++I){var A=g(I),z=32767&I,D=w[A];if(p[z]=D,w[A]=z,M<=I){var C=s-I;if((S>7e3||_>24576)&&(C>423||!u)){l=Yn(t,c,0,b,k,T,x,_,E,I-E,l),_=S=x=0,E=I;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(I-$))for(var O=Math.min(h,C)-1,B=Math.min(32767,I),j=Math.min(258,C);$<=B&&--R&&z!=D;){if(t[I+L]==t[I+L-$]){for(var q=0;q<j&&t[I+q]==t[I+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=I-$+U&32767,Z=N-p[N]&32767;Z>H&&(H=Z,D=N)}}}$+=(z=D)-(D=p[z])&32767}if(P){b[_++]=268435456|kn[L]<<18|xn[P];var X=31&kn[L],G=31&xn[P];x+=pn[X]+wn[G],++k[257+X],++T[G],M=I+L,++S}else b[_++]=t[I],++k[t[I]]}}for(I=Math.max(I,M);I<s;++I)b[_++]=t[I],++k[t[I]];l=Yn(t,c,u,b,k,T,x,_,E,I-E,l),u||(o.r=7&l|c[l/8|0]<<3,l-=7,o.h=w,o.p=p,o.i=I,o.w=M)}else{for(I=o.w||0;I<s+u;I+=65535){var K=I+65535;K>=s&&(c[l/8|0]=u,K=s),l=Vn(c,l+1,t.subarray(I,K))}o.i=s}return Bn(a,0,i+On(l)+r)},te=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}(),ne=function(){var t=-1;return{p:function(n){for(var e=t,i=0;i<n.length;++i)e=te[255&e^n[i]]^e>>>8;t=e},d:function(){return~t}}},ee=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}}},ie=function(t,n,e,i,r){if(!r&&(r={l:1},n.dictionary)){var o=n.dictionary.subarray(-32768),s=new hn(o.length+t.length);s.set(o),s.set(t,o.length),t=s,r.w=o.length}return Wn(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)},re=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},oe=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},se=[],ae=function(t,n,e,i){if(!se[e]){for(var r="",o={},s=t.length-1,a=0;a<s;++a)r=oe(t[a],r,o);se[e]={c:oe(t[s],r,o),e:o}}var c=re({},se[e].e);return function(t,n,e,i,r){var o=new Worker(fn[n]||(fn[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}(se[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)},ce=function(){return[hn,dn,vn,pn,wn,mn,bn,Sn,Cn,Ln,In,jn,En,Pn,Rn,$n,On,Bn,qn,Fn,$e,ve,pe]},ue=function(){return[hn,dn,vn,pn,wn,mn,kn,xn,Dn,An,Un,zn,In,Jn,Qn,En,Hn,Nn,Zn,Xn,Gn,Kn,Vn,Yn,On,Bn,Wn,ie,Ue,ve]},le=function(){return[Se,_e,Te,ne,te]},fe=function(){return[xe,Ie]},he=function(){return[Me,Te,ee]},de=function(){return[Ee]},ve=function(t){return postMessage(t,[t.buffer])},pe=function(t){return t&&{out:t.size&&new hn(t.size),dictionary:t.dictionary}},we=function(t,n,e,i,r,o){var s=ae(e,i,r,function(t,n){s.terminate(),o(t,n)});return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},me=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()}},ye=function(t,n,e,i,r,o,s){var a,c=ae(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||qn(5),a&&n.ondata(qn(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([])})},ge=function(t,n){return t[n]|t[n+1]<<8},be=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},ke=function(t,n){return be(t,n)+4294967296*be(t,n+4)},Te=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},Se=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&&Te(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]||qn(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)},Ie=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},_e=function(t){return 10+(t.filename?t.filename.length+1:0)},Me=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=ee();r.p(n.dictionary),Te(t,2,r.d())}},Ee=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&qn(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&qn(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function Ae(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var ze=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 hn(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(ie(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,n){this.ondata||qn(5),this.s.l&&qn(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new hn(-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||qn(5),this.s.l&&qn(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},t}(),De=function(){return function(t,n){ye([ue,function(){return[me,ze]}],this,Ae.call(this,t,n),function(t){var n=new ze(t.data);onmessage=me(n)},6,1)}}();function Ce(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ue],function(t){return ve(Ue(t.data[0],t.data[1]))},0,e)}function Ue(t,n){return ie(t,n||{},0,0)}var Le=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 hn(32768),this.p=new hn(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||qn(5),this.d&&qn(4),this.p.length){if(t.length){var n=new hn(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=Fn(this.p,this.s,this.o);this.ondata(Bn(e,n,this.s.b),this.d),this.o=Bn(e,this.s.b-32768),this.s.b=this.o.length,this.p=Bn(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}(),Pe=function(){return function(t,n){ye([ce,function(){return[me,Le]}],this,Ae.call(this,t,n),function(t){var n=new Le(t.data);onmessage=me(n)},7,0)}}();function Re(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ce],function(t){return ve($e(t.data[0],pe(t.data[1])))},1,e)}function $e(t,n){return Fn(t,{i:2},n&&n.out,n&&n.dictionary)}var Oe=function(){function t(t,n){this.c=ne(),this.l=0,this.v=1,ze.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,ze.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=ie(t,this.o,this.v&&_e(this.o),n&&8,this.s);this.v&&(Se(e,this.o),this.v=0),n&&(Te(e,e.length-8,this.c.d()),Te(e,e.length-4,this.l)),this.ondata(e,n)},t.prototype.flush=function(){ze.prototype.flush.call(this)},t}(),Be=function(){return function(t,n){ye([ue,le,function(){return[me,ze,Oe]}],this,Ae.call(this,t,n),function(t){var n=new Oe(t.data);onmessage=me(n)},8,1)}}();function je(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ue,le,function(){return[qe]}],function(t){return ve(qe(t.data[0],t.data[1]))},2,e)}function qe(t,n){n||(n={});var e=ne(),i=t.length;e.p(t);var r=ie(t,n,_e(n),8),o=r.length;return Se(r,n),Te(r,o-8,e.d()),Te(r,o-4,i),r}var Fe=function(){function t(t,n){this.v=1,this.r=0,Le.call(this,t,n)}return t.prototype.push=function(t,n){if(Le.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}Le.prototype.c.call(this,n),!this.s.f||this.s.l||n||(this.v=On(this.s.p)+9,this.s={i:0},this.o=new hn(0),this.push(new hn(0),n))},t}(),He=function(){return function(t,n){var e=this;ye([ce,fe,function(){return[me,Le,Fe]}],this,Ae.call(this,t,n),function(t){var n=new Fe(t.data);n.onmember=function(t){return postMessage(t)},onmessage=me(n)},9,0,function(t){return e.onmember&&e.onmember(t)})}}();function Ne(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ce,fe,function(){return[Ze]}],function(t){return ve(Ze(t.data[0],t.data[1]))},3,e)}function Ze(t,n){var e=xe(t);return e+8>t.length&&qn(6,"invalid gzip data"),Fn(t.subarray(e,-8),{i:2},n&&n.out||new hn(Ie(t)),n&&n.dictionary)}var Xe=function(){function t(t,n){this.c=ee(),this.v=1,ze.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),ze.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=ie(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(Me(e,this.o),this.v=0),n&&Te(e,e.length-4,this.c.d()),this.ondata(e,n)},t.prototype.flush=function(){ze.prototype.flush.call(this)},t}(),Ge=function(){return function(t,n){ye([ue,he,function(){return[me,ze,Xe]}],this,Ae.call(this,t,n),function(t){var n=new Xe(t.data);onmessage=me(n)},10,1)}}();function Ke(t,n){n||(n={});var e=ee();e.p(t);var i=ie(t,n,n.dictionary?6:2,4);return Me(i,n),Te(i,i.length-4,e.d()),i}var Ve=function(){function t(t,n){Le.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(Le.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(Ee(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&qn(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Le.prototype.c.call(this,n)},t}(),Ye=function(){return function(t,n){ye([ce,de,function(){return[me,Le,Ve]}],this,Ae.call(this,t,n),function(t){var n=new Ve(t.data);onmessage=me(n)},11,0)}}();function Je(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ce,de,function(){return[Qe]}],function(t){return ve(Qe(t.data[0],pe(t.data[1])))},5,e)}function Qe(t,n){return Fn(t.subarray(Ee(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}var We=function(){function t(t,n){this.o=Ae.call(this,t,n)||{},this.G=Fe,this.I=Le,this.Z=Ve}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||qn(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new hn(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}(),ti=function(){function t(t,n){We.call(this,t,n),this.queuedSize=0,this.G=He,this.I=Pe,this.Z=Ye}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,We.prototype.push.call(this,t,n)},t}(),ni=function(t,n,e,i){for(var r in t){var o=t[r],s=n+r,a=i;Array.isArray(o)&&(a=re(i,o[1]),o=o[0]),o instanceof hn?e[s]=[o,a]:(e[s+="/"]=[new hn(0),a],ni(o,s,e,i))}},ei="undefined"!=typeof TextEncoder&&new TextEncoder,ii="undefined"!=typeof TextDecoder&&new TextDecoder,ri=0;try{ii.decode(Qn,{stream:!0}),ri=1}catch(t){}var oi=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:Bn(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)}},si=function(){function t(t){this.ondata=t,ri?this.t=new TextDecoder:this.p=Qn}return t.prototype.push=function(t,n){if(this.ondata||qn(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:!0}),n),void(n&&(this.t.decode().length&&qn(8),this.t=null));this.p||qn(4);var e=new hn(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=oi(e),r=i.s,o=i.r;n?(o.length&&qn(8),this.p=null):this.p=o,this.ondata(r,n)},t}(),ai=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||qn(5),this.d&&qn(4),this.ondata(ci(t),this.d=n||!1)},t}();function ci(t,n){if(n){for(var e=new hn(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(ei)return ei.encode(t);var r=t.length,o=new hn(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 hn(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 Bn(o,0,s)}function ui(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(ii)return ii.decode(t);var r=oi(t),o=r.s;return(e=r.r).length&&qn(8),o}var li=function(t){return 1==t?3:t<6?2:9==t?1:0},fi=function(t,n){return n+30+ge(t,n+26)+ge(t,n+28)},hi=function(t,n,e){var i=ge(t,n+28),r=ui(t.subarray(n+46,n+46+i),!(2048&ge(t,n+8))),o=n+46+i,s=be(t,n+20),a=e&&4294967295==s?di(t,o):[s,be(t,n+24),be(t,n+42)],c=a[0],u=a[1],l=a[2];return[ge(t,n+10),c,u,r,o+ge(t,n+30)+ge(t,n+32),l]},di=function(t,n){for(;1!=ge(t,n);n+=4+ge(t,n+2));return[ke(t,n+12),ke(t,n+4),ke(t,n+20)]},vi=function(t){var n=0;if(t)for(var e in t){var i=t[e].length;i>65535&&qn(9),n+=i+4}return n},pi=function(t,n,e,i,r,o,s,a){var c=i.length,u=e.extra,l=a&&a.length,f=vi(u);Te(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)&&qn(10),Te(t,n,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),n+=4,-1!=o&&(Te(t,n,e.crc),Te(t,n+4,o<0?-o-2:o),Te(t,n+8,e.size)),Te(t,n+12,c),Te(t,n+14,f),n+=16,null!=s&&(Te(t,n,l),Te(t,n+6,e.attrs),Te(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;Te(t,n,+v),Te(t,n+2,w),t.set(p,n+4),n+=4+w}return l&&(t.set(a,n),n+=l),n},wi=function(t,n,e,i,r){Te(t,n,101010256),Te(t,n+8,e),Te(t,n+10,e),Te(t,n+12,i),Te(t,n+16,r)},mi=function(){function t(t){this.filename=t,this.c=ne(),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||qn(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}(),yi=function(){function t(t,n){var e=this;n||(n={}),mi.call(this,t),this.d=new ze(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=li(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){mi.prototype.push.call(this,t,n)},t}(),gi=function(){function t(t,n){var e=this;n||(n={}),mi.call(this,t),this.d=new De(n,function(t,n,i){e.ondata(t,n,i)}),this.compression=8,this.flag=li(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){mi.prototype.push.call(this,t,n)},t}(),bi=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||qn(5),2&this.d)this.ondata(qn(4+8*(1&this.d),0,1),null,!1);else{var e=ci(t.filename),i=e.length,r=t.comment,o=r&&ci(r),s=i!=t.filename.length||o&&r.length!=o.length,a=i+vi(t.extra)+30;i>65535&&this.ondata(qn(11,0,1),null,!1);var c=new hn(a);pi(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=re(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 hn(16);Te(o,0,134695760),Te(o,4,t.crc),Te(o,8,v),Te(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(qn(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+vi(c.extra)+(c.o?c.o.length:0);for(var o=new hn(e+22),s=0,a=this.u;s<a.length;s++){var c;pi(o,t,c=a[s],c.f,c.u,-c.c-2,n,c.o),t+=46+c.f.length+vi(c.extra)+(c.o?c.o.length:0),n+=c.b}wi(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}(),ki=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}(),Ti=function(){function t(){var t=this;this.i=new Le(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}(),Si=function(){function t(t,n){var e=this;n<32e4?this.i=new Le(function(t,n){e.ondata(null,t,n)}):(this.i=new Pe(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=Bn(t,0)),this.i.push(t,n)},t.compression=8,t}(),xi=function(){function t(t){this.onfile=t,this.k=[],this.o={0:ki},this.p=Qn}return t.prototype.push=function(t,n){var e=this;if(this.onfile||qn(5),this.p||qn(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 hn(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=be(c,s);if(67324752==n){o=1,a=s,d.d=null,d.c=0;var i=ge(c,s+6),r=ge(c,s+8),f=2048&i,h=8&i,v=ge(c,s+26),p=ge(c,s+28);if(u>s+30+v+p){var w=[];d.k.unshift(w),o=2;var m,y=be(c,s+18),g=be(c,s+22),b=ui(c.subarray(s+30,s+=30+v),!f);4294967295==y?(t=h?[-2]:di(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||qn(5),y){var t=e.o[r];t||k.ondata(qn(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(Qn,!0)}else k.ondata(null,Qn,!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=Qn,l<0){var v=c.subarray(0,o?a-12-(-2==l&&8)-(134695760==be(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&&qn(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),Ii="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()},_i=Object.freeze({__proto__:null,AsyncCompress:Be,AsyncDecompress:ti,AsyncDeflate:De,AsyncGunzip:He,AsyncGzip:Be,AsyncInflate:Pe,AsyncUnzipInflate:Si,AsyncUnzlib:Ye,AsyncZipDeflate:gi,AsyncZlib:Ge,Compress:Oe,DecodeUTF8:si,Decompress:We,Deflate:ze,EncodeUTF8:ai,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:Fe,Gzip:Oe,Inflate:Le,Unzip:xi,UnzipInflate:Ti,UnzipPassThrough:ki,Unzlib:Ve,Zip:bi,ZipDeflate:yi,ZipPassThrough:mi,Zlib:Xe,compress:je,compressSync:qe,decompress:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),31==t[0]&&139==t[1]&&8==t[2]?Ne(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Re(t,n,e):Je(t,n,e)},decompressSync:function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?Ze(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?$e(t,n):Qe(t,n)},deflate:Ce,deflateSync:Ue,gunzip:Ne,gunzipSync:Ze,gzip:je,gzipSync:qe,inflate:Re,inflateSync:$e,strFromU8:ui,strToU8:ci,unzip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&qn(7);var i=[],r=function(){for(var t=0;t<i.length;++t)i[t]()},o={},s=function(t,n){Ii(function(){e(t,n)})};Ii(function(){s=e});for(var a=t.length-22;101010256!=be(t,a);--a)if(!a||t.length-a>65558)return s(qn(13,0,1),null),r;var c=ge(t,a+8);if(c){var u=c,l=be(t,a+16),f=4294967295==l||65535==u;if(f){var h=be(t,a-12);(f=101075792==be(t,h))&&(u=c=be(t,h+32),l=be(t,h+48))}for(var d=n&&n.filter,v=function(n){var e=hi(t,l,f),a=e[0],u=e[1],h=e[2],v=e[3],p=e[4],w=fi(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,$e(y,{out:new hn(h)}))}catch(t){m(t,null)}else i.push(Re(y,{size:h},m))}else m(qn(14,"unknown compression type "+a,1),null);else m(null,Bn(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!=be(t,i);--i)(!i||t.length-i>65558)&&qn(13);var r=ge(t,i+8);if(!r)return{};var o=be(t,i+16),s=4294967295==o||65535==r;if(s){var a=be(t,i-12);(s=101075792==be(t,a))&&(r=be(t,a+32),o=be(t,a+48))}for(var c=n&&n.filter,u=0;u<r;++u){var l=hi(t,o,s),f=l[0],h=l[1],d=l[2],v=l[3],p=l[4],w=fi(t,l[5]);o=p,c&&!c({name:v,size:h,originalSize:d,compression:f})||(f?8==f?e[v]=$e(t.subarray(w,w+h),{out:new hn(d)}):qn(14,"unknown compression type "+f):e[v]=Bn(t,w,w+h))}return e},unzlib:Je,unzlibSync:Qe,zip:function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&qn(7);var i={};ni(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){Ii(function(){e(t,n)})};Ii(function(){h=e});var d=function(){var t=new hn(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;pi(t,a,r,r.f,r.u,o);var l=30+r.f.length+vi(r.extra),f=a+l;t.set(r.c,f),pi(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)}}wi(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=ne(),w=c.length;p.p(c);var m=ci(n),y=m.length,g=v.comment,b=g&&ci(g),k=b&&b.length,T=vi(v.extra),S=0==v.level?0:8,x=function(e,i){if(e)f(),h(e,null);else{var r=i.length;u[t]=re(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&&x(qn(11,0,1),null),S)if(w<16e4)try{x(null,Ue(c,v))}catch(t){x(t,null)}else l.push(Ce(c,v,x));else x(null,c)},p=0;p<c;++p)v(p);return f},zipSync:function(t,n){n||(n={});var e={},i=[];ni(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=ci(s)).length,h=u.comment,d=h&&ci(h),v=d&&d.length,p=vi(u.extra);f>65535&&qn(11);var w=l?Ue(c,u):c,m=w.length,y=ne();y.p(c),i.push(re(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 hn(o+22),b=r,k=o-r,T=0;T<i.length;++T){var S;pi(g,(S=i[T]).o,S,S.f,S.u,S.c.length);var x=30+S.f.length+vi(S.extra);g.set(S.c,S.o+x),pi(g,r,S,S.f,S.u,S.c.length,S.o,S.m),r+=16+x+(S.m?S.m.length:0)}return wi(g,r,i.length,k,b),g},zlib:function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&qn(7),we(t,n,[ue,he,function(){return[Ke]}],function(t){return ve(Ke(t.data[0],t.data[1]))},4,e)},zlibSync:Ke});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=ln,Object.defineProperty(t,"Bt",{value:!0})});
|