@novu/js 3.11.0 → 3.12.0-rc.2

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.
Files changed (32) hide show
  1. package/dist/cjs/{chunk-VWSQDNZX.js → chunk-OZV3TKWX.js} +6 -0
  2. package/dist/cjs/{chunk-QQNKEWGC.js → chunk-SZEUW4CB.js} +1070 -309
  3. package/dist/cjs/index.d.ts +5 -4
  4. package/dist/cjs/index.js +26 -14
  5. package/dist/cjs/internal/index.d.ts +8 -2
  6. package/dist/cjs/internal/index.js +8 -4
  7. package/dist/{esm/novu-DY-mm8Og.d.mts → cjs/novu-BVtCFUxa.d.ts} +398 -203
  8. package/dist/cjs/themes/index.d.ts +11 -5
  9. package/dist/cjs/themes/index.js +17 -1
  10. package/dist/{esm/types-BM_9Xx5Z.d.mts → cjs/types-D-9ozWeQ.d.ts} +20 -1
  11. package/dist/cjs/types-Rjzg7eo3.d.ts +836 -0
  12. package/dist/cjs/ui/index.d.ts +74 -7
  13. package/dist/cjs/ui/index.js +1785 -260
  14. package/dist/esm/{chunk-UM35OVAD.mjs → chunk-IA6ISHOP.mjs} +1068 -310
  15. package/dist/esm/{chunk-RZWQYM3H.mjs → chunk-RO3GDYAG.mjs} +6 -1
  16. package/dist/esm/index.d.mts +5 -4
  17. package/dist/esm/index.mjs +2 -2
  18. package/dist/esm/internal/index.d.mts +8 -2
  19. package/dist/esm/internal/index.mjs +1 -1
  20. package/dist/{cjs/novu-ThMWeiRt.d.ts → esm/novu-YP3PwsQR.d.mts} +398 -203
  21. package/dist/esm/themes/index.d.mts +11 -5
  22. package/dist/esm/themes/index.mjs +16 -2
  23. package/dist/{cjs/types-BM_9Xx5Z.d.ts → esm/types-D-9ozWeQ.d.mts} +20 -1
  24. package/dist/esm/types-DmMJ1GiR.d.mts +836 -0
  25. package/dist/esm/ui/index.d.mts +74 -7
  26. package/dist/esm/ui/index.mjs +1782 -256
  27. package/dist/index.css +1 -1
  28. package/dist/novu.min.js +12 -12
  29. package/dist/novu.min.js.gz +0 -0
  30. package/package.json +18 -17
  31. package/dist/cjs/types-BjANCN3c.d.ts +0 -537
  32. package/dist/esm/types-C5eX1GmB.d.mts +0 -537
