@novu/js 3.17.0 → 3.18.0
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-7B52C2XE.js → chunk-A6CBLMST.js} +9 -0
- package/dist/cjs/{chunk-SP44ETLM.js → chunk-NR4RSYUE.js} +772 -694
- package/dist/cjs/{chunk-WDGG3OER.js → chunk-TLQQB5Y7.js} +217 -199
- package/dist/{esm/inbox-service-CGCuuYnv.d.mts → cjs/inbox-service-DSSwFYNG.d.ts} +18 -2
- package/dist/cjs/index.d.ts +93 -4
- package/dist/cjs/index.js +246 -20
- package/dist/cjs/internal/index.d.ts +1 -1
- package/dist/cjs/internal/index.js +7 -7
- package/dist/cjs/{novu-CmNBco-0.d.ts → novu-BQCC3vQS.d.ts} +3 -2
- package/dist/cjs/themes/index.d.ts +3 -3
- package/dist/cjs/themes/index.js +1 -1
- package/dist/cjs/{types-BF6zvyj6.d.ts → types-Djf8MaW9.d.ts} +2 -2
- package/dist/cjs/ui/index.d.ts +18 -6
- package/dist/cjs/ui/index.js +609 -243
- package/dist/esm/{chunk-BKA3HRZM.mjs → chunk-33B2GJE2.mjs} +140 -64
- package/dist/esm/{chunk-STZMOEWR.mjs → chunk-3LR3AF54.mjs} +9 -1
- package/dist/esm/{chunk-4S22IB5W.mjs → chunk-T3NTOGY3.mjs} +193 -176
- package/dist/{cjs/inbox-service-CGCuuYnv.d.ts → esm/inbox-service-DSSwFYNG.d.mts} +18 -2
- package/dist/esm/index.d.mts +93 -4
- package/dist/esm/index.mjs +228 -3
- package/dist/esm/internal/index.d.mts +1 -1
- package/dist/esm/internal/index.mjs +2 -2
- package/dist/esm/{novu-CFYEiYN8.d.mts → novu-Z0z0-IxO.d.mts} +3 -2
- package/dist/esm/themes/index.d.mts +3 -3
- package/dist/esm/themes/index.mjs +1 -1
- package/dist/esm/{types-CJKmgwu6.d.mts → types-BJ345m1Q.d.mts} +2 -2
- package/dist/esm/ui/index.d.mts +18 -6
- package/dist/esm/ui/index.mjs +424 -58
- package/dist/novu.min.js +15 -15
- package/dist/novu.min.js.gz +0 -0
- package/package.json +7 -2
package/dist/novu.min.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";(()=>{var Hc=Object.create;var li=Object.defineProperty,Yc=Object.defineProperties,Jc=Object.getOwnPropertyDescriptor,Xc=Object.getOwnPropertyDescriptors,Qc=Object.getOwnPropertyNames,ci=Object.getOwnPropertySymbols,Zc=Object.getPrototypeOf,Or=Object.prototype.hasOwnProperty,Ds=Object.prototype.propertyIsEnumerable;var Bs=n=>{throw TypeError(n)},Ms=Math.pow,Rr=(n,e,t)=>e in n?li(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))Or.call(e,t)&&Rr(n,t,e[t]);if(ci)for(var t of ci(e))Ds.call(e,t)&&Rr(n,t,e[t]);return n},x=(n,e)=>Yc(n,Xc(e));var T=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var un=(n,e)=>{var t={};for(var i in n)Or.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&ci)for(var i of ci(n))e.indexOf(i)<0&&Ds.call(n,i)&&(t[i]=n[i]);return t};var I=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),el=(n,e)=>{for(var t in e)li(n,t,{get:e[t],enumerable:!0})},tl=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Qc(e))!Or.call(n,r)&&r!==t&&li(n,r,{get:()=>e[r],enumerable:!(i=Jc(e,r))||i.enumerable});return n};var G=(n,e,t)=>(t=n!=null?Hc(Zc(n)):{},tl(e||!n||!n.__esModule?li(t,"default",{value:n,enumerable:!0}):t,n));var F=(n,e,t)=>Rr(n,typeof e!="symbol"?e+"":e,t),Tr=(n,e,t)=>e.has(n)||Bs("Cannot "+t);var a=(n,e,t)=>(Tr(n,e,"read from private field"),t?t.call(n):e.get(n)),v=(n,e,t)=>e.has(n)?Bs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),b=(n,e,t,i)=>(Tr(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),ae=(n,e,t)=>(Tr(n,e,"access private method"),t);var p=(n,e,t)=>new Promise((i,r)=>{var s=u=>{try{c(t.next(u))}catch(h){r(h)}},o=u=>{try{c(t.throw(u))}catch(h){r(h)}},c=u=>u.done?i(u.value):Promise.resolve(u.value).then(s,o);c((t=t.apply(n,e)).next())});var Gr=I((Dm,Bo)=>{"use strict";var $t=1e3,Kt=$t*60,zt=Kt*60,wt=zt*24,Il=wt*7,Pl=wt*365.25;Bo.exports=function(n,e){e=e||{};var t=typeof n;if(t==="string"&&n.length>0)return Fl(n);if(t==="number"&&isFinite(n))return e.long?Ul(n):Ll(n);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(n))};function Fl(n){if(n=String(n),!(n.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(n);if(e){var t=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return t*Pl;case"weeks":case"week":case"w":return t*Il;case"days":case"day":case"d":return t*wt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*zt;case"minutes":case"minute":case"mins":case"min":case"m":return t*Kt;case"seconds":case"second":case"secs":case"sec":case"s":return t*$t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Ll(n){var e=Math.abs(n);return e>=wt?Math.round(n/wt)+"d":e>=zt?Math.round(n/zt)+"h":e>=Kt?Math.round(n/Kt)+"m":e>=$t?Math.round(n/$t)+"s":n+"ms"}function Ul(n){var e=Math.abs(n);return e>=wt?Gi(n,e,wt,"day"):e>=zt?Gi(n,e,zt,"hour"):e>=Kt?Gi(n,e,Kt,"minute"):e>=$t?Gi(n,e,$t,"second"):n+" ms"}function Gi(n,e,t,i){var r=e>=t*1.5;return Math.round(n/t)+" "+i+(r?"s":"")}});var jr=I((Bm,Mo)=>{"use strict";function Dl(n){t.debug=t,t.default=t,t.coerce=u,t.disable=s,t.enable=r,t.enabled=o,t.humanize=Gr(),t.destroy=h,Object.keys(n).forEach(l=>{t[l]=n[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,d,w;function g(...S){if(!g.enabled)return;let R=g,N=Number(new Date),_=N-(f||N);R.diff=_,R.prev=f,R.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let C=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(O,P)=>{if(O==="%%")return"%";C++;let $=t.formatters[P];if(typeof $=="function"){let te=S[C];O=$.call(R,te),S.splice(C,1),C--}return O}),t.formatArgs.call(R,S),(R.log||t.log).apply(R,S)}return g.namespace=l,g.useColors=t.useColors(),g.color=t.selectColor(l),g.extend=i,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(d!==t.namespaces&&(d=t.namespaces,w=t.enabled(l)),w),set:S=>{m=S}}),typeof t.init=="function"&&t.init(g),g}function i(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,m=(typeof l=="string"?l:"").split(/[\s,]+/),d=m.length;for(f=0;f<d;f++)m[f]&&(l=m[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(l))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Mo.exports=Dl});var qo=I((me,ji)=>{"use strict";me.formatArgs=Ml;me.save=ql;me.load=Wl;me.useColors=Bl;me.storage=$l();me.destroy=(()=>{let n=!1;return()=>{n||(n=!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`."))}})();me.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 Bl(){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 n;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&&(n=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(n[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Ml(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+ji.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;n.splice(1,0,e,"color: inherit");let t=0,i=0;n[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(i=t))}),n.splice(i,0,e)}me.log=console.debug||console.log||(()=>{});function ql(n){try{n?me.storage.setItem("debug",n):me.storage.removeItem("debug")}catch(e){}}function Wl(){let n;try{n=me.storage.getItem("debug")}catch(e){}return!n&&typeof process!="undefined"&&"env"in process&&(n=process.env.DEBUG),n}function $l(){try{return localStorage}catch(n){}}ji.exports=jr()(me);var{formatters:Kl}=ji.exports;Kl.j=function(n){try{return JSON.stringify(n)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var $o=I((Mm,Wo)=>{"use strict";Wo.exports=(n,e=process.argv)=>{let t=n.startsWith("-")?"":n.length===1?"-":"--",i=e.indexOf(t+n),r=e.indexOf("--");return i!==-1&&(r===-1||i<r)}});var Vi=I((qm,zo)=>{"use strict";var zl=T("os"),Ko=T("tty"),Ce=$o(),{env:J}=process,ft;Ce("no-color")||Ce("no-colors")||Ce("color=false")||Ce("color=never")?ft=0:(Ce("color")||Ce("colors")||Ce("color=true")||Ce("color=always"))&&(ft=1);"FORCE_COLOR"in J&&(J.FORCE_COLOR==="true"?ft=1:J.FORCE_COLOR==="false"?ft=0:ft=J.FORCE_COLOR.length===0?1:Math.min(parseInt(J.FORCE_COLOR,10),3));function Vr(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}function Hr(n,e){if(ft===0)return 0;if(Ce("color=16m")||Ce("color=full")||Ce("color=truecolor"))return 3;if(Ce("color=256"))return 2;if(n&&!e&&ft===void 0)return 0;let t=ft||0;if(J.TERM==="dumb")return t;if(process.platform==="win32"){let i=zl.release().split(".");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if("CI"in J)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(i=>i 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 i=parseInt((J.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(J.TERM_PROGRAM){case"iTerm.app":return i>=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 Gl(n){let e=Hr(n,n&&n.isTTY);return Vr(e)}zo.exports={supportsColor:Gl,stdout:Vr(Hr(!0,Ko.isatty(1))),stderr:Vr(Hr(!0,Ko.isatty(2)))}});var jo=I((X,Yi)=>{"use strict";var jl=T("tty"),Hi=T("util");X.init=Zl;X.log=Jl;X.formatArgs=Hl;X.save=Xl;X.load=Ql;X.useColors=Vl;X.destroy=Hi.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");X.colors=[6,2,3,4,5,1];try{let n=Vi();n&&(n.stderr||n).level>=2&&(X.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(n){}X.inspectOpts=Object.keys(process.env).filter(n=>/^debug_/i.test(n)).reduce((n,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,s)=>s.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),n[t]=i,n},{});function Vl(){return"colors"in X.inspectOpts?!!X.inspectOpts.colors:jl.isatty(process.stderr.fd)}function Hl(n){let{namespace:e,useColors:t}=this;if(t){let i=this.color,r="\x1B[3"+(i<8?i:"8;5;"+i),s=` ${r};1m${e} \x1B[0m`;n[0]=s+n[0].split(`
|
|
1
|
+
"use strict";(()=>{var tl=Object.create;var di=Object.defineProperty,nl=Object.defineProperties,il=Object.getOwnPropertyDescriptor,rl=Object.getOwnPropertyDescriptors,sl=Object.getOwnPropertyNames,fi=Object.getOwnPropertySymbols,ol=Object.getPrototypeOf,Fr=Object.prototype.hasOwnProperty,Ws=Object.prototype.propertyIsEnumerable;var $s=n=>{throw TypeError(n)},Ks=Math.pow,Pr=(n,e,t)=>e in n?di(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))Fr.call(e,t)&&Pr(n,t,e[t]);if(fi)for(var t of fi(e))Ws.call(e,t)&&Pr(n,t,e[t]);return n},x=(n,e)=>nl(n,rl(e));var T=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var pn=(n,e)=>{var t={};for(var i in n)Fr.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&fi)for(var i of fi(n))e.indexOf(i)<0&&Ws.call(n,i)&&(t[i]=n[i]);return t};var I=(n,e)=>()=>{try{return e||n((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},al=(n,e)=>{for(var t in e)di(n,t,{get:e[t],enumerable:!0})},cl=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of sl(e))!Fr.call(n,r)&&r!==t&&di(n,r,{get:()=>e[r],enumerable:!(i=il(e,r))||i.enumerable});return n};var G=(n,e,t)=>(t=n!=null?tl(ol(n)):{},cl(e||!n||!n.__esModule?di(t,"default",{value:n,enumerable:!0}):t,n));var P=(n,e,t)=>Pr(n,typeof e!="symbol"?e+"":e,t),Lr=(n,e,t)=>e.has(n)||$s("Cannot "+t);var a=(n,e,t)=>(Lr(n,e,"read from private field"),t?t.call(n):e.get(n)),v=(n,e,t)=>e.has(n)?$s("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),b=(n,e,t,i)=>(Lr(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),ae=(n,e,t)=>(Lr(n,e,"access private method"),t);var d=(n,e,t)=>new Promise((i,r)=>{var s=u=>{try{c(t.next(u))}catch(h){r(h)}},o=u=>{try{c(t.throw(u))}catch(h){r(h)}},c=u=>u.done?i(u.value):Promise.resolve(u.value).then(s,o);c((t=t.apply(n,e)).next())});var Yr=I((Hm,Vo)=>{"use strict";var Vt=1e3,jt=Vt*60,Ht=jt*60,Nt=Ht*24,$l=Nt*7,Kl=Nt*365.25;Vo.exports=function(n,e){e=e||{};var t=typeof n;if(t==="string"&&n.length>0)return zl(n);if(t==="number"&&isFinite(n))return e.long?Vl(n):Gl(n);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(n))};function zl(n){if(n=String(n),!(n.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(n);if(e){var t=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return t*Kl;case"weeks":case"week":case"w":return t*$l;case"days":case"day":case"d":return t*Nt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Ht;case"minutes":case"minute":case"mins":case"min":case"m":return t*jt;case"seconds":case"second":case"secs":case"sec":case"s":return t*Vt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Gl(n){var e=Math.abs(n);return e>=Nt?Math.round(n/Nt)+"d":e>=Ht?Math.round(n/Ht)+"h":e>=jt?Math.round(n/jt)+"m":e>=Vt?Math.round(n/Vt)+"s":n+"ms"}function Vl(n){var e=Math.abs(n);return e>=Nt?Yi(n,e,Nt,"day"):e>=Ht?Yi(n,e,Ht,"hour"):e>=jt?Yi(n,e,jt,"minute"):e>=Vt?Yi(n,e,Vt,"second"):n+" ms"}function Yi(n,e,t,i){var r=e>=t*1.5;return Math.round(n/t)+" "+i+(r?"s":"")}});var Jr=I((Ym,jo)=>{"use strict";function jl(n){t.debug=t,t.default=t,t.coerce=u,t.disable=s,t.enable=r,t.enabled=o,t.humanize=Yr(),t.destroy=h,Object.keys(n).forEach(l=>{t[l]=n[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,p,w;function g(...S){if(!g.enabled)return;let R=g,N=Number(new Date),_=N-(f||N);R.diff=_,R.prev=f,R.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let C=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(O,F)=>{if(O==="%%")return"%";C++;let $=t.formatters[F];if(typeof $=="function"){let te=S[C];O=$.call(R,te),S.splice(C,1),C--}return O}),t.formatArgs.call(R,S),(R.log||t.log).apply(R,S)}return g.namespace=l,g.useColors=t.useColors(),g.color=t.selectColor(l),g.extend=i,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(p!==t.namespaces&&(p=t.namespaces,w=t.enabled(l)),w),set:S=>{m=S}}),typeof t.init=="function"&&t.init(g),g}function i(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,m=(typeof l=="string"?l:"").split(/[\s,]+/),p=m.length;for(f=0;f<p;f++)m[f]&&(l=m[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(l))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}jo.exports=jl});var Ho=I((me,Ji)=>{"use strict";me.formatArgs=Yl;me.save=Jl;me.load=Xl;me.useColors=Hl;me.storage=Ql();me.destroy=(()=>{let n=!1;return()=>{n||(n=!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`."))}})();me.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 Hl(){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 n;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&&(n=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(n[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Yl(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+Ji.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;n.splice(1,0,e,"color: inherit");let t=0,i=0;n[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(i=t))}),n.splice(i,0,e)}me.log=console.debug||console.log||(()=>{});function Jl(n){try{n?me.storage.setItem("debug",n):me.storage.removeItem("debug")}catch(e){}}function Xl(){let n;try{n=me.storage.getItem("debug")}catch(e){}return!n&&typeof process!="undefined"&&"env"in process&&(n=process.env.DEBUG),n}function Ql(){try{return localStorage}catch(n){}}Ji.exports=Jr()(me);var{formatters:Zl}=Ji.exports;Zl.j=function(n){try{return JSON.stringify(n)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Jo=I((Jm,Yo)=>{"use strict";Yo.exports=(n,e=process.argv)=>{let t=n.startsWith("-")?"":n.length===1?"-":"--",i=e.indexOf(t+n),r=e.indexOf("--");return i!==-1&&(r===-1||i<r)}});var Xi=I((Xm,Qo)=>{"use strict";var eu=T("os"),Xo=T("tty"),Ce=Jo(),{env:J}=process,mt;Ce("no-color")||Ce("no-colors")||Ce("color=false")||Ce("color=never")?mt=0:(Ce("color")||Ce("colors")||Ce("color=true")||Ce("color=always"))&&(mt=1);"FORCE_COLOR"in J&&(J.FORCE_COLOR==="true"?mt=1:J.FORCE_COLOR==="false"?mt=0:mt=J.FORCE_COLOR.length===0?1:Math.min(parseInt(J.FORCE_COLOR,10),3));function Xr(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}function Qr(n,e){if(mt===0)return 0;if(Ce("color=16m")||Ce("color=full")||Ce("color=truecolor"))return 3;if(Ce("color=256"))return 2;if(n&&!e&&mt===void 0)return 0;let t=mt||0;if(J.TERM==="dumb")return t;if(process.platform==="win32"){let i=eu.release().split(".");return Number(i[0])>=10&&Number(i[2])>=10586?Number(i[2])>=14931?3:2:1}if("CI"in J)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(i=>i 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 i=parseInt((J.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(J.TERM_PROGRAM){case"iTerm.app":return i>=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 tu(n){let e=Qr(n,n&&n.isTTY);return Xr(e)}Qo.exports={supportsColor:tu,stdout:Xr(Qr(!0,Xo.isatty(1))),stderr:Xr(Qr(!0,Xo.isatty(2)))}});var ea=I((X,Zi)=>{"use strict";var nu=T("tty"),Qi=T("util");X.init=lu;X.log=ou;X.formatArgs=ru;X.save=au;X.load=cu;X.useColors=iu;X.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`.");X.colors=[6,2,3,4,5,1];try{let n=Xi();n&&(n.stderr||n).level>=2&&(X.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(n){}X.inspectOpts=Object.keys(process.env).filter(n=>/^debug_/i.test(n)).reduce((n,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,s)=>s.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),n[t]=i,n},{});function iu(){return"colors"in X.inspectOpts?!!X.inspectOpts.colors:nu.isatty(process.stderr.fd)}function ru(n){let{namespace:e,useColors:t}=this;if(t){let i=this.color,r="\x1B[3"+(i<8?i:"8;5;"+i),s=` ${r};1m${e} \x1B[0m`;n[0]=s+n[0].split(`
|
|
2
2
|
`).join(`
|
|
3
|
-
`+s),n.push(r+"m+"+
|
|
4
|
-
`)}function
|
|
5
|
-
`).map(e=>e.trim()).join(" ")};
|
|
6
|
-
`);return _.substr(0,_.length-2)},this.getRequestHeader=function(_){return typeof _=="string"&&h[_]?h[_]:""},this.send=function(_){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(m)throw new Error("INVALID_STATE_ERR: send has already been called");var C=!1,M=!1,O=ea.parse(o.url),P;switch(O.protocol){case"https:":C=!0;case"http:":P=O.hostname;break;case"file:":M=!0;break;case void 0:case"":P="localhost";break;default:throw new Error("Protocol not supported.")}if(M){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)jt.readFile(unescape(O.pathname),"utf8",function(_e,Ft){_e?e.handleError(_e,_e.errno||-1):(e.status=200,e.responseText=Ft,N(e.DONE))});else try{this.responseText=jt.readFileSync(unescape(O.pathname),"utf8"),this.status=200,N(e.DONE)}catch(_e){this.handleError(_e,_e.errno||-1)}return}var $=O.port||(C?443:80),te=O.pathname+(O.search?O.search:"");if(h.Host=P,C&&$===443||$===80||(h.Host+=":"+O.port),o.user){typeof o.password=="undefined"&&(o.password="");var qe=new Buffer(o.user+":"+o.password);h.Authorization="Basic "+qe.toString("base64")}o.method==="GET"||o.method==="HEAD"?_=null:_?(h["Content-Length"]=Buffer.isBuffer(_)?_.length:Buffer.byteLength(_),h["Content-Type"]||(h["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(h["Content-Length"]=0);var gt=n.agent||!1,he={host:P,port:$,path:te,method:o.method,headers:h,agent:gt};if(C&&(he.pfx=n.pfx,he.key=n.key,he.passphrase=n.passphrase,he.cert=n.cert,he.ca=n.ca,he.ciphers=n.ciphers,he.rejectUnauthorized=n.rejectUnauthorized!==!1),d=!1,o.async){var tt=C?i.request:t.request;m=!0,e.dispatchEvent("readystatechange");var nt=function(_e){if(s=_e,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var Ft=ea.parse(o.url);P=Ft.hostname;var rt={hostname:Ft.hostname,port:Ft.port,path:Ft.path,method:s.statusCode===303?"GET":o.method,headers:h};C&&(rt.pfx=n.pfx,rt.key=n.key,rt.passphrase=n.passphrase,rt.cert=n.cert,rt.ca=n.ca,rt.ciphers=n.ciphers,rt.rejectUnauthorized=n.rejectUnauthorized!==!1),r=tt(rt,nt).on("error",it),r.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(ai){ai&&(e.responseText+=ai),m&&N(e.LOADING)}),s.on("end",function(){m&&(m=!1,N(e.DONE))}),s.on("error",function(ai){e.handleError(ai)})},it=function(_e){e.handleError(_e)};r=tt(he,nt).on("error",it),n.autoUnref&&r.on("socket",_e=>{_e.unref()}),_&&r.write(_),r.end(),e.dispatchEvent("loadstart")}else{var Ae=".node-xmlhttprequest-content-"+process.pid,Ne=".node-xmlhttprequest-sync-"+process.pid;jt.writeFileSync(Ne,"","utf8");for(var We="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(C?"s":"")+".request;var options = "+JSON.stringify(he)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+Ne+"');});response.on('error', function(error) {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});}).on('error', function(error) {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});"+(_?"req.write('"+JSON.stringify(_).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",jc=nu(process.argv[0],["-e",We]),Df;jt.existsSync(Ne););if(e.responseText=jt.readFileSync(Ae,"utf8"),jc.stdin.end(),jt.unlinkSync(Ae),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var Vc=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(Vc,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),N(e.DONE)}},this.handleError=function(_,C){this.status=C||0,this.statusText=_,this.responseText=_.stack,d=!0,N(this.DONE)},this.abort=function(){r&&(r.abort(),r=null),h=Object.assign({},u),this.responseText="",this.responseXML="",d=w=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||m)&&this.readyState!==this.DONE&&(m=!1,N(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(_,C){_ in g||(g[_]=[]),g[_].push(C)},this.removeEventListener=function(_,C){_ in g&&(g[_]=g[_].filter(function(M){return M!==C}))},this.dispatchEvent=function(_){if(typeof e["on"+_]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+_]()}):e["on"+_]()),_ in g)for(let C=0,M=g[_].length;C<M;C++)this.readyState===this.DONE?setImmediate(function(){g[_][C].call(e)}):g[_][C].call(e)};var N=function(_){if(!(e.readyState===_||e.readyState===e.UNSENT&&w)&&(e.readyState=_,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let C;w?C="abort":d?C="error":C="load",e.dispatchEvent(C),e.dispatchEvent("loadend")}}}});var Xe=I((sg,ca)=>{"use strict";var oa=["nodebuffer","arraybuffer","fragments"],aa=typeof Blob!="undefined";aa&&oa.push("blob");ca.exports={BINARY_TYPES:oa,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:aa,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Gn=I((og,Zi)=>{"use strict";var{EMPTY_BUFFER:ou}=Xe(),ns=Buffer[Symbol.species];function au(n,e){if(n.length===0)return ou;if(n.length===1)return n[0];let t=Buffer.allocUnsafe(e),i=0;for(let r=0;r<n.length;r++){let s=n[r];t.set(s,i),i+=s.length}return i<e?new ns(t.buffer,t.byteOffset,i):t}function la(n,e,t,i,r){for(let s=0;s<r;s++)t[i+s]=n[s]^e[s&3]}function ua(n,e){for(let t=0;t<n.length;t++)n[t]^=e[t&3]}function cu(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function is(n){if(is.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new ns(n):ArrayBuffer.isView(n)?e=new ns(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),is.readOnly=!1),e}Zi.exports={concat:au,mask:la,toArrayBuffer:cu,toBuffer:is,unmask:ua};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=T("bufferutil");Zi.exports.mask=function(e,t,i,r,s){s<48?la(e,t,i,r,s):n.mask(e,t,i,r,s)},Zi.exports.unmask=function(e,t){e.length<32?ua(e,t):n.unmask(e,t)}}catch(n){}});var da=I((ag,fa)=>{"use strict";var ha=Symbol("kDone"),rs=Symbol("kRun"),ss=class{constructor(e){this[ha]=()=>{this.pending--,this[rs]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[rs]()}[rs](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ha])}}};fa.exports=ss});var Yt=I((cg,ya)=>{"use strict";var jn=T("zlib"),pa=Gn(),lu=da(),{kStatusCode:ma}=Xe(),uu=Buffer[Symbol.species],hu=Buffer.from([0,0,255,255]),tr=Symbol("permessage-deflate"),Qe=Symbol("total-length"),Vt=Symbol("callback"),pt=Symbol("buffers"),Ht=Symbol("error"),er,os=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!er){let t=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;er=new lu(t)}}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[Vt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,i=e.find(r=>!(t.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>r.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(i.server_no_context_takeover=!0),t.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(i.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?i.client_max_window_bits=t.clientMaxWindowBits:(i.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(i=>{let r=t[i];if(r.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(r=r[0],i==="client_max_window_bits"){if(r!==!0){let s=+r;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else if(i==="server_max_window_bits"){let s=+r;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=s}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else throw new Error(`Unknown parameter "${i}"`);t[i]=r})}),e}decompress(e,t,i){er.add(r=>{this._decompress(e,t,(s,o)=>{r(),i(s,o)})})}compress(e,t,i){er.add(r=>{this._compress(e,t,(s,o)=>{r(),i(s,o)})})}_decompress(e,t,i){let r=this._isServer?"client":"server";if(!this._inflate){let s=`${r}_max_window_bits`,o=typeof this.params[s]!="number"?jn.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=jn.createInflateRaw(x(y({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[tr]=this,this._inflate[Qe]=0,this._inflate[pt]=[],this._inflate.on("error",du),this._inflate.on("data",ga)}this._inflate[Vt]=i,this._inflate.write(e),t&&this._inflate.write(hu),this._inflate.flush(()=>{let s=this._inflate[Ht];if(s){this._inflate.close(),this._inflate=null,i(s);return}let o=pa.concat(this._inflate[pt],this._inflate[Qe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Qe]=0,this._inflate[pt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),i(null,o)})}_compress(e,t,i){let r=this._isServer?"server":"client";if(!this._deflate){let s=`${r}_max_window_bits`,o=typeof this.params[s]!="number"?jn.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=jn.createDeflateRaw(x(y({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Qe]=0,this._deflate[pt]=[],this._deflate.on("data",fu)}this._deflate[Vt]=i,this._deflate.write(e),this._deflate.flush(jn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=pa.concat(this._deflate[pt],this._deflate[Qe]);t&&(s=new uu(s.buffer,s.byteOffset,s.length-4)),this._deflate[Vt]=null,this._deflate[Qe]=0,this._deflate[pt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),i(null,s)})}};ya.exports=os;function fu(n){this[pt].push(n),this[Qe]+=n.length}function ga(n){if(this[Qe]+=n.length,this[tr]._maxPayload<1||this[Qe]<=this[tr]._maxPayload){this[pt].push(n);return}this[Ht]=new RangeError("Max payload size exceeded"),this[Ht].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ht][ma]=1009,this.removeListener("data",ga),this.reset()}function du(n){if(this[tr]._inflate=null,this[Ht]){this[Vt](this[Ht]);return}n[ma]=1007,this[Vt](n)}});var Jt=I((ug,nr)=>{"use strict";var{isUtf8:va}=T("buffer"),{hasBlob:pu}=Xe(),mu=[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 gu(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function as(n){let e=n.length,t=0;for(;t<e;)if((n[t]&128)===0)t++;else if((n[t]&224)===192){if(t+1===e||(n[t+1]&192)!==128||(n[t]&254)===192)return!1;t+=2}else if((n[t]&240)===224){if(t+2>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return!1;t+=3}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return!1;t+=4}else return!1;return!0}function yu(n){return pu&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}nr.exports={isBlob:yu,isValidStatusCode:gu,isValidUTF8:as,tokenChars:mu};if(va)nr.exports.isValidUTF8=function(n){return n.length<24?as(n):va(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=T("utf-8-validate");nr.exports.isValidUTF8=function(e){return e.length<32?as(e):n(e)}}catch(n){}});var fs=I((hg,xa)=>{"use strict";var{Writable:vu}=T("stream"),ba=Yt(),{BINARY_TYPES:bu,EMPTY_BUFFER:Sa,kStatusCode:Su,kWebSocket:_u}=Xe(),{concat:cs,toArrayBuffer:Eu,unmask:Cu}=Gn(),{isValidStatusCode:wu,isValidUTF8:_a}=Jt(),ir=Buffer[Symbol.species],we=0,Ea=1,Ca=2,wa=3,ls=4,us=5,rr=6,hs=class extends vu{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||bu[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[_u]=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._errored=!1,this._loop=!1,this._state=we}_write(e,t,i){if(this._opcode===8&&this._state==we)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new ir(i.buffer,i.byteOffset+e,i.length-e),new ir(i.buffer,i.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let i=this._buffers[0],r=t.length-e;e>=i.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(i.buffer,i.byteOffset,e),r),this._buffers[0]=new ir(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case we:this.getInfo(e);break;case Ea:this.getPayloadLength16(e);break;case Ca:this.getPayloadLength64(e);break;case wa:this.getMask();break;case ls:this.getData(e);break;case us:case rr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((t[0]&48)!==0){let r=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(r);return}let i=(t[0]&64)===64;if(i&&!this._extensions[ba.extensionName]){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(!this._fragmented){let r=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let r=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(r);return}if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let r=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(r);return}}else{let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let r=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(r);return}}else if(this._masked){let r=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(r);return}this._payloadLength===126?this._state=Ea:this._payloadLength===127?this._state=Ca:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),i=t.readUInt32BE(0);if(i>Math.pow(2,21)-1){let r=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(r);return}this._payloadLength=i*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=wa:this._state=ls}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ls}getData(e){let t=Sa;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])!==0&&Cu(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=us,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[ba.extensionName].decompress(e,this._fin,(r,s)=>{if(r)return t(r);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(o);return}this._fragments.push(s)}this.dataMessage(t),this._state===we&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=we;return}let t=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=cs(i,t):this._binaryType==="arraybuffer"?r=Eu(cs(i,t)):this._binaryType==="blob"?r=new Blob(i):r=i,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=we):(this._state=rr,setImmediate(()=>{this.emit("message",r,!0),this._state=we,this.startLoop(e)}))}else{let r=cs(i,t);if(!this._skipUTF8Validation&&!_a(r)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===us||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=we):(this._state=rr,setImmediate(()=>{this.emit("message",r,!1),this._state=we,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Sa),this.end();else{let i=e.readUInt16BE(0);if(!wu(i)){let s=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let r=new ir(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!_a(r)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",i,r),this.end()}this._state=we;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=we):(this._state=rr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=we,this.startLoop(t)}))}createError(e,t,i,r,s){this._loop=!1,this._errored=!0;let o=new e(i?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=s,o[Su]=r,o}};xa.exports=hs});var ms=I((dg,ka)=>{"use strict";var{Duplex:fg}=T("stream"),{randomFillSync:xu}=T("crypto"),{types:{isUint8Array:Au}}=T("util"),Aa=Yt(),{EMPTY_BUFFER:Nu,kWebSocket:ku,NOOP:Ru}=Xe(),{isBlob:Xt,isValidStatusCode:Ou}=Jt(),{mask:Na,toBuffer:xt}=Gn(),xe=Symbol("kByteLength"),Tu=Buffer.alloc(4),sr=8*1024,At,Qt=sr,Pe=0,Iu=1,Pu=2,ds=class n{constructor(e,t,i){this._extensions=t||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Pe,this.onerror=Ru,this[ku]=void 0}static frame(e,t){let i,r=!1,s=2,o=!1;t.mask&&(i=t.maskBuffer||Tu,t.generateMask?t.generateMask(i):(Qt===sr&&(At===void 0&&(At=Buffer.alloc(sr)),xu(At,0,sr),Qt=0),i[0]=At[Qt++],i[1]=At[Qt++],i[2]=At[Qt++],i[3]=At[Qt++]),o=(i[0]|i[1]|i[2]|i[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[xe]!==void 0?c=t[xe]:(e=Buffer.from(e),c=e.length):(c=e.length,r=t.mask&&t.readOnly&&!o);let u=c;c>=65536?(s+=8,u=127):c>125&&(s+=2,u=126);let h=Buffer.allocUnsafe(r?c+s:s);return h[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(h[0]|=64),h[1]=u,u===126?h.writeUInt16BE(c,2):u===127&&(h[2]=h[3]=0,h.writeUIntBE(c,4,6)),t.mask?(h[1]|=128,h[s-4]=i[0],h[s-3]=i[1],h[s-2]=i[2],h[s-1]=i[3],o?[h,e]:r?(Na(e,i,h,s,c),[h]):(Na(e,i,e,0,c),[h,e])):[h,e]}close(e,t,i,r){let s;if(e===void 0)s=Nu;else{if(typeof e!="number"||!Ou(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");if(s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(e,0),typeof t=="string")s.write(t,2);else if(Au(t))s.set(t,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[xe]:s.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Pe?this.enqueue([this.dispatch,s,!1,o,r]):this.sendFrame(n.frame(s,o),r)}ping(e,t,i){let r,s;if(typeof e=="string"?(r=Buffer.byteLength(e),s=!1):Xt(e)?(r=e.size,s=!1):(e=xt(e),r=e.length,s=xt.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};Xt(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,!1,o,i]):this.getBlobData(e,!1,o,i):this._state!==Pe?this.enqueue([this.dispatch,e,!1,o,i]):this.sendFrame(n.frame(e,o),i)}pong(e,t,i){let r,s;if(typeof e=="string"?(r=Buffer.byteLength(e),s=!1):Xt(e)?(r=e.size,s=!1):(e=xt(e),r=e.length,s=xt.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};Xt(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,!1,o,i]):this.getBlobData(e,!1,o,i):this._state!==Pe?this.enqueue([this.dispatch,e,!1,o,i]):this.sendFrame(n.frame(e,o),i)}send(e,t,i){let r=this._extensions[Aa.extensionName],s=t.binary?2:1,o=t.compress,c,u;typeof e=="string"?(c=Buffer.byteLength(e),u=!1):Xt(e)?(c=e.size,u=!1):(e=xt(e),c=e.length,u=xt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=r._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0);let h={[xe]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:u,rsv1:o};Xt(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==Pe?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,t,i,r){this._bufferedBytes+=i[xe],this._state=Pu,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(ps,this,c,r);return}this._bufferedBytes-=i[xe];let o=xt(s);t?this.dispatch(o,t,i,r):(this._state=Pe,this.sendFrame(n.frame(o,i),r),this.dequeue())}).catch(s=>{process.nextTick(Fu,this,s,r)})}dispatch(e,t,i,r){if(!t){this.sendFrame(n.frame(e,i),r);return}let s=this._extensions[Aa.extensionName];this._bufferedBytes+=i[xe],this._state=Iu,s.compress(e,i.fin,(o,c)=>{if(this._socket.destroyed){let u=new Error("The socket was closed while data was being compressed");ps(this,u,r);return}this._bufferedBytes-=i[xe],this._state=Pe,i.readOnly=!1,this.sendFrame(n.frame(c,i),r),this.dequeue()})}dequeue(){for(;this._state===Pe&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][xe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][xe],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)}};ka.exports=ds;function ps(n,e,t){typeof t=="function"&&t(e);for(let i=0;i<n._queue.length;i++){let r=n._queue[i],s=r[r.length-1];typeof s=="function"&&s(e)}}function Fu(n,e,t){ps(n,e,t),n.onerror(e)}});var Da=I((pg,Ua)=>{"use strict";var{kForOnEventAttribute:Vn,kListener:gs}=Xe(),Ra=Symbol("kCode"),Oa=Symbol("kData"),Ta=Symbol("kError"),Ia=Symbol("kMessage"),Pa=Symbol("kReason"),Zt=Symbol("kTarget"),Fa=Symbol("kType"),La=Symbol("kWasClean"),Ze=class{constructor(e){this[Zt]=null,this[Fa]=e}get target(){return this[Zt]}get type(){return this[Fa]}};Object.defineProperty(Ze.prototype,"target",{enumerable:!0});Object.defineProperty(Ze.prototype,"type",{enumerable:!0});var Nt=class extends Ze{constructor(e,t={}){super(e),this[Ra]=t.code===void 0?0:t.code,this[Pa]=t.reason===void 0?"":t.reason,this[La]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Ra]}get reason(){return this[Pa]}get wasClean(){return this[La]}};Object.defineProperty(Nt.prototype,"code",{enumerable:!0});Object.defineProperty(Nt.prototype,"reason",{enumerable:!0});Object.defineProperty(Nt.prototype,"wasClean",{enumerable:!0});var en=class extends Ze{constructor(e,t={}){super(e),this[Ta]=t.error===void 0?null:t.error,this[Ia]=t.message===void 0?"":t.message}get error(){return this[Ta]}get message(){return this[Ia]}};Object.defineProperty(en.prototype,"error",{enumerable:!0});Object.defineProperty(en.prototype,"message",{enumerable:!0});var Hn=class extends Ze{constructor(e,t={}){super(e),this[Oa]=t.data===void 0?null:t.data}get data(){return this[Oa]}};Object.defineProperty(Hn.prototype,"data",{enumerable:!0});var Lu={addEventListener(n,e,t={}){for(let r of this.listeners(n))if(!t[Vn]&&r[gs]===e&&!r[Vn])return;let i;if(n==="message")i=function(s,o){let c=new Hn("message",{data:o?s:s.toString()});c[Zt]=this,or(e,this,c)};else if(n==="close")i=function(s,o){let c=new Nt("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[Zt]=this,or(e,this,c)};else if(n==="error")i=function(s){let o=new en("error",{error:s,message:s.message});o[Zt]=this,or(e,this,o)};else if(n==="open")i=function(){let s=new Ze("open");s[Zt]=this,or(e,this,s)};else return;i[Vn]=!!t[Vn],i[gs]=e,t.once?this.once(n,i):this.on(n,i)},removeEventListener(n,e){for(let t of this.listeners(n))if(t[gs]===e&&!t[Vn]){this.removeListener(n,t);break}}};Ua.exports={CloseEvent:Nt,ErrorEvent:en,Event:Ze,EventTarget:Lu,MessageEvent:Hn};function or(n,e,t){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,t):n.call(e,t)}});var ar=I((mg,Ba)=>{"use strict";var{tokenChars:Yn}=Jt();function Be(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}function Uu(n){let e=Object.create(null),t=Object.create(null),i=!1,r=!1,s=!1,o,c,u=-1,h=-1,l=-1,f=0;for(;f<n.length;f++)if(h=n.charCodeAt(f),o===void 0)if(l===-1&&Yn[h]===1)u===-1&&(u=f);else if(f!==0&&(h===32||h===9))l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=n.slice(u,l);h===44?(Be(e,d,t),t=Object.create(null)):o=d,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(l===-1&&Yn[h]===1)u===-1&&(u=f);else if(h===32||h===9)l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),Be(t,n.slice(u,l),!0),h===44&&(Be(e,o,t),t=Object.create(null),o=void 0),u=l=-1}else if(h===61&&u!==-1&&l===-1)c=n.slice(u,f),u=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(r){if(Yn[h]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1?u=f:i||(i=!0),r=!1}else if(s)if(Yn[h]===1)u===-1&&(u=f);else if(h===34&&u!==-1)s=!1,l=f;else if(h===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(h===34&&n.charCodeAt(f-1)===61)s=!0;else if(l===-1&&Yn[h]===1)u===-1&&(u=f);else if(u!==-1&&(h===32||h===9))l===-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let d=n.slice(u,l);i&&(d=d.replace(/\\/g,""),i=!1),Be(t,c,d),h===44&&(Be(e,o,t),t=Object.create(null),o=void 0),c=void 0,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(u===-1||s||h===32||h===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let m=n.slice(u,l);return o===void 0?Be(e,m,t):(c===void 0?Be(t,m,!0):i?Be(t,c,m.replace(/\\/g,"")):Be(t,c,m),Be(e,o,t)),e}function Du(n){return Object.keys(n).map(e=>{let t=n[e];return Array.isArray(t)||(t=[t]),t.map(i=>[e].concat(Object.keys(i).map(r=>{let s=i[r];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?r:`${r}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ba.exports={format:Du,parse:Uu}});var hr=I((vg,Ja)=>{"use strict";var Bu=T("events"),Mu=T("https"),qu=T("http"),Wa=T("net"),Wu=T("tls"),{randomBytes:$u,createHash:Ku}=T("crypto"),{Duplex:gg,Readable:yg}=T("stream"),{URL:ys}=T("url"),mt=Yt(),zu=fs(),Gu=ms(),{isBlob:ju}=Jt(),{BINARY_TYPES:Ma,CLOSE_TIMEOUT:Vu,EMPTY_BUFFER:cr,GUID:Hu,kForOnEventAttribute:vs,kListener:Yu,kStatusCode:Ju,kWebSocket:Q,NOOP:$a}=Xe(),{EventTarget:{addEventListener:Xu,removeEventListener:Qu}}=Da(),{format:Zu,parse:eh}=ar(),{toBuffer:th}=Gn(),Ka=Symbol("kAborted"),bs=[8,13],et=["CONNECTING","OPEN","CLOSING","CLOSED"],nh=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,D=class n extends Bu{constructor(e,t,i){super(),this._binaryType=Ma[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=cr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(i=t,t=[]):t=[t]),za(this,e,t,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ma.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,i){let r=new zu({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),s=new Gu(e,this._extensions,i.generateMask);this._receiver=r,this._sender=s,this._socket=e,r[Q]=this,s[Q]=this,e[Q]=this,r.on("conclude",sh),r.on("drain",oh),r.on("error",ah),r.on("message",ch),r.on("ping",lh),r.on("pong",uh),s.onerror=hh,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Va),e.on("data",ur),e.on("end",Ha),e.on("error",Ya),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[mt.extensionName]&&this._extensions[mt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ge(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,t,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ja(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,i){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Ss(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||cr,t,i)}pong(e,t,i){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Ss(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||cr,t,i)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,i){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(i=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Ss(this,e,i);return}let r=y({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[mt.extensionName]||(r.compress=!1),this._sender.send(e||cr,r,i)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ge(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:et.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:et.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:et.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:et.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:et.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:et.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:et.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:et.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(D.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(D.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[vs])return e[Yu];return null},set(e){for(let t of this.listeners(n))if(t[vs]){this.removeListener(n,t);break}typeof e=="function"&&this.addEventListener(n,e,{[vs]:!0})}})});D.prototype.addEventListener=Xu;D.prototype.removeEventListener=Qu;Ja.exports=D;function za(n,e,t,i){let r=x(y({allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Vu,protocolVersion:bs[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},i),{socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(n._autoPong=r.autoPong,n._closeTimeout=r.closeTimeout,!bs.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${bs.join(", ")})`);let s;if(e instanceof ys)s=e;else try{s=new ys(e)}catch(g){throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),n._url=s.href;let o=s.protocol==="wss:",c=s.protocol==="ws+unix:",u;if(s.protocol!=="ws:"&&!o&&!c?u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!s.pathname?u="The URL's pathname is empty":s.hash&&(u="The URL contains a fragment identifier"),u){let g=new SyntaxError(u);if(n._redirects===0)throw g;lr(n,g);return}let h=o?443:80,l=$u(16).toString("base64"),f=o?Mu.request:qu.request,m=new Set,d;if(r.createConnection=r.createConnection||(o?rh:ih),r.defaultPort=r.defaultPort||h,r.port=s.port||h,r.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,r.headers=x(y({},r.headers),{"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"}),r.path=s.pathname+s.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(d=new mt(x(y({},r.perMessageDeflate),{isServer:!1,maxPayload:r.maxPayload})),r.headers["Sec-WebSocket-Extensions"]=Zu({[mt.extensionName]:d.offer()})),t.length){for(let g of t){if(typeof g!="string"||!nh.test(g)||m.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(g)}r.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(s.username||s.password)&&(r.auth=`${s.username}:${s.password}`),c){let g=r.path.split(":");r.socketPath=g[0],r.path=g[1]}let w;if(r.followRedirects){if(n._redirects===0){n._originalIpc=c,n._originalSecure=o,n._originalHostOrSocketPath=c?r.socketPath:s.host;let g=i&&i.headers;if(i=x(y({},i),{headers:{}}),g)for(let[S,R]of Object.entries(g))i.headers[S.toLowerCase()]=R}else if(n.listenerCount("redirect")===0){let g=c?n._originalIpc?r.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:s.host===n._originalHostOrSocketPath;(!g||n._originalSecure&&!o)&&(delete r.headers.authorization,delete r.headers.cookie,g||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),w=n._req=f(r),n._redirects&&n.emit("redirect",n.url,w)}else w=n._req=f(r);r.timeout&&w.on("timeout",()=>{ge(n,w,"Opening handshake has timed out")}),w.on("error",g=>{w===null||w[Ka]||(w=n._req=null,lr(n,g))}),w.on("response",g=>{let S=g.headers.location,R=g.statusCode;if(S&&r.followRedirects&&R>=300&&R<400){if(++n._redirects>r.maxRedirects){ge(n,w,"Maximum redirects exceeded");return}w.abort();let N;try{N=new ys(S,e)}catch(_){let C=new SyntaxError(`Invalid URL: ${S}`);lr(n,C);return}za(n,N,t,i)}else n.emit("unexpected-response",w,g)||ge(n,w,`Unexpected server response: ${g.statusCode}`)}),w.on("upgrade",(g,S,R)=>{if(n.emit("upgrade",g),n.readyState!==D.CONNECTING)return;w=n._req=null;let N=g.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){ge(n,S,"Invalid Upgrade header");return}let _=Ku("sha1").update(l+Hu).digest("base64");if(g.headers["sec-websocket-accept"]!==_){ge(n,S,"Invalid Sec-WebSocket-Accept header");return}let C=g.headers["sec-websocket-protocol"],M;if(C!==void 0?m.size?m.has(C)||(M="Server sent an invalid subprotocol"):M="Server sent a subprotocol but none was requested":m.size&&(M="Server sent no subprotocol"),M){ge(n,S,M);return}C&&(n._protocol=C);let O=g.headers["sec-websocket-extensions"];if(O!==void 0){if(!d){ge(n,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;try{P=eh(O)}catch(te){ge(n,S,"Invalid Sec-WebSocket-Extensions header");return}let $=Object.keys(P);if($.length!==1||$[0]!==mt.extensionName){ge(n,S,"Server indicated an extension that was not requested");return}try{d.accept(P[mt.extensionName])}catch(te){ge(n,S,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[mt.extensionName]=d}n.setSocket(S,R,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})}),r.finishRequest?r.finishRequest(w,n):w.end()}function lr(n,e){n._readyState=D.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function ih(n){return n.path=n.socketPath,Wa.connect(n)}function rh(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Wa.isIP(n.host)?"":n.host),Wu.connect(n)}function ge(n,e,t){n._readyState=D.CLOSING;let i=new Error(t);Error.captureStackTrace(i,ge),e.setHeader?(e[Ka]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(lr,n,i)):(e.destroy(i),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Ss(n,e,t){if(e){let i=ju(e)?e.size:th(e).length;n._socket?n._sender._bufferedBytes+=i:n._bufferedAmount+=i}if(t){let i=new Error(`WebSocket is not open: readyState ${n.readyState} (${et[n.readyState]})`);process.nextTick(t,i)}}function sh(n,e){let t=this[Q];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=n,t._socket[Q]!==void 0&&(t._socket.removeListener("data",ur),process.nextTick(Ga,t._socket),n===1005?t.close():t.close(n,e))}function oh(){let n=this[Q];n.isPaused||n._socket.resume()}function ah(n){let e=this[Q];e._socket[Q]!==void 0&&(e._socket.removeListener("data",ur),process.nextTick(Ga,e._socket),e.close(n[Ju])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function qa(){this[Q].emitClose()}function ch(n,e){this[Q].emit("message",n,e)}function lh(n){let e=this[Q];e._autoPong&&e.pong(n,!this._isServer,$a),e.emit("ping",n)}function uh(n){this[Q].emit("pong",n)}function Ga(n){n.resume()}function hh(n){let e=this[Q];e.readyState!==D.CLOSED&&(e.readyState===D.OPEN&&(e._readyState=D.CLOSING,ja(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function ja(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Va(){let n=this[Q];if(this.removeListener("close",Va),this.removeListener("data",ur),this.removeListener("end",Ha),n._readyState=D.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[Q]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",qa),n._receiver.on("finish",qa))}function ur(n){this[Q]._receiver.write(n)||this.pause()}function Ha(){let n=this[Q];n._readyState=D.CLOSING,n._receiver.end(),this.end()}function Ya(){let n=this[Q];this.removeListener("error",Ya),this.on("error",$a),n&&(n._readyState=D.CLOSING,this.destroy())}});var ec=I((_g,Za)=>{"use strict";var Sg=hr(),{Duplex:fh}=T("stream");function Xa(n){n.emit("close")}function dh(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Qa(n){this.removeListener("error",Qa),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function ph(n,e){let t=!0,i=new fh(x(y({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return n.on("message",function(s,o){let c=!o&&i._readableState.objectMode?s.toString():s;i.push(c)||n.pause()}),n.once("error",function(s){i.destroyed||(t=!1,i.destroy(s))}),n.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(r,s){if(n.readyState===n.CLOSED){s(r),process.nextTick(Xa,i);return}let o=!1;n.once("error",function(u){o=!0,s(u)}),n.once("close",function(){o||s(r),process.nextTick(Xa,i)}),t&&n.terminate()},i._final=function(r){if(n.readyState===n.CONNECTING){n.once("open",function(){i._final(r)});return}n._socket!==null&&(n._socket._writableState.finished?(r(),i._readableState.endEmitted&&i.destroy()):(n._socket.once("finish",function(){r()}),n.close()))},i._read=function(){n.isPaused&&n.resume()},i._write=function(r,s,o){if(n.readyState===n.CONNECTING){n.once("open",function(){i._write(r,s,o)});return}n.send(r,o)},i.on("end",dh),i.on("error",Qa),i}Za.exports=ph});var _s=I((Cg,tc)=>{"use strict";var{tokenChars:mh}=Jt();function gh(n){let e=new Set,t=-1,i=-1,r=0;for(r;r<n.length;r++){let o=n.charCodeAt(r);if(i===-1&&mh[o]===1)t===-1&&(t=r);else if(r!==0&&(o===32||o===9))i===-1&&t!==-1&&(i=r);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${r}`);i===-1&&(i=r);let c=n.slice(t,i);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),t=i=-1}else throw new SyntaxError(`Unexpected character at index ${r}`)}if(t===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let s=n.slice(t,r);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}tc.exports={parse:gh}});var cc=I((xg,ac)=>{"use strict";var yh=T("events"),fr=T("http"),{Duplex:wg}=T("stream"),{createHash:vh}=T("crypto"),nc=ar(),kt=Yt(),bh=_s(),Sh=hr(),{CLOSE_TIMEOUT:_h,GUID:Eh,kWebSocket:Ch}=Xe(),wh=/^[+/0-9A-Za-z]{22}==$/,ic=0,rc=1,oc=2,Es=class extends yh{constructor(e,t){if(super(),e=y({allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:_h,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Sh},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((i,r)=>{let s=fr.STATUS_CODES[426];r.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),r.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=xh(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,s,o)=>{this.handleUpgrade(r,s,o,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ic}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===oc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Jn,this);return}if(e&&this.once("close",e),this._state!==rc)if(this._state=rc,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(Jn,this):process.nextTick(Jn,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Jn(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,i,r){t.on("error",sc);let s=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Rt(this,e,t,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){Rt(this,e,t,400,"Invalid Upgrade header");return}if(s===void 0||!wh.test(s)){Rt(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){Rt(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Xn(t,400);return}let u=e.headers["sec-websocket-protocol"],h=new Set;if(u!==void 0)try{h=bh.parse(u)}catch(m){Rt(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&l!==void 0){let m=new kt(x(y({},this.options.perMessageDeflate),{isServer:!0,maxPayload:this.options.maxPayload}));try{let d=nc.parse(l);d[kt.extensionName]&&(m.accept(d[kt.extensionName]),f[kt.extensionName]=m)}catch(d){Rt(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:e.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(d,w,g,S)=>{if(!d)return Xn(t,w||401,g,S);this.completeUpgrade(f,s,h,e,t,i,r)});return}if(!this.options.verifyClient(m))return Xn(t,401)}this.completeUpgrade(f,s,h,e,t,i,r)}completeUpgrade(e,t,i,r,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[Ch])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ic)return Xn(s,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${vh("sha1").update(t+Eh).digest("base64")}`],l=new this.options.WebSocket(null,void 0,this.options);if(i.size){let f=this.options.handleProtocols?this.options.handleProtocols(i,r):i.values().next().value;f&&(h.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)}if(e[kt.extensionName]){let f=e[kt.extensionName].params,m=nc.format({[kt.extensionName]:[f]});h.push(`Sec-WebSocket-Extensions: ${m}`),l._extensions=e}this.emit("headers",h,r),s.write(h.concat(`\r
|
|
3
|
+
`+s),n.push(r+"m+"+Zi.exports.humanize(this.diff)+"\x1B[0m")}else n[0]=su()+e+" "+n[0]}function su(){return X.inspectOpts.hideDate?"":new Date().toISOString()+" "}function ou(...n){return process.stderr.write(Qi.formatWithOptions(X.inspectOpts,...n)+`
|
|
4
|
+
`)}function au(n){n?process.env.DEBUG=n:delete process.env.DEBUG}function cu(){return process.env.DEBUG}function lu(n){n.inspectOpts={};let e=Object.keys(X.inspectOpts);for(let t=0;t<e.length;t++)n.inspectOpts[e[t]]=X.inspectOpts[e[t]]}Zi.exports=Jr()(X);var{formatters:Zo}=Zi.exports;Zo.o=function(n){return this.inspectOpts.colors=this.useColors,Qi.inspect(n,this.inspectOpts).split(`
|
|
5
|
+
`).map(e=>e.trim()).join(" ")};Zo.O=function(n){return this.inspectOpts.colors=this.useColors,Qi.inspect(n,this.inspectOpts)}});var Yt=I((Qm,Zr)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Zr.exports=Ho():Zr.exports=ea()});var ua=I((og,la)=>{"use strict";var Jt=T("fs"),ca=T("url"),fu=T("child_process").spawn;la.exports=ns;ns.XMLHttpRequest=ns;function ns(n){"use strict";n=n||{};var e=this,t=T("http"),i=T("https"),r,s,o={},c=!1,u={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},h=Object.assign({},u),l=["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"],m=!1,p=!1,w=!1,g={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;var S=function(_){return c||_&&l.indexOf(_.toLowerCase())===-1},R=function(_){return _&&f.indexOf(_)===-1};this.open=function(_,C,M,O,F){if(this.abort(),p=!1,w=!1,!R(_))throw new Error("SecurityError: Request method not allowed");o={method:_,url:C.toString(),async:typeof M!="boolean"?!0:M,user:O||null,password:F||null},N(this.OPENED)},this.setDisableHeaderCheck=function(_){c=_},this.setRequestHeader=function(_,C){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!S(_))return console.warn('Refused to set unsafe header "'+_+'"'),!1;if(m)throw new Error("INVALID_STATE_ERR: send flag is true");return h[_]=C,!0},this.getResponseHeader=function(_){return typeof _=="string"&&this.readyState>this.OPENED&&s.headers[_.toLowerCase()]&&!p?s.headers[_.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||p)return"";var _="";for(var C in s.headers)C!=="set-cookie"&&C!=="set-cookie2"&&(_+=C+": "+s.headers[C]+`\r
|
|
6
|
+
`);return _.substr(0,_.length-2)},this.getRequestHeader=function(_){return typeof _=="string"&&h[_]?h[_]:""},this.send=function(_){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(m)throw new Error("INVALID_STATE_ERR: send has already been called");var C=!1,M=!1,O=ca.parse(o.url),F;switch(O.protocol){case"https:":C=!0;case"http:":F=O.hostname;break;case"file:":M=!0;break;case void 0:case"":F="localhost";break;default:throw new Error("Protocol not supported.")}if(M){if(o.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(o.async)Jt.readFile(unescape(O.pathname),"utf8",function(_e,Dt){_e?e.handleError(_e,_e.errno||-1):(e.status=200,e.responseText=Dt,N(e.DONE))});else try{this.responseText=Jt.readFileSync(unescape(O.pathname),"utf8"),this.status=200,N(e.DONE)}catch(_e){this.handleError(_e,_e.errno||-1)}return}var $=O.port||(C?443:80),te=O.pathname+(O.search?O.search:"");if(h.Host=F,C&&$===443||$===80||(h.Host+=":"+O.port),o.user){typeof o.password=="undefined"&&(o.password="");var qe=new Buffer(o.user+":"+o.password);h.Authorization="Basic "+qe.toString("base64")}o.method==="GET"||o.method==="HEAD"?_=null:_?(h["Content-Length"]=Buffer.isBuffer(_)?_.length:Buffer.byteLength(_),h["Content-Type"]||(h["Content-Type"]="text/plain;charset=UTF-8")):o.method==="POST"&&(h["Content-Length"]=0);var bt=n.agent||!1,he={host:F,port:$,path:te,method:o.method,headers:h,agent:bt};if(C&&(he.pfx=n.pfx,he.key=n.key,he.passphrase=n.passphrase,he.cert=n.cert,he.ca=n.ca,he.ciphers=n.ciphers,he.rejectUnauthorized=n.rejectUnauthorized!==!1),p=!1,o.async){var tt=C?i.request:t.request;m=!0,e.dispatchEvent("readystatechange");var nt=function(_e){if(s=_e,s.statusCode===302||s.statusCode===303||s.statusCode===307){o.url=s.headers.location;var Dt=ca.parse(o.url);F=Dt.hostname;var rt={hostname:Dt.hostname,port:Dt.port,path:Dt.path,method:s.statusCode===303?"GET":o.method,headers:h};C&&(rt.pfx=n.pfx,rt.key=n.key,rt.passphrase=n.passphrase,rt.cert=n.cert,rt.ca=n.ca,rt.ciphers=n.ciphers,rt.rejectUnauthorized=n.rejectUnauthorized!==!1),r=tt(rt,nt).on("error",it),r.end();return}s&&s.setEncoding&&s.setEncoding("utf8"),N(e.HEADERS_RECEIVED),e.status=s.statusCode,s.on("data",function(hi){hi&&(e.responseText+=hi),m&&N(e.LOADING)}),s.on("end",function(){m&&(m=!1,N(e.DONE))}),s.on("error",function(hi){e.handleError(hi)})},it=function(_e){e.handleError(_e)};r=tt(he,nt).on("error",it),n.autoUnref&&r.on("socket",_e=>{_e.unref()}),_&&r.write(_),r.end(),e.dispatchEvent("loadstart")}else{var Ae=".node-xmlhttprequest-content-"+process.pid,Ne=".node-xmlhttprequest-sync-"+process.pid;Jt.writeFileSync(Ne,"","utf8");for(var St="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(C?"s":"")+".request;var options = "+JSON.stringify(he)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+Ne+"');});response.on('error', function(error) {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});}).on('error', function(error) {fs.writeFileSync('"+Ae+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Ne+"');});"+(_?"req.write('"+JSON.stringify(_).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",We=fu(process.argv[0],["-e",St]),jf;Jt.existsSync(Ne););if(e.responseText=Jt.readFileSync(Ae,"utf8"),We.stdin.end(),Jt.unlinkSync(Ae),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var el=e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");e.handleError(el,503)}else e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),e.responseText=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),N(e.DONE)}},this.handleError=function(_,C){this.status=C||0,this.statusText=_,this.responseText=_.stack,p=!0,N(this.DONE)},this.abort=function(){r&&(r.abort(),r=null),h=Object.assign({},u),this.responseText="",this.responseXML="",p=w=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||m)&&this.readyState!==this.DONE&&(m=!1,N(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(_,C){_ in g||(g[_]=[]),g[_].push(C)},this.removeEventListener=function(_,C){_ in g&&(g[_]=g[_].filter(function(M){return M!==C}))},this.dispatchEvent=function(_){if(typeof e["on"+_]=="function"&&(this.readyState===this.DONE?setImmediate(function(){e["on"+_]()}):e["on"+_]()),_ in g)for(let C=0,M=g[_].length;C<M;C++)this.readyState===this.DONE?setImmediate(function(){g[_][C].call(e)}):g[_][C].call(e)};var N=function(_){if(!(e.readyState===_||e.readyState===e.UNSENT&&w)&&(e.readyState=_,(o.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let C;w?C="abort":p?C="error":C="load",e.dispatchEvent(C),e.dispatchEvent("loadend")}}}});var Xe=I((gg,ga)=>{"use strict";var pa=["nodebuffer","arraybuffer","fragments"],ma=typeof Blob!="undefined";ma&&pa.push("blob");ga.exports={BINARY_TYPES:pa,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ma,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Yn=I((yg,ir)=>{"use strict";var{EMPTY_BUFFER:gu}=Xe(),os=Buffer[Symbol.species];function yu(n,e){if(n.length===0)return gu;if(n.length===1)return n[0];let t=Buffer.allocUnsafe(e),i=0;for(let r=0;r<n.length;r++){let s=n[r];t.set(s,i),i+=s.length}return i<e?new os(t.buffer,t.byteOffset,i):t}function ya(n,e,t,i,r){for(let s=0;s<r;s++)t[i+s]=n[s]^e[s&3]}function va(n,e){for(let t=0;t<n.length;t++)n[t]^=e[t&3]}function vu(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function as(n){if(as.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new os(n):ArrayBuffer.isView(n)?e=new os(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),as.readOnly=!1),e}ir.exports={concat:yu,mask:ya,toArrayBuffer:vu,toBuffer:as,unmask:va};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=T("bufferutil");ir.exports.mask=function(e,t,i,r,s){s<48?ya(e,t,i,r,s):n.mask(e,t,i,r,s)},ir.exports.unmask=function(e,t){e.length<32?va(e,t):n.unmask(e,t)}}catch(n){}});var _a=I((vg,Sa)=>{"use strict";var ba=Symbol("kDone"),cs=Symbol("kRun"),ls=class{constructor(e){this[ba]=()=>{this.pending--,this[cs]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[cs]()}[cs](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ba])}}};Sa.exports=ls});var Zt=I((bg,xa)=>{"use strict";var Jn=T("zlib"),Ea=Yn(),bu=_a(),{kStatusCode:Ca}=Xe(),Su=Buffer[Symbol.species],_u=Buffer.from([0,0,255,255]),sr=Symbol("permessage-deflate"),Qe=Symbol("total-length"),Xt=Symbol("callback"),yt=Symbol("buffers"),Qt=Symbol("error"),rr,us=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!rr){let t=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;rr=new bu(t)}}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[Xt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,i=e.find(r=>!(t.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>r.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(i.server_no_context_takeover=!0),t.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(i.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?i.client_max_window_bits=t.clientMaxWindowBits:(i.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(i=>{let r=t[i];if(r.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(r=r[0],i==="client_max_window_bits"){if(r!==!0){let s=+r;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else if(i==="server_max_window_bits"){let s=+r;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=s}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else throw new Error(`Unknown parameter "${i}"`);t[i]=r})}),e}decompress(e,t,i){rr.add(r=>{this._decompress(e,t,(s,o)=>{r(),i(s,o)})})}compress(e,t,i){rr.add(r=>{this._compress(e,t,(s,o)=>{r(),i(s,o)})})}_decompress(e,t,i){let r=this._isServer?"client":"server";if(!this._inflate){let s=`${r}_max_window_bits`,o=typeof this.params[s]!="number"?Jn.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Jn.createInflateRaw(x(y({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[sr]=this,this._inflate[Qe]=0,this._inflate[yt]=[],this._inflate.on("error",Cu),this._inflate.on("data",wa)}this._inflate[Xt]=i,this._inflate.write(e),t&&this._inflate.write(_u),this._inflate.flush(()=>{let s=this._inflate[Qt];if(s){this._inflate.close(),this._inflate=null,i(s);return}let o=Ea.concat(this._inflate[yt],this._inflate[Qe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Qe]=0,this._inflate[yt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),i(null,o)})}_compress(e,t,i){let r=this._isServer?"server":"client";if(!this._deflate){let s=`${r}_max_window_bits`,o=typeof this.params[s]!="number"?Jn.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Jn.createDeflateRaw(x(y({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[Qe]=0,this._deflate[yt]=[],this._deflate.on("data",Eu)}this._deflate[Xt]=i,this._deflate.write(e),this._deflate.flush(Jn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Ea.concat(this._deflate[yt],this._deflate[Qe]);t&&(s=new Su(s.buffer,s.byteOffset,s.length-4)),this._deflate[Xt]=null,this._deflate[Qe]=0,this._deflate[yt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),i(null,s)})}};xa.exports=us;function Eu(n){this[yt].push(n),this[Qe]+=n.length}function wa(n){if(this[Qe]+=n.length,this[sr]._maxPayload<1||this[Qe]<=this[sr]._maxPayload){this[yt].push(n);return}this[Qt]=new RangeError("Max payload size exceeded"),this[Qt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Qt][Ca]=1009,this.removeListener("data",wa),this.reset()}function Cu(n){if(this[sr]._inflate=null,this[Qt]){this[Xt](this[Qt]);return}n[Ca]=1007,this[Xt](n)}});var en=I((_g,or)=>{"use strict";var{isUtf8:Aa}=T("buffer"),{hasBlob:wu}=Xe(),xu=[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 Au(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function hs(n){let e=n.length,t=0;for(;t<e;)if((n[t]&128)===0)t++;else if((n[t]&224)===192){if(t+1===e||(n[t+1]&192)!==128||(n[t]&254)===192)return!1;t+=2}else if((n[t]&240)===224){if(t+2>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return!1;t+=3}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return!1;t+=4}else return!1;return!0}function Nu(n){return wu&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}or.exports={isBlob:Nu,isValidStatusCode:Au,isValidUTF8:hs,tokenChars:xu};if(Aa)or.exports.isValidUTF8=function(n){return n.length<24?hs(n):Aa(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=T("utf-8-validate");or.exports.isValidUTF8=function(e){return e.length<32?hs(e):n(e)}}catch(n){}});var gs=I((Eg,Pa)=>{"use strict";var{Writable:ku}=T("stream"),Na=Zt(),{BINARY_TYPES:Ru,EMPTY_BUFFER:ka,kStatusCode:Ou,kWebSocket:Tu}=Xe(),{concat:fs,toArrayBuffer:Iu,unmask:Pu}=Yn(),{isValidStatusCode:Fu,isValidUTF8:Ra}=en(),ar=Buffer[Symbol.species],we=0,Oa=1,Ta=2,Ia=3,ds=4,ps=5,cr=6,ms=class extends ku{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Ru[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Tu]=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._errored=!1,this._loop=!1,this._state=we}_write(e,t,i){if(this._opcode===8&&this._state==we)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new ar(i.buffer,i.byteOffset+e,i.length-e),new ar(i.buffer,i.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let i=this._buffers[0],r=t.length-e;e>=i.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(i.buffer,i.byteOffset,e),r),this._buffers[0]=new ar(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case we:this.getInfo(e);break;case Oa:this.getPayloadLength16(e);break;case Ta:this.getPayloadLength64(e);break;case Ia:this.getMask();break;case ds:this.getData(e);break;case ps:case cr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((t[0]&48)!==0){let r=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(r);return}let i=(t[0]&64)===64;if(i&&!this._extensions[Na.extensionName]){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(!this._fragmented){let r=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let r=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(r);return}if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(r);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let r=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(r);return}}else{let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(r);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let r=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(r);return}}else if(this._masked){let r=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(r);return}this._payloadLength===126?this._state=Oa:this._payloadLength===127?this._state=Ta:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),i=t.readUInt32BE(0);if(i>Math.pow(2,21)-1){let r=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(r);return}this._payloadLength=i*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=Ia:this._state=ds}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ds}getData(e){let t=ka;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])!==0&&Pu(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=ps,this.decompress(t,e);return}if(t.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(t)}this.dataMessage(e)}decompress(e,t){this._extensions[Na.extensionName].decompress(e,this._fin,(r,s)=>{if(r)return t(r);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(o);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let o=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");t(o);return}this._fragments.push(s)}this.dataMessage(t),this._state===we&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=we;return}let t=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=fs(i,t):this._binaryType==="arraybuffer"?r=Iu(fs(i,t)):this._binaryType==="blob"?r=new Blob(i):r=i,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=we):(this._state=cr,setImmediate(()=>{this.emit("message",r,!0),this._state=we,this.startLoop(e)}))}else{let r=fs(i,t);if(!this._skipUTF8Validation&&!Ra(r)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===ps||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=we):(this._state=cr,setImmediate(()=>{this.emit("message",r,!1),this._state=we,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ka),this.end();else{let i=e.readUInt16BE(0);if(!Fu(i)){let s=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let r=new ar(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ra(r)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",i,r),this.end()}this._state=we;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=we):(this._state=cr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=we,this.startLoop(t)}))}createError(e,t,i,r,s){this._loop=!1,this._errored=!0;let o=new e(i?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=s,o[Ou]=r,o}};Pa.exports=ms});var bs=I((wg,Ua)=>{"use strict";var{Duplex:Cg}=T("stream"),{randomFillSync:Lu}=T("crypto"),{types:{isUint8Array:Uu}}=T("util"),Fa=Zt(),{EMPTY_BUFFER:Du,kWebSocket:Bu,NOOP:Mu}=Xe(),{isBlob:tn,isValidStatusCode:qu}=en(),{mask:La,toBuffer:kt}=Yn(),xe=Symbol("kByteLength"),Wu=Buffer.alloc(4),lr=8*1024,Rt,nn=lr,Pe=0,$u=1,Ku=2,ys=class n{constructor(e,t,i){this._extensions=t||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Pe,this.onerror=Mu,this[Bu]=void 0}static frame(e,t){let i,r=!1,s=2,o=!1;t.mask&&(i=t.maskBuffer||Wu,t.generateMask?t.generateMask(i):(nn===lr&&(Rt===void 0&&(Rt=Buffer.alloc(lr)),Lu(Rt,0,lr),nn=0),i[0]=Rt[nn++],i[1]=Rt[nn++],i[2]=Rt[nn++],i[3]=Rt[nn++]),o=(i[0]|i[1]|i[2]|i[3])===0,s=6);let c;typeof e=="string"?(!t.mask||o)&&t[xe]!==void 0?c=t[xe]:(e=Buffer.from(e),c=e.length):(c=e.length,r=t.mask&&t.readOnly&&!o);let u=c;c>=65536?(s+=8,u=127):c>125&&(s+=2,u=126);let h=Buffer.allocUnsafe(r?c+s:s);return h[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(h[0]|=64),h[1]=u,u===126?h.writeUInt16BE(c,2):u===127&&(h[2]=h[3]=0,h.writeUIntBE(c,4,6)),t.mask?(h[1]|=128,h[s-4]=i[0],h[s-3]=i[1],h[s-2]=i[2],h[s-1]=i[3],o?[h,e]:r?(La(e,i,h,s,c),[h]):(La(e,i,e,0,c),[h,e])):[h,e]}close(e,t,i,r){let s;if(e===void 0)s=Du;else{if(typeof e!="number"||!qu(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");if(s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(e,0),typeof t=="string")s.write(t,2);else if(Uu(t))s.set(t,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[xe]:s.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Pe?this.enqueue([this.dispatch,s,!1,o,r]):this.sendFrame(n.frame(s,o),r)}ping(e,t,i){let r,s;if(typeof e=="string"?(r=Buffer.byteLength(e),s=!1):tn(e)?(r=e.size,s=!1):(e=kt(e),r=e.length,s=kt.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};tn(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,!1,o,i]):this.getBlobData(e,!1,o,i):this._state!==Pe?this.enqueue([this.dispatch,e,!1,o,i]):this.sendFrame(n.frame(e,o),i)}pong(e,t,i){let r,s;if(typeof e=="string"?(r=Buffer.byteLength(e),s=!1):tn(e)?(r=e.size,s=!1):(e=kt(e),r=e.length,s=kt.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[xe]:r,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};tn(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,!1,o,i]):this.getBlobData(e,!1,o,i):this._state!==Pe?this.enqueue([this.dispatch,e,!1,o,i]):this.sendFrame(n.frame(e,o),i)}send(e,t,i){let r=this._extensions[Fa.extensionName],s=t.binary?2:1,o=t.compress,c,u;typeof e=="string"?(c=Buffer.byteLength(e),u=!1):tn(e)?(c=e.size,u=!1):(e=kt(e),c=e.length,u=kt.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=r._threshold),this._compress=o):(o=!1,s=0),t.fin&&(this._firstFragment=!0);let h={[xe]:c,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:u,rsv1:o};tn(e)?this._state!==Pe?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==Pe?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,t,i,r){this._bufferedBytes+=i[xe],this._state=Ku,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(vs,this,c,r);return}this._bufferedBytes-=i[xe];let o=kt(s);t?this.dispatch(o,t,i,r):(this._state=Pe,this.sendFrame(n.frame(o,i),r),this.dequeue())}).catch(s=>{process.nextTick(zu,this,s,r)})}dispatch(e,t,i,r){if(!t){this.sendFrame(n.frame(e,i),r);return}let s=this._extensions[Fa.extensionName];this._bufferedBytes+=i[xe],this._state=$u,s.compress(e,i.fin,(o,c)=>{if(this._socket.destroyed){let u=new Error("The socket was closed while data was being compressed");vs(this,u,r);return}this._bufferedBytes-=i[xe],this._state=Pe,i.readOnly=!1,this.sendFrame(n.frame(c,i),r),this.dequeue()})}dequeue(){for(;this._state===Pe&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][xe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][xe],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)}};Ua.exports=ys;function vs(n,e,t){typeof t=="function"&&t(e);for(let i=0;i<n._queue.length;i++){let r=n._queue[i],s=r[r.length-1];typeof s=="function"&&s(e)}}function zu(n,e,t){vs(n,e,t),n.onerror(e)}});var Ga=I((xg,za)=>{"use strict";var{kForOnEventAttribute:Xn,kListener:Ss}=Xe(),Da=Symbol("kCode"),Ba=Symbol("kData"),Ma=Symbol("kError"),qa=Symbol("kMessage"),Wa=Symbol("kReason"),rn=Symbol("kTarget"),$a=Symbol("kType"),Ka=Symbol("kWasClean"),Ze=class{constructor(e){this[rn]=null,this[$a]=e}get target(){return this[rn]}get type(){return this[$a]}};Object.defineProperty(Ze.prototype,"target",{enumerable:!0});Object.defineProperty(Ze.prototype,"type",{enumerable:!0});var Ot=class extends Ze{constructor(e,t={}){super(e),this[Da]=t.code===void 0?0:t.code,this[Wa]=t.reason===void 0?"":t.reason,this[Ka]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Da]}get reason(){return this[Wa]}get wasClean(){return this[Ka]}};Object.defineProperty(Ot.prototype,"code",{enumerable:!0});Object.defineProperty(Ot.prototype,"reason",{enumerable:!0});Object.defineProperty(Ot.prototype,"wasClean",{enumerable:!0});var sn=class extends Ze{constructor(e,t={}){super(e),this[Ma]=t.error===void 0?null:t.error,this[qa]=t.message===void 0?"":t.message}get error(){return this[Ma]}get message(){return this[qa]}};Object.defineProperty(sn.prototype,"error",{enumerable:!0});Object.defineProperty(sn.prototype,"message",{enumerable:!0});var Qn=class extends Ze{constructor(e,t={}){super(e),this[Ba]=t.data===void 0?null:t.data}get data(){return this[Ba]}};Object.defineProperty(Qn.prototype,"data",{enumerable:!0});var Gu={addEventListener(n,e,t={}){for(let r of this.listeners(n))if(!t[Xn]&&r[Ss]===e&&!r[Xn])return;let i;if(n==="message")i=function(s,o){let c=new Qn("message",{data:o?s:s.toString()});c[rn]=this,ur(e,this,c)};else if(n==="close")i=function(s,o){let c=new Ot("close",{code:s,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[rn]=this,ur(e,this,c)};else if(n==="error")i=function(s){let o=new sn("error",{error:s,message:s.message});o[rn]=this,ur(e,this,o)};else if(n==="open")i=function(){let s=new Ze("open");s[rn]=this,ur(e,this,s)};else return;i[Xn]=!!t[Xn],i[Ss]=e,t.once?this.once(n,i):this.on(n,i)},removeEventListener(n,e){for(let t of this.listeners(n))if(t[Ss]===e&&!t[Xn]){this.removeListener(n,t);break}}};za.exports={CloseEvent:Ot,ErrorEvent:sn,Event:Ze,EventTarget:Gu,MessageEvent:Qn};function ur(n,e,t){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,t):n.call(e,t)}});var hr=I((Ag,Va)=>{"use strict";var{tokenChars:Zn}=en();function Be(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}function Vu(n){let e=Object.create(null),t=Object.create(null),i=!1,r=!1,s=!1,o,c,u=-1,h=-1,l=-1,f=0;for(;f<n.length;f++)if(h=n.charCodeAt(f),o===void 0)if(l===-1&&Zn[h]===1)u===-1&&(u=f);else if(f!==0&&(h===32||h===9))l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let p=n.slice(u,l);h===44?(Be(e,p,t),t=Object.create(null)):o=p,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===void 0)if(l===-1&&Zn[h]===1)u===-1&&(u=f);else if(h===32||h===9)l===-1&&u!==-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f),Be(t,n.slice(u,l),!0),h===44&&(Be(e,o,t),t=Object.create(null),o=void 0),u=l=-1}else if(h===61&&u!==-1&&l===-1)c=n.slice(u,f),u=l=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(r){if(Zn[h]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1?u=f:i||(i=!0),r=!1}else if(s)if(Zn[h]===1)u===-1&&(u=f);else if(h===34&&u!==-1)s=!1,l=f;else if(h===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(h===34&&n.charCodeAt(f-1)===61)s=!0;else if(l===-1&&Zn[h]===1)u===-1&&(u=f);else if(u!==-1&&(h===32||h===9))l===-1&&(l=f);else if(h===59||h===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1&&(l=f);let p=n.slice(u,l);i&&(p=p.replace(/\\/g,""),i=!1),Be(t,c,p),h===44&&(Be(e,o,t),t=Object.create(null),o=void 0),c=void 0,u=l=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(u===-1||s||h===32||h===9)throw new SyntaxError("Unexpected end of input");l===-1&&(l=f);let m=n.slice(u,l);return o===void 0?Be(e,m,t):(c===void 0?Be(t,m,!0):i?Be(t,c,m.replace(/\\/g,"")):Be(t,c,m),Be(e,o,t)),e}function ju(n){return Object.keys(n).map(e=>{let t=n[e];return Array.isArray(t)||(t=[t]),t.map(i=>[e].concat(Object.keys(i).map(r=>{let s=i[r];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?r:`${r}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Va.exports={format:ju,parse:Vu}});var mr=I((Rg,rc)=>{"use strict";var Hu=T("events"),Yu=T("https"),Ju=T("http"),Ya=T("net"),Xu=T("tls"),{randomBytes:Qu,createHash:Zu}=T("crypto"),{Duplex:Ng,Readable:kg}=T("stream"),{URL:_s}=T("url"),vt=Zt(),eh=gs(),th=bs(),{isBlob:nh}=en(),{BINARY_TYPES:ja,CLOSE_TIMEOUT:ih,EMPTY_BUFFER:fr,GUID:rh,kForOnEventAttribute:Es,kListener:sh,kStatusCode:oh,kWebSocket:Q,NOOP:Ja}=Xe(),{EventTarget:{addEventListener:ah,removeEventListener:ch}}=Ga(),{format:lh,parse:uh}=hr(),{toBuffer:hh}=Yn(),Xa=Symbol("kAborted"),Cs=[8,13],et=["CONNECTING","OPEN","CLOSING","CLOSED"],fh=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,D=class n extends Hu{constructor(e,t,i){super(),this._binaryType=ja[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=fr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(i=t,t=[]):t=[t]),Qa(this,e,t,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){ja.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,i){let r=new eh({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),s=new th(e,this._extensions,i.generateMask);this._receiver=r,this._sender=s,this._socket=e,r[Q]=this,s[Q]=this,e[Q]=this,r.on("conclude",mh),r.on("drain",gh),r.on("error",yh),r.on("message",vh),r.on("ping",bh),r.on("pong",Sh),s.onerror=_h,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",tc),e.on("data",pr),e.on("end",nc),e.on("error",ic),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[vt.extensionName]&&this._extensions[vt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ge(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,t,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ec(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,i){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ws(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||fr,t,i)}pong(e,t,i){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ws(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||fr,t,i)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,i){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(i=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ws(this,e,i);return}let r=y({binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0},t);this._extensions[vt.extensionName]||(r.compress=!1),this._sender.send(e||fr,r,i)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ge(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:et.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:et.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:et.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:et.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:et.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:et.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:et.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:et.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(D.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(D.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Es])return e[sh];return null},set(e){for(let t of this.listeners(n))if(t[Es]){this.removeListener(n,t);break}typeof e=="function"&&this.addEventListener(n,e,{[Es]:!0})}})});D.prototype.addEventListener=ah;D.prototype.removeEventListener=ch;rc.exports=D;function Qa(n,e,t,i){let r=x(y({allowSynchronousEvents:!0,autoPong:!0,closeTimeout:ih,protocolVersion:Cs[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},i),{socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0});if(n._autoPong=r.autoPong,n._closeTimeout=r.closeTimeout,!Cs.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${Cs.join(", ")})`);let s;if(e instanceof _s)s=e;else try{s=new _s(e)}catch(g){throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),n._url=s.href;let o=s.protocol==="wss:",c=s.protocol==="ws+unix:",u;if(s.protocol!=="ws:"&&!o&&!c?u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!s.pathname?u="The URL's pathname is empty":s.hash&&(u="The URL contains a fragment identifier"),u){let g=new SyntaxError(u);if(n._redirects===0)throw g;dr(n,g);return}let h=o?443:80,l=Qu(16).toString("base64"),f=o?Yu.request:Ju.request,m=new Set,p;if(r.createConnection=r.createConnection||(o?ph:dh),r.defaultPort=r.defaultPort||h,r.port=s.port||h,r.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,r.headers=x(y({},r.headers),{"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"}),r.path=s.pathname+s.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(p=new vt(x(y({},r.perMessageDeflate),{isServer:!1,maxPayload:r.maxPayload})),r.headers["Sec-WebSocket-Extensions"]=lh({[vt.extensionName]:p.offer()})),t.length){for(let g of t){if(typeof g!="string"||!fh.test(g)||m.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(g)}r.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(s.username||s.password)&&(r.auth=`${s.username}:${s.password}`),c){let g=r.path.split(":");r.socketPath=g[0],r.path=g[1]}let w;if(r.followRedirects){if(n._redirects===0){n._originalIpc=c,n._originalSecure=o,n._originalHostOrSocketPath=c?r.socketPath:s.host;let g=i&&i.headers;if(i=x(y({},i),{headers:{}}),g)for(let[S,R]of Object.entries(g))i.headers[S.toLowerCase()]=R}else if(n.listenerCount("redirect")===0){let g=c?n._originalIpc?r.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:s.host===n._originalHostOrSocketPath;(!g||n._originalSecure&&!o)&&(delete r.headers.authorization,delete r.headers.cookie,g||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),w=n._req=f(r),n._redirects&&n.emit("redirect",n.url,w)}else w=n._req=f(r);r.timeout&&w.on("timeout",()=>{ge(n,w,"Opening handshake has timed out")}),w.on("error",g=>{w===null||w[Xa]||(w=n._req=null,dr(n,g))}),w.on("response",g=>{let S=g.headers.location,R=g.statusCode;if(S&&r.followRedirects&&R>=300&&R<400){if(++n._redirects>r.maxRedirects){ge(n,w,"Maximum redirects exceeded");return}w.abort();let N;try{N=new _s(S,e)}catch(_){let C=new SyntaxError(`Invalid URL: ${S}`);dr(n,C);return}Qa(n,N,t,i)}else n.emit("unexpected-response",w,g)||ge(n,w,`Unexpected server response: ${g.statusCode}`)}),w.on("upgrade",(g,S,R)=>{if(n.emit("upgrade",g),n.readyState!==D.CONNECTING)return;w=n._req=null;let N=g.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){ge(n,S,"Invalid Upgrade header");return}let _=Zu("sha1").update(l+rh).digest("base64");if(g.headers["sec-websocket-accept"]!==_){ge(n,S,"Invalid Sec-WebSocket-Accept header");return}let C=g.headers["sec-websocket-protocol"],M;if(C!==void 0?m.size?m.has(C)||(M="Server sent an invalid subprotocol"):M="Server sent a subprotocol but none was requested":m.size&&(M="Server sent no subprotocol"),M){ge(n,S,M);return}C&&(n._protocol=C);let O=g.headers["sec-websocket-extensions"];if(O!==void 0){if(!p){ge(n,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let F;try{F=uh(O)}catch(te){ge(n,S,"Invalid Sec-WebSocket-Extensions header");return}let $=Object.keys(F);if($.length!==1||$[0]!==vt.extensionName){ge(n,S,"Server indicated an extension that was not requested");return}try{p.accept(F[vt.extensionName])}catch(te){ge(n,S,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[vt.extensionName]=p}n.setSocket(S,R,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})}),r.finishRequest?r.finishRequest(w,n):w.end()}function dr(n,e){n._readyState=D.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function dh(n){return n.path=n.socketPath,Ya.connect(n)}function ph(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Ya.isIP(n.host)?"":n.host),Xu.connect(n)}function ge(n,e,t){n._readyState=D.CLOSING;let i=new Error(t);Error.captureStackTrace(i,ge),e.setHeader?(e[Xa]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(dr,n,i)):(e.destroy(i),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function ws(n,e,t){if(e){let i=nh(e)?e.size:hh(e).length;n._socket?n._sender._bufferedBytes+=i:n._bufferedAmount+=i}if(t){let i=new Error(`WebSocket is not open: readyState ${n.readyState} (${et[n.readyState]})`);process.nextTick(t,i)}}function mh(n,e){let t=this[Q];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=n,t._socket[Q]!==void 0&&(t._socket.removeListener("data",pr),process.nextTick(Za,t._socket),n===1005?t.close():t.close(n,e))}function gh(){let n=this[Q];n.isPaused||n._socket.resume()}function yh(n){let e=this[Q];e._socket[Q]!==void 0&&(e._socket.removeListener("data",pr),process.nextTick(Za,e._socket),e.close(n[oh])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Ha(){this[Q].emitClose()}function vh(n,e){this[Q].emit("message",n,e)}function bh(n){let e=this[Q];e._autoPong&&e.pong(n,!this._isServer,Ja),e.emit("ping",n)}function Sh(n){this[Q].emit("pong",n)}function Za(n){n.resume()}function _h(n){let e=this[Q];e.readyState!==D.CLOSED&&(e.readyState===D.OPEN&&(e._readyState=D.CLOSING,ec(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function ec(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function tc(){let n=this[Q];if(this.removeListener("close",tc),this.removeListener("data",pr),this.removeListener("end",nc),n._readyState=D.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[Q]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Ha),n._receiver.on("finish",Ha))}function pr(n){this[Q]._receiver.write(n)||this.pause()}function nc(){let n=this[Q];n._readyState=D.CLOSING,n._receiver.end(),this.end()}function ic(){let n=this[Q];this.removeListener("error",ic),this.on("error",Ja),n&&(n._readyState=D.CLOSING,this.destroy())}});var cc=I((Ig,ac)=>{"use strict";var Tg=mr(),{Duplex:Eh}=T("stream");function sc(n){n.emit("close")}function Ch(){!this.destroyed&&this._writableState.finished&&this.destroy()}function oc(n){this.removeListener("error",oc),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function wh(n,e){let t=!0,i=new Eh(x(y({},e),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return n.on("message",function(s,o){let c=!o&&i._readableState.objectMode?s.toString():s;i.push(c)||n.pause()}),n.once("error",function(s){i.destroyed||(t=!1,i.destroy(s))}),n.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(r,s){if(n.readyState===n.CLOSED){s(r),process.nextTick(sc,i);return}let o=!1;n.once("error",function(u){o=!0,s(u)}),n.once("close",function(){o||s(r),process.nextTick(sc,i)}),t&&n.terminate()},i._final=function(r){if(n.readyState===n.CONNECTING){n.once("open",function(){i._final(r)});return}n._socket!==null&&(n._socket._writableState.finished?(r(),i._readableState.endEmitted&&i.destroy()):(n._socket.once("finish",function(){r()}),n.close()))},i._read=function(){n.isPaused&&n.resume()},i._write=function(r,s,o){if(n.readyState===n.CONNECTING){n.once("open",function(){i._write(r,s,o)});return}n.send(r,o)},i.on("end",Ch),i.on("error",oc),i}ac.exports=wh});var xs=I((Fg,lc)=>{"use strict";var{tokenChars:xh}=en();function Ah(n){let e=new Set,t=-1,i=-1,r=0;for(r;r<n.length;r++){let o=n.charCodeAt(r);if(i===-1&&xh[o]===1)t===-1&&(t=r);else if(r!==0&&(o===32||o===9))i===-1&&t!==-1&&(i=r);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${r}`);i===-1&&(i=r);let c=n.slice(t,i);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),t=i=-1}else throw new SyntaxError(`Unexpected character at index ${r}`)}if(t===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let s=n.slice(t,r);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}lc.exports={parse:Ah}});var gc=I((Ug,mc)=>{"use strict";var Nh=T("events"),gr=T("http"),{Duplex:Lg}=T("stream"),{createHash:kh}=T("crypto"),uc=hr(),Tt=Zt(),Rh=xs(),Oh=mr(),{CLOSE_TIMEOUT:Th,GUID:Ih,kWebSocket:Ph}=Xe(),Fh=/^[+/0-9A-Za-z]{22}==$/,hc=0,fc=1,pc=2,As=class extends Nh{constructor(e,t){if(super(),e=y({allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Th,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Oh},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=gr.createServer((i,r)=>{let s=gr.STATUS_CODES[426];r.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),r.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=Lh(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,s,o)=>{this.handleUpgrade(r,s,o,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=hc}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===pc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ei,this);return}if(e&&this.once("close",e),this._state!==fc)if(this._state=fc,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(ei,this):process.nextTick(ei,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ei(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,i,r){t.on("error",dc);let s=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){It(this,e,t,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){It(this,e,t,400,"Invalid Upgrade header");return}if(s===void 0||!Fh.test(s)){It(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){It(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ti(t,400);return}let u=e.headers["sec-websocket-protocol"],h=new Set;if(u!==void 0)try{h=Rh.parse(u)}catch(m){It(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&l!==void 0){let m=new Tt(x(y({},this.options.perMessageDeflate),{isServer:!0,maxPayload:this.options.maxPayload}));try{let p=uc.parse(l);p[Tt.extensionName]&&(m.accept(p[Tt.extensionName]),f[Tt.extensionName]=m)}catch(p){It(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:e.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(p,w,g,S)=>{if(!p)return ti(t,w||401,g,S);this.completeUpgrade(f,s,h,e,t,i,r)});return}if(!this.options.verifyClient(m))return ti(t,401)}this.completeUpgrade(f,s,h,e,t,i,r)}completeUpgrade(e,t,i,r,s,o,c){if(!s.readable||!s.writable)return s.destroy();if(s[Ph])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>hc)return ti(s,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${kh("sha1").update(t+Ih).digest("base64")}`],l=new this.options.WebSocket(null,void 0,this.options);if(i.size){let f=this.options.handleProtocols?this.options.handleProtocols(i,r):i.values().next().value;f&&(h.push(`Sec-WebSocket-Protocol: ${f}`),l._protocol=f)}if(e[Tt.extensionName]){let f=e[Tt.extensionName].params,m=uc.format({[Tt.extensionName]:[f]});h.push(`Sec-WebSocket-Extensions: ${m}`),l._extensions=e}this.emit("headers",h,r),s.write(h.concat(`\r
|
|
7
7
|
`).join(`\r
|
|
8
|
-
`)),s.removeListener("error",
|
|
8
|
+
`)),s.removeListener("error",dc),l.setSocket(s,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(l),l.on("close",()=>{this.clients.delete(l),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ei,this)})),c(l,r)}};mc.exports=As;function Lh(n,e){for(let t of Object.keys(e))n.on(t,e[t]);return function(){for(let i of Object.keys(e))n.removeListener(i,e[i])}}function ei(n){n._state=pc,n.emit("close")}function dc(){this.destroy()}function ti(n,e,t,i){t=t||gr.STATUS_CODES[e],i=y({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t)},i),n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${gr.STATUS_CODES[e]}\r
|
|
9
9
|
`+Object.keys(i).map(r=>`${r}: ${i[r]}`).join(`\r
|
|
10
10
|
`)+`\r
|
|
11
11
|
\r
|
|
12
|
-
`+t)}function
|
|
12
|
+
`+t)}function It(n,e,t,i,r,s){if(n.listenerCount("wsClientError")){let o=new Error(r);Error.captureStackTrace(o,It),n.emit("wsClientError",o,t,e)}else ti(t,i,r,s)}});var ks=I((vy,wc)=>{"use strict";function Hh(n){t.debug=t,t.default=t,t.coerce=u,t.disable=s,t.enable=r,t.enabled=o,t.humanize=Yr(),t.destroy=h,Object.keys(n).forEach(l=>{t[l]=n[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,p,w;function g(...S){if(!g.enabled)return;let R=g,N=Number(new Date),_=N-(f||N);R.diff=_,R.prev=f,R.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let C=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(O,F)=>{if(O==="%%")return"%";C++;let $=t.formatters[F];if(typeof $=="function"){let te=S[C];O=$.call(R,te),S.splice(C,1),C--}return O}),t.formatArgs.call(R,S),(R.log||t.log).apply(R,S)}return g.namespace=l,g.useColors=t.useColors(),g.color=t.selectColor(l),g.extend=i,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(p!==t.namespaces&&(p=t.namespaces,w=t.enabled(l)),w),set:S=>{m=S}}),typeof t.init=="function"&&t.init(g),g}function i(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,m=(typeof l=="string"?l:"").split(/[\s,]+/),p=m.length;for(f=0;f<p;f++)m[f]&&(l=m[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.slice(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,m;for(f=0,m=t.skips.length;f<m;f++)if(t.skips[f].test(l))return!1;for(f=0,m=t.names.length;f<m;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack||l.message:l}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}wc.exports=Hh});var xc=I((ye,Sr)=>{"use strict";ye.formatArgs=Jh;ye.save=Xh;ye.load=Qh;ye.useColors=Yh;ye.storage=Zh();ye.destroy=(()=>{let n=!1;return()=>{n||(n=!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`."))}})();ye.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 Yh(){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 Jh(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+Sr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;n.splice(1,0,e,"color: inherit");let t=0,i=0;n[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(i=t))}),n.splice(i,0,e)}ye.log=console.debug||console.log||(()=>{});function Xh(n){try{n?ye.storage.setItem("debug",n):ye.storage.removeItem("debug")}catch(e){}}function Qh(){let n;try{n=ye.storage.getItem("debug")}catch(e){}return!n&&typeof process!="undefined"&&"env"in process&&(n=process.env.DEBUG),n}function Zh(){try{return localStorage}catch(n){}}Sr.exports=ks()(ye);var{formatters:ef}=Sr.exports;ef.j=function(n){try{return JSON.stringify(n)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Nc=I((Z,Er)=>{"use strict";var tf=T("tty"),_r=T("util");Z.init=lf;Z.log=of;Z.formatArgs=rf;Z.save=af;Z.load=cf;Z.useColors=nf;Z.destroy=_r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Z.colors=[6,2,3,4,5,1];try{let n=Xi();n&&(n.stderr||n).level>=2&&(Z.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(n){}Z.inspectOpts=Object.keys(process.env).filter(n=>/^debug_/i.test(n)).reduce((n,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,s)=>s.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),n[t]=i,n},{});function nf(){return"colors"in Z.inspectOpts?!!Z.inspectOpts.colors:tf.isatty(process.stderr.fd)}function rf(n){let{namespace:e,useColors:t}=this;if(t){let i=this.color,r="\x1B[3"+(i<8?i:"8;5;"+i),s=` ${r};1m${e} \x1B[0m`;n[0]=s+n[0].split(`
|
|
13
13
|
`).join(`
|
|
14
|
-
`+s),n.push(r+"m+"+
|
|
15
|
-
`)}function
|
|
16
|
-
`).map(e=>e.trim()).join(" ")};
|
|
14
|
+
`+s),n.push(r+"m+"+Er.exports.humanize(this.diff)+"\x1B[0m")}else n[0]=sf()+e+" "+n[0]}function sf(){return Z.inspectOpts.hideDate?"":new Date().toISOString()+" "}function of(...n){return process.stderr.write(_r.formatWithOptions(Z.inspectOpts,...n)+`
|
|
15
|
+
`)}function af(n){n?process.env.DEBUG=n:delete process.env.DEBUG}function cf(){return process.env.DEBUG}function lf(n){n.inspectOpts={};let e=Object.keys(Z.inspectOpts);for(let t=0;t<e.length;t++)n.inspectOpts[e[t]]=Z.inspectOpts[e[t]]}Er.exports=ks()(Z);var{formatters:Ac}=Er.exports;Ac.o=function(n){return this.inspectOpts.colors=this.useColors,_r.inspect(n,this.inspectOpts).split(`
|
|
16
|
+
`).map(e=>e.trim()).join(" ")};Ac.O=function(n){return this.inspectOpts.colors=this.useColors,_r.inspect(n,this.inspectOpts)}});var ri=I((by,Rs)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Rs.exports=xc():Rs.exports=Nc()});var Lc=I((xy,Fc)=>{"use strict";var an=1e3,cn=an*60,ln=cn*60,Lt=ln*24,pf=Lt*7,mf=Lt*365.25;Fc.exports=function(n,e){e=e||{};var t=typeof n;if(t==="string"&&n.length>0)return gf(n);if(t==="number"&&isFinite(n))return e.long?vf(n):yf(n);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(n))};function gf(n){if(n=String(n),!(n.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(n);if(e){var t=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return t*mf;case"weeks":case"week":case"w":return t*pf;case"days":case"day":case"d":return t*Lt;case"hours":case"hour":case"hrs":case"hr":case"h":return t*ln;case"minutes":case"minute":case"mins":case"min":case"m":return t*cn;case"seconds":case"second":case"secs":case"sec":case"s":return t*an;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function yf(n){var e=Math.abs(n);return e>=Lt?Math.round(n/Lt)+"d":e>=ln?Math.round(n/ln)+"h":e>=cn?Math.round(n/cn)+"m":e>=an?Math.round(n/an)+"s":n+"ms"}function vf(n){var e=Math.abs(n);return e>=Lt?Cr(n,e,Lt,"day"):e>=ln?Cr(n,e,ln,"hour"):e>=cn?Cr(n,e,cn,"minute"):e>=an?Cr(n,e,an,"second"):n+" ms"}function Cr(n,e,t,i){var r=e>=t*1.5;return Math.round(n/t)+" "+i+(r?"s":"")}});var Is=I((Ay,Uc)=>{"use strict";function bf(n){t.debug=t,t.default=t,t.coerce=u,t.disable=o,t.enable=r,t.enabled=c,t.humanize=Lc(),t.destroy=h,Object.keys(n).forEach(l=>{t[l]=n[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let m=0;m<l.length;m++)f=(f<<5)-f+l.charCodeAt(m),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,m=null,p,w;function g(...S){if(!g.enabled)return;let R=g,N=Number(new Date),_=N-(f||N);R.diff=_,R.prev=f,R.curr=N,f=N,S[0]=t.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let C=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(O,F)=>{if(O==="%%")return"%";C++;let $=t.formatters[F];if(typeof $=="function"){let te=S[C];O=$.call(R,te),S.splice(C,1),C--}return O}),t.formatArgs.call(R,S),(R.log||t.log).apply(R,S)}return g.namespace=l,g.useColors=t.useColors(),g.color=t.selectColor(l),g.extend=i,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(p!==t.namespaces&&(p=t.namespaces,w=t.enabled(l)),w),set:S=>{m=S}}),typeof t.init=="function"&&t.init(g),g}function i(l,f){let m=t(this.namespace+(typeof f=="undefined"?":":f)+l);return m.log=this.log,m}function r(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let m of f)m[0]==="-"?t.skips.push(m.slice(1)):t.names.push(m)}function s(l,f){let m=0,p=0,w=-1,g=0;for(;m<l.length;)if(p<f.length&&(f[p]===l[m]||f[p]==="*"))f[p]==="*"?(w=p,g=m,p++):(m++,p++);else if(w!==-1)p=w+1,g++,m=g;else return!1;for(;p<f.length&&f[p]==="*";)p++;return p===f.length}function o(){let l=[...t.names,...t.skips.map(f=>"-"+f)].join(",");return t.enable(""),l}function c(l){for(let f of t.skips)if(s(l,f))return!1;for(let f of t.names)if(s(l,f))return!0;return!1}function u(l){return l instanceof Error?l.stack||l.message:l}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Uc.exports=bf});var Dc=I((de,wr)=>{"use strict";de.formatArgs=_f;de.save=Ef;de.load=Cf;de.useColors=Sf;de.storage=wf();de.destroy=(()=>{let n=!1;return()=>{n||(n=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();de.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Sf(){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 n;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&&(n=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(n[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function _f(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+wr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;n.splice(1,0,e,"color: inherit");let t=0,i=0;n[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(i=t))}),n.splice(i,0,e)}de.log=console.debug||console.log||(()=>{});function Ef(n){try{n?de.storage.setItem("debug",n):de.storage.removeItem("debug")}catch(e){}}function Cf(){let n;try{n=de.storage.getItem("debug")||de.storage.getItem("DEBUG")}catch(e){}return!n&&typeof process!="undefined"&&"env"in process&&(n=process.env.DEBUG),n}function wf(){try{return localStorage}catch(n){}}wr.exports=Is()(de);var{formatters:xf}=wr.exports;xf.j=function(n){try{return JSON.stringify(n)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Mc=I((ee,Ar)=>{"use strict";var Af=T("tty"),xr=T("util");ee.init=Pf;ee.log=Of;ee.formatArgs=kf;ee.save=Tf;ee.load=If;ee.useColors=Nf;ee.destroy=xr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");ee.colors=[6,2,3,4,5,1];try{let n=Xi();n&&(n.stderr||n).level>=2&&(ee.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(n){}ee.inspectOpts=Object.keys(process.env).filter(n=>/^debug_/i.test(n)).reduce((n,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,s)=>s.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),n[t]=i,n},{});function Nf(){return"colors"in ee.inspectOpts?!!ee.inspectOpts.colors:Af.isatty(process.stderr.fd)}function kf(n){let{namespace:e,useColors:t}=this;if(t){let i=this.color,r="\x1B[3"+(i<8?i:"8;5;"+i),s=` ${r};1m${e} \x1B[0m`;n[0]=s+n[0].split(`
|
|
17
17
|
`).join(`
|
|
18
|
-
`+s),n.push(r+"m+"+
|
|
19
|
-
`)}function
|
|
20
|
-
`).map(e=>e.trim()).join(" ")};Oc.O=function(n){return this.inspectOpts.colors=this.useColors,_r.inspect(n,this.inspectOpts)}});var Ic=I((gy,Rs)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Rs.exports=Rc():Rs.exports=Tc()});var nl=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,ui=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t="v1",apiUrl:i=this.DEFAULT_BACKEND_URL,headers:r={}}=e||{};this.apiVersion=t,this.apiUrl=`${i}/${t}`,this.headers=y({"Novu-API-Version":NOVU_API_VERSION,"Novu-Client-Version":nl,"Content-Type":"application/json"},r)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var i;let t=e||typeof window!="undefined"&&((i=window.localStorage)==null?void 0:i.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=y(y({},this.headers),e)}get(e,t,i=!0){return p(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:i})})}post(e,t,i){return p(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:i==null?void 0:i.headers}})})}patch(e,t){return p(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return p(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return p(this,arguments,function*({path:e,searchParams:t,options:i,unwrapEnvelope:r=!0}){let o=il(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(i==null?void 0:i.method)||"GET",headers:y(y({},this.headers),(i==null?void 0:i.headers)||{}),body:i!=null&&i.body?JSON.stringify(i.body):void 0},u=yield fetch(o,c);if(!u.ok){let l=yield u.json();throw new Error(`${this.headers["Novu-Client-Version"]} error. Status: ${u.status}, Message: ${l.message}`)}if(u.status===204)return;let h=yield u.json();return r?h.data:h})}};function il(...n){return n.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var ne="/inbox",ce=`${ne}/notifications`,rl=`${ne}/chat/oauth`,hn=`${ne}/channel-connections`,sl=`${hn}/oauth`,fn=`${ne}/channel-endpoints`,ol=`${fn}/oauth`;function qs(n){let e=new URLSearchParams;if(n.subscriberId&&e.append("subscriberId",n.subscriberId),n.integrationIdentifier&&e.append("integrationIdentifier",n.integrationIdentifier),n.connectionIdentifier&&e.append("connectionIdentifier",n.connectionIdentifier),n.channel&&e.append("channel",n.channel),n.providerId&&e.append("providerId",n.providerId),n.contextKeys!==void 0)if(n.contextKeys.length===0)e.append("contextKeys","");else for(let t of n.contextKeys)e.append("contextKeys",t);return n.limit&&e.append("limit",String(n.limit)),n.after&&e.append("after",n.after),n.before&&e.append("before",n.before),e.size?`?${e.toString()}`:""}function al(n,e){if(e!==void 0){if(Array.isArray(e)){if(e.length===0)return;for(let t of e)n.append("tags[]",t);return}if("or"in e){if(e.or.length===0)return;for(let t of e.or)n.append("tags[]",t);return}if("and"in e){if(e.and.length===0)return;e.and.forEach((t,i)=>{for(let r of t.or)n.append(`tags[${i}][]`,r)})}}}var A,hi=class{constructor(e={}){this.isSessionInitialized=!1;v(this,A);b(this,A,new ui(e))}initializeSession(c){return p(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:i,subscriber:r,defaultSchedule:s,context:o}){let u=yield a(this,A).post(`${ne}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:i,subscriber:r,defaultSchedule:s,context:o});return a(this,A).setAuthorizationToken(u.token),a(this,A).setKeylessHeader(u.applicationIdentifier),this.isSessionInitialized=!0,u})}fetchNotifications({after:e,archived:t,limit:i=10,offset:r,read:s,tags:o,snoozed:c,seen:u,data:h,severity:l,createdGte:f,createdLte:m}){let d=new URLSearchParams(`limit=${i}`);if(e&&d.append("after",e),r&&d.append("offset",`${r}`),al(d,o),s!==void 0&&d.append("read",`${s}`),t!==void 0&&d.append("archived",`${t}`),c!==void 0&&d.append("snoozed",`${c}`),u!==void 0&&d.append("seen",`${u}`),h!==void 0&&d.append("data",JSON.stringify(h)),l&&Array.isArray(l))for(let w of l)d.append("severity[]",w);else l&&d.append("severity",l);return f&&d.append("createdGte",`${f}`),m&&d.append("createdLte",`${m}`),a(this,A).get(ce,d,!1)}count({filters:e}){return a(this,A).get(`${ce}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,A).patch(`${ce}/${e}/read`)}unread(e){return a(this,A).patch(`${ce}/${e}/unread`)}archive(e){return a(this,A).patch(`${ce}/${e}/archive`)}unarchive(e){return a(this,A).patch(`${ce}/${e}/unarchive`)}snooze(e,t){return a(this,A).patch(`${ce}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,A).patch(`${ce}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,A).post(`${ce}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,A).post(`${ce}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,A).post(`${ce}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,A).delete(`${ce}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,A).post(`${ce}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:i}){return a(this,A).post(`${ce}/seen`,{notificationIds:e,tags:t,data:i?JSON.stringify(i):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return a(this,A).patch(`${ce}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,A).patch(`${ce}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:i}){let r=new URLSearchParams;if(e)for(let o of e)r.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)r.append("severity[]",o);else t&&r.append("severity",t);i&&r.append("criticality",i);let s=r.size?`?${r.toString()}`:"";return a(this,A).get(`${ne}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,A).patch(`${ne}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,A).patch(`${ne}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,A).patch(`${ne}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,A).get(`${ne}/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,A).post("/inbox/events",e)}fetchSubscriptions(e){return a(this,A).get(`${ne}/topics/${e}/subscriptions`)}getSubscription(e,t,i,r){let s=new URLSearchParams;if(i!=null&&i.length)for(let c of i)s.append("workflowIds",c);if(r!=null&&r.length)for(let c of r)s.append("tags",c);let o=s.size?`?${s.toString()}`:"";return a(this,A).get(`${ne}/topics/${e}/subscriptions/${t}${o}`)}createSubscription({identifier:e,name:t,topicKey:i,topicName:r,preferences:s}){return a(this,A).post(`${ne}/topics/${i}/subscriptions`,y(y({identifier:e,name:t},r&&{topic:{name:r}}),s!==void 0&&{preferences:s}))}updateSubscription({topicKey:e,identifier:t,name:i,preferences:r}){return a(this,A).patch(`${ne}/topics/${e}/subscriptions/${t}`,y({name:i},r!==void 0&&{preferences:r}))}updateSubscriptionPreference({subscriptionIdentifier:e,workflowId:t,enabled:i,condition:r,email:s,sms:o,in_app:c,chat:u,push:h}){return a(this,A).patch(`${ne}/subscriptions/${e}/preferences/${t}`,{enabled:i,condition:r,email:s,sms:o,in_app:c,chat:u,push:h})}bulkUpdateSubscriptionPreferences(e){return a(this,A).patch(`${ne}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,identifier:t}){return a(this,A).delete(`${ne}/topics/${e}/subscriptions/${t}`)}generateChatOAuthUrl({integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,userScope:o,mode:c,connectionMode:u,autoLinkUser:h}){return a(this,A).post(rl,{integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,userScope:o,mode:c,connectionMode:u,autoLinkUser:h})}generateConnectOAuthUrl({integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,connectionMode:o,autoLinkUser:c}){return a(this,A).post(sl,{integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,connectionMode:o,autoLinkUser:c})}generateLinkUserOAuthUrl({integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,userScope:s}){return a(this,A).post(ol,{integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,userScope:s})}listChannelConnections(e={}){let t=qs(e);return a(this,A).get(`${hn}${t}`,void 0,!1)}getChannelConnection(e){return a(this,A).get(`${hn}/${e}`)}createChannelConnection({identifier:e,integrationIdentifier:t,subscriberId:i,context:r,workspace:s,auth:o}){return a(this,A).post(hn,{identifier:e,integrationIdentifier:t,subscriberId:i,context:r,workspace:s,auth:o})}deleteChannelConnection(e){return a(this,A).delete(`${hn}/${e}`)}listChannelEndpoints(e={}){let t=qs(e);return a(this,A).get(`${fn}${t}`,void 0,!1)}getChannelEndpoint(e){return a(this,A).get(`${fn}/${e}`)}createChannelEndpoint({identifier:e,integrationIdentifier:t,connectionIdentifier:i,subscriberId:r,context:s,type:o,endpoint:c}){return a(this,A).post(fn,{identifier:e,integrationIdentifier:t,connectionIdentifier:i,subscriberId:r,context:s,type:o,endpoint:c})}deleteChannelEndpoint(e){return a(this,A).delete(`${fn}/${e}`)}};A=new WeakMap;var E=class extends Error{constructor(e,t){super(e),this.originalError=t}};var st,Lt,V=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){v(this,st,[]);v(this,Lt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:i,data:r})=>{r?(this.onSessionSuccess(r),a(this,st).forEach(c=>p(this,[c],function*({fn:s,resolve:o}){o(yield s())})),b(this,st,[])):i&&(this.onSessionError(i),b(this,Lt,i),a(this,st).forEach(({resolve:s})=>{s({error:new E("Failed to initialize session, please contact the support",i)})}),b(this,st,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return p(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,Lt)?Promise.resolve({error:new E("Failed to initialize session, please contact the support",a(this,Lt))}):new Promise((t,i)=>{a(this,st).push({fn:e,resolve:t,reject:i})})})}};st=new WeakMap,Lt=new WeakMap;var Ws=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connection.oauth-url.pending",{args:t});let r=yield e.generateChatOAuthUrl(t);return n.emit("channel-connection.oauth-url.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-connection.oauth-url.resolved",{args:t,error:r}),{error:new E("Failed to generate chat OAuth URL",r)}}}),$s=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connection.oauth-url.pending",{args:t});let r=yield e.generateConnectOAuthUrl(t);return n.emit("channel-connection.oauth-url.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-connection.oauth-url.resolved",{args:t,error:r}),{error:new E("Failed to generate connect OAuth URL",r)}}}),Ks=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connections.list.pending",{args:t});let s=(yield e.listChannelConnections(t)).data;return n.emit("channel-connections.list.resolved",{args:t,data:s}),{data:s}}catch(r){return n.emit("channel-connections.list.resolved",{args:t,error:r}),{error:new E("Failed to list channel connections",r)}}}),zs=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connection.get.pending",{args:t});let r=yield e.getChannelConnection(t.identifier);return n.emit("channel-connection.get.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-connection.get.resolved",{args:t,error:r}),{error:new E("Failed to get channel connection",r)}}}),Gs=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{return n.emit("channel-connection.delete.pending",{args:t}),yield e.deleteChannelConnection(t.identifier),n.emit("channel-connection.delete.resolved",{args:t}),{data:void 0}}catch(r){return n.emit("channel-connection.delete.resolved",{args:t,error:r}),{error:new E("Failed to delete channel connection",r)}}});var dn=class extends V{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){super({inboxServiceInstance:e,eventEmitterInstance:t})}generateOAuthUrl(e){return p(this,null,function*(){return this.callWithSession(()=>Ws({emitter:this._emitter,apiService:this._inboxService,args:e}))})}generateConnectOAuthUrl(e){return p(this,null,function*(){return this.callWithSession(()=>$s({emitter:this._emitter,apiService:this._inboxService,args:e}))})}list(){return p(this,arguments,function*(e={}){return this.callWithSession(()=>Ks({emitter:this._emitter,apiService:this._inboxService,args:e}))})}get(e){return p(this,null,function*(){return this.callWithSession(()=>zs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}delete(e){return p(this,null,function*(){return this.callWithSession(()=>Gs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}};var js=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoint.oauth-url.pending",{args:t});let r=yield e.generateLinkUserOAuthUrl(t);return n.emit("channel-endpoint.oauth-url.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-endpoint.oauth-url.resolved",{args:t,error:r}),{error:new E("Failed to generate link user OAuth URL",r)}}}),Vs=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoints.list.pending",{args:t});let s=(yield e.listChannelEndpoints(t)).data;return n.emit("channel-endpoints.list.resolved",{args:t,data:s}),{data:s}}catch(r){return n.emit("channel-endpoints.list.resolved",{args:t,error:r}),{error:new E("Failed to list channel endpoints",r)}}}),Hs=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoint.get.pending",{args:t});let r=yield e.getChannelEndpoint(t.identifier);return n.emit("channel-endpoint.get.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-endpoint.get.resolved",{args:t,error:r}),{error:new E("Failed to get channel endpoint",r)}}}),Ys=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoint.create.pending",{args:t});let r=yield e.createChannelEndpoint(t);return n.emit("channel-endpoint.create.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-endpoint.create.resolved",{args:t,error:r}),{error:new E("Failed to create channel endpoint",r)}}}),Js=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){try{return n.emit("channel-endpoint.delete.pending",{args:t}),yield e.deleteChannelEndpoint(t.identifier),n.emit("channel-endpoint.delete.resolved",{args:t}),{data:void 0}}catch(r){return n.emit("channel-endpoint.delete.resolved",{args:t,error:r}),{error:new E("Failed to delete channel endpoint",r)}}});var pn=class extends V{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){super({inboxServiceInstance:e,eventEmitterInstance:t})}generateLinkUserOAuthUrl(e){return p(this,null,function*(){return this.callWithSession(()=>js({emitter:this._emitter,apiService:this._inboxService,args:e}))})}list(){return p(this,arguments,function*(e={}){return this.callWithSession(()=>Vs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}get(e){return p(this,null,function*(){return this.callWithSession(()=>Hs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}create(e){return p(this,null,function*(){return this.callWithSession(()=>Ys({emitter:this._emitter,apiService:this._inboxService,args:e}))})}delete(e){return p(this,null,function*(){return this.callWithSession(()=>Js({emitter:this._emitter,apiService:this._inboxService,args:e}))})}};function Xs(n){return{all:n=n||new Map,on:function(e,t){var i=n.get(e);i?i.push(t):n.set(e,[t])},off:function(e,t){var i=n.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var i=n.get(e);i&&i.slice().map(function(r){r(t)}),(i=n.get("*"))&&i.slice().map(function(r){r(e,t)})}}}var yt,fi=class{constructor(){v(this,yt);b(this,yt,Xs())}on(e,t){return a(this,yt).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,yt).off(e,t)}emit(e,t){a(this,yt).emit(e,t)}};yt=new WeakMap;var di=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0},{emitter:n,apiService:e});try{n.emit("notification.read.pending",{args:t,data:s});let o=yield e.read(r),c=new U(o,n,e);return n.emit("notification.read.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.read.resolved",{args:t,error:o}),{error:new E("Failed to read notification",o)}}}),pi=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:n,apiService:e});try{n.emit("notification.unread.pending",{args:t,data:s});let o=yield e.unread(r),c=new U(o,n,e);return n.emit("notification.unread.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.unread.resolved",{args:t,error:o}),{error:new E("Failed to unread notification",o)}}}),mi=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isSeen:!0},{emitter:n,apiService:e});try{if(n.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(r),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,n,e);return n.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return n.emit("notification.seen.resolved",{args:t,error:o}),{error:new E("Failed to mark notification as seen",o)}}}),gi=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()},{emitter:n,apiService:e});try{n.emit("notification.archive.pending",{args:t,data:s});let o=yield e.archive(r),c=new U(o,n,e);return n.emit("notification.archive.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.archive.resolved",{args:t,error:o}),{error:new E("Failed to archive notification",o)}}}),yi=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:n,apiService:e});try{n.emit("notification.unarchive.pending",{args:t,data:s});let o=yield e.unarchive(r),c=new U(o,n,e);return n.emit("notification.unarchive.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new E("Failed to unarchive notification",o)}}}),vi=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isSnoozed:!0,snoozedUntil:t.snoozeUntil},{emitter:n,apiService:e});try{n.emit("notification.snooze.pending",{args:t,data:s});let o=yield e.snooze(r,t.snoozeUntil),c=new U(o,n,e);return n.emit("notification.snooze.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.snooze.resolved",{args:t,error:o}),{error:new E("Failed to snooze notification",o)}}}),bi=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isSnoozed:!1,snoozedUntil:null},{emitter:n,apiService:e});try{n.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(r),c=new U(o,n,e);return n.emit("notification.unsnooze.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new E("Failed to unsnooze notification",o)}}}),Ut=r=>p(null,[r],function*({emitter:n,apiService:e,args:t,actionType:i}){let s=i==="primary"?{primaryAction:x(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:x(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=Ue(t,s,{emitter:n,apiService:e});try{n.emit("notification.complete_action.pending",{args:t,data:c});let u=yield e.completeAction({actionType:i,notificationId:o}),h=new U(u,n,e);return n.emit("notification.complete_action.resolved",{args:t,data:h}),{data:h}}catch(u){return n.emit("notification.complete_action.resolved",{args:t,error:u}),{error:new E(`Failed to complete ${i} action on the notification`,u)}}}),Dt=r=>p(null,[r],function*({emitter:n,apiService:e,args:t,actionType:i}){let s=i==="primary"?{primaryAction:x(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:x(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=Ue(t,s,{emitter:n,apiService:e});try{n.emit("notification.revert_action.pending",{args:t,data:c});let u=yield e.revertAction({actionType:i,notificationId:o}),h=new U(u,n,e);return n.emit("notification.revert_action.resolved",{args:t,data:h}),{data:h}}catch(u){return n.emit("notification.revert_action.resolved",{args:t,error:u}),{error:new E("Failed to fetch notifications",u)}}}),Ue=(n,e,t)=>"notification"in n?{notificationId:n.notification.id,optimisticValue:new U(y(y({},n.notification),e),t.emitter,t.apiService)}:{notificationId:n.notificationId},Qs=s=>p(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let c=t.getUniqueNotifications({tags:i,data:r}).map(u=>new U(x(y({},u),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),n,e));return n.emit("notifications.read_all.pending",{args:{tags:i,data:r},data:c}),yield e.readAll({tags:i,data:r}),n.emit("notifications.read_all.resolved",{args:{tags:i,data:r},data:c}),{}}catch(o){return n.emit("notifications.read_all.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to read all notifications",o)}}}),Ir=o=>p(null,[o],function*({emitter:n,inboxService:e,notificationsCache:t,notificationIds:i,tags:r,data:s}){try{let c=t.getUniqueNotifications({tags:r,data:s}),h=(i&&i.length>0?c.filter(l=>i.includes(l.id)):c).map(l=>new U(x(y({},l),{isSeen:!0,firstSeenAt:l.firstSeenAt||new Date().toISOString()}),n,e));return n.emit("notifications.seen_all.pending",{args:{notificationIds:i,tags:r,data:s},data:h}),yield e.markAsSeen({notificationIds:i,tags:r,data:s}),n.emit("notifications.seen_all.resolved",{args:{notificationIds:i,tags:r,data:s},data:h}),{}}catch(c){return n.emit("notifications.seen_all.resolved",{args:{notificationIds:i,tags:r,data:s},error:c}),{error:new E("Failed to mark all notifications as seen",c)}}}),Zs=s=>p(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let c=t.getUniqueNotifications({tags:i,data:r}).map(u=>new U(x(y({},u),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),n,e));return n.emit("notifications.archive_all.pending",{args:{tags:i,data:r},data:c}),yield e.archiveAll({tags:i,data:r}),n.emit("notifications.archive_all.resolved",{args:{tags:i,data:r},data:c}),{}}catch(o){return n.emit("notifications.archive_all.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to archive all notifications",o)}}}),eo=s=>p(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let c=t.getUniqueNotifications({tags:i,data:r,read:!0}).map(u=>new U(x(y({},u),{isArchived:!0,archivedAt:new Date().toISOString()}),n,e));return n.emit("notifications.archive_all_read.pending",{args:{tags:i,data:r},data:c}),yield e.archiveAllRead({tags:i,data:r}),n.emit("notifications.archive_all_read.resolved",{args:{tags:i,data:r},data:c}),{}}catch(o){return n.emit("notifications.archive_all_read.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to archive all read notifications",o)}}}),Si=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r}=Ue(t,{},{emitter:n,apiService:e});try{return n.emit("notification.delete.pending",{args:t}),yield e.delete(r),n.emit("notification.delete.resolved",{args:t}),{}}catch(s){return n.emit("notification.delete.resolved",{args:t,error:s}),{error:new E("Failed to delete notification",s)}}}),to=s=>p(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let o=t.getUniqueNotifications({tags:i,data:r});return n.emit("notifications.delete_all.pending",{args:{tags:i,data:r},data:o}),yield e.deleteAll({tags:i,data:r}),n.emit("notifications.delete_all.resolved",{args:{tags:i,data:r}}),{}}catch(o){return n.emit("notifications.delete_all.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to delete all notifications",o)}}});var H,le,U=class{constructor(e,t,i){v(this,H);v(this,le);b(this,H,t),b(this,le,i),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 di({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}unread(){return pi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}seen(){return mi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}archive(){return gi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}unarchive(){return yi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}delete(){return Si({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}snooze(e){return vi({emitter:a(this,H),apiService:a(this,le),args:{notification:this,snoozeUntil:e}})}unsnooze(){return bi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Ut({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Ut({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Dt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Dt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"secondary"})}on(e,t){let i=a(this,H).on(e,t);return()=>{i()}}off(e,t){a(this,H).off(e,t)}};H=new WeakMap,le=new WeakMap;function no({emitter:n,inboxService:e,notification:t}){return new U(t,n,e)}var io=(n,e)=>n===e?!0:!n||!e||n.length!==e.length?!1:n.every((t,i)=>t===e[i]);var Od=["seen","unseen"],Td=["read","unread"],ro=30,_i=100,so=200,K=class extends Error{constructor(e){super(e),this.name="TagsFilterValidationError"}};function oo(n,e){if(n.length>e)throw new K(`At most ${e} tags are allowed in a single OR-group`);for(let t of n)if(typeof t!="string")throw new K("Tags must be strings");return n}function cl(n){let e=Object.keys(n),t=Object.prototype.hasOwnProperty.call(n,"or"),i=Object.prototype.hasOwnProperty.call(n,"and");if(t&&i)throw new K('Tags filter cannot have both "or" and "and"');if(t){if(e.length!==1)throw new K("Invalid tags filter object");let r=n.or;if(!Array.isArray(r))throw new K('"or" must be an array of strings');return r.length===0?[]:[oo(r,_i)]}if(i){if(e.length!==1)throw new K("Invalid tags filter object");let r=n.and;if(!Array.isArray(r))throw new K('"and" must be an array');if(r.length===0)return[];if(r.length>ro)throw new K(`At most ${ro} tag groups are allowed`);let s=[],o=0;for(let c of r){if(typeof c!="object"||c===null||Array.isArray(c))throw new K('Each "and" entry must be an object { or: string[] }');if(Object.keys(c).length!==1||!Object.prototype.hasOwnProperty.call(c,"or"))throw new K('Each "and" entry must be { or: string[] }');let h=c.or;if(!Array.isArray(h))throw new K('"or" must be an array of strings');if(h.length===0)throw new K("Each tag group must be a non-empty array of strings");let l=oo(h,_i);o+=l.length,s.push(l)}if(o>so)throw new K(`At most ${so} total tag values are allowed`);return s}throw new K('Tags filter object must have "or" or "and"')}function ll(n){if(n===void 0)return[];if(n===null)throw new K("Tags must be an array or object");if(typeof n=="object"&&!Array.isArray(n))return cl(n);if(!Array.isArray(n))throw new K("Tags must be an array or object");if(n.length===0)return[];if(Array.isArray(n[0]))throw new K("Nested tag arrays are not supported; use { and: [{ or: string[] }, ...] } for multiple OR-groups");let e=n;if(e.length>_i)throw new K(`At most ${_i} tags are allowed in a single OR-group`);for(let t of e)if(typeof t!="string")throw new K("Tags must be strings");return[e]}function ao(n){if(n===void 0)return"";let e=ll(n);if(e.length===0)return"";let t=Array.from(new Map(e.map(i=>{let r=Array.from(new Set(i)).sort((s,o)=>s.localeCompare(o));return[JSON.stringify(r),r]})).values()).sort((i,r)=>JSON.stringify(i).localeCompare(JSON.stringify(r)));return JSON.stringify(t)}var Pr=(n,e)=>{try{return ao(n)===ao(e)}catch(t){return!1}},ul=(n,e)=>{let t=Array.isArray(n)?n:n?[n]:[],i=Array.isArray(e)?e:e?[e]:[];return io(t,i)},Fr=(n,e)=>{if(!n&&!e)return!0;if(!n||!e)return!1;try{return JSON.stringify(n)===JSON.stringify(e)}catch(t){return!1}},Lr=(n,e)=>Fr(n.data,e.data)&&Pr(n.tags,e.tags)&&n.read===e.read&&n.archived===e.archived&&n.snoozed===e.snoozed&&n.seen===e.seen&&ul(n.severity,e.severity)&&n.createdGte===e.createdGte&&n.createdLte===e.createdLte;var ke,Re=class{constructor(){v(this,ke);b(this,ke,new Map)}get(e){return a(this,ke).get(e)}getValues(){return Array.from(a(this,ke).values())}entries(){return Array.from(a(this,ke).entries())}keys(){return Array.from(a(this,ke).keys())}set(e,t){a(this,ke).set(e,t)}remove(e){a(this,ke).delete(e)}clear(){a(this,ke).clear()}};ke=new WeakMap;var co=({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>Object.entries({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f}).filter(([m,d])=>d!=null&&!(Array.isArray(d)&&d.length===0)).reduce((m,[d,w])=>(m[d]=w,m),{}),mn=({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>JSON.stringify(co({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})),hl=({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,createdGte:c,createdLte:u})=>JSON.stringify(co({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,createdGte:c,createdLte:u})),vt=n=>JSON.parse(n),fl=["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"],dl=["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"],$e,yn,q,gn=class{constructor({emitter:e,inboxService:t}){v(this,$e);v(this,yn);v(this,q);this.updateNotification=(e,t)=>{let i=a(this,q).get(e);if(!i)return!1;let r=i.notifications.findIndex(o=>o.id===t.id);if(r===-1)return!1;let s=[...i.notifications];return s[r]=t,a(this,q).set(e,x(y({},i),{notifications:s})),!0};this.removeNotification=(e,t)=>{let i=a(this,q).get(e);if(!i)return!1;let r=i.notifications.findIndex(o=>o.id===t.id);if(r===-1)return!1;let s=[...i.notifications];return s.splice(r,1),a(this,q).set(e,x(y({},i),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:i,args:r}=t,s=[];if(i!=null)Array.isArray(i)&&i.every(c=>typeof c=="object"&&"id"in c)?s=i:typeof i=="object"&&"id"in i&&(s=[i]);else if(e&&r){if("notification"in r&&r.notification)s=[r.notification];else if("notificationId"in r&&r.notificationId){let c=[];a(this,q).keys().forEach(u=>{let h=a(this,q).get(u);if(h){let l=h.notifications.find(f=>f.id===r.notificationId);l&&c.push(l)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,q).keys().forEach(c=>{s.forEach(u=>{let h=!1;e?h=this.removeNotification(c,u):h=this.updateNotification(c,u),h&&o.add(hl(vt(c)))})}),o.forEach(c=>{let u=this.getAggregated(vt(c));a(this,$e).emit("notifications.list.updated",{data:u})})};b(this,$e,e),b(this,yn,t),fl.forEach(i=>{a(this,$e).on(i,this.handleNotificationEvent())}),dl.forEach(i=>{a(this,$e).on(i,this.handleNotificationEvent({remove:!0}))}),b(this,q,new Re)}getAggregated(e){return a(this,q).keys().filter(i=>{let r=vt(i);return Lr(r,e)}).map(i=>a(this,q).get(i)).reduce((i,r)=>r?{hasMore:r.hasMore,filter:r.filter,notifications:[...i.notifications,...r.notifications]}:i,{hasMore:!1,filter:{},notifications:[]})}get(e){return a(this,q).get(mn(e))}has(e){return a(this,q).get(mn(e))!==void 0}set(e,t){a(this,q).set(mn(e),t)}unshift(e,t){let i=mn(e),r=a(this,q).get(i)||{hasMore:!1,filter:vt(i),notifications:[]},s=no({notification:y({},t),emitter:a(this,$e),inboxService:a(this,yn)});this.update(e,x(y({},r),{notifications:[s,...r.notifications]}))}update(e,t){this.set(e,t);let i=this.getAggregated(vt(mn(e)));a(this,$e).emit("notifications.list.updated",{data:i})}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,createdGte:e.createdGte,createdLte:e.createdLte})}getUniqueNotifications({tags:e,read:t,data:i}){let r=a(this,q).keys(),s=new Map;return r.forEach(o=>{let c=vt(o);if(Pr(e,c.tags)&&Fr(i,c.data)){let u=a(this,q).get(o);if(!u)return;u.notifications.filter(h=>typeof t=="undefined"||t===h.isRead).forEach(h=>{s.set(h.id,h)})}}),Array.from(s.values())}clear(e){a(this,q).keys().forEach(i=>{Lr(vt(i),e)&&a(this,q).remove(i)})}clearAll(){a(this,q).clear()}};$e=new WeakMap,yn=new WeakMap,q=new WeakMap;var vn,bn,Sn,_n,Ke=class{constructor(e,t,i,r,s){v(this,vn);v(this,bn);v(this,Sn);v(this,_n);var o;b(this,vn,t),b(this,bn,i),b(this,Sn,r),b(this,_n,s),this.enabled=e.enabled,this.condition=(o=e.condition)!=null?o:void 0,this.workflow=e.workflow,this.subscriptionId=e.subscriptionId}update(e){return p(this,null,function*(){var t;return Ei({emitter:a(this,vn),apiService:a(this,bn),cache:a(this,Sn),useCache:a(this,_n),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};vn=new WeakMap,bn=new WeakMap,Sn=new WeakMap,_n=new WeakMap;var lo=s=>p(null,[s],function*({emitter:n,apiService:e,cache:t,options:i,args:r}){try{let{useCache:o,refetch:c}=i,u=o&&!c?t.getAll(r):void 0;return n.emit("subscriptions.list.pending",{args:r,data:u}),(!u||c)&&(u=(yield e.fetchSubscriptions(r.topicKey)).map(l=>new ze(x(y({},l),{topicKey:r.topicKey}),n,e,t,o)),o&&(t.set(r,u),u=t.getAll(r))),n.emit("subscriptions.list.resolved",{args:r,data:u}),{data:u}}catch(o){return n.emit("subscriptions.list.resolved",{args:r,error:o}),{error:new E("Failed to fetch subscriptions",o)}}}),uo=s=>p(null,[s],function*({emitter:n,apiService:e,cache:t,options:i,args:r}){try{let{useCache:o,refetch:c}=i,u=o&&!c?t.get(r):void 0;if(n.emit("subscription.get.pending",{args:r,data:u}),!u||c){let h=yield e.getSubscription(r.topicKey,r.identifier,r.workflowIds,r.tags);if(!h)return n.emit("subscription.get.resolved",{args:r,data:null}),{data:null};u=new ze(x(y({},h),{topicKey:r.topicKey}),n,e,t,o),o&&(t.setOne(r,u),u=t.get(r))}return n.emit("subscription.get.resolved",{args:r,data:u}),{data:u}}catch(o){return n.emit("subscription.get.resolved",{args:r,error:o}),{error:new E("Failed to fetch subscription",o)}}}),ho=s=>p(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){var o;try{n.emit("subscription.create.pending",{args:r});let c=yield e.createSubscription({identifier:(o=r.identifier)!=null?o:"",name:r.name,topicKey:r.topicKey,topicName:r.topicName,preferences:r.preferences}),u=new ze(x(y({},c),{topicKey:r.topicKey}),n,e,t,i);return n.emit("subscription.create.resolved",{args:r,data:u}),{data:u}}catch(c){return n.emit("subscription.create.resolved",{args:r,error:c}),{error:new E("Failed to create subscription",c)}}}),Ci=s=>p(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){let o="identifier"in r?r.identifier:r.subscription.identifier,c="topicKey"in r?r.topicKey:r.subscription.topicKey;try{n.emit("subscription.update.pending",{args:r});let u=yield e.updateSubscription({topicKey:c,identifier:o,name:r.name,preferences:r.preferences}),h=new ze(x(y({},u),{topicKey:c}),n,e,t,i);return n.emit("subscription.update.resolved",{args:r,data:h}),{data:h}}catch(u){return n.emit("subscription.update.resolved",{args:r,error:u}),{error:new E("Failed to update subscription",u)}}}),Ei=s=>p(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){var c,u;let o="workflowId"in r?r.workflowId:(u=(c=r.preference)==null?void 0:c.workflow)==null?void 0:u.id;try{n.emit("subscription.preference.update.pending",{args:r,data:"preference"in r?new Ke(y(y({},r.preference),typeof r.value=="boolean"?{enabled:r.value}:{condition:r.value}),n,e,t,i):void 0});let h=yield e.updateSubscriptionPreference(y({subscriptionIdentifier:r.subscriptionId,workflowId:o},typeof r.value=="boolean"?{enabled:r.value,email:r.value,sms:r.value,in_app:r.value,chat:r.value,push:r.value}:{condition:r.value})),l=new Ke(y({},h),n,e,t,i);return n.emit("subscription.preference.update.resolved",{args:r,data:l}),{data:l}}catch(h){return n.emit("subscription.preference.update.resolved",{args:r,error:h}),{error:new E("Failed to update subscription",h)}}}),fo=s=>p(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){try{let o=r.map(l=>"preference"in l?new Ke(y(y({},l.preference),typeof l.value=="boolean"?{enabled:l.value}:{condition:l.value}),n,e,t,i):void 0).filter(l=>l!==void 0);n.emit("subscription.preferences.bulk_update.pending",{args:r,data:o});let c=r.map(l=>{var f,m,d,w,g,S;return y({subscriptionIdentifier:l.subscriptionId,workflowId:"workflowId"in l?l.workflowId:(S=(g=(m=(f=l.preference)==null?void 0:f.workflow)==null?void 0:m.id)!=null?g:(w=(d=l.preference)==null?void 0:d.workflow)==null?void 0:w.identifier)!=null?S:""},typeof l.value=="boolean"?{enabled:l.value,email:l.value,sms:l.value,in_app:l.value,chat:l.value,push:l.value}:{condition:l.value})}),h=(yield e.bulkUpdateSubscriptionPreferences(c)).map(l=>new Ke(l,n,e,t,i));return n.emit("subscription.preferences.bulk_update.resolved",{args:r,data:h}),{data:h}}catch(o){return n.emit("subscription.preferences.bulk_update.resolved",{args:r,error:o}),{error:new E("Failed to bulk update subscription preferences",o)}}}),wi=i=>p(null,[i],function*({emitter:n,apiService:e,args:t}){let r="identifier"in t?t.identifier:t.subscription.identifier,s="topicKey"in t?t.topicKey:t.subscription.topicKey;try{return n.emit("subscription.delete.pending",{args:t}),yield e.deleteSubscription({topicKey:s,identifier:r}),n.emit("subscription.delete.resolved",{args:t}),{data:void 0}}catch(o){return n.emit("subscription.delete.resolved",{args:t,error:o}),{error:new E("Failed to delete subscription",o)}}});var Ge,je,ot,at,Bt,ze=class{constructor(e,t,i,r,s){v(this,Ge);v(this,je);v(this,ot);v(this,at);v(this,Bt,!1);var o;b(this,Ge,t),b(this,je,i),b(this,ot,r),b(this,at,s),this.id=e.id,this.identifier=e.identifier,this.topicKey=e.topicKey,this.preferences=(o=e.preferences)==null?void 0:o.map(c=>new Ke(y({},c),a(this,Ge),a(this,je),a(this,ot),a(this,at)))}update(e){return p(this,null,function*(){return Ci({emitter:a(this,Ge),apiService:a(this,je),cache:a(this,ot),useCache:a(this,at),args:x(y({},e),{subscription:this})})})}updatePreference(e){return p(this,null,function*(){return a(this,Bt)?{error:new E("Cannot update a deleted subscription",new Error("Subscription is stale"))}:Ei({emitter:a(this,Ge),apiService:a(this,je),cache:a(this,ot),useCache:a(this,at),args:x(y({},e),{subscriptionId:this.identifier})})})}bulkUpdatePreferences(e){return p(this,null,function*(){return a(this,Bt)?{error:new E("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:fo({emitter:a(this,Ge),apiService:a(this,je),cache:a(this,ot),useCache:a(this,at),args:e.map(t=>x(y({},t),{subscriptionId:this.identifier}))})})}delete(){return p(this,null,function*(){return a(this,Bt)?{error:new E("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:wi({emitter:a(this,Ge),apiService:a(this,je),args:{subscription:this}})})}};Ge=new WeakMap,je=new WeakMap,ot=new WeakMap,at=new WeakMap,Bt=new WeakMap;var bt=n=>`list:${n.topicKey}`,po=n=>n.split(":")[1],ct=n=>`item:${n.topicKey}:${n.identifier}`,ie,W,En,z,Cn,xi=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:i}){v(this,ie);v(this,W);v(this,En);v(this,z);v(this,Cn);this.handleCreate=e=>{let t=bt({topicKey:e.topicKey}),i=a(this,W).get(t);if(i){let r=[...i,e];a(this,W).set(t,r),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).set(ct({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=bt({topicKey:e.topicKey}),i=a(this,W).get(t);if(i){let r=i.map(s=>s.id===e.id?e:s);a(this,W).set(t,r),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).set(ct({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handlePreferenceUpdate=e=>{this.updateSubscriptionPreferences([e])};this.handleBulkPreferenceUpdate=e=>{this.updateSubscriptionPreferences(e)};this.updateSubscriptionPreferences=e=>{var s;let t=new Map;for(let o of e){let c=(s=t.get(o.subscriptionId))!=null?s:[];c.push(o),t.set(o.subscriptionId,c)}let i=a(this,W).keys();for(let o of i){let c=a(this,W).get(o);if(!c)continue;let u=!1,h=c.map(l=>{let f=t.get(l.identifier);return f?(u=!0,this.createUpdatedSubscription(l,f)):l});u&&(a(this,W).set(o,h),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:po(o),subscriptions:h}}))}let r=a(this,z).keys();for(let o of r){let c=a(this,z).get(o);if(!c)continue;let u=t.get(c.identifier);if(u){let h=this.createUpdatedSubscription(c,u);a(this,z).set(o,h),a(this,ie).emit("subscription.update.resolved",{args:{subscription:c},data:h})}}};this.createUpdatedSubscription=(e,t)=>{var r;let i=(r=e.preferences)==null?void 0:r.map(s=>{let o=t.find(c=>c.workflow.id===s.workflow.id);return o||s});return new ze({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:i},a(this,ie),a(this,Cn),this,a(this,En))};this.handleDelete=e=>{let t=bt({topicKey:e.topicKey}),i=a(this,W).get(t);if(i){let r=i.filter(s=>s.id!==e.id);a(this,W).set(t,r),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).remove(ct({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteByIdentifier=e=>{let t=a(this,W).keys();for(let r of t){let s=a(this,W).get(r);if(s){let o=s.find(c=>c.identifier===e);if(o){let c=s.filter(u=>u.identifier!==e);a(this,W).set(r,c),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:po(r),subscriptions:c}}),a(this,z).remove(ct({topicKey:o.topicKey,identifier:o.identifier}));return}}}let i=a(this,z).keys();for(let r of i){let s=a(this,z).get(r);if(s&&s.identifier===e){a(this,z).remove(r);return}}};b(this,ie,e),b(this,W,new Re),b(this,z,new Re),b(this,Cn,t),b(this,En,i),a(this,ie).on("subscription.create.resolved",({data:r})=>{r&&this.handleCreate(r)}),a(this,ie).on("subscription.update.resolved",({data:r})=>{r&&this.handleUpdate(r)}),a(this,ie).on("subscription.delete.resolved",({args:r})=>{"subscription"in r?this.handleDelete(r.subscription):"identifier"in r&&this.handleDeleteByIdentifier(r.identifier)}),a(this,ie).on("subscription.preference.update.pending",({data:r})=>{r&&this.handlePreferenceUpdate(r)}),a(this,ie).on("subscription.preference.update.resolved",({data:r})=>{r&&this.handlePreferenceUpdate(r)}),a(this,ie).on("subscription.preferences.bulk_update.resolved",({data:r})=>{r&&r.length>0&&this.handleBulkPreferenceUpdate(r)})}has(e){return a(this,W).get(bt(e))!==void 0}set(e,t){a(this,W).set(bt(e),t);for(let i of t)a(this,z).set(ct({topicKey:e.topicKey,identifier:i.identifier}),i)}setOne(e,t){a(this,z).set(ct(e),t)}getAll(e){return a(this,W).get(bt(e))}get(e){return a(this,z).get(ct(e))}invalidate(e){let t=bt({topicKey:e.topicKey}),i=a(this,W).get(t);if(i)for(let s of i)a(this,z).remove(ct({topicKey:e.topicKey,identifier:s.identifier}));a(this,W).remove(t);let r=a(this,z).keys();for(let s of r)s.startsWith(`item:${e.topicKey}:`)&&a(this,z).remove(s)}clearAll(){a(this,W).clear(),a(this,z).clear()}};ie=new WeakMap,W=new WeakMap,En=new WeakMap,z=new WeakMap,Cn=new WeakMap;var wn,Ai=class extends V{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:r}){super({eventEmitterInstance:r,inboxServiceInstance:i});v(this,wn);this.cache=new gn({emitter:r,inboxService:i}),b(this,wn,t)}list(){return p(this,arguments,function*(r={}){var s=r,{limit:t=10}=s,i=un(s,["limit"]);return this.callWithSession(()=>p(this,null,function*(){let o=y({limit:t},i);try{let c="useCache"in o?o.useCache:a(this,wn),u=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:u}),!u){let h=yield this._inboxService.fetchNotifications(y({limit:t},i));u={hasMore:h.hasMore,filter:h.filter,notifications:h.data.map(l=>new U(l,this._emitter,this._inboxService))},c&&(this.cache.set(o,u),u=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:u}),{data:u}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new E("Failed to fetch notifications",c)}}}))})}count(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){let i=t&&"filters"in t?t.filters:[y({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let r=yield this._inboxService.count({filters:i}),s=t&&"filters"in t?{counts:r.data}:r.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(r){return this._emitter.emit("notifications.count.resolved",{args:t,error:r}),{error:new E("Failed to count notifications",r)}}}))})}read(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return di({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return pi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return mi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return gi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Si({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return vi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return bi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Ut({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Ut({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Dt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){return Dt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return p(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>p(this,null,function*(){return Qs({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}seenAll(){return p(this,arguments,function*(t={}){return this.callWithSession(()=>p(this,null,function*(){return"notificationIds"in t?Ir({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):Ir({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 p(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>p(this,null,function*(){return Zs({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}archiveAllRead(){return p(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>p(this,null,function*(){return eo({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}deleteAll(){return p(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>p(this,null,function*(){return to({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}clearCache({filter:t}={}){if(t){this.cache.clear(t!=null?t:{});return}this.cache.clearAll()}triggerHelloWorldEvent(){return p(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};wn=new WeakMap;var xn,An,Nn,kn,Ve=class{constructor(e,{emitterInstance:t,inboxServiceInstance:i,cache:r,useCache:s}){v(this,xn);v(this,An);v(this,Nn);v(this,kn);b(this,xn,t),b(this,An,i),b(this,Nn,r),b(this,kn,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return p(this,null,function*(){var i;let t=!!e.weeklySchedule||!!this.weeklySchedule;return Ni({emitter:a(this,xn),apiService:a(this,An),cache:a(this,Nn),useCache:a(this,kn),args:y({isEnabled:(i=e.isEnabled)!=null?i:this.isEnabled},t&&{weeklySchedule:y(y({},this.weeklySchedule),e.weeklySchedule)})})})}};xn=new WeakMap,An=new WeakMap,Nn=new WeakMap,kn=new WeakMap;var Rn,On,Tn,In,Pn,De=class{constructor(e,{emitterInstance:t,inboxServiceInstance:i,cache:r,scheduleCache:s,useCache:o}){v(this,Rn);v(this,On);v(this,Tn);v(this,In);v(this,Pn);b(this,Rn,t),b(this,On,i),b(this,Tn,r),b(this,In,s),b(this,Pn,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new Ve(y({},e.schedule),{emitterInstance:t,inboxServiceInstance:i,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var i;return ki({emitter:a(this,Rn),apiService:a(this,On),cache:a(this,Tn),scheduleCache:a(this,In),useCache:a(this,Pn),args:{workflowId:(i=this.workflow)==null?void 0:i.id,channels:e||t,preference:this}})}};Rn=new WeakMap,On=new WeakMap,Tn=new WeakMap,In=new WeakMap,Pn=new WeakMap;var ki=o=>p(null,[o],function*({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s}){var h;let{channels:c}=s,u="workflowId"in s?s.workflowId:(h=s.preference.workflow)==null?void 0:h.id;try{n.emit("preference.update.pending",{args:s,data:"preference"in s?new De(x(y({},s.preference),{channels:y(y({},s.preference.channels),c)}),{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}):void 0});let l;u?l=yield e.updateWorkflowPreferences({workflowId:u,channels:c}):(pl({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s}),l=yield e.updateGlobalPreferences(c));let f=new De(l,{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r});return n.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(l){return n.emit("preference.update.resolved",{args:s,error:l}),{error:new E("Failed to update preference",l)}}}),mo=o=>p(null,[o],function*({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s}){if(s.find(u=>"preference"in u&&u.preference.level==="global"))return{error:new E("Global preference is not supported in bulk update","")};try{let u=s.map(m=>"preference"in m?new De(x(y({},m.preference),{channels:y(y({},m.preference.channels),m.channels)}),{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}):void 0).filter(m=>m!==void 0);n.emit("preferences.bulk_update.pending",{args:s,data:u});let h=s.map(m=>{var d,w,g,S;return y({workflowId:"workflowId"in m?m.workflowId:(S=(g=(d=m.preference.workflow)==null?void 0:d.id)!=null?g:(w=m.preference.workflow)==null?void 0:w.identifier)!=null?S:""},m.channels)}),f=(yield e.bulkUpdatePreferences(h)).map(m=>new De(m,{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}));return n.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(u){return n.emit("preferences.bulk_update.resolved",{args:s,error:u}),{error:new E("Failed to bulk update preferences",u)}}}),pl=({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s})=>{let o=r?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var u,h;if(c.level==="template"){let l=x(y({},c),{channels:Object.entries(c.channels).reduce((m,[d,w])=>{var S;let g=d;return m[g]=(S=s.channels[g])!=null?S:w,m},{})}),f="preference"in s?new De(l,{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}):void 0;f&&n.emit("preference.update.pending",{args:{workflowId:(h=(u=c.workflow)==null?void 0:u.id)!=null?h:"",channels:f.channels},data:f})}})},Ni=s=>p(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){var o,c;try{let{isEnabled:u,weeklySchedule:h}=r,l=new Ve({isEnabled:u,weeklySchedule:h},{emitterInstance:n,inboxServiceInstance:e,cache:t,useCache:i});n.emit("preference.schedule.update.pending",{args:r,data:l});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:u,weeklySchedule:h}}),m=new Ve({isEnabled:(o=f.schedule)==null?void 0:o.isEnabled,weeklySchedule:(c=f.schedule)==null?void 0:c.weeklySchedule},{emitterInstance:n,inboxServiceInstance:e,cache:t,useCache:i});return n.emit("preference.schedule.update.resolved",{args:r,data:m}),{data:m}}catch(u){return n.emit("preference.schedule.update.resolved",{args:r,error:u}),{error:new E("Failed to update preference",u)}}});var lt,Ri=class extends V{constructor({cache:t,useCache:i,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,lt);this.cache=t,b(this,lt,i)}get(){return p(this,null,function*(){return this.callWithSession(()=>p(this,null,function*(){var t,i;try{let r=a(this,lt)?this.cache.getAll():void 0;if(this._emitter.emit("preference.schedule.get.pending",{args:void 0,data:r}),!r){let s=yield this._inboxService.fetchGlobalPreferences();r=new Ve({isEnabled:(t=s==null?void 0:s.schedule)==null?void 0:t.isEnabled,weeklySchedule:(i=s==null?void 0:s.schedule)==null?void 0:i.weeklySchedule},{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:a(this,lt)}),a(this,lt)&&(this.cache.set(r),r=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:r}),{data:r}}catch(r){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:r}),r}}))})}update(t){return p(this,null,function*(){return this.callWithSession(()=>Ni({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,lt),args:t}))})}};lt=new WeakMap;var ml=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],gl=["preference.schedule.update.pending","preference.schedule.update.resolved"],yl=({tags:n,severity:e})=>Object.entries({tags:n,severity:e}).reduce((t,[i,r])=>(r==null||Array.isArray(r)&&r.length===0||(t[i]=r),t),{}),Ur=({tags:n,severity:e})=>JSON.stringify(yl({tags:n,severity:e})),ut,Y,Oi=class{constructor({emitterInstance:e}){v(this,ut);v(this,Y);this.updatePreference=(e,t)=>{let i=a(this,Y).get(e);if(!i)return!1;let r=i.findIndex(o=>{var c,u;return((c=o.workflow)==null?void 0:c.id)===((u=t.workflow)==null?void 0:u.id)||o.level===t.level&&t.level==="global"});if(r===-1)return!1;let s=[...i];return s[r]=t,a(this,Y).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let i=a(this,Y).get(e);if(!i)return!1;let r=i.findIndex(o=>o.level==="global");if(r===-1)return!1;let s=[...i];return s[r].schedule=t,a(this,Y).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var r;if(!e)return;let t=a(this,Y).keys(),i=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,Y).get(s);!o||!c||i.add(s)}for(let s of i)a(this,ut).emit("preferences.list.updated",{data:(r=a(this,Y).get(s))!=null?r:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],i=new Set;a(this,Y).keys().forEach(r=>{t.forEach(s=>{let o=this.updatePreference(r,s),c=a(this,Y).get(r);!o||!c||i.add(r)})}),i.forEach(r=>{var s;a(this,ut).emit("preferences.list.updated",{data:(s=a(this,Y).get(r))!=null?s:[]})})};b(this,ut,e);for(let t of ml)a(this,ut).on(t,this.handlePreferenceEvent);for(let t of gl)a(this,ut).on(t,this.handleScheduleEvent);b(this,Y,new Re)}has(e){return a(this,Y).get(Ur(e))!==void 0}set(e,t){a(this,Y).set(Ur(e),t)}getAll(e){if(this.has(e))return a(this,Y).get(Ur(e))}clearAll(){a(this,Y).clear()}};ut=new WeakMap,Y=new WeakMap;var vl=["preference.schedule.update.pending","preference.schedule.update.resolved"],Dr=()=>"schedule",Mt,pe,Ti=class{constructor({emitterInstance:e}){v(this,Mt);v(this,pe);this.updateScheduleInCache=(e,t)=>a(this,pe).get(e)?(a(this,pe).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,i=a(this,pe).keys();for(let r of i){let s=this.updateScheduleInCache(r,e),o=a(this,pe).get(r);!s||!o||t.add(r)}for(let r of t)a(this,Mt).emit("preference.schedule.get.updated",{data:a(this,pe).get(r)})};b(this,Mt,e);for(let t of vl)a(this,Mt).on(t,this.handleScheduleEvent);b(this,pe,new Re)}has(){return a(this,pe).get(Dr())!==void 0}set(e){a(this,pe).set(Dr(),e)}getAll(){if(this.has())return a(this,pe).get(Dr())}clearAll(){a(this,pe).clear()}};Mt=new WeakMap,pe=new WeakMap;var He,Ii=class extends V{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:r}){super({eventEmitterInstance:r,inboxServiceInstance:i});v(this,He);this.cache=new Oi({emitterInstance:this._emitter}),this.scheduleCache=new Ti({emitterInstance:this._emitter}),b(this,He,t),this.schedule=new Ri({cache:this.scheduleCache,useCache:t,inboxServiceInstance:i,eventEmitterInstance:r})}list(){return p(this,arguments,function*(t={}){return this.callWithSession(()=>p(this,null,function*(){var i;try{let r=a(this,He)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:r}),r||(r=(yield this._inboxService.fetchPreferences({tags:t.tags,severity:t.severity,criticality:(i=t.criticality)!=null?i:"nonCritical"})).map(o=>new De(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,He)})),a(this,He)&&(this.cache.set(t,r),r=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:r}),{data:r}}catch(r){throw this._emitter.emit("preferences.list.resolved",{args:t,error:r}),r}}))})}update(t){return p(this,null,function*(){return this.callWithSession(()=>ki({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,He),args:t}))})}bulkUpdate(t){return p(this,null,function*(){return this.callWithSession(()=>mo({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,He),args:t}))})}};He=new WeakMap;function go(){return typeof window!="undefined"}var St,Fn,re,Pi=class{constructor(e,t,i){v(this,St);v(this,Fn);v(this,re);b(this,St,i),b(this,Fn,t),b(this,re,e)}get applicationIdentifier(){return a(this,re).applicationIdentifier}get subscriberId(){var e;return(e=a(this,re).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,re).context}get subscriberHash(){return a(this,re).subscriberHash}get contextHash(){return a(this,re).contextHash}get subscriber(){return a(this,re).subscriber}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let i="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(i);case"store":return t&&window.localStorage.setItem(i,t),null;case"delete":return window.localStorage.removeItem(i),null;default:return null}}initialize(e){return p(this,null,function*(){var r,s,o,c,u,h;let t=((r=a(this,re).subscriber)==null?void 0:r.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),i=JSON.stringify(a(this,re).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&i))try{e&&b(this,re,e);let{subscriber:l,subscriberHash:f,contextHash:m,applicationIdentifier:d,defaultSchedule:w,context:g}=a(this,re),S;go()&&(S=Intl.DateTimeFormat().resolvedOptions().timeZone);let R=d;if(R)this.handleApplicationIdentifier("delete");else{let _=this.handleApplicationIdentifier("get");_&&(R=_)}a(this,St).emit("session.initialize.pending",{args:a(this,re)});let N=yield a(this,Fn).initializeSession({applicationIdentifier:R,subscriberHash:f,contextHash:m,subscriber:x(y({},l),{subscriberId:(o=l==null?void 0:l.subscriberId)!=null?o:"",timezone:(c=l==null?void 0:l.timezone)!=null?c:S}),defaultSchedule:w,context:g});(u=N==null?void 0:N.applicationIdentifier)!=null&&u.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",N.applicationIdentifier),(h=N==null?void 0:N.applicationIdentifier)!=null&&h.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,St).emit("session.initialize.resolved",{args:a(this,re),data:N})}catch(l){a(this,St).emit("session.initialize.resolved",{args:a(this,re),error:l})}})}};St=new WeakMap,Fn=new WeakMap,re=new WeakMap;function Br(n){if(!n)return"";let e=[];for(let[t,i]of Object.entries(n))if(i){let r=typeof i=="string"?i:i.id;e.push(`${t}:${r}`)}return e.sort().join(",")}function yo({subscriberId:n,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:n?{subscriberId:n}:{subscriberId:""}}function vo({topicKey:n,subscriberId:e,contextKey:t}){let i=`tk_${n}:si_${e}`;return t&&t.length>0?`${i}:ctx_${t}`:i}var ht,Un,Dn,Ln=class extends V{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:r,subscriber:s,contextKey:o}){super({eventEmitterInstance:r,inboxServiceInstance:i});v(this,ht);v(this,Un);v(this,Dn);this.cache=new xi({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),b(this,ht,t),b(this,Un,s),b(this,Dn,o)}list(t,i){return p(this,null,function*(){return this.callWithSession(()=>{var r;return lo({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},i),{useCache:(r=i==null?void 0:i.useCache)!=null?r:a(this,ht)}),args:t})})})}get(t,i){return p(this,null,function*(){return this.callWithSession(()=>{var r,s;return uo({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},i),{useCache:(r=i==null?void 0:i.useCache)!=null?r:a(this,ht)}),args:x(y({},t),{identifier:(s=t.identifier)!=null?s:vo({topicKey:t.topicKey,subscriberId:a(this,Un).subscriberId,contextKey:a(this,Dn)})})})})})}create(t){return p(this,null,function*(){return this.callWithSession(()=>ho({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ht),args:t}))})}update(t){return p(this,null,function*(){return this.callWithSession(()=>Ci({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ht),args:t}))})}delete(t){return p(this,null,function*(){return this.callWithSession(()=>wi({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};ht=new WeakMap,Un=new WeakMap,Dn=new WeakMap;var Fi=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,bl=(function(){try{new Fi.Event("")}catch(n){return!0}return!1})(),Sl=(function(){try{new Fi.EventTarget}catch(n){return!0}return!1})();bl&&(Fi.Event=(function(){function n(e,t){this.bubbles=!!t&&!!t.bubbles,this.cancelable=!!t&&!!t.cancelable,this.composed=!!t&&!!t.composed,this.type=e}return n})());Sl&&(Fi.EventTarget=(function(){function n(){this.__listeners=new Map}return n.prototype=Object.create(Object.prototype),n.prototype.addEventListener=function(e,t,i){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let r=this.__listeners,s=e.toString();r.has(s)||r.set(s,new Map);let o=r.get(s);o.has(t)||o.set(t,i)},n.prototype.removeEventListener=function(e,t,i){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let r=this.__listeners,s=e.toString();if(r.has(s)){let o=r.get(s);o.has(t)&&o.delete(t)}},n.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,r=this.__listeners.get(t);if(r)for(var s of r.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(u){setTimeout(()=>{throw u})}c&&c.once&&r.delete(o)}return!0},n})());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
|
|
18
|
+
`+s),n.push(r+"m+"+Ar.exports.humanize(this.diff)+"\x1B[0m")}else n[0]=Rf()+e+" "+n[0]}function Rf(){return ee.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Of(...n){return process.stderr.write(xr.formatWithOptions(ee.inspectOpts,...n)+`
|
|
19
|
+
`)}function Tf(n){n?process.env.DEBUG=n:delete process.env.DEBUG}function If(){return process.env.DEBUG}function Pf(n){n.inspectOpts={};let e=Object.keys(ee.inspectOpts);for(let t=0;t<e.length;t++)n.inspectOpts[e[t]]=ee.inspectOpts[e[t]]}Ar.exports=Is()(ee);var{formatters:Bc}=Ar.exports;Bc.o=function(n){return this.inspectOpts.colors=this.useColors,xr.inspect(n,this.inspectOpts).split(`
|
|
20
|
+
`).map(e=>e.trim()).join(" ")};Bc.O=function(n){return this.inspectOpts.colors=this.useColors,xr.inspect(n,this.inspectOpts)}});var qc=I((Ny,Ps)=>{"use strict";typeof process=="undefined"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ps.exports=Dc():Ps.exports=Mc()});var ll=`${PACKAGE_NAME}@${PACKAGE_VERSION}`,pi=class{constructor(e={}){this.DEFAULT_BACKEND_URL=typeof window!="undefined"&&window.NOVU_LOCAL_BACKEND_URL||"https://api.novu.co";let{apiVersion:t="v1",apiUrl:i=this.DEFAULT_BACKEND_URL,headers:r={}}=e||{};this.apiVersion=t,this.apiUrl=`${i}/${t}`,this.headers=y({"Novu-API-Version":NOVU_API_VERSION,"Novu-Client-Version":ll,"Content-Type":"application/json"},r)}setAuthorizationToken(e){this.headers.Authorization=`Bearer ${e}`}setKeylessHeader(e){var i;let t=e||typeof window!="undefined"&&((i=window.localStorage)==null?void 0:i.getItem("novu_keyless_application_identifier"));!t||!t.startsWith("pk_keyless_")||(this.headers["Novu-Application-Identifier"]=t)}setHeaders(e){this.headers=y(y({},this.headers),e)}get(e,t,i=!0){return d(this,null,function*(){return this.doFetch({path:e,searchParams:t,options:{method:"GET"},unwrapEnvelope:i})})}post(e,t,i){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"POST",body:t,headers:i==null?void 0:i.headers}})})}patch(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"PATCH",body:t}})})}delete(e,t){return d(this,null,function*(){return this.doFetch({path:e,options:{method:"DELETE",body:t}})})}doFetch(s){return d(this,arguments,function*({path:e,searchParams:t,options:i,unwrapEnvelope:r=!0}){let o=ul(this.apiUrl,e,t?`?${t.toString()}`:""),c={method:(i==null?void 0:i.method)||"GET",headers:y(y({},this.headers),(i==null?void 0:i.headers)||{}),body:i!=null&&i.body?JSON.stringify(i.body):void 0},u=yield fetch(o,c);if(!u.ok){let l=yield u.json();throw new Error(`${this.headers["Novu-Client-Version"]} error. Status: ${u.status}, Message: ${l.message}`)}if(u.status===204)return;let h=yield u.json();return r?h.data:h})}};function ul(...n){return n.reduce((e,t)=>(t&&e.push(t.replace(new RegExp("(?<!https?:)\\/+","g"),"/").replace(/^\/+|\/+$/g,"")),e),[]).join("/").replace(/\/\?/,"?")}var ne="/inbox",ce=`${ne}/notifications`,hl=`${ne}/chat/oauth`,mn=`${ne}/channel-connections`,fl=`${mn}/oauth`,Bt=`${ne}/channel-endpoints`,dl=`${Bt}/oauth`;function zs(n){let e=new URLSearchParams;if(n.subscriberId&&e.append("subscriberId",n.subscriberId),n.integrationIdentifier&&e.append("integrationIdentifier",n.integrationIdentifier),n.connectionIdentifier&&e.append("connectionIdentifier",n.connectionIdentifier),n.channel&&e.append("channel",n.channel),n.providerId&&e.append("providerId",n.providerId),n.contextKeys!==void 0)if(n.contextKeys.length===0)e.append("contextKeys","");else for(let t of n.contextKeys)e.append("contextKeys",t);return n.limit&&e.append("limit",String(n.limit)),n.after&&e.append("after",n.after),n.before&&e.append("before",n.before),e.size?`?${e.toString()}`:""}function pl(n,e){if(e!==void 0){if(Array.isArray(e)){if(e.length===0)return;for(let t of e)n.append("tags[]",t);return}if("or"in e){if(e.or.length===0)return;for(let t of e.or)n.append("tags[]",t);return}if("and"in e){if(e.and.length===0)return;e.and.forEach((t,i)=>{for(let r of t.or)n.append(`tags[${i}][]`,r)})}}}var A,mi=class{constructor(e={}){this.isSessionInitialized=!1;v(this,A);b(this,A,new pi(e))}initializeSession(c){return d(this,arguments,function*({applicationIdentifier:e,subscriberHash:t,contextHash:i,subscriber:r,defaultSchedule:s,context:o}){let u=yield a(this,A).post(`${ne}/session`,{applicationIdentifier:e,subscriberHash:t,contextHash:i,subscriber:r,defaultSchedule:s,context:o});return a(this,A).setAuthorizationToken(u.token),a(this,A).setKeylessHeader(u.applicationIdentifier),this.isSessionInitialized=!0,u})}fetchNotifications({after:e,archived:t,limit:i=10,offset:r,read:s,tags:o,snoozed:c,seen:u,data:h,severity:l,createdGte:f,createdLte:m}){let p=new URLSearchParams(`limit=${i}`);if(e&&p.append("after",e),r&&p.append("offset",`${r}`),pl(p,o),s!==void 0&&p.append("read",`${s}`),t!==void 0&&p.append("archived",`${t}`),c!==void 0&&p.append("snoozed",`${c}`),u!==void 0&&p.append("seen",`${u}`),h!==void 0&&p.append("data",JSON.stringify(h)),l&&Array.isArray(l))for(let w of l)p.append("severity[]",w);else l&&p.append("severity",l);return f&&p.append("createdGte",`${f}`),m&&p.append("createdLte",`${m}`),a(this,A).get(ce,p,!1)}count({filters:e}){return a(this,A).get(`${ce}/count`,new URLSearchParams({filters:JSON.stringify(e)}),!1)}read(e){return a(this,A).patch(`${ce}/${e}/read`)}unread(e){return a(this,A).patch(`${ce}/${e}/unread`)}archive(e){return a(this,A).patch(`${ce}/${e}/archive`)}unarchive(e){return a(this,A).patch(`${ce}/${e}/unarchive`)}snooze(e,t){return a(this,A).patch(`${ce}/${e}/snooze`,{snoozeUntil:t})}unsnooze(e){return a(this,A).patch(`${ce}/${e}/unsnooze`)}readAll({tags:e,data:t}){return a(this,A).post(`${ce}/read`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAll({tags:e,data:t}){return a(this,A).post(`${ce}/archive`,{tags:e,data:t?JSON.stringify(t):void 0})}archiveAllRead({tags:e,data:t}){return a(this,A).post(`${ce}/read-archive`,{tags:e,data:t?JSON.stringify(t):void 0})}delete(e){return a(this,A).delete(`${ce}/${e}/delete`)}deleteAll({tags:e,data:t}){return a(this,A).post(`${ce}/delete`,{tags:e,data:t?JSON.stringify(t):void 0})}markAsSeen({notificationIds:e,tags:t,data:i}){return a(this,A).post(`${ce}/seen`,{notificationIds:e,tags:t,data:i?JSON.stringify(i):void 0})}seen(e){return this.markAsSeen({notificationIds:[e]})}completeAction({actionType:e,notificationId:t}){return a(this,A).patch(`${ce}/${t}/complete`,{actionType:e})}revertAction({actionType:e,notificationId:t}){return a(this,A).patch(`${ce}/${t}/revert`,{actionType:e})}fetchPreferences({tags:e,severity:t,criticality:i}){let r=new URLSearchParams;if(e)for(let o of e)r.append("tags[]",o);if(t&&Array.isArray(t))for(let o of t)r.append("severity[]",o);else t&&r.append("severity",t);i&&r.append("criticality",i);let s=r.size?`?${r.toString()}`:"";return a(this,A).get(`${ne}/preferences${s}`)}bulkUpdatePreferences(e){return a(this,A).patch(`${ne}/preferences/bulk`,{preferences:e})}updateGlobalPreferences(e){return a(this,A).patch(`${ne}/preferences`,e)}updateWorkflowPreferences({workflowId:e,channels:t}){return a(this,A).patch(`${ne}/preferences/${e}`,t)}fetchGlobalPreferences(){return a(this,A).get(`${ne}/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,A).post("/inbox/events",e)}fetchSubscriptions(e){return a(this,A).get(`${ne}/topics/${e}/subscriptions`)}getSubscription(e,t,i,r){let s=new URLSearchParams;if(i!=null&&i.length)for(let c of i)s.append("workflowIds",c);if(r!=null&&r.length)for(let c of r)s.append("tags",c);let o=s.size?`?${s.toString()}`:"";return a(this,A).get(`${ne}/topics/${e}/subscriptions/${t}${o}`)}createSubscription({identifier:e,name:t,topicKey:i,topicName:r,preferences:s}){return a(this,A).post(`${ne}/topics/${i}/subscriptions`,y(y({identifier:e,name:t},r&&{topic:{name:r}}),s!==void 0&&{preferences:s}))}updateSubscription({topicKey:e,identifier:t,name:i,preferences:r}){return a(this,A).patch(`${ne}/topics/${e}/subscriptions/${t}`,y({name:i},r!==void 0&&{preferences:r}))}updateSubscriptionPreference({subscriptionIdentifier:e,workflowId:t,enabled:i,condition:r,email:s,sms:o,in_app:c,chat:u,push:h}){return a(this,A).patch(`${ne}/subscriptions/${e}/preferences/${t}`,{enabled:i,condition:r,email:s,sms:o,in_app:c,chat:u,push:h})}bulkUpdateSubscriptionPreferences(e){return a(this,A).patch(`${ne}/preferences/bulk`,{preferences:e})}deleteSubscription({topicKey:e,identifier:t}){return a(this,A).delete(`${ne}/topics/${e}/subscriptions/${t}`)}generateChatOAuthUrl({integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,userScope:o,mode:c,connectionMode:u,autoLinkUser:h}){return a(this,A).post(hl,{integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,userScope:o,mode:c,connectionMode:u,autoLinkUser:h})}generateConnectOAuthUrl({integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,connectionMode:o,autoLinkUser:c}){return a(this,A).post(fl,{integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,scope:s,connectionMode:o,autoLinkUser:c})}generateLinkUserOAuthUrl({integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,userScope:s}){return a(this,A).post(dl,{integrationIdentifier:e,connectionIdentifier:t,subscriberId:i,context:r,userScope:s})}listChannelConnections(e={}){let t=zs(e);return a(this,A).get(`${mn}${t}`,void 0,!1)}getChannelConnection(e){return a(this,A).get(`${mn}/${e}`)}createChannelConnection({identifier:e,integrationIdentifier:t,subscriberId:i,context:r,workspace:s,auth:o}){return a(this,A).post(mn,{identifier:e,integrationIdentifier:t,subscriberId:i,context:r,workspace:s,auth:o})}deleteChannelConnection(e){return a(this,A).delete(`${mn}/${e}`)}listChannelEndpoints(e={}){let t=zs(e);return a(this,A).get(`${Bt}${t}`,void 0,!1)}getChannelEndpoint(e){return a(this,A).get(`${Bt}/${e}`)}createChannelEndpoint({identifier:e,integrationIdentifier:t,connectionIdentifier:i,subscriberId:r,context:s,type:o,endpoint:c}){return a(this,A).post(Bt,{identifier:e,integrationIdentifier:t,connectionIdentifier:i,subscriberId:r,context:s,type:o,endpoint:c})}deleteChannelEndpoint(e){return a(this,A).delete(`${Bt}/${e}`)}linkChannelEndpoint({integrationIdentifier:e}){return a(this,A).post(`${Bt}/link`,{integrationIdentifier:e})}};A=new WeakMap;var E=class extends Error{constructor(e,t){super(e),this.originalError=t}};var st,Mt,j=class{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){v(this,st,[]);v(this,Mt);this._emitter=t,this._inboxService=e,this._emitter.on("session.initialize.resolved",({error:i,data:r})=>{r?(this.onSessionSuccess(r),a(this,st).forEach(c=>d(this,[c],function*({fn:s,resolve:o}){o(yield s())})),b(this,st,[])):i&&(this.onSessionError(i),b(this,Mt,i),a(this,st).forEach(({resolve:s})=>{s({error:new E("Failed to initialize session, please contact the support",i)})}),b(this,st,[]))})}onSessionSuccess(e){}onSessionError(e){}callWithSession(e){return d(this,null,function*(){return this._inboxService.isSessionInitialized?e():a(this,Mt)?Promise.resolve({error:new E("Failed to initialize session, please contact the support",a(this,Mt))}):new Promise((t,i)=>{a(this,st).push({fn:e,resolve:t,reject:i})})})}};st=new WeakMap,Mt=new WeakMap;var Gs=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connection.oauth-url.pending",{args:t});let r=yield e.generateChatOAuthUrl(t);return n.emit("channel-connection.oauth-url.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-connection.oauth-url.resolved",{args:t,error:r}),{error:new E("Failed to generate chat OAuth URL",r)}}}),Vs=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connection.oauth-url.pending",{args:t});let r=yield e.generateConnectOAuthUrl(t);return n.emit("channel-connection.oauth-url.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-connection.oauth-url.resolved",{args:t,error:r}),{error:new E("Failed to generate connect OAuth URL",r)}}}),js=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connections.list.pending",{args:t});let s=(yield e.listChannelConnections(t)).data;return n.emit("channel-connections.list.resolved",{args:t,data:s}),{data:s}}catch(r){return n.emit("channel-connections.list.resolved",{args:t,error:r}),{error:new E("Failed to list channel connections",r)}}}),Hs=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-connection.get.pending",{args:t});let r=yield e.getChannelConnection(t.identifier);return n.emit("channel-connection.get.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-connection.get.resolved",{args:t,error:r}),{error:new E("Failed to get channel connection",r)}}}),Ys=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{return n.emit("channel-connection.delete.pending",{args:t}),yield e.deleteChannelConnection(t.identifier),n.emit("channel-connection.delete.resolved",{args:t}),{data:void 0}}catch(r){return n.emit("channel-connection.delete.resolved",{args:t,error:r}),{error:new E("Failed to delete channel connection",r)}}});var gn=class extends j{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){super({inboxServiceInstance:e,eventEmitterInstance:t})}generateOAuthUrl(e){return d(this,null,function*(){return this.callWithSession(()=>Gs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}generateConnectOAuthUrl(e){return d(this,null,function*(){return this.callWithSession(()=>Vs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}list(){return d(this,arguments,function*(e={}){return this.callWithSession(()=>js({emitter:this._emitter,apiService:this._inboxService,args:e}))})}get(e){return d(this,null,function*(){return this.callWithSession(()=>Hs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}delete(e){return d(this,null,function*(){return this.callWithSession(()=>Ys({emitter:this._emitter,apiService:this._inboxService,args:e}))})}};var Js=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoint.oauth-url.pending",{args:t});let r=yield e.generateLinkUserOAuthUrl(t);return n.emit("channel-endpoint.oauth-url.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-endpoint.oauth-url.resolved",{args:t,error:r}),{error:new E("Failed to generate link user OAuth URL",r)}}}),Xs=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoints.list.pending",{args:t});let s=(yield e.listChannelEndpoints(t)).data;return n.emit("channel-endpoints.list.resolved",{args:t,data:s}),{data:s}}catch(r){return n.emit("channel-endpoints.list.resolved",{args:t,error:r}),{error:new E("Failed to list channel endpoints",r)}}}),Qs=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoint.get.pending",{args:t});let r=yield e.getChannelEndpoint(t.identifier);return n.emit("channel-endpoint.get.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-endpoint.get.resolved",{args:t,error:r}),{error:new E("Failed to get channel endpoint",r)}}}),Zs=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoint.create.pending",{args:t});let r=yield e.createChannelEndpoint(t);return n.emit("channel-endpoint.create.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-endpoint.create.resolved",{args:t,error:r}),{error:new E("Failed to create channel endpoint",r)}}}),eo=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{return n.emit("channel-endpoint.delete.pending",{args:t}),yield e.deleteChannelEndpoint(t.identifier),n.emit("channel-endpoint.delete.resolved",{args:t}),{data:void 0}}catch(r){return n.emit("channel-endpoint.delete.resolved",{args:t,error:r}),{error:new E("Failed to delete channel endpoint",r)}}}),to=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){try{n.emit("channel-endpoint.link.pending",{args:t});let r=yield e.linkChannelEndpoint(t);return n.emit("channel-endpoint.link.resolved",{args:t,data:r}),{data:r}}catch(r){return n.emit("channel-endpoint.link.resolved",{args:t,error:r}),{error:new E("Failed to link channel endpoint",r)}}});var yn=class extends j{constructor({inboxServiceInstance:e,eventEmitterInstance:t}){super({inboxServiceInstance:e,eventEmitterInstance:t})}generateLinkUserOAuthUrl(e){return d(this,null,function*(){return this.callWithSession(()=>Js({emitter:this._emitter,apiService:this._inboxService,args:e}))})}list(){return d(this,arguments,function*(e={}){return this.callWithSession(()=>Xs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}get(e){return d(this,null,function*(){return this.callWithSession(()=>Qs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}create(e){return d(this,null,function*(){return this.callWithSession(()=>Zs({emitter:this._emitter,apiService:this._inboxService,args:e}))})}delete(e){return d(this,null,function*(){return this.callWithSession(()=>eo({emitter:this._emitter,apiService:this._inboxService,args:e}))})}link(e){return d(this,null,function*(){return this.callWithSession(()=>to({emitter:this._emitter,apiService:this._inboxService,args:e}))})}};function no(n){return{all:n=n||new Map,on:function(e,t){var i=n.get(e);i?i.push(t):n.set(e,[t])},off:function(e,t){var i=n.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var i=n.get(e);i&&i.slice().map(function(r){r(t)}),(i=n.get("*"))&&i.slice().map(function(r){r(e,t)})}}}var _t,gi=class{constructor(){v(this,_t);b(this,_t,no())}on(e,t){return a(this,_t).on(e,t),()=>{this.off(e,t)}}off(e,t){a(this,_t).off(e,t)}emit(e,t){a(this,_t).emit(e,t)}};_t=new WeakMap;function io({notification:n,emitter:e,inboxService:t}){return n instanceof U||typeof n.read=="function"?n:new U(n,e,t)}var yi=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0},{emitter:n,apiService:e});try{n.emit("notification.read.pending",{args:t,data:s});let o=yield e.read(r),c=new U(o,n,e);return n.emit("notification.read.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.read.resolved",{args:t,error:o}),{error:new E("Failed to read notification",o)}}}),vi=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isRead:!1,readAt:null,isArchived:!1,archivedAt:void 0},{emitter:n,apiService:e});try{n.emit("notification.unread.pending",{args:t,data:s});let o=yield e.unread(r),c=new U(o,n,e);return n.emit("notification.unread.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.unread.resolved",{args:t,error:o}),{error:new E("Failed to unread notification",o)}}}),bi=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isSeen:!0},{emitter:n,apiService:e});try{if(n.emit("notification.seen.pending",{args:t,data:s}),yield e.seen(r),!s)throw new Error("Failed to create optimistic value for notification");let o=new U(s,n,e);return n.emit("notification.seen.resolved",{args:t,data:o}),{data:o}}catch(o){return n.emit("notification.seen.resolved",{args:t,error:o}),{error:new E("Failed to mark notification as seen",o)}}}),Si=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isArchived:!0,archivedAt:new Date().toISOString(),isRead:!0,readAt:new Date().toISOString()},{emitter:n,apiService:e});try{n.emit("notification.archive.pending",{args:t,data:s});let o=yield e.archive(r),c=new U(o,n,e);return n.emit("notification.archive.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.archive.resolved",{args:t,error:o}),{error:new E("Failed to archive notification",o)}}}),_i=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isArchived:!1,archivedAt:null,isRead:!0,readAt:new Date().toISOString()},{emitter:n,apiService:e});try{n.emit("notification.unarchive.pending",{args:t,data:s});let o=yield e.unarchive(r),c=new U(o,n,e);return n.emit("notification.unarchive.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.unarchive.resolved",{args:t,error:o}),{error:new E("Failed to unarchive notification",o)}}}),Ei=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isSnoozed:!0,snoozedUntil:t.snoozeUntil},{emitter:n,apiService:e});try{n.emit("notification.snooze.pending",{args:t,data:s});let o=yield e.snooze(r,t.snoozeUntil),c=new U(o,n,e);return n.emit("notification.snooze.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.snooze.resolved",{args:t,error:o}),{error:new E("Failed to snooze notification",o)}}}),Ci=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r,optimisticValue:s}=Ue(t,{isSnoozed:!1,snoozedUntil:null},{emitter:n,apiService:e});try{n.emit("notification.unsnooze.pending",{args:t,data:s});let o=yield e.unsnooze(r),c=new U(o,n,e);return n.emit("notification.unsnooze.resolved",{args:t,data:c}),{data:c}}catch(o){return n.emit("notification.unsnooze.resolved",{args:t,error:o}),{error:new E("Failed to unsnooze notification",o)}}}),qt=r=>d(null,[r],function*({emitter:n,apiService:e,args:t,actionType:i}){let s=i==="primary"?{primaryAction:x(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!0})}:{secondaryAction:x(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!0})},{notificationId:o,optimisticValue:c}=Ue(t,s,{emitter:n,apiService:e});try{n.emit("notification.complete_action.pending",{args:t,data:c});let u=yield e.completeAction({actionType:i,notificationId:o}),h=new U(u,n,e);return n.emit("notification.complete_action.resolved",{args:t,data:h}),{data:h}}catch(u){return n.emit("notification.complete_action.resolved",{args:t,error:u}),{error:new E(`Failed to complete ${i} action on the notification`,u)}}}),Wt=r=>d(null,[r],function*({emitter:n,apiService:e,args:t,actionType:i}){let s=i==="primary"?{primaryAction:x(y({},"notification"in t?t.notification.primaryAction:{}),{isCompleted:!1})}:{secondaryAction:x(y({},"notification"in t?t.notification.secondaryAction:{}),{isCompleted:!1})},{notificationId:o,optimisticValue:c}=Ue(t,s,{emitter:n,apiService:e});try{n.emit("notification.revert_action.pending",{args:t,data:c});let u=yield e.revertAction({actionType:i,notificationId:o}),h=new U(u,n,e);return n.emit("notification.revert_action.resolved",{args:t,data:h}),{data:h}}catch(u){return n.emit("notification.revert_action.resolved",{args:t,error:u}),{error:new E("Failed to fetch notifications",u)}}}),Ue=(n,e,t)=>"notification"in n?{notificationId:n.notification.id,optimisticValue:new U(y(y({},n.notification),e),t.emitter,t.apiService)}:{notificationId:n.notificationId},ro=s=>d(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let c=t.getUniqueNotifications({tags:i,data:r}).map(u=>new U(x(y({},u),{isRead:!0,readAt:new Date().toISOString(),isArchived:!1,archivedAt:void 0}),n,e));return n.emit("notifications.read_all.pending",{args:{tags:i,data:r},data:c}),yield e.readAll({tags:i,data:r}),n.emit("notifications.read_all.resolved",{args:{tags:i,data:r},data:c}),{}}catch(o){return n.emit("notifications.read_all.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to read all notifications",o)}}}),Ur=o=>d(null,[o],function*({emitter:n,inboxService:e,notificationsCache:t,notificationIds:i,tags:r,data:s}){try{let c=t.getUniqueNotifications({tags:r,data:s}),h=(i&&i.length>0?c.filter(l=>i.includes(l.id)):c).map(l=>new U(x(y({},l),{isSeen:!0,firstSeenAt:l.firstSeenAt||new Date().toISOString()}),n,e));return n.emit("notifications.seen_all.pending",{args:{notificationIds:i,tags:r,data:s},data:h}),yield e.markAsSeen({notificationIds:i,tags:r,data:s}),n.emit("notifications.seen_all.resolved",{args:{notificationIds:i,tags:r,data:s},data:h}),{}}catch(c){return n.emit("notifications.seen_all.resolved",{args:{notificationIds:i,tags:r,data:s},error:c}),{error:new E("Failed to mark all notifications as seen",c)}}}),so=s=>d(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let c=t.getUniqueNotifications({tags:i,data:r}).map(u=>new U(x(y({},u),{isRead:!0,readAt:new Date().toISOString(),isArchived:!0,archivedAt:new Date().toISOString()}),n,e));return n.emit("notifications.archive_all.pending",{args:{tags:i,data:r},data:c}),yield e.archiveAll({tags:i,data:r}),n.emit("notifications.archive_all.resolved",{args:{tags:i,data:r},data:c}),{}}catch(o){return n.emit("notifications.archive_all.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to archive all notifications",o)}}}),oo=s=>d(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let c=t.getUniqueNotifications({tags:i,data:r,read:!0}).map(u=>new U(x(y({},u),{isArchived:!0,archivedAt:new Date().toISOString()}),n,e));return n.emit("notifications.archive_all_read.pending",{args:{tags:i,data:r},data:c}),yield e.archiveAllRead({tags:i,data:r}),n.emit("notifications.archive_all_read.resolved",{args:{tags:i,data:r},data:c}),{}}catch(o){return n.emit("notifications.archive_all_read.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to archive all read notifications",o)}}}),wi=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let{notificationId:r}=Ue(t,{},{emitter:n,apiService:e});try{return n.emit("notification.delete.pending",{args:t}),yield e.delete(r),n.emit("notification.delete.resolved",{args:t}),{}}catch(s){return n.emit("notification.delete.resolved",{args:t,error:s}),{error:new E("Failed to delete notification",s)}}}),ao=s=>d(null,[s],function*({emitter:n,inboxService:e,notificationsCache:t,tags:i,data:r}){try{let o=t.getUniqueNotifications({tags:i,data:r});return n.emit("notifications.delete_all.pending",{args:{tags:i,data:r},data:o}),yield e.deleteAll({tags:i,data:r}),n.emit("notifications.delete_all.resolved",{args:{tags:i,data:r}}),{}}catch(o){return n.emit("notifications.delete_all.resolved",{args:{tags:i,data:r},error:o}),{error:new E("Failed to delete all notifications",o)}}});var H,le,U=class{constructor(e,t,i){v(this,H);v(this,le);b(this,H,t),b(this,le,i),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 yi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}unread(){return vi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}seen(){return bi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}archive(){return Si({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}unarchive(){return _i({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}delete(){return wi({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}snooze(e){return Ei({emitter:a(this,H),apiService:a(this,le),args:{notification:this,snoozeUntil:e}})}unsnooze(){return Ci({emitter:a(this,H),apiService:a(this,le),args:{notification:this}})}completePrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return qt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"primary"})}completeSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return qt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"secondary"})}revertPrimary(){if(!this.primaryAction)throw new Error("Primary action is not available");return Wt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"primary"})}revertSecondary(){if(!this.primaryAction)throw new Error("Secondary action is not available");return Wt({emitter:a(this,H),apiService:a(this,le),args:{notification:this},actionType:"secondary"})}on(e,t){let i=a(this,H).on(e,t);return()=>{i()}}off(e,t){a(this,H).off(e,t)}};H=new WeakMap,le=new WeakMap;var co=(n,e)=>n===e?!0:!n||!e||n.length!==e.length?!1:n.every((t,i)=>t===e[i]);var Bd=["seen","unseen"],Md=["read","unread"],lo=30,xi=100,uo=200,K=class extends Error{constructor(e){super(e),this.name="TagsFilterValidationError"}};function ho(n,e){if(n.length>e)throw new K(`At most ${e} tags are allowed in a single OR-group`);for(let t of n)if(typeof t!="string")throw new K("Tags must be strings");return n}function ml(n){let e=Object.keys(n),t=Object.prototype.hasOwnProperty.call(n,"or"),i=Object.prototype.hasOwnProperty.call(n,"and");if(t&&i)throw new K('Tags filter cannot have both "or" and "and"');if(t){if(e.length!==1)throw new K("Invalid tags filter object");let r=n.or;if(!Array.isArray(r))throw new K('"or" must be an array of strings');return r.length===0?[]:[ho(r,xi)]}if(i){if(e.length!==1)throw new K("Invalid tags filter object");let r=n.and;if(!Array.isArray(r))throw new K('"and" must be an array');if(r.length===0)return[];if(r.length>lo)throw new K(`At most ${lo} tag groups are allowed`);let s=[],o=0;for(let c of r){if(typeof c!="object"||c===null||Array.isArray(c))throw new K('Each "and" entry must be an object { or: string[] }');if(Object.keys(c).length!==1||!Object.prototype.hasOwnProperty.call(c,"or"))throw new K('Each "and" entry must be { or: string[] }');let h=c.or;if(!Array.isArray(h))throw new K('"or" must be an array of strings');if(h.length===0)throw new K("Each tag group must be a non-empty array of strings");let l=ho(h,xi);o+=l.length,s.push(l)}if(o>uo)throw new K(`At most ${uo} total tag values are allowed`);return s}throw new K('Tags filter object must have "or" or "and"')}function po(n){if(n===void 0)return[];if(n===null)throw new K("Tags must be an array or object");if(typeof n=="object"&&!Array.isArray(n))return ml(n);if(!Array.isArray(n))throw new K("Tags must be an array or object");if(n.length===0)return[];if(Array.isArray(n[0]))throw new K("Nested tag arrays are not supported; use { and: [{ or: string[] }, ...] } for multiple OR-groups");let e=n;if(e.length>xi)throw new K(`At most ${xi} tags are allowed in a single OR-group`);for(let t of e)if(typeof t!="string")throw new K("Tags must be strings");return[e]}function fo(n){if(n===void 0)return"";let e=po(n);if(e.length===0)return"";let t=Array.from(new Map(e.map(i=>{let r=Array.from(new Set(i)).sort((s,o)=>s.localeCompare(o));return[JSON.stringify(r),r]})).values()).sort((i,r)=>JSON.stringify(i).localeCompare(JSON.stringify(r)));return JSON.stringify(t)}var Dr=(n,e)=>{try{return fo(n)===fo(e)}catch(t){return!1}},gl=(n,e)=>{let t=Array.isArray(n)?n:n?[n]:[],i=Array.isArray(e)?e:e?[e]:[];return co(t,i)},Br=(n,e)=>{if(!n&&!e)return!0;if(!n||!e)return!1;try{return JSON.stringify(n)===JSON.stringify(e)}catch(t){return!1}},Mr=(n,e)=>Br(n.data,e.data)&&Dr(n.tags,e.tags)&&n.read===e.read&&n.archived===e.archived&&n.snoozed===e.snoozed&&n.seen===e.seen&&gl(n.severity,e.severity)&&n.createdGte===e.createdGte&&n.createdLte===e.createdLte;function mo(n,e){let t;try{t=po(e)}catch(i){return!1}return t.length===0?!0:!n||n.length===0?!1:t.every(i=>i.some(r=>n.includes(r)))}function go(n,e){return!(e.read!==void 0&&n.isRead!==e.read||e.seen!==void 0&&n.isSeen!==e.seen||e.archived!==void 0&&n.isArchived!==e.archived||e.snoozed!==void 0&&n.isSnoozed!==e.snoozed)}var ke,Re=class{constructor(){v(this,ke);b(this,ke,new Map)}get(e){return a(this,ke).get(e)}getValues(){return Array.from(a(this,ke).values())}entries(){return Array.from(a(this,ke).entries())}keys(){return Array.from(a(this,ke).keys())}set(e,t){a(this,ke).set(e,t)}remove(e){a(this,ke).delete(e)}clear(){a(this,ke).clear()}};ke=new WeakMap;var yo=({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>Object.entries({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f}).filter(([m,p])=>p!=null&&!(Array.isArray(p)&&p.length===0)).reduce((m,[p,w])=>(m[p]=w,m),{}),vn=({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})=>JSON.stringify(yo({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,limit:c,offset:u,after:h,createdGte:l,createdLte:f})),yl=({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,createdGte:c,createdLte:u})=>JSON.stringify(yo({tags:n,data:e,read:t,archived:i,snoozed:r,seen:s,severity:o,createdGte:c,createdLte:u})),ot=n=>JSON.parse(n),vl=["notification.read.pending","notification.read.resolved","notification.unread.pending","notification.unread.resolved","notification.seen.pending","notification.seen.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","notifications.seen_all.pending","notifications.seen_all.resolved"],bl=["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"],$e,Sn,q,at,_n,bn=class{constructor({emitter:e,inboxService:t}){v(this,$e);v(this,Sn);v(this,q);v(this,at,e=>io({notification:e,emitter:a(this,$e),inboxService:a(this,Sn)}));v(this,_n,e=>e.map(t=>a(this,at).call(this,t)));this.syncNotificationInBucket=(e,t)=>{let i=a(this,at).call(this,t),r=a(this,q).get(e);if(!r)return!1;let s=ot(e),o=go(i,s)&&mo(i.tags,s.tags),c=r.notifications.findIndex(h=>h.id===i.id),u=c!==-1;if(o&&u){let h=[...r.notifications];return h[c]=i,a(this,q).set(e,x(y({},r),{notifications:h})),!0}return!o&&u?this.removeNotification(e,i):!1};this.removeNotification=(e,t)=>{let i=a(this,q).get(e);if(!i)return!1;let r=i.notifications.findIndex(o=>o.id===t.id);if(r===-1)return!1;let s=[...i.notifications];return s.splice(r,1),a(this,q).set(e,x(y({},i),{notifications:s})),!0};this.handleNotificationEvent=({remove:e}={remove:!1})=>t=>{let{data:i,args:r}=t,s=[];if(i!=null)Array.isArray(i)&&i.every(c=>typeof c=="object"&&"id"in c)?s=a(this,_n).call(this,i):typeof i=="object"&&"id"in i&&(s=[a(this,at).call(this,i)]);else if(e&&r){if("notification"in r&&r.notification)s=[a(this,at).call(this,r.notification)];else if("notificationId"in r&&r.notificationId){let c=[];a(this,q).keys().forEach(u=>{let h=a(this,q).get(u);if(h){let l=h.notifications.find(f=>f.id===r.notificationId);l&&c.push(l)}}),s=c}}if(s.length===0)return;let o=new Set;a(this,q).keys().forEach(c=>{s.forEach(u=>{let h=!1;e?h=this.removeNotification(c,u):h=this.syncNotificationInBucket(c,u),h&&o.add(yl(ot(c)))})}),o.forEach(c=>{let u=this.getAggregated(ot(c));a(this,$e).emit("notifications.list.updated",{data:u})})};b(this,$e,e),b(this,Sn,t),vl.forEach(i=>{a(this,$e).on(i,this.handleNotificationEvent())}),bl.forEach(i=>{a(this,$e).on(i,this.handleNotificationEvent({remove:!0}))}),b(this,q,new Re)}getAggregated(e){let t=a(this,q).keys().filter(s=>{let o=ot(s);return Mr(o,e)}),i=new Map,r=!1;for(let s of t){let o=a(this,q).get(s);if(o){r=o.hasMore;for(let c of o.notifications)i.set(c.id,c)}}return{hasMore:r,filter:e,notifications:Array.from(i.values())}}get(e){return a(this,q).get(vn(e))}has(e){return a(this,q).get(vn(e))!==void 0}set(e,t){a(this,q).set(vn(e),x(y({},t),{notifications:a(this,_n).call(this,t.notifications)}))}unshift(e,t){let i=vn(e),r=a(this,q).get(i)||{hasMore:!1,filter:ot(i),notifications:[]},s=a(this,at).call(this,y({},t)),o=r.notifications.filter(c=>c.id!==t.id);this.update(e,x(y({},r),{notifications:[s,...o]}))}update(e,t){this.set(e,t);let i=this.getAggregated(ot(vn(e)));a(this,$e).emit("notifications.list.updated",{data:i})}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,createdGte:e.createdGte,createdLte:e.createdLte})}getUniqueNotifications({tags:e,read:t,data:i}){let r=a(this,q).keys(),s=new Map;return r.forEach(o=>{let c=ot(o);if(Dr(e,c.tags)&&Br(i,c.data)){let u=a(this,q).get(o);if(!u)return;u.notifications.filter(h=>typeof t=="undefined"||t===h.isRead).forEach(h=>{s.set(h.id,h)})}}),Array.from(s.values())}clear(e){a(this,q).keys().forEach(i=>{Mr(ot(i),e)&&a(this,q).remove(i)})}clearAll(){a(this,q).clear()}};$e=new WeakMap,Sn=new WeakMap,q=new WeakMap,at=new WeakMap,_n=new WeakMap;var En,Cn,wn,xn,Ke=class{constructor(e,t,i,r,s){v(this,En);v(this,Cn);v(this,wn);v(this,xn);var o;b(this,En,t),b(this,Cn,i),b(this,wn,r),b(this,xn,s),this.enabled=e.enabled,this.condition=(o=e.condition)!=null?o:void 0,this.workflow=e.workflow,this.subscriptionId=e.subscriptionId}update(e){return d(this,null,function*(){var t;return Ai({emitter:a(this,En),apiService:a(this,Cn),cache:a(this,wn),useCache:a(this,xn),args:{subscriptionId:this.subscriptionId,workflowId:(t=this.workflow)==null?void 0:t.id,value:e.value,preference:this}})})}};En=new WeakMap,Cn=new WeakMap,wn=new WeakMap,xn=new WeakMap;var vo=s=>d(null,[s],function*({emitter:n,apiService:e,cache:t,options:i,args:r}){try{let{useCache:o,refetch:c}=i,u=o&&!c?t.getAll(r):void 0;return n.emit("subscriptions.list.pending",{args:r,data:u}),(!u||c)&&(u=(yield e.fetchSubscriptions(r.topicKey)).map(l=>new ze(x(y({},l),{topicKey:r.topicKey}),n,e,t,o)),o&&(t.set(r,u),u=t.getAll(r))),n.emit("subscriptions.list.resolved",{args:r,data:u}),{data:u}}catch(o){return n.emit("subscriptions.list.resolved",{args:r,error:o}),{error:new E("Failed to fetch subscriptions",o)}}}),bo=s=>d(null,[s],function*({emitter:n,apiService:e,cache:t,options:i,args:r}){try{let{useCache:o,refetch:c}=i,u=o&&!c?t.get(r):void 0;if(n.emit("subscription.get.pending",{args:r,data:u}),!u||c){let h=yield e.getSubscription(r.topicKey,r.identifier,r.workflowIds,r.tags);if(!h)return n.emit("subscription.get.resolved",{args:r,data:null}),{data:null};u=new ze(x(y({},h),{topicKey:r.topicKey}),n,e,t,o),o&&(t.setOne(r,u),u=t.get(r))}return n.emit("subscription.get.resolved",{args:r,data:u}),{data:u}}catch(o){return n.emit("subscription.get.resolved",{args:r,error:o}),{error:new E("Failed to fetch subscription",o)}}}),So=s=>d(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){var o;try{n.emit("subscription.create.pending",{args:r});let c=yield e.createSubscription({identifier:(o=r.identifier)!=null?o:"",name:r.name,topicKey:r.topicKey,topicName:r.topicName,preferences:r.preferences}),u=new ze(x(y({},c),{topicKey:r.topicKey}),n,e,t,i);return n.emit("subscription.create.resolved",{args:r,data:u}),{data:u}}catch(c){return n.emit("subscription.create.resolved",{args:r,error:c}),{error:new E("Failed to create subscription",c)}}}),Ni=s=>d(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){let o="identifier"in r?r.identifier:r.subscription.identifier,c="topicKey"in r?r.topicKey:r.subscription.topicKey;try{n.emit("subscription.update.pending",{args:r});let u=yield e.updateSubscription({topicKey:c,identifier:o,name:r.name,preferences:r.preferences}),h=new ze(x(y({},u),{topicKey:c}),n,e,t,i);return n.emit("subscription.update.resolved",{args:r,data:h}),{data:h}}catch(u){return n.emit("subscription.update.resolved",{args:r,error:u}),{error:new E("Failed to update subscription",u)}}}),Ai=s=>d(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){var c,u;let o="workflowId"in r?r.workflowId:(u=(c=r.preference)==null?void 0:c.workflow)==null?void 0:u.id;try{n.emit("subscription.preference.update.pending",{args:r,data:"preference"in r?new Ke(y(y({},r.preference),typeof r.value=="boolean"?{enabled:r.value}:{condition:r.value}),n,e,t,i):void 0});let h=yield e.updateSubscriptionPreference(y({subscriptionIdentifier:r.subscriptionId,workflowId:o},typeof r.value=="boolean"?{enabled:r.value,email:r.value,sms:r.value,in_app:r.value,chat:r.value,push:r.value}:{condition:r.value})),l=new Ke(y({},h),n,e,t,i);return n.emit("subscription.preference.update.resolved",{args:r,data:l}),{data:l}}catch(h){return n.emit("subscription.preference.update.resolved",{args:r,error:h}),{error:new E("Failed to update subscription",h)}}}),_o=s=>d(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){try{let o=r.map(l=>"preference"in l?new Ke(y(y({},l.preference),typeof l.value=="boolean"?{enabled:l.value}:{condition:l.value}),n,e,t,i):void 0).filter(l=>l!==void 0);n.emit("subscription.preferences.bulk_update.pending",{args:r,data:o});let c=r.map(l=>{var f,m,p,w,g,S;return y({subscriptionIdentifier:l.subscriptionId,workflowId:"workflowId"in l?l.workflowId:(S=(g=(m=(f=l.preference)==null?void 0:f.workflow)==null?void 0:m.id)!=null?g:(w=(p=l.preference)==null?void 0:p.workflow)==null?void 0:w.identifier)!=null?S:""},typeof l.value=="boolean"?{enabled:l.value,email:l.value,sms:l.value,in_app:l.value,chat:l.value,push:l.value}:{condition:l.value})}),h=(yield e.bulkUpdateSubscriptionPreferences(c)).map(l=>new Ke(l,n,e,t,i));return n.emit("subscription.preferences.bulk_update.resolved",{args:r,data:h}),{data:h}}catch(o){return n.emit("subscription.preferences.bulk_update.resolved",{args:r,error:o}),{error:new E("Failed to bulk update subscription preferences",o)}}}),ki=i=>d(null,[i],function*({emitter:n,apiService:e,args:t}){let r="identifier"in t?t.identifier:t.subscription.identifier,s="topicKey"in t?t.topicKey:t.subscription.topicKey;try{return n.emit("subscription.delete.pending",{args:t}),yield e.deleteSubscription({topicKey:s,identifier:r}),n.emit("subscription.delete.resolved",{args:t}),{data:void 0}}catch(o){return n.emit("subscription.delete.resolved",{args:t,error:o}),{error:new E("Failed to delete subscription",o)}}});var Ge,Ve,ct,lt,$t,ze=class{constructor(e,t,i,r,s){v(this,Ge);v(this,Ve);v(this,ct);v(this,lt);v(this,$t,!1);var o;b(this,Ge,t),b(this,Ve,i),b(this,ct,r),b(this,lt,s),this.id=e.id,this.identifier=e.identifier,this.topicKey=e.topicKey,this.preferences=(o=e.preferences)==null?void 0:o.map(c=>new Ke(y({},c),a(this,Ge),a(this,Ve),a(this,ct),a(this,lt)))}update(e){return d(this,null,function*(){return Ni({emitter:a(this,Ge),apiService:a(this,Ve),cache:a(this,ct),useCache:a(this,lt),args:x(y({},e),{subscription:this})})})}updatePreference(e){return d(this,null,function*(){return a(this,$t)?{error:new E("Cannot update a deleted subscription",new Error("Subscription is stale"))}:Ai({emitter:a(this,Ge),apiService:a(this,Ve),cache:a(this,ct),useCache:a(this,lt),args:x(y({},e),{subscriptionId:this.identifier})})})}bulkUpdatePreferences(e){return d(this,null,function*(){return a(this,$t)?{error:new E("Cannot bulk update a deleted subscription",new Error("Subscription is stale"))}:_o({emitter:a(this,Ge),apiService:a(this,Ve),cache:a(this,ct),useCache:a(this,lt),args:e.map(t=>x(y({},t),{subscriptionId:this.identifier}))})})}delete(){return d(this,null,function*(){return a(this,$t)?{error:new E("Cannot delete an already deleted subscription",new Error("Subscription is stale"))}:ki({emitter:a(this,Ge),apiService:a(this,Ve),args:{subscription:this}})})}};Ge=new WeakMap,Ve=new WeakMap,ct=new WeakMap,lt=new WeakMap,$t=new WeakMap;var Et=n=>`list:${n.topicKey}`,Eo=n=>n.split(":")[1],ut=n=>`item:${n.topicKey}:${n.identifier}`,ie,W,An,z,Nn,Ri=class{constructor({emitterInstance:e,inboxServiceInstance:t,useCache:i}){v(this,ie);v(this,W);v(this,An);v(this,z);v(this,Nn);this.handleCreate=e=>{let t=Et({topicKey:e.topicKey}),i=a(this,W).get(t);if(i){let r=[...i,e];a(this,W).set(t,r),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).set(ut({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handleUpdate=e=>{let t=Et({topicKey:e.topicKey}),i=a(this,W).get(t);if(i){let r=i.map(s=>s.id===e.id?e:s);a(this,W).set(t,r),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).set(ut({topicKey:e.topicKey,identifier:e.identifier}),e)};this.handlePreferenceUpdate=e=>{this.updateSubscriptionPreferences([e])};this.handleBulkPreferenceUpdate=e=>{this.updateSubscriptionPreferences(e)};this.updateSubscriptionPreferences=e=>{var s;let t=new Map;for(let o of e){let c=(s=t.get(o.subscriptionId))!=null?s:[];c.push(o),t.set(o.subscriptionId,c)}let i=a(this,W).keys();for(let o of i){let c=a(this,W).get(o);if(!c)continue;let u=!1,h=c.map(l=>{let f=t.get(l.identifier);return f?(u=!0,this.createUpdatedSubscription(l,f)):l});u&&(a(this,W).set(o,h),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:Eo(o),subscriptions:h}}))}let r=a(this,z).keys();for(let o of r){let c=a(this,z).get(o);if(!c)continue;let u=t.get(c.identifier);if(u){let h=this.createUpdatedSubscription(c,u);a(this,z).set(o,h),a(this,ie).emit("subscription.update.resolved",{args:{subscription:c},data:h})}}};this.createUpdatedSubscription=(e,t)=>{var r;let i=(r=e.preferences)==null?void 0:r.map(s=>{let o=t.find(c=>c.workflow.id===s.workflow.id);return o||s});return new ze({id:e.id,identifier:e.identifier,topicKey:e.topicKey,preferences:i},a(this,ie),a(this,Nn),this,a(this,An))};this.handleDelete=e=>{let t=Et({topicKey:e.topicKey}),i=a(this,W).get(t);if(i){let r=i.filter(s=>s.id!==e.id);a(this,W).set(t,r),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:e.topicKey,subscriptions:r}})}a(this,z).remove(ut({topicKey:e.topicKey,identifier:e.identifier}))};this.handleDeleteByIdentifier=e=>{let t=a(this,W).keys();for(let r of t){let s=a(this,W).get(r);if(s){let o=s.find(c=>c.identifier===e);if(o){let c=s.filter(u=>u.identifier!==e);a(this,W).set(r,c),a(this,ie).emit("subscriptions.list.updated",{data:{topicKey:Eo(r),subscriptions:c}}),a(this,z).remove(ut({topicKey:o.topicKey,identifier:o.identifier}));return}}}let i=a(this,z).keys();for(let r of i){let s=a(this,z).get(r);if(s&&s.identifier===e){a(this,z).remove(r);return}}};b(this,ie,e),b(this,W,new Re),b(this,z,new Re),b(this,Nn,t),b(this,An,i),a(this,ie).on("subscription.create.resolved",({data:r})=>{r&&this.handleCreate(r)}),a(this,ie).on("subscription.update.resolved",({data:r})=>{r&&this.handleUpdate(r)}),a(this,ie).on("subscription.delete.resolved",({args:r})=>{"subscription"in r?this.handleDelete(r.subscription):"identifier"in r&&this.handleDeleteByIdentifier(r.identifier)}),a(this,ie).on("subscription.preference.update.pending",({data:r})=>{r&&this.handlePreferenceUpdate(r)}),a(this,ie).on("subscription.preference.update.resolved",({data:r})=>{r&&this.handlePreferenceUpdate(r)}),a(this,ie).on("subscription.preferences.bulk_update.resolved",({data:r})=>{r&&r.length>0&&this.handleBulkPreferenceUpdate(r)})}has(e){return a(this,W).get(Et(e))!==void 0}set(e,t){a(this,W).set(Et(e),t);for(let i of t)a(this,z).set(ut({topicKey:e.topicKey,identifier:i.identifier}),i)}setOne(e,t){a(this,z).set(ut(e),t)}getAll(e){return a(this,W).get(Et(e))}get(e){return a(this,z).get(ut(e))}invalidate(e){let t=Et({topicKey:e.topicKey}),i=a(this,W).get(t);if(i)for(let s of i)a(this,z).remove(ut({topicKey:e.topicKey,identifier:s.identifier}));a(this,W).remove(t);let r=a(this,z).keys();for(let s of r)s.startsWith(`item:${e.topicKey}:`)&&a(this,z).remove(s)}clearAll(){a(this,W).clear(),a(this,z).clear()}};ie=new WeakMap,W=new WeakMap,An=new WeakMap,z=new WeakMap,Nn=new WeakMap;var kn,Oi=class extends j{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:r}){super({eventEmitterInstance:r,inboxServiceInstance:i});v(this,kn);this.cache=new bn({emitter:r,inboxService:i}),b(this,kn,t)}list(){return d(this,arguments,function*(r={}){var s=r,{limit:t=10}=s,i=pn(s,["limit"]);return this.callWithSession(()=>d(this,null,function*(){let o=y({limit:t},i);try{let c="useCache"in o?o.useCache:a(this,kn),u=c?this.cache.getAll(o):void 0;if(this._emitter.emit("notifications.list.pending",{args:o,data:u}),!u){let h=yield this._inboxService.fetchNotifications(y({limit:t},i));u={hasMore:h.hasMore,filter:h.filter,notifications:h.data.map(l=>new U(l,this._emitter,this._inboxService))},c&&(this.cache.set(o,u),u=this.cache.getAll(o))}return this._emitter.emit("notifications.list.resolved",{args:o,data:u}),{data:u}}catch(c){return this._emitter.emit("notifications.list.resolved",{args:o,error:c}),{error:new E("Failed to fetch notifications",c)}}}))})}count(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){let i=t&&"filters"in t?t.filters:[y({},t)];try{this._emitter.emit("notifications.count.pending",{args:t});let r=yield this._inboxService.count({filters:i}),s=t&&"filters"in t?{counts:r.data}:r.data[0];return this._emitter.emit("notifications.count.resolved",{args:t,data:s}),{data:s}}catch(r){return this._emitter.emit("notifications.count.resolved",{args:t,error:r}),{error:new E("Failed to count notifications",r)}}}))})}read(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return yi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unread(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return vi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}seen(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return bi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}archive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Si({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unarchive(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return _i({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return wi({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}snooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ei({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}unsnooze(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Ci({emitter:this._emitter,apiService:this._inboxService,args:t})}))})}completePrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return qt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}completeSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return qt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}revertPrimary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Wt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"primary"})}))})}revertSecondary(t){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){return Wt({emitter:this._emitter,apiService:this._inboxService,args:t,actionType:"secondary"})}))})}readAll(){return d(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>d(this,null,function*(){return ro({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}seenAll(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){return"notificationIds"in t?Ur({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,notificationIds:t.notificationIds}):Ur({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:"tags"in t?t.tags:void 0,data:"data"in t?t.data:void 0})}))})}archiveAll(){return d(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>d(this,null,function*(){return so({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}archiveAllRead(){return d(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>d(this,null,function*(){return oo({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}deleteAll(){return d(this,arguments,function*({tags:t,data:i}={}){return this.callWithSession(()=>d(this,null,function*(){return ao({emitter:this._emitter,inboxService:this._inboxService,notificationsCache:this.cache,tags:t,data:i})}))})}clearCache({filter:t}={}){if(t){this.cache.clear(t!=null?t:{});return}this.cache.clearAll()}triggerHelloWorldEvent(){return d(this,null,function*(){return this._inboxService.triggerHelloWorldEvent()})}};kn=new WeakMap;var Rn,On,Tn,In,je=class{constructor(e,{emitterInstance:t,inboxServiceInstance:i,cache:r,useCache:s}){v(this,Rn);v(this,On);v(this,Tn);v(this,In);b(this,Rn,t),b(this,On,i),b(this,Tn,r),b(this,In,s),this.isEnabled=e.isEnabled,this.weeklySchedule=e.weeklySchedule}update(e){return d(this,null,function*(){var i;let t=!!e.weeklySchedule||!!this.weeklySchedule;return Ti({emitter:a(this,Rn),apiService:a(this,On),cache:a(this,Tn),useCache:a(this,In),args:y({isEnabled:(i=e.isEnabled)!=null?i:this.isEnabled},t&&{weeklySchedule:y(y({},this.weeklySchedule),e.weeklySchedule)})})})}};Rn=new WeakMap,On=new WeakMap,Tn=new WeakMap,In=new WeakMap;var Pn,Fn,Ln,Un,Dn,De=class{constructor(e,{emitterInstance:t,inboxServiceInstance:i,cache:r,scheduleCache:s,useCache:o}){v(this,Pn);v(this,Fn);v(this,Ln);v(this,Un);v(this,Dn);b(this,Pn,t),b(this,Fn,i),b(this,Ln,r),b(this,Un,s),b(this,Dn,o),this.level=e.level,this.enabled=e.enabled,this.channels=e.channels,this.workflow=e.workflow,this.schedule=new je(y({},e.schedule),{emitterInstance:t,inboxServiceInstance:i,cache:s,useCache:o})}update({channels:e,channelPreferences:t}){var i;return Ii({emitter:a(this,Pn),apiService:a(this,Fn),cache:a(this,Ln),scheduleCache:a(this,Un),useCache:a(this,Dn),args:{workflowId:(i=this.workflow)==null?void 0:i.id,channels:e||t,preference:this}})}};Pn=new WeakMap,Fn=new WeakMap,Ln=new WeakMap,Un=new WeakMap,Dn=new WeakMap;var Ii=o=>d(null,[o],function*({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s}){var h;let{channels:c}=s,u="workflowId"in s?s.workflowId:(h=s.preference.workflow)==null?void 0:h.id;try{n.emit("preference.update.pending",{args:s,data:"preference"in s?new De(x(y({},s.preference),{channels:y(y({},s.preference.channels),c)}),{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}):void 0});let l;u?l=yield e.updateWorkflowPreferences({workflowId:u,channels:c}):(Sl({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s}),l=yield e.updateGlobalPreferences(c));let f=new De(l,{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r});return n.emit("preference.update.resolved",{args:s,data:f}),{data:f}}catch(l){return n.emit("preference.update.resolved",{args:s,error:l}),{error:new E("Failed to update preference",l)}}}),Co=o=>d(null,[o],function*({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s}){if(s.find(u=>"preference"in u&&u.preference.level==="global"))return{error:new E("Global preference is not supported in bulk update","")};try{let u=s.map(m=>"preference"in m?new De(x(y({},m.preference),{channels:y(y({},m.preference.channels),m.channels)}),{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}):void 0).filter(m=>m!==void 0);n.emit("preferences.bulk_update.pending",{args:s,data:u});let h=s.map(m=>{var p,w,g,S;return y({workflowId:"workflowId"in m?m.workflowId:(S=(g=(p=m.preference.workflow)==null?void 0:p.id)!=null?g:(w=m.preference.workflow)==null?void 0:w.identifier)!=null?S:""},m.channels)}),f=(yield e.bulkUpdatePreferences(h)).map(m=>new De(m,{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}));return n.emit("preferences.bulk_update.resolved",{args:s,data:f}),{data:f}}catch(u){return n.emit("preferences.bulk_update.resolved",{args:s,error:u}),{error:new E("Failed to bulk update preferences",u)}}}),Sl=({emitter:n,apiService:e,cache:t,scheduleCache:i,useCache:r,args:s})=>{let o=r?t==null?void 0:t.getAll({}):void 0;o==null||o.forEach(c=>{var u,h;if(c.level==="template"){let l=x(y({},c),{channels:Object.entries(c.channels).reduce((m,[p,w])=>{var S;let g=p;return m[g]=(S=s.channels[g])!=null?S:w,m},{})}),f="preference"in s?new De(l,{emitterInstance:n,inboxServiceInstance:e,cache:t,scheduleCache:i,useCache:r}):void 0;f&&n.emit("preference.update.pending",{args:{workflowId:(h=(u=c.workflow)==null?void 0:u.id)!=null?h:"",channels:f.channels},data:f})}})},Ti=s=>d(null,[s],function*({emitter:n,apiService:e,cache:t,useCache:i,args:r}){var o,c;try{let{isEnabled:u,weeklySchedule:h}=r,l=new je({isEnabled:u,weeklySchedule:h},{emitterInstance:n,inboxServiceInstance:e,cache:t,useCache:i});n.emit("preference.schedule.update.pending",{args:r,data:l});let f=yield e.updateGlobalPreferences({schedule:{isEnabled:u,weeklySchedule:h}}),m=new je({isEnabled:(o=f.schedule)==null?void 0:o.isEnabled,weeklySchedule:(c=f.schedule)==null?void 0:c.weeklySchedule},{emitterInstance:n,inboxServiceInstance:e,cache:t,useCache:i});return n.emit("preference.schedule.update.resolved",{args:r,data:m}),{data:m}}catch(u){return n.emit("preference.schedule.update.resolved",{args:r,error:u}),{error:new E("Failed to update preference",u)}}});var ht,Pi=class extends j{constructor({cache:t,useCache:i,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,ht);this.cache=t,b(this,ht,i)}get(){return d(this,null,function*(){return this.callWithSession(()=>d(this,null,function*(){var t,i;try{let r=a(this,ht)?this.cache.getAll():void 0;if(this._emitter.emit("preference.schedule.get.pending",{args:void 0,data:r}),!r){let s=yield this._inboxService.fetchGlobalPreferences();r=new je({isEnabled:(t=s==null?void 0:s.schedule)==null?void 0:t.isEnabled,weeklySchedule:(i=s==null?void 0:s.schedule)==null?void 0:i.weeklySchedule},{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,useCache:a(this,ht)}),a(this,ht)&&(this.cache.set(r),r=this.cache.getAll())}return this._emitter.emit("preference.schedule.get.resolved",{args:void 0,data:r}),{data:r}}catch(r){throw this._emitter.emit("preference.schedule.get.resolved",{args:void 0,error:r}),r}}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>Ti({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,ht),args:t}))})}};ht=new WeakMap;var _l=["preference.update.pending","preference.update.resolved","preferences.bulk_update.pending","preferences.bulk_update.resolved"],El=["preference.schedule.update.pending","preference.schedule.update.resolved"],Cl=({tags:n,severity:e})=>Object.entries({tags:n,severity:e}).reduce((t,[i,r])=>(r==null||Array.isArray(r)&&r.length===0||(t[i]=r),t),{}),qr=({tags:n,severity:e})=>JSON.stringify(Cl({tags:n,severity:e})),ft,Y,Fi=class{constructor({emitterInstance:e}){v(this,ft);v(this,Y);this.updatePreference=(e,t)=>{let i=a(this,Y).get(e);if(!i)return!1;let r=i.findIndex(o=>{var c,u;return((c=o.workflow)==null?void 0:c.id)===((u=t.workflow)==null?void 0:u.id)||o.level===t.level&&t.level==="global"});if(r===-1)return!1;let s=[...i];return s[r]=t,a(this,Y).set(e,s),!0};this.updatePreferenceSchedule=(e,t)=>{let i=a(this,Y).get(e);if(!i)return!1;let r=i.findIndex(o=>o.level==="global");if(r===-1)return!1;let s=[...i];return s[r].schedule=t,a(this,Y).set(e,s),!0};this.handleScheduleEvent=({data:e})=>{var r;if(!e)return;let t=a(this,Y).keys(),i=new Set;for(let s of t){let o=this.updatePreferenceSchedule(s,e),c=a(this,Y).get(s);!o||!c||i.add(s)}for(let s of i)a(this,ft).emit("preferences.list.updated",{data:(r=a(this,Y).get(s))!=null?r:[]})};this.handlePreferenceEvent=({data:e})=>{if(!e)return;let t=Array.isArray(e)?e:[e],i=new Set;a(this,Y).keys().forEach(r=>{t.forEach(s=>{let o=this.updatePreference(r,s),c=a(this,Y).get(r);!o||!c||i.add(r)})}),i.forEach(r=>{var s;a(this,ft).emit("preferences.list.updated",{data:(s=a(this,Y).get(r))!=null?s:[]})})};b(this,ft,e);for(let t of _l)a(this,ft).on(t,this.handlePreferenceEvent);for(let t of El)a(this,ft).on(t,this.handleScheduleEvent);b(this,Y,new Re)}has(e){return a(this,Y).get(qr(e))!==void 0}set(e,t){a(this,Y).set(qr(e),t)}getAll(e){if(this.has(e))return a(this,Y).get(qr(e))}clearAll(){a(this,Y).clear()}};ft=new WeakMap,Y=new WeakMap;var wl=["preference.schedule.update.pending","preference.schedule.update.resolved"],Wr=()=>"schedule",Kt,pe,Li=class{constructor({emitterInstance:e}){v(this,Kt);v(this,pe);this.updateScheduleInCache=(e,t)=>a(this,pe).get(e)?(a(this,pe).set(e,t),!0):!1;this.handleScheduleEvent=({data:e})=>{if(!e)return;let t=new Set,i=a(this,pe).keys();for(let r of i){let s=this.updateScheduleInCache(r,e),o=a(this,pe).get(r);!s||!o||t.add(r)}for(let r of t)a(this,Kt).emit("preference.schedule.get.updated",{data:a(this,pe).get(r)})};b(this,Kt,e);for(let t of wl)a(this,Kt).on(t,this.handleScheduleEvent);b(this,pe,new Re)}has(){return a(this,pe).get(Wr())!==void 0}set(e){a(this,pe).set(Wr(),e)}getAll(){if(this.has())return a(this,pe).get(Wr())}clearAll(){a(this,pe).clear()}};Kt=new WeakMap,pe=new WeakMap;var He,Ui=class extends j{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:r}){super({eventEmitterInstance:r,inboxServiceInstance:i});v(this,He);this.cache=new Fi({emitterInstance:this._emitter}),this.scheduleCache=new Li({emitterInstance:this._emitter}),b(this,He,t),this.schedule=new Pi({cache:this.scheduleCache,useCache:t,inboxServiceInstance:i,eventEmitterInstance:r})}list(){return d(this,arguments,function*(t={}){return this.callWithSession(()=>d(this,null,function*(){var i;try{let r=a(this,He)?this.cache.getAll(t):void 0;return this._emitter.emit("preferences.list.pending",{args:t,data:r}),r||(r=(yield this._inboxService.fetchPreferences({tags:t.tags,severity:t.severity,criticality:(i=t.criticality)!=null?i:"nonCritical"})).map(o=>new De(o,{emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,He)})),a(this,He)&&(this.cache.set(t,r),r=this.cache.getAll(t))),this._emitter.emit("preferences.list.resolved",{args:t,data:r}),{data:r}}catch(r){throw this._emitter.emit("preferences.list.resolved",{args:t,error:r}),r}}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>Ii({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,He),args:t}))})}bulkUpdate(t){return d(this,null,function*(){return this.callWithSession(()=>Co({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,scheduleCache:this.scheduleCache,useCache:a(this,He),args:t}))})}};He=new WeakMap;function wo(){return typeof window!="undefined"}var Ct,Bn,re,Di=class{constructor(e,t,i){v(this,Ct);v(this,Bn);v(this,re);b(this,Ct,i),b(this,Bn,t),b(this,re,e)}get applicationIdentifier(){return a(this,re).applicationIdentifier}get subscriberId(){var e;return(e=a(this,re).subscriber)==null?void 0:e.subscriberId}get context(){return a(this,re).context}get subscriberHash(){return a(this,re).subscriberHash}get contextHash(){return a(this,re).contextHash}get subscriber(){return a(this,re).subscriber}handleApplicationIdentifier(e,t){if(typeof window=="undefined"||!window.localStorage)return null;let i="novu_keyless_application_identifier";switch(e){case"get":return window.localStorage.getItem(i);case"store":return t&&window.localStorage.setItem(i,t),null;case"delete":return window.localStorage.removeItem(i),null;default:return null}}initialize(e){return d(this,null,function*(){var r,s,o,c,u,h;let t=((r=a(this,re).subscriber)==null?void 0:r.subscriberId)===((s=e==null?void 0:e.subscriber)==null?void 0:s.subscriberId),i=JSON.stringify(a(this,re).context)===JSON.stringify(e==null?void 0:e.context);if(!(t&&i))try{e&&b(this,re,e);let{subscriber:l,subscriberHash:f,contextHash:m,applicationIdentifier:p,defaultSchedule:w,context:g}=a(this,re),S;wo()&&(S=Intl.DateTimeFormat().resolvedOptions().timeZone);let R=p;if(R)this.handleApplicationIdentifier("delete");else{let _=this.handleApplicationIdentifier("get");_&&(R=_)}a(this,Ct).emit("session.initialize.pending",{args:a(this,re)});let N=yield a(this,Bn).initializeSession({applicationIdentifier:R,subscriberHash:f,contextHash:m,subscriber:x(y({},l),{subscriberId:(o=l==null?void 0:l.subscriberId)!=null?o:"",timezone:(c=l==null?void 0:l.timezone)!=null?c:S}),defaultSchedule:w,context:g});(u=N==null?void 0:N.applicationIdentifier)!=null&&u.startsWith("pk_keyless_")&&this.handleApplicationIdentifier("store",N.applicationIdentifier),(h=N==null?void 0:N.applicationIdentifier)!=null&&h.startsWith("pk_keyless_")||this.handleApplicationIdentifier("delete"),a(this,Ct).emit("session.initialize.resolved",{args:a(this,re),data:N})}catch(l){a(this,Ct).emit("session.initialize.resolved",{args:a(this,re),error:l})}})}};Ct=new WeakMap,Bn=new WeakMap,re=new WeakMap;function $r(n){if(!n)return"";let e=[];for(let[t,i]of Object.entries(n))if(i){let r=typeof i=="string"?i:i.id;e.push(`${t}:${r}`)}return e.sort().join(",")}function xo({subscriberId:n,subscriber:e}){return e?typeof e=="string"?{subscriberId:e}:e:n?{subscriberId:n}:{subscriberId:""}}function Ao({topicKey:n,subscriberId:e,contextKey:t}){let i=`tk_${n}:si_${e}`;return t&&t.length>0?`${i}:ctx_${t}`:i}var dt,qn,Wn,Mn=class extends j{constructor({useCache:t,inboxServiceInstance:i,eventEmitterInstance:r,subscriber:s,contextKey:o}){super({eventEmitterInstance:r,inboxServiceInstance:i});v(this,dt);v(this,qn);v(this,Wn);this.cache=new Ri({emitterInstance:this._emitter,inboxServiceInstance:this._inboxService,useCache:t}),b(this,dt,t),b(this,qn,s),b(this,Wn,o)}list(t,i){return d(this,null,function*(){return this.callWithSession(()=>{var r;return vo({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},i),{useCache:(r=i==null?void 0:i.useCache)!=null?r:a(this,dt)}),args:t})})})}get(t,i){return d(this,null,function*(){return this.callWithSession(()=>{var r,s;return bo({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,options:x(y({},i),{useCache:(r=i==null?void 0:i.useCache)!=null?r:a(this,dt)}),args:x(y({},t),{identifier:(s=t.identifier)!=null?s:Ao({topicKey:t.topicKey,subscriberId:a(this,qn).subscriberId,contextKey:a(this,Wn)})})})})})}create(t){return d(this,null,function*(){return this.callWithSession(()=>So({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,dt),args:t}))})}update(t){return d(this,null,function*(){return this.callWithSession(()=>Ni({emitter:this._emitter,apiService:this._inboxService,cache:this.cache,useCache:a(this,dt),args:t}))})}delete(t){return d(this,null,function*(){return this.callWithSession(()=>ki({emitter:this._emitter,apiService:this._inboxService,args:t}))})}};dt=new WeakMap,qn=new WeakMap,Wn=new WeakMap;var Bi=typeof globalThis!="undefined"&&globalThis||typeof self!="undefined"&&self||typeof global!="undefined"&&global,xl=(function(){try{new Bi.Event("")}catch(n){return!0}return!1})(),Al=(function(){try{new Bi.EventTarget}catch(n){return!0}return!1})();xl&&(Bi.Event=(function(){function n(e,t){this.bubbles=!!t&&!!t.bubbles,this.cancelable=!!t&&!!t.cancelable,this.composed=!!t&&!!t.composed,this.type=e}return n})());Al&&(Bi.EventTarget=(function(){function n(){this.__listeners=new Map}return n.prototype=Object.create(Object.prototype),n.prototype.addEventListener=function(e,t,i){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let r=this.__listeners,s=e.toString();r.has(s)||r.set(s,new Map);let o=r.get(s);o.has(t)||o.set(t,i)},n.prototype.removeEventListener=function(e,t,i){if(arguments.length<2)throw new TypeError("TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only "+arguments.length+" present.");let r=this.__listeners,s=e.toString();if(r.has(s)){let o=r.get(s);o.has(t)&&o.delete(t)}},n.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,r=this.__listeners.get(t);if(r)for(var s of r.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(u){setTimeout(()=>{throw u})}c&&c.once&&r.delete(o)}return!0},n})());(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
|
|
21
21
|
PartySocket requires a global 'EventTarget' class to be available!
|
|
22
22
|
You can polyfill this global by adding this to your code before any partysocket imports:
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import 'partysocket/event-target-polyfill';
|
|
26
26
|
\`\`\`
|
|
27
27
|
Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
|
|
28
|
-
`);var
|
|
28
|
+
`);var Ro=class extends Event{constructor(e,t){super("error",t);P(this,"message");P(this,"error");this.message=e.message,this.error=e}},Oo=class extends Event{constructor(e=1e3,t="",i){super("close",i);P(this,"code");P(this,"reason");P(this,"wasClean",!0);this.code=e,this.reason=t}},Kr={Event,ErrorEvent:Ro,CloseEvent:Oo};function Nl(n,e){if(!n)throw new Error(e)}function kl(n){return new n.constructor(n.type,n)}function Rl(n){return"data"in n?new MessageEvent(n.type,n):"code"in n||"reason"in n?new Oo(n.code||1999,n.reason||"unknown reason",n):"error"in n?new Ro(n.error,n):new Event(n.type,n)}var No,Ol=typeof process!="undefined"&&typeof((No=process.versions)==null?void 0:No.node)!="undefined"&&typeof document=="undefined",Mi=Ol?Rl:kl,wt={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},ko=!1,$n=class xt extends EventTarget{constructor(t,i,r={}){super();P(this,"_ws");P(this,"_retryCount",-1);P(this,"_uptimeTimeout");P(this,"_connectTimeout");P(this,"_shouldReconnect",!0);P(this,"_connectLock",!1);P(this,"_binaryType","blob");P(this,"_closeCalled",!1);P(this,"_messageQueue",[]);P(this,"_debugLogger",console.log.bind(console));P(this,"_url");P(this,"_protocols");P(this,"_options");P(this,"onclose",null);P(this,"onerror",null);P(this,"onmessage",null);P(this,"onopen",null);P(this,"_handleOpen",t=>{this._debug("open event");let{minUptime:i=wt.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),i),Nl(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(r=>{var s;return(s=this._ws)==null?void 0:s.send(r)}),this._messageQueue=[],this.onopen&&this.onopen(t),this.dispatchEvent(Mi(t))});P(this,"_handleMessage",t=>{this._debug("message event"),this.onmessage&&this.onmessage(t),this.dispatchEvent(Mi(t))});P(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(Mi(t)),this._connect()});P(this,"_handleClose",t=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(t),this.dispatchEvent(Mi(t))});this._url=t,this._protocols=i,this._options=r,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 xt.CONNECTING}get OPEN(){return xt.OPEN}get CLOSING(){return xt.CLOSING}get CLOSED(){return xt.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((i,r)=>(typeof r=="string"?i+=r.length:r instanceof Blob?i+=r.size:i+=r.byteLength,i),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?xt.CLOSED:xt.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,i){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,i)}reconnect(t,i){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,i),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{let{maxEnqueuedMessages:i=wt.maxEnqueuedMessages}=this._options;this._messageQueue.length<i&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){let{reconnectionDelayGrowFactor:t=wt.reconnectionDelayGrowFactor,minReconnectionDelay:i=wt.minReconnectionDelay,maxReconnectionDelay:r=wt.maxReconnectionDelay}=this._options,s=0;return this._retryCount>0&&(s=i*Ks(t,this._retryCount-1),s>r&&(s=r)),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 i=t();if(!i)return Promise.resolve(null);if(typeof i=="string"||Array.isArray(i))return Promise.resolve(i);if(i.then)return i}throw Error("Invalid protocols")}_getNextUrl(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){let i=t();if(typeof i=="string")return Promise.resolve(i);if(i.then)return i}throw Error("Invalid URL")}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:t=wt.maxRetries,connectionTimeout:i=wt.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(([r,s])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket=="undefined"&&!ko&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket.
|
|
29
29
|
|
|
30
30
|
For example, if you're using node.js, run \`npm install ws\`, and then in your code:
|
|
31
31
|
|
|
@@ -38,7 +38,7 @@ const partysocket = new PartySocket({
|
|
|
38
38
|
WebSocket: WS
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
`),So=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:r,protocols:s}),this._ws=s?new o(r,s):new o(r),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),i)}).catch(r=>{this._connectLock=!1,this._handleError(new Mr.ErrorEvent(Error(r.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Mr.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,i){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,i),this._handleClose(new Mr.CloseEvent(t,i,this))}catch(r){}}}_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 qn="wss://socket.novu.co",xl=25e3,Co="ping",wo="notifications.notification_received",xo="notifications.unseen_count_changed",Ao="notifications.unread_count_changed",Al=({_id:n,transactionId:e,content:t,read:i,seen:r,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:m,subscriber:d,subject:w,avatar:g,cta:S,tags:R,data:N,workflow:_,severity:C})=>{var qe,gt,he,tt,nt,it,Ae,Ne;let M={id:d==null?void 0:d._id,subscriberId:d==null?void 0:d.subscriberId,firstName:d==null?void 0:d.firstName,lastName:d==null?void 0:d.lastName,avatar:d==null?void 0:d.avatar,locale:d==null?void 0:d.locale,data:d==null?void 0:d.data,timezone:d==null?void 0:d.timezone,email:d==null?void 0:d.email,phone:d==null?void 0:d.phone},O=(gt=(qe=S.action)==null?void 0:qe.buttons)==null?void 0:gt.find(We=>We.type==="primary"),P=(tt=(he=S.action)==null?void 0:he.buttons)==null?void 0:tt.find(We=>We.type==="secondary"),$=(it=(nt=S.action)==null?void 0:nt.result)==null?void 0:it.type,te=(Ae=S.action)==null?void 0:Ae.status;return x(y(y({id:n,transactionId:e,subject:w,body:t,to:M,isRead:i,isSeen:r,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:g,primaryAction:O&&{label:O.content,isCompleted:$==="primary"&&te==="done",redirect:O.url?{target:O.target,url:O.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&te==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:m,tags:R,redirect:(Ne=S.data)!=null&&Ne.url?{url:S.data.url,target:S.data.target}:void 0,data:N,workflow:_,severity:C})},qt,Oe,Ee,Wt,Mn,Ct,Bi,Mi,qi,Wi,ue,Ui,No,ko,qr,Wr,Di=class extends V{constructor({socketUrl:t,socketOptions:i,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,ue);v(this,qt);v(this,Oe);v(this,Ee);v(this,Wt);v(this,Mn);v(this,Ct);v(this,Bi,t=>{try{let i=JSON.parse(t.data);i.event==="notification_received"&&a(this,Oe).emit(wo,{result:new U(Al(i.data.message),a(this,Oe),this._inboxService)})}catch(i){console.log("error",i)}});v(this,Mi,t=>{try{let i=JSON.parse(t.data);i.event==="unseen_count_changed"&&a(this,Oe).emit(xo,{result:i.data.unseenCount})}catch(i){}});v(this,qi,t=>{try{let i=JSON.parse(t.data);i.event==="unread_count_changed"&&a(this,Oe).emit(Ao,{result:i.data.counts})}catch(i){}});v(this,Wi,t=>{if(!(t.data===Co||t.data==="pong"))try{switch(JSON.parse(t.data).event){case"notification_received":a(this,Bi).call(this,t);break;case"unseen_count_changed":a(this,Mi).call(this,t);break;case"unread_count_changed":a(this,qi).call(this,t);break;default:}}catch(i){}});b(this,Oe,s),b(this,Wt,t!=null?t:qn),b(this,Mn,i)}onSessionSuccess({token:t}){b(this,qt,t)}isSocketEvent(t){return t===wo||t===xo||t===Ao}connect(){return p(this,null,function*(){return a(this,qt)?ae(this,ue,qr).call(this):this.callWithSession(ae(this,ue,qr).bind(this))})}disconnect(){return p(this,null,function*(){return a(this,Ee)?ae(this,ue,Wr).call(this):this.callWithSession(ae(this,ue,Wr).bind(this))})}};qt=new WeakMap,Oe=new WeakMap,Ee=new WeakMap,Wt=new WeakMap,Mn=new WeakMap,Ct=new WeakMap,Bi=new WeakMap,Mi=new WeakMap,qi=new WeakMap,Wi=new WeakMap,ue=new WeakSet,Ui=function(){a(this,Ct)!==void 0&&(clearInterval(a(this,Ct)),b(this,Ct,void 0))},No=function(){ae(this,ue,Ui).call(this),b(this,Ct,setInterval(()=>{let t=a(this,Ee);if(!(!t||t.readyState!==Bn.OPEN))try{t.send(Co)}catch(i){}},xl))},ko=function(){return p(this,null,function*(){if(a(this,Ee))return;let t={socketUrl:a(this,Wt)};a(this,Oe).emit("socket.connect.pending",{args:t});let i=new URL(a(this,Wt));i.searchParams.set("token",a(this,qt)),b(this,Ee,new Bn(i.toString(),void 0,a(this,Mn)));let r=a(this,Ee);r.addEventListener("open",()=>{ae(this,ue,No).call(this),a(this,Oe).emit("socket.connect.resolved",{args:t})}),r.addEventListener("error",s=>{a(this,Oe).emit("socket.connect.resolved",{args:t,error:s})}),r.addEventListener("close",()=>{r===a(this,Ee)&&(ae(this,ue,Ui).call(this),b(this,Ee,void 0))}),r.addEventListener("message",a(this,Wi))})},qr=function(){return p(this,null,function*(){try{return yield ae(this,ue,ko).call(this),{}}catch(t){return{error:new E("Failed to initialize the PartySocket",t)}}})},Wr=function(){return p(this,null,function*(){var t;try{return ae(this,ue,Ui).call(this),(t=a(this,Ee))==null||t.close(),b(this,Ee,void 0),{}}catch(i){return{error:new E("Failed to disconnect from the PartySocket",i)}}})};var Te=Object.create(null);Te.open="0";Te.close="1";Te.ping="2";Te.pong="3";Te.message="4";Te.upgrade="5";Te.noop="6";var Wn=Object.create(null);Object.keys(Te).forEach(n=>{Wn[Te[n]]=n});var $n={type:"error",data:"parser error"};var Kn=({type:n,data:e},t,i)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?i(t?e:"b"+Ro(e,!0).toString("base64")):i(Te[n]+(e||"")),Ro=(n,e)=>Buffer.isBuffer(n)||n instanceof Uint8Array&&!e?n:n instanceof ArrayBuffer?Buffer.from(n):Buffer.from(n.buffer,n.byteOffset,n.byteLength),$r;function Oo(n,e){if(n.data instanceof ArrayBuffer||ArrayBuffer.isView(n.data))return e(Ro(n.data,!1));Kn(n,!0,t=>{$r||($r=new TextEncoder),e($r.encode(t))})}var zn=(n,e)=>{if(typeof n!="string")return{type:"message",data:To(n,e)};let t=n.charAt(0);if(t==="b"){let i=Buffer.from(n.substring(1),"base64");return{type:"message",data:To(i,e)}}return Wn[t]?n.length>1?{type:Wn[t],data:n.substring(1)}:{type:Wn[t]}:$n},To=(n,e)=>e==="arraybuffer"?n instanceof ArrayBuffer?n:Buffer.isBuffer(n)?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n.buffer:Buffer.isBuffer(n)?n:Buffer.from(n);var Io="",Po=(n,e)=>{let t=n.length,i=new Array(t),r=0;n.forEach((s,o)=>{Kn(s,!1,c=>{i[o]=c,++r===t&&e(i.join(Io))})})},Fo=(n,e)=>{let t=n.split(Io),i=[];for(let r=0;r<t.length;r++){let s=zn(t[r],e);if(i.push(s),s.type==="error")break}return i};function Lo(){return new TransformStream({transform(n,e){Oo(n,t=>{let i=t.length,r;if(i<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,i);else if(i<65536){r=new Uint8Array(3);let s=new DataView(r.buffer);s.setUint8(0,126),s.setUint16(1,i)}else{r=new Uint8Array(9);let s=new DataView(r.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}var Kr;function $i(n){return n.reduce((e,t)=>e+t.length,0)}function Ki(n,e){if(n[0].length===e)return n.shift();let t=new Uint8Array(e),i=0;for(let r=0;r<e;r++)t[r]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),t}function Uo(n,e){Kr||(Kr=new TextDecoder);let t=[],i=0,r=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(i===0){if($i(t)<1)break;let u=Ki(t,1);s=(u[0]&128)===128,r=u[0]&127,r<126?i=3:r===126?i=1:i=2}else if(i===1){if($i(t)<2)break;let u=Ki(t,2);r=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),i=3}else if(i===2){if($i(t)<8)break;let u=Ki(t,8),h=new DataView(u.buffer,u.byteOffset,u.length),l=h.getUint32(0);if(l>Math.pow(2,21)-1){c.enqueue($n);break}r=l*Math.pow(2,32)+h.getUint32(4),i=3}else{if($i(t)<r)break;let u=Ki(t,r);c.enqueue(zn(s?u:Kr.decode(u),e)),i=0}if(r===0||r>n){c.enqueue($n);break}}}})}var zr=4;function L(n){if(n)return Nl(n)}function Nl(n){for(var e in L.prototype)n[e]=L.prototype[e];return n}L.prototype.on=L.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};L.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,r=0;r<t.length;r++)if(i=t[r],i===e||i.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+n],this};L.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,r=t.length;i<r;++i)t[i].apply(this,e)}return this};L.prototype.emitReserved=L.prototype.emit;L.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};L.prototype.hasListeners=function(n){return!!this.listeners(n).length};var Ie=global;function zi(n,...e){return e.reduce((t,i)=>(n.hasOwnProperty(i)&&(t[i]=n[i]),t),{})}var kl=Ie.setTimeout,Rl=Ie.clearTimeout;function Ye(n,e){e.useNativeTimers?(n.setTimeoutFn=kl.bind(Ie),n.clearTimeoutFn=Rl.bind(Ie)):(n.setTimeoutFn=Ie.setTimeout.bind(Ie),n.clearTimeoutFn=Ie.clearTimeout.bind(Ie))}var Ol=1.33;function Do(n){return typeof n=="string"?Tl(n):Math.ceil((n.byteLength||n.size)*Ol)}function Tl(n){let e=0,t=0;for(let i=0,r=n.length;i<r;i++)e=n.charCodeAt(i),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(i++,t+=4);return t}var Yo=G(Gt(),1);function Vo(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function Ho(n){let e={},t=n.split("&");for(let i=0,r=t.length;i<r;i++){let s=t[i].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}var eu=(0,Yo.default)("engine.io-client:transport"),Jr=class extends Error{constructor(e,t,i){super(e),this.description=t,this.context=i,this.type="TransportError"}},Je=class extends L{constructor(e){super(),this.writable=!1,Ye(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,i){return super.emitReserved("error",new Jr(e,t,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):eu("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=zn(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=Vo(e);return t.length?"?"+t:""}};var sa=G(Gt(),1);var Zo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Xr=64,tu={},Jo=0,Ji=0,Xo;function Qo(n){let e="";do e=Zo[n%Xr]+e,n=Math.floor(n/Xr);while(n>0);return e}function Xi(){let n=Qo(+new Date);return n!==Xo?(Jo=0,Xo=n):n+"."+Qo(Jo++)}for(;Ji<Xr;Ji++)tu[Zo[Ji]]=Ji;var es=G(na(),1),ts=es.default||es;function ia(){return new Zr}function iu(n){let e=n.split("; "),t=e[0].indexOf("=");if(t===-1)return;let i=e[0].substring(0,t).trim();if(!i.length)return;let r=e[0].substring(t+1).trim();r.charCodeAt(0)===34&&(r=r.slice(1,-1));let s={name:i,value:r};for(let o=1;o<e.length;o++){let c=e[o].split("=");if(c.length!==2)continue;let u=c[0].trim(),h=c[1].trim();switch(u){case"Expires":s.expires=new Date(h);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(h,10)),s.expires=l;break;default:}}return s}var Zr=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(i=>{let r=iu(i);r&&this.cookies.set(r.name,r)})}addCookies(e){let t=[];this.cookies.forEach((i,r)=>{var s;((s=i.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(r):t.push(`${r}=${i.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var fe=(0,sa.default)("engine.io-client:polling");function ru(){}var su=(function(){return new ts({xdomain:!1}).responseType!=null})(),Qi=class extends Je{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let i=location.protocol==="https:",r=location.port;r||(r=i?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||r!==e.port}let t=e&&e.forceBase64;this.supportsBinary=su&&!t,this.opts.withCredentials&&(this.cookieJar=ia())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{fe("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let i=0;this.polling&&(fe("we are currently polling - waiting to pause"),i++,this.once("pollComplete",function(){fe("pre-pause polling complete"),--i||t()})),this.writable||(fe("we are currently writing - waiting to pause"),i++,this.once("drain",function(){fe("pre-pause writing complete"),--i||t()}))}else t()}poll(){fe("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){fe("polling got data %s",e);let t=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};Fo(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():fe('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{fe("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(fe("transport open - closing"),e()):(fe("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Po(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]=Xi()),!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 dt(this.uri(),e)}doWrite(e,t){let i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",(r,s)=>{this.onError("xhr post error",r,s)})}doPoll(){fe("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,i)=>{this.onError("xhr poll error",t,i)}),this.pollXhr=e}},dt=class n extends L{constructor(e,t){super(),Ye(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=zi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let i=this.xhr=new ts(t);try{fe("xhr open %s: %s",this.method,this.uri),i.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let r in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&i.setRequestHeader(r,this.opts.extraHeaders[r])}}catch(r){}if(this.method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(r){}try{i.setRequestHeader("Accept","*/*")}catch(r){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(i.timeout=this.opts.requestTimeout),i.onreadystatechange=()=>{var r;i.readyState===3&&((r=this.opts.cookieJar)===null||r===void 0||r.parseCookies(i)),i.readyState===4&&(i.status===200||i.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof i.status=="number"?i.status:0)},0))},fe("xhr data %s",this.data),i.send(this.data)}catch(r){this.setTimeoutFn(()=>{this.onError(r)},0);return}typeof document!="undefined"&&(this.index=n.requestsCount++,n.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=ru,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete n.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()}};dt.requestsCount=0;dt.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",ra);else if(typeof addEventListener=="function"){let n="onpagehide"in Ie?"pagehide":"unload";addEventListener(n,ra,!1)}}function ra(){for(let n in dt.requests)dt.requests.hasOwnProperty(n)&&dt.requests[n].abort()}var Ah=G(ec(),1),Nh=G(ar(),1),kh=G(Yt(),1),Rh=G(fs(),1),Oh=G(ms(),1),Th=G(_s(),1),lc=G(hr(),1),Ih=G(cc(),1);var uc=lc.default;var Qn=uc,dr=!1,hc="nodebuffer",Ot=process.nextTick;var dc=G(Gt(),1);var Ph=(0,dc.default)("engine.io-client:websocket"),fc=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",pr=class extends Je{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,i=fc?{}:zi(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=dr&&!fc?t?new Qn(e,t):new Qn(e):new Qn(e,t,i)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],r=t===e.length-1;Kn(i,this.supportsBinary,s=>{let o={};dr||(i.options&&(o.compress=i.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{dr?this.ws.send(s):this.ws.send(s,o)}catch(c){Ph("websocket closed before onclose event")}r&&Ot(()=>{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]=Xi()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Qn}};var pc=G(Gt(),1),Zn=(0,pc.default)("engine.io-client:webtransport"),mr=class extends Je{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{Zn("transport closed gracefully"),this.onClose()}).catch(e=>{Zn("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=Uo(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(t).getReader(),r=Lo();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();let s=()=>{i.read().then(({done:c,value:u})=>{if(c){Zn("session is closed");return}Zn("received chunk: %o",u),this.onPacket(u),s()}).catch(c=>{Zn("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 i=e[t],r=t===e.length-1;this.writer.write(i).then(()=>{r&&Ot(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var Cs={websocket:pr,webtransport:mr,polling:Qi};var Fh=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Lh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function tn(n){let e=n,t=n.indexOf("["),i=n.indexOf("]");t!=-1&&i!=-1&&(n=n.substring(0,t)+n.substring(t,i).replace(/:/g,";")+n.substring(i,n.length));let r=Fh.exec(n||""),s={},o=14;for(;o--;)s[Lh[o]]=r[o]||"";return t!=-1&&i!=-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=Uh(s,s.path),s.queryKey=Dh(s,s.query),s}function Uh(n,e){let t=/\/{2,9}/g,i=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function Dh(n,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,r,s){r&&(t[r]=s)}),t}var mc=G(Gt(),1);var B=(0,mc.default)("engine.io-client:socket"),Tt=class n extends L{constructor(e,t={}){super(),this.binaryType=hc,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=tn(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=tn(t.host).host),Ye(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=Ho(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){B('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=zr,t.transport=e,this.id&&(t.sid=this.id);let i=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return B("options: %j",i),new Cs[e](i)}open(){let e;if(this.opts.rememberUpgrade&&n.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){B("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){B("setting transport %s",e.name),this.transport&&(B("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){B('probing transport "%s"',e);let t=this.createTransport(e),i=!1;n.priorWebsocketSuccess=!1;let r=()=>{i||(B('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!i)if(f.type==="pong"&&f.data==="probe"){if(B('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;n.priorWebsocketSuccess=t.name==="websocket",B('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{i||this.readyState!=="closed"&&(B("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{B('probe transport "%s" failed',e);let m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function s(){i||(i=!0,l(),t.close(),t=null)}let o=f=>{let m=new Error("probe error: "+f);m.transport=t.name,s(),B('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",m)};function c(){o("transport closed")}function u(){o("socket closed")}function h(f){t&&f.name!==t.name&&(B('"%s" works - aborting "%s"',f.name,t.name),s())}let l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",c),this.off("close",u),this.off("upgrading",h)};t.once("open",r),t.once("error",o),t.once("close",c),this.once("close",u),this.once("upgrading",h),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||t.open()},200):t.open()}onOpen(){if(B("socket open"),this.readyState="open",n.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){B("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(B('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 B('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();B("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i<this.writeBuffer.length;i++){let r=this.writeBuffer[i].data;if(r&&(t+=Do(r)),i>0&&t>this.maxPayload)return B("only send %d out of %d packets",i,this.writeBuffer.length),this.writeBuffer.slice(0,i);t+=2}return B("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,i){return this.sendPacket("message",e,t,i),this}send(e,t,i){return this.sendPacket("message",e,t,i),this}sendPacket(e,t,i,r){if(typeof t=="function"&&(r=t,t=void 0),typeof i=="function"&&(r=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;let s={type:e,data:t,options:i};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),r&&this.once("flush",r),this.flush()}close(){let e=()=>{this.onClose("forced close"),B("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}onError(e){B("socket error %j",e),n.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(B('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],i=0,r=e.length;for(;i<r;i++)~this.transports.indexOf(e[i])&&t.push(e[i]);return t}};Tt.protocol=zr;var ey=Tt.protocol;var _c=G(ei(),1),Sc=(0,_c.default)("socket.io-client:url");function Ec(n,e="",t){let i=n;t=t||typeof location!="undefined"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(Sc("protocol-less url %s",n),typeof t!="undefined"?n=t.protocol+"//"+n:n="https://"+n),Sc("parse %s",n),i=tn(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";let s=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+s+":"+i.port+e,i.href=i.protocol+"://"+s+(t&&t.port===i.port?"":":"+i.port),i}var Fs={};el(Fs,{Decoder:()=>Is,Encoder:()=>Ts,PacketType:()=>k,isPacketValid:()=>Nf,protocol:()=>Lc});var Zh=typeof ArrayBuffer=="function",ef=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Cc=Object.prototype.toString,tf=typeof Blob=="function"||typeof Blob!="undefined"&&Cc.call(Blob)==="[object BlobConstructor]",nf=typeof File=="function"||typeof File!="undefined"&&Cc.call(File)==="[object FileConstructor]";function ni(n){return Zh&&(n instanceof ArrayBuffer||ef(n))||tf&&n instanceof Blob||nf&&n instanceof File}function ti(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,i=n.length;t<i;t++)if(ti(n[t]))return!0;return!1}if(ni(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return ti(n.toJSON(),!0);for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&ti(n[t]))return!0;return!1}function wc(n){let e=[],t=n.data,i=n;return i.data=As(t,e),i.attachments=e.length,{packet:i,buffers:e}}function As(n,e){if(!n)return n;if(ni(n)){let t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){let t=new Array(n.length);for(let i=0;i<n.length;i++)t[i]=As(n[i],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){let t={};for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=As(n[i],e));return t}return n}function xc(n,e){return n.data=Ns(n.data,e),delete n.attachments,n}function Ns(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=Ns(n[t],e);else if(typeof n=="object")for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=Ns(n[t],e));return n}var Pc=G(Ic(),1),Os=(0,Pc.default)("socket.io-parser"),Fc=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Lc=5,k;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(k||(k={}));var Ts=class{constructor(e){this.replacer=e}encode(e){return Os("encoding packet %j",e),(e.type===k.EVENT||e.type===k.ACK)&&ti(e)?this.encodeAsBinary({type:e.type===k.EVENT?k.BINARY_EVENT:k.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===k.BINARY_EVENT||e.type===k.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)),Os("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=wc(e),i=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(i),r}},Is=class n extends L{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let i=t.type===k.BINARY_EVENT;i||t.type===k.BINARY_ACK?(t.type=i?k.EVENT:k.ACK,this.reconstructor=new Ps(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(ni(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,i={type:Number(e.charAt(0))};if(k[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===k.BINARY_EVENT||i.type===k.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");let c=Number(o);if(!Uc(c)||c<0)throw new Error("Illegal attachments");if(c>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=c}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););i.nsp=e.substring(s,t)}else i.nsp="/";let r=e.charAt(t+1);if(r!==""&&Number(r)==r){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}i.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(n.isPayloadValid(i.type,s))i.data=s;else throw new Error("invalid payload")}return Os("decoded %s as %j",e,i),i}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case k.CONNECT:return Cr(t);case k.DISCONNECT:return t===void 0;case k.CONNECT_ERROR:return typeof t=="string"||Cr(t);case k.EVENT:case k.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Fc.indexOf(t[0])===-1);case k.ACK:case k.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Ps=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=xc(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function wf(n){return typeof n=="string"}var Uc=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function xf(n){return n===void 0||Uc(n)}function Cr(n){return Object.prototype.toString.call(n)==="[object Object]"}function Af(n,e){switch(n){case k.CONNECT:return e===void 0||Cr(e);case k.DISCONNECT:return e===void 0;case k.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&Fc.indexOf(e[0])===-1);case k.ACK:return Array.isArray(e);case k.CONNECT_ERROR:return typeof e=="string"||Cr(e);default:return!1}}function Nf(n){return wf(n.nsp)&&xf(n.id)&&Af(n.type,n.data)}function ve(n,e,t){return n.on(e,t),function(){n.off(e,t)}}var Dc=G(ei(),1),j=(0,Dc.default)("socket.io-client:socket"),kf=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),on=class extends L{constructor(e,t,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ve(e,"open",this.onopen.bind(this)),ve(e,"packet",this.onpacket.bind(this)),ve(e,"error",this.onerror.bind(this)),ve(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(kf.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let i={type:k.EVENT,data:t};if(i.options={},i.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;j("emitting packet with ack id %d",o);let c=t.pop();this._registerAckCallback(o,c),i.id=o}let r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)?j("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i),this.flags={},this}_registerAckCallback(e,t){var i;let r=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(r===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&&(j("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));j("event with ack id %d has timed out after %d ms",e,r),t.call(this,new Error("operation has timed out"))},r);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let i=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((r,s)=>{t.push((o,c)=>i?o?s(o):r(c):r(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...s)=>i!==this._queue[0]?void 0:(r!==null?i.tryCount>this._opts.retries&&(j("packet [%d] is discarded after %d tries",i.id,i.tryCount),this._queue.shift(),t&&t(r)):(j("packet [%d] was successfully sent",i.id),this._queue.shift(),t&&t(null,...s)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(j("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){j("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,j("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(){j("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:k.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){j("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 k.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 k.EVENT:case k.BINARY_EVENT:this.onevent(e);break;case k.ACK:case k.BINARY_ACK:this.onack(e);break;case k.DISCONNECT:this.ondisconnect();break;case k.CONNECT_ERROR:this.destroy();let i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){let t=e.data||[];j("emitting event %j",t),e.id!=null&&(j("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let i of t)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,i=!1;return function(...r){i||(i=!0,j("sending ack %j",r),t.packet({type:k.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(j("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):j("bad ack %s",e.id)}onconnect(e,t){j("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(){j("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&&(j("performing disconnect (%s)",this.nsp),this.packet({type:k.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let i of t)i.apply(this,e.data)}}};function Pt(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Pt.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0};Pt.prototype.reset=function(){this.attempts=0};Pt.prototype.setMin=function(n){this.ms=n};Pt.prototype.setMax=function(n){this.max=n};Pt.prototype.setJitter=function(n){this.jitter=n};var Bc=G(ei(),1),se=(0,Bc.default)("socket.io-client:manager"),an=class extends L{constructor(e,t){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Ye(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((i=t.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new 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 r=t.parser||Fs;this.encoder=new r.Encoder,this.decoder=new r.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(se("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;se("opening %s",this.uri),this.engine=new Tt(this.uri,this.opts);let t=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;let r=ve(t,"open",function(){i.onopen(),e&&e()}),s=c=>{se("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=ve(t,"error",s);if(this._timeout!==!1){let c=this._timeout;se("connect attempt will timeout after %d",c);let u=this.setTimeoutFn(()=>{se("connect attempt timed out after %d",c),r(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){se("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ve(e,"ping",this.onping.bind(this)),ve(e,"data",this.ondata.bind(this)),ve(e,"error",this.onerror.bind(this)),ve(e,"close",this.onclose.bind(this)),ve(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){Ot(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){se("error",e),this.emitReserved("error",e)}socket(e,t){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new on(this,e,t),this.nsps[e]=i),i}_destroy(e){let t=Object.keys(this.nsps);for(let i of t)if(this.nsps[i].active){se("socket %s is still active, skipping close",i);return}this._close()}_packet(e){se("writing packet %j",e);let t=this.encoder.encode(e);for(let i=0;i<t.length;i++)this.engine.write(t[i],e.options)}cleanup(){se("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){se("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){se("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)se("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();se("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let i=this.setTimeoutFn(()=>{e.skipReconnect||(se("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(se("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):(se("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var qc=G(ei(),1),Mc=(0,qc.default)("socket.io-client"),ii={};function ri(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};let t=Ec(n,e.path||"/socket.io"),i=t.source,r=t.id,s=t.path,o=ii[r]&&s in ii[r].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,u;return c?(Mc("ignoring socket cache for %s",i),u=new an(i,e)):(ii[r]||(Mc("new io instance for %s",i),ii[r]=new an(i,e)),u=ii[r]),t.query&&!e.query&&(e.query=t.queryKey),u.socket(t.path,e)}Object.assign(ri,{Manager:an,Socket:on,io:ri,connect:ri});var Rf="https://ws.novu.co",Wc="notifications.notification_received",$c="notifications.unseen_count_changed",Kc="notifications.unread_count_changed",Of=({_id:n,transactionId:e,content:t,read:i,seen:r,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:m,subscriber:d,subject:w,avatar:g,cta:S,tags:R,data:N,workflow:_,severity:C})=>{var qe,gt,he,tt,nt,it,Ae,Ne;let M={id:d==null?void 0:d._id,subscriberId:d==null?void 0:d.subscriberId,firstName:d==null?void 0:d.firstName,lastName:d==null?void 0:d.lastName,avatar:d==null?void 0:d.avatar,locale:d==null?void 0:d.locale,data:d==null?void 0:d.data,timezone:d==null?void 0:d.timezone,email:d==null?void 0:d.email,phone:d==null?void 0:d.phone},O=(gt=(qe=S.action)==null?void 0:qe.buttons)==null?void 0:gt.find(We=>We.type==="primary"),P=(tt=(he=S.action)==null?void 0:he.buttons)==null?void 0:tt.find(We=>We.type==="secondary"),$=(it=(nt=S.action)==null?void 0:nt.result)==null?void 0:it.type,te=(Ae=S.action)==null?void 0:Ae.status;return x(y(y({id:n,transactionId:e,subject:w,body:t,to:M,isRead:i,isSeen:r,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:g,primaryAction:O&&{label:O.content,isCompleted:$==="primary"&&te==="done",redirect:O.url?{target:O.target,url:O.url}:void 0},secondaryAction:P&&{label:P.content,isCompleted:$==="secondary"&&te==="done",redirect:P.url?{target:P.target,url:P.url}:void 0},channelType:m,tags:R,redirect:(Ne=S.data)!=null&&Ne.url?{url:S.data.url,target:S.data.target}:void 0,data:N,workflow:_,severity:C})},cn,Fe,be,ln,si,xr,Ar,Nr,Me,zc,Ls,Us,wr=class extends V{constructor({socketUrl:t,socketOptions:i,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,Me);v(this,cn);v(this,Fe);v(this,be);v(this,ln);v(this,si);v(this,xr,({message:t})=>{a(this,Fe).emit(Wc,{result:new U(Of(t),a(this,Fe),this._inboxService)})});v(this,Ar,({unseenCount:t})=>{a(this,Fe).emit($c,{result:t})});v(this,Nr,({counts:t})=>{a(this,Fe).emit(Kc,{result:t})});b(this,Fe,s),b(this,ln,t!=null?t:Rf),b(this,si,i)}onSessionSuccess({token:t}){b(this,cn,t)}isSocketEvent(t){return t===Wc||t===$c||t===Kc}connect(){return p(this,null,function*(){return a(this,cn)?ae(this,Me,Ls).call(this):this.callWithSession(ae(this,Me,Ls).bind(this))})}disconnect(){return p(this,null,function*(){return a(this,be)?ae(this,Me,Us).call(this):this.callWithSession(ae(this,Me,Us).bind(this))})}};cn=new WeakMap,Fe=new WeakMap,be=new WeakMap,ln=new WeakMap,si=new WeakMap,xr=new WeakMap,Ar=new WeakMap,Nr=new WeakMap,Me=new WeakSet,zc=function(){return p(this,null,function*(){var i,r,s,o;if(a(this,be))return;let t={socketUrl:a(this,ln)};a(this,Fe).emit("socket.connect.pending",{args:t}),b(this,be,ri(a(this,ln),y({reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,cn)}`}},(i=a(this,si))!=null?i:{}))),a(this,be).on("connect",()=>{a(this,Fe).emit("socket.connect.resolved",{args:t})}),a(this,be).on("connect_error",c=>{a(this,Fe).emit("socket.connect.resolved",{args:t,error:c})}),(r=a(this,be))==null||r.on("notification_received",a(this,xr)),(s=a(this,be))==null||s.on("unseen_count_changed",a(this,Ar)),(o=a(this,be))==null||o.on("unread_count_changed",a(this,Nr))})},Ls=function(){return p(this,null,function*(){try{return yield ae(this,Me,zc).call(this),{}}catch(t){return{error:new E("Failed to initialize the socket",t)}}})},Us=function(){return p(this,null,function*(){var t;try{return(t=a(this,be))==null||t.disconnect(),b(this,be,void 0),{}}catch(i){return{error:new E("Failed to disconnect from the socket",i)}}})};var Tf=["wss://eu.socket.novu.co",qn,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],If={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":qn,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"},Pf={cloud:"partysocket","self-hosted":"socket.io"};function Ff(n){return n?If[n]||n:qn}function Lf(n){return!n||Tf.includes(n)}function Uf(n,e){return e?Pf[e]:Lf(n)?"partysocket":"socket.io"}function Gc({socketUrl:n,socketOptions:e,inboxServiceInstance:t,eventEmitterInstance:i}){let r=Ff(n),u=e||{},{socketType:s}=u,o=un(u,["socketType"]);switch(Uf(r,s)){case"partysocket":return new Di({socketUrl:r,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:i});case"socket.io":default:return new wr({socketUrl:r,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:i})}}var Se,oe,Le,oi,kr=class{constructor(e){v(this,Se);v(this,oe);v(this,Le);v(this,oi);var r,s,o;b(this,oi,e),b(this,Le,new hi({apiUrl:e.apiUrl||e.backendUrl})),b(this,Se,new fi);let t=yo({subscriberId:e.subscriberId,subscriber:e.subscriber}),i=Br(e.context);b(this,oe,new Pi({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Le),a(this,Se))),a(this,oe).initialize(),this.notifications=new Ai({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.preferences=new Ii({useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.subscriptions=new Ln({subscriber:t,contextKey:i,useCache:(o=e.useCache)!=null?o:!0,inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.channelConnections=new dn({inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.channelEndpoints=new pn({inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.socket=Gc({socketUrl:e.socketUrl,socketOptions:e.socketOptions,eventEmitterInstance:a(this,Se),inboxServiceInstance:a(this,Le)}),this.on=(c,u)=>{this.socket.isSocketEvent(c)&&this.socket.connect();let h=a(this,Se).on(c,u);return()=>{h()}},this.off=(c,u)=>{a(this,Se).off(c,u)}}get applicationIdentifier(){return a(this,oe).applicationIdentifier}get subscriberId(){return a(this,oe).subscriberId}get context(){return a(this,oe).context}get options(){return a(this,oi)}get contextKey(){return Br(a(this,oe).context)}clearCache(){this.notifications.cache.clearAll(),this.preferences.cache.clearAll(),this.preferences.scheduleCache.clearAll(),this.subscriptions.cache.clearAll()}changeSubscriber(e){return p(this,null,function*(){yield a(this,oe).initialize({applicationIdentifier:a(this,oe).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,oe).context,contextHash:a(this,oe).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return p(this,null,function*(){let t=a(this,oe).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,oe).initialize({applicationIdentifier:a(this,oe).applicationIdentifier||"",subscriberHash:a(this,oe).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Se=new WeakMap,oe=new WeakMap,Le=new WeakMap,oi=new WeakMap;window.Novu=kr;})();
|
|
41
|
+
`),ko=!0);let o=this._options.WebSocket||WebSocket;this._debug("connect",{url:r,protocols:s}),this._ws=s?new o(r,s):new o(r),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),i)}).catch(r=>{this._connectLock=!1,this._handleError(new Kr.ErrorEvent(Error(r.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Kr.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,i){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(t,i),this._handleClose(new Kr.CloseEvent(t,i,this))}catch(r){}}}_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 Tl=/^(?:\{\{[^}]*\}\}.*|(?!mailto:)(?:https?:\/\/[^\s/$.?#][^\s{}]*(?:\{\{[^}]*\}\}[^\s{}]*)*)|\/(?!\/)[^\s{}]*(?:\{\{[^}]*\}\}[^\s{}]*)*)$/,Il=["_self","_blank","_parent","_top","_unfencedTop"];function Pl(n){return Tl.test(n)}function Fl(n){return typeof n=="string"&&Il.includes(n)}function pt(n,e){if(!(!n||!Pl(n)))return y({url:n},Fl(e)?{target:e}:{})}var zn="wss://socket.novu.co",Ll=25e3,To="ping",Io="notifications.notification_received",Po="notifications.unseen_count_changed",Fo="notifications.unread_count_changed",Ul=({_id:n,transactionId:e,content:t,read:i,seen:r,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:m,subscriber:p,subject:w,avatar:g,cta:S,tags:R,data:N,workflow:_,severity:C})=>{var qe,bt,he,tt,nt,it,Ae,Ne,St;let M={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},O=(bt=(qe=S.action)==null?void 0:qe.buttons)==null?void 0:bt.find(We=>We.type==="primary"),F=(tt=(he=S.action)==null?void 0:he.buttons)==null?void 0:tt.find(We=>We.type==="secondary"),$=(it=(nt=S.action)==null?void 0:nt.result)==null?void 0:it.type,te=(Ae=S.action)==null?void 0:Ae.status;return x(y(y({id:n,transactionId:e,subject:w,body:t,to:M,isRead:i,isSeen:r,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:g,primaryAction:O&&{label:O.content,isCompleted:$==="primary"&&te==="done",redirect:pt(O.url,O.target)},secondaryAction:F&&{label:F.content,isCompleted:$==="secondary"&&te==="done",redirect:pt(F.url,F.target)},channelType:m,tags:R,redirect:pt((Ne=S.data)==null?void 0:Ne.url,(St=S.data)==null?void 0:St.target),data:N,workflow:_,severity:C})},zt,Oe,Ee,Gt,Kn,At,$i,Ki,zi,Gi,ue,qi,Lo,Uo,zr,Gr,Wi=class extends j{constructor({socketUrl:t,socketOptions:i,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,ue);v(this,zt);v(this,Oe);v(this,Ee);v(this,Gt);v(this,Kn);v(this,At);v(this,$i,t=>{try{let i=JSON.parse(t.data);i.event==="notification_received"&&a(this,Oe).emit(Io,{result:new U(Ul(i.data.message),a(this,Oe),this._inboxService)})}catch(i){console.log("error",i)}});v(this,Ki,t=>{try{let i=JSON.parse(t.data);i.event==="unseen_count_changed"&&a(this,Oe).emit(Po,{result:i.data.unseenCount})}catch(i){}});v(this,zi,t=>{try{let i=JSON.parse(t.data);i.event==="unread_count_changed"&&a(this,Oe).emit(Fo,{result:i.data.counts})}catch(i){}});v(this,Gi,t=>{if(!(t.data===To||t.data==="pong"))try{switch(JSON.parse(t.data).event){case"notification_received":a(this,$i).call(this,t);break;case"unseen_count_changed":a(this,Ki).call(this,t);break;case"unread_count_changed":a(this,zi).call(this,t);break;default:}}catch(i){}});b(this,Oe,s),b(this,Gt,t!=null?t:zn),b(this,Kn,i)}onSessionSuccess({token:t}){b(this,zt,t)}isSocketEvent(t){return t===Io||t===Po||t===Fo}connect(){return d(this,null,function*(){return a(this,zt)?ae(this,ue,zr).call(this):this.callWithSession(ae(this,ue,zr).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,Ee)?ae(this,ue,Gr).call(this):this.callWithSession(ae(this,ue,Gr).bind(this))})}};zt=new WeakMap,Oe=new WeakMap,Ee=new WeakMap,Gt=new WeakMap,Kn=new WeakMap,At=new WeakMap,$i=new WeakMap,Ki=new WeakMap,zi=new WeakMap,Gi=new WeakMap,ue=new WeakSet,qi=function(){a(this,At)!==void 0&&(clearInterval(a(this,At)),b(this,At,void 0))},Lo=function(){ae(this,ue,qi).call(this),b(this,At,setInterval(()=>{let t=a(this,Ee);if(!(!t||t.readyState!==$n.OPEN))try{t.send(To)}catch(i){}},Ll))},Uo=function(){return d(this,null,function*(){if(a(this,Ee))return;let t={socketUrl:a(this,Gt)};a(this,Oe).emit("socket.connect.pending",{args:t});let i=new URL(a(this,Gt));i.searchParams.set("token",a(this,zt)),b(this,Ee,new $n(i.toString(),void 0,a(this,Kn)));let r=a(this,Ee);r.addEventListener("open",()=>{ae(this,ue,Lo).call(this),a(this,Oe).emit("socket.connect.resolved",{args:t})}),r.addEventListener("error",s=>{a(this,Oe).emit("socket.connect.resolved",{args:t,error:s})}),r.addEventListener("close",()=>{r===a(this,Ee)&&(ae(this,ue,qi).call(this),b(this,Ee,void 0))}),r.addEventListener("message",a(this,Gi))})},zr=function(){return d(this,null,function*(){try{return yield ae(this,ue,Uo).call(this),{}}catch(t){return{error:new E("Failed to initialize the PartySocket",t)}}})},Gr=function(){return d(this,null,function*(){var t;try{return ae(this,ue,qi).call(this),(t=a(this,Ee))==null||t.close(),b(this,Ee,void 0),{}}catch(i){return{error:new E("Failed to disconnect from the PartySocket",i)}}})};var Te=Object.create(null);Te.open="0";Te.close="1";Te.ping="2";Te.pong="3";Te.message="4";Te.upgrade="5";Te.noop="6";var Gn=Object.create(null);Object.keys(Te).forEach(n=>{Gn[Te[n]]=n});var Vn={type:"error",data:"parser error"};var jn=({type:n,data:e},t,i)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?i(t?e:"b"+Do(e,!0).toString("base64")):i(Te[n]+(e||"")),Do=(n,e)=>Buffer.isBuffer(n)||n instanceof Uint8Array&&!e?n:n instanceof ArrayBuffer?Buffer.from(n):Buffer.from(n.buffer,n.byteOffset,n.byteLength),Vr;function Bo(n,e){if(n.data instanceof ArrayBuffer||ArrayBuffer.isView(n.data))return e(Do(n.data,!1));jn(n,!0,t=>{Vr||(Vr=new TextEncoder),e(Vr.encode(t))})}var Hn=(n,e)=>{if(typeof n!="string")return{type:"message",data:Mo(n,e)};let t=n.charAt(0);if(t==="b"){let i=Buffer.from(n.substring(1),"base64");return{type:"message",data:Mo(i,e)}}return Gn[t]?n.length>1?{type:Gn[t],data:n.substring(1)}:{type:Gn[t]}:Vn},Mo=(n,e)=>e==="arraybuffer"?n instanceof ArrayBuffer?n:Buffer.isBuffer(n)?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n.buffer:Buffer.isBuffer(n)?n:Buffer.from(n);var qo="",Wo=(n,e)=>{let t=n.length,i=new Array(t),r=0;n.forEach((s,o)=>{jn(s,!1,c=>{i[o]=c,++r===t&&e(i.join(qo))})})},$o=(n,e)=>{let t=n.split(qo),i=[];for(let r=0;r<t.length;r++){let s=Hn(t[r],e);if(i.push(s),s.type==="error")break}return i};function Ko(){return new TransformStream({transform(n,e){Bo(n,t=>{let i=t.length,r;if(i<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,i);else if(i<65536){r=new Uint8Array(3);let s=new DataView(r.buffer);s.setUint8(0,126),s.setUint16(1,i)}else{r=new Uint8Array(9);let s=new DataView(r.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}var jr;function Vi(n){return n.reduce((e,t)=>e+t.length,0)}function ji(n,e){if(n[0].length===e)return n.shift();let t=new Uint8Array(e),i=0;for(let r=0;r<e;r++)t[r]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),t}function zo(n,e){jr||(jr=new TextDecoder);let t=[],i=0,r=-1,s=!1;return new TransformStream({transform(o,c){for(t.push(o);;){if(i===0){if(Vi(t)<1)break;let u=ji(t,1);s=(u[0]&128)===128,r=u[0]&127,r<126?i=3:r===126?i=1:i=2}else if(i===1){if(Vi(t)<2)break;let u=ji(t,2);r=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),i=3}else if(i===2){if(Vi(t)<8)break;let u=ji(t,8),h=new DataView(u.buffer,u.byteOffset,u.length),l=h.getUint32(0);if(l>Math.pow(2,21)-1){c.enqueue(Vn);break}r=l*Math.pow(2,32)+h.getUint32(4),i=3}else{if(Vi(t)<r)break;let u=ji(t,r);c.enqueue(Hn(s?u:jr.decode(u),e)),i=0}if(r===0||r>n){c.enqueue(Vn);break}}}})}var Hr=4;function L(n){if(n)return Dl(n)}function Dl(n){for(var e in L.prototype)n[e]=L.prototype[e];return n}L.prototype.on=L.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};L.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,r=0;r<t.length;r++)if(i=t[r],i===e||i.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+n],this};L.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,r=t.length;i<r;++i)t[i].apply(this,e)}return this};L.prototype.emitReserved=L.prototype.emit;L.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};L.prototype.hasListeners=function(n){return!!this.listeners(n).length};var Ie=global;function Hi(n,...e){return e.reduce((t,i)=>(n.hasOwnProperty(i)&&(t[i]=n[i]),t),{})}var Bl=Ie.setTimeout,Ml=Ie.clearTimeout;function Ye(n,e){e.useNativeTimers?(n.setTimeoutFn=Bl.bind(Ie),n.clearTimeoutFn=Ml.bind(Ie)):(n.setTimeoutFn=Ie.setTimeout.bind(Ie),n.clearTimeoutFn=Ie.clearTimeout.bind(Ie))}var ql=1.33;function Go(n){return typeof n=="string"?Wl(n):Math.ceil((n.byteLength||n.size)*ql)}function Wl(n){let e=0,t=0;for(let i=0,r=n.length;i<r;i++)e=n.charCodeAt(i),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(i++,t+=4);return t}var ia=G(Yt(),1);function ta(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function na(n){let e={},t=n.split("&");for(let i=0,r=t.length;i<r;i++){let s=t[i].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}var uu=(0,ia.default)("engine.io-client:transport"),es=class extends Error{constructor(e,t,i){super(e),this.description=t,this.context=i,this.type="TransportError"}},Je=class extends L{constructor(e){super(),this.writable=!1,Ye(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,i){return super.emitReserved("error",new es(e,t,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):uu("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Hn(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=ta(e);return t.length?"?"+t:""}};var da=G(Yt(),1);var aa="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),ts=64,hu={},ra=0,er=0,sa;function oa(n){let e="";do e=aa[n%ts]+e,n=Math.floor(n/ts);while(n>0);return e}function tr(){let n=oa(+new Date);return n!==sa?(ra=0,sa=n):n+"."+oa(ra++)}for(;er<ts;er++)hu[aa[er]]=er;var rs=G(ua(),1),ss=rs.default||rs;function ha(){return new is}function du(n){let e=n.split("; "),t=e[0].indexOf("=");if(t===-1)return;let i=e[0].substring(0,t).trim();if(!i.length)return;let r=e[0].substring(t+1).trim();r.charCodeAt(0)===34&&(r=r.slice(1,-1));let s={name:i,value:r};for(let o=1;o<e.length;o++){let c=e[o].split("=");if(c.length!==2)continue;let u=c[0].trim(),h=c[1].trim();switch(u){case"Expires":s.expires=new Date(h);break;case"Max-Age":let l=new Date;l.setUTCSeconds(l.getUTCSeconds()+parseInt(h,10)),s.expires=l;break;default:}}return s}var is=class{constructor(){this.cookies=new Map}parseCookies(e){let t=e.getResponseHeader("set-cookie");t&&t.forEach(i=>{let r=du(i);r&&this.cookies.set(r.name,r)})}addCookies(e){let t=[];this.cookies.forEach((i,r)=>{var s;((s=i.expires)===null||s===void 0?void 0:s.getTime())<Date.now()?this.cookies.delete(r):t.push(`${r}=${i.value}`)}),t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}};var fe=(0,da.default)("engine.io-client:polling");function pu(){}var mu=(function(){return new ss({xdomain:!1}).responseType!=null})(),nr=class extends Je{constructor(e){if(super(e),this.polling=!1,typeof location!="undefined"){let i=location.protocol==="https:",r=location.port;r||(r=i?"443":"80"),this.xd=typeof location!="undefined"&&e.hostname!==location.hostname||r!==e.port}let t=e&&e.forceBase64;this.supportsBinary=mu&&!t,this.opts.withCredentials&&(this.cookieJar=ha())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";let t=()=>{fe("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let i=0;this.polling&&(fe("we are currently polling - waiting to pause"),i++,this.once("pollComplete",function(){fe("pre-pause polling complete"),--i||t()})),this.writable||(fe("we are currently writing - waiting to pause"),i++,this.once("drain",function(){fe("pre-pause writing complete"),--i||t()}))}else t()}poll(){fe("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){fe("polling got data %s",e);let t=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};$o(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this.poll():fe('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{fe("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(fe("transport open - closing"),e()):(fe("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,Wo(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 gt(this.uri(),e)}doWrite(e,t){let i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",(r,s)=>{this.onError("xhr post error",r,s)})}doPoll(){fe("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,i)=>{this.onError("xhr poll error",t,i)}),this.pollXhr=e}},gt=class n extends L{constructor(e,t){super(),Ye(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=Hi(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;let i=this.xhr=new ss(t);try{fe("xhr open %s: %s",this.method,this.uri),i.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let r in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&i.setRequestHeader(r,this.opts.extraHeaders[r])}}catch(r){}if(this.method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(r){}try{i.setRequestHeader("Accept","*/*")}catch(r){}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(i.timeout=this.opts.requestTimeout),i.onreadystatechange=()=>{var r;i.readyState===3&&((r=this.opts.cookieJar)===null||r===void 0||r.parseCookies(i)),i.readyState===4&&(i.status===200||i.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof i.status=="number"?i.status:0)},0))},fe("xhr data %s",this.data),i.send(this.data)}catch(r){this.setTimeoutFn(()=>{this.onError(r)},0);return}typeof document!="undefined"&&(this.index=n.requestsCount++,n.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=pu,e)try{this.xhr.abort()}catch(t){}typeof document!="undefined"&&delete n.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()}};gt.requestsCount=0;gt.requests={};if(typeof document!="undefined"){if(typeof attachEvent=="function")attachEvent("onunload",fa);else if(typeof addEventListener=="function"){let n="onpagehide"in Ie?"pagehide":"unload";addEventListener(n,fa,!1)}}function fa(){for(let n in gt.requests)gt.requests.hasOwnProperty(n)&>.requests[n].abort()}var Uh=G(cc(),1),Dh=G(hr(),1),Bh=G(Zt(),1),Mh=G(gs(),1),qh=G(bs(),1),Wh=G(xs(),1),yc=G(mr(),1),$h=G(gc(),1);var vc=yc.default;var ni=vc,yr=!1,bc="nodebuffer",Pt=process.nextTick;var _c=G(Yt(),1);var Kh=(0,_c.default)("engine.io-client:websocket"),Sc=typeof navigator!="undefined"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",vr=class extends Je{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;let e=this.uri(),t=this.opts.protocols,i=Sc?{}:Hi(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=yr&&!Sc?t?new ni(e,t):new ni(e):new ni(e,t,i)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],r=t===e.length-1;jn(i,this.supportsBinary,s=>{let o={};yr||(i.options&&(o.compress=i.options.compress),this.opts.perMessageDeflate&&(typeof s=="string"?Buffer.byteLength(s):s.length)<this.opts.perMessageDeflate.threshold&&(o.compress=!1));try{yr?this.ws.send(s):this.ws.send(s,o)}catch(c){Kh("websocket closed before onclose event")}r&&Pt(()=>{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!!ni}};var Ec=G(Yt(),1),ii=(0,Ec.default)("engine.io-client:webtransport"),br=class extends Je{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{ii("transport closed gracefully"),this.onClose()}).catch(e=>{ii("transport closed due to %s",e),this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{let t=zo(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(t).getReader(),r=Ko();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();let s=()=>{i.read().then(({done:c,value:u})=>{if(c){ii("session is closed");return}ii("received chunk: %o",u),this.onPacket(u),s()}).catch(c=>{ii("an error occurred while reading: %s",c)})};s();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let i=e[t],r=t===e.length-1;this.writer.write(i).then(()=>{r&&Pt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}};var Ns={websocket:vr,webtransport:br,polling:nr};var zh=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Gh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function on(n){let e=n,t=n.indexOf("["),i=n.indexOf("]");t!=-1&&i!=-1&&(n=n.substring(0,t)+n.substring(t,i).replace(/:/g,";")+n.substring(i,n.length));let r=zh.exec(n||""),s={},o=14;for(;o--;)s[Gh[o]]=r[o]||"";return t!=-1&&i!=-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=Vh(s,s.path),s.queryKey=jh(s,s.query),s}function Vh(n,e){let t=/\/{2,9}/g,i=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function jh(n,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,r,s){r&&(t[r]=s)}),t}var Cc=G(Yt(),1);var B=(0,Cc.default)("engine.io-client:socket"),Ft=class n extends L{constructor(e,t={}){super(),this.binaryType=bc,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=on(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=on(t.host).host),Ye(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=na(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){B('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Hr,t.transport=e,this.id&&(t.sid=this.id);let i=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return B("options: %j",i),new Ns[e](i)}open(){let e;if(this.opts.rememberUpgrade&&n.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){B("error while creating transport: %s",t),this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){B("setting transport %s",e.name),this.transport&&(B("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){B('probing transport "%s"',e);let t=this.createTransport(e),i=!1;n.priorWebsocketSuccess=!1;let r=()=>{i||(B('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",f=>{if(!i)if(f.type==="pong"&&f.data==="probe"){if(B('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;n.priorWebsocketSuccess=t.name==="websocket",B('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{i||this.readyState!=="closed"&&(B("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{B('probe transport "%s" failed',e);let m=new Error("probe error");m.transport=t.name,this.emitReserved("upgradeError",m)}}))};function s(){i||(i=!0,l(),t.close(),t=null)}let o=f=>{let m=new Error("probe error: "+f);m.transport=t.name,s(),B('probe transport "%s" failed because of error: %s',e,f),this.emitReserved("upgradeError",m)};function c(){o("transport closed")}function u(){o("socket closed")}function h(f){t&&f.name!==t.name&&(B('"%s" works - aborting "%s"',f.name,t.name),s())}let l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",c),this.off("close",u),this.off("upgrading",h)};t.once("open",r),t.once("error",o),t.once("close",c),this.once("close",u),this.once("upgrading",h),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{i||t.open()},200):t.open()}onOpen(){if(B("socket open"),this.readyState="open",n.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){B("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(B('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 B('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();B("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i<this.writeBuffer.length;i++){let r=this.writeBuffer[i].data;if(r&&(t+=Go(r)),i>0&&t>this.maxPayload)return B("only send %d out of %d packets",i,this.writeBuffer.length),this.writeBuffer.slice(0,i);t+=2}return B("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,i){return this.sendPacket("message",e,t,i),this}send(e,t,i){return this.sendPacket("message",e,t,i),this}sendPacket(e,t,i,r){if(typeof t=="function"&&(r=t,t=void 0),typeof i=="function"&&(r=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;let s={type:e,data:t,options:i};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),r&&this.once("flush",r),this.flush()}close(){let e=()=>{this.onClose("forced close"),B("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}onError(e){B("socket error %j",e),n.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(B('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){let t=[],i=0,r=e.length;for(;i<r;i++)~this.transports.indexOf(e[i])&&t.push(e[i]);return t}};Ft.protocol=Hr;var hy=Ft.protocol;var Rc=G(ri(),1),kc=(0,Rc.default)("socket.io-client:url");function Oc(n,e="",t){let i=n;t=t||typeof location!="undefined"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(kc("protocol-less url %s",n),typeof t!="undefined"?n=t.protocol+"//"+n:n="https://"+n),kc("parse %s",n),i=on(n)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";let s=i.host.indexOf(":")!==-1?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+s+":"+i.port+e,i.href=i.protocol+"://"+s+(t&&t.port===i.port?"":":"+i.port),i}var Bs={};al(Bs,{Decoder:()=>Us,Encoder:()=>Ls,PacketType:()=>k,isPacketValid:()=>Df,protocol:()=>Kc});var uf=typeof ArrayBuffer=="function",hf=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,Tc=Object.prototype.toString,ff=typeof Blob=="function"||typeof Blob!="undefined"&&Tc.call(Blob)==="[object BlobConstructor]",df=typeof File=="function"||typeof File!="undefined"&&Tc.call(File)==="[object FileConstructor]";function oi(n){return uf&&(n instanceof ArrayBuffer||hf(n))||ff&&n instanceof Blob||df&&n instanceof File}function si(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,i=n.length;t<i;t++)if(si(n[t]))return!0;return!1}if(oi(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return si(n.toJSON(),!0);for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&si(n[t]))return!0;return!1}function Ic(n){let e=[],t=n.data,i=n;return i.data=Os(t,e),i.attachments=e.length,{packet:i,buffers:e}}function Os(n,e){if(!n)return n;if(oi(n)){let t={_placeholder:!0,num:e.length};return e.push(n),t}else if(Array.isArray(n)){let t=new Array(n.length);for(let i=0;i<n.length;i++)t[i]=Os(n[i],e);return t}else if(typeof n=="object"&&!(n instanceof Date)){let t={};for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=Os(n[i],e));return t}return n}function Pc(n,e){return n.data=Ts(n.data,e),delete n.attachments,n}function Ts(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=Ts(n[t],e);else if(typeof n=="object")for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=Ts(n[t],e));return n}var Wc=G(qc(),1),Fs=(0,Wc.default)("socket.io-parser"),$c=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Kc=5,k;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(k||(k={}));var Ls=class{constructor(e){this.replacer=e}encode(e){return Fs("encoding packet %j",e),(e.type===k.EVENT||e.type===k.ACK)&&si(e)?this.encodeAsBinary({type:e.type===k.EVENT?k.BINARY_EVENT:k.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===k.BINARY_EVENT||e.type===k.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)),Fs("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=Ic(e),i=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(i),r}},Us=class n extends L{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let i=t.type===k.BINARY_EVENT;i||t.type===k.BINARY_ACK?(t.type=i?k.EVENT:k.ACK,this.reconstructor=new Ds(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(oi(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,i={type:Number(e.charAt(0))};if(k[i.type]===void 0)throw new Error("unknown packet type "+i.type);if(i.type===k.BINARY_EVENT||i.type===k.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");let c=Number(o);if(!zc(c)||c<0)throw new Error("Illegal attachments");if(c>this.opts.maxAttachments)throw new Error("too many attachments");i.attachments=c}if(e.charAt(t+1)==="/"){let s=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););i.nsp=e.substring(s,t)}else i.nsp="/";let r=e.charAt(t+1);if(r!==""&&Number(r)==r){let s=t+1;for(;++t;){let o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}i.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){let s=this.tryParse(e.substr(t));if(n.isPayloadValid(i.type,s))i.data=s;else throw new Error("invalid payload")}return Fs("decoded %s as %j",e,i),i}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(t){return!1}}static isPayloadValid(e,t){switch(e){case k.CONNECT:return Nr(t);case k.DISCONNECT:return t===void 0;case k.CONNECT_ERROR:return typeof t=="string"||Nr(t);case k.EVENT:case k.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&$c.indexOf(t[0])===-1);case k.ACK:case k.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Ds=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=Pc(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Ff(n){return typeof n=="string"}var zc=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function Lf(n){return n===void 0||zc(n)}function Nr(n){return Object.prototype.toString.call(n)==="[object Object]"}function Uf(n,e){switch(n){case k.CONNECT:return e===void 0||Nr(e);case k.DISCONNECT:return e===void 0;case k.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&$c.indexOf(e[0])===-1);case k.ACK:return Array.isArray(e);case k.CONNECT_ERROR:return typeof e=="string"||Nr(e);default:return!1}}function Df(n){return Ff(n.nsp)&&Lf(n.id)&&Uf(n.type,n.data)}function ve(n,e,t){return n.on(e,t),function(){n.off(e,t)}}var Gc=G(ri(),1),V=(0,Gc.default)("socket.io-client:socket"),Bf=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),un=class extends L{constructor(e,t,i){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,i&&i.auth&&(this.auth=i.auth),this._opts=Object.assign({},i),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ve(e,"open",this.onopen.bind(this)),ve(e,"packet",this.onpacket.bind(this)),ve(e,"error",this.onerror.bind(this)),ve(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(Bf.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let i={type:k.EVENT,data:t};if(i.options={},i.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let o=this.ids++;V("emitting packet with ack id %d",o);let c=t.pop();this._registerAckCallback(o,c),i.id=o}let r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)?V("discard packet as the transport is not currently writable"):this.connected?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i),this.flags={},this}_registerAckCallback(e,t){var i;let r=(i=this.flags.timeout)!==null&&i!==void 0?i:this._opts.ackTimeout;if(r===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&&(V("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(o,1));V("event with ack id %d has timed out after %d ms",e,r),t.call(this,new Error("operation has timed out"))},r);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...o])}}emitWithAck(e,...t){let i=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((r,s)=>{t.push((o,c)=>i?o?s(o):r(c):r(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let i={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((r,...s)=>i!==this._queue[0]?void 0:(r!==null?i.tryCount>this._opts.retries&&(V("packet [%d] is discarded after %d tries",i.id,i.tryCount),this._queue.shift(),t&&t(r)):(V("packet [%d] was successfully sent",i.id),this._queue.shift(),t&&t(null,...s)),i.pending=!1,this._drainQueue())),this._queue.push(i),this._drainQueue()}_drainQueue(e=!1){if(V("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){V("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,V("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(){V("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:k.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){V("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 k.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 k.EVENT:case k.BINARY_EVENT:this.onevent(e);break;case k.ACK:case k.BINARY_ACK:this.onack(e);break;case k.DISCONNECT:this.ondisconnect();break;case k.CONNECT_ERROR:this.destroy();let i=new Error(e.data.message);i.data=e.data.data,this.emitReserved("connect_error",i);break}}onevent(e){let t=e.data||[];V("emitting event %j",t),e.id!=null&&(V("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let i of t)i.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,i=!1;return function(...r){i||(i=!0,V("sending ack %j",r),t.packet({type:k.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t=="function"?(V("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):V("bad ack %s",e.id)}onconnect(e,t){V("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(){V("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&&(V("performing disconnect (%s)",this.nsp),this.packet({type:k.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let i=0;i<t.length;i++)if(e===t[i])return t.splice(i,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let i of t)i.apply(this,e.data)}}};function Ut(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}Ut.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0};Ut.prototype.reset=function(){this.attempts=0};Ut.prototype.setMin=function(n){this.ms=n};Ut.prototype.setMax=function(n){this.max=n};Ut.prototype.setJitter=function(n){this.jitter=n};var Vc=G(ri(),1),se=(0,Vc.default)("socket.io-client:manager"),hn=class extends L{constructor(e,t){var i;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Ye(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((i=t.randomizationFactor)!==null&&i!==void 0?i:.5),this.backoff=new Ut({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let r=t.parser||Bs;this.encoder=new r.Encoder,this.decoder=new r.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(se("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;se("opening %s",this.uri),this.engine=new Ft(this.uri,this.opts);let t=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;let r=ve(t,"open",function(){i.onopen(),e&&e()}),s=c=>{se("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",c),e?e(c):this.maybeReconnectOnOpen()},o=ve(t,"error",s);if(this._timeout!==!1){let c=this._timeout;se("connect attempt will timeout after %d",c);let u=this.setTimeoutFn(()=>{se("connect attempt timed out after %d",c),r(),s(new Error("timeout")),t.close()},c);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){se("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(ve(e,"ping",this.onping.bind(this)),ve(e,"data",this.ondata.bind(this)),ve(e,"error",this.onerror.bind(this)),ve(e,"close",this.onclose.bind(this)),ve(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){Pt(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){se("error",e),this.emitReserved("error",e)}socket(e,t){let i=this.nsps[e];return i?this._autoConnect&&!i.active&&i.connect():(i=new un(this,e,t),this.nsps[e]=i),i}_destroy(e){let t=Object.keys(this.nsps);for(let i of t)if(this.nsps[i].active){se("socket %s is still active, skipping close",i);return}this._close()}_packet(e){se("writing packet %j",e);let t=this.encoder.encode(e);for(let i=0;i<t.length;i++)this.engine.write(t[i],e.options)}cleanup(){se("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){se("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){se("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)se("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();se("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let i=this.setTimeoutFn(()=>{e.skipReconnect||(se("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(r=>{r?(se("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",r)):(se("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&i.unref(),this.subs.push(()=>{this.clearTimeoutFn(i)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};var Hc=G(ri(),1),jc=(0,Hc.default)("socket.io-client"),ai={};function ci(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};let t=Oc(n,e.path||"/socket.io"),i=t.source,r=t.id,s=t.path,o=ai[r]&&s in ai[r].nsps,c=e.forceNew||e["force new connection"]||e.multiplex===!1||o,u;return c?(jc("ignoring socket cache for %s",i),u=new hn(i,e)):(ai[r]||(jc("new io instance for %s",i),ai[r]=new hn(i,e)),u=ai[r]),t.query&&!e.query&&(e.query=t.queryKey),u.socket(t.path,e)}Object.assign(ci,{Manager:hn,Socket:un,io:ci,connect:ci});var Mf="https://ws.novu.co",Yc="notifications.notification_received",Jc="notifications.unseen_count_changed",Xc="notifications.unread_count_changed",qf=({_id:n,transactionId:e,content:t,read:i,seen:r,archived:s,snoozedUntil:o,deliveredAt:c,createdAt:u,lastReadDate:h,firstSeenDate:l,archivedAt:f,channel:m,subscriber:p,subject:w,avatar:g,cta:S,tags:R,data:N,workflow:_,severity:C})=>{var qe,bt,he,tt,nt,it,Ae,Ne,St;let M={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},O=(bt=(qe=S.action)==null?void 0:qe.buttons)==null?void 0:bt.find(We=>We.type==="primary"),F=(tt=(he=S.action)==null?void 0:he.buttons)==null?void 0:tt.find(We=>We.type==="secondary"),$=(it=(nt=S.action)==null?void 0:nt.result)==null?void 0:it.type,te=(Ae=S.action)==null?void 0:Ae.status;return x(y(y({id:n,transactionId:e,subject:w,body:t,to:M,isRead:i,isSeen:r,isArchived:s,isSnoozed:!!o},c&&{deliveredAt:c}),o&&{snoozedUntil:o}),{createdAt:u,readAt:h,firstSeenAt:l,archivedAt:f,avatar:g,primaryAction:O&&{label:O.content,isCompleted:$==="primary"&&te==="done",redirect:pt(O.url,O.target)},secondaryAction:F&&{label:F.content,isCompleted:$==="secondary"&&te==="done",redirect:pt(F.url,F.target)},channelType:m,tags:R,redirect:pt((Ne=S.data)==null?void 0:Ne.url,(St=S.data)==null?void 0:St.target),data:N,workflow:_,severity:C})},fn,Fe,be,dn,li,Rr,Or,Tr,Me,Qc,Ms,qs,kr=class extends j{constructor({socketUrl:t,socketOptions:i,inboxServiceInstance:r,eventEmitterInstance:s}){super({eventEmitterInstance:s,inboxServiceInstance:r});v(this,Me);v(this,fn);v(this,Fe);v(this,be);v(this,dn);v(this,li);v(this,Rr,({message:t})=>{a(this,Fe).emit(Yc,{result:new U(qf(t),a(this,Fe),this._inboxService)})});v(this,Or,({unseenCount:t})=>{a(this,Fe).emit(Jc,{result:t})});v(this,Tr,({counts:t})=>{a(this,Fe).emit(Xc,{result:t})});b(this,Fe,s),b(this,dn,t!=null?t:Mf),b(this,li,i)}onSessionSuccess({token:t}){b(this,fn,t)}isSocketEvent(t){return t===Yc||t===Jc||t===Xc}connect(){return d(this,null,function*(){return a(this,fn)?ae(this,Me,Ms).call(this):this.callWithSession(ae(this,Me,Ms).bind(this))})}disconnect(){return d(this,null,function*(){return a(this,be)?ae(this,Me,qs).call(this):this.callWithSession(ae(this,Me,qs).bind(this))})}};fn=new WeakMap,Fe=new WeakMap,be=new WeakMap,dn=new WeakMap,li=new WeakMap,Rr=new WeakMap,Or=new WeakMap,Tr=new WeakMap,Me=new WeakSet,Qc=function(){return d(this,null,function*(){var i,r,s,o;if(a(this,be))return;let t={socketUrl:a(this,dn)};a(this,Fe).emit("socket.connect.pending",{args:t}),b(this,be,ci(a(this,dn),y({reconnectionDelayMax:1e4,transports:["websocket"],query:{token:`${a(this,fn)}`}},(i=a(this,li))!=null?i:{}))),a(this,be).on("connect",()=>{a(this,Fe).emit("socket.connect.resolved",{args:t})}),a(this,be).on("connect_error",c=>{a(this,Fe).emit("socket.connect.resolved",{args:t,error:c})}),(r=a(this,be))==null||r.on("notification_received",a(this,Rr)),(s=a(this,be))==null||s.on("unseen_count_changed",a(this,Or)),(o=a(this,be))==null||o.on("unread_count_changed",a(this,Tr))})},Ms=function(){return d(this,null,function*(){try{return yield ae(this,Me,Qc).call(this),{}}catch(t){return{error:new E("Failed to initialize the socket",t)}}})},qs=function(){return d(this,null,function*(){var t;try{return(t=a(this,be))==null||t.disconnect(),b(this,be,void 0),{}}catch(i){return{error:new E("Failed to disconnect from the socket",i)}}})};var Wf=["wss://eu.socket.novu.co",zn,"wss://socket.novu-staging.co","wss://socket-worker-local.cli-shortener.workers.dev"],$f={"https://eu.ws.novu.co":"wss://eu.socket.novu.co","https://ws.novu.co":zn,"https://dev.ws.novu.co":"wss://socket.novu-staging.co"},Kf={cloud:"partysocket","self-hosted":"socket.io"};function zf(n){return n?$f[n]||n:zn}function Gf(n){return!n||Wf.includes(n)}function Vf(n,e){return e?Kf[e]:Gf(n)?"partysocket":"socket.io"}function Zc({socketUrl:n,socketOptions:e,inboxServiceInstance:t,eventEmitterInstance:i}){let r=zf(n),u=e||{},{socketType:s}=u,o=pn(u,["socketType"]);switch(Vf(r,s)){case"partysocket":return new Wi({socketUrl:r,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:i});case"socket.io":default:return new kr({socketUrl:r,socketOptions:o,inboxServiceInstance:t,eventEmitterInstance:i})}}var Se,oe,Le,ui,Ir=class{constructor(e){v(this,Se);v(this,oe);v(this,Le);v(this,ui);var r,s,o;b(this,ui,e),b(this,Le,new mi({apiUrl:e.apiUrl||e.backendUrl})),b(this,Se,new gi);let t=xo({subscriberId:e.subscriberId,subscriber:e.subscriber}),i=$r(e.context);b(this,oe,new Di({applicationIdentifier:e.applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:t,defaultSchedule:e.defaultSchedule,context:e.context,contextHash:e.contextHash},a(this,Le),a(this,Se))),a(this,oe).initialize(),this.notifications=new Oi({useCache:(r=e.useCache)!=null?r:!0,inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.preferences=new Ui({useCache:(s=e.useCache)!=null?s:!0,inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.subscriptions=new Mn({subscriber:t,contextKey:i,useCache:(o=e.useCache)!=null?o:!0,inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.channelConnections=new gn({inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.channelEndpoints=new yn({inboxServiceInstance:a(this,Le),eventEmitterInstance:a(this,Se)}),this.socket=Zc({socketUrl:e.socketUrl,socketOptions:e.socketOptions,eventEmitterInstance:a(this,Se),inboxServiceInstance:a(this,Le)}),this.on=(c,u)=>{this.socket.isSocketEvent(c)&&this.socket.connect();let h=a(this,Se).on(c,u);return()=>{h()}},this.off=(c,u)=>{a(this,Se).off(c,u)}}get applicationIdentifier(){return a(this,oe).applicationIdentifier}get subscriberId(){return a(this,oe).subscriberId}get context(){return a(this,oe).context}get options(){return a(this,ui)}get contextKey(){return $r(a(this,oe).context)}clearCache(){this.notifications.cache.clearAll(),this.preferences.cache.clearAll(),this.preferences.scheduleCache.clearAll(),this.subscriptions.cache.clearAll()}changeSubscriber(e){return d(this,null,function*(){yield a(this,oe).initialize({applicationIdentifier:a(this,oe).applicationIdentifier||"",subscriberHash:e.subscriberHash,subscriber:e.subscriber,context:a(this,oe).context,contextHash:a(this,oe).contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}changeContext(e){return d(this,null,function*(){let t=a(this,oe).subscriber;if(!t)throw new Error("Cannot change context without an active subscriber");yield a(this,oe).initialize({applicationIdentifier:a(this,oe).applicationIdentifier||"",subscriberHash:a(this,oe).subscriberHash,subscriber:t,context:e.context,contextHash:e.contextHash}),this.clearCache(),(yield this.socket.disconnect()).error||(yield this.socket.connect())})}};Se=new WeakMap,oe=new WeakMap,Le=new WeakMap,ui=new WeakMap;window.Novu=Ir;})();
|
|
42
42
|
/*! Bundled license information:
|
|
43
43
|
|
|
44
44
|
xmlhttprequest-ssl/lib/XMLHttpRequest.js:
|