@gadgetinc/ggt 1.0.5 → 1.1.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.
Files changed (89) hide show
  1. package/dist/add-RDTHYTCK.js +78 -0
  2. package/dist/add-RDTHYTCK.js.map +7 -0
  3. package/dist/chunk-3Q3GPB6Z.js +2 -0
  4. package/dist/chunk-3Q3GPB6Z.js.map +7 -0
  5. package/dist/chunk-457GEPUN.js +9 -0
  6. package/dist/chunk-457GEPUN.js.map +7 -0
  7. package/dist/{chunk-5DLLJX5F.js → chunk-5ONACLO6.js} +8 -8
  8. package/dist/{chunk-5DLLJX5F.js.map → chunk-5ONACLO6.js.map} +3 -3
  9. package/dist/chunk-CQLM5U6T.js +67 -0
  10. package/dist/chunk-CQLM5U6T.js.map +7 -0
  11. package/dist/chunk-FLXIAZND.js +12 -0
  12. package/dist/chunk-FLXIAZND.js.map +7 -0
  13. package/dist/chunk-JKDJXJKF.js +8 -0
  14. package/dist/{chunk-QEVWPU3D.js.map → chunk-JKDJXJKF.js.map} +3 -3
  15. package/dist/chunk-LWW4E6P5.js +173 -0
  16. package/dist/chunk-LWW4E6P5.js.map +7 -0
  17. package/dist/chunk-M2OJZLL7.js +18 -0
  18. package/dist/chunk-M2OJZLL7.js.map +7 -0
  19. package/dist/{chunk-Q5N5L6H3.js → chunk-M4PNFOA5.js} +2 -2
  20. package/dist/chunk-M4PNFOA5.js.map +7 -0
  21. package/dist/chunk-NGTOMLDS.js +33 -0
  22. package/dist/{chunk-G3VNV5Z6.js.map → chunk-NGTOMLDS.js.map} +3 -3
  23. package/dist/chunk-RYQWS5BH.js +117 -0
  24. package/dist/chunk-RYQWS5BH.js.map +7 -0
  25. package/dist/{chunk-IKJVXTZK.js → chunk-TRHAPK2F.js} +4 -6
  26. package/dist/{chunk-IKJVXTZK.js.map → chunk-TRHAPK2F.js.map} +2 -2
  27. package/dist/chunk-VICN6LTV.js +12 -0
  28. package/dist/chunk-VICN6LTV.js.map +7 -0
  29. package/dist/context-GN36UFJL.js +2 -0
  30. package/dist/deploy-BAMMI3ZA.js +24 -0
  31. package/dist/deploy-BAMMI3ZA.js.map +7 -0
  32. package/dist/{dev-M3WDGK4D.js → dev-5UFCKF4X.js} +9 -11
  33. package/dist/{dev-M3WDGK4D.js.map → dev-5UFCKF4X.js.map} +3 -3
  34. package/dist/esm-GJ7RK6IC.js +34 -0
  35. package/dist/esm-GJ7RK6IC.js.map +7 -0
  36. package/dist/list-WGRXHV2B.js +11 -0
  37. package/dist/list-WGRXHV2B.js.map +7 -0
  38. package/dist/login-5YZOB4XB.js +2 -0
  39. package/dist/logout-YXDH5ZZI.js +7 -0
  40. package/dist/{logout-UZBACOIX.js.map → logout-YXDH5ZZI.js.map} +3 -3
  41. package/dist/main.js +6 -8
  42. package/dist/main.js.map +3 -3
  43. package/dist/{open-GWKGQQG3.js → open-EOH3Q5KP.js} +3 -3
  44. package/dist/{open-GWKGQQG3.js.map → open-EOH3Q5KP.js.map} +2 -2
  45. package/dist/{pull-7C5A65KB.js → pull-UAKKKJJP.js} +3 -5
  46. package/dist/{pull-7C5A65KB.js.map → pull-UAKKKJJP.js.map} +2 -2
  47. package/dist/push-7X4P2364.js +2 -0
  48. package/dist/push-7X4P2364.js.map +7 -0
  49. package/dist/status-UJUGP24U.js +14 -0
  50. package/dist/{status-DFKKSRVB.js.map → status-UJUGP24U.js.map} +1 -1
  51. package/dist/user-B2RIDVTH.js +2 -0
  52. package/dist/user-B2RIDVTH.js.map +7 -0
  53. package/dist/{version-JD42JXWY.js → version-VE55GG37.js} +2 -2
  54. package/dist/whoami-OAH55L4M.js +7 -0
  55. package/dist/{whoami-I23R6HOG.js.map → whoami-OAH55L4M.js.map} +2 -2
  56. package/package.json +22 -22
  57. package/dist/add-4ME2KTJQ.js +0 -84
  58. package/dist/add-4ME2KTJQ.js.map +0 -7
  59. package/dist/chunk-BZY2AIPV.js +0 -57
  60. package/dist/chunk-BZY2AIPV.js.map +0 -7
  61. package/dist/chunk-G3VNV5Z6.js +0 -33
  62. package/dist/chunk-GA7AL463.js +0 -24
  63. package/dist/chunk-GA7AL463.js.map +0 -7
  64. package/dist/chunk-KGSSHEEC.js +0 -17
  65. package/dist/chunk-KGSSHEEC.js.map +0 -7
  66. package/dist/chunk-KXK37C5D.js +0 -183
  67. package/dist/chunk-KXK37C5D.js.map +0 -7
  68. package/dist/chunk-NJIDVM2C.js +0 -27
  69. package/dist/chunk-NJIDVM2C.js.map +0 -7
  70. package/dist/chunk-Q5N5L6H3.js.map +0 -7
  71. package/dist/chunk-QEVWPU3D.js +0 -8
  72. package/dist/chunk-X36GM74C.js +0 -2
  73. package/dist/chunk-X36GM74C.js.map +0 -7
  74. package/dist/chunk-YRP2UZ2I.js +0 -126
  75. package/dist/chunk-YRP2UZ2I.js.map +0 -7
  76. package/dist/deploy-6HOBYPE6.js +0 -30
  77. package/dist/deploy-6HOBYPE6.js.map +0 -7
  78. package/dist/esm-BL3OM5UJ.js +0 -33
  79. package/dist/esm-BL3OM5UJ.js.map +0 -7
  80. package/dist/list-725RHWD5.js +0 -11
  81. package/dist/list-725RHWD5.js.map +0 -7
  82. package/dist/login-I4RGMDLE.js +0 -2
  83. package/dist/logout-UZBACOIX.js +0 -7
  84. package/dist/push-LPUIR4EO.js +0 -2
  85. package/dist/status-DFKKSRVB.js +0 -14
  86. package/dist/whoami-I23R6HOG.js +0 -7
  87. /package/dist/{login-I4RGMDLE.js.map → context-GN36UFJL.js.map} +0 -0
  88. /package/dist/{push-LPUIR4EO.js.map → login-5YZOB4XB.js.map} +0 -0
  89. /package/dist/{version-JD42JXWY.js.map → version-VE55GG37.js.map} +0 -0
