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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";var t={},n=Uint8Array,i=Uint16Array,r=Int32Array,e=new n([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]),o=new n([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]),s=new n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=function(t,n){for(var e=new i(31),o=0;o<31;++o)e[o]=n+=1<<t[o-1];var s=new r(e[30]);for(o=1;o<30;++o)for(var f=e[o];f<e[o+1];++f)s[f]=f-e[o]<<5|o;return{b:e,r:s}},u=f(e,2),a=u.b,h=u.r;a[28]=258,h[258]=28;for(var c=f(o,0),v=c.b,l=c.r,p=new i(32768),w=0;w<32768;++w){var d=(43690&w)>>1|(21845&w)<<1;p[w]=((65280&(d=(61680&(d=(52428&d)>>2|(13107&d)<<2))>>4|(3855&d)<<4))>>8|(255&d)<<8)>>1}var x=function(t,n,r){for(var e=t.length,o=0,s=new i(n);o<e;++o)t[o]&&++s[t[o]-1];var f,u=new i(n);for(o=1;o<n;++o)u[o]=u[o-1]+s[o-1]<<1;if(r){f=new i(1<<n);var a=15-n;for(o=0;o<e;++o)if(t[o])for(var h=o<<4|t[o],c=n-t[o],v=u[t[o]-1]++<<c,l=v|(1<<c)-1;v<=l;++v)f[p[v]>>a]=h}else for(f=new i(e),o=0;o<e;++o)t[o]&&(f[o]=p[u[t[o]-1]++]>>15-t[o]);return f},y=new n(288);for(w=0;w<144;++w)y[w]=8;for(w=144;w<256;++w)y[w]=9;for(w=256;w<280;++w)y[w]=7;for(w=280;w<288;++w)y[w]=8;var m=new n(32);for(w=0;w<32;++w)m[w]=5;var g=x(y,9,0),k=x(y,9,1),M=x(m,5,0),b=x(m,5,1),z=function(t){for(var n=t[0],i=1;i<t.length;++i)t[i]>n&&(n=t[i]);return n},T=function(t,n,i){var r=n/8|0;return(t[r]|t[r+1]<<8)>>(7&n)&i},D=function(t,n){var i=n/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(7&n)},E=function(t){return(t+7)/8|0},I=function(t,i,r){return(null==i||i<0)&&(i=0),(null==r||r>t.length)&&(r=t.length),new n(t.subarray(i,r))},S=["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"],F=function(t,n,i){var r=new Error(n||S[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,F),!i)throw r;return r},A=function(t,i,r,f){var u=t.length,h=f?f.length:0;if(!u||i.f&&!i.l)return r||new n(0);var c=!r,l=c||2!=i.i,p=i.i;c&&(r=new n(3*u));var w=function(t){var i=r.length;if(t>i){var e=new n(Math.max(2*i,t));e.set(r),r=e}},d=i.f||0,y=i.p||0,m=i.b||0,g=i.l,M=i.d,S=i.m,A=i.n,U=8*u;do{if(!g){d=T(t,y,1);var L=T(t,y+1,3);if(y+=3,!L){var O=t[(G=E(y)+4)-4]|t[G-3]<<8,j=G+O;if(j>u){p&&F(0);break}l&&w(m+O),r.set(t.subarray(G,j),m),i.b=m+=O,i.p=y=8*j,i.f=d;continue}if(1==L)g=k,M=b,S=9,A=5;else if(2==L){var q=T(t,y,31)+257,B=T(t,y+10,15)+4,C=q+T(t,y+5,31)+1;y+=14;for(var H=new n(C),N=new n(19),$=0;$<B;++$)N[s[$]]=T(t,y+3*$,7);y+=3*B;var R=z(N),W=(1<<R)-1,Z=x(N,R,1);for($=0;$<C;){var G,J=Z[T(t,y,W)];if(y+=15&J,(G=J>>4)<16)H[$++]=G;else{var K=0,P=0;for(16==G?(P=3+T(t,y,3),y+=2,K=H[$-1]):17==G?(P=3+T(t,y,7),y+=3):18==G&&(P=11+T(t,y,127),y+=7);P--;)H[$++]=K}}var Q=H.subarray(0,q),V=H.subarray(q);S=z(Q),A=z(V),g=x(Q,S,1),M=x(V,A,1)}else F(1);if(y>U){p&&F(0);break}}l&&w(m+131072);for(var X=(1<<S)-1,Y=(1<<A)-1,_=y;;_=y){var tt=(K=g[D(t,y)&X])>>4;if((y+=15&K)>U){p&&F(0);break}if(K||F(2),tt<256)r[m++]=tt;else{if(256==tt){_=y,g=null;break}var nt=tt-254;tt>264&&(nt=T(t,y,(1<<(et=e[$=tt-257]))-1)+a[$],y+=et);var it=M[D(t,y)&Y],rt=it>>4;if(it||F(3),y+=15&it,V=v[rt],rt>3){var et=o[rt];V+=D(t,y)&(1<<et)-1,y+=et}if(y>U){p&&F(0);break}l&&w(m+131072);var ot=m+nt;if(m<V){var st=h-V,ft=Math.min(V,ot);for(st+m<0&&F(3);m<ft;++m)r[m]=f[st+m]}for(;m<ot;++m)r[m]=r[m-V]}}i.l=g,i.p=_,i.b=m,i.f=d,g&&(d=1,i.m=S,i.d=M,i.n=A)}while(!d);return m!=r.length&&c?I(r,0,m):r.subarray(0,m)},U=function(t,n,i){var r=n/8|0;t[r]|=i<<=7&n,t[r+1]|=i>>8},L=function(t,n,i){var r=n/8|0;t[r]|=i<<=7&n,t[r+1]|=i>>8,t[r+2]|=i>>16},O=function(t,r){for(var e=[],o=0;o<t.length;++o)t[o]&&e.push({s:o,f:t[o]});var s=e.length,f=e.slice();if(!s)return{t:$,l:0};if(1==s){var u=new n(e[0].s+1);return u[e[0].s]=1,{t:u,l:1}}e.sort(function(t,n){return t.f-n.f}),e.push({s:-1,f:25001});var a=e[0],h=e[1],c=0,v=1,l=2;for(e[0]={s:-1,f:a.f+h.f,l:a,r:h};v!=s-1;)a=e[e[c].f<e[l].f?c++:l++],h=e[c!=v&&e[c].f<e[l].f?c++:l++],e[v++]={s:-1,f:a.f+h.f,l:a,r:h};var p=f[0].s;for(o=1;o<s;++o)f[o].s>p&&(p=f[o].s);var w=new i(p+1),d=j(e[v-1],w,0);if(d>r){o=0;var x=0,y=d-r,m=1<<y;for(f.sort(function(t,n){return w[n.s]-w[t.s]||t.f-n.f});o<s;++o){var g=f[o].s;if(!(w[g]>r))break;x+=m-(1<<d-w[g]),w[g]=r}for(x>>=y;x>0;){var k=f[o].s;w[k]<r?x-=1<<r-w[k]++-1:++o}for(;o>=0&&x;--o){var M=f[o].s;w[M]==r&&(--w[M],++x)}d=r}return{t:new n(w),l:d}},j=function(t,n,i){return-1==t.s?Math.max(j(t.l,n,i+1),j(t.r,n,i+1)):n[t.s]=i},q=function(t){for(var n=t.length;n&&!t[--n];);for(var r=new i(++n),e=0,o=t[0],s=1,f=function(t){r[e++]=t},u=1;u<=n;++u)if(t[u]==o&&u!=n)++s;else{if(!o&&s>2){for(;s>138;s-=138)f(32754);s>2&&(f(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(f(o),--s;s>6;s-=6)f(8304);s>2&&(f(s-3<<5|8208),s=0)}for(;s--;)f(o);s=1,o=t[u]}return{c:r.subarray(0,e),n:n}},B=function(t,n){for(var i=0,r=0;r<n.length;++r)i+=t[r]*n[r];return i},C=function(t,n,i){var r=i.length,e=E(n+2);t[e]=255&r,t[e+1]=r>>8,t[e+2]=255^t[e],t[e+3]=255^t[e+1];for(var o=0;o<r;++o)t[e+o+4]=i[o];return 8*(e+4+r)},H=function(t,n,r,f,u,a,h,c,v,l,p){U(n,p++,r),++u[256];for(var w=O(u,15),d=w.t,k=w.l,b=O(a,15),z=b.t,T=b.l,D=q(d),E=D.c,I=D.n,S=q(z),F=S.c,A=S.n,j=new i(19),H=0;H<E.length;++H)++j[31&E[H]];for(H=0;H<F.length;++H)++j[31&F[H]];for(var N=O(j,7),$=N.t,R=N.l,W=19;W>4&&!$[s[W-1]];--W);var Z,G,J,K,P=l+5<<3,Q=B(u,y)+B(a,m)+h,V=B(u,d)+B(a,z)+h+14+3*W+B(j,$)+2*j[16]+3*j[17]+7*j[18];if(v>=0&&P<=Q&&P<=V)return C(n,p,t.subarray(v,v+l));if(U(n,p,1+(V<Q)),p+=2,V<Q){Z=x(d,k,0),G=d,J=x(z,T,0),K=z;var X=x($,R,0);for(U(n,p,I-257),U(n,p+5,A-1),U(n,p+10,W-4),p+=14,H=0;H<W;++H)U(n,p+3*H,$[s[H]]);p+=3*W;for(var Y=[E,F],_=0;_<2;++_){var tt=Y[_];for(H=0;H<tt.length;++H)U(n,p,X[it=31&tt[H]]),p+=$[it],it>15&&(U(n,p,tt[H]>>5&127),p+=tt[H]>>12)}}else Z=g,G=y,J=M,K=m;for(H=0;H<c;++H){var nt=f[H];if(nt>255){var it;L(n,p,Z[257+(it=nt>>18&31)]),p+=G[it+257],it>7&&(U(n,p,nt>>23&31),p+=e[it]);var rt=31&nt;L(n,p,J[rt]),p+=K[rt],rt>3&&(L(n,p,nt>>5&8191),p+=o[rt])}else L(n,p,Z[nt]),p+=G[nt]}return L(n,p,Z[256]),p+G[256]},N=new r([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$=new n(0),R=function(t,s,f,u,a,c){var v=c.z||t.length,p=new n(u+v+5*(1+Math.ceil(v/7e3))+a),w=p.subarray(u,p.length-a),d=c.l,x=7&(c.r||0);if(s){x&&(w[0]=c.r>>3);for(var y=N[s-1],m=y>>13,g=8191&y,k=(1<<f)-1,M=c.p||new i(32768),b=c.h||new i(k+1),z=Math.ceil(f/3),T=2*z,D=function(n){return(t[n]^t[n+1]<<z^t[n+2]<<T)&k},S=new r(25e3),F=new i(288),A=new i(32),U=0,L=0,O=c.i||0,j=0,q=c.w||0,B=0;O+2<v;++O){var $=D(O),R=32767&O,W=b[$];if(M[R]=W,b[$]=R,q<=O){var Z=v-O;if((U>7e3||j>24576)&&(Z>423||!d)){x=H(t,w,0,S,F,A,L,j,B,O-B,x),j=U=L=0,B=O;for(var G=0;G<286;++G)F[G]=0;for(G=0;G<30;++G)A[G]=0}var J=2,K=0,P=g,Q=R-W&32767;if(Z>2&&$==D(O-Q))for(var V=Math.min(m,Z)-1,X=Math.min(32767,O),Y=Math.min(258,Z);Q<=X&&--P&&R!=W;){if(t[O+J]==t[O+J-Q]){for(var _=0;_<Y&&t[O+_]==t[O+_-Q];++_);if(_>J){if(J=_,K=Q,_>V)break;var tt=Math.min(Q,_-2),nt=0;for(G=0;G<tt;++G){var it=O-Q+G&32767,rt=it-M[it]&32767;rt>nt&&(nt=rt,W=it)}}}Q+=(R=W)-(W=M[R])&32767}if(K){S[j++]=268435456|h[J]<<18|l[K];var et=31&h[J],ot=31&l[K];L+=e[et]+o[ot],++F[257+et],++A[ot],q=O+J,++U}else S[j++]=t[O],++F[t[O]]}}for(O=Math.max(O,q);O<v;++O)S[j++]=t[O],++F[t[O]];x=H(t,w,d,S,F,A,L,j,B,O-B,x),d||(c.r=7&x|w[x/8|0]<<3,x-=7,c.h=b,c.p=M,c.i=O,c.w=q)}else{for(O=c.w||0;O<v+d;O+=65535){var st=O+65535;st>=v&&(w[x/8|0]=d,st=v),x=C(w,x+1,t.subarray(O,st))}c.i=v}return I(p,0,u+E(x)+a)},W=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var i=n,r=9;--r;)i=(1&i&&-306674912)^i>>>1;t[n]=i}return t}(),Z=function(){var t=-1;return{p:function(n){for(var i=t,r=0;r<n.length;++r)i=W[255&i^n[r]]^i>>>8;t=i},d:function(){return~t}}},G=function(){var t=1,n=0;return{p:function(i){for(var r=t,e=n,o=0|i.length,s=0;s!=o;){for(var f=Math.min(s+2655,o);s<f;++s)e+=r+=i[s];r=(65535&r)+15*(r>>16),e=(65535&e)+15*(e>>16)}t=r,n=e},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},J=function(t,i,r,e,o){if(!o&&(o={l:1},i.dictionary)){var s=i.dictionary.subarray(-32768),f=new n(s.length+t.length);f.set(s),f.set(t,s.length),t=f,o.w=s.length}return R(t,null==i.level?6:i.level,null==i.mem?o.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+i.mem,r,e,o)},K=function(t,n){var i={};for(var r in t)i[r]=t[r];for(var r in n)i[r]=n[r];return i},P=function(t,n,i){for(var r=t(),e=t.toString(),o=e.slice(e.indexOf("[")+1,e.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<r.length;++s){var f=r[s],u=o[s];if("function"==typeof f){n+=";"+u+"=";var a=f.toString();if(f.prototype)if(-1!=a.indexOf("[native code]")){var h=a.indexOf(" ",8)+1;n+=a.slice(h,a.indexOf("(",h))}else for(var c in n+=a,f.prototype)n+=";"+u+".prototype."+c+"="+f.prototype[c].toString();else n+=a}else i[u]=f}return n},Q=[],V=function(n,i,r,e){if(!Q[r]){for(var o="",s={},f=n.length-1,u=0;u<f;++u)o=P(n[u],o,s);Q[r]={c:P(n[f],o,s),e:s}}var a=K({},Q[r].e);return function(n,i,r,e,o){var s=new Worker(t[i]||(t[i]=URL.createObjectURL(new Blob([n+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return s.onmessage=function(t){var n=t.data,i=n.$e$;if(i){var r=new Error(i[0]);r.code=i[1],r.stack=i[2],o(r,null)}else o(null,n)},s.postMessage(r,e),s}(Q[r].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+i.toString()+"}",r,a,function(t){var n=[];for(var i in t)t[i].buffer&&n.push((t[i]=new t[i].constructor(t[i])).buffer);return n}(a),e)},X=function(){return[n,i,r,e,o,s,a,v,k,b,p,S,x,z,T,D,E,I,F,A,Dt,rt,et]},Y=function(){return[n,i,r,e,o,s,h,l,g,y,M,m,p,N,$,x,U,L,O,j,q,B,C,H,E,I,R,J,Mt,rt]},_=function(){return[vt,wt,ct,Z,W]},tt=function(){return[lt,pt]},nt=function(){return[dt,ct,G]},it=function(){return[xt]},rt=function(t){return postMessage(t,[t.buffer])},et=function(t){return t&&{out:t.size&&new n(t.size),dictionary:t.dictionary}},ot=function(t,n,i,r,e,o){var s=V(i,r,e,function(t,n){s.terminate(),o(t,n)});return s.postMessage([t,n],n.consume?[t.buffer]:[]),function(){s.terminate()}},st=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()}},ft=function(t,n,i,r,e,o,s){var f,u=V(t,r,e,function(t,i){t?(u.terminate(),n.ondata.call(n,t)):Array.isArray(i)?1==i.length?(n.queuedSize-=i[0],n.ondrain&&n.ondrain(i[0])):(i[1]&&u.terminate(),n.ondata.call(n,t,i[0],i[1])):s(i)});u.postMessage(i),n.queuedSize=0,n.push=function(t,i){n.ondata||F(5),f&&n.ondata(F(4,0,1),null,!!i),n.queuedSize+=t.length,u.postMessage([t,f=i],[t.buffer])},n.terminate=function(){u.terminate()},o&&(n.flush=function(){u.postMessage([])})},ut=function(t,n){return t[n]|t[n+1]<<8},at=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},ht=function(t,n){return at(t,n)+4294967296*at(t,n+4)},ct=function(t,n,i){for(;i;++n)t[n]=i,i>>>=8},vt=function(t,n){var i=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&&ct(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),i){t[3]=8;for(var r=0;r<=i.length;++r)t[r+10]=i.charCodeAt(r)}},lt=function(t){31==t[0]&&139==t[1]&&8==t[2]||F(6,"invalid gzip data");var n=t[3],i=10;4&n&&(i+=2+(t[10]|t[11]<<8));for(var r=(n>>3&1)+(n>>4&1);r>0;r-=!t[i++]);return i+(2&n)},pt=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},wt=function(t){return 10+(t.filename?t.filename.length+1:0)},dt=function(t,n){var i=n.level,r=0==i?0:i<6?1:9==i?3:2;if(t[0]=120,t[1]=r<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var e=G();e.p(n.dictionary),ct(t,2,e.d())}},xt=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&F(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&F(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function yt(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var mt=function(){function t(t,i){if("function"==typeof t&&(i=t,t={}),this.ondata=i,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new n(98304),this.o.dictionary){var r=this.o.dictionary.subarray(-32768);this.b.set(r,32768-r.length),this.s.i=32768-r.length}}return t.prototype.p=function(t,n){this.ondata(J(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,i){this.ondata||F(5),this.s.l&&F(4);var r=t.length+this.s.z;if(r>this.b.length){if(r>2*this.b.length-32768){var e=new n(-32768&r);e.set(this.b.subarray(0,this.s.z)),this.b=e}var o=this.b.length-this.s.z;this.b.set(t.subarray(0,o),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(o),32768),this.s.z=t.length-o+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&i,(this.s.z>this.s.w+8191||i)&&(this.p(this.b,i||!1),this.s.w=this.s.i,this.s.i-=2)},t.prototype.flush=function(){this.ondata||F(5),this.s.l&&F(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},t}(),gt=function(){return function(t,n){ft([Y,function(){return[st,mt]}],this,yt.call(this,t,n),function(t){var n=new mt(t.data);onmessage=st(n)},6,1)}}();function kt(t,n,i){return i||(i=n,n={}),"function"!=typeof i&&F(7),ot(t,n,[Y],function(t){return rt(Mt(t.data[0],t.data[1]))},0,i)}function Mt(t,n){return J(t,n||{},0,0)}var bt=function(){function t(t,i){"function"==typeof t&&(i=t,t={}),this.ondata=i;var r=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new n(32768),this.p=new n(0),r&&this.o.set(r)}return t.prototype.e=function(t){if(this.ondata||F(5),this.d&&F(4),this.p.length){if(t.length){var i=new n(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length),this.p=i}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||!1);var n=this.s.b,i=A(this.p,this.s,this.o);this.ondata(I(i,n,this.s.b),this.d),this.o=I(i,this.s.b-32768),this.s.b=this.o.length,this.p=I(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}(),zt=function(){return function(t,n){ft([X,function(){return[st,bt]}],this,yt.call(this,t,n),function(t){var n=new bt(t.data);onmessage=st(n)},7,0)}}();function Tt(t,n,i){return i||(i=n,n={}),"function"!=typeof i&&F(7),ot(t,n,[X],function(t){return rt(Dt(t.data[0],et(t.data[1])))},1,i)}function Dt(t,n){return A(t,{i:2},n&&n.out,n&&n.dictionary)}var Et=function(){function t(t,n){this.c=Z(),this.l=0,this.v=1,mt.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,mt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var i=J(t,this.o,this.v&&wt(this.o),n&&8,this.s);this.v&&(vt(i,this.o),this.v=0),n&&(ct(i,i.length-8,this.c.d()),ct(i,i.length-4,this.l)),this.ondata(i,n)},t.prototype.flush=function(){mt.prototype.flush.call(this)},t}(),It=function(){return function(t,n){ft([Y,_,function(){return[st,mt,Et]}],this,yt.call(this,t,n),function(t){var n=new Et(t.data);onmessage=st(n)},8,1)}}();function St(t,n,i){return i||(i=n,n={}),"function"!=typeof i&&F(7),ot(t,n,[Y,_,function(){return[Ft]}],function(t){return rt(Ft(t.data[0],t.data[1]))},2,i)}function Ft(t,n){n||(n={});var i=Z(),r=t.length;i.p(t);var e=J(t,n,wt(n),8),o=e.length;return vt(e,n),ct(e,o-8,i.d()),ct(e,o-4,r),e}var At=function(){function t(t,n){this.v=1,this.r=0,bt.call(this,t,n)}return t.prototype.push=function(t,i){if(bt.prototype.e.call(this,t),this.r+=t.length,this.v){var r=this.p.subarray(this.v-1),e=r.length>3?lt(r):4;if(e>r.length){if(!i)return}else this.v>1&&this.onmember&&this.onmember(this.r-r.length);this.p=r.subarray(e),this.v=0}bt.prototype.c.call(this,i),!this.s.f||this.s.l||i||(this.v=E(this.s.p)+9,this.s={i:0},this.o=new n(0),this.push(new n(0),i))},t}(),Ut=function(){return function(t,n){var i=this;ft([X,tt,function(){return[st,bt,At]}],this,yt.call(this,t,n),function(t){var n=new At(t.data);n.onmember=function(t){return postMessage(t)},onmessage=st(n)},9,0,function(t){return i.onmember&&i.onmember(t)})}}();function Lt(t,n,i){return i||(i=n,n={}),"function"!=typeof i&&F(7),ot(t,n,[X,tt,function(){return[Ot]}],function(t){return rt(Ot(t.data[0],t.data[1]))},3,i)}function Ot(t,i){var r=lt(t);return r+8>t.length&&F(6,"invalid gzip data"),A(t.subarray(r,-8),{i:2},i&&i.out||new n(pt(t)),i&&i.dictionary)}var jt=function(){function t(t,n){this.c=G(),this.v=1,mt.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),mt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var i=J(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(dt(i,this.o),this.v=0),n&&ct(i,i.length-4,this.c.d()),this.ondata(i,n)},t.prototype.flush=function(){mt.prototype.flush.call(this)},t}(),qt=function(){return function(t,n){ft([Y,nt,function(){return[st,mt,jt]}],this,yt.call(this,t,n),function(t){var n=new jt(t.data);onmessage=st(n)},10,1)}}();function Bt(t,n){n||(n={});var i=G();i.p(t);var r=J(t,n,n.dictionary?6:2,4);return dt(r,n),ct(r,r.length-4,i.d()),r}var Ct=function(){function t(t,n){bt.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(bt.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(xt(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&F(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),bt.prototype.c.call(this,n)},t}(),Ht=function(){return function(t,n){ft([X,it,function(){return[st,bt,Ct]}],this,yt.call(this,t,n),function(t){var n=new Ct(t.data);onmessage=st(n)},11,0)}}();function Nt(t,n,i){return i||(i=n,n={}),"function"!=typeof i&&F(7),ot(t,n,[X,it,function(){return[$t]}],function(t){return rt($t(t.data[0],et(t.data[1])))},5,i)}function $t(t,n){return A(t.subarray(xt(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}var Rt=function(){function t(t,n){this.o=yt.call(this,t,n)||{},this.G=At,this.I=bt,this.Z=Ct}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,i){t.ondata(n,i)}},t.prototype.push=function(t,i){if(this.ondata||F(5),this.s)this.s.push(t,i);else{if(this.p&&this.p.length){var r=new n(this.p.length+t.length);r.set(this.p),r.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,i),this.p=null)}},t}(),Wt=function(){function t(t,n){Rt.call(this,t,n),this.queuedSize=0,this.G=Ut,this.I=zt,this.Z=Ht}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,i,r){t.ondata(n,i,r)},this.s.ondrain=function(n){t.queuedSize-=n,t.ondrain&&t.ondrain(n)}},t.prototype.push=function(t,n){this.queuedSize+=t.length,Rt.prototype.push.call(this,t,n)},t}(),Zt=function(t,i,r,e){for(var o in t){var s=t[o],f=i+o,u=e;Array.isArray(s)&&(u=K(e,s[1]),s=s[0]),s instanceof n?r[f]=[s,u]:(r[f+="/"]=[new n(0),u],Zt(s,f,r,e))}},Gt="undefined"!=typeof TextEncoder&&new TextEncoder,Jt="undefined"!=typeof TextDecoder&&new TextDecoder,Kt=0;try{Jt.decode($,{stream:!0}),Kt=1}catch(t){}var Pt=function(t){for(var n="",i=0;;){var r=t[i++],e=(r>127)+(r>223)+(r>239);if(i+e>t.length)return{s:n,r:I(t,i-1)};e?3==e?(r=((15&r)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536,n+=String.fromCharCode(55296|r>>10,56320|1023&r)):n+=String.fromCharCode(1&e?(31&r)<<6|63&t[i++]:(15&r)<<12|(63&t[i++])<<6|63&t[i++]):n+=String.fromCharCode(r)}},Qt=function(){function t(t){this.ondata=t,Kt?this.t=new TextDecoder:this.p=$}return t.prototype.push=function(t,i){if(this.ondata||F(5),i=!!i,this.t)return this.ondata(this.t.decode(t,{stream:!0}),i),void(i&&(this.t.decode().length&&F(8),this.t=null));this.p||F(4);var r=new n(this.p.length+t.length);r.set(this.p),r.set(t,this.p.length);var e=Pt(r),o=e.s,s=e.r;i?(s.length&&F(8),this.p=null):this.p=s,this.ondata(o,i)},t}(),Vt=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||F(5),this.d&&F(4),this.ondata(Xt(t),this.d=n||!1)},t}();function Xt(t,i){if(i){for(var r=new n(t.length),e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}if(Gt)return Gt.encode(t);var o=t.length,s=new n(t.length+(t.length>>1)),f=0,u=function(t){s[f++]=t};for(e=0;e<o;++e){if(f+5>s.length){var a=new n(f+8+(o-e<<1));a.set(s),s=a}var h=t.charCodeAt(e);h<128||i?u(h):h<2048?(u(192|h>>6),u(128|63&h)):h>55295&&h<57344?(u(240|(h=65536+(1047552&h)|1023&t.charCodeAt(++e))>>18),u(128|h>>12&63),u(128|h>>6&63),u(128|63&h)):(u(224|h>>12),u(128|h>>6&63),u(128|63&h))}return I(s,0,f)}function Yt(t,n){if(n){for(var i="",r=0;r<t.length;r+=16384)i+=String.fromCharCode.apply(null,t.subarray(r,r+16384));return i}if(Jt)return Jt.decode(t);var e=Pt(t),o=e.s;return(i=e.r).length&&F(8),o}var _t=function(t){return 1==t?3:t<6?2:9==t?1:0},tn=function(t,n){return n+30+ut(t,n+26)+ut(t,n+28)},nn=function(t,n,i){var r=ut(t,n+28),e=Yt(t.subarray(n+46,n+46+r),!(2048&ut(t,n+8))),o=n+46+r,s=at(t,n+20),f=i&&4294967295==s?rn(t,o):[s,at(t,n+24),at(t,n+42)],u=f[0],a=f[1],h=f[2];return[ut(t,n+10),u,a,e,o+ut(t,n+30)+ut(t,n+32),h]},rn=function(t,n){for(;1!=ut(t,n);n+=4+ut(t,n+2));return[ht(t,n+12),ht(t,n+4),ht(t,n+20)]},en=function(t){var n=0;if(t)for(var i in t){var r=t[i].length;r>65535&&F(9),n+=r+4}return n},on=function(t,n,i,r,e,o,s,f){var u=r.length,a=i.extra,h=f&&f.length,c=en(a);ct(t,n,null!=s?33639248:67324752),n+=4,null!=s&&(t[n++]=20,t[n++]=i.os),t[n]=20,n+=2,t[n++]=i.flag<<1|(o<0&&8),t[n++]=e&&8,t[n++]=255&i.compression,t[n++]=i.compression>>8;var v=new Date(null==i.mtime?Date.now():i.mtime),l=v.getFullYear()-1980;if((l<0||l>119)&&F(10),ct(t,n,l<<25|v.getMonth()+1<<21|v.getDate()<<16|v.getHours()<<11|v.getMinutes()<<5|v.getSeconds()>>1),n+=4,-1!=o&&(ct(t,n,i.crc),ct(t,n+4,o<0?-o-2:o),ct(t,n+8,i.size)),ct(t,n+12,u),ct(t,n+14,c),n+=16,null!=s&&(ct(t,n,h),ct(t,n+6,i.attrs),ct(t,n+10,s),n+=14),t.set(r,n),n+=u,c)for(var p in a){var w=a[p],d=w.length;ct(t,n,+p),ct(t,n+2,d),t.set(w,n+4),n+=4+d}return h&&(t.set(f,n),n+=h),n},sn=function(t,n,i,r,e){ct(t,n,101010256),ct(t,n+8,i),ct(t,n+10,i),ct(t,n+12,r),ct(t,n+16,e)},fn=function(){function t(t){this.filename=t,this.c=Z(),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||F(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}(),un=function(){function t(t,n){var i=this;n||(n={}),fn.call(this,t),this.d=new mt(n,function(t,n){i.ondata(null,t,n)}),this.compression=8,this.flag=_t(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){fn.prototype.push.call(this,t,n)},t}(),an=function(){function t(t,n){var i=this;n||(n={}),fn.call(this,t),this.d=new gt(n,function(t,n,r){i.ondata(t,n,r)}),this.compression=8,this.flag=_t(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){fn.prototype.push.call(this,t,n)},t}(),hn=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var i=this;if(this.ondata||F(5),2&this.d)this.ondata(F(4+8*(1&this.d),0,1),null,!1);else{var r=Xt(t.filename),e=r.length,o=t.comment,s=o&&Xt(o),f=e!=t.filename.length||s&&o.length!=s.length,u=e+en(t.extra)+30;e>65535&&this.ondata(F(11,0,1),null,!1);var a=new n(u);on(a,0,t,r,f,-1);var h=[a],c=function(){for(var t=0,n=h;t<n.length;t++)i.ondata(null,n[t],!1);h=[]},v=this.d;this.d=0;var l=this.u.length,p=K(t,{f:r,u:f,o:s,t:function(){t.terminate&&t.terminate()},r:function(){if(c(),v){var t=i.u[l+1];t?t.r():i.d=1}v=1}}),w=0;t.ondata=function(r,e,o){if(r)i.ondata(r,e,o),i.terminate();else if(w+=e.length,h.push(e),o){var s=new n(16);ct(s,0,134695760),ct(s,4,t.crc),ct(s,8,w),ct(s,12,t.size),h.push(s),p.c=w,p.b=u+w+16,p.crc=t.crc,p.size=t.size,v&&p.r(),v=1}else v&&c()},this.u.push(p)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata(F(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,i=0,r=0,e=0,o=this.u;e<o.length;e++)r+=46+(a=o[e]).f.length+en(a.extra)+(a.o?a.o.length:0);for(var s=new n(r+22),f=0,u=this.u;f<u.length;f++){var a;on(s,t,a=u[f],a.f,a.u,-a.c-2,i,a.o),t+=46+a.f.length+en(a.extra)+(a.o?a.o.length:0),i+=a.b}sn(s,t,this.u.length,r,i),this.ondata(null,s,!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}(),cn=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}(),vn=function(){function t(){var t=this;this.i=new bt(function(n,i){t.ondata(null,n,i)})}return t.prototype.push=function(t,n){try{this.i.push(t,n)}catch(t){this.ondata(t,null,n)}},t.compression=8,t}(),ln=function(){function t(t,n){var i=this;n<32e4?this.i=new bt(function(t,n){i.ondata(null,t,n)}):(this.i=new zt(function(t,n,r){i.ondata(t,n,r)}),this.terminate=this.i.terminate)}return t.prototype.push=function(t,n){this.i.terminate&&(t=I(t,0)),this.i.push(t,n)},t.compression=8,t}(),pn=function(){function t(t){this.onfile=t,this.k=[],this.o={0:cn},this.p=$}return t.prototype.push=function(t,i){var r=this;if(this.onfile||F(5),this.p||F(4),this.c>0){var e=Math.min(this.c,t.length),o=t.subarray(0,e);if(this.c-=e,this.d?this.d.push(o,!this.c):this.k[0].push(o),(t=t.subarray(e)).length)return this.push(t,i)}else{var s=0,f=0,u=void 0,a=void 0;this.p.length?t.length?((a=new n(this.p.length+t.length)).set(this.p),a.set(t,this.p.length)):a=this.p:a=t;for(var h=a.length,c=this.c,v=c&&this.d,l=function(){var t,n=at(a,f);if(67324752==n){s=1,u=f,p.d=null,p.c=0;var i=ut(a,f+6),e=ut(a,f+8),o=2048&i,v=8&i,l=ut(a,f+26),w=ut(a,f+28);if(h>f+30+l+w){var d=[];p.k.unshift(d),s=2;var x,y=at(a,f+18),m=at(a,f+22),g=Yt(a.subarray(f+30,f+=30+l),!o);4294967295==y?(t=v?[-2]:rn(a,f),y=t[0],m=t[1]):v&&(y=-1),f+=w,p.c=y;var k={name:g,compression:e,start:function(){if(k.ondata||F(5),y){var t=r.o[e];t||k.ondata(F(14,"unknown compression type "+e,1),null,!1),(x=y<0?new t(g):new t(g,y,m)).ondata=function(t,n,i){k.ondata(t,n,i)};for(var n=0,i=d;n<i.length;n++)x.push(i[n],!1);r.k[0]==d&&r.c?r.d=x:x.push($,!0)}else k.ondata(null,$,!0)},terminate:function(){x&&x.terminate&&x.terminate()}};y>=0&&(k.size=y,k.originalSize=m),p.onfile(k)}return"break"}if(c){if(134695760==n)return u=f+=12+(-2==c&&8),s=3,p.c=0,"break";if(33639248==n)return u=f-=4,s=3,p.c=0,"break"}},p=this;f<h-4&&"break"!==l();++f);if(this.p=$,c<0){var w=a.subarray(0,s?u-12-(-2==c&&8)-(134695760==at(a,u-16)&&4):f);v?v.push(w,!!s):this.k[+(2==s)].push(w)}if(2&s)return this.push(a.subarray(f),i);this.p=a.subarray(f)}i&&(this.c&&F(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}(),wn="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()};exports.AsyncCompress=It,exports.AsyncDecompress=Wt,exports.AsyncDeflate=gt,exports.AsyncGunzip=Ut,exports.AsyncGzip=It,exports.AsyncInflate=zt,exports.AsyncUnzipInflate=ln,exports.AsyncUnzlib=Ht,exports.AsyncZipDeflate=an,exports.AsyncZlib=qt,exports.Compress=Et,exports.DecodeUTF8=Qt,exports.Decompress=Rt,exports.Deflate=mt,exports.EncodeUTF8=Vt,exports.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},exports.Gunzip=At,exports.Gzip=Et,exports.Inflate=bt,exports.Unzip=pn,exports.UnzipInflate=vn,exports.UnzipPassThrough=cn,exports.Unzlib=Ct,exports.Zip=hn,exports.ZipDeflate=un,exports.ZipPassThrough=fn,exports.Zlib=jt,exports.compress=St,exports.compressSync=Ft,exports.decompress=function(t,n,i){return i||(i=n,n={}),"function"!=typeof i&&F(7),31==t[0]&&139==t[1]&&8==t[2]?Lt(t,n,i):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Tt(t,n,i):Nt(t,n,i)},exports.decompressSync=function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?Ot(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Dt(t,n):$t(t,n)},exports.deflate=kt,exports.deflateSync=Mt,exports.gunzip=Lt,exports.gunzipSync=Ot,exports.gzip=St,exports.gzipSync=Ft,exports.inflate=Tt,exports.inflateSync=Dt,exports.strFromU8=Yt,exports.strToU8=Xt,exports.unzip=function(t,i,r){r||(r=i,i={}),"function"!=typeof r&&F(7);var e=[],o=function(){for(var t=0;t<e.length;++t)e[t]()},s={},f=function(t,n){wn(function(){r(t,n)})};wn(function(){f=r});for(var u=t.length-22;101010256!=at(t,u);--u)if(!u||t.length-u>65558)return f(F(13,0,1),null),o;var a=ut(t,u+8);if(a){var h=a,c=at(t,u+16),v=4294967295==c||65535==h;if(v){var l=at(t,u-12);(v=101075792==at(t,l))&&(h=a=at(t,l+32),c=at(t,l+48))}for(var p=i&&i.filter,w=function(i){var r=nn(t,c,v),u=r[0],h=r[1],l=r[2],w=r[3],d=r[4],x=tn(t,r[5]);c=d;var y=function(t,n){t?(o(),f(t,null)):(n&&(s[w]=n),--a||f(null,s))};if(!p||p({name:w,size:h,originalSize:l,compression:u}))if(u)if(8==u){var m=t.subarray(x,x+h);if(l<524288||h>.8*l)try{y(null,Dt(m,{out:new n(l)}))}catch(t){y(t,null)}else e.push(Tt(m,{size:l},y))}else y(F(14,"unknown compression type "+u,1),null);else y(null,I(t,x,x+h));else y(null,null)},d=0;d<h;++d)w()}else f(null,{});return o},exports.unzipSync=function(t,i){for(var r={},e=t.length-22;101010256!=at(t,e);--e)(!e||t.length-e>65558)&&F(13);var o=ut(t,e+8);if(!o)return{};var s=at(t,e+16),f=4294967295==s||65535==o;if(f){var u=at(t,e-12);(f=101075792==at(t,u))&&(o=at(t,u+32),s=at(t,u+48))}for(var a=i&&i.filter,h=0;h<o;++h){var c=nn(t,s,f),v=c[0],l=c[1],p=c[2],w=c[3],d=c[4],x=tn(t,c[5]);s=d,a&&!a({name:w,size:l,originalSize:p,compression:v})||(v?8==v?r[w]=Dt(t.subarray(x,x+l),{out:new n(p)}):F(14,"unknown compression type "+v):r[w]=I(t,x,x+l))}return r},exports.unzlib=Nt,exports.unzlibSync=$t,exports.zip=function(t,i,r){r||(r=i,i={}),"function"!=typeof r&&F(7);var e={};Zt(t,"",e,i);var o=Object.keys(e),s=o.length,f=0,u=0,a=s,h=new Array(s),c=[],v=function(){for(var t=0;t<c.length;++t)c[t]()},l=function(t,n){wn(function(){r(t,n)})};wn(function(){l=r});var p=function(){var t=new n(u+22),i=f,r=u-f;u=0;for(var e=0;e<a;++e){var o=h[e];try{var s=o.c.length;on(t,u,o,o.f,o.u,s);var c=30+o.f.length+en(o.extra),v=u+c;t.set(o.c,v),on(t,f,o,o.f,o.u,s,u,o.m),f+=16+c+(o.m?o.m.length:0),u=v+s}catch(t){return l(t,null)}}sn(t,f,h.length,r,i),l(null,t)};s||p();for(var w=function(t){var n=o[t],i=e[n],r=i[0],a=i[1],w=Z(),d=r.length;w.p(r);var x=Xt(n),y=x.length,m=a.comment,g=m&&Xt(m),k=g&&g.length,M=en(a.extra),b=0==a.level?0:8,z=function(i,r){if(i)v(),l(i,null);else{var e=r.length;h[t]=K(a,{size:d,crc:w.d(),c:r,f:x,m:g,u:y!=n.length||g&&m.length!=k,compression:b}),f+=30+y+M+e,u+=76+2*(y+M)+(k||0)+e,--s||p()}};if(y>65535&&z(F(11,0,1),null),b)if(d<16e4)try{z(null,Mt(r,a))}catch(t){z(t,null)}else c.push(kt(r,a,z));else z(null,r)},d=0;d<a;++d)w(d);return v},exports.zipSync=function(t,i){i||(i={});var r={},e=[];Zt(t,"",r,i);var o=0,s=0;for(var f in r){var u=r[f],a=u[0],h=u[1],c=0==h.level?0:8,v=(z=Xt(f)).length,l=h.comment,p=l&&Xt(l),w=p&&p.length,d=en(h.extra);v>65535&&F(11);var x=c?Mt(a,h):a,y=x.length,m=Z();m.p(a),e.push(K(h,{size:a.length,crc:m.d(),c:x,f:z,m:p,u:v!=f.length||p&&l.length!=w,o:o,compression:c})),o+=30+v+d+y,s+=76+2*(v+d)+(w||0)+y}for(var g=new n(s+22),k=o,M=s-o,b=0;b<e.length;++b){var z;on(g,(z=e[b]).o,z,z.f,z.u,z.c.length);var T=30+z.f.length+en(z.extra);g.set(z.c,z.o+T),on(g,o,z,z.f,z.u,z.c.length,z.o,z.m),o+=16+T+(z.m?z.m.length:0)}return sn(g,o,e.length,M,k),g},exports.zlib=function(t,n,i){return i||(i=n,n={}),"function"!=typeof i&&F(7),ot(t,n,[Y,nt,function(){return[Bt]}],function(t){return rt(Bt(t.data[0],t.data[1]))},4,i)},exports.zlibSync=Bt;
@@ -0,0 +1 @@
1
+ var n={},t=Uint8Array,i=Uint16Array,r=Int32Array,e=new t([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]),f=new t([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]),s=new t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=function(n,t){for(var e=new i(31),f=0;f<31;++f)e[f]=t+=1<<n[f-1];var s=new r(e[30]);for(f=1;f<30;++f)for(var u=e[f];u<e[f+1];++u)s[u]=u-e[f]<<5|f;return{b:e,r:s}},o=u(e,2),a=o.b,h=o.r;a[28]=258,h[258]=28;for(var c=u(f,0),v=c.b,l=c.r,w=new i(32768),d=0;d<32768;++d){var p=(43690&d)>>1|(21845&d)<<1;w[d]=((65280&(p=(61680&(p=(52428&p)>>2|(13107&p)<<2))>>4|(3855&p)<<4))>>8|(255&p)<<8)>>1}var y=function(n,t,r){for(var e=n.length,f=0,s=new i(t);f<e;++f)n[f]&&++s[n[f]-1];var u,o=new i(t);for(f=1;f<t;++f)o[f]=o[f-1]+s[f-1]<<1;if(r){u=new i(1<<t);var a=15-t;for(f=0;f<e;++f)if(n[f])for(var h=f<<4|n[f],c=t-n[f],v=o[n[f]-1]++<<c,l=v|(1<<c)-1;v<=l;++v)u[w[v]>>a]=h}else for(u=new i(e),f=0;f<e;++f)n[f]&&(u[f]=w[o[n[f]-1]++]>>15-n[f]);return u},m=new t(288);for(d=0;d<144;++d)m[d]=8;for(d=144;d<256;++d)m[d]=9;for(d=256;d<280;++d)m[d]=7;for(d=280;d<288;++d)m[d]=8;var g=new t(32);for(d=0;d<32;++d)g[d]=5;var k=y(m,9,0),M=y(m,9,1),b=y(g,5,0),z=y(g,5,1),x=function(n){for(var t=n[0],i=1;i<n.length;++i)n[i]>t&&(t=n[i]);return t},T=function(n,t,i){var r=t/8|0;return(n[r]|n[r+1]<<8)>>(7&t)&i},D=function(n,t){var i=t/8|0;return(n[i]|n[i+1]<<8|n[i+2]<<16)>>(7&t)},E=function(n){return(n+7)/8|0},S=function(n,i,r){return(null==i||i<0)&&(i=0),(null==r||r>n.length)&&(r=n.length),new t(n.subarray(i,r))},I={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},A=["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"],F=function(n,t,i){var r=new Error(t||A[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,F),!i)throw r;return r},U=function(n,i,r,u){var o=n.length,h=u?u.length:0;if(!o||i.f&&!i.l)return r||new t(0);var c=!r,l=c||2!=i.i,w=i.i;c&&(r=new t(3*o));var d=function(n){var i=r.length;if(n>i){var e=new t(Math.max(2*i,n));e.set(r),r=e}},p=i.f||0,m=i.p||0,g=i.b||0,k=i.l,b=i.d,I=i.m,A=i.n,U=8*o;do{if(!k){p=T(n,m,1);var L=T(n,m+1,3);if(m+=3,!L){var C=n[(G=E(m)+4)-4]|n[G-3]<<8,O=G+C;if(O>o){w&&F(0);break}l&&d(g+C),r.set(n.subarray(G,O),g),i.b=g+=C,i.p=m=8*O,i.f=p;continue}if(1==L)k=M,b=z,I=9,A=5;else if(2==L){var j=T(n,m,31)+257,q=T(n,m+10,15)+4,B=j+T(n,m+5,31)+1;m+=14;for(var H=new t(B),N=new t(19),$=0;$<q;++$)N[s[$]]=T(n,m+3*$,7);m+=3*q;var R=x(N),W=(1<<R)-1,Z=y(N,R,1);for($=0;$<B;){var G,J=Z[T(n,m,W)];if(m+=15&J,(G=J>>4)<16)H[$++]=G;else{var K=0,P=0;for(16==G?(P=3+T(n,m,3),m+=2,K=H[$-1]):17==G?(P=3+T(n,m,7),m+=3):18==G&&(P=11+T(n,m,127),m+=7);P--;)H[$++]=K}}var Q=H.subarray(0,j),V=H.subarray(j);I=x(Q),A=x(V),k=y(Q,I,1),b=y(V,A,1)}else F(1);if(m>U){w&&F(0);break}}l&&d(g+131072);for(var X=(1<<I)-1,Y=(1<<A)-1,_=m;;_=m){var nn=(K=k[D(n,m)&X])>>4;if((m+=15&K)>U){w&&F(0);break}if(K||F(2),nn<256)r[g++]=nn;else{if(256==nn){_=m,k=null;break}var tn=nn-254;nn>264&&(tn=T(n,m,(1<<(fn=e[$=nn-257]))-1)+a[$],m+=fn);var rn=b[D(n,m)&Y],en=rn>>4;if(rn||F(3),m+=15&rn,V=v[en],en>3){var fn=f[en];V+=D(n,m)&(1<<fn)-1,m+=fn}if(m>U){w&&F(0);break}l&&d(g+131072);var sn=g+tn;if(g<V){var un=h-V,on=Math.min(V,sn);for(un+g<0&&F(3);g<on;++g)r[g]=u[un+g]}for(;g<sn;++g)r[g]=r[g-V]}}i.l=k,i.p=_,i.b=g,i.f=p,k&&(p=1,i.m=I,i.d=b,i.n=A)}while(!p);return g!=r.length&&c?S(r,0,g):r.subarray(0,g)},L=function(n,t,i){var r=t/8|0;n[r]|=i<<=7&t,n[r+1]|=i>>8},C=function(n,t,i){var r=t/8|0;n[r]|=i<<=7&t,n[r+1]|=i>>8,n[r+2]|=i>>16},O=function(n,r){for(var e=[],f=0;f<n.length;++f)n[f]&&e.push({s:f,f:n[f]});var s=e.length,u=e.slice();if(!s)return{t:R,l:0};if(1==s){var o=new t(e[0].s+1);return o[e[0].s]=1,{t:o,l:1}}e.sort(function(n,t){return n.f-t.f}),e.push({s:-1,f:25001});var a=e[0],h=e[1],c=0,v=1,l=2;for(e[0]={s:-1,f:a.f+h.f,l:a,r:h};v!=s-1;)a=e[e[c].f<e[l].f?c++:l++],h=e[c!=v&&e[c].f<e[l].f?c++:l++],e[v++]={s:-1,f:a.f+h.f,l:a,r:h};var w=u[0].s;for(f=1;f<s;++f)u[f].s>w&&(w=u[f].s);var d=new i(w+1),p=j(e[v-1],d,0);if(p>r){f=0;var y=0,m=p-r,g=1<<m;for(u.sort(function(n,t){return d[t.s]-d[n.s]||n.f-t.f});f<s;++f){var k=u[f].s;if(!(d[k]>r))break;y+=g-(1<<p-d[k]),d[k]=r}for(y>>=m;y>0;){var M=u[f].s;d[M]<r?y-=1<<r-d[M]++-1:++f}for(;f>=0&&y;--f){var b=u[f].s;d[b]==r&&(--d[b],++y)}p=r}return{t:new t(d),l:p}},j=function(n,t,i){return-1==n.s?Math.max(j(n.l,t,i+1),j(n.r,t,i+1)):t[n.s]=i},q=function(n){for(var t=n.length;t&&!n[--t];);for(var r=new i(++t),e=0,f=n[0],s=1,u=function(n){r[e++]=n},o=1;o<=t;++o)if(n[o]==f&&o!=t)++s;else{if(!f&&s>2){for(;s>138;s-=138)u(32754);s>2&&(u(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(u(f),--s;s>6;s-=6)u(8304);s>2&&(u(s-3<<5|8208),s=0)}for(;s--;)u(f);s=1,f=n[o]}return{c:r.subarray(0,e),n:t}},B=function(n,t){for(var i=0,r=0;r<t.length;++r)i+=n[r]*t[r];return i},H=function(n,t,i){var r=i.length,e=E(t+2);n[e]=255&r,n[e+1]=r>>8,n[e+2]=255^n[e],n[e+3]=255^n[e+1];for(var f=0;f<r;++f)n[e+f+4]=i[f];return 8*(e+4+r)},N=function(n,t,r,u,o,a,h,c,v,l,w){L(t,w++,r),++o[256];for(var d=O(o,15),p=d.t,M=d.l,z=O(a,15),x=z.t,T=z.l,D=q(p),E=D.c,S=D.n,I=q(x),A=I.c,F=I.n,U=new i(19),j=0;j<E.length;++j)++U[31&E[j]];for(j=0;j<A.length;++j)++U[31&A[j]];for(var N=O(U,7),$=N.t,R=N.l,W=19;W>4&&!$[s[W-1]];--W);var Z,G,J,K,P=l+5<<3,Q=B(o,m)+B(a,g)+h,V=B(o,p)+B(a,x)+h+14+3*W+B(U,$)+2*U[16]+3*U[17]+7*U[18];if(v>=0&&P<=Q&&P<=V)return H(t,w,n.subarray(v,v+l));if(L(t,w,1+(V<Q)),w+=2,V<Q){Z=y(p,M,0),G=p,J=y(x,T,0),K=x;var X=y($,R,0);for(L(t,w,S-257),L(t,w+5,F-1),L(t,w+10,W-4),w+=14,j=0;j<W;++j)L(t,w+3*j,$[s[j]]);w+=3*W;for(var Y=[E,A],_=0;_<2;++_){var nn=Y[_];for(j=0;j<nn.length;++j)L(t,w,X[rn=31&nn[j]]),w+=$[rn],rn>15&&(L(t,w,nn[j]>>5&127),w+=nn[j]>>12)}}else Z=k,G=m,J=b,K=g;for(j=0;j<c;++j){var tn=u[j];if(tn>255){var rn;C(t,w,Z[257+(rn=tn>>18&31)]),w+=G[rn+257],rn>7&&(L(t,w,tn>>23&31),w+=e[rn]);var en=31&tn;C(t,w,J[en]),w+=K[en],en>3&&(C(t,w,tn>>5&8191),w+=f[en])}else C(t,w,Z[tn]),w+=G[tn]}return C(t,w,Z[256]),w+G[256]},$=new r([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),R=new t(0),W=function(n,s,u,o,a,c){var v=c.z||n.length,w=new t(o+v+5*(1+Math.ceil(v/7e3))+a),d=w.subarray(o,w.length-a),p=c.l,y=7&(c.r||0);if(s){y&&(d[0]=c.r>>3);for(var m=$[s-1],g=m>>13,k=8191&m,M=(1<<u)-1,b=c.p||new i(32768),z=c.h||new i(M+1),x=Math.ceil(u/3),T=2*x,D=function(t){return(n[t]^n[t+1]<<x^n[t+2]<<T)&M},I=new r(25e3),A=new i(288),F=new i(32),U=0,L=0,C=c.i||0,O=0,j=c.w||0,q=0;C+2<v;++C){var B=D(C),R=32767&C,W=z[B];if(b[R]=W,z[B]=R,j<=C){var Z=v-C;if((U>7e3||O>24576)&&(Z>423||!p)){y=N(n,d,0,I,A,F,L,O,q,C-q,y),O=U=L=0,q=C;for(var G=0;G<286;++G)A[G]=0;for(G=0;G<30;++G)F[G]=0}var J=2,K=0,P=k,Q=R-W&32767;if(Z>2&&B==D(C-Q))for(var V=Math.min(g,Z)-1,X=Math.min(32767,C),Y=Math.min(258,Z);Q<=X&&--P&&R!=W;){if(n[C+J]==n[C+J-Q]){for(var _=0;_<Y&&n[C+_]==n[C+_-Q];++_);if(_>J){if(J=_,K=Q,_>V)break;var nn=Math.min(Q,_-2),tn=0;for(G=0;G<nn;++G){var rn=C-Q+G&32767,en=rn-b[rn]&32767;en>tn&&(tn=en,W=rn)}}}Q+=(R=W)-(W=b[R])&32767}if(K){I[O++]=268435456|h[J]<<18|l[K];var fn=31&h[J],sn=31&l[K];L+=e[fn]+f[sn],++A[257+fn],++F[sn],j=C+J,++U}else I[O++]=n[C],++A[n[C]]}}for(C=Math.max(C,j);C<v;++C)I[O++]=n[C],++A[n[C]];y=N(n,d,p,I,A,F,L,O,q,C-q,y),p||(c.r=7&y|d[y/8|0]<<3,y-=7,c.h=z,c.p=b,c.i=C,c.w=j)}else{for(C=c.w||0;C<v+p;C+=65535){var un=C+65535;un>=v&&(d[y/8|0]=p,un=v),y=H(d,y+1,n.subarray(C,un))}c.i=v}return S(w,0,o+E(y)+a)},Z=function(){for(var n=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&-306674912)^i>>>1;n[t]=i}return n}(),G=function(){var n=-1;return{p:function(t){for(var i=n,r=0;r<t.length;++r)i=Z[255&i^t[r]]^i>>>8;n=i},d:function(){return~n}}},J=function(){var n=1,t=0;return{p:function(i){for(var r=n,e=t,f=0|i.length,s=0;s!=f;){for(var u=Math.min(s+2655,f);s<u;++s)e+=r+=i[s];r=(65535&r)+15*(r>>16),e=(65535&e)+15*(e>>16)}n=r,t=e},d:function(){return(255&(n%=65521))<<24|(65280&n)<<8|(255&(t%=65521))<<8|t>>8}}},K=function(n,i,r,e,f){if(!f&&(f={l:1},i.dictionary)){var s=i.dictionary.subarray(-32768),u=new t(s.length+n.length);u.set(s),u.set(n,s.length),n=u,f.w=s.length}return W(n,null==i.level?6:i.level,null==i.mem?f.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):20:12+i.mem,r,e,f)},P=function(n,t){var i={};for(var r in n)i[r]=n[r];for(var r in t)i[r]=t[r];return i},Q=function(n,t,i){for(var r=n(),e=n.toString(),f=e.slice(e.indexOf("[")+1,e.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<r.length;++s){var u=r[s],o=f[s];if("function"==typeof u){t+=";"+o+"=";var a=u.toString();if(u.prototype)if(-1!=a.indexOf("[native code]")){var h=a.indexOf(" ",8)+1;t+=a.slice(h,a.indexOf("(",h))}else for(var c in t+=a,u.prototype)t+=";"+o+".prototype."+c+"="+u.prototype[c].toString();else t+=a}else i[o]=u}return t},V=[],X=function(t,i,r,e){if(!V[r]){for(var f="",s={},u=t.length-1,o=0;o<u;++o)f=Q(t[o],f,s);V[r]={c:Q(t[u],f,s),e:s}}var a=P({},V[r].e);return function(t,i,r,e,f){var s=new Worker(n[i]||(n[i]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return s.onmessage=function(n){var t=n.data,i=t.$e$;if(i){var r=new Error(i[0]);r.code=i[1],r.stack=i[2],f(r,null)}else f(null,t)},s.postMessage(r,e),s}(V[r].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+i.toString()+"}",r,a,function(n){var t=[];for(var i in n)n[i].buffer&&t.push((n[i]=new n[i].constructor(n[i])).buffer);return t}(a),e)},Y=function(){return[t,i,r,e,f,s,a,v,M,z,w,A,y,x,T,D,E,S,F,U,Sn,fn,sn]},_=function(){return[t,i,r,e,f,s,h,l,k,m,b,g,w,$,R,y,L,C,O,j,q,B,H,N,E,S,W,K,xn,fn]},nn=function(){return[wn,yn,ln,G,Z]},tn=function(){return[dn,pn]},rn=function(){return[mn,ln,J]},en=function(){return[gn]},fn=function(n){return postMessage(n,[n.buffer])},sn=function(n){return n&&{out:n.size&&new t(n.size),dictionary:n.dictionary}},un=function(n,t,i,r,e,f){var s=X(i,r,e,function(n,t){s.terminate(),f(n,t)});return s.postMessage([n,t],t.consume?[n.buffer]:[]),function(){s.terminate()}},on=function(n){return n.ondata=function(n,t){return postMessage([n,t],[n.buffer])},function(t){t.data.length?(n.push(t.data[0],t.data[1]),postMessage([t.data[0].length])):n.flush()}},an=function(n,t,i,r,e,f,s){var u,o=X(n,r,e,function(n,i){n?(o.terminate(),t.ondata.call(t,n)):Array.isArray(i)?1==i.length?(t.queuedSize-=i[0],t.ondrain&&t.ondrain(i[0])):(i[1]&&o.terminate(),t.ondata.call(t,n,i[0],i[1])):s(i)});o.postMessage(i),t.queuedSize=0,t.push=function(n,i){t.ondata||F(5),u&&t.ondata(F(4,0,1),null,!!i),t.queuedSize+=n.length,o.postMessage([n,u=i],[n.buffer])},t.terminate=function(){o.terminate()},f&&(t.flush=function(){o.postMessage([])})},hn=function(n,t){return n[t]|n[t+1]<<8},cn=function(n,t){return(n[t]|n[t+1]<<8|n[t+2]<<16|n[t+3]<<24)>>>0},vn=function(n,t){return cn(n,t)+4294967296*cn(n,t+4)},ln=function(n,t,i){for(;i;++t)n[t]=i,i>>>=8},wn=function(n,t){var i=t.filename;if(n[0]=31,n[1]=139,n[2]=8,n[8]=t.level<2?4:9==t.level?2:0,n[9]=3,0!=t.mtime&&ln(n,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){n[3]=8;for(var r=0;r<=i.length;++r)n[r+10]=i.charCodeAt(r)}},dn=function(n){31==n[0]&&139==n[1]&&8==n[2]||F(6,"invalid gzip data");var t=n[3],i=10;4&t&&(i+=2+(n[10]|n[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!n[i++]);return i+(2&t)},pn=function(n){var t=n.length;return(n[t-4]|n[t-3]<<8|n[t-2]<<16|n[t-1]<<24)>>>0},yn=function(n){return 10+(n.filename?n.filename.length+1:0)},mn=function(n,t){var i=t.level,r=0==i?0:i<6?1:9==i?3:2;if(n[0]=120,n[1]=r<<6|(t.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,t.dictionary){var e=J();e.p(t.dictionary),ln(n,2,e.d())}},gn=function(n,t){return(8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&F(6,"invalid zlib data"),(n[1]>>5&1)==+!t&&F(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)};function kn(n,t){return"function"==typeof n&&(t=n,n={}),this.ondata=t,n}var Mn=function(){function n(n,i){if("function"==typeof n&&(i=n,n={}),this.ondata=i,this.o=n||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new t(98304),this.o.dictionary){var r=this.o.dictionary.subarray(-32768);this.b.set(r,32768-r.length),this.s.i=32768-r.length}}return n.prototype.p=function(n,t){this.ondata(K(n,this.o,0,0,this.s),t)},n.prototype.push=function(n,i){this.ondata||F(5),this.s.l&&F(4);var r=n.length+this.s.z;if(r>this.b.length){if(r>2*this.b.length-32768){var e=new t(-32768&r);e.set(this.b.subarray(0,this.s.z)),this.b=e}var f=this.b.length-this.s.z;this.b.set(n.subarray(0,f),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(n.subarray(f),32768),this.s.z=n.length-f+32768,this.s.i=32766,this.s.w=32768}else this.b.set(n,this.s.z),this.s.z+=n.length;this.s.l=1&i,(this.s.z>this.s.w+8191||i)&&(this.p(this.b,i||!1),this.s.w=this.s.i,this.s.i-=2)},n.prototype.flush=function(){this.ondata||F(5),this.s.l&&F(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},n}(),bn=function(){return function(n,t){an([_,function(){return[on,Mn]}],this,kn.call(this,n,t),function(n){var t=new Mn(n.data);onmessage=on(t)},6,1)}}();function zn(n,t,i){return i||(i=t,t={}),"function"!=typeof i&&F(7),un(n,t,[_],function(n){return fn(xn(n.data[0],n.data[1]))},0,i)}function xn(n,t){return K(n,t||{},0,0)}var Tn=function(){function n(n,i){"function"==typeof n&&(i=n,n={}),this.ondata=i;var r=n&&n.dictionary&&n.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new t(32768),this.p=new t(0),r&&this.o.set(r)}return n.prototype.e=function(n){if(this.ondata||F(5),this.d&&F(4),this.p.length){if(n.length){var i=new t(this.p.length+n.length);i.set(this.p),i.set(n,this.p.length),this.p=i}}else this.p=n},n.prototype.c=function(n){this.s.i=+(this.d=n||!1);var t=this.s.b,i=U(this.p,this.s,this.o);this.ondata(S(i,t,this.s.b),this.d),this.o=S(i,this.s.b-32768),this.s.b=this.o.length,this.p=S(this.p,this.s.p/8|0),this.s.p&=7},n.prototype.push=function(n,t){this.e(n),this.c(t)},n}(),Dn=function(){return function(n,t){an([Y,function(){return[on,Tn]}],this,kn.call(this,n,t),function(n){var t=new Tn(n.data);onmessage=on(t)},7,0)}}();function En(n,t,i){return i||(i=t,t={}),"function"!=typeof i&&F(7),un(n,t,[Y],function(n){return fn(Sn(n.data[0],sn(n.data[1])))},1,i)}function Sn(n,t){return U(n,{i:2},t&&t.out,t&&t.dictionary)}var In=function(){function n(n,t){this.c=G(),this.l=0,this.v=1,Mn.call(this,n,t)}return n.prototype.push=function(n,t){this.c.p(n),this.l+=n.length,Mn.prototype.push.call(this,n,t)},n.prototype.p=function(n,t){var i=K(n,this.o,this.v&&yn(this.o),t&&8,this.s);this.v&&(wn(i,this.o),this.v=0),t&&(ln(i,i.length-8,this.c.d()),ln(i,i.length-4,this.l)),this.ondata(i,t)},n.prototype.flush=function(){Mn.prototype.flush.call(this)},n}(),An=function(){return function(n,t){an([_,nn,function(){return[on,Mn,In]}],this,kn.call(this,n,t),function(n){var t=new In(n.data);onmessage=on(t)},8,1)}}();function Fn(n,t,i){return i||(i=t,t={}),"function"!=typeof i&&F(7),un(n,t,[_,nn,function(){return[Un]}],function(n){return fn(Un(n.data[0],n.data[1]))},2,i)}function Un(n,t){t||(t={});var i=G(),r=n.length;i.p(n);var e=K(n,t,yn(t),8),f=e.length;return wn(e,t),ln(e,f-8,i.d()),ln(e,f-4,r),e}var Ln=function(){function n(n,t){this.v=1,this.r=0,Tn.call(this,n,t)}return n.prototype.push=function(n,i){if(Tn.prototype.e.call(this,n),this.r+=n.length,this.v){var r=this.p.subarray(this.v-1),e=r.length>3?dn(r):4;if(e>r.length){if(!i)return}else this.v>1&&this.onmember&&this.onmember(this.r-r.length);this.p=r.subarray(e),this.v=0}Tn.prototype.c.call(this,i),!this.s.f||this.s.l||i||(this.v=E(this.s.p)+9,this.s={i:0},this.o=new t(0),this.push(new t(0),i))},n}(),Cn=function(){return function(n,t){var i=this;an([Y,tn,function(){return[on,Tn,Ln]}],this,kn.call(this,n,t),function(n){var t=new Ln(n.data);t.onmember=function(n){return postMessage(n)},onmessage=on(t)},9,0,function(n){return i.onmember&&i.onmember(n)})}}();function On(n,t,i){return i||(i=t,t={}),"function"!=typeof i&&F(7),un(n,t,[Y,tn,function(){return[jn]}],function(n){return fn(jn(n.data[0],n.data[1]))},3,i)}function jn(n,i){var r=dn(n);return r+8>n.length&&F(6,"invalid gzip data"),U(n.subarray(r,-8),{i:2},i&&i.out||new t(pn(n)),i&&i.dictionary)}var qn=function(){function n(n,t){this.c=J(),this.v=1,Mn.call(this,n,t)}return n.prototype.push=function(n,t){this.c.p(n),Mn.prototype.push.call(this,n,t)},n.prototype.p=function(n,t){var i=K(n,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(mn(i,this.o),this.v=0),t&&ln(i,i.length-4,this.c.d()),this.ondata(i,t)},n.prototype.flush=function(){Mn.prototype.flush.call(this)},n}(),Bn=function(){return function(n,t){an([_,rn,function(){return[on,Mn,qn]}],this,kn.call(this,n,t),function(n){var t=new qn(n.data);onmessage=on(t)},10,1)}}();function Hn(n,t,i){return i||(i=t,t={}),"function"!=typeof i&&F(7),un(n,t,[_,rn,function(){return[Nn]}],function(n){return fn(Nn(n.data[0],n.data[1]))},4,i)}function Nn(n,t){t||(t={});var i=J();i.p(n);var r=K(n,t,t.dictionary?6:2,4);return mn(r,t),ln(r,r.length-4,i.d()),r}var $n=function(){function n(n,t){Tn.call(this,n,t),this.v=n&&n.dictionary?2:1}return n.prototype.push=function(n,t){if(Tn.prototype.e.call(this,n),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(gn(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&F(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Tn.prototype.c.call(this,t)},n}(),Rn=function(){return function(n,t){an([Y,en,function(){return[on,Tn,$n]}],this,kn.call(this,n,t),function(n){var t=new $n(n.data);onmessage=on(t)},11,0)}}();function Wn(n,t,i){return i||(i=t,t={}),"function"!=typeof i&&F(7),un(n,t,[Y,en,function(){return[Zn]}],function(n){return fn(Zn(n.data[0],sn(n.data[1])))},5,i)}function Zn(n,t){return U(n.subarray(gn(n,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Gn=function(){function n(n,t){this.o=kn.call(this,n,t)||{},this.G=Ln,this.I=Tn,this.Z=$n}return n.prototype.i=function(){var n=this;this.s.ondata=function(t,i){n.ondata(t,i)}},n.prototype.push=function(n,i){if(this.ondata||F(5),this.s)this.s.push(n,i);else{if(this.p&&this.p.length){var r=new t(this.p.length+n.length);r.set(this.p),r.set(n,this.p.length)}else this.p=n;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,i),this.p=null)}},n}(),Jn=function(){function n(n,t){Gn.call(this,n,t),this.queuedSize=0,this.G=Cn,this.I=Dn,this.Z=Rn}return n.prototype.i=function(){var n=this;this.s.ondata=function(t,i,r){n.ondata(t,i,r)},this.s.ondrain=function(t){n.queuedSize-=t,n.ondrain&&n.ondrain(t)}},n.prototype.push=function(n,t){this.queuedSize+=n.length,Gn.prototype.push.call(this,n,t)},n}();function Kn(n,t,i){return i||(i=t,t={}),"function"!=typeof i&&F(7),31==n[0]&&139==n[1]&&8==n[2]?On(n,t,i):8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31?En(n,t,i):Wn(n,t,i)}function Pn(n,t){return 31==n[0]&&139==n[1]&&8==n[2]?jn(n,t):8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31?Sn(n,t):Zn(n,t)}var Qn=function(n,i,r,e){for(var f in n){var s=n[f],u=i+f,o=e;Array.isArray(s)&&(o=P(e,s[1]),s=s[0]),s instanceof t?r[u]=[s,o]:(r[u+="/"]=[new t(0),o],Qn(s,u,r,e))}},Vn="undefined"!=typeof TextEncoder&&new TextEncoder,Xn="undefined"!=typeof TextDecoder&&new TextDecoder,Yn=0;try{Xn.decode(R,{stream:!0}),Yn=1}catch(n){}var _n=function(n){for(var t="",i=0;;){var r=n[i++],e=(r>127)+(r>223)+(r>239);if(i+e>n.length)return{s:t,r:S(n,i-1)};e?3==e?(r=((15&r)<<18|(63&n[i++])<<12|(63&n[i++])<<6|63&n[i++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=String.fromCharCode(1&e?(31&r)<<6|63&n[i++]:(15&r)<<12|(63&n[i++])<<6|63&n[i++]):t+=String.fromCharCode(r)}},nt=function(){function n(n){this.ondata=n,Yn?this.t=new TextDecoder:this.p=R}return n.prototype.push=function(n,i){if(this.ondata||F(5),i=!!i,this.t)return this.ondata(this.t.decode(n,{stream:!0}),i),void(i&&(this.t.decode().length&&F(8),this.t=null));this.p||F(4);var r=new t(this.p.length+n.length);r.set(this.p),r.set(n,this.p.length);var e=_n(r),f=e.s,s=e.r;i?(s.length&&F(8),this.p=null):this.p=s,this.ondata(f,i)},n}(),tt=function(){function n(n){this.ondata=n}return n.prototype.push=function(n,t){this.ondata||F(5),this.d&&F(4),this.ondata(it(n),this.d=t||!1)},n}();function it(n,i){if(i){for(var r=new t(n.length),e=0;e<n.length;++e)r[e]=n.charCodeAt(e);return r}if(Vn)return Vn.encode(n);var f=n.length,s=new t(n.length+(n.length>>1)),u=0,o=function(n){s[u++]=n};for(e=0;e<f;++e){if(u+5>s.length){var a=new t(u+8+(f-e<<1));a.set(s),s=a}var h=n.charCodeAt(e);h<128||i?o(h):h<2048?(o(192|h>>6),o(128|63&h)):h>55295&&h<57344?(o(240|(h=65536+(1047552&h)|1023&n.charCodeAt(++e))>>18),o(128|h>>12&63),o(128|h>>6&63),o(128|63&h)):(o(224|h>>12),o(128|h>>6&63),o(128|63&h))}return S(s,0,u)}function rt(n,t){if(t){for(var i="",r=0;r<n.length;r+=16384)i+=String.fromCharCode.apply(null,n.subarray(r,r+16384));return i}if(Xn)return Xn.decode(n);var e=_n(n),f=e.s;return(i=e.r).length&&F(8),f}var et=function(n){return 1==n?3:n<6?2:9==n?1:0},ft=function(n,t){return t+30+hn(n,t+26)+hn(n,t+28)},st=function(n,t,i){var r=hn(n,t+28),e=rt(n.subarray(t+46,t+46+r),!(2048&hn(n,t+8))),f=t+46+r,s=cn(n,t+20),u=i&&4294967295==s?ut(n,f):[s,cn(n,t+24),cn(n,t+42)],o=u[0],a=u[1],h=u[2];return[hn(n,t+10),o,a,e,f+hn(n,t+30)+hn(n,t+32),h]},ut=function(n,t){for(;1!=hn(n,t);t+=4+hn(n,t+2));return[vn(n,t+12),vn(n,t+4),vn(n,t+20)]},ot=function(n){var t=0;if(n)for(var i in n){var r=n[i].length;r>65535&&F(9),t+=r+4}return t},at=function(n,t,i,r,e,f,s,u){var o=r.length,a=i.extra,h=u&&u.length,c=ot(a);ln(n,t,null!=s?33639248:67324752),t+=4,null!=s&&(n[t++]=20,n[t++]=i.os),n[t]=20,t+=2,n[t++]=i.flag<<1|(f<0&&8),n[t++]=e&&8,n[t++]=255&i.compression,n[t++]=i.compression>>8;var v=new Date(null==i.mtime?Date.now():i.mtime),l=v.getFullYear()-1980;if((l<0||l>119)&&F(10),ln(n,t,l<<25|v.getMonth()+1<<21|v.getDate()<<16|v.getHours()<<11|v.getMinutes()<<5|v.getSeconds()>>1),t+=4,-1!=f&&(ln(n,t,i.crc),ln(n,t+4,f<0?-f-2:f),ln(n,t+8,i.size)),ln(n,t+12,o),ln(n,t+14,c),t+=16,null!=s&&(ln(n,t,h),ln(n,t+6,i.attrs),ln(n,t+10,s),t+=14),n.set(r,t),t+=o,c)for(var w in a){var d=a[w],p=d.length;ln(n,t,+w),ln(n,t+2,p),n.set(d,t+4),t+=4+p}return h&&(n.set(u,t),t+=h),t},ht=function(n,t,i,r,e){ln(n,t,101010256),ln(n,t+8,i),ln(n,t+10,i),ln(n,t+12,r),ln(n,t+16,e)},ct=function(){function n(n){this.filename=n,this.c=G(),this.size=0,this.compression=0}return n.prototype.process=function(n,t){this.ondata(null,n,t)},n.prototype.push=function(n,t){this.ondata||F(5),this.c.p(n),this.size+=n.length,t&&(this.crc=this.c.d()),this.process(n,t||!1)},n}(),vt=function(){function n(n,t){var i=this;t||(t={}),ct.call(this,n),this.d=new Mn(t,function(n,t){i.ondata(null,n,t)}),this.compression=8,this.flag=et(t.level)}return n.prototype.process=function(n,t){try{this.d.push(n,t)}catch(n){this.ondata(n,null,t)}},n.prototype.push=function(n,t){ct.prototype.push.call(this,n,t)},n}(),lt=function(){function n(n,t){var i=this;t||(t={}),ct.call(this,n),this.d=new bn(t,function(n,t,r){i.ondata(n,t,r)}),this.compression=8,this.flag=et(t.level),this.terminate=this.d.terminate}return n.prototype.process=function(n,t){this.d.push(n,t)},n.prototype.push=function(n,t){ct.prototype.push.call(this,n,t)},n}(),wt=function(){function n(n){this.ondata=n,this.u=[],this.d=1}return n.prototype.add=function(n){var i=this;if(this.ondata||F(5),2&this.d)this.ondata(F(4+8*(1&this.d),0,1),null,!1);else{var r=it(n.filename),e=r.length,f=n.comment,s=f&&it(f),u=e!=n.filename.length||s&&f.length!=s.length,o=e+ot(n.extra)+30;e>65535&&this.ondata(F(11,0,1),null,!1);var a=new t(o);at(a,0,n,r,u,-1);var h=[a],c=function(){for(var n=0,t=h;n<t.length;n++)i.ondata(null,t[n],!1);h=[]},v=this.d;this.d=0;var l=this.u.length,w=P(n,{f:r,u:u,o:s,t:function(){n.terminate&&n.terminate()},r:function(){if(c(),v){var n=i.u[l+1];n?n.r():i.d=1}v=1}}),d=0;n.ondata=function(r,e,f){if(r)i.ondata(r,e,f),i.terminate();else if(d+=e.length,h.push(e),f){var s=new t(16);ln(s,0,134695760),ln(s,4,n.crc),ln(s,8,d),ln(s,12,n.size),h.push(s),w.c=d,w.b=o+d+16,w.crc=n.crc,w.size=n.size,v&&w.r(),v=1}else v&&c()},this.u.push(w)}},n.prototype.end=function(){var n=this;2&this.d?this.ondata(F(4+8*(1&this.d),0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&n.d&&(n.u.splice(-1,1),n.e())},t:function(){}}),this.d=3)},n.prototype.e=function(){for(var n=0,i=0,r=0,e=0,f=this.u;e<f.length;e++)r+=46+(a=f[e]).f.length+ot(a.extra)+(a.o?a.o.length:0);for(var s=new t(r+22),u=0,o=this.u;u<o.length;u++){var a;at(s,n,a=o[u],a.f,a.u,-a.c-2,i,a.o),n+=46+a.f.length+ot(a.extra)+(a.o?a.o.length:0),i+=a.b}ht(s,n,this.u.length,r,i),this.ondata(null,s,!0),this.d=2},n.prototype.terminate=function(){for(var n=0,t=this.u;n<t.length;n++)t[n].t();this.d=2},n}();function dt(n,i,r){r||(r=i,i={}),"function"!=typeof r&&F(7);var e={};Qn(n,"",e,i);var f=Object.keys(e),s=f.length,u=0,o=0,a=s,h=new Array(s),c=[],v=function(){for(var n=0;n<c.length;++n)c[n]()},l=function(n,t){Mt(function(){r(n,t)})};Mt(function(){l=r});var w=function(){var n=new t(o+22),i=u,r=o-u;o=0;for(var e=0;e<a;++e){var f=h[e];try{var s=f.c.length;at(n,o,f,f.f,f.u,s);var c=30+f.f.length+ot(f.extra),v=o+c;n.set(f.c,v),at(n,u,f,f.f,f.u,s,o,f.m),u+=16+c+(f.m?f.m.length:0),o=v+s}catch(n){return l(n,null)}}ht(n,u,h.length,r,i),l(null,n)};s||w();for(var d=function(n){var t=f[n],i=e[t],r=i[0],a=i[1],d=G(),p=r.length;d.p(r);var y=it(t),m=y.length,g=a.comment,k=g&&it(g),M=k&&k.length,b=ot(a.extra),z=0==a.level?0:8,x=function(i,r){if(i)v(),l(i,null);else{var e=r.length;h[n]=P(a,{size:p,crc:d.d(),c:r,f:y,m:k,u:m!=t.length||k&&g.length!=M,compression:z}),u+=30+m+b+e,o+=76+2*(m+b)+(M||0)+e,--s||w()}};if(m>65535&&x(F(11,0,1),null),z)if(p<16e4)try{x(null,xn(r,a))}catch(n){x(n,null)}else c.push(zn(r,a,x));else x(null,r)},p=0;p<a;++p)d(p);return v}function pt(n,i){i||(i={});var r={},e=[];Qn(n,"",r,i);var f=0,s=0;for(var u in r){var o=r[u],a=o[0],h=o[1],c=0==h.level?0:8,v=(x=it(u)).length,l=h.comment,w=l&&it(l),d=w&&w.length,p=ot(h.extra);v>65535&&F(11);var y=c?xn(a,h):a,m=y.length,g=G();g.p(a),e.push(P(h,{size:a.length,crc:g.d(),c:y,f:x,m:w,u:v!=u.length||w&&l.length!=d,o:f,compression:c})),f+=30+v+p+m,s+=76+2*(v+p)+(d||0)+m}for(var k=new t(s+22),M=f,b=s-f,z=0;z<e.length;++z){var x;at(k,(x=e[z]).o,x,x.f,x.u,x.c.length);var T=30+x.f.length+ot(x.extra);k.set(x.c,x.o+T),at(k,f,x,x.f,x.u,x.c.length,x.o,x.m),f+=16+T+(x.m?x.m.length:0)}return ht(k,f,e.length,b,M),k}var yt=function(){function n(){}return n.prototype.push=function(n,t){this.ondata(null,n,t)},n.compression=0,n}(),mt=function(){function n(){var n=this;this.i=new Tn(function(t,i){n.ondata(null,t,i)})}return n.prototype.push=function(n,t){try{this.i.push(n,t)}catch(n){this.ondata(n,null,t)}},n.compression=8,n}(),gt=function(){function n(n,t){var i=this;t<32e4?this.i=new Tn(function(n,t){i.ondata(null,n,t)}):(this.i=new Dn(function(n,t,r){i.ondata(n,t,r)}),this.terminate=this.i.terminate)}return n.prototype.push=function(n,t){this.i.terminate&&(n=S(n,0)),this.i.push(n,t)},n.compression=8,n}(),kt=function(){function n(n){this.onfile=n,this.k=[],this.o={0:yt},this.p=R}return n.prototype.push=function(n,i){var r=this;if(this.onfile||F(5),this.p||F(4),this.c>0){var e=Math.min(this.c,n.length),f=n.subarray(0,e);if(this.c-=e,this.d?this.d.push(f,!this.c):this.k[0].push(f),(n=n.subarray(e)).length)return this.push(n,i)}else{var s=0,u=0,o=void 0,a=void 0;this.p.length?n.length?((a=new t(this.p.length+n.length)).set(this.p),a.set(n,this.p.length)):a=this.p:a=n;for(var h=a.length,c=this.c,v=c&&this.d,l=function(){var n,t=cn(a,u);if(67324752==t){s=1,o=u,w.d=null,w.c=0;var i=hn(a,u+6),e=hn(a,u+8),f=2048&i,v=8&i,l=hn(a,u+26),d=hn(a,u+28);if(h>u+30+l+d){var p=[];w.k.unshift(p),s=2;var y,m=cn(a,u+18),g=cn(a,u+22),k=rt(a.subarray(u+30,u+=30+l),!f);4294967295==m?(n=v?[-2]:ut(a,u),m=n[0],g=n[1]):v&&(m=-1),u+=d,w.c=m;var M={name:k,compression:e,start:function(){if(M.ondata||F(5),m){var n=r.o[e];n||M.ondata(F(14,"unknown compression type "+e,1),null,!1),(y=m<0?new n(k):new n(k,m,g)).ondata=function(n,t,i){M.ondata(n,t,i)};for(var t=0,i=p;t<i.length;t++)y.push(i[t],!1);r.k[0]==p&&r.c?r.d=y:y.push(R,!0)}else M.ondata(null,R,!0)},terminate:function(){y&&y.terminate&&y.terminate()}};m>=0&&(M.size=m,M.originalSize=g),w.onfile(M)}return"break"}if(c){if(134695760==t)return o=u+=12+(-2==c&&8),s=3,w.c=0,"break";if(33639248==t)return o=u-=4,s=3,w.c=0,"break"}},w=this;u<h-4&&"break"!==l();++u);if(this.p=R,c<0){var d=a.subarray(0,s?o-12-(-2==c&&8)-(134695760==cn(a,o-16)&&4):u);v?v.push(d,!!s):this.k[+(2==s)].push(d)}if(2&s)return this.push(a.subarray(u),i);this.p=a.subarray(u)}i&&(this.c&&F(13),this.p=null)},n.prototype.register=function(n){this.o[n.compression]=n},n}(),Mt="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(n){n()};function bt(n,i,r){r||(r=i,i={}),"function"!=typeof r&&F(7);var e=[],f=function(){for(var n=0;n<e.length;++n)e[n]()},s={},u=function(n,t){Mt(function(){r(n,t)})};Mt(function(){u=r});for(var o=n.length-22;101010256!=cn(n,o);--o)if(!o||n.length-o>65558)return u(F(13,0,1),null),f;var a=hn(n,o+8);if(a){var h=a,c=cn(n,o+16),v=4294967295==c||65535==h;if(v){var l=cn(n,o-12);(v=101075792==cn(n,l))&&(h=a=cn(n,l+32),c=cn(n,l+48))}for(var w=i&&i.filter,d=function(i){var r=st(n,c,v),o=r[0],h=r[1],l=r[2],d=r[3],p=r[4],y=ft(n,r[5]);c=p;var m=function(n,t){n?(f(),u(n,null)):(t&&(s[d]=t),--a||u(null,s))};if(!w||w({name:d,size:h,originalSize:l,compression:o}))if(o)if(8==o){var g=n.subarray(y,y+h);if(l<524288||h>.8*l)try{m(null,Sn(g,{out:new t(l)}))}catch(n){m(n,null)}else e.push(En(g,{size:l},m))}else m(F(14,"unknown compression type "+o,1),null);else m(null,S(n,y,y+h));else m(null,null)},p=0;p<h;++p)d()}else u(null,{});return f}function zt(n,i){for(var r={},e=n.length-22;101010256!=cn(n,e);--e)(!e||n.length-e>65558)&&F(13);var f=hn(n,e+8);if(!f)return{};var s=cn(n,e+16),u=4294967295==s||65535==f;if(u){var o=cn(n,e-12);(u=101075792==cn(n,o))&&(f=cn(n,o+32),s=cn(n,o+48))}for(var a=i&&i.filter,h=0;h<f;++h){var c=st(n,s,u),v=c[0],l=c[1],w=c[2],d=c[3],p=c[4],y=ft(n,c[5]);s=p,a&&!a({name:d,size:l,originalSize:w,compression:v})||(v?8==v?r[d]=Sn(n.subarray(y,y+l),{out:new t(w)}):F(14,"unknown compression type "+v):r[d]=S(n,y,y+l))}return r}export{An as AsyncCompress,Jn as AsyncDecompress,bn as AsyncDeflate,Cn as AsyncGunzip,An as AsyncGzip,Dn as AsyncInflate,gt as AsyncUnzipInflate,Rn as AsyncUnzlib,lt as AsyncZipDeflate,Bn as AsyncZlib,In as Compress,nt as DecodeUTF8,Gn as Decompress,Mn as Deflate,tt as EncodeUTF8,I as FlateErrorCode,Ln as Gunzip,In as Gzip,Tn as Inflate,kt as Unzip,mt as UnzipInflate,yt as UnzipPassThrough,$n as Unzlib,wt as Zip,vt as ZipDeflate,ct as ZipPassThrough,qn as Zlib,Fn as compress,Un as compressSync,Kn as decompress,Pn as decompressSync,zn as deflate,xn as deflateSync,On as gunzip,jn as gunzipSync,Fn as gzip,Un as gzipSync,En as inflate,Sn as inflateSync,rt as strFromU8,it as strToU8,bt as unzip,zt as unzipSync,Wn as unzlib,Zn as unzlibSync,dt as zip,pt as zipSync,Hn as zlib,Nn as zlibSync};
package/dist/index.d.ts CHANGED
@@ -24,10 +24,9 @@ type CollectorEventMap = {
24
24
  sensors: 'motion' | 'orientation' | 'light';
25
25
  'network-request': never;
26
26
  networkconnection: never;
27
- environmental: never;
28
27
  screen: never;
29
28
  };
30
- type Layer = 'session' | 'behavioral' | 'device-fingerprinting' | 'environmental-integrity' | 'network-intelligence' | 'persistent-identity';
29
+ type Layer = 'session' | 'behavioral' | 'device-fingerprinting';
31
30
 
32
31
  /**
33
32
  * Hook that allows the host application to extend or replace the SDK's default
@@ -85,7 +84,6 @@ type TRIConfigBase = {
85
84
  element?: CaptureElementLevel;
86
85
  content?: CaptureContentLevel;
87
86
  };
88
- profileId?: string;
89
87
  apiVersion?: string;
90
88
  /**
91
89
  * Optional URL sanitiser hook. When omitted, the SDK applies its built-in
@@ -158,8 +156,6 @@ interface IncodeTRIInterface {
158
156
  * and return `'init-failed'`.
159
157
  */
160
158
  setup(config: IncodeTRIConfig): Promise<IncodeTRIState>;
161
- /** Sets the profileId. */
162
- setProfileId(profileId: string): void;
163
159
  /** Starts the SDK with the supplied config. Idempotent while running. */
164
160
  start(): Promise<IncodeTRIState>;
165
161
  /**
@@ -174,14 +170,6 @@ interface IncodeTRIInterface {
174
170
  * The returned promise resolves to `'idle'` once teardown has settled.
175
171
  */
176
172
  reset(): Promise<IncodeTRIState>;
177
- /** Reports a host-defined event. Drops silently (with a dev warn) if not yet started. */
178
- reportEvent(name: string, metadata: Record<string, unknown>): void;
179
- /**
180
- * Links an interview to the current activity by sessionToken. Returns `true` on success,
181
- * `false` if the SDK has not started or the request fails. Requires a prior
182
- * successful `start()` to have minted a session token.
183
- */
184
- linkInterview(sessionToken: string): Promise<boolean>;
185
173
  }
186
174
  /**
187
175
  * Life-cycle states for an `IncodeTRI` instance.
@@ -189,7 +177,7 @@ interface IncodeTRIInterface {
189
177
  * - `'idle'` — initial state; `setup()` has not completed successfully.
190
178
  * - `'ready'` — managers are wired and ready; `start()` may be called.
191
179
  * - `'starting'` — `start()` has been called; async sequence in progress.
192
- * - `'started'` — all managers are running and `reportEvent()` is active.
180
+ * - `'started'` — all managers are running and collecting.
193
181
  * - `'collection-disabled'` — collection is disabled for the provided SDK token.
194
182
  * - `'init-failed'` — setup failed.
195
183
  */
@@ -210,8 +198,6 @@ type IncodeTRIState = 'idle' | 'ready' | 'starting' | 'started' | 'collection-di
210
198
  * Takes no config.
211
199
  * - `stop()` — stops all collectors and managers without destroying them.
212
200
  * Returns the instance to `'setup'` state so `start()` can be called again.
213
- * - `reportEvent(name, metadata)` — host-defined events; no-op with a dev
214
- * warn until `start()` has fully completed.
215
201
  *
216
202
  * ### Never throws
217
203
  * All public methods swallow exceptions. Errors are surfaced through `logger`
@@ -232,7 +218,6 @@ declare class IncodeTRI$1 implements IncodeTRIInterface {
232
218
  * and bails out after every `await` if the counter has moved on.
233
219
  */
234
220
  private _generation;
235
- private _config;
236
221
  private _managers;
237
222
  private _state;
238
223
  private constructor();
@@ -276,10 +261,10 @@ declare class IncodeTRI$1 implements IncodeTRIInterface {
276
261
  */
277
262
  stop(): Promise<IncodeTRIState>;
278
263
  /**
279
- * Resets the SDK to its initial state. Clears all managers, config, and
280
- * profile storage. State transitions to `'idle'` synchronously so un-awaited
281
- * callers can call `setup()` immediately after. The returned promise resolves
282
- * to `'idle'` once the in-flight teardown has settled.
264
+ * Resets the SDK to its initial state. Clears all managers and config.
265
+ * State transitions to `'idle'` synchronously so un-awaited callers can call
266
+ * `setup()` immediately after. The returned promise resolves to `'idle'` once
267
+ * the in-flight teardown has settled.
283
268
  *
284
269
  * @returns A promise that resolves to `'idle'` once teardown is complete.
285
270
  */
@@ -290,25 +275,6 @@ declare class IncodeTRI$1 implements IncodeTRIInterface {
290
275
  * `reset()` calls that null `this._managers` cannot strand the drain.
291
276
  */
292
277
  private _teardown;
293
- /**
294
- * Reports a host-defined event to the TRI backend. Fire-and-forget — never
295
- * throws and never returns a promise the host must handle. Drops the event
296
- * silently (with a dev warning) if called before `start()` completes.
297
- */
298
- reportEvent(name: string, metadata: Record<string, unknown>): void;
299
- /**
300
- * Sets the Profile ID which will be used for all subsequent requests.
301
- * Profile ID is used to connect the activity events to the specific profile.
302
- */
303
- setProfileId(profileId: string): void;
304
- /**
305
- * Links an interview to the current activity. Returns `true` when the backend
306
- * confirms the link, `false` if the SDK has not started, the token is not
307
- * available, or the request fails. Never throws.
308
- */
309
- linkInterview(sessionToken: string): Promise<boolean>;
310
- private _getProfileId;
311
- private _persistProfileId;
312
278
  private _start;
313
279
  }
314
280
 
@@ -318,8 +284,10 @@ interface SessionError {
318
284
  }
319
285
  interface Session {
320
286
  token: string | null;
287
+ expiresAt: number | null;
288
+ tokenType: 'sdk' | null;
321
289
  eventsCollectionEnabled: boolean;
322
- error?: SessionError;
290
+ error: SessionError | null;
323
291
  }
324
292
  /**
325
293
  * Initializes the TRI SDK session and returns an SDK token.
package/dist/tri.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"t",{value:1});class t{constructor(){this.i=0}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.l("warn",t,n,...e)}error(t,n,...e){this.i&&this.l("error",t,n,...e)}info(t,n,...e){this.i&&this.l("info",t,n,...e)}fatal(t,n,e,...i){this.l(t,n,e,...i)}l(t,n,e,...i){const o=n?`[${n}]`:"",r=console?.[t];r&&r(`[IncodeTRI]${o} ${e}`,...i)}}const n=t.instance;function e(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.addEventListener(o,e,{capture:1,passive:1})}function i(t,n,e){let i=t,o=n;if("devicepixelratiochange"===n){const t=window.devicePixelRatio;i=window.matchMedia(`(resolution: ${t}dppx)`),o="change"}i.removeEventListener(o,e,{capture:1})}const o=globalThis.setTimeout.bind(globalThis),r=globalThis.clearTimeout.bind(globalThis);function s(t,e){try{return t()}catch(t){n.warn("utils","safeSync swallowed error:",t)}}async function c(t){try{return await t()}catch(t){n.warn("utils","safeAsync swallowed error:",t)}}function a(t){return n=>s(()=>t(n))}function l(t){return(...e)=>{try{t(...e)}catch(t){n.warn("utils","safeTimer swallowed error:",t)}}}function u(t,n){return o(l(t),n)}function d(t){if(null!==t)try{r(t)}catch(t){n.warn("utils","safeClearTimeout swallowed error:",t)}}const h=new Set(["xmlhttprequest","fetch","beacon","navigation","script","link","css","img","iframe","video","audio"]),f=new Set(["xmlhttprequest","fetch","beacon"]);function p(t,n){return n?t:null}function m(t,n){const e=t,i=t.responseStart>0,o=p(t.domainLookupEnd-t.domainLookupStart,i),r=p(t.connectEnd-t.connectStart,i),s=p(t.connectEnd>0&&t.secureConnectionStart>0?t.connectEnd-t.secureConnectionStart:0,i),c=p(t.responseStart-t.requestStart,i),a=p(t.responseEnd-t.responseStart,i),l=i?t.transferSize:null,u=i?t.encodedBodySize:null,d=i?t.decodedBodySize:null,f=i&&t.nextHopProtocol||null,m=i&&void 0!==e.deliveryType?e.deliveryType:null,w=e.responseStatus,y=void 0!==w&&0!==w?w:null;return{name:"network_request",timestamp:Date.now(),performanceTime:t.startTime+t.duration,url:n(t.name),initiatorType:(v=t.initiatorType,h.has(v)?v:"other"),startTime:t.startTime,durationMs:t.duration,dnsLookupMs:o,tcpConnectMs:r,tlsHandshakeMs:s,ttfbMs:c,responseDownloadMs:a,transferSize:l,encodedBodySize:u,decodedBodySize:d,nextHopProtocol:f,deliveryType:m,responseStatus:y};var v}function w(){}const y=2e3;function v(t){return!!t&&t.nodeType===Node.TEXT_NODE}function g(t,n){return t.tagName?.toLowerCase()===n.toLowerCase()}function b(t){return!!t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function k(t){return t?t.hasAttribute("data-tri-ignore"):0}function T(t){return t?t.hasAttribute("data-tri-redact"):0}function _(t,n){return n?.includes(t.toLowerCase())??0}function I(t){try{return new URL(t).origin!==window.location.origin}catch{return 0}}function x(t,n){return t?t[n]?.enabled??0:1}function S(){const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const n=t.selectionStart,e=t.selectionEnd;return null==n||null==e||n===e?null:t.value.substring(n,e)}const n=window.getSelection();return!n||n.isCollapsed?null:n.toString()||null}function E(t,n){return"off"===n||k(t)||T(t)?0:1}function A(t){const n=document.activeElement;if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)return n;const e=window.getSelection();return(i=("start"===t?e?.anchorNode:e?.focusNode)??null)?v(i)?i.parentElement:i instanceof Element?i:null:null;var i}function M(){const t=window,n="__fpjs_p_l_b",e=t[n];if(function(t,n){var e;const i=null===(e=Object.getOwnPropertyDescriptor)||void 0===e?void 0:e.call(Object,t,n);(null==i?void 0:i.configurable)?delete t[n]:i&&!i.writable||(t[n]=void 0)}(t,n),"function"!=typeof(null==e?void 0:e.load))throw new Error($);return e}const D="Blocked by CSP",P="The endpoint parameter is not a valid URL";function C(t){return function(t,n){const e=document,i="securitypolicyviolation";let o;const r=n=>{const e=new URL(t,location.href),{blockedURI:i}=n;i!==e.href&&i!==e.protocol.slice(0,-1)&&i!==e.origin||(o=n,s())};e.addEventListener(i,r);const s=()=>e.removeEventListener(i,r);return Promise.resolve().then(n).then(t=>(s(),t),t=>new Promise(t=>{const n=new MessageChannel;n.port1.onmessage=()=>t(),n.port2.postMessage(null)}).then(()=>{if(s(),o)return(()=>{throw new Error(D)})();throw t}))}(t,()=>function(t){return new Promise((n,e)=>{if(function(t){if(URL.prototype)try{return new URL(t,location.href),0}catch(t){if(t instanceof Error&&"TypeError"===t.name)return 1;throw t}}(t))throw new Error(P);const i=document.createElement("script"),o=()=>{var t;return null===(t=i.parentNode)||void 0===t?void 0:t.removeChild(i)},r=document.head||document.getElementsByTagName("head")[0];i.onload=()=>{o(),n()},i.onerror=()=>{o(),e(new Error(L))},i.async=1,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function 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(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===P)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(l=a,new Promise(t=>setTimeout(t,l))).then(()=>s(c));var l})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),C)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:1});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};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=0;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=1}},layer:"device-fingerprinting"},pointer:{create:function(t,n,o){const r=a(n=>{const e=function(n){const e=n,i=function(t){if("mouse"===t.pointerType)return{button:t.button,buttons:t.buttons};const n={force:t.pressure,contact:Math.min(t.width,t.height)};return"pen"===t.pointerType&&(n.tiltX=t.tiltX,n.tiltY=t.tiltY,n.twist=t.twist),n}(e);return{id:e.pointerId,name:"pointer",timestamp:Date.now(),type:J[e.pointerType]??"unknown",phase:G[n.type],isTrusted:e.isTrusted,element:t.resolveElement(e.target),isPrimary:e.isPrimary,modifiers:{shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey},coordinates:{x:e.clientX,y:e.clientY},...i}}(n);t.push(e)});return x(o,"pointer")&&(e(document,"pointerdown",r),e(document,"pointerup",r)),x(o,"click")&&e(document,"click",r),x(o,"dblclick")&&e(document,"dblclick",r),x(o,"contextmenu")&&e(document,"contextmenu",r),()=>{i(document,"pointerdown",r),i(document,"pointerup",r),i(document,"click",r),i(document,"dblclick",r),i(document,"contextmenu",r)}},layer:"behavioral",events:["pointer","click","dblclick","contextmenu"]},pointermove:{create:function(t){let n=null,o=null;const r=a(e=>{const i=e;return n&&n.id!==i.pointerId&&(t.push(n),n=null),n?n.samples.ts.length>=50?(t.push(n),n=s(i),void c(t)):(n.samples.x.push(i.clientX),n.samples.y.push(i.clientY),n.samples.ts.push(i.timeStamp),"pen"===i.pointerType&&(n.samples.tiltX?.push(i.tiltX),n.samples.tiltY?.push(i.tiltY)),"mouse"!==i.pointerType&&(n.samples.force?.push(i.pressure),n.samples.radius?.push(Math.max(i.width,i.height))),void c(t)):(n=s(i),void c(t))});function s(t){const n=function(t){if("mouse"===t.pointerType)return null;const n={force:[t.pressure],radius:[Math.max(t.width,t.height)]};return"pen"===t.pointerType&&(n.tiltX=[t.tiltX],n.tiltY=[t.tiltY]),n}(t);return{name:"pointer",timestamp:Date.now(),id:t.pointerId,type:t.pointerType,phase:"move",isTrusted:t.isTrusted,isPrimary:t.isPrimary,samples:{x:[t.clientX],y:[t.clientY],ts:[t.timeStamp],...n??{}}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(document,"pointermove",r),()=>{i(document,"pointermove",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},focus:{create:function(t){const n=a(n=>{const e=function(n){const e=n;return{name:"focus",type:K[n.type]??"unknown",timestamp:Date.now(),isTrusted:e.isTrusted,element:t.resolveElement(e.target),relatedTarget:t.resolveElement(e.relatedTarget)}}(n);t.push(e)});return e(document,"focusin",n),e(document,"focusout",n),()=>{i(document,"focusin",n),i(document,"focusout",n)}},layer:"behavioral"},input:{create:function(t){const n=a(n=>{const e=n;t.push(function(n){return{name:"keystroke",type:"input",timestamp:Date.now(),isTrusted:n.isTrusted,element:t.resolveElement(n.target),inputType:n.inputType??"",isComposing:n.isComposing??0,length:(e=n.target,e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value.length:0)};var e}(e)),function(t){if("insertReplacementText"===t.inputType)return 1;const n=t.target;return V(n)?function(t){try{return t.matches(":-webkit-autofill")}catch{return 0}}(n):0}(e)&&t.push(function(t,n){const e=t.target;let i=0;return V(e)&&(i=e.value.length),{name:"autofill",timestamp:Date.now(),element:n.resolveElement(e),length:i}}(e,t))});return e(document,"input",n),function(){i(document,"input",n)}},layer:"behavioral"},keystroke:{create:function(t){const{resolve:n,reset:o}=function(){let t=0;const n=new Map;return{resolve:function(e,i){if("keydown"===i){const i=n.get(e);if(void 0!==i)return i;const o=++t;if(n.size>=32){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return n.set(e,o),o}const o=n.get(e);return void 0!==o?(n.delete(e),o):++t},reset:function(){n.clear()}}}(),r=a(e=>{const i=function(t){const e=t,i=t.type;return{name:"keystroke",type:i,id:n(e.code,i),timestamp:Date.now(),isTrusted:e.isTrusted,keys:Y.has(e.key)?[e.key]:[]}}(e);t.push(i)}),s=a(()=>{o()});return e(document,"keydown",r),e(document,"keyup",r),e(window,"blur",s),()=>{i(document,"keydown",r),i(document,"keyup",r),i(window,"blur",s)}},layer:"behavioral"},clipboard:{create:function(t,n="on",o){const r=a(e=>{const i=function(e){const i=e,o=e.type,r=("paste"===e.type?i.clipboardData?.getData("text/plain"):S())??null,s=E(i.target,n);return{name:"clipboard",type:o,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target),length:r?.length??0,...s&&r?{content:r}:{}}}(e);t.push(i)});return x(o,"paste")&&e(document,"paste",r),x(o,"cut")&&e(document,"cut",r),x(o,"copy")&&e(document,"copy",r),()=>{i(document,"paste",r),i(document,"cut",r),i(document,"copy",r)}},layer:"behavioral",events:["paste","cut","copy"]},form:{create:function(t,n,o){const r=a(n=>{const e={name:"form",type:(i=n).type,timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)};var i;t.push(e)});return x(o,"submit")&&e(document,"submit",r),x(o,"invalid")&&e(document,"invalid",r),()=>{i(document,"submit",r),i(document,"invalid",r)}},layer:"behavioral",events:["submit","invalid"]},change:{create:function(t){const n=a(n=>{const e=(i=n,{name:"change",timestamp:Date.now(),isTrusted:i.isTrusted,element:t.resolveElement(i.target)});var i;t.push(e)});return e(document,"change",n),()=>{i(document,"change",n)}},layer:"behavioral"},selection:{create:function(t,n){let o=0,r=0,s=null,c=0,l=0;function u(){s&&(clearTimeout(s),s=null)}function d(){u(),c||l||(s=setTimeout(()=>{s=null,o&&h("timeout")},250))}function h(e){o&&(o=0,u(),function(e){const i=A("end"),o=i&&E(i,n),r=S();t.push({name:"selection",phase:"end",timestamp:Date.now(),trigger:e,isTrusted:1,element:t.resolveElement(i),length:r?.length??0,...o&&r?{content:r}:{}})}(e))}const f=a(()=>{const n=function(){const t=document.getSelection();return!t||t.isCollapsed||0===t.rangeCount}();if(!o&&!n)return o=1,r=Date.now(),t.push({name:"selection",phase:"start",timestamp:r,element:t.resolveElement(A("start"))}),void d();o&&n?h("collapse"):o&&d()}),p=a(t=>{0===t.button&&(c=1,u())}),m=a(t=>{0===t.button&&(c=0,o&&h("pointer"))}),w=a(t=>{"Shift"===t.key&&(l=1,u())}),y=a(t=>{"Shift"===t.key&&(l=0,o&&h("keyboard"))}),v=a(()=>{c=0}),g=a(()=>{"hidden"===document.visibilityState&&(c=0,l=0,o&&h("timeout"))}),b=a(()=>{c=0,o&&h("pointer")});return e(document,"selectionchange",f),e(document,"pointerdown",p),e(document,"pointerup",m),e(document,"keydown",w),e(document,"keyup",y),e(document,"contextmenu",v),e(document,"visibilitychange",g),e(document,"dragend",b),()=>{u(),i(document,"selectionchange",f),i(document,"pointerdown",p),i(document,"pointerup",m),i(document,"keydown",w),i(document,"keyup",y),i(document,"contextmenu",v),i(document,"visibilitychange",g),i(document,"dragend",b)}},layer:"behavioral"},tab:{create:()=>()=>{},layer:"session",events:["state","count"]},visibility:{create:function(t){const n=a(n=>{const e=document.visibilityState;if("visible"!==e&&"hidden"!==e)return;const i={name:"visibility",type:e,timestamp:Date.now(),isTrusted:n.isTrusted};t.push(i)});return e(document,"visibilitychange",n),()=>{i(document,"visibilitychange",n)}},layer:"session"},navigation:{create:function(t){let n=t.sanitizeUrl(document.referrer||"");function o(e){t.push(e),n=e.to??""}const r=a(()=>{const[n]=performance.getEntriesByType("navigation");var e;o(Z("load",n?.type??"navigate",{from:document.referrer?t.sanitizeUrl(document.referrer):null,to:t.sanitizeUrl(location.href)},performance.timeOrigin,n?{fetchStart:(e=n).fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,domInteractive:e.domInteractive,domContentLoadedEventStart:e.domContentLoadedEventStart,domContentLoadedEventEnd:e.domContentLoadedEventEnd,domComplete:e.domComplete,loadEventStart:e.loadEventStart,loadEventEnd:e.loadEventEnd,redirectCount:e.redirectCount,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize}:void 0))}),c=a(e=>{const i=e;if(null===i.navigationType)return;const r=t.sanitizeUrl(location.href);r!==n&&o(Z("change",i.navigationType,{from:n,to:r},performance.timeOrigin))}),l=a(()=>d("traverse")),u=a(()=>d("hashchange"));function d(e){const i=t.sanitizeUrl(location.href);"hashchange"===e&&i===n||o(Z("change",e,{from:n,to:i},performance.timeOrigin))}const h=history.pushState,f=history.replaceState,p=function(...t){const n=h.apply(this,t);return s(()=>d("push")),n},m=function(...t){const n=f.apply(this,t);return s(()=>d("replace")),n};return window.navigation?e(window.navigation,"currententrychange",c):(history.pushState=p,history.replaceState=m,e(window,"popstate",l),e(window,"hashchange",u)),"complete"===document.readyState?r(new Event("load")):e(window,"load",r),()=>{window.navigation?i(window.navigation,"currententrychange",c):(history.pushState===p&&(history.pushState=h),history.replaceState===m&&(history.replaceState=f),i(window,"popstate",l),i(window,"hashchange",u)),i(window,"load",r)}},layer:"session"},networkconnection:{create:function(t){const n=a(()=>{const n={name:"network",type:"connection",state:navigator.onLine?"online":"offline",timestamp:Date.now()};t.push(n)});return e(window,"online",n),e(window,"offline",n),()=>{i(window,"online",n),i(window,"offline",n)}},layer:"session"},scroll:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.x.push(window.scrollX),n.samples.y.push(window.scrollY),n.samples.ts.push(e.timeStamp),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"scroll",timestamp:Date.now(),samples:{x:[window.scrollX],y:[window.scrollY],ts:[t.timeStamp]},height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,pageX:window.pageXOffset,pageY:window.pageYOffset}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"scroll",r),()=>{i(window,"scroll",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewportresize:{create:function(t){let n=null,o=null;const r=a(e=>n?n.samples.ts.length>=50?(t.push(n),n=s(e),void c(t)):(n.samples.height.push(window.innerHeight),n.samples.width.push(window.innerWidth),n.samples.ts.push(e.timeStamp),n.samples.scrollX.push(window.scrollX),n.samples.scrollY.push(window.scrollY),n.samples.dpr.push(window.devicePixelRatio),void c(t)):(n=s(e),void c(t)));function s(t){return{name:"viewport",type:"resize",timestamp:Date.now(),samples:{height:[window.innerHeight],width:[window.innerWidth],ts:[t.timeStamp],scrollX:[window.scrollX],scrollY:[window.scrollY],dpr:[window.devicePixelRatio]}}}function c(t){o&&clearTimeout(o),o=setTimeout(()=>{n&&(t.push(n),n=null),o=null},y)}return e(window,"resize",r),()=>{i(window,"resize",r),o&&(clearTimeout(o),o=null),n&&(t.push(n),n=null)}},layer:"behavioral"},viewport:{create:function(t,n,o){const r=a(n=>{const e=c(n,"orientation");t.push(e)}),s=a(n=>{const e=c(n,"ratiochange");t.push(e)});function c(t,n){return{name:"viewport",type:n,timestamp:Date.now(),isTrusted:t.isTrusted,height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}return x(o,"orientationchange")&&e(window,"orientationchange",r),x(o,"devicepixelratiochange")&&e(window,"devicepixelratiochange",s),()=>{i(window,"orientationchange",r),i(window,"devicepixelratiochange",s)}},layer:"behavioral",events:["orientationchange","devicepixelratiochange"]},sensors:{create:function(t,n,o){let r=null,s=null,c=null,u=null,h=0;function f(){u&&d(u),u=setTimeout(l(()=>{p(),u=null}),y)}function p(){r&&(t.push(r),r=null),s&&(t.push(s),s=null),c&&(t.push(c),c=null)}const m=a(n=>{const e=n,i=e.timeStamp,o=e.acceleration,s=e.accelerationIncludingGravity,c=e.rotationRate;if(!o&&!s&&!c||null===o?.x&&null===o?.y&&null===o?.z&&null===s?.x&&null===s?.y&&null===s?.z&&null===c?.alpha&&null===c?.beta&&null===c?.gamma)return;if(!r)return r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();if(r.samples.ts.length>=50)return t.push(r),r={name:"sensors",type:"motion",timestamp:Date.now(),interval:e.interval??null,samples:{ax:[o?.x??0],ay:[o?.y??0],az:[o?.z??0],agx:[s?.x??0],agy:[s?.y??0],agz:[s?.z??0],rrAlpha:[c?.alpha??0],rrBeta:[c?.beta??0],rrGamma:[c?.gamma??0],ts:[i]}},void f();const a=r.samples;a.ax.push(o?.x??0),a.ay.push(o?.y??0),a.az.push(o?.z??0),a.agx.push(s?.x??0),a.agy.push(s?.y??0),a.agz.push(s?.z??0),a.rrAlpha.push(c?.alpha??0),a.rrBeta.push(c?.beta??0),a.rrGamma.push(c?.gamma??0),a.ts.push(i),f()}),w=a(n=>{const e=n;if(null==e.alpha&&null==e.beta&&null==e.gamma)return;const i=e.timeStamp,o=e.webkitCompassHeading??0;if(!s)return s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();if(s.samples.ts.length>=50)return t.push(s),s={name:"sensors",type:"orientation",timestamp:Date.now(),absolute:h||e.absolute,samples:{alpha:[e.alpha??0],beta:[e.beta??0],gamma:[e.gamma??0],compassHeading:[o],ts:[i]}},void f();const r=s.samples;r.alpha.push(e.alpha??0),r.beta.push(e.beta??0),r.gamma.push(e.gamma??0),r.compassHeading.push(o),r.ts.push(i),f()}),v=a(n=>{const e=n.value;if(null==e)return;const i=n.timeStamp;return c?c.samples.ts.length>=50?(t.push(c),c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f()):(c.samples.lux.push(e),c.samples.ts.push(i),void f()):(c={name:"sensors",type:"light",timestamp:Date.now(),samples:{lux:[e],ts:[i]}},void f())});return x(o,"motion")&&e(window,"devicemotion",m),x(o,"orientation")&&("ondeviceorientationabsolute"in window?(h=1,e(window,"deviceorientationabsolute",w)):e(window,"deviceorientation",w)),x(o,"light")&&e(window,"devicelight",v),function(){i(window,"devicemotion",m),i(window,h?"deviceorientationabsolute":"deviceorientation",w),i(window,"devicelight",v),u&&(d(u),u=null),p()}},layer:"behavioral",events:["motion","orientation","light"]},"network-request":{create:function(t){var e;const i=function(t,e,i,o=f){if("undefined"==typeof PerformanceObserver)return w;let r=null;try{r=new PerformanceObserver(n=>{for(const r of n.getEntries()){const n=r;o.has(n.initiatorType)&&(e(n.name)||t(m(n,i)))}}),r.observe({type:"resource",buffered:1})}catch{return n.warn("network-request","PerformanceObserver failed to start"),w}return function(){r?.disconnect(),r=null}}(function(n){s(()=>t.push(n))},(e=t.ignoredOrigins,function(t){try{return e.has(new URL(t).origin)}catch{return 0}}),t.sanitizeUrl);return function(){i()}},layer:"session"},screen:{create:function(t){const n=s(()=>function(){const t=window.screen;return{name:"screen",timestamp:Date.now(),availWidth:t.availWidth,availHeight:t.availHeight,width:t.width,height:t.height,colorDepth:t.colorDepth,pixelDepth:t.pixelDepth,availLeft:t.availLeft??0,availTop:t.availTop??0,orientation:t.orientation?{type:t.orientation.type,angle:t.orientation.angle}:null,isExtended:t.isExtended??0,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio}}}());return n&&t.push(n),()=>{}},layer:"session"}},W=Object.keys(Q),tt=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^0b[01]+$/i,/^0o[0-7]+$/i,/^0x[0-9a-f]+$/i,/^[a-z][a-z0-9]{1,12}:[A-Za-z0-9+/=_-]{6,}$/i,/^[a-z]{2,8}_(?=.*\d)[A-Za-z0-9]{3,}$/,/^\d{4,}$/,/@/,/^[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{10,}$/,/^[A-Za-z0-9_-]{20,}={0,2}$/,/^[0-9a-f]{7,}$/i];function nt(t){try{const n=new URL(t,location.href);n.username="",n.password="",n.hash="";const e=[...n.searchParams.keys()],i=e.length>0?"?"+e.map(t=>`${encodeURIComponent(t)}=<redacted>`).join("&"):"";n.search="",n.pathname=n.pathname.split("/").map(t=>""!==t&&function(t){for(const n of tt)if(n.test(t))return 1;return 0}(t)?":param":t).join("/");const o=n.origin+n.pathname+i;return o.length>2048?o.slice(0,2048):o}catch{return""}}const et={flush:{intervalMs:2e3,maxIntervalMs:3e4,size:50,backoffFailureThreshold:2},queue:{size:100}};function it(){const t={};for(const n of W)t[n]=st(n,void 0,1);return t}function ot(t){const n={};for(const e of W)n[e]=st(e,void 0,t[Q[e].layer]??0);return n}function rt(t){const n={};for(const e of W){const i=t[e];n[e]=st(e,i,i?.enabled??0)}return n}function st(t,n,e){const i=Q[t]?.events??[];if(0===i.length)return{enabled:e};const o=n?.events,r={};for(const t of i)r[t]={enabled:o?.[t]??1};return{enabled:e,events:r}}function ct(t){if(!t)return null;const n=t.split(".")[1],e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}const at=function(t,n=30){if(!t)return 1;const e=ct(t);return e&&"number"==typeof e.exp?1e3*e.exp<=Date.now()+1e3*n:1};async function lt(t,n){return globalThis.navigator&&"locks"in globalThis.navigator&&"request"in globalThis.navigator.locks&&"query"in globalThis.navigator.locks?navigator.locks.request(t,{mode:"exclusive"},async()=>c(n)):c(n)}const ut="__tri",dt=`${ut}_activity_token`,ht=`${ut}_activity_id`,ft=`${ut}_activity_status`,pt="__tri_activity_lock";class mt{constructor(t){this.context=t,this.u=null,this.h=null,this.p=null,this.m=null,this.v=0}getToken(){return this.u}getActivityId(){return this.h??""}isActive(){return"ACTIVE"===this.p&&null!==this.u}async start(){return this.v=1,this.m||(this.m=this.k()),this.m}async stop(){this.v=0,this.T(null),this.m=null,this.u&&await this.context.stopActivity(),this._(null)}async refresh(){if(!this.v)return;const t=this.u;await lt(pt,async()=>{if(this.u&&this.u!==t&&!at(this.u)&&"ACTIVE"===this.p)return;const n=this.I();n&&n.token!==t&&!at(n.token)&&"ACTIVE"===n.activityStatus?this._(n):(this.S(),await this.A())})}async k(){try{if(this.u&&!at(this.u))return;await lt(pt,async()=>{await this.A()})}finally{this.m=null}}async A(){const t=this.I();if(t&&!at(t.token)&&"ACTIVE"===t.activityStatus)return void this._(t);t&&this.S();const n=await this.context.startActivity();if(!n.ok)return;if(!n.data.token)return;const e=n.data;this._(e),this.M(e)}I(){const[t,n,e]=[q.get(dt),q.get(ht),q.get(ft)];return t&&n&&e?{token:t,activityId:n,activityStatus:e}:((t||n||e)&&this.S(),null)}M(t){q.set(dt,t.token),q.set(ht,t.activityId),q.set(ft,t.activityStatus)}S(){this.T(null),this._(null)}T(t){if(!t)return q.remove(dt),q.remove(ht),void q.remove(ft);q.set(dt,t.token),q.set(ht,t.activityId),q.set(ft,t.activityStatus)}_(t){if(!t)return this.u=null,this.h=null,void(this.p=null);this.u=t.token,this.h=t.activityId,this.p=t.activityStatus}}const wt=[401,403,409],yt=Object.freeze({tab:80,navigation:80,visibility:80,network:80,screen:80,fingerprint:80,pointer:60,keystroke:60,autofill:60,change:60,form:60,clipboard:60,selection:60,focus:60,viewport:60,network_request:60,scroll:40,sensors:40});function vt(t){return"pointer"===t.name&&"move"===t.phase||"viewport"===t.name&&"resize"===t.type?40:yt[t.name]}const gt=new Array(256);for(let t=0;t<256;t++)gt[t]=(t+256).toString(16).slice(1);const bt=new Uint8Array(16);function kt(t){return gt[t[0]]+gt[t[1]]+gt[t[2]]+gt[t[3]]+"-"+gt[t[4]]+gt[t[5]]+"-"+gt[t[6]]+gt[t[7]]+"-"+gt[t[8]]+gt[t[9]]+"-"+gt[t[10]]+gt[t[11]]+gt[t[12]]+gt[t[13]]+gt[t[14]]+gt[t[15]]}function Tt(){return crypto.randomUUID()}function _t(){return crypto.getRandomValues(bt),bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}function It(){for(let t=0;t<16;t++)bt[t]=256*Math.random()|0;return bt[6]=15&bt[6]|64,bt[8]=63&bt[8]|128,kt(bt)}const xt=function(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return Tt;if("function"==typeof crypto.getRandomValues)return _t}return It}();function St(){return xt()}class Et{constructor(t,n){this.D=t,this.P=n,this.C=[],this.R=null,this.L=[],this.$=null,this.v=0,this.U=1,this.O=0,this.q=0,this.B=t.flush.intervalMs}push(t){if(this.v){if(this.C.length<this.j()?this.C.push(t):this.H(t),this.U)return this.C.length>=this.D.flush.size?(d(this.R),this.R=null,void this.flush("capacity")):void this.N()}else n.warn("Transport","push() called before start() — event dropped")}flush(t){if(this.v&&this.P.isActivityActive())try{if("lifecycle"===t)return void this.F();if(0===this.C.length)return;const e=this.X(t);this.P.ingest(e,0).then(t=>this.K(t,e)).catch(()=>{n.warn("Transport","ingest threw unexpectedly — batch dropped")}),this.C.length>0&&this.N()}catch(t){n.warn("Transport","flush() threw unexpectedly:",t)}}start(){this.v||(this.v=1,this.U="undefined"!=typeof navigator?navigator.onLine:1)}stop(){if(!this.v)return Promise.resolve();d(this.R),this.R=null,d(this.$),this.$=null;const t=this.F();return this.v=0,t}onConnectionChange(){const t="undefined"!=typeof navigator?navigator.onLine:1;if(t!==this.U){if(this.U=t,!this.U)return d(this.R),this.R=null,d(this.$),void(this.$=null);this.C.length>0&&this.N(),this.L.length>0&&this.V()}}N(){this.v&&this.U&&null===this.R&&(this.R=u(()=>{this.R=null,this.flush("interval")},this.B))}V(){this.v&&this.U&&null===this.$&&(this.$=u(()=>{this.$=null,this.Y()},this.B))}Y(){if(!this.v||!this.U||0===this.L.length||!this.P.isActivityActive())return;const t=this.L.shift();this.P.ingest(t.batch,0).then(n=>this.J(n,t)).catch(()=>{n.warn("Transport","retry drain ingest threw unexpectedly — batch dropped"),this.L.length>0&&this.V()})}G(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.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.L.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.L.length>0&&this.V());this.tt(),this.G(e.batch,e.attempts+1)}else this.L.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.P.isActivityActive())return Promise.resolve();const t=[];for(const e of this.L)t.push(this.P.ingest(e.batch,1).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.L=[],this.C.length>0){const e=this.X("lifecycle");t.push(this.P.ingest(e,1).catch(()=>{n.warn("Transport","lifecycle ingest threw — batch dropped")}))}return Promise.allSettled(t).then(()=>{})}H(t){const n=vt(t);for(let e=0;e<this.C.length;e++)if(vt(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)}}X(t){const n="lifecycle"===t?this.C.splice(-this.D.flush.size):this.C.splice(0,this.D.flush.size);return{activityId:"",batchId:St(),batchSequence:this.q++,clientTimestamp:Date.now(),schemaVersion:"0.1.0",sdkVersion:"0.4.0-rc.0",sdkPlatform:"web",tabId:this.P.getTabId(),events:n}}W(t){if(t.ok)return 0;switch(t.kind){case"timeout":case"server":case"rate_limited":return 1;default:return 0}}}const At="tri:bcast:";const Mt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return 0;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return 0}}()?class{constructor(t){this.seq=0,this.closed=0,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${At}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>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=St(),window.addEventListener("storage",this.onStorageEvent)}postMessage(t){if(this.closed)return;const n=`${At}${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=1,window.removeEventListener("storage",this.onStorageEvent),this.listeners.clear())}}:class{constructor(t){n.warn("BroadcastChannel","BroadcastChannel is unavailable and localStorage is not writable in this context. Cross-tab discovery is disabled; tab count will always be reported as 1.")}postMessage(t){}addEventListener(t,n){}removeEventListener(t,n){}close(){}},Dt="__tri_tabId";class Pt{constructor(t){this.context=t,this.nt="",this.v=0,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=1,this.nt=this.lt(),this.ut(),this.dt({type:"hello",tabId:this.nt,ts:Date.now()}),this.ht(),this.ft("active"),this.wt())}stop(){this.v&&(this.v=0,this.ft("inactive"),this.dt({type:"bye",tabId:this.nt,ts:Date.now()}),this.yt(this.vt()),this.gt(),this.bt(),this.kt())}getTabId(){return this.nt}queryTabsNumber(){return this.rt.size+1}ut(){try{this.et=new Mt("__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)}gt(){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)}bt(){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})}lt(){const t=B.get(Dt);if(t)return t;const n=St();return B.set(Dt,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 Ct=globalThis.CompressionStream,Rt=globalThis.Response,zt=globalThis.Blob,Lt=new TextEncoder;let $t=null;async function Ut(t){const e=await async function(t){if("function"!=typeof Ct)return null;try{const n=Lt.encode(t),e=new zt([n]).stream().pipeThrough(new Ct("gzip"));return await new Rt(e).arrayBuffer()}catch(t){return n.warn("compression","Native gzip failed:",t),null}}(t);return null!==e?e:async function(t){try{const e=await function(){if(null===$t){const t=function(t,e=1e4){let i=null;const o=new Promise(t=>{i=u(()=>{n.warn("import",`Import timed out after ${e}ms`),t(null)},e)}),r=Promise.resolve().then(t).catch(t=>(n.warn("import","Import failed:",t),null));return Promise.race([r,o]).finally(()=>{d(i)})}(()=>Promise.resolve().then(function(){return require("./chunks/browser-D1C751kT.cjs")}),1e4);$t=t,t.then(n=>{null===n&&u(()=>{$t===t&&($t=null)},1e4)})}return $t}();if(null===e)return null;const{gzipSync:i}=e,o=i(Lt.encode(t));return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}catch(t){return n.warn("compression","fflate gzip failed:",t),null}}(t)}function Ot(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 qt="function"==typeof globalThis.fetch?globalThis.fetch.bind(globalThis):void 0;class Bt{constructor(t){this.context=t}stop(){}async report(t,e){const i={name:t,metadata:e,timestamp:Date.now(),activityId:this.context.getActivityId()??""};try{const o=await this.context.reportEvent(i);if(o.ok)return o;n.warn("EventReport","Failed to report event:",t,e,"with result:",o)}catch(i){n.warn("EventReport","Failed to report event:",t,e,"with error:",i)}}}const jt=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY","DETAILS","LABEL","OPTION","FIELDSET"]),Ht=new Set(["button","link","tab","menuitem","menuitemcheckbox","menuitemradio","checkbox","radio","switch","slider","spinbutton","combobox","listbox","option","searchbox","textbox","treeitem"]),Nt=255;function Ft(t,n,e){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(g(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const l=t.hasAttribute("readonly");l&&!_("readonly",e)&&(i.readOnly=l);const u=t.hasAttribute("required");u&&!_("required",e)&&(i.required=u);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:I(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Xt(t,n){let e=0;const i=[];return function(t){return jt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return g(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Ht.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return 0;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Kt(t){return t>=20}function Vt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Yt(t){return 1==t.disabled||"true"===t.getAttribute("aria-disabled")}function Jt(t,n=0){if(n)return null;const e=Zt(t,"labelledby");if(e)return{text:Wt(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=Qt(t);if(i)return{text:Wt(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?Gt(n):null}(t);if(o)return{text:Wt(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?Gt(n):null}(t);if(r)return{text:Wt(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:Wt(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:Wt(c),resolutionMethod:"title",confidence:"low"};const a=Zt(t,"describedby");if(a)return{text:Wt(a),resolutionMethod:"aria-describedby",confidence:"low"};const l=Gt(t);return l?{text:l,resolutionMethod:"text-content",confidence:"low"}:null}function Gt(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Nt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=Gt(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Nt))break}return Wt(e)}function Zt(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=Qt(n)??Gt(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function Qt(t){return t?.getAttribute("aria-label")?.trim()??null}function Wt(t){return t.length>Nt?t.slice(0,Nt)+"...":t}function tn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class nn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function en(t,o){const{collectors:r,sdk:s}=t;let c=null,l=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===qt)return{ok:0,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,l=0;a=u(()=>{l=1,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:1}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:1,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:1,body:t};try{return{ok:1,body:JSON.stringify(t)}}catch{return{ok:0}}}(r.body);if(!t.ok)return d(a),p(),{ok:0,kind:"serialize"};f=t.body}try{const n=await qt(s,{method:t,headers:Ot({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:0,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:0,kind:"client",status:m}:{ok:0,kind:"server",status:m};if(204===n.status)return{ok:1,data:void 0,status:204};try{return{ok:1,data:await n.json(),status:n.status}}catch{return c.signal.aborted?l?{ok:0,kind:"timeout"}:{ok:0,kind:"abort"}:{ok:0,kind:"parse",status:n.status}}}catch{return l?{ok:0,kind:"timeout"}:c.signal.aborted?{ok:0,kind:"abort"}:{ok:0,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!wt.includes(a.status)||0==r?.refreshable)return c;var a;const l=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return l&&l!==s?t(l):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let l;try{l=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await Ut(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:0,kind:"serialize"}}return e.post("/events/capture",{body:l.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===l.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:1,...o()}),{refreshable:0})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>l?.getToken()??null,refresh:async()=>l?.refresh()??Promise.resolve(),getActivityId:()=>l?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||1!=t.data.eventsCollectionEnabled)return{status:"collection-disabled"};l=new mt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Et(et,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>l?.isActive()??0});const p=r.tab;f=new Pt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>l?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new nn(6),i=new nn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||g(e,"body"))break;e=b(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=tn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Ft(r,s,tn(r)),{score:l,reasons:u}=Xt(r,c);if(e.push(a),!Kt(l))continue;const d=Jt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:l,reasons:u})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Ft(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Xt(t,0);return{interactive:Kt(i),...o.length>0?{reasons:o}:{},disabled:Yt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Vt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let l=null;return e||(l=a.interactive?Jt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...l?{label:l}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??0}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new Bt({getActivityId:()=>l?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:l,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let on=class t{constructor(){this._t=0,this.D=null,this.It=null,this.xt="idle"}static get instance(){return t.o||(t.o=new t),t.o}async setup(t){if("idle"!==this.xt)return n.fatal("error","setup()","called more than once — ignoring."),"init-failed";try{const e=function(t){if("undefined"==typeof document)return n.fatal("error","IncodeTRI","TRI is not available in a non-browser environment."),null;if(!t?.token)return n.fatal("error","SDK","token is required."),null;if(!t.apiURL)return n.fatal("error","SDK","Couldn't initialise SDK — apiURL isn't provided."),null;const{element:e,content:i}=t.capture??{},o={token:t.token,capture:{element:e??"redact",content:i??"off"},profileId:t.profileId,api:{version:t.apiVersion??"1.0",url:t.apiURL},sanitizeUrl:(r=t.sanitizeUrl,r?function(t){return s(()=>r(t,nt))??nt(t)}:nt),DEBUG:t.DEBUG??0};var r;return void 0===t.collectors&&void 0===t.layers?{sdk:o,collectors:it()}:void 0!==t.collectors?{sdk:o,collectors:rt(t.collectors)}:{sdk:o,collectors:ot(t.layers)}}(t);if(!e)return"init-failed";n.DEBUG=e.sdk.DEBUG;const i=await en(e,{getProfileId:()=>this.St()});return"collection-disabled"===i.status?(n.fatal("warn","setup()","Collection is disabled for the provided API Key."),"collection-disabled"):"init-failed"===i.status?"init-failed":(this.D=e,this.It=i.managers,this.xt="ready",this.Et(e.sdk.profileId),"ready")}catch(t){return n.warn("setup()","failed:",t),"init-failed"}}async start(){if("idle"===this.xt)return n.warn("start()","start() requires a prior successful setup() — ignoring."),this.xt;if("ready"!==this.xt)return n.fatal("warn","start()","TRI is either already started or isn't ready — ignoring."),this.xt;this.xt="starting";const t=++this._t;return await this.k(t),this.xt}async stop(){n.warn("stop()","called");const t=this.It;return t?(++this._t,t.lifecycleManager.stop(),t.collectorManager.stop(),t.tabManager.stop(),t.eventReportManager.stop(),this.xt="ready",this.At(t)):Promise.resolve(this.xt)}async reset(){const t=this.stop();return this.xt="idle",this.D=null,this.It=null,q.remove("__tri_profile_id"),t.then(()=>this.xt)}async At(t){return await function(t){let n=null;const e=new Promise(t=>{n=u(t,2e3)});return Promise.race([t.finally(()=>d(n)),e])}(Promise.resolve(t.transportManager.stop())),await t.activityManager.stop(),this.xt}reportEvent(t,e){"started"===this.xt?this.It?c(()=>this.It.eventReportManager.report(t,e)):n.warn("reportEvent()","reportEvent() called but managers are unavailable — dropping event."):n.warn("reportEvent()","reportEvent() called before start() completed — dropping event.")}setProfileId(t){"started"===this.xt?this.D?.sdk&&(this.D.sdk.profileId=t,this.Et(t)):n.warn("setProfileId()","setProfileId() called before start() completed — ignoring.")}async linkInterview(t){if("started"!==this.xt||!this.It)return n.warn("linkInterview()","linkInterview() called before start() completed — ignoring."),0;if(!t)return n.warn("linkInterview()","linkInterview() called without sessionToken — ignoring."),0;try{return(await this.It.falconServiceManager.api.linkInterview(t)).ok}catch(t){return n.warn("linkInterview()","failed:",t),0}}St(){return this.D?.sdk?.profileId??q.get("__tri_profile_id")??null}Et(t){t&&q.set("__tri_profile_id",t)}async k(t){const e=this.It;if(e){try{if(await e.activityManager.start(),t!==this._t)return;if(e.transportManager.start(),await e.tabManager.start(),t!==this._t)return;e.lifecycleManager.start(),e.collectorManager.autocapture()}catch(e){return n.warn("start()","failed during monitoring start:",e),void(t===this._t&&(this.xt="ready"))}t===this._t&&(this.xt="started")}}};on.o=null;const rn=on.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=0,c=()=>{};i&&(r=u(()=>{s=1,o.abort()},i));const a=n?.signal;if(a)if(a.aborted)o.abort();else{const t=()=>o.abort();a.addEventListener("abort",t,{once:1}),c=()=>a.removeEventListener("abort",t)}try{const n=await fetch(`${e}/api/v1/sdk/init`,{method:"POST",headers:{"content-type":"application/json","x-api-key":t,"x-api-version":"1.0"},signal:o.signal});if(!n.ok){let t=n.statusText;try{const e=await n.json();e.errorMessage&&(t=e.errorMessage)}catch{}return{token:null,eventsCollectionEnabled:0,error:{status:n.status,message:t}}}return await n.json()}catch(t){throw new Error((s?"[TRI] createSession timed out":"[TRI] Failed to create session:")+" "+t.message)}finally{d(r),c()}},exports.default=rn;
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(L))},i.async=!0,i.src=t,r.appendChild(i)})}(t)).then(M)}const R="API key required";var z="3.12.9";const L="Failed to load the JS script of the agent",$="9319",U={scriptUrl:"https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js"};function 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(R);return function(t,n){const e=[],[i,o]=function(t){const n=function(t){const n=[...t];return{current:()=>n[0],postpone(){const t=n.shift();void 0!==t&&n.push(t)},exclude(){n.shift()}}}(t),e=function(){let t=0;return()=>Math.random()*Math.min(3e3,100*Math.pow(2,t++))}(),i=new Set;return[n.current(),(t,o)=>{let r;const s=o instanceof Error?o.message:"";if(s===D||s===C)n.exclude(),r=0;else if(s===$)n.exclude();else if(s===L){const e=Date.now()-t.getTime()<50,o=n.current();o&&e&&!i.has(o)&&(i.add(o),r=0),n.postpone()}else n.postpone();const c=n.current();return void 0===c?void 0:[c,null!=r?r:t.getTime()+e()-Date.now()]}]}(t);let r;if(void 0===i)return Promise.reject(new TypeError("The list of script URL patterns is empty"));const s=t=>{const i=new Date,c=n=>e.push({url:t,startedAt:i,finishedAt:new Date,error:n}),a=n(t);return a.then(()=>c(),c),a.catch(t=>{if(null!=r||(r=t),e.length>=5)throw r;const n=o(i,t);if(!n)throw r;const[c,a]=n;return(u=a,new Promise(t=>setTimeout(t,u))).then(()=>s(c));var u})};return s(i).then(t=>[t,e])}(function(t,n){return(Array.isArray(t)?t:[t]).map(t=>function(t,n){const e=encodeURIComponent;return t.replace(/<[^<>]+>/g,t=>"<version>"===t?"3":"<apiKey>"===t?e(n):"<loaderVersion>"===t?e(z):t)}(String(t),n))}(s,r),P)}).catch(t=>{throw a(),function(t){return t instanceof Error&&t.message===$?new Error(L):t}(t)}).then(([t,n])=>(a(),t.load({...o,ldi:{attempts:n,visibilityStates:c}})))}({apiKey:t.apiKey,region:t.region,endpoint:t.endpoint,scriptUrlPattern:t.scriptUrlPattern}).catch(t=>{throw H=null,t}),H)}(t),e=await n.get({timeout:t.timeoutMs,extendedResult:!0});if(!e.visitorId)return null;const i=t.cacheTtlMs??2592e6;return i>0&&function(t,n,e){const i={visitorId:t,requestId:n,expiresAt:Date.now()+e};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.R=null,this.L=[],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.R),this.R=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.R),this.R=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.R),this.R=null,d(this.$),void(this.$=null);this.P.length>0&&this.N(),this.L.length>0&&this.V()}}N(){this.v&&this.U&&null===this.R&&(this.R=l(()=>{this.R=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.L.length||!this.C.isActivityActive())return;const t=this.L.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.L.length>0&&this.V()})}G(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.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.L.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.L.length>0&&this.V());this.tt(),this.G(e.batch,e.attempts+1)}else this.L.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.L)t.push(this.C.ingest(e.batch,!0).catch(()=>{n.warn("Transport","lifecycle retry ingest threw — batch dropped")}));if(this.L=[],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.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 Rt="function"==typeof BroadcastChannel?BroadcastChannel:function(){if("undefined"==typeof Storage||"undefined"==typeof window)return!1;try{const t="__tri_bcast_probe__";localStorage.setItem(t,"1");const n="1"===localStorage.getItem(t);return localStorage.removeItem(t),n}catch{return!1}}()?class{constructor(t){this.seq=0,this.closed=!1,this.listeners=new Set,this.onStorageEvent=t=>{if(this.closed)return;if(!t.key||!t.key.startsWith(`${Pt}${this.channelName}:`))return;if(null===t.newValue)return;let n;s(()=>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(){}},zt="__tri_tabId";class Lt{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 Rt("__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(zt);if(t)return t;const n=Dt();return B.set(zt,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){const i=t.tagName.toLowerCase(),o=function(t){const n=t.parentElement?.children??[],e=Math.min(n.length,1e3);let i=e-1,o=0,r=0;for(let i=0;i<e;i++){r++;const e=n[i];if(b(e,t.tagName)&&o++,e===t)break}return{siblings:i,ofType:o,child:r}}(t),r=function(t,n){const e=function(t){if(!t)return null;const n=t.getAttribute("data-tri-redact-attrs");return n?n.split(",").map(t=>t.trim().toLowerCase()):null}(t),i={},o=t.id;o&&!_("id",e)&&(i.id=o);const r=t.getAttribute("autocomplete");r&&!_("autocomplete",e)&&(i.autocomplete=r);const s=t.getAttribute("aria-invalid");s&&!_("aria-invalid",e)&&(i.ariaInvalid=s);const c=t.getAttribute("tabindex");c&&!_("tabindex",e)&&(i.tabIndex=parseInt(c,10));const a=function(t){return t.getAttribute("data-testid")??t.getAttribute("data-cy")??null}(t);a&&!_("data-testid",e)&&(i.testId=a);const u=t.hasAttribute("readonly");u&&!_("readonly",e)&&(i.readOnly=u);const l=t.hasAttribute("required");l&&!_("required",e)&&(i.required=l);const d=t.getAttribute("contenteditable");d&&!_("contenteditable",e)&&(i.contentEditable="true"===d||""===d);const h=t.getAttribute("href");h&&!_("href",e)&&(i.href={...n?{}:{url:h},external:x(h)});const f=t.getAttribute("role");f&&!_("role",e)&&(i.role=f);const p=t.getAttribute("type");p&&!_("type",e)&&(i.type=p);const m=t.getAttribute("name");m&&!_("name",e)&&(i.name=m);const w=t.getAttribute("placeholder");!w||n||_("placeholder",e)||(i.placeholder=w);const y=Array.from(t.classList).slice(0,5);y.length>0&&!_("class",e)&&(i.classes=y);const v=t.getAttribute("alt");return!v||n||_("alt",e)||(i.alt=v),Object.keys(i).length?i:null}(t,n);return{tagName:i,frame:e,...r?{attributes:r}:{},...o?{nth:o}:{}}}function Jt(t,n){let e=0;const i=[];return function(t){return Xt.has(t.tagName)}(t)&&(e+=40,i.push("native")),function(t){return t.hasAttribute("data-tri-interactive")}(t)&&(e+=40,i.push("tri-interactive")),function(t){return b(t,"a")&&t.hasAttribute("href")}(t)&&(e+=15,i.push("has-href")),function(t){const n=t.getAttribute("role");return null!==n&&Kt.has(n)}(t)&&(e+=30,i.push("role")),function(t){return t.hasAttribute("onclick")||t.hasAttribute("ng-click")||t.hasAttribute("data-action")||t.hasAttribute("@click")}(t)&&(e+=20,i.push("click-handler")),function(t){const n=t.getAttribute("tabindex");if(null===n)return!1;const e=parseInt(n,10);return null!==e&&e>=0}(t)&&(e+=10,i.push("tabindex")),(t.id||t.getAttribute("data-testid"))&&(e+=5,i.push("has-id")),n>0&&(e+=Math.round(15/n),i.push("depth")),{score:e,reasons:i}}function Gt(t){return t>=20}function Zt(t){return null!==t&&t.width>0&&t.height>0&&t.y<window.innerHeight&&t.y+t.height>0&&t.x<window.innerWidth&&t.x+t.width>0}function Qt(t){return!0===t.disabled||"true"===t.getAttribute("aria-disabled")}function Wt(t,n=!1){if(n)return null;const e=nn(t,"labelledby");if(e)return{text:on(e),resolutionMethod:"aria-labelledby",confidence:"high"};const i=en(t);if(i)return{text:on(i),resolutionMethod:"aria-label",confidence:"high"};const o=function(t){if(!t.id)return null;const n=document.querySelector(`label[for="${CSS.escape(t.id)}"]`);return n?tn(n):null}(t);if(o)return{text:on(o),resolutionMethod:"html-for",confidence:"high"};const r=function(t){const n=t.closest("label");return n?tn(n):null}(t);if(r)return{text:on(r),resolutionMethod:"wrapping-label",confidence:"high"};const s=function(t){const n=t.getAttribute("placeholder");return n?.trim()??null}(t);if(s)return{text:on(s),resolutionMethod:"placeholder",confidence:"low"};const c=function(t){const n=t.getAttribute("title");return n?.trim()??null}(t);if(c)return{text:on(c),resolutionMethod:"title",confidence:"low"};const a=nn(t,"describedby");if(a)return{text:on(a),resolutionMethod:"aria-describedby",confidence:"low"};const u=tn(t);return u?{text:u,resolutionMethod:"text-content",confidence:"low"}:null}function tn(t,n=0){if(n>8)return"";if(v(t))return function(t){return t?t.trim().split(/(\s+)/).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,Vt):null}(t.textContent)??"";if(!t.childNodes?.length)return"";let e="";for(const i of t.childNodes){const t=tn(i,n+1);if(t&&(e=e?`${e} ${t}`:t,e.length>=Vt))break}return on(e)}function nn(t,n){const e="labelledby"===n?"aria-labelledby":"aria-describedby",i=t?.getAttribute(e);if(!i)return null;const o=i.split(/\s+/),r=[];for(const t of o){const n=document.getElementById(t);if(!n)continue;const e=en(n)??tn(n);e.length&&r.push(e)}return r.length?r.join(" "):null}function en(t){return t?.getAttribute("aria-label")?.trim()??null}function on(t){return t.length>Vt?t.slice(0,Vt)+"...":t}function rn(t){const n=t.getBoundingClientRect();return{x:n.x,y:n.y,width:n.width,height:n.height}}class sn{constructor(t){this.capacity=t,this.cache=new Map}get(t){return this.cache.get(t)}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t&&this.cache.delete(t)}this.cache.set(t,n)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}async function cn(t,o){const{collectors:r,sdk:s}=t;let c=null,u=null,h=null,f=null;try{c=function(t){"undefined"!=typeof document&&"function"==typeof globalThis.fetch||n.warn("FalconService","createFalconServiceManager called in a non-browser environment — all requests will resolve with { ok: false, kind: 'network' }.");const e=function(t){const n=t?.timeout,e=t?.baseUrl??"",i=t?.api;async function o(t,o,r){if(void 0===Nt)return{ok:!1,kind:"network"};const s=e?`${e}${o}`:o,c=new AbortController;let a=null,u=!1;a=l(()=>{u=!0,c.abort()},n);const h=r?.signal;let f,p=()=>{};if(h)if(h.aborted)c.abort();else{const t=()=>c.abort();h.addEventListener("abort",t,{once:!0}),p=()=>h.removeEventListener("abort",t)}if(null!=r&&"body"in r&&null!=r.body){const t=function(t){if(null==t)return{ok:!0,body:void 0};if("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)||t instanceof Blob||t instanceof FormData||t instanceof URLSearchParams||t instanceof ReadableStream)return{ok:!0,body:t};try{return{ok:!0,body:JSON.stringify(t)}}catch{return{ok:!1}}}(r.body);if(!t.ok)return d(a),p(),{ok:!1,kind:"serialize"};f=t.body}try{const n=await Nt(s,{method:t,headers:Ht({token:r?.token,profileId:r?.profileId,contentType:r?.contentType,contentEncoding:r?.contentEncoding,api:i,hasBody:void 0!==f,customHeaders:r?.customHeaders}),body:f,signal:c.signal,keepalive:r?.keepalive});if(!n.ok)return 429===(m=n.status)?{ok:!1,kind:"rate_limited",status:m}:m>=400&&m<500?{ok:!1,kind:"client",status:m}:{ok:!1,kind:"server",status:m};if(204===n.status)return{ok:!0,data:void 0,status:204};try{return{ok:!0,data:await n.json(),status:n.status}}catch{return c.signal.aborted?u?{ok:!1,kind:"timeout"}:{ok:!1,kind:"abort"}:{ok:!1,kind:"parse",status:n.status}}}catch{return u?{ok:!1,kind:"timeout"}:c.signal.aborted?{ok:!1,kind:"abort"}:{ok:!1,kind:"network"}}finally{d(a),p()}var m}return{post:async function(t,n){return o("POST",t,n)},get:async function(t,n){return o("GET",t,n)}}}({baseUrl:`${t.api.url}/api/v1`,timeout:1e4,api:{version:t.api.version}}),i=function(t){const{getToken:e,refresh:i}=t;let o=null;return{withAuth:async function(t,r){if(o){const n=await o;if(n)return t(n)}const s=e()??"",c=await t(s);if((a=c).ok||"client"!==a.kind||!gt.includes(a.status)||!1===r?.refreshable)return c;var a;const u=await(o||(o=async function(){try{return await i(),e()}catch(t){return n.warn("AuthMiddleware","auth refresh failed",t),null}}().finally(()=>{o=null}),o));return u&&u!==s?t(u):c}}}(t),o=()=>({profileId:t.getProfileId()??void 0});return{api:{ingest:async function(n,r){return i.withAuth(async i=>{const{events:s,...c}=n,a={...c,activityId:t.getActivityId()};let u;try{u=await async function(t,n){const e=function(t,n){const e=[JSON.stringify(t)];for(let t=0;t<n.length;t++)try{e.push(JSON.stringify(n[t]))}catch{}return e.join("\n")}(t,n),i=await jt(e);return i?{type:"gzip",body:i}:{type:"ndjson",body:e}}(a,s)}catch{return{ok:!1,kind:"serialize"}}return e.post("/events/capture",{body:u.body,token:i,keepalive:r,contentType:"ndjson",contentEncoding:"gzip"===u.type?"gzip":void 0,...o()})},{refreshable:!r})},reportEvent:async function(t){return i.withAuth(n=>e.post("/events/report-event",{body:t,token:n,contentType:"json",...o()}))},startActivity:async function(){return e.post("/events/start-activity",{token:t.getSdkToken(),...o()})},stopActivity:async function(){return i.withAuth(t=>e.post("/events/end-activity",{token:t,keepalive:!0,...o()}),{refreshable:!1})},collectionStatus:async function(){return e.get("/sdk/collection-status",{token:t.getSdkToken(),...o()})},linkInterview:async function(t){return i.withAuth(n=>e.post("/events/link-interview",{token:n,contentType:"json",...o(),customHeaders:{"X-Incode-Hardware-Id":t}}))}}}}({api:{version:s.api.version,url:s.api.url},getSdkToken:()=>s.token,getProfileId:()=>o.getProfileId(),getToken:()=>u?.getToken()??null,refresh:async()=>u?.refresh()??Promise.resolve(),getActivityId:()=>u?.getActivityId()??""});const t=await c.api.collectionStatus();if(!t.ok||!0!==t.data.eventsCollectionEnabled)return{status:"collection-disabled"};u=new bt({startActivity:()=>c.api.startActivity(),stopActivity:()=>c.api.stopActivity()}),h=new Ct(st,{ingest:(t,n)=>c.api.ingest(t,n),getTabId:()=>f?.getTabId()??"unknown",isActivityActive:()=>u?.isActive()??!1});const p=r.tab;f=new Lt({push:t=>h?.push(t),events:{state:p.enabled&&p.events.state.enabled,count:p.enabled&&p.events.count.enabled}});const m=function(t){function n(n){"hidden"===document.visibilityState&&t.flush()}function o(n){t.flush(),t.stopTab(),t.getShouldSkipStopActivity()||t.stopActivity()}const r=a(()=>t.onConnectionChange());return{start:function(){e(document,"visibilitychange",n),e(window,"pagehide",o),e(window,"online",r),e(window,"offline",r)},stop:function(){i(document,"visibilitychange",n),i(window,"pagehide",o),i(window,"online",r),i(window,"offline",r)}}}({flush:()=>h?.flush("lifecycle"),stopActivity:async()=>u?.stop(),stopTab:()=>f?.stop(),getShouldSkipStopActivity:()=>(f?.queryTabsNumber()??0)>1,onConnectionChange:()=>h?.onConnectionChange()}),w=function(t){const n=t||"redact",e=new sn(6),i=new sn(6);return{resolve:function(t){if(!t||k(t)||"off"===n)return null;let o=e.get(t);if(o||(o=function(t){if(!t||k(t))return{chain:[],redaction:{level:"ignore",index:-1}};const n=[];let e=t,i=-1;for(;e;){if(k(e))return{chain:[],redaction:{level:"ignore",index:-1}};T(e)&&(i=n.length),n.push(e);const t=e.parentNode;if(!t||b(e,"body"))break;e=g(t)?t.host:t}return{chain:n,redaction:{level:-1===i?"full":"redact",index:i}}}(t.parentElement),e.set(t,o)),"ignore"===o.redaction.level)return null;const r="redact"===o.redaction.level||"redact"===n||T(t);let s=i.get(t);return s||(s=function(t,n,e,i){const o=getComputedStyle(t),r=rn(t),s=function(t,n){const e=[],i=[];for(let o=t.length-1;o>=0;o--){const r=t[o],s=o<=n,c=o+1,a=Yt(r,s,rn(r)),{score:u,reasons:l}=Jt(r,c);if(e.push(a),!Gt(u))continue;const d=Wt(r,s);i.push({...a,...d?{label:d}:{},depth:c,score:u,reasons:l})}return{ancestors:e,interactiveCandidates:i.reverse()}}(n,i),c=Yt(t,e,r),a=function(t,n,e){const{score:i,reasons:o}=Jt(t,0);return{interactive:Gt(i),...o.length>0?{reasons:o}:{},disabled:Qt(t),rendered:"none"!==n?.display,visible:"hidden"!==n?.visibility,inViewport:Zt(e),acceptsPointer:"none"!==n?.pointerEvents,opacity:parseFloat(n?.opacity||"1")}}(t,o,r);let u=null;return e||(u=a.interactive?Wt(t):null),{tagName:c.tagName,frame:c.frame,viewport:{height:window.innerHeight,width:window.innerWidth,scrollX:window.scrollX,scrollY:window.scrollY,dpr:window.devicePixelRatio},attributes:c.attributes,nth:c.nth,...u?{label:u}:{},ancestors:s.ancestors,interactiveCandidates:s.interactiveCandidates,interactivity:a}}(t,o.chain,r,o.redaction.index),i.set(t,s)),s}}}(s.capture?.element),y=new Set;try{y.add(new URL(s.api.url).origin)}catch{}const v=function(t,n,e="on"){const i=new Map;function o(o){if(i.has(o))return;const r=Q[o];if(!r||!function(t,n){return n[t]?.enabled??!1}(o,n))return;const s=n[o],c=r.create(t,e,s&&"events"in s?s.events:void 0);i.set(o,c)}return{start:o,stopCollector:function(t){const n=i.get(t);n&&(n(),i.delete(t))},stop:function(){for(const[,t]of i)t();i.clear()},isRunning:function(t){return i.has(t)},autocapture:function(){for(const t of W)o(t)}}}({push:t=>h?.push(t),resolveElement:t=>w.resolve(t),sanitizeUrl:s.sanitizeUrl,ignoredOrigins:y},r,s.capture?.content),_=new Ft({getActivityId:()=>u?.getActivityId()??"",reportEvent:t=>c.api.reportEvent(t)});return{status:"ready",managers:{falconServiceManager:c,activityManager:u,transportManager:h,tabManager:f,lifecycleManager:m,collectorManager:v,eventReportManager:_}}}catch(t){return n.warn("IncodeTRI","setup() failed during construction:",t),{status:"init-failed"}}}let an=class t{constructor(){this._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;