@novu/js 3.11.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{chunk-QQNKEWGC.js → chunk-MKYWGA37.js} +131 -809
- package/dist/cjs/chunk-WFVHYVDM.js +793 -0
- package/dist/cjs/index.d.ts +3 -4
- package/dist/cjs/index.js +26 -26
- package/dist/cjs/internal/index.d.ts +8 -2
- package/dist/cjs/internal/index.js +8 -4
- package/dist/cjs/novu-CKWESYFZ.d.ts +165 -0
- package/dist/cjs/{novu-ThMWeiRt.d.ts → novu-event-emitter-C7GZ7-r1.d.ts} +220 -163
- package/dist/cjs/themes/index.d.ts +3 -3
- package/dist/cjs/{types-BjANCN3c.d.ts → types-CeLsxWJg.d.ts} +2 -2
- package/dist/cjs/ui/index.d.ts +5 -4
- package/dist/cjs/ui/index.js +12 -12
- package/dist/esm/{chunk-UM35OVAD.mjs → chunk-76A4RQYD.mjs} +99 -771
- package/dist/esm/chunk-GY4JXBST.mjs +765 -0
- package/dist/esm/index.d.mts +3 -4
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/internal/index.d.mts +8 -2
- package/dist/esm/internal/index.mjs +1 -1
- package/dist/esm/novu-3CfttQ8e.d.mts +165 -0
- package/dist/esm/{novu-DY-mm8Og.d.mts → novu-event-emitter-C7GZ7-r1.d.mts} +220 -163
- package/dist/esm/themes/index.d.mts +3 -3
- package/dist/esm/{types-C5eX1GmB.d.mts → types-4YuozpWu.d.mts} +2 -2
- package/dist/esm/ui/index.d.mts +5 -4
- package/dist/esm/ui/index.mjs +4 -4
- package/dist/novu.min.js +12 -12
- package/dist/novu.min.js.gz +0 -0
- package/package.json +17 -17
- package/dist/cjs/chunk-VWSQDNZX.js +0 -66
- package/dist/cjs/types-BM_9Xx5Z.d.ts +0 -220
- package/dist/esm/chunk-RZWQYM3H.mjs +0 -62
- package/dist/esm/types-BM_9Xx5Z.d.mts +0 -220
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 ca=Object.create;var _i=Object.defineProperty,la=Object.defineProperties,ha=Object.getOwnPropertyDescriptor,fa=Object.getOwnPropertyDescriptors,ua=Object.getOwnPropertyNames,vi=Object.getOwnPropertySymbols,da=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty,Tn=Object.prototype.propertyIsEnumerable;var On=i=>{throw TypeError(i)},In=Math.pow,xr=(i,e,t)=>e in i?_i(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,E=(i,e)=>{for(var t in e||(e={}))wr.call(e,t)&&xr(i,t,e[t]);if(vi)for(var t of vi(e))Tn.call(e,t)&&xr(i,t,e[t]);return i},A=(i,e)=>la(i,fa(e));var R=(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 Cr=(i,e)=>{var t={};for(var r in i)wr.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&vi)for(var r of vi(i))e.indexOf(r)<0&&Tn.call(i,r)&&(t[r]=i[r]);return t};var F=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),pa=(i,e)=>{for(var t in e)_i(i,t,{get:e[t],enumerable:!0})},ma=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ua(e))!wr.call(i,n)&&n!==t&&_i(i,n,{get:()=>e[n],enumerable:!(r=ha(e,n))||r.enumerable});return i};var Q=(i,e,t)=>(t=i!=null?ca(da(i)):{},ma(e||!i||!i.__esModule?_i(t,"default",{value:i,enumerable:!0}):t,i));var I=(i,e,t)=>xr(i,typeof e!="symbol"?e+"":e,t),Nr=(i,e,t)=>e.has(i)||On("Cannot "+t);var a=(i,e,t)=>(Nr(i,e,"read from private field"),t?t.call(i):e.get(i)),_=(i,e,t)=>e.has(i)?On("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),S=(i,e,t,r)=>(Nr(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ue=(i,e,t)=>(Nr(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 qr=F((pu,as)=>{"use strict";var bt=1e3,xt=bt*60,wt=xt*60,at=wt*24,qa=at*7,Wa=at*365.25;as.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return za(i);if(t==="number"&&isFinite(i))return e.long?Va(i):$a(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function za(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*Wa;case"weeks":case"week":case"w":return t*qa;case"days":case"day":case"d":return t*at;case"hours":case"hour":case"hrs":case"hr":case"h":return t*wt;case"minutes":case"minute":case"mins":case"min":case"m":return t*xt;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 $a(i){var e=Math.abs(i);return e>=at?Math.round(i/at)+"d":e>=wt?Math.round(i/wt)+"h":e>=xt?Math.round(i/xt)+"m":e>=bt?Math.round(i/bt)+"s":i+"ms"}function Va(i){var e=Math.abs(i);return e>=at?Ji(i,e,at,"day"):e>=wt?Ji(i,e,wt,"hour"):e>=xt?Ji(i,e,xt,"minute"):e>=bt?Ji(i,e,bt,"second"):i+" ms"}function Ji(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var Wr=F((mu,cs)=>{"use strict";function Ha(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=qr(),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,x;function g(...v){if(!g.enabled)return;let T=g,w=Number(new Date),y=w-(f||w);T.diff=y,T.prev=f,T.curr=w,f=w,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(T,ne),v.splice(b,1),b--}return N}),t.formatArgs.call(T,v),(T.log||t.log).apply(T,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,x=t.enabled(h)),x),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}cs.exports=Ha});var ls=F((oe,Xi)=>{"use strict";oe.formatArgs=Ga;oe.save=Ka;oe.load=Ya;oe.useColors=ja;oe.storage=Ja();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 ja(){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 Ga(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+Xi.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 Ka(i){try{i?oe.storage.setItem("debug",i):oe.storage.removeItem("debug")}catch(e){}}function Ya(){let i;try{i=oe.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Ja(){try{return localStorage}catch(i){}}Xi.exports=Wr()(oe);var{formatters:Xa}=Xi.exports;Xa.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var fs=F((gu,hs)=>{"use strict";hs.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 Vr=F((yu,ds)=>{"use strict";var Qa=R("os"),us=R("tty"),pe=fs(),{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 zr(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function $r(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=Qa.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 Za(i){let e=$r(i,i&&i.isTTY);return zr(e)}ds.exports={supportsColor:Za,stdout:zr($r(!0,us.isatty(1))),stderr:zr($r(!0,us.isatty(2)))}});var ms=F((G,Zi)=>{"use strict";var ec=R("tty"),Qi=R("util");G.init=ac;G.log=nc;G.formatArgs=ic;G.save=sc;G.load=oc;G.useColors=tc;G.destroy=Qi.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=Vr();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 tc(){return"colors"in G.inspectOpts?!!G.inspectOpts.colors:ec.isatty(process.stderr.fd)}function ic(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+"+
|
|
4
|
-
`)}function
|
|
5
|
-
`).map(e=>e.trim()).join(" ")};
|
|
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+"+Zi.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=rc()+e+" "+i[0]}function rc(){return G.inspectOpts.hideDate?"":new Date().toISOString()+" "}function nc(...i){return process.stderr.write(Qi.formatWithOptions(G.inspectOpts,...i)+`
|
|
4
|
+
`)}function sc(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function oc(){return process.env.DEBUG}function ac(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]]}Zi.exports=Wr()(G);var{formatters:ps}=Zi.exports;ps.o=function(i){return this.inspectOpts.colors=this.useColors,Qi.inspect(i,this.inspectOpts).split(`
|
|
5
|
+
`).map(e=>e.trim()).join(" ")};ps.O=function(i){return this.inspectOpts.colors=this.useColors,Qi.inspect(i,this.inspectOpts)}});var ct=F((vu,Hr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Hr.exports=ls():Hr.exports=ms()});var Cs=F((Nu,ws)=>{"use strict";var Ct=R("fs"),xs=R("url"),hc=R("child_process").spawn;ws.exports=Kr;Kr.XMLHttpRequest=Kr;function Kr(i){"use strict";i=i||{};var e=this,t=R("http"),r=R("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,x=!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},T=function(y){return y&&f.indexOf(y)===-1};this.open=function(y,b,$,N,P){if(this.abort(),p=!1,x=!1,!T(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},w(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=xs.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,mt){fe?e.handleError(fe,fe.errno||-1):(e.status=200,e.responseText=mt,w(e.DONE))});else try{this.responseText=Ct.readFileSync(unescape(N.pathname),"utf8"),this.status=200,w(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 Me=b?r.request:t.request;d=!0,e.dispatchEvent("readystatechange");var qe=function(fe){if(s=fe,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var mt=xs.parse(o.url);P=mt.hostname;var ze={hostname:mt.hostname,port:mt.port,path:mt.path,method:s.statusCode===303?"GET":o.method,headers:u};b&&(ze.pfx=i.pfx,ze.key=i.key,ze.passphrase=i.passphrase,ze.cert=i.cert,ze.ca=i.ca,ze.ciphers=i.ciphers,ze.rejectUnauthorized=i.rejectUnauthorized!==!1),n=Me(ze,qe).on("error",We),n.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),w(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(yi){yi&&(e.responseText+=yi),d&&w(e.LOADING)}),s.on("end",function(){d&&(d=!1,w(e.DONE))}),s.on("error",function(yi){e.handleError(yi)})},We=function(fe){e.handleError(fe)};n=Me(ie,qe).on("error",We),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();",oa=hc(process.argv[0],["-e",Te]),sh;Ct.existsSync(ge););if(e.responseText=Ct.readFileSync(me,"utf8"),oa.stdin.end(),Ct.unlinkSync(me),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var aa=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(aa,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),w(e.DONE)}},this.handleError=function(y,b){this.status=b||0,this.statusText=y,this.responseText=y.stack,p=!0,w(this.DONE)},this.abort=function(){n&&(n.abort(),n=null),u=Object.assign({},l),this.responseText="",this.responseXML="",p=x=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||d)&&this.readyState!==this.DONE&&(d=!1,w(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 w=function(y){if(!(e.readyState===y||e.readyState===e.UNSENT&&x)&&(e.readyState=y,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let b;x?b="abort":p?b="error":b="load",e.dispatchEvent(b),e.dispatchEvent("loadend")}}}});var Is=F((Uu,Os)=>{"use strict";var{Duplex:pc}=R("stream");function Rs(i){i.emit("close")}function mc(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ts(i){this.removeListener("error",Ts),this.destroy(),this.listenerCount("error")===0&&this.emit("error",i)}function gc(i,e){let t=!0,r=new pc(A(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(Rs,r);return}let o=!1;i.once("error",function(l){o=!0,s(l)}),i.once("close",function(){o||s(n),process.nextTick(Rs,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",mc),r.on("error",Ts),r}Os.exports=gc});var Ye=F((Bu,Ps)=>{"use strict";Ps.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 Zt=F((Mu,rr)=>{"use strict";var{EMPTY_BUFFER:yc}=Ye();function vc(i,e){if(i.length===0)return yc;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 Ls(i,e,t,r,n){for(let s=0;s<n;s++)t[r+s]=i[s]^e[s&3]}function Fs(i,e){for(let t=0;t<i.length;t++)i[t]^=e[t&3]}function _c(i){return i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}function Qr(i){if(Qr.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),Qr.readOnly=!1),e}rr.exports={concat:vc,mask:Ls,toArrayBuffer:_c,toBuffer:Qr,unmask:Fs};if(!process.env.WS_NO_BUFFER_UTIL)try{let i=R("bufferutil");rr.exports.mask=function(e,t,r,n,s){s<48?Ls(e,t,r,n,s):i.mask(e,t,r,n,s)},rr.exports.unmask=function(e,t){e.length<32?Fs(e,t):i.unmask(e,t)}}catch(i){}});var Bs=F((qu,Ds)=>{"use strict";var Us=Symbol("kDone"),Zr=Symbol("kRun"),en=class{constructor(e){this[Us]=()=>{this.pending--,this[Zr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Zr]()}[Zr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Us])}}};Ds.exports=en});var ii=F((Wu,zs)=>{"use strict";var ei=R("zlib"),Ms=Zt(),Ec=Bs(),{kStatusCode:qs}=Ye(),Sc=Buffer.from([0,0,255,255]),or=Symbol("permessage-deflate"),Ue=Symbol("total-length"),ti=Symbol("callback"),Je=Symbol("buffers"),sr=Symbol("error"),nr,tn=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,!nr){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;nr=new Ec(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[ti];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){nr.add(n=>{this._decompress(e,t,(s,o)=>{n(),r(s,o)})})}compress(e,t,r){nr.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"?ei.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=ei.createInflateRaw(A(E({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[or]=this,this._inflate[Ue]=0,this._inflate[Je]=[],this._inflate.on("error",xc),this._inflate.on("data",Ws)}this._inflate[ti]=r,this._inflate.write(e),t&&this._inflate.write(Sc),this._inflate.flush(()=>{let s=this._inflate[sr];if(s){this._inflate.close(),this._inflate=null,r(s);return}let o=Ms.concat(this._inflate[Je],this._inflate[Ue]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ue]=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"?ei.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=ei.createDeflateRaw(A(E({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Ue]=0,this._deflate[Je]=[],this._deflate.on("data",bc)}this._deflate[ti]=r,this._deflate.write(e),this._deflate.flush(ei.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Ms.concat(this._deflate[Je],this._deflate[Ue]);t&&(s=s.slice(0,s.length-4)),this._deflate[ti]=null,this._deflate[Ue]=0,this._deflate[Je]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};zs.exports=tn;function bc(i){this[Je].push(i),this[Ue]+=i.length}function Ws(i){if(this[Ue]+=i.length,this[or]._maxPayload<1||this[Ue]<=this[or]._maxPayload){this[Je].push(i);return}this[sr]=new RangeError("Max payload size exceeded"),this[sr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[sr][qs]=1009,this.removeListener("data",Ws),this.reset()}function xc(i){this[or]._inflate=null,i[qs]=1007,this[ti](i)}});var ri=F(($u,rn)=>{"use strict";var wc=[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 Cc(i){return i>=1e3&&i<=1014&&i!==1004&&i!==1005&&i!==1006||i>=3e3&&i<=4999}function $s(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}rn.exports={isValidStatusCode:Cc,isValidUTF8:$s,tokenChars:wc};if(!process.env.WS_NO_UTF_8_VALIDATE)try{let i=R("utf-8-validate");rn.exports.isValidUTF8=function(e){return e.length<150?$s(e):i(e)}}catch(i){}});var an=F((Vu,Js)=>{"use strict";var{Writable:Nc}=R("stream"),Vs=ii(),{BINARY_TYPES:kc,EMPTY_BUFFER:Hs,kStatusCode:Ac,kWebSocket:Rc}=Ye(),{concat:nn,toArrayBuffer:Tc,unmask:Oc}=Zt(),{isValidStatusCode:Ic,isValidUTF8:js}=ri(),ni=0,Gs=1,Ks=2,Ys=3,sn=4,Pc=5,on=class extends Nc{constructor(e={}){super(),this._binaryType=e.binaryType||kc[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Rc]=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=ni,this._loop=!1}_write(e,t,r){if(this._opcode===8&&this._state==ni)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 ni:t=this.getInfo();break;case Gs:t=this.getPayloadLength16();break;case Ks:t=this.getPayloadLength64();break;case Ys:this.getMask();break;case sn: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[Vs.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=Gs;else if(this._payloadLength===127)this._state=Ks;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=Ys:this._state=sn}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=sn}getData(e){let t=Hs;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]&&Oc(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=Pc,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Vs.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=nn(t,e):this._binaryType==="arraybuffer"?r=Tc(nn(t,e)):r=t,this.emit("message",r,!0)}else{let r=nn(t,e);if(!this._skipUTF8Validation&&!js(r))return this._loop=!1,W(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",r,!1)}}this._state=ni}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,Hs),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(!Ic(t))return W(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let r=e.slice(2);if(!this._skipUTF8Validation&&!js(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=ni}};Js.exports=on;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[Ac]=r,s}});var ln=F((Gu,Zs)=>{"use strict";var Hu=R("net"),ju=R("tls"),{randomFillSync:Lc}=R("crypto"),Xs=ii(),{EMPTY_BUFFER:Fc}=Ye(),{isValidStatusCode:Uc}=ri(),{mask:Qs,toBuffer:Nt}=Zt(),be=Symbol("kByteLength"),Dc=Buffer.alloc(4),cn=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||Dc,t.generateMask?t.generateMask(r):Lc(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?(Qs(e,r,u,s,c),[u]):(Qs(e,r,e,0,c),[u,e])):[u,e]}close(e,t,r,n){let s;if(e===void 0)s=Fc;else{if(typeof e!="number"||!Uc(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[Xs.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[Xs.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)}};Zs.exports=cn});var co=F((Ku,ao)=>{"use strict";var{kForOnEventAttribute:si,kListener:hn}=Ye(),eo=Symbol("kCode"),to=Symbol("kData"),io=Symbol("kError"),ro=Symbol("kMessage"),no=Symbol("kReason"),kt=Symbol("kTarget"),so=Symbol("kType"),oo=Symbol("kWasClean"),De=class{constructor(e){this[kt]=null,this[so]=e}get target(){return this[kt]}get type(){return this[so]}};Object.defineProperty(De.prototype,"target",{enumerable:!0});Object.defineProperty(De.prototype,"type",{enumerable:!0});var lt=class extends De{constructor(e,t={}){super(e),this[eo]=t.code===void 0?0:t.code,this[no]=t.reason===void 0?"":t.reason,this[oo]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[eo]}get reason(){return this[no]}get wasClean(){return this[oo]}};Object.defineProperty(lt.prototype,"code",{enumerable:!0});Object.defineProperty(lt.prototype,"reason",{enumerable:!0});Object.defineProperty(lt.prototype,"wasClean",{enumerable:!0});var At=class extends De{constructor(e,t={}){super(e),this[io]=t.error===void 0?null:t.error,this[ro]=t.message===void 0?"":t.message}get error(){return this[io]}get message(){return this[ro]}};Object.defineProperty(At.prototype,"error",{enumerable:!0});Object.defineProperty(At.prototype,"message",{enumerable:!0});var oi=class extends De{constructor(e,t={}){super(e),this[to]=t.data===void 0?null:t.data}get data(){return this[to]}};Object.defineProperty(oi.prototype,"data",{enumerable:!0});var Bc={addEventListener(i,e,t={}){for(let n of this.listeners(i))if(!t[si]&&n[hn]===e&&!n[si])return;let r;if(i==="message")r=function(s,o){let c=new oi("message",{data:o?s:s.toString()});c[kt]=this,ar(e,this,c)};else if(i==="close")r=function(s,o){let c=new lt("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[kt]=this,ar(e,this,c)};else if(i==="error")r=function(s){let o=new At("error",{error:s,message:s.message});o[kt]=this,ar(e,this,o)};else if(i==="open")r=function(){let s=new De("open");s[kt]=this,ar(e,this,s)};else return;r[si]=!!t[si],r[hn]=e,t.once?this.once(i,r):this.on(i,r)},removeEventListener(i,e){for(let t of this.listeners(i))if(t[hn]===e&&!t[si]){this.removeListener(i,t);break}}};ao.exports={CloseEvent:lt,ErrorEvent:At,Event:De,EventTarget:Bc,MessageEvent:oi};function ar(i,e,t){typeof i=="object"&&i.handleEvent?i.handleEvent.call(i,t):i.call(e,t)}});var fn=F((Yu,lo)=>{"use strict";var{tokenChars:ai}=ri();function ke(i,e,t){i[e]===void 0?i[e]=[t]:i[e].push(t)}function Mc(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&&ai[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&&ai[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(ai[u]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),n=!1}else if(s)if(ai[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&&ai[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 qc(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(", ")}lo.exports={format:qc,parse:Mc}});var gn=F((Xu,So)=>{"use strict";var Wc=R("events"),zc=R("https"),$c=R("http"),uo=R("net"),Vc=R("tls"),{randomBytes:Hc,createHash:jc}=R("crypto"),{Readable:Ju}=R("stream"),{URL:un}=R("url"),Xe=ii(),Gc=an(),Kc=ln(),{BINARY_TYPES:ho,EMPTY_BUFFER:cr,GUID:Yc,kForOnEventAttribute:dn,kListener:Jc,kStatusCode:Xc,kWebSocket:te,NOOP:po}=Ye(),{EventTarget:{addEventListener:Qc,removeEventListener:Zc}}=co(),{format:el,parse:tl}=fn(),{toBuffer:il}=Zt(),rl=30*1e3,mo=Symbol("kAborted"),pn=[8,13],Be=["CONNECTING","OPEN","CLOSING","CLOSED"],nl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,M=class i extends Wc{constructor(e,t,r){super(),this._binaryType=ho[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=cr,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]),go(this,e,t,r)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){ho.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 Gc({binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new Kc(e,this._extensions,r.generateMask),this._receiver=n,this._socket=e,n[te]=this,e[te]=this,n.on("conclude",al),n.on("drain",cl),n.on("error",ll),n.on("message",hl),n.on("ping",fl),n.on("pong",ul),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",vo),e.on("data",hr),e.on("end",_o),e.on("error",Eo),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),rl)}}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){mn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||cr,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){mn(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||cr,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){mn(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||cr,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(M,"CONNECTING",{enumerable:!0,value:Be.indexOf("CONNECTING")});Object.defineProperty(M.prototype,"CONNECTING",{enumerable:!0,value:Be.indexOf("CONNECTING")});Object.defineProperty(M,"OPEN",{enumerable:!0,value:Be.indexOf("OPEN")});Object.defineProperty(M.prototype,"OPEN",{enumerable:!0,value:Be.indexOf("OPEN")});Object.defineProperty(M,"CLOSING",{enumerable:!0,value:Be.indexOf("CLOSING")});Object.defineProperty(M.prototype,"CLOSING",{enumerable:!0,value:Be.indexOf("CLOSING")});Object.defineProperty(M,"CLOSED",{enumerable:!0,value:Be.indexOf("CLOSED")});Object.defineProperty(M.prototype,"CLOSED",{enumerable:!0,value:Be.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(i=>{Object.defineProperty(M.prototype,i,{enumerable:!0})});["open","error","close","message"].forEach(i=>{Object.defineProperty(M.prototype,`on${i}`,{enumerable:!0,get(){for(let e of this.listeners(i))if(e[dn])return e[Jc];return null},set(e){for(let t of this.listeners(i))if(t[dn]){this.removeListener(i,t);break}typeof e=="function"&&this.addEventListener(i,e,{[dn]:!0})}})});M.prototype.addEventListener=Qc;M.prototype.removeEventListener=Zc;So.exports=M;function go(i,e,t,r){let n=A(E({protocolVersion:pn[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(!pn.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${pn.join(", ")})`);let s;if(e instanceof un)s=e,i._url=e.href;else{try{s=new un(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;lr(i,g);return}let u=o?443:80,h=Hc(16).toString("base64"),f=o?zc.request:$c.request,d=new Set,p;if(n.createConnection=o?ol:sl,n.defaultPort=n.defaultPort||u,n.port=s.port||u,n.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,n.headers=A(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"]=el({[Xe.extensionName]:p.offer()})),t.length){for(let g of t){if(typeof g!="string"||!nl.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 x;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=A(E({},r),{headers:{}}),g)for(let[v,T]of Object.entries(g))r.headers[v.toLowerCase()]=T}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")),x=i._req=f(n),i._redirects&&i.emit("redirect",i.url,x)}else x=i._req=f(n);n.timeout&&x.on("timeout",()=>{ae(i,x,"Opening handshake has timed out")}),x.on("error",g=>{x===null||x[mo]||(x=i._req=null,lr(i,g))}),x.on("response",g=>{let v=g.headers.location,T=g.statusCode;if(v&&n.followRedirects&&T>=300&&T<400){if(++i._redirects>n.maxRedirects){ae(i,x,"Maximum redirects exceeded");return}x.abort();let w;try{w=new un(v,e)}catch(y){let b=new SyntaxError(`Invalid URL: ${v}`);lr(i,b);return}go(i,w,t,r)}else i.emit("unexpected-response",x,g)||ae(i,x,`Unexpected server response: ${g.statusCode}`)}),x.on("upgrade",(g,v,T)=>{if(i.emit("upgrade",g),i.readyState!==M.CONNECTING)return;if(x=i._req=null,g.headers.upgrade.toLowerCase()!=="websocket"){ae(i,v,"Invalid Upgrade header");return}let w=jc("sha1").update(h+Yc).digest("base64");if(g.headers["sec-websocket-accept"]!==w){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=tl($)}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,T,{generateMask:n.generateMask,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation})}),x.end()}function lr(i,e){i._readyState=M.CLOSING,i.emit("error",e),i.emitClose()}function sl(i){return i.path=i.socketPath,uo.connect(i)}function ol(i){return i.path=void 0,!i.servername&&i.servername!==""&&(i.servername=uo.isIP(i.host)?"":i.host),Vc.connect(i)}function ae(i,e,t){i._readyState=M.CLOSING;let r=new Error(t);Error.captureStackTrace(r,ae),e.setHeader?(e[mo]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(lr,i,r)):(e.destroy(r),e.once("error",i.emit.bind(i,"error")),e.once("close",i.emitClose.bind(i)))}function mn(i,e,t){if(e){let r=il(e).length;i._socket?i._sender._bufferedBytes+=r:i._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${i.readyState} (${Be[i.readyState]})`);t(r)}}function al(i,e){let t=this[te];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=i,t._socket[te]!==void 0&&(t._socket.removeListener("data",hr),process.nextTick(yo,t._socket),i===1005?t.close():t.close(i,e))}function cl(){let i=this[te];i.isPaused||i._socket.resume()}function ll(i){let e=this[te];e._socket[te]!==void 0&&(e._socket.removeListener("data",hr),process.nextTick(yo,e._socket),e.close(i[Xc])),e.emit("error",i)}function fo(){this[te].emitClose()}function hl(i,e){this[te].emit("message",i,e)}function fl(i){let e=this[te];e.pong(i,!e._isServer,po),e.emit("ping",i)}function ul(i){this[te].emit("pong",i)}function yo(i){i.resume()}function vo(){let i=this[te];this.removeListener("close",vo),this.removeListener("data",hr),this.removeListener("end",_o),i._readyState=M.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",fo),i._receiver.on("finish",fo))}function hr(i){this[te]._receiver.write(i)||this.pause()}function _o(){let i=this[te];i._readyState=M.CLOSING,i._receiver.end(),this.end()}function Eo(){let i=this[te];this.removeListener("error",Eo),this.on("error",po),i&&(i._readyState=M.CLOSING,this.destroy())}});var xo=F((Zu,bo)=>{"use strict";var{tokenChars:dl}=ri();function pl(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&&dl[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}bo.exports={parse:pl}});var To=F((rd,Ro)=>{"use strict";var ml=R("events"),fr=R("http"),ed=R("https"),td=R("net"),id=R("tls"),{createHash:gl}=R("crypto"),wo=fn(),ht=ii(),yl=xo(),vl=gn(),{GUID:_l,kWebSocket:El}=Ye(),Sl=/^[+/0-9A-Za-z]{22}==$/,Co=0,No=1,Ao=2,yn=class extends ml{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:vl},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=bl(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=Co}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===Ao){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ci,this);return}if(e&&this.once("close",e),this._state!==No)if(this._state=No,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(ci,this):process.nextTick(ci,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ci(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",ko);let s=e.headers["sec-websocket-key"],o=+e.headers["sec-websocket-version"];if(e.method!=="GET"){ft(this,e,t,405,"Invalid HTTP method");return}if(e.headers.upgrade.toLowerCase()!=="websocket"){ft(this,e,t,400,"Invalid Upgrade header");return}if(!s||!Sl.test(s)){ft(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(o!==8&&o!==13){ft(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){li(t,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=yl.parse(c)}catch(f){ft(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 ht(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let d=wo.parse(u);d[ht.extensionName]&&(f.accept(d[ht.extensionName]),h[ht.extensionName]=f)}catch(d){ft(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,x,g)=>{if(!d)return li(t,p||401,x,g);this.completeUpgrade(h,s,l,e,t,r,n)});return}if(!this.options.verifyClient(f))return li(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[El])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Co)return li(s,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${gl("sha1").update(t+_l).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[ht.extensionName]){let f=e[ht.extensionName].params,d=wo.format({[ht.extensionName]:[f]});u.push(`Sec-WebSocket-Extensions: ${d}`),h._extensions=e}this.emit("headers",u,n),s.write(u.concat(`\r
|
|
7
7
|
`).join(`\r
|
|
8
|
-
`)),s.removeListener("error",
|
|
8
|
+
`)),s.removeListener("error",ko),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(ci,this)})),c(h,n)}};Ro.exports=yn;function bl(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 ci(i){i._state=Ao,i.emit("close")}function ko(){this.destroy()}function li(i,e,t,r){t=t||fr.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} ${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
|
|
12
|
+
`+t)}function ft(i,e,t,r,n){if(i.listenerCount("wsClientError")){let s=new Error(n);Error.captureStackTrace(s,ft),i.emit("wsClientError",s,t,e)}else li(t,r,n)}});var _n=F((Md,Bo)=>{"use strict";function Il(i){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=n,t.enabled=o,t.humanize=qr(),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,x;function g(...v){if(!g.enabled)return;let T=g,w=Number(new Date),y=w-(f||w);T.diff=y,T.prev=f,T.curr=w,f=w,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(T,ne),v.splice(b,1),b--}return N}),t.formatArgs.call(T,v),(T.log||t.log).apply(T,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,x=t.enabled(h)),x),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}Bo.exports=Il});var Mo=F((ce,mr)=>{"use strict";ce.formatArgs=Ll;ce.save=Fl;ce.load=Ul;ce.useColors=Pl;ce.storage=Dl();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 Pl(){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 Ll(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)}ce.log=console.debug||console.log||(()=>{});function Fl(i){try{i?ce.storage.setItem("debug",i):ce.storage.removeItem("debug")}catch(e){}}function Ul(){let i;try{i=ce.storage.getItem("debug")}catch(e){}return!i&&typeof process!="undefined"&&"env"in process&&(i=process.env.DEBUG),i}function Dl(){try{return localStorage}catch(i){}}mr.exports=_n()(ce);var{formatters:Bl}=mr.exports;Bl.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Wo=F((K,yr)=>{"use strict";var Ml=R("tty"),gr=R("util");K.init=jl;K.log=$l;K.formatArgs=Wl;K.save=Vl;K.load=Hl;K.useColors=ql;K.destroy=gr.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=Vr();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 ql(){return"colors"in K.inspectOpts?!!K.inspectOpts.colors:Ml.isatty(process.stderr.fd)}function Wl(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+"+
|
|
15
|
-
`)}function
|
|
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+"+yr.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=zl()+e+" "+i[0]}function zl(){return K.inspectOpts.hideDate?"":new Date().toISOString()+" "}function $l(...i){return process.stderr.write(gr.formatWithOptions(K.inspectOpts,...i)+`
|
|
15
|
+
`)}function Vl(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Hl(){return process.env.DEBUG}function jl(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]]}yr.exports=_n()(K);var{formatters:qo}=yr.exports;qo.o=function(i){return this.inspectOpts.colors=this.useColors,gr.inspect(i,this.inspectOpts).split(`
|
|
16
|
+
`).map(e=>e.trim()).join(" ")};qo.O=function(i){return this.inspectOpts.colors=this.useColors,gr.inspect(i,this.inspectOpts)}});var ui=F((qd,En)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?En.exports=Mo():En.exports=Wo()});var ga="v1",ya=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,Ei=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t=ga,apiUrl:r=this.DEFAULT_BACKEND_URL,userAgent:n=ya,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=va(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 va(...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,Si=class{constructor(e={}){this.isSessionInitialized=!1;_(this,O);S(this,O,new Ei(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 Pn(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,bi=class{constructor(){_(this,it);S(this,it,Pn())}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 xi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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)}}}),wi=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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)}}}),Ci=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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)}}}),Ni=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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)}}}),ki=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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)}}}),Ai=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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)}}}),Ri=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n,optimisticValue:s}=we(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)}}}),gt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:A(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:A(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=we(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)}}}),yt=n=>m(void 0,[n],function*({emitter:i,apiService:e,args:t,actionType:r}){let s=r==="primary"?{primaryAction:A(E({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:A(E({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=we(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)}}}),we=(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},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(A(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)}}}),kr=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(A(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)}}}),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}).map(l=>new U(A(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)}}}),Un=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(A(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)}}}),Ti=r=>m(void 0,[r],function*({emitter:i,apiService:e,args:t}){let{notificationId:n}=we(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)}}}),Dn=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 xi({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}unread(){return wi({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}seen(){return Ci({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}archive(){return Ni({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}unarchive(){return ki({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}delete(){return Ti({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}snooze(e){return Ai({emitter:a(this,V),apiService:a(this,ee),args:{notification:this,snoozeUntil:e}})}unsnooze(){return Ri({emitter:a(this,V),apiService:a(this,ee),args:{notification:this}})}completePrimary(){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"})}completeSecondary(){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"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return yt({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 yt({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 $e,vt,de=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){_(this,$e,[]);_(this,vt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:r,data:n})=>{n?(this.onSessionSuccess(n),a(this,$e).forEach(c=>m(this,[c],function*({fn:s,resolve:o}){o(yield s())})),S(this,$e,[])):r&&(this.onSessionError(r),S(this,vt,r),a(this,$e).forEach(({resolve:s})=>{s({error:new k("Failed to initialize session, please contact the support",r)})}),S(this,$e,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return m(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,vt)?Promise.resolve({error:new k("Failed to initialize session, please contact the support",a(this,vt))}):new Promise((t,r)=>{a(this,$e).push({fn:e,resolve:t,reject:r})})})}};$e=new WeakMap,vt=new WeakMap;function Bn({emitter:i,inboxService:e,notification:t}){return new U(t,i,e)}var Ar=(i,e)=>i===e?!0:!i||!e||i.length!==e.length?!1:i.every((t,r)=>t===e[r]);var Ph=["seen","unseen"],Lh=["read","unread"],Rr=(i,e)=>Ar(i,e)||!i&&(e==null?void 0:e.length)===0||(i==null?void 0:i.length)===0&&!e,_a=(i,e)=>{let t=Array.isArray(i)?i:i?[i]:[],r=Array.isArray(e)?e:e?[e]:[];return Ar(t,r)},Tr=(i,e)=>{if(!i&&!e)return!0;if(!i||!e)return!1;try{return JSON.stringify(i)===JSON.stringify(e)}catch(t){return!1}},Or=(i,e)=>Tr(i.data,e.data)&&Rr(i.tags,e.tags)&&i.read===e.read&&i.archived===e.archived&&i.snoozed===e.snoozed&&i.seen===e.seen&&_a(i.severity,e.severity);var ye,Ve=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 Mn=({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),{}),Lt=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})=>JSON.stringify(Mn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o,limit:c,offset:l,after:u})),Ea=({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})=>JSON.stringify(Mn({tags:i,data:e,read:t,archived:r,snoozed:n,seen:s,severity:o})),rt=i=>JSON.parse(i),Sa=["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"],ba=["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"],Oe,Ut,B,Ft=class{constructor({emitter:e,inboxService:t}){_(this,Oe);_(this,Ut);_(this,B);this.updateNotification=(e,t)=>{let r=a(this,B).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,B).set(e,A(E({},r),{notifications:s})),!0};this.removeNotification=(e,t)=>{let r=a(this,B).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,B).set(e,A(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,B).keys().forEach(l=>{let u=a(this,B).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,B).keys().forEach(c=>{s.forEach(l=>{let u=!1;e?u=this.removeNotification(c,l):u=this.updateNotification(c,l),u&&o.add(Ea(rt(c)))})}),o.forEach(c=>{let l=this.getAggregated(rt(c));a(this,Oe).emit("notifications.list.updated",{data:l})})};S(this,Oe,e),S(this,Ut,t),Sa.forEach(r=>{a(this,Oe).on(r,this.handleNotificationEvent())}),ba.forEach(r=>{a(this,Oe).on(r,this.handleNotificationEvent({remove:!0}))}),S(this,B,new Ve)}getAggregated(e){return a(this,B).keys().filter(r=>{let n=rt(r);return Or(n,e)}).map(r=>a(this,B).get(r)).reduce((r,n)=>n?{hasMore:n.hasMore,filter:n.filter,notifications:[...r.notifications,...n.notifications]}:r,{hasMore:!1,filter:{},notifications:[]})}get(e){return a(this,B).get(Lt(e))}has(e){return a(this,B).get(Lt(e))!==void 0}set(e,t){a(this,B).set(Lt(e),t)}unshift(e,t){let r=Lt(e),n=a(this,B).get(r)||{hasMore:!1,filter:rt(r),notifications:[]},s=Bn({notification:E({},t),emitter:a(this,Oe),inboxService:a(this,Ut)});this.update(e,A(E({},n),{notifications:[s,...n.notifications]}))}update(e,t){this.set(e,t);let r=this.getAggregated(rt(Lt(e)));a(this,Oe).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,B).keys(),s=new Map;return n.forEach(o=>{let c=rt(o);if(Rr(e,c.tags)&&Tr(r,c.data)){let l=a(this,B).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,B).keys().forEach(r=>{Or(rt(r),e)&&a(this,B).remove(r)})}clearAll(){a(this,B).clear()}};Oe=new WeakMap,Ut=new WeakMap,B=new WeakMap;var Dt,Oi=class extends de{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Dt);this.cache=new Ft({emitter:n,inboxService:r}),S(this,Dt,t)}list(){return m(this,arguments,function*(n={}){var s=n,{limit:t=10}=s,r=Cr(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,Dt),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 xi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return wi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ci({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ni({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return ki({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ti({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ai({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return Ri({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(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"})}))})}completeSecondary(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"})}))})}revertPrimary(t){return m(this,null,function*(){return this.callWithSession(()=>m(this,null,function*(){return yt({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 yt({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 Ln({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?kr({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):kr({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 Fn({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 Un({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 Dn({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()})}};Dt=new WeakMap;var Bt,Mt,qt,Wt,Ie=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,useCache:s}){_(this,Bt);_(this,Mt);_(this,qt);_(this,Wt);S(this,Bt,t),S(this,Mt,r),S(this,qt,n),S(this,Wt,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 Ii({emitter:a(this,Bt),apiService:a(this,Mt),cache:a(this,qt),useCache:a(this,Wt),args:E({isEnabled:(r=e.isEnabled)!=null?r:this.isEnabled},t&&{weeklySchedule:E(E({},this.weeklySchedule),e.weeklySchedule)})})})}};Bt=new WeakMap,Mt=new WeakMap,qt=new WeakMap,Wt=new WeakMap;var zt,$t,Vt,Ht,jt,Ce=class{constructor(e,{emitterInstance:t,inboxServiceInstance:r,cache:n,scheduleCache:s,useCache:o}){_(this,zt);_(this,$t);_(this,Vt);_(this,Ht);_(this,jt);S(this,zt,t),S(this,$t,r),S(this,Vt,n),S(this,Ht,s),S(this,jt,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Ie(E({},e.schedule),{emitterInstance:t,inboxServiceInstance:r,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var r;return Pi({emitter:a(this,zt),apiService:a(this,$t),cache:a(this,Vt),scheduleCache:a(this,Ht),useCache:a(this,jt),args:{workflowId:(r=this.workflow)==null?void 0:r.id,channels:e||t,preference:this}})}};zt=new WeakMap,$t=new WeakMap,Vt=new WeakMap,Ht=new WeakMap,jt=new WeakMap;var Pi=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(A(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}):(xa({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)}}}),qn=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(A(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,x,g,v;return E({workflowId:"workflowId"in d?d.workflowId:(v=(g=(p=d.preference.workflow)==null?void 0:p.id)!=null?g:(x=d.preference.workflow)==null?void 0:x.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)}}}),xa=({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=A(E({},c),{channels:Object.entries(c.channels).reduce((d,[p,x])=>{var v;let g=p;return d[g]=(v=s.channels[g])!=null?v:x,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})}})},Ii=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 Ie({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 Ie({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,Li=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 Ie({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(()=>Ii({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,He),args:t}))})}};He=new WeakMap;var wa=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],Ca=["preference.schedule.update.pending","preference.schedule.update.resolved"],Na=({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),{}),Ir=({tags:i,severity:e})=>JSON.stringify(Na({tags:i,severity:e})),je,H,Fi=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 wa)a(this,je).on(t,this.handlePreferenceEvent);for(let t of Ca)a(this,je).on(t,this.handleScheduleEvent);S(this,H,new Ve)}has(e){return a(this,H).get(Ir(e))!==void 0}set(e,t){a(this,H).set(Ir(e),t)}getAll(e){if(this.has(e))return a(this,H).get(Ir(e))}clearAll(){a(this,H).clear()}};je=new WeakMap,H=new WeakMap;var ka=["preference.schedule.update.pending","preference.schedule.update.resolved"],Pr=()=>"schedule",_t,se,Ui=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 ka)a(this,_t).on(t,this.handleScheduleEvent);S(this,se,new Ve)}has(){return a(this,se).get(Pr())!==void 0}set(e){a(this,se).set(Pr(),e)}getAll(){if(this.has())return a(this,se).get(Pr())}clearAll(){a(this,se).clear()}};_t=new WeakMap,se=new WeakMap;var Pe,Di=class extends de{constructor({useCache:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Pe);this.cache=new Fi({emitterInstance:this._emitter}),this.scheduleCache=new Ui({emitterInstance:this._emitter}),S(this,Pe,t),this.schedule=new Li({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,Pe)?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,Pe)})),a(this,Pe)&&(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(()=>Pi({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Pe),args:t}))})}bulkUpdate(t){return m(this,null,function*(){return this.callWithSession(()=>qn({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,Pe),args:t}))})}};Pe=new WeakMap;function Wn(){return typeof window!="undefined"}var nt,Gt,Y,Bi=class{constructor(e,t,r){_(this,nt);_(this,Gt);_(this,Y);S(this,nt,r),S(this,Gt,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:x,context:g}=a(this,Y),v;Wn()&&(v=Intl.DateTimeFormat().resolvedOptions().timeZone);let T=p;if(T)this.handleApplicationIdentifier("delete");else{let y=this.handleApplicationIdentifier("get");y&&(T=y)}a(this,nt).emit("session.initialize.pending",{args:a(this,Y)});let w=yield a(this,Gt).initializeSession({applicationIdentifier:T,subscriberHash:f,contextHash:d,subscriber:A(E({},h),{subscriberId:(o=h==null?void 0:h.subscriberId)!=null?o:"",timezone:(c=h==null?void 0:h.timezone)!=null?c:v}),defaultSchedule:x,context:g});(l=w==null?void 0:w.applicationIdentifier)!=null&&l.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",w.applicationIdentifier),(u=w==null?void 0:w.applicationIdentifier)!=null&&u.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,nt).emit("session.initialize.resolved",{args:a(this,Y),data:w})}catch(h){a(this,nt).emit("session.initialize.resolved",{args:a(this,Y),error:h})}})}};nt=new WeakMap,Gt=new WeakMap,Y=new WeakMap;function zn(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 $n({subscriberId:i,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:i?{subscriberId:i}:{subscriberId:""}}var Mi=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,Aa=function(){try{new Mi.Event("")}catch(i){return!0}return!1}(),Ra=function(){try{new Mi.EventTarget}catch(i){return!0}return!1}();Aa&&(Mi.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}());Ra&&(Mi.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
|
|
24
|
+
`);var jn=class extends Event{constructor(e,t){super("error",t);I(this,"message");I(this,"error");this.message=e.message,this.error=e}},Gn=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}},Lr={Event,ErrorEvent:jn,CloseEvent:Gn};function Ta(i,e){if(!i)throw new Error(e)}function Oa(i){return new i.constructor(i.type,i)}function Ia(i){return"data"in i?new MessageEvent(i.type,i):"code"in i||"reason"in i?new Gn(i.code||1999,i.reason||"unknown reason",i):"error"in i?new jn(i.error,i):new Event(i.type,i)}var Vn,Pa=typeof process!="undefined"&&typeof((Vn=process.versions)==null?void 0:Vn.node)!="undefined"&&typeof document=="undefined",qi=Pa?Ia:Oa,st={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},Hn=!1,Wi=class ot 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=st.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),r),Ta(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(qi(t))});I(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(qi(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(qi(t)),this._connect()});I(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(qi(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 ot.CONNECTING}get OPEN(){return ot.OPEN}get CLOSING(){return ot.CLOSING}get CLOSED(){return ot.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?ot.CLOSED:ot.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=st.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=st.reconnectionDelayGrowFactor,minReconnectionDelay:r=st.minReconnectionDelay,maxReconnectionDelay:n=st.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=r*In(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=st.maxRetries,connectionTimeout:r=st.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"&&!Hn&&(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
|
+
`),Hn=!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 Lr.ErrorEvent(Error(n.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Lr.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 Lr.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 Kt="wss://socket.novu.co",Kn="notifications.notification_received",Yn="notifications.unseen_count_changed",Jn="notifications.unread_count_changed",La=({_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:x,avatar:g,cta:v,tags:T,data:w,workflow:y,severity:b})=>{var Ze,et,ie,Me,qe,We,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=(Me=(ie=v.action)==null?void 0:ie.buttons)==null?void 0:Me.find(Te=>Te.type==="secondary"),q=(We=(qe=v.action)==null?void 0:qe.result)==null?void 0:We.type,ne=(me=v.action)==null?void 0:me.status;return A(E(E({id:i,transactionId:e,subject:x,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:T,redirect:(ge=v.data)!=null&&ge.url?{url:v.data.url,target:v.data.target}:void 0,data:w,workflow:y,severity:b})},Et,ve,_e,St,$i,Vi,Hi,ji,Ne,Xn,Fr,Ur,zi=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,$i,t=>{try{let r=JSON.parse(t.data);r.event==="notification_received"&&a(this,ve).emit(Kn,{result:new U(La(r.data.message),a(this,ve),this._inboxService)})}catch(r){console.log("error",r)}});_(this,Vi,t=>{try{let r=JSON.parse(t.data);r.event==="unseen_count_changed"&&a(this,ve).emit(Yn,{result:r.data.unseenCount})}catch(r){}});_(this,Hi,t=>{try{let r=JSON.parse(t.data);r.event==="unread_count_changed"&&a(this,ve).emit(Jn,{result:r.data.counts})}catch(r){}});_(this,ji,t=>{try{switch(JSON.parse(t.data).event){case"notification_received":a(this,$i).call(this,t);break;case"unseen_count_changed":a(this,Vi).call(this,t);break;case"unread_count_changed":a(this,Hi).call(this,t);break;default:}}catch(r){}});S(this,ve,n),S(this,St,t!=null?t:Kt)}onSessionSuccess({token:t}){S(this,Et,t)}isSocketEvent(t){return t===Kn||t===Yn||t===Jn}connect(){return m(this,null,function*(){return a(this,Et)?ue(this,Ne,Fr).call(this):this.callWithSession(ue(this,Ne,Fr).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,_e)?ue(this,Ne,Ur).call(this):this.callWithSession(ue(this,Ne,Ur).bind(this))})}};Et=new WeakMap,ve=new WeakMap,_e=new WeakMap,St=new WeakMap,$i=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,ji=new WeakMap,Ne=new WeakSet,Xn=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 Wi(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,ji))})},Fr=function(){return m(this,null,function*(){try{return yield ue(this,Ne,Xn).call(this),{}}catch(t){return{error:new k("Failed to initialize the PartySocket",t)}}})},Ur=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 Yt=Object.create(null);Object.keys(Ee).forEach(i=>{Yt[Ee[i]]=i});var Jt={type:"error",data:"parser error"};var Xt=({type:i,data:e},t,r)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?r(t?e:"b"+Qn(e,!0).toString("base64")):r(Ee[i]+(e||"")),Qn=(i,e)=>Buffer.isBuffer(i)||i instanceof Uint8Array&&!e?i:i instanceof ArrayBuffer?Buffer.from(i):Buffer.from(i.buffer,i.byteOffset,i.byteLength),Dr;function Zn(i,e){if(i.data instanceof ArrayBuffer||ArrayBuffer.isView(i.data))return e(Qn(i.data,!1));Xt(i,!0,t=>{Dr||(Dr=new TextEncoder),e(Dr.encode(t))})}var Qt=(i,e)=>{if(typeof i!="string")return{type:"message",data:es(i,e)};let t=i.charAt(0);if(t==="b"){let r=Buffer.from(i.substring(1),"base64");return{type:"message",data:es(r,e)}}return Yt[t]?i.length>1?{type:Yt[t],data:i.substring(1)}:{type:Yt[t]}:Jt},es=(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="",is=(i,e)=>{let t=i.length,r=new Array(t),n=0;i.forEach((s,o)=>{Xt(s,!1,c=>{r[o]=c,++n===t&&e(r.join(ts))})})},rs=(i,e)=>{let t=i.split(ts),r=[];for(let n=0;n<t.length;n++){let s=Qt(t[n],e);if(r.push(s),s.type==="error")break}return r};function ns(){return new TransformStream({transform(i,e){Zn(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 Br;function Gi(i){return i.reduce((e,t)=>e+t.length,0)}function Ki(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 ss(i,e){Br||(Br=new TextDecoder);let t=[],r=0,n=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(r===0){if(Gi(t)<1)break;let l=Ki(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(Gi(t)<2)break;let l=Ki(t,2);n=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Gi(t)<8)break;let l=Ki(t,8),u=new DataView(l.buffer,l.byteOffset,l.length),h=u.getUint32(0);if(h>Math.pow(2,21)-1){c.enqueue(Jt);break}n=h*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Gi(t)<n)break;let l=Ki(t,n);c.enqueue(Qt(s?l:Br.decode(l),e)),r=0}if(n===0||n>i){c.enqueue(Jt);break}}}})}var Mr=4;function L(i){if(i)return Fa(i)}function Fa(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 Yi(i,...e){return e.reduce((t,r)=>(i.hasOwnProperty(r)&&(t[r]=i[r]),t),{})}var Ua=Se.setTimeout,Da=Se.clearTimeout;function Le(i,e){e.useNativeTimers?(i.setTimeoutFn=Ua.bind(Se),i.clearTimeoutFn=Da.bind(Se)):(i.setTimeoutFn=Se.setTimeout.bind(Se),i.clearTimeoutFn=Se.clearTimeout.bind(Se))}var Ba=1.33;function os(i){return typeof i=="string"?Ma(i):Math.ceil((i.byteLength||i.size)*Ba)}function Ma(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 vs=Q(ct(),1);function gs(i){let e="";for(let t in i)i.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(i[t]));return e}function ys(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 cc=(0,vs.default)("engine.io-client:transport"),jr=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Fe=class extends L{constructor(e){super(),this.writable=!1,Le(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new jr(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):cc("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Qt(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=gs(e);return t.length?"?"+t:""}};var As=Q(ct(),1);var bs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Gr=64,lc={},_s=0,er=0,Es;function Ss(i){let e="";do e=bs[i%Gr]+e,i=Math.floor(i/Gr);while(i>0);return e}function tr(){let i=Ss(+new Date);return i!==Es?(_s=0,Es=i):i+"."+Ss(_s++)}for(;er<Gr;er++)lc[bs[er]]=er;var Jr=Q(Cs(),1),Xr=Jr.default||Jr;function Ns(){return new Yr}function fc(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 Yr=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(r=>{let n=fc(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,As.default)("engine.io-client:polling");function uc(){}var dc=function(){return new Xr({xdomain:!1}).responseType!=null}(),ir=class extends Fe{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=dc&&!t,this.opts.withCredentials&&(this.cookieJar=Ns())}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)};rs(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,is(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=tr()),!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(),Le(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=Yi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let r=this.xhr=new Xr(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=uc,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",ks);else if(typeof addEventListener=="function"){let i="onpagehide"in Se?"pagehide":"unload";addEventListener(i,ks,!1)}}function ks(){for(let i in Ke.requests)Ke.requests.hasOwnProperty(i)&&Ke.requests[i].abort()}var xl=Q(Is(),1),wl=Q(an(),1),Cl=Q(ln(),1),Oo=Q(gn(),1),Nl=Q(To(),1);var Io=Oo.default;var hi=Io,ur=!1,Po="nodebuffer",ut=process.nextTick;var Fo=Q(ct(),1);var kl=(0,Fo.default)("engine.io-client:websocket"),Lo=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",dr=class extends Fe{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=Lo?{}:Yi(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&&!Lo?t?new hi(e,t):new hi(e):new hi(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;Xt(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){kl("websocket closed before onclose event")}n&&ut(()=>{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]=tr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!hi}};var Uo=Q(ct(),1),fi=(0,Uo.default)("engine.io-client:webtransport"),pr=class extends Fe{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{fi("transport closed gracefully"),this.onClose()}).catch(e=>{fi("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=ss(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=ns();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();let s=()=>{r.read().then(({done:c,value:l})=>{if(c){fi("session is closed");return}fi("received chunk: %o",l),this.onPacket(l),s()}).catch(c=>{fi("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&&ut(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var vn={websocket:dr,webtransport:pr,polling:ir};var Al=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Rl=["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=Al.exec(i||""),s={},o=14;for(;o--;)s[Rl[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=Tl(s,s.path),s.queryKey=Ol(s,s.query),s}function Tl(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 Ol(i,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,n,s){n&&(t[n]=s)}),t}var Do=Q(ct(),1);var D=(0,Do.default)("engine.io-client:socket"),dt=class i extends L{constructor(e,t={}){super(),this.binaryType=Po,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),Le(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=ys(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=Mr,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 vn[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+=os(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}};dt.protocol=Mr;var Id=dt.protocol;var $o=Q(ui(),1),zo=(0,$o.default)("socket.io-client:url");function Vo(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)||(zo("protocol-less url %s",i),typeof t!="undefined"?i=t.protocol+"//"+i:i="https://"+i),zo("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 kn={};pa(kn,{Decoder:()=>Cn,Encoder:()=>wn,PacketType:()=>C,protocol:()=>Jo});var Gl=typeof ArrayBuffer=="function",Kl=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Ho=Object.prototype.toString,Yl=typeof Blob=="function"||typeof Blob!="undefined"&&Ho.call(Blob)==="[object BlobConstructor]",Jl=typeof File=="function"||typeof File!="undefined"&&Ho.call(File)==="[object FileConstructor]";function pi(i){return Gl&&(i instanceof ArrayBuffer||Kl(i))||Yl&&i instanceof Blob||Jl&&i instanceof File}function di(i,e){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let t=0,r=i.length;t<r;t++)if(di(i[t]))return!0;return!1}if(pi(i))return!0;if(i.toJSON&&typeof i.toJSON=="function"&&arguments.length===1)return di(i.toJSON(),!0);for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)&&di(i[t]))return!0;return!1}function jo(i){let e=[],t=i.data,r=i;return r.data=Sn(t,e),r.attachments=e.length,{packet:r,buffers:e}}function Sn(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]=Sn(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]=Sn(i[r],e));return t}return i}function Go(i,e){return i.data=bn(i.data,e),delete i.attachments,i}function bn(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]=bn(i[t],e);else if(typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(i[t]=bn(i[t],e));return i}var Yo=Q(ct(),1),xn=(0,Yo.default)("socket.io-parser"),Xl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Jo=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 xn("encoding packet %j",e),(e.type===C.EVENT||e.type===C.ACK)&&di(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)),xn("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=jo(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function Ko(i){return Object.prototype.toString.call(i)==="[object Object]"}var Cn=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 Nn(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(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 xn("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 Ko(t);case C.DISCONNECT:return t===void 0;case C.CONNECT_ERROR:return typeof t=="string"||Ko(t);case C.EVENT:case C.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Xl.indexOf(t[0])===-1);case C.ACK:case C.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Nn=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=Go(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 Xo=Q(ui(),1),z=(0,Xo.default)("socket.io-client:socket"),Ql=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(Ql.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 pt(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}pt.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};pt.prototype.reset=function(){this.attempts=0};pt.prototype.setMin=function(i){this.ms=i};pt.prototype.setMax=function(i){this.max=i};pt.prototype.setJitter=function(i){this.jitter=i};var Qo=Q(ui(),1),J=(0,Qo.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,Le(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 pt({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||kn;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 dt(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){ut(()=>{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 ea=Q(ui(),1),Zo=(0,ea.default)("socket.io-client"),mi={};function gi(i,e){typeof i=="object"&&(e=i,i=void 0),e=e||{};let t=Vo(i,e.path||"/socket.io"),r=t.source,n=t.id,s=t.path,o=mi[n]&&s in mi[n].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,l;return c?(Zo("ignoring socket cache for %s",r),l=new Ot(r,e)):(mi[n]||(Zo("new io instance for %s",r),mi[n]=new Ot(r,e)),l=mi[n]),t.query&&!e.query&&(e.query=t.queryKey),l.socket(t.path,e)}Object.assign(gi,{Manager:Ot,Socket:Tt,io:gi,connect:gi});var Zl="https://ws.novu.co",ta="notifications.notification_received",ia="notifications.unseen_count_changed",ra="notifications.unread_count_changed",eh=({_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:x,avatar:g,cta:v,tags:T,data:w,workflow:y,severity:b})=>{var Ze,et,ie,Me,qe,We,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=(Me=(ie=v.action)==null?void 0:ie.buttons)==null?void 0:Me.find(Te=>Te.type==="secondary"),q=(We=(qe=v.action)==null?void 0:qe.result)==null?void 0:We.type,ne=(me=v.action)==null?void 0:me.status;return A(E(E({id:i,transactionId:e,subject:x,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:T,redirect:(ge=v.data)!=null&&ge.url?{url:v.data.url,target:v.data.target}:void 0,data:w,workflow:y,severity:b})},It,xe,he,Pt,_r,Er,Sr,Ae,na,An,Rn,vr=class extends de{constructor({socketUrl:t,inboxServiceInstance:r,eventEmitterInstance:n}){super({eventEmitterInstance:n,inboxServiceInstance:r});_(this,Ae);_(this,It);_(this,xe);_(this,he);_(this,Pt);_(this,_r,({message:t})=>{a(this,xe).emit(ta,{result:new U(eh(t),a(this,xe),this._inboxService)})});_(this,Er,({unseenCount:t})=>{a(this,xe).emit(ia,{result:t})});_(this,Sr,({counts:t})=>{a(this,xe).emit(ra,{result:t})});S(this,xe,n),S(this,Pt,t!=null?t:Zl)}onSessionSuccess({token:t}){S(this,It,t)}isSocketEvent(t){return t===ta||t===ia||t===ra}connect(){return m(this,null,function*(){return a(this,It)?ue(this,Ae,An).call(this):this.callWithSession(ue(this,Ae,An).bind(this))})}disconnect(){return m(this,null,function*(){return a(this,he)?ue(this,Ae,Rn).call(this):this.callWithSession(ue(this,Ae,Rn).bind(this))})}};It=new WeakMap,xe=new WeakMap,he=new WeakMap,Pt=new WeakMap,_r=new WeakMap,Er=new WeakMap,Sr=new WeakMap,Ae=new WeakSet,na=function(){return m(this,null,function*(){var r,n,s;if(a(this,he))return;let t={socketUrl:a(this,Pt)};a(this,xe).emit("socket.connect.pending",{args:t}),S(this,he,gi(a(this,Pt),{reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,It)}`}})),a(this,he).on("connect",()=>{a(this,xe).emit("socket.connect.resolved",{args:t})}),a(this,he).on("connect_error",o=>{a(this,xe).emit("socket.connect.resolved",{args:t,error:o})}),(r=a(this,he))==null||r.on("notification_received",a(this,_r)),(n=a(this,he))==null||n.on("unseen_count_changed",a(this,Er)),(s=a(this,he))==null||s.on("unread_count_changed",a(this,Sr))})},An=function(){return m(this,null,function*(){try{return yield ue(this,Ae,na).call(this),{}}catch(t){return{error:new k("Failed to initialize the socket",t)}}})},Rn=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 th=["wss://eu.socket.novu.co",Kt,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],ih={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":Kt,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"};function rh(i){return i?ih[i]||i:Kt}function nh(i){return!i||th.includes(i)}function sa({socketUrl:i,inboxServiceInstance:e,eventEmitterInstance:t}){let r=rh(i);switch(nh(r)?"partysocket":"socket.io"){case"partysocket":return new zi({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t});case"socket.io":default:return new vr({socketUrl:r,inboxServiceInstance:e,eventEmitterInstance:t})}}var Re,X,Qe,br=class{constructor(e){_(this,Re);_(this,X);_(this,Qe);var t,r;S(this,Qe,new Si({apiUrl:e.apiUrl||e.backendUrl,userAgent:e.__userAgent})),S(this,Re,new bi),S(this,X,new Bi({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:$n({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 Oi({useCache:(t=e.useCache)!=null?t:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Re)}),this.preferences=new Di({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Qe),eventEmitterInstance:a(this,Re)}),this.socket=sa({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 zn(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=br;})();
|
|
38
38
|
/*! Bundled license information:
|
|
39
39
|
|
|
40
40
|
xmlhttprequest-ssl/lib/XMLHttpRequest.js:
|