@@ -0,0 +1,33 @@
1
+ import{b as Jt}from"./chunk-D2K5XPNJ.js";import{b as lt,e as ct}from"./chunk-3Q3GPB6Z.js";import{a as ut,b as qe,d as Ue}from"./chunk-457GEPUN.js";import{k as Xt,l as Zt}from"./chunk-VICN6LTV.js";import{A as Yt,H as pe,Y as Kt,Z as ve,e as x,g as Qt,h as Ht,i as it,j as nt,k as ot,m as at,z as K}from"./chunk-CQLM5U6T.js";import{a as k,c as A,e as oe,g as m}from"./chunk-5WC5D4WL.js";var er=A((ft,ht)=>{m();(function(t,e){typeof k=="function"&&typeof ft=="object"&&typeof ht=="object"?ht.exports=e():typeof define=="function"&&define.amd?define(function(){return e()}):t.pluralize=e()})(ft,function(){var t=[],e=[],r={},s={},i={};function n(a){return typeof a=="string"?new RegExp("^"+a+"$","i"):a}function o(a,p){return a===p?p:a===a.toLowerCase()?p.toLowerCase():a===a.toUpperCase()?p.toUpperCase():a[0]===a[0].toUpperCase()?p.charAt(0).toUpperCase()+p.substr(1).toLowerCase():p.toLowerCase()}function c(a,p){return a.replace(/\$(\d{1,2})/g,function(y,b){return p[b]||""})}function l(a,p){return a.replace(p[0],function(y,b){var O=c(p[1],arguments);return o(y===""?a[b-1]:y,O)})}function u(a,p,y){if(!a.length||r.hasOwnProperty(a))return p;for(var b=y.length;b--;){var O=y[b];if(O[0].test(p))return l(p,O)}return p}function d(a,p,y){return function(b){var O=b.toLowerCase();return p.hasOwnProperty(O)?o(b,O):a.hasOwnProperty(O)?o(b,a[O]):u(O,b,y)}}function h(a,p,y,b){return function(O){var L=O.toLowerCase();return p.hasOwnProperty(L)?!0:a.hasOwnProperty(L)?!1:u(L,L,y)===L}}function f(a,p,y){var b=p===1?f.singular(a):f.plural(a);return(y?p+" ":"")+b}return f.plural=d(i,s,t),f.isPlural=h(i,s,t),f.singular=d(s,i,e),f.isSingular=h(s,i,e),f.addPluralRule=function(a,p){t.push([n(a),p])},f.addSingularRule=function(a,p){e.push([n(a),p])},f.addUncountableRule=function(a){if(typeof a=="string"){r[a.toLowerCase()]=!0;return}f.addPluralRule(a,"$0"),f.addSingularRule(a,"$0")},f.addIrregularRule=function(a,p){p=p.toLowerCase(),a=a.toLowerCase(),i[a]=p,s[p]=a},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(a){return f.addIrregularRule(a[0],a[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(a){return f.addPluralRule(a[0],a[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(a){return f.addSingularRule(a[0],a[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(f.addUncountableRule),f})});var lr=A((bn,mt)=>{"use strict";m();var vs=Object.prototype.hasOwnProperty,B="~";function Te(){}Object.create&&(Te.prototype=Object.create(null),new Te().__proto__||(B=!1));function Ts(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function ar(t,e,r,s,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var n=new Ts(r,s||t,i),o=B?B+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],n]:t._events[o].push(n):(t._events[o]=n,t._eventsCount++),t}function Fe(t,e){--t._eventsCount===0?t._events=new Te:delete t._events[e]}function R(){this._events=new Te,this._eventsCount=0}R.prototype.eventNames=function(){var e=[],r,s;if(this._eventsCount===0)return e;for(s in r=this._events)vs.call(r,s)&&e.push(B?s.slice(1):s);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};R.prototype.listeners=function(e){var r=B?B+e:e,s=this._events[r];if(!s)return[];if(s.fn)return[s.fn];for(var i=0,n=s.length,o=new Array(n);i<n;i++)o[i]=s[i].fn;return o};R.prototype.listenerCount=function(e){var r=B?B+e:e,s=this._events[r];return s?s.fn?1:s.length:0};R.prototype.emit=function(e,r,s,i,n,o){var c=B?B+e:e;if(!this._events[c])return!1;var l=this._events[c],u=arguments.length,d,h;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,r),!0;case 3:return l.fn.call(l.context,r,s),!0;case 4:return l.fn.call(l.context,r,s,i),!0;case 5:return l.fn.call(l.context,r,s,i,n),!0;case 6:return l.fn.call(l.context,r,s,i,n,o),!0}for(h=1,d=new Array(u-1);h<u;h++)d[h-1]=arguments[h];l.fn.apply(l.context,d)}else{var f=l.length,a;for(h=0;h<f;h++)switch(l[h].once&&this.removeListener(e,l[h].fn,void 0,!0),u){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,r);break;case 3:l[h].fn.call(l[h].context,r,s);break;case 4:l[h].fn.call(l[h].context,r,s,i);break;default:if(!d)for(a=1,d=new Array(u-1);a<u;a++)d[a-1]=arguments[a];l[h].fn.apply(l[h].context,d)}}return!0};R.prototype.on=function(e,r,s){return ar(this,e,r,s,!1)};R.prototype.once=function(e,r,s){return ar(this,e,r,s,!0)};R.prototype.removeListener=function(e,r,s,i){var n=B?B+e:e;if(!this._events[n])return this;if(!r)return Fe(this,n),this;var o=this._events[n];if(o.fn)o.fn===r&&(!i||o.once)&&(!s||o.context===s)&&Fe(this,n);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==r||i&&!o[c].once||s&&o[c].context!==s)&&l.push(o[c]);l.length?this._events[n]=l.length===1?l[0]:l:Fe(this,n)}return this};R.prototype.removeAllListeners=function(e){var r;return e?(r=B?B+e:e,this._events[r]&&Fe(this,r)):(this._events=new Te,this._eventsCount=0),this};R.prototype.off=R.prototype.removeListener;R.prototype.addListener=R.prototype.on;R.prefixed=B;R.EventEmitter=R;typeof mt<"u"&&(mt.exports=R)});var pr=A((An,dr)=>{"use strict";m();var{Duplex:Cs}=k("stream");function fr(t){t.emit("close")}function Os(){!this.destroyed&&this._writableState.finished&&this.destroy()}function hr(t){this.removeListener("error",hr),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function ks(t,e){let r=!0,s=new Cs({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let c=!o&&s._readableState.objectMode?n.toString():n;s.push(c)||t.pause()}),t.once("error",function(n){s.destroyed||(r=!1,s.destroy(n))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(fr,s);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(fr,s)}),r&&t.terminate()},s._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(i,n,o)});return}t.send(i,o)},s.on("end",Os),s.on("error",hr),s}dr.exports=ks});var Z=A((Bn,gr)=>{"use strict";m();var mr=["nodebuffer","arraybuffer","fragments"],yr=typeof Blob<"u";yr&&mr.push("blob");gr.exports={BINARY_TYPES:mr,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:yr,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ne=A((Gn,je)=>{"use strict";m();var{EMPTY_BUFFER:Ns}=Z(),xt=Buffer[Symbol.species];function Ls(t,e){if(t.length===0)return Ns;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let i=0;i<t.length;i++){let n=t[i];r.set(n,s),s+=n.length}return s<e?new xt(r.buffer,r.byteOffset,s):r}function _r(t,e,r,s,i){for(let n=0;n<i;n++)r[s+n]=t[n]^e[n&3]}function br(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Ps(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Et(t){if(Et.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xt(t):ArrayBuffer.isView(t)?e=new xt(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Et.readOnly=!1),e}je.exports={concat:Ls,mask:_r,toArrayBuffer:Ps,toBuffer:Et,unmask:br};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=k("bufferutil");je.exports.mask=function(e,r,s,i,n){n<48?_r(e,r,s,i,n):t.mask(e,r,s,i,n)},je.exports.unmask=function(e,r){e.length<32?br(e,r):t.unmask(e,r)}}catch{}});var wr=A((Un,Er)=>{"use strict";m();var xr=Symbol("kDone"),wt=Symbol("kRun"),St=class{constructor(e){this[xr]=()=>{this.pending--,this[wt]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[wt]()}[wt](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[xr])}}};Er.exports=St});var Ie=A((Fn,Cr)=>{"use strict";m();var Le=k("zlib"),Sr=Ne(),Is=wr(),{kStatusCode:vr}=Z(),$s=Buffer[Symbol.species],Rs=Buffer.from([0,0,255,255]),Qe=Symbol("permessage-deflate"),J=Symbol("total-length"),Pe=Symbol("callback"),ie=Symbol("buffers"),Ve=Symbol("error"),ze,vt=class{constructor(e,r,s){if(this._maxPayload=s|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!r,this._deflate=null,this._inflate=null,this.params=null,!ze){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ze=new Is(i)}}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[Pe];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let i=r[s];if(i.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(i=i[0],s==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else if(s==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=i})}),e}decompress(e,r,s){ze.add(i=>{this._decompress(e,r,(n,o)=>{i(),s(n,o)})})}compress(e,r,s){ze.add(i=>{this._compress(e,r,(n,o)=>{i(),s(n,o)})})}_decompress(e,r,s){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Le.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Le.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[Qe]=this,this._inflate[J]=0,this._inflate[ie]=[],this._inflate.on("error",Ms),this._inflate.on("data",Tr)}this._inflate[Pe]=s,this._inflate.write(e),r&&this._inflate.write(Rs),this._inflate.flush(()=>{let n=this._inflate[Ve];if(n){this._inflate.close(),this._inflate=null,s(n);return}let o=Sr.concat(this._inflate[ie],this._inflate[J]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[J]=0,this._inflate[ie]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),s(null,o)})}_compress(e,r,s){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Le.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Le.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[J]=0,this._deflate[ie]=[],this._deflate.on("data",As)}this._deflate[Pe]=s,this._deflate.write(e),this._deflate.flush(Le.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Sr.concat(this._deflate[ie],this._deflate[J]);r&&(n=new $s(n.buffer,n.byteOffset,n.length-4)),this._deflate[Pe]=null,this._deflate[J]=0,this._deflate[ie]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),s(null,n)})}};Cr.exports=vt;function As(t){this[ie].push(t),this[J]+=t.length}function Tr(t){if(this[J]+=t.length,this[Qe]._maxPayload<1||this[J]<=this[Qe]._maxPayload){this[ie].push(t);return}this[Ve]=new RangeError("Max payload size exceeded"),this[Ve].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ve][vr]=1009,this.removeListener("data",Tr),this.reset()}function Ms(t){this[Qe]._inflate=null,t[vr]=1007,this[Pe](t)}});var ge=A((zn,He)=>{"use strict";m();var{isUtf8:Or}=k("buffer"),{hasBlob:Bs}=Z(),Ds=[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 Gs(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Tt(t){let e=t.length,r=0;for(;r<e;)if(!(t[r]&128))r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function qs(t){return Bs&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}He.exports={isBlob:qs,isValidStatusCode:Gs,isValidUTF8:Tt,tokenChars:Ds};if(Or)He.exports.isValidUTF8=function(t){return t.length<24?Tt(t):Or(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=k("utf-8-validate");He.exports.isValidUTF8=function(e){return e.length<32?Tt(e):t(e)}}catch{}});var Lt=A((Qn,Rr)=>{"use strict";m();var{Writable:Us}=k("stream"),kr=Ie(),{BINARY_TYPES:Ws,EMPTY_BUFFER:Nr,kStatusCode:Fs,kWebSocket:js}=Z(),{concat:Ct,toArrayBuffer:zs,unmask:Vs}=Ne(),{isValidStatusCode:Qs,isValidUTF8:Lr}=ge(),Ye=Buffer[Symbol.species],F=0,Pr=1,Ir=2,$r=3,Ot=4,kt=5,Ke=6,Nt=class extends Us{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Ws[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[js]=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=F}_write(e,r,s){if(this._opcode===8&&this._state==F)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new Ye(s.buffer,s.byteOffset+e,s.length-e),new Ye(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],i=r.length-e;e>=s.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),i),this._buffers[0]=new Ye(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case F:this.getInfo(e);break;case Pr:this.getPayloadLength16(e);break;case Ir:this.getPayloadLength64(e);break;case $r:this.getMask();break;case Ot:this.getData(e);break;case kt:case Ke:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if(r[0]&48){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let s=(r[0]&64)===64;if(s&&!this._extensions[kr.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=Pr:this._payloadLength===127?this._state=Ir: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 r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=s*Math.pow(2,32)+r.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 r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=$r:this._state=Ot}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ot}getData(e){let r=Nr;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&Vs(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=kt,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[kr.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return r(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}this._fragments.push(n)}this.dataMessage(r),this._state===F&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=F;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Ct(s,r):this._binaryType==="arraybuffer"?i=zs(Ct(s,r)):this._binaryType==="blob"?i=new Blob(s):i=s,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=F):(this._state=Ke,setImmediate(()=>{this.emit("message",i,!0),this._state=F,this.startLoop(e)}))}else{let i=Ct(s,r);if(!this._skipUTF8Validation&&!Lr(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===kt||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=F):(this._state=Ke,setImmediate(()=>{this.emit("message",i,!1),this._state=F,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Nr),this.end();else{let s=e.readUInt16BE(0);if(!Qs(s)){let n=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(n);return}let i=new Ye(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Lr(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(n);return}this._loop=!1,this.emit("conclude",s,i),this.end()}this._state=F;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=F):(this._state=Ke,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=F,this.startLoop(r)}))}createError(e,r,s,i,n){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=n,o[Fs]=i,o}};Rr.exports=Nt});var $t=A((Kn,Br)=>{"use strict";m();var{Duplex:Yn}=k("stream"),{randomFillSync:Hs}=k("crypto"),Ar=Ie(),{EMPTY_BUFFER:Ys,kWebSocket:Ks,NOOP:Xs}=Z(),{isBlob:_e,isValidStatusCode:Zs}=ge(),{mask:Mr,toBuffer:ae}=Ne(),j=Symbol("kByteLength"),Js=Buffer.alloc(4),Xe=8*1024,le,be=Xe,V=0,ei=1,ti=2,Pt=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=V,this.onerror=Xs,this[Ks]=void 0}static frame(e,r){let s,i=!1,n=2,o=!1;r.mask&&(s=r.maskBuffer||Js,r.generateMask?r.generateMask(s):(be===Xe&&(le===void 0&&(le=Buffer.alloc(Xe)),Hs(le,0,Xe),be=0),s[0]=le[be++],s[1]=le[be++],s[2]=le[be++],s[3]=le[be++]),o=(s[0]|s[1]|s[2]|s[3])===0,n=6);let c;typeof e=="string"?(!r.mask||o)&&r[j]!==void 0?c=r[j]:(e=Buffer.from(e),c=e.length):(c=e.length,i=r.mask&&r.readOnly&&!o);let l=c;c>=65536?(n+=8,l=127):c>125&&(n+=2,l=126);let u=Buffer.allocUnsafe(i?c+n:n);return u[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(u[0]|=64),u[1]=l,l===126?u.writeUInt16BE(c,2):l===127&&(u[2]=u[3]=0,u.writeUIntBE(c,4,6)),r.mask?(u[1]|=128,u[n-4]=s[0],u[n-3]=s[1],u[n-2]=s[2],u[n-1]=s[3],o?[u,e]:i?(Mr(e,s,u,n,c),[u]):(Mr(e,s,e,0,c),[u,e])):[u,e]}close(e,r,s,i){let n;if(e===void 0)n=Ys;else{if(typeof e!="number"||!Zs(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let c=Buffer.byteLength(r);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+c),n.writeUInt16BE(e,0),typeof r=="string"?n.write(r,2):n.set(r,2)}}let o={[j]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==V?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):_e(e)?(i=e.size,n=!1):(e=ae(e),i=e.length,n=ae.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[j]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};_e(e)?this._state!==V?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==V?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}pong(e,r,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):_e(e)?(i=e.size,n=!1):(e=ae(e),i=e.length,n=ae.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[j]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};_e(e)?this._state!==V?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==V?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(t.frame(e,o),s)}send(e,r,s){let i=this._extensions[Ar.extensionName],n=r.binary?2:1,o=r.compress,c,l;typeof e=="string"?(c=Buffer.byteLength(e),l=!1):_e(e)?(c=e.size,l=!1):(e=ae(e),c=e.length,l=ae.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=i._threshold),this._compress=o):(o=!1,n=0),r.fin&&(this._firstFragment=!0);let u={[j]:c,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};_e(e)?this._state!==V?this.enqueue([this.getBlobData,e,this._compress,u,s]):this.getBlobData(e,this._compress,u,s):this._state!==V?this.enqueue([this.dispatch,e,this._compress,u,s]):this.dispatch(e,this._compress,u,s)}getBlobData(e,r,s,i){this._bufferedBytes+=s[j],this._state=ti,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(It,this,c,i);return}this._bufferedBytes-=s[j];let o=ae(n);r?this.dispatch(o,r,s,i):(this._state=V,this.sendFrame(t.frame(o,s),i),this.dequeue())}).catch(n=>{process.nextTick(ri,this,n,i)})}dispatch(e,r,s,i){if(!r){this.sendFrame(t.frame(e,s),i);return}let n=this._extensions[Ar.extensionName];this._bufferedBytes+=s[j],this._state=ei,n.compress(e,s.fin,(o,c)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");It(this,l,i);return}this._bufferedBytes-=s[j],this._state=V,s.readOnly=!1,this.sendFrame(t.frame(c,s),i),this.dequeue()})}dequeue(){for(;this._state===V&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][j],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][j],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Br.exports=Pt;function It(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let i=t._queue[s],n=i[i.length-1];typeof n=="function"&&n(e)}}function ri(t,e,r){It(t,e,r),t.onerror(e)}});var Vr=A((Zn,zr)=>{"use strict";m();var{kForOnEventAttribute:$e,kListener:Rt}=Z(),Dr=Symbol("kCode"),Gr=Symbol("kData"),qr=Symbol("kError"),Ur=Symbol("kMessage"),Wr=Symbol("kReason"),xe=Symbol("kTarget"),Fr=Symbol("kType"),jr=Symbol("kWasClean"),ee=class{constructor(e){this[xe]=null,this[Fr]=e}get target(){return this[xe]}get type(){return this[Fr]}};Object.defineProperty(ee.prototype,"target",{enumerable:!0});Object.defineProperty(ee.prototype,"type",{enumerable:!0});var ce=class extends ee{constructor(e,r={}){super(e),this[Dr]=r.code===void 0?0:r.code,this[Wr]=r.reason===void 0?"":r.reason,this[jr]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Dr]}get reason(){return this[Wr]}get wasClean(){return this[jr]}};Object.defineProperty(ce.prototype,"code",{enumerable:!0});Object.defineProperty(ce.prototype,"reason",{enumerable:!0});Object.defineProperty(ce.prototype,"wasClean",{enumerable:!0});var Ee=class extends ee{constructor(e,r={}){super(e),this[qr]=r.error===void 0?null:r.error,this[Ur]=r.message===void 0?"":r.message}get error(){return this[qr]}get message(){return this[Ur]}};Object.defineProperty(Ee.prototype,"error",{enumerable:!0});Object.defineProperty(Ee.prototype,"message",{enumerable:!0});var Re=class extends ee{constructor(e,r={}){super(e),this[Gr]=r.data===void 0?null:r.data}get data(){return this[Gr]}};Object.defineProperty(Re.prototype,"data",{enumerable:!0});var si={addEventListener(t,e,r={}){for(let i of this.listeners(t))if(!r[$e]&&i[Rt]===e&&!i[$e])return;let s;if(t==="message")s=function(n,o){let c=new Re("message",{data:o?n:n.toString()});c[xe]=this,Ze(e,this,c)};else if(t==="close")s=function(n,o){let c=new ce("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[xe]=this,Ze(e,this,c)};else if(t==="error")s=function(n){let o=new Ee("error",{error:n,message:n.message});o[xe]=this,Ze(e,this,o)};else if(t==="open")s=function(){let n=new ee("open");n[xe]=this,Ze(e,this,n)};else return;s[$e]=!!r[$e],s[Rt]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Rt]===e&&!r[$e]){this.removeListener(t,r);break}}};zr.exports={CloseEvent:ce,ErrorEvent:Ee,Event:ee,EventTarget:si,MessageEvent:Re};function Ze(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var At=A((eo,Qr)=>{"use strict";m();var{tokenChars:Ae}=ge();function Q(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ii(t){let e=Object.create(null),r=Object.create(null),s=!1,i=!1,n=!1,o,c,l=-1,u=-1,d=-1,h=0;for(;h<t.length;h++)if(u=t.charCodeAt(h),o===void 0)if(d===-1&&Ae[u]===1)l===-1&&(l=h);else if(h!==0&&(u===32||u===9))d===-1&&l!==-1&&(d=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);d===-1&&(d=h);let a=t.slice(l,d);u===44?(Q(e,a,r),r=Object.create(null)):o=a,l=d=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);else if(c===void 0)if(d===-1&&Ae[u]===1)l===-1&&(l=h);else if(u===32||u===9)d===-1&&l!==-1&&(d=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);d===-1&&(d=h),Q(r,t.slice(l,d),!0),u===44&&(Q(e,o,r),r=Object.create(null),o=void 0),l=d=-1}else if(u===61&&l!==-1&&d===-1)c=t.slice(l,h),l=d=-1;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(i){if(Ae[u]!==1)throw new SyntaxError(`Unexpected character at index ${h}`);l===-1?l=h:s||(s=!0),i=!1}else if(n)if(Ae[u]===1)l===-1&&(l=h);else if(u===34&&l!==-1)n=!1,d=h;else if(u===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${h}`);else if(u===34&&t.charCodeAt(h-1)===61)n=!0;else if(d===-1&&Ae[u]===1)l===-1&&(l=h);else if(l!==-1&&(u===32||u===9))d===-1&&(d=h);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${h}`);d===-1&&(d=h);let a=t.slice(l,d);s&&(a=a.replace(/\\/g,""),s=!1),Q(r,c,a),u===44&&(Q(e,o,r),r=Object.create(null),o=void 0),c=void 0,l=d=-1}else throw new SyntaxError(`Unexpected character at index ${h}`);if(l===-1||n||u===32||u===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=h);let f=t.slice(l,d);return o===void 0?Q(e,f,r):(c===void 0?Q(r,f,!0):s?Q(r,c,f.replace(/\\/g,"")):Q(r,c,f),Q(e,o,r)),e}function ni(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(i=>{let n=s[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Qr.exports={format:ni,parse:ii}});var qt=A((io,ns)=>{"use strict";m();var oi=k("events"),ai=k("https"),li=k("http"),Kr=k("net"),ci=k("tls"),{randomBytes:ui,createHash:fi}=k("crypto"),{Duplex:ro,Readable:so}=k("stream"),{URL:Mt}=k("url"),ne=Ie(),hi=Lt(),di=$t(),{isBlob:pi}=ge(),{BINARY_TYPES:Hr,EMPTY_BUFFER:Je,GUID:mi,kForOnEventAttribute:Bt,kListener:yi,kStatusCode:gi,kWebSocket:P,NOOP:Xr}=Z(),{EventTarget:{addEventListener:_i,removeEventListener:bi}}=Vr(),{format:xi,parse:Ei}=At(),{toBuffer:wi}=Ne(),Si=30*1e3,Zr=Symbol("kAborted"),Dt=[8,13],te=["CONNECTING","OPEN","CLOSING","CLOSED"],vi=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,T=class t extends oi{constructor(e,r,s){super(),this._binaryType=Hr[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Je,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,r=[]):r=[r]),Jr(this,e,r,s)):(this._autoPong=s.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Hr.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,r,s){let i=new hi({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),n=new di(e,this._extensions,s.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[P]=this,n[P]=this,e[P]=this,i.on("conclude",Oi),i.on("drain",ki),i.on("error",Ni),i.on("message",Li),i.on("ping",Pi),i.on("pong",Ii),n.onerror=$i,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",rs),e.on("data",tt),e.on("end",ss),e.on("error",is),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ne.extensionName]&&this._extensions[ne.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){q(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ts(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Gt(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Je,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Gt(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Je,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Gt(this,e,s);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[ne.extensionName]||(i.compress=!1),this._sender.send(e||Je,i,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){q(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(T,"CONNECTING",{enumerable:!0,value:te.indexOf("CONNECTING")});Object.defineProperty(T.prototype,"CONNECTING",{enumerable:!0,value:te.indexOf("CONNECTING")});Object.defineProperty(T,"OPEN",{enumerable:!0,value:te.indexOf("OPEN")});Object.defineProperty(T.prototype,"OPEN",{enumerable:!0,value:te.indexOf("OPEN")});Object.defineProperty(T,"CLOSING",{enumerable:!0,value:te.indexOf("CLOSING")});Object.defineProperty(T.prototype,"CLOSING",{enumerable:!0,value:te.indexOf("CLOSING")});Object.defineProperty(T,"CLOSED",{enumerable:!0,value:te.indexOf("CLOSED")});Object.defineProperty(T.prototype,"CLOSED",{enumerable:!0,value:te.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(T.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(T.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Bt])return e[yi];return null},set(e){for(let r of this.listeners(t))if(r[Bt]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Bt]:!0})}})});T.prototype.addEventListener=_i;T.prototype.removeEventListener=bi;ns.exports=T;function Jr(t,e,r,s){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Dt[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,!Dt.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Dt.join(", ")})`);let n;if(e instanceof Mt)n=e;else try{n=new Mt(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",c=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!c?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`:c&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let y=new SyntaxError(l);if(t._redirects===0)throw y;et(t,y);return}let u=o?443:80,d=ui(16).toString("base64"),h=o?ai.request:li.request,f=new Set,a;if(i.createConnection=i.createConnection||(o?Ci:Ti),i.defaultPort=i.defaultPort||u,i.port=n.port||u,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(a=new ne(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=xi({[ne.extensionName]:a.offer()})),r.length){for(let y of r){if(typeof y!="string"||!vi.test(y)||f.has(y))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(y)}i.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),c){let y=i.path.split(":");i.socketPath=y[0],i.path=y[1]}let p;if(i.followRedirects){if(t._redirects===0){t._originalIpc=c,t._originalSecure=o,t._originalHostOrSocketPath=c?i.socketPath:n.host;let y=s&&s.headers;if(s={...s,headers:{}},y)for(let[b,O]of Object.entries(y))s.headers[b.toLowerCase()]=O}else if(t.listenerCount("redirect")===0){let y=c?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!y||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,y||delete i.headers.host,i.auth=void 0)}i.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),p=t._req=h(i),t._redirects&&t.emit("redirect",t.url,p)}else p=t._req=h(i);i.timeout&&p.on("timeout",()=>{q(t,p,"Opening handshake has timed out")}),p.on("error",y=>{p===null||p[Zr]||(p=t._req=null,et(t,y))}),p.on("response",y=>{let b=y.headers.location,O=y.statusCode;if(b&&i.followRedirects&&O>=300&&O<400){if(++t._redirects>i.maxRedirects){q(t,p,"Maximum redirects exceeded");return}p.abort();let L;try{L=new Mt(b,e)}catch{let C=new SyntaxError(`Invalid URL: ${b}`);et(t,C);return}Jr(t,L,r,s)}else t.emit("unexpected-response",p,y)||q(t,p,`Unexpected server response: ${y.statusCode}`)}),p.on("upgrade",(y,b,O)=>{if(t.emit("upgrade",y),t.readyState!==T.CONNECTING)return;p=t._req=null;let L=y.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){q(t,b,"Invalid Upgrade header");return}let H=fi("sha1").update(d+mi).digest("base64");if(y.headers["sec-websocket-accept"]!==H){q(t,b,"Invalid Sec-WebSocket-Accept header");return}let C=y.headers["sec-websocket-protocol"],re;if(C!==void 0?f.size?f.has(C)||(re="Server sent an invalid subprotocol"):re="Server sent a subprotocol but none was requested":f.size&&(re="Server sent no subprotocol"),re){q(t,b,re);return}C&&(t._protocol=C);let U=y.headers["sec-websocket-extensions"];if(U!==void 0){if(!a){q(t,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=Ei(U)}catch{q(t,b,"Invalid Sec-WebSocket-Extensions header");return}let we=Object.keys(z);if(we.length!==1||we[0]!==ne.extensionName){q(t,b,"Server indicated an extension that was not requested");return}try{a.accept(z[ne.extensionName])}catch{q(t,b,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ne.extensionName]=a}t.setSocket(b,O,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(p,t):p.end()}function et(t,e){t._readyState=T.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ti(t){return t.path=t.socketPath,Kr.connect(t)}function Ci(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Kr.isIP(t.host)?"":t.host),ci.connect(t)}function q(t,e,r){t._readyState=T.CLOSING;let s=new Error(r);Error.captureStackTrace(s,q),e.setHeader?(e[Zr]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(et,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Gt(t,e,r){if(e){let s=pi(e)?e.size:wi(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${te[t.readyState]})`);process.nextTick(r,s)}}function Oi(t,e){let r=this[P];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[P]!==void 0&&(r._socket.removeListener("data",tt),process.nextTick(es,r._socket),t===1005?r.close():r.close(t,e))}function ki(){let t=this[P];t.isPaused||t._socket.resume()}function Ni(t){let e=this[P];e._socket[P]!==void 0&&(e._socket.removeListener("data",tt),process.nextTick(es,e._socket),e.close(t[gi])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Yr(){this[P].emitClose()}function Li(t,e){this[P].emit("message",t,e)}function Pi(t){let e=this[P];e._autoPong&&e.pong(t,!this._isServer,Xr),e.emit("ping",t)}function Ii(t){this[P].emit("pong",t)}function es(t){t.resume()}function $i(t){let e=this[P];e.readyState!==T.CLOSED&&(e.readyState===T.OPEN&&(e._readyState=T.CLOSING,ts(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function ts(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),Si)}function rs(){let t=this[P];this.removeListener("close",rs),this.removeListener("data",tt),this.removeListener("end",ss),t._readyState=T.CLOSING;let e;!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&(e=t._socket.read())!==null&&t._receiver.write(e),t._receiver.end(),this[P]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Yr),t._receiver.on("finish",Yr))}function tt(t){this[P]._receiver.write(t)||this.pause()}function ss(){let t=this[P];t._readyState=T.CLOSING,t._receiver.end(),this.end()}function is(){let t=this[P];this.removeListener("error",is),this.on("error",Xr),t&&(t._readyState=T.CLOSING,this.destroy())}});var as=A((oo,os)=>{"use strict";m();var{tokenChars:Ri}=ge();function Ai(t){let e=new Set,r=-1,s=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(s===-1&&Ri[o]===1)r===-1&&(r=i);else if(i!==0&&(o===32||o===9))s===-1&&r!==-1&&(s=i);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${i}`);s===-1&&(s=i);let c=t.slice(r,s);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);e.add(c),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(r,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}os.exports={parse:Ai}});var ps=A((co,ds)=>{"use strict";m();var Mi=k("events"),rt=k("http"),{Duplex:lo}=k("stream"),{createHash:Bi}=k("crypto"),ls=At(),ue=Ie(),Di=as(),Gi=qt(),{GUID:qi,kWebSocket:Ui}=Z(),Wi=/^[+/0-9A-Za-z]{22}==$/,cs=0,us=1,hs=2,Ut=class extends Mi{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Gi,...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=rt.createServer((s,i)=>{let n=rt.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=Fi(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=cs}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===hs){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Me,this);return}if(e&&this.once("close",e),this._state!==us)if(this._state=us,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(Me,this):process.nextTick(Me,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Me(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,i){r.on("error",fs);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,c=+e.headers["sec-websocket-version"];if(e.method!=="GET"){fe(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){fe(this,e,r,400,"Invalid Upgrade header");return}if(n===void 0||!Wi.test(n)){fe(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==8&&c!==13){fe(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){Be(r,400);return}let l=e.headers["sec-websocket-protocol"],u=new Set;if(l!==void 0)try{u=Di.parse(l)}catch{fe(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&d!==void 0){let f=new ue(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let a=ls.parse(d);a[ue.extensionName]&&(f.accept(a[ue.extensionName]),h[ue.extensionName]=f)}catch{fe(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={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(f,(a,p,y,b)=>{if(!a)return Be(r,p||401,y,b);this.completeUpgrade(h,n,u,e,r,s,i)});return}if(!this.options.verifyClient(f))return Be(r,401)}this.completeUpgrade(h,n,u,e,r,s,i)}completeUpgrade(e,r,s,i,n,o,c){if(!n.readable||!n.writable)return n.destroy();if(n[Ui])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>cs)return Be(n,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Bi("sha1").update(r+qi).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(s.size){let h=this.options.handleProtocols?this.options.handleProtocols(s,i):s.values().next().value;h&&(u.push(`Sec-WebSocket-Protocol: ${h}`),d._protocol=h)}if(e[ue.extensionName]){let h=e[ue.extensionName].params,f=ls.format({[ue.extensionName]:[h]});u.push(`Sec-WebSocket-Extensions: ${f}`),d._extensions=e}this.emit("headers",u,i),n.write(u.concat(`\r
2
+ `).join(`\r
3
+ `)),n.removeListener("error",fs),d.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on("close",()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Me,this)})),c(d,i)}};ds.exports=Ut;function Fi(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function Me(t){t._state=hs,t.emit("close")}function fs(){this.destroy()}function Be(t,e,r,s){r=r||rt.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${rt.STATUS_CODES[e]}\r
4
+ `+Object.keys(s).map(i=>`${i}: ${s[i]}`).join(`\r
5
+ `)+`\r
6
+ \r
7
+ `+r)}function fe(t,e,r,s,i){if(t.listenerCount("wsClientError")){let n=new Error(i);Error.captureStackTrace(n,fe),t.emit("wsClientError",n,r,e)}else Be(r,s,i)}});m();var tr=oe(er(),1);import xs from"node:assert";var W=class extends Zt{constructor(r,s){super("An error occurred while communicating with Gadget");this.request=r;ot(s)?this.cause={type:s.type,message:s.message,error:Kt(s.error)}:nt(s)?this.cause={type:s.type,code:s.code,reason:s.reason,wasClean:s.wasClean}:(xs(Qt(s)||it(s)||at(s),"cause must be a string, Error, GraphQLError[], CloseEvent, or ErrorEvent"),this.cause=s)}isBug=Xt.MAYBE;cause;render(){let r="";switch(!0){case at(this.cause):{let s=Jt(this.cause.map(i=>i.message));r=ve`
8
+ Gadget responded with the following ${(0,tr.default)("error",s.length,!1)}:
9
+
10
+ • ${s.join(`
11
+ \u2022 `)}
12
+ `;break}case nt(this.cause):r="The connection to Gadget closed unexpectedly.";break;case(ot(this.cause)||it(this.cause)):r=this.cause.message;break;default:r=this.cause;break}return this.message+`
13
+
14
+ `+r}};m();m();import Wt from"node:assert";m();m();m();m();function M(t){return t===null?"null":Array.isArray(t)?"array":typeof t}function X(t){return M(t)==="object"}function rr(t){return Array.isArray(t)&&t.length>0&&t.every(e=>"message"in e)}function dt(t,e){return t.length<124?t:e}var sr="graphql-transport-ws";var G;(function(t){t[t.InternalServerError=4500]="InternalServerError",t[t.InternalClientError=4005]="InternalClientError",t[t.BadRequest=4400]="BadRequest",t[t.BadResponse=4004]="BadResponse",t[t.Unauthorized=4401]="Unauthorized",t[t.Forbidden=4403]="Forbidden",t[t.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",t[t.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",t[t.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",t[t.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",t[t.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(G||(G={}));var N;(function(t){t.ConnectionInit="connection_init",t.ConnectionAck="connection_ack",t.Ping="ping",t.Pong="pong",t.Subscribe="subscribe",t.Next="next",t.Error="error",t.Complete="complete"})(N||(N={}));function ir(t){if(!X(t))throw new Error(`Message is expected to be an object, but got ${M(t)}`);if(!t.type)throw new Error("Message is missing the 'type' property");if(typeof t.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${M(t.type)}`);switch(t.type){case N.ConnectionInit:case N.ConnectionAck:case N.Ping:case N.Pong:{if(t.payload!=null&&!X(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${t.payload}"`);break}case N.Subscribe:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);if(!X(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an object, but got ${M(t.payload)}`);if(typeof t.payload.query!="string")throw new Error(`"${t.type}" message payload expects the 'query' property to be a string, but got ${M(t.payload.query)}`);if(t.payload.variables!=null&&!X(t.payload.variables))throw new Error(`"${t.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${M(t.payload.variables)}`);if(t.payload.operationName!=null&&M(t.payload.operationName)!=="string")throw new Error(`"${t.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${M(t.payload.operationName)}`);if(t.payload.extensions!=null&&!X(t.payload.extensions))throw new Error(`"${t.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${M(t.payload.extensions)}`);break}case N.Next:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);if(!X(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an object, but got ${M(t.payload)}`);break}case N.Error:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);if(!rr(t.payload))throw new Error(`"${t.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(t.payload)}`);break}case N.Complete:{if(typeof t.id!="string")throw new Error(`"${t.type}" message expects the 'id' property to be a string, but got ${M(t.id)}`);if(!t.id)throw new Error(`"${t.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${t.type}"`)}return t}function nr(t,e){return ir(typeof t=="string"?JSON.parse(t,e):t)}function me(t,e){return ir(t),JSON.stringify(t,e)}var ye=function(t){return this instanceof ye?(this.v=t,this):new ye(t)},Es=function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),i,n=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(f){s[f]&&(i[f]=function(a){return new Promise(function(p,y){n.push([f,a,p,y])>1||c(f,a)})})}function c(f,a){try{l(s[f](a))}catch(p){h(n[0][3],p)}}function l(f){f.value instanceof ye?Promise.resolve(f.value.v).then(u,d):h(n[0][2],f)}function u(f){c("next",f)}function d(f){c("throw",f)}function h(f,a){f(a),n.shift(),n.length&&c(n[0][0],n[0][1])}};function or(t){let{url:e,connectionParams:r,lazy:s=!0,onNonLazyError:i=console.error,lazyCloseTimeout:n=0,keepAlive:o=0,disablePong:c,connectionAckWaitTimeout:l=0,retryAttempts:u=5,retryWait:d=async function(v){let g=1e3;for(let E=0;E<v;E++)g*=2;await new Promise(E=>setTimeout(E,g+Math.floor(Math.random()*2700+300)))},shouldRetry:h=pt,isFatalConnectionProblem:f,on:a,webSocketImpl:p,generateID:y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,v=>{let g=Math.random()*16|0;return(v=="x"?g:g&3|8).toString(16)})},jsonMessageReplacer:b,jsonMessageReviver:O}=t,L;if(p){if(!Ss(p))throw new Error("Invalid WebSocket implementation provided");L=p}else typeof WebSocket<"u"?L=WebSocket:typeof global<"u"?L=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(L=window.WebSocket||window.MozWebSocket);if(!L)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let H=L,C=(()=>{let _=(()=>{let g={};return{on(E,S){return g[E]=S,()=>{delete g[E]}},emit(E){var S;"id"in E&&((S=g[E.id])===null||S===void 0||S.call(g,E))}}})(),v={connecting:a?.connecting?[a.connecting]:[],opened:a?.opened?[a.opened]:[],connected:a?.connected?[a.connected]:[],ping:a?.ping?[a.ping]:[],pong:a?.pong?[a.pong]:[],message:a?.message?[_.emit,a.message]:[_.emit],closed:a?.closed?[a.closed]:[],error:a?.error?[a.error]:[]};return{onMessage:_.on,on(g,E){let S=v[g];return S.push(E),()=>{S.splice(S.indexOf(E),1)}},emit(g,...E){for(let S of[...v[g]])S(...E)}}})();function re(_){let v=[C.on("error",g=>{v.forEach(E=>E()),_(g)}),C.on("closed",g=>{v.forEach(E=>E()),_(g)})]}let U,z=0,we,Y=!1,he=0,Ft=!1;async function jt(){clearTimeout(we);let[_,v]=await(U??(U=new Promise((S,D)=>(async()=>{if(Y){if(await d(he),!z)return U=void 0,D({code:1e3,reason:"All Subscriptions Gone"});he++}C.emit("connecting",Y);let w=new H(typeof e=="function"?await e():e,sr),se,Se;function Ge(){isFinite(o)&&o>0&&(clearTimeout(Se),Se=setTimeout(()=>{w.readyState===H.OPEN&&(w.send(me({type:N.Ping})),C.emit("ping",!1,void 0))},o))}re($=>{U=void 0,clearTimeout(se),clearTimeout(Se),D($),$ instanceof We&&(w.close(4499,"Terminated"),w.onerror=null,w.onclose=null)}),w.onerror=$=>C.emit("error",$),w.onclose=$=>C.emit("closed",$),w.onopen=async()=>{try{C.emit("opened",w);let $=typeof r=="function"?await r():r;if(w.readyState!==H.OPEN)return;w.send(me($?{type:N.ConnectionInit,payload:$}:{type:N.ConnectionInit},b)),isFinite(l)&&l>0&&(se=setTimeout(()=>{w.close(G.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},l)),Ge()}catch($){C.emit("error",$),w.close(G.InternalClientError,dt($ instanceof Error?$.message:new Error($).message,"Internal client error"))}};let de=!1;w.onmessage=({data:$})=>{try{let I=nr($,O);if(C.emit("message",I),I.type==="ping"||I.type==="pong"){C.emit(I.type,!0,I.payload),I.type==="pong"?Ge():c||(w.send(me(I.payload?{type:N.Pong,payload:I.payload}:{type:N.Pong})),C.emit("pong",!1,I.payload));return}if(de)return;if(I.type!==N.ConnectionAck)throw new Error(`First message cannot be of type ${I.type}`);clearTimeout(se),de=!0,C.emit("connected",w,I.payload,Y),Y=!1,he=0,S([w,new Promise((Xi,bs)=>re(bs))])}catch(I){w.onmessage=null,C.emit("error",I),w.close(G.BadResponse,dt(I instanceof Error?I.message:new Error(I).message,"Bad response"))}}})())));_.readyState===H.CLOSING&&await v;let g=()=>{},E=new Promise(S=>g=S);return[_,g,Promise.race([E.then(()=>{if(!z){let S=()=>_.close(1e3,"Normal Closure");isFinite(n)&&n>0?we=setTimeout(()=>{_.readyState===H.OPEN&&S()},n):S()}}),v])]}function zt(_){if(pt(_)&&(ws(_.code)||[G.InternalServerError,G.InternalClientError,G.BadRequest,G.BadResponse,G.Unauthorized,G.SubprotocolNotAcceptable,G.SubscriberAlreadyExists,G.TooManyInitialisationRequests].includes(_.code)))throw _;if(Ft)return!1;if(pt(_)&&_.code===1e3)return z>0;if(!u||he>=u||!h(_)||f?.(_))throw _;return Y=!0}s||(async()=>{for(z++;;)try{let[,,_]=await jt();await _}catch(_){try{if(!zt(_))return}catch(v){return i?.(v)}}})();function Vt(_,v){let g=y(_),E=!1,S=!1,D=()=>{z--,E=!0};return(async()=>{for(z++;;)try{let[w,se,Se]=await jt();if(E)return se();let Ge=C.onMessage(g,de=>{switch(de.type){case N.Next:{v.next(de.payload);return}case N.Error:{S=!0,E=!0,v.error(de.payload),D();return}case N.Complete:{E=!0,D();return}}});w.send(me({id:g,type:N.Subscribe,payload:_},b)),D=()=>{!E&&w.readyState===H.OPEN&&w.send(me({id:g,type:N.Complete},b)),z--,E=!0,se()},await Se.finally(Ge);return}catch(w){if(!zt(w))return}})().then(()=>{S||v.complete()}).catch(w=>{v.error(w)}),()=>{E||D()}}return{on:C.on,subscribe:Vt,iterate(_){let v=[],g={done:!1,error:null,resolve:()=>{}},E=Vt(_,{next(D){v.push(D),g.resolve()},error(D){g.done=!0,g.error=D,g.resolve()},complete(){g.done=!0,g.resolve()}}),S=function(){return Es(this,arguments,function*(){for(;;){for(v.length||(yield ye(new Promise(se=>g.resolve=se)));v.length;)yield yield ye(v.shift());if(g.error)throw g.error;if(g.done)return yield ye(void 0)}})}();return S.throw=async D=>(g.done||(g.done=!0,g.error=D,g.resolve()),{done:!0,value:void 0}),S.return=async()=>(E(),{done:!0,value:void 0}),S},async dispose(){if(Ft=!0,U){let[_]=await U;_.close(1e3,"Normal Closure")}},terminate(){U&&C.emit("closed",new We)}}}var We=class extends Error{constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}};function pt(t){return X(t)&&"code"in t&&"reason"in t}function ws(t){return[1e3,1001,1006,1005,1012,1013,1014].includes(t)?!1:t>=1e3&&t<=1999}function Ss(t){return typeof t=="function"&&"constructor"in t&&"CLOSED"in t&&"CLOSING"in t&&"CONNECTING"in t&&"OPEN"in t}m();m();var yt=oe(lr(),1);m();var Ce=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},gt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},cr=t=>globalThis.DOMException===void 0?new gt(t):new DOMException(t),ur=t=>{let e=t.reason===void 0?cr("This operation was aborted."):t.reason;return e instanceof Error?e:cr(e)};function _t(t,e){let{milliseconds:r,fallback:s,message:i,customTimers:n={setTimeout,clearTimeout}}=e,o,l=new Promise((u,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:f}=e;f.aborted&&d(ur(f)),f.addEventListener("abort",()=>{d(ur(f))})}if(r===Number.POSITIVE_INFINITY){t.then(u,d);return}let h=new Ce;o=n.setTimeout.call(void 0,()=>{if(s){try{u(s())}catch(f){d(f)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?u():i instanceof Error?d(i):(h.message=i??`Promise timed out after ${r} milliseconds`,d(h))},r),(async()=>{try{u(await t)}catch(f){d(f)}})()}).finally(()=>{l.clear()});return l.clear=()=>{n.clearTimeout.call(void 0,o),o=void 0},l}m();m();function bt(t,e,r){let s=0,i=t.length;for(;i>0;){let n=Math.trunc(i/2),o=s+n;r(t[o],e)<=0?(s=++o,i-=n+1):i=n}return s}var Oe=class{#e=[];enqueue(e,r){r={priority:0,...r};let s={priority:r.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(s);return}let i=bt(this.#e,s,(n,o)=>o.priority-n.priority);this.#e.splice(i,0,s)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this.#e.length}};var ke=class extends yt.default{#e;#o;#n=0;#d;#a;#p=0;#r;#l;#t;#m;#s=0;#c;#i;#y;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Oe,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#o=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#a=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#y=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#b(){return this.#o||this.#n<this.#d}get#x(){return this.#s<this.#c}#E(){this.#s--,this.#u(),this.emit("next")}#w(){this.#_(),this.#g(),this.#l=void 0}get#S(){let e=Date.now();if(this.#r===void 0){let r=this.#p-e;if(r<0)this.#n=this.#e?this.#s:0;else return this.#l===void 0&&(this.#l=setTimeout(()=>{this.#w()},r)),!0}return!1}#u(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#s===0&&this.emit("idle"),!1;if(!this.#i){let e=!this.#S;if(this.#b&&this.#x){let r=this.#t.dequeue();return r?(this.emit("active"),r(),e&&this.#g(),!0):!1}}return!1}#g(){this.#o||this.#r!==void 0||(this.#r=setInterval(()=>{this.#_()},this.#a),this.#p=Date.now()+this.#a)}#_(){this.#n===0&&this.#s===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#n=this.#e?this.#s:0,this.#f()}#f(){for(;this.#u(););}get concurrency(){return this.#c}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#c=e,this.#f()}async#v(e){return new Promise((r,s)=>{e.addEventListener("abort",()=>{s(e.reason)},{once:!0})})}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((s,i)=>{this.#t.enqueue(async()=>{this.#s++,this.#n++;try{r.signal?.throwIfAborted();let n=e({signal:r.signal});r.timeout&&(n=_t(Promise.resolve(n),{milliseconds:r.timeout})),r.signal&&(n=Promise.race([n,this.#v(r.signal)]));let o=await n;s(o),this.emit("completed",o)}catch(n){if(n instanceof Ce&&!r.throwOnTimeout){s();return}i(n),this.emit("error",n)}finally{this.#E()}},r),this.emit("add"),this.#u()})}async addAll(e,r){return Promise.all(e.map(async s=>this.add(s,r)))}start(){return this.#i?(this.#i=!1,this.#f(),this):this}pause(){this.#i=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#h("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#h("next",()=>this.#t.size<e)}async onIdle(){this.#s===0&&this.#t.size===0||await this.#h("idle")}async#h(e,r){return new Promise(s=>{let i=()=>{r&&!r()||(this.off(e,i),s())};this.on(e,i)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#s}get isPaused(){return this.#i}};m();var ji=oe(pr(),1),zi=oe(Lt(),1),Vi=oe($t(),1),ms=oe(qt(),1),Qi=oe(ps(),1);var ys=ms.default;var st=class{status=0;ctx;endpoint;_graphqlWsClient;constructor(e,r){this.ctx=e.child({name:"client"}),this.endpoint=r;let s=lt(this.ctx),i=ct(this.ctx);this._graphqlWsClient=or({url:`wss://${s.slug}.${pe.domains.app}/edit/api/graphql-ws`,shouldRetry:()=>!0,connectionParams:{environment:i.name},webSocketImpl:class extends ys{constructor(n,o,c){super(n,o,{signal:e.signal,...c,headers:{...c?.headers,"user-agent":pe.versionFull,...ut(e)}})}},on:{connecting:()=>{switch(this.status){case 1:this.status=2,this.ctx.log.info("reconnecting");break;case 2:this.ctx.log.info("retrying");break;default:this.ctx.log.debug("connecting");break}},connected:()=>{this.status===2?this.ctx.log.info("reconnected"):this.ctx.log.debug("connected"),setImmediate(()=>this.status=0)},closed:()=>{this.status=1,this.ctx.log.debug("disconnected")},error:n=>{this.status===2?this.ctx.log.error("failed to reconnect",{error:n}):this.ctx.log.error("connection error",{error:n})}}})}subscribe(e,{subscription:r,variables:s,onResponse:i,onError:n,onComplete:o=Yt}){let c={query:r,variables:K(s)},l=this._graphqlWsClient.on("connected",()=>{this.status===2&&(c.variables=K(s),e.log.info("re-subscribing to graphql subscription"))}),u=new ke({concurrency:1}),d=f=>n(new W(r,f)),h=this._graphqlWsClient.subscribe(c,{next:f=>void u.add(()=>i(f)).catch(d),error:f=>void u.add(()=>d(f)),complete:()=>void u.add(()=>o()).catch(d)});return()=>{e.log.trace("unsubscribing from graphql subscription"),l(),u.clear(),h()}}async execute(e,r){let s=lt(this.ctx),i=ct(this.ctx),n=s.slug;s.multiEnvironmentEnabled?n+=`--${i.name}`:s.hasSplitEnvironments&&(n+="--development");try{let o=await Ue({context:{ctx:e},method:"POST",url:`https://${n}.${pe.domains.app}${this.endpoint}`,headers:{...ut(e),"x-gadget-environment":i.name},json:{query:r.operation,variables:K(r.variables)},responseType:"json",resolveBodyOnly:!0,throwHttpErrors:!1,...r.http});if(!Ht(o)||!("data"in o)&&!("errors"in o))throw e.log.error("received invalid graphql response",{error:o}),o;return o}catch(o){throw new W(r.operation,o)}}async dispose(){await this._graphqlWsClient.dispose()}};var De=class{ctx;#e;constructor(e){this.ctx=e.child({name:"api"}),this.#e=new st(this.ctx,"/api/graphql")}async query({query:e,variables:r,...s}){let i=/query (\w+)/.exec(e)?.[1];Wt(i,"query name not found");let n=this.ctx.child({fields:{edit:{query:i}},devFields:{edit:{query:i,variables:K(r)}}});n.log.info("executing graphql query");let o=await this.#e.execute(n,{operation:e,variables:r,...s,http:{retry:{methods:["POST"]},...s.http}});if(o.errors)throw new W(e,o.errors);if(!o.data)throw new W(e,"Query response did not contain data");return o.data}async mutate({mutation:e,variables:r,...s}){let i=/mutation (\w+)/.exec(e)?.[1];Wt(i,"mutation name not found");let n=this.ctx.child({fields:{edit:{mutation:i}},devFields:{edit:{mutation:i,variables:K(r)}}});n.log.info("executing graphql mutation");let o=await this.#e.execute(n,{operation:e,variables:r,...s});if(o.errors)throw new W(e,o.errors);if(!o.data)throw new W(e,"Mutation response did not contain data");return o.data}subscribe({onData:e,...r}){let s=/subscription (\w+)/.exec(r.subscription)?.[1];Wt(s,"subscription name not found");let i=this.ctx.child({fields:{edit:{subscription:s}},devFields:{edit:{subscription:s,variables:K(r.variables)}}}),n=async c=>{if(c.errors){o(),await r.onError(new W(r.subscription,c.errors));return}if(!c.data){o(),await r.onError(new W(r.subscription,"Subscription response did not contain data"));return}await e(c.data)};i.log.info("subscribing to graphql subscription");let o=this.#e.subscribe(i,{...r,onResponse:n});return{unsubscribe:o,resubscribe:c=>{o(),c!==void 0&&(r.variables=c),i=this.ctx.child({fields:{edit:{subscription:s}},devFields:{edit:{subscription:s,variables:K(r.variables)}}}),i.log.info("re-subscribing to graphql subscription"),o=this.#e.subscribe(i,{...r,onResponse:n})}}}async dispose(){await this.#e.dispose()}};m();var gs=ve(`
15
+ query GadgetMetaModels {
16
+ gadgetMeta {
17
+ models {
18
+ apiIdentifier
19
+ namespace
20
+ }
21
+ }
22
+ }
23
+ `),_s=ve(`
24
+ query GadgetMetaGlobalActions {
25
+ gadgetMeta {
26
+ globalActions {
27
+ apiIdentifier
28
+ namespace
29
+ }
30
+ }
31
+ }
32
+ `);var Hi=Object.freeze({Development:"development",Production:"production",Test:"test"}),Yi=x.object({id:x.union([x.string(),x.number(),x.bigint()]).transform(t=>BigInt(t)),name:x.string().transform(t=>t.toLowerCase()),type:x.nativeEnum(Hi)}),Ki=x.object({id:x.union([x.string(),x.number(),x.bigint()]).transform(t=>BigInt(t)),slug:x.string(),primaryDomain:x.string(),hasSplitEnvironments:x.boolean(),multiEnvironmentEnabled:x.boolean(),environments:x.array(Yi),team:x.object({id:x.union([x.string(),x.number(),x.bigint()]).transform(t=>BigInt(t)),name:x.string()})}),Wo=x.object({apiIdentifier:x.string(),namespace:x.nullable(x.array(x.string())).optional()}),Fo=x.object({apiIdentifier:x.string(),namespace:x.nullable(x.array(x.string())).optional()}),jo=async t=>{let e=qe(t);if(!e)return[];let r=await Ue({context:{ctx:t},url:`https://${pe.domains.services}/auth/api/apps`,headers:{...e},responseType:"json",resolveBodyOnly:!0});return x.array(Ki).parse(r)},zo=t=>t.reduce((e,r)=>(e.set(r.team.name,[...e.get(r.team.name)??[],r]),e),new Map),Vo=async t=>{if(!qe(t))return[];let r=new De(t),{gadgetMeta:s}=await r.query({query:gs});return s.models},Qo=async t=>{if(!qe(t))return[];let r=new De(t),{gadgetMeta:s}=await r.query({query:_s});return s.globalActions};export{er as a,W as b,ke as c,st as d,Hi as e,jo as f,zo as g,Vo as h,Qo as i};
33
+ //# sourceMappingURL=chunk-NGTOMLDS.js.map