@imtbl/audience 2.15.0 → 2.15.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +2 -2
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.js +2 -2
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var mn=Object.create;var ut=Object.defineProperty;var wn=Object.getOwnPropertyDescriptor;var bn=Object.getOwnPropertyNames;var vn=Object.getPrototypeOf,In=Object.prototype.hasOwnProperty;var lt=(i,r)=>()=>(i&&(r=i(i=0)),r);var En=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports);var Sn=(i,r,o,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let h of bn(r))!In.call(i,h)&&h!==o&&ut(i,h,{get:()=>r[h],enumerable:!(f=wn(r,h))||f.enumerable});return i};var Bn=(i,r,o)=>(o=i!=null?mn(vn(i)):{},Sn(ut(o,"default",{value:i,enumerable:!0}),i));var U=lt(()=>{});var O=lt(()=>{});var gt=En(ne=>{O();U();Object.defineProperty(ne,"__esModule",{value:!0});ne.clearGlobalNamespace=ne.getGlobalisedValue=void 0;var Tn="globalise__singleton__",xn={},ct=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:xn,Un=(i,r)=>{if(typeof i!="string")throw "Invalid namespace key";if(typeof r!="string")throw "Invalid item key"},dt=i=>`${Tn}${i}`,pt=i=>{let r=ct(),o=dt(i);return r[o]||(r[o]={}),r[o]},On=(i,r)=>pt(i)[r]||void 0,kn=(i,r,o)=>{let f=pt(i);f[r]=o;},Nn=(i,r,o)=>{Un(i,r);let f=On(i,r);return f!==void 0?f:(kn(i,r,o),o)};ne.getGlobalisedValue=Nn;var Ln=i=>{let r=ct(),o=dt(i);r[o]!==void 0&&delete r[o];};ne.clearGlobalNamespace=Ln;});O();U();O();U();O();U();O();U();O();U();O();U();var Te=class{constructor(r=0,o=0,f=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=r,this.resetTtl=f,this.size=0,this.ttl=o;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(r){if(this.has(r)){let o=this.items[r];delete this.items[r],this.size--,o.prev!==null&&(o.prev.next=o.next),o.next!==null&&(o.next.prev=o.prev),this.first===o&&(this.first=o.next),this.last===o&&(this.last=o.prev);}return this}entries(r=this.keys()){return r.map(o=>[o,this.get(o)])}evict(r=!1){if(r||this.size>0){let o=this.first;delete this.items[o.key],--this.size===0?(this.first=null,this.last=null):(this.first=o.next,this.first.prev=null);}return this}expiresAt(r){let o;return this.has(r)&&(o=this.items[r].expiry),o}get(r){let o;if(this.has(r)){let f=this.items[r];this.ttl>0&&f.expiry<=Date.now()?this.delete(r):(o=f.value,this.set(r,o,!0));}return o}has(r){return r in this.items}keys(){let r=[],o=this.first;for(;o!==null;)r.push(o.key),o=o.next;return r}set(r,o,f=!1,h=this.resetTtl){let c;if(f||this.has(r)){if(c=this.items[r],c.value=o,f===!1&&h&&(c.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==c){let a=this.last,y=c.next,w=c.prev;this.first===c&&(this.first=c.next),c.next=null,c.prev=this.last,a.next=c,w!==null&&(w.next=y),y!==null&&(y.prev=w);}}else this.max>0&&this.size===this.max&&this.evict(!0),c=this.items[r]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:r,prev:this.last,next:null,value:o},++this.size===1?this.first=c:this.last.next=c;return this.last=c,this}values(r=this.keys()){return r.map(o=>this.get(o))}};function ft(i=1e3,r=0,o=!1){if(isNaN(i)||i<0)throw new TypeError("Invalid max value");if(isNaN(r)||r<0)throw new TypeError("Invalid ttl value");if(typeof o!="boolean")throw new TypeError("Invalid resetTtl value");return new Te(i,r,o)}var An={max:1e3},ht=(i,r={})=>{let{cache:o,cacheKeyResolver:f=xe,onHit:h,lruOptions:c={}}=r,a={...An,...c},y=o||ft(a.max,a.ttl);function w(...B){let b=f(...B),m=y.get(b);if(y.has(b))return h&&h(b,m,y),m;let p=i.apply(this,B);return y.set(b,p),p}return w._cache=y,w},xe=(...i)=>i.length===0?"no-args":i.map(r=>r===void 0?"undefined":r===null?"null":Array.isArray(r)?`[${xe(...r)}]`:typeof r=="object"?`{${xe(..._n(r))}}`:JSON.stringify(r)).join(","),_n=i=>Object.entries(i).sort((r,o)=>r[0]<o[0]?-1:1);var De=Bn(gt()),Rn=Object.defineProperty,Cn=(i,r)=>{for(var o in r)Rn(i,o,{get:r[o],enumerable:!0});};function Pe(i){throw new Error("Node.js process "+i+" is not supported by JSPM core outside of Node.js")}var j=[],ie=!1,J,me=-1;function $n(){!ie||!J||(ie=!1,J.length?j=J.concat(j):me=-1,j.length&&It());}function It(){if(!ie){var i=setTimeout($n,0);ie=!0;for(var r=j.length;r;){for(J=j,j=[];++me<r;)J&&J[me].run();me=-1,r=j.length;}J=null,ie=!1,clearTimeout(i);}}function Mn(i){var r=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)r[o-1]=arguments[o];j.push(new Et(i,r)),j.length===1&&!ie&&setTimeout(It,0);}function Et(i,r){this.fun=i,this.array=r;}Et.prototype.run=function(){this.fun.apply(null,this.array);};var Dn="browser",Pn="x64",Fn="browser",jn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},qn=["/usr/bin/node"],Gn=[],Vn="v16.8.0",Kn={},zn=function(i,r){console.warn((r?r+": ":"")+i);},Hn=function(i){Pe("binding");},Yn=function(i){return 0},Jn=function(){return "/"},Wn=function(i){},Xn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function R(){}var Zn=R,Qn=[];function ei(i){Pe("_linkedBinding");}var ti={},ni=!1,ii={};function ri(i){Pe("dlopen");}function si(){return []}function oi(){return []}var ai=R,ui=R,Fe=function(){return {}},li=Fe,fi=Fe,hi=R,ci=R,di=R,pi={};function gi(i,r){if(!i)throw new Error(r||"assertion error")}var yi={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},mi=R,wi=R;function bi(){return !1}var vi=R,Ii=R,Ei=R,Si=R,Bi=R,Ai=void 0,_i=void 0,Ti=void 0,xi=R,Ui=2,Oi=1,ki="/bin/usr/node",Ni=9229,Li="node",Ri=[],Ci=R,K={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};K.now===void 0&&(Ue=Date.now(),K.timing&&K.timing.navigationStart&&(Ue=K.timing.navigationStart),K.now=()=>Date.now()-Ue);var Ue;function $i(){return K.now()/1e3}var ke=1e9;function Ne(i){var r=Math.floor((Date.now()-K.now())*.001),o=K.now()*.001,f=Math.floor(o)+r,h=Math.floor(o%1*1e9);return i&&(f=f-i[0],h=h-i[1],h<0&&(f--,h+=ke)),[f,h]}Ne.bigint=function(i){var r=Ne(i);return typeof BigInt>"u"?r[0]*ke+r[1]:BigInt(r[0]*ke)+BigInt(r[1])};var Mi=10,Di={},Pi=0;function z(){return Le}var Fi=z,ji=z,qi=z,Gi=z,Vi=z,Ki=R,zi=z,Hi=z;function Yi(i){return []}var Le={version:Vn,versions:Kn,arch:Pn,platform:Fn,release:Xn,_rawDebug:Zn,moduleLoadList:Qn,binding:Hn,_linkedBinding:ei,_events:Di,_eventsCount:Pi,_maxListeners:Mi,on:z,addListener:Fi,once:ji,off:qi,removeListener:Gi,removeAllListeners:Vi,emit:Ki,prependListener:zi,prependOnceListener:Hi,listeners:Yi,domain:ti,_exiting:ni,config:ii,dlopen:ri,uptime:$i,_getActiveRequests:si,_getActiveHandles:oi,reallyExit:ai,_kill:ui,cpuUsage:Fe,resourceUsage:li,memoryUsage:fi,kill:hi,exit:ci,openStdin:di,allowedNodeEnvironmentFlags:pi,assert:gi,features:yi,_fatalExceptions:mi,setUncaughtExceptionCaptureCallback:wi,hasUncaughtExceptionCaptureCallback:bi,emitWarning:zn,nextTick:Mn,_tickCallback:vi,_debugProcess:Ii,_debugEnd:Ei,_startProfilerIdleNotifier:Si,_stopProfilerIdleNotifier:Bi,stdout:Ai,stdin:Ti,stderr:_i,abort:xi,umask:Yn,chdir:Wn,cwd:Jn,env:jn,title:Dn,argv:qn,execArgv:Gn,pid:Ui,ppid:Oi,execPath:ki,debugPort:Ni,hrtime:Ne,argv0:Li,_preload_modules:Ri,setSourceMapsEnabled:Ci},fe={},yt=!1;function Ji(){if(yt)return fe;yt=!0,fe.byteLength=y,fe.toByteArray=B,fe.fromByteArray=v;for(var i=[],r=[],o=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,c=f.length;h<c;++h)i[h]=f[h],r[f.charCodeAt(h)]=h;r[45]=62,r[95]=63;function a(p){var g=p.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=p.indexOf("=");I===-1&&(I=g);var _=I===g?0:4-I%4;return [I,_]}function y(p){var g=a(p),I=g[0],_=g[1];return (I+_)*3/4-_}function w(p,g,I){return (g+I)*3/4-I}function B(p){var g,I=a(p),_=I[0],L=I[1],T=new o(w(p,_,L)),$=0,D=L>0?_-4:_,C;for(C=0;C<D;C+=4)g=r[p.charCodeAt(C)]<<18|r[p.charCodeAt(C+1)]<<12|r[p.charCodeAt(C+2)]<<6|r[p.charCodeAt(C+3)],T[$++]=g>>16&255,T[$++]=g>>8&255,T[$++]=g&255;return L===2&&(g=r[p.charCodeAt(C)]<<2|r[p.charCodeAt(C+1)]>>4,T[$++]=g&255),L===1&&(g=r[p.charCodeAt(C)]<<10|r[p.charCodeAt(C+1)]<<4|r[p.charCodeAt(C+2)]>>2,T[$++]=g>>8&255,T[$++]=g&255),T}function b(p){return i[p>>18&63]+i[p>>12&63]+i[p>>6&63]+i[p&63]}function m(p,g,I){for(var _,L=[],T=g;T<I;T+=3)_=(p[T]<<16&16711680)+(p[T+1]<<8&65280)+(p[T+2]&255),L.push(b(_));return L.join("")}function v(p){for(var g,I=p.length,_=I%3,L=[],T=16383,$=0,D=I-_;$<D;$+=T)L.push(m(p,$,$+T>D?D:$+T));return _===1?(g=p[I-1],L.push(i[g>>2]+i[g<<4&63]+"==")):_===2&&(g=(p[I-2]<<8)+p[I-1],L.push(i[g>>10]+i[g>>4&63]+i[g<<2&63]+"=")),L.join("")}return fe}var ye={},mt=!1;function Wi(){return mt?ye:(mt=!0,ye.read=function(i,r,o,f,h){var c,a,y=h*8-f-1,w=(1<<y)-1,B=w>>1,b=-7,m=o?h-1:0,v=o?-1:1,p=i[r+m];for(m+=v,c=p&(1<<-b)-1,p>>=-b,b+=y;b>0;c=c*256+i[r+m],m+=v,b-=8);for(a=c&(1<<-b)-1,c>>=-b,b+=f;b>0;a=a*256+i[r+m],m+=v,b-=8);if(c===0)c=1-B;else {if(c===w)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,f),c=c-B;}return (p?-1:1)*a*Math.pow(2,c-f)},ye.write=function(i,r,o,f,h,c){var a,y,w,B=c*8-h-1,b=(1<<B)-1,m=b>>1,v=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=f?0:c-1,g=f?1:-1,I=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(y=isNaN(r)?1:0,a=b):(a=Math.floor(Math.log(r)/Math.LN2),r*(w=Math.pow(2,-a))<1&&(a--,w*=2),a+m>=1?r+=v/w:r+=v*Math.pow(2,1-m),r*w>=2&&(a++,w/=2),a+m>=b?(y=0,a=b):a+m>=1?(y=(r*w-1)*Math.pow(2,h),a=a+m):(y=r*Math.pow(2,m-1)*Math.pow(2,h),a=0));h>=8;i[o+p]=y&255,p+=g,y/=256,h-=8);for(a=a<<h|y,B+=h;B>0;i[o+p]=a&255,p+=g,a/=256,B-=8);i[o+p-g]|=I*128;},ye)}var Y={},wt=!1;function Xi(){if(wt)return Y;wt=!0;let i=Ji(),r=Wi(),o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Y.Buffer=a,Y.SlowBuffer=L,Y.INSPECT_MAX_BYTES=50;let f=2147483647;Y.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=h(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return !1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(e){if(e>f)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(e)}return y(e,t,n)}a.poolSize=8192;function y(e,t,n){if(typeof e=="string")return m(e,t);if(ArrayBuffer.isView(e))return p(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return g(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let s=e.valueOf&&e.valueOf();if(s!=null&&s!==e)return a.from(s,t,n);let u=I(e);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}a.from=function(e,t,n){return y(e,t,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function w(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function B(e,t,n){return w(e),e<=0?c(e):t!==void 0?typeof n=="string"?c(e).fill(t,n):c(e).fill(t):c(e)}a.alloc=function(e,t,n){return B(e,t,n)};function b(e){return w(e),c(e<0?0:_(e)|0)}a.allocUnsafe=function(e){return b(e)},a.allocUnsafeSlow=function(e){return b(e)};function m(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=T(e,t)|0,s=c(n),u=s.write(e,t);return u!==n&&(s=s.slice(0,u)),s}function v(e){let t=e.length<0?0:_(e.length)|0,n=c(t);for(let s=0;s<t;s+=1)n[s]=e[s]&255;return n}function p(e){if(F(e,Uint8Array)){let t=new Uint8Array(e);return g(t.buffer,t.byteOffset,t.byteLength)}return v(e)}function g(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let s;return t===void 0&&n===void 0?s=new Uint8Array(e):n===void 0?s=new Uint8Array(e,t):s=new Uint8Array(e,t,n),Object.setPrototypeOf(s,a.prototype),s}function I(e){if(a.isBuffer(e)){let t=_(e.length)|0,n=c(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||_e(e.length)?c(0):v(e);if(e.type==="Buffer"&&Array.isArray(e.data))return v(e.data)}function _(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function L(e){return +e!=e&&(e=0),a.alloc(+e)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype},a.compare=function(e,t){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,s=t.length;for(let u=0,l=Math.min(n,s);u<l;++u)if(e[u]!==t[u]){n=e[u],s=t[u];break}return n<s?-1:s<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let s=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(F(l,Uint8Array))u+l.length>s.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(s,u)):Uint8Array.prototype.set.call(s,l,u);else if(a.isBuffer(l))l.copy(s,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return s};function T(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let n=e.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Ae(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return at(e).length;default:if(u)return s?-1:Ae(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=T;function $(e,t,n){let s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return "";for(e||(e="utf8");;)switch(e){case"hex":return un(this,t,n);case"utf8":case"utf-8":return Ze(this,t,n);case"ascii":return on(this,t,n);case"latin1":case"binary":return an(this,t,n);case"base64":return rn(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ln(this,t,n);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0;}}a.prototype._isBuffer=!0;function D(e,t,n){let s=e[t];e[t]=e[n],e[n]=s;}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)D(this,t,t+1);return this},a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)D(this,t,t+3),D(this,t+1,t+2);return this},a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)D(this,t,t+7),D(this,t+1,t+6),D(this,t+2,t+5),D(this,t+3,t+4);return this},a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ze(this,0,e):$.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0},a.prototype.inspect=function(){let e="",t=Y.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},o&&(a.prototype[o]=a.prototype.inspect),a.prototype.compare=function(e,t,n,s,u){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),s===void 0&&(s=0),u===void 0&&(u=this.length),t<0||n>e.length||s<0||u>this.length)throw new RangeError("out of range index");if(s>=u&&t>=n)return 0;if(s>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,s>>>=0,u>>>=0,this===e)return 0;let l=u-s,d=n-t,S=Math.min(l,d),N=this.slice(s,u),A=e.slice(t,n);for(let E=0;E<S;++E)if(N[E]!==A[E]){l=N[E],d=A[E];break}return l<d?-1:d<l?1:0};function C(e,t,n,s,u){if(e.length===0)return -1;if(typeof n=="string"?(s=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,_e(n)&&(n=u?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(u)return -1;n=e.length-1;}else if(n<0)if(u)n=0;else return -1;if(typeof t=="string"&&(t=a.from(t,s)),a.isBuffer(t))return t.length===0?-1:Xe(e,t,n,s,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Xe(e,[t],n,s,u);throw new TypeError("val must be string, number or Buffer")}function Xe(e,t,n,s,u){let l=1,d=e.length,S=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,d/=2,S/=2,n/=2;}function N(E,x){return l===1?E[x]:E.readUInt16BE(x*l)}let A;if(u){let E=-1;for(A=n;A<d;A++)if(N(e,A)===N(t,E===-1?0:A-E)){if(E===-1&&(E=A),A-E+1===S)return E*l}else E!==-1&&(A-=A-E),E=-1;}else for(n+S>d&&(n=d-S),A=n;A>=0;A--){let E=!0;for(let x=0;x<S;x++)if(N(e,A+x)!==N(t,x)){E=!1;break}if(E)return A}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)};function Zt(e,t,n,s){n=Number(n)||0;let u=e.length-n;s?(s=Number(s),s>u&&(s=u)):s=u;let l=t.length;s>l/2&&(s=l/2);let d;for(d=0;d<s;++d){let S=parseInt(t.substr(d*2,2),16);if(_e(S))return d;e[n+d]=S;}return d}function Qt(e,t,n,s){return ge(Ae(t,e.length-n),e,n,s)}function en(e,t,n,s){return ge(dn(t),e,n,s)}function tn(e,t,n,s){return ge(at(t),e,n,s)}function nn(e,t,n,s){return ge(pn(t,e.length-n),e,n,s)}a.prototype.write=function(e,t,n,s){if(t===void 0)s="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")s=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let u=this.length-t;if((n===void 0||n>u)&&(n=u),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let l=!1;for(;;)switch(s){case"hex":return Zt(this,e,t,n);case"utf8":case"utf-8":return Qt(this,e,t,n);case"ascii":case"latin1":case"binary":return en(this,e,t,n);case"base64":return tn(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nn(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function rn(e,t,n){return t===0&&n===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,n))}function Ze(e,t,n){n=Math.min(e.length,n);let s=[],u=t;for(;u<n;){let l=e[u],d=null,S=l>239?4:l>223?3:l>191?2:1;if(u+S<=n){let N,A,E,x;switch(S){case 1:l<128&&(d=l);break;case 2:N=e[u+1],(N&192)===128&&(x=(l&31)<<6|N&63,x>127&&(d=x));break;case 3:N=e[u+1],A=e[u+2],(N&192)===128&&(A&192)===128&&(x=(l&15)<<12|(N&63)<<6|A&63,x>2047&&(x<55296||x>57343)&&(d=x));break;case 4:N=e[u+1],A=e[u+2],E=e[u+3],(N&192)===128&&(A&192)===128&&(E&192)===128&&(x=(l&15)<<18|(N&63)<<12|(A&63)<<6|E&63,x>65535&&x<1114112&&(d=x));}}d===null?(d=65533,S=1):d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d),u+=S;}return sn(s)}let Qe=4096;function sn(e){let t=e.length;if(t<=Qe)return String.fromCharCode.apply(String,e);let n="",s=0;for(;s<t;)n+=String.fromCharCode.apply(String,e.slice(s,s+=Qe));return n}function on(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]&127);return s}function an(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]);return s}function un(e,t,n){let s=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>s)&&(n=s);let u="";for(let l=t;l<n;++l)u+=gn[e[l]];return u}function ln(e,t,n){let s=e.slice(t,n),u="";for(let l=0;l<s.length-1;l+=2)u+=String.fromCharCode(s[l]+s[l+1]*256);return u}a.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let s=this.subarray(e,t);return Object.setPrototypeOf(s,a.prototype),s};function k(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=this[e+--t],u=1;for(;t>0&&(u*=256);)s+=this[e+--t]*u;return s},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||k(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||k(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||k(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||k(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,u=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(s)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],u=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return (BigInt(s)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return u*=128,s>=u&&(s-=Math.pow(2,8*t)),s},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=t,u=1,l=this[e+--s];for(;s>0&&(u*=256);)l+=this[e+--s]*u;return u*=128,l>=u&&(l-=Math.pow(2,8*t)),l},a.prototype.readInt8=function(e,t){return e=e>>>0,t||k(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){e=e>>>0,t||k(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},a.prototype.readInt16BE=function(e,t){e=e>>>0,t||k(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(s)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),a.prototype.readBigInt64BE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(s)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||k(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||k(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||k(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||k(e,8,this.length),r.read(this,e,!1,52,8)};function M(e,t,n,s,u,l){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<l)throw new RangeError('"value" argument is out of bounds');if(n+s>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let d=Math.pow(2,8*n)-1;M(this,e,t,n,d,0);}let u=1,l=0;for(this[t]=e&255;++l<n&&(u*=256);)this[t+l]=e/u&255;return t+n},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let d=Math.pow(2,8*n)-1;M(this,e,t,n,d,0);}let u=n-1,l=1;for(this[t+u]=e&255;--u>=0&&(l*=256);)this[t+u]=e/l&255;return t+n},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function et(e,t,n,s,u){ot(t,s,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,n}function tt(e,t,n,s,u){ot(t,s,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n+7]=l,l=l>>8,e[n+6]=l,l=l>>8,e[n+5]=l,l=l>>8,e[n+4]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=d,d=d>>8,e[n+2]=d,d=d>>8,e[n+1]=d,d=d>>8,e[n]=d,n+8}a.prototype.writeBigUInt64LE=q(function(e,t=0){return et(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=q(function(e,t=0){return tt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);M(this,e,t,n,S-1,-S);}let u=0,l=1,d=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&d===0&&this[t+u-1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);M(this,e,t,n,S-1,-S);}let u=n-1,l=1,d=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&d===0&&this[t+u+1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},a.prototype.writeBigInt64LE=q(function(e,t=0){return et(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=q(function(e,t=0){return tt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function nt(e,t,n,s,u,l){if(n+s>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function it(e,t,n,s,u){return t=+t,n=n>>>0,u||nt(e,t,n,4),r.write(e,t,n,s,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return it(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return it(this,e,t,!1,n)};function rt(e,t,n,s,u){return t=+t,n=n>>>0,u||nt(e,t,n,8),r.write(e,t,n,s,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return rt(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return rt(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,s){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<n&&(s=n),s===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-n&&(s=e.length-t+n);let u=s-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,s):Uint8Array.prototype.set.call(e,this.subarray(n,s),t),u},a.prototype.fill=function(e,t,n,s){if(typeof e=="string"){if(typeof t=="string"?(s=t,t=0,n=this.length):typeof n=="string"&&(s=n,n=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(e.length===1){let l=e.charCodeAt(0);(s==="utf8"&&l<128||s==="latin1")&&(e=l);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let u;if(typeof e=="number")for(u=t;u<n;++u)this[u]=e;else {let l=a.isBuffer(e)?e:a.from(e,s),d=l.length;if(d===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%d];}return this};let ee={};function Be(e,t,n){ee[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name;}get code(){return e}set code(s){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:s,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}Be("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Be("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Be("ERR_OUT_OF_RANGE",function(e,t,n){let s=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=st(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=st(u)),u+="n"),s+=` It must be ${t}. Received ${u}`,s},RangeError);function st(e){let t="",n=e.length,s=e[0]==="-"?1:0;for(;n>=s+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function fn(e,t,n){te(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&le(t,e.length-(n+1));}function ot(e,t,n,s,u,l){if(e>n||e<t){let d=typeof t=="bigint"?"n":"",S;throw t===0||t===BigInt(0)?S=`>= 0${d} and < 2${d} ** ${(l+1)*8}${d}`:S=`>= -(2${d} ** ${(l+1)*8-1}${d}) and < 2 ** ${(l+1)*8-1}${d}`,new ee.ERR_OUT_OF_RANGE("value",S,e)}fn(s,u,l);}function te(e,t){if(typeof e!="number")throw new ee.ERR_INVALID_ARG_TYPE(t,"number",e)}function le(e,t,n){throw Math.floor(e)!==e?(te(e,n),new ee.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new ee.ERR_BUFFER_OUT_OF_BOUNDS:new ee.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let hn=/[^+/0-9A-Za-z-_]/g;function cn(e){if(e=e.split("=")[0],e=e.trim().replace(hn,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function Ae(e,t){t=t||1/0;let n,s=e.length,u=null,l=[];for(let d=0;d<s;++d){if(n=e.charCodeAt(d),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(d+1===s){(t-=3)>-1&&l.push(239,191,189);continue}u=n;continue}if(n<56320){(t-=3)>-1&&l.push(239,191,189),u=n;continue}n=(u-55296<<10|n-56320)+65536;}else u&&(t-=3)>-1&&l.push(239,191,189);if(u=null,n<128){if((t-=1)<0)break;l.push(n);}else if(n<2048){if((t-=2)<0)break;l.push(n>>6|192,n&63|128);}else if(n<65536){if((t-=3)<0)break;l.push(n>>12|224,n>>6&63|128,n&63|128);}else if(n<1114112){if((t-=4)<0)break;l.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128);}else throw new Error("Invalid code point")}return l}function dn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function pn(e,t){let n,s,u,l=[];for(let d=0;d<e.length&&!((t-=2)<0);++d)n=e.charCodeAt(d),s=n>>8,u=n%256,l.push(u),l.push(s);return l}function at(e){return i.toByteArray(cn(e))}function ge(e,t,n,s){let u;for(u=0;u<s&&!(u+n>=t.length||u>=e.length);++u)t[u+n]=e[u];return u}function F(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function _e(e){return e!==e}let gn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let s=n*16;for(let u=0;u<16;++u)t[s+u]=e[n]+e[u];}return t}();function q(e){return typeof BigInt>"u"?yn:e}function yn(){throw new Error("BigInt not supported")}return Y}var Q=Xi();Q.Buffer;Q.SlowBuffer;Q.INSPECT_MAX_BYTES;Q.kMaxLength;var bt=Q.Buffer;Q.INSPECT_MAX_BYTES;Q.kMaxLength;var Zi={};Cn(Zi,{deleteItem:()=>nr,getItem:()=>Re,setItem:()=>be});var we=()=>typeof window>"u",St=()=>!we(),Qi="__IMX-",je=()=>St()&&window.localStorage,er=i=>{if(i!==null)try{return JSON.parse(i)}catch{return i}},tr=i=>typeof i=="string"?i:JSON.stringify(i),qe=i=>`${Qi}${i}`;function Re(i){if(je())return er(window.localStorage.getItem(qe(i)))}var be=(i,r)=>je()?(window.localStorage.setItem(qe(i),tr(r)),!0):!1,nr=i=>je()?(window.localStorage.removeItem(qe(i)),!0):!1,Ce=0,ir=i=>{let r=parseInt(i,10)*1e3,o=new Date(r),f=new Date;return Ce=o.getTime()-f.getTime(),Ce},rr=()=>{let i=new Date().getTime()+Ce;return new Date(i).toISOString()},sr=(i=>(i.RUNTIME_ID="rid",i.PASSPORT_CLIENT_ID="passportClientId",i.ENVIRONMENT="env",i.PUBLISHABLE_API_KEY="pak",i.IDENTITY="uid",i.DOMAIN="domain",i.SDK_VERSION="sdkVersion",i))(sr||{}),or="https://api.immutable.com",ar=i=>{if(typeof bt<"u")return bt.from(i,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(i)));throw new Error("Base64 encoding not supported in this environment")};async function Bt(i,r){let o=JSON.stringify(r),f={payload:ar(o)},h=await fetch(`${or}${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){let c=await h.text().catch(()=>"");throw new Error(`Request failed (${h.status}): ${c||h.statusText}`)}return h.json()}var W,X,ur=()=>{W=Re("metrics-events")||[],X=Re("metrics-runtime")||{};};ur();var Z=(i,r)=>{X={...X,[i]:r},be("metrics-runtime",X);},$e=i=>{if(X[i]!==void 0)return X[i]},lr=()=>X,fr=()=>W,hr=i=>{W.push(i),be("metrics-events",W);},cr=i=>{W=W.slice(i),be("metrics-events",W);},At=i=>{let r=[];return Object.entries(i).forEach(([o,f])=>{(typeof o=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&r.push([o,f.toString()]);}),r},Oe="2.15.0",dr=()=>we()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",pr=()=>{if(we())return "";let i;try{window.self!==window.top&&(i=dr());}catch{}return i||(i=window.location.hostname),i},gr=()=>{if(Z("sdkVersion",Oe),we())return {browser:"nodejs",sdkVersion:Oe};let i=pr();return i&&Z("domain",i),{sdkVersion:Oe,browser:window.navigator.userAgent,domain:i,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},Me=!1,yr=()=>Me,mr=async()=>{Me=!0;try{let i=At(gr()),r=$e("rid"),o=$e("uid"),f=await Bt("/v1/sdk/initialise",{version:1,data:{runtimeDetails:i,runtimeId:r,uId:o}}),{runtimeId:h,sTime:c}=f;Z("rid",h),ir(c);}catch{Me=!1;}};function P(i,r){return (...o)=>{try{let f=i(...o);return f instanceof Promise?f.catch(()=>r):f}catch{return r}}}function wr(){return St()||typeof Le>"u"?!1:Le.env.JEST_WORKER_ID!==void 0}var br=P(wr,!1),_t="imtbl__metrics",vr=5e3,Ir=1e3,he=(i,r)=>(0, De.getGlobalisedValue)(_t,i,r),Er=(i,r)=>{let o=ht(r,{lruOptions:{ttl:vr,max:Ir}});return (0, De.getGlobalisedValue)(_t,i,o)},Sr=5e3,Br=(i,r,o)=>{let f={event:`${i}.${r}`,time:rr(),...o&&{properties:At(o)}};hr(f);},re=P(Er("track",Br)),Ar=async()=>{if(yr()===!1){await mr();return}let i=fr();if(i.length===0)return;let r=i.length,o=lr();await Bt("/v1/sdk/metrics",{version:1,data:{events:i,details:o}})instanceof Error||cr(r);},_r=P(Ar),Tt=async()=>{await _r(),setTimeout(Tt,Sr);},vt=!1,Tr=()=>{vt||(vt=!0,Tt());};br()||P(he("startFlushing",Tr))();var Rr=(i,r,o,f)=>{let{message:h}=o,c=o.stack||"",{cause:a}=o;a instanceof Error&&(c=`${c}
|
|
1
|
+
var mn=Object.create;var ut=Object.defineProperty;var wn=Object.getOwnPropertyDescriptor;var bn=Object.getOwnPropertyNames;var vn=Object.getPrototypeOf,In=Object.prototype.hasOwnProperty;var lt=(i,r)=>()=>(i&&(r=i(i=0)),r);var En=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports);var Sn=(i,r,o,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let h of bn(r))!In.call(i,h)&&h!==o&&ut(i,h,{get:()=>r[h],enumerable:!(f=wn(r,h))||f.enumerable});return i};var Bn=(i,r,o)=>(o=i!=null?mn(vn(i)):{},Sn(ut(o,"default",{value:i,enumerable:!0}),i));var U=lt(()=>{});var O=lt(()=>{});var gt=En(ne=>{O();U();Object.defineProperty(ne,"__esModule",{value:!0});ne.clearGlobalNamespace=ne.getGlobalisedValue=void 0;var Tn="globalise__singleton__",xn={},ct=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:xn,Un=(i,r)=>{if(typeof i!="string")throw "Invalid namespace key";if(typeof r!="string")throw "Invalid item key"},dt=i=>`${Tn}${i}`,pt=i=>{let r=ct(),o=dt(i);return r[o]||(r[o]={}),r[o]},On=(i,r)=>pt(i)[r]||void 0,kn=(i,r,o)=>{let f=pt(i);f[r]=o;},Nn=(i,r,o)=>{Un(i,r);let f=On(i,r);return f!==void 0?f:(kn(i,r,o),o)};ne.getGlobalisedValue=Nn;var Ln=i=>{let r=ct(),o=dt(i);r[o]!==void 0&&delete r[o];};ne.clearGlobalNamespace=Ln;});O();U();O();U();O();U();O();U();O();U();O();U();var Te=class{constructor(r=0,o=0,f=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=r,this.resetTtl=f,this.size=0,this.ttl=o;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(r){if(this.has(r)){let o=this.items[r];delete this.items[r],this.size--,o.prev!==null&&(o.prev.next=o.next),o.next!==null&&(o.next.prev=o.prev),this.first===o&&(this.first=o.next),this.last===o&&(this.last=o.prev);}return this}entries(r=this.keys()){return r.map(o=>[o,this.get(o)])}evict(r=!1){if(r||this.size>0){let o=this.first;delete this.items[o.key],--this.size===0?(this.first=null,this.last=null):(this.first=o.next,this.first.prev=null);}return this}expiresAt(r){let o;return this.has(r)&&(o=this.items[r].expiry),o}get(r){let o;if(this.has(r)){let f=this.items[r];this.ttl>0&&f.expiry<=Date.now()?this.delete(r):(o=f.value,this.set(r,o,!0));}return o}has(r){return r in this.items}keys(){let r=[],o=this.first;for(;o!==null;)r.push(o.key),o=o.next;return r}set(r,o,f=!1,h=this.resetTtl){let c;if(f||this.has(r)){if(c=this.items[r],c.value=o,f===!1&&h&&(c.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==c){let a=this.last,y=c.next,w=c.prev;this.first===c&&(this.first=c.next),c.next=null,c.prev=this.last,a.next=c,w!==null&&(w.next=y),y!==null&&(y.prev=w);}}else this.max>0&&this.size===this.max&&this.evict(!0),c=this.items[r]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:r,prev:this.last,next:null,value:o},++this.size===1?this.first=c:this.last.next=c;return this.last=c,this}values(r=this.keys()){return r.map(o=>this.get(o))}};function ft(i=1e3,r=0,o=!1){if(isNaN(i)||i<0)throw new TypeError("Invalid max value");if(isNaN(r)||r<0)throw new TypeError("Invalid ttl value");if(typeof o!="boolean")throw new TypeError("Invalid resetTtl value");return new Te(i,r,o)}var An={max:1e3},ht=(i,r={})=>{let{cache:o,cacheKeyResolver:f=xe,onHit:h,lruOptions:c={}}=r,a={...An,...c},y=o||ft(a.max,a.ttl);function w(...B){let b=f(...B),m=y.get(b);if(y.has(b))return h&&h(b,m,y),m;let p=i.apply(this,B);return y.set(b,p),p}return w._cache=y,w},xe=(...i)=>i.length===0?"no-args":i.map(r=>r===void 0?"undefined":r===null?"null":Array.isArray(r)?`[${xe(...r)}]`:typeof r=="object"?`{${xe(..._n(r))}}`:JSON.stringify(r)).join(","),_n=i=>Object.entries(i).sort((r,o)=>r[0]<o[0]?-1:1);var De=Bn(gt()),Rn=Object.defineProperty,Cn=(i,r)=>{for(var o in r)Rn(i,o,{get:r[o],enumerable:!0});};function Pe(i){throw new Error("Node.js process "+i+" is not supported by JSPM core outside of Node.js")}var j=[],ie=!1,J,me=-1;function $n(){!ie||!J||(ie=!1,J.length?j=J.concat(j):me=-1,j.length&&It());}function It(){if(!ie){var i=setTimeout($n,0);ie=!0;for(var r=j.length;r;){for(J=j,j=[];++me<r;)J&&J[me].run();me=-1,r=j.length;}J=null,ie=!1,clearTimeout(i);}}function Mn(i){var r=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)r[o-1]=arguments[o];j.push(new Et(i,r)),j.length===1&&!ie&&setTimeout(It,0);}function Et(i,r){this.fun=i,this.array=r;}Et.prototype.run=function(){this.fun.apply(null,this.array);};var Dn="browser",Pn="x64",Fn="browser",jn={PATH:"/usr/bin",LANG:navigator.language+".UTF-8",PWD:"/",HOME:"/home",TMP:"/tmp"},qn=["/usr/bin/node"],Gn=[],Vn="v16.8.0",Kn={},zn=function(i,r){console.warn((r?r+": ":"")+i);},Hn=function(i){Pe("binding");},Yn=function(i){return 0},Jn=function(){return "/"},Wn=function(i){},Xn={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};function R(){}var Zn=R,Qn=[];function ei(i){Pe("_linkedBinding");}var ti={},ni=!1,ii={};function ri(i){Pe("dlopen");}function si(){return []}function oi(){return []}var ai=R,ui=R,Fe=function(){return {}},li=Fe,fi=Fe,hi=R,ci=R,di=R,pi={};function gi(i,r){if(!i)throw new Error(r||"assertion error")}var yi={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},mi=R,wi=R;function bi(){return !1}var vi=R,Ii=R,Ei=R,Si=R,Bi=R,Ai=void 0,_i=void 0,Ti=void 0,xi=R,Ui=2,Oi=1,ki="/bin/usr/node",Ni=9229,Li="node",Ri=[],Ci=R,K={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};K.now===void 0&&(Ue=Date.now(),K.timing&&K.timing.navigationStart&&(Ue=K.timing.navigationStart),K.now=()=>Date.now()-Ue);var Ue;function $i(){return K.now()/1e3}var ke=1e9;function Ne(i){var r=Math.floor((Date.now()-K.now())*.001),o=K.now()*.001,f=Math.floor(o)+r,h=Math.floor(o%1*1e9);return i&&(f=f-i[0],h=h-i[1],h<0&&(f--,h+=ke)),[f,h]}Ne.bigint=function(i){var r=Ne(i);return typeof BigInt>"u"?r[0]*ke+r[1]:BigInt(r[0]*ke)+BigInt(r[1])};var Mi=10,Di={},Pi=0;function z(){return Le}var Fi=z,ji=z,qi=z,Gi=z,Vi=z,Ki=R,zi=z,Hi=z;function Yi(i){return []}var Le={version:Vn,versions:Kn,arch:Pn,platform:Fn,release:Xn,_rawDebug:Zn,moduleLoadList:Qn,binding:Hn,_linkedBinding:ei,_events:Di,_eventsCount:Pi,_maxListeners:Mi,on:z,addListener:Fi,once:ji,off:qi,removeListener:Gi,removeAllListeners:Vi,emit:Ki,prependListener:zi,prependOnceListener:Hi,listeners:Yi,domain:ti,_exiting:ni,config:ii,dlopen:ri,uptime:$i,_getActiveRequests:si,_getActiveHandles:oi,reallyExit:ai,_kill:ui,cpuUsage:Fe,resourceUsage:li,memoryUsage:fi,kill:hi,exit:ci,openStdin:di,allowedNodeEnvironmentFlags:pi,assert:gi,features:yi,_fatalExceptions:mi,setUncaughtExceptionCaptureCallback:wi,hasUncaughtExceptionCaptureCallback:bi,emitWarning:zn,nextTick:Mn,_tickCallback:vi,_debugProcess:Ii,_debugEnd:Ei,_startProfilerIdleNotifier:Si,_stopProfilerIdleNotifier:Bi,stdout:Ai,stdin:Ti,stderr:_i,abort:xi,umask:Yn,chdir:Wn,cwd:Jn,env:jn,title:Dn,argv:qn,execArgv:Gn,pid:Ui,ppid:Oi,execPath:ki,debugPort:Ni,hrtime:Ne,argv0:Li,_preload_modules:Ri,setSourceMapsEnabled:Ci},fe={},yt=!1;function Ji(){if(yt)return fe;yt=!0,fe.byteLength=y,fe.toByteArray=B,fe.fromByteArray=v;for(var i=[],r=[],o=typeof Uint8Array<"u"?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,c=f.length;h<c;++h)i[h]=f[h],r[f.charCodeAt(h)]=h;r[45]=62,r[95]=63;function a(p){var g=p.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=p.indexOf("=");I===-1&&(I=g);var _=I===g?0:4-I%4;return [I,_]}function y(p){var g=a(p),I=g[0],_=g[1];return (I+_)*3/4-_}function w(p,g,I){return (g+I)*3/4-I}function B(p){var g,I=a(p),_=I[0],L=I[1],T=new o(w(p,_,L)),$=0,D=L>0?_-4:_,C;for(C=0;C<D;C+=4)g=r[p.charCodeAt(C)]<<18|r[p.charCodeAt(C+1)]<<12|r[p.charCodeAt(C+2)]<<6|r[p.charCodeAt(C+3)],T[$++]=g>>16&255,T[$++]=g>>8&255,T[$++]=g&255;return L===2&&(g=r[p.charCodeAt(C)]<<2|r[p.charCodeAt(C+1)]>>4,T[$++]=g&255),L===1&&(g=r[p.charCodeAt(C)]<<10|r[p.charCodeAt(C+1)]<<4|r[p.charCodeAt(C+2)]>>2,T[$++]=g>>8&255,T[$++]=g&255),T}function b(p){return i[p>>18&63]+i[p>>12&63]+i[p>>6&63]+i[p&63]}function m(p,g,I){for(var _,L=[],T=g;T<I;T+=3)_=(p[T]<<16&16711680)+(p[T+1]<<8&65280)+(p[T+2]&255),L.push(b(_));return L.join("")}function v(p){for(var g,I=p.length,_=I%3,L=[],T=16383,$=0,D=I-_;$<D;$+=T)L.push(m(p,$,$+T>D?D:$+T));return _===1?(g=p[I-1],L.push(i[g>>2]+i[g<<4&63]+"==")):_===2&&(g=(p[I-2]<<8)+p[I-1],L.push(i[g>>10]+i[g>>4&63]+i[g<<2&63]+"=")),L.join("")}return fe}var ye={},mt=!1;function Wi(){return mt?ye:(mt=!0,ye.read=function(i,r,o,f,h){var c,a,y=h*8-f-1,w=(1<<y)-1,B=w>>1,b=-7,m=o?h-1:0,v=o?-1:1,p=i[r+m];for(m+=v,c=p&(1<<-b)-1,p>>=-b,b+=y;b>0;c=c*256+i[r+m],m+=v,b-=8);for(a=c&(1<<-b)-1,c>>=-b,b+=f;b>0;a=a*256+i[r+m],m+=v,b-=8);if(c===0)c=1-B;else {if(c===w)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,f),c=c-B;}return (p?-1:1)*a*Math.pow(2,c-f)},ye.write=function(i,r,o,f,h,c){var a,y,w,B=c*8-h-1,b=(1<<B)-1,m=b>>1,v=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=f?0:c-1,g=f?1:-1,I=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(y=isNaN(r)?1:0,a=b):(a=Math.floor(Math.log(r)/Math.LN2),r*(w=Math.pow(2,-a))<1&&(a--,w*=2),a+m>=1?r+=v/w:r+=v*Math.pow(2,1-m),r*w>=2&&(a++,w/=2),a+m>=b?(y=0,a=b):a+m>=1?(y=(r*w-1)*Math.pow(2,h),a=a+m):(y=r*Math.pow(2,m-1)*Math.pow(2,h),a=0));h>=8;i[o+p]=y&255,p+=g,y/=256,h-=8);for(a=a<<h|y,B+=h;B>0;i[o+p]=a&255,p+=g,a/=256,B-=8);i[o+p-g]|=I*128;},ye)}var Y={},wt=!1;function Xi(){if(wt)return Y;wt=!0;let i=Ji(),r=Wi(),o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Y.Buffer=a,Y.SlowBuffer=L,Y.INSPECT_MAX_BYTES=50;let f=2147483647;Y.kMaxLength=f,a.TYPED_ARRAY_SUPPORT=h(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return !1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(e){if(e>f)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,a.prototype),t}function a(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(e)}return y(e,t,n)}a.poolSize=8192;function y(e,t,n){if(typeof e=="string")return m(e,t);if(ArrayBuffer.isView(e))return p(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return g(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let s=e.valueOf&&e.valueOf();if(s!=null&&s!==e)return a.from(s,t,n);let u=I(e);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}a.from=function(e,t,n){return y(e,t,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function w(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function B(e,t,n){return w(e),e<=0?c(e):t!==void 0?typeof n=="string"?c(e).fill(t,n):c(e).fill(t):c(e)}a.alloc=function(e,t,n){return B(e,t,n)};function b(e){return w(e),c(e<0?0:_(e)|0)}a.allocUnsafe=function(e){return b(e)},a.allocUnsafeSlow=function(e){return b(e)};function m(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let n=T(e,t)|0,s=c(n),u=s.write(e,t);return u!==n&&(s=s.slice(0,u)),s}function v(e){let t=e.length<0?0:_(e.length)|0,n=c(t);for(let s=0;s<t;s+=1)n[s]=e[s]&255;return n}function p(e){if(F(e,Uint8Array)){let t=new Uint8Array(e);return g(t.buffer,t.byteOffset,t.byteLength)}return v(e)}function g(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');let s;return t===void 0&&n===void 0?s=new Uint8Array(e):n===void 0?s=new Uint8Array(e,t):s=new Uint8Array(e,t,n),Object.setPrototypeOf(s,a.prototype),s}function I(e){if(a.isBuffer(e)){let t=_(e.length)|0,n=c(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||_e(e.length)?c(0):v(e);if(e.type==="Buffer"&&Array.isArray(e.data))return v(e.data)}function _(e){if(e>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return e|0}function L(e){return +e!=e&&(e=0),a.alloc(+e)}a.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==a.prototype},a.compare=function(e,t){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,s=t.length;for(let u=0,l=Math.min(n,s);u<l;++u)if(e[u]!==t[u]){n=e[u],s=t[u];break}return n<s?-1:s<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return a.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let s=a.allocUnsafe(t),u=0;for(n=0;n<e.length;++n){let l=e[n];if(F(l,Uint8Array))u+l.length>s.length?(a.isBuffer(l)||(l=a.from(l)),l.copy(s,u)):Uint8Array.prototype.set.call(s,l,u);else if(a.isBuffer(l))l.copy(s,u);else throw new TypeError('"list" argument must be an Array of Buffers');u+=l.length;}return s};function T(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let n=e.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&n===0)return 0;let u=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Ae(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return at(e).length;default:if(u)return s?-1:Ae(e).length;t=(""+t).toLowerCase(),u=!0;}}a.byteLength=T;function $(e,t,n){let s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return "";for(e||(e="utf8");;)switch(e){case"hex":return un(this,t,n);case"utf8":case"utf-8":return Ze(this,t,n);case"ascii":return on(this,t,n);case"latin1":case"binary":return an(this,t,n);case"base64":return rn(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ln(this,t,n);default:if(s)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),s=!0;}}a.prototype._isBuffer=!0;function D(e,t,n){let s=e[t];e[t]=e[n],e[n]=s;}a.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)D(this,t,t+1);return this},a.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)D(this,t,t+3),D(this,t+1,t+2);return this},a.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)D(this,t,t+7),D(this,t+1,t+6),D(this,t+2,t+5),D(this,t+3,t+4);return this},a.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Ze(this,0,e):$.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:a.compare(this,e)===0},a.prototype.inspect=function(){let e="",t=Y.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},o&&(a.prototype[o]=a.prototype.inspect),a.prototype.compare=function(e,t,n,s,u){if(F(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),s===void 0&&(s=0),u===void 0&&(u=this.length),t<0||n>e.length||s<0||u>this.length)throw new RangeError("out of range index");if(s>=u&&t>=n)return 0;if(s>=u)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,s>>>=0,u>>>=0,this===e)return 0;let l=u-s,d=n-t,S=Math.min(l,d),N=this.slice(s,u),A=e.slice(t,n);for(let E=0;E<S;++E)if(N[E]!==A[E]){l=N[E],d=A[E];break}return l<d?-1:d<l?1:0};function C(e,t,n,s,u){if(e.length===0)return -1;if(typeof n=="string"?(s=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,_e(n)&&(n=u?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(u)return -1;n=e.length-1;}else if(n<0)if(u)n=0;else return -1;if(typeof t=="string"&&(t=a.from(t,s)),a.isBuffer(t))return t.length===0?-1:Xe(e,t,n,s,u);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Xe(e,[t],n,s,u);throw new TypeError("val must be string, number or Buffer")}function Xe(e,t,n,s,u){let l=1,d=e.length,S=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(e.length<2||t.length<2)return -1;l=2,d/=2,S/=2,n/=2;}function N(E,x){return l===1?E[x]:E.readUInt16BE(x*l)}let A;if(u){let E=-1;for(A=n;A<d;A++)if(N(e,A)===N(t,E===-1?0:A-E)){if(E===-1&&(E=A),A-E+1===S)return E*l}else E!==-1&&(A-=A-E),E=-1;}else for(n+S>d&&(n=d-S),A=n;A>=0;A--){let E=!0;for(let x=0;x<S;x++)if(N(e,A+x)!==N(t,x)){E=!1;break}if(E)return A}return -1}a.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)};function Zt(e,t,n,s){n=Number(n)||0;let u=e.length-n;s?(s=Number(s),s>u&&(s=u)):s=u;let l=t.length;s>l/2&&(s=l/2);let d;for(d=0;d<s;++d){let S=parseInt(t.substr(d*2,2),16);if(_e(S))return d;e[n+d]=S;}return d}function Qt(e,t,n,s){return ge(Ae(t,e.length-n),e,n,s)}function en(e,t,n,s){return ge(dn(t),e,n,s)}function tn(e,t,n,s){return ge(at(t),e,n,s)}function nn(e,t,n,s){return ge(pn(t,e.length-n),e,n,s)}a.prototype.write=function(e,t,n,s){if(t===void 0)s="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")s=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,s===void 0&&(s="utf8")):(s=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let u=this.length-t;if((n===void 0||n>u)&&(n=u),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let l=!1;for(;;)switch(s){case"hex":return Zt(this,e,t,n);case"utf8":case"utf-8":return Qt(this,e,t,n);case"ascii":case"latin1":case"binary":return en(this,e,t,n);case"base64":return tn(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nn(this,e,t,n);default:if(l)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),l=!0;}},a.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function rn(e,t,n){return t===0&&n===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,n))}function Ze(e,t,n){n=Math.min(e.length,n);let s=[],u=t;for(;u<n;){let l=e[u],d=null,S=l>239?4:l>223?3:l>191?2:1;if(u+S<=n){let N,A,E,x;switch(S){case 1:l<128&&(d=l);break;case 2:N=e[u+1],(N&192)===128&&(x=(l&31)<<6|N&63,x>127&&(d=x));break;case 3:N=e[u+1],A=e[u+2],(N&192)===128&&(A&192)===128&&(x=(l&15)<<12|(N&63)<<6|A&63,x>2047&&(x<55296||x>57343)&&(d=x));break;case 4:N=e[u+1],A=e[u+2],E=e[u+3],(N&192)===128&&(A&192)===128&&(E&192)===128&&(x=(l&15)<<18|(N&63)<<12|(A&63)<<6|E&63,x>65535&&x<1114112&&(d=x));}}d===null?(d=65533,S=1):d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d),u+=S;}return sn(s)}let Qe=4096;function sn(e){let t=e.length;if(t<=Qe)return String.fromCharCode.apply(String,e);let n="",s=0;for(;s<t;)n+=String.fromCharCode.apply(String,e.slice(s,s+=Qe));return n}function on(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]&127);return s}function an(e,t,n){let s="";n=Math.min(e.length,n);for(let u=t;u<n;++u)s+=String.fromCharCode(e[u]);return s}function un(e,t,n){let s=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>s)&&(n=s);let u="";for(let l=t;l<n;++l)u+=gn[e[l]];return u}function ln(e,t,n){let s=e.slice(t,n),u="";for(let l=0;l<s.length-1;l+=2)u+=String.fromCharCode(s[l]+s[l+1]*256);return u}a.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let s=this.subarray(e,t);return Object.setPrototypeOf(s,a.prototype),s};function k(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return s},a.prototype.readUintBE=a.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=this[e+--t],u=1;for(;t>0&&(u*=256);)s+=this[e+--t]*u;return s},a.prototype.readUint8=a.prototype.readUInt8=function(e,t){return e=e>>>0,t||k(e,1,this.length),this[e]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||k(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||k(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||k(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readBigUInt64LE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,u=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(s)+(BigInt(u)<<BigInt(32))}),a.prototype.readBigUInt64BE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],u=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return (BigInt(s)<<BigInt(32))+BigInt(u)}),a.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=this[e],u=1,l=0;for(;++l<t&&(u*=256);)s+=this[e+l]*u;return u*=128,s>=u&&(s-=Math.pow(2,8*t)),s},a.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||k(e,t,this.length);let s=t,u=1,l=this[e+--s];for(;s>0&&(u*=256);)l+=this[e+--s]*u;return u*=128,l>=u&&(l-=Math.pow(2,8*t)),l},a.prototype.readInt8=function(e,t){return e=e>>>0,t||k(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},a.prototype.readInt16LE=function(e,t){e=e>>>0,t||k(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},a.prototype.readInt16BE=function(e,t){e=e>>>0,t||k(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},a.prototype.readInt32LE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e=e>>>0,t||k(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readBigInt64LE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return (BigInt(s)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),a.prototype.readBigInt64BE=q(function(e){e=e>>>0,te(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&le(e,this.length-8);let s=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return (BigInt(s)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),a.prototype.readFloatLE=function(e,t){return e=e>>>0,t||k(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e=e>>>0,t||k(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||k(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||k(e,8,this.length),r.read(this,e,!1,52,8)};function M(e,t,n,s,u,l){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>u||t<l)throw new RangeError('"value" argument is out of bounds');if(n+s>e.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let d=Math.pow(2,8*n)-1;M(this,e,t,n,d,0);}let u=1,l=0;for(this[t]=e&255;++l<n&&(u*=256);)this[t+l]=e/u&255;return t+n},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,n=n>>>0,!s){let d=Math.pow(2,8*n)-1;M(this,e,t,n,d,0);}let u=n-1,l=1;for(this[t+u]=e&255;--u>=0&&(l*=256);)this[t+u]=e/l&255;return t+n},a.prototype.writeUint8=a.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function et(e,t,n,s,u){ot(t,s,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l,l=l>>8,e[n++]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,d=d>>8,e[n++]=d,n}function tt(e,t,n,s,u){ot(t,s,u,e,n,7);let l=Number(t&BigInt(4294967295));e[n+7]=l,l=l>>8,e[n+6]=l,l=l>>8,e[n+5]=l,l=l>>8,e[n+4]=l;let d=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=d,d=d>>8,e[n+2]=d,d=d>>8,e[n+1]=d,d=d>>8,e[n]=d,n+8}a.prototype.writeBigUInt64LE=q(function(e,t=0){return et(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=q(function(e,t=0){return tt(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);M(this,e,t,n,S-1,-S);}let u=0,l=1,d=0;for(this[t]=e&255;++u<n&&(l*=256);)e<0&&d===0&&this[t+u-1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeIntBE=function(e,t,n,s){if(e=+e,t=t>>>0,!s){let S=Math.pow(2,8*n-1);M(this,e,t,n,S-1,-S);}let u=n-1,l=1,d=0;for(this[t+u]=e&255;--u>=0&&(l*=256);)e<0&&d===0&&this[t+u+1]!==0&&(d=1),this[t+u]=(e/l>>0)-d&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},a.prototype.writeBigInt64LE=q(function(e,t=0){return et(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=q(function(e,t=0){return tt(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function nt(e,t,n,s,u,l){if(n+s>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function it(e,t,n,s,u){return t=+t,n=n>>>0,u||nt(e,t,n,4),r.write(e,t,n,s,23,4),n+4}a.prototype.writeFloatLE=function(e,t,n){return it(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return it(this,e,t,!1,n)};function rt(e,t,n,s,u){return t=+t,n=n>>>0,u||nt(e,t,n,8),r.write(e,t,n,s,52,8),n+8}a.prototype.writeDoubleLE=function(e,t,n){return rt(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return rt(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,s){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s<n&&(s=n),s===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t<s-n&&(s=e.length-t+n);let u=s-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,s):Uint8Array.prototype.set.call(e,this.subarray(n,s),t),u},a.prototype.fill=function(e,t,n,s){if(typeof e=="string"){if(typeof t=="string"?(s=t,t=0,n=this.length):typeof n=="string"&&(s=n,n=this.length),s!==void 0&&typeof s!="string")throw new TypeError("encoding must be a string");if(typeof s=="string"&&!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);if(e.length===1){let l=e.charCodeAt(0);(s==="utf8"&&l<128||s==="latin1")&&(e=l);}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let u;if(typeof e=="number")for(u=t;u<n;++u)this[u]=e;else {let l=a.isBuffer(e)?e:a.from(e,s),d=l.length;if(d===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(u=0;u<n-t;++u)this[u+t]=l[u%d];}return this};let ee={};function Be(e,t,n){ee[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name;}get code(){return e}set code(s){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:s,writable:!0});}toString(){return `${this.name} [${e}]: ${this.message}`}};}Be("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Be("ERR_INVALID_ARG_TYPE",function(e,t){return `The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Be("ERR_OUT_OF_RANGE",function(e,t,n){let s=`The value of "${e}" is out of range.`,u=n;return Number.isInteger(n)&&Math.abs(n)>2**32?u=st(String(n)):typeof n=="bigint"&&(u=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(u=st(u)),u+="n"),s+=` It must be ${t}. Received ${u}`,s},RangeError);function st(e){let t="",n=e.length,s=e[0]==="-"?1:0;for(;n>=s+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return `${e.slice(0,n)}${t}`}function fn(e,t,n){te(t,"offset"),(e[t]===void 0||e[t+n]===void 0)&&le(t,e.length-(n+1));}function ot(e,t,n,s,u,l){if(e>n||e<t){let d=typeof t=="bigint"?"n":"",S;throw t===0||t===BigInt(0)?S=`>= 0${d} and < 2${d} ** ${(l+1)*8}${d}`:S=`>= -(2${d} ** ${(l+1)*8-1}${d}) and < 2 ** ${(l+1)*8-1}${d}`,new ee.ERR_OUT_OF_RANGE("value",S,e)}fn(s,u,l);}function te(e,t){if(typeof e!="number")throw new ee.ERR_INVALID_ARG_TYPE(t,"number",e)}function le(e,t,n){throw Math.floor(e)!==e?(te(e,n),new ee.ERR_OUT_OF_RANGE("offset","an integer",e)):t<0?new ee.ERR_BUFFER_OUT_OF_BOUNDS:new ee.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,e)}let hn=/[^+/0-9A-Za-z-_]/g;function cn(e){if(e=e.split("=")[0],e=e.trim().replace(hn,""),e.length<2)return "";for(;e.length%4!==0;)e=e+"=";return e}function Ae(e,t){t=t||1/0;let n,s=e.length,u=null,l=[];for(let d=0;d<s;++d){if(n=e.charCodeAt(d),n>55295&&n<57344){if(!u){if(n>56319){(t-=3)>-1&&l.push(239,191,189);continue}else if(d+1===s){(t-=3)>-1&&l.push(239,191,189);continue}u=n;continue}if(n<56320){(t-=3)>-1&&l.push(239,191,189),u=n;continue}n=(u-55296<<10|n-56320)+65536;}else u&&(t-=3)>-1&&l.push(239,191,189);if(u=null,n<128){if((t-=1)<0)break;l.push(n);}else if(n<2048){if((t-=2)<0)break;l.push(n>>6|192,n&63|128);}else if(n<65536){if((t-=3)<0)break;l.push(n>>12|224,n>>6&63|128,n&63|128);}else if(n<1114112){if((t-=4)<0)break;l.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128);}else throw new Error("Invalid code point")}return l}function dn(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function pn(e,t){let n,s,u,l=[];for(let d=0;d<e.length&&!((t-=2)<0);++d)n=e.charCodeAt(d),s=n>>8,u=n%256,l.push(u),l.push(s);return l}function at(e){return i.toByteArray(cn(e))}function ge(e,t,n,s){let u;for(u=0;u<s&&!(u+n>=t.length||u>=e.length);++u)t[u+n]=e[u];return u}function F(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function _e(e){return e!==e}let gn=function(){let e="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){let s=n*16;for(let u=0;u<16;++u)t[s+u]=e[n]+e[u];}return t}();function q(e){return typeof BigInt>"u"?yn:e}function yn(){throw new Error("BigInt not supported")}return Y}var Q=Xi();Q.Buffer;Q.SlowBuffer;Q.INSPECT_MAX_BYTES;Q.kMaxLength;var bt=Q.Buffer;Q.INSPECT_MAX_BYTES;Q.kMaxLength;var Zi={};Cn(Zi,{deleteItem:()=>nr,getItem:()=>Re,setItem:()=>be});var we=()=>typeof window>"u",St=()=>!we(),Qi="__IMX-",je=()=>St()&&window.localStorage,er=i=>{if(i!==null)try{return JSON.parse(i)}catch{return i}},tr=i=>typeof i=="string"?i:JSON.stringify(i),qe=i=>`${Qi}${i}`;function Re(i){if(je())return er(window.localStorage.getItem(qe(i)))}var be=(i,r)=>je()?(window.localStorage.setItem(qe(i),tr(r)),!0):!1,nr=i=>je()?(window.localStorage.removeItem(qe(i)),!0):!1,Ce=0,ir=i=>{let r=parseInt(i,10)*1e3,o=new Date(r),f=new Date;return Ce=o.getTime()-f.getTime(),Ce},rr=()=>{let i=new Date().getTime()+Ce;return new Date(i).toISOString()},sr=(i=>(i.RUNTIME_ID="rid",i.PASSPORT_CLIENT_ID="passportClientId",i.ENVIRONMENT="env",i.PUBLISHABLE_API_KEY="pak",i.IDENTITY="uid",i.DOMAIN="domain",i.SDK_VERSION="sdkVersion",i))(sr||{}),or="https://api.immutable.com",ar=i=>{if(typeof bt<"u")return bt.from(i,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(i)));throw new Error("Base64 encoding not supported in this environment")};async function Bt(i,r){let o=JSON.stringify(r),f={payload:ar(o)},h=await fetch(`${or}${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){let c=await h.text().catch(()=>"");throw new Error(`Request failed (${h.status}): ${c||h.statusText}`)}return h.json()}var W,X,ur=()=>{W=Re("metrics-events")||[],X=Re("metrics-runtime")||{};};ur();var Z=(i,r)=>{X={...X,[i]:r},be("metrics-runtime",X);},$e=i=>{if(X[i]!==void 0)return X[i]},lr=()=>X,fr=()=>W,hr=i=>{W.push(i),be("metrics-events",W);},cr=i=>{W=W.slice(i),be("metrics-events",W);},At=i=>{let r=[];return Object.entries(i).forEach(([o,f])=>{(typeof o=="string"||typeof f=="string"||typeof f=="number"||typeof f=="boolean")&&r.push([o,f.toString()]);}),r},Oe="2.15.1-alpha.1",dr=()=>we()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",pr=()=>{if(we())return "";let i;try{window.self!==window.top&&(i=dr());}catch{}return i||(i=window.location.hostname),i},gr=()=>{if(Z("sdkVersion",Oe),we())return {browser:"nodejs",sdkVersion:Oe};let i=pr();return i&&Z("domain",i),{sdkVersion:Oe,browser:window.navigator.userAgent,domain:i,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},Me=!1,yr=()=>Me,mr=async()=>{Me=!0;try{let i=At(gr()),r=$e("rid"),o=$e("uid"),f=await Bt("/v1/sdk/initialise",{version:1,data:{runtimeDetails:i,runtimeId:r,uId:o}}),{runtimeId:h,sTime:c}=f;Z("rid",h),ir(c);}catch{Me=!1;}};function P(i,r){return (...o)=>{try{let f=i(...o);return f instanceof Promise?f.catch(()=>r):f}catch{return r}}}function wr(){return St()||typeof Le>"u"?!1:Le.env.JEST_WORKER_ID!==void 0}var br=P(wr,!1),_t="imtbl__metrics",vr=5e3,Ir=1e3,he=(i,r)=>(0, De.getGlobalisedValue)(_t,i,r),Er=(i,r)=>{let o=ht(r,{lruOptions:{ttl:vr,max:Ir}});return (0, De.getGlobalisedValue)(_t,i,o)},Sr=5e3,Br=(i,r,o)=>{let f={event:`${i}.${r}`,time:rr(),...o&&{properties:At(o)}};hr(f);},re=P(Er("track",Br)),Ar=async()=>{if(yr()===!1){await mr();return}let i=fr();if(i.length===0)return;let r=i.length,o=lr();await Bt("/v1/sdk/metrics",{version:1,data:{events:i,details:o}})instanceof Error||cr(r);},_r=P(Ar),Tt=async()=>{await _r(),setTimeout(Tt,Sr);},vt=!1,Tr=()=>{vt||(vt=!0,Tt());};br()||P(he("startFlushing",Tr))();var Rr=(i,r,o,f)=>{let{message:h}=o,c=o.stack||"",{cause:a}=o;a instanceof Error&&(c=`${c}
|
|
2
2
|
Cause: ${a.message}
|
|
3
|
-
${a.stack}`),re(i,`trackError_${r}`,{...f||{},errorMessage:h,errorStack:c,isTrackError:!0});},xt=P(Rr),Mr=i=>{Z("env",i);};P(he("setEnvironment",Mr));var Dr=i=>{Z("passportClientId",i);};P(he("setPassportClientId",Dr));var Pr=i=>{Z("pak",i);};P(he("setPublishableApiKey",Pr));P(he("getDetail",$e));var Fr={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},jr={dev:"https://api.dev.immutable.com",sandbox:"https://api.sandbox.immutable.com",production:"https://api.immutable.com"},Nt="/v1/audience/messages",qr="/v1/audience/tracking-consent",Lt=5e3,Rt=20,oe="imtbl_anon_id",se="_imtbl_sid",Gr=365*24*60*60*2,Ut=30*60,Ct="session_start",$t="session_end",ze=i=>jr[i],ce=()=>typeof window<"u"&&typeof document<"u",ae=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let r=Math.trunc(Math.random()*16);return (i==="x"?r:r%4+8).toString(16)}),Mt=()=>new Date().toISOString();function Ie(i){if(!ce())return;let r=document.cookie.match(new RegExp(`(?:^|; )${i}=([^;]*)`));return r?decodeURIComponent(r[1]):void 0}function ve(i,r,o,f){if(!ce())return;let h=window.location.protocol==="https:"?"; Secure":"",c=f?`; domain=${f}`:"";document.cookie=`${i}=${encodeURIComponent(r)}; path=/; max-age=${o}; SameSite=Lax${c}${h}`;}function de(i,r){ve(i,"",0,r);}function Ee(i){let r=Ie(oe);if(r)return r;let o=ae();return ve(oe,o,Gr,i),o}var Ge=class extends Error{status;endpoint;body;constructor(i){super(`audience transport failed: ${i.status||"network error"} ${i.endpoint}`,i.cause!==void 0?{cause:i.cause}:void 0),this.name="TransportError",this.status=i.status,this.endpoint=i.endpoint,this.body=i.body;}},Ve=class extends Error{code;status;endpoint;responseBody;cause;constructor(i){super(i.message),this.name="AudienceError",this.code=i.code,this.status=i.status,this.endpoint=i.endpoint,this.responseBody=i.responseBody,this.cause=i.cause;}};function Dt(i,r,o){if(i.status===0)return new Ve({code:"NETWORK_ERROR",message:r==="flush"?`Network error sending ${o??0} messages`:"Network error syncing consent",status:0,endpoint:i.endpoint,cause:i.cause});if(i.status>=200&&i.status<300){let f=i.body,h=f?.rejected??0,c=f?.accepted??0;return new Ve({code:"VALIDATION_REJECTED",message:`Backend rejected ${h} of ${h+c} messages`,status:i.status,endpoint:i.endpoint,responseBody:i.body})}return new Ve({code:r==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:r==="flush"?`Flush failed with status ${i.status}`:`Consent sync failed with status ${i.status}`,status:i.status,endpoint:i.endpoint,responseBody:i.body,cause:i.cause})}function Pt(i,r){if(i)try{i(r);}catch{}}async function Ot(i){let r=i.headers?.get?.("content-type")??"";try{return r.includes("application/json")?await i.json():await i.text()}catch{return}}var He=async(i,r,o,f)=>{try{let h=await fetch(i,{method:f?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":r},body:JSON.stringify(o),keepalive:f?.keepalive});if(!h.ok){let a=await Ot(h);return re("audience","transport_send_failed",{status:h.status}),{ok:!1,error:new Ge({status:h.status,endpoint:i,body:a})}}let c=await Ot(h);if(typeof c=="object"&&c!==null&&"rejected"in c){let a=c.rejected??0;if(a>0)return re("audience","transport_partial_rejected",{status:h.status,rejected:a}),{ok:!1,error:new Ge({status:h.status,endpoint:i,body:c})}}return {ok:!0}}catch(h){let c=new Ge({status:0,endpoint:i,cause:h});return xt("audience","transport_send",c),{ok:!1,error:c}}},Ye="__imtbl_audience_";function Je(){try{return ce()&&typeof localStorage<"u"}catch{return !1}}function Vr(i,r=Ye){if(Je())try{let o=localStorage.getItem(`${r}${i}`);return o?JSON.parse(o):void 0}catch{return}}function Kr(i,r,o=Ye){if(Je())try{localStorage.setItem(`${o}${i}`,JSON.stringify(r));}catch{}}function zr(i,r=Ye){if(Je())try{localStorage.removeItem(`${r}${i}`);}catch{}}var Ke="queue",kt=100,Ft=class{constructor(i,r,o,f,h,c){this.send=i,this.endpointUrl=r,this.publishableKey=o,this.flushIntervalMs=f,this.flushSize=h,this.onFlush=c?.onFlush,this.onError=c?.onError,this.storagePrefix=c?.storagePrefix;let a=Vr(Ke,this.storagePrefix)??[];this.messages=c?.staleFilter?a.filter(c.staleFilter):a;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(i){this.messages.push(i),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)){this.flushing=!0;try{let i=this.messages.slice(0,kt),r={messages:i},o=await this.send(this.endpointUrl,this.publishableKey,r),f;!o.ok&&o.error&&(f=Dt(o.error,"flush",i.length));let h=f?.code==="VALIDATION_REJECTED";(o.ok||h)&&(this.messages=this.messages.slice(i.length),this.persist()),this.onFlush?.(o.ok,i.length),f&&Pt(this.onError,f);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let i=this.messages.slice(0,kt),r={messages:i};this.send(this.endpointUrl,this.publishableKey,r,{keepalive:!0}),this.messages=this.messages.slice(i.length),this.persist();}purge(i){this.messages=this.messages.filter(r=>!i(r)),this.persist();}transform(i){this.messages=this.messages.map(i),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],zr(Ke,this.storagePrefix);}registerUnload(){!ce()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}persist(){Kr(Ke,this.messages,this.storagePrefix);}},Hr="2.15.0";function jt(i="@imtbl/audience",r=Hr){let o={library:i,libraryVersion:r};return ce()&&(o.userAgent=navigator.userAgent,o.locale=navigator.language,o.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,o.screen=`${window.screen.width}x${window.screen.height}`,o.pageUrl=window.location.href,o.pagePath=window.location.pathname,o.pageReferrer=document.referrer,o.pageTitle=document.title),o}function qt(i){let r=new Date(i).getTime();if(Number.isNaN(r))return !1;let o=Date.now();return r<=o+864e5&&r>=o-2592e6}function Gt(i,r,o,f){return i!==o||r!==f}function pe(i,r=256){return i.length>r?i.slice(0,r):i}function ue(i){let r=Ie(se);if(r)return ve(se,r,Ut,i),{sessionId:r,isNew:!1};let o=ae();return ve(se,o,Ut,i),{sessionId:o,isNew:!0}}var Vt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Kt=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],zt="__imtbl_attribution";function Yr(i){let r;try{r=new URL(i).searchParams;}catch{return {}}let o={};for(let h of [...Vt,...Kt]){let c=r.get(h);c&&(o[h]=c);}let f=r.get("referral_code");return f&&(o.referral_code=f),o}function Jr(){try{let i=sessionStorage.getItem(zt);return i?JSON.parse(i):null}catch{return null}}function Wr(i){try{sessionStorage.setItem(zt,JSON.stringify(i));}catch{}}function Ht(){let i=Jr();if(i)return i;let r=typeof window<"u"&&window.location?Yr(window.location.href):{},o=typeof document<"u"&&document.referrer||void 0,f=typeof window<"u"&&window.location?window.location.href:void 0,h=Kt.some(y=>y in r),c=Vt.some(y=>y in r),a={...r,referrer:o,landing_page:f,touchpoint_type:h||c?"click":void 0};return Wr(a),a}function Yt(i,r,o,f,h,c,a,y){let w=a??"none",B={none:0,anonymous:1,full:2};function b(m){let v=`${ze(h)}${qr}`;r(v,o,{anonymousId:f,status:m,source:c},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Pt(y,Dt(p.error,"consent"));});}return {get level(){return w},setLevel(m){m!==w&&(B[m]<B[w]&&(m==="none"?i.purge(()=>!0):m==="anonymous"&&(i.purge(v=>v.type==="identify"||v.type==="alias"),i.transform(v=>{if("userId"in v){let{userId:p,...g}=v;return g}return v}))),w=m,b(m));}}}O();U();O();U();var Jt="@imtbl/audience",Wt="2.15.0",H="[audience]",Xt="WebSDK";var Se=class{enabled;constructor(r=!1){this.enabled=r;}logEvent(r,o){this.enabled&&console.log(`${H} ${r}`,o);}logFlush(r,o){this.enabled&&console.log(`${H} flush ${r?"ok":"failed"} (${o} messages)`);}logConsent(r,o){this.enabled&&console.log(`${H} consent ${r} \u2192 ${o}`);}logWarning(r){this.enabled&&console.warn(`${H} ${r}`);}};var We=class i{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(r){let{cookieDomain:o,environment:f,publishableKey:h}=r,c=r.consent??"none",a=Xt,y=r.flushInterval??Lt,w=r.flushSize??Rt;this.cookieDomain=o,this.debug=new Se(r.debug??!1);let B=!1;c!=="none"?(this.anonymousId=Ee(o),B=this.startSession()):this.anonymousId=Ie(oe)??ae();let b=`${ze(f)}${Nt}`;this.queue=new Ft(He,b,h,y,w,{onFlush:(m,v)=>this.debug.logFlush(m,v),staleFilter:m=>qt(m.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Yt(this.queue,He,h,this.anonymousId,f,a,c),this.attribution=Ht(),this.isTrackingDisabled()||(this.queue.start(),B&&this.trackSessionStart());}static init(r){if(!r.publishableKey?.trim())throw new Error(`${H} publishableKey is required`);return i.liveInstances>0&&console.warn(`${H} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),i.liveInstances+=1,new i(r)}isTrackingDisabled(){return this.consent.level==="none"}effectiveUserId(){return this.consent.level==="full"?this.userId:void 0}startSession(){let r=ue(this.cookieDomain);return this.sessionId=r.sessionId,this.sessionStartTime=Date.now(),r.isNew}baseMessage(){return {messageId:ae(),eventTimestamp:Mt(),anonymousId:this.anonymousId,surface:"web",context:jt(Jt,Wt)}}enqueue(r,o){this.queue.enqueue(o),this.debug.logEvent(r,o);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Ct,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:$t,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(r){if(this.isTrackingDisabled())return;ue(this.cookieDomain);let o={...r};this.isFirstPage&&(Object.assign(o,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(o).length>0?o:void 0,userId:this.effectiveUserId()});}track(r,o){this.isTrackingDisabled()||(ue(this.cookieDomain),this.enqueue("track",{...this.baseMessage(),type:"track",eventName:pe(r),properties:o,userId:this.effectiveUserId()}));}identify(r,o,f){if(this.consent.level!=="full"){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(ue(this.cookieDomain),r!==null&&typeof r=="object"&&!Array.isArray(r)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:r});return}if(typeof r!="string")return;let h=pe(r);this.userId=h,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:h,identityType:o,traits:f});}alias(r,o){if(this.consent.level!=="full"){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Gt(r.id,r.identityType,o.id,o.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}ue(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:pe(r.id),fromType:r.identityType,toId:pe(o.id),toType:o.identityType});}setConsent(r){let o=this.consent.level;if(r===o)return;this.debug.logConsent(o,r);let f=o==="none"&&r!=="none";if(f&&(this.anonymousId=Ee(this.cookieDomain)),r==="none"&&this.queue.stop(),this.consent.setLevel(r),r==="none"?(de(oe,this.cookieDomain),de(se,this.cookieDomain)):r==="anonymous"&&o==="full"&&(this.userId=void 0),f){this.isFirstPage=!0;let h=this.startSession();this.queue.start(),h&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),de(oe,this.cookieDomain),de(se,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=ae(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=Ee(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),i.liveInstances=Math.max(0,i.liveInstances-1));}};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
+
${a.stack}`),re(i,`trackError_${r}`,{...f||{},errorMessage:h,errorStack:c,isTrackError:!0});},xt=P(Rr),Mr=i=>{Z("env",i);};P(he("setEnvironment",Mr));var Dr=i=>{Z("passportClientId",i);};P(he("setPassportClientId",Dr));var Pr=i=>{Z("pak",i);};P(he("setPublishableApiKey",Pr));P(he("getDetail",$e));var Fr={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},jr={dev:"https://api.dev.immutable.com",sandbox:"https://api.sandbox.immutable.com",production:"https://api.immutable.com"},Nt="/v1/audience/messages",qr="/v1/audience/tracking-consent",Lt=5e3,Rt=20,oe="imtbl_anon_id",se="_imtbl_sid",Gr=365*24*60*60*2,Ut=30*60,Ct="session_start",$t="session_end",ze=i=>jr[i],ce=()=>typeof window<"u"&&typeof document<"u",ae=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let r=Math.trunc(Math.random()*16);return (i==="x"?r:r%4+8).toString(16)}),Mt=()=>new Date().toISOString();function Ie(i){if(!ce())return;let r=document.cookie.match(new RegExp(`(?:^|; )${i}=([^;]*)`));return r?decodeURIComponent(r[1]):void 0}function ve(i,r,o,f){if(!ce())return;let h=window.location.protocol==="https:"?"; Secure":"",c=f?`; domain=${f}`:"";document.cookie=`${i}=${encodeURIComponent(r)}; path=/; max-age=${o}; SameSite=Lax${c}${h}`;}function de(i,r){ve(i,"",0,r);}function Ee(i){let r=Ie(oe);if(r)return r;let o=ae();return ve(oe,o,Gr,i),o}var Ge=class extends Error{status;endpoint;body;constructor(i){super(`audience transport failed: ${i.status||"network error"} ${i.endpoint}`,i.cause!==void 0?{cause:i.cause}:void 0),this.name="TransportError",this.status=i.status,this.endpoint=i.endpoint,this.body=i.body;}},Ve=class extends Error{code;status;endpoint;responseBody;cause;constructor(i){super(i.message),this.name="AudienceError",this.code=i.code,this.status=i.status,this.endpoint=i.endpoint,this.responseBody=i.responseBody,this.cause=i.cause;}};function Dt(i,r,o){if(i.status===0)return new Ve({code:"NETWORK_ERROR",message:r==="flush"?`Network error sending ${o??0} messages`:"Network error syncing consent",status:0,endpoint:i.endpoint,cause:i.cause});if(i.status>=200&&i.status<300){let f=i.body,h=f?.rejected??0,c=f?.accepted??0;return new Ve({code:"VALIDATION_REJECTED",message:`Backend rejected ${h} of ${h+c} messages`,status:i.status,endpoint:i.endpoint,responseBody:i.body})}return new Ve({code:r==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:r==="flush"?`Flush failed with status ${i.status}`:`Consent sync failed with status ${i.status}`,status:i.status,endpoint:i.endpoint,responseBody:i.body,cause:i.cause})}function Pt(i,r){if(i)try{i(r);}catch{}}async function Ot(i){let r=i.headers?.get?.("content-type")??"";try{return r.includes("application/json")?await i.json():await i.text()}catch{return}}var He=async(i,r,o,f)=>{try{let h=await fetch(i,{method:f?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":r},body:JSON.stringify(o),keepalive:f?.keepalive});if(!h.ok){let a=await Ot(h);return re("audience","transport_send_failed",{status:h.status}),{ok:!1,error:new Ge({status:h.status,endpoint:i,body:a})}}let c=await Ot(h);if(typeof c=="object"&&c!==null&&"rejected"in c){let a=c.rejected??0;if(a>0)return re("audience","transport_partial_rejected",{status:h.status,rejected:a}),{ok:!1,error:new Ge({status:h.status,endpoint:i,body:c})}}return {ok:!0}}catch(h){let c=new Ge({status:0,endpoint:i,cause:h});return xt("audience","transport_send",c),{ok:!1,error:c}}},Ye="__imtbl_audience_";function Je(){try{return ce()&&typeof localStorage<"u"}catch{return !1}}function Vr(i,r=Ye){if(Je())try{let o=localStorage.getItem(`${r}${i}`);return o?JSON.parse(o):void 0}catch{return}}function Kr(i,r,o=Ye){if(Je())try{localStorage.setItem(`${o}${i}`,JSON.stringify(r));}catch{}}function zr(i,r=Ye){if(Je())try{localStorage.removeItem(`${r}${i}`);}catch{}}var Ke="queue",kt=100,Ft=class{constructor(i,r,o,f,h,c){this.send=i,this.endpointUrl=r,this.publishableKey=o,this.flushIntervalMs=f,this.flushSize=h,this.onFlush=c?.onFlush,this.onError=c?.onError,this.storagePrefix=c?.storagePrefix;let a=Vr(Ke,this.storagePrefix)??[];this.messages=c?.staleFilter?a.filter(c.staleFilter):a;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(i){this.messages.push(i),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)){this.flushing=!0;try{let i=this.messages.slice(0,kt),r={messages:i},o=await this.send(this.endpointUrl,this.publishableKey,r),f;!o.ok&&o.error&&(f=Dt(o.error,"flush",i.length));let h=f?.code==="VALIDATION_REJECTED";(o.ok||h)&&(this.messages=this.messages.slice(i.length),this.persist()),this.onFlush?.(o.ok,i.length),f&&Pt(this.onError,f);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let i=this.messages.slice(0,kt),r={messages:i};this.send(this.endpointUrl,this.publishableKey,r,{keepalive:!0}),this.messages=this.messages.slice(i.length),this.persist();}purge(i){this.messages=this.messages.filter(r=>!i(r)),this.persist();}transform(i){this.messages=this.messages.map(i),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],zr(Ke,this.storagePrefix);}registerUnload(){!ce()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}persist(){Kr(Ke,this.messages,this.storagePrefix);}},Hr="2.15.1-alpha.1";function jt(i="@imtbl/audience",r=Hr){let o={library:i,libraryVersion:r};return ce()&&(o.userAgent=navigator.userAgent,o.locale=navigator.language,o.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,o.screen=`${window.screen.width}x${window.screen.height}`,o.pageUrl=window.location.href,o.pagePath=window.location.pathname,o.pageReferrer=document.referrer,o.pageTitle=document.title),o}function qt(i){let r=new Date(i).getTime();if(Number.isNaN(r))return !1;let o=Date.now();return r<=o+864e5&&r>=o-2592e6}function Gt(i,r,o,f){return i!==o||r!==f}function pe(i,r=256){return i.length>r?i.slice(0,r):i}function ue(i){let r=Ie(se);if(r)return ve(se,r,Ut,i),{sessionId:r,isNew:!1};let o=ae();return ve(se,o,Ut,i),{sessionId:o,isNew:!0}}var Vt=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],Kt=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],zt="__imtbl_attribution";function Yr(i){let r;try{r=new URL(i).searchParams;}catch{return {}}let o={};for(let h of [...Vt,...Kt]){let c=r.get(h);c&&(o[h]=c);}let f=r.get("referral_code");return f&&(o.referral_code=f),o}function Jr(){try{let i=sessionStorage.getItem(zt);return i?JSON.parse(i):null}catch{return null}}function Wr(i){try{sessionStorage.setItem(zt,JSON.stringify(i));}catch{}}function Ht(){let i=Jr();if(i)return i;let r=typeof window<"u"&&window.location?Yr(window.location.href):{},o=typeof document<"u"&&document.referrer||void 0,f=typeof window<"u"&&window.location?window.location.href:void 0,h=Kt.some(y=>y in r),c=Vt.some(y=>y in r),a={...r,referrer:o,landing_page:f,touchpoint_type:h||c?"click":void 0};return Wr(a),a}function Yt(i,r,o,f,h,c,a,y){let w=a??"none",B={none:0,anonymous:1,full:2};function b(m){let v=`${ze(h)}${qr}`;r(v,o,{anonymousId:f,status:m,source:c},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Pt(y,Dt(p.error,"consent"));});}return {get level(){return w},setLevel(m){m!==w&&(B[m]<B[w]&&(m==="none"?i.purge(()=>!0):m==="anonymous"&&(i.purge(v=>v.type==="identify"||v.type==="alias"),i.transform(v=>{if("userId"in v){let{userId:p,...g}=v;return g}return v}))),w=m,b(m));}}}O();U();O();U();var Jt="@imtbl/audience",Wt="2.15.1-alpha.1",H="[audience]",Xt="WebSDK";var Se=class{enabled;constructor(r=!1){this.enabled=r;}logEvent(r,o){this.enabled&&console.log(`${H} ${r}`,o);}logFlush(r,o){this.enabled&&console.log(`${H} flush ${r?"ok":"failed"} (${o} messages)`);}logConsent(r,o){this.enabled&&console.log(`${H} consent ${r} \u2192 ${o}`);}logWarning(r){this.enabled&&console.warn(`${H} ${r}`);}};var We=class i{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(r){let{cookieDomain:o,environment:f,publishableKey:h}=r,c=r.consent??"none",a=Xt,y=r.flushInterval??Lt,w=r.flushSize??Rt;this.cookieDomain=o,this.debug=new Se(r.debug??!1);let B=!1;c!=="none"?(this.anonymousId=Ee(o),B=this.startSession()):this.anonymousId=Ie(oe)??ae();let b=`${ze(f)}${Nt}`;this.queue=new Ft(He,b,h,y,w,{onFlush:(m,v)=>this.debug.logFlush(m,v),staleFilter:m=>qt(m.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Yt(this.queue,He,h,this.anonymousId,f,a,c),this.attribution=Ht(),this.isTrackingDisabled()||(this.queue.start(),B&&this.trackSessionStart());}static init(r){if(!r.publishableKey?.trim())throw new Error(`${H} publishableKey is required`);return i.liveInstances>0&&console.warn(`${H} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),i.liveInstances+=1,new i(r)}isTrackingDisabled(){return this.consent.level==="none"}effectiveUserId(){return this.consent.level==="full"?this.userId:void 0}startSession(){let r=ue(this.cookieDomain);return this.sessionId=r.sessionId,this.sessionStartTime=Date.now(),r.isNew}baseMessage(){return {messageId:ae(),eventTimestamp:Mt(),anonymousId:this.anonymousId,surface:"web",context:jt(Jt,Wt)}}enqueue(r,o){this.queue.enqueue(o),this.debug.logEvent(r,o);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Ct,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:$t,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(r){if(this.isTrackingDisabled())return;ue(this.cookieDomain);let o={...r};this.isFirstPage&&(Object.assign(o,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(o).length>0?o:void 0,userId:this.effectiveUserId()});}track(r,o){this.isTrackingDisabled()||(ue(this.cookieDomain),this.enqueue("track",{...this.baseMessage(),type:"track",eventName:pe(r),properties:o,userId:this.effectiveUserId()}));}identify(r,o,f){if(this.consent.level!=="full"){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(ue(this.cookieDomain),r!==null&&typeof r=="object"&&!Array.isArray(r)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:r});return}if(typeof r!="string")return;let h=pe(r);this.userId=h,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:h,identityType:o,traits:f});}alias(r,o){if(this.consent.level!=="full"){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!Gt(r.id,r.identityType,o.id,o.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}ue(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:pe(r.id),fromType:r.identityType,toId:pe(o.id),toType:o.identityType});}setConsent(r){let o=this.consent.level;if(r===o)return;this.debug.logConsent(o,r);let f=o==="none"&&r!=="none";if(f&&(this.anonymousId=Ee(this.cookieDomain)),r==="none"&&this.queue.stop(),this.consent.setLevel(r),r==="none"?(de(oe,this.cookieDomain),de(se,this.cookieDomain)):r==="anonymous"&&o==="full"&&(this.userId=void 0),f){this.isFirstPage=!0;let h=this.startSession();this.queue.start(),h&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),de(oe,this.cookieDomain),de(se,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=ae(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=Ee(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),i.liveInstances=Math.max(0,i.liveInstances-1));}};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
tiny-lru/dist/tiny-lru.js:
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var je=Object.create;var se=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var He=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ke(t))!Ve.call(e,n)&&n!==s&&se(e,n,{get:()=>t[n],enumerable:!(i=Be(t,n))||i.enumerable});return e};var ze=(e,t,s)=>(s=e!=null?je(qe(e)):{},He(se(s,"default",{value:e,enumerable:!0}),e));var le=Ge(w=>{Object.defineProperty(w,"__esModule",{value:!0});w.clearGlobalNamespace=w.getGlobalisedValue=void 0;var We="globalise__singleton__",Xe={},re=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Xe,Ze=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},oe=e=>`${We}${e}`,ae=e=>{let t=re(),s=oe(e);return t[s]||(t[s]={}),t[s]},Qe=(e,t)=>ae(e)[t]||void 0,et=(e,t,s)=>{let i=ae(e);i[t]=s;},tt=(e,t,s)=>{Ze(e,t);let i=Qe(e,t);return i!==void 0?i:(et(e,t,s),s)};w.getGlobalisedValue=tt;var st=e=>{let t=re(),s=oe(e);t[s]!==void 0&&delete t[s];};w.clearGlobalNamespace=st;});var R=class{constructor(t=0,s=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){let s=this.items[t];delete this.items[t],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(t=this.keys()){return t.map(s=>[s,this.get(s)])}evict(t=!1){if(t||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(t){let s;return this.has(t)&&(s=this.items[t].expiry),s}get(t){let s;if(this.has(t)){let i=this.items[t];this.ttl>0&&i.expiry<=Date.now()?this.delete(t):(s=i.value,this.set(t,s,!0));}return s}has(t){return t in this.items}keys(){let t=[],s=this.first;for(;s!==null;)t.push(s.key),s=s.next;return t}set(t,s,i=!1,n=this.resetTtl){let r;if(i||this.has(t)){if(r=this.items[t],r.value=s,i===!1&&n&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==r){let o=this.last,a=r.next,d=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,o.next=r,d!==null&&(d.next=a),a!==null&&(a.prev=d);}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:s},++this.size===1?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map(s=>this.get(s))}};function ie(e=1e3,t=0,s=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new R(e,t,s)}var Je={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=M,onHit:n,lruOptions:r={}}=t,o={...Je,...r},a=s||ie(o.max,o.ttl);function d(...h){let f=i(...h),u=a.get(f);if(a.has(f))return n&&n(f,u,a),u;let p=e.apply(this,h);return a.set(f,p),p}return d._cache=a,d},M=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${M(...t)}]`:typeof t=="object"?`{${M(...Ye(t))}}`:JSON.stringify(t)).join(","),Ye=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var q=ze(le()),it=Object.defineProperty,nt=(e,t)=>{for(var s in t)it(e,s,{get:t[s],enumerable:!0});},rt={};nt(rt,{deleteItem:()=>ut,getItem:()=>F,setItem:()=>$});var O=()=>typeof window>"u",de=()=>!O(),ot="__IMX-",V=()=>de()&&window.localStorage,at=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},lt=e=>typeof e=="string"?e:JSON.stringify(e),G=e=>`${ot}${e}`;function F(e){if(V())return at(window.localStorage.getItem(G(e)))}var $=(e,t)=>V()?(window.localStorage.setItem(G(e),lt(t)),!0):!1,ut=e=>V()?(window.localStorage.removeItem(G(e)),!0):!1,j=0,dt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return j=s.getTime()-i.getTime(),j},ct=()=>{let e=new Date().getTime()+j;return new Date(e).toISOString()},ht=(e=>(e.RUNTIME_ID="rid",e.PASSPORT_CLIENT_ID="passportClientId",e.ENVIRONMENT="env",e.PUBLISHABLE_API_KEY="pak",e.IDENTITY="uid",e.DOMAIN="domain",e.SDK_VERSION="sdkVersion",e))(ht||{}),ft="https://api.immutable.com",pt=e=>{if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(e)));throw new Error("Base64 encoding not supported in this environment")};async function ce(e,t){let s=JSON.stringify(t),i={payload:pt(s)},n=await fetch(`${ft}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok){let r=await n.text().catch(()=>"");throw new Error(`Request failed (${n.status}): ${r||n.statusText}`)}return n.json()}var g,y,mt=()=>{g=F("metrics-events")||[],y=F("metrics-runtime")||{};};mt();var v=(e,t)=>{y={...y,[e]:t},$("metrics-runtime",y);},B=e=>{if(y[e]!==void 0)return y[e]},gt=()=>y,yt=()=>g,vt=e=>{g.push(e),$("metrics-events",g);},wt=e=>{g=g.slice(e),$("metrics-events",g);},he=e=>{let t=[];return Object.entries(e).forEach(([s,i])=>{(typeof s=="string"||typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&t.push([s,i.toString()]);}),t},P="2.15.
|
|
3
|
+
var je=Object.create;var se=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var He=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ke(t))!Ve.call(e,n)&&n!==s&&se(e,n,{get:()=>t[n],enumerable:!(i=Be(t,n))||i.enumerable});return e};var ze=(e,t,s)=>(s=e!=null?je(qe(e)):{},He(se(s,"default",{value:e,enumerable:!0}),e));var le=Ge(w=>{Object.defineProperty(w,"__esModule",{value:!0});w.clearGlobalNamespace=w.getGlobalisedValue=void 0;var We="globalise__singleton__",Xe={},re=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Xe,Ze=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},oe=e=>`${We}${e}`,ae=e=>{let t=re(),s=oe(e);return t[s]||(t[s]={}),t[s]},Qe=(e,t)=>ae(e)[t]||void 0,et=(e,t,s)=>{let i=ae(e);i[t]=s;},tt=(e,t,s)=>{Ze(e,t);let i=Qe(e,t);return i!==void 0?i:(et(e,t,s),s)};w.getGlobalisedValue=tt;var st=e=>{let t=re(),s=oe(e);t[s]!==void 0&&delete t[s];};w.clearGlobalNamespace=st;});var R=class{constructor(t=0,s=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){let s=this.items[t];delete this.items[t],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(t=this.keys()){return t.map(s=>[s,this.get(s)])}evict(t=!1){if(t||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(t){let s;return this.has(t)&&(s=this.items[t].expiry),s}get(t){let s;if(this.has(t)){let i=this.items[t];this.ttl>0&&i.expiry<=Date.now()?this.delete(t):(s=i.value,this.set(t,s,!0));}return s}has(t){return t in this.items}keys(){let t=[],s=this.first;for(;s!==null;)t.push(s.key),s=s.next;return t}set(t,s,i=!1,n=this.resetTtl){let r;if(i||this.has(t)){if(r=this.items[t],r.value=s,i===!1&&n&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==r){let o=this.last,a=r.next,d=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,o.next=r,d!==null&&(d.next=a),a!==null&&(a.prev=d);}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:s},++this.size===1?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map(s=>this.get(s))}};function ie(e=1e3,t=0,s=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new R(e,t,s)}var Je={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=M,onHit:n,lruOptions:r={}}=t,o={...Je,...r},a=s||ie(o.max,o.ttl);function d(...h){let f=i(...h),u=a.get(f);if(a.has(f))return n&&n(f,u,a),u;let p=e.apply(this,h);return a.set(f,p),p}return d._cache=a,d},M=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${M(...t)}]`:typeof t=="object"?`{${M(...Ye(t))}}`:JSON.stringify(t)).join(","),Ye=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var q=ze(le()),it=Object.defineProperty,nt=(e,t)=>{for(var s in t)it(e,s,{get:t[s],enumerable:!0});},rt={};nt(rt,{deleteItem:()=>ut,getItem:()=>F,setItem:()=>$});var O=()=>typeof window>"u",de=()=>!O(),ot="__IMX-",V=()=>de()&&window.localStorage,at=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},lt=e=>typeof e=="string"?e:JSON.stringify(e),G=e=>`${ot}${e}`;function F(e){if(V())return at(window.localStorage.getItem(G(e)))}var $=(e,t)=>V()?(window.localStorage.setItem(G(e),lt(t)),!0):!1,ut=e=>V()?(window.localStorage.removeItem(G(e)),!0):!1,j=0,dt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return j=s.getTime()-i.getTime(),j},ct=()=>{let e=new Date().getTime()+j;return new Date(e).toISOString()},ht=(e=>(e.RUNTIME_ID="rid",e.PASSPORT_CLIENT_ID="passportClientId",e.ENVIRONMENT="env",e.PUBLISHABLE_API_KEY="pak",e.IDENTITY="uid",e.DOMAIN="domain",e.SDK_VERSION="sdkVersion",e))(ht||{}),ft="https://api.immutable.com",pt=e=>{if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(e)));throw new Error("Base64 encoding not supported in this environment")};async function ce(e,t){let s=JSON.stringify(t),i={payload:pt(s)},n=await fetch(`${ft}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok){let r=await n.text().catch(()=>"");throw new Error(`Request failed (${n.status}): ${r||n.statusText}`)}return n.json()}var g,y,mt=()=>{g=F("metrics-events")||[],y=F("metrics-runtime")||{};};mt();var v=(e,t)=>{y={...y,[e]:t},$("metrics-runtime",y);},B=e=>{if(y[e]!==void 0)return y[e]},gt=()=>y,yt=()=>g,vt=e=>{g.push(e),$("metrics-events",g);},wt=e=>{g=g.slice(e),$("metrics-events",g);},he=e=>{let t=[];return Object.entries(e).forEach(([s,i])=>{(typeof s=="string"||typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&t.push([s,i.toString()]);}),t},P="2.15.1-alpha.1",bt=()=>O()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",It=()=>{if(O())return "";let e;try{window.self!==window.top&&(e=bt());}catch{}return e||(e=window.location.hostname),e},St=()=>{if(v("sdkVersion",P),O())return {browser:"nodejs",sdkVersion:P};let e=It();return e&&v("domain",e),{sdkVersion:P,browser:window.navigator.userAgent,domain:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},K=!1,Et=()=>K,xt=async()=>{K=!0;try{let e=he(St()),t=B("rid"),s=B("uid"),i=await ce("/v1/sdk/initialise",{version:1,data:{runtimeDetails:e,runtimeId:t,uId:s}}),{runtimeId:n,sTime:r}=i;v("rid",n),dt(r);}catch{K=!1;}};function c(e,t){return (...s)=>{try{let i=e(...s);return i instanceof Promise?i.catch(()=>t):i}catch{return t}}}function _t(){return de()||typeof process>"u"?!1:process.env.JEST_WORKER_ID!==void 0}var Tt=c(_t,!1),fe="imtbl__metrics",kt=5e3,Nt=1e3,_=(e,t)=>(0, q.getGlobalisedValue)(fe,e,t),Ot=(e,t)=>{let s=ne(t,{lruOptions:{ttl:kt,max:Nt}});return (0, q.getGlobalisedValue)(fe,e,s)},$t=5e3,At=(e,t,s)=>{let i={event:`${e}.${t}`,time:ct(),...s&&{properties:he(s)}};vt(i);},b=c(Ot("track",At)),Dt=async()=>{if(Et()===!1){await xt();return}let e=yt();if(e.length===0)return;let t=e.length,s=gt();await ce("/v1/sdk/metrics",{version:1,data:{events:e,details:s}})instanceof Error||wt(t);},Ct=c(Dt),pe=async()=>{await Ct(),setTimeout(pe,$t);},ue=!1,Lt=()=>{ue||(ue=!0,pe());};Tt()||c(_("startFlushing",Lt))();var Bt=(e,t,s,i)=>{let{message:n}=s,r=s.stack||"",{cause:o}=s;o instanceof Error&&(r=`${r}
|
|
4
4
|
Cause: ${o.message}
|
|
5
|
-
${o.stack}`),b(e,`trackError_${t}`,{...i||{},errorMessage:n,errorStack:r,isTrackError:!0});},me=c(Bt),Vt=e=>{v("env",e);};c(_("setEnvironment",Vt));var Gt=e=>{v("passportClientId",e);};c(_("setPassportClientId",Gt));var Ht=e=>{v("pak",e);};c(_("setPublishableApiKey",Ht));c(_("getDetail",B));var zt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Jt={dev:"https://api.dev.immutable.com",sandbox:"https://api.sandbox.immutable.com",production:"https://api.immutable.com"},we="/v1/audience/messages",Yt="/v1/audience/tracking-consent",be=5e3,Ie=20,S="imtbl_anon_id",I="_imtbl_sid",Wt=365*24*60*60*2,ge=30*60,Se="session_start",Ee="session_end",Y=e=>Jt[e],T=()=>typeof window<"u"&&typeof document<"u",E=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return (e==="x"?t:t%4+8).toString(16)}),xe=()=>new Date().toISOString();function D(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function A(e,t,s,i){if(!T())return;let n=window.location.protocol==="https:"?"; Secure":"",r=i?`; domain=${i}`:"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${s}; SameSite=Lax${r}${n}`;}function k(e,t){A(e,"",0,t);}function C(e){let t=D(S);if(t)return t;let s=E();return A(S,s,Wt,e),s}var H=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},z=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function _e(e,t,s){if(e.status===0)return new z({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,n=i?.rejected??0,r=i?.accepted??0;return new z({code:"VALIDATION_REJECTED",message:`Backend rejected ${n} of ${n+r} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new z({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Te(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var W=async(e,t,s,i)=>{try{let n=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!n.ok){let o=await ye(n);return b("audience","transport_send_failed",{status:n.status}),{ok:!1,error:new H({status:n.status,endpoint:e,body:o})}}let r=await ye(n);if(typeof r=="object"&&r!==null&&"rejected"in r){let o=r.rejected??0;if(o>0)return b("audience","transport_partial_rejected",{status:n.status,rejected:o}),{ok:!1,error:new H({status:n.status,endpoint:e,body:r})}}return {ok:!0}}catch(n){let r=new H({status:0,endpoint:e,cause:n});return me("audience","transport_send",r),{ok:!1,error:r}}},X="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Xt(e,t=X){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Zt(e,t,s=X){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Qt(e,t=X){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var J="queue",ve=100,ke=class{constructor(e,t,s,i,n,r){this.send=e,this.endpointUrl=t,this.publishableKey=s,this.flushIntervalMs=i,this.flushSize=n,this.onFlush=r?.onFlush,this.onError=r?.onError,this.storagePrefix=r?.storagePrefix;let o=Xt(J,this.storagePrefix)??[];this.messages=r?.staleFilter?o.filter(r.staleFilter):o;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=_e(s.error,"flush",e.length));let n=i?.code==="VALIDATION_REJECTED";(s.ok||n)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&Te(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Qt(J,this.storagePrefix);}registerUnload(){!T()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}persist(){Zt(J,this.messages,this.storagePrefix);}},es="2.15.0";function Ne(e="@imtbl/audience",t=es){let s={library:e,libraryVersion:t};return T()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Oe(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function $e(e,t,s,i){return e!==s||t!==i}function N(e,t=256){return e.length>t?e.slice(0,t):e}function x(e){let t=D(I);if(t)return A(I,t,ge,e),{sessionId:t,isNew:!1};let s=E();return A(I,s,ge,e),{sessionId:s,isNew:!0}}var Ae=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],De=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Ce="__imtbl_attribution";function ts(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let n of [...Ae,...De]){let r=t.get(n);r&&(s[n]=r);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function ss(){try{let e=sessionStorage.getItem(Ce);return e?JSON.parse(e):null}catch{return null}}function is(e){try{sessionStorage.setItem(Ce,JSON.stringify(e));}catch{}}function Le(){let e=ss();if(e)return e;let t=typeof window<"u"&&window.location?ts(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,n=De.some(a=>a in t),r=Ae.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:n||r?"click":void 0};return is(o),o}function Ue(e,t,s,i,n,r,o,a){let d=o??"none",h={none:0,anonymous:1,full:2};function f(u){let l=`${Y(n)}${Yt}`;t(l,s,{anonymousId:i,status:u,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Te(a,_e(p.error,"consent"));});}return {get level(){return d},setLevel(u){u!==d&&(h[u]<h[d]&&(u==="none"?e.purge(()=>!0):u==="anonymous"&&(e.purge(l=>l.type==="identify"||l.type==="alias"),e.transform(l=>{if("userId"in l){let{userId:p,...U}=l;return U}return l}))),d=u,f(u));}}}var Re="@imtbl/audience",Me="2.15.0",m="[audience]",Pe="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${m} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${m} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${m} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${m} ${t}`);}};var Q=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,environment:i,publishableKey:n}=t,r=t.consent??"none",o=Pe,a=t.flushInterval??be,d=t.flushSize??Ie;this.cookieDomain=s,this.debug=new L(t.debug??!1);let h=!1;r!=="none"?(this.anonymousId=C(s),h=this.startSession()):this.anonymousId=D(S)??E();let f=`${Y(i)}${we}`;this.queue=new ke(W,f,n,a,d,{onFlush:(u,l)=>this.debug.logFlush(u,l),staleFilter:u=>Oe(u.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Ue(this.queue,W,n,this.anonymousId,i,o,r),this.attribution=Le(),this.isTrackingDisabled()||(this.queue.start(),h&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${m} publishableKey is required`);return e.liveInstances>0&&console.warn(`${m} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return this.consent.level==="none"}effectiveUserId(){return this.consent.level==="full"?this.userId:void 0}startSession(){let t=x(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:E(),eventTimestamp:xe(),anonymousId:this.anonymousId,surface:"web",context:Ne(Re,Me)}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Se,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ee,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;x(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,s){this.isTrackingDisabled()||(x(this.cookieDomain),this.enqueue("track",{...this.baseMessage(),type:"track",eventName:N(t),properties:s,userId:this.effectiveUserId()}));}identify(t,s,i){if(this.consent.level!=="full"){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(x(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let n=N(t);this.userId=n,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:n,identityType:s,traits:i});}alias(t,s){if(this.consent.level!=="full"){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!$e(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}x(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:N(t.id),fromType:t.identityType,toId:N(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=s==="none"&&t!=="none";if(i&&(this.anonymousId=C(this.cookieDomain)),t==="none"&&this.queue.stop(),this.consent.setLevel(t),t==="none"?(k(S,this.cookieDomain),k(I,this.cookieDomain)):t==="anonymous"&&s==="full"&&(this.userId=void 0),i){this.isFirstPage=!0;let n=this.startSession();this.queue.start(),n&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),k(S,this.cookieDomain),k(I,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=E(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=C(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};/*! Bundled license information:
|
|
5
|
+
${o.stack}`),b(e,`trackError_${t}`,{...i||{},errorMessage:n,errorStack:r,isTrackError:!0});},me=c(Bt),Vt=e=>{v("env",e);};c(_("setEnvironment",Vt));var Gt=e=>{v("passportClientId",e);};c(_("setPassportClientId",Gt));var Ht=e=>{v("pak",e);};c(_("setPublishableApiKey",Ht));c(_("getDetail",B));var zt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Jt={dev:"https://api.dev.immutable.com",sandbox:"https://api.sandbox.immutable.com",production:"https://api.immutable.com"},we="/v1/audience/messages",Yt="/v1/audience/tracking-consent",be=5e3,Ie=20,S="imtbl_anon_id",I="_imtbl_sid",Wt=365*24*60*60*2,ge=30*60,Se="session_start",Ee="session_end",Y=e=>Jt[e],T=()=>typeof window<"u"&&typeof document<"u",E=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return (e==="x"?t:t%4+8).toString(16)}),xe=()=>new Date().toISOString();function D(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function A(e,t,s,i){if(!T())return;let n=window.location.protocol==="https:"?"; Secure":"",r=i?`; domain=${i}`:"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${s}; SameSite=Lax${r}${n}`;}function k(e,t){A(e,"",0,t);}function C(e){let t=D(S);if(t)return t;let s=E();return A(S,s,Wt,e),s}var H=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},z=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function _e(e,t,s){if(e.status===0)return new z({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,n=i?.rejected??0,r=i?.accepted??0;return new z({code:"VALIDATION_REJECTED",message:`Backend rejected ${n} of ${n+r} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new z({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Te(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var W=async(e,t,s,i)=>{try{let n=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!n.ok){let o=await ye(n);return b("audience","transport_send_failed",{status:n.status}),{ok:!1,error:new H({status:n.status,endpoint:e,body:o})}}let r=await ye(n);if(typeof r=="object"&&r!==null&&"rejected"in r){let o=r.rejected??0;if(o>0)return b("audience","transport_partial_rejected",{status:n.status,rejected:o}),{ok:!1,error:new H({status:n.status,endpoint:e,body:r})}}return {ok:!0}}catch(n){let r=new H({status:0,endpoint:e,cause:n});return me("audience","transport_send",r),{ok:!1,error:r}}},X="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Xt(e,t=X){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Zt(e,t,s=X){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Qt(e,t=X){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var J="queue",ve=100,ke=class{constructor(e,t,s,i,n,r){this.send=e,this.endpointUrl=t,this.publishableKey=s,this.flushIntervalMs=i,this.flushSize=n,this.onFlush=r?.onFlush,this.onError=r?.onError,this.storagePrefix=r?.storagePrefix;let o=Xt(J,this.storagePrefix)??[];this.messages=r?.staleFilter?o.filter(r.staleFilter):o;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=_e(s.error,"flush",e.length));let n=i?.code==="VALIDATION_REJECTED";(s.ok||n)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&Te(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Qt(J,this.storagePrefix);}registerUnload(){!T()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}persist(){Zt(J,this.messages,this.storagePrefix);}},es="2.15.1-alpha.1";function Ne(e="@imtbl/audience",t=es){let s={library:e,libraryVersion:t};return T()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Oe(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function $e(e,t,s,i){return e!==s||t!==i}function N(e,t=256){return e.length>t?e.slice(0,t):e}function x(e){let t=D(I);if(t)return A(I,t,ge,e),{sessionId:t,isNew:!1};let s=E();return A(I,s,ge,e),{sessionId:s,isNew:!0}}var Ae=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],De=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Ce="__imtbl_attribution";function ts(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let n of [...Ae,...De]){let r=t.get(n);r&&(s[n]=r);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function ss(){try{let e=sessionStorage.getItem(Ce);return e?JSON.parse(e):null}catch{return null}}function is(e){try{sessionStorage.setItem(Ce,JSON.stringify(e));}catch{}}function Le(){let e=ss();if(e)return e;let t=typeof window<"u"&&window.location?ts(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,n=De.some(a=>a in t),r=Ae.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:n||r?"click":void 0};return is(o),o}function Ue(e,t,s,i,n,r,o,a){let d=o??"none",h={none:0,anonymous:1,full:2};function f(u){let l=`${Y(n)}${Yt}`;t(l,s,{anonymousId:i,status:u,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Te(a,_e(p.error,"consent"));});}return {get level(){return d},setLevel(u){u!==d&&(h[u]<h[d]&&(u==="none"?e.purge(()=>!0):u==="anonymous"&&(e.purge(l=>l.type==="identify"||l.type==="alias"),e.transform(l=>{if("userId"in l){let{userId:p,...U}=l;return U}return l}))),d=u,f(u));}}}var Re="@imtbl/audience",Me="2.15.1-alpha.1",m="[audience]",Pe="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${m} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${m} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${m} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${m} ${t}`);}};var Q=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,environment:i,publishableKey:n}=t,r=t.consent??"none",o=Pe,a=t.flushInterval??be,d=t.flushSize??Ie;this.cookieDomain=s,this.debug=new L(t.debug??!1);let h=!1;r!=="none"?(this.anonymousId=C(s),h=this.startSession()):this.anonymousId=D(S)??E();let f=`${Y(i)}${we}`;this.queue=new ke(W,f,n,a,d,{onFlush:(u,l)=>this.debug.logFlush(u,l),staleFilter:u=>Oe(u.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Ue(this.queue,W,n,this.anonymousId,i,o,r),this.attribution=Le(),this.isTrackingDisabled()||(this.queue.start(),h&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${m} publishableKey is required`);return e.liveInstances>0&&console.warn(`${m} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return this.consent.level==="none"}effectiveUserId(){return this.consent.level==="full"?this.userId:void 0}startSession(){let t=x(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:E(),eventTimestamp:xe(),anonymousId:this.anonymousId,surface:"web",context:Ne(Re,Me)}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Se,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ee,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;x(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,s){this.isTrackingDisabled()||(x(this.cookieDomain),this.enqueue("track",{...this.baseMessage(),type:"track",eventName:N(t),properties:s,userId:this.effectiveUserId()}));}identify(t,s,i){if(this.consent.level!=="full"){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(x(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let n=N(t);this.userId=n,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:n,identityType:s,traits:i});}alias(t,s){if(this.consent.level!=="full"){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!$e(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}x(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:N(t.id),fromType:t.identityType,toId:N(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=s==="none"&&t!=="none";if(i&&(this.anonymousId=C(this.cookieDomain)),t==="none"&&this.queue.stop(),this.consent.setLevel(t),t==="none"?(k(S,this.cookieDomain),k(I,this.cookieDomain)):t==="anonymous"&&s==="full"&&(this.userId=void 0),i){this.isFirstPage=!0;let n=this.startSession();this.queue.start(),n&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),k(S,this.cookieDomain),k(I,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=E(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=C(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};/*! Bundled license information:
|
|
6
6
|
|
|
7
7
|
tiny-lru/dist/tiny-lru.js:
|
|
8
8
|
(**
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var je=Object.create;var se=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var He=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ke(t))!Ve.call(e,n)&&n!==s&&se(e,n,{get:()=>t[n],enumerable:!(i=Be(t,n))||i.enumerable});return e};var ze=(e,t,s)=>(s=e!=null?je(qe(e)):{},He(se(s,"default",{value:e,enumerable:!0}),e));var le=Ge(w=>{Object.defineProperty(w,"__esModule",{value:!0});w.clearGlobalNamespace=w.getGlobalisedValue=void 0;var We="globalise__singleton__",Xe={},re=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Xe,Ze=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},oe=e=>`${We}${e}`,ae=e=>{let t=re(),s=oe(e);return t[s]||(t[s]={}),t[s]},Qe=(e,t)=>ae(e)[t]||void 0,et=(e,t,s)=>{let i=ae(e);i[t]=s;},tt=(e,t,s)=>{Ze(e,t);let i=Qe(e,t);return i!==void 0?i:(et(e,t,s),s)};w.getGlobalisedValue=tt;var st=e=>{let t=re(),s=oe(e);t[s]!==void 0&&delete t[s];};w.clearGlobalNamespace=st;});var R=class{constructor(t=0,s=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){let s=this.items[t];delete this.items[t],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(t=this.keys()){return t.map(s=>[s,this.get(s)])}evict(t=!1){if(t||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(t){let s;return this.has(t)&&(s=this.items[t].expiry),s}get(t){let s;if(this.has(t)){let i=this.items[t];this.ttl>0&&i.expiry<=Date.now()?this.delete(t):(s=i.value,this.set(t,s,!0));}return s}has(t){return t in this.items}keys(){let t=[],s=this.first;for(;s!==null;)t.push(s.key),s=s.next;return t}set(t,s,i=!1,n=this.resetTtl){let r;if(i||this.has(t)){if(r=this.items[t],r.value=s,i===!1&&n&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==r){let o=this.last,a=r.next,d=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,o.next=r,d!==null&&(d.next=a),a!==null&&(a.prev=d);}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:s},++this.size===1?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map(s=>this.get(s))}};function ie(e=1e3,t=0,s=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new R(e,t,s)}var Je={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=M,onHit:n,lruOptions:r={}}=t,o={...Je,...r},a=s||ie(o.max,o.ttl);function d(...h){let f=i(...h),u=a.get(f);if(a.has(f))return n&&n(f,u,a),u;let p=e.apply(this,h);return a.set(f,p),p}return d._cache=a,d},M=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${M(...t)}]`:typeof t=="object"?`{${M(...Ye(t))}}`:JSON.stringify(t)).join(","),Ye=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var q=ze(le()),it=Object.defineProperty,nt=(e,t)=>{for(var s in t)it(e,s,{get:t[s],enumerable:!0});},rt={};nt(rt,{deleteItem:()=>ut,getItem:()=>F,setItem:()=>$});var O=()=>typeof window>"u",de=()=>!O(),ot="__IMX-",V=()=>de()&&window.localStorage,at=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},lt=e=>typeof e=="string"?e:JSON.stringify(e),G=e=>`${ot}${e}`;function F(e){if(V())return at(window.localStorage.getItem(G(e)))}var $=(e,t)=>V()?(window.localStorage.setItem(G(e),lt(t)),!0):!1,ut=e=>V()?(window.localStorage.removeItem(G(e)),!0):!1,j=0,dt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return j=s.getTime()-i.getTime(),j},ct=()=>{let e=new Date().getTime()+j;return new Date(e).toISOString()},ht=(e=>(e.RUNTIME_ID="rid",e.PASSPORT_CLIENT_ID="passportClientId",e.ENVIRONMENT="env",e.PUBLISHABLE_API_KEY="pak",e.IDENTITY="uid",e.DOMAIN="domain",e.SDK_VERSION="sdkVersion",e))(ht||{}),ft="https://api.immutable.com",pt=e=>{if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(e)));throw new Error("Base64 encoding not supported in this environment")};async function ce(e,t){let s=JSON.stringify(t),i={payload:pt(s)},n=await fetch(`${ft}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok){let r=await n.text().catch(()=>"");throw new Error(`Request failed (${n.status}): ${r||n.statusText}`)}return n.json()}var g,y,mt=()=>{g=F("metrics-events")||[],y=F("metrics-runtime")||{};};mt();var v=(e,t)=>{y={...y,[e]:t},$("metrics-runtime",y);},B=e=>{if(y[e]!==void 0)return y[e]},gt=()=>y,yt=()=>g,vt=e=>{g.push(e),$("metrics-events",g);},wt=e=>{g=g.slice(e),$("metrics-events",g);},he=e=>{let t=[];return Object.entries(e).forEach(([s,i])=>{(typeof s=="string"||typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&t.push([s,i.toString()]);}),t},P="2.15.
|
|
1
|
+
var je=Object.create;var se=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var He=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ke(t))!Ve.call(e,n)&&n!==s&&se(e,n,{get:()=>t[n],enumerable:!(i=Be(t,n))||i.enumerable});return e};var ze=(e,t,s)=>(s=e!=null?je(qe(e)):{},He(se(s,"default",{value:e,enumerable:!0}),e));var le=Ge(w=>{Object.defineProperty(w,"__esModule",{value:!0});w.clearGlobalNamespace=w.getGlobalisedValue=void 0;var We="globalise__singleton__",Xe={},re=()=>typeof window<"u"?window:typeof globalThis<"u"?globalThis:Xe,Ze=(e,t)=>{if(typeof e!="string")throw "Invalid namespace key";if(typeof t!="string")throw "Invalid item key"},oe=e=>`${We}${e}`,ae=e=>{let t=re(),s=oe(e);return t[s]||(t[s]={}),t[s]},Qe=(e,t)=>ae(e)[t]||void 0,et=(e,t,s)=>{let i=ae(e);i[t]=s;},tt=(e,t,s)=>{Ze(e,t);let i=Qe(e,t);return i!==void 0?i:(et(e,t,s),s)};w.getGlobalisedValue=tt;var st=e=>{let t=re(),s=oe(e);t[s]!==void 0&&delete t[s];};w.clearGlobalNamespace=st;});var R=class{constructor(t=0,s=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=s;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){let s=this.items[t];delete this.items[t],this.size--,s.prev!==null&&(s.prev.next=s.next),s.next!==null&&(s.next.prev=s.prev),this.first===s&&(this.first=s.next),this.last===s&&(this.last=s.prev);}return this}entries(t=this.keys()){return t.map(s=>[s,this.get(s)])}evict(t=!1){if(t||this.size>0){let s=this.first;delete this.items[s.key],--this.size===0?(this.first=null,this.last=null):(this.first=s.next,this.first.prev=null);}return this}expiresAt(t){let s;return this.has(t)&&(s=this.items[t].expiry),s}get(t){let s;if(this.has(t)){let i=this.items[t];this.ttl>0&&i.expiry<=Date.now()?this.delete(t):(s=i.value,this.set(t,s,!0));}return s}has(t){return t in this.items}keys(){let t=[],s=this.first;for(;s!==null;)t.push(s.key),s=s.next;return t}set(t,s,i=!1,n=this.resetTtl){let r;if(i||this.has(t)){if(r=this.items[t],r.value=s,i===!1&&n&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==r){let o=this.last,a=r.next,d=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,o.next=r,d!==null&&(d.next=a),a!==null&&(a.prev=d);}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:s},++this.size===1?this.first=r:this.last.next=r;return this.last=r,this}values(t=this.keys()){return t.map(s=>this.get(s))}};function ie(e=1e3,t=0,s=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof s!="boolean")throw new TypeError("Invalid resetTtl value");return new R(e,t,s)}var Je={max:1e3},ne=(e,t={})=>{let{cache:s,cacheKeyResolver:i=M,onHit:n,lruOptions:r={}}=t,o={...Je,...r},a=s||ie(o.max,o.ttl);function d(...h){let f=i(...h),u=a.get(f);if(a.has(f))return n&&n(f,u,a),u;let p=e.apply(this,h);return a.set(f,p),p}return d._cache=a,d},M=(...e)=>e.length===0?"no-args":e.map(t=>t===void 0?"undefined":t===null?"null":Array.isArray(t)?`[${M(...t)}]`:typeof t=="object"?`{${M(...Ye(t))}}`:JSON.stringify(t)).join(","),Ye=e=>Object.entries(e).sort((t,s)=>t[0]<s[0]?-1:1);var q=ze(le()),it=Object.defineProperty,nt=(e,t)=>{for(var s in t)it(e,s,{get:t[s],enumerable:!0});},rt={};nt(rt,{deleteItem:()=>ut,getItem:()=>F,setItem:()=>$});var O=()=>typeof window>"u",de=()=>!O(),ot="__IMX-",V=()=>de()&&window.localStorage,at=e=>{if(e!==null)try{return JSON.parse(e)}catch{return e}},lt=e=>typeof e=="string"?e:JSON.stringify(e),G=e=>`${ot}${e}`;function F(e){if(V())return at(window.localStorage.getItem(G(e)))}var $=(e,t)=>V()?(window.localStorage.setItem(G(e),lt(t)),!0):!1,ut=e=>V()?(window.localStorage.removeItem(G(e)),!0):!1,j=0,dt=e=>{let t=parseInt(e,10)*1e3,s=new Date(t),i=new Date;return j=s.getTime()-i.getTime(),j},ct=()=>{let e=new Date().getTime()+j;return new Date(e).toISOString()},ht=(e=>(e.RUNTIME_ID="rid",e.PASSPORT_CLIENT_ID="passportClientId",e.ENVIRONMENT="env",e.PUBLISHABLE_API_KEY="pak",e.IDENTITY="uid",e.DOMAIN="domain",e.SDK_VERSION="sdkVersion",e))(ht||{}),ft="https://api.immutable.com",pt=e=>{if(typeof Buffer<"u")return Buffer.from(e,"utf-8").toString("base64");if(typeof btoa=="function")return btoa(unescape(encodeURIComponent(e)));throw new Error("Base64 encoding not supported in this environment")};async function ce(e,t){let s=JSON.stringify(t),i={payload:pt(s)},n=await fetch(`${ft}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok){let r=await n.text().catch(()=>"");throw new Error(`Request failed (${n.status}): ${r||n.statusText}`)}return n.json()}var g,y,mt=()=>{g=F("metrics-events")||[],y=F("metrics-runtime")||{};};mt();var v=(e,t)=>{y={...y,[e]:t},$("metrics-runtime",y);},B=e=>{if(y[e]!==void 0)return y[e]},gt=()=>y,yt=()=>g,vt=e=>{g.push(e),$("metrics-events",g);},wt=e=>{g=g.slice(e),$("metrics-events",g);},he=e=>{let t=[];return Object.entries(e).forEach(([s,i])=>{(typeof s=="string"||typeof i=="string"||typeof i=="number"||typeof i=="boolean")&&t.push([s,i.toString()]);}),t},P="2.15.1-alpha.1",bt=()=>O()?"":window.location.ancestorOrigins&&window.location.ancestorOrigins.length>0?new URL(window.location.ancestorOrigins[0]).hostname:document.referrer?new URL(window.document.referrer).hostname:"",It=()=>{if(O())return "";let e;try{window.self!==window.top&&(e=bt());}catch{}return e||(e=window.location.hostname),e},St=()=>{if(v("sdkVersion",P),O())return {browser:"nodejs",sdkVersion:P};let e=It();return e&&v("domain",e),{sdkVersion:P,browser:window.navigator.userAgent,domain:e,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,screen:`${window.screen.width}x${window.screen.height}`}},K=!1,Et=()=>K,xt=async()=>{K=!0;try{let e=he(St()),t=B("rid"),s=B("uid"),i=await ce("/v1/sdk/initialise",{version:1,data:{runtimeDetails:e,runtimeId:t,uId:s}}),{runtimeId:n,sTime:r}=i;v("rid",n),dt(r);}catch{K=!1;}};function c(e,t){return (...s)=>{try{let i=e(...s);return i instanceof Promise?i.catch(()=>t):i}catch{return t}}}function _t(){return de()||typeof process>"u"?!1:process.env.JEST_WORKER_ID!==void 0}var Tt=c(_t,!1),fe="imtbl__metrics",kt=5e3,Nt=1e3,_=(e,t)=>(0, q.getGlobalisedValue)(fe,e,t),Ot=(e,t)=>{let s=ne(t,{lruOptions:{ttl:kt,max:Nt}});return (0, q.getGlobalisedValue)(fe,e,s)},$t=5e3,At=(e,t,s)=>{let i={event:`${e}.${t}`,time:ct(),...s&&{properties:he(s)}};vt(i);},b=c(Ot("track",At)),Dt=async()=>{if(Et()===!1){await xt();return}let e=yt();if(e.length===0)return;let t=e.length,s=gt();await ce("/v1/sdk/metrics",{version:1,data:{events:e,details:s}})instanceof Error||wt(t);},Ct=c(Dt),pe=async()=>{await Ct(),setTimeout(pe,$t);},ue=!1,Lt=()=>{ue||(ue=!0,pe());};Tt()||c(_("startFlushing",Lt))();var Bt=(e,t,s,i)=>{let{message:n}=s,r=s.stack||"",{cause:o}=s;o instanceof Error&&(r=`${r}
|
|
2
2
|
Cause: ${o.message}
|
|
3
|
-
${o.stack}`),b(e,`trackError_${t}`,{...i||{},errorMessage:n,errorStack:r,isTrackError:!0});},me=c(Bt),Vt=e=>{v("env",e);};c(_("setEnvironment",Vt));var Gt=e=>{v("passportClientId",e);};c(_("setPassportClientId",Gt));var Ht=e=>{v("pak",e);};c(_("setPublishableApiKey",Ht));c(_("getDetail",B));var zt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Jt={dev:"https://api.dev.immutable.com",sandbox:"https://api.sandbox.immutable.com",production:"https://api.immutable.com"},we="/v1/audience/messages",Yt="/v1/audience/tracking-consent",be=5e3,Ie=20,S="imtbl_anon_id",I="_imtbl_sid",Wt=365*24*60*60*2,ge=30*60,Se="session_start",Ee="session_end",Y=e=>Jt[e],T=()=>typeof window<"u"&&typeof document<"u",E=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return (e==="x"?t:t%4+8).toString(16)}),xe=()=>new Date().toISOString();function D(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function A(e,t,s,i){if(!T())return;let n=window.location.protocol==="https:"?"; Secure":"",r=i?`; domain=${i}`:"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${s}; SameSite=Lax${r}${n}`;}function k(e,t){A(e,"",0,t);}function C(e){let t=D(S);if(t)return t;let s=E();return A(S,s,Wt,e),s}var H=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},z=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function _e(e,t,s){if(e.status===0)return new z({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,n=i?.rejected??0,r=i?.accepted??0;return new z({code:"VALIDATION_REJECTED",message:`Backend rejected ${n} of ${n+r} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new z({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Te(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var W=async(e,t,s,i)=>{try{let n=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!n.ok){let o=await ye(n);return b("audience","transport_send_failed",{status:n.status}),{ok:!1,error:new H({status:n.status,endpoint:e,body:o})}}let r=await ye(n);if(typeof r=="object"&&r!==null&&"rejected"in r){let o=r.rejected??0;if(o>0)return b("audience","transport_partial_rejected",{status:n.status,rejected:o}),{ok:!1,error:new H({status:n.status,endpoint:e,body:r})}}return {ok:!0}}catch(n){let r=new H({status:0,endpoint:e,cause:n});return me("audience","transport_send",r),{ok:!1,error:r}}},X="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Xt(e,t=X){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Zt(e,t,s=X){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Qt(e,t=X){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var J="queue",ve=100,ke=class{constructor(e,t,s,i,n,r){this.send=e,this.endpointUrl=t,this.publishableKey=s,this.flushIntervalMs=i,this.flushSize=n,this.onFlush=r?.onFlush,this.onError=r?.onError,this.storagePrefix=r?.storagePrefix;let o=Xt(J,this.storagePrefix)??[];this.messages=r?.staleFilter?o.filter(r.staleFilter):o;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=_e(s.error,"flush",e.length));let n=i?.code==="VALIDATION_REJECTED";(s.ok||n)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&Te(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Qt(J,this.storagePrefix);}registerUnload(){!T()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}persist(){Zt(J,this.messages,this.storagePrefix);}},es="2.15.0";function Ne(e="@imtbl/audience",t=es){let s={library:e,libraryVersion:t};return T()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Oe(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function $e(e,t,s,i){return e!==s||t!==i}function N(e,t=256){return e.length>t?e.slice(0,t):e}function x(e){let t=D(I);if(t)return A(I,t,ge,e),{sessionId:t,isNew:!1};let s=E();return A(I,s,ge,e),{sessionId:s,isNew:!0}}var Ae=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],De=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Ce="__imtbl_attribution";function ts(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let n of [...Ae,...De]){let r=t.get(n);r&&(s[n]=r);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function ss(){try{let e=sessionStorage.getItem(Ce);return e?JSON.parse(e):null}catch{return null}}function is(e){try{sessionStorage.setItem(Ce,JSON.stringify(e));}catch{}}function Le(){let e=ss();if(e)return e;let t=typeof window<"u"&&window.location?ts(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,n=De.some(a=>a in t),r=Ae.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:n||r?"click":void 0};return is(o),o}function Ue(e,t,s,i,n,r,o,a){let d=o??"none",h={none:0,anonymous:1,full:2};function f(u){let l=`${Y(n)}${Yt}`;t(l,s,{anonymousId:i,status:u,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Te(a,_e(p.error,"consent"));});}return {get level(){return d},setLevel(u){u!==d&&(h[u]<h[d]&&(u==="none"?e.purge(()=>!0):u==="anonymous"&&(e.purge(l=>l.type==="identify"||l.type==="alias"),e.transform(l=>{if("userId"in l){let{userId:p,...U}=l;return U}return l}))),d=u,f(u));}}}var Re="@imtbl/audience",Me="2.15.0",m="[audience]",Pe="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${m} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${m} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${m} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${m} ${t}`);}};var Q=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,environment:i,publishableKey:n}=t,r=t.consent??"none",o=Pe,a=t.flushInterval??be,d=t.flushSize??Ie;this.cookieDomain=s,this.debug=new L(t.debug??!1);let h=!1;r!=="none"?(this.anonymousId=C(s),h=this.startSession()):this.anonymousId=D(S)??E();let f=`${Y(i)}${we}`;this.queue=new ke(W,f,n,a,d,{onFlush:(u,l)=>this.debug.logFlush(u,l),staleFilter:u=>Oe(u.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Ue(this.queue,W,n,this.anonymousId,i,o,r),this.attribution=Le(),this.isTrackingDisabled()||(this.queue.start(),h&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${m} publishableKey is required`);return e.liveInstances>0&&console.warn(`${m} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return this.consent.level==="none"}effectiveUserId(){return this.consent.level==="full"?this.userId:void 0}startSession(){let t=x(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:E(),eventTimestamp:xe(),anonymousId:this.anonymousId,surface:"web",context:Ne(Re,Me)}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Se,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ee,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;x(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,s){this.isTrackingDisabled()||(x(this.cookieDomain),this.enqueue("track",{...this.baseMessage(),type:"track",eventName:N(t),properties:s,userId:this.effectiveUserId()}));}identify(t,s,i){if(this.consent.level!=="full"){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(x(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let n=N(t);this.userId=n,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:n,identityType:s,traits:i});}alias(t,s){if(this.consent.level!=="full"){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!$e(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}x(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:N(t.id),fromType:t.identityType,toId:N(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=s==="none"&&t!=="none";if(i&&(this.anonymousId=C(this.cookieDomain)),t==="none"&&this.queue.stop(),this.consent.setLevel(t),t==="none"?(k(S,this.cookieDomain),k(I,this.cookieDomain)):t==="anonymous"&&s==="full"&&(this.userId=void 0),i){this.isFirstPage=!0;let n=this.startSession();this.queue.start(),n&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),k(S,this.cookieDomain),k(I,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=E(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=C(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};/*! Bundled license information:
|
|
3
|
+
${o.stack}`),b(e,`trackError_${t}`,{...i||{},errorMessage:n,errorStack:r,isTrackError:!0});},me=c(Bt),Vt=e=>{v("env",e);};c(_("setEnvironment",Vt));var Gt=e=>{v("passportClientId",e);};c(_("setPassportClientId",Gt));var Ht=e=>{v("pak",e);};c(_("setPublishableApiKey",Ht));c(_("getDetail",B));var zt={Passport:"passport",Steam:"steam",Epic:"epic",Google:"google",Apple:"apple",Discord:"discord",Email:"email",Custom:"custom"},Jt={dev:"https://api.dev.immutable.com",sandbox:"https://api.sandbox.immutable.com",production:"https://api.immutable.com"},we="/v1/audience/messages",Yt="/v1/audience/tracking-consent",be=5e3,Ie=20,S="imtbl_anon_id",I="_imtbl_sid",Wt=365*24*60*60*2,ge=30*60,Se="session_start",Ee="session_end",Y=e=>Jt[e],T=()=>typeof window<"u"&&typeof document<"u",E=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return (e==="x"?t:t%4+8).toString(16)}),xe=()=>new Date().toISOString();function D(e){if(!T())return;let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0}function A(e,t,s,i){if(!T())return;let n=window.location.protocol==="https:"?"; Secure":"",r=i?`; domain=${i}`:"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${s}; SameSite=Lax${r}${n}`;}function k(e,t){A(e,"",0,t);}function C(e){let t=D(S);if(t)return t;let s=E();return A(S,s,Wt,e),s}var H=class extends Error{status;endpoint;body;constructor(e){super(`audience transport failed: ${e.status||"network error"} ${e.endpoint}`,e.cause!==void 0?{cause:e.cause}:void 0),this.name="TransportError",this.status=e.status,this.endpoint=e.endpoint,this.body=e.body;}},z=class extends Error{code;status;endpoint;responseBody;cause;constructor(e){super(e.message),this.name="AudienceError",this.code=e.code,this.status=e.status,this.endpoint=e.endpoint,this.responseBody=e.responseBody,this.cause=e.cause;}};function _e(e,t,s){if(e.status===0)return new z({code:"NETWORK_ERROR",message:t==="flush"?`Network error sending ${s??0} messages`:"Network error syncing consent",status:0,endpoint:e.endpoint,cause:e.cause});if(e.status>=200&&e.status<300){let i=e.body,n=i?.rejected??0,r=i?.accepted??0;return new z({code:"VALIDATION_REJECTED",message:`Backend rejected ${n} of ${n+r} messages`,status:e.status,endpoint:e.endpoint,responseBody:e.body})}return new z({code:t==="flush"?"FLUSH_FAILED":"CONSENT_SYNC_FAILED",message:t==="flush"?`Flush failed with status ${e.status}`:`Consent sync failed with status ${e.status}`,status:e.status,endpoint:e.endpoint,responseBody:e.body,cause:e.cause})}function Te(e,t){if(e)try{e(t);}catch{}}async function ye(e){let t=e.headers?.get?.("content-type")??"";try{return t.includes("application/json")?await e.json():await e.text()}catch{return}}var W=async(e,t,s,i)=>{try{let n=await fetch(e,{method:i?.method??"POST",headers:{"Content-Type":"application/json","x-immutable-publishable-key":t},body:JSON.stringify(s),keepalive:i?.keepalive});if(!n.ok){let o=await ye(n);return b("audience","transport_send_failed",{status:n.status}),{ok:!1,error:new H({status:n.status,endpoint:e,body:o})}}let r=await ye(n);if(typeof r=="object"&&r!==null&&"rejected"in r){let o=r.rejected??0;if(o>0)return b("audience","transport_partial_rejected",{status:n.status,rejected:o}),{ok:!1,error:new H({status:n.status,endpoint:e,body:r})}}return {ok:!0}}catch(n){let r=new H({status:0,endpoint:e,cause:n});return me("audience","transport_send",r),{ok:!1,error:r}}},X="__imtbl_audience_";function Z(){try{return T()&&typeof localStorage<"u"}catch{return !1}}function Xt(e,t=X){if(Z())try{let s=localStorage.getItem(`${t}${e}`);return s?JSON.parse(s):void 0}catch{return}}function Zt(e,t,s=X){if(Z())try{localStorage.setItem(`${s}${e}`,JSON.stringify(t));}catch{}}function Qt(e,t=X){if(Z())try{localStorage.removeItem(`${t}${e}`);}catch{}}var J="queue",ve=100,ke=class{constructor(e,t,s,i,n,r){this.send=e,this.endpointUrl=t,this.publishableKey=s,this.flushIntervalMs=i,this.flushSize=n,this.onFlush=r?.onFlush,this.onError=r?.onError,this.storagePrefix=r?.storagePrefix;let o=Xt(J,this.storagePrefix)??[];this.messages=r?.staleFilter?o.filter(r.staleFilter):o;}messages;timer=null;flushing=!1;unloadBound=!1;visibilityHandler;pagehideHandler;onFlush;onError;storagePrefix;start(){this.timer||(this.timer=setInterval(()=>this.flush(),this.flushIntervalMs),this.registerUnload());}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.removeUnload();}destroy(){this.stop(),this.flushUnload();}enqueue(e){this.messages.push(e),this.persist(),this.messages.length>=this.flushSize&&this.flush();}async flush(){if(!(this.flushing||this.messages.length===0)){this.flushing=!0;try{let e=this.messages.slice(0,ve),t={messages:e},s=await this.send(this.endpointUrl,this.publishableKey,t),i;!s.ok&&s.error&&(i=_e(s.error,"flush",e.length));let n=i?.code==="VALIDATION_REJECTED";(s.ok||n)&&(this.messages=this.messages.slice(e.length),this.persist()),this.onFlush?.(s.ok,e.length),i&&Te(this.onError,i);}finally{this.flushing=!1;}}}flushUnload(){if(this.flushing||this.messages.length===0)return;let e=this.messages.slice(0,ve),t={messages:e};this.send(this.endpointUrl,this.publishableKey,t,{keepalive:!0}),this.messages=this.messages.slice(e.length),this.persist();}purge(e){this.messages=this.messages.filter(t=>!e(t)),this.persist();}transform(e){this.messages=this.messages.map(e),this.persist();}get length(){return this.messages.length}clear(){this.messages=[],Qt(J,this.storagePrefix);}registerUnload(){!T()||this.unloadBound||(this.unloadBound=!0,this.pagehideHandler=()=>this.flushUnload(),this.visibilityHandler=()=>{document.visibilityState==="hidden"&&this.flushUnload();},document.addEventListener("visibilitychange",this.visibilityHandler),window.addEventListener("pagehide",this.pagehideHandler));}removeUnload(){this.unloadBound&&(this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.pagehideHandler&&window.removeEventListener("pagehide",this.pagehideHandler),this.unloadBound=!1);}persist(){Zt(J,this.messages,this.storagePrefix);}},es="2.15.1-alpha.1";function Ne(e="@imtbl/audience",t=es){let s={library:e,libraryVersion:t};return T()&&(s.userAgent=navigator.userAgent,s.locale=navigator.language,s.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,s.screen=`${window.screen.width}x${window.screen.height}`,s.pageUrl=window.location.href,s.pagePath=window.location.pathname,s.pageReferrer=document.referrer,s.pageTitle=document.title),s}function Oe(e){let t=new Date(e).getTime();if(Number.isNaN(t))return !1;let s=Date.now();return t<=s+864e5&&t>=s-2592e6}function $e(e,t,s,i){return e!==s||t!==i}function N(e,t=256){return e.length>t?e.slice(0,t):e}function x(e){let t=D(I);if(t)return A(I,t,ge,e),{sessionId:t,isNew:!1};let s=E();return A(I,s,ge,e),{sessionId:s,isNew:!0}}var Ae=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"],De=["gclid","dclid","fbclid","ttclid","msclkid","li_fat_id"],Ce="__imtbl_attribution";function ts(e){let t;try{t=new URL(e).searchParams;}catch{return {}}let s={};for(let n of [...Ae,...De]){let r=t.get(n);r&&(s[n]=r);}let i=t.get("referral_code");return i&&(s.referral_code=i),s}function ss(){try{let e=sessionStorage.getItem(Ce);return e?JSON.parse(e):null}catch{return null}}function is(e){try{sessionStorage.setItem(Ce,JSON.stringify(e));}catch{}}function Le(){let e=ss();if(e)return e;let t=typeof window<"u"&&window.location?ts(window.location.href):{},s=typeof document<"u"&&document.referrer||void 0,i=typeof window<"u"&&window.location?window.location.href:void 0,n=De.some(a=>a in t),r=Ae.some(a=>a in t),o={...t,referrer:s,landing_page:i,touchpoint_type:n||r?"click":void 0};return is(o),o}function Ue(e,t,s,i,n,r,o,a){let d=o??"none",h={none:0,anonymous:1,full:2};function f(u){let l=`${Y(n)}${Yt}`;t(l,s,{anonymousId:i,status:u,source:r},{method:"PUT",keepalive:!0}).then(p=>{!p.ok&&p.error&&Te(a,_e(p.error,"consent"));});}return {get level(){return d},setLevel(u){u!==d&&(h[u]<h[d]&&(u==="none"?e.purge(()=>!0):u==="anonymous"&&(e.purge(l=>l.type==="identify"||l.type==="alias"),e.transform(l=>{if("userId"in l){let{userId:p,...U}=l;return U}return l}))),d=u,f(u));}}}var Re="@imtbl/audience",Me="2.15.1-alpha.1",m="[audience]",Pe="WebSDK";var L=class{enabled;constructor(t=!1){this.enabled=t;}logEvent(t,s){this.enabled&&console.log(`${m} ${t}`,s);}logFlush(t,s){this.enabled&&console.log(`${m} flush ${t?"ok":"failed"} (${s} messages)`);}logConsent(t,s){this.enabled&&console.log(`${m} consent ${t} \u2192 ${s}`);}logWarning(t){this.enabled&&console.warn(`${m} ${t}`);}};var Q=class e{static liveInstances=0;queue;consent;attribution;debug;cookieDomain;anonymousId;sessionId;sessionStartTime;userId;isFirstPage=!0;destroyed=!1;constructor(t){let{cookieDomain:s,environment:i,publishableKey:n}=t,r=t.consent??"none",o=Pe,a=t.flushInterval??be,d=t.flushSize??Ie;this.cookieDomain=s,this.debug=new L(t.debug??!1);let h=!1;r!=="none"?(this.anonymousId=C(s),h=this.startSession()):this.anonymousId=D(S)??E();let f=`${Y(i)}${we}`;this.queue=new ke(W,f,n,a,d,{onFlush:(u,l)=>this.debug.logFlush(u,l),staleFilter:u=>Oe(u.eventTimestamp),storagePrefix:"__imtbl_web_"}),this.consent=Ue(this.queue,W,n,this.anonymousId,i,o,r),this.attribution=Le(),this.isTrackingDisabled()||(this.queue.start(),h&&this.trackSessionStart());}static init(t){if(!t.publishableKey?.trim())throw new Error(`${m} publishableKey is required`);return e.liveInstances>0&&console.warn(`${m} Multiple SDK instances detected. Ensure previous instances are shut down to avoid duplicate events.`),e.liveInstances+=1,new e(t)}isTrackingDisabled(){return this.consent.level==="none"}effectiveUserId(){return this.consent.level==="full"?this.userId:void 0}startSession(){let t=x(this.cookieDomain);return this.sessionId=t.sessionId,this.sessionStartTime=Date.now(),t.isNew}baseMessage(){return {messageId:E(),eventTimestamp:xe(),anonymousId:this.anonymousId,surface:"web",context:Ne(Re,Me)}}enqueue(t,s){this.queue.enqueue(s),this.debug.logEvent(t,s);}trackSessionStart(){this.sessionId&&this.enqueue("track(session_start)",{...this.baseMessage(),type:"track",eventName:Se,properties:{sessionId:this.sessionId,...this.attribution}});}trackSessionEnd(){this.sessionId&&this.enqueue("track(session_end)",{...this.baseMessage(),type:"track",eventName:Ee,properties:{sessionId:this.sessionId,...this.sessionStartTime&&{duration:Math.round((Date.now()-this.sessionStartTime)/1e3)}}});}page(t){if(this.isTrackingDisabled())return;x(this.cookieDomain);let s={...t};this.isFirstPage&&(Object.assign(s,this.attribution),this.isFirstPage=!1),this.enqueue("page",{...this.baseMessage(),type:"page",properties:Object.keys(s).length>0?s:void 0,userId:this.effectiveUserId()});}track(t,s){this.isTrackingDisabled()||(x(this.cookieDomain),this.enqueue("track",{...this.baseMessage(),type:"track",eventName:N(t),properties:s,userId:this.effectiveUserId()}));}identify(t,s,i){if(this.consent.level!=="full"){this.debug.logWarning("identify() requires full consent \u2014 call ignored.");return}if(x(this.cookieDomain),t!==null&&typeof t=="object"&&!Array.isArray(t)){this.enqueue("identify",{...this.baseMessage(),type:"identify",traits:t});return}if(typeof t!="string")return;let n=N(t);this.userId=n,this.enqueue("identify",{...this.baseMessage(),type:"identify",userId:n,identityType:s,traits:i});}alias(t,s){if(this.consent.level!=="full"){this.debug.logWarning("alias() requires full consent \u2014 call ignored.");return}if(!$e(t.id,t.identityType,s.id,s.identityType)){this.debug.logWarning("alias() from and to are identical \u2014 call ignored.");return}x(this.cookieDomain),this.enqueue("alias",{...this.baseMessage(),type:"alias",fromId:N(t.id),fromType:t.identityType,toId:N(s.id),toType:s.identityType});}setConsent(t){let s=this.consent.level;if(t===s)return;this.debug.logConsent(s,t);let i=s==="none"&&t!=="none";if(i&&(this.anonymousId=C(this.cookieDomain)),t==="none"&&this.queue.stop(),this.consent.setLevel(t),t==="none"?(k(S,this.cookieDomain),k(I,this.cookieDomain)):t==="anonymous"&&s==="full"&&(this.userId=void 0),i){this.isFirstPage=!0;let n=this.startSession();this.queue.start(),n&&this.trackSessionStart();}}reset(){this.userId=void 0,this.queue.clear(),k(S,this.cookieDomain),k(I,this.cookieDomain),this.isTrackingDisabled()?(this.anonymousId=E(),this.sessionId=void 0,this.sessionStartTime=void 0):(this.anonymousId=C(this.cookieDomain),this.startSession()&&this.trackSessionStart()),this.isFirstPage=!0;}async flush(){await this.queue.flush();}shutdown(){this.destroyed||(this.destroyed=!0,this.isTrackingDisabled()||this.trackSessionEnd(),this.queue.destroy(),e.liveInstances=Math.max(0,e.liveInstances-1));}};/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
tiny-lru/dist/tiny-lru.js:
|
|
6
6
|
(**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/audience",
|
|
3
3
|
"description": "Immutable Audience — consent-aware event tracking and identity management",
|
|
4
|
-
"version": "2.15.
|
|
4
|
+
"version": "2.15.1-alpha.1",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
7
7
|
"devDependencies": {
|