package/dist/novu.min.js CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";(()=>{var oa=Object.create;var yi=Object.defineProperty,aa=Object.defineProperties,ca=Object.getOwnPropertyDescriptor,la=Object.getOwnPropertyDescriptors,ha=Object.getOwnPropertyNames,gi=Object.getOwnPropertySymbols,fa=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable;var Tn=i=>{throw TypeError(i)},On=Math.pow,Sr=(i,e,t)=>e in i?yi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,E=(i,e)=>{for(var t in e||(e={}))br.call(e,t)&&Sr(i,t,e[t]);if(gi)for(var t of gi(e))Rn.call(e,t)&&Sr(i,t,e[t]);return i},T=(i,e)=>aa(i,la(e));var A=(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)br.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&gi)for(var r of gi(i))e.indexOf(r)<0&&Rn.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),ua=(i,e)=>{for(var t in e)yi(i,t,{get:e[t],enumerable:!0})},da=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ha(e))!br.call(i,n)&&n!==t&&yi(i,n,{get:()=>e[n],enumerable:!(r=ca(e,n))||r.enumerable});return i};var Q=(i,e,t)=>(t=i!=null?oa(fa(i)):{},da(e||!i||!i.__esModule?yi(t,"default",{value:i,enumerable:!0}):t,i));var I=(i,e,t)=>Sr(i,typeof e!="symbol"?e+"":e,t),xr=(i,e,t)=>e.has(i)||Tn("Cannot "+t);var a=(i,e,t)=>(xr(i,e,"read from private field"),t?t.call(i):e.get(i)),_=(i,e,t)=>e.has(i)?Tn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,r)=>(xr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ue=(i,e,t)=>(xr(i,e,"access private method"),t);var m=(i,e,t)=>new Promise((r,n)=>{var s=l=>{try{c(t.next(l))}catch(u){n(u)}},o=l=>{try{c(t.throw(l))}catch(u){n(u)}},c=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);c((t=t.apply(i,e)).next())});var Mr=F((lu,ss)=>{"use strict";var bt=1e3,wt=bt*60,xt=wt*60,ot=xt*24,Ba=ot*7,Ma=ot*365.25;ss.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return qa(i);if(t==="number"&&isFinite(i))return e.long?za(i):Wa(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function qa(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*Ma;case"weeks":case"week":case"w":return t*Ba;case"days":case"day":case"d":return t*ot;case"hours":case"hour":case"hrs":case"hr":case"h":return t*xt;case"minutes":case"minute":case"mins":case"min":case"m":return t*wt;case"seconds":case"second":case"secs":case"sec":case"s":return t*bt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Wa(i){var e=Math.abs(i);return e>=ot?Math.round(i/ot)+"d":e>=xt?Math.round(i/xt)+"h":e>=wt?Math.round(i/wt)+"m":e>=bt?Math.round(i/bt)+"s":i+"ms"}function za(i){var e=Math.abs(i);return e>=ot?Ki(i,e,ot,"day"):e>=xt?Ki(i,e,xt,"hour"):e>=wt?Ki(i,e,wt,"minute"):e>=bt?Ki(i,e,bt,"second"):i+" ms"}function Ki(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var qr=F((hu,os)=>{"use strict";function $a(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Mr(),t.destroy=u,Object.keys(i).forEach(h=>{t[h]=i[h]}),t.names=[],t.skips=[],t.formatters={};function e(h){let f=0;for(let d=0;d<h.length;d++)f=(f<<5)-f+h.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(h){let f,d=null,p,w;function g(...v){if(!g.enabled)return;let R=g,x=Number(new Date),y=x-(f||x);R.diff=y,R.prev=f,R.curr=x,f=x,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let b=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(N,P)=>{if(N==="%%")return"%";b++;let q=t.formatters[P];if(typeof q=="function"){let ne=v[b];N=q.call(R,ne),v.splice(b,1),b--}return N}),t.formatArgs.call(R,v),(R.log||t.log).apply(R,v)}return g.namespace=h,g.useColors=t.useColors(),g.color=t.selectColor(h),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,w=t.enabled(h)),w),set:v=>{d=v}}),typeof t.init=="function"&&t.init(g),g}function r(h,f){let d=t(this.namespace+(typeof f=="undefined"?":":f)+h);return d.log=this.log,d}function n(h){t.save(h),t.namespaces=h,t.names=[],t.skips=[];let f,d=(typeof h=="string"?h:"").split(/[\s,]+/),p=d.length;for(f=0;f<p;f++)d[f]&&(h=d[f].replace(/\*/g,".*?"),h[0]==="-"?t.skips.push(new RegExp("^"+h.slice(1)+"$")):t.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),h}function o(h){if(h[h.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(h))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(h))return!0;return!1}function c(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}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}os.exports=$a});var as=F((oe,Yi)=>{"use strict";oe.formatArgs=Ha;oe.save=ja;oe.load=Ga;oe.useColors=Va;oe.storage=Ka();oe.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`."))}})();oe.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 Va(){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 Ha(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Yi.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,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}oe.log=console.debug||console.log||(()=>{});function ja(i){try{i?oe.storage.setItem("debug",i):oe.storage.removeItem("debug")}catch(e){}}function Ga(){let i;try{i=oe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Ka(){try{return localStorage}catch(i){}}Yi.exports=qr()(oe);var{formatters:Ya}=Yi.exports;Ya.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var ls=F((fu,cs)=>{"use strict";cs.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",r=e.indexOf(t+i),n=e.indexOf("--");return r!==-1&&(n===-1||r<n)}});var $r=F((uu,fs)=>{"use strict";var Ja=A("os"),hs=A("tty"),pe=ls(),{env:j}=process,Ge;pe("no-color")||pe("no-colors")||pe("color=false")||pe("color=never")?Ge=0:(pe("color")||pe("colors")||pe("color=true")||pe("color=always"))&&(Ge=1);"FORCE_COLOR"in j&&(j.FORCE_COLOR==="true"?Ge=1:j.FORCE_COLOR==="false"?Ge=0:Ge=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3));function Wr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function zr(i,e){if(Ge===0)return 0;if(pe("color=16m")||pe("color=full")||pe("color=truecolor"))return 3;if(pe("color=256"))return 2;if(i&&!e&&Ge===void 0)return 0;let t=Ge||0;if(j.TERM==="dumb")return t;if(process.platform==="win32"){let r=Ja.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in j)||j.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let r=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:t}function Xa(i){let e=zr(i,i&&i.isTTY);return Wr(e)}fs.exports={supportsColor:Xa,stdout:Wr(zr(!0,hs.isatty(1))),stderr:Wr(zr(!0,hs.isatty(2)))}});var ds=F((G,Xi)=>{"use strict";var Qa=A("tty"),Ji=A("util");G.init=sc;G.log=ic;G.formatArgs=ec;G.save=rc;G.load=nc;G.useColors=Za;G.destroy=Ji.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");G.colors=[6,2,3,4,5,1];try{let i=$r();i&&(i.stderr||i).level>=2&&(G.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){}G.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.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 Za(){return"colors"in G.inspectOpts?!!G.inspectOpts.colors:Qa.isatty(process.stderr.fd)}function ec(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
1
+ "use strict";(()=>{var Ba=Object.create;var Mi=Object.defineProperty,Ma=Object.defineProperties,qa=Object.getOwnPropertyDescriptor,Wa=Object.getOwnPropertyDescriptors,$a=Object.getOwnPropertyNames,Bi=Object.getOwnPropertySymbols,Ka=Object.getPrototypeOf,Gr=Object.prototype.hasOwnProperty,ts=Object.prototype.propertyIsEnumerable;var is=i=>{throw TypeError(i)},rs=Math.pow,jr=(i,e,t)=>e in i?Mi(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,g=(i,e)=>{for(var t in e||(e={}))Gr.call(e,t)&&jr(i,t,e[t]);if(Bi)for(var t of Bi(e))ts.call(e,t)&&jr(i,t,e[t]);return i},w=(i,e)=>Ma(i,Wa(e));var I=(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 Yr=(i,e)=>{var t={};for(var r in i)Gr.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&Bi)for(var r of Bi(i))e.indexOf(r)<0&&ts.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),za=(i,e)=>{for(var t in e)Mi(i,t,{get:e[t],enumerable:!0})},Va=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $a(e))!Gr.call(i,n)&&n!==t&&Mi(i,n,{get:()=>e[n],enumerable:!(r=qa(e,n))||r.enumerable});return i};var te=(i,e,t)=>(t=i!=null?Ba(Ka(i)):{},Va(e||!i||!i.__esModule?Mi(t,"default",{value:i,enumerable:!0}):t,i));var O=(i,e,t)=>jr(i,typeof e!="symbol"?e+"":e,t),Jr=(i,e,t)=>e.has(i)||is("Cannot "+t);var a=(i,e,t)=>(Jr(i,e,"read from private field"),t?t.call(i):e.get(i)),y=(i,e,t)=>e.has(i)?is("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),b=(i,e,t,r)=>(Jr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ge=(i,e,t)=>(Jr(i,e,"access private method"),t);var d=(i,e,t)=>new Promise((r,n)=>{var s=l=>{try{c(t.next(l))}catch(h){n(h)}},o=l=>{try{c(t.throw(l))}catch(h){n(h)}},c=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);c((t=t.apply(i,e)).next())});var fn=F((pd,Ds)=>{"use strict";var Ft=1e3,Ut=Ft*60,Dt=Ut*60,vt=Dt*24,yc=vt*7,gc=vt*365.25;Ds.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return vc(i);if(t==="number"&&isFinite(i))return e.long?Sc(i):bc(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function vc(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*gc;case"weeks":case"week":case"w":return t*yc;case"days":case"day":case"d":return t*vt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Dt;case"minutes":case"minute":case"mins":case"min":case"m":return t*Ut;case"seconds":case"second":case"secs":case"sec":case"s":return t*Ft;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function bc(i){var e=Math.abs(i);return e>=vt?Math.round(i/vt)+"d":e>=Dt?Math.round(i/Dt)+"h":e>=Ut?Math.round(i/Ut)+"m":e>=Ft?Math.round(i/Ft)+"s":i+"ms"}function Sc(i){var e=Math.abs(i);return e>=vt?Sr(i,e,vt,"day"):e>=Dt?Sr(i,e,Dt,"hour"):e>=Ut?Sr(i,e,Ut,"minute"):e>=Ft?Sr(i,e,Ft,"second"):i+" ms"}function Sr(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var dn=F((md,Bs)=>{"use strict";function _c(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=fn(),t.destroy=h,Object.keys(i).forEach(u=>{t[u]=i[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let f=0;for(let p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(u){let f,p=null,m,C;function v(..._){if(!v.enabled)return;let T=v,N=Number(new Date),S=N-(f||N);T.diff=S,T.prev=f,T.curr=N,f=N,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let E=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let le=_[E];R=$.call(T,le),_.splice(E,1),E--}return R}),t.formatArgs.call(T,_),(T.log||t.log).apply(T,_)}return v.namespace=u,v.useColors=t.useColors(),v.color=t.selectColor(u),v.extend=r,v.destroy=t.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(m!==t.namespaces&&(m=t.namespaces,C=t.enabled(u)),C),set:_=>{p=_}}),typeof t.init=="function"&&t.init(v),v}function r(u,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+u);return p.log=this.log,p}function n(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let f,p=(typeof u=="string"?u:"").split(/[\s,]+/),m=p.length;for(f=0;f<m;f++)p[f]&&(u=p[f].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let f,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(u))return!1;for(f=0,p=t.names.length;f<p;f++)if(t.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function h(){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}Bs.exports=_c});var Ms=F((he,_r)=>{"use strict";he.formatArgs=wc;he.save=xc;he.load=Cc;he.useColors=Ec;he.storage=Nc();he.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`."))}})();he.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 Ec(){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 wc(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+_r.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,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}he.log=console.debug||console.log||(()=>{});function xc(i){try{i?he.storage.setItem("debug",i):he.storage.removeItem("debug")}catch(e){}}function Cc(){let i;try{i=he.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Nc(){try{return localStorage}catch(i){}}_r.exports=dn()(he);var{formatters:kc}=_r.exports;kc.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Ws=F((yd,qs)=>{"use strict";qs.exports=(i,e=process.argv)=>{let t=i.startsWith("-")?"":i.length===1?"-":"--",r=e.indexOf(t+i),n=e.indexOf("--");return r!==-1&&(n===-1||r<n)}});var yn=F((gd,Ks)=>{"use strict";var Ac=I("os"),$s=I("tty"),ve=Ws(),{env:G}=process,ot;ve("no-color")||ve("no-colors")||ve("color=false")||ve("color=never")?ot=0:(ve("color")||ve("colors")||ve("color=true")||ve("color=always"))&&(ot=1);"FORCE_COLOR"in G&&(G.FORCE_COLOR==="true"?ot=1:G.FORCE_COLOR==="false"?ot=0:ot=G.FORCE_COLOR.length===0?1:Math.min(parseInt(G.FORCE_COLOR,10),3));function pn(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function mn(i,e){if(ot===0)return 0;if(ve("color=16m")||ve("color=full")||ve("color=truecolor"))return 3;if(ve("color=256"))return 2;if(i&&!e&&ot===void 0)return 0;let t=ot||0;if(G.TERM==="dumb")return t;if(process.platform==="win32"){let r=Ac.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in G)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(r=>r in G)||G.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in G)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(G.TEAMCITY_VERSION)?1:0;if(G.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in G){let r=parseInt((G.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(G.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(G.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(G.TERM)||"COLORTERM"in G?1:t}function Rc(i){let e=mn(i,i&&i.isTTY);return pn(e)}Ks.exports={supportsColor:Rc,stdout:pn(mn(!0,$s.isatty(1))),stderr:pn(mn(!0,$s.isatty(2)))}});var Vs=F((Y,wr)=>{"use strict";var Ic=I("tty"),Er=I("util");Y.init=Dc;Y.log=Lc;Y.formatArgs=Oc;Y.save=Fc;Y.load=Uc;Y.useColors=Tc;Y.destroy=Er.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Y.colors=[6,2,3,4,5,1];try{let i=yn();i&&(i.stderr||i).level>=2&&(Y.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){}Y.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.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 Tc(){return"colors"in Y.inspectOpts?!!Y.inspectOpts.colors:Ic.isatty(process.stderr.fd)}function Oc(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
2
2
  `).join(`
3
- `+s),i.push(n+"m+"+Xi.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=tc()+e+" "+i[0]}function tc(){return G.inspectOpts.hideDate?"":new Date().toISOString()+" "}function ic(...i){return process.stderr.write(Ji.formatWithOptions(G.inspectOpts,...i)+`
4
- `)}function rc(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function nc(){return process.env.DEBUG}function sc(i){i.inspectOpts={};let e=Object.keys(G.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=G.inspectOpts[e[t]]}Xi.exports=qr()(G);var{formatters:us}=Xi.exports;us.o=function(i){return this.inspectOpts.colors=this.useColors,Ji.inspect(i,this.inspectOpts).split(`
5
- `).map(e=>e.trim()).join(" ")};us.O=function(i){return this.inspectOpts.colors=this.useColors,Ji.inspect(i,this.inspectOpts)}});var at=F((du,Vr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Vr.exports=as():Vr.exports=ds()});var ws=F((Su,bs)=>{"use strict";var Ct=A("fs"),Ss=A("url"),cc=A("child_process").spawn;bs.exports=Gr;Gr.XMLHttpRequest=Gr;function Gr(i){"use strict";i=i||{};var e=this,t=A("http"),r=A("https"),n,s,o={},c=!1,l={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},u=Object.assign({},l),h=["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"],f=["TRACE","TRACK","CONNECT"],d=!1,p=!1,w=!1,g={};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(y){return c||y&&h.indexOf(y.toLowerCase())===-1},R=function(y){return y&&f.indexOf(y)===-1};this.open=function(y,b,$,N,P){if(this.abort(),p=!1,w=!1,!R(y))throw new Error("SecurityError: Request method not allowed");o={method:y,url:b.toString(),async:typeof $!="boolean"?!0:$,user:N||null,password:P||null},x(this.OPENED)},this.setDisableHeaderCheck=function(y){c=y},this.setRequestHeader=function(y,b){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!v(y))return console.warn('Refused to set unsafe header "'+y+'"'),!1;if(d)throw new Error("INVALID_STATE_ERR: send flag is true");return u[y]=b,!0},this.getResponseHeader=function(y){return typeof y=="string"&&this.readyState>this.OPENED&&s.headers[y.toLowerCase()]&&!p?s.headers[y.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||p)return"";var y="";for(var b in s.headers)b!=="set-cookie"&&b!=="set-cookie2"&&(y+=b+": "+s.headers[b]+`\r
6
- `);return y.substr(0,y.length-2)},this.getRequestHeader=function(y){return typeof y=="string"&&u[y]?u[y]:""},this.send=function(y){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 b=!1,$=!1,N=Ss.parse(o.url),P;switch(N.protocol){case"https:":b=!0;case"http:":P=N.hostname;break;case"file:":$=!0;break;case void 0:case"":P="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)Ct.readFile(unescape(N.pathname),"utf8",function(fe,pt){fe?e.handleError(fe,fe.errno||-1):(e.status=200,e.responseText=pt,x(e.DONE))});else try{this.responseText=Ct.readFileSync(unescape(N.pathname),"utf8"),this.status=200,x(e.DONE)}catch(fe){this.handleError(fe,fe.errno||-1)}return}var q=N.port||(b?443:80),ne=N.pathname+(N.search?N.search:"");if(u.Host=P,b&&q===443||q===80||(u.Host+=":"+N.port),o.user){typeof o.password=="undefined"&&(o.password="");var Ze=new Buffer(o.user+":"+o.password);u.Authorization="Basic "+Ze.toString("base64")}o.method==="GET"||o.method==="HEAD"?y=null:y?(u["Content-Length"]=Buffer.isBuffer(y)?y.length:Buffer.byteLength(y),u["Content-Type"]||(u["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(u["Content-Length"]=0);var et=i.agent||!1,ie={host:P,port:q,path:ne,method:o.method,headers:u,agent:et};if(b&&(ie.pfx=i.pfx,ie.key=i.key,ie.passphrase=i.passphrase,ie.cert=i.cert,ie.ca=i.ca,ie.ciphers=i.ciphers,ie.rejectUnauthorized=i.rejectUnauthorized!==!1),p=!1,o.async){var Be=b?r.request:t.request;d=!0,e.dispatchEvent("readystatechange");var Me=function(fe){if(s=fe,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var pt=Ss.parse(o.url);P=pt.hostname;var We={hostname:pt.hostname,port:pt.port,path:pt.path,method:s.statusCode===303?"GET":o.method,headers:u};b&&(We.pfx=i.pfx,We.key=i.key,We.passphrase=i.passphrase,We.cert=i.cert,We.ca=i.ca,We.ciphers=i.ciphers,We.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Be(We,Me).on("error",qe),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),x(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(mi){mi&&(e.responseText+=mi),d&&x(e.LOADING)}),s.on("end",function(){d&&(d=!1,x(e.DONE))}),s.on("error",function(mi){e.handleError(mi)})},qe=function(fe){e.handleError(fe)};n=Be(ie,Me).on("error",qe),i.autoUnref&&n.on("socket",fe=>{fe.unref()}),y&&n.write(y),n.end(),e.dispatchEvent("loadstart")}else{var me=".node-xmlhttprequest-content-"+process.pid,ge=".node-xmlhttprequest-sync-"+process.pid;Ct.writeFileSync(ge,"","utf8");for(var Te="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(b?"s":"")+".request;var options = "+JSON.stringify(ie)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+me+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+ge+"');});response.on('error', function(error) {fs.writeFileSync('"+me+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+ge+"');});}).on('error', function(error) {fs.writeFileSync('"+me+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+ge+"');});"+(y?"req.write('"+JSON.stringify(y).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",na=cc(process.argv[0],["-e",Te]),rh;Ct.existsSync(ge););if(e.responseText=Ct.readFileSync(me,"utf8"),na.stdin.end(),Ct.unlinkSync(me),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var sa=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(sa,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),x(e.DONE)}},this.handleError=function(y,b){this.status=b||0,this.statusText=y,this.responseText=y.stack,p=!0,x(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),u=Object.assign({},l),this.responseText="",this.responseXML="",p=w=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||d)&&this.readyState!==this.DONE&&(d=!1,x(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(y,b){y in g||(g[y]=[]),g[y].push(b)},this.removeEventListener=function(y,b){y in g&&(g[y]=g[y].filter(function($){return $!==b}))},this.dispatchEvent=function(y){if(typeof e["on"+y]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+y]()}):e["on"+y]()),y in g)for(let b=0,$=g[y].length;b<$;b++)this.readyState===this.DONE?setImmediate(function(){g[y][b].call(e)}):g[y][b].call(e)};var x=function(y){if(!(e.readyState===y||e.readyState===e.UNSENT&&w)&&(e.readyState=y,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let b;w?b="abort":p?b="error":b="load",e.dispatchEvent(b),e.dispatchEvent("loadend")}}}});var Ts=F((Ou,Rs)=>{"use strict";var{Duplex:uc}=A("stream");function ks(i){i.emit("close")}function dc(){!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 pc(i,e){let t=!0,r=new uc(T(E({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let c=!o&&r._readableState.objectMode?s.toString():s;r.push(c)||i.pause()}),i.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(n,s){if(i.readyState===i.CLOSED){s(n),process.nextTick(ks,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(ks,r)}),t&&i.terminate()},r._final=function(n){if(i.readyState===i.CONNECTING){i.once("open",function(){r._final(n)});return}i._socket!==null&&(i._socket._writableState.finished?(n(),r._readableState.endEmitted&&r.destroy()):(i._socket.once("finish",function(){n()}),i.close()))},r._read=function(){i.isPaused&&i.resume()},r._write=function(n,s,o){if(i.readyState===i.CONNECTING){i.once("open",function(){r._write(n,s,o)});return}i.send(n,o)},r.on("end",dc),r.on("error",As),r}Rs.exports=pc});var Ye=F((Pu,Os)=>{"use strict";Os.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 Xt=F((Lu,tr)=>{"use strict";var{EMPTY_BUFFER:mc}=Ye();function gc(i,e){if(i.length===0)return mc;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let n=0;n<i.length;n++){let s=i[n];t.set(s,r),r+=s.length}return r<e?t.slice(0,r):t}function Is(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function Ps(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function yc(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Xr(i){if(Xr.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),Xr.readOnly=!1),e}tr.exports={concat:gc,mask:Is,toArrayBuffer:yc,toBuffer:Xr,unmask:Ps};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=A("bufferutil");tr.exports.mask=function(e,t,r,n,s){s<48?Is(e,t,r,n,s):i.mask(e,t,r,n,s)},tr.exports.unmask=function(e,t){e.length<32?Ps(e,t):i.unmask(e,t)}}catch(i){}});var Us=F((Fu,Fs)=>{"use strict";var Ls=Symbol("kDone"),Qr=Symbol("kRun"),Zr=class{constructor(e){this[Ls]=()=>{this.pending--,this[Qr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Qr]()}[Qr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ls])}}};Fs.exports=Zr});var ei=F((Uu,qs)=>{"use strict";var Qt=A("zlib"),Ds=Xt(),vc=Us(),{kStatusCode:Bs}=Ye(),_c=Buffer.from([0,0,255,255]),nr=Symbol("permessage-deflate"),Fe=Symbol("total-length"),Zt=Symbol("callback"),Je=Symbol("buffers"),rr=Symbol("error"),ir,en=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,!ir){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ir=new vc(n)}}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[Zt];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(n=>!(t.serverNoContextTakeover===!1&&n.server_no_context_takeover||n.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>n.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!n.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 n=t[r];if(n.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(n=n[0],r==="client_max_window_bits"){if(n!==!0){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else if(r==="server_max_window_bits"){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(n!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=n})}),e}decompress(e,t,r){ir.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){ir.add(n=>{this._compress(e,t,(s,o)=>{n(),r(s,o)})})}_decompress(e,t,r){let n=this._isServer?"client":"server";if(!this._inflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Qt.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Qt.createInflateRaw(T(E({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[nr]=this,this._inflate[Fe]=0,this._inflate[Je]=[],this._inflate.on("error",Sc),this._inflate.on("data",Ms)}this._inflate[Zt]=r,this._inflate.write(e),t&&this._inflate.write(_c),this._inflate.flush(()=>{let s=this._inflate[rr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Ds.concat(this._inflate[Je],this._inflate[Fe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Fe]=0,this._inflate[Je]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let n=this._isServer?"server":"client";if(!this._deflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?Qt.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Qt.createDeflateRaw(T(E({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Fe]=0,this._deflate[Je]=[],this._deflate.on("data",Ec)}this._deflate[Zt]=r,this._deflate.write(e),this._deflate.flush(Qt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Ds.concat(this._deflate[Je],this._deflate[Fe]);t&&(s=s.slice(0,s.length-4)),this._deflate[Zt]=null,this._deflate[Fe]=0,this._deflate[Je]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};qs.exports=en;function Ec(i){this[Je].push(i),this[Fe]+=i.length}function Ms(i){if(this[Fe]+=i.length,this[nr]._maxPayload<1||this[Fe]<=this[nr]._maxPayload){this[Je].push(i);return}this[rr]=new RangeError("Max payload size exceeded"),this[rr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[rr][Bs]=1009,this.removeListener("data",Ms),this.reset()}function Sc(i){this[nr]._inflate=null,i[Bs]=1007,this[Zt](i)}});var ti=F((Bu,tn)=>{"use strict";var bc=[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 wc(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function Ws(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}tn.exports={isValidStatusCode:wc,isValidUTF8:Ws,tokenChars:bc};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=A("utf-8-validate");tn.exports.isValidUTF8=function(e){return e.length<150?Ws(e):i(e)}}catch(i){}});var on=F((Mu,Ks)=>{"use strict";var{Writable:xc}=A("stream"),zs=ei(),{BINARY_TYPES:Cc,EMPTY_BUFFER:$s,kStatusCode:Nc,kWebSocket:kc}=Ye(),{concat:rn,toArrayBuffer:Ac,unmask:Rc}=Xt(),{isValidStatusCode:Tc,isValidUTF8:Vs}=ti(),ii=0,Hs=1,js=2,Gs=3,nn=4,Oc=5,sn=class extends xc{constructor(e={}){super(),this._binaryType=e.binaryType||Cc[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[kc]=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=ii,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==ii)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],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),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 ii:t=this.getInfo();break;case Hs:t=this.getPayloadLength16();break;case js:t=this.getPayloadLength64();break;case Gs:this.getMask();break;case nn: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,W(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[zs.extensionName])return this._loop=!1,W(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,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,W(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,W(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,W(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,W(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,W(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,W(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,W(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,W(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Hs;else if(this._payloadLength===127)this._state=js;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,W(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,W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Gs:this._state=nn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=nn}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]&&Rc(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=Oc,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[zs.extensionName].decompress(e,this._fin,(n,s)=>{if(n)return t(n);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(W(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}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=rn(t,e):this._binaryType==="arraybuffer"?r=Ac(rn(t,e)):r=t,this.emit("message",r,!0)}else{let r=rn(t,e);if(!this._skipUTF8Validation&&!Vs(r))return this._loop=!1,W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=ii}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 W(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!Tc(t))return W(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!Vs(r))return W(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=ii}};Ks.exports=sn;function W(i,e,t,r,n){let s=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,W),s.code=n,s[Nc]=r,s}});var cn=F((zu,Xs)=>{"use strict";var qu=A("net"),Wu=A("tls"),{randomFillSync:Ic}=A("crypto"),Ys=ei(),{EMPTY_BUFFER:Pc}=Ye(),{isValidStatusCode:Lc}=ti(),{mask:Js,toBuffer:Nt}=Xt(),be=Symbol("kByteLength"),Fc=Buffer.alloc(4),an=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,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||Fc,t.generateMask?t.generateMask(r):Ic(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[be]!==void 0?c=t[be]:(e=Buffer.from(e),c=e.length):(c=e.length,n=t.mask&&t.readOnly&&!o);let l=c;c>=65536?(s+=8,l=127):c>125&&(s+=2,l=126);let u=Buffer.allocUnsafe(n?c+s:s);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=l,l===126?u.writeUInt16BE(c,2):l===127&&(u[2]=u[3]=0,u.writeUIntBE(c,4,6)),t.mask?(u[1]|=128,u[s-4]=r[0],u[s-3]=r[1],u[s-2]=r[2],u[s-1]=r[3],o?[u,e]:n?(Js(e,r,u,s,c),[u]):(Js(e,r,e,0,c),[u,e])):[u,e]}close(e,t,r,n){let s;if(e===void 0)s=Pc;else{if(typeof e!="number"||!Lc(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let c=Buffer.byteLength(t);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(e,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let o={[be]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,n]):this.sendFrame(i.frame(s,o),n)}ping(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Nt(e),n=e.length,s=Nt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[be]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[Ys.extensionName],s=t.binary?2:1,o=t.compress,c,l;if(typeof e=="string"?(c=Buffer.byteLength(e),l=!1):(e=Nt(e),c=e.length,l=Nt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0),n){let u={[be]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,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,{[be]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Ys.extensionName];this._bufferedBytes+=r[be],this._deflating=!0,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(l);for(let u=0;u<this._queue.length;u++){let h=this._queue[u],f=h[h.length-1];typeof f=="function"&&f(l)}return}this._bufferedBytes-=r[be],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][be],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][be],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=an});var oo=F(($u,so)=>{"use strict";var{kForOnEventAttribute:ri,kListener:ln}=Ye(),Qs=Symbol("kCode"),Zs=Symbol("kData"),eo=Symbol("kError"),to=Symbol("kMessage"),io=Symbol("kReason"),kt=Symbol("kTarget"),ro=Symbol("kType"),no=Symbol("kWasClean"),Ue=class{constructor(e){this[kt]=null,this[ro]=e}get target(){return this[kt]}get type(){return this[ro]}};Object.defineProperty(Ue.prototype,"target",{enumerable:!0});Object.defineProperty(Ue.prototype,"type",{enumerable:!0});var ct=class extends Ue{constructor(e,t={}){super(e),this[Qs]=t.code===void 0?0:t.code,this[io]=t.reason===void 0?"":t.reason,this[no]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Qs]}get reason(){return this[io]}get wasClean(){return this[no]}};Object.defineProperty(ct.prototype,"code",{enumerable:!0});Object.defineProperty(ct.prototype,"reason",{enumerable:!0});Object.defineProperty(ct.prototype,"wasClean",{enumerable:!0});var At=class extends Ue{constructor(e,t={}){super(e),this[eo]=t.error===void 0?null:t.error,this[to]=t.message===void 0?"":t.message}get error(){return this[eo]}get message(){return this[to]}};Object.defineProperty(At.prototype,"error",{enumerable:!0});Object.defineProperty(At.prototype,"message",{enumerable:!0});var ni=class extends Ue{constructor(e,t={}){super(e),this[Zs]=t.data===void 0?null:t.data}get data(){return this[Zs]}};Object.defineProperty(ni.prototype,"data",{enumerable:!0});var Uc={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[ri]&&n[ln]===e&&!n[ri])return;let r;if(i==="message")r=function(s,o){let c=new ni("message",{data:o?s:s.toString()});c[kt]=this,sr(e,this,c)};else if(i==="close")r=function(s,o){let c=new ct("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[kt]=this,sr(e,this,c)};else if(i==="error")r=function(s){let o=new At("error",{error:s,message:s.message});o[kt]=this,sr(e,this,o)};else if(i==="open")r=function(){let s=new Ue("open");s[kt]=this,sr(e,this,s)};else return;r[ri]=!!t[ri],r[ln]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[ln]===e&&!t[ri]){this.removeListener(i,t);break}}};so.exports={CloseEvent:ct,ErrorEvent:At,Event:Ue,EventTarget:Uc,MessageEvent:ni};function sr(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var hn=F((Vu,ao)=>{"use strict";var{tokenChars:si}=ti();function ke(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function Dc(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,c,l=-1,u=-1,h=-1,f=0;for(;f<i.length;f++)if(u=i.charCodeAt(f),o===void 0)if(h===-1&&si[u]===1)l===-1&&(l=f);else if(f!==0&&(u===32||u===9))h===-1&&l!==-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f);let p=i.slice(l,h);u===44?(ke(e,p,t),t=Object.create(null)):o=p,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(h===-1&&si[u]===1)l===-1&&(l=f);else if(u===32||u===9)h===-1&&l!==-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f),ke(t,i.slice(l,h),!0),u===44&&(ke(e,o,t),t=Object.create(null),o=void 0),l=h=-1}else if(u===61&&l!==-1&&h===-1)c=i.slice(l,f),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(si[u]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(si[u]===1)l===-1&&(l=f);else if(u===34&&l!==-1)s=!1,h=f;else if(u===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(u===34&&i.charCodeAt(f-1)===61)s=!0;else if(h===-1&&si[u]===1)l===-1&&(l=f);else if(l!==-1&&(u===32||u===9))h===-1&&(h=f);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);h===-1&&(h=f);let p=i.slice(l,h);r&&(p=p.replace(/\\/g,""),r=!1),ke(t,c,p),u===44&&(ke(e,o,t),t=Object.create(null),o=void 0),c=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||s||u===32||u===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=f);let d=i.slice(l,h);return o===void 0?ke(e,d,t):(c===void 0?ke(t,d,!0):r?ke(t,c,d.replace(/\\/g,"")):ke(t,c,d),ke(e,o,t)),e}function Bc(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(n=>{let s=r[n];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?n:`${n}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}ao.exports={format:Bc,parse:Dc}});var mn=F((ju,_o)=>{"use strict";var Mc=A("events"),qc=A("https"),Wc=A("http"),ho=A("net"),zc=A("tls"),{randomBytes:$c,createHash:Vc}=A("crypto"),{Readable:Hu}=A("stream"),{URL:fn}=A("url"),Xe=ei(),Hc=on(),jc=cn(),{BINARY_TYPES:co,EMPTY_BUFFER:or,GUID:Gc,kForOnEventAttribute:un,kListener:Kc,kStatusCode:Yc,kWebSocket:te,NOOP:fo}=Ye(),{EventTarget:{addEventListener:Jc,removeEventListener:Xc}}=oo(),{format:Qc,parse:Zc}=hn(),{toBuffer:el}=Xt(),tl=30*1e3,uo=Symbol("kAborted"),dn=[8,13],De=["CONNECTING","OPEN","CLOSING","CLOSED"],il=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,B=class i extends Mc{constructor(e,t,r){super(),this._binaryType=co[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=or,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]),po(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){co.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 n=new Hc({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new jc(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[te]=this,e[te]=this,n.on("conclude",sl),n.on("drain",ol),n.on("error",al),n.on("message",cl),n.on("ping",ll),n.on("pong",hl),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",go),e.on("data",cr),e.on("end",yo),e.on("error",vo),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[Xe.extensionName]&&this._extensions[Xe.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 ae(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),tl)}}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){pn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||or,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){pn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||or,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){pn(this,e,r);return}let n=E({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[Xe.extensionName]||(n.compress=!1),this._sender.send(e||or,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return ae(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(B,"CONNECTING",{enumerable:!0,value:De.indexOf("CONNECTING")});Object.defineProperty(B.prototype,"CONNECTING",{enumerable:!0,value:De.indexOf("CONNECTING")});Object.defineProperty(B,"OPEN",{enumerable:!0,value:De.indexOf("OPEN")});Object.defineProperty(B.prototype,"OPEN",{enumerable:!0,value:De.indexOf("OPEN")});Object.defineProperty(B,"CLOSING",{enumerable:!0,value:De.indexOf("CLOSING")});Object.defineProperty(B.prototype,"CLOSING",{enumerable:!0,value:De.indexOf("CLOSING")});Object.defineProperty(B,"CLOSED",{enumerable:!0,value:De.indexOf("CLOSED")});Object.defineProperty(B.prototype,"CLOSED",{enumerable:!0,value:De.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(B.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(B.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[un])return e[Kc];return null},set(e){for(let t of this.listeners(i))if(t[un]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[un]:!0})}})});B.prototype.addEventListener=Jc;B.prototype.removeEventListener=Xc;_o.exports=B;function po(i,e,t,r){let n=T(E({protocolVersion:dn[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(!dn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${dn.join(", ")})`);let s;if(e instanceof fn)s=e,i._url=e.href;else{try{s=new fn(e)}catch(g){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",c=s.protocol==="ws+unix:",l;if(s.protocol!=="ws:"&&!o&&!c?l=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let g=new SyntaxError(l);if(i._redirects===0)throw g;ar(i,g);return}let u=o?443:80,h=$c(16).toString("base64"),f=o?qc.request:Wc.request,d=new Set,p;if(n.createConnection=o?nl:rl,n.defaultPort=n.defaultPort||u,n.port=s.port||u,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=T(E({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(p=new Xe(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=Qc({[Xe.extensionName]:p.offer()})),t.length){for(let g of t){if(typeof g!="string"||!il.test(g)||d.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");d.add(g)}n.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(s.username||s.password)&&(n.auth=`${s.username}:${s.password}`),c){let g=n.path.split(":");n.socketPath=g[0],n.path=g[1]}let w;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let g=r&&r.headers;if(r=T(E({},r),{headers:{}}),g)for(let[v,R]of Object.entries(g))r.headers[v.toLowerCase()]=R}else if(i.listenerCount("redirect")===0){let g=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!g||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,g||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),w=i._req=f(n),i._redirects&&i.emit("redirect",i.url,w)}else w=i._req=f(n);n.timeout&&w.on("timeout",()=>{ae(i,w,"Opening handshake has timed out")}),w.on("error",g=>{w===null||w[uo]||(w=i._req=null,ar(i,g))}),w.on("response",g=>{let v=g.headers.location,R=g.statusCode;if(v&&n.followRedirects&&R>=300&&R<400){if(++i._redirects>n.maxRedirects){ae(i,w,"Maximum redirects exceeded");return}w.abort();let x;try{x=new fn(v,e)}catch(y){let b=new SyntaxError(`Invalid URL: ${v}`);ar(i,b);return}po(i,x,t,r)}else i.emit("unexpected-response",w,g)||ae(i,w,`Unexpected server response: ${g.statusCode}`)}),w.on("upgrade",(g,v,R)=>{if(i.emit("upgrade",g),i.readyState!==B.CONNECTING)return;if(w=i._req=null,g.headers.upgrade.toLowerCase()!=="websocket"){ae(i,v,"Invalid Upgrade header");return}let x=Vc("sha1").update(h+Gc).digest("base64");if(g.headers["sec-websocket-accept"]!==x){ae(i,v,"Invalid Sec-WebSocket-Accept header");return}let y=g.headers["sec-websocket-protocol"],b;if(y!==void 0?d.size?d.has(y)||(b="Server sent an invalid subprotocol"):b="Server sent a subprotocol but none was requested":d.size&&(b="Server sent no subprotocol"),b){ae(i,v,b);return}y&&(i._protocol=y);let $=g.headers["sec-websocket-extensions"];if($!==void 0){if(!p){ae(i,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let N;try{N=Zc($)}catch(q){ae(i,v,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(N);if(P.length!==1||P[0]!==Xe.extensionName){ae(i,v,"Server indicated an extension that was not requested");return}try{p.accept(N[Xe.extensionName])}catch(q){ae(i,v,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[Xe.extensionName]=p}i.setSocket(v,R,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),w.end()}function ar(i,e){i._readyState=B.CLOSING,i.emit("error",e),i.emitClose()}function rl(i){return i.path=i.socketPath,ho.connect(i)}function nl(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=ho.isIP(i.host)?"":i.host),zc.connect(i)}function ae(i,e,t){i._readyState=B.CLOSING;let r=new Error(t);Error.captureStackTrace(r,ae),e.setHeader?(e[uo]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(ar,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function pn(i,e,t){if(e){let r=el(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${De[i.readyState]})`);t(r)}}function sl(i,e){let t=this[te];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[te]!==void 0&&(t._socket.removeListener("data",cr),process.nextTick(mo,t._socket),i===1005?t.close():t.close(i,e))}function ol(){let i=this[te];i.isPaused||i._socket.resume()}function al(i){let e=this[te];e._socket[te]!==void 0&&(e._socket.removeListener("data",cr),process.nextTick(mo,e._socket),e.close(i[Yc])),e.emit("error",i)}function lo(){this[te].emitClose()}function cl(i,e){this[te].emit("message",i,e)}function ll(i){let e=this[te];e.pong(i,!e._isServer,fo),e.emit("ping",i)}function hl(i){this[te].emit("pong",i)}function mo(i){i.resume()}function go(){let i=this[te];this.removeListener("close",go),this.removeListener("data",cr),this.removeListener("end",yo),i._readyState=B.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[te]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",lo),i._receiver.on("finish",lo))}function cr(i){this[te]._receiver.write(i)||this.pause()}function yo(){let i=this[te];i._readyState=B.CLOSING,i._receiver.end(),this.end()}function vo(){let i=this[te];this.removeListener("error",vo),this.on("error",fo),i&&(i._readyState=B.CLOSING,this.destroy())}});var So=F((Ku,Eo)=>{"use strict";var{tokenChars:fl}=ti();function ul(i){let e=new Set,t=-1,r=-1,n=0;for(n;n<i.length;n++){let o=i.charCodeAt(n);if(r===-1&&fl[o]===1)t===-1&&(t=n);else if(n!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=n);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${n}`);r===-1&&(r=n);let c=i.slice(t,r);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${n}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=i.slice(t,n);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}Eo.exports={parse:ul}});var Ao=F((Qu,ko)=>{"use strict";var dl=A("events"),lr=A("http"),Yu=A("https"),Ju=A("net"),Xu=A("tls"),{createHash:pl}=A("crypto"),bo=hn(),lt=ei(),ml=So(),gl=mn(),{GUID:yl,kWebSocket:vl}=Ye(),_l=/^[+/0-9A-Za-z]{22}==$/,wo=0,xo=1,No=2,gn=class extends dl{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:gl},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=lr.createServer((r,n)=>{let s=lr.STATUS_CODES[426];n.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),n.end(s)}),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=El(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(n,s,o)=>{this.handleUpgrade(n,s,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=wo}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===No){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(oi,this);return}if(e&&this.once("close",e),this._state!==xo)if(this._state=xo,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(oi,this):process.nextTick(oi,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{oi(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,n){t.on("error",Co);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){ht(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){ht(this,e,t,400,"Invalid Upgrade header");return}if(!s||!_l.test(s)){ht(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){ht(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){ai(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=ml.parse(c)}catch(f){ht(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&u!==void 0){let f=new lt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let d=bo.parse(u);d[lt.extensionName]&&(f.accept(d[lt.extensionName]),h[lt.extensionName]=f)}catch(d){ht(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={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(f,(d,p,w,g)=>{if(!d)return ai(t,p||401,w,g);this.completeUpgrade(h,s,l,e,t,r,n)});return}if(!this.options.verifyClient(f))return ai(t,401)}this.completeUpgrade(h,s,l,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[vl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>wo)return ai(s,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${pl("sha1").update(t+yl).digest("base64")}`],h=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(u.push(`Sec-WebSocket-Protocol: ${f}`),h._protocol=f)}if(e[lt.extensionName]){let f=e[lt.extensionName].params,d=bo.format({[lt.extensionName]:[f]});u.push(`Sec-WebSocket-Extensions: ${d}`),h._extensions=e}this.emit("headers",u,n),s.write(u.concat(`\r
3
+ `+s),i.push(n+"m+"+wr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=Pc()+e+" "+i[0]}function Pc(){return Y.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Lc(...i){return process.stderr.write(Er.formatWithOptions(Y.inspectOpts,...i)+`
4
+ `)}function Fc(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Uc(){return process.env.DEBUG}function Dc(i){i.inspectOpts={};let e=Object.keys(Y.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=Y.inspectOpts[e[t]]}wr.exports=dn()(Y);var{formatters:zs}=wr.exports;zs.o=function(i){return this.inspectOpts.colors=this.useColors,Er.inspect(i,this.inspectOpts).split(`
5
+ `).map(e=>e.trim()).join(" ")};zs.O=function(i){return this.inspectOpts.colors=this.useColors,Er.inspect(i,this.inspectOpts)}});var bt=F((vd,gn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?gn.exports=Ms():gn.exports=Vs()});var to=F((Nd,eo)=>{"use strict";var Bt=I("fs"),Zs=I("url"),qc=I("child_process").spawn;eo.exports=Sn;Sn.XMLHttpRequest=Sn;function Sn(i){"use strict";i=i||{};var e=this,t=I("http"),r=I("https"),n,s,o={},c=!1,l={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},h=Object.assign({},l),u=["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"],f=["TRACE","TRACK","CONNECT"],p=!1,m=!1,C=!1,v={};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 _=function(S){return c||S&&u.indexOf(S.toLowerCase())===-1},T=function(S){return S&&f.indexOf(S)===-1};this.open=function(S,E,V,R,P){if(this.abort(),m=!1,C=!1,!T(S))throw new Error("SecurityError: Request method not allowed");o={method:S,url:E.toString(),async:typeof V!="boolean"?!0:V,user:R||null,password:P||null},N(this.OPENED)},this.setDisableHeaderCheck=function(S){c=S},this.setRequestHeader=function(S,E){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!_(S))return console.warn('Refused to set unsafe header "'+S+'"'),!1;if(p)throw new Error("INVALID_STATE_ERR: send flag is true");return h[S]=E,!0},this.getResponseHeader=function(S){return typeof S=="string"&&this.readyState>this.OPENED&&s.headers[S.toLowerCase()]&&!m?s.headers[S.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||m)return"";var S="";for(var E in s.headers)E!=="set-cookie"&&E!=="set-cookie2"&&(S+=E+": "+s.headers[E]+`\r
6
+ `);return S.substr(0,S.length-2)},this.getRequestHeader=function(S){return typeof S=="string"&&h[S]?h[S]:""},this.send=function(S){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(p)throw new Error("INVALID_STATE_ERR: send has already been called");var E=!1,V=!1,R=Zs.parse(o.url),P;switch(R.protocol){case"https:":E=!0;case"http:":P=R.hostname;break;case"file:":V=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if(V){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Bt.readFile(unescape(R.pathname),"utf8",function(ye,Nt){ye?e.handleError(ye,ye.errno||-1):(e.status=200,e.responseText=Nt,N(e.DONE))});else try{this.responseText=Bt.readFileSync(unescape(R.pathname),"utf8"),this.status=200,N(e.DONE)}catch(ye){this.handleError(ye,ye.errno||-1)}return}var $=R.port||(E?443:80),le=R.pathname+(R.search?R.search:"");if(h.Host=P,E&&$===443||$===80||(h.Host+=":"+R.port),o.user){typeof o.password=="undefined"&&(o.password="");var ht=new Buffer(o.user+":"+o.password);h.Authorization="Basic "+ht.toString("base64")}o.method==="GET"||o.method==="HEAD"?S=null:S?(h["Content-Length"]=Buffer.isBuffer(S)?S.length:Buffer.byteLength(S),h["Content-Type"]||(h["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(h["Content-Length"]=0);var ft=i.agent||!1,se={host:P,port:$,path:le,method:o.method,headers:h,agent:ft};if(E&&(se.pfx=i.pfx,se.key=i.key,se.passphrase=i.passphrase,se.cert=i.cert,se.ca=i.ca,se.ciphers=i.ciphers,se.rejectUnauthorized=i.rejectUnauthorized!==!1),m=!1,o.async){var Ge=E?r.request:t.request;p=!0,e.dispatchEvent("readystatechange");var Ye=function(ye){if(s=ye,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var Nt=Zs.parse(o.url);P=Nt.hostname;var Xe={hostname:Nt.hostname,port:Nt.port,path:Nt.path,method:s.statusCode===303?"GET":o.method,headers:h};E&&(Xe.pfx=i.pfx,Xe.key=i.key,Xe.passphrase=i.passphrase,Xe.cert=i.cert,Xe.ca=i.ca,Xe.ciphers=i.ciphers,Xe.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Ge(Xe,Ye).on("error",Je),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(Di){Di&&(e.responseText+=Di),p&&N(e.LOADING)}),s.on("end",function(){p&&(p=!1,N(e.DONE))}),s.on("error",function(Di){e.handleError(Di)})},Je=function(ye){e.handleError(ye)};n=Ge(se,Ye).on("error",Je),i.autoUnref&&n.on("socket",ye=>{ye.unref()}),S&&n.write(S),n.end(),e.dispatchEvent("loadstart")}else{var be=".node-xmlhttprequest-content-"+process.pid,Se=".node-xmlhttprequest-sync-"+process.pid;Bt.writeFileSync(Se,"","utf8");for(var Fe="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(E?"s":"")+".request;var options = "+JSON.stringify(se)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+be+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+Se+"');});response.on('error', function(error) {fs.writeFileSync('"+be+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Se+"');});}).on('error', function(error) {fs.writeFileSync('"+be+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Se+"');});"+(S?"req.write('"+JSON.stringify(S).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Ua=qc(process.argv[0],["-e",Fe]),Fu;Bt.existsSync(Se););if(e.responseText=Bt.readFileSync(be,"utf8"),Ua.stdin.end(),Bt.unlinkSync(be),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var Da=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(Da,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),N(e.DONE)}},this.handleError=function(S,E){this.status=E||0,this.statusText=S,this.responseText=S.stack,m=!0,N(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),h=Object.assign({},l),this.responseText="",this.responseXML="",m=C=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||p)&&this.readyState!==this.DONE&&(p=!1,N(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(S,E){S in v||(v[S]=[]),v[S].push(E)},this.removeEventListener=function(S,E){S in v&&(v[S]=v[S].filter(function(V){return V!==E}))},this.dispatchEvent=function(S){if(typeof e["on"+S]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+S]()}):e["on"+S]()),S in v)for(let E=0,V=v[S].length;E<V;E++)this.readyState===this.DONE?setImmediate(function(){v[S][E].call(e)}):v[S][E].call(e)};var N=function(S){if(!(e.readyState===S||e.readyState===e.UNSENT&&C)&&(e.readyState=S,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let E;C?E="abort":m?E="error":E="load",e.dispatchEvent(E),e.dispatchEvent("loadend")}}}});var co=F((Ud,ao)=>{"use strict";var{Duplex:zc}=I("stream");function so(i){i.emit("close")}function Vc(){!this.destroyed&&this._writableState.finished&&this.destroy()}function oo(i){this.removeListener("error",oo),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function Hc(i,e){let t=!0,r=new zc(w(g({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return i.on("message",function(s,o){let c=!o&&r._readableState.objectMode?s.toString():s;r.push(c)||i.pause()}),i.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),i.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(n,s){if(i.readyState===i.CLOSED){s(n),process.nextTick(so,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(so,r)}),t&&i.terminate()},r._final=function(n){if(i.readyState===i.CONNECTING){i.once("open",function(){r._final(n)});return}i._socket!==null&&(i._socket._writableState.finished?(n(),r._readableState.endEmitted&&r.destroy()):(i._socket.once("finish",function(){n()}),i.close()))},r._read=function(){i.isPaused&&i.resume()},r._write=function(n,s,o){if(i.readyState===i.CONNECTING){i.once("open",function(){r._write(n,s,o)});return}i.send(n,o)},r.on("end",Vc),r.on("error",oo),r}ao.exports=Hc});var ct=F((Bd,lo)=>{"use strict";lo.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 vi=F((Md,kr)=>{"use strict";var{EMPTY_BUFFER:jc}=ct();function Gc(i,e){if(i.length===0)return jc;if(i.length===1)return i[0];let t=Buffer.allocUnsafe(e),r=0;for(let n=0;n<i.length;n++){let s=i[n];t.set(s,r),r+=s.length}return r<e?t.slice(0,r):t}function uo(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function ho(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function Yc(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function xn(i){if(xn.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),xn.readOnly=!1),e}kr.exports={concat:Gc,mask:uo,toArrayBuffer:Yc,toBuffer:xn,unmask:ho};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=I("bufferutil");kr.exports.mask=function(e,t,r,n,s){s<48?uo(e,t,r,n,s):i.mask(e,t,r,n,s)},kr.exports.unmask=function(e,t){e.length<32?ho(e,t):i.unmask(e,t)}}catch(i){}});var mo=F((qd,po)=>{"use strict";var fo=Symbol("kDone"),Cn=Symbol("kRun"),Nn=class{constructor(e){this[fo]=()=>{this.pending--,this[Cn]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Cn]()}[Cn](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[fo])}}};po.exports=Nn});var _i=F((Wd,bo)=>{"use strict";var bi=I("zlib"),yo=vi(),Jc=mo(),{kStatusCode:go}=ct(),Xc=Buffer.from([0,0,255,255]),Ir=Symbol("permessage-deflate"),ze=Symbol("total-length"),Si=Symbol("callback"),lt=Symbol("buffers"),Rr=Symbol("error"),Ar,kn=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,!Ar){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ar=new Jc(n)}}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[Si];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(n=>!(t.serverNoContextTakeover===!1&&n.server_no_context_takeover||n.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>n.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!n.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 n=t[r];if(n.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(n=n[0],r==="client_max_window_bits"){if(n!==!0){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else if(r==="server_max_window_bits"){let s=+n;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${n}`);n=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(n!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${n}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=n})}),e}decompress(e,t,r){Ar.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){Ar.add(n=>{this._compress(e,t,(s,o)=>{n(),r(s,o)})})}_decompress(e,t,r){let n=this._isServer?"client":"server";if(!this._inflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?bi.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=bi.createInflateRaw(w(g({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[Ir]=this,this._inflate[ze]=0,this._inflate[lt]=[],this._inflate.on("error",Zc),this._inflate.on("data",vo)}this._inflate[Si]=r,this._inflate.write(e),t&&this._inflate.write(Xc),this._inflate.flush(()=>{let s=this._inflate[Rr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=yo.concat(this._inflate[lt],this._inflate[ze]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[ze]=0,this._inflate[lt]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,t,r){let n=this._isServer?"server":"client";if(!this._deflate){let s=`${n}_max_window_bits`,o=typeof this.params[s]!="number"?bi.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=bi.createDeflateRaw(w(g({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[ze]=0,this._deflate[lt]=[],this._deflate.on("data",Qc)}this._deflate[Si]=r,this._deflate.write(e),this._deflate.flush(bi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=yo.concat(this._deflate[lt],this._deflate[ze]);t&&(s=s.slice(0,s.length-4)),this._deflate[Si]=null,this._deflate[ze]=0,this._deflate[lt]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};bo.exports=kn;function Qc(i){this[lt].push(i),this[ze]+=i.length}function vo(i){if(this[ze]+=i.length,this[Ir]._maxPayload<1||this[ze]<=this[Ir]._maxPayload){this[lt].push(i);return}this[Rr]=new RangeError("Max payload size exceeded"),this[Rr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Rr][go]=1009,this.removeListener("data",vo),this.reset()}function Zc(i){this[Ir]._inflate=null,i[go]=1007,this[Si](i)}});var Ei=F((Kd,An)=>{"use strict";var el=[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 tl(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function So(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}An.exports={isValidStatusCode:tl,isValidUTF8:So,tokenChars:el};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=I("utf-8-validate");An.exports.isValidUTF8=function(e){return e.length<150?So(e):i(e)}}catch(i){}});var On=F((zd,ko)=>{"use strict";var{Writable:il}=I("stream"),_o=_i(),{BINARY_TYPES:rl,EMPTY_BUFFER:Eo,kStatusCode:nl,kWebSocket:sl}=ct(),{concat:Rn,toArrayBuffer:ol,unmask:al}=vi(),{isValidStatusCode:cl,isValidUTF8:wo}=Ei(),wi=0,xo=1,Co=2,No=3,In=4,ll=5,Tn=class extends il{constructor(e={}){super(),this._binaryType=e.binaryType||rl[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[sl]=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=wi,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==wi)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],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),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 wi:t=this.getInfo();break;case xo:t=this.getPayloadLength16();break;case Co:t=this.getPayloadLength64();break;case No:this.getMask();break;case In: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,K(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[_o.extensionName])return this._loop=!1,K(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,K(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,K(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,K(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,K(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,K(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,K(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,K(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,K(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,K(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=xo;else if(this._payloadLength===127)this._state=Co;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,K(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,K(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=No:this._state=In}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=In}getData(e){let t=Eo;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]&&al(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=ll,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[_o.extensionName].decompress(e,this._fin,(n,s)=>{if(n)return t(n);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(K(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}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=Rn(t,e):this._binaryType==="arraybuffer"?r=ol(Rn(t,e)):r=t,this.emit("message",r,!0)}else{let r=Rn(t,e);if(!this._skipUTF8Validation&&!wo(r))return this._loop=!1,K(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=wi}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Eo),this.end();else{if(e.length===1)return K(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!cl(t))return K(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!wo(r))return K(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=wi}};ko.exports=Tn;function K(i,e,t,r,n){let s=new i(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(s,K),s.code=n,s[nl]=r,s}});var Ln=F((jd,Io)=>{"use strict";var Vd=I("net"),Hd=I("tls"),{randomFillSync:ul}=I("crypto"),Ao=_i(),{EMPTY_BUFFER:hl}=ct(),{isValidStatusCode:fl}=Ei(),{mask:Ro,toBuffer:Mt}=vi(),ke=Symbol("kByteLength"),dl=Buffer.alloc(4),Pn=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,n=!1,s=2,o=!1;t.mask&&(r=t.maskBuffer||dl,t.generateMask?t.generateMask(r):ul(r,0,4),o=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[ke]!==void 0?c=t[ke]:(e=Buffer.from(e),c=e.length):(c=e.length,n=t.mask&&t.readOnly&&!o);let l=c;c>=65536?(s+=8,l=127):c>125&&(s+=2,l=126);let h=Buffer.allocUnsafe(n?c+s:s);return h[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(h[0]|=64),h[1]=l,l===126?h.writeUInt16BE(c,2):l===127&&(h[2]=h[3]=0,h.writeUIntBE(c,4,6)),t.mask?(h[1]|=128,h[s-4]=r[0],h[s-3]=r[1],h[s-2]=r[2],h[s-1]=r[3],o?[h,e]:n?(Ro(e,r,h,s,c),[h]):(Ro(e,r,e,0,c),[h,e])):[h,e]}close(e,t,r,n){let s;if(e===void 0)s=hl;else{if(typeof e!="number"||!fl(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let c=Buffer.byteLength(t);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(e,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let o={[ke]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,o,n]):this.sendFrame(i.frame(s,o),n)}ping(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Mt(e),n=e.length,s=Mt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ke]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}pong(e,t,r){let n,s;if(typeof e=="string"?(n=Buffer.byteLength(e),s=!1):(e=Mt(e),n=e.length,s=Mt.readOnly),n>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[ke]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(i.frame(e,o),r)}send(e,t,r){let n=this._extensions[Ao.extensionName],s=t.binary?2:1,o=t.compress,c,l;if(typeof e=="string"?(c=Buffer.byteLength(e),l=!1):(e=Mt(e),c=e.length,l=Mt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&n&&n.params[n._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=n._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0),n){let h={[ke]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:o};this._deflating?this.enqueue([this.dispatch,e,this._compress,h,r]):this.dispatch(e,this._compress,h,r)}else this.sendFrame(i.frame(e,{[ke]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:l,rsv1:!1}),r)}dispatch(e,t,r,n){if(!t){this.sendFrame(i.frame(e,r),n);return}let s=this._extensions[Ao.extensionName];this._bufferedBytes+=r[ke],this._deflating=!0,s.compress(e,r.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(l);for(let h=0;h<this._queue.length;h++){let u=this._queue[h],f=u[u.length-1];typeof f=="function"&&f(l)}return}this._bufferedBytes-=r[ke],this._deflating=!1,r.readOnly=!1,this.sendFrame(i.frame(c,r),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ke],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ke],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)}};Io.exports=Pn});var Mo=F((Gd,Bo)=>{"use strict";var{kForOnEventAttribute:xi,kListener:Fn}=ct(),To=Symbol("kCode"),Oo=Symbol("kData"),Po=Symbol("kError"),Lo=Symbol("kMessage"),Fo=Symbol("kReason"),qt=Symbol("kTarget"),Uo=Symbol("kType"),Do=Symbol("kWasClean"),Ve=class{constructor(e){this[qt]=null,this[Uo]=e}get target(){return this[qt]}get type(){return this[Uo]}};Object.defineProperty(Ve.prototype,"target",{enumerable:!0});Object.defineProperty(Ve.prototype,"type",{enumerable:!0});var St=class extends Ve{constructor(e,t={}){super(e),this[To]=t.code===void 0?0:t.code,this[Fo]=t.reason===void 0?"":t.reason,this[Do]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[To]}get reason(){return this[Fo]}get wasClean(){return this[Do]}};Object.defineProperty(St.prototype,"code",{enumerable:!0});Object.defineProperty(St.prototype,"reason",{enumerable:!0});Object.defineProperty(St.prototype,"wasClean",{enumerable:!0});var Wt=class extends Ve{constructor(e,t={}){super(e),this[Po]=t.error===void 0?null:t.error,this[Lo]=t.message===void 0?"":t.message}get error(){return this[Po]}get message(){return this[Lo]}};Object.defineProperty(Wt.prototype,"error",{enumerable:!0});Object.defineProperty(Wt.prototype,"message",{enumerable:!0});var Ci=class extends Ve{constructor(e,t={}){super(e),this[Oo]=t.data===void 0?null:t.data}get data(){return this[Oo]}};Object.defineProperty(Ci.prototype,"data",{enumerable:!0});var pl={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[xi]&&n[Fn]===e&&!n[xi])return;let r;if(i==="message")r=function(s,o){let c=new Ci("message",{data:o?s:s.toString()});c[qt]=this,Tr(e,this,c)};else if(i==="close")r=function(s,o){let c=new St("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[qt]=this,Tr(e,this,c)};else if(i==="error")r=function(s){let o=new Wt("error",{error:s,message:s.message});o[qt]=this,Tr(e,this,o)};else if(i==="open")r=function(){let s=new Ve("open");s[qt]=this,Tr(e,this,s)};else return;r[xi]=!!t[xi],r[Fn]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[Fn]===e&&!t[xi]){this.removeListener(i,t);break}}};Bo.exports={CloseEvent:St,ErrorEvent:Wt,Event:Ve,EventTarget:pl,MessageEvent:Ci};function Tr(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var Un=F((Yd,qo)=>{"use strict";var{tokenChars:Ni}=Ei();function Pe(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function ml(i){let e=Object.create(null),t=Object.create(null),r=!1,n=!1,s=!1,o,c,l=-1,h=-1,u=-1,f=0;for(;f<i.length;f++)if(h=i.charCodeAt(f),o===void 0)if(u===-1&&Ni[h]===1)l===-1&&(l=f);else if(f!==0&&(h===32||h===9))u===-1&&l!==-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let m=i.slice(l,u);h===44?(Pe(e,m,t),t=Object.create(null)):o=m,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(u===-1&&Ni[h]===1)l===-1&&(l=f);else if(h===32||h===9)u===-1&&l!==-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f),Pe(t,i.slice(l,u),!0),h===44&&(Pe(e,o,t),t=Object.create(null),o=void 0),l=u=-1}else if(h===61&&l!==-1&&u===-1)c=i.slice(l,f),l=u=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(n){if(Ni[h]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(Ni[h]===1)l===-1&&(l=f);else if(h===34&&l!==-1)s=!1,u=f;else if(h===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(h===34&&i.charCodeAt(f-1)===61)s=!0;else if(u===-1&&Ni[h]===1)l===-1&&(l=f);else if(l!==-1&&(h===32||h===9))u===-1&&(u=f);else if(h===59||h===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let m=i.slice(l,u);r&&(m=m.replace(/\\/g,""),r=!1),Pe(t,c,m),h===44&&(Pe(e,o,t),t=Object.create(null),o=void 0),c=void 0,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||s||h===32||h===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=f);let p=i.slice(l,u);return o===void 0?Pe(e,p,t):(c===void 0?Pe(t,p,!0):r?Pe(t,c,p.replace(/\\/g,"")):Pe(t,c,p),Pe(e,o,t)),e}function yl(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(n=>{let s=r[n];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?n:`${n}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}qo.exports={format:yl,parse:ml}});var Wn=F((Xd,Xo)=>{"use strict";var gl=I("events"),vl=I("https"),bl=I("http"),Ko=I("net"),Sl=I("tls"),{randomBytes:_l,createHash:El}=I("crypto"),{Readable:Jd}=I("stream"),{URL:Dn}=I("url"),ut=_i(),wl=On(),xl=Ln(),{BINARY_TYPES:Wo,EMPTY_BUFFER:Or,GUID:Cl,kForOnEventAttribute:Bn,kListener:Nl,kStatusCode:kl,kWebSocket:ne,NOOP:zo}=ct(),{EventTarget:{addEventListener:Al,removeEventListener:Rl}}=Mo(),{format:Il,parse:Tl}=Un(),{toBuffer:Ol}=vi(),Pl=30*1e3,Vo=Symbol("kAborted"),Mn=[8,13],He=["CONNECTING","OPEN","CLOSING","CLOSED"],Ll=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,q=class i extends gl{constructor(e,t,r){super(),this._binaryType=Wo[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Or,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]),Ho(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Wo.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 n=new wl({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new xl(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[ne]=this,e[ne]=this,n.on("conclude",Dl),n.on("drain",Bl),n.on("error",Ml),n.on("message",ql),n.on("ping",Wl),n.on("pong",$l),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Go),e.on("data",Lr),e.on("end",Yo),e.on("error",Jo),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[ut.extensionName]&&this._extensions[ut.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 fe(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),Pl)}}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){qn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Or,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){qn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Or,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){qn(this,e,r);return}let n=g({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[ut.extensionName]||(n.compress=!1),this._sender.send(e||Or,n,r)}terminate(){if(this.readyState!==i.CLOSED){if(this.readyState===i.CONNECTING)return fe(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=i.CLOSING,this._socket.destroy())}}};Object.defineProperty(q,"CONNECTING",{enumerable:!0,value:He.indexOf("CONNECTING")});Object.defineProperty(q.prototype,"CONNECTING",{enumerable:!0,value:He.indexOf("CONNECTING")});Object.defineProperty(q,"OPEN",{enumerable:!0,value:He.indexOf("OPEN")});Object.defineProperty(q.prototype,"OPEN",{enumerable:!0,value:He.indexOf("OPEN")});Object.defineProperty(q,"CLOSING",{enumerable:!0,value:He.indexOf("CLOSING")});Object.defineProperty(q.prototype,"CLOSING",{enumerable:!0,value:He.indexOf("CLOSING")});Object.defineProperty(q,"CLOSED",{enumerable:!0,value:He.indexOf("CLOSED")});Object.defineProperty(q.prototype,"CLOSED",{enumerable:!0,value:He.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(q.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(q.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[Bn])return e[Nl];return null},set(e){for(let t of this.listeners(i))if(t[Bn]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[Bn]:!0})}})});q.prototype.addEventListener=Al;q.prototype.removeEventListener=Rl;Xo.exports=q;function Ho(i,e,t,r){let n=w(g({protocolVersion:Mn[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(!Mn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${Mn.join(", ")})`);let s;if(e instanceof Dn)s=e,i._url=e.href;else{try{s=new Dn(e)}catch(v){throw new SyntaxError(`Invalid URL: ${e}`)}i._url=e}let o=s.protocol==="wss:",c=s.protocol==="ws+unix:",l;if(s.protocol!=="ws:"&&!o&&!c?l=`The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`:c&&!s.pathname?l="The URL's pathname is empty":s.hash&&(l="The URL contains a fragment identifier"),l){let v=new SyntaxError(l);if(i._redirects===0)throw v;Pr(i,v);return}let h=o?443:80,u=_l(16).toString("base64"),f=o?vl.request:bl.request,p=new Set,m;if(n.createConnection=o?Ul:Fl,n.defaultPort=n.defaultPort||h,n.port=s.port||h,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=w(g({},n.headers),{"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"}),n.path=s.pathname+s.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(m=new ut(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=Il({[ut.extensionName]:m.offer()})),t.length){for(let v of t){if(typeof v!="string"||!Ll.test(v)||p.has(v))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(v)}n.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(s.username||s.password)&&(n.auth=`${s.username}:${s.password}`),c){let v=n.path.split(":");n.socketPath=v[0],n.path=v[1]}let C;if(n.followRedirects){if(i._redirects===0){i._originalIpc=c,i._originalSecure=o,i._originalHostOrSocketPath=c?n.socketPath:s.host;let v=r&&r.headers;if(r=w(g({},r),{headers:{}}),v)for(let[_,T]of Object.entries(v))r.headers[_.toLowerCase()]=T}else if(i.listenerCount("redirect")===0){let v=c?i._originalIpc?n.socketPath===i._originalHostOrSocketPath:!1:i._originalIpc?!1:s.host===i._originalHostOrSocketPath;(!v||i._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,v||delete n.headers.host,n.auth=void 0)}n.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64")),C=i._req=f(n),i._redirects&&i.emit("redirect",i.url,C)}else C=i._req=f(n);n.timeout&&C.on("timeout",()=>{fe(i,C,"Opening handshake has timed out")}),C.on("error",v=>{C===null||C[Vo]||(C=i._req=null,Pr(i,v))}),C.on("response",v=>{let _=v.headers.location,T=v.statusCode;if(_&&n.followRedirects&&T>=300&&T<400){if(++i._redirects>n.maxRedirects){fe(i,C,"Maximum redirects exceeded");return}C.abort();let N;try{N=new Dn(_,e)}catch(S){let E=new SyntaxError(`Invalid URL: ${_}`);Pr(i,E);return}Ho(i,N,t,r)}else i.emit("unexpected-response",C,v)||fe(i,C,`Unexpected server response: ${v.statusCode}`)}),C.on("upgrade",(v,_,T)=>{if(i.emit("upgrade",v),i.readyState!==q.CONNECTING)return;if(C=i._req=null,v.headers.upgrade.toLowerCase()!=="websocket"){fe(i,_,"Invalid Upgrade header");return}let N=El("sha1").update(u+Cl).digest("base64");if(v.headers["sec-websocket-accept"]!==N){fe(i,_,"Invalid Sec-WebSocket-Accept header");return}let S=v.headers["sec-websocket-protocol"],E;if(S!==void 0?p.size?p.has(S)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":p.size&&(E="Server sent no subprotocol"),E){fe(i,_,E);return}S&&(i._protocol=S);let V=v.headers["sec-websocket-extensions"];if(V!==void 0){if(!m){fe(i,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R;try{R=Tl(V)}catch($){fe(i,_,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(R);if(P.length!==1||P[0]!==ut.extensionName){fe(i,_,"Server indicated an extension that was not requested");return}try{m.accept(R[ut.extensionName])}catch($){fe(i,_,"Invalid Sec-WebSocket-Extensions header");return}i._extensions[ut.extensionName]=m}i.setSocket(_,T,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),C.end()}function Pr(i,e){i._readyState=q.CLOSING,i.emit("error",e),i.emitClose()}function Fl(i){return i.path=i.socketPath,Ko.connect(i)}function Ul(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=Ko.isIP(i.host)?"":i.host),Sl.connect(i)}function fe(i,e,t){i._readyState=q.CLOSING;let r=new Error(t);Error.captureStackTrace(r,fe),e.setHeader?(e[Vo]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Pr,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function qn(i,e,t){if(e){let r=Ol(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${He[i.readyState]})`);t(r)}}function Dl(i,e){let t=this[ne];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[ne]!==void 0&&(t._socket.removeListener("data",Lr),process.nextTick(jo,t._socket),i===1005?t.close():t.close(i,e))}function Bl(){let i=this[ne];i.isPaused||i._socket.resume()}function Ml(i){let e=this[ne];e._socket[ne]!==void 0&&(e._socket.removeListener("data",Lr),process.nextTick(jo,e._socket),e.close(i[kl])),e.emit("error",i)}function $o(){this[ne].emitClose()}function ql(i,e){this[ne].emit("message",i,e)}function Wl(i){let e=this[ne];e.pong(i,!e._isServer,zo),e.emit("ping",i)}function $l(i){this[ne].emit("pong",i)}function jo(i){i.resume()}function Go(){let i=this[ne];this.removeListener("close",Go),this.removeListener("data",Lr),this.removeListener("end",Yo),i._readyState=q.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[ne]=void 0,clearTimeout(i._closeTimer),i._receiver._writableState.finished||i._receiver._writableState.errorEmitted?i.emitClose():(i._receiver.on("error",$o),i._receiver.on("finish",$o))}function Lr(i){this[ne]._receiver.write(i)||this.pause()}function Yo(){let i=this[ne];i._readyState=q.CLOSING,i._receiver.end(),this.end()}function Jo(){let i=this[ne];this.removeListener("error",Jo),this.on("error",zo),i&&(i._readyState=q.CLOSING,this.destroy())}});var Zo=F((Zd,Qo)=>{"use strict";var{tokenChars:Kl}=Ei();function zl(i){let e=new Set,t=-1,r=-1,n=0;for(n;n<i.length;n++){let o=i.charCodeAt(n);if(r===-1&&Kl[o]===1)t===-1&&(t=n);else if(n!==0&&(o===32||o===9))r===-1&&t!==-1&&(r=n);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${n}`);r===-1&&(r=n);let c=i.slice(t,r);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${n}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=i.slice(t,n);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}Qo.exports={parse:zl}});var oa=F((rp,sa)=>{"use strict";var Vl=I("events"),Fr=I("http"),ep=I("https"),tp=I("net"),ip=I("tls"),{createHash:Hl}=I("crypto"),ea=Un(),_t=_i(),jl=Zo(),Gl=Wn(),{GUID:Yl,kWebSocket:Jl}=ct(),Xl=/^[+/0-9A-Za-z]{22}==$/,ta=0,ia=1,na=2,$n=class extends Vl{constructor(e,t){if(super(),e=g({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:Gl},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=Fr.createServer((r,n)=>{let s=Fr.STATUS_CODES[426];n.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),n.end(s)}),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=Ql(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(n,s,o)=>{this.handleUpgrade(n,s,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ta}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===na){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ki,this);return}if(e&&this.once("close",e),this._state!==ia)if(this._state=ia,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(ki,this):process.nextTick(ki,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ki(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,n){t.on("error",ra);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Et(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){Et(this,e,t,400,"Invalid Upgrade header");return}if(!s||!Xl.test(s)){Et(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){Et(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Ai(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=jl.parse(c)}catch(f){Et(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&h!==void 0){let f=new _t(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let p=ea.parse(h);p[_t.extensionName]&&(f.accept(p[_t.extensionName]),u[_t.extensionName]=f)}catch(p){Et(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={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(f,(p,m,C,v)=>{if(!p)return Ai(t,m||401,C,v);this.completeUpgrade(u,s,l,e,t,r,n)});return}if(!this.options.verifyClient(f))return Ai(t,401)}this.completeUpgrade(u,s,l,e,t,r,n)}completeUpgrade(e,t,r,n,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[Jl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ta)return Ai(s,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Hl("sha1").update(t+Yl).digest("base64")}`],u=new this.options.WebSocket(null);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;f&&(h.push(`Sec-WebSocket-Protocol: ${f}`),u._protocol=f)}if(e[_t.extensionName]){let f=e[_t.extensionName].params,p=ea.format({[_t.extensionName]:[f]});h.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=e}this.emit("headers",h,n),s.write(h.concat(`\r
7
7
  `).join(`\r
8
- `)),s.removeListener("error",Co),h.setSocket(s,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(oi,this)})),c(h,n)}};ko.exports=gn;function El(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 oi(i){i._state=No,i.emit("close")}function Co(){this.destroy()}function ai(i,e,t,r){t=t||lr.STATUS_CODES[e],r=E({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${lr.STATUS_CODES[e]}\r
8
+ `)),s.removeListener("error",ra),u.setSocket(s,o,{maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ki,this)})),c(u,n)}};sa.exports=$n;function Ql(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 ki(i){i._state=na,i.emit("close")}function ra(){this.destroy()}function Ai(i,e,t,r){t=t||Fr.STATUS_CODES[e],r=g({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},r),i.once("finish",i.destroy),i.end(`HTTP/1.1 ${e} ${Fr.STATUS_CODES[e]}\r
9
9
  `+Object.keys(r).map(n=>`${n}: ${r[n]}`).join(`\r
10
10
  `)+`\r
11
11
  \r
12
- `+t)}function ht(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,ht),i.emit("wsClientError",s,t,e)}else ai(t,r,n)}});var vn=F((Ld,Uo)=>{"use strict";function Tl(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=Mr(),t.destroy=u,Object.keys(i).forEach(h=>{t[h]=i[h]}),t.names=[],t.skips=[],t.formatters={};function e(h){let f=0;for(let d=0;d<h.length;d++)f=(f<<5)-f+h.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(h){let f,d=null,p,w;function g(...v){if(!g.enabled)return;let R=g,x=Number(new Date),y=x-(f||x);R.diff=y,R.prev=f,R.curr=x,f=x,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let b=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(N,P)=>{if(N==="%%")return"%";b++;let q=t.formatters[P];if(typeof q=="function"){let ne=v[b];N=q.call(R,ne),v.splice(b,1),b--}return N}),t.formatArgs.call(R,v),(R.log||t.log).apply(R,v)}return g.namespace=h,g.useColors=t.useColors(),g.color=t.selectColor(h),g.extend=r,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==t.namespaces&&(p=t.namespaces,w=t.enabled(h)),w),set:v=>{d=v}}),typeof t.init=="function"&&t.init(g),g}function r(h,f){let d=t(this.namespace+(typeof f=="undefined"?":":f)+h);return d.log=this.log,d}function n(h){t.save(h),t.namespaces=h,t.names=[],t.skips=[];let f,d=(typeof h=="string"?h:"").split(/[\s,]+/),p=d.length;for(f=0;f<p;f++)d[f]&&(h=d[f].replace(/\*/g,".*?"),h[0]==="-"?t.skips.push(new RegExp("^"+h.slice(1)+"$")):t.names.push(new RegExp("^"+h+"$")))}function s(){let h=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),h}function o(h){if(h[h.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(h))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(h))return!0;return!1}function c(h){return h.toString().substring(2,h.toString().length-2).replace(/\.\*\?$/,"*")}function l(h){return h instanceof Error?h.stack||h.message:h}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}Uo.exports=Tl});var Do=F((ce,dr)=>{"use strict";ce.formatArgs=Il;ce.save=Pl;ce.load=Ll;ce.useColors=Ol;ce.storage=Fl();ce.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`."))}})();ce.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 Ol(){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 Il(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+dr.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,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}ce.log=console.debug||console.log||(()=>{});function Pl(i){try{i?ce.storage.setItem("debug",i):ce.storage.removeItem("debug")}catch(e){}}function Ll(){let i;try{i=ce.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Fl(){try{return localStorage}catch(i){}}dr.exports=vn()(ce);var{formatters:Ul}=dr.exports;Ul.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Mo=F((K,mr)=>{"use strict";var Dl=A("tty"),pr=A("util");K.init=Vl;K.log=Wl;K.formatArgs=Ml;K.save=zl;K.load=$l;K.useColors=Bl;K.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`.");K.colors=[6,2,3,4,5,1];try{let i=$r();i&&(i.stderr||i).level>=2&&(K.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){}K.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.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 Bl(){return"colors"in K.inspectOpts?!!K.inspectOpts.colors:Dl.isatty(process.stderr.fd)}function Ml(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
12
+ `+t)}function Et(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,Et),i.emit("wsClientError",s,t,e)}else Ai(t,r,n)}});var zn=F((Mp,pa)=>{"use strict";function cu(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=fn(),t.destroy=h,Object.keys(i).forEach(u=>{t[u]=i[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let f=0;for(let p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(u){let f,p=null,m,C;function v(..._){if(!v.enabled)return;let T=v,N=Number(new Date),S=N-(f||N);T.diff=S,T.prev=f,T.curr=N,f=N,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let E=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(R,P)=>{if(R==="%%")return"%";E++;let $=t.formatters[P];if(typeof $=="function"){let le=_[E];R=$.call(T,le),_.splice(E,1),E--}return R}),t.formatArgs.call(T,_),(T.log||t.log).apply(T,_)}return v.namespace=u,v.useColors=t.useColors(),v.color=t.selectColor(u),v.extend=r,v.destroy=t.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(m!==t.namespaces&&(m=t.namespaces,C=t.enabled(u)),C),set:_=>{p=_}}),typeof t.init=="function"&&t.init(v),v}function r(u,f){let p=t(this.namespace+(typeof f=="undefined"?":":f)+u);return p.log=this.log,p}function n(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let f,p=(typeof u=="string"?u:"").split(/[\s,]+/),m=p.length;for(f=0;f<m;f++)p[f]&&(u=p[f].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let f,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(u))return!1;for(f=0,p=t.names.length;f<p;f++)if(t.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function h(){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}pa.exports=cu});var ma=F((de,Mr)=>{"use strict";de.formatArgs=uu;de.save=hu;de.load=fu;de.useColors=lu;de.storage=du();de.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`."))}})();de.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 lu(){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 uu(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Mr.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,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}de.log=console.debug||console.log||(()=>{});function hu(i){try{i?de.storage.setItem("debug",i):de.storage.removeItem("debug")}catch(e){}}function fu(){let i;try{i=de.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function du(){try{return localStorage}catch(i){}}Mr.exports=zn()(de);var{formatters:pu}=Mr.exports;pu.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var ga=F((J,Wr)=>{"use strict";var mu=I("tty"),qr=I("util");J.init=Eu;J.log=bu;J.formatArgs=gu;J.save=Su;J.load=_u;J.useColors=yu;J.destroy=qr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");J.colors=[6,2,3,4,5,1];try{let i=yn();i&&(i.stderr||i).level>=2&&(J.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){}J.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.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 yu(){return"colors"in J.inspectOpts?!!J.inspectOpts.colors:mu.isatty(process.stderr.fd)}function gu(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),s=` ${n};1m${e} \x1B[0m`;i[0]=s+i[0].split(`
13
13
  `).join(`
14
- `+s),i.push(n+"m+"+mr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=ql()+e+" "+i[0]}function ql(){return K.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Wl(...i){return process.stderr.write(pr.formatWithOptions(K.inspectOpts,...i)+`
15
- `)}function zl(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function $l(){return process.env.DEBUG}function Vl(i){i.inspectOpts={};let e=Object.keys(K.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=K.inspectOpts[e[t]]}mr.exports=vn()(K);var{formatters:Bo}=mr.exports;Bo.o=function(i){return this.inspectOpts.colors=this.useColors,pr.inspect(i,this.inspectOpts).split(`
16
- `).map(e=>e.trim()).join(" ")};Bo.O=function(i){return this.inspectOpts.colors=this.useColors,pr.inspect(i,this.inspectOpts)}});var hi=F((Fd,_n)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?_n.exports=Do():_n.exports=Mo()});var pa="v1",ma=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,vi=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=pa,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=ma,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=E({"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":n},s)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var r;let t=e||typeof window!="undefined"&&((r=window.localStorage)==null?void 0:r.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=E(E({},this.headers),e)}get(e,t,r=!0){return m(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return m(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return m(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=ga(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(r==null?void 0:r.method)||"GET",headers:E(E({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},l=yield fetch(o,c);if(!l.ok){let h=yield l.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${l.status}, Message: ${h.message}`)}if(l.status===204)return;let u=yield l.json();return n?u.data:u})}};function ga(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var tt="/inbox",Z=`${tt}/notifications`,O,_i=class{constructor(e={}){this.isSessionInitialized=!1;_(this,O);S(this,O,new vi(e))}initializeSession(c){return m(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o}){let l=yield a(this,O).post(`${tt}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o});return a(this,O).setAuthorizationToken(l.token),a(this,O).setKeylessHeader(l.applicationIdentifier),this.isSessionInitialized=!0,l})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:c,seen:l,data:u,severity:h}){let f=new URLSearchParams(`limit=${r}`);if(e&&f.append("after",e),n&&f.append("offset",`${n}`),o)for(let d of o)f.append("tags[]",d);if(s!==void 0&&f.append("read",`${s}`),t!==void 0&&f.append("archived",`${t}`),c!==void 0&&f.append("snoozed",`${c}`),l!==void 0&&f.append("seen",`${l}`),u!==void 0&&f.append("data",JSON.stringify(u)),h&&Array.isArray(h))for(let d of h)f.append("severity[]",d);else h&&f.append("severity",h);return a(this,O).get(Z,f,!1)}count({filters:e}){return a(this,O).get(`${Z}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,O).patch(`${Z}/${e}/read`)}unread(e){return a(this,O).patch(`${Z}/${e}/unread`)}archive(e){return a(this,O).patch(`${Z}/${e}/archive`)}unarchive(e){return a(this,O).patch(`${Z}/${e}/unarchive`)}snooze(e,t){return a(this,O).patch(`${Z}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,O).patch(`${Z}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,O).post(`${Z}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,O).post(`${Z}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,O).post(`${Z}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,O).delete(`${Z}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,O).post(`${Z}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,O).post(`${Z}/seen`,{notificationIds:e,tags:t,data:r?JSON.stringify(r):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return a(this,O).patch(`${Z}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,O).patch(`${Z}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:r}){let n=new URLSearchParams;if(e)for(let o of e)n.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)n.append("severity[]",o);else t&&n.append("severity",t);r&&n.append("criticality",r);let s=n.size?`?${n.toString()}`:"";return a(this,O).get(`${tt}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,O).patch(`${tt}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,O).patch(`${tt}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,O).patch(`${tt}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,O).get(`${tt}/preferences/global`)}triggerHelloWorldEvent(){let e={name:"hello-world",to:{subscriberId:"keyless-subscriber-id"},payload:{subject:"Novu Keyless Environment",body:"You're using a keyless demo environment. For full access to Novu features and cloud integration, obtain your API key.",primaryActionText:"Obtain API Key",primaryActionUrl:"https://go.novu.co/keyless",secondaryActionText:"Explore Documentation",secondaryActionUrl:"https://go.novu.co/keyless-docs"}};return a(this,O).post("/inbox/events",e)}};O=new WeakMap;function In(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(n){n(t)}),(r=i.get("*"))&&r.slice().map(function(n){n(e,t)})}}}var it,Ei=class{constructor(){_(this,it);S(this,it,In())}on(e,t){return a(this,it).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,it).off(e,t)}emit(e,t){a(this,it).emit(e,t)}};it=new WeakMap;var k=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Si=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=xe(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:s});let o=yield e.read(n),c=new U(o,i,e);return i.emit("notification.read.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new k("Failed to read notification",o)}}}),bi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=xe(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.unread.pending",{args:t,data:s});let o=yield e.unread(n),c=new U(o,i,e);return i.emit("notification.unread.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new k("Failed to unread notification",o)}}}),wi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=xe(t,{isSeen:!0},{emitter:i,apiService:e});try{if(i.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(n),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,i,e);return i.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return i.emit("notification.seen.resolved",{args:t,error:o}),{error:new k("Failed to mark notification as seen",o)}}}),xi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=xe(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:s});let o=yield e.archive(n),c=new U(o,i,e);return i.emit("notification.archive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new k("Failed to archive notification",o)}}}),Ci=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=xe(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.unarchive.pending",{args:t,data:s});let o=yield e.unarchive(n),c=new U(o,i,e);return i.emit("notification.unarchive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new k("Failed to unarchive notification",o)}}}),Ni=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=xe(t,{isSnoozed:!0,snoozedUntil:t.snoozeUntil},{emitter:i,apiService:e});try{i.emit("notification.snooze.pending",{args:t,data:s});let o=yield e.snooze(n,t.snoozeUntil),c=new U(o,i,e);return i.emit("notification.snooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.snooze.resolved",{args:t,error:o}),{error:new k("Failed to snooze notification",o)}}}),ki=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=xe(t,{isSnoozed:!1,snoozedUntil:null},{emitter:i,apiService:e});try{i.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(n),c=new U(o,i,e);return i.emit("notification.unsnooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new k("Failed to unsnooze notification",o)}}}),mt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:T(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:T(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=xe(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:c});let l=yield e.completeAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new k(`Failed to complete ${r} action on the notification`,l)}}}),gt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:T(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:T(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=xe(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:c});let l=yield e.revertAction({actionType:r,notificationId:o}),u=new U(l,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:u}),{data:u}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new k("Failed to fetch notifications",l)}}}),xe=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(E(E({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},Pn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(T(E({},l),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),i,e));return i.emit("notifications.read_all.pending",{args:{tags:r,data:n},data:c}),yield e.readAll({tags:r,data:n}),i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to read all notifications",o)}}}),Cr=o=>m(void 0,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:r,tags:n,data:s}){try{let c=t.getUniqueNotifications({tags:n,data:s}),u=(r&&r.length>0?c.filter(h=>r.includes(h.id)):c).map(h=>new U(T(E({},h),{isSeen:!0,firstSeenAt:h.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:u}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:u}),{}}catch(c){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:c}),{error:new k("Failed to mark all notifications as seen",c)}}}),Ln=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(T(E({},l),{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:n},data:c}),yield e.archiveAll({tags:r,data:n}),i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all notifications",o)}}}),Fn=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(l=>new U(T(E({},l),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r,data:n},data:c}),yield e.archiveAllRead({tags:r,data:n}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to archive all read notifications",o)}}}),Ai=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=xe(t,{},{emitter:i,apiService:e});try{return i.emit("notification.delete.pending",{args:t}),yield e.delete(n),i.emit("notification.delete.resolved",{args:t}),{}}catch(s){return i.emit("notification.delete.resolved",{args:t,error:s}),{error:new k("Failed to delete notification",s)}}}),Un=s=>m(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let o=t.getUniqueNotifications({tags:r,data:n});return i.emit("notifications.delete_all.pending",{args:{tags:r,data:n},data:o}),yield e.deleteAll({tags:r,data:n}),i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n}}),{}}catch(o){return i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n},error:o}),{error:new k("Failed to delete all notifications",o)}}});var V,ee,U=class{constructor(e,t,r){_(this,V);_(this,ee);S(this,V,t),S(this,ee,r),this.id=e.id,this.transactionId=e.transactionId,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isSeen=e.isSeen,this.isArchived=e.isArchived,this.isSnoozed=e.isSnoozed,this.snoozedUntil=e.snoozedUntil,this.deliveredAt=e.deliveredAt,this.createdAt=e.createdAt,this.readAt=e.readAt,this.firstSeenAt=e.firstSeenAt,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,this.workflow=e.workflow,this.severity=e.severity}read(){return Si({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}unread(){return bi({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}seen(){return wi({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}archive(){return xi({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}unarchive(){return Ci({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}delete(){return Ai({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}snooze(e){return Ni({emitter:a(this,V),apiService:a(this,ee),args:{notification:this,snoozeUntil:e}})}unsnooze(){return ki({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return mt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return mt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return gt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return gt({emitter:a(this,V),apiService:a(this,ee),args:{notification:this},actionType:"secondary"})}on(e,t){let r=a(this,V).on(e,t);return()=>{r()}}off(e,t){a(this,V).off(e,t)}};V=new WeakMap,ee=new WeakMap;var ze,yt,de=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){_(this,ze,[]);_(this,yt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,ze).forEach(c=>m(this,[c],function*({fn:s,resolve:o}){o(yield s())})),S(this,ze,[])):r&&(this.onSessionError(r),S(this,yt,r),a(this,ze).forEach(({resolve:s})=>{s({error:new k("Failed to initialize session, please contact the support",r)})}),S(this,ze,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,yt)?Promise.resolve({error:new k("Failed to initialize session, please contact the support",a(this,yt))}):new Promise((t,r)=>{a(this,ze).push({fn:e,resolve:t,reject:r})})})}};ze=new WeakMap,yt=new WeakMap;var Nr=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var Rh=["seen","unseen"],Th=["read","unread"],kr=(i,e)=>Nr(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,ya=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return Nr(t,r)},Ar=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},Rr=(i,e)=>Ar(i.data,e.data)&&kr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&ya(i.severity,e.severity);var ye,$e=class{constructor(){_(this,ye);S(this,ye,new Map)}get(e){return a(this,ye).get(e)}getValues(){return Array.from(a(this,ye).values())}entries(){return Array.from(a(this,ye).entries())}keys(){return Array.from(a(this,ye).keys())}set(e,t){a(this,ye).set(e,t)}remove(e){a(this,ye).delete(e)}clear(){a(this,ye).clear()}};ye=new WeakMap;var Dn=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u}).filter(([h,f])=>f!=null&&!(Array.isArray(f)&&f.length===0)).reduce((h,[f,d])=>(h[f]=d,h),{}),Tr=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>JSON.stringify(Dn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})),va=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(Dn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),vt=i=>JSON.parse(i),_a=["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"],Ea=["notification.archive.pending","notification.unarchive.pending","notification.snooze.pending","notification.unsnooze.pending","notification.delete.pending","notifications.archive_all.pending","notifications.archive_all_read.pending","notifications.delete_all.pending"],Ve,M,Lt=class{constructor({emitter:e}){_(this,Ve);_(this,M);this.updateNotification=(e,t)=>{let r=a(this,M).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s[n]=t,a(this,M).set(e,T(E({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=a(this,M).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s.splice(n,1),a(this,M).set(e,T(E({},r),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:r,args:n}=t,s=[];if(r!=null)Array.isArray(r)&&r.every(c=>typeof c=="object"&&"id"in c)?s=r:typeof r=="object"&&"id"in r&&(s=[r]);else if(e&&n){if("notification"in n&&n.notification)s=[n.notification];else if("notificationId"in n&&n.notificationId){let c=[];a(this,M).keys().forEach(l=>{let u=a(this,M).get(l);if(u){let h=u.notifications.find(f=>f.id===n.notificationId);h&&c.push(h)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,M).keys().forEach(c=>{s.forEach(l=>{let u=!1;e?u=this.removeNotification(c,l):u=this.updateNotification(c,l),u&&o.add(va(vt(c)))})}),o.forEach(c=>{let l=this.getAggregated(vt(c));a(this,Ve).emit("notifications.list.updated",{data:l})})};S(this,Ve,e),_a.forEach(t=>{a(this,Ve).on(t,this.handleNotificationEvent())}),Ea.forEach(t=>{a(this,Ve).on(t,this.handleNotificationEvent({remove:!0}))}),S(this,M,new $e)}getAggregated(e){return a(this,M).keys().filter(r=>{let n=vt(r);return Rr(n,e)}).map(r=>a(this,M).get(r)).reduce((r,n)=>n?{hasMore:n.hasMore,filter:n.filter,notifications:[...r.notifications,...n.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}has(e){return a(this,M).get(Tr(e))!==void 0}set(e,t){a(this,M).set(Tr(e),t)}update(e,t){this.set(e,t);let r=this.getAggregated(vt(Tr(e)));a(this,Ve).emit("notifications.list.updated",{data:r})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,data:e.data,read:e.read,snoozed:e.snoozed,archived:e.archived,seen:e.seen,severity:e.severity})}getUniqueNotifications({tags:e,read:t,data:r}){let n=a(this,M).keys(),s=new Map;return n.forEach(o=>{let c=vt(o);if(kr(e,c.tags)&&Ar(r,c.data)){let l=a(this,M).get(o);if(!l)return;l.notifications.filter(u=>typeof t=="undefined"||t===u.isRead).forEach(u=>{s.set(u.id,u)})}}),Array.from(s.values())}clear(e){a(this,M).keys().forEach(r=>{Rr(vt(r),e)&&a(this,M).remove(r)})}clearAll(){a(this,M).clear()}};Ve=new WeakMap,M=new WeakMap;var Ft,Ri=class extends de{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Ft);this.cache=new Lt({emitter:n}),S(this,Ft,t)}get inboxService(){return this._inboxService}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=wr(s,["limit"]);return this.callWithSession(()=>m(this,null,function*(){let o=E({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,Ft),l=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:l}),!l){let u=yield this._inboxService.fetchNotifications(E({limit:t},r));l={hasMore:u.hasMore,filter:u.filter,notifications:u.data.map(h=>new U(h,this._emitter,this._inboxService))},c&&(this.cache.set(o,l),l=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:l}),{data:l}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new k("Failed to fetch notifications",c)}}}))})}count(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){let r=t&&"filters"in t?t.filters:[E({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let n=yield this._inboxService.count({filters:r}),s=t&&"filters"in t?{counts:n.data}:n.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(n){return this._emitter.emit("notifications.count.resolved",{args:t,error:n}),{error:new k("Failed to count notifications",n)}}}))})}read(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Si({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return bi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return wi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return xi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ci({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ai({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ni({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ki({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return mt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return mt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return gt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return gt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return Pn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){return"notificationIds"in t?Cr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):Cr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:"tags"in t?t.tags:void 0,data:"data"in t?t.data:void 0})}))})}archiveAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return Ln({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return Fn({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}deleteAll(){return m(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>m(this,null,function*(){return Un({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}clearCache({filter:t}={}){if(t){this.cache.clear(t!=null?t:{});return}this.cache.clearAll()}triggerHelloWorldEvent(){return m(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};Ft=new WeakMap;var Ut,Dt,Bt,Mt,Oe=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){_(this,Ut);_(this,Dt);_(this,Bt);_(this,Mt);S(this,Ut,t),S(this,Dt,r),S(this,Bt,n),S(this,Mt,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return m(this,null,function*(){var r;let t=!!e.weeklySchedule||!!this.weeklySchedule;return Ti({emitter:a(this,Ut),apiService:a(this,Dt),cache:a(this,Bt),useCache:a(this,Mt),args:E({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:E(E({},this.weeklySchedule),e.weeklySchedule)})})})}};Ut=new WeakMap,Dt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap;var qt,Wt,zt,$t,Vt,Ce=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){_(this,qt);_(this,Wt);_(this,zt);_(this,$t);_(this,Vt);S(this,qt,t),S(this,Wt,r),S(this,zt,n),S(this,$t,s),S(this,Vt,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Oe(E({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return Oi({emitter:a(this,qt),apiService:a(this,Wt),cache:a(this,zt),scheduleCache:a(this,$t),useCache:a(this,Vt),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};qt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,$t=new WeakMap,Vt=new WeakMap;var Oi=o=>m(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){var u;let{channels:c}=s,l="workflowId"in s?s.workflowId:(u=s.preference.workflow)==null?void 0:u.id;try{i.emit("preference.update.pending",{args:s,data:"preference"in s?new Ce(T(E({},s.preference),{channels:E(E({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0});let h;l?h=yield e.updateWorkflowPreferences({workflowId:l,channels:c}):(Sa({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),h=yield e.updateGlobalPreferences(c));let f=new Ce(h,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(h){return i.emit("preference.update.resolved",{args:s,error:h}),{error:new k("Failed to update preference",h)}}}),Bn=o=>m(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){if(s.find(l=>"preference"in l&&l.preference.level==="global"))return{error:new k("Global preference is not supported in bulk update","")};try{let l=s.map(d=>"preference"in d?new Ce(T(E({},d.preference),{channels:E(E({},d.preference.channels),d.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0).filter(d=>d!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:l});let u=s.map(d=>{var p,w,g,v;return E({workflowId:"workflowId"in d?d.workflowId:(v=(g=(p=d.preference.workflow)==null?void 0:p.id)!=null?g:(w=d.preference.workflow)==null?void 0:w.identifier)!=null?v:""},d.channels)}),f=(yield e.bulkUpdatePreferences(u)).map(d=>new Ce(d,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}));return i.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(l){return i.emit("preferences.bulk_update.resolved",{args:s,error:l}),{error:new k("Failed to bulk update preferences",l)}}}),Sa=({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s})=>{let o=n?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var l,u;if(c.level==="template"){let h=T(E({},c),{channels:Object.entries(c.channels).reduce((d,[p,w])=>{var v;let g=p;return d[g]=(v=s.channels[g])!=null?v:w,d},{})}),f="preference"in s?new Ce(h,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(u=(l=c.workflow)==null?void 0:l.id)!=null?u:"",channels:f.channels},data:f})}})},Ti=s=>m(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o,c;try{let{isEnabled:l,weeklySchedule:u}=n,h=new Oe({isEnabled:l,weeklySchedule:u},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});i.emit("preference.schedule.update.pending",{args:n,data:h});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:l,weeklySchedule:u}}),d=new Oe({isEnabled:(o=f.schedule)==null?void 0:o.isEnabled,weeklySchedule:(c=f.schedule)==null?void 0:c.weeklySchedule},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.schedule.update.resolved",{args:n,data:d}),{data:d}}catch(l){return i.emit("preference.schedule.update.resolved",{args:n,error:l}),{error:new k("Failed to update preference",l)}}});var He,Ii=class extends de{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});_(this,He);this.cache=t,S(this,He,r)}get(){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){var t,r;try{let n=a(this,He)?this.cache.getAll():void 0;if(this._emitter.emit("preference.schedule.get.pending",{args:void 0,data:n}),!n){let s=yield this._inboxService.fetchGlobalPreferences();n=new Oe({isEnabled:(t=s==null?void 0:s.schedule)==null?void 0:t.isEnabled,weeklySchedule:(r=s==null?void 0:s.schedule)==null?void 0:r.weeklySchedule},{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:a(this,He)}),a(this,He)&&(this.cache.set(n),n=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:n}),{data:n}}catch(n){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Ti({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,He),args:t}))})}};He=new WeakMap;var ba=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],wa=["preference.schedule.update.pending","preference.schedule.update.resolved"],xa=({tags:i,severity:e})=>Object.entries({tags:i,severity:e}).reduce((t,[r,n])=>(n==null||Array.isArray(n)&&n.length===0||(t[r]=n),t),{}),Or=({tags:i,severity:e})=>JSON.stringify(xa({tags:i,severity:e})),je,H,Pi=class{constructor({emitterInstance:e}){_(this,je);_(this,H);this.updatePreference=(e,t)=>{let r=a(this,H).get(e);if(!r)return!1;let n=r.findIndex(o=>{var c,l;return((c=o.workflow)==null?void 0:c.id)===((l=t.workflow)==null?void 0:l.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,a(this,H).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let r=a(this,H).get(e);if(!r)return!1;let n=r.findIndex(o=>o.level==="global");if(n===-1)return!1;let s=[...r];return s[n].schedule=t,a(this,H).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var n;if(!e)return;let t=a(this,H).keys(),r=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,H).get(s);!o||!c||r.add(s)}for(let s of r)a(this,je).emit("preferences.list.updated",{data:(n=a(this,H).get(s))!=null?n:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;a(this,H).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),c=a(this,H).get(n);!o||!c||r.add(n)})}),r.forEach(n=>{var s;a(this,je).emit("preferences.list.updated",{data:(s=a(this,H).get(n))!=null?s:[]})})};S(this,je,e);for(let t of ba)a(this,je).on(t,this.handlePreferenceEvent);for(let t of wa)a(this,je).on(t,this.handleScheduleEvent);S(this,H,new $e)}has(e){return a(this,H).get(Or(e))!==void 0}set(e,t){a(this,H).set(Or(e),t)}getAll(e){if(this.has(e))return a(this,H).get(Or(e))}clearAll(){a(this,H).clear()}};je=new WeakMap,H=new WeakMap;var Ca=["preference.schedule.update.pending","preference.schedule.update.resolved"],Ir=()=>"schedule",_t,se,Li=class{constructor({emitterInstance:e}){_(this,_t);_(this,se);this.updateScheduleInCache=(e,t)=>a(this,se).get(e)?(a(this,se).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,se).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,se).get(n);!s||!o||t.add(n)}for(let n of t)a(this,_t).emit("preference.schedule.get.updated",{data:a(this,se).get(n)})};S(this,_t,e);for(let t of Ca)a(this,_t).on(t,this.handleScheduleEvent);S(this,se,new $e)}has(){return a(this,se).get(Ir())!==void 0}set(e){a(this,se).set(Ir(),e)}getAll(){if(this.has())return a(this,se).get(Ir())}clearAll(){a(this,se).clear()}};_t=new WeakMap,se=new WeakMap;var Ie,Fi=class extends de{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Ie);this.cache=new Pi({emitterInstance:this._emitter}),this.scheduleCache=new Li({emitterInstance:this._emitter}),S(this,Ie,t),this.schedule=new Ii({cache:this.scheduleCache,useCache:t,inboxServiceInstance:r,eventEmitterInstance:n})}list(){return m(this,arguments,function*(t={}){return this.callWithSession(()=>m(this,null,function*(){var r;try{let n=a(this,Ie)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:n}),n||(n=(yield this._inboxService.fetchPreferences({tags:t.tags,severity:t.severity,criticality:(r=t.criticality)!=null?r:"nonCritical"})).map(o=>new Ce(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Ie)})),a(this,Ie)&&(this.cache.set(t,n),n=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:n}),{data:n}}catch(n){throw this._emitter.emit("preferences.list.resolved",{args:t,error:n}),n}}))})}update(t){return m(this,null,function*(){return this.callWithSession(()=>Oi({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Ie),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>Bn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Ie),args:t}))})}};Ie=new WeakMap;function Mn(){return typeof window!="undefined"}var rt,Ht,Y,Ui=class{constructor(e,t,r){_(this,rt);_(this,Ht);_(this,Y);S(this,rt,r),S(this,Ht,t),S(this,Y,e)}get applicationIdentifier(){return a(this,Y).applicationIdentifier}get subscriberId(){var e;return(e=a(this,Y).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,Y).context}get subscriberHash(){return a(this,Y).subscriberHash}get contextHash(){return a(this,Y).contextHash}get subscriber(){return a(this,Y).subscriber}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let r="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(r);case"store":return t&&window.localStorage.setItem(r,t),null;case"delete":return window.localStorage.removeItem(r),null;default:return null}}initialize(e){return m(this,null,function*(){var n,s,o,c,l,u;let t=((n=a(this,Y).subscriber)==null?void 0:n.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),r=JSON.stringify(a(this,Y).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&r))try{e&&S(this,Y,e);let{subscriber:h,subscriberHash:f,contextHash:d,applicationIdentifier:p,defaultSchedule:w,context:g}=a(this,Y),v;Mn()&&(v=Intl.DateTimeFormat().resolvedOptions().timeZone);let R=p;if(R)this.handleApplicationIdentifier("delete");else{let y=this.handleApplicationIdentifier("get");y&&(R=y)}a(this,rt).emit("session.initialize.pending",{args:a(this,Y)});let x=yield a(this,Ht).initializeSession({applicationIdentifier:R,subscriberHash:f,contextHash:d,subscriber:T(E({},h),{subscriberId:(o=h==null?void 0:h.subscriberId)!=null?o:"",timezone:(c=h==null?void 0:h.timezone)!=null?c:v}),defaultSchedule:w,context:g});(l=x==null?void 0:x.applicationIdentifier)!=null&&l.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",x.applicationIdentifier),(u=x==null?void 0:x.applicationIdentifier)!=null&&u.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,rt).emit("session.initialize.resolved",{args:a(this,Y),data:x})}catch(h){a(this,rt).emit("session.initialize.resolved",{args:a(this,Y),error:h})}})}};rt=new WeakMap,Ht=new WeakMap,Y=new WeakMap;function qn(i){if(!i)return"";let e=[];for(let[t,r]of Object.entries(i))if(r){let n=typeof r=="string"?r:r.id;e.push(`${t}:${n}`)}return e.sort().join(",")}function Wn({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}var Di=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,Na=function(){try{new Di.Event("")}catch(i){return!0}return!1}(),ka=function(){try{new Di.EventTarget}catch(i){return!0}return!1}();Na&&(Di.Event=function(){function i(e,t){this.bubbles=!!t&&!!t.bubbles,this.cancelable=!!t&&!!t.cancelable,this.composed=!!t&&!!t.composed,this.type=e}return i}());ka&&(Di.EventTarget=function(){function i(){this.__listeners=new Map}return i.prototype=Object.create(Object.prototype),i.prototype.addEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();n.has(s)||n.set(s,new Map);let o=n.get(s);o.has(t)||o.set(t,r)},i.prototype.removeEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();if(n.has(s)){let o=n.get(s);o.has(t)&&o.delete(t)}},i.prototype.dispatchEvent=function(e){if(!(e instanceof Event))throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.");let t=e.type,n=this.__listeners.get(t);if(n)for(var s of n.entries()){let o=s[0],c=s[1];try{typeof o=="function"?o.call(this,e):o&&typeof o.handleEvent=="function"&&o.handleEvent(e)}catch(l){setTimeout(()=>{throw l})}c&&c.once&&n.delete(o)}return!0},i}());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
14
+ `+s),i.push(n+"m+"+Wr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=vu()+e+" "+i[0]}function vu(){return J.inspectOpts.hideDate?"":new Date().toISOString()+" "}function bu(...i){return process.stderr.write(qr.formatWithOptions(J.inspectOpts,...i)+`
15
+ `)}function Su(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function _u(){return process.env.DEBUG}function Eu(i){i.inspectOpts={};let e=Object.keys(J.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=J.inspectOpts[e[t]]}Wr.exports=zn()(J);var{formatters:ya}=Wr.exports;ya.o=function(i){return this.inspectOpts.colors=this.useColors,qr.inspect(i,this.inspectOpts).split(`
16
+ `).map(e=>e.trim()).join(" ")};ya.O=function(i){return this.inspectOpts.colors=this.useColors,qr.inspect(i,this.inspectOpts)}});var Ti=F((qp,Vn)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Vn.exports=ma():Vn.exports=ga()});var Ha="v1",ja=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,qi=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=Ha,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=ja,headers:s={}}=e||{};this.apiVersion=t,this.apiUrl=`${r}/${t}`,this.headers=g({"Novu-API-Version":NOVU_API_VERSION,"Content-Type":"application/json","User-Agent":n},s)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var r;let t=e||typeof window!="undefined"&&((r=window.localStorage)==null?void 0:r.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=g(g({},this.headers),e)}get(e,t,r=!0){return d(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:r})})}post(e,t,r){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:r==null?void 0:r.headers}})})}patch(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return d(this,arguments,function*({path:e,searchParams:t,options:r,unwrapEnvelope:n=!0}){let o=Ga(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(r==null?void 0:r.method)||"GET",headers:g(g({},this.headers),(r==null?void 0:r.headers)||{}),body:r!=null&&r.body?JSON.stringify(r.body):void 0},l=yield fetch(o,c);if(!l.ok){let u=yield l.json();throw new Error(`${this.headers["User-Agent"]} error. Status: ${l.status}, Message: ${u.message}`)}if(l.status===204)return;let h=yield l.json();return n?h.data:h})}};function Ga(...i){return i.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var oe="/inbox",ie=`${oe}/notifications`,k,Wi=class{constructor(e={}){this.isSessionInitialized=!1;y(this,k);b(this,k,new qi(e))}initializeSession(c){return d(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o}){let l=yield a(this,k).post(`${oe}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:r,subscriber:n,defaultSchedule:s,context:o});return a(this,k).setAuthorizationToken(l.token),a(this,k).setKeylessHeader(l.applicationIdentifier),this.isSessionInitialized=!0,l})}fetchNotifications({after:e,archived:t,limit:r=10,offset:n,read:s,tags:o,snoozed:c,seen:l,data:h,severity:u}){let f=new URLSearchParams(`limit=${r}`);if(e&&f.append("after",e),n&&f.append("offset",`${n}`),o)for(let p of o)f.append("tags[]",p);if(s!==void 0&&f.append("read",`${s}`),t!==void 0&&f.append("archived",`${t}`),c!==void 0&&f.append("snoozed",`${c}`),l!==void 0&&f.append("seen",`${l}`),h!==void 0&&f.append("data",JSON.stringify(h)),u&&Array.isArray(u))for(let p of u)f.append("severity[]",p);else u&&f.append("severity",u);return a(this,k).get(ie,f,!1)}count({filters:e}){return a(this,k).get(`${ie}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,k).patch(`${ie}/${e}/read`)}unread(e){return a(this,k).patch(`${ie}/${e}/unread`)}archive(e){return a(this,k).patch(`${ie}/${e}/archive`)}unarchive(e){return a(this,k).patch(`${ie}/${e}/unarchive`)}snooze(e,t){return a(this,k).patch(`${ie}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,k).patch(`${ie}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,k).post(`${ie}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,k).post(`${ie}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,k).post(`${ie}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,k).delete(`${ie}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,k).post(`${ie}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:r}){return a(this,k).post(`${ie}/seen`,{notificationIds:e,tags:t,data:r?JSON.stringify(r):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return a(this,k).patch(`${ie}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,k).patch(`${ie}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:r}){let n=new URLSearchParams;if(e)for(let o of e)n.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)n.append("severity[]",o);else t&&n.append("severity",t);r&&n.append("criticality",r);let s=n.size?`?${n.toString()}`:"";return a(this,k).get(`${oe}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,k).patch(`${oe}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,k).patch(`${oe}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,k).patch(`${oe}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,k).get(`${oe}/preferences/global`)}triggerHelloWorldEvent(){let e={name:"hello-world",to:{subscriberId:"keyless-subscriber-id"},payload:{subject:"Novu Keyless Environment",body:"You're using a keyless demo environment. For full access to Novu features and cloud integration, obtain your API key.",primaryActionText:"Obtain API Key",primaryActionUrl:"https://go.novu.co/keyless",secondaryActionText:"Explore Documentation",secondaryActionUrl:"https://go.novu.co/keyless-docs"}};return a(this,k).post("/inbox/events",e)}fetchSubscriptions(e){return a(this,k).get(`${oe}/topics/${e}/subscriptions`)}getSubscription({topicKey:e,identifier:t}){return a(this,k).get(`${oe}/topics/${e}/subscriptions/${t}`)}createSubscription({identifier:e,name:t,topicKey:r,topicName:n,preferences:s}){return a(this,k).post(`${oe}/topics/${r}/subscriptions`,w(g({identifier:e,name:t},n&&{topic:{name:n}}),{preferences:s}))}updateSubscription({topicKey:e,subscriptionId:t,name:r,preferences:n}){return a(this,k).patch(`${oe}/topics/${e}/subscriptions/${t}`,{name:r,preferences:n})}updateSubscriptionPreference({subscriptionId:e,workflowId:t,enabled:r,condition:n}){return a(this,k).patch(`${oe}/subscriptions/${e}/preferences/${t}`,{enabled:r,condition:n})}bulkUpdateSubscriptionPreferences(e){return a(this,k).patch(`${oe}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,subscriptionId:t}){return a(this,k).delete(`${oe}/topics/${e}/subscriptions/${t}`)}};k=new WeakMap;function ns(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(n){n(t)}),(r=i.get("*"))&&r.slice().map(function(n){n(e,t)})}}}var dt,$i=class{constructor(){y(this,dt);b(this,dt,ns())}on(e,t){return a(this,dt).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,dt).off(e,t)}emit(e,t){a(this,dt).emit(e,t)}};dt=new WeakMap;var x=class extends Error{constructor(e,t){super(e),this.originalError=t}};var Ki=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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:s});let o=yield e.read(n),c=new U(o,i,e);return i.emit("notification.read.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.read.resolved",{args:t,error:o}),{error:new x("Failed to read notification",o)}}}),zi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:i,apiService:e});try{i.emit("notification.unread.pending",{args:t,data:s});let o=yield e.unread(n),c=new U(o,i,e);return i.emit("notification.unread.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unread.resolved",{args:t,error:o}),{error:new x("Failed to unread notification",o)}}}),Vi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isSeen:!0},{emitter:i,apiService:e});try{if(i.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(n),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,i,e);return i.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return i.emit("notification.seen.resolved",{args:t,error:o}),{error:new x("Failed to mark notification as seen",o)}}}),Hi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(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:s});let o=yield e.archive(n),c=new U(o,i,e);return i.emit("notification.archive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.archive.resolved",{args:t,error:o}),{error:new x("Failed to archive notification",o)}}}),ji=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:i,apiService:e});try{i.emit("notification.unarchive.pending",{args:t,data:s});let o=yield e.unarchive(n),c=new U(o,i,e);return i.emit("notification.unarchive.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new x("Failed to unarchive notification",o)}}}),Gi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isSnoozed:!0,snoozedUntil:t.snoozeUntil},{emitter:i,apiService:e});try{i.emit("notification.snooze.pending",{args:t,data:s});let o=yield e.snooze(n,t.snoozeUntil),c=new U(o,i,e);return i.emit("notification.snooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.snooze.resolved",{args:t,error:o}),{error:new x("Failed to snooze notification",o)}}}),Yi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=Ie(t,{isSnoozed:!1,snoozedUntil:null},{emitter:i,apiService:e});try{i.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(n),c=new U(o,i,e);return i.emit("notification.unsnooze.resolved",{args:t,data:c}),{data:c}}catch(o){return i.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new x("Failed to unsnooze notification",o)}}}),kt=n=>d(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:w(g({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:w(g({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=Ie(t,s,{emitter:i,apiService:e});try{i.emit("notification.complete_action.pending",{args:t,data:c});let l=yield e.completeAction({actionType:r,notificationId:o}),h=new U(l,i,e);return i.emit("notification.complete_action.resolved",{args:t,data:h}),{data:h}}catch(l){return i.emit("notification.complete_action.resolved",{args:t,error:l}),{error:new x(`Failed to complete ${r} action on the notification`,l)}}}),At=n=>d(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:w(g({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:w(g({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=Ie(t,s,{emitter:i,apiService:e});try{i.emit("notification.revert_action.pending",{args:t,data:c});let l=yield e.revertAction({actionType:r,notificationId:o}),h=new U(l,i,e);return i.emit("notification.revert_action.resolved",{args:t,data:h}),{data:h}}catch(l){return i.emit("notification.revert_action.resolved",{args:t,error:l}),{error:new x("Failed to fetch notifications",l)}}}),Ie=(i,e,t)=>"notification"in i?{notificationId:i.notification.id,optimisticValue:new U(g(g({},i.notification),e),t.emitter,t.apiService)}:{notificationId:i.notificationId},ss=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(w(g({},l),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),i,e));return i.emit("notifications.read_all.pending",{args:{tags:r,data:n},data:c}),yield e.readAll({tags:r,data:n}),i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.read_all.resolved",{args:{tags:r,data:n},error:o}),{error:new x("Failed to read all notifications",o)}}}),Xr=o=>d(void 0,[o],function*({emitter:i,inboxService:e,notificationsCache:t,notificationIds:r,tags:n,data:s}){try{let c=t.getUniqueNotifications({tags:n,data:s}),h=(r&&r.length>0?c.filter(u=>r.includes(u.id)):c).map(u=>new U(w(g({},u),{isSeen:!0,firstSeenAt:u.firstSeenAt||new Date().toISOString()}),i,e));return i.emit("notifications.seen_all.pending",{args:{notificationIds:r,tags:n,data:s},data:h}),yield e.markAsSeen({notificationIds:r,tags:n,data:s}),i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},data:h}),{}}catch(c){return i.emit("notifications.seen_all.resolved",{args:{notificationIds:r,tags:n,data:s},error:c}),{error:new x("Failed to mark all notifications as seen",c)}}}),os=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n}).map(l=>new U(w(g({},l),{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:n},data:c}),yield e.archiveAll({tags:r,data:n}),i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all.resolved",{args:{tags:r,data:n},error:o}),{error:new x("Failed to archive all notifications",o)}}}),as=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let c=t.getUniqueNotifications({tags:r,data:n,read:!0}).map(l=>new U(w(g({},l),{isArchived:!0,archivedAt:new Date().toISOString()}),i,e));return i.emit("notifications.archive_all_read.pending",{args:{tags:r,data:n},data:c}),yield e.archiveAllRead({tags:r,data:n}),i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},data:c}),{}}catch(o){return i.emit("notifications.archive_all_read.resolved",{args:{tags:r,data:n},error:o}),{error:new x("Failed to archive all read notifications",o)}}}),Ji=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=Ie(t,{},{emitter:i,apiService:e});try{return i.emit("notification.delete.pending",{args:t}),yield e.delete(n),i.emit("notification.delete.resolved",{args:t}),{}}catch(s){return i.emit("notification.delete.resolved",{args:t,error:s}),{error:new x("Failed to delete notification",s)}}}),cs=s=>d(void 0,[s],function*({emitter:i,inboxService:e,notificationsCache:t,tags:r,data:n}){try{let o=t.getUniqueNotifications({tags:r,data:n});return i.emit("notifications.delete_all.pending",{args:{tags:r,data:n},data:o}),yield e.deleteAll({tags:r,data:n}),i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n}}),{}}catch(o){return i.emit("notifications.delete_all.resolved",{args:{tags:r,data:n},error:o}),{error:new x("Failed to delete all notifications",o)}}});var H,re,U=class{constructor(e,t,r){y(this,H);y(this,re);b(this,H,t),b(this,re,r),this.id=e.id,this.transactionId=e.transactionId,this.subject=e.subject,this.body=e.body,this.to=e.to,this.isRead=e.isRead,this.isSeen=e.isSeen,this.isArchived=e.isArchived,this.isSnoozed=e.isSnoozed,this.snoozedUntil=e.snoozedUntil,this.deliveredAt=e.deliveredAt,this.createdAt=e.createdAt,this.readAt=e.readAt,this.firstSeenAt=e.firstSeenAt,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,this.workflow=e.workflow,this.severity=e.severity}read(){return Ki({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}unread(){return zi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}seen(){return Vi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}archive(){return Hi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}unarchive(){return ji({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}delete(){return Ji({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}snooze(e){return Gi({emitter:a(this,H),apiService:a(this,re),args:{notification:this,snoozeUntil:e}})}unsnooze(){return Yi({emitter:a(this,H),apiService:a(this,re),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return kt({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return kt({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return At({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return At({emitter:a(this,H),apiService:a(this,re),args:{notification:this},actionType:"secondary"})}on(e,t){let r=a(this,H).on(e,t);return()=>{r()}}off(e,t){a(this,H).off(e,t)}};H=new WeakMap,re=new WeakMap;var Qe,Rt,ae=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){y(this,Qe,[]);y(this,Rt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,Qe).forEach(c=>d(this,[c],function*({fn:s,resolve:o}){o(yield s())})),b(this,Qe,[])):r&&(this.onSessionError(r),b(this,Rt,r),a(this,Qe).forEach(({resolve:s})=>{s({error:new x("Failed to initialize session, please contact the support",r)})}),b(this,Qe,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return d(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,Rt)?Promise.resolve({error:new x("Failed to initialize session, please contact the support",a(this,Rt))}):new Promise((t,r)=>{a(this,Qe).push({fn:e,resolve:t,reject:r})})})}};Qe=new WeakMap,Rt=new WeakMap;var Qr=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var ah=["seen","unseen"],ch=["read","unread"],Zr=(i,e)=>Qr(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,Ya=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return Qr(t,r)},en=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},tn=(i,e)=>en(i.data,e.data)&&Zr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&Ya(i.severity,e.severity);var _e,Ee=class{constructor(){y(this,_e);b(this,_e,new Map)}get(e){return a(this,_e).get(e)}getValues(){return Array.from(a(this,_e).values())}entries(){return Array.from(a(this,_e).entries())}keys(){return Array.from(a(this,_e).keys())}set(e,t){a(this,_e).set(e,t)}remove(e){a(this,_e).delete(e)}clear(){a(this,_e).clear()}};_e=new WeakMap;var ls=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h})=>Object.entries({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h}).filter(([u,f])=>f!=null&&!(Array.isArray(f)&&f.length===0)).reduce((u,[f,p])=>(u[f]=p,u),{}),rn=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h})=>JSON.stringify(ls({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:h})),Ja=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(ls({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),It=i=>JSON.parse(i),Xa=["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"],Qa=["notification.archive.pending","notification.unarchive.pending","notification.snooze.pending","notification.unsnooze.pending","notification.delete.pending","notifications.archive_all.pending","notifications.archive_all_read.pending","notifications.delete_all.pending"],Ze,W,jt=class{constructor({emitter:e}){y(this,Ze);y(this,W);this.updateNotification=(e,t)=>{let r=a(this,W).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s[n]=t,a(this,W).set(e,w(g({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=a(this,W).get(e);if(!r)return!1;let n=r.notifications.findIndex(o=>o.id===t.id);if(n===-1)return!1;let s=[...r.notifications];return s.splice(n,1),a(this,W).set(e,w(g({},r),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:r,args:n}=t,s=[];if(r!=null)Array.isArray(r)&&r.every(c=>typeof c=="object"&&"id"in c)?s=r:typeof r=="object"&&"id"in r&&(s=[r]);else if(e&&n){if("notification"in n&&n.notification)s=[n.notification];else if("notificationId"in n&&n.notificationId){let c=[];a(this,W).keys().forEach(l=>{let h=a(this,W).get(l);if(h){let u=h.notifications.find(f=>f.id===n.notificationId);u&&c.push(u)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,W).keys().forEach(c=>{s.forEach(l=>{let h=!1;e?h=this.removeNotification(c,l):h=this.updateNotification(c,l),h&&o.add(Ja(It(c)))})}),o.forEach(c=>{let l=this.getAggregated(It(c));a(this,Ze).emit("notifications.list.updated",{data:l})})};b(this,Ze,e),Xa.forEach(t=>{a(this,Ze).on(t,this.handleNotificationEvent())}),Qa.forEach(t=>{a(this,Ze).on(t,this.handleNotificationEvent({remove:!0}))}),b(this,W,new Ee)}getAggregated(e){return a(this,W).keys().filter(r=>{let n=It(r);return tn(n,e)}).map(r=>a(this,W).get(r)).reduce((r,n)=>n?{hasMore:n.hasMore,filter:n.filter,notifications:[...r.notifications,...n.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}has(e){return a(this,W).get(rn(e))!==void 0}set(e,t){a(this,W).set(rn(e),t)}update(e,t){this.set(e,t);let r=this.getAggregated(It(rn(e)));a(this,Ze).emit("notifications.list.updated",{data:r})}getAll(e){if(this.has(e))return this.getAggregated({tags:e.tags,data:e.data,read:e.read,snoozed:e.snoozed,archived:e.archived,seen:e.seen,severity:e.severity})}getUniqueNotifications({tags:e,read:t,data:r}){let n=a(this,W).keys(),s=new Map;return n.forEach(o=>{let c=It(o);if(Zr(e,c.tags)&&en(r,c.data)){let l=a(this,W).get(o);if(!l)return;l.notifications.filter(h=>typeof t=="undefined"||t===h.isRead).forEach(h=>{s.set(h.id,h)})}}),Array.from(s.values())}clear(e){a(this,W).keys().forEach(r=>{tn(It(r),e)&&a(this,W).remove(r)})}clearAll(){a(this,W).clear()}};Ze=new WeakMap,W=new WeakMap;var Gt,Yt,Jt,Xt,Ue=class{constructor(e,t,r,n,s){y(this,Gt);y(this,Yt);y(this,Jt);y(this,Xt);var o;b(this,Gt,t),b(this,Yt,r),b(this,Jt,n),b(this,Xt,s),this.enabled=e.enabled,this.condition=(o=e.condition)!=null?o:void 0,this.workflow=e.workflow,this.subscriptionId=e.subscriptionId}update(e){return d(this,null,function*(){var t;return Xi({emitter:a(this,Gt),apiService:a(this,Yt),cache:a(this,Jt),useCache:a(this,Xt),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};Gt=new WeakMap,Yt=new WeakMap,Jt=new WeakMap,Xt=new WeakMap;var us=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.getAll(n):void 0;return i.emit("subscriptions.list.pending",{args:n,data:l}),(!l||c)&&(l=(yield e.fetchSubscriptions(n.topicKey)).map(u=>new De(w(g({},u),{topicKey:n.topicKey}),i,e,t,o)),o&&(t.set(n,l),l=t.getAll(n))),i.emit("subscriptions.list.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscriptions.list.resolved",{args:n,error:o}),{error:new x("Failed to fetch subscriptions",o)}}}),hs=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,options:r,args:n}){try{let{useCache:o,refetch:c}=r,l=o&&!c?t.get(n):void 0;if(i.emit("subscription.get.pending",{args:n,data:l}),!l||c){let h=yield e.getSubscription({topicKey:n.topicKey,identifier:n.identifier});if(!h)return i.emit("subscription.get.resolved",{args:n,data:null}),{data:null};l=new De(w(g({},h),{topicKey:n.topicKey}),i,e,t,o),o&&(t.setOne(n,l),l=t.get(n))}return i.emit("subscription.get.resolved",{args:n,data:l}),{data:l}}catch(o){return i.emit("subscription.get.resolved",{args:n,error:o}),{error:new x("Failed to fetch subscription",o)}}}),fs=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o;try{i.emit("subscription.create.pending",{args:n});let c=yield e.createSubscription({identifier:(o=n.identifier)!=null?o:"",name:n.name,topicKey:n.topicKey,topicName:n.topicName,preferences:n.preferences}),l=new De(w(g({},c),{topicKey:n.topicKey}),i,e,t,r);return i.emit("subscription.create.resolved",{args:n,data:l}),{data:l}}catch(c){return i.emit("subscription.create.resolved",{args:n,error:c}),{error:new x("Failed to create subscription",c)}}}),Qi=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){let o="subscriptionId"in n?n.subscriptionId:n.subscription.id,c="topicKey"in n?n.topicKey:n.subscription.topicKey;try{i.emit("subscription.update.pending",{args:n});let l=yield e.updateSubscription({topicKey:c,subscriptionId:o,name:n.name,preferences:n.preferences}),h=new De(w(g({},l),{topicKey:c}),i,e,t,r);return i.emit("subscription.update.resolved",{args:n,data:h}),{data:h}}catch(l){return i.emit("subscription.update.resolved",{args:n,error:l}),{error:new x("Failed to update subscription",l)}}}),Xi=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var c,l;let o="workflowId"in n?n.workflowId:(l=(c=n.preference)==null?void 0:c.workflow)==null?void 0:l.id;try{i.emit("subscription.preference.update.pending",{args:n,data:"preference"in n?new Ue(g(g({},n.preference),typeof n.value=="boolean"?{enabled:n.value}:{condition:n.value}),i,e,t,r):void 0});let h=yield e.updateSubscriptionPreference(g({subscriptionId:n.subscriptionId,workflowId:o},typeof n.value=="boolean"?{enabled:n.value}:{condition:n.value})),u=new Ue(g({},h),i,e,t,r);return i.emit("subscription.preference.update.resolved",{args:n,data:u}),{data:u}}catch(h){return i.emit("subscription.preference.update.resolved",{args:n,error:h}),{error:new x("Failed to update subscription",h)}}}),ds=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){try{let o=n.map(u=>"preference"in u?new Ue(g(g({},u.preference),typeof u.value=="boolean"?{enabled:u.value}:{condition:u.value}),i,e,t,r):void 0).filter(u=>u!==void 0);i.emit("subscription.preferences.bulk_update.pending",{args:n,data:o});let c=n.map(u=>{var f,p,m,C,v,_;return g({subscriptionIdOrIdentifier:u.subscriptionId,workflowId:"workflowId"in u?u.workflowId:(_=(v=(p=(f=u.preference)==null?void 0:f.workflow)==null?void 0:p.id)!=null?v:(C=(m=u.preference)==null?void 0:m.workflow)==null?void 0:C.identifier)!=null?_:""},typeof u.value=="boolean"?{enabled:u.value}:{condition:u.value})}),h=(yield e.bulkUpdateSubscriptionPreferences(c)).map(u=>new Ue(u,i,e,t,r));return i.emit("subscription.preferences.bulk_update.resolved",{args:n,data:h}),{data:h}}catch(o){return i.emit("subscription.preferences.bulk_update.resolved",{args:n,error:o}),{error:new x("Failed to bulk update subscription preferences",o)}}}),Zi=r=>d(void 0,[r],function*({emitter:i,apiService:e,args:t}){let n="subscriptionId"in t?t.subscriptionId:t.subscription.id,s="topicKey"in t?t.topicKey:t.subscription.topicKey;try{return i.emit("subscription.delete.pending",{args:t}),yield e.deleteSubscription({topicKey:s,subscriptionId:n}),i.emit("subscription.delete.resolved",{args:t}),{data:void 0}}catch(o){return i.emit("subscription.delete.resolved",{args:t,error:o}),{error:new x("Failed to delete subscription",o)}}});var Be,Me,et,tt,Tt,De=class{constructor(e,t,r,n,s){y(this,Be);y(this,Me);y(this,et);y(this,tt);y(this,Tt,!1);b(this,Be,t),b(this,Me,r),b(this,et,n),b(this,tt,s),this.id=e.id,this.identifier=e.identifier,this.topicKey=e.topicKey,this.preferences=e.preferences.map(o=>new Ue(g({},o),a(this,Be),a(this,Me),a(this,et),a(this,tt)))}update(e){return d(this,null,function*(){return Qi({emitter:a(this,Be),apiService:a(this,Me),cache:a(this,et),useCache:a(this,tt),args:w(g({},e),{subscription:this})})})}updatePreference(e){return d(this,null,function*(){return a(this,Tt)?{error:new x("Cannot update a deleted subscription",new Error("Subscription is stale"))}:Xi({emitter:a(this,Be),apiService:a(this,Me),cache:a(this,et),useCache:a(this,tt),args:w(g({},e),{subscriptionId:this.id})})})}bulkUpdatePreferences(e){return d(this,null,function*(){return a(this,Tt)?{error:new x("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:ds({emitter:a(this,Be),apiService:a(this,Me),cache:a(this,et),useCache:a(this,tt),args:e.map(t=>w(g({},t),{subscriptionId:this.id}))})})}delete(){return d(this,null,function*(){return a(this,Tt)?{error:new x("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:Zi({emitter:a(this,Be),apiService:a(this,Me),args:{subscription:this}})})}};Be=new WeakMap,Me=new WeakMap,et=new WeakMap,tt=new WeakMap,Tt=new WeakMap;var pt=i=>`list:${i.topicKey}`,ps=i=>i.split(":")[1],it=i=>`item:${i.topicKey}:${i.identifier}`,X,B,Qt,M,Zt,er=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:r}){y(this,X);y(this,B);y(this,Qt);y(this,M);y(this,Zt);this.handleCreate=e=>{let t=pt({topicKey:e.topicKey}),r=a(this,B).get(t);if(r){let n=[...r,e];a(this,B).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,M).set(it({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=pt({topicKey:e.topicKey}),r=a(this,B).get(t);if(r){let n=r.map(s=>s.id===e.id?e:s);a(this,B).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,M).set(it({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handlePreferenceUpdate=e=>{this.updateSubscriptionPreferences([e])};this.handleBulkPreferenceUpdate=e=>{this.updateSubscriptionPreferences(e)};this.updateSubscriptionPreferences=e=>{var s;let t=new Map;for(let o of e){let c=(s=t.get(o.subscriptionId))!=null?s:[];c.push(o),t.set(o.subscriptionId,c)}let r=a(this,B).keys();for(let o of r){let c=a(this,B).get(o);if(!c)continue;let l=!1,h=c.map(u=>{let f=t.get(u.id);return f?(l=!0,this.createUpdatedSubscription(u,f)):u});l&&(a(this,B).set(o,h),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:ps(o),subscriptions:h}}))}let n=a(this,M).keys();for(let o of n){let c=a(this,M).get(o);if(!c)continue;let l=t.get(c.id);if(l){let h=this.createUpdatedSubscription(c,l);a(this,M).set(o,h),a(this,X).emit("subscription.update.resolved",{args:{subscription:c},data:h})}}};this.createUpdatedSubscription=(e,t)=>{let r=e.preferences.map(n=>{let s=t.find(o=>o.workflow.id===n.workflow.id);return s||n});return new De({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:r},a(this,X),a(this,Zt),this,a(this,Qt))};this.handleDelete=e=>{let t=pt({topicKey:e.topicKey}),r=a(this,B).get(t);if(r){let n=r.filter(s=>s.id!==e.id);a(this,B).set(t,n),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:n}})}a(this,M).remove(it({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteById=e=>{let t=a(this,B).keys();for(let n of t){let s=a(this,B).get(n);if(s){let o=s.find(c=>c.id===e||c.identifier===e);if(o){let c=s.filter(l=>l.id!==o.id);a(this,B).set(n,c),a(this,X).emit("subscriptions.list.updated",{data:{topicKey:ps(n),subscriptions:c}}),a(this,M).remove(it({topicKey:o.topicKey,identifier:o.identifier}));return}}}let r=a(this,M).keys();for(let n of r){let s=a(this,M).get(n);if(s&&(s.id===e||s.identifier===e)){a(this,M).remove(n);return}}};b(this,X,e),b(this,B,new Ee),b(this,M,new Ee),b(this,Zt,t),b(this,Qt,r),a(this,X).on("subscription.create.resolved",({data:n})=>{n&&this.handleCreate(n)}),a(this,X).on("subscription.update.resolved",({data:n})=>{n&&this.handleUpdate(n)}),a(this,X).on("subscription.delete.resolved",({args:n})=>{"subscription"in n?this.handleDelete(n.subscription):"subscriptionId"in n&&this.handleDeleteById(n.subscriptionId)}),a(this,X).on("subscription.preference.update.pending",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preference.update.resolved",({data:n})=>{n&&this.handlePreferenceUpdate(n)}),a(this,X).on("subscription.preferences.bulk_update.resolved",({data:n})=>{n&&n.length>0&&this.handleBulkPreferenceUpdate(n)})}has(e){return a(this,B).get(pt(e))!==void 0}set(e,t){a(this,B).set(pt(e),t);for(let r of t)a(this,M).set(it({topicKey:e.topicKey,identifier:r.identifier}),r)}setOne(e,t){a(this,M).set(it(e),t)}getAll(e){return a(this,B).get(pt(e))}get(e){return a(this,M).get(it(e))}invalidate(e){let t=pt({topicKey:e.topicKey}),r=a(this,B).get(t);if(r)for(let s of r)a(this,M).remove(it({topicKey:e.topicKey,identifier:s.identifier}));a(this,B).remove(t);let n=a(this,M).keys();for(let s of n)s.startsWith(`item:${e.topicKey}:`)&&a(this,M).remove(s)}clearAll(){a(this,B).clear(),a(this,M).clear()}};X=new WeakMap,B=new WeakMap,Qt=new WeakMap,M=new WeakMap,Zt=new WeakMap;var ei,tr=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,ei);this.cache=new jt({emitter:n}),b(this,ei,t)}get inboxService(){return this._inboxService}list(){return d(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=Yr(s,["limit"]);return this.callWithSession(()=>d(this,null,function*(){let o=g({limit:t},r);try{let c="useCache"in o?o.useCache:a(this,ei),l=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:l}),!l){let h=yield this._inboxService.fetchNotifications(g({limit:t},r));l={hasMore:h.hasMore,filter:h.filter,notifications:h.data.map(u=>new U(u,this._emitter,this._inboxService))},c&&(this.cache.set(o,l),l=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:l}),{data:l}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new x("Failed to fetch notifications",c)}}}))})}count(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){let r=t&&"filters"in t?t.filters:[g({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let n=yield this._inboxService.count({filters:r}),s=t&&"filters"in t?{counts:n.data}:n.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(n){return this._emitter.emit("notifications.count.resolved",{args:t,error:n}),{error:new x("Failed to count notifications",n)}}}))})}read(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ki({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return zi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Vi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Hi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return ji({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ji({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Gi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return kt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return kt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return At({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return At({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return ss({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}seenAll(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){return"notificationIds"in t?Xr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):Xr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:"tags"in t?t.tags:void 0,data:"data"in t?t.data:void 0})}))})}archiveAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return os({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}archiveAllRead(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return as({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}deleteAll(){return d(this,arguments,function*({tags:t,data:r}={}){return this.callWithSession(()=>d(this,null,function*(){return cs({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:r})}))})}clearCache({filter:t}={}){if(t){this.cache.clear(t!=null?t:{});return}this.cache.clearAll()}triggerHelloWorldEvent(){return d(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};ei=new WeakMap;var ti,ii,ri,ni,qe=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){y(this,ti);y(this,ii);y(this,ri);y(this,ni);b(this,ti,t),b(this,ii,r),b(this,ri,n),b(this,ni,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return d(this,null,function*(){var r;let t=!!e.weeklySchedule||!!this.weeklySchedule;return ir({emitter:a(this,ti),apiService:a(this,ii),cache:a(this,ri),useCache:a(this,ni),args:g({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:g(g({},this.weeklySchedule),e.weeklySchedule)})})})}};ti=new WeakMap,ii=new WeakMap,ri=new WeakMap,ni=new WeakMap;var si,oi,ai,ci,li,Te=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){y(this,si);y(this,oi);y(this,ai);y(this,ci);y(this,li);b(this,si,t),b(this,oi,r),b(this,ai,n),b(this,ci,s),b(this,li,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new qe(g({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return rr({emitter:a(this,si),apiService:a(this,oi),cache:a(this,ai),scheduleCache:a(this,ci),useCache:a(this,li),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};si=new WeakMap,oi=new WeakMap,ai=new WeakMap,ci=new WeakMap,li=new WeakMap;var rr=o=>d(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){var h;let{channels:c}=s,l="workflowId"in s?s.workflowId:(h=s.preference.workflow)==null?void 0:h.id;try{i.emit("preference.update.pending",{args:s,data:"preference"in s?new Te(w(g({},s.preference),{channels:g(g({},s.preference.channels),c)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0});let u;l?u=yield e.updateWorkflowPreferences({workflowId:l,channels:c}):(Za({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}),u=yield e.updateGlobalPreferences(c));let f=new Te(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n});return i.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(u){return i.emit("preference.update.resolved",{args:s,error:u}),{error:new x("Failed to update preference",u)}}}),ms=o=>d(void 0,[o],function*({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s}){if(s.find(l=>"preference"in l&&l.preference.level==="global"))return{error:new x("Global preference is not supported in bulk update","")};try{let l=s.map(p=>"preference"in p?new Te(w(g({},p.preference),{channels:g(g({},p.preference.channels),p.channels)}),{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0).filter(p=>p!==void 0);i.emit("preferences.bulk_update.pending",{args:s,data:l});let h=s.map(p=>{var m,C,v,_;return g({workflowId:"workflowId"in p?p.workflowId:(_=(v=(m=p.preference.workflow)==null?void 0:m.id)!=null?v:(C=p.preference.workflow)==null?void 0:C.identifier)!=null?_:""},p.channels)}),f=(yield e.bulkUpdatePreferences(h)).map(p=>new Te(p,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}));return i.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(l){return i.emit("preferences.bulk_update.resolved",{args:s,error:l}),{error:new x("Failed to bulk update preferences",l)}}}),Za=({emitter:i,apiService:e,cache:t,scheduleCache:r,useCache:n,args:s})=>{let o=n?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var l,h;if(c.level==="template"){let u=w(g({},c),{channels:Object.entries(c.channels).reduce((p,[m,C])=>{var _;let v=m;return p[v]=(_=s.channels[v])!=null?_:C,p},{})}),f="preference"in s?new Te(u,{emitterInstance:i,inboxServiceInstance:e,cache:t,scheduleCache:r,useCache:n}):void 0;f&&i.emit("preference.update.pending",{args:{workflowId:(h=(l=c.workflow)==null?void 0:l.id)!=null?h:"",channels:f.channels},data:f})}})},ir=s=>d(void 0,[s],function*({emitter:i,apiService:e,cache:t,useCache:r,args:n}){var o,c;try{let{isEnabled:l,weeklySchedule:h}=n,u=new qe({isEnabled:l,weeklySchedule:h},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});i.emit("preference.schedule.update.pending",{args:n,data:u});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:l,weeklySchedule:h}}),p=new qe({isEnabled:(o=f.schedule)==null?void 0:o.isEnabled,weeklySchedule:(c=f.schedule)==null?void 0:c.weeklySchedule},{emitterInstance:i,inboxServiceInstance:e,cache:t,useCache:r});return i.emit("preference.schedule.update.resolved",{args:n,data:p}),{data:p}}catch(l){return i.emit("preference.schedule.update.resolved",{args:n,error:l}),{error:new x("Failed to update preference",l)}}});var rt,nr=class extends ae{constructor({cache:t,useCache:r,inboxServiceInstance:n,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:n});y(this,rt);this.cache=t,b(this,rt,r)}get(){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){var t,r;try{let n=a(this,rt)?this.cache.getAll():void 0;if(this._emitter.emit("preference.schedule.get.pending",{args:void 0,data:n}),!n){let s=yield this._inboxService.fetchGlobalPreferences();n=new qe({isEnabled:(t=s==null?void 0:s.schedule)==null?void 0:t.isEnabled,weeklySchedule:(r=s==null?void 0:s.schedule)==null?void 0:r.weeklySchedule},{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:a(this,rt)}),a(this,rt)&&(this.cache.set(n),n=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:n}),{data:n}}catch(n){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:n}),n}}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>ir({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,rt),args:t}))})}};rt=new WeakMap;var ec=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],tc=["preference.schedule.update.pending","preference.schedule.update.resolved"],ic=({tags:i,severity:e})=>Object.entries({tags:i,severity:e}).reduce((t,[r,n])=>(n==null||Array.isArray(n)&&n.length===0||(t[r]=n),t),{}),nn=({tags:i,severity:e})=>JSON.stringify(ic({tags:i,severity:e})),nt,j,sr=class{constructor({emitterInstance:e}){y(this,nt);y(this,j);this.updatePreference=(e,t)=>{let r=a(this,j).get(e);if(!r)return!1;let n=r.findIndex(o=>{var c,l;return((c=o.workflow)==null?void 0:c.id)===((l=t.workflow)==null?void 0:l.id)||o.level===t.level&&t.level==="global"});if(n===-1)return!1;let s=[...r];return s[n]=t,a(this,j).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let r=a(this,j).get(e);if(!r)return!1;let n=r.findIndex(o=>o.level==="global");if(n===-1)return!1;let s=[...r];return s[n].schedule=t,a(this,j).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var n;if(!e)return;let t=a(this,j).keys(),r=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,j).get(s);!o||!c||r.add(s)}for(let s of r)a(this,nt).emit("preferences.list.updated",{data:(n=a(this,j).get(s))!=null?n:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],r=new Set;a(this,j).keys().forEach(n=>{t.forEach(s=>{let o=this.updatePreference(n,s),c=a(this,j).get(n);!o||!c||r.add(n)})}),r.forEach(n=>{var s;a(this,nt).emit("preferences.list.updated",{data:(s=a(this,j).get(n))!=null?s:[]})})};b(this,nt,e);for(let t of ec)a(this,nt).on(t,this.handlePreferenceEvent);for(let t of tc)a(this,nt).on(t,this.handleScheduleEvent);b(this,j,new Ee)}has(e){return a(this,j).get(nn(e))!==void 0}set(e,t){a(this,j).set(nn(e),t)}getAll(e){if(this.has(e))return a(this,j).get(nn(e))}clearAll(){a(this,j).clear()}};nt=new WeakMap,j=new WeakMap;var rc=["preference.schedule.update.pending","preference.schedule.update.resolved"],sn=()=>"schedule",Ot,ue,or=class{constructor({emitterInstance:e}){y(this,Ot);y(this,ue);this.updateScheduleInCache=(e,t)=>a(this,ue).get(e)?(a(this,ue).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,r=a(this,ue).keys();for(let n of r){let s=this.updateScheduleInCache(n,e),o=a(this,ue).get(n);!s||!o||t.add(n)}for(let n of t)a(this,Ot).emit("preference.schedule.get.updated",{data:a(this,ue).get(n)})};b(this,Ot,e);for(let t of rc)a(this,Ot).on(t,this.handleScheduleEvent);b(this,ue,new Ee)}has(){return a(this,ue).get(sn())!==void 0}set(e){a(this,ue).set(sn(),e)}getAll(){if(this.has())return a(this,ue).get(sn())}clearAll(){a(this,ue).clear()}};Ot=new WeakMap,ue=new WeakMap;var We,ar=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,We);this.cache=new sr({emitterInstance:this._emitter}),this.scheduleCache=new or({emitterInstance:this._emitter}),b(this,We,t),this.schedule=new nr({cache:this.scheduleCache,useCache:t,inboxServiceInstance:r,eventEmitterInstance:n})}list(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){var r;try{let n=a(this,We)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:n}),n||(n=(yield this._inboxService.fetchPreferences({tags:t.tags,severity:t.severity,criticality:(r=t.criticality)!=null?r:"nonCritical"})).map(o=>new Te(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,We)})),a(this,We)&&(this.cache.set(t,n),n=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:n}),{data:n}}catch(n){throw this._emitter.emit("preferences.list.resolved",{args:t,error:n}),n}}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>rr({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,We),args:t}))})}bulkUpdate(t){return d(this,null,function*(){return this.callWithSession(()=>ms({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,We),args:t}))})}};We=new WeakMap;function ys(){return typeof window!="undefined"}var mt,ui,Q,cr=class{constructor(e,t,r){y(this,mt);y(this,ui);y(this,Q);b(this,mt,r),b(this,ui,t),b(this,Q,e)}get applicationIdentifier(){return a(this,Q).applicationIdentifier}get subscriberId(){var e;return(e=a(this,Q).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,Q).context}get subscriberHash(){return a(this,Q).subscriberHash}get contextHash(){return a(this,Q).contextHash}get subscriber(){return a(this,Q).subscriber}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let r="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(r);case"store":return t&&window.localStorage.setItem(r,t),null;case"delete":return window.localStorage.removeItem(r),null;default:return null}}initialize(e){return d(this,null,function*(){var n,s,o,c,l,h;let t=((n=a(this,Q).subscriber)==null?void 0:n.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),r=JSON.stringify(a(this,Q).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&r))try{e&&b(this,Q,e);let{subscriber:u,subscriberHash:f,contextHash:p,applicationIdentifier:m,defaultSchedule:C,context:v}=a(this,Q),_;ys()&&(_=Intl.DateTimeFormat().resolvedOptions().timeZone);let T=m;if(T)this.handleApplicationIdentifier("delete");else{let S=this.handleApplicationIdentifier("get");S&&(T=S)}a(this,mt).emit("session.initialize.pending",{args:a(this,Q)});let N=yield a(this,ui).initializeSession({applicationIdentifier:T,subscriberHash:f,contextHash:p,subscriber:w(g({},u),{subscriberId:(o=u==null?void 0:u.subscriberId)!=null?o:"",timezone:(c=u==null?void 0:u.timezone)!=null?c:_}),defaultSchedule:C,context:v});(l=N==null?void 0:N.applicationIdentifier)!=null&&l.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",N.applicationIdentifier),(h=N==null?void 0:N.applicationIdentifier)!=null&&h.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,mt).emit("session.initialize.resolved",{args:a(this,Q),data:N})}catch(u){a(this,mt).emit("session.initialize.resolved",{args:a(this,Q),error:u})}})}};mt=new WeakMap,ui=new WeakMap,Q=new WeakMap;function gs(i){if(!i)return"";let e=[];for(let[t,r]of Object.entries(i))if(r){let n=typeof r=="string"?r:r.id;e.push(`${t}:${n}`)}return e.sort().join(",")}function vs({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}function bs({topicKey:i,subscriberId:e}){return`tk_${i}:si_${e}`}var st,fi,hi=class extends ae{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n,subscriber:s}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,st);y(this,fi);this.cache=new er({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),b(this,st,t),b(this,fi,s)}list(t,r){return d(this,null,function*(){return this.callWithSession(()=>{var n;return us({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:w(g({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,st)}),args:t})})})}get(t,r){return d(this,null,function*(){return this.callWithSession(()=>{var n,s;return hs({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:w(g({},r),{useCache:(n=r==null?void 0:r.useCache)!=null?n:a(this,st)}),args:w(g({},t),{identifier:(s=t.identifier)!=null?s:bs({topicKey:t.topicKey,subscriberId:a(this,fi).subscriberId})})})})})}create(t){return d(this,null,function*(){return this.callWithSession(()=>fs({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,st),args:t}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>Qi({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,st),args:t}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>Zi({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};st=new WeakMap,fi=new WeakMap;var lr=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,nc=function(){try{new lr.Event("")}catch(i){return!0}return!1}(),sc=function(){try{new lr.EventTarget}catch(i){return!0}return!1}();nc&&(lr.Event=function(){function i(e,t){this.bubbles=!!t&&!!t.bubbles,this.cancelable=!!t&&!!t.cancelable,this.composed=!!t&&!!t.composed,this.type=e}return i}());sc&&(lr.EventTarget=function(){function i(){this.__listeners=new Map}return i.prototype=Object.create(Object.prototype),i.prototype.addEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();n.has(s)||n.set(s,new Map);let o=n.get(s);o.has(t)||o.set(t,r)},i.prototype.removeEventListener=function(e,t,r){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let n=this.__listeners,s=e.toString();if(n.has(s)){let o=n.get(s);o.has(t)&&o.delete(t)}},i.prototype.dispatchEvent=function(e){if(!(e instanceof Event))throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.");let t=e.type,n=this.__listeners.get(t);if(n)for(var s of n.entries()){let o=s[0],c=s[1];try{typeof o=="function"?o.call(this,e):o&&typeof o.handleEvent=="function"&&o.handleEvent(e)}catch(l){setTimeout(()=>{throw l})}c&&c.once&&n.delete(o)}return!0},i}());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
17
17
  PartySocket requires a global 'EventTarget' class to be available!
18
18
  You can polyfill this global by adding this to your code before any partysocket imports:
19
19
 
@@ -21,7 +21,7 @@
21
21
  import 'partysocket/event-target-polyfill';
22
22
  \`\`\`
23
23
  Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
24
- `);var Vn=class extends Event{constructor(e,t){super("error",t);I(this,"message");I(this,"error");this.message=e.message,this.error=e}},Hn=class extends Event{constructor(e=1e3,t="",r){super("close",r);I(this,"code");I(this,"reason");I(this,"wasClean",!0);this.code=e,this.reason=t}},Pr={Event,ErrorEvent:Vn,CloseEvent:Hn};function Aa(i,e){if(!i)throw new Error(e)}function Ra(i){return new i.constructor(i.type,i)}function Ta(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Hn(i.code||1999,i.reason||"unknown reason",i):"error"in i?new Vn(i.error,i):new Event(i.type,i)}var zn,Oa=typeof process!="undefined"&&typeof((zn=process.versions)==null?void 0:zn.node)!="undefined"&&typeof document=="undefined",Bi=Oa?Ta:Ra,nt={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:Number.POSITIVE_INFINITY,maxEnqueuedMessages:Number.POSITIVE_INFINITY,startClosed:!1,debug:!1},$n=!1,Mi=class st extends EventTarget{constructor(t,r,n={}){super();I(this,"_ws");I(this,"_retryCount",-1);I(this,"_uptimeTimeout");I(this,"_connectTimeout");I(this,"_shouldReconnect",!0);I(this,"_connectLock",!1);I(this,"_binaryType","blob");I(this,"_closeCalled",!1);I(this,"_messageQueue",[]);I(this,"_debugLogger",console.log.bind(console));I(this,"_url");I(this,"_protocols");I(this,"_options");I(this,"onclose",null);I(this,"onerror",null);I(this,"onmessage",null);I(this,"onopen",null);I(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:r=nt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),Aa(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(n=>{var s;return(s=this._ws)==null?void 0:s.send(n)}),this._messageQueue=[],this.onopen&&this.onopen(t),this.dispatchEvent(Bi(t))});I(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(Bi(t))});I(this,"_handleError",t=>{this._debug("error event",t.message),this._disconnect(void 0,t.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(t),this._debug("exec error listeners"),this.dispatchEvent(Bi(t)),this._connect()});I(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(Bi(t))});this._url=t,this._protocols=r,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return st.CONNECTING}get OPEN(){return st.OPEN}get CLOSING(){return st.CLOSING}get CLOSED(){return st.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((r,n)=>(typeof n=="string"?r+=n.length:n instanceof Blob?r+=n.size:r+=n.byteLength,r),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:""}get protocol(){return this._ws?this._ws.protocol:""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?st.CLOSED:st.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,r){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,r)}reconnect(t,r){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,r),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{let{maxEnqueuedMessages:r=nt.maxEnqueuedMessages}=this._options;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){let{reconnectionDelayGrowFactor:t=nt.reconnectionDelayGrowFactor,minReconnectionDelay:r=nt.minReconnectionDelay,maxReconnectionDelay:n=nt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*On(t,this._retryCount-1),s>n&&(s=n)),this._debug("next delay",s),s}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_getNextProtocols(t){if(!t)return Promise.resolve(null);if(typeof t=="string"||Array.isArray(t))return Promise.resolve(t);if(typeof t=="function"){let r=t();if(!r)return Promise.resolve(null);if(typeof r=="string"||Array.isArray(r))return Promise.resolve(r);if(r.then)return r}throw Error("Invalid protocols")}_getNextUrl(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){let r=t();if(typeof r=="string")return Promise.resolve(r);if(r.then)return r}throw Error("Invalid URL")}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:t=nt.maxRetries,connectionTimeout:r=nt.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([n,s])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket=="undefined"&&!$n&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
24
+ `);var Es=class extends Event{constructor(e,t){super("error",t);O(this,"message");O(this,"error");this.message=e.message,this.error=e}},ws=class extends Event{constructor(e=1e3,t="",r){super("close",r);O(this,"code");O(this,"reason");O(this,"wasClean",!0);this.code=e,this.reason=t}},on={Event,ErrorEvent:Es,CloseEvent:ws};function oc(i,e){if(!i)throw new Error(e)}function ac(i){return new i.constructor(i.type,i)}function cc(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new ws(i.code||1999,i.reason||"unknown reason",i):"error"in i?new Es(i.error,i):new Event(i.type,i)}var Ss,lc=typeof process!="undefined"&&typeof((Ss=process.versions)==null?void 0:Ss.node)!="undefined"&&typeof document=="undefined",ur=lc?cc:ac,yt={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:Number.POSITIVE_INFINITY,maxEnqueuedMessages:Number.POSITIVE_INFINITY,startClosed:!1,debug:!1},_s=!1,hr=class gt extends EventTarget{constructor(t,r,n={}){super();O(this,"_ws");O(this,"_retryCount",-1);O(this,"_uptimeTimeout");O(this,"_connectTimeout");O(this,"_shouldReconnect",!0);O(this,"_connectLock",!1);O(this,"_binaryType","blob");O(this,"_closeCalled",!1);O(this,"_messageQueue",[]);O(this,"_debugLogger",console.log.bind(console));O(this,"_url");O(this,"_protocols");O(this,"_options");O(this,"onclose",null);O(this,"onerror",null);O(this,"onmessage",null);O(this,"onopen",null);O(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:r=yt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),oc(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(n=>{var s;return(s=this._ws)==null?void 0:s.send(n)}),this._messageQueue=[],this.onopen&&this.onopen(t),this.dispatchEvent(ur(t))});O(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(ur(t))});O(this,"_handleError",t=>{this._debug("error event",t.message),this._disconnect(void 0,t.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(t),this._debug("exec error listeners"),this.dispatchEvent(ur(t)),this._connect()});O(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(ur(t))});this._url=t,this._protocols=r,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return gt.CONNECTING}get OPEN(){return gt.OPEN}get CLOSING(){return gt.CLOSING}get CLOSED(){return gt.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((r,n)=>(typeof n=="string"?r+=n.length:n instanceof Blob?r+=n.size:r+=n.byteLength,r),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:""}get protocol(){return this._ws?this._ws.protocol:""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?gt.CLOSED:gt.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,r){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,r)}reconnect(t,r){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,r),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{let{maxEnqueuedMessages:r=yt.maxEnqueuedMessages}=this._options;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){let{reconnectionDelayGrowFactor:t=yt.reconnectionDelayGrowFactor,minReconnectionDelay:r=yt.minReconnectionDelay,maxReconnectionDelay:n=yt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*rs(t,this._retryCount-1),s>n&&(s=n)),this._debug("next delay",s),s}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_getNextProtocols(t){if(!t)return Promise.resolve(null);if(typeof t=="string"||Array.isArray(t))return Promise.resolve(t);if(typeof t=="function"){let r=t();if(!r)return Promise.resolve(null);if(typeof r=="string"||Array.isArray(r))return Promise.resolve(r);if(r.then)return r}throw Error("Invalid protocols")}_getNextUrl(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){let r=t();if(typeof r=="string")return Promise.resolve(r);if(r.then)return r}throw Error("Invalid URL")}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:t=yt.maxRetries,connectionTimeout:r=yt.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([n,s])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket=="undefined"&&!_s&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
25
25
 
26
26
  For example, if you're using node.js, run \`npm install ws\`, and then in your code:
27
27
 
@@ -34,7 +34,7 @@ const partysocket = new PartySocket({
34
34
  WebSocket: WS
35
35
  });
36
36
 
37
- `),$n=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:n,protocols:s}),this._ws=s?new o(n,s):new o(n),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),r)}).catch(n=>{this._connectLock=!1,this._handleError(new Pr.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Pr.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,r){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,r),this._handleClose(new Pr.CloseEvent(t,r,this))}catch(n){}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};var jt="wss://socket.novu.co",jn="notifications.notification_received",Gn="notifications.unseen_count_changed",Kn="notifications.unread_count_changed",Ia=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:u,firstSeenDate:h,archivedAt:f,channel:d,subscriber:p,subject:w,avatar:g,cta:v,tags:R,data:x,workflow:y,severity:b})=>{var Ze,et,ie,Be,Me,qe,me,ge;let $={id:p==null?void 0:p._id,subscriberId:p==null?void 0:p.subscriberId,firstName:p==null?void 0:p.firstName,lastName:p==null?void 0:p.lastName,avatar:p==null?void 0:p.avatar,locale:p==null?void 0:p.locale,data:p==null?void 0:p.data,timezone:p==null?void 0:p.timezone,email:p==null?void 0:p.email,phone:p==null?void 0:p.phone},N=(et=(Ze=v.action)==null?void 0:Ze.buttons)==null?void 0:et.find(Te=>Te.type==="primary"),P=(Be=(ie=v.action)==null?void 0:ie.buttons)==null?void 0:Be.find(Te=>Te.type==="secondary"),q=(qe=(Me=v.action)==null?void 0:Me.result)==null?void 0:qe.type,ne=(me=v.action)==null?void 0:me.status;return T(E(E({id:i,transactionId:e,subject:w,body:t,to:$,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:g,primaryAction:N&&{label:N.content,isCompleted:q==="primary"&&ne==="done",redirect:N.url?{target:N.target,url:N.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:q==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:d,tags:R,redirect:(ge=v.data)!=null&&ge.url?{url:v.data.url,target:v.data.target}:void 0,data:x,workflow:y,severity:b})},Et,ve,_e,St,Wi,zi,$i,Vi,Ne,Yn,Lr,Fr,qi=class extends de{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Ne);_(this,Et);_(this,ve);_(this,_e);_(this,St);_(this,Wi,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,ve).emit(jn,{result:new U(Ia(r.data.message),a(this,ve),this._inboxService)})}catch(r){console.log("error",r)}});_(this,zi,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,ve).emit(Gn,{result:r.data.unseenCount})}catch(r){}});_(this,$i,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,ve).emit(Kn,{result:r.data.counts})}catch(r){}});_(this,Vi,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,Wi).call(this,t);break;case"unseen_count_changed":a(this,zi).call(this,t);break;case"unread_count_changed":a(this,$i).call(this,t);break;default:}}catch(r){}});S(this,ve,n),S(this,St,t!=null?t:jt)}onSessionSuccess({token:t}){S(this,Et,t)}isSocketEvent(t){return t===jn||t===Gn||t===Kn}connect(){return m(this,null,function*(){return a(this,Et)?ue(this,Ne,Lr).call(this):this.callWithSession(ue(this,Ne,Lr).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,_e)?ue(this,Ne,Fr).call(this):this.callWithSession(ue(this,Ne,Fr).bind(this))})}};Et=new WeakMap,ve=new WeakMap,_e=new WeakMap,St=new WeakMap,Wi=new WeakMap,zi=new WeakMap,$i=new WeakMap,Vi=new WeakMap,Ne=new WeakSet,Yn=function(){return m(this,null,function*(){if(a(this,_e))return;let t={socketUrl:a(this,St)};a(this,ve).emit("socket.connect.pending",{args:t});let r=new URL(a(this,St));r.searchParams.set("token",a(this,Et)),S(this,_e,new Mi(r.toString())),a(this,_e).addEventListener("open",()=>{a(this,ve).emit("socket.connect.resolved",{args:t})}),a(this,_e).addEventListener("error",n=>{a(this,ve).emit("socket.connect.resolved",{args:t,error:n})}),a(this,_e).addEventListener("message",a(this,Vi))})},Lr=function(){return m(this,null,function*(){try{return yield ue(this,Ne,Yn).call(this),{}}catch(t){return{error:new k("Failed to initialize the PartySocket",t)}}})},Fr=function(){return m(this,null,function*(){var t;try{return(t=a(this,_e))==null||t.close(),S(this,_e,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the PartySocket",r)}}})};var Ee=Object.create(null);Ee.open="0";Ee.close="1";Ee.ping="2";Ee.pong="3";Ee.message="4";Ee.upgrade="5";Ee.noop="6";var Gt=Object.create(null);Object.keys(Ee).forEach(i=>{Gt[Ee[i]]=i});var Kt={type:"error",data:"parser error"};var Yt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Jn(e,!0).toString("base64")):r(Ee[i]+(e||"")),Jn=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),Ur;function Xn(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Jn(i.data,!1));Yt(i,!0,t=>{Ur||(Ur=new TextEncoder),e(Ur.encode(t))})}var Jt=(i,e)=>{if(typeof i!="string")return{type:"message",data:Qn(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Qn(r,e)}}return Gt[t]?i.length>1?{type:Gt[t],data:i.substring(1)}:{type:Gt[t]}:Kt},Qn=(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 Zn="",es=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Yt(s,!1,c=>{r[o]=c,++n===t&&e(r.join(Zn))})})},ts=(i,e)=>{let t=i.split(Zn),r=[];for(let n=0;n<t.length;n++){let s=Jt(t[n],e);if(r.push(s),s.type==="error")break}return r};function is(){return new TransformStream({transform(i,e){Xn(i,t=>{let r=t.length,n;if(r<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,r);else if(r<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(n[0]|=128),e.enqueue(n),e.enqueue(t)})}})}var Dr;function Hi(i){return i.reduce((e,t)=>e+t.length,0)}function ji(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),r=0;for(let n=0;n<e;n++)t[n]=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 rs(i,e){Dr||(Dr=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(Hi(t)<1)break;let l=ji(t,1);s=(l[0]&128)===128,n=l[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(Hi(t)<2)break;let l=ji(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Hi(t)<8)break;let l=ji(t,8),u=new DataView(l.buffer,l.byteOffset,l.length),h=u.getUint32(0);if(h>Math.pow(2,21)-1){c.enqueue(Kt);break}n=h*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Hi(t)<n)break;let l=ji(t,n);c.enqueue(Jt(s?l:Dr.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(Kt);break}}}})}var Br=4;function L(i){if(i)return Pa(i)}function Pa(i){for(var e in L.prototype)i[e]=L.prototype[e];return i}L.prototype.on=L.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};L.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.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,n=0;n<t.length;n++)if(r=t[n],r===e||r.fn===e){t.splice(n,1);break}return t.length===0&&delete this._callbacks["$"+i],this};L.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,n=t.length;r<n;++r)t[r].apply(this,e)}return this};L.prototype.emitReserved=L.prototype.emit;L.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};L.prototype.hasListeners=function(i){return!!this.listeners(i).length};var Se=global;function Gi(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var La=Se.setTimeout,Fa=Se.clearTimeout;function Pe(i,e){e.useNativeTimers?(i.setTimeoutFn=La.bind(Se),i.clearTimeoutFn=Fa.bind(Se)):(i.setTimeoutFn=Se.setTimeout.bind(Se),i.clearTimeoutFn=Se.clearTimeout.bind(Se))}var Ua=1.33;function ns(i){return typeof i=="string"?Da(i):Math.ceil((i.byteLength||i.size)*Ua)}function Da(i){let e=0,t=0;for(let r=0,n=i.length;r<n;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 gs=Q(at(),1);function ps(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ms(i){let e={},t=i.split("&");for(let r=0,n=t.length;r<n;r++){let s=t[r].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}var oc=(0,gs.default)("engine.io-client:transport"),Hr=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Le=class extends L{constructor(e){super(),this.writable=!1,Pe(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Hr(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):oc("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Jt(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=ps(e);return t.length?"?"+t:""}};var Ns=Q(at(),1);var Es="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),jr=64,ac={},ys=0,Qi=0,vs;function _s(i){let e="";do e=Es[i%jr]+e,i=Math.floor(i/jr);while(i>0);return e}function Zi(){let i=_s(+new Date);return i!==vs?(ys=0,vs=i):i+"."+_s(ys++)}for(;Qi<jr;Qi++)ac[Es[Qi]]=Qi;var Yr=Q(ws(),1),Jr=Yr.default||Yr;function xs(){return new Kr}function lc(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 n=e[0].substring(t+1).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));let s={name:r,value:n};for(let o=1;o<e.length;o++){let c=e[o].split("=");if(c.length!==2)continue;let l=c[0].trim(),u=c[1].trim();switch(l){case"Expires":s.expires=new Date(u);break;case"Max-Age":let h=new Date;h.setUTCSeconds(h.getUTCSeconds()+parseInt(u,10)),s.expires=h;break;default:}}return s}var Kr=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=lc(r);n&&this.cookies.set(n.name,n)})}addCookies(e){let t=[];this.cookies.forEach((r,n)=>{var s;((s=r.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(n):t.push(`${n}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var re=(0,Ns.default)("engine.io-client:polling");function hc(){}var fc=function(){return new Jr({xdomain:!1}).responseType!=null}(),er=class extends Le{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let r=location.protocol==="https:",n=location.port;n||(n=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||n!==e.port}let t=e&&e.forceBase64;this.supportsBinary=fc&&!t,this.opts.withCredentials&&(this.cookieJar=xs())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{re("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(re("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){re("pre-pause polling complete"),--r||t()})),this.writable||(re("we are currently writing - waiting to pause"),r++,this.once("drain",function(){re("pre-pause writing complete"),--r||t()}))}else t()}poll(){re("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){re("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)};ts(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():re('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{re("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(re("transport open - closing"),e()):(re("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,es(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]=Zi()),!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",(n,s)=>{this.onError("xhr post error",n,s)})}doPoll(){re("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 L{constructor(e,t){super(),Pe(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=Gi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Jr(t);try{re("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 n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this.opts.extraHeaders[n])}}catch(n){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(n){}try{r.setRequestHeader("Accept","*/*")}catch(n){}(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 n;r.readyState===3&&((n=this.opts.cookieJar)===null||n===void 0||n.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))},re("xhr data %s",this.data),r.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},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=hc,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",Cs);else if(typeof addEventListener=="function"){let i="onpagehide"in Se?"pagehide":"unload";addEventListener(i,Cs,!1)}}function Cs(){for(let i in Ke.requests)Ke.requests.hasOwnProperty(i)&&Ke.requests[i].abort()}var Sl=Q(Ts(),1),bl=Q(on(),1),wl=Q(cn(),1),Ro=Q(mn(),1),xl=Q(Ao(),1);var To=Ro.default;var ci=To,hr=!1,Oo="nodebuffer",ft=process.nextTick;var Po=Q(at(),1);var Cl=(0,Po.default)("engine.io-client:websocket"),Io=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",fr=class extends Le{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=Io?{}:Gi(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=hr&&!Io?t?new ci(e,t):new ci(e):new ci(e,t,r)}catch(n){return this.emitReserved("error",n)}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],n=t===e.length-1;Yt(r,this.supportsBinary,s=>{let o={};hr||(r.options&&(o.compress=r.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{hr?this.ws.send(s):this.ws.send(s,o)}catch(c){Cl("websocket closed before onclose event")}n&&ft(()=>{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]=Zi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!ci}};var Lo=Q(at(),1),li=(0,Lo.default)("engine.io-client:webtransport"),ur=class extends Le{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{li("transport closed gracefully"),this.onClose()}).catch(e=>{li("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=rs(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=is();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){li("session is closed");return}li("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{li("an error occurred while reading: %s",c)})};s();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],n=t===e.length-1;this.writer.write(r).then(()=>{n&&ft(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var yn={websocket:fr,webtransport:ur,polling:er};var Nl=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,kl=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Rt(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 n=Nl.exec(i||""),s={},o=14;for(;o--;)s[kl[o]]=n[o]||"";return t!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=Al(s,s.path),s.queryKey=Rl(s,s.query),s}function Al(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 Rl(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var Fo=Q(at(),1);var D=(0,Fo.default)("engine.io-client:socket"),ut=class i extends L{constructor(e,t={}){super(),this.binaryType=Oo,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=Rt(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=Rt(t.host).host),Pe(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=ms(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){D('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Br,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 D("options: %j",r),new yn[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){D("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){D("setting transport %s",e.name),this.transport&&(D("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){D('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(D('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(D('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",D('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(D("changing transport and sending upgrade packet"),h(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{D('probe transport "%s" failed',e);let d=new Error("probe error");d.transport=t.name,this.emitReserved("upgradeError",d)}}))};function s(){r||(r=!0,h(),t.close(),t=null)}let o=f=>{let d=new Error("probe error: "+f);d.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",d)};function c(){o("transport closed")}function l(){o("socket closed")}function u(f){t&&f.name!==t.name&&(D('"%s" works - aborting "%s"',f.name,t.name),s())}let h=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",u)};t.once("open",n),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(D("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){D("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(D('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 D('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();D("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 n=this.writeBuffer[r].data;if(n&&(t+=ns(n)),r>0&&t>this.maxPayload)return D("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return D("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,n){if(typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:e,data:t,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let e=()=>{this.onClose("forced close"),D("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){D("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")&&(D('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,n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};ut.protocol=Br;var kd=ut.protocol;var Wo=Q(hi(),1),qo=(0,Wo.default)("socket.io-client:url");function zo(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)||(qo("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),qo("parse %s",i),r=Rt(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 s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(t&&t.port===r.port?"":":"+r.port),r}var Nn={};ua(Nn,{Decoder:()=>xn,Encoder:()=>wn,PacketType:()=>C,protocol:()=>Ko});var Hl=typeof ArrayBuffer=="function",jl=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,$o=Object.prototype.toString,Gl=typeof Blob=="function"||typeof Blob!="undefined"&&$o.call(Blob)==="[object BlobConstructor]",Kl=typeof File=="function"||typeof File!="undefined"&&$o.call(File)==="[object FileConstructor]";function ui(i){return Hl&&(i instanceof ArrayBuffer||jl(i))||Gl&&i instanceof Blob||Kl&&i instanceof File}function fi(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(fi(i[t]))return!0;return!1}if(ui(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return fi(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&fi(i[t]))return!0;return!1}function Vo(i){let e=[],t=i.data,r=i;return r.data=En(t,e),r.attachments=e.length,{packet:r,buffers:e}}function En(i,e){if(!i)return i;if(ui(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]=En(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]=En(i[r],e));return t}return i}function Ho(i,e){return i.data=Sn(i.data,e),delete i.attachments,i}function Sn(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]=Sn(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=Sn(i[t],e));return i}var Go=Q(at(),1),bn=(0,Go.default)("socket.io-parser"),Yl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Ko=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 wn=class{constructor(e){this.replacer=e}encode(e){return bn("encoding packet %j",e),(e.type===C.EVENT||e.type===C.ACK)&&fi(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)),bn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Vo(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function jo(i){return Object.prototype.toString.call(i)==="[object Object]"}var xn=class i extends L{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 Cn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ui(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 s=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(s,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(s,t)}else r.nsp="/";let n=e.charAt(t+1);if(n!==""&&Number(n)==n){let s=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(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return bn("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 jo(t);case C.DISCONNECT:return t===void 0;case C.CONNECT_ERROR:return typeof t=="string"||jo(t);case C.EVENT:case C.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Yl.indexOf(t[0])===-1);case C.ACK:case C.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Cn=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=Ho(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function le(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var Yo=Q(hi(),1),z=(0,Yo.default)("socket.io-client:socket"),Jl=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Tt=class extends L{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=[le(e,"open",this.onopen.bind(this)),le(e,"packet",this.onpacket.bind(this)),le(e,"error",this.onerror.bind(this)),le(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(Jl.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++;z("emitting packet with ack id %d",o);let c=t.pop();this._registerAckCallback(o,c),r.id=o}let n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)?z("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 n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(z("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));z("event with ack id %d has timed out after %d ms",e,n),t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((n,s)=>{t.push((o,c)=>r?o?s(o):n(c):n(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((n,...s)=>r!==this._queue[0]?void 0:(n!==null?r.tryCount>this._opts.retries&&(z("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(z("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(z("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){z("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,z("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(){z("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){z("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||[];z("emitting event %j",t),e.id!=null&&(z("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(...n){r||(r=!0,z("sending ack %j",n),t.packet({type:C.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(z("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):z("bad ack %s",e.id)}onconnect(e,t){z("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(){z("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&&(z("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 dt(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}dt.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};dt.prototype.reset=function(){this.attempts=0};dt.prototype.setMin=function(i){this.ms=i};dt.prototype.setMax=function(i){this.max=i};dt.prototype.setJitter=function(i){this.jitter=i};var Jo=Q(hi(),1),J=(0,Jo.default)("socket.io-client:manager"),Ot=class extends L{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,Pe(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 dt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||Nn;this.encoder=new n.Encoder,this.decoder=new n.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(J("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;J("opening %s",this.uri),this.engine=new ut(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=le(t,"open",function(){r.onopen(),e&&e()}),s=c=>{J("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=le(t,"error",s);if(this._timeout!==!1){let c=this._timeout;J("connect attempt will timeout after %d",c);let l=this.setTimeoutFn(()=>{J("connect attempt timed out after %d",c),n(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){J("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(le(e,"ping",this.onping.bind(this)),le(e,"data",this.ondata.bind(this)),le(e,"error",this.onerror.bind(this)),le(e,"close",this.onclose.bind(this)),le(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){ft(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){J("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Tt(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){J("socket %s is still active, skipping close",r);return}this._close()}_packet(e){J("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(){J("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){J("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){J("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)J("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();J("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(J("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(J("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(J("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 Qo=Q(hi(),1),Xo=(0,Qo.default)("socket.io-client"),di={};function pi(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=zo(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=di[n]&&s in di[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Xo("ignoring socket cache for %s",r),l=new Ot(r,e)):(di[n]||(Xo("new io instance for %s",r),di[n]=new Ot(r,e)),l=di[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(pi,{Manager:Ot,Socket:Tt,io:pi,connect:pi});var Xl="https://ws.novu.co",Zo="notifications.notification_received",ea="notifications.unseen_count_changed",ta="notifications.unread_count_changed",Ql=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:u,firstSeenDate:h,archivedAt:f,channel:d,subscriber:p,subject:w,avatar:g,cta:v,tags:R,data:x,workflow:y,severity:b})=>{var Ze,et,ie,Be,Me,qe,me,ge;let $={id:p==null?void 0:p._id,subscriberId:p==null?void 0:p.subscriberId,firstName:p==null?void 0:p.firstName,lastName:p==null?void 0:p.lastName,avatar:p==null?void 0:p.avatar,locale:p==null?void 0:p.locale,data:p==null?void 0:p.data,timezone:p==null?void 0:p.timezone,email:p==null?void 0:p.email,phone:p==null?void 0:p.phone},N=(et=(Ze=v.action)==null?void 0:Ze.buttons)==null?void 0:et.find(Te=>Te.type==="primary"),P=(Be=(ie=v.action)==null?void 0:ie.buttons)==null?void 0:Be.find(Te=>Te.type==="secondary"),q=(qe=(Me=v.action)==null?void 0:Me.result)==null?void 0:qe.type,ne=(me=v.action)==null?void 0:me.status;return T(E(E({id:i,transactionId:e,subject:w,body:t,to:$,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:u,firstSeenAt:h,archivedAt:f,avatar:g,primaryAction:N&&{label:N.content,isCompleted:q==="primary"&&ne==="done",redirect:N.url?{target:N.target,url:N.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:q==="secondary"&&ne==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:d,tags:R,redirect:(ge=v.data)!=null&&ge.url?{url:v.data.url,target:v.data.target}:void 0,data:x,workflow:y,severity:b})},It,we,he,Pt,yr,vr,_r,Ae,ia,kn,An,gr=class extends de{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Ae);_(this,It);_(this,we);_(this,he);_(this,Pt);_(this,yr,({message:t})=>{a(this,we).emit(Zo,{result:new U(Ql(t),a(this,we),this._inboxService)})});_(this,vr,({unseenCount:t})=>{a(this,we).emit(ea,{result:t})});_(this,_r,({counts:t})=>{a(this,we).emit(ta,{result:t})});S(this,we,n),S(this,Pt,t!=null?t:Xl)}onSessionSuccess({token:t}){S(this,It,t)}isSocketEvent(t){return t===Zo||t===ea||t===ta}connect(){return m(this,null,function*(){return a(this,It)?ue(this,Ae,kn).call(this):this.callWithSession(ue(this,Ae,kn).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,he)?ue(this,Ae,An).call(this):this.callWithSession(ue(this,Ae,An).bind(this))})}};It=new WeakMap,we=new WeakMap,he=new WeakMap,Pt=new WeakMap,yr=new WeakMap,vr=new WeakMap,_r=new WeakMap,Ae=new WeakSet,ia=function(){return m(this,null,function*(){var r,n,s;if(a(this,he))return;let t={socketUrl:a(this,Pt)};a(this,we).emit("socket.connect.pending",{args:t}),S(this,he,pi(a(this,Pt),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,It)}`}})),a(this,he).on("connect",()=>{a(this,we).emit("socket.connect.resolved",{args:t})}),a(this,he).on("connect_error",o=>{a(this,we).emit("socket.connect.resolved",{args:t,error:o})}),(r=a(this,he))==null||r.on("notification_received",a(this,yr)),(n=a(this,he))==null||n.on("unseen_count_changed",a(this,vr)),(s=a(this,he))==null||s.on("unread_count_changed",a(this,_r))})},kn=function(){return m(this,null,function*(){try{return yield ue(this,Ae,ia).call(this),{}}catch(t){return{error:new k("Failed to initialize the socket",t)}}})},An=function(){return m(this,null,function*(){var t;try{return(t=a(this,he))==null||t.disconnect(),S(this,he,void 0),{}}catch(r){return{error:new k("Failed to disconnect from the socket",r)}}})};var Zl=["wss://eu.socket.novu.co",jt,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],eh={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":jt,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function th(i){return i?eh[i]||i:jt}function ih(i){return!i||Zl.includes(i)}function ra({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=th(i);switch(ih(r)?"partysocket":"socket.io"){case"partysocket":return new qi({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new gr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Re,X,Qe,Er=class{constructor(e){_(this,Re);_(this,X);_(this,Qe);var t,r;S(this,Qe,new _i({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),S(this,Re,new Ei),S(this,X,new Ui({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:Wn({subscriberId:e.subscriberId,subscriber:e.subscriber}),defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Qe),a(this,Re))),a(this,X).initialize(),this.notifications=new Ri({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Re)}),this.preferences=new Fi({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Re)}),this.socket=ra({socketUrl:e.socketUrl,eventEmitterInstance:a(this,Re),inboxServiceInstance:a(this,Qe)}),this.on=(n,s)=>{this.socket.isSocketEvent(n)&&this.socket.connect();let o=a(this,Re).on(n,s);return()=>{o()}},this.off=(n,s)=>{a(this,Re).off(n,s)}}get applicationIdentifier(){return a(this,X).applicationIdentifier}get subscriberId(){return a(this,X).subscriberId}get context(){return a(this,X).context}get contextKey(){return qn(a(this,X).context)}changeSubscriber(e){return m(this,null,function*(){yield a(this,X).initialize({applicationIdentifier:a(this,X).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,X).context,contextHash:a(this,X).contextHash}),this.notifications.cache.clearAll(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return m(this,null,function*(){let t=a(this,X).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,X).initialize({applicationIdentifier:a(this,X).applicationIdentifier||"",subscriberHash:a(this,X).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.notifications.cache.clearAll(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Re=new WeakMap,X=new WeakMap,Qe=new WeakMap;window.Novu=Er;})();
37
+ `),_s=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:n,protocols:s}),this._ws=s?new o(n,s):new o(n),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),r)}).catch(n=>{this._connectLock=!1,this._handleError(new on.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new on.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,r){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,r),this._handleClose(new on.CloseEvent(t,r,this))}catch(n){}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};var di="wss://socket.novu.co",xs="notifications.notification_received",Cs="notifications.unseen_count_changed",Ns="notifications.unread_count_changed",uc=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:h,firstSeenDate:u,archivedAt:f,channel:p,subscriber:m,subject:C,avatar:v,cta:_,tags:T,data:N,workflow:S,severity:E})=>{var ht,ft,se,Ge,Ye,Je,be,Se;let V={id:m==null?void 0:m._id,subscriberId:m==null?void 0:m.subscriberId,firstName:m==null?void 0:m.firstName,lastName:m==null?void 0:m.lastName,avatar:m==null?void 0:m.avatar,locale:m==null?void 0:m.locale,data:m==null?void 0:m.data,timezone:m==null?void 0:m.timezone,email:m==null?void 0:m.email,phone:m==null?void 0:m.phone},R=(ft=(ht=_.action)==null?void 0:ht.buttons)==null?void 0:ft.find(Fe=>Fe.type==="primary"),P=(Ge=(se=_.action)==null?void 0:se.buttons)==null?void 0:Ge.find(Fe=>Fe.type==="secondary"),$=(Je=(Ye=_.action)==null?void 0:Ye.result)==null?void 0:Je.type,le=(be=_.action)==null?void 0:be.status;return w(g(g({id:i,transactionId:e,subject:C,body:t,to:V,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:h,firstSeenAt:u,archivedAt:f,avatar:v,primaryAction:R&&{label:R.content,isCompleted:$==="primary"&&le==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&le==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:T,redirect:(Se=_.data)!=null&&Se.url?{url:_.data.url,target:_.data.target}:void 0,data:N,workflow:S,severity:E})},Pt,we,xe,Lt,dr,pr,mr,yr,Oe,ks,an,cn,fr=class extends ae{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,Oe);y(this,Pt);y(this,we);y(this,xe);y(this,Lt);y(this,dr,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,we).emit(xs,{result:new U(uc(r.data.message),a(this,we),this._inboxService)})}catch(r){console.log("error",r)}});y(this,pr,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,we).emit(Cs,{result:r.data.unseenCount})}catch(r){}});y(this,mr,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,we).emit(Ns,{result:r.data.counts})}catch(r){}});y(this,yr,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,dr).call(this,t);break;case"unseen_count_changed":a(this,pr).call(this,t);break;case"unread_count_changed":a(this,mr).call(this,t);break;default:}}catch(r){}});b(this,we,n),b(this,Lt,t!=null?t:di)}onSessionSuccess({token:t}){b(this,Pt,t)}isSocketEvent(t){return t===xs||t===Cs||t===Ns}connect(){return d(this,null,function*(){return a(this,Pt)?ge(this,Oe,an).call(this):this.callWithSession(ge(this,Oe,an).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,xe)?ge(this,Oe,cn).call(this):this.callWithSession(ge(this,Oe,cn).bind(this))})}};Pt=new WeakMap,we=new WeakMap,xe=new WeakMap,Lt=new WeakMap,dr=new WeakMap,pr=new WeakMap,mr=new WeakMap,yr=new WeakMap,Oe=new WeakSet,ks=function(){return d(this,null,function*(){if(a(this,xe))return;let t={socketUrl:a(this,Lt)};a(this,we).emit("socket.connect.pending",{args:t});let r=new URL(a(this,Lt));r.searchParams.set("token",a(this,Pt)),b(this,xe,new hr(r.toString())),a(this,xe).addEventListener("open",()=>{a(this,we).emit("socket.connect.resolved",{args:t})}),a(this,xe).addEventListener("error",n=>{a(this,we).emit("socket.connect.resolved",{args:t,error:n})}),a(this,xe).addEventListener("message",a(this,yr))})},an=function(){return d(this,null,function*(){try{return yield ge(this,Oe,ks).call(this),{}}catch(t){return{error:new x("Failed to initialize the PartySocket",t)}}})},cn=function(){return d(this,null,function*(){var t;try{return(t=a(this,xe))==null||t.close(),b(this,xe,void 0),{}}catch(r){return{error:new x("Failed to disconnect from the PartySocket",r)}}})};var Ce=Object.create(null);Ce.open="0";Ce.close="1";Ce.ping="2";Ce.pong="3";Ce.message="4";Ce.upgrade="5";Ce.noop="6";var pi=Object.create(null);Object.keys(Ce).forEach(i=>{pi[Ce[i]]=i});var mi={type:"error",data:"parser error"};var yi=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+As(e,!0).toString("base64")):r(Ce[i]+(e||"")),As=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),ln;function Rs(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(As(i.data,!1));yi(i,!0,t=>{ln||(ln=new TextEncoder),e(ln.encode(t))})}var gi=(i,e)=>{if(typeof i!="string")return{type:"message",data:Is(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:Is(r,e)}}return pi[t]?i.length>1?{type:pi[t],data:i.substring(1)}:{type:pi[t]}:mi},Is=(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 Ts="",Os=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{yi(s,!1,c=>{r[o]=c,++n===t&&e(r.join(Ts))})})},Ps=(i,e)=>{let t=i.split(Ts),r=[];for(let n=0;n<t.length;n++){let s=gi(t[n],e);if(r.push(s),s.type==="error")break}return r};function Ls(){return new TransformStream({transform(i,e){Rs(i,t=>{let r=t.length,n;if(r<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,r);else if(r<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}i.data&&typeof i.data!="string"&&(n[0]|=128),e.enqueue(n),e.enqueue(t)})}})}var un;function gr(i){return i.reduce((e,t)=>e+t.length,0)}function vr(i,e){if(i[0].length===e)return i.shift();let t=new Uint8Array(e),r=0;for(let n=0;n<e;n++)t[n]=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 Fs(i,e){un||(un=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(gr(t)<1)break;let l=vr(t,1);s=(l[0]&128)===128,n=l[0]&127,n<126?r=3:n===126?r=1:r=2}else if(r===1){if(gr(t)<2)break;let l=vr(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(gr(t)<8)break;let l=vr(t,8),h=new DataView(l.buffer,l.byteOffset,l.length),u=h.getUint32(0);if(u>Math.pow(2,21)-1){c.enqueue(mi);break}n=u*Math.pow(2,32)+h.getUint32(4),r=3}else{if(gr(t)<n)break;let l=vr(t,n);c.enqueue(gi(s?l:un.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(mi);break}}}})}var hn=4;function L(i){if(i)return hc(i)}function hc(i){for(var e in L.prototype)i[e]=L.prototype[e];return i}L.prototype.on=L.prototype.addEventListener=function(i,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(e),this};L.prototype.once=function(i,e){function t(){this.off(i,t),e.apply(this,arguments)}return t.fn=e,this.on(i,t),this};L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.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,n=0;n<t.length;n++)if(r=t[n],r===e||r.fn===e){t.splice(n,1);break}return t.length===0&&delete this._callbacks["$"+i],this};L.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,n=t.length;r<n;++r)t[r].apply(this,e)}return this};L.prototype.emitReserved=L.prototype.emit;L.prototype.listeners=function(i){return this._callbacks=this._callbacks||{},this._callbacks["$"+i]||[]};L.prototype.hasListeners=function(i){return!!this.listeners(i).length};var Ne=global;function br(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var fc=Ne.setTimeout,dc=Ne.clearTimeout;function $e(i,e){e.useNativeTimers?(i.setTimeoutFn=fc.bind(Ne),i.clearTimeoutFn=dc.bind(Ne)):(i.setTimeoutFn=Ne.setTimeout.bind(Ne),i.clearTimeoutFn=Ne.clearTimeout.bind(Ne))}var pc=1.33;function Us(i){return typeof i=="string"?mc(i):Math.ceil((i.byteLength||i.size)*pc)}function mc(i){let e=0,t=0;for(let r=0,n=i.length;r<n;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 Gs=te(bt(),1);function Hs(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function js(i){let e={},t=i.split("&");for(let r=0,n=t.length;r<n;r++){let s=t[r].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}var Bc=(0,Gs.default)("engine.io-client:transport"),vn=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Ke=class extends L{constructor(e){super(),this.writable=!1,$e(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new vn(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):Bc("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=gi(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=Hs(e);return t.length?"?"+t:""}};var no=te(bt(),1);var Qs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),bn=64,Mc={},Ys=0,xr=0,Js;function Xs(i){let e="";do e=Qs[i%bn]+e,i=Math.floor(i/bn);while(i>0);return e}function Cr(){let i=Xs(+new Date);return i!==Js?(Ys=0,Js=i):i+"."+Xs(Ys++)}for(;xr<bn;xr++)Mc[Qs[xr]]=xr;var En=te(to(),1),wn=En.default||En;function io(){return new _n}function Wc(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 n=e[0].substring(t+1).trim();n.charCodeAt(0)===34&&(n=n.slice(1,-1));let s={name:r,value:n};for(let o=1;o<e.length;o++){let c=e[o].split("=");if(c.length!==2)continue;let l=c[0].trim(),h=c[1].trim();switch(l){case"Expires":s.expires=new Date(h);break;case"Max-Age":let u=new Date;u.setUTCSeconds(u.getUTCSeconds()+parseInt(h,10)),s.expires=u;break;default:}}return s}var _n=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=Wc(r);n&&this.cookies.set(n.name,n)})}addCookies(e){let t=[];this.cookies.forEach((r,n)=>{var s;((s=r.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(n):t.push(`${n}=${r.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var ce=(0,no.default)("engine.io-client:polling");function $c(){}var Kc=function(){return new wn({xdomain:!1}).responseType!=null}(),Nr=class extends Ke{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let r=location.protocol==="https:",n=location.port;n||(n=r?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||n!==e.port}let t=e&&e.forceBase64;this.supportsBinary=Kc&&!t,this.opts.withCredentials&&(this.cookieJar=io())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{ce("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let r=0;this.polling&&(ce("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){ce("pre-pause polling complete"),--r||t()})),this.writable||(ce("we are currently writing - waiting to pause"),r++,this.once("drain",function(){ce("pre-pause writing complete"),--r||t()}))}else t()}poll(){ce("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){ce("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)};Ps(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():ce('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{ce("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(ce("transport open - closing"),e()):(ce("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Os(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]=Cr()),!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 at(this.uri(),e)}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(n,s)=>{this.onError("xhr post error",n,s)})}doPoll(){ce("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}},at=class i extends L{constructor(e,t){super(),$e(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=br(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new wn(t);try{ce("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 n in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(n)&&r.setRequestHeader(n,this.opts.extraHeaders[n])}}catch(n){}if(this.method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(n){}try{r.setRequestHeader("Accept","*/*")}catch(n){}(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 n;r.readyState===3&&((n=this.opts.cookieJar)===null||n===void 0||n.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))},ce("xhr data %s",this.data),r.send(this.data)}catch(n){this.setTimeoutFn(()=>{this.onError(n)},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=$c,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()}};at.requestsCount=0;at.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",ro);else if(typeof addEventListener=="function"){let i="onpagehide"in Ne?"pagehide":"unload";addEventListener(i,ro,!1)}}function ro(){for(let i in at.requests)at.requests.hasOwnProperty(i)&&at.requests[i].abort()}var Zl=te(co(),1),eu=te(On(),1),tu=te(Ln(),1),aa=te(Wn(),1),iu=te(oa(),1);var ca=aa.default;var Ri=ca,Ur=!1,la="nodebuffer",wt=process.nextTick;var ha=te(bt(),1);var ru=(0,ha.default)("engine.io-client:websocket"),ua=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Dr=class extends Ke{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=ua?{}:br(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=Ur&&!ua?t?new Ri(e,t):new Ri(e):new Ri(e,t,r)}catch(n){return this.emitReserved("error",n)}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],n=t===e.length-1;yi(r,this.supportsBinary,s=>{let o={};Ur||(r.options&&(o.compress=r.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{Ur?this.ws.send(s):this.ws.send(s,o)}catch(c){ru("websocket closed before onclose event")}n&&wt(()=>{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]=Cr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Ri}};var fa=te(bt(),1),Ii=(0,fa.default)("engine.io-client:webtransport"),Br=class extends Ke{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Ii("transport closed gracefully"),this.onClose()}).catch(e=>{Ii("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Fs(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Ls();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){Ii("session is closed");return}Ii("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{Ii("an error occurred while reading: %s",c)})};s();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],n=t===e.length-1;this.writer.write(r).then(()=>{n&&wt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var Kn={websocket:Dr,webtransport:Br,polling:Nr};var nu=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,su=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function $t(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 n=nu.exec(i||""),s={},o=14;for(;o--;)s[su[o]]=n[o]||"";return t!=-1&&r!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=ou(s,s.path),s.queryKey=au(s,s.query),s}function ou(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 au(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var da=te(bt(),1);var D=(0,da.default)("engine.io-client:socket"),xt=class i extends L{constructor(e,t={}){super(),this.binaryType=la,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=$t(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=$t(t.host).host),$e(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=js(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){D('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=hn,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 D("options: %j",r),new Kn[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){D("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){D("setting transport %s",e.name),this.transport&&(D("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){D('probing transport "%s"',e);let t=this.createTransport(e),r=!1;i.priorWebsocketSuccess=!1;let n=()=>{r||(D('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(D('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;i.priorWebsocketSuccess=t.name==="websocket",D('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||this.readyState!=="closed"&&(D("changing transport and sending upgrade packet"),u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{D('probe transport "%s" failed',e);let p=new Error("probe error");p.transport=t.name,this.emitReserved("upgradeError",p)}}))};function s(){r||(r=!0,u(),t.close(),t=null)}let o=f=>{let p=new Error("probe error: "+f);p.transport=t.name,s(),D('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",p)};function c(){o("transport closed")}function l(){o("socket closed")}function h(f){t&&f.name!==t.name&&(D('"%s" works - aborting "%s"',f.name,t.name),s())}let u=()=>{t.removeListener("open",n),t.removeListener("error",o),t.removeListener("close",c),this.off("close",l),this.off("upgrading",h)};t.once("open",n),t.once("error",o),t.once("close",c),this.once("close",l),this.once("upgrading",h),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onOpen(){if(D("socket open"),this.readyState="open",i.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){D("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(D('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 D('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();D("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 n=this.writeBuffer[r].data;if(n&&(t+=Us(n)),r>0&&t>this.maxPayload)return D("only send %d out of %d packets",r,this.writeBuffer.length),this.writeBuffer.slice(0,r);t+=2}return D("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,n){if(typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:e,data:t,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let e=()=>{this.onClose("forced close"),D("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){D("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")&&(D('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,n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}};xt.protocol=hn;var Op=xt.protocol;var ba=te(Ti(),1),va=(0,ba.default)("socket.io-client:url");function Sa(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)||(va("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),va("parse %s",i),r=$t(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 s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+e,r.href=r.protocol+"://"+s+(t&&t.port===r.port?"":":"+r.port),r}var Qn={};za(Qn,{Decoder:()=>Jn,Encoder:()=>Yn,PacketType:()=>A,protocol:()=>Na});var wu=typeof ArrayBuffer=="function",xu=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,_a=Object.prototype.toString,Cu=typeof Blob=="function"||typeof Blob!="undefined"&&_a.call(Blob)==="[object BlobConstructor]",Nu=typeof File=="function"||typeof File!="undefined"&&_a.call(File)==="[object FileConstructor]";function Pi(i){return wu&&(i instanceof ArrayBuffer||xu(i))||Cu&&i instanceof Blob||Nu&&i instanceof File}function Oi(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(Oi(i[t]))return!0;return!1}if(Pi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return Oi(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&Oi(i[t]))return!0;return!1}function Ea(i){let e=[],t=i.data,r=i;return r.data=Hn(t,e),r.attachments=e.length,{packet:r,buffers:e}}function Hn(i,e){if(!i)return i;if(Pi(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]=Hn(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]=Hn(i[r],e));return t}return i}function wa(i,e){return i.data=jn(i.data,e),delete i.attachments,i}function jn(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]=jn(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=jn(i[t],e));return i}var Ca=te(bt(),1),Gn=(0,Ca.default)("socket.io-parser"),ku=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Na=5,A;(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"})(A||(A={}));var Yn=class{constructor(e){this.replacer=e}encode(e){return Gn("encoding packet %j",e),(e.type===A.EVENT||e.type===A.ACK)&&Oi(e)?this.encodeAsBinary({type:e.type===A.EVENT?A.BINARY_EVENT:A.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===A.BINARY_EVENT||e.type===A.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)),Gn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Ea(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function xa(i){return Object.prototype.toString.call(i)==="[object Object]"}var Jn=class i extends L{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===A.BINARY_EVENT;r||t.type===A.BINARY_ACK?(t.type=r?A.EVENT:A.ACK,this.reconstructor=new Xn(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(Pi(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(A[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===A.BINARY_EVENT||r.type===A.BINARY_ACK){let s=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let o=e.substring(s,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););r.nsp=e.substring(s,t)}else r.nsp="/";let n=e.charAt(t+1);if(n!==""&&Number(n)==n){let s=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(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(i.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return Gn("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 A.CONNECT:return xa(t);case A.DISCONNECT:return t===void 0;case A.CONNECT_ERROR:return typeof t=="string"||xa(t);case A.EVENT:case A.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&ku.indexOf(t[0])===-1);case A.ACK:case A.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Xn=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=wa(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function pe(i,e,t){return i.on(e,t),function(){i.off(e,t)}}var ka=te(Ti(),1),z=(0,ka.default)("socket.io-client:socket"),Au=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Kt=class extends L{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=[pe(e,"open",this.onopen.bind(this)),pe(e,"packet",this.onpacket.bind(this)),pe(e,"error",this.onerror.bind(this)),pe(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(Au.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:A.EVENT,data:t};if(r.options={},r.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;z("emitting packet with ack id %d",o);let c=t.pop();this._registerAckCallback(o,c),r.id=o}let n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)?z("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 n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&(z("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));z("event with ack id %d has timed out after %d ms",e,n),t.call(this,new Error("operation has timed out"))},n);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let r=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((n,s)=>{t.push((o,c)=>r?o?s(o):n(c):n(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((n,...s)=>r!==this._queue[0]?void 0:(n!==null?r.tryCount>this._opts.retries&&(z("packet [%d] is discarded after %d tries",r.id,r.tryCount),this._queue.shift(),t&&t(n)):(z("packet [%d] was successfully sent",r.id),this._queue.shift(),t&&t(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(z("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){z("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,z("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(){z("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:A.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){z("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 A.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 A.EVENT:case A.BINARY_EVENT:this.onevent(e);break;case A.ACK:case A.BINARY_ACK:this.onack(e);break;case A.DISCONNECT:this.ondisconnect();break;case A.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||[];z("emitting event %j",t),e.id!=null&&(z("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(...n){r||(r=!0,z("sending ack %j",n),t.packet({type:A.ACK,id:e,data:n}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(z("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):z("bad ack %s",e.id)}onconnect(e,t){z("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(){z("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&&(z("performing disconnect (%s)",this.nsp),this.packet({type:A.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 Ct(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}Ct.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};Ct.prototype.reset=function(){this.attempts=0};Ct.prototype.setMin=function(i){this.ms=i};Ct.prototype.setMax=function(i){this.max=i};Ct.prototype.setJitter=function(i){this.jitter=i};var Aa=te(Ti(),1),Z=(0,Aa.default)("socket.io-client:manager"),zt=class extends L{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,$e(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 Ct({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||Qn;this.encoder=new n.Encoder,this.decoder=new n.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(Z("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;Z("opening %s",this.uri),this.engine=new xt(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=pe(t,"open",function(){r.onopen(),e&&e()}),s=c=>{Z("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=pe(t,"error",s);if(this._timeout!==!1){let c=this._timeout;Z("connect attempt will timeout after %d",c);let l=this.setTimeoutFn(()=>{Z("connect attempt timed out after %d",c),n(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(n),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){Z("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(pe(e,"ping",this.onping.bind(this)),pe(e,"data",this.ondata.bind(this)),pe(e,"error",this.onerror.bind(this)),pe(e,"close",this.onclose.bind(this)),pe(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){wt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){Z("error",e),this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Kt(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){Z("socket %s is still active, skipping close",r);return}this._close()}_packet(e){Z("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(){Z("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){Z("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){Z("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)Z("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();Z("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(Z("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(n=>{n?(Z("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):(Z("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 Ia=te(Ti(),1),Ra=(0,Ia.default)("socket.io-client"),Li={};function Fi(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Sa(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=Li[n]&&s in Li[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Ra("ignoring socket cache for %s",r),l=new zt(r,e)):(Li[n]||(Ra("new io instance for %s",r),Li[n]=new zt(r,e)),l=Li[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(Fi,{Manager:zt,Socket:Kt,io:Fi,connect:Fi});var Ru="https://ws.novu.co",Ta="notifications.notification_received",Oa="notifications.unseen_count_changed",Pa="notifications.unread_count_changed",Iu=({_id:i,transactionId:e,content:t,read:r,seen:n,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:l,lastReadDate:h,firstSeenDate:u,archivedAt:f,channel:p,subscriber:m,subject:C,avatar:v,cta:_,tags:T,data:N,workflow:S,severity:E})=>{var ht,ft,se,Ge,Ye,Je,be,Se;let V={id:m==null?void 0:m._id,subscriberId:m==null?void 0:m.subscriberId,firstName:m==null?void 0:m.firstName,lastName:m==null?void 0:m.lastName,avatar:m==null?void 0:m.avatar,locale:m==null?void 0:m.locale,data:m==null?void 0:m.data,timezone:m==null?void 0:m.timezone,email:m==null?void 0:m.email,phone:m==null?void 0:m.phone},R=(ft=(ht=_.action)==null?void 0:ht.buttons)==null?void 0:ft.find(Fe=>Fe.type==="primary"),P=(Ge=(se=_.action)==null?void 0:se.buttons)==null?void 0:Ge.find(Fe=>Fe.type==="secondary"),$=(Je=(Ye=_.action)==null?void 0:Ye.result)==null?void 0:Je.type,le=(be=_.action)==null?void 0:be.status;return w(g(g({id:i,transactionId:e,subject:C,body:t,to:V,isRead:r,isSeen:n,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:l,readAt:h,firstSeenAt:u,archivedAt:f,avatar:v,primaryAction:R&&{label:R.content,isCompleted:$==="primary"&&le==="done",redirect:R.url?{target:R.target,url:R.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&le==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:p,tags:T,redirect:(Se=_.data)!=null&&Se.url?{url:_.data.url,target:_.data.target}:void 0,data:N,workflow:S,severity:E})},Vt,Ae,me,Ht,Kr,zr,Vr,Le,La,Zn,es,$r=class extends ae{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});y(this,Le);y(this,Vt);y(this,Ae);y(this,me);y(this,Ht);y(this,Kr,({message:t})=>{a(this,Ae).emit(Ta,{result:new U(Iu(t),a(this,Ae),this._inboxService)})});y(this,zr,({unseenCount:t})=>{a(this,Ae).emit(Oa,{result:t})});y(this,Vr,({counts:t})=>{a(this,Ae).emit(Pa,{result:t})});b(this,Ae,n),b(this,Ht,t!=null?t:Ru)}onSessionSuccess({token:t}){b(this,Vt,t)}isSocketEvent(t){return t===Ta||t===Oa||t===Pa}connect(){return d(this,null,function*(){return a(this,Vt)?ge(this,Le,Zn).call(this):this.callWithSession(ge(this,Le,Zn).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,me)?ge(this,Le,es).call(this):this.callWithSession(ge(this,Le,es).bind(this))})}};Vt=new WeakMap,Ae=new WeakMap,me=new WeakMap,Ht=new WeakMap,Kr=new WeakMap,zr=new WeakMap,Vr=new WeakMap,Le=new WeakSet,La=function(){return d(this,null,function*(){var r,n,s;if(a(this,me))return;let t={socketUrl:a(this,Ht)};a(this,Ae).emit("socket.connect.pending",{args:t}),b(this,me,Fi(a(this,Ht),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,Vt)}`}})),a(this,me).on("connect",()=>{a(this,Ae).emit("socket.connect.resolved",{args:t})}),a(this,me).on("connect_error",o=>{a(this,Ae).emit("socket.connect.resolved",{args:t,error:o})}),(r=a(this,me))==null||r.on("notification_received",a(this,Kr)),(n=a(this,me))==null||n.on("unseen_count_changed",a(this,zr)),(s=a(this,me))==null||s.on("unread_count_changed",a(this,Vr))})},Zn=function(){return d(this,null,function*(){try{return yield ge(this,Le,La).call(this),{}}catch(t){return{error:new x("Failed to initialize the socket",t)}}})},es=function(){return d(this,null,function*(){var t;try{return(t=a(this,me))==null||t.disconnect(),b(this,me,void 0),{}}catch(r){return{error:new x("Failed to disconnect from the socket",r)}}})};var Tu=["wss://eu.socket.novu.co",di,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],Ou={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":di,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function Pu(i){return i?Ou[i]||i:di}function Lu(i){return!i||Tu.includes(i)}function Fa({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=Pu(i);switch(Lu(r)?"partysocket":"socket.io"){case"partysocket":return new fr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new $r({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Re,ee,je,Ui,Hr=class{constructor(e){y(this,Re);y(this,ee);y(this,je);y(this,Ui);var r,n,s;b(this,Ui,e),b(this,je,new Wi({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),b(this,Re,new $i);let t=vs({subscriberId:e.subscriberId,subscriber:e.subscriber});b(this,ee,new cr({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,je),a(this,Re))),a(this,ee).initialize(),this.notifications=new tr({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,je),eventEmitterInstance:a(this,Re)}),this.preferences=new ar({useCache:(n=e.useCache)!=null?n:!0,inboxServiceInstance:a(this,je),eventEmitterInstance:a(this,Re)}),this.subscriptions=new hi({subscriber:t,useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,je),eventEmitterInstance:a(this,Re)}),this.socket=Fa({socketUrl:e.socketUrl,eventEmitterInstance:a(this,Re),inboxServiceInstance:a(this,je)}),this.on=(o,c)=>{this.socket.isSocketEvent(o)&&this.socket.connect();let l=a(this,Re).on(o,c);return()=>{l()}},this.off=(o,c)=>{a(this,Re).off(o,c)}}get applicationIdentifier(){return a(this,ee).applicationIdentifier}get subscriberId(){return a(this,ee).subscriberId}get context(){return a(this,ee).context}get options(){return a(this,Ui)}get contextKey(){return gs(a(this,ee).context)}clearCache(){this.notifications.cache.clearAll(),this.preferences.cache.clearAll(),this.preferences.scheduleCache.clearAll(),this.subscriptions.cache.clearAll()}changeSubscriber(e){return d(this,null,function*(){yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,ee).context,contextHash:a(this,ee).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return d(this,null,function*(){let t=a(this,ee).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,ee).initialize({applicationIdentifier:a(this,ee).applicationIdentifier||"",subscriberHash:a(this,ee).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Re=new WeakMap,ee=new WeakMap,je=new WeakMap,Ui=new WeakMap;window.Novu=Hr;})();
38
38
  /*! Bundled license information:
39
39
 
40
40
  xmlhttprequest-ssl/lib/XMLHttpRequest.js: