@novu/js 2.6.4 → 2.6.6

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/novu.min.js CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";(()=>{var uo=Object.create;var Qt=Object.defineProperty,po=Object.defineProperties,mo=Object.getOwnPropertyDescriptor,go=Object.getOwnPropertyDescriptors,yo=Object.getOwnPropertyNames,Jt=Object.getOwnPropertySymbols,vo=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty,$i=Object.prototype.propertyIsEnumerable;var Hi=r=>{throw TypeError(r)};var Vi=(r,e,t)=>e in r?Qt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,E=(r,e)=>{for(var t in e||(e={}))Wr.call(e,t)&&Vi(r,t,e[t]);if(Jt)for(var t of Jt(e))$i.call(e,t)&&Vi(r,t,e[t]);return r},O=(r,e)=>po(r,go(e));var w=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var ji=(r,e)=>{var t={};for(var i in r)Wr.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Jt)for(var i of Jt(r))e.indexOf(i)<0&&$i.call(r,i)&&(t[i]=r[i]);return t};var k=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_o=(r,e)=>{for(var t in e)Qt(r,t,{get:e[t],enumerable:!0})},Eo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of yo(e))!Wr.call(r,s)&&s!==t&&Qt(r,s,{get:()=>e[s],enumerable:!(i=mo(e,s))||i.enumerable});return r};var K=(r,e,t)=>(t=r!=null?uo(vo(r)):{},Eo(e||!r||!r.__esModule?Qt(t,"default",{value:r,enumerable:!0}):t,r));var Vr=(r,e,t)=>e.has(r)||Hi("Cannot "+t);var l=(r,e,t)=>(Vr(r,e,"read from private field"),t?t.call(r):e.get(r)),_=(r,e,t)=>e.has(r)?Hi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),b=(r,e,t,i)=>(Vr(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),$r=(r,e,t)=>(Vr(r,e,"access private method"),t);var g=(r,e,t)=>new Promise((i,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},o=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(n,o);a((t=t.apply(r,e)).next())});var Jr=k((gf,cs)=>{"use strict";var tt=1e3,rt=tt*60,it=rt*60,De=it*24,Io=De*7,Po=De*365.25;cs.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Lo(r);if(t==="number"&&isFinite(r))return e.long?Bo(r):Fo(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Lo(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return t*Po;case"weeks":case"week":case"w":return t*Io;case"days":case"day":case"d":return t*De;case"hours":case"hour":case"hrs":case"hr":case"h":return t*it;case"minutes":case"minute":case"mins":case"min":case"m":return t*rt;case"seconds":case"second":case"secs":case"sec":case"s":return t*tt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Fo(r){var e=Math.abs(r);return e>=De?Math.round(r/De)+"d":e>=it?Math.round(r/it)+"h":e>=rt?Math.round(r/rt)+"m":e>=tt?Math.round(r/tt)+"s":r+"ms"}function Bo(r){var e=Math.abs(r);return e>=De?hr(r,e,De,"day"):e>=it?hr(r,e,it,"hour"):e>=rt?hr(r,e,rt,"minute"):e>=tt?hr(r,e,tt,"second"):r+" ms"}function hr(r,e,t,i){var s=e>=t*1.5;return Math.round(r/t)+" "+i+(s?"s":"")}});var Qr=k((yf,ls)=>{"use strict";function Uo(r){t.debug=t,t.default=t,t.coerce=c,t.disable=n,t.enable=s,t.enabled=o,t.humanize=Jr(),t.destroy=u,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let h=0;for(let d=0;d<f.length;d++)h=(h<<5)-h+f.charCodeAt(d),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(f){let h,d=null,C,S;function p(...v){if(!p.enabled)return;let N=p,A=Number(new Date),m=A-(h||A);N.diff=m,N.prev=h,N.curr=A,h=A,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let y=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(R,H)=>{if(R==="%%")return"%";y++;let z=t.formatters[H];if(typeof z=="function"){let pe=v[y];R=z.call(N,pe),v.splice(y,1),y--}return R}),t.formatArgs.call(N,v),(N.log||t.log).apply(N,v)}return p.namespace=f,p.useColors=t.useColors(),p.color=t.selectColor(f),p.extend=i,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(C!==t.namespaces&&(C=t.namespaces,S=t.enabled(f)),S),set:v=>{d=v}}),typeof t.init=="function"&&t.init(p),p}function i(f,h){let d=t(this.namespace+(typeof h=="undefined"?":":h)+f);return d.log=this.log,d}function s(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let h,d=(typeof f=="string"?f:"").split(/[\s,]+/),C=d.length;for(h=0;h<C;h++)d[h]&&(f=d[h].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function n(){let f=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),f}function o(f){if(f[f.length-1]==="*")return!0;let h,d;for(h=0,d=t.skips.length;h<d;h++)if(t.skips[h].test(f))return!1;for(h=0,d=t.names.length;h<d;h++)if(t.names[h].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}ls.exports=Uo});var fs=k((Q,ur)=>{"use strict";Q.formatArgs=Mo;Q.save=qo;Q.load=Wo;Q.useColors=Do;Q.storage=Vo();Q.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Q.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Do(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Mo(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+ur.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,i=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(t++,s==="%c"&&(i=t))}),r.splice(i,0,e)}Q.log=console.debug||console.log||(()=>{});function qo(r){try{r?Q.storage.setItem("debug",r):Q.storage.removeItem("debug")}catch(e){}}function Wo(){let r;try{r=Q.storage.getItem("debug")}catch(e){}return!r&&typeof process!="undefined"&&"env"in process&&(r=process.env.DEBUG),r}function Vo(){try{return localStorage}catch(r){}}ur.exports=Qr()(Q);var{formatters:$o}=ur.exports;$o.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Zr=k((vf,hs)=>{"use strict";hs.exports=(r,e=process.argv)=>{let t=r.startsWith("-")?"":r.length===1?"-":"--",i=e.indexOf(t+r),s=e.indexOf("--");return i!==-1&&(s===-1||i<s)}});var ps=k((_f,ds)=>{"use strict";var Ho=w("os"),us=w("tty"),oe=Zr(),{env:M}=process,dr;oe("no-color")||oe("no-colors")||oe("color=false")||oe("color=never")?dr=0:(oe("color")||oe("colors")||oe("color=true")||oe("color=always"))&&(dr=1);function jo(){if("FORCE_COLOR"in M)return M.FORCE_COLOR==="true"?1:M.FORCE_COLOR==="false"?0:M.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(M.FORCE_COLOR,10),3)}function Go(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function zo(r,{streamIsTTY:e,sniffFlags:t=!0}={}){let i=jo();i!==void 0&&(dr=i);let s=t?dr:i;if(s===0)return 0;if(t){if(oe("color=16m")||oe("color=full")||oe("color=truecolor"))return 3;if(oe("color=256"))return 2}if(r&&!e&&s===void 0)return 0;let n=s||0;if(M.TERM==="dumb")return n;if(process.platform==="win32"){let o=Ho.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in M)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in M)||M.CI_NAME==="codeship"?1:n;if("TEAMCITY_VERSION"in M)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(M.TEAMCITY_VERSION)?1:0;if(M.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in M){let o=Number.parseInt((M.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(M.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(M.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(M.TERM)||"COLORTERM"in M?1:n}function ei(r,e={}){let t=zo(r,E({streamIsTTY:r&&r.isTTY},e));return Go(t)}ds.exports={supportsColor:ei,stdout:ei({isTTY:us.isatty(1)}),stderr:ei({isTTY:us.isatty(2)})}});var gs=k((q,mr)=>{"use strict";var Ko=w("tty"),pr=w("util");q.init=ta;q.log=Qo;q.formatArgs=Xo;q.save=Zo;q.load=ea;q.useColors=Yo;q.destroy=pr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");q.colors=[6,2,3,4,5,1];try{let r=ps();r&&(r.stderr||r).level>=2&&(q.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(r){}q.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,n)=>n.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),r[t]=i,r},{});function Yo(){return"colors"in q.inspectOpts?!!q.inspectOpts.colors:Ko.isatty(process.stderr.fd)}function Xo(r){let{namespace:e,useColors:t}=this;if(t){let i=this.color,s="\x1B[3"+(i<8?i:"8;5;"+i),n=` ${s};1m${e} \x1B[0m`;r[0]=n+r[0].split(`
1
+ "use strict";(()=>{var so=Object.create;var Xt=Object.defineProperty,no=Object.defineProperties,oo=Object.getOwnPropertyDescriptor,ao=Object.getOwnPropertyDescriptors,co=Object.getOwnPropertyNames,Yt=Object.getOwnPropertySymbols,lo=Object.getPrototypeOf,Di=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable;var qr=i=>{throw TypeError(i)};var Dr=(i,e,t)=>e in i?Xt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,b=(i,e)=>{for(var t in e||(e={}))Di.call(e,t)&&Dr(i,t,e[t]);if(Yt)for(var t of Yt(e))Mr.call(e,t)&&Dr(i,t,e[t]);return i},O=(i,e)=>no(i,ao(e));var w=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Wr=(i,e)=>{var t={};for(var r in i)Di.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&Yt)for(var r of Yt(i))e.indexOf(r)<0&&Mr.call(i,r)&&(t[r]=i[r]);return t};var T=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),fo=(i,e)=>{for(var t in e)Xt(i,t,{get:e[t],enumerable:!0})},ho=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of co(e))!Di.call(i,s)&&s!==t&&Xt(i,s,{get:()=>e[s],enumerable:!(r=oo(e,s))||r.enumerable});return i};var z=(i,e,t)=>(t=i!=null?so(lo(i)):{},ho(e||!i||!i.__esModule?Xt(t,"default",{value:i,enumerable:!0}):t,i));var Mi=(i,e,t)=>e.has(i)||qr("Cannot "+t);var l=(i,e,t)=>(Mi(i,e,"read from private field"),t?t.call(i):e.get(i)),_=(i,e,t)=>e.has(i)?qr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),E=(i,e,t,r)=>(Mi(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),qi=(i,e,t)=>(Mi(i,e,"access private method"),t);var g=(i,e,t)=>new Promise((r,s)=>{var n=c=>{try{a(t.next(c))}catch(u){s(u)}},o=c=>{try{a(t.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,o);a((t=t.apply(i,e)).next())});var Ki=T((sf,ss)=>{"use strict";var Ze=1e3,et=Ze*60,tt=et*60,Be=tt*24,So=Be*7,wo=Be*365.25;ss.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return No(i);if(t==="number"&&isFinite(i))return e.long?ko(i):Ao(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function No(i){if(i=String(i),!(i.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return t*wo;case"weeks":case"week":case"w":return t*So;case"days":case"day":case"d":return t*Be;case"hours":case"hour":case"hrs":case"hr":case"h":return t*tt;case"minutes":case"minute":case"mins":case"min":case"m":return t*et;case"seconds":case"second":case"secs":case"sec":case"s":return t*Ze;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Ao(i){var e=Math.abs(i);return e>=Be?Math.round(i/Be)+"d":e>=tt?Math.round(i/tt)+"h":e>=et?Math.round(i/et)+"m":e>=Ze?Math.round(i/Ze)+"s":i+"ms"}function ko(i){var e=Math.abs(i);return e>=Be?li(i,e,Be,"day"):e>=tt?li(i,e,tt,"hour"):e>=et?li(i,e,et,"minute"):e>=Ze?li(i,e,Ze,"second"):i+" ms"}function li(i,e,t,r){var s=e>=t*1.5;return Math.round(i/t)+" "+r+(s?"s":"")}});var Yi=T((nf,ns)=>{"use strict";function Ro(i){t.debug=t,t.default=t,t.coerce=c,t.disable=n,t.enable=s,t.enabled=o,t.humanize=Ki(),t.destroy=u,Object.keys(i).forEach(f=>{t[f]=i[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let h=0;for(let d=0;d<f.length;d++)h=(h<<5)-h+f.charCodeAt(d),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(f){let h,d=null,x,S;function p(...v){if(!p.enabled)return;let N=p,A=Number(new Date),m=A-(h||A);N.diff=m,N.prev=h,N.curr=A,h=A,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let y=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(k,V)=>{if(k==="%%")return"%";y++;let G=t.formatters[V];if(typeof G=="function"){let ue=v[y];k=G.call(N,ue),v.splice(y,1),y--}return k}),t.formatArgs.call(N,v),(N.log||t.log).apply(N,v)}return p.namespace=f,p.useColors=t.useColors(),p.color=t.selectColor(f),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(x!==t.namespaces&&(x=t.namespaces,S=t.enabled(f)),S),set:v=>{d=v}}),typeof t.init=="function"&&t.init(p),p}function r(f,h){let d=t(this.namespace+(typeof h=="undefined"?":":h)+f);return d.log=this.log,d}function s(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let h,d=(typeof f=="string"?f:"").split(/[\s,]+/),x=d.length;for(h=0;h<x;h++)d[h]&&(f=d[h].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function n(){let f=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),f}function o(f){if(f[f.length-1]==="*")return!0;let h,d;for(h=0,d=t.skips.length;h<d;h++)if(t.skips[h].test(f))return!1;for(h=0,d=t.names.length;h<d;h++)if(t.names[h].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}ns.exports=Ro});var os=T((J,fi)=>{"use strict";J.formatArgs=Oo;J.save=Io;J.load=Po;J.useColors=To;J.storage=Lo();J.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();J.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function To(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let i;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(i=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(i[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Oo(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+fi.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(t++,s==="%c"&&(r=t))}),i.splice(r,0,e)}J.log=console.debug||console.log||(()=>{});function Io(i){try{i?J.storage.setItem("debug",i):J.storage.removeItem("debug")}catch(e){}}function Po(){let i;try{i=J.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Lo(){try{return localStorage}catch(i){}}fi.exports=Yi()(J);var{formatters:Fo}=fi.exports;Fo.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var cs=T((of,as)=>{"use strict";as.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",r=e.indexOf(t+i),s=e.indexOf("--");return r!==-1&&(s===-1||r<s)}});var Qi=T((af,fs)=>{"use strict";var Bo=w("os"),ls=w("tty"),ne=cs(),{env:M}=process,Ae;ne("no-color")||ne("no-colors")||ne("color=false")||ne("color=never")?Ae=0:(ne("color")||ne("colors")||ne("color=true")||ne("color=always"))&&(Ae=1);"FORCE_COLOR"in M&&(M.FORCE_COLOR==="true"?Ae=1:M.FORCE_COLOR==="false"?Ae=0:Ae=M.FORCE_COLOR.length===0?1:Math.min(parseInt(M.FORCE_COLOR,10),3));function Xi(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function Ji(i,e){if(Ae===0)return 0;if(ne("color=16m")||ne("color=full")||ne("color=truecolor"))return 3;if(ne("color=256"))return 2;if(i&&!e&&Ae===void 0)return 0;let t=Ae||0;if(M.TERM==="dumb")return t;if(process.platform==="win32"){let r=Bo.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in M)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in M)||M.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in M)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(M.TEAMCITY_VERSION)?1:0;if(M.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in M){let r=parseInt((M.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(M.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(M.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(M.TERM)||"COLORTERM"in M?1:t}function Uo(i){let e=Ji(i,i&&i.isTTY);return Xi(e)}fs.exports={supportsColor:Uo,stdout:Xi(Ji(!0,ls.isatty(1))),stderr:Xi(Ji(!0,ls.isatty(2)))}});var us=T((q,ui)=>{"use strict";var Do=w("tty"),hi=w("util");q.init=Ho;q.log=$o;q.formatArgs=qo;q.save=Vo;q.load=jo;q.useColors=Mo;q.destroy=hi.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");q.colors=[6,2,3,4,5,1];try{let i=Qi();i&&(i.stderr||i).level>=2&&(q.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}q.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,n)=>n.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function Mo(){return"colors"in q.inspectOpts?!!q.inspectOpts.colors:Do.isatty(process.stderr.fd)}function qo(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,s="\x1B[3"+(r<8?r:"8;5;"+r),n=` ${s};1m${e} \x1B[0m`;i[0]=n+i[0].split(`
2
2
  `).join(`
3
- `+n),r.push(s+"m+"+mr.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Jo()+e+" "+r[0]}function Jo(){return q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Qo(...r){return process.stderr.write(pr.formatWithOptions(q.inspectOpts,...r)+`
4
- `)}function Zo(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function ea(){return process.env.DEBUG}function ta(r){r.inspectOpts={};let e=Object.keys(q.inspectOpts);for(let t=0;t<e.length;t++)r.inspectOpts[e[t]]=q.inspectOpts[e[t]]}mr.exports=Qr()(q);var{formatters:ms}=mr.exports;ms.o=function(r){return this.inspectOpts.colors=this.useColors,pr.inspect(r,this.inspectOpts).split(`
5
- `).map(e=>e.trim()).join(" ")};ms.O=function(r){return this.inspectOpts.colors=this.useColors,pr.inspect(r,this.inspectOpts)}});var Me=k((bf,ti)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?ti.exports=fs():ti.exports=gs()});var Ns=k((kf,ws)=>{"use strict";var st=w("fs"),Ss=w("url"),sa=w("child_process").spawn;ws.exports=si;si.XMLHttpRequest=si;function si(r){"use strict";r=r||{};var e=this,t=w("http"),i=w("https"),s,n,o={},a=!1,c={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},c),f=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],h=["TRACE","TRACK","CONNECT"],d=!1,C=!1,S=!1,p={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var v=function(m){return a||m&&f.indexOf(m.toLowerCase())===-1},N=function(m){return m&&h.indexOf(m)===-1};this.open=function(m,y,$,R,H){if(this.abort(),C=!1,S=!1,!N(m))throw new Error("SecurityError: Request method not allowed");o={method:m,url:y.toString(),async:typeof $!="boolean"?!0:$,user:R||null,password:H||null},A(this.OPENED)},this.setDisableHeaderCheck=function(m){a=m},this.setRequestHeader=function(m,y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!v(m))return console.warn('Refused to set unsafe header "'+m+'"'),!1;if(d)throw new Error("INVALID_STATE_ERR: send flag is true");return u[m]=y,!0},this.getResponseHeader=function(m){return typeof m=="string"&&this.readyState>this.OPENED&&n.headers[m.toLowerCase()]&&!C?n.headers[m.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||C)return"";var m="";for(var y in n.headers)y!=="set-cookie"&&y!=="set-cookie2"&&(m+=y+": "+n.headers[y]+`\r
6
- `);return m.substr(0,m.length-2)},this.getRequestHeader=function(m){return typeof m=="string"&&u[m]?u[m]:""},this.send=function(m){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(d)throw new Error("INVALID_STATE_ERR: send has already been called");var y=!1,$=!1,R=Ss.parse(o.url),H;switch(R.protocol){case"https:":y=!0;case"http:":H=R.hostname;break;case"file:":$=!0;break;case void 0:case"":H="localhost";break;default:throw new Error("Protocol not supported.")}if($){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)st.readFile(unescape(R.pathname),"utf8",function(ie,ze){ie?e.handleError(ie,ie.errno||-1):(e.status=200,e.responseText=ze,A(e.DONE))});else try{this.responseText=st.readFileSync(unescape(R.pathname),"utf8"),this.status=200,A(e.DONE)}catch(ie){this.handleError(ie,ie.errno||-1)}return}var z=R.port||(y?443:80),pe=R.pathname+(R.search?R.search:"");if(u.Host=H,y&&z===443||z===80||(u.Host+=":"+R.port),o.user){typeof o.password=="undefined"&&(o.password="");var Kt=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Kt.toString("base64")}o.method==="GET"||o.method==="HEAD"?m=null:m?(u["Content-Length"]=Buffer.isBuffer(m)?m.length:Buffer.byteLength(m),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var Yt=r.agent||!1,re={host:H,port:z,path:pe,method:o.method,headers:u,agent:Yt};if(y&&(re.pfx=r.pfx,re.key=r.key,re.passphrase=r.passphrase,re.cert=r.cert,re.ca=r.ca,re.ciphers=r.ciphers,re.rejectUnauthorized=r.rejectUnauthorized!==!1),C=!1,o.async){var Ge=y?i.request:t.request;d=!0,e.dispatchEvent("readystatechange");var qi=function(ie){if(n=ie,n.statusCode===302||n.statusCode===303||n.statusCode===307){o.url=n.headers.location;var ze=Ss.parse(o.url);H=ze.hostname;var xe={hostname:ze.hostname,port:ze.port,path:ze.path,method:n.statusCode===303?"GET":o.method,headers:u};y&&(xe.pfx=r.pfx,xe.key=r.key,xe.passphrase=r.passphrase,xe.cert=r.cert,xe.ca=r.ca,xe.ciphers=r.ciphers,xe.rejectUnauthorized=r.rejectUnauthorized!==!1),s=Ge(xe,qi).on("error",Wi),s.end();return}n&&n.setEncoding&&n.setEncoding("utf8"),A(e.HEADERS_RECEIVED),e.status=n.statusCode,n.on("data",function(Xt){Xt&&(e.responseText+=Xt),d&&A(e.LOADING)}),n.on("end",function(){d&&(d=!1,A(e.DONE))}),n.on("error",function(Xt){e.handleError(Xt)})},Wi=function(ie){e.handleError(ie)};s=Ge(re,qi).on("error",Wi),r.autoUnref&&s.on("socket",ie=>{ie.unref()}),m&&s.write(m),s.end(),e.dispatchEvent("loadstart")}else{var pt=".node-xmlhttprequest-content-"+process.pid,mt=".node-xmlhttprequest-sync-"+process.pid;st.writeFileSync(mt,"","utf8");for(var lo="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(y?"s":"")+".request;var options = "+JSON.stringify(re)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+pt+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+mt+"');});response.on('error', function(error) {fs.writeFileSync('"+pt+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+mt+"');});}).on('error', function(error) {fs.writeFileSync('"+pt+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+mt+"');});"+(m?"req.write('"+JSON.stringify(m).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",fo=sa(process.argv[0],["-e",lo]),tl;st.existsSync(mt););if(e.responseText=st.readFileSync(pt,"utf8"),fo.stdin.end(),st.unlinkSync(pt),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var ho=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(ho,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),A(e.DONE)}},this.handleError=function(m,y){this.status=y||0,this.statusText=m,this.responseText=m.stack,C=!0,A(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),u=Object.assign({},c),this.responseText="",this.responseXML="",C=S=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||d)&&this.readyState!==this.DONE&&(d=!1,A(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(m,y){m in p||(p[m]=[]),p[m].push(y)},this.removeEventListener=function(m,y){m in p&&(p[m]=p[m].filter(function($){return $!==y}))},this.dispatchEvent=function(m){if(typeof e["on"+m]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+m]()}):e["on"+m]()),m in p)for(let y=0,$=p[m].length;y<$;y++)this.readyState===this.DONE?setImmediate(function(){p[m][y].call(e)}):p[m][y].call(e)};var A=function(m){if(!(e.readyState===m||e.readyState===e.UNSENT&&S)&&(e.readyState=m,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let y;S?y="abort":C?y="error":y="load",e.dispatchEvent(y),e.dispatchEvent("loadend")}}}});var Ps=k((Mf,Is)=>{"use strict";var{Duplex:ca}=w("stream");function Ts(r){r.emit("close")}function la(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Os(r){this.removeListener("error",Os),this.destroy(),this.listenerCount("error")===0&&this.emit("error",r)}function fa(r,e){let t=!0,i=new ca(O(E({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return r.on("message",function(n,o){let a=!o&&i._readableState.objectMode?n.toString():n;i.push(a)||r.pause()}),r.once("error",function(n){i.destroyed||(t=!1,i.destroy(n))}),r.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(s,n){if(r.readyState===r.CLOSED){n(s),process.nextTick(Ts,i);return}let o=!1;r.once("error",function(c){o=!0,n(c)}),r.once("close",function(){o||n(s),process.nextTick(Ts,i)}),t&&r.terminate()},i._final=function(s){if(r.readyState===r.CONNECTING){r.once("open",function(){i._final(s)});return}r._socket!==null&&(r._socket._writableState.finished?(s(),i._readableState.endEmitted&&i.destroy()):(r._socket.once("finish",function(){s()}),r.close()))},i._read=function(){r.isPaused&&r.resume()},i._write=function(s,n,o){if(r.readyState===r.CONNECTING){r.once("open",function(){i._write(s,n,o)});return}r.send(s,o)},i.on("end",la),i.on("error",Os),i}Is.exports=fa});var Te=k((Wf,Ls)=>{"use strict";Ls.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var At=k((Vf,_r)=>{"use strict";var{EMPTY_BUFFER:ha}=Te();function ua(r,e){if(r.length===0)return ha;if(r.length===1)return r[0];let t=Buffer.allocUnsafe(e),i=0;for(let s=0;s<r.length;s++){let n=r[s];t.set(n,i),i+=n.length}return i<e?t.slice(0,i):t}function Fs(r,e,t,i,s){for(let n=0;n<s;n++)t[i+n]=r[n]^e[n&3]}function Bs(r,e){for(let t=0;t<r.length;t++)r[t]^=e[t&3]}function da(r){return r.byteLength===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}function ci(r){if(ci.readOnly=!0,Buffer.isBuffer(r))return r;let e;return r instanceof ArrayBuffer?e=Buffer.from(r):ArrayBuffer.isView(r)?e=Buffer.from(r.buffer,r.byteOffset,r.byteLength):(e=Buffer.from(r),ci.readOnly=!1),e}_r.exports={concat:ua,mask:Fs,toArrayBuffer:da,toBuffer:ci,unmask:Bs};if(!process.env.WS_NO_BUFFER_UTIL)try{let r=w("bufferutil");_r.exports.mask=function(e,t,i,s,n){n<48?Fs(e,t,i,s,n):r.mask(e,t,i,s,n)},_r.exports.unmask=function(e,t){e.length<32?Bs(e,t):r.unmask(e,t)}}catch(r){}});var Ms=k(($f,Ds)=>{"use strict";var Us=Symbol("kDone"),li=Symbol("kRun"),fi=class{constructor(e){this[Us]=()=>{this.pending--,this[li]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[li]()}[li](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Us])}}};Ds.exports=fi});var Tt=k((Hf,$s)=>{"use strict";var Rt=w("zlib"),qs=At(),pa=Ms(),{kStatusCode:Ws}=Te(),ma=Buffer.from([0,0,255,255]),Cr=Symbol("permessage-deflate"),Ee=Symbol("total-length"),kt=Symbol("callback"),Oe=Symbol("buffers"),br=Symbol("error"),Er,hi=class{constructor(e,t,i){if(this._maxPayload=i|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Er){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Er=new pa(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[kt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,i=e.find(s=>!(t.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>s.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(i.server_no_context_takeover=!0),t.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(i.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?i.client_max_window_bits=t.clientMaxWindowBits:(i.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(i=>{let s=t[i];if(s.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(s=s[0],i==="client_max_window_bits"){if(s!==!0){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${i}": ${s}`);s=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${s}`)}else if(i==="server_max_window_bits"){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${i}": ${s}`);s=n}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${s}`)}else throw new Error(`Unknown parameter "${i}"`);t[i]=s})}),e}decompress(e,t,i){Er.add(s=>{this._decompress(e,t,(n,o)=>{s(),i(n,o)})})}compress(e,t,i){Er.add(s=>{this._compress(e,t,(n,o)=>{s(),i(n,o)})})}_decompress(e,t,i){let s=this._isServer?"client":"server";if(!this._inflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Rt.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Rt.createInflateRaw(O(E({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Cr]=this,this._inflate[Ee]=0,this._inflate[Oe]=[],this._inflate.on("error",ya),this._inflate.on("data",Vs)}this._inflate[kt]=i,this._inflate.write(e),t&&this._inflate.write(ma),this._inflate.flush(()=>{let n=this._inflate[br];if(n){this._inflate.close(),this._inflate=null,i(n);return}let o=qs.concat(this._inflate[Oe],this._inflate[Ee]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ee]=0,this._inflate[Oe]=[],t&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),i(null,o)})}_compress(e,t,i){let s=this._isServer?"server":"client";if(!this._deflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Rt.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Rt.createDeflateRaw(O(E({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Ee]=0,this._deflate[Oe]=[],this._deflate.on("data",ga)}this._deflate[kt]=i,this._deflate.write(e),this._deflate.flush(Rt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=qs.concat(this._deflate[Oe],this._deflate[Ee]);t&&(n=n.slice(0,n.length-4)),this._deflate[kt]=null,this._deflate[Ee]=0,this._deflate[Oe]=[],t&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),i(null,n)})}};$s.exports=hi;function ga(r){this[Oe].push(r),this[Ee]+=r.length}function Vs(r){if(this[Ee]+=r.length,this[Cr]._maxPayload<1||this[Ee]<=this[Cr]._maxPayload){this[Oe].push(r);return}this[br]=new RangeError("Max payload size exceeded"),this[br].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[br][Ws]=1009,this.removeListener("data",Vs),this.reset()}function ya(r){this[Cr]._inflate=null,r[Ws]=1007,this[kt](r)}});var Ot=k((Gf,ui)=>{"use strict";var va=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function _a(r){return r>=1e3&&r<=1014&&r!==1004&&r!==1005&&r!==1006||r>=3e3&&r<=4999}function Hs(r){let e=r.length,t=0;for(;t<e;)if(!(r[t]&128))t++;else if((r[t]&224)===192){if(t+1===e||(r[t+1]&192)!==128||(r[t]&254)===192)return!1;t+=2}else if((r[t]&240)===224){if(t+2>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||r[t]===224&&(r[t+1]&224)===128||r[t]===237&&(r[t+1]&224)===160)return!1;t+=3}else if((r[t]&248)===240){if(t+3>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||(r[t+3]&192)!==128||r[t]===240&&(r[t+1]&240)===128||r[t]===244&&r[t+1]>143||r[t]>244)return!1;t+=4}else return!1;return!0}ui.exports={isValidStatusCode:_a,isValidUTF8:Hs,tokenChars:va};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let r=w("utf-8-validate");ui.exports.isValidUTF8=function(e){return e.length<150?Hs(e):r(e)}}catch(r){}});var gi=k((zf,Js)=>{"use strict";var{Writable:Ea}=w("stream"),js=Tt(),{BINARY_TYPES:ba,EMPTY_BUFFER:Gs,kStatusCode:Ca,kWebSocket:xa}=Te(),{concat:di,toArrayBuffer:Sa,unmask:wa}=At(),{isValidStatusCode:Na,isValidUTF8:zs}=Ot(),It=0,Ks=1,Ys=2,Xs=3,pi=4,Aa=5,mi=class extends Ea{constructor(e={}){super(),this._binaryType=e.binaryType||ba[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[xa]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=It,this._loop=!1}_write(e,t,i){if(this._opcode===8&&this._state==It)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=i.slice(e),i.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let i=this._buffers[0],s=t.length-e;e>=i.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(i.buffer,i.byteOffset,e),s),this._buffers[0]=i.slice(e)),e-=i.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case It:t=this.getInfo();break;case Ks:t=this.getPayloadLength16();break;case Ys:t=this.getPayloadLength64();break;case Xs:this.getMask();break;case pi:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,B(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[js.extensionName])return this._loop=!1,B(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,B(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,B(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,B(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,B(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,B(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,B(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,B(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,B(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,B(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Ks;else if(this._payloadLength===127)this._state=Ys;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,B(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,B(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Xs:this._state=pi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=pi}getData(e){let t=Gs;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&wa(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=Aa,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[js.extensionName].decompress(e,this._fin,(s,n)=>{if(s)return t(s);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(B(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(n)}let o=this.dataMessage();if(o)return t(o);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=di(t,e):this._binaryType==="arraybuffer"?i=Sa(di(t,e)):i=t,this.emit("message",i,!0)}else{let i=di(t,e);if(!this._skipUTF8Validation&&!zs(i))return this._loop=!1,B(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",i,!1)}}this._state=It}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Gs),this.end();else{if(e.length===1)return B(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!Na(t))return B(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let i=e.slice(2);if(!this._skipUTF8Validation&&!zs(i))return B(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,i),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=It}};Js.exports=mi;function B(r,e,t,i,s){let n=new r(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(n,B),n.code=s,n[Ca]=i,n}});var vi=k((Xf,en)=>{"use strict";var Kf=w("net"),Yf=w("tls"),{randomFillSync:Ra}=w("crypto"),Qs=Tt(),{EMPTY_BUFFER:ka}=Te(),{isValidStatusCode:Ta}=Ot(),{mask:Zs,toBuffer:nt}=At(),he=Symbol("kByteLength"),Oa=Buffer.alloc(4),yi=class r{constructor(e,t,i){this._extensions=t||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let i,s=!1,n=2,o=!1;t.mask&&(i=t.maskBuffer||Oa,t.generateMask?t.generateMask(i):Ra(i,0,4),o=(i[0]|i[1]|i[2]|i[3])===0,n=6);let a;typeof e=="string"?(!t.mask||o)&&t[he]!==void 0?a=t[he]:(e=Buffer.from(e),a=e.length):(a=e.length,s=t.mask&&t.readOnly&&!o);let c=a;a>=65536?(n+=8,c=127):a>125&&(n+=2,c=126);let u=Buffer.allocUnsafe(s?a+n:n);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=c,c===126?u.writeUInt16BE(a,2):c===127&&(u[2]=u[3]=0,u.writeUIntBE(a,4,6)),t.mask?(u[1]|=128,u[n-4]=i[0],u[n-3]=i[1],u[n-2]=i[2],u[n-1]=i[3],o?[u,e]:s?(Zs(e,i,u,n,a),[u]):(Zs(e,i,e,0,a),[u,e])):[u,e]}close(e,t,i,s){let n;if(e===void 0)n=ka;else{if(typeof e!="number"||!Ta(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof t=="string"?n.write(t,2):n.set(t,2)}}let o={[he]:n.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,n,!1,o,s]):this.sendFrame(r.frame(n,o),s)}ping(e,t,i){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=nt(e),s=e.length,n=nt.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[he]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,i]):this.sendFrame(r.frame(e,o),i)}pong(e,t,i){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=nt(e),s=e.length,n=nt.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[he]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,i]):this.sendFrame(r.frame(e,o),i)}send(e,t,i){let s=this._extensions[Qs.extensionName],n=t.binary?2:1,o=t.compress,a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):(e=nt(e),a=e.length,c=nt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,n=0),t.fin&&(this._firstFragment=!0),s){let u={[he]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,u,i]):this.dispatch(e,this._compress,u,i)}else this.sendFrame(r.frame(e,{[he]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:!1}),i)}dispatch(e,t,i,s){if(!t){this.sendFrame(r.frame(e,i),s);return}let n=this._extensions[Qs.extensionName];this._bufferedBytes+=i[he],this._deflating=!0,n.compress(e,i.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof s=="function"&&s(c);for(let u=0;u<this._queue.length;u++){let f=this._queue[u],h=f[f.length-1];typeof h=="function"&&h(c)}return}this._bufferedBytes-=i[he],this._deflating=!1,i.readOnly=!1,this.sendFrame(r.frame(a,i),s),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][he],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][he],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};en.exports=yi});var fn=k((Jf,ln)=>{"use strict";var{kForOnEventAttribute:Pt,kListener:_i}=Te(),tn=Symbol("kCode"),rn=Symbol("kData"),sn=Symbol("kError"),nn=Symbol("kMessage"),on=Symbol("kReason"),ot=Symbol("kTarget"),an=Symbol("kType"),cn=Symbol("kWasClean"),be=class{constructor(e){this[ot]=null,this[an]=e}get target(){return this[ot]}get type(){return this[an]}};Object.defineProperty(be.prototype,"target",{enumerable:!0});Object.defineProperty(be.prototype,"type",{enumerable:!0});var qe=class extends be{constructor(e,t={}){super(e),this[tn]=t.code===void 0?0:t.code,this[on]=t.reason===void 0?"":t.reason,this[cn]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[tn]}get reason(){return this[on]}get wasClean(){return this[cn]}};Object.defineProperty(qe.prototype,"code",{enumerable:!0});Object.defineProperty(qe.prototype,"reason",{enumerable:!0});Object.defineProperty(qe.prototype,"wasClean",{enumerable:!0});var at=class extends be{constructor(e,t={}){super(e),this[sn]=t.error===void 0?null:t.error,this[nn]=t.message===void 0?"":t.message}get error(){return this[sn]}get message(){return this[nn]}};Object.defineProperty(at.prototype,"error",{enumerable:!0});Object.defineProperty(at.prototype,"message",{enumerable:!0});var Lt=class extends be{constructor(e,t={}){super(e),this[rn]=t.data===void 0?null:t.data}get data(){return this[rn]}};Object.defineProperty(Lt.prototype,"data",{enumerable:!0});var Ia={addEventListener(r,e,t={}){for(let s of this.listeners(r))if(!t[Pt]&&s[_i]===e&&!s[Pt])return;let i;if(r==="message")i=function(n,o){let a=new Lt("message",{data:o?n:n.toString()});a[ot]=this,xr(e,this,a)};else if(r==="close")i=function(n,o){let a=new qe("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ot]=this,xr(e,this,a)};else if(r==="error")i=function(n){let o=new at("error",{error:n,message:n.message});o[ot]=this,xr(e,this,o)};else if(r==="open")i=function(){let n=new be("open");n[ot]=this,xr(e,this,n)};else return;i[Pt]=!!t[Pt],i[_i]=e,t.once?this.once(r,i):this.on(r,i)},removeEventListener(r,e){for(let t of this.listeners(r))if(t[_i]===e&&!t[Pt]){this.removeListener(r,t);break}}};ln.exports={CloseEvent:qe,ErrorEvent:at,Event:be,EventTarget:Ia,MessageEvent:Lt};function xr(r,e,t){typeof r=="object"&&r.handleEvent?r.handleEvent.call(r,t):r.call(e,t)}});var Ei=k((Qf,hn)=>{"use strict";var{tokenChars:Ft}=Ot();function me(r,e,t){r[e]===void 0?r[e]=[t]:r[e].push(t)}function Pa(r){let e=Object.create(null),t=Object.create(null),i=!1,s=!1,n=!1,o,a,c=-1,u=-1,f=-1,h=0;for(;h<r.length;h++)if(u=r.charCodeAt(h),o===void 0)if(f===-1&&Ft[u]===1)c===-1&&(c=h);else if(h!==0&&(u===32||u===9))f===-1&&c!==-1&&(f=h);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h);let C=r.slice(c,f);u===44?(me(e,C,t),t=Object.create(null)):o=C,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);else if(a===void 0)if(f===-1&&Ft[u]===1)c===-1&&(c=h);else if(u===32||u===9)f===-1&&c!==-1&&(f=h);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h),me(t,r.slice(c,f),!0),u===44&&(me(e,o,t),t=Object.create(null),o=void 0),c=f=-1}else if(u===61&&c!==-1&&f===-1)a=r.slice(c,h),c=f=-1;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(s){if(Ft[u]!==1)throw new SyntaxError(`Unexpected character at index ${h}`);c===-1?c=h:i||(i=!0),s=!1}else if(n)if(Ft[u]===1)c===-1&&(c=h);else if(u===34&&c!==-1)n=!1,f=h;else if(u===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(u===34&&r.charCodeAt(h-1)===61)n=!0;else if(f===-1&&Ft[u]===1)c===-1&&(c=h);else if(c!==-1&&(u===32||u===9))f===-1&&(f=h);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h);let C=r.slice(c,f);i&&(C=C.replace(/\\/g,""),i=!1),me(t,a,C),u===44&&(me(e,o,t),t=Object.create(null),o=void 0),a=void 0,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);if(c===-1||n||u===32||u===9)throw new SyntaxError("Unexpected end of input");f===-1&&(f=h);let d=r.slice(c,f);return o===void 0?me(e,d,t):(a===void 0?me(t,d,!0):i?me(t,a,d.replace(/\\/g,"")):me(t,a,d),me(e,o,t)),e}function La(r){return Object.keys(r).map(e=>{let t=r[e];return Array.isArray(t)||(t=[t]),t.map(i=>[e].concat(Object.keys(i).map(s=>{let n=i[s];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}hn.exports={format:La,parse:Pa}});var wi=k((eh,Cn)=>{"use strict";var Fa=w("events"),Ba=w("https"),Ua=w("http"),pn=w("net"),Da=w("tls"),{randomBytes:Ma,createHash:qa}=w("crypto"),{Readable:Zf}=w("stream"),{URL:bi}=w("url"),Ie=Tt(),Wa=gi(),Va=vi(),{BINARY_TYPES:un,EMPTY_BUFFER:Sr,GUID:$a,kForOnEventAttribute:Ci,kListener:Ha,kStatusCode:ja,kWebSocket:Y,NOOP:mn}=Te(),{EventTarget:{addEventListener:Ga,removeEventListener:za}}=fn(),{format:Ka,parse:Ya}=Ei(),{toBuffer:Xa}=At(),Ja=30*1e3,gn=Symbol("kAborted"),xi=[8,13],Ce=["CONNECTING","OPEN","CLOSING","CLOSED"],Qa=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,P=class r extends Fa{constructor(e,t,i){super(),this._binaryType=un[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Sr,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=r.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(i=t,t=[]):t=[t]),yn(this,e,t,i)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){un.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,i){let s=new Wa({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation});this._sender=new Va(e,this._extensions,i.generateMask),this._receiver=s,this._socket=e,s[Y]=this,e[Y]=this,s.on("conclude",tc),s.on("drain",rc),s.on("error",ic),s.on("message",sc),s.on("ping",nc),s.on("pong",oc),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",_n),e.on("data",Nr),e.on("end",En),e.on("error",bn),this._readyState=r.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=r.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ie.extensionName]&&this._extensions[Ie.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=r.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==r.CLOSED){if(this.readyState===r.CONNECTING)return Z(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===r.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=r.CLOSING,this._sender.close(e,t,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),Ja)}}pause(){this.readyState===r.CONNECTING||this.readyState===r.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,i){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){Si(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Sr,t,i)}pong(e,t,i){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){Si(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Sr,t,i)}resume(){this.readyState===r.CONNECTING||this.readyState===r.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,i){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(i=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){Si(this,e,i);return}let s=E({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Ie.extensionName]||(s.compress=!1),this._sender.send(e||Sr,s,i)}terminate(){if(this.readyState!==r.CLOSED){if(this.readyState===r.CONNECTING)return Z(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=r.CLOSING,this._socket.destroy())}}};Object.defineProperty(P,"CONNECTING",{enumerable:!0,value:Ce.indexOf("CONNECTING")});Object.defineProperty(P.prototype,"CONNECTING",{enumerable:!0,value:Ce.indexOf("CONNECTING")});Object.defineProperty(P,"OPEN",{enumerable:!0,value:Ce.indexOf("OPEN")});Object.defineProperty(P.prototype,"OPEN",{enumerable:!0,value:Ce.indexOf("OPEN")});Object.defineProperty(P,"CLOSING",{enumerable:!0,value:Ce.indexOf("CLOSING")});Object.defineProperty(P.prototype,"CLOSING",{enumerable:!0,value:Ce.indexOf("CLOSING")});Object.defineProperty(P,"CLOSED",{enumerable:!0,value:Ce.indexOf("CLOSED")});Object.defineProperty(P.prototype,"CLOSED",{enumerable:!0,value:Ce.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(r=>{Object.defineProperty(P.prototype,r,{enumerable:!0})});["open","error","close","message"].forEach(r=>{Object.defineProperty(P.prototype,`on${r}`,{enumerable:!0,get(){for(let e of this.listeners(r))if(e[Ci])return e[Ha];return null},set(e){for(let t of this.listeners(r))if(t[Ci]){this.removeListener(r,t);break}typeof e=="function"&&this.addEventListener(r,e,{[Ci]:!0})}})});P.prototype.addEventListener=Ga;P.prototype.removeEventListener=za;Cn.exports=P;function yn(r,e,t,i){let s=O(E({protocolVersion:xi[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},i),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(!xi.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${xi.join(", ")})`);let n;if(e instanceof bi)n=e,r._url=e.href;else{try{n=new bi(e)}catch(p){throw new SyntaxError(`Invalid URL: ${e}`)}r._url=e}let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",c;if(n.protocol!=="ws:"&&!o&&!a?c=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!n.pathname?c="The URL's pathname is empty":n.hash&&(c="The URL contains a fragment identifier"),c){let p=new SyntaxError(c);if(r._redirects===0)throw p;wr(r,p);return}let u=o?443:80,f=Ma(16).toString("base64"),h=o?Ba.request:Ua.request,d=new Set,C;if(s.createConnection=o?ec:Za,s.defaultPort=s.defaultPort||u,s.port=n.port||u,s.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,s.headers=O(E({},s.headers),{"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":f,Connection:"Upgrade",Upgrade:"websocket"}),s.path=n.pathname+n.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(C=new Ie(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=Ka({[Ie.extensionName]:C.offer()})),t.length){for(let p of t){if(typeof p!="string"||!Qa.test(p)||d.has(p))throw new SyntaxError("An invalid or duplicated subprotocol was specified");d.add(p)}s.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(n.username||n.password)&&(s.auth=`${n.username}:${n.password}`),a){let p=s.path.split(":");s.socketPath=p[0],s.path=p[1]}let S;if(s.followRedirects){if(r._redirects===0){r._originalIpc=a,r._originalSecure=o,r._originalHostOrSocketPath=a?s.socketPath:n.host;let p=i&&i.headers;if(i=O(E({},i),{headers:{}}),p)for(let[v,N]of Object.entries(p))i.headers[v.toLowerCase()]=N}else if(r.listenerCount("redirect")===0){let p=a?r._originalIpc?s.socketPath===r._originalHostOrSocketPath:!1:r._originalIpc?!1:n.host===r._originalHostOrSocketPath;(!p||r._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,p||delete s.headers.host,s.auth=void 0)}s.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),S=r._req=h(s),r._redirects&&r.emit("redirect",r.url,S)}else S=r._req=h(s);s.timeout&&S.on("timeout",()=>{Z(r,S,"Opening handshake has timed out")}),S.on("error",p=>{S===null||S[gn]||(S=r._req=null,wr(r,p))}),S.on("response",p=>{let v=p.headers.location,N=p.statusCode;if(v&&s.followRedirects&&N>=300&&N<400){if(++r._redirects>s.maxRedirects){Z(r,S,"Maximum redirects exceeded");return}S.abort();let A;try{A=new bi(v,e)}catch(m){let y=new SyntaxError(`Invalid URL: ${v}`);wr(r,y);return}yn(r,A,t,i)}else r.emit("unexpected-response",S,p)||Z(r,S,`Unexpected server response: ${p.statusCode}`)}),S.on("upgrade",(p,v,N)=>{if(r.emit("upgrade",p),r.readyState!==P.CONNECTING)return;if(S=r._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){Z(r,v,"Invalid Upgrade header");return}let A=qa("sha1").update(f+$a).digest("base64");if(p.headers["sec-websocket-accept"]!==A){Z(r,v,"Invalid Sec-WebSocket-Accept header");return}let m=p.headers["sec-websocket-protocol"],y;if(m!==void 0?d.size?d.has(m)||(y="Server sent an invalid subprotocol"):y="Server sent a subprotocol but none was requested":d.size&&(y="Server sent no subprotocol"),y){Z(r,v,y);return}m&&(r._protocol=m);let $=p.headers["sec-websocket-extensions"];if($!==void 0){if(!C){Z(r,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R;try{R=Ya($)}catch(z){Z(r,v,"Invalid Sec-WebSocket-Extensions header");return}let H=Object.keys(R);if(H.length!==1||H[0]!==Ie.extensionName){Z(r,v,"Server indicated an extension that was not requested");return}try{C.accept(R[Ie.extensionName])}catch(z){Z(r,v,"Invalid Sec-WebSocket-Extensions header");return}r._extensions[Ie.extensionName]=C}r.setSocket(v,N,{generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),S.end()}function wr(r,e){r._readyState=P.CLOSING,r.emit("error",e),r.emitClose()}function Za(r){return r.path=r.socketPath,pn.connect(r)}function ec(r){return r.path=void 0,!r.servername&&r.servername!==""&&(r.servername=pn.isIP(r.host)?"":r.host),Da.connect(r)}function Z(r,e,t){r._readyState=P.CLOSING;let i=new Error(t);Error.captureStackTrace(i,Z),e.setHeader?(e[gn]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(wr,r,i)):(e.destroy(i),e.once("error",r.emit.bind(r,"error")),e.once("close",r.emitClose.bind(r)))}function Si(r,e,t){if(e){let i=Xa(e).length;r._socket?r._sender._bufferedBytes+=i:r._bufferedAmount+=i}if(t){let i=new Error(`WebSocket is not open: readyState ${r.readyState} (${Ce[r.readyState]})`);t(i)}}function tc(r,e){let t=this[Y];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=r,t._socket[Y]!==void 0&&(t._socket.removeListener("data",Nr),process.nextTick(vn,t._socket),r===1005?t.close():t.close(r,e))}function rc(){let r=this[Y];r.isPaused||r._socket.resume()}function ic(r){let e=this[Y];e._socket[Y]!==void 0&&(e._socket.removeListener("data",Nr),process.nextTick(vn,e._socket),e.close(r[ja])),e.emit("error",r)}function dn(){this[Y].emitClose()}function sc(r,e){this[Y].emit("message",r,e)}function nc(r){let e=this[Y];e.pong(r,!e._isServer,mn),e.emit("ping",r)}function oc(r){this[Y].emit("pong",r)}function vn(r){r.resume()}function _n(){let r=this[Y];this.removeListener("close",_n),this.removeListener("data",Nr),this.removeListener("end",En),r._readyState=P.CLOSING;let e;!this._readableState.endEmitted&&!r._closeFrameReceived&&!r._receiver._writableState.errorEmitted&&(e=r._socket.read())!==null&&r._receiver.write(e),r._receiver.end(),this[Y]=void 0,clearTimeout(r._closeTimer),r._receiver._writableState.finished||r._receiver._writableState.errorEmitted?r.emitClose():(r._receiver.on("error",dn),r._receiver.on("finish",dn))}function Nr(r){this[Y]._receiver.write(r)||this.pause()}function En(){let r=this[Y];r._readyState=P.CLOSING,r._receiver.end(),this.end()}function bn(){let r=this[Y];this.removeListener("error",bn),this.on("error",mn),r&&(r._readyState=P.CLOSING,this.destroy())}});var Sn=k((rh,xn)=>{"use strict";var{tokenChars:ac}=Ot();function cc(r){let e=new Set,t=-1,i=-1,s=0;for(s;s<r.length;s++){let o=r.charCodeAt(s);if(i===-1&&ac[o]===1)t===-1&&(t=s);else if(s!==0&&(o===32||o===9))i===-1&&t!==-1&&(i=s);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${s}`);i===-1&&(i=s);let a=r.slice(t,i);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=i=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(t===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let n=r.slice(t,s);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}xn.exports={parse:cc}});var On=k((oh,Tn)=>{"use strict";var lc=w("events"),Ar=w("http"),ih=w("https"),sh=w("net"),nh=w("tls"),{createHash:fc}=w("crypto"),wn=Ei(),We=Tt(),hc=Sn(),uc=wi(),{GUID:dc,kWebSocket:pc}=Te(),mc=/^[+/0-9A-Za-z]{22}==$/,Nn=0,An=1,kn=2,Ni=class extends lc{constructor(e,t){if(super(),e=E({maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:uc},e),e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Ar.createServer((i,s)=>{let n=Ar.STATUS_CODES[426];s.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),s.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=gc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,n,o)=>{this.handleUpgrade(s,n,o,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Nn}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===kn){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Bt,this);return}if(e&&this.once("close",e),this._state!==An)if(this._state=An,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Bt,this):process.nextTick(Bt,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Bt(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,i,s){t.on("error",Rn);let n=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Ve(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){Ve(this,e,t,400,"Invalid Upgrade header");return}if(!n||!mc.test(n)){Ve(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){Ve(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Ut(t,400);return}let a=e.headers["sec-websocket-protocol"],c=new Set;if(a!==void 0)try{c=hc.parse(a)}catch(h){Ve(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&u!==void 0){let h=new We(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let d=wn.parse(u);d[We.extensionName]&&(h.accept(d[We.extensionName]),f[We.extensionName]=h)}catch(d){Ve(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let h={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(h,(d,C,S,p)=>{if(!d)return Ut(t,C||401,S,p);this.completeUpgrade(f,n,c,e,t,i,s)});return}if(!this.options.verifyClient(h))return Ut(t,401)}this.completeUpgrade(f,n,c,e,t,i,s)}completeUpgrade(e,t,i,s,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[pc])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Nn)return Ut(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${fc("sha1").update(t+dc).digest("base64")}`],f=new this.options.WebSocket(null);if(i.size){let h=this.options.handleProtocols?this.options.handleProtocols(i,s):i.values().next().value;h&&(u.push(`Sec-WebSocket-Protocol: ${h}`),f._protocol=h)}if(e[We.extensionName]){let h=e[We.extensionName].params,d=wn.format({[We.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${d}`),f._extensions=e}this.emit("headers",u,s),n.write(u.concat(`\r
3
+ `+n),i.push(s+"m+"+ui.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Wo()+e+" "+i[0]}function Wo(){return q.inspectOpts.hideDate?"":new Date().toISOString()+" "}function $o(...i){return process.stderr.write(hi.formatWithOptions(q.inspectOpts,...i)+`
4
+ `)}function Vo(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function jo(){return process.env.DEBUG}function Ho(i){i.inspectOpts={};let e=Object.keys(q.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=q.inspectOpts[e[t]]}ui.exports=Yi()(q);var{formatters:hs}=ui.exports;hs.o=function(i){return this.inspectOpts.colors=this.useColors,hi.inspect(i,this.inspectOpts).split(`
5
+ `).map(e=>e.trim()).join(" ")};hs.O=function(i){return this.inspectOpts.colors=this.useColors,hi.inspect(i,this.inspectOpts)}});var Ue=T((cf,Zi)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Zi.exports=os():Zi.exports=us()});var xs=T((gf,bs)=>{"use strict";var it=w("fs"),Es=w("url"),Ko=w("child_process").spawn;bs.exports=ir;ir.XMLHttpRequest=ir;function ir(i){"use strict";i=i||{};var e=this,t=w("http"),r=w("https"),s,n,o={},a=!1,c={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},c),f=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],h=["TRACE","TRACK","CONNECT"],d=!1,x=!1,S=!1,p={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var v=function(m){return a||m&&f.indexOf(m.toLowerCase())===-1},N=function(m){return m&&h.indexOf(m)===-1};this.open=function(m,y,$,k,V){if(this.abort(),x=!1,S=!1,!N(m))throw new Error("SecurityError: Request method not allowed");o={method:m,url:y.toString(),async:typeof $!="boolean"?!0:$,user:k||null,password:V||null},A(this.OPENED)},this.setDisableHeaderCheck=function(m){a=m},this.setRequestHeader=function(m,y){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!v(m))return console.warn('Refused to set unsafe header "'+m+'"'),!1;if(d)throw new Error("INVALID_STATE_ERR: send flag is true");return u[m]=y,!0},this.getResponseHeader=function(m){return typeof m=="string"&&this.readyState>this.OPENED&&n.headers[m.toLowerCase()]&&!x?n.headers[m.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||x)return"";var m="";for(var y in n.headers)y!=="set-cookie"&&y!=="set-cookie2"&&(m+=y+": "+n.headers[y]+`\r
6
+ `);return m.substr(0,m.length-2)},this.getRequestHeader=function(m){return typeof m=="string"&&u[m]?u[m]:""},this.send=function(m){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(d)throw new Error("INVALID_STATE_ERR: send has already been called");var y=!1,$=!1,k=Es.parse(o.url),V;switch(k.protocol){case"https:":y=!0;case"http:":V=k.hostname;break;case"file:":$=!0;break;case void 0:case"":V="localhost";break;default:throw new Error("Protocol not supported.")}if($){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)it.readFile(unescape(k.pathname),"utf8",function(ie,He){ie?e.handleError(ie,ie.errno||-1):(e.status=200,e.responseText=He,A(e.DONE))});else try{this.responseText=it.readFileSync(unescape(k.pathname),"utf8"),this.status=200,A(e.DONE)}catch(ie){this.handleError(ie,ie.errno||-1)}return}var G=k.port||(y?443:80),ue=k.pathname+(k.search?k.search:"");if(u.Host=V,y&&G===443||G===80||(u.Host+=":"+k.port),o.user){typeof o.password=="undefined"&&(o.password="");var Gt=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Gt.toString("base64")}o.method==="GET"||o.method==="HEAD"?m=null:m?(u["Content-Length"]=Buffer.isBuffer(m)?m.length:Buffer.byteLength(m),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var zt=i.agent||!1,te={host:V,port:G,path:ue,method:o.method,headers:u,agent:zt};if(y&&(te.pfx=i.pfx,te.key=i.key,te.passphrase=i.passphrase,te.cert=i.cert,te.ca=i.ca,te.ciphers=i.ciphers,te.rejectUnauthorized=i.rejectUnauthorized!==!1),x=!1,o.async){var je=y?r.request:t.request;d=!0,e.dispatchEvent("readystatechange");var Br=function(ie){if(n=ie,n.statusCode===302||n.statusCode===303||n.statusCode===307){o.url=n.headers.location;var He=Es.parse(o.url);V=He.hostname;var be={hostname:He.hostname,port:He.port,path:He.path,method:n.statusCode===303?"GET":o.method,headers:u};y&&(be.pfx=i.pfx,be.key=i.key,be.passphrase=i.passphrase,be.cert=i.cert,be.ca=i.ca,be.ciphers=i.ciphers,be.rejectUnauthorized=i.rejectUnauthorized!==!1),s=je(be,Br).on("error",Ur),s.end();return}n&&n.setEncoding&&n.setEncoding("utf8"),A(e.HEADERS_RECEIVED),e.status=n.statusCode,n.on("data",function(Kt){Kt&&(e.responseText+=Kt),d&&A(e.LOADING)}),n.on("end",function(){d&&(d=!1,A(e.DONE))}),n.on("error",function(Kt){e.handleError(Kt)})},Ur=function(ie){e.handleError(ie)};s=je(te,Br).on("error",Ur),i.autoUnref&&s.on("socket",ie=>{ie.unref()}),m&&s.write(m),s.end(),e.dispatchEvent("loadstart")}else{var ut=".node-xmlhttprequest-content-"+process.pid,dt=".node-xmlhttprequest-sync-"+process.pid;it.writeFileSync(dt,"","utf8");for(var to="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(y?"s":"")+".request;var options = "+JSON.stringify(te)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+ut+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+dt+"');});response.on('error', function(error) {fs.writeFileSync('"+ut+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+dt+"');});}).on('error', function(error) {fs.writeFileSync('"+ut+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+dt+"');});"+(m?"req.write('"+JSON.stringify(m).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",io=Ko(process.argv[0],["-e",to]),Vc;it.existsSync(dt););if(e.responseText=it.readFileSync(ut,"utf8"),io.stdin.end(),it.unlinkSync(ut),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var ro=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(ro,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),A(e.DONE)}},this.handleError=function(m,y){this.status=y||0,this.statusText=m,this.responseText=m.stack,x=!0,A(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),u=Object.assign({},c),this.responseText="",this.responseXML="",x=S=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||d)&&this.readyState!==this.DONE&&(d=!1,A(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(m,y){m in p||(p[m]=[]),p[m].push(y)},this.removeEventListener=function(m,y){m in p&&(p[m]=p[m].filter(function($){return $!==y}))},this.dispatchEvent=function(m){if(typeof e["on"+m]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+m]()}):e["on"+m]()),m in p)for(let y=0,$=p[m].length;y<$;y++)this.readyState===this.DONE?setImmediate(function(){p[m][y].call(e)}):p[m][y].call(e)};var A=function(m){if(!(e.readyState===m||e.readyState===e.UNSENT&&S)&&(e.readyState=m,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let y;S?y="abort":x?y="error":y="load",e.dispatchEvent(y),e.dispatchEvent("loadend")}}}});var Rs=T((Nf,ks)=>{"use strict";var{Duplex:Qo}=w("stream");function Ns(i){i.emit("close")}function Zo(){!this.destroyed&&this._writableState.finished&&this.destroy()}function As(i){this.removeListener("error",As),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function ea(i,e){let t=!0,r=new Qo(O(b({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(n,o){let a=!o&&r._readableState.objectMode?n.toString():n;r.push(a)||i.pause()}),i.once("error",function(n){r.destroyed||(t=!1,r.destroy(n))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(s,n){if(i.readyState===i.CLOSED){n(s),process.nextTick(Ns,r);return}let o=!1;i.once("error",function(c){o=!0,n(c)}),i.once("close",function(){o||n(s),process.nextTick(Ns,r)}),t&&i.terminate()},r._final=function(s){if(i.readyState===i.CONNECTING){i.once("open",function(){r._final(s)});return}i._socket!==null&&(i._socket._writableState.finished?(s(),r._readableState.endEmitted&&r.destroy()):(i._socket.once("finish",function(){s()}),i.close()))},r._read=function(){i.isPaused&&i.resume()},r._write=function(s,n,o){if(i.readyState===i.CONNECTING){i.once("open",function(){r._write(s,n,o)});return}i.send(s,o)},r.on("end",Zo),r.on("error",As),r}ks.exports=ea});var Re=T((kf,Ts)=>{"use strict";Ts.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var wt=T((Rf,gi)=>{"use strict";var{EMPTY_BUFFER:ta}=Re();function ia(i,e){if(i.length===0)return ta;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return r<e?t.slice(0,r):t}function Os(i,e,t,r,s){for(let n=0;n<s;n++)t[r+n]=i[n]^e[n&3]}function Is(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function ra(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function or(i){if(or.readOnly=!0,Buffer.isBuffer(i))return i;let e;return i instanceof ArrayBuffer?e=Buffer.from(i):ArrayBuffer.isView(i)?e=Buffer.from(i.buffer,i.byteOffset,i.byteLength):(e=Buffer.from(i),or.readOnly=!1),e}gi.exports={concat:ia,mask:Os,toArrayBuffer:ra,toBuffer:or,unmask:Is};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=w("bufferutil");gi.exports.mask=function(e,t,r,s,n){n<48?Os(e,t,r,s,n):i.mask(e,t,r,s,n)},gi.exports.unmask=function(e,t){e.length<32?Is(e,t):i.unmask(e,t)}}catch(i){}});var Fs=T((Tf,Ls)=>{"use strict";var Ps=Symbol("kDone"),ar=Symbol("kRun"),cr=class{constructor(e){this[Ps]=()=>{this.pending--,this[ar]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ar]()}[ar](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ps])}}};Ls.exports=cr});var kt=T((Of,Ms)=>{"use strict";var Nt=w("zlib"),Bs=wt(),sa=Fs(),{kStatusCode:Us}=Re(),na=Buffer.from([0,0,255,255]),_i=Symbol("permessage-deflate"),ve=Symbol("total-length"),At=Symbol("callback"),Te=Symbol("buffers"),vi=Symbol("error"),yi,lr=class{constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!yi){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;yi=new sa(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[At];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(s=>!(t.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>s.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let s=t[r];if(s.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(s=s[0],r==="client_max_window_bits"){if(s!==!0){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else if(r==="server_max_window_bits"){let n=+s;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${s}`);s=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${s}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=s})}),e}decompress(e,t,r){yi.add(s=>{this._decompress(e,t,(n,o)=>{s(),r(n,o)})})}compress(e,t,r){yi.add(s=>{this._compress(e,t,(n,o)=>{s(),r(n,o)})})}_decompress(e,t,r){let s=this._isServer?"client":"server";if(!this._inflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Nt.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Nt.createInflateRaw(O(b({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[_i]=this,this._inflate[ve]=0,this._inflate[Te]=[],this._inflate.on("error",aa),this._inflate.on("data",Ds)}this._inflate[At]=r,this._inflate.write(e),t&&this._inflate.write(na),this._inflate.flush(()=>{let n=this._inflate[vi];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Bs.concat(this._inflate[Te],this._inflate[ve]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[ve]=0,this._inflate[Te]=[],t&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let s=this._isServer?"server":"client";if(!this._deflate){let n=`${s}_max_window_bits`,o=typeof this.params[n]!="number"?Nt.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Nt.createDeflateRaw(O(b({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[ve]=0,this._deflate[Te]=[],this._deflate.on("data",oa)}this._deflate[At]=r,this._deflate.write(e),this._deflate.flush(Nt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Bs.concat(this._deflate[Te],this._deflate[ve]);t&&(n=n.slice(0,n.length-4)),this._deflate[At]=null,this._deflate[ve]=0,this._deflate[Te]=[],t&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};Ms.exports=lr;function oa(i){this[Te].push(i),this[ve]+=i.length}function Ds(i){if(this[ve]+=i.length,this[_i]._maxPayload<1||this[ve]<=this[_i]._maxPayload){this[Te].push(i);return}this[vi]=new RangeError("Max payload size exceeded"),this[vi].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[vi][Us]=1009,this.removeListener("data",Ds),this.reset()}function aa(i){this[_i]._inflate=null,i[Us]=1007,this[At](i)}});var Rt=T((Pf,fr)=>{"use strict";var ca=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function la(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function qs(i){let e=i.length,t=0;for(;t<e;)if(!(i[t]&128))t++;else if((i[t]&224)===192){if(t+1===e||(i[t+1]&192)!==128||(i[t]&254)===192)return!1;t+=2}else if((i[t]&240)===224){if(t+2>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||i[t]===224&&(i[t+1]&224)===128||i[t]===237&&(i[t+1]&224)===160)return!1;t+=3}else if((i[t]&248)===240){if(t+3>=e||(i[t+1]&192)!==128||(i[t+2]&192)!==128||(i[t+3]&192)!==128||i[t]===240&&(i[t+1]&240)===128||i[t]===244&&i[t+1]>143||i[t]>244)return!1;t+=4}else return!1;return!0}fr.exports={isValidStatusCode:la,isValidUTF8:qs,tokenChars:ca};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=w("utf-8-validate");fr.exports.isValidUTF8=function(e){return e.length<150?qs(e):i(e)}}catch(i){}});var pr=T((Lf,zs)=>{"use strict";var{Writable:fa}=w("stream"),Ws=kt(),{BINARY_TYPES:ha,EMPTY_BUFFER:$s,kStatusCode:ua,kWebSocket:da}=Re(),{concat:hr,toArrayBuffer:pa,unmask:ma}=wt(),{isValidStatusCode:ga,isValidUTF8:Vs}=Rt(),Tt=0,js=1,Hs=2,Gs=3,ur=4,ya=5,dr=class extends fa{constructor(e={}){super(),this._binaryType=e.binaryType||ha[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[da]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=Tt,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==Tt)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=r.slice(e),r.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],s=t.length-e;e>=r.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),s),this._buffers[0]=r.slice(e)),e-=r.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case Tt:t=this.getInfo();break;case js:t=this.getPayloadLength16();break;case Hs:t=this.getPayloadLength64();break;case Gs:this.getMask();break;case ur:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if(e[0]&48)return this._loop=!1,B(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[Ws.extensionName])return this._loop=!1,B(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,B(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,B(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,B(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,B(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,B(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,B(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,B(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,B(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,B(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=js;else if(this._payloadLength===127)this._state=Hs;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,B(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,B(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Gs:this._state=ur}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ur}getData(e){let t=$s;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&ma(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=ya,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Ws.extensionName].decompress(e,this._fin,(s,n)=>{if(s)return t(s);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(B(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(n)}let o=this.dataMessage();if(o)return t(o);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=hr(t,e):this._binaryType==="arraybuffer"?r=pa(hr(t,e)):r=t,this.emit("message",r,!0)}else{let r=hr(t,e);if(!this._skipUTF8Validation&&!Vs(r))return this._loop=!1,B(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=Tt}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,$s),this.end();else{if(e.length===1)return B(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!ga(t))return B(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!Vs(r))return B(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,r),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=Tt}};zs.exports=dr;function B(i,e,t,r,s){let n=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(n,B),n.code=s,n[ua]=r,n}});var gr=T((Uf,Xs)=>{"use strict";var Ff=w("net"),Bf=w("tls"),{randomFillSync:va}=w("crypto"),Ks=kt(),{EMPTY_BUFFER:_a}=Re(),{isValidStatusCode:Ea}=Rt(),{mask:Ys,toBuffer:rt}=wt(),le=Symbol("kByteLength"),ba=Buffer.alloc(4),mr=class i{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let r,s=!1,n=2,o=!1;t.mask&&(r=t.maskBuffer||ba,t.generateMask?t.generateMask(r):va(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let a;typeof e=="string"?(!t.mask||o)&&t[le]!==void 0?a=t[le]:(e=Buffer.from(e),a=e.length):(a=e.length,s=t.mask&&t.readOnly&&!o);let c=a;a>=65536?(n+=8,c=127):a>125&&(n+=2,c=126);let u=Buffer.allocUnsafe(s?a+n:n);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=c,c===126?u.writeUInt16BE(a,2):c===127&&(u[2]=u[3]=0,u.writeUIntBE(a,4,6)),t.mask?(u[1]|=128,u[n-4]=r[0],u[n-3]=r[1],u[n-2]=r[2],u[n-1]=r[3],o?[u,e]:s?(Ys(e,r,u,n,a),[u]):(Ys(e,r,e,0,a),[u,e])):[u,e]}close(e,t,r,s){let n;if(e===void 0)n=_a;else{if(typeof e!="number"||!Ea(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof t=="string"?n.write(t,2):n.set(t,2)}}let o={[le]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,n,!1,o,s]):this.sendFrame(i.frame(n,o),s)}ping(e,t,r){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=rt(e),s=e.length,n=rt.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[le]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let s,n;if(typeof e=="string"?(s=Buffer.byteLength(e),n=!1):(e=rt(e),s=e.length,n=rt.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[le]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let s=this._extensions[Ks.extensionName],n=t.binary?2:1,o=t.compress,a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):(e=rt(e),a=e.length,c=rt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,n=0),t.fin&&(this._firstFragment=!0),s){let u={[le]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,u,r]):this.dispatch(e,this._compress,u,r)}else this.sendFrame(i.frame(e,{[le]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:c,rsv1:!1}),r)}dispatch(e,t,r,s){if(!t){this.sendFrame(i.frame(e,r),s);return}let n=this._extensions[Ks.extensionName];this._bufferedBytes+=r[le],this._deflating=!0,n.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof s=="function"&&s(c);for(let u=0;u<this._queue.length;u++){let f=this._queue[u],h=f[f.length-1];typeof h=="function"&&h(c)}return}this._bufferedBytes-=r[le],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(a,r),s),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][le],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][le],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};Xs.exports=mr});var on=T((Df,nn)=>{"use strict";var{kForOnEventAttribute:Ot,kListener:yr}=Re(),Js=Symbol("kCode"),Qs=Symbol("kData"),Zs=Symbol("kError"),en=Symbol("kMessage"),tn=Symbol("kReason"),st=Symbol("kTarget"),rn=Symbol("kType"),sn=Symbol("kWasClean"),_e=class{constructor(e){this[st]=null,this[rn]=e}get target(){return this[st]}get type(){return this[rn]}};Object.defineProperty(_e.prototype,"target",{enumerable:!0});Object.defineProperty(_e.prototype,"type",{enumerable:!0});var De=class extends _e{constructor(e,t={}){super(e),this[Js]=t.code===void 0?0:t.code,this[tn]=t.reason===void 0?"":t.reason,this[sn]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Js]}get reason(){return this[tn]}get wasClean(){return this[sn]}};Object.defineProperty(De.prototype,"code",{enumerable:!0});Object.defineProperty(De.prototype,"reason",{enumerable:!0});Object.defineProperty(De.prototype,"wasClean",{enumerable:!0});var nt=class extends _e{constructor(e,t={}){super(e),this[Zs]=t.error===void 0?null:t.error,this[en]=t.message===void 0?"":t.message}get error(){return this[Zs]}get message(){return this[en]}};Object.defineProperty(nt.prototype,"error",{enumerable:!0});Object.defineProperty(nt.prototype,"message",{enumerable:!0});var It=class extends _e{constructor(e,t={}){super(e),this[Qs]=t.data===void 0?null:t.data}get data(){return this[Qs]}};Object.defineProperty(It.prototype,"data",{enumerable:!0});var xa={addEventListener(i,e,t={}){for(let s of this.listeners(i))if(!t[Ot]&&s[yr]===e&&!s[Ot])return;let r;if(i==="message")r=function(n,o){let a=new It("message",{data:o?n:n.toString()});a[st]=this,Ei(e,this,a)};else if(i==="close")r=function(n,o){let a=new De("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[st]=this,Ei(e,this,a)};else if(i==="error")r=function(n){let o=new nt("error",{error:n,message:n.message});o[st]=this,Ei(e,this,o)};else if(i==="open")r=function(){let n=new _e("open");n[st]=this,Ei(e,this,n)};else return;r[Ot]=!!t[Ot],r[yr]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[yr]===e&&!t[Ot]){this.removeListener(i,t);break}}};nn.exports={CloseEvent:De,ErrorEvent:nt,Event:_e,EventTarget:xa,MessageEvent:It};function Ei(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var vr=T((Mf,an)=>{"use strict";var{tokenChars:Pt}=Rt();function de(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function Ca(i){let e=Object.create(null),t=Object.create(null),r=!1,s=!1,n=!1,o,a,c=-1,u=-1,f=-1,h=0;for(;h<i.length;h++)if(u=i.charCodeAt(h),o===void 0)if(f===-1&&Pt[u]===1)c===-1&&(c=h);else if(h!==0&&(u===32||u===9))f===-1&&c!==-1&&(f=h);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h);let x=i.slice(c,f);u===44?(de(e,x,t),t=Object.create(null)):o=x,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);else if(a===void 0)if(f===-1&&Pt[u]===1)c===-1&&(c=h);else if(u===32||u===9)f===-1&&c!==-1&&(f=h);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h),de(t,i.slice(c,f),!0),u===44&&(de(e,o,t),t=Object.create(null),o=void 0),c=f=-1}else if(u===61&&c!==-1&&f===-1)a=i.slice(c,h),c=f=-1;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(s){if(Pt[u]!==1)throw new SyntaxError(`Unexpected character at index ${h}`);c===-1?c=h:r||(r=!0),s=!1}else if(n)if(Pt[u]===1)c===-1&&(c=h);else if(u===34&&c!==-1)n=!1,f=h;else if(u===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(u===34&&i.charCodeAt(h-1)===61)n=!0;else if(f===-1&&Pt[u]===1)c===-1&&(c=h);else if(c!==-1&&(u===32||u===9))f===-1&&(f=h);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${h}`);f===-1&&(f=h);let x=i.slice(c,f);r&&(x=x.replace(/\\/g,""),r=!1),de(t,a,x),u===44&&(de(e,o,t),t=Object.create(null),o=void 0),a=void 0,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);if(c===-1||n||u===32||u===9)throw new SyntaxError("Unexpected end of input");f===-1&&(f=h);let d=i.slice(c,f);return o===void 0?de(e,d,t):(a===void 0?de(t,d,!0):r?de(t,a,d.replace(/\\/g,"")):de(t,a,d),de(e,o,t)),e}function Sa(i){return Object.keys(i).map(e=>{let t=i[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(s=>{let n=r[s];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}an.exports={format:Sa,parse:Ca}});var Cr=T((Wf,vn)=>{"use strict";var wa=w("events"),Na=w("https"),Aa=w("http"),fn=w("net"),ka=w("tls"),{randomBytes:Ra,createHash:Ta}=w("crypto"),{Readable:qf}=w("stream"),{URL:_r}=w("url"),Oe=kt(),Oa=pr(),Ia=gr(),{BINARY_TYPES:cn,EMPTY_BUFFER:bi,GUID:Pa,kForOnEventAttribute:Er,kListener:La,kStatusCode:Fa,kWebSocket:K,NOOP:hn}=Re(),{EventTarget:{addEventListener:Ba,removeEventListener:Ua}}=on(),{format:Da,parse:Ma}=vr(),{toBuffer:qa}=wt(),Wa=30*1e3,un=Symbol("kAborted"),br=[8,13],Ee=["CONNECTING","OPEN","CLOSING","CLOSED"],$a=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,P=class i extends wa{constructor(e,t,r){super(),this._binaryType=cn[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=bi,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=i.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),dn(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){cn.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let s=new Oa({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new Ia(e,this._extensions,r.generateMask),this._receiver=s,this._socket=e,s[K]=this,e[K]=this,s.on("conclude",Ha),s.on("drain",Ga),s.on("error",za),s.on("message",Ka),s.on("ping",Ya),s.on("pong",Xa),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",mn),e.on("data",Ci),e.on("end",gn),e.on("error",yn),this._readyState=i.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Oe.extensionName]&&this._extensions[Oe.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=i.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return Q(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===i.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=i.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),Wa)}}pause(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){xr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||bi,t,r)}pong(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){xr(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||bi,t,r)}resume(){this.readyState===i.CONNECTING||this.readyState===i.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===i.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==i.OPEN){xr(this,e,r);return}let s=b({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Oe.extensionName]||(s.compress=!1),this._sender.send(e||bi,s,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return Q(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(P,"CONNECTING",{enumerable:!0,value:Ee.indexOf("CONNECTING")});Object.defineProperty(P.prototype,"CONNECTING",{enumerable:!0,value:Ee.indexOf("CONNECTING")});Object.defineProperty(P,"OPEN",{enumerable:!0,value:Ee.indexOf("OPEN")});Object.defineProperty(P.prototype,"OPEN",{enumerable:!0,value:Ee.indexOf("OPEN")});Object.defineProperty(P,"CLOSING",{enumerable:!0,value:Ee.indexOf("CLOSING")});Object.defineProperty(P.prototype,"CLOSING",{enumerable:!0,value:Ee.indexOf("CLOSING")});Object.defineProperty(P,"CLOSED",{enumerable:!0,value:Ee.indexOf("CLOSED")});Object.defineProperty(P.prototype,"CLOSED",{enumerable:!0,value:Ee.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(P.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(P.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[Er])return e[La];return null},set(e){for(let t of this.listeners(i))if(t[Er]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Er]:!0})}})});P.prototype.addEventListener=Ba;P.prototype.removeEventListener=Ua;vn.exports=P;function dn(i,e,t,r){let s=O(b({protocolVersion:br[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},r),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(!br.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${br.join(", ")})`);let n;if(e instanceof _r)n=e,i._url=e.href;else{try{n=new _r(e)}catch(p){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",c;if(n.protocol!=="ws:"&&!o&&!a?c=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:a&&!n.pathname?c="The URL's pathname is empty":n.hash&&(c="The URL contains a fragment identifier"),c){let p=new SyntaxError(c);if(i._redirects===0)throw p;xi(i,p);return}let u=o?443:80,f=Ra(16).toString("base64"),h=o?Na.request:Aa.request,d=new Set,x;if(s.createConnection=o?ja:Va,s.defaultPort=s.defaultPort||u,s.port=n.port||u,s.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,s.headers=O(b({},s.headers),{"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":f,Connection:"Upgrade",Upgrade:"websocket"}),s.path=n.pathname+n.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(x=new Oe(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=Da({[Oe.extensionName]:x.offer()})),t.length){for(let p of t){if(typeof p!="string"||!$a.test(p)||d.has(p))throw new SyntaxError("An invalid or duplicated subprotocol was specified");d.add(p)}s.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(n.username||n.password)&&(s.auth=`${n.username}:${n.password}`),a){let p=s.path.split(":");s.socketPath=p[0],s.path=p[1]}let S;if(s.followRedirects){if(i._redirects===0){i._originalIpc=a,i._originalSecure=o,i._originalHostOrSocketPath=a?s.socketPath:n.host;let p=r&&r.headers;if(r=O(b({},r),{headers:{}}),p)for(let[v,N]of Object.entries(p))r.headers[v.toLowerCase()]=N}else if(i.listenerCount("redirect")===0){let p=a?i._originalIpc?s.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:n.host===i._originalHostOrSocketPath;(!p||i._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,p||delete s.headers.host,s.auth=void 0)}s.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),S=i._req=h(s),i._redirects&&i.emit("redirect",i.url,S)}else S=i._req=h(s);s.timeout&&S.on("timeout",()=>{Q(i,S,"Opening handshake has timed out")}),S.on("error",p=>{S===null||S[un]||(S=i._req=null,xi(i,p))}),S.on("response",p=>{let v=p.headers.location,N=p.statusCode;if(v&&s.followRedirects&&N>=300&&N<400){if(++i._redirects>s.maxRedirects){Q(i,S,"Maximum redirects exceeded");return}S.abort();let A;try{A=new _r(v,e)}catch(m){let y=new SyntaxError(`Invalid URL: ${v}`);xi(i,y);return}dn(i,A,t,r)}else i.emit("unexpected-response",S,p)||Q(i,S,`Unexpected server response: ${p.statusCode}`)}),S.on("upgrade",(p,v,N)=>{if(i.emit("upgrade",p),i.readyState!==P.CONNECTING)return;if(S=i._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){Q(i,v,"Invalid Upgrade header");return}let A=Ta("sha1").update(f+Pa).digest("base64");if(p.headers["sec-websocket-accept"]!==A){Q(i,v,"Invalid Sec-WebSocket-Accept header");return}let m=p.headers["sec-websocket-protocol"],y;if(m!==void 0?d.size?d.has(m)||(y="Server sent an invalid subprotocol"):y="Server sent a subprotocol but none was requested":d.size&&(y="Server sent no subprotocol"),y){Q(i,v,y);return}m&&(i._protocol=m);let $=p.headers["sec-websocket-extensions"];if($!==void 0){if(!x){Q(i,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let k;try{k=Ma($)}catch(G){Q(i,v,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(k);if(V.length!==1||V[0]!==Oe.extensionName){Q(i,v,"Server indicated an extension that was not requested");return}try{x.accept(k[Oe.extensionName])}catch(G){Q(i,v,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[Oe.extensionName]=x}i.setSocket(v,N,{generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),S.end()}function xi(i,e){i._readyState=P.CLOSING,i.emit("error",e),i.emitClose()}function Va(i){return i.path=i.socketPath,fn.connect(i)}function ja(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=fn.isIP(i.host)?"":i.host),ka.connect(i)}function Q(i,e,t){i._readyState=P.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Q),e.setHeader?(e[un]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(xi,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function xr(i,e,t){if(e){let r=qa(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Ee[i.readyState]})`);t(r)}}function Ha(i,e){let t=this[K];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[K]!==void 0&&(t._socket.removeListener("data",Ci),process.nextTick(pn,t._socket),i===1005?t.close():t.close(i,e))}function Ga(){let i=this[K];i.isPaused||i._socket.resume()}function za(i){let e=this[K];e._socket[K]!==void 0&&(e._socket.removeListener("data",Ci),process.nextTick(pn,e._socket),e.close(i[Fa])),e.emit("error",i)}function ln(){this[K].emitClose()}function Ka(i,e){this[K].emit("message",i,e)}function Ya(i){let e=this[K];e.pong(i,!e._isServer,hn),e.emit("ping",i)}function Xa(i){this[K].emit("pong",i)}function pn(i){i.resume()}function mn(){let i=this[K];this.removeListener("close",mn),this.removeListener("data",Ci),this.removeListener("end",gn),i._readyState=P.CLOSING;let e;!this._readableState.endEmitted&&!i._closeFrameReceived&&!i._receiver._writableState.errorEmitted&&(e=i._socket.read())!==null&&i._receiver.write(e),i._receiver.end(),this[K]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",ln),i._receiver.on("finish",ln))}function Ci(i){this[K]._receiver.write(i)||this.pause()}function gn(){let i=this[K];i._readyState=P.CLOSING,i._receiver.end(),this.end()}function yn(){let i=this[K];this.removeListener("error",yn),this.on("error",hn),i&&(i._readyState=P.CLOSING,this.destroy())}});var En=T((Vf,_n)=>{"use strict";var{tokenChars:Ja}=Rt();function Qa(i){let e=new Set,t=-1,r=-1,s=0;for(s;s<i.length;s++){let o=i.charCodeAt(s);if(r===-1&&Ja[o]===1)t===-1&&(t=s);else if(s!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=s);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${s}`);r===-1&&(r=s);let a=i.slice(t,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=i.slice(t,s);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}_n.exports={parse:Qa}});var An=T((zf,Nn)=>{"use strict";var Za=w("events"),Si=w("http"),jf=w("https"),Hf=w("net"),Gf=w("tls"),{createHash:ec}=w("crypto"),bn=vr(),Me=kt(),tc=En(),ic=Cr(),{GUID:rc,kWebSocket:sc}=Re(),nc=/^[+/0-9A-Za-z]{22}==$/,xn=0,Cn=1,wn=2,Sr=class extends Za{constructor(e,t){if(super(),e=b({maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ic},e),e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Si.createServer((r,s)=>{let n=Si.STATUS_CODES[426];s.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),s.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=oc(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,n,o)=>{this.handleUpgrade(s,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=xn}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===wn){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Lt,this);return}if(e&&this.once("close",e),this._state!==Cn)if(this._state=Cn,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Lt,this):process.nextTick(Lt,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Lt(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,s){t.on("error",Sn);let n=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){qe(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){qe(this,e,t,400,"Invalid Upgrade header");return}if(!n||!nc.test(n)){qe(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){qe(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Ft(t,400);return}let a=e.headers["sec-websocket-protocol"],c=new Set;if(a!==void 0)try{c=tc.parse(a)}catch(h){qe(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&u!==void 0){let h=new Me(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let d=bn.parse(u);d[Me.extensionName]&&(h.accept(d[Me.extensionName]),f[Me.extensionName]=h)}catch(d){qe(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let h={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(h,(d,x,S,p)=>{if(!d)return Ft(t,x||401,S,p);this.completeUpgrade(f,n,c,e,t,r,s)});return}if(!this.options.verifyClient(h))return Ft(t,401)}this.completeUpgrade(f,n,c,e,t,r,s)}completeUpgrade(e,t,r,s,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[sc])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>xn)return Ft(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ec("sha1").update(t+rc).digest("base64")}`],f=new this.options.WebSocket(null);if(r.size){let h=this.options.handleProtocols?this.options.handleProtocols(r,s):r.values().next().value;h&&(u.push(`Sec-WebSocket-Protocol: ${h}`),f._protocol=h)}if(e[Me.extensionName]){let h=e[Me.extensionName].params,d=bn.format({[Me.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${d}`),f._extensions=e}this.emit("headers",u,s),n.write(u.concat(`\r
7
7
  `).join(`\r
8
- `)),n.removeListener("error",Rn),f.setSocket(n,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Bt,this)})),a(f,s)}};Tn.exports=Ni;function gc(r,e){for(let t of Object.keys(e))r.on(t,e[t]);return function(){for(let i of Object.keys(e))r.removeListener(i,e[i])}}function Bt(r){r._state=kn,r.emit("close")}function Rn(){this.destroy()}function Ut(r,e,t,i){t=t||Ar.STATUS_CODES[e],i=E({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},i),r.once("finish",r.destroy),r.end(`HTTP/1.1 ${e} ${Ar.STATUS_CODES[e]}\r
9
- `+Object.keys(i).map(s=>`${s}: ${i[s]}`).join(`\r
8
+ `)),n.removeListener("error",Sn),f.setSocket(n,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Lt,this)})),a(f,s)}};Nn.exports=Sr;function oc(i,e){for(let t of Object.keys(e))i.on(t,e[t]);return function(){for(let r of Object.keys(e))i.removeListener(r,e[r])}}function Lt(i){i._state=wn,i.emit("close")}function Sn(){this.destroy()}function Ft(i,e,t,r){t=t||Si.STATUS_CODES[e],r=b({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Si.STATUS_CODES[e]}\r
9
+ `+Object.keys(r).map(s=>`${s}: ${r[s]}`).join(`\r
10
10
  `)+`\r
11
11
  \r
12
- `+t)}function Ve(r,e,t,i,s){if(r.listenerCount("wsClientError")){let n=new Error(s);Error.captureStackTrace(n,Ve),r.emit("wsClientError",n,t,e)}else Ut(t,i,s)}});var Ri=k((Vh,Mn)=>{"use strict";function Nc(r){t.debug=t,t.default=t,t.coerce=c,t.disable=n,t.enable=s,t.enabled=o,t.humanize=Jr(),t.destroy=u,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let h=0;for(let d=0;d<f.length;d++)h=(h<<5)-h+f.charCodeAt(d),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(f){let h,d=null,C,S;function p(...v){if(!p.enabled)return;let N=p,A=Number(new Date),m=A-(h||A);N.diff=m,N.prev=h,N.curr=A,h=A,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let y=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(R,H)=>{if(R==="%%")return"%";y++;let z=t.formatters[H];if(typeof z=="function"){let pe=v[y];R=z.call(N,pe),v.splice(y,1),y--}return R}),t.formatArgs.call(N,v),(N.log||t.log).apply(N,v)}return p.namespace=f,p.useColors=t.useColors(),p.color=t.selectColor(f),p.extend=i,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(C!==t.namespaces&&(C=t.namespaces,S=t.enabled(f)),S),set:v=>{d=v}}),typeof t.init=="function"&&t.init(p),p}function i(f,h){let d=t(this.namespace+(typeof h=="undefined"?":":h)+f);return d.log=this.log,d}function s(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let h,d=(typeof f=="string"?f:"").split(/[\s,]+/),C=d.length;for(h=0;h<C;h++)d[h]&&(f=d[h].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function n(){let f=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),f}function o(f){if(f[f.length-1]==="*")return!0;let h,d;for(h=0,d=t.skips.length;h<d;h++)if(t.skips[h].test(f))return!1;for(h=0,d=t.names.length;h<d;h++)if(t.names[h].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Mn.exports=Nc});var qn=k((ee,Or)=>{"use strict";ee.formatArgs=Rc;ee.save=kc;ee.load=Tc;ee.useColors=Ac;ee.storage=Oc();ee.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();ee.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Ac(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Rc(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Or.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,i=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(t++,s==="%c"&&(i=t))}),r.splice(i,0,e)}ee.log=console.debug||console.log||(()=>{});function kc(r){try{r?ee.storage.setItem("debug",r):ee.storage.removeItem("debug")}catch(e){}}function Tc(){let r;try{r=ee.storage.getItem("debug")}catch(e){}return!r&&typeof process!="undefined"&&"env"in process&&(r=process.env.DEBUG),r}function Oc(){try{return localStorage}catch(r){}}Or.exports=Ri()(ee);var{formatters:Ic}=Or.exports;Ic.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var $n=k(($h,Vn)=>{"use strict";var Pc=w("os"),Wn=w("tty"),ae=Zr(),{env:W}=process,Pe;ae("no-color")||ae("no-colors")||ae("color=false")||ae("color=never")?Pe=0:(ae("color")||ae("colors")||ae("color=true")||ae("color=always"))&&(Pe=1);"FORCE_COLOR"in W&&(W.FORCE_COLOR==="true"?Pe=1:W.FORCE_COLOR==="false"?Pe=0:Pe=W.FORCE_COLOR.length===0?1:Math.min(parseInt(W.FORCE_COLOR,10),3));function ki(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Ti(r,e){if(Pe===0)return 0;if(ae("color=16m")||ae("color=full")||ae("color=truecolor"))return 3;if(ae("color=256"))return 2;if(r&&!e&&Pe===void 0)return 0;let t=Pe||0;if(W.TERM==="dumb")return t;if(process.platform==="win32"){let i=Pc.release().split(".");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if("CI"in W)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(i=>i in W)||W.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in W)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(W.TEAMCITY_VERSION)?1:0;if(W.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in W){let i=parseInt((W.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(W.TERM_PROGRAM){case"iTerm.app":return i>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(W.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(W.TERM)||"COLORTERM"in W?1:t}function Lc(r){let e=Ti(r,r&&r.isTTY);return ki(e)}Vn.exports={supportsColor:Lc,stdout:ki(Ti(!0,Wn.isatty(1))),stderr:ki(Ti(!0,Wn.isatty(2)))}});var jn=k((V,Pr)=>{"use strict";var Fc=w("tty"),Ir=w("util");V.init=Vc;V.log=Mc;V.formatArgs=Uc;V.save=qc;V.load=Wc;V.useColors=Bc;V.destroy=Ir.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");V.colors=[6,2,3,4,5,1];try{let r=$n();r&&(r.stderr||r).level>=2&&(V.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(r){}V.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,n)=>n.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),r[t]=i,r},{});function Bc(){return"colors"in V.inspectOpts?!!V.inspectOpts.colors:Fc.isatty(process.stderr.fd)}function Uc(r){let{namespace:e,useColors:t}=this;if(t){let i=this.color,s="\x1B[3"+(i<8?i:"8;5;"+i),n=` ${s};1m${e} \x1B[0m`;r[0]=n+r[0].split(`
12
+ `+t)}function qe(i,e,t,r,s){if(i.listenerCount("wsClientError")){let n=new Error(s);Error.captureStackTrace(n,qe),i.emit("wsClientError",n,t,e)}else Ft(t,r,s)}});var Nr=T((Rh,Fn)=>{"use strict";function gc(i){t.debug=t,t.default=t,t.coerce=c,t.disable=n,t.enable=s,t.enabled=o,t.humanize=Ki(),t.destroy=u,Object.keys(i).forEach(f=>{t[f]=i[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let h=0;for(let d=0;d<f.length;d++)h=(h<<5)-h+f.charCodeAt(d),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(f){let h,d=null,x,S;function p(...v){if(!p.enabled)return;let N=p,A=Number(new Date),m=A-(h||A);N.diff=m,N.prev=h,N.curr=A,h=A,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let y=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(k,V)=>{if(k==="%%")return"%";y++;let G=t.formatters[V];if(typeof G=="function"){let ue=v[y];k=G.call(N,ue),v.splice(y,1),y--}return k}),t.formatArgs.call(N,v),(N.log||t.log).apply(N,v)}return p.namespace=f,p.useColors=t.useColors(),p.color=t.selectColor(f),p.extend=r,p.destroy=t.destroy,Object.defineProperty(p,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(x!==t.namespaces&&(x=t.namespaces,S=t.enabled(f)),S),set:v=>{d=v}}),typeof t.init=="function"&&t.init(p),p}function r(f,h){let d=t(this.namespace+(typeof h=="undefined"?":":h)+f);return d.log=this.log,d}function s(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let h,d=(typeof f=="string"?f:"").split(/[\s,]+/),x=d.length;for(h=0;h<x;h++)d[h]&&(f=d[h].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function n(){let f=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),f}function o(f){if(f[f.length-1]==="*")return!0;let h,d;for(h=0,d=t.skips.length;h<d;h++)if(t.skips[h].test(f))return!1;for(h=0,d=t.names.length;h<d;h++)if(t.names[h].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Fn.exports=gc});var Bn=T((Z,ki)=>{"use strict";Z.formatArgs=vc;Z.save=_c;Z.load=Ec;Z.useColors=yc;Z.storage=bc();Z.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Z.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function yc(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function vc(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+ki.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(t++,s==="%c"&&(r=t))}),i.splice(r,0,e)}Z.log=console.debug||console.log||(()=>{});function _c(i){try{i?Z.storage.setItem("debug",i):Z.storage.removeItem("debug")}catch(e){}}function Ec(){let i;try{i=Z.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function bc(){try{return localStorage}catch(i){}}ki.exports=Nr()(Z);var{formatters:xc}=ki.exports;xc.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Dn=T((W,Ti)=>{"use strict";var Cc=w("tty"),Ri=w("util");W.init=Tc;W.log=Ac;W.formatArgs=wc;W.save=kc;W.load=Rc;W.useColors=Sc;W.destroy=Ri.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");W.colors=[6,2,3,4,5,1];try{let i=Qi();i&&(i.stderr||i).level>=2&&(W.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(i){}W.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,n)=>n.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function Sc(){return"colors"in W.inspectOpts?!!W.inspectOpts.colors:Cc.isatty(process.stderr.fd)}function wc(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,s="\x1B[3"+(r<8?r:"8;5;"+r),n=` ${s};1m${e} \x1B[0m`;i[0]=n+i[0].split(`
13
13
  `).join(`
14
- `+n),r.push(s+"m+"+Pr.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=Dc()+e+" "+r[0]}function Dc(){return V.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Mc(...r){return process.stderr.write(Ir.formatWithOptions(V.inspectOpts,...r)+`
15
- `)}function qc(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function Wc(){return process.env.DEBUG}function Vc(r){r.inspectOpts={};let e=Object.keys(V.inspectOpts);for(let t=0;t<e.length;t++)r.inspectOpts[e[t]]=V.inspectOpts[e[t]]}Pr.exports=Ri()(V);var{formatters:Hn}=Pr.exports;Hn.o=function(r){return this.inspectOpts.colors=this.useColors,Ir.inspect(r,this.inspectOpts).split(`
16
- `).map(e=>e.trim()).join(" ")};Hn.O=function(r){return this.inspectOpts.colors=this.useColors,Ir.inspect(r,this.inspectOpts)}});var qt=k((Hh,Oi)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Oi.exports=qn():Oi.exports=jn()});function Gi(r){return{all:r=r||new Map,on:function(e,t){var i=r.get(e);i?i.push(t):r.set(e,[t])},off:function(e,t){var i=r.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):r.set(e,[]))},emit:function(e,t){var i=r.get(e);i&&i.slice().map(function(s){s(t)}),(i=r.get("*"))&&i.slice().map(function(s){s(e,t)})}}}var Fe,Zt=class{constructor(){_(this,Fe);b(this,Fe,Gi())}on(e,t){return l(this,Fe).on(e,t),()=>{this.off(e,t)}}off(e,t){l(this,Fe).off(e,t)}emit(e,t){l(this,Fe).emit(e,t)}};Fe=new WeakMap;var L=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Se,Ke,we=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){_(this,Se,[]);_(this,Ke);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:i,data:s})=>{s?(this.onSessionSuccess(s),l(this,Se).forEach(a=>g(this,[a],function*({fn:n,resolve:o}){o(yield n())})),b(this,Se,[])):i&&(this.onSessionError(i),b(this,Ke,i),l(this,Se).forEach(({resolve:n})=>{n({error:new L("Failed to initialize session, please contact the support",i)})}),b(this,Se,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return g(this,null,function*(){return this._inboxService.isSessionInitialized?e():l(this,Ke)?Promise.resolve({error:new L("Failed to initialize session, please contact the support",l(this,Ke))}):new Promise((t,i)=>{l(this,Se).push({fn:e,resolve:t,reject:i})})})}};Se=new WeakMap,Ke=new WeakMap;var X,se,j=class{constructor(e,t,i){_(this,X);_(this,se);b(this,X,t),b(this,se,i),this.id=e.id,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isArchived=e.isArchived,this.createdAt=e.createdAt,this.readAt=e.readAt,this.archivedAt=e.archivedAt,this.avatar=e.avatar,this.primaryAction=e.primaryAction,this.secondaryAction=e.secondaryAction,this.channelType=e.channelType,this.tags=e.tags,this.redirect=e.redirect,this.data=e.data}read(){return er({emitter:l(this,X),apiService:l(this,se),args:{notification:this}})}unread(){return tr({emitter:l(this,X),apiService:l(this,se),args:{notification:this}})}archive(){return rr({emitter:l(this,X),apiService:l(this,se),args:{notification:this}})}unarchive(){return ir({emitter:l(this,X),apiService:l(this,se),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ye({emitter:l(this,X),apiService:l(this,se),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ye({emitter:l(this,X),apiService:l(this,se),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Xe({emitter:l(this,X),apiService:l(this,se),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Xe({emitter:l(this,X),apiService:l(this,se),args:{notification:this},actionType:"secondary"})}on(e,t){let i=l(this,X).on(e,t);return()=>{i()}}off(e,t){l(this,X).off(e,t)}};X=new WeakMap,se=new WeakMap;var er=i=>g(void 0,[i],function*({emitter:r,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Je(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0},{emitter:r,apiService:e});try{r.emit("notification.read.pending",{args:t,data:n});let o=yield e.read(s),a=new j(o,r,e);return r.emit("notification.read.resolved",{args:t,data:a}),{data:a}}catch(o){return r.emit("notification.read.resolved",{args:t,error:o}),{error:new L("Failed to read notification",o)}}}),tr=i=>g(void 0,[i],function*({emitter:r,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Je(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:r,apiService:e});try{r.emit("notification.unread.pending",{args:t,data:n});let o=yield e.unread(s),a=new j(o,r,e);return r.emit("notification.unread.resolved",{args:t,data:a}),{data:a}}catch(o){return r.emit("notification.unread.resolved",{args:t,error:o}),{error:new L("Failed to unread notification",o)}}}),rr=i=>g(void 0,[i],function*({emitter:r,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Je(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()},{emitter:r,apiService:e});try{r.emit("notification.archive.pending",{args:t,data:n});let o=yield e.archive(s),a=new j(o,r,e);return r.emit("notification.archive.resolved",{args:t,data:a}),{data:a}}catch(o){return r.emit("notification.archive.resolved",{args:t,error:o}),{error:new L("Failed to archive notification",o)}}}),ir=i=>g(void 0,[i],function*({emitter:r,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Je(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:r,apiService:e});try{r.emit("notification.unarchive.pending",{args:t,data:n});let o=yield e.unarchive(s),a=new j(o,r,e);return r.emit("notification.unarchive.resolved",{args:t,data:a}),{data:a}}catch(o){return r.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new L("Failed to unarchive notification",o)}}}),Ye=s=>g(void 0,[s],function*({emitter:r,apiService:e,args:t,actionType:i}){let n=i==="primary"?{primaryAction:O(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:O(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:a}=Je(t,n,{emitter:r,apiService:e});try{r.emit("notification.complete_action.pending",{args:t,data:a});let c=yield e.completeAction({actionType:i,notificationId:o}),u=new j(c,r,e);return r.emit("notification.complete_action.resolved",{args:t,data:u}),{data:u}}catch(c){return r.emit("notification.complete_action.resolved",{args:t,error:c}),{error:new L(`Failed to complete ${i} action on the notification`,c)}}}),Xe=s=>g(void 0,[s],function*({emitter:r,apiService:e,args:t,actionType:i}){let n=i==="primary"?{primaryAction:O(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:O(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:a}=Je(t,n,{emitter:r,apiService:e});try{r.emit("notification.revert_action.pending",{args:t,data:a});let c=yield e.revertAction({actionType:i,notificationId:o}),u=new j(c,r,e);return r.emit("notification.revert_action.resolved",{args:t,data:u}),{data:u}}catch(c){return r.emit("notification.revert_action.resolved",{args:t,error:c}),{error:new L("Failed to fetch notifications",c)}}}),Je=(r,e,t)=>"notification"in r?{notificationId:r.notification.id,optimisticValue:new j(E(E({},r.notification),e),t.emitter,t.apiService)}:{notificationId:r.notificationId},zi=s=>g(void 0,[s],function*({emitter:r,inboxService:e,notificationsCache:t,tags:i}){try{let o=t.getUniqueNotifications({tags:i}).map(a=>new j(O(E({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),r,e));return r.emit("notifications.read_all.pending",{args:{tags:i},data:o}),yield e.readAll({tags:i}),r.emit("notifications.read_all.resolved",{args:{tags:i},data:o}),{}}catch(n){return r.emit("notifications.read_all.resolved",{args:{tags:i},error:n}),{error:new L("Failed to read all notifications",n)}}}),Ki=s=>g(void 0,[s],function*({emitter:r,inboxService:e,notificationsCache:t,tags:i}){try{let o=t.getUniqueNotifications({tags:i}).map(a=>new j(O(E({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),r,e));return r.emit("notifications.archive_all.pending",{args:{tags:i},data:o}),yield e.archiveAll({tags:i}),r.emit("notifications.archive_all.resolved",{args:{tags:i},data:o}),{}}catch(n){return r.emit("notifications.archive_all.resolved",{args:{tags:i},error:n}),{error:new L("Failed to archive all notifications",n)}}}),Yi=s=>g(void 0,[s],function*({emitter:r,inboxService:e,notificationsCache:t,tags:i}){try{let o=t.getUniqueNotifications({tags:i,read:!0}).map(a=>new j(O(E({},a),{isArchived:!0,archivedAt:new Date().toISOString()}),r,e));return r.emit("notifications.archive_all_read.pending",{args:{tags:i},data:o}),yield e.archiveAllRead({tags:i}),r.emit("notifications.archive_all_read.resolved",{args:{tags:i},data:o}),{}}catch(n){return r.emit("notifications.archive_all_read.resolved",{args:{tags:i},error:n}),{error:new L("Failed to archive all read notifications",n)}}});var Xi=(r,e)=>r===e?!0:!r||!e||r.length!==e.length?!1:r.every((t,i)=>t===e[i]);var bl=["seen","unseen"],Cl=["read","unread"],Hr=(r,e)=>Xi(r,e)||!r&&(e==null?void 0:e.length)===0||(r==null?void 0:r.length)===0&&!e,jr=(r,e)=>Hr(r.tags,e.tags)&&r.read===e.read&&r.archived===e.archived;var ce,Qe=class{constructor(){_(this,ce);b(this,ce,new Map)}get(e){return l(this,ce).get(e)}getValues(){return Array.from(l(this,ce).values())}entries(){return Array.from(l(this,ce).entries())}keys(){return Array.from(l(this,ce).keys())}set(e,t){l(this,ce).set(e,t)}remove(e){l(this,ce).delete(e)}clear(){l(this,ce).clear()}};ce=new WeakMap;var Ji=({tags:r,read:e,archived:t,limit:i,offset:s,after:n})=>Object.entries({tags:r,read:e,archived:t,limit:i,offset:s,after:n}).filter(([o,a])=>a!=null&&!(Array.isArray(a)&&a.length===0)).reduce((o,[a,c])=>(o[a]=c,o),{}),Gr=({tags:r,read:e,archived:t,limit:i,offset:s,after:n})=>JSON.stringify(Ji({tags:r,read:e,archived:t,limit:i,offset:s,after:n})),bo=({tags:r,read:e,archived:t})=>JSON.stringify(Ji({tags:r,read:e,archived:t})),Ze=r=>JSON.parse(r),Co=["notification.read.pending","notification.read.resolved","notification.unread.pending","notification.unread.resolved","notification.complete_action.pending","notification.complete_action.resolved","notification.revert_action.pending","notification.revert_action.resolved","notifications.read_all.pending","notifications.read_all.resolved"],xo=["notification.archive.pending","notification.unarchive.pending","notifications.archive_all.pending","notifications.archive_all_read.pending"],Ne,D,gt=class{constructor({emitter:e}){_(this,Ne);_(this,D);this.updateNotification=(e,t)=>{let i=l(this,D).get(e);if(!i)return!1;let s=i.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...i.notifications];return n[s]=t,l(this,D).set(e,O(E({},i),{notifications:n})),!0};this.removeNotification=(e,t)=>{let i=l(this,D).get(e);if(!i)return!1;let s=i.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...i.notifications];return n.splice(s,1),l(this,D).set(e,O(E({},i),{notifications:n})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>({data:t})=>{if(!t)return;let i=Array.isArray(t)?t:[t],s=new Set;l(this,D).keys().forEach(n=>{i.forEach(o=>{let a=!1;e?a=this.removeNotification(n,o):a=this.updateNotification(n,o),a&&s.add(bo(Ze(n)))})}),s.forEach(n=>{let o=this.getAggregated(Ze(n));l(this,Ne).emit("notifications.list.updated",{data:o})})};b(this,Ne,e),Co.forEach(t=>{l(this,Ne).on(t,this.handleNotificationEvent())}),xo.forEach(t=>{l(this,Ne).on(t,this.handleNotificationEvent({remove:!0}))}),b(this,D,new Qe)}getAggregated(e){return l(this,D).keys().filter(i=>{let s=Ze(i);return jr(s,e)}).map(i=>l(this,D).get(i)).reduce((i,s)=>s?{hasMore:s.hasMore,filter:s.filter,notifications:[...i.notifications,...s.notifications]}:i,{hasMore:!1,filter:{},notifications:[]})}has(e){return l(this,D).get(Gr(e))!==void 0}set(e,t){l(this,D).set(Gr(e),t)}update(e,t){this.set(e,t);let i=this.getAggregated(Ze(Gr(e)));l(this,Ne).emit("notifications.list.updated",{data:i})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,read:e.read,archived:e.archived})}getUniqueNotifications({tags:e,read:t}){let i=l(this,D).keys(),s=new Map;return i.forEach(n=>{let o=Ze(n);if(Hr(e,o.tags)){let a=l(this,D).get(n);if(!a)return;a.notifications.filter(c=>typeof t=="undefined"||t===c.isRead).forEach(c=>s.set(c.id,c))}}),Array.from(s.values())}clear(e){l(this,D).keys().forEach(i=>{jr(Ze(i),e)&&l(this,D).remove(i)})}clearAll(){l(this,D).clear()}};Ne=new WeakMap,D=new WeakMap;var yt,sr=class extends we{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:i});_(this,yt);this.cache=new gt({emitter:s}),b(this,yt,t)}list(){return g(this,arguments,function*(s={}){var n=s,{limit:t=10}=n,i=ji(n,["limit"]);return this.callWithSession(()=>g(this,null,function*(){let o=E({limit:t},i);try{let a="useCache"in o?o.useCache:l(this,yt),c=a?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:c}),!c){let u=yield this._inboxService.fetchNotifications(E({limit:t},i));c={hasMore:u.hasMore,filter:u.filter,notifications:u.data.map(f=>new j(f,this._emitter,this._inboxService))},a&&(this.cache.set(o,c),c=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:c}),{data:c}}catch(a){return this._emitter.emit("notifications.list.resolved",{args:o,error:a}),{error:new L("Failed to fetch notifications",a)}}}))})}count(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){let i=t&&"filters"in t?t.filters:[E({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let s=yield this._inboxService.count({filters:i}),n=t&&"filters"in t?{counts:s.data}:s.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:n}),{data:n}}catch(s){return this._emitter.emit("notifications.count.resolved",{args:t,error:s}),{error:new L("Failed to count notifications",s)}}}))})}read(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return er({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return tr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return rr({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ir({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ye({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ye({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Xe({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Xe({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return zi({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t})}))})}archiveAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Ki({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t})}))})}archiveAllRead(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Yi({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t})}))})}clearCache({filter:t}={}){return t?this.cache.clear(t!=null?t:{}):this.cache.clearAll()}};yt=new WeakMap;var Be,vt,Ae,nr=class{constructor(e,t,i){_(this,Be);_(this,vt);_(this,Ae);b(this,Be,i),b(this,vt,t),b(this,Ae,e)}initialize(){return g(this,null,function*(){try{let{applicationIdentifier:e,subscriberId:t,subscriberHash:i}=l(this,Ae);l(this,Be).emit("session.initialize.pending",{args:l(this,Ae)});let s=yield l(this,vt).initializeSession({applicationIdentifier:e,subscriberId:t,subscriberHash:i});l(this,Be).emit("session.initialize.resolved",{args:l(this,Ae),data:s})}catch(e){l(this,Be).emit("session.initialize.resolved",{args:l(this,Ae),error:e})}})}};Be=new WeakMap,vt=new WeakMap,Ae=new WeakMap;var Qi=n=>g(void 0,[n],function*({emitter:r,apiService:e,cache:t,useCache:i,args:s}){let{workflowId:o,channelPreferences:a}=s;try{r.emit("preference.update.pending",{args:s,data:s.preference?new Re(O(E({},s.preference),{channels:E(E({},s.preference.channels),a)}),{emitterInstance:r,inboxServiceInstance:e,cache:t,useCache:i}):void 0});let c;o?c=yield e.updateWorkflowPreferences({workflowId:o,channelPreferences:a}):(So({emitter:r,apiService:e,cache:t,useCache:i,args:s}),c=yield e.updateGlobalPreferences(a));let u=new Re(c,{emitterInstance:r,inboxServiceInstance:e,cache:t,useCache:i});return r.emit("preference.update.resolved",{args:s,data:u}),{data:u}}catch(c){return r.emit("preference.update.resolved",{args:s,error:c}),{error:new L("Failed to fetch notifications",c)}}}),So=({emitter:r,apiService:e,cache:t,useCache:i,args:s})=>{let n=i?t==null?void 0:t.getAll({}):void 0;n==null||n.forEach(o=>{var a;if(o.level==="template"){let c=O(E({},o),{channels:Object.entries(o.channels).reduce((f,[h,d])=>{var S;let C=h;return f[C]=(S=s.channelPreferences[C])!=null?S:d,f},{})}),u=s.preference?new Re(c,{emitterInstance:r,inboxServiceInstance:e,cache:t,useCache:i}):void 0;u&&r.emit("preference.update.pending",{args:{workflowId:(a=o.workflow)==null?void 0:a.id,channelPreferences:u.channels},data:u})}})};var _t,Et,bt,Ct,Re=class{constructor(e,{emitterInstance:t,inboxServiceInstance:i,cache:s,useCache:n}){_(this,_t);_(this,Et);_(this,bt);_(this,Ct);b(this,_t,t),b(this,Et,i),b(this,bt,s),b(this,Ct,n),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow}update({channelPreferences:e}){var t;return Qi({emitter:l(this,_t),apiService:l(this,Et),cache:l(this,bt),useCache:l(this,Ct),args:{workflowId:(t=this.workflow)==null?void 0:t.id,channelPreferences:e,preference:{level:this.level,enabled:this.enabled,channels:this.channels,workflow:this.workflow}}})}};_t=new WeakMap,Et=new WeakMap,bt=new WeakMap,Ct=new WeakMap;var wo=["preference.update.pending","preference.update.resolved"],No=({tags:r})=>Object.entries({tags:r}).reduce((e,[t,i])=>(i==null||Array.isArray(i)&&i.length===0||(e[t]=i),e),{}),zr=({tags:r})=>JSON.stringify(No({tags:r})),et,ne,or=class{constructor({emitterInstance:e}){_(this,et);_(this,ne);this.updatePreference=(e,t)=>{let i=l(this,ne).get(e);if(!i)return!1;let s=i.findIndex(o=>{var a,c;return((a=o.workflow)==null?void 0:a.id)===((c=t.workflow)==null?void 0:c.id)||o.level===t.level&&t.level==="global"});if(s===-1)return!1;let n=[...i];return n[s]=t,l(this,ne).set(e,n),!0};this.handlePreferenceEvent=({data:e})=>{e&&l(this,ne).keys().forEach(t=>{let i=this.updatePreference(t,e),s=l(this,ne).get(t);!i||!s||l(this,et).emit("preferences.list.updated",{data:s})})};b(this,et,e),wo.forEach(t=>{l(this,et).on(t,this.handlePreferenceEvent)}),b(this,ne,new Qe)}has(e){return l(this,ne).get(zr(e))!==void 0}set(e,t){l(this,ne).set(zr(e),t)}getAll(e){if(this.has(e))return l(this,ne).get(zr(e))}clearAll(){l(this,ne).clear()}};et=new WeakMap,ne=new WeakMap;var Ue,ar=class extends we{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:i});_(this,Ue);this.cache=new or({emitterInstance:this._emitter}),b(this,Ue,t)}list(){return g(this,arguments,function*(t={}){return this.callWithSession(()=>g(this,null,function*(){try{let i=l(this,Ue)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:i}),i||(i=(yield this._inboxService.fetchPreferences(t.tags)).map(n=>new Re(n,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:l(this,Ue)})),l(this,Ue)&&(this.cache.set(t,i),i=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:i}),{data:i}}catch(i){throw this._emitter.emit("preferences.list.resolved",{args:t,error:i}),i}}))})}};Ue=new WeakMap;var le=Object.create(null);le.open="0";le.close="1";le.ping="2";le.pong="3";le.message="4";le.upgrade="5";le.noop="6";var xt=Object.create(null);Object.keys(le).forEach(r=>{xt[le[r]]=r});var St={type:"error",data:"parser error"};var wt=({type:r,data:e},t,i)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?i(t?e:"b"+Zi(e,!0).toString("base64")):i(le[r]+(e||"")),Zi=(r,e)=>Buffer.isBuffer(r)||r instanceof Uint8Array&&!e?r:r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),Kr;function es(r,e){if(r.data instanceof ArrayBuffer||ArrayBuffer.isView(r.data))return e(Zi(r.data,!1));wt(r,!0,t=>{Kr||(Kr=new TextEncoder),e(Kr.encode(t))})}var Nt=(r,e)=>{if(typeof r!="string")return{type:"message",data:ts(r,e)};let t=r.charAt(0);if(t==="b"){let i=Buffer.from(r.substring(1),"base64");return{type:"message",data:ts(i,e)}}return xt[t]?r.length>1?{type:xt[t],data:r.substring(1)}:{type:xt[t]}:St},ts=(r,e)=>{switch(e){case"arraybuffer":return r instanceof ArrayBuffer?r:Buffer.isBuffer(r)?r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength):r.buffer;case"nodebuffer":default:return Buffer.isBuffer(r)?r:Buffer.from(r)}};var rs="",is=(r,e)=>{let t=r.length,i=new Array(t),s=0;r.forEach((n,o)=>{wt(n,!1,a=>{i[o]=a,++s===t&&e(i.join(rs))})})},ss=(r,e)=>{let t=r.split(rs),i=[];for(let s=0;s<t.length;s++){let n=Nt(t[s],e);if(i.push(n),n.type==="error")break}return i};function ns(){return new TransformStream({transform(r,e){es(r,t=>{let i=t.length,s;if(i<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,i);else if(i<65536){s=new Uint8Array(3);let n=new DataView(s.buffer);n.setUint8(0,126),n.setUint16(1,i)}else{s=new Uint8Array(9);let n=new DataView(s.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(i))}r.data&&typeof r.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var Yr;function cr(r){return r.reduce((e,t)=>e+t.length,0)}function lr(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),i=0;for(let s=0;s<e;s++)t[s]=r[0][i++],i===r[0].length&&(r.shift(),i=0);return r.length&&i<r[0].length&&(r[0]=r[0].slice(i)),t}function os(r,e){Yr||(Yr=new TextDecoder);let t=[],i=0,s=-1,n=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(i===0){if(cr(t)<1)break;let c=lr(t,1);n=(c[0]&128)===128,s=c[0]&127,s<126?i=3:s===126?i=1:i=2}else if(i===1){if(cr(t)<2)break;let c=lr(t,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),i=3}else if(i===2){if(cr(t)<8)break;let c=lr(t,8),u=new DataView(c.buffer,c.byteOffset,c.length),f=u.getUint32(0);if(f>Math.pow(2,21)-1){a.enqueue(St);break}s=f*Math.pow(2,32)+u.getUint32(4),i=3}else{if(cr(t)<s)break;let c=lr(t,s);a.enqueue(Nt(n?c:Yr.decode(c),e)),i=0}if(s===0||s>r){a.enqueue(St);break}}}})}var Xr=4;function T(r){if(r)return Ao(r)}function Ao(r){for(var e in T.prototype)r[e]=T.prototype[e];return r}T.prototype.on=T.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};T.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};T.prototype.off=T.prototype.removeListener=T.prototype.removeAllListeners=T.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var i,s=0;s<t.length;s++)if(i=t[s],i===e||i.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};T.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,s=t.length;i<s;++i)t[i].apply(this,e)}return this};T.prototype.emitReserved=T.prototype.emit;T.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};T.prototype.hasListeners=function(r){return!!this.listeners(r).length};var fe=global;function fr(r,...e){return e.reduce((t,i)=>(r.hasOwnProperty(i)&&(t[i]=r[i]),t),{})}var Ro=fe.setTimeout,ko=fe.clearTimeout;function ve(r,e){e.useNativeTimers?(r.setTimeoutFn=Ro.bind(fe),r.clearTimeoutFn=ko.bind(fe)):(r.setTimeoutFn=fe.setTimeout.bind(fe),r.clearTimeoutFn=fe.clearTimeout.bind(fe))}var To=1.33;function as(r){return typeof r=="string"?Oo(r):Math.ceil((r.byteLength||r.size)*To)}function Oo(r){let e=0,t=0;for(let i=0,s=r.length;i<s;i++)e=r.charCodeAt(i),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(i++,t+=4);return t}var _s=K(Me(),1);function ys(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function vs(r){let e={},t=r.split("&");for(let i=0,s=t.length;i<s;i++){let n=t[i].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var ra=(0,_s.default)("engine.io-client:transport"),ri=class extends Error{constructor(e,t,i){super(e),this.description=t,this.context=i,this.type="TransportError"}},_e=class extends T{constructor(e){super(),this.writable=!1,ve(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,i){return super.emitReserved("error",new ri(e,t,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):ra("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Nt(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=ys(e);return t.length?"?"+t:""}};var ks=K(Me(),1);var xs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),ii=64,ia={},Es=0,gr=0,bs;function Cs(r){let e="";do e=xs[r%ii]+e,r=Math.floor(r/ii);while(r>0);return e}function yr(){let r=Cs(+new Date);return r!==bs?(Es=0,bs=r):r+"."+Cs(Es++)}for(;gr<ii;gr++)ia[xs[gr]]=gr;var oi=K(Ns(),1),ai=oi.default||oi;function As(){return new ni}function na(r){let e=r.split("; "),t=e[0].indexOf("=");if(t===-1)return;let i=e[0].substring(0,t).trim();if(!i.length)return;let s=e[0].substring(t+1).trim();s.charCodeAt(0)===34&&(s=s.slice(1,-1));let n={name:i,value:s};for(let o=1;o<e.length;o++){let a=e[o].split("=");if(a.length!==2)continue;let c=a[0].trim(),u=a[1].trim();switch(c){case"Expires":n.expires=new Date(u);break;case"Max-Age":let f=new Date;f.setUTCSeconds(f.getUTCSeconds()+parseInt(u,10)),n.expires=f;break;default:}}return n}var ni=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(i=>{let s=na(i);s&&this.cookies.set(s.name,s)})}addCookies(e){let t=[];this.cookies.forEach((i,s)=>{var n;((n=i.expires)===null||n===void 0?void 0:n.getTime())<Date.now()?this.cookies.delete(s):t.push(`${s}=${i.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var J=(0,ks.default)("engine.io-client:polling");function oa(){}var aa=function(){return new ai({xdomain:!1}).responseType!=null}(),vr=class extends _e{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let i=location.protocol==="https:",s=location.port;s||(s=i?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||s!==e.port}let t=e&&e.forceBase64;this.supportsBinary=aa&&!t,this.opts.withCredentials&&(this.cookieJar=As())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{J("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let i=0;this.polling&&(J("we are currently polling - waiting to pause"),i++,this.once("pollComplete",function(){J("pre-pause polling complete"),--i||t()})),this.writable||(J("we are currently writing - waiting to pause"),i++,this.once("drain",function(){J("pre-pause writing complete"),--i||t()}))}else t()}poll(){J("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){J("polling got data %s",e);let t=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};ss(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():J('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{J("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(J("transport open - closing"),e()):(J("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,is(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=yr()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ke(this.uri(),e)}doWrite(e,t){let i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",(s,n)=>{this.onError("xhr post error",s,n)})}doPoll(){J("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,i)=>{this.onError("xhr poll error",t,i)}),this.pollXhr=e}},ke=class r extends T{constructor(e,t){super(),ve(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;let t=fr(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let i=this.xhr=new ai(t);try{J("xhr open %s: %s",this.method,this.uri),i.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let s in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(s)&&i.setRequestHeader(s,this.opts.extraHeaders[s])}}catch(s){}if(this.method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(s){}try{i.setRequestHeader("Accept","*/*")}catch(s){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(i.timeout=this.opts.requestTimeout),i.onreadystatechange=()=>{var s;i.readyState===3&&((s=this.opts.cookieJar)===null||s===void 0||s.parseCookies(i)),i.readyState===4&&(i.status===200||i.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof i.status=="number"?i.status:0)},0))},J("xhr data %s",this.data),i.send(this.data)}catch(s){this.setTimeoutFn(()=>{this.onError(s)},0);return}typeof document!="undefined"&&(this.index=r.requestsCount++,r.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr=="undefined"||this.xhr===null)){if(this.xhr.onreadystatechange=oa,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete r.requests[this.index],this.xhr=null}}onLoad(){let e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};ke.requestsCount=0;ke.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",Rs);else if(typeof addEventListener=="function"){let r="onpagehide"in fe?"pagehide":"unload";addEventListener(r,Rs,!1)}}function Rs(){for(let r in ke.requests)ke.requests.hasOwnProperty(r)&&ke.requests[r].abort()}var yc=K(Ps(),1),vc=K(gi(),1),_c=K(vi(),1),In=K(wi(),1),Ec=K(On(),1);var Pn=In.default;var Dt=Pn,Rr=!1,Ln="nodebuffer",$e=process.nextTick;var Bn=K(Me(),1);var bc=(0,Bn.default)("engine.io-client:websocket"),Fn=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",kr=class extends _e{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,i=Fn?{}:fr(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=Rr&&!Fn?t?new Dt(e,t):new Dt(e):new Dt(e,t,i)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],s=t===e.length-1;wt(i,this.supportsBinary,n=>{let o={};Rr||(i.options&&(o.compress=i.options.compress),this.opts.perMessageDeflate&&(typeof n=="string"?Buffer.byteLength(n):n.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{Rr?this.ws.send(n):this.ws.send(n,o)}catch(a){bc("websocket closed before onclose event")}s&&$e(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=yr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Dt}};var Un=K(Me(),1),Mt=(0,Un.default)("engine.io-client:webtransport"),Tr=class extends _e{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Mt("transport closed gracefully"),this.onClose()}).catch(e=>{Mt("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=os(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(t).getReader(),s=ns();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();let n=()=>{i.read().then(({done:a,value:c})=>{if(a){Mt("session is closed");return}Mt("received chunk: %o",c),this.onPacket(c),n()}).catch(a=>{Mt("an error occurred while reading: %s",a)})};n();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],s=t===e.length-1;this.writer.write(i).then(()=>{s&&$e(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var Ai={websocket:kr,webtransport:Tr,polling:vr};var Cc=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,xc=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ct(r){let e=r,t=r.indexOf("["),i=r.indexOf("]");t!=-1&&i!=-1&&(r=r.substring(0,t)+r.substring(t,i).replace(/:/g,";")+r.substring(i,r.length));let s=Cc.exec(r||""),n={},o=14;for(;o--;)n[xc[o]]=s[o]||"";return t!=-1&&i!=-1&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=Sc(n,n.path),n.queryKey=wc(n,n.query),n}function Sc(r,e){let t=/\/{2,9}/g,i=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function wc(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,s,n){s&&(t[s]=n)}),t}var Dn=K(Me(),1);var I=(0,Dn.default)("engine.io-client:socket"),He=class r extends T{constructor(e,t={}){super(),this.binaryType=Ln,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=ct(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=ct(t.host).host),ve(this,t),this.secure=t.secure!=null?t.secure:typeof location!="undefined"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=t.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=vs(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){I('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Xr,t.transport=e,this.id&&(t.sid=this.id);let i=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return I("options: %j",i),new Ai[e](i)}open(){let e;if(this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){I("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){I("setting transport %s",e.name),this.transport&&(I("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){I('probing transport "%s"',e);let t=this.createTransport(e),i=!1;r.priorWebsocketSuccess=!1;let s=()=>{i||(I('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",h=>{if(!i)if(h.type==="pong"&&h.data==="probe"){if(I('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;r.priorWebsocketSuccess=t.name==="websocket",I('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{i||this.readyState!=="closed"&&(I("changing transport and sending upgrade packet"),f(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{I('probe transport "%s" failed',e);let d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function n(){i||(i=!0,f(),t.close(),t=null)}let o=h=>{let d=new Error("probe error: "+h);d.transport=t.name,n(),I('probe transport "%s" failed because of error: %s',e,h),this.emitReserved("upgradeError",d)};function a(){o("transport closed")}function c(){o("socket closed")}function u(h){t&&h.name!==t.name&&(I('"%s" works - aborting "%s"',h.name,t.name),n())}let f=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",u)};t.once("open",s),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||t.open()},200):t.open()}onOpen(){if(I("socket open"),this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){I("starting upgrade probes");let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(I('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else I('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();I("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i<this.writeBuffer.length;i++){let s=this.writeBuffer[i].data;if(s&&(t+=as(s)),i>0&&t>this.maxPayload)return I("only send %d out of %d packets",i,this.writeBuffer.length),this.writeBuffer.slice(0,i);t+=2}return I("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,i){return this.sendPacket("message",e,t,i),this}send(e,t,i){return this.sendPacket("message",e,t,i),this}sendPacket(e,t,i,s){if(typeof t=="function"&&(s=t,t=void 0),typeof i=="function"&&(s=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;let n={type:e,data:t,options:i};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this.onClose("forced close"),I("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}onError(e){I("socket error %j",e),r.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(I('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],i=0,s=e.length;for(;i<s;i++)~this.transports.indexOf(e[i])&&t.push(e[i]);return t}};He.protocol=Xr;var Fh=He.protocol;var zn=K(qt(),1),Gn=(0,zn.default)("socket.io-client:url");function Kn(r,e="",t){let i=r;t=t||typeof location!="undefined"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(Gn("protocol-less url %s",r),typeof t!="undefined"?r=t.protocol+"//"+r:r="https://"+r),Gn("parse %s",r),i=ct(r)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";let n=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+n+":"+i.port+e,i.href=i.protocol+"://"+n+(t&&t.port===i.port?"":":"+i.port),i}var Di={};_o(Di,{Decoder:()=>Bi,Encoder:()=>Fi,PacketType:()=>x,protocol:()=>eo});var $c=typeof ArrayBuffer=="function",Hc=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Yn=Object.prototype.toString,jc=typeof Blob=="function"||typeof Blob!="undefined"&&Yn.call(Blob)==="[object BlobConstructor]",Gc=typeof File=="function"||typeof File!="undefined"&&Yn.call(File)==="[object FileConstructor]";function Vt(r){return $c&&(r instanceof ArrayBuffer||Hc(r))||jc&&r instanceof Blob||Gc&&r instanceof File}function Wt(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,i=r.length;t<i;t++)if(Wt(r[t]))return!0;return!1}if(Vt(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return Wt(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&Wt(r[t]))return!0;return!1}function Xn(r){let e=[],t=r.data,i=r;return i.data=Ii(t,e),i.attachments=e.length,{packet:i,buffers:e}}function Ii(r,e){if(!r)return r;if(Vt(r)){let t={_placeholder:!0,num:e.length};return e.push(r),t}else if(Array.isArray(r)){let t=new Array(r.length);for(let i=0;i<r.length;i++)t[i]=Ii(r[i],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){let t={};for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=Ii(r[i],e));return t}return r}function Jn(r,e){return r.data=Pi(r.data,e),delete r.attachments,r}function Pi(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=Pi(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=Pi(r[t],e));return r}var Zn=K(Me(),1),Li=(0,Zn.default)("socket.io-parser"),zc=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],eo=5,x;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(x||(x={}));var Fi=class{constructor(e){this.replacer=e}encode(e){return Li("encoding packet %j",e),(e.type===x.EVENT||e.type===x.ACK)&&Wt(e)?this.encodeAsBinary({type:e.type===x.EVENT?x.BINARY_EVENT:x.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===x.BINARY_EVENT||e.type===x.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),Li("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Xn(e),i=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(i),s}};function Qn(r){return Object.prototype.toString.call(r)==="[object Object]"}var Bi=class r extends T{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let i=t.type===x.BINARY_EVENT;i||t.type===x.BINARY_ACK?(t.type=i?x.EVENT:x.ACK,this.reconstructor=new Ui(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Vt(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,i={type:Number(e.charAt(0))};if(x[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===x.BINARY_EVENT||i.type===x.BINARY_ACK){let n=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(n,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");i.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););i.nsp=e.substring(n,t)}else i.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let n=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}i.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(r.isPayloadValid(i.type,n))i.data=n;else throw new Error("invalid payload")}return Li("decoded %s as %j",e,i),i}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case x.CONNECT:return Qn(t);case x.DISCONNECT:return t===void 0;case x.CONNECT_ERROR:return typeof t=="string"||Qn(t);case x.EVENT:case x.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&zc.indexOf(t[0])===-1);case x.ACK:case x.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Ui=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=Jn(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function te(r,e,t){return r.on(e,t),function(){r.off(e,t)}}var to=K(qt(),1),U=(0,to.default)("socket.io-client:socket"),Kc=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),lt=class extends T{constructor(e,t,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[te(e,"open",this.onopen.bind(this)),te(e,"packet",this.onpacket.bind(this)),te(e,"error",this.onerror.bind(this)),te(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Kc.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let i={type:x.EVENT,data:t};if(i.options={},i.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;U("emitting packet with ack id %d",o);let a=t.pop();this._registerAckCallback(o,a),i.id=o}let s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)?U("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i),this.flags={},this}_registerAckCallback(e,t){var i;let s=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(U("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));U("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(n),t.apply(this,[null,...o])}}emitWithAck(e,...t){let i=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((s,n)=>{t.push((o,a)=>i?o?n(o):s(a):s(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...n)=>i!==this._queue[0]?void 0:(s!==null?i.tryCount>this._opts.retries&&(U("packet [%d] is discarded after %d tries",i.id,i.tryCount),this._queue.shift(),t&&t(s)):(U("packet [%d] was successfully sent",i.id),this._queue.shift(),t&&t(null,...n)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(U("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){U("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,U("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){U("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:x.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){U("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case x.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case x.EVENT:case x.BINARY_EVENT:this.onevent(e);break;case x.ACK:case x.BINARY_ACK:this.onack(e);break;case x.DISCONNECT:this.ondisconnect();break;case x.CONNECT_ERROR:this.destroy();let i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){let t=e.data||[];U("emitting event %j",t),e.id!=null&&(U("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let i of t)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,i=!1;return function(...s){i||(i=!0,U("sending ack %j",s),t.packet({type:x.ACK,id:e,data:s}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(U("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):U("bad ack %s",e.id)}onconnect(e,t){U("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){U("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(U("performing disconnect (%s)",this.nsp),this.packet({type:x.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let i of t)i.apply(this,e.data)}}};function je(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}je.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=Math.floor(e*10)&1?r+t:r-t}return Math.min(r,this.max)|0};je.prototype.reset=function(){this.attempts=0};je.prototype.setMin=function(r){this.ms=r};je.prototype.setMax=function(r){this.max=r};je.prototype.setJitter=function(r){this.jitter=r};var ro=K(qt(),1),G=(0,ro.default)("socket.io-client:manager"),ft=class extends T{constructor(e,t){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,ve(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((i=t.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new je({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||Di;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(G("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;G("opening %s",this.uri),this.engine=new He(this.uri,this.opts);let t=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;let s=te(t,"open",function(){i.onopen(),e&&e()}),n=a=>{G("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=te(t,"error",n);if(this._timeout!==!1){let a=this._timeout;G("connect attempt will timeout after %d",a);let c=this.setTimeoutFn(()=>{G("connect attempt timed out after %d",a),s(),n(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){G("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(te(e,"ping",this.onping.bind(this)),te(e,"data",this.ondata.bind(this)),te(e,"error",this.onerror.bind(this)),te(e,"close",this.onclose.bind(this)),te(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){$e(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){G("error",e),this.emitReserved("error",e)}socket(e,t){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new lt(this,e,t),this.nsps[e]=i),i}_destroy(e){let t=Object.keys(this.nsps);for(let i of t)if(this.nsps[i].active){G("socket %s is still active, skipping close",i);return}this._close()}_packet(e){G("writing packet %j",e);let t=this.encoder.encode(e);for(let i=0;i<t.length;i++)this.engine.write(t[i],e.options)}cleanup(){G("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){G("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){G("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)G("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();G("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let i=this.setTimeoutFn(()=>{e.skipReconnect||(G("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(G("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):(G("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var so=K(qt(),1),io=(0,so.default)("socket.io-client"),$t={};function Ht(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=Kn(r,e.path||"/socket.io"),i=t.source,s=t.id,n=t.path,o=$t[s]&&n in $t[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?(io("ignoring socket cache for %s",i),c=new ft(i,e)):($t[s]||(io("new io instance for %s",i),$t[s]=new ft(i,e)),c=$t[s]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign(Ht,{Manager:ft,Socket:lt,io:Ht,connect:Ht});var Yc="https://ws.novu.co",no="notifications.notification_received",oo="notifications.unseen_count_changed",ao="notifications.unread_count_changed",Xc=({_id:r,content:e,read:t,archived:i,createdAt:s,lastReadDate:n,archivedAt:o,channel:a,subscriber:c,subject:u,avatar:f,cta:h,tags:d,data:C})=>{var m,y,$,R,H,z,pe,Kt,Yt,re;let S={id:(m=c==null?void 0:c._id)!=null?m:"",firstName:c==null?void 0:c.firstName,lastName:c==null?void 0:c.lastName,avatar:c==null?void 0:c.avatar,subscriberId:(y=c==null?void 0:c.subscriberId)!=null?y:""},p=(R=($=h.action)==null?void 0:$.buttons)==null?void 0:R.find(Ge=>Ge.type==="primary"),v=(z=(H=h.action)==null?void 0:H.buttons)==null?void 0:z.find(Ge=>Ge.type==="secondary"),N=(Kt=(pe=h.action)==null?void 0:pe.result)==null?void 0:Kt.type,A=(Yt=h.action)==null?void 0:Yt.status;return{id:r,subject:u,body:e,to:S,isRead:t,isArchived:i,createdAt:s,readAt:n,archivedAt:o,avatar:f,primaryAction:p&&{label:p.content,isCompleted:N==="primary"&&A==="done",redirect:p.url?{target:p.target,url:p.url}:void 0},secondaryAction:v&&{label:v.content,isCompleted:N==="secondary"&&A==="done",redirect:v.url?{target:v.target,url:v.url}:void 0},channelType:a,tags:d,redirect:(re=h.data)!=null&&re.url?{url:h.data.url,target:h.data.target}:void 0,data:C}},ht,ue,ge,ut,Fr,Br,Ur,jt,Mi,Lr=class extends we{constructor({socketUrl:t,inboxServiceInstance:i,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:i});_(this,jt);_(this,ht);_(this,ue);_(this,ge);_(this,ut);_(this,Fr,({message:t})=>{l(this,ue).emit(no,{result:new j(Xc(t),l(this,ue),this._inboxService)})});_(this,Br,({unseenCount:t})=>{l(this,ue).emit(oo,{result:t})});_(this,Ur,({unreadCount:t})=>{l(this,ue).emit(ao,{result:t})});b(this,ue,s),b(this,ut,t!=null?t:Yc)}onSessionSuccess({token:t}){b(this,ht,t)}isSocketEvent(t){return t===no||t===oo||t===ao}initialize(){if(l(this,ht)){$r(this,jt,Mi).call(this).catch(t=>{console.error(t)});return}this.callWithSession(()=>g(this,null,function*(){return $r(this,jt,Mi).call(this).catch(t=>{console.error(t)}),{}}))}};ht=new WeakMap,ue=new WeakMap,ge=new WeakMap,ut=new WeakMap,Fr=new WeakMap,Br=new WeakMap,Ur=new WeakMap,jt=new WeakSet,Mi=function(){return g(this,null,function*(){var i,s,n;if(l(this,ge))return;let t={socketUrl:l(this,ut)};l(this,ue).emit("socket.connect.pending",{args:t}),b(this,ge,Ht(l(this,ut),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${l(this,ht)}`}})),l(this,ge).on("connect",()=>{l(this,ue).emit("socket.connect.resolved",{args:t})}),l(this,ge).on("connect_error",o=>{l(this,ue).emit("socket.connect.resolved",{args:t,error:o})}),(i=l(this,ge))==null||i.on("notification_received",l(this,Fr)),(s=l(this,ge))==null||s.on("unseen_count_changed",l(this,Br)),(n=l(this,ge))==null||n.on("unread_count_changed",l(this,Ur))})};var co="https://api.novu.co";var Jc="v1",Qc="https://api.novu.co",Zc=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,Dr=class{constructor(e={}){let{apiVersion:t=Jc,backendUrl:i=Qc,userAgent:s=Zc}=e||{};this.apiVersion=t,this.backendUrl=`${i}/${this.apiVersion}`,this.headers={"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":s}}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setHeaders(e){this.headers=E(E({},this.headers),e)}get(e,t,i=!0){return g(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:i})})}post(e,t){return g(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t}})})}patch(e,t){return g(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return g(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(n){return g(this,arguments,function*({path:e,searchParams:t,options:i,unwrapEnvelope:s=!0}){let o=el(this.backendUrl,e,t?`?${t.toString()}`:""),a={method:(i==null?void 0:i.method)||"GET",headers:E(E({},this.headers),(i==null?void 0:i.headers)||{}),body:i!=null&&i.body?JSON.stringify(i.body):void 0},c=yield fetch(o,a);if(!c.ok){let f=yield c.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${c.status}, Message: ${f.message}`)}if(c.status===204)return;let u=yield c.json();return s?u.data:u})}};function el(...r){return r.map(e=>e.replace(/^\/+|\/+$/g,"")).join("/")}var Gt="/inbox",de=`${Gt}/notifications`,F,Mr=class{constructor(e={}){this.isSessionInitialized=!1;_(this,F);b(this,F,new Dr(e))}initializeSession(s){return g(this,arguments,function*({applicationIdentifier:e,subscriberId:t,subscriberHash:i}){let n=yield l(this,F).post(`${Gt}/session`,{applicationIdentifier:e,subscriberId:t,subscriberHash:i});return l(this,F).setAuthorizationToken(n.token),this.isSessionInitialized=!0,n})}fetchNotifications({after:e,archived:t,limit:i=10,offset:s,read:n,tags:o}){let a=new URLSearchParams(`limit=${i}`);return e&&a.append("after",e),s&&a.append("offset",`${s}`),o&&o.forEach(c=>a.append("tags[]",c)),n!==void 0&&a.append("read",`${n}`),t!==void 0&&a.append("archived",`${t}`),l(this,F).get(de,a,!1)}count({filters:e}){return l(this,F).get(`${de}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return l(this,F).patch(`${de}/${e}/read`)}unread(e){return l(this,F).patch(`${de}/${e}/unread`)}archive(e){return l(this,F).patch(`${de}/${e}/archive`)}unarchive(e){return l(this,F).patch(`${de}/${e}/unarchive`)}readAll({tags:e}){return l(this,F).post(`${de}/read`,{tags:e})}archiveAll({tags:e}){return l(this,F).post(`${de}/archive`,{tags:e})}archiveAllRead({tags:e}){return l(this,F).post(`${de}/read-archive`,{tags:e})}completeAction({actionType:e,notificationId:t}){return l(this,F).patch(`${de}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return l(this,F).patch(`${de}/${t}/revert`,{actionType:e})}fetchPreferences(e){let t=new URLSearchParams;e&&e.forEach(s=>t.append("tags[]",s));let i=t.size?`?${t.toString()}`:"";return l(this,F).get(`${Gt}/preferences${i}`)}updateGlobalPreferences(e){return l(this,F).patch(`${Gt}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channelPreferences:t}){return l(this,F).patch(`${Gt}/preferences/${e}`,t)}};F=new WeakMap;var ye,zt,dt,Le,qr=class{constructor(e){_(this,ye);_(this,zt);_(this,dt);_(this,Le);var t,i,s;b(this,Le,new Mr({backendUrl:(t=e.backendUrl)!=null?t:co,userAgent:e.__userAgent})),b(this,ye,new Zt),b(this,zt,new nr({applicationIdentifier:e.applicationIdentifier,subscriberId:e.subscriberId,subscriberHash:e.subscriberHash},l(this,Le),l(this,ye))),l(this,zt).initialize(),this.notifications=new sr({useCache:(i=e.useCache)!=null?i:!0,inboxServiceInstance:l(this,Le),eventEmitterInstance:l(this,ye)}),this.preferences=new ar({useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:l(this,Le),eventEmitterInstance:l(this,ye)}),b(this,dt,new Lr({socketUrl:e.socketUrl,eventEmitterInstance:l(this,ye),inboxServiceInstance:l(this,Le)})),this.on=(n,o)=>{l(this,dt).isSocketEvent(n)&&l(this,dt).initialize();let a=l(this,ye).on(n,o);return()=>{a()}},this.off=(n,o)=>{l(this,ye).off(n,o)}}};ye=new WeakMap,zt=new WeakMap,dt=new WeakMap,Le=new WeakMap;window.Novu=qr;})();
14
+ `+n),i.push(s+"m+"+Ti.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Nc()+e+" "+i[0]}function Nc(){return W.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ac(...i){return process.stderr.write(Ri.formatWithOptions(W.inspectOpts,...i)+`
15
+ `)}function kc(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Rc(){return process.env.DEBUG}function Tc(i){i.inspectOpts={};let e=Object.keys(W.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=W.inspectOpts[e[t]]}Ti.exports=Nr()(W);var{formatters:Un}=Ti.exports;Un.o=function(i){return this.inspectOpts.colors=this.useColors,Ri.inspect(i,this.inspectOpts).split(`
16
+ `).map(e=>e.trim()).join(" ")};Un.O=function(i){return this.inspectOpts.colors=this.useColors,Ri.inspect(i,this.inspectOpts)}});var Dt=T((Th,Ar)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ar.exports=Bn():Ar.exports=Dn()});function $r(i){return{all:i=i||new Map,on:function(e,t){var r=i.get(e);r?r.push(t):i.set(e,[t])},off:function(e,t){var r=i.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):i.set(e,[]))},emit:function(e,t){var r=i.get(e);r&&r.slice().map(function(s){s(t)}),(r=i.get("*"))&&r.slice().map(function(s){s(e,t)})}}}var Pe,Jt=class{constructor(){_(this,Pe);E(this,Pe,$r())}on(e,t){return l(this,Pe).on(e,t),()=>{this.off(e,t)}}off(e,t){l(this,Pe).off(e,t)}emit(e,t){l(this,Pe).emit(e,t)}};Pe=new WeakMap;var L=class extends Error{constructor(e,t){super(e),this.originalError=t}};var xe,Ge,Ce=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){_(this,xe,[]);_(this,Ge);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:s})=>{s?(this.onSessionSuccess(s),l(this,xe).forEach(a=>g(this,[a],function*({fn:n,resolve:o}){o(yield n())})),E(this,xe,[])):r&&(this.onSessionError(r),E(this,Ge,r),l(this,xe).forEach(({resolve:n})=>{n({error:new L("Failed to initialize session, please contact the support",r)})}),E(this,xe,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return g(this,null,function*(){return this._inboxService.isSessionInitialized?e():l(this,Ge)?Promise.resolve({error:new L("Failed to initialize session, please contact the support",l(this,Ge))}):new Promise((t,r)=>{l(this,xe).push({fn:e,resolve:t,reject:r})})})}};xe=new WeakMap,Ge=new WeakMap;var Y,re,j=class{constructor(e,t,r){_(this,Y);_(this,re);E(this,Y,t),E(this,re,r),this.id=e.id,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isArchived=e.isArchived,this.createdAt=e.createdAt,this.readAt=e.readAt,this.archivedAt=e.archivedAt,this.avatar=e.avatar,this.primaryAction=e.primaryAction,this.secondaryAction=e.secondaryAction,this.channelType=e.channelType,this.tags=e.tags,this.redirect=e.redirect,this.data=e.data}read(){return Qt({emitter:l(this,Y),apiService:l(this,re),args:{notification:this}})}unread(){return Zt({emitter:l(this,Y),apiService:l(this,re),args:{notification:this}})}archive(){return ei({emitter:l(this,Y),apiService:l(this,re),args:{notification:this}})}unarchive(){return ti({emitter:l(this,Y),apiService:l(this,re),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return ze({emitter:l(this,Y),apiService:l(this,re),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return ze({emitter:l(this,Y),apiService:l(this,re),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ke({emitter:l(this,Y),apiService:l(this,re),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ke({emitter:l(this,Y),apiService:l(this,re),args:{notification:this},actionType:"secondary"})}on(e,t){let r=l(this,Y).on(e,t);return()=>{r()}}off(e,t){l(this,Y).off(e,t)}};Y=new WeakMap,re=new WeakMap;var Qt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ye(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.read.pending",{args:t,data:n});let o=yield e.read(s),a=new j(o,i,e);return i.emit("notification.read.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new L("Failed to read notification",o)}}}),Zt=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ye(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.unread.pending",{args:t,data:n});let o=yield e.unread(s),a=new j(o,i,e);return i.emit("notification.unread.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new L("Failed to unread notification",o)}}}),ei=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ye(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.archive.pending",{args:t,data:n});let o=yield e.archive(s),a=new j(o,i,e);return i.emit("notification.archive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new L("Failed to archive notification",o)}}}),ti=r=>g(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:s,optimisticValue:n}=Ye(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.unarchive.pending",{args:t,data:n});let o=yield e.unarchive(s),a=new j(o,i,e);return i.emit("notification.unarchive.resolved",{args:t,data:a}),{data:a}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new L("Failed to unarchive notification",o)}}}),ze=s=>g(void 0,[s],function*({emitter:i,apiService:e,args:t,actionType:r}){let n=r==="primary"?{primaryAction:O(b({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:O(b({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:a}=Ye(t,n,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:a});let c=yield e.completeAction({actionType:r,notificationId:o}),u=new j(c,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:u}),{data:u}}catch(c){return i.emit("notification.complete_action.resolved",{args:t,error:c}),{error:new L(`Failed to complete ${r} action on the notification`,c)}}}),Ke=s=>g(void 0,[s],function*({emitter:i,apiService:e,args:t,actionType:r}){let n=r==="primary"?{primaryAction:O(b({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:O(b({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:a}=Ye(t,n,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:a});let c=yield e.revertAction({actionType:r,notificationId:o}),u=new j(c,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:u}),{data:u}}catch(c){return i.emit("notification.revert_action.resolved",{args:t,error:c}),{error:new L("Failed to fetch notifications",c)}}}),Ye=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new j(b(b({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},Vr=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r}).map(a=>new j(O(b({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),i,e));return i.emit("notifications.read_all.pending",{args:{tags:r},data:o}),yield e.readAll({tags:r}),i.emit("notifications.read_all.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.read_all.resolved",{args:{tags:r},error:n}),{error:new L("Failed to read all notifications",n)}}}),jr=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r}).map(a=>new j(O(b({},a),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all.pending",{args:{tags:r},data:o}),yield e.archiveAll({tags:r}),i.emit("notifications.archive_all.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.archive_all.resolved",{args:{tags:r},error:n}),{error:new L("Failed to archive all notifications",n)}}}),Hr=s=>g(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r}){try{let o=t.getUniqueNotifications({tags:r,read:!0}).map(a=>new j(O(b({},a),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r},data:o}),yield e.archiveAllRead({tags:r}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r},data:o}),{}}catch(n){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r},error:n}),{error:new L("Failed to archive all read notifications",n)}}});var Gr=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var ll=["seen","unseen"],fl=["read","unread"],Wi=(i,e)=>Gr(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,$i=(i,e)=>Wi(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived;var oe,Xe=class{constructor(){_(this,oe);E(this,oe,new Map)}get(e){return l(this,oe).get(e)}getValues(){return Array.from(l(this,oe).values())}entries(){return Array.from(l(this,oe).entries())}keys(){return Array.from(l(this,oe).keys())}set(e,t){l(this,oe).set(e,t)}remove(e){l(this,oe).delete(e)}clear(){l(this,oe).clear()}};oe=new WeakMap;var zr=({tags:i,read:e,archived:t,limit:r,offset:s,after:n})=>Object.entries({tags:i,read:e,archived:t,limit:r,offset:s,after:n}).filter(([o,a])=>a!=null&&!(Array.isArray(a)&&a.length===0)).reduce((o,[a,c])=>(o[a]=c,o),{}),Vi=({tags:i,read:e,archived:t,limit:r,offset:s,after:n})=>JSON.stringify(zr({tags:i,read:e,archived:t,limit:r,offset:s,after:n})),uo=({tags:i,read:e,archived:t})=>JSON.stringify(zr({tags:i,read:e,archived:t})),Je=i=>JSON.parse(i),po=["notification.read.pending","notification.read.resolved","notification.unread.pending","notification.unread.resolved","notification.complete_action.pending","notification.complete_action.resolved","notification.revert_action.pending","notification.revert_action.resolved","notifications.read_all.pending","notifications.read_all.resolved"],mo=["notification.archive.pending","notification.unarchive.pending","notifications.archive_all.pending","notifications.archive_all_read.pending"],Se,D,pt=class{constructor({emitter:e}){_(this,Se);_(this,D);this.updateNotification=(e,t)=>{let r=l(this,D).get(e);if(!r)return!1;let s=r.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...r.notifications];return n[s]=t,l(this,D).set(e,O(b({},r),{notifications:n})),!0};this.removeNotification=(e,t)=>{let r=l(this,D).get(e);if(!r)return!1;let s=r.notifications.findIndex(o=>o.id===t.id);if(s===-1)return!1;let n=[...r.notifications];return n.splice(s,1),l(this,D).set(e,O(b({},r),{notifications:n})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>({data:t})=>{if(!t)return;let r=Array.isArray(t)?t:[t],s=new Set;l(this,D).keys().forEach(n=>{r.forEach(o=>{let a=!1;e?a=this.removeNotification(n,o):a=this.updateNotification(n,o),a&&s.add(uo(Je(n)))})}),s.forEach(n=>{let o=this.getAggregated(Je(n));l(this,Se).emit("notifications.list.updated",{data:o})})};E(this,Se,e),po.forEach(t=>{l(this,Se).on(t,this.handleNotificationEvent())}),mo.forEach(t=>{l(this,Se).on(t,this.handleNotificationEvent({remove:!0}))}),E(this,D,new Xe)}getAggregated(e){return l(this,D).keys().filter(r=>{let s=Je(r);return $i(s,e)}).map(r=>l(this,D).get(r)).reduce((r,s)=>s?{hasMore:s.hasMore,filter:s.filter,notifications:[...r.notifications,...s.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}has(e){return l(this,D).get(Vi(e))!==void 0}set(e,t){l(this,D).set(Vi(e),t)}update(e,t){this.set(e,t);let r=this.getAggregated(Je(Vi(e)));l(this,Se).emit("notifications.list.updated",{data:r})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,read:e.read,archived:e.archived})}getUniqueNotifications({tags:e,read:t}){let r=l(this,D).keys(),s=new Map;return r.forEach(n=>{let o=Je(n);if(Wi(e,o.tags)){let a=l(this,D).get(n);if(!a)return;a.notifications.filter(c=>typeof t=="undefined"||t===c.isRead).forEach(c=>s.set(c.id,c))}}),Array.from(s.values())}clear(e){l(this,D).keys().forEach(r=>{$i(Je(r),e)&&l(this,D).remove(r)})}clearAll(){l(this,D).clear()}};Se=new WeakMap,D=new WeakMap;var mt,ii=class extends Ce{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});_(this,mt);this.cache=new pt({emitter:s}),E(this,mt,t)}list(){return g(this,arguments,function*(s={}){var n=s,{limit:t=10}=n,r=Wr(n,["limit"]);return this.callWithSession(()=>g(this,null,function*(){let o=b({limit:t},r);try{let a="useCache"in o?o.useCache:l(this,mt),c=a?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:c}),!c){let u=yield this._inboxService.fetchNotifications(b({limit:t},r));c={hasMore:u.hasMore,filter:u.filter,notifications:u.data.map(f=>new j(f,this._emitter,this._inboxService))},a&&(this.cache.set(o,c),c=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:c}),{data:c}}catch(a){return this._emitter.emit("notifications.list.resolved",{args:o,error:a}),{error:new L("Failed to fetch notifications",a)}}}))})}count(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){let r=t&&"filters"in t?t.filters:[b({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let s=yield this._inboxService.count({filters:r}),n=t&&"filters"in t?{counts:s.data}:s.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:n}),{data:n}}catch(s){return this._emitter.emit("notifications.count.resolved",{args:t,error:s}),{error:new L("Failed to count notifications",s)}}}))})}read(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Qt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Zt({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ei({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ti({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ze({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return ze({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ke({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return g(this,null,function*(){return this.callWithSession(()=>g(this,null,function*(){return Ke({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Vr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t})}))})}archiveAll(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return jr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t})}))})}archiveAllRead(){return g(this,arguments,function*({tags:t}={}){return this.callWithSession(()=>g(this,null,function*(){return Hr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t})}))})}clearCache({filter:t}={}){return t?this.cache.clear(t!=null?t:{}):this.cache.clearAll()}};mt=new WeakMap;var Le,gt,we,ri=class{constructor(e,t,r){_(this,Le);_(this,gt);_(this,we);E(this,Le,r),E(this,gt,t),E(this,we,e)}initialize(){return g(this,null,function*(){try{let{applicationIdentifier:e,subscriberId:t,subscriberHash:r}=l(this,we);l(this,Le).emit("session.initialize.pending",{args:l(this,we)});let s=yield l(this,gt).initializeSession({applicationIdentifier:e,subscriberId:t,subscriberHash:r});l(this,Le).emit("session.initialize.resolved",{args:l(this,we),data:s})}catch(e){l(this,Le).emit("session.initialize.resolved",{args:l(this,we),error:e})}})}};Le=new WeakMap,gt=new WeakMap,we=new WeakMap;var Kr=n=>g(void 0,[n],function*({emitter:i,apiService:e,cache:t,useCache:r,args:s}){let{workflowId:o,channels:a}=s;try{i.emit("preference.update.pending",{args:s,data:s.preference?new Ne(O(b({},s.preference),{channels:b(b({},s.preference.channels),a)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0});let c;o?c=yield e.updateWorkflowPreferences({workflowId:o,channels:a}):(go({emitter:i,apiService:e,cache:t,useCache:r,args:s}),c=yield e.updateGlobalPreferences(a));let u=new Ne(c,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.update.resolved",{args:s,data:u}),{data:u}}catch(c){return i.emit("preference.update.resolved",{args:s,error:c}),{error:new L("Failed to fetch notifications",c)}}}),go=({emitter:i,apiService:e,cache:t,useCache:r,args:s})=>{let n=r?t==null?void 0:t.getAll({}):void 0;n==null||n.forEach(o=>{var a;if(o.level==="template"){let c=O(b({},o),{channels:Object.entries(o.channels).reduce((f,[h,d])=>{var S;let x=h;return f[x]=(S=s.channels[x])!=null?S:d,f},{})}),u=s.preference?new Ne(c,{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r}):void 0;u&&i.emit("preference.update.pending",{args:{workflowId:(a=o.workflow)==null?void 0:a.id,channels:u.channels},data:u})}})};var yt,vt,_t,Et,Ne=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:n}){_(this,yt);_(this,vt);_(this,_t);_(this,Et);E(this,yt,t),E(this,vt,r),E(this,_t,s),E(this,Et,n),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow}update({channels:e,channelPreferences:t}){var r;return Kr({emitter:l(this,yt),apiService:l(this,vt),cache:l(this,_t),useCache:l(this,Et),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:{level:this.level,enabled:this.enabled,channels:this.channels,workflow:this.workflow}}})}};yt=new WeakMap,vt=new WeakMap,_t=new WeakMap,Et=new WeakMap;var yo=["preference.update.pending","preference.update.resolved"],vo=({tags:i})=>Object.entries({tags:i}).reduce((e,[t,r])=>(r==null||Array.isArray(r)&&r.length===0||(e[t]=r),e),{}),ji=({tags:i})=>JSON.stringify(vo({tags:i})),Qe,se,si=class{constructor({emitterInstance:e}){_(this,Qe);_(this,se);this.updatePreference=(e,t)=>{let r=l(this,se).get(e);if(!r)return!1;let s=r.findIndex(o=>{var a,c;return((a=o.workflow)==null?void 0:a.id)===((c=t.workflow)==null?void 0:c.id)||o.level===t.level&&t.level==="global"});if(s===-1)return!1;let n=[...r];return n[s]=t,l(this,se).set(e,n),!0};this.handlePreferenceEvent=({data:e})=>{e&&l(this,se).keys().forEach(t=>{let r=this.updatePreference(t,e),s=l(this,se).get(t);!r||!s||l(this,Qe).emit("preferences.list.updated",{data:s})})};E(this,Qe,e),yo.forEach(t=>{l(this,Qe).on(t,this.handlePreferenceEvent)}),E(this,se,new Xe)}has(e){return l(this,se).get(ji(e))!==void 0}set(e,t){l(this,se).set(ji(e),t)}getAll(e){if(this.has(e))return l(this,se).get(ji(e))}clearAll(){l(this,se).clear()}};Qe=new WeakMap,se=new WeakMap;var Fe,ni=class extends Ce{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});_(this,Fe);this.cache=new si({emitterInstance:this._emitter}),E(this,Fe,t)}list(){return g(this,arguments,function*(t={}){return this.callWithSession(()=>g(this,null,function*(){try{let r=l(this,Fe)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:r}),r||(r=(yield this._inboxService.fetchPreferences(t.tags)).map(n=>new Ne(n,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:l(this,Fe)})),l(this,Fe)&&(this.cache.set(t,r),r=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:r}),{data:r}}catch(r){throw this._emitter.emit("preferences.list.resolved",{args:t,error:r}),r}}))})}};Fe=new WeakMap;var ae=Object.create(null);ae.open="0";ae.close="1";ae.ping="2";ae.pong="3";ae.message="4";ae.upgrade="5";ae.noop="6";var bt=Object.create(null);Object.keys(ae).forEach(i=>{bt[ae[i]]=i});var xt={type:"error",data:"parser error"};var Ct=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Yr(e,!0).toString("base64")):r(ae[i]+(e||"")),Yr=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),Hi;function Xr(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Yr(i.data,!1));Ct(i,!0,t=>{Hi||(Hi=new TextEncoder),e(Hi.encode(t))})}var St=(i,e)=>{if(typeof i!="string")return{type:"message",data:Jr(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Jr(r,e)}}return bt[t]?i.length>1?{type:bt[t],data:i.substring(1)}:{type:bt[t]}:xt},Jr=(i,e)=>{switch(e){case"arraybuffer":return i instanceof ArrayBuffer?i:Buffer.isBuffer(i)?i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength):i.buffer;case"nodebuffer":default:return Buffer.isBuffer(i)?i:Buffer.from(i)}};var Qr="",Zr=(i,e)=>{let t=i.length,r=new Array(t),s=0;i.forEach((n,o)=>{Ct(n,!1,a=>{r[o]=a,++s===t&&e(r.join(Qr))})})},es=(i,e)=>{let t=i.split(Qr),r=[];for(let s=0;s<t.length;s++){let n=St(t[s],e);if(r.push(n),n.type==="error")break}return r};function ts(){return new TransformStream({transform(i,e){Xr(i,t=>{let r=t.length,s;if(r<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,r);else if(r<65536){s=new Uint8Array(3);let n=new DataView(s.buffer);n.setUint8(0,126),n.setUint16(1,r)}else{s=new Uint8Array(9);let n=new DataView(s.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var Gi;function oi(i){return i.reduce((e,t)=>e+t.length,0)}function ai(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),r=0;for(let s=0;s<e;s++)t[s]=i[0][r++],r===i[0].length&&(i.shift(),r=0);return i.length&&r<i[0].length&&(i[0]=i[0].slice(r)),t}function is(i,e){Gi||(Gi=new TextDecoder);let t=[],r=0,s=-1,n=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(r===0){if(oi(t)<1)break;let c=ai(t,1);n=(c[0]&128)===128,s=c[0]&127,s<126?r=3:s===126?r=1:r=2}else if(r===1){if(oi(t)<2)break;let c=ai(t,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),r=3}else if(r===2){if(oi(t)<8)break;let c=ai(t,8),u=new DataView(c.buffer,c.byteOffset,c.length),f=u.getUint32(0);if(f>Math.pow(2,21)-1){a.enqueue(xt);break}s=f*Math.pow(2,32)+u.getUint32(4),r=3}else{if(oi(t)<s)break;let c=ai(t,s);a.enqueue(St(n?c:Gi.decode(c),e)),r=0}if(s===0||s>i){a.enqueue(xt);break}}}})}var zi=4;function R(i){if(i)return _o(i)}function _o(i){for(var e in R.prototype)i[e]=R.prototype[e];return i}R.prototype.on=R.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};R.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};R.prototype.off=R.prototype.removeListener=R.prototype.removeAllListeners=R.prototype.removeEventListener=function(i,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+i];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var r,s=0;s<t.length;s++)if(r=t[s],r===e||r.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+i],this};R.prototype.emit=function(i){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+i],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(t){t=t.slice(0);for(var r=0,s=t.length;r<s;++r)t[r].apply(this,e)}return this};R.prototype.emitReserved=R.prototype.emit;R.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};R.prototype.hasListeners=function(i){return!!this.listeners(i).length};var ce=global;function ci(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var Eo=ce.setTimeout,bo=ce.clearTimeout;function ge(i,e){e.useNativeTimers?(i.setTimeoutFn=Eo.bind(ce),i.clearTimeoutFn=bo.bind(ce)):(i.setTimeoutFn=ce.setTimeout.bind(ce),i.clearTimeoutFn=ce.clearTimeout.bind(ce))}var xo=1.33;function rs(i){return typeof i=="string"?Co(i):Math.ceil((i.byteLength||i.size)*xo)}function Co(i){let e=0,t=0;for(let r=0,s=i.length;r<s;r++)e=i.charCodeAt(r),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(r++,t+=4);return t}var ms=z(Ue(),1);function ds(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ps(i){let e={},t=i.split("&");for(let r=0,s=t.length;r<s;r++){let n=t[r].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}var Go=(0,ms.default)("engine.io-client:transport"),er=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},ye=class extends R{constructor(e){super(),this.writable=!1,ge(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new er(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):Go("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=St(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=ds(e);return t.length?"?"+t:""}};var ws=z(Ue(),1);var _s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),tr=64,zo={},gs=0,di=0,ys;function vs(i){let e="";do e=_s[i%tr]+e,i=Math.floor(i/tr);while(i>0);return e}function pi(){let i=vs(+new Date);return i!==ys?(gs=0,ys=i):i+"."+vs(gs++)}for(;di<tr;di++)zo[_s[di]]=di;var sr=z(xs(),1),nr=sr.default||sr;function Cs(){return new rr}function Yo(i){let e=i.split("; "),t=e[0].indexOf("=");if(t===-1)return;let r=e[0].substring(0,t).trim();if(!r.length)return;let s=e[0].substring(t+1).trim();s.charCodeAt(0)===34&&(s=s.slice(1,-1));let n={name:r,value:s};for(let o=1;o<e.length;o++){let a=e[o].split("=");if(a.length!==2)continue;let c=a[0].trim(),u=a[1].trim();switch(c){case"Expires":n.expires=new Date(u);break;case"Max-Age":let f=new Date;f.setUTCSeconds(f.getUTCSeconds()+parseInt(u,10)),n.expires=f;break;default:}}return n}var rr=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let s=Yo(r);s&&this.cookies.set(s.name,s)})}addCookies(e){let t=[];this.cookies.forEach((r,s)=>{var n;((n=r.expires)===null||n===void 0?void 0:n.getTime())<Date.now()?this.cookies.delete(s):t.push(`${s}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var X=(0,ws.default)("engine.io-client:polling");function Xo(){}var Jo=function(){return new nr({xdomain:!1}).responseType!=null}(),mi=class extends ye{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let r=location.protocol==="https:",s=location.port;s||(s=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||s!==e.port}let t=e&&e.forceBase64;this.supportsBinary=Jo&&!t,this.opts.withCredentials&&(this.cookieJar=Cs())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{X("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(X("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){X("pre-pause polling complete"),--r||t()})),this.writable||(X("we are currently writing - waiting to pause"),r++,this.once("drain",function(){X("pre-pause writing complete"),--r||t()}))}else t()}poll(){X("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){X("polling got data %s",e);let t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};es(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():X('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{X("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(X("transport open - closing"),e()):(X("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Zr(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=pi()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ke(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(s,n)=>{this.onError("xhr post error",s,n)})}doPoll(){X("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},ke=class i extends R{constructor(e,t){super(),ge(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;let t=ci(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new nr(t);try{X("xhr open %s: %s",this.method,this.uri),r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let s in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(s)&&r.setRequestHeader(s,this.opts.extraHeaders[s])}}catch(s){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(s){}try{r.setRequestHeader("Accept","*/*")}catch(s){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var s;r.readyState===3&&((s=this.opts.cookieJar)===null||s===void 0||s.parseCookies(r)),r.readyState===4&&(r.status===200||r.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof r.status=="number"?r.status:0)},0))},X("xhr data %s",this.data),r.send(this.data)}catch(s){this.setTimeoutFn(()=>{this.onError(s)},0);return}typeof document!="undefined"&&(this.index=i.requestsCount++,i.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr=="undefined"||this.xhr===null)){if(this.xhr.onreadystatechange=Xo,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete i.requests[this.index],this.xhr=null}}onLoad(){let e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};ke.requestsCount=0;ke.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",Ss);else if(typeof addEventListener=="function"){let i="onpagehide"in ce?"pagehide":"unload";addEventListener(i,Ss,!1)}}function Ss(){for(let i in ke.requests)ke.requests.hasOwnProperty(i)&&ke.requests[i].abort()}var ac=z(Rs(),1),cc=z(pr(),1),lc=z(gr(),1),kn=z(Cr(),1),fc=z(An(),1);var Rn=kn.default;var Bt=Rn,wi=!1,Tn="nodebuffer",We=process.nextTick;var In=z(Ue(),1);var hc=(0,In.default)("engine.io-client:websocket"),On=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ni=class extends ye{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,r=On?{}:ci(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=wi&&!On?t?new Bt(e,t):new Bt(e):new Bt(e,t,r)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],s=t===e.length-1;Ct(r,this.supportsBinary,n=>{let o={};wi||(r.options&&(o.compress=r.options.compress),this.opts.perMessageDeflate&&(typeof n=="string"?Buffer.byteLength(n):n.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{wi?this.ws.send(n):this.ws.send(n,o)}catch(a){hc("websocket closed before onclose event")}s&&We(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws!="undefined"&&(this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=pi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Bt}};var Pn=z(Ue(),1),Ut=(0,Pn.default)("engine.io-client:webtransport"),Ai=class extends ye{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Ut("transport closed gracefully"),this.onClose()}).catch(e=>{Ut("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=is(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),s=ts();s.readable.pipeTo(e.writable),this.writer=s.writable.getWriter();let n=()=>{r.read().then(({done:a,value:c})=>{if(a){Ut("session is closed");return}Ut("received chunk: %o",c),this.onPacket(c),n()}).catch(a=>{Ut("an error occurred while reading: %s",a)})};n();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],s=t===e.length-1;this.writer.write(r).then(()=>{s&&We(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var wr={websocket:Ni,webtransport:Ai,polling:mi};var uc=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,dc=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ot(i){let e=i,t=i.indexOf("["),r=i.indexOf("]");t!=-1&&r!=-1&&(i=i.substring(0,t)+i.substring(t,r).replace(/:/g,";")+i.substring(r,i.length));let s=uc.exec(i||""),n={},o=14;for(;o--;)n[dc[o]]=s[o]||"";return t!=-1&&r!=-1&&(n.source=e,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=pc(n,n.path),n.queryKey=mc(n,n.query),n}function pc(i,e){let t=/\/{2,9}/g,r=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&r.splice(0,1),e.slice(-1)=="/"&&r.splice(r.length-1,1),r}function mc(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,s,n){s&&(t[s]=n)}),t}var Ln=z(Ue(),1);var I=(0,Ln.default)("engine.io-client:socket"),$e=class i extends R{constructor(e,t={}){super(),this.binaryType=Tn,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=ot(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=ot(t.host).host),ge(this,t),this.secure=t.secure!=null?t.secure:typeof location!="undefined"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location!="undefined"?location.hostname:"localhost"),this.port=t.port||(typeof location!="undefined"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=ps(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){I('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=zi,t.transport=e,this.id&&(t.sid=this.id);let r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return I("options: %j",r),new wr[e](r)}open(){let e;if(this.opts.rememberUpgrade&&i.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch(t){I("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){I("setting transport %s",e.name),this.transport&&(I("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){I('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let s=()=>{r||(I('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",h=>{if(!r)if(h.type==="pong"&&h.data==="probe"){if(I('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",I('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(I("changing transport and sending upgrade packet"),f(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{I('probe transport "%s" failed',e);let d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function n(){r||(r=!0,f(),t.close(),t=null)}let o=h=>{let d=new Error("probe error: "+h);d.transport=t.name,n(),I('probe transport "%s" failed because of error: %s',e,h),this.emitReserved("upgradeError",d)};function a(){o("transport closed")}function c(){o("socket closed")}function u(h){t&&h.name!==t.name&&(I('"%s" works - aborting "%s"',h.name,t.name),n())}let f=()=>{t.removeListener("open",s),t.removeListener("error",o),t.removeListener("close",a),this.off("close",c),this.off("upgrading",u)};t.once("open",s),t.once("error",o),t.once("close",a),this.once("close",c),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(I("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){I("starting upgrade probes");let e=0,t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(I('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":let t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else I('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this.getWritablePackets();I("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let s=this.writeBuffer[r].data;if(s&&(t+=rs(s)),r>0&&t>this.maxPayload)return I("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return I("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,s){if(typeof t=="function"&&(s=t,t=void 0),typeof r=="function"&&(s=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let n={type:e,data:t,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this.onClose("forced close"),I("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():e()}):this.upgrading?r():e()),this}onError(e){I("socket error %j",e),i.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(I('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],r=0,s=e.length;for(;r<s;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};$e.protocol=zi;var xh=$e.protocol;var qn=z(Dt(),1),Mn=(0,qn.default)("socket.io-client:url");function Wn(i,e="",t){let r=i;t=t||typeof location!="undefined"&&location,i==null&&(i=t.protocol+"//"+t.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=t.protocol+i:i=t.host+i),/^(https?|wss?):\/\//.test(i)||(Mn("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),Mn("parse %s",i),r=ot(i)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";let n=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port+e,r.href=r.protocol+"://"+n+(t&&t.port===r.port?"":":"+r.port),r}var Lr={};fo(Lr,{Decoder:()=>Ir,Encoder:()=>Or,PacketType:()=>C,protocol:()=>zn});var Oc=typeof ArrayBuffer=="function",Ic=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,$n=Object.prototype.toString,Pc=typeof Blob=="function"||typeof Blob!="undefined"&&$n.call(Blob)==="[object BlobConstructor]",Lc=typeof File=="function"||typeof File!="undefined"&&$n.call(File)==="[object FileConstructor]";function qt(i){return Oc&&(i instanceof ArrayBuffer||Ic(i))||Pc&&i instanceof Blob||Lc&&i instanceof File}function Mt(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Mt(i[t]))return!0;return!1}if(qt(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Mt(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Mt(i[t]))return!0;return!1}function Vn(i){let e=[],t=i.data,r=i;return r.data=kr(t,e),r.attachments=e.length,{packet:r,buffers:e}}function kr(i,e){if(!i)return i;if(qt(i)){let t={_placeholder:!0,num:e.length};return e.push(i),t}else if(Array.isArray(i)){let t=new Array(i.length);for(let r=0;r<i.length;r++)t[r]=kr(i[r],e);return t}else if(typeof i=="object"&&!(i instanceof Date)){let t={};for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=kr(i[r],e));return t}return i}function jn(i,e){return i.data=Rr(i.data,e),delete i.attachments,i}function Rr(i,e){if(!i)return i;if(i&&i._placeholder===!0){if(typeof i.num=="number"&&i.num>=0&&i.num<e.length)return e[i.num];throw new Error("illegal attachments")}else if(Array.isArray(i))for(let t=0;t<i.length;t++)i[t]=Rr(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=Rr(i[t],e));return i}var Gn=z(Ue(),1),Tr=(0,Gn.default)("socket.io-parser"),Fc=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],zn=5,C;(function(i){i[i.CONNECT=0]="CONNECT",i[i.DISCONNECT=1]="DISCONNECT",i[i.EVENT=2]="EVENT",i[i.ACK=3]="ACK",i[i.CONNECT_ERROR=4]="CONNECT_ERROR",i[i.BINARY_EVENT=5]="BINARY_EVENT",i[i.BINARY_ACK=6]="BINARY_ACK"})(C||(C={}));var Or=class{constructor(e){this.replacer=e}encode(e){return Tr("encoding packet %j",e),(e.type===C.EVENT||e.type===C.ACK)&&Mt(e)?this.encodeAsBinary({type:e.type===C.EVENT?C.BINARY_EVENT:C.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===C.BINARY_EVENT||e.type===C.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),Tr("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Vn(e),r=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(r),s}};function Hn(i){return Object.prototype.toString.call(i)==="[object Object]"}var Ir=class i extends R{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let r=t.type===C.BINARY_EVENT;r||t.type===C.BINARY_ACK?(t.type=r?C.EVENT:C.ACK,this.reconstructor=new Pr(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(qt(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,r={type:Number(e.charAt(0))};if(C[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===C.BINARY_EVENT||r.type===C.BINARY_ACK){let n=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(n,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let n=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(n,t)}else r.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let n=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}r.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){let n=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,n))r.data=n;else throw new Error("invalid payload")}return Tr("decoded %s as %j",e,r),r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case C.CONNECT:return Hn(t);case C.DISCONNECT:return t===void 0;case C.CONNECT_ERROR:return typeof t=="string"||Hn(t);case C.EVENT:case C.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Fc.indexOf(t[0])===-1);case C.ACK:case C.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Pr=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=jn(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function ee(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Kn=z(Dt(),1),U=(0,Kn.default)("socket.io-client:socket"),Bc=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),at=class extends R{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ee(e,"open",this.onopen.bind(this)),ee(e,"packet",this.onpacket.bind(this)),ee(e,"error",this.onerror.bind(this)),ee(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Bc.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let r={type:C.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;U("emitting packet with ack id %d",o);let a=t.pop();this._registerAckCallback(o,a),r.id=o}let s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)?U("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r),this.flags={},this}_registerAckCallback(e,t){var r;let s=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(U("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));U("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(n),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((s,n)=>{t.push((o,a)=>r?o?n(o):s(a):s(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...n)=>r!==this._queue[0]?void 0:(s!==null?r.tryCount>this._opts.retries&&(U("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(s)):(U("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(U("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){U("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,U("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){U("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:C.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){U("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case C.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case C.EVENT:case C.BINARY_EVENT:this.onevent(e);break;case C.ACK:case C.BINARY_ACK:this.onack(e);break;case C.DISCONNECT:this.ondisconnect();break;case C.CONNECT_ERROR:this.destroy();let r=new Error(e.data.message);r.data=e.data.data,this.emitReserved("connect_error",r);break}}onevent(e){let t=e.data||[];U("emitting event %j",t),e.id!=null&&(U("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,r=!1;return function(...s){r||(r=!0,U("sending ack %j",s),t.packet({type:C.ACK,id:e,data:s}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(U("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):U("bad ack %s",e.id)}onconnect(e,t){U("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){U("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(U("performing disconnect (%s)",this.nsp),this.packet({type:C.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function Ve(i){i=i||{},this.ms=i.min||100,this.max=i.max||1e4,this.factor=i.factor||2,this.jitter=i.jitter>0&&i.jitter<=1?i.jitter:0,this.attempts=0}Ve.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*i);i=Math.floor(e*10)&1?i+t:i-t}return Math.min(i,this.max)|0};Ve.prototype.reset=function(){this.attempts=0};Ve.prototype.setMin=function(i){this.ms=i};Ve.prototype.setMax=function(i){this.max=i};Ve.prototype.setJitter=function(i){this.jitter=i};var Yn=z(Dt(),1),H=(0,Yn.default)("socket.io-client:manager"),ct=class extends R{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,ge(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Ve({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||Lr;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(H("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;H("opening %s",this.uri),this.engine=new $e(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let s=ee(t,"open",function(){r.onopen(),e&&e()}),n=a=>{H("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=ee(t,"error",n);if(this._timeout!==!1){let a=this._timeout;H("connect attempt will timeout after %d",a);let c=this.setTimeoutFn(()=>{H("connect attempt timed out after %d",a),s(),n(new Error("timeout")),t.close()},a);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){H("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ee(e,"ping",this.onping.bind(this)),ee(e,"data",this.ondata.bind(this)),ee(e,"error",this.onerror.bind(this)),ee(e,"close",this.onclose.bind(this)),ee(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){We(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){H("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new at(this,e,t),this.nsps[e]=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nsps[r].active){H("socket %s is still active, skipping close",r);return}this._close()}_packet(e){H("writing packet %j",e);let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){H("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){H("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){H("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)H("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();H("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(H("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(H("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):(H("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Jn=z(Dt(),1),Xn=(0,Jn.default)("socket.io-client"),Wt={};function $t(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Wn(i,e.path||"/socket.io"),r=t.source,s=t.id,n=t.path,o=Wt[s]&&n in Wt[s].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o,c;return a?(Xn("ignoring socket cache for %s",r),c=new ct(r,e)):(Wt[s]||(Xn("new io instance for %s",r),Wt[s]=new ct(r,e)),c=Wt[s]),t.query&&!e.query&&(e.query=t.queryKey),c.socket(t.path,e)}Object.assign($t,{Manager:ct,Socket:at,io:$t,connect:$t});var Uc="https://ws.novu.co",Qn="notifications.notification_received",Zn="notifications.unseen_count_changed",eo="notifications.unread_count_changed",Dc=({_id:i,content:e,read:t,archived:r,createdAt:s,lastReadDate:n,archivedAt:o,channel:a,subscriber:c,subject:u,avatar:f,cta:h,tags:d,data:x})=>{var m,y,$,k,V,G,ue,Gt,zt,te;let S={id:(m=c==null?void 0:c._id)!=null?m:"",firstName:c==null?void 0:c.firstName,lastName:c==null?void 0:c.lastName,avatar:c==null?void 0:c.avatar,subscriberId:(y=c==null?void 0:c.subscriberId)!=null?y:""},p=(k=($=h.action)==null?void 0:$.buttons)==null?void 0:k.find(je=>je.type==="primary"),v=(G=(V=h.action)==null?void 0:V.buttons)==null?void 0:G.find(je=>je.type==="secondary"),N=(Gt=(ue=h.action)==null?void 0:ue.result)==null?void 0:Gt.type,A=(zt=h.action)==null?void 0:zt.status;return{id:i,subject:u,body:e,to:S,isRead:t,isArchived:r,createdAt:s,readAt:n,archivedAt:o,avatar:f,primaryAction:p&&{label:p.content,isCompleted:N==="primary"&&A==="done",redirect:p.url?{target:p.target,url:p.url}:void 0},secondaryAction:v&&{label:v.content,isCompleted:N==="secondary"&&A==="done",redirect:v.url?{target:v.target,url:v.url}:void 0},channelType:a,tags:d,redirect:(te=h.data)!=null&&te.url?{url:h.data.url,target:h.data.target}:void 0,data:x}},lt,fe,pe,ft,Ii,Pi,Li,Vt,Fr,Oi=class extends Ce{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});_(this,Vt);_(this,lt);_(this,fe);_(this,pe);_(this,ft);_(this,Ii,({message:t})=>{l(this,fe).emit(Qn,{result:new j(Dc(t),l(this,fe),this._inboxService)})});_(this,Pi,({unseenCount:t})=>{l(this,fe).emit(Zn,{result:t})});_(this,Li,({unreadCount:t})=>{l(this,fe).emit(eo,{result:t})});E(this,fe,s),E(this,ft,t!=null?t:Uc)}onSessionSuccess({token:t}){E(this,lt,t)}isSocketEvent(t){return t===Qn||t===Zn||t===eo}initialize(){if(l(this,lt)){qi(this,Vt,Fr).call(this).catch(t=>{console.error(t)});return}this.callWithSession(()=>g(this,null,function*(){return qi(this,Vt,Fr).call(this).catch(t=>{console.error(t)}),{}}))}};lt=new WeakMap,fe=new WeakMap,pe=new WeakMap,ft=new WeakMap,Ii=new WeakMap,Pi=new WeakMap,Li=new WeakMap,Vt=new WeakSet,Fr=function(){return g(this,null,function*(){var r,s,n;if(l(this,pe))return;let t={socketUrl:l(this,ft)};l(this,fe).emit("socket.connect.pending",{args:t}),E(this,pe,$t(l(this,ft),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${l(this,lt)}`}})),l(this,pe).on("connect",()=>{l(this,fe).emit("socket.connect.resolved",{args:t})}),l(this,pe).on("connect_error",o=>{l(this,fe).emit("socket.connect.resolved",{args:t,error:o})}),(r=l(this,pe))==null||r.on("notification_received",l(this,Ii)),(s=l(this,pe))==null||s.on("unseen_count_changed",l(this,Pi)),(n=l(this,pe))==null||n.on("unread_count_changed",l(this,Li))})};var Mc="v1",qc="https://api.novu.co",Wc=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,Fi=class{constructor(e={}){let{apiVersion:t=Mc,apiUrl:r=qc,userAgent:s=Wc}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${this.apiVersion}`,this.headers={"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":s}}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setHeaders(e){this.headers=b(b({},this.headers),e)}get(e,t,r=!0){return g(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t){return g(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t}})})}patch(e,t){return g(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return g(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(n){return g(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:s=!0}){let o=$c(this.apiUrl,e,t?`?${t.toString()}`:""),a={method:(r==null?void 0:r.method)||"GET",headers:b(b({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},c=yield fetch(o,a);if(!c.ok){let f=yield c.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${c.status}, Message: ${f.message}`)}if(c.status===204)return;let u=yield c.json();return s?u.data:u})}};function $c(...i){return i.map(e=>e.replace(/^\/+|\/+$/g,"")).join("/")}var jt="/inbox",he=`${jt}/notifications`,F,Bi=class{constructor(e={}){this.isSessionInitialized=!1;_(this,F);E(this,F,new Fi(e))}initializeSession(s){return g(this,arguments,function*({applicationIdentifier:e,subscriberId:t,subscriberHash:r}){let n=yield l(this,F).post(`${jt}/session`,{applicationIdentifier:e,subscriberId:t,subscriberHash:r});return l(this,F).setAuthorizationToken(n.token),this.isSessionInitialized=!0,n})}fetchNotifications({after:e,archived:t,limit:r=10,offset:s,read:n,tags:o}){let a=new URLSearchParams(`limit=${r}`);return e&&a.append("after",e),s&&a.append("offset",`${s}`),o&&o.forEach(c=>a.append("tags[]",c)),n!==void 0&&a.append("read",`${n}`),t!==void 0&&a.append("archived",`${t}`),l(this,F).get(he,a,!1)}count({filters:e}){return l(this,F).get(`${he}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return l(this,F).patch(`${he}/${e}/read`)}unread(e){return l(this,F).patch(`${he}/${e}/unread`)}archive(e){return l(this,F).patch(`${he}/${e}/archive`)}unarchive(e){return l(this,F).patch(`${he}/${e}/unarchive`)}readAll({tags:e}){return l(this,F).post(`${he}/read`,{tags:e})}archiveAll({tags:e}){return l(this,F).post(`${he}/archive`,{tags:e})}archiveAllRead({tags:e}){return l(this,F).post(`${he}/read-archive`,{tags:e})}completeAction({actionType:e,notificationId:t}){return l(this,F).patch(`${he}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return l(this,F).patch(`${he}/${t}/revert`,{actionType:e})}fetchPreferences(e){let t=new URLSearchParams;e&&e.forEach(s=>t.append("tags[]",s));let r=t.size?`?${t.toString()}`:"";return l(this,F).get(`${jt}/preferences${r}`)}updateGlobalPreferences(e){return l(this,F).patch(`${jt}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return l(this,F).patch(`${jt}/preferences/${e}`,t)}};F=new WeakMap;var me,Ht,ht,Ie,Ui=class{constructor(e){_(this,me);_(this,Ht);_(this,ht);_(this,Ie);var t,r;E(this,Ie,new Bi({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),E(this,me,new Jt),E(this,Ht,new ri({applicationIdentifier:e.applicationIdentifier,subscriberId:e.subscriberId,subscriberHash:e.subscriberHash},l(this,Ie),l(this,me))),l(this,Ht).initialize(),this.notifications=new ii({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:l(this,Ie),eventEmitterInstance:l(this,me)}),this.preferences=new ni({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:l(this,Ie),eventEmitterInstance:l(this,me)}),E(this,ht,new Oi({socketUrl:e.socketUrl,eventEmitterInstance:l(this,me),inboxServiceInstance:l(this,Ie)})),this.on=(s,n)=>{l(this,ht).isSocketEvent(s)&&l(this,ht).initialize();let o=l(this,me).on(s,n);return()=>{o()}},this.off=(s,n)=>{l(this,me).off(s,n)}}};me=new WeakMap,Ht=new WeakMap,ht=new WeakMap,Ie=new WeakMap;window.Novu=Ui;})();
17
17
  /*! Bundled license information:
18
18
 
19
19
  xmlhttprequest-ssl/lib/XMLHttpRequest.js: