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