openpond 0.2.38 → 0.2.39

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.
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{b as Re,c as Ie,e as X,j as Ee,k as ke,l as Oe,m as Ae}from"./chunk-KNEMKYHY.js";import{i as Pe,o as xe,q as Ce}from"./chunk-25OT6IYM.js";import{E as v,I as Te}from"./chunk-PKBU37CH.js";import{a as K,b as Se,h as ye}from"./chunk-V5BC6QT2.js";import{Cd as O,Fd as j,Gd as re,I as k,J as te,M as N,N as H,a as F}from"./chunk-SBBXUZWL.js";import{$a as L,Ra as me,Sa as ge,Ua as Y,X as oe,Xa as he,Y as ie,_a as fe,db as ve,fb as we,gb as be,ja as ae,la as ue,ma as le,na as ce,oa as pe,qa as de,v as _}from"./chunk-QK2GLRCY.js";import{b as o}from"./chunk-ES2ISFJC.js";import{c as ne,d as q,f as se,h as M}from"./chunk-H7IWJN7L.js";import{a as u}from"./chunk-FTQLQJQV.js";import{promises as Q}from"node:fs";import it from"node:os";import at from"node:path";import{createServer as ut}from"node:http";import{randomBytes as lt}from"node:crypto";var Qe=o.discriminatedUnion("op",[o.strictObject({op:o.literal("set"),path:o.array(o.string().min(1)).min(1),value:o.unknown()}),o.strictObject({op:o.literal("unset"),path:o.array(o.string().min(1)).min(1)})]),et=o.discriminatedUnion("action",[o.strictObject({action:o.literal("patch"),expectedRevision:o.string(),operations:o.array(Qe).max(100)}),o.strictObject({action:o.literal("replace"),expectedRevision:o.string(),text:o.string().max(1048576)}),o.strictObject({action:o.literal("validate"),text:o.string().max(1048576)}),o.strictObject({action:o.literal("restore"),expectedRevision:o.string(),revision:o.string()}),o.strictObject({action:o.literal("trust"),root:o.string(),accountId:o.string(),trusted:o.boolean()}),o.strictObject({action:o.literal("client-state"),owner:o.string(),patch:ve,importOnly:o.boolean().optional()})]);function _e(n){let e=null;async function t(s,i){let a=M(n).config,l=null,c=null,p=null;try{l=await ie(a),p=await L(n,{projectRoot:s,accountId:i}),s||(e=p)}catch(b){c=q(b,a)}let h=p??(s?null:e);return{path:a,text:l,rawRevision:oe(l),issue:c,effective:h,usingLastValid:!p&&!!h,applies:"next_turn",recoverableRevisions:await ue(n),clientState:c?null:await we(n)}}u(t,"status");async function r(s){let i=et.parse(s);return i.action==="validate"?{valid:!0,document:ae(i.text,M(n).config)}:(i.action==="patch"&&await de(n,i.expectedRevision,i.operations),i.action==="replace"&&await le(n,i.expectedRevision,i.text),i.action==="restore"&&await ce(n,i.revision,i.expectedRevision),i.action==="trust"&&await fe(n,i.root,i.accountId,i.trusted),i.action==="client-state"?be(n,i.owner,i.patch,i.importOnly):t())}return u(r,"mutate"),{status:t,mutate:r,schema:pe}}u(_e,"createConfigurationPayloads");import{Buffer as He}from"node:buffer";var V={"Access-Control-Allow-Headers":"authorization, content-type, x-openpond-team-id","Access-Control-Allow-Methods":"GET, POST, PUT, PATCH, DELETE, OPTIONS"},tt=25*1024*1024,B=class extends Error{constructor(t,r,s){super(s);this.status=t;this.code=r;this.name="HttpBodyError"}status;code;static{u(this,"HttpBodyError")}};function Ue(n,e,t={}){for(let[s,i]of Object.entries(V))e.setHeader(s,i);let r=qe(n.headers.origin);return r?(e.setHeader("Vary",ot(e.getHeader("Vary"))),rt(r,t)?(e.setHeader("Access-Control-Allow-Origin",r),{allowed:!0,origin:r}):{allowed:!1,origin:r}):{allowed:!0,origin:null}}u(Ue,"applyCorsHeaders");function rt(n,e={}){if(n==="null")return!0;let t=Me(n);return t?st(t)?!0:new Set((e.allowedOrigins??[]).map(s=>s?Me(s):null).filter(s=>!!s)).has(t):!1}u(rt,"isAllowedCorsOrigin");function I(n,e,t){n.writeHead(e,{"Content-Type":"application/json",...V}),n.end(JSON.stringify(t))}u(I,"sendJson");function Ft(n,e,t){n.writeHead(e,{"Content-Type":"text/plain; charset=utf-8",...V}),n.end(t)}u(Ft,"sendText");function jt(n,e,t,r){n.writeHead(e,{"Content-Type":r,"Content-Length":String(t.byteLength),"Cache-Control":"no-store","X-Content-Type-Options":"nosniff",...V}),n.end(t)}u(jt,"sendBinary");async function Z(n,e={}){let t=e.maxBytes??tt,r=qe(n.headers["content-type"]),s=[],i=0;for await(let l of n){let c=He.from(l);if(i+=c.byteLength,i>t)throw new B(413,"request_body_too_large",`JSON request body exceeds ${t} bytes.`);s.push(c)}let a=He.concat(s).toString("utf8").trim();if(!a)return{};if(!nt(r))throw new B(415,"unsupported_media_type","JSON request body requires Content-Type: application/json.");try{return JSON.parse(a)}catch{throw new B(400,"invalid_json","Request body is not valid JSON.")}}u(Z,"readJson");function Ne(n,e,t){let r=n.headers.authorization;return(typeof r=="string"&&r.startsWith("Bearer ")?r.slice(7):null)===t}u(Ne,"hasAuth");function qe(n){return Array.isArray(n)?n[0]??null:n??null}u(qe,"headerValue");function nt(n){if(!n)return!1;let e=n.split(";")[0]?.trim().toLowerCase();return e==="application/json"||!!e?.endsWith("+json")}u(nt,"isJsonContentType");function Me(n){try{let e=new URL(n);return e.protocol!=="http:"&&e.protocol!=="https:"?null:e.origin}catch{return null}}u(Me,"normalizeOrigin");function st(n){let e=new URL(n);return e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="::1"||e.hostname==="[::1]"}u(st,"isLoopbackOrigin");function ot(n){let t=(Array.isArray(n)?n.join(", "):n?String(n):"").split(",").map(r=>r.trim()).filter(Boolean);return t.some(r=>r.toLowerCase()==="origin")||t.push("Origin"),t.join(", ")}u(ot,"appendVaryOrigin");function Be(n){return`<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>OpenPond recovery</title>
2
+ import{b as Re,c as Ie,e as X,j as Ee,k as ke,l as Oe,m as Ae}from"./chunk-FVALIUVY.js";import{i as Pe,o as xe,q as Ce}from"./chunk-25OT6IYM.js";import{E as v,I as Te}from"./chunk-PKBU37CH.js";import{a as K,b as Se,h as ye}from"./chunk-6GLGOIMQ.js";import{Cd as O,Fd as j,Gd as re,I as k,J as te,M as N,N as H,a as F}from"./chunk-SBBXUZWL.js";import{$a as L,Ra as me,Sa as ge,Ua as Y,X as oe,Xa as he,Y as ie,_a as fe,db as ve,fb as we,gb as be,ja as ae,la as ue,ma as le,na as ce,oa as pe,qa as de,v as _}from"./chunk-QK2GLRCY.js";import{b as o}from"./chunk-ES2ISFJC.js";import{c as ne,d as q,f as se,h as M}from"./chunk-H7IWJN7L.js";import{a as u}from"./chunk-FTQLQJQV.js";import{promises as Q}from"node:fs";import it from"node:os";import at from"node:path";import{createServer as ut}from"node:http";import{randomBytes as lt}from"node:crypto";var Qe=o.discriminatedUnion("op",[o.strictObject({op:o.literal("set"),path:o.array(o.string().min(1)).min(1),value:o.unknown()}),o.strictObject({op:o.literal("unset"),path:o.array(o.string().min(1)).min(1)})]),et=o.discriminatedUnion("action",[o.strictObject({action:o.literal("patch"),expectedRevision:o.string(),operations:o.array(Qe).max(100)}),o.strictObject({action:o.literal("replace"),expectedRevision:o.string(),text:o.string().max(1048576)}),o.strictObject({action:o.literal("validate"),text:o.string().max(1048576)}),o.strictObject({action:o.literal("restore"),expectedRevision:o.string(),revision:o.string()}),o.strictObject({action:o.literal("trust"),root:o.string(),accountId:o.string(),trusted:o.boolean()}),o.strictObject({action:o.literal("client-state"),owner:o.string(),patch:ve,importOnly:o.boolean().optional()})]);function _e(n){let e=null;async function t(s,i){let a=M(n).config,l=null,c=null,p=null;try{l=await ie(a),p=await L(n,{projectRoot:s,accountId:i}),s||(e=p)}catch(b){c=q(b,a)}let h=p??(s?null:e);return{path:a,text:l,rawRevision:oe(l),issue:c,effective:h,usingLastValid:!p&&!!h,applies:"next_turn",recoverableRevisions:await ue(n),clientState:c?null:await we(n)}}u(t,"status");async function r(s){let i=et.parse(s);return i.action==="validate"?{valid:!0,document:ae(i.text,M(n).config)}:(i.action==="patch"&&await de(n,i.expectedRevision,i.operations),i.action==="replace"&&await le(n,i.expectedRevision,i.text),i.action==="restore"&&await ce(n,i.revision,i.expectedRevision),i.action==="trust"&&await fe(n,i.root,i.accountId,i.trusted),i.action==="client-state"?be(n,i.owner,i.patch,i.importOnly):t())}return u(r,"mutate"),{status:t,mutate:r,schema:pe}}u(_e,"createConfigurationPayloads");import{Buffer as He}from"node:buffer";var V={"Access-Control-Allow-Headers":"authorization, content-type, x-openpond-team-id","Access-Control-Allow-Methods":"GET, POST, PUT, PATCH, DELETE, OPTIONS"},tt=25*1024*1024,B=class extends Error{constructor(t,r,s){super(s);this.status=t;this.code=r;this.name="HttpBodyError"}status;code;static{u(this,"HttpBodyError")}};function Ue(n,e,t={}){for(let[s,i]of Object.entries(V))e.setHeader(s,i);let r=qe(n.headers.origin);return r?(e.setHeader("Vary",ot(e.getHeader("Vary"))),rt(r,t)?(e.setHeader("Access-Control-Allow-Origin",r),{allowed:!0,origin:r}):{allowed:!1,origin:r}):{allowed:!0,origin:null}}u(Ue,"applyCorsHeaders");function rt(n,e={}){if(n==="null")return!0;let t=Me(n);return t?st(t)?!0:new Set((e.allowedOrigins??[]).map(s=>s?Me(s):null).filter(s=>!!s)).has(t):!1}u(rt,"isAllowedCorsOrigin");function I(n,e,t){n.writeHead(e,{"Content-Type":"application/json",...V}),n.end(JSON.stringify(t))}u(I,"sendJson");function Ft(n,e,t){n.writeHead(e,{"Content-Type":"text/plain; charset=utf-8",...V}),n.end(t)}u(Ft,"sendText");function jt(n,e,t,r){n.writeHead(e,{"Content-Type":r,"Content-Length":String(t.byteLength),"Cache-Control":"no-store","X-Content-Type-Options":"nosniff",...V}),n.end(t)}u(jt,"sendBinary");async function Z(n,e={}){let t=e.maxBytes??tt,r=qe(n.headers["content-type"]),s=[],i=0;for await(let l of n){let c=He.from(l);if(i+=c.byteLength,i>t)throw new B(413,"request_body_too_large",`JSON request body exceeds ${t} bytes.`);s.push(c)}let a=He.concat(s).toString("utf8").trim();if(!a)return{};if(!nt(r))throw new B(415,"unsupported_media_type","JSON request body requires Content-Type: application/json.");try{return JSON.parse(a)}catch{throw new B(400,"invalid_json","Request body is not valid JSON.")}}u(Z,"readJson");function Ne(n,e,t){let r=n.headers.authorization;return(typeof r=="string"&&r.startsWith("Bearer ")?r.slice(7):null)===t}u(Ne,"hasAuth");function qe(n){return Array.isArray(n)?n[0]??null:n??null}u(qe,"headerValue");function nt(n){if(!n)return!1;let e=n.split(";")[0]?.trim().toLowerCase();return e==="application/json"||!!e?.endsWith("+json")}u(nt,"isJsonContentType");function Me(n){try{let e=new URL(n);return e.protocol!=="http:"&&e.protocol!=="https:"?null:e.origin}catch{return null}}u(Me,"normalizeOrigin");function st(n){let e=new URL(n);return e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname==="::1"||e.hostname==="[::1]"}u(st,"isLoopbackOrigin");function ot(n){let t=(Array.isArray(n)?n.join(", "):n?String(n):"").split(",").map(r=>r.trim()).filter(Boolean);return t.some(r=>r.toLowerCase()==="origin")||t.push("Origin"),t.join(", ")}u(ot,"appendVaryOrigin");function Be(n){return`<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>OpenPond recovery</title>
3
3
  <style nonce="${n}">body{font:16px system-ui;background:#171819;color:#eee;max-width:850px;margin:6vh auto;padding:24px}textarea{box-sizing:border-box;width:100%;min-height:280px;background:#222;color:#eee;padding:14px;border:1px solid #777;border-radius:8px;font:14px monospace}button,input,select{font:inherit;margin:6px;padding:8px}pre{white-space:pre-wrap}code{overflow-wrap:anywhere}button{cursor:pointer}p{line-height:1.5}</style>
4
4
  <h1>OpenPond needs a storage repair</h1><p id="issue" role="alert">Loading recovery details\u2026</p><p><code id="file"></code></p>
5
5
  <p id="action"></p><p>Migration backups and the source installation remain available. Execution services are stopped while recovery is open.</p>
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{i as a,j as b,k as c}from"./chunk-ZCDOE3EO.js";import"./chunk-KNEMKYHY.js";import"./chunk-25OT6IYM.js";import"./chunk-GKRTXVNT.js";import"./chunk-OCWH4BV7.js";import"./chunk-PKBU37CH.js";import"./chunk-V5BC6QT2.js";import"./chunk-XHJUP7M4.js";import"./chunk-7BGT6Q2D.js";import"./chunk-SBBXUZWL.js";import"./chunk-L3KS6MOV.js";import"./chunk-SHCRE7B2.js";import"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import"./chunk-WCZRDULE.js";import"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import"./chunk-JUX77H6K.js";import"./chunk-QUNRWDVO.js";import"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-QK2GLRCY.js";import"./chunk-HZP5U2AA.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as resolveWebLaunchMessages,c as runOpenPondAppServerCli,b as runOpenPondServerCli};
2
+ import{i as a,j as b,k as c}from"./chunk-ZO7DTED5.js";import"./chunk-FVALIUVY.js";import"./chunk-25OT6IYM.js";import"./chunk-R6DWG5A4.js";import"./chunk-L6ELXODL.js";import"./chunk-PKBU37CH.js";import"./chunk-6GLGOIMQ.js";import"./chunk-XHJUP7M4.js";import"./chunk-7BGT6Q2D.js";import"./chunk-SBBXUZWL.js";import"./chunk-L3KS6MOV.js";import"./chunk-SHCRE7B2.js";import"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import"./chunk-WCZRDULE.js";import"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import"./chunk-JUX77H6K.js";import"./chunk-QUNRWDVO.js";import"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-QK2GLRCY.js";import"./chunk-HZP5U2AA.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as resolveWebLaunchMessages,c as runOpenPondAppServerCli,b as runOpenPondServerCli};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{j as a,k as b}from"./chunk-GKRTXVNT.js";import"./chunk-OCWH4BV7.js";import"./chunk-PKBU37CH.js";import"./chunk-V5BC6QT2.js";import"./chunk-XHJUP7M4.js";import"./chunk-7BGT6Q2D.js";import"./chunk-SBBXUZWL.js";import"./chunk-L3KS6MOV.js";import"./chunk-SHCRE7B2.js";import"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import"./chunk-WCZRDULE.js";import"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import"./chunk-JUX77H6K.js";import"./chunk-QUNRWDVO.js";import"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-QK2GLRCY.js";import"./chunk-HZP5U2AA.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as loadHostedHarnessRuntime,b as loadHostedHarnessRuntimeForSession};
2
+ import{j as a,k as b}from"./chunk-R6DWG5A4.js";import"./chunk-L6ELXODL.js";import"./chunk-PKBU37CH.js";import"./chunk-6GLGOIMQ.js";import"./chunk-XHJUP7M4.js";import"./chunk-7BGT6Q2D.js";import"./chunk-SBBXUZWL.js";import"./chunk-L3KS6MOV.js";import"./chunk-SHCRE7B2.js";import"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import"./chunk-WCZRDULE.js";import"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import"./chunk-JUX77H6K.js";import"./chunk-QUNRWDVO.js";import"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-QK2GLRCY.js";import"./chunk-HZP5U2AA.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as loadHostedHarnessRuntime,b as loadHostedHarnessRuntimeForSession};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{ia as l,ma as c}from"./chunk-OCWH4BV7.js";import"./chunk-V5BC6QT2.js";import{M as n}from"./chunk-XHJUP7M4.js";import"./chunk-7BGT6Q2D.js";import"./chunk-SBBXUZWL.js";import"./chunk-L3KS6MOV.js";import"./chunk-SHCRE7B2.js";import"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import"./chunk-WCZRDULE.js";import"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import"./chunk-JUX77H6K.js";import"./chunk-QUNRWDVO.js";import"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-QK2GLRCY.js";import"./chunk-HZP5U2AA.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as t}from"./chunk-FTQLQJQV.js";import{mkdir as f}from"node:fs/promises";import p from"node:path";import a from"node:path";function d(e,o){let s=a.resolve(e),r=a.resolve(o);return r===s||r.startsWith(`${s}${a.sep}`)}t(d,"isHostedProfileSourceWithinRepo");async function m(e){if(!p.isAbsolute(e.repoPath)||!p.isAbsolute(e.outputDir)||!/^[a-f0-9]{40,64}$/.test(e.sourceRevision)||!e.workspaceId.trim()||!e.repositoryId.trim()||!e.profileId.trim())throw new Error("Hosted Profile compile request is invalid.");let o=await n({repoPath:e.repoPath,profileId:e.profileId});if(o.error||o.mode!=="local"||o.activeProfile!==e.profileId||!o.sourcePath||!d(e.repoPath,o.sourcePath))throw new Error("Hosted Profile source is unavailable.");await f(e.outputDir,{recursive:!0});let s=await l({storeDir:e.outputDir,workspaceId:e.workspaceId,name:e.profileId,profile:o,sourceRevision:e.sourceRevision,repositoryId:e.repositoryId}),r=s.harnessRelease.metadata.profile;if(!r||typeof r!="object"||r.id!==e.profileId||r.sourceRevision!==e.sourceRevision||r.repositoryId!==e.repositoryId)throw new Error("Hosted Profile release provenance is invalid.");let i=await c({storeDir:e.outputDir,workspaceId:e.workspaceId,compiled:s,createdAt:new Date().toISOString()});return{workspaceId:e.workspaceId,sourceRevision:i.sourceRevision,harnessRelease:i.harnessRelease,agentSnapshot:i.agentSnapshot,bundlePath:i.bundlePath}}t(m,"compileHostedProfileRelease");async function H(e){if(e.length!==1||e[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(e[0]))throw new Error("Hosted Profile compile argument is invalid.");let o=JSON.parse(Buffer.from(e[0],"base64url").toString("utf8")),s=await m(o);process.stdout.write(`${JSON.stringify(s)}
2
+ import{ia as l,ma as c}from"./chunk-L6ELXODL.js";import"./chunk-6GLGOIMQ.js";import{M as n}from"./chunk-XHJUP7M4.js";import"./chunk-7BGT6Q2D.js";import"./chunk-SBBXUZWL.js";import"./chunk-L3KS6MOV.js";import"./chunk-SHCRE7B2.js";import"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import"./chunk-WCZRDULE.js";import"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import"./chunk-JUX77H6K.js";import"./chunk-QUNRWDVO.js";import"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import"./chunk-QK2GLRCY.js";import"./chunk-HZP5U2AA.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as t}from"./chunk-FTQLQJQV.js";import{mkdir as f}from"node:fs/promises";import p from"node:path";import a from"node:path";function d(e,o){let s=a.resolve(e),r=a.resolve(o);return r===s||r.startsWith(`${s}${a.sep}`)}t(d,"isHostedProfileSourceWithinRepo");async function m(e){if(!p.isAbsolute(e.repoPath)||!p.isAbsolute(e.outputDir)||!/^[a-f0-9]{40,64}$/.test(e.sourceRevision)||!e.workspaceId.trim()||!e.repositoryId.trim()||!e.profileId.trim())throw new Error("Hosted Profile compile request is invalid.");let o=await n({repoPath:e.repoPath,profileId:e.profileId});if(o.error||o.mode!=="local"||o.activeProfile!==e.profileId||!o.sourcePath||!d(e.repoPath,o.sourcePath))throw new Error("Hosted Profile source is unavailable.");await f(e.outputDir,{recursive:!0});let s=await l({storeDir:e.outputDir,workspaceId:e.workspaceId,name:e.profileId,profile:o,sourceRevision:e.sourceRevision,repositoryId:e.repositoryId}),r=s.harnessRelease.metadata.profile;if(!r||typeof r!="object"||r.id!==e.profileId||r.sourceRevision!==e.sourceRevision||r.repositoryId!==e.repositoryId)throw new Error("Hosted Profile release provenance is invalid.");let i=await c({storeDir:e.outputDir,workspaceId:e.workspaceId,compiled:s,createdAt:new Date().toISOString()});return{workspaceId:e.workspaceId,sourceRevision:i.sourceRevision,harnessRelease:i.harnessRelease,agentSnapshot:i.agentSnapshot,bundlePath:i.bundlePath}}t(m,"compileHostedProfileRelease");async function H(e){if(e.length!==1||e[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(e[0]))throw new Error("Hosted Profile compile argument is invalid.");let o=JSON.parse(Buffer.from(e[0],"base64url").toString("utf8")),s=await m(o);process.stdout.write(`${JSON.stringify(s)}
3
3
  `)}t(H,"runHostedProfileCompilerCli");export{m as compileHostedProfileRelease,H as runHostedProfileCompilerCli};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
3
- import{a as HA,b as OA,c as DA,d as j,e as BA,f as so,g as z,h as vu,j as $A}from"./chunk-ZCDOE3EO.js";import{$ as Cx,$a as pu,$b as rA,A as nu,Aa as Xx,Ab as LT,Ac as SA,B as Y_,Ba as du,Bb as NT,Bc as IA,C as X_,Ca as Qx,Cb as FT,Cc as RA,D as Q_,Da as ro,Db as UT,Dc as PA,E as ru,Ea as Ae,Eb as qT,Ec as _A,F as Z_,Fa as Zx,Fb as zT,Fc as xA,G as ex,Ga as pe,Gb as WT,Gc as TA,H as tx,Ha as eT,Hb as VT,Hc as AA,I as nx,Ia as tT,Ib as fu,Ic as CA,J as rx,Ja as nT,Jb as JT,Jc as EA,K as dc,Ka as rT,Kb as Yo,Kc as MA,L as wx,La as oT,Lb as gu,M as yx,Ma as aT,Mb as GT,Mc as jA,N as vx,Na as sT,Nb as oo,O as kx,Oa as iT,Ob as hu,P as bx,Pa as cT,Pb as KT,Q as lc,Qa as dT,Qb as YT,R as Sx,Ra as lT,Rb as Zg,S as Ix,Sa as vs,Sb as eh,T as hs,Ta as jn,Tb as XT,U as ws,Ua as je,Ub as QT,V as Rx,Va as uT,Vb as ZT,W as Px,Wa as pT,Wb as eA,X as _x,Xa as mT,Xb as th,Y as xx,Ya as fT,Yb as tA,Z as Tx,Za as wT,Zb as nh,_ as Ax,_a as yT,_b as nA,a as gg,aa as no,ab as vT,ac as oA,b as Yb,ba as Ex,bb as kT,bc as aA,c as Xb,ca as Mx,cb as bT,cc as sA,d as Qb,da as Yg,db as ST,dc as iA,e as Zb,ea as jx,eb as IT,ec as cA,f as eS,fa as Hx,fb as Qg,fc as dA,g as tS,ga as Ox,gb as RT,gc as lA,h as Do,ha as ys,hb as PT,hc as uA,i as nS,ia as Dx,ib as _T,ic as rh,j as rS,ja as Bx,jb as xT,jc as pA,k as al,ka as $x,kb as TT,kc as oh,l as oS,la as Lx,lb as AT,lc as mA,m as aS,ma as Nx,mb as CT,mc as fA,n as E2,na as Fx,nb as Hn,nc as gA,o as P_,oa as iu,ob as ET,oc as hA,p as __,pa as Ux,pb as mu,pc as wA,q as x_,qa as qx,qb as MT,qc as ao,r as T_,ra as ae,rb as jT,rc as Pr,s as H_,sa as zx,sb as $t,sc as ah,t as eu,ta as Wx,tb as Ko,tc as yA,u as W_,ua as Vx,ub as HT,uc as vA,v as V_,va as cu,vb as Rr,vc as wu,w as J_,wa as Jx,wb as OT,wc as ks,x as tu,xa as Gx,xb as DT,xc as kA,y as G_,ya as Kx,yb as BT,yc as yu,z as K_,za as Yx,zb as $T,zc as bA}from"./chunk-GOHJHZVA.js";import{a as at,b as A_,c as C_,d as j_,f as Xg,g as gT,h as lu,i as uu,j as hT}from"./chunk-KNEMKYHY.js";import{a as nn,b as O_,c as D_,d as Ql,e as Zl,g as B_,h as $_,j as L_,k as N_,l as F_,m as U_,n as q_,o as z_}from"./chunk-25OT6IYM.js";import{e as M_,f as Yl,g as Xl,h as ms}from"./chunk-GKRTXVNT.js";import{$ as k_,M as Gl,P as h_,S as w_,T as y_,U as ps,V as Kl,W as ic,Y as Wg,Z as Go,_ as v_,a as Ab,aa as b_,b as Cb,ba as S_,c as Eb,e as Mb,f as jb,fa as I_,g as nl,h as qb,i as zb,j as Wb,k as Vb,ka as R_,l as Jb,r as l_,s as u_,t as p_,u as m_,v as f_,w as Jl,x as g_}from"./chunk-OCWH4BV7.js";import{d as E_}from"./chunk-PKBU37CH.js";import{A as lx,C as au,F as su,G as sr,H as ux,I as Vg,J as px,K as Jg,N as mx,O as Gg,P as fx,Q as gx,R as hx,S as Kg,T as gs,b as ou,d as ox,e as ax,h as sx,m as fs,n as ix,p as cx,q as dx,s as cc}from"./chunk-IKM6ICPY.js";import{a as c_,b as Vl,d as ie,e as ot,f as us,g as ne,i as d_}from"./chunk-V5BC6QT2.js";import{A as QP,B as Wl,C as ZP,D as zg,E as e_,F as t_,G as Qe,H as n_,I as gt,J as sc,K as r_,L as o_,N as a_,P as s_,Q as i_,R as Mn,c as LP,l as NP,m as FP,n as UP,q as qP,r as zP,s as WP,t as VP,u as JP,v as qg,w as GP,x as KP,y as YP,z as XP}from"./chunk-XHJUP7M4.js";import{f as SP}from"./chunk-7BGT6Q2D.js";import{$ as TI,$a as sR,$b as FR,$c as cP,Aa as XI,Ab as TR,Ba as Pg,Bb as AR,Ca as Pl,Cb as CR,Da as QI,Ea as rr,Eb as Al,F as vI,Fa as _l,Fb as HR,Ga as _g,H as kI,Ha as xl,Hb as OR,I as Ig,Ib as nc,Ja as xg,Jb as Og,K as Ue,Ka as Zi,L as Sl,M as bI,Ma as ZI,Mb as Cl,Mc as Uo,N as Rg,Nc as tP,Ob as Dg,Oc as Ir,P as SI,Pa as eR,Pb as DR,Pc as nP,Qa as tR,Qb as BR,Qc as rP,Ra as nR,Rc as oP,Sc as Zr,T as II,Ta as ns,Tb as El,Tc as cs,Ua as rR,Ub as $R,Uc as Ol,V as Il,Vb as Bg,Vc as aP,W as RI,Wa as ec,Wb as or,Wc as sP,Xa as Tl,Xb as LR,Xc as iP,Y as PI,Ya as oR,Yb as NR,Yc as oc,Z as _I,Za as Tg,Zb as $g,Zc as ds,_ as xI,_a as aR,_b as rc,_c as Dl,aa as AI,ab as Ag,ac as Ml,ad as Bl,ba as CI,bb as iR,bc as UR,bd as eo,ca as EI,cb as cR,cc as qR,cd as dP,d as tI,da as MI,db as dR,dc as as,dd as lP,ea as jI,eb as lR,ec as zR,ed as uP,f as vl,fa as Qr,fb as uR,fc as ss,fd as $l,gb as pR,gc as WR,gd as pP,h as aI,ha as HI,hb as mR,hc as VR,hd as ac,ia as OI,ib as Cg,ic as Lg,id as mP,ja as DI,jb as fR,jc as jl,jd as fP,k as bg,ka as BI,kb as gR,kc as JR,l as iI,lb as hR,lc as De,m as Bt,ma as $I,mb as wR,mc as Hl,n as Lo,na as Rl,nb as Eg,nc as GR,o as No,oa as LI,ob as yR,oc as KR,p as Sg,pa as NI,pb as vR,pc as YR,q as cI,qa as FI,qb as kR,qc as Ng,r as dI,ra as UI,rb as bR,rc as XR,s as lI,sa as qI,sb as SR,sc as QR,sd as Ll,t as uI,ta as zI,tb as IR,tc as ZR,td as gP,u as pI,ua as WI,ub as RR,ud as hP,v as mI,va as VI,vb as PR,vc as is,vd as ar,w as kl,wa as JI,wb as _R,wc as eP,wd as wP,xa as GI,xb as xR,xd as qo,y as bl,ya as KI,yb as Mg,yd as yP,za as YI,zb as Fo}from"./chunk-SBBXUZWL.js";import{b as BP,c as $P}from"./chunk-L3KS6MOV.js";import{a as vP,h as kP,k as bP}from"./chunk-SHCRE7B2.js";import"./chunk-XEOEKFG6.js";import{N as os,O as tc,P as ER,Q as MR,R as jR,T as jg,V as Hg,f as zS,j as WS,k as VS,l as nI,m as rI,n as gn,o as wl,r as $o,s as Qi,t as kg,u as yl,v as oI,z as sI}from"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import{A as fg,B as Qa,Bb as ES,Ca as fS,Db as MS,Ea as gS,Fa as hS,Lb as En,Mb as jS,Na as wS,Nb as ll,Ob as tn,Qa as yS,Qb as ul,R as rl,U as Gb,Va as vS,Za as kS,_b as HS,a as ug,aa as ol,ab as bS,ac as OS,bb as cl,bc as es,ca as Kb,cc as DS,da as sS,dc as BS,e as Hb,ea as sl,ec as pl,fc as ml,gc as fl,ha as hg,hc as $S,ia as iS,ib as SS,ic as yg,j as Ob,ja as cS,jb as IS,jc as LS,ka as dS,kb as RS,l as pg,la as il,lb as PS,lc as NS,m as Tt,ma as lS,mb as _S,mc as FS,n as mg,na as uS,nb as dl,nc as US,o as fn,oa as pS,ob as wg,oc as Yr,pa as mS,pb as xS,pc as qS,qb as TS,qc as nr,rb as AS,s as Db,v as Ki,vc as rs,w as Bb,wb as CS,x as el,yb as Za,z as $b}from"./chunk-WCZRDULE.js";import"./chunk-RELOOVWW.js";import{D as Xa,E as Gi,F as Zd,d as Qd,m as xb,n as Kr,o as We,p as Tb}from"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import{Ka as Lb,La as Nb,Ma as tr,Pa as Fb,Qa as tl,Ra as Ub,a as en,fa as Ve,ga as zt,ma as Rb,s as Xd,va as Pb,xa as _b}from"./chunk-JUX77H6K.js";import{Da as C2,Ea as Sb,Fa as dg,Ga as lg,Ia as Ib,R as Kd,pa as vb,qa as Yd,sa as kb,wa as bb}from"./chunk-QUNRWDVO.js";import{a as Xi}from"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{$ as Fl,$a as Jo,Ca as EP,D as fI,Ea as Fg,Fa as Ug,Ga as MP,H as Xr,J as gI,L as hI,M as wI,N as yI,Ta as ql,Ua as jP,Ya as HP,Za as OP,a as Bo,ab as DP,b as JS,bb as zl,c as Yi,d as Sr,e as gl,f as GS,g as hl,h as KS,i as ts,k as YS,l as XS,m as QS,n as ZS,o as eI,pa as to,ra as Wo,v as vg,wa as _P,xa as xP,ya as AP,za as CP}from"./chunk-QK2GLRCY.js";import{a as Ka,b as Ya,c as ig,d as Vd,e as rt,f as cg,g as Jd,j as ze,k as Se,l as O,m as wb,o as yb,p as Gd,q as xt}from"./chunk-HZP5U2AA.js";import{a as Oo,b as T}from"./chunk-ES2ISFJC.js";import{a as IP,c as zo,f as RP,h as Nl,i as PP,p as ls,q as TP,r as Vo,s as Ul}from"./chunk-H7IWJN7L.js";import{a,b as Pe,c as Te,e as Cn}from"./chunk-FTQLQJQV.js";var Or=Te((Hpe,Y0)=>{"use strict";var G0=["nodebuffer","arraybuffer","fragments"],K0=typeof Blob<"u";K0&&G0.push("blob");Y0.exports={BINARY_TYPES:G0,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:K0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:a(()=>{},"NOOP")}});var Oc=Te((Dpe,up)=>{"use strict";var{EMPTY_BUFFER:xG}=Or(),Tw=Buffer[Symbol.species];function TG(e,t){if(e.length===0)return xG;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];n.set(s,r),r+=s.length}return r<t?new Tw(n.buffer,n.byteOffset,r):n}a(TG,"concat");function X0(e,t,n,r,o){for(let s=0;s<o;s++)n[r+s]=e[s]^t[s&3]}a(X0,"_mask");function Q0(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}a(Q0,"_unmask");function AG(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}a(AG,"toArrayBuffer");function Aw(e){if(Aw.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new Tw(e):ArrayBuffer.isView(e)?t=new Tw(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Aw.readOnly=!1),t}a(Aw,"toBuffer");up.exports={concat:TG,mask:X0,toArrayBuffer:AG,toBuffer:Aw,unmask:Q0};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=Pe("bufferutil");up.exports.mask=function(t,n,r,o,s){s<48?X0(t,n,r,o,s):e.mask(t,n,r,o,s)},up.exports.unmask=function(t,n){t.length<32?Q0(t,n):e.unmask(t,n)}}catch{}});var tj=Te(($pe,ej)=>{"use strict";var Z0=Symbol("kDone"),Cw=Symbol("kRun"),Ew=class{static{a(this,"Limiter")}constructor(t){this[Z0]=()=>{this.pending--,this[Cw]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[Cw]()}[Cw](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[Z0])}}};ej.exports=Ew});var Xs=Te((Npe,aj)=>{"use strict";var Dc=Pe("zlib"),nj=Oc(),CG=tj(),{kStatusCode:rj}=Or(),EG=Buffer[Symbol.species],MG=Buffer.from([0,0,255,255]),mp=Symbol("permessage-deflate"),Dr=Symbol("total-length"),Ks=Symbol("callback"),ko=Symbol("buffers"),Ys=Symbol("error"),pp,Mw=class{static{a(this,"PerMessageDeflate")}constructor(t){if(this._options=t||{},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,!pp){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;pp=new CG(n)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[Ks];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,r=t.find(o=>!(n.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>o.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(r=>{let o=n[r];if(o.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else if(r==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else throw new Error(`Unknown parameter "${r}"`);n[r]=o})}),t}decompress(t,n,r){pp.add(o=>{this._decompress(t,n,(s,i)=>{o(),r(s,i)})})}compress(t,n,r){pp.add(o=>{this._compress(t,n,(s,i)=>{o(),r(s,i)})})}_decompress(t,n,r){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?Dc.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Dc.createInflateRaw({...this._options.zlibInflateOptions,windowBits:i}),this._inflate[mp]=this,this._inflate[Dr]=0,this._inflate[ko]=[],this._inflate.on("error",HG),this._inflate.on("data",oj)}this._inflate[Ks]=r,this._inflate.write(t),n&&this._inflate.write(MG),this._inflate.flush(()=>{let s=this._inflate[Ys];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=nj.concat(this._inflate[ko],this._inflate[Dr]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Dr]=0,this._inflate[ko]=[],n&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(t,n,r){let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?Dc.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Dc.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),this._deflate[Dr]=0,this._deflate[ko]=[],this._deflate.on("data",jG)}this._deflate[Ks]=r,this._deflate.write(t),this._deflate.flush(Dc.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=nj.concat(this._deflate[ko],this._deflate[Dr]);n&&(s=new EG(s.buffer,s.byteOffset,s.length-4)),this._deflate[Ks]=null,this._deflate[Dr]=0,this._deflate[ko]=[],n&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};aj.exports=Mw;function jG(e){this[ko].push(e),this[Dr]+=e.length}a(jG,"deflateOnData");function oj(e){if(this[Dr]+=e.length,this[mp]._maxPayload<1||this[Dr]<=this[mp]._maxPayload){this[ko].push(e);return}this[Ys]=new RangeError("Max payload size exceeded"),this[Ys].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ys][rj]=1009,this.removeListener("data",oj),this.reset()}a(oj,"inflateOnData");function HG(e){if(this[mp]._inflate=null,this[Ys]){this[Ks](this[Ys]);return}e[rj]=1007,this[Ks](e)}a(HG,"inflateOnError")});var Qs=Te((Upe,fp)=>{"use strict";var{isUtf8:sj}=Pe("buffer"),{hasBlob:OG}=Or(),DG=[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 BG(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}a(BG,"isValidStatusCode");function jw(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}a(jw,"_isValidUTF8");function $G(e){return OG&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}a($G,"isBlob");fp.exports={isBlob:$G,isValidStatusCode:BG,isValidUTF8:jw,tokenChars:DG};if(sj)fp.exports.isValidUTF8=function(e){return e.length<24?jw(e):sj(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=Pe("utf-8-validate");fp.exports.isValidUTF8=function(t){return t.length<32?jw(t):e(t)}}catch{}});var $w=Te((zpe,mj)=>{"use strict";var{Writable:LG}=Pe("stream"),ij=Xs(),{BINARY_TYPES:NG,EMPTY_BUFFER:cj,kStatusCode:FG,kWebSocket:UG}=Or(),{concat:Hw,toArrayBuffer:qG,unmask:zG}=Oc(),{isValidStatusCode:WG,isValidUTF8:dj}=Qs(),gp=Buffer[Symbol.species],Sn=0,lj=1,uj=2,pj=3,Ow=4,Dw=5,hp=6,Bw=class extends LG{static{a(this,"Receiver")}constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||NG[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxBufferedChunks=t.maxBufferedChunks|0,this._maxFragments=t.maxFragments|0,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[UG]=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._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Sn}_write(t,n,r){if(this._opcode===8&&this._state==Sn)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(r)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new gp(r.buffer,r.byteOffset+t,r.length-t),new gp(r.buffer,r.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let r=this._buffers[0],o=n.length-t;t>=r.length?n.set(this._buffers.shift(),o):(n.set(new Uint8Array(r.buffer,r.byteOffset,t),o),this._buffers[0]=new gp(r.buffer,r.byteOffset+t,r.length-t)),t-=r.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case Sn:this.getInfo(t);break;case lj:this.getPayloadLength16(t);break;case uj:this.getPayloadLength64(t);break;case pj:this.getMask();break;case Ow:this.getData(t);break;case Dw:case hp:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(o);return}let r=(n[0]&64)===64;if(r&&!this._extensions[ij.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(o);return}if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(o);return}this._payloadLength===126?this._state=lj:this._payloadLength===127?this._state=uj:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(o);return}this._payloadLength=r*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=pj:this._state=Ow}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ow}getData(t){let n=cj;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&zG(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");t(r);return}if(this._compressed){this._state=Dw,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[ij.extensionName].decompress(t,this._fin,(o,s)=>{if(o)return n(o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(i);return}this._fragments.push(s)}this.dataMessage(n),this._state===Sn&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=Sn;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Hw(r,n):this._binaryType==="arraybuffer"?o=qG(Hw(r,n)):this._binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=Sn):(this._state=hp,setImmediate(()=>{this.emit("message",o,!0),this._state=Sn,this.startLoop(t)}))}else{let o=Hw(r,n);if(!this._skipUTF8Validation&&!dj(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._state===Dw||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=Sn):(this._state=hp,setImmediate(()=>{this.emit("message",o,!1),this._state=Sn,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,cj),this.end();else{let r=t.readUInt16BE(0);if(!WG(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(s);return}let o=new gp(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!dj(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=Sn;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Sn):(this._state=hp,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Sn,this.startLoop(n)}))}createError(t,n,r,o,s){this._loop=!1,this._errored=!0;let i=new t(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(i,this.createError),i.code=s,i[FG]=o,i}};mj.exports=Bw});var Fw=Te((Jpe,hj)=>{"use strict";var{Duplex:Vpe}=Pe("stream"),{randomFillSync:VG}=Pe("crypto"),{types:{isUint8Array:JG}}=Pe("util"),fj=Xs(),{EMPTY_BUFFER:GG,kWebSocket:KG,NOOP:YG}=Or(),{isBlob:Zs,isValidStatusCode:XG}=Qs(),{mask:gj,toBuffer:aa}=Oc(),In=Symbol("kByteLength"),QG=Buffer.alloc(4),wp=8*1024,sa,ei=wp,$n=0,ZG=1,e6=2,Lw=class e{static{a(this,"Sender")}constructor(t,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=$n,this.onerror=YG,this[KG]=void 0}static frame(t,n){let r,o=!1,s=2,i=!1;n.mask&&(r=n.maskBuffer||QG,n.generateMask?n.generateMask(r):(ei===wp&&(sa===void 0&&(sa=Buffer.alloc(wp)),VG(sa,0,wp),ei=0),r[0]=sa[ei++],r[1]=sa[ei++],r[2]=sa[ei++],r[3]=sa[ei++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof t=="string"?(!n.mask||i)&&n[In]!==void 0?c=n[In]:(t=Buffer.from(t),c=t.length):(c=t.length,o=n.mask&&n.readOnly&&!i);let d=c;c>=65536?(s+=8,d=127):c>125&&(s+=2,d=126);let l=Buffer.allocUnsafe(o?c+s:s);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(c,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(c,4,6)),n.mask?(l[1]|=128,l[s-4]=r[0],l[s-3]=r[1],l[s-2]=r[2],l[s-1]=r[3],i?[l,t]:o?(gj(t,r,l,s,c),[l]):(gj(t,r,t,0,c),[l,t])):[l,t]}close(t,n,r,o){let s;if(t===void 0)s=GG;else{if(typeof t!="number"||!XG(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0);else{let c=Buffer.byteLength(n);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");if(s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(t,0),typeof n=="string")s.write(n,2);else if(JG(n))s.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[In]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==$n?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(e.frame(s,i),o)}ping(t,n,r){let o,s;if(typeof t=="string"?(o=Buffer.byteLength(t),s=!1):Zs(t)?(o=t.size,s=!1):(t=aa(t),o=t.length,s=aa.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[In]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};Zs(t)?this._state!==$n?this.enqueue([this.getBlobData,t,!1,i,r]):this.getBlobData(t,!1,i,r):this._state!==$n?this.enqueue([this.dispatch,t,!1,i,r]):this.sendFrame(e.frame(t,i),r)}pong(t,n,r){let o,s;if(typeof t=="string"?(o=Buffer.byteLength(t),s=!1):Zs(t)?(o=t.size,s=!1):(t=aa(t),o=t.length,s=aa.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[In]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};Zs(t)?this._state!==$n?this.enqueue([this.getBlobData,t,!1,i,r]):this.getBlobData(t,!1,i,r):this._state!==$n?this.enqueue([this.dispatch,t,!1,i,r]):this.sendFrame(e.frame(t,i),r)}send(t,n,r){let o=this._extensions[fj.extensionName],s=n.binary?2:1,i=n.compress,c,d;typeof t=="string"?(c=Buffer.byteLength(t),d=!1):Zs(t)?(c=t.size,d=!1):(t=aa(t),c=t.length,d=aa.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=c>=o._threshold),this._compress=i):(i=!1,s=0),n.fin&&(this._firstFragment=!0);let l={[In]:c,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:d,rsv1:i};Zs(t)?this._state!==$n?this.enqueue([this.getBlobData,t,this._compress,l,r]):this.getBlobData(t,this._compress,l,r):this._state!==$n?this.enqueue([this.dispatch,t,this._compress,l,r]):this.dispatch(t,this._compress,l,r)}getBlobData(t,n,r,o){this._bufferedBytes+=r[In],this._state=e6,t.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(Nw,this,c,o);return}this._bufferedBytes-=r[In];let i=aa(s);n?this.dispatch(i,n,r,o):(this._state=$n,this.sendFrame(e.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(t6,this,s,o)})}dispatch(t,n,r,o){if(!n){this.sendFrame(e.frame(t,r),o);return}let s=this._extensions[fj.extensionName];this._bufferedBytes+=r[In],this._state=ZG,s.compress(t,r.fin,(i,c)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Nw(this,d,o);return}this._bufferedBytes-=r[In],this._state=$n,r.readOnly=!1,this.sendFrame(e.frame(c,r),o),this.dequeue()})}dequeue(){for(;this._state===$n&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][In],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][In],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};hj.exports=Lw;function Nw(e,t,n){typeof n=="function"&&n(t);for(let r=0;r<e._queue.length;r++){let o=e._queue[r],s=o[o.length-1];typeof s=="function"&&s(t)}}a(Nw,"callCallbacks");function t6(e,t,n){Nw(e,t,n),e.onerror(t)}a(t6,"onError")});var Pj=Te((Kpe,Rj)=>{"use strict";var{kForOnEventAttribute:Bc,kListener:Uw}=Or(),wj=Symbol("kCode"),yj=Symbol("kData"),vj=Symbol("kError"),kj=Symbol("kMessage"),bj=Symbol("kReason"),ti=Symbol("kTarget"),Sj=Symbol("kType"),Ij=Symbol("kWasClean"),Br=class{static{a(this,"Event")}constructor(t){this[ti]=null,this[Sj]=t}get target(){return this[ti]}get type(){return this[Sj]}};Object.defineProperty(Br.prototype,"target",{enumerable:!0});Object.defineProperty(Br.prototype,"type",{enumerable:!0});var ia=class extends Br{static{a(this,"CloseEvent")}constructor(t,n={}){super(t),this[wj]=n.code===void 0?0:n.code,this[bj]=n.reason===void 0?"":n.reason,this[Ij]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[wj]}get reason(){return this[bj]}get wasClean(){return this[Ij]}};Object.defineProperty(ia.prototype,"code",{enumerable:!0});Object.defineProperty(ia.prototype,"reason",{enumerable:!0});Object.defineProperty(ia.prototype,"wasClean",{enumerable:!0});var ni=class extends Br{static{a(this,"ErrorEvent")}constructor(t,n={}){super(t),this[vj]=n.error===void 0?null:n.error,this[kj]=n.message===void 0?"":n.message}get error(){return this[vj]}get message(){return this[kj]}};Object.defineProperty(ni.prototype,"error",{enumerable:!0});Object.defineProperty(ni.prototype,"message",{enumerable:!0});var $c=class extends Br{static{a(this,"MessageEvent")}constructor(t,n={}){super(t),this[yj]=n.data===void 0?null:n.data}get data(){return this[yj]}};Object.defineProperty($c.prototype,"data",{enumerable:!0});var n6={addEventListener(e,t,n={}){for(let o of this.listeners(e))if(!n[Bc]&&o[Uw]===t&&!o[Bc])return;let r;if(e==="message")r=a(function(s,i){let c=new $c("message",{data:i?s:s.toString()});c[ti]=this,yp(t,this,c)},"onMessage");else if(e==="close")r=a(function(s,i){let c=new ia("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[ti]=this,yp(t,this,c)},"onClose");else if(e==="error")r=a(function(s){let i=new ni("error",{error:s,message:s.message});i[ti]=this,yp(t,this,i)},"onError");else if(e==="open")r=a(function(){let s=new Br("open");s[ti]=this,yp(t,this,s)},"onOpen");else return;r[Bc]=!!n[Bc],r[Uw]=t,n.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[Uw]===t&&!n[Bc]){this.removeListener(e,n);break}}};Rj.exports={CloseEvent:ia,ErrorEvent:ni,Event:Br,EventTarget:n6,MessageEvent:$c};function yp(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}a(yp,"callListener")});var vp=Te((Xpe,_j)=>{"use strict";var{tokenChars:Lc}=Qs();function ur(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}a(ur,"push");function r6(e){let t=Object.create(null),n=Object.create(null),r=!1,o=!1,s=!1,i,c,d=-1,l=-1,u=-1,p=0;for(;p<e.length;p++)if(l=e.charCodeAt(p),i===void 0)if(u===-1&&Lc[l]===1)d===-1&&(d=p);else if(p!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=e.slice(d,u);l===44?(ur(t,f,n),n=Object.create(null)):i=f,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(c===void 0)if(u===-1&&Lc[l]===1)d===-1&&(d=p);else if(l===32||l===9)u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p),ur(n,e.slice(d,u),!0),l===44&&(ur(t,i,n),n=Object.create(null),i=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)c=e.slice(d,p),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o){if(Lc[l]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1?d=p:r||(r=!0),o=!1}else if(s)if(Lc[l]===1)d===-1&&(d=p);else if(l===34&&d!==-1)s=!1,u=p;else if(l===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===34&&e.charCodeAt(p-1)===61)s=!0;else if(u===-1&&Lc[l]===1)d===-1&&(d=p);else if(d!==-1&&(l===32||l===9))u===-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=e.slice(d,u);r&&(f=f.replace(/\\/g,""),r=!1),ur(n,c,f),l===44&&(ur(t,i,n),n=Object.create(null),i=void 0),c=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(d===-1||s||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=p);let m=e.slice(d,u);return i===void 0?ur(t,m,n):(c===void 0?ur(n,m,!0):r?ur(n,c,m.replace(/\\/g,"")):ur(n,c,m),ur(t,i,n)),t}a(r6,"parse");function o6(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(r=>[t].concat(Object.keys(r).map(o=>{let s=r[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}a(o6,"format");_j.exports={format:o6,parse:r6}});var Ip=Te((tme,$j)=>{"use strict";var a6=Pe("events"),s6=Pe("https"),i6=Pe("http"),Aj=Pe("net"),c6=Pe("tls"),{randomBytes:d6,createHash:l6}=Pe("crypto"),{Duplex:Zpe,Readable:eme}=Pe("stream"),{URL:qw}=Pe("url"),bo=Xs(),u6=$w(),p6=Fw(),{isBlob:m6}=Qs(),{BINARY_TYPES:xj,CLOSE_TIMEOUT:f6,EMPTY_BUFFER:kp,GUID:g6,kForOnEventAttribute:zw,kListener:h6,kStatusCode:w6,kWebSocket:dt,NOOP:Cj}=Or(),{EventTarget:{addEventListener:y6,removeEventListener:v6}}=Pj(),{format:k6,parse:b6}=vp(),{toBuffer:S6}=Oc(),Ej=Symbol("kAborted"),Ww=[8,13],$r=["CONNECTING","OPEN","CLOSING","CLOSED"],I6=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,qe=class e extends a6{static{a(this,"WebSocket")}constructor(t,n,r){super(),this._binaryType=xj[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=kp,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),Mj(this,t,n,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){xj.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}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(t,n,r){let o=new u6({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),s=new p6(t,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=t,o[dt]=this,s[dt]=this,t[dt]=this,o.on("conclude",_6),o.on("drain",x6),o.on("error",T6),o.on("message",A6),o.on("ping",C6),o.on("pong",E6),s.onerror=M6,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",Oj),t.on("data",Sp),t.on("end",Dj),t.on("error",Bj),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[bo.extensionName]&&this._extensions[bo.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){sn(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Hj(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Vw(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||kp,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Vw(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||kp,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Vw(this,t,r);return}let o={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[bo.extensionName]||(o.compress=!1),this._sender.send(t||kp,o,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){sn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(qe,"CONNECTING",{enumerable:!0,value:$r.indexOf("CONNECTING")});Object.defineProperty(qe.prototype,"CONNECTING",{enumerable:!0,value:$r.indexOf("CONNECTING")});Object.defineProperty(qe,"OPEN",{enumerable:!0,value:$r.indexOf("OPEN")});Object.defineProperty(qe.prototype,"OPEN",{enumerable:!0,value:$r.indexOf("OPEN")});Object.defineProperty(qe,"CLOSING",{enumerable:!0,value:$r.indexOf("CLOSING")});Object.defineProperty(qe.prototype,"CLOSING",{enumerable:!0,value:$r.indexOf("CLOSING")});Object.defineProperty(qe,"CLOSED",{enumerable:!0,value:$r.indexOf("CLOSED")});Object.defineProperty(qe.prototype,"CLOSED",{enumerable:!0,value:$r.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(qe.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(qe.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[zw])return t[h6];return null},set(t){for(let n of this.listeners(e))if(n[zw]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[zw]:!0})}})});qe.prototype.addEventListener=y6;qe.prototype.removeEventListener=v6;$j.exports=qe;function Mj(e,t,n,r){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:f6,protocolVersion:Ww[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!Ww.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Ww.join(", ")})`);let s;if(t instanceof qw)s=t;else try{s=new qw(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),e._url=s.href;let i=s.protocol==="wss:",c=s.protocol==="ws+unix:",d;if(s.protocol!=="ws:"&&!i&&!c?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!s.pathname?d="The URL's pathname is empty":s.hash&&(d="The URL contains a fragment identifier"),d){let h=new SyntaxError(d);if(e._redirects===0)throw h;bp(e,h);return}let l=i?443:80,u=d6(16).toString("base64"),p=i?s6.request:i6.request,m=new Set,f;if(o.createConnection=o.createConnection||(i?P6:R6),o.defaultPort=o.defaultPort||l,o.port=s.port||l,o.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(f=new bo({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=k6({[bo.extensionName]:f.offer()})),n.length){for(let h of n){if(typeof h!="string"||!I6.test(h)||m.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(h)}o.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),c){let h=o.path.split(":");o.socketPath=h[0],o.path=h[1]}let y;if(o.followRedirects){if(e._redirects===0){e._originalIpc=c,e._originalSecure=i,e._originalHostOrSocketPath=c?o.socketPath:s.host;let h=r&&r.headers;if(r={...r,headers:{}},h)for(let[v,g]of Object.entries(h))r.headers[v.toLowerCase()]=g}else if(e.listenerCount("redirect")===0){let h=c?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,h||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),y=e._req=p(o),e._redirects&&e.emit("redirect",e.url,y)}else y=e._req=p(o);o.timeout&&y.on("timeout",()=>{sn(e,y,"Opening handshake has timed out")}),y.on("error",h=>{y===null||y[Ej]||(y=e._req=null,bp(e,h))}),y.on("response",h=>{let v=h.headers.location,g=h.statusCode;if(v&&o.followRedirects&&g>=300&&g<400){if(++e._redirects>o.maxRedirects){sn(e,y,"Maximum redirects exceeded");return}y.abort();let I;try{I=new qw(v,t)}catch{let k=new SyntaxError(`Invalid URL: ${v}`);bp(e,k);return}Mj(e,I,n,r)}else e.emit("unexpected-response",y,h)||sn(e,y,`Unexpected server response: ${h.statusCode}`)}),y.on("upgrade",(h,v,g)=>{if(e.emit("upgrade",h),e.readyState!==qe.CONNECTING)return;y=e._req=null;let I=h.headers.upgrade;if(I===void 0||I.toLowerCase()!=="websocket"){sn(e,v,"Invalid Upgrade header");return}let R=l6("sha1").update(u+g6).digest("base64");if(h.headers["sec-websocket-accept"]!==R){sn(e,v,"Invalid Sec-WebSocket-Accept header");return}let k=h.headers["sec-websocket-protocol"],w;if(k!==void 0?m.size?m.has(k)||(w="Server sent an invalid subprotocol"):w="Server sent a subprotocol but none was requested":m.size&&(w="Server sent no subprotocol"),w){sn(e,v,w);return}k&&(e._protocol=k);let x=h.headers["sec-websocket-extensions"];if(x!==void 0){if(!f){sn(e,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=b6(x)}catch{sn(e,v,"Invalid Sec-WebSocket-Extensions header");return}let b=Object.keys(C);if(b.length!==1||b[0]!==bo.extensionName){sn(e,v,"Server indicated an extension that was not requested");return}try{f.accept(C[bo.extensionName])}catch{sn(e,v,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[bo.extensionName]=f}e.setSocket(v,g,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(y,e):y.end()}a(Mj,"initAsClient");function bp(e,t){e._readyState=qe.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}a(bp,"emitErrorAndClose");function R6(e){return e.path=e.socketPath,Aj.connect(e)}a(R6,"netConnect");function P6(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Aj.isIP(e.host)?"":e.host),c6.connect(e)}a(P6,"tlsConnect");function sn(e,t,n){e._readyState=qe.CLOSING;let r=new Error(n);Error.captureStackTrace(r,sn),t.setHeader?(t[Ej]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(bp,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}a(sn,"abortHandshake");function Vw(e,t,n){if(t){let r=m6(t)?t.size:S6(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${$r[e.readyState]})`);process.nextTick(n,r)}}a(Vw,"sendAfterClose");function _6(e,t){let n=this[dt];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[dt]!==void 0&&(n._socket.removeListener("data",Sp),process.nextTick(jj,n._socket),e===1005?n.close():n.close(e,t))}a(_6,"receiverOnConclude");function x6(){let e=this[dt];e.isPaused||e._socket.resume()}a(x6,"receiverOnDrain");function T6(e){let t=this[dt];t._socket[dt]!==void 0&&(t._socket.removeListener("data",Sp),process.nextTick(jj,t._socket),t.close(e[w6])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}a(T6,"receiverOnError");function Tj(){this[dt].emitClose()}a(Tj,"receiverOnFinish");function A6(e,t){this[dt].emit("message",e,t)}a(A6,"receiverOnMessage");function C6(e){let t=this[dt];t._autoPong&&t.pong(e,!this._isServer,Cj),t.emit("ping",e)}a(C6,"receiverOnPing");function E6(e){this[dt].emit("pong",e)}a(E6,"receiverOnPong");function jj(e){e.resume()}a(jj,"resume");function M6(e){let t=this[dt];t.readyState!==qe.CLOSED&&(t.readyState===qe.OPEN&&(t._readyState=qe.CLOSING,Hj(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}a(M6,"senderOnError");function Hj(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}a(Hj,"setCloseTimer");function Oj(){let e=this[dt];if(this.removeListener("close",Oj),this.removeListener("data",Sp),this.removeListener("end",Dj),e._readyState=qe.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[dt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Tj),e._receiver.on("finish",Tj))}a(Oj,"socketOnClose");function Sp(e){this[dt]._receiver.write(e)||this.pause()}a(Sp,"socketOnData");function Dj(){let e=this[dt];e._readyState=qe.CLOSING,e._receiver.end(),this.end()}a(Dj,"socketOnEnd");function Bj(){let e=this[dt];this.removeListener("error",Bj),this.on("error",Cj),e&&(e._readyState=qe.CLOSING,this.destroy())}a(Bj,"socketOnError")});var Uj=Te((ome,Fj)=>{"use strict";var rme=Ip(),{Duplex:j6}=Pe("stream");function Lj(e){e.emit("close")}a(Lj,"emitClose");function H6(){!this.destroyed&&this._writableState.finished&&this.destroy()}a(H6,"duplexOnEnd");function Nj(e){this.removeListener("error",Nj),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}a(Nj,"duplexOnError");function O6(e,t){let n=!0,r=new j6({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",a(function(s,i){let c=!i&&r._readableState.objectMode?s.toString():s;r.push(c)||e.pause()},"message")),e.once("error",a(function(s){r.destroyed||(n=!1,r.destroy(s))},"error")),e.once("close",a(function(){r.destroyed||r.push(null)},"close")),r._destroy=function(o,s){if(e.readyState===e.CLOSED){s(o),process.nextTick(Lj,r);return}let i=!1;e.once("error",a(function(d){i=!0,s(d)},"error")),e.once("close",a(function(){i||s(o),process.nextTick(Lj,r)},"close")),n&&e.terminate()},r._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",a(function(){r._final(o)},"open"));return}e._socket!==null&&(e._socket._writableState.finished?(o(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",a(function(){o()},"finish")),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(o,s,i){if(e.readyState===e.CONNECTING){e.once("open",a(function(){r._write(o,s,i)},"open"));return}e.send(o,i)},r.on("end",H6),r.on("error",Nj),r}a(O6,"createWebSocketStream");Fj.exports=O6});var Jw=Te((sme,qj)=>{"use strict";var{tokenChars:D6}=Qs();function B6(e){let t=new Set,n=-1,r=-1,o=0;for(o;o<e.length;o++){let i=e.charCodeAt(o);if(r===-1&&D6[i]===1)n===-1&&(n=o);else if(o!==0&&(i===32||i===9))r===-1&&n!==-1&&(r=o);else if(i===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${o}`);r===-1&&(r=o);let c=e.slice(n,r);if(t.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);t.add(c),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=e.slice(n,o);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return t.add(s),t}a(B6,"parse");qj.exports={parse:B6}});var Yj=Te((dme,Kj)=>{"use strict";var $6=Pe("events"),Rp=Pe("http"),{Duplex:cme}=Pe("stream"),{createHash:L6}=Pe("crypto"),zj=vp(),ca=Xs(),N6=Jw(),F6=Ip(),{CLOSE_TIMEOUT:U6,GUID:q6,kWebSocket:z6}=Or(),W6=/^[+/0-9A-Za-z]{22}==$/,Wj=0,Vj=1,Gj=2,Gw=class extends $6{static{a(this,"WebSocketServer")}constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:U6,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:F6,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=Rp.createServer((r,o)=>{let s=Rp.STATUS_CODES[426];o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=V6(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:a((o,s,i)=>{this.handleUpgrade(o,s,i,r)},"upgrade")})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=Wj}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===Gj){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(Nc,this);return}if(t&&this.once("close",t),this._state!==Vj)if(this._state=Vj,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(Nc,this):process.nextTick(Nc,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{Nc(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,r,o){n.on("error",Jj);let s=t.headers["sec-websocket-key"],i=t.headers.upgrade,c=+t.headers["sec-websocket-version"];if(t.method!=="GET"){da(this,t,n,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){da(this,t,n,400,"Invalid Upgrade header");return}if(s===void 0||!W6.test(s)){da(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){da(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Fc(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=N6.parse(d)}catch{da(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&u!==void 0){let m=new ca({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let f=zj.parse(u);f[ca.extensionName]&&(m.accept(f[ca.extensionName]),p[ca.extensionName]=m)}catch{da(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:t.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(f,y,h,v)=>{if(!f)return Fc(n,y||401,h,v);this.completeUpgrade(p,s,l,t,n,r,o)});return}if(!this.options.verifyClient(m))return Fc(n,401)}this.completeUpgrade(p,s,l,t,n,r,o)}completeUpgrade(t,n,r,o,s,i,c){if(!s.readable||!s.writable)return s.destroy();if(s[z6])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Wj)return Fc(s,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${L6("sha1").update(n+q6).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,o):r.values().next().value;p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),u._protocol=p)}if(t[ca.extensionName]){let p=t[ca.extensionName].params,m=zj.format({[ca.extensionName]:[p]});l.push(`Sec-WebSocket-Extensions: ${m}`),u._extensions=t}this.emit("headers",l,o),s.write(l.concat(`\r
3
+ import{a as HA,b as OA,c as DA,d as j,e as BA,f as so,g as z,h as vu,j as $A}from"./chunk-ZO7DTED5.js";import{$ as Cx,$a as pu,$b as rA,A as nu,Aa as Xx,Ab as LT,Ac as SA,B as Y_,Ba as du,Bb as NT,Bc as IA,C as X_,Ca as Qx,Cb as FT,Cc as RA,D as Q_,Da as ro,Db as UT,Dc as PA,E as ru,Ea as Ae,Eb as qT,Ec as _A,F as Z_,Fa as Zx,Fb as zT,Fc as xA,G as ex,Ga as pe,Gb as WT,Gc as TA,H as tx,Ha as eT,Hb as VT,Hc as AA,I as nx,Ia as tT,Ib as fu,Ic as CA,J as rx,Ja as nT,Jb as JT,Jc as EA,K as dc,Ka as rT,Kb as Yo,Kc as MA,L as wx,La as oT,Lb as gu,M as yx,Ma as aT,Mb as GT,Mc as jA,N as vx,Na as sT,Nb as oo,O as kx,Oa as iT,Ob as hu,P as bx,Pa as cT,Pb as KT,Q as lc,Qa as dT,Qb as YT,R as Sx,Ra as lT,Rb as Zg,S as Ix,Sa as vs,Sb as eh,T as hs,Ta as jn,Tb as XT,U as ws,Ua as je,Ub as QT,V as Rx,Va as uT,Vb as ZT,W as Px,Wa as pT,Wb as eA,X as _x,Xa as mT,Xb as th,Y as xx,Ya as fT,Yb as tA,Z as Tx,Za as wT,Zb as nh,_ as Ax,_a as yT,_b as nA,a as gg,aa as no,ab as vT,ac as oA,b as Yb,ba as Ex,bb as kT,bc as aA,c as Xb,ca as Mx,cb as bT,cc as sA,d as Qb,da as Yg,db as ST,dc as iA,e as Zb,ea as jx,eb as IT,ec as cA,f as eS,fa as Hx,fb as Qg,fc as dA,g as tS,ga as Ox,gb as RT,gc as lA,h as Do,ha as ys,hb as PT,hc as uA,i as nS,ia as Dx,ib as _T,ic as rh,j as rS,ja as Bx,jb as xT,jc as pA,k as al,ka as $x,kb as TT,kc as oh,l as oS,la as Lx,lb as AT,lc as mA,m as aS,ma as Nx,mb as CT,mc as fA,n as E2,na as Fx,nb as Hn,nc as gA,o as P_,oa as iu,ob as ET,oc as hA,p as __,pa as Ux,pb as mu,pc as wA,q as x_,qa as qx,qb as MT,qc as ao,r as T_,ra as ae,rb as jT,rc as Pr,s as H_,sa as zx,sb as $t,sc as ah,t as eu,ta as Wx,tb as Ko,tc as yA,u as W_,ua as Vx,ub as HT,uc as vA,v as V_,va as cu,vb as Rr,vc as wu,w as J_,wa as Jx,wb as OT,wc as ks,x as tu,xa as Gx,xb as DT,xc as kA,y as G_,ya as Kx,yb as BT,yc as yu,z as K_,za as Yx,zb as $T,zc as bA}from"./chunk-RJACNWYJ.js";import{a as at,b as A_,c as C_,d as j_,f as Xg,g as gT,h as lu,i as uu,j as hT}from"./chunk-FVALIUVY.js";import{a as nn,b as O_,c as D_,d as Ql,e as Zl,g as B_,h as $_,j as L_,k as N_,l as F_,m as U_,n as q_,o as z_}from"./chunk-25OT6IYM.js";import{e as M_,f as Yl,g as Xl,h as ms}from"./chunk-R6DWG5A4.js";import{$ as k_,M as Gl,P as h_,S as w_,T as y_,U as ps,V as Kl,W as ic,Y as Wg,Z as Go,_ as v_,a as Ab,aa as b_,b as Cb,ba as S_,c as Eb,e as Mb,f as jb,fa as I_,g as nl,h as qb,i as zb,j as Wb,k as Vb,ka as R_,l as Jb,r as l_,s as u_,t as p_,u as m_,v as f_,w as Jl,x as g_}from"./chunk-L6ELXODL.js";import{d as E_}from"./chunk-PKBU37CH.js";import{A as lx,C as au,F as su,G as sr,H as ux,I as Vg,J as px,K as Jg,N as mx,O as Gg,P as fx,Q as gx,R as hx,S as Kg,T as gs,b as ou,d as ox,e as ax,h as sx,m as fs,n as ix,p as cx,q as dx,s as cc}from"./chunk-DHP75QSG.js";import{a as c_,b as Vl,d as ie,e as ot,f as us,g as ne,i as d_}from"./chunk-6GLGOIMQ.js";import{A as QP,B as Wl,C as ZP,D as zg,E as e_,F as t_,G as Qe,H as n_,I as gt,J as sc,K as r_,L as o_,N as a_,P as s_,Q as i_,R as Mn,c as LP,l as NP,m as FP,n as UP,q as qP,r as zP,s as WP,t as VP,u as JP,v as qg,w as GP,x as KP,y as YP,z as XP}from"./chunk-XHJUP7M4.js";import{f as SP}from"./chunk-7BGT6Q2D.js";import{$ as TI,$a as sR,$b as FR,$c as cP,Aa as XI,Ab as TR,Ba as Pg,Bb as AR,Ca as Pl,Cb as CR,Da as QI,Ea as rr,Eb as Al,F as vI,Fa as _l,Fb as HR,Ga as _g,H as kI,Ha as xl,Hb as OR,I as Ig,Ib as nc,Ja as xg,Jb as Og,K as Ue,Ka as Zi,L as Sl,M as bI,Ma as ZI,Mb as Cl,Mc as Uo,N as Rg,Nc as tP,Ob as Dg,Oc as Ir,P as SI,Pa as eR,Pb as DR,Pc as nP,Qa as tR,Qb as BR,Qc as rP,Ra as nR,Rc as oP,Sc as Zr,T as II,Ta as ns,Tb as El,Tc as cs,Ua as rR,Ub as $R,Uc as Ol,V as Il,Vb as Bg,Vc as aP,W as RI,Wa as ec,Wb as or,Wc as sP,Xa as Tl,Xb as LR,Xc as iP,Y as PI,Ya as oR,Yb as NR,Yc as oc,Z as _I,Za as Tg,Zb as $g,Zc as ds,_ as xI,_a as aR,_b as rc,_c as Dl,aa as AI,ab as Ag,ac as Ml,ad as Bl,ba as CI,bb as iR,bc as UR,bd as eo,ca as EI,cb as cR,cc as qR,cd as dP,d as tI,da as MI,db as dR,dc as as,dd as lP,ea as jI,eb as lR,ec as zR,ed as uP,f as vl,fa as Qr,fb as uR,fc as ss,fd as $l,gb as pR,gc as WR,gd as pP,h as aI,ha as HI,hb as mR,hc as VR,hd as ac,ia as OI,ib as Cg,ic as Lg,id as mP,ja as DI,jb as fR,jc as jl,jd as fP,k as bg,ka as BI,kb as gR,kc as JR,l as iI,lb as hR,lc as De,m as Bt,ma as $I,mb as wR,mc as Hl,n as Lo,na as Rl,nb as Eg,nc as GR,o as No,oa as LI,ob as yR,oc as KR,p as Sg,pa as NI,pb as vR,pc as YR,q as cI,qa as FI,qb as kR,qc as Ng,r as dI,ra as UI,rb as bR,rc as XR,s as lI,sa as qI,sb as SR,sc as QR,sd as Ll,t as uI,ta as zI,tb as IR,tc as ZR,td as gP,u as pI,ua as WI,ub as RR,ud as hP,v as mI,va as VI,vb as PR,vc as is,vd as ar,w as kl,wa as JI,wb as _R,wc as eP,wd as wP,xa as GI,xb as xR,xd as qo,y as bl,ya as KI,yb as Mg,yd as yP,za as YI,zb as Fo}from"./chunk-SBBXUZWL.js";import{b as BP,c as $P}from"./chunk-L3KS6MOV.js";import{a as vP,h as kP,k as bP}from"./chunk-SHCRE7B2.js";import"./chunk-XEOEKFG6.js";import{N as os,O as tc,P as ER,Q as MR,R as jR,T as jg,V as Hg,f as zS,j as WS,k as VS,l as nI,m as rI,n as gn,o as wl,r as $o,s as Qi,t as kg,u as yl,v as oI,z as sI}from"./chunk-MRGA6BKG.js";import"./chunk-6MI4KKWF.js";import{A as fg,B as Qa,Bb as ES,Ca as fS,Db as MS,Ea as gS,Fa as hS,Lb as En,Mb as jS,Na as wS,Nb as ll,Ob as tn,Qa as yS,Qb as ul,R as rl,U as Gb,Va as vS,Za as kS,_b as HS,a as ug,aa as ol,ab as bS,ac as OS,bb as cl,bc as es,ca as Kb,cc as DS,da as sS,dc as BS,e as Hb,ea as sl,ec as pl,fc as ml,gc as fl,ha as hg,hc as $S,ia as iS,ib as SS,ic as yg,j as Ob,ja as cS,jb as IS,jc as LS,ka as dS,kb as RS,l as pg,la as il,lb as PS,lc as NS,m as Tt,ma as lS,mb as _S,mc as FS,n as mg,na as uS,nb as dl,nc as US,o as fn,oa as pS,ob as wg,oc as Yr,pa as mS,pb as xS,pc as qS,qb as TS,qc as nr,rb as AS,s as Db,v as Ki,vc as rs,w as Bb,wb as CS,x as el,yb as Za,z as $b}from"./chunk-WCZRDULE.js";import"./chunk-RELOOVWW.js";import{D as Xa,E as Gi,F as Zd,d as Qd,m as xb,n as Kr,o as We,p as Tb}from"./chunk-GIPSOLAY.js";import"./chunk-MJC26GOX.js";import{Ka as Lb,La as Nb,Ma as tr,Pa as Fb,Qa as tl,Ra as Ub,a as en,fa as Ve,ga as zt,ma as Rb,s as Xd,va as Pb,xa as _b}from"./chunk-JUX77H6K.js";import{Da as C2,Ea as Sb,Fa as dg,Ga as lg,Ia as Ib,R as Kd,pa as vb,qa as Yd,sa as kb,wa as bb}from"./chunk-QUNRWDVO.js";import{a as Xi}from"./chunk-6FA3GG5B.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{$ as Fl,$a as Jo,Ca as EP,D as fI,Ea as Fg,Fa as Ug,Ga as MP,H as Xr,J as gI,L as hI,M as wI,N as yI,Ta as ql,Ua as jP,Ya as HP,Za as OP,a as Bo,ab as DP,b as JS,bb as zl,c as Yi,d as Sr,e as gl,f as GS,g as hl,h as KS,i as ts,k as YS,l as XS,m as QS,n as ZS,o as eI,pa as to,ra as Wo,v as vg,wa as _P,xa as xP,ya as AP,za as CP}from"./chunk-QK2GLRCY.js";import{a as Ka,b as Ya,c as ig,d as Vd,e as rt,f as cg,g as Jd,j as ze,k as Se,l as O,m as wb,o as yb,p as Gd,q as xt}from"./chunk-HZP5U2AA.js";import{a as Oo,b as T}from"./chunk-ES2ISFJC.js";import{a as IP,c as zo,f as RP,h as Nl,i as PP,p as ls,q as TP,r as Vo,s as Ul}from"./chunk-H7IWJN7L.js";import{a,b as Pe,c as Te,e as Cn}from"./chunk-FTQLQJQV.js";var Or=Te((Hpe,Y0)=>{"use strict";var G0=["nodebuffer","arraybuffer","fragments"],K0=typeof Blob<"u";K0&&G0.push("blob");Y0.exports={BINARY_TYPES:G0,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:K0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:a(()=>{},"NOOP")}});var Oc=Te((Dpe,up)=>{"use strict";var{EMPTY_BUFFER:xG}=Or(),Tw=Buffer[Symbol.species];function TG(e,t){if(e.length===0)return xG;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];n.set(s,r),r+=s.length}return r<t?new Tw(n.buffer,n.byteOffset,r):n}a(TG,"concat");function X0(e,t,n,r,o){for(let s=0;s<o;s++)n[r+s]=e[s]^t[s&3]}a(X0,"_mask");function Q0(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}a(Q0,"_unmask");function AG(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}a(AG,"toArrayBuffer");function Aw(e){if(Aw.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new Tw(e):ArrayBuffer.isView(e)?t=new Tw(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Aw.readOnly=!1),t}a(Aw,"toBuffer");up.exports={concat:TG,mask:X0,toArrayBuffer:AG,toBuffer:Aw,unmask:Q0};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=Pe("bufferutil");up.exports.mask=function(t,n,r,o,s){s<48?X0(t,n,r,o,s):e.mask(t,n,r,o,s)},up.exports.unmask=function(t,n){t.length<32?Q0(t,n):e.unmask(t,n)}}catch{}});var tj=Te(($pe,ej)=>{"use strict";var Z0=Symbol("kDone"),Cw=Symbol("kRun"),Ew=class{static{a(this,"Limiter")}constructor(t){this[Z0]=()=>{this.pending--,this[Cw]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[Cw]()}[Cw](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[Z0])}}};ej.exports=Ew});var Xs=Te((Npe,aj)=>{"use strict";var Dc=Pe("zlib"),nj=Oc(),CG=tj(),{kStatusCode:rj}=Or(),EG=Buffer[Symbol.species],MG=Buffer.from([0,0,255,255]),mp=Symbol("permessage-deflate"),Dr=Symbol("total-length"),Ks=Symbol("callback"),ko=Symbol("buffers"),Ys=Symbol("error"),pp,Mw=class{static{a(this,"PerMessageDeflate")}constructor(t){if(this._options=t||{},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,!pp){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;pp=new CG(n)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[Ks];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,r=t.find(o=>!(n.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>o.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(r=>{let o=n[r];if(o.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else if(r==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else throw new Error(`Unknown parameter "${r}"`);n[r]=o})}),t}decompress(t,n,r){pp.add(o=>{this._decompress(t,n,(s,i)=>{o(),r(s,i)})})}compress(t,n,r){pp.add(o=>{this._compress(t,n,(s,i)=>{o(),r(s,i)})})}_decompress(t,n,r){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?Dc.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=Dc.createInflateRaw({...this._options.zlibInflateOptions,windowBits:i}),this._inflate[mp]=this,this._inflate[Dr]=0,this._inflate[ko]=[],this._inflate.on("error",HG),this._inflate.on("data",oj)}this._inflate[Ks]=r,this._inflate.write(t),n&&this._inflate.write(MG),this._inflate.flush(()=>{let s=this._inflate[Ys];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=nj.concat(this._inflate[ko],this._inflate[Dr]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Dr]=0,this._inflate[ko]=[],n&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(t,n,r){let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?Dc.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=Dc.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),this._deflate[Dr]=0,this._deflate[ko]=[],this._deflate.on("data",jG)}this._deflate[Ks]=r,this._deflate.write(t),this._deflate.flush(Dc.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=nj.concat(this._deflate[ko],this._deflate[Dr]);n&&(s=new EG(s.buffer,s.byteOffset,s.length-4)),this._deflate[Ks]=null,this._deflate[Dr]=0,this._deflate[ko]=[],n&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};aj.exports=Mw;function jG(e){this[ko].push(e),this[Dr]+=e.length}a(jG,"deflateOnData");function oj(e){if(this[Dr]+=e.length,this[mp]._maxPayload<1||this[Dr]<=this[mp]._maxPayload){this[ko].push(e);return}this[Ys]=new RangeError("Max payload size exceeded"),this[Ys].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ys][rj]=1009,this.removeListener("data",oj),this.reset()}a(oj,"inflateOnData");function HG(e){if(this[mp]._inflate=null,this[Ys]){this[Ks](this[Ys]);return}e[rj]=1007,this[Ks](e)}a(HG,"inflateOnError")});var Qs=Te((Upe,fp)=>{"use strict";var{isUtf8:sj}=Pe("buffer"),{hasBlob:OG}=Or(),DG=[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 BG(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}a(BG,"isValidStatusCode");function jw(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}a(jw,"_isValidUTF8");function $G(e){return OG&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}a($G,"isBlob");fp.exports={isBlob:$G,isValidStatusCode:BG,isValidUTF8:jw,tokenChars:DG};if(sj)fp.exports.isValidUTF8=function(e){return e.length<24?jw(e):sj(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=Pe("utf-8-validate");fp.exports.isValidUTF8=function(t){return t.length<32?jw(t):e(t)}}catch{}});var $w=Te((zpe,mj)=>{"use strict";var{Writable:LG}=Pe("stream"),ij=Xs(),{BINARY_TYPES:NG,EMPTY_BUFFER:cj,kStatusCode:FG,kWebSocket:UG}=Or(),{concat:Hw,toArrayBuffer:qG,unmask:zG}=Oc(),{isValidStatusCode:WG,isValidUTF8:dj}=Qs(),gp=Buffer[Symbol.species],Sn=0,lj=1,uj=2,pj=3,Ow=4,Dw=5,hp=6,Bw=class extends LG{static{a(this,"Receiver")}constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||NG[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxBufferedChunks=t.maxBufferedChunks|0,this._maxFragments=t.maxFragments|0,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[UG]=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._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Sn}_write(t,n,r){if(this._opcode===8&&this._state==Sn)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(r)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new gp(r.buffer,r.byteOffset+t,r.length-t),new gp(r.buffer,r.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let r=this._buffers[0],o=n.length-t;t>=r.length?n.set(this._buffers.shift(),o):(n.set(new Uint8Array(r.buffer,r.byteOffset,t),o),this._buffers[0]=new gp(r.buffer,r.byteOffset+t,r.length-t)),t-=r.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case Sn:this.getInfo(t);break;case lj:this.getPayloadLength16(t);break;case uj:this.getPayloadLength64(t);break;case pj:this.getMask();break;case Ow:this.getData(t);break;case Dw:case hp:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(o);return}let r=(n[0]&64)===64;if(r&&!this._extensions[ij.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(o);return}if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(o);return}this._payloadLength===126?this._state=lj:this._payloadLength===127?this._state=uj:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(o);return}this._payloadLength=r*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=pj:this._state=Ow}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ow}getData(t){let n=cj;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&zG(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");t(r);return}if(this._compressed){this._state=Dw,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[ij.extensionName].decompress(t,this._fin,(o,s)=>{if(o)return n(o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(i);return}this._fragments.push(s)}this.dataMessage(n),this._state===Sn&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=Sn;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Hw(r,n):this._binaryType==="arraybuffer"?o=qG(Hw(r,n)):this._binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=Sn):(this._state=hp,setImmediate(()=>{this.emit("message",o,!0),this._state=Sn,this.startLoop(t)}))}else{let o=Hw(r,n);if(!this._skipUTF8Validation&&!dj(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._state===Dw||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=Sn):(this._state=hp,setImmediate(()=>{this.emit("message",o,!1),this._state=Sn,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,cj),this.end();else{let r=t.readUInt16BE(0);if(!WG(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(s);return}let o=new gp(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!dj(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=Sn;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Sn):(this._state=hp,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Sn,this.startLoop(n)}))}createError(t,n,r,o,s){this._loop=!1,this._errored=!0;let i=new t(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(i,this.createError),i.code=s,i[FG]=o,i}};mj.exports=Bw});var Fw=Te((Jpe,hj)=>{"use strict";var{Duplex:Vpe}=Pe("stream"),{randomFillSync:VG}=Pe("crypto"),{types:{isUint8Array:JG}}=Pe("util"),fj=Xs(),{EMPTY_BUFFER:GG,kWebSocket:KG,NOOP:YG}=Or(),{isBlob:Zs,isValidStatusCode:XG}=Qs(),{mask:gj,toBuffer:aa}=Oc(),In=Symbol("kByteLength"),QG=Buffer.alloc(4),wp=8*1024,sa,ei=wp,$n=0,ZG=1,e6=2,Lw=class e{static{a(this,"Sender")}constructor(t,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=$n,this.onerror=YG,this[KG]=void 0}static frame(t,n){let r,o=!1,s=2,i=!1;n.mask&&(r=n.maskBuffer||QG,n.generateMask?n.generateMask(r):(ei===wp&&(sa===void 0&&(sa=Buffer.alloc(wp)),VG(sa,0,wp),ei=0),r[0]=sa[ei++],r[1]=sa[ei++],r[2]=sa[ei++],r[3]=sa[ei++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let c;typeof t=="string"?(!n.mask||i)&&n[In]!==void 0?c=n[In]:(t=Buffer.from(t),c=t.length):(c=t.length,o=n.mask&&n.readOnly&&!i);let d=c;c>=65536?(s+=8,d=127):c>125&&(s+=2,d=126);let l=Buffer.allocUnsafe(o?c+s:s);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(c,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(c,4,6)),n.mask?(l[1]|=128,l[s-4]=r[0],l[s-3]=r[1],l[s-2]=r[2],l[s-1]=r[3],i?[l,t]:o?(gj(t,r,l,s,c),[l]):(gj(t,r,t,0,c),[l,t])):[l,t]}close(t,n,r,o){let s;if(t===void 0)s=GG;else{if(typeof t!="number"||!XG(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0);else{let c=Buffer.byteLength(n);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");if(s=Buffer.allocUnsafe(2+c),s.writeUInt16BE(t,0),typeof n=="string")s.write(n,2);else if(JG(n))s.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[In]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==$n?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(e.frame(s,i),o)}ping(t,n,r){let o,s;if(typeof t=="string"?(o=Buffer.byteLength(t),s=!1):Zs(t)?(o=t.size,s=!1):(t=aa(t),o=t.length,s=aa.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[In]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};Zs(t)?this._state!==$n?this.enqueue([this.getBlobData,t,!1,i,r]):this.getBlobData(t,!1,i,r):this._state!==$n?this.enqueue([this.dispatch,t,!1,i,r]):this.sendFrame(e.frame(t,i),r)}pong(t,n,r){let o,s;if(typeof t=="string"?(o=Buffer.byteLength(t),s=!1):Zs(t)?(o=t.size,s=!1):(t=aa(t),o=t.length,s=aa.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[In]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};Zs(t)?this._state!==$n?this.enqueue([this.getBlobData,t,!1,i,r]):this.getBlobData(t,!1,i,r):this._state!==$n?this.enqueue([this.dispatch,t,!1,i,r]):this.sendFrame(e.frame(t,i),r)}send(t,n,r){let o=this._extensions[fj.extensionName],s=n.binary?2:1,i=n.compress,c,d;typeof t=="string"?(c=Buffer.byteLength(t),d=!1):Zs(t)?(c=t.size,d=!1):(t=aa(t),c=t.length,d=aa.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=c>=o._threshold),this._compress=i):(i=!1,s=0),n.fin&&(this._firstFragment=!0);let l={[In]:c,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:d,rsv1:i};Zs(t)?this._state!==$n?this.enqueue([this.getBlobData,t,this._compress,l,r]):this.getBlobData(t,this._compress,l,r):this._state!==$n?this.enqueue([this.dispatch,t,this._compress,l,r]):this.dispatch(t,this._compress,l,r)}getBlobData(t,n,r,o){this._bufferedBytes+=r[In],this._state=e6,t.arrayBuffer().then(s=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(Nw,this,c,o);return}this._bufferedBytes-=r[In];let i=aa(s);n?this.dispatch(i,n,r,o):(this._state=$n,this.sendFrame(e.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(t6,this,s,o)})}dispatch(t,n,r,o){if(!n){this.sendFrame(e.frame(t,r),o);return}let s=this._extensions[fj.extensionName];this._bufferedBytes+=r[In],this._state=ZG,s.compress(t,r.fin,(i,c)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Nw(this,d,o);return}this._bufferedBytes-=r[In],this._state=$n,r.readOnly=!1,this.sendFrame(e.frame(c,r),o),this.dequeue()})}dequeue(){for(;this._state===$n&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][In],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][In],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};hj.exports=Lw;function Nw(e,t,n){typeof n=="function"&&n(t);for(let r=0;r<e._queue.length;r++){let o=e._queue[r],s=o[o.length-1];typeof s=="function"&&s(t)}}a(Nw,"callCallbacks");function t6(e,t,n){Nw(e,t,n),e.onerror(t)}a(t6,"onError")});var Pj=Te((Kpe,Rj)=>{"use strict";var{kForOnEventAttribute:Bc,kListener:Uw}=Or(),wj=Symbol("kCode"),yj=Symbol("kData"),vj=Symbol("kError"),kj=Symbol("kMessage"),bj=Symbol("kReason"),ti=Symbol("kTarget"),Sj=Symbol("kType"),Ij=Symbol("kWasClean"),Br=class{static{a(this,"Event")}constructor(t){this[ti]=null,this[Sj]=t}get target(){return this[ti]}get type(){return this[Sj]}};Object.defineProperty(Br.prototype,"target",{enumerable:!0});Object.defineProperty(Br.prototype,"type",{enumerable:!0});var ia=class extends Br{static{a(this,"CloseEvent")}constructor(t,n={}){super(t),this[wj]=n.code===void 0?0:n.code,this[bj]=n.reason===void 0?"":n.reason,this[Ij]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[wj]}get reason(){return this[bj]}get wasClean(){return this[Ij]}};Object.defineProperty(ia.prototype,"code",{enumerable:!0});Object.defineProperty(ia.prototype,"reason",{enumerable:!0});Object.defineProperty(ia.prototype,"wasClean",{enumerable:!0});var ni=class extends Br{static{a(this,"ErrorEvent")}constructor(t,n={}){super(t),this[vj]=n.error===void 0?null:n.error,this[kj]=n.message===void 0?"":n.message}get error(){return this[vj]}get message(){return this[kj]}};Object.defineProperty(ni.prototype,"error",{enumerable:!0});Object.defineProperty(ni.prototype,"message",{enumerable:!0});var $c=class extends Br{static{a(this,"MessageEvent")}constructor(t,n={}){super(t),this[yj]=n.data===void 0?null:n.data}get data(){return this[yj]}};Object.defineProperty($c.prototype,"data",{enumerable:!0});var n6={addEventListener(e,t,n={}){for(let o of this.listeners(e))if(!n[Bc]&&o[Uw]===t&&!o[Bc])return;let r;if(e==="message")r=a(function(s,i){let c=new $c("message",{data:i?s:s.toString()});c[ti]=this,yp(t,this,c)},"onMessage");else if(e==="close")r=a(function(s,i){let c=new ia("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[ti]=this,yp(t,this,c)},"onClose");else if(e==="error")r=a(function(s){let i=new ni("error",{error:s,message:s.message});i[ti]=this,yp(t,this,i)},"onError");else if(e==="open")r=a(function(){let s=new Br("open");s[ti]=this,yp(t,this,s)},"onOpen");else return;r[Bc]=!!n[Bc],r[Uw]=t,n.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[Uw]===t&&!n[Bc]){this.removeListener(e,n);break}}};Rj.exports={CloseEvent:ia,ErrorEvent:ni,Event:Br,EventTarget:n6,MessageEvent:$c};function yp(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}a(yp,"callListener")});var vp=Te((Xpe,_j)=>{"use strict";var{tokenChars:Lc}=Qs();function ur(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}a(ur,"push");function r6(e){let t=Object.create(null),n=Object.create(null),r=!1,o=!1,s=!1,i,c,d=-1,l=-1,u=-1,p=0;for(;p<e.length;p++)if(l=e.charCodeAt(p),i===void 0)if(u===-1&&Lc[l]===1)d===-1&&(d=p);else if(p!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=e.slice(d,u);l===44?(ur(t,f,n),n=Object.create(null)):i=f,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(c===void 0)if(u===-1&&Lc[l]===1)d===-1&&(d=p);else if(l===32||l===9)u===-1&&d!==-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p),ur(n,e.slice(d,u),!0),l===44&&(ur(t,i,n),n=Object.create(null),i=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)c=e.slice(d,p),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o){if(Lc[l]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);d===-1?d=p:r||(r=!0),o=!1}else if(s)if(Lc[l]===1)d===-1&&(d=p);else if(l===34&&d!==-1)s=!1,u=p;else if(l===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(l===34&&e.charCodeAt(p-1)===61)s=!0;else if(u===-1&&Lc[l]===1)d===-1&&(d=p);else if(d!==-1&&(l===32||l===9))u===-1&&(u=p);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${p}`);u===-1&&(u=p);let f=e.slice(d,u);r&&(f=f.replace(/\\/g,""),r=!1),ur(n,c,f),l===44&&(ur(t,i,n),n=Object.create(null),i=void 0),c=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(d===-1||s||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=p);let m=e.slice(d,u);return i===void 0?ur(t,m,n):(c===void 0?ur(n,m,!0):r?ur(n,c,m.replace(/\\/g,"")):ur(n,c,m),ur(t,i,n)),t}a(r6,"parse");function o6(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(r=>[t].concat(Object.keys(r).map(o=>{let s=r[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}a(o6,"format");_j.exports={format:o6,parse:r6}});var Ip=Te((tme,$j)=>{"use strict";var a6=Pe("events"),s6=Pe("https"),i6=Pe("http"),Aj=Pe("net"),c6=Pe("tls"),{randomBytes:d6,createHash:l6}=Pe("crypto"),{Duplex:Zpe,Readable:eme}=Pe("stream"),{URL:qw}=Pe("url"),bo=Xs(),u6=$w(),p6=Fw(),{isBlob:m6}=Qs(),{BINARY_TYPES:xj,CLOSE_TIMEOUT:f6,EMPTY_BUFFER:kp,GUID:g6,kForOnEventAttribute:zw,kListener:h6,kStatusCode:w6,kWebSocket:dt,NOOP:Cj}=Or(),{EventTarget:{addEventListener:y6,removeEventListener:v6}}=Pj(),{format:k6,parse:b6}=vp(),{toBuffer:S6}=Oc(),Ej=Symbol("kAborted"),Ww=[8,13],$r=["CONNECTING","OPEN","CLOSING","CLOSED"],I6=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,qe=class e extends a6{static{a(this,"WebSocket")}constructor(t,n,r){super(),this._binaryType=xj[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=kp,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),Mj(this,t,n,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){xj.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}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(t,n,r){let o=new u6({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),s=new p6(t,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=t,o[dt]=this,s[dt]=this,t[dt]=this,o.on("conclude",_6),o.on("drain",x6),o.on("error",T6),o.on("message",A6),o.on("ping",C6),o.on("pong",E6),s.onerror=M6,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",Oj),t.on("data",Sp),t.on("end",Dj),t.on("error",Bj),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[bo.extensionName]&&this._extensions[bo.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){sn(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Hj(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Vw(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||kp,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Vw(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||kp,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Vw(this,t,r);return}let o={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[bo.extensionName]||(o.compress=!1),this._sender.send(t||kp,o,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){sn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(qe,"CONNECTING",{enumerable:!0,value:$r.indexOf("CONNECTING")});Object.defineProperty(qe.prototype,"CONNECTING",{enumerable:!0,value:$r.indexOf("CONNECTING")});Object.defineProperty(qe,"OPEN",{enumerable:!0,value:$r.indexOf("OPEN")});Object.defineProperty(qe.prototype,"OPEN",{enumerable:!0,value:$r.indexOf("OPEN")});Object.defineProperty(qe,"CLOSING",{enumerable:!0,value:$r.indexOf("CLOSING")});Object.defineProperty(qe.prototype,"CLOSING",{enumerable:!0,value:$r.indexOf("CLOSING")});Object.defineProperty(qe,"CLOSED",{enumerable:!0,value:$r.indexOf("CLOSED")});Object.defineProperty(qe.prototype,"CLOSED",{enumerable:!0,value:$r.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(qe.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(qe.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[zw])return t[h6];return null},set(t){for(let n of this.listeners(e))if(n[zw]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[zw]:!0})}})});qe.prototype.addEventListener=y6;qe.prototype.removeEventListener=v6;$j.exports=qe;function Mj(e,t,n,r){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:f6,protocolVersion:Ww[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!Ww.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Ww.join(", ")})`);let s;if(t instanceof qw)s=t;else try{s=new qw(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),e._url=s.href;let i=s.protocol==="wss:",c=s.protocol==="ws+unix:",d;if(s.protocol!=="ws:"&&!i&&!c?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!s.pathname?d="The URL's pathname is empty":s.hash&&(d="The URL contains a fragment identifier"),d){let h=new SyntaxError(d);if(e._redirects===0)throw h;bp(e,h);return}let l=i?443:80,u=d6(16).toString("base64"),p=i?s6.request:i6.request,m=new Set,f;if(o.createConnection=o.createConnection||(i?P6:R6),o.defaultPort=o.defaultPort||l,o.port=s.port||l,o.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(f=new bo({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=k6({[bo.extensionName]:f.offer()})),n.length){for(let h of n){if(typeof h!="string"||!I6.test(h)||m.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");m.add(h)}o.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),c){let h=o.path.split(":");o.socketPath=h[0],o.path=h[1]}let y;if(o.followRedirects){if(e._redirects===0){e._originalIpc=c,e._originalSecure=i,e._originalHostOrSocketPath=c?o.socketPath:s.host;let h=r&&r.headers;if(r={...r,headers:{}},h)for(let[v,g]of Object.entries(h))r.headers[v.toLowerCase()]=g}else if(e.listenerCount("redirect")===0){let h=c?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,h||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),y=e._req=p(o),e._redirects&&e.emit("redirect",e.url,y)}else y=e._req=p(o);o.timeout&&y.on("timeout",()=>{sn(e,y,"Opening handshake has timed out")}),y.on("error",h=>{y===null||y[Ej]||(y=e._req=null,bp(e,h))}),y.on("response",h=>{let v=h.headers.location,g=h.statusCode;if(v&&o.followRedirects&&g>=300&&g<400){if(++e._redirects>o.maxRedirects){sn(e,y,"Maximum redirects exceeded");return}y.abort();let I;try{I=new qw(v,t)}catch{let k=new SyntaxError(`Invalid URL: ${v}`);bp(e,k);return}Mj(e,I,n,r)}else e.emit("unexpected-response",y,h)||sn(e,y,`Unexpected server response: ${h.statusCode}`)}),y.on("upgrade",(h,v,g)=>{if(e.emit("upgrade",h),e.readyState!==qe.CONNECTING)return;y=e._req=null;let I=h.headers.upgrade;if(I===void 0||I.toLowerCase()!=="websocket"){sn(e,v,"Invalid Upgrade header");return}let R=l6("sha1").update(u+g6).digest("base64");if(h.headers["sec-websocket-accept"]!==R){sn(e,v,"Invalid Sec-WebSocket-Accept header");return}let k=h.headers["sec-websocket-protocol"],w;if(k!==void 0?m.size?m.has(k)||(w="Server sent an invalid subprotocol"):w="Server sent a subprotocol but none was requested":m.size&&(w="Server sent no subprotocol"),w){sn(e,v,w);return}k&&(e._protocol=k);let x=h.headers["sec-websocket-extensions"];if(x!==void 0){if(!f){sn(e,v,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let C;try{C=b6(x)}catch{sn(e,v,"Invalid Sec-WebSocket-Extensions header");return}let b=Object.keys(C);if(b.length!==1||b[0]!==bo.extensionName){sn(e,v,"Server indicated an extension that was not requested");return}try{f.accept(C[bo.extensionName])}catch{sn(e,v,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[bo.extensionName]=f}e.setSocket(v,g,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(y,e):y.end()}a(Mj,"initAsClient");function bp(e,t){e._readyState=qe.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}a(bp,"emitErrorAndClose");function R6(e){return e.path=e.socketPath,Aj.connect(e)}a(R6,"netConnect");function P6(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Aj.isIP(e.host)?"":e.host),c6.connect(e)}a(P6,"tlsConnect");function sn(e,t,n){e._readyState=qe.CLOSING;let r=new Error(n);Error.captureStackTrace(r,sn),t.setHeader?(t[Ej]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(bp,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}a(sn,"abortHandshake");function Vw(e,t,n){if(t){let r=m6(t)?t.size:S6(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${$r[e.readyState]})`);process.nextTick(n,r)}}a(Vw,"sendAfterClose");function _6(e,t){let n=this[dt];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[dt]!==void 0&&(n._socket.removeListener("data",Sp),process.nextTick(jj,n._socket),e===1005?n.close():n.close(e,t))}a(_6,"receiverOnConclude");function x6(){let e=this[dt];e.isPaused||e._socket.resume()}a(x6,"receiverOnDrain");function T6(e){let t=this[dt];t._socket[dt]!==void 0&&(t._socket.removeListener("data",Sp),process.nextTick(jj,t._socket),t.close(e[w6])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}a(T6,"receiverOnError");function Tj(){this[dt].emitClose()}a(Tj,"receiverOnFinish");function A6(e,t){this[dt].emit("message",e,t)}a(A6,"receiverOnMessage");function C6(e){let t=this[dt];t._autoPong&&t.pong(e,!this._isServer,Cj),t.emit("ping",e)}a(C6,"receiverOnPing");function E6(e){this[dt].emit("pong",e)}a(E6,"receiverOnPong");function jj(e){e.resume()}a(jj,"resume");function M6(e){let t=this[dt];t.readyState!==qe.CLOSED&&(t.readyState===qe.OPEN&&(t._readyState=qe.CLOSING,Hj(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}a(M6,"senderOnError");function Hj(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}a(Hj,"setCloseTimer");function Oj(){let e=this[dt];if(this.removeListener("close",Oj),this.removeListener("data",Sp),this.removeListener("end",Dj),e._readyState=qe.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&this._readableState.length!==0){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[dt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Tj),e._receiver.on("finish",Tj))}a(Oj,"socketOnClose");function Sp(e){this[dt]._receiver.write(e)||this.pause()}a(Sp,"socketOnData");function Dj(){let e=this[dt];e._readyState=qe.CLOSING,e._receiver.end(),this.end()}a(Dj,"socketOnEnd");function Bj(){let e=this[dt];this.removeListener("error",Bj),this.on("error",Cj),e&&(e._readyState=qe.CLOSING,this.destroy())}a(Bj,"socketOnError")});var Uj=Te((ome,Fj)=>{"use strict";var rme=Ip(),{Duplex:j6}=Pe("stream");function Lj(e){e.emit("close")}a(Lj,"emitClose");function H6(){!this.destroyed&&this._writableState.finished&&this.destroy()}a(H6,"duplexOnEnd");function Nj(e){this.removeListener("error",Nj),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}a(Nj,"duplexOnError");function O6(e,t){let n=!0,r=new j6({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",a(function(s,i){let c=!i&&r._readableState.objectMode?s.toString():s;r.push(c)||e.pause()},"message")),e.once("error",a(function(s){r.destroyed||(n=!1,r.destroy(s))},"error")),e.once("close",a(function(){r.destroyed||r.push(null)},"close")),r._destroy=function(o,s){if(e.readyState===e.CLOSED){s(o),process.nextTick(Lj,r);return}let i=!1;e.once("error",a(function(d){i=!0,s(d)},"error")),e.once("close",a(function(){i||s(o),process.nextTick(Lj,r)},"close")),n&&e.terminate()},r._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",a(function(){r._final(o)},"open"));return}e._socket!==null&&(e._socket._writableState.finished?(o(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",a(function(){o()},"finish")),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(o,s,i){if(e.readyState===e.CONNECTING){e.once("open",a(function(){r._write(o,s,i)},"open"));return}e.send(o,i)},r.on("end",H6),r.on("error",Nj),r}a(O6,"createWebSocketStream");Fj.exports=O6});var Jw=Te((sme,qj)=>{"use strict";var{tokenChars:D6}=Qs();function B6(e){let t=new Set,n=-1,r=-1,o=0;for(o;o<e.length;o++){let i=e.charCodeAt(o);if(r===-1&&D6[i]===1)n===-1&&(n=o);else if(o!==0&&(i===32||i===9))r===-1&&n!==-1&&(r=o);else if(i===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${o}`);r===-1&&(r=o);let c=e.slice(n,r);if(t.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);t.add(c),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=e.slice(n,o);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return t.add(s),t}a(B6,"parse");qj.exports={parse:B6}});var Yj=Te((dme,Kj)=>{"use strict";var $6=Pe("events"),Rp=Pe("http"),{Duplex:cme}=Pe("stream"),{createHash:L6}=Pe("crypto"),zj=vp(),ca=Xs(),N6=Jw(),F6=Ip(),{CLOSE_TIMEOUT:U6,GUID:q6,kWebSocket:z6}=Or(),W6=/^[+/0-9A-Za-z]{22}==$/,Wj=0,Vj=1,Gj=2,Gw=class extends $6{static{a(this,"WebSocketServer")}constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:U6,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:F6,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=Rp.createServer((r,o)=>{let s=Rp.STATUS_CODES[426];o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=V6(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:a((o,s,i)=>{this.handleUpgrade(o,s,i,r)},"upgrade")})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=Wj}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===Gj){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(Nc,this);return}if(t&&this.once("close",t),this._state!==Vj)if(this._state=Vj,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(Nc,this):process.nextTick(Nc,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{Nc(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,r,o){n.on("error",Jj);let s=t.headers["sec-websocket-key"],i=t.headers.upgrade,c=+t.headers["sec-websocket-version"];if(t.method!=="GET"){da(this,t,n,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){da(this,t,n,400,"Invalid Upgrade header");return}if(s===void 0||!W6.test(s)){da(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(c!==13&&c!==8){da(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Fc(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=N6.parse(d)}catch{da(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&u!==void 0){let m=new ca({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let f=zj.parse(u);f[ca.extensionName]&&(m.accept(f[ca.extensionName]),p[ca.extensionName]=m)}catch{da(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let m={origin:t.headers[`${c===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(m,(f,y,h,v)=>{if(!f)return Fc(n,y||401,h,v);this.completeUpgrade(p,s,l,t,n,r,o)});return}if(!this.options.verifyClient(m))return Fc(n,401)}this.completeUpgrade(p,s,l,t,n,r,o)}completeUpgrade(t,n,r,o,s,i,c){if(!s.readable||!s.writable)return s.destroy();if(s[z6])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Wj)return Fc(s,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${L6("sha1").update(n+q6).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,o):r.values().next().value;p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),u._protocol=p)}if(t[ca.extensionName]){let p=t[ca.extensionName].params,m=zj.format({[ca.extensionName]:[p]});l.push(`Sec-WebSocket-Extensions: ${m}`),u._extensions=t}this.emit("headers",l,o),s.write(l.concat(`\r
4
4
  `).join(`\r
5
5
  `)),s.removeListener("error",Jj),u.setSocket(s,i,{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(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Nc,this)})),c(u,o)}};Kj.exports=Gw;function V6(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return a(function(){for(let r of Object.keys(t))e.removeListener(r,t[r])},"removeListeners")}a(V6,"addListeners");function Nc(e){e._state=Gj,e.emit("close")}a(Nc,"emitClose");function Jj(){this.destroy()}a(Jj,"socketOnError");function Fc(e,t,n,r){n=n||Rp.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${Rp.STATUS_CODES[t]}\r
6
6
  `+Object.keys(r).map(o=>`${o}: ${r[o]}`).join(`\r
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-IKM6ICPY.js";import"./chunk-V5BC6QT2.js";import"./chunk-FTQLQJQV.js";export{a as MACOS_GIT_MISSING_DEVELOPER_TOOLS_ERROR,C as appWorkspacePaths,B as assertSafeBranchName,d as checkWorkspaceGitAvailability,J as checkoutBranch,K as checkoutBranchAtPath,M as clearWorkspaceDiffCacheForTests,D as cloneWorkspace,H as createAndCheckoutBranch,I as createAndCheckoutBranchAtPath,A as expectedRemoteUrl,t as isGeneratedWorkspacePath,i as isGitRepo,c as isMacOSGitDeveloperToolsMissing,u as isVisibleGitWorkspaceFile,r as isWorkspaceDirectory,E as lastFetchAt,z as listPlainWorkspaceFiles,P as loadGitCommitDiffAtPath,N as loadWorkspaceDiff,O as loadWorkspaceDiffAtPath,Q as loadWorkspaceFile,T as loadWorkspaceFileAtPath,R as loadWorkspaceImageFile,S as loadWorkspaceImageFileAtPath,F as loadWorkspaceState,G as loadWorkspaceStateAtPath,n as localVideoContentType,L as mapWorkspaceDiffEntriesWithConcurrency,s as normalizeWorkspaceFilePath,w as parseBranchStatusLine,x as parseNumstat,v as parseStatusLine,h as pathExists,p as readLocalImageFile,q as readLocalVideoFile,l as readWorkspaceDocumentPreview,k as readWorkspaceFile,o as readWorkspaceImageFile,g as redactRemoteUrl,b as runWorkspaceCommand,f as sourceFromRemote,e as startMacOSCommandLineToolsInstall,j as truncatePatch,y as uniqueSortedPaths,m as workspaceImageContentType};
2
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-DHP75QSG.js";import"./chunk-6GLGOIMQ.js";import"./chunk-FTQLQJQV.js";export{a as MACOS_GIT_MISSING_DEVELOPER_TOOLS_ERROR,C as appWorkspacePaths,B as assertSafeBranchName,d as checkWorkspaceGitAvailability,J as checkoutBranch,K as checkoutBranchAtPath,M as clearWorkspaceDiffCacheForTests,D as cloneWorkspace,H as createAndCheckoutBranch,I as createAndCheckoutBranchAtPath,A as expectedRemoteUrl,t as isGeneratedWorkspacePath,i as isGitRepo,c as isMacOSGitDeveloperToolsMissing,u as isVisibleGitWorkspaceFile,r as isWorkspaceDirectory,E as lastFetchAt,z as listPlainWorkspaceFiles,P as loadGitCommitDiffAtPath,N as loadWorkspaceDiff,O as loadWorkspaceDiffAtPath,Q as loadWorkspaceFile,T as loadWorkspaceFileAtPath,R as loadWorkspaceImageFile,S as loadWorkspaceImageFileAtPath,F as loadWorkspaceState,G as loadWorkspaceStateAtPath,n as localVideoContentType,L as mapWorkspaceDiffEntriesWithConcurrency,s as normalizeWorkspaceFilePath,w as parseBranchStatusLine,x as parseNumstat,v as parseStatusLine,h as pathExists,p as readLocalImageFile,q as readLocalVideoFile,l as readWorkspaceDocumentPreview,k as readWorkspaceFile,o as readWorkspaceImageFile,g as redactRemoteUrl,b as runWorkspaceCommand,f as sourceFromRemote,e as startMacOSCommandLineToolsInstall,j as truncatePatch,y as uniqueSortedPaths,m as workspaceImageContentType};
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
3
- import{a as m,b as l}from"./chunks/chunk-BSHAIAXY.js";import{b as u}from"./chunks/chunk-FKVP26MC.js";import{a as c,j as d}from"./chunks/chunk-P5CFBE6Z.js";import"./chunks/chunk-XWPC3AN4.js";import{f as s}from"./chunks/chunk-3M53YXEI.js";import"./chunks/chunk-GLUWATL5.js";import{a as t}from"./chunks/chunk-FTQLQJQV.js";function f(e){return!e.command&&s(e.options.version)?"version":s(e.options.checkUpdate)?"check-update":!e.command&&s(e.options.help)?"help":!e.command&&s(e.options.tui)?"tui":e.command?"command":"ui"}t(f,"resolveCliTopLevelAction");async function C(e=process.argv.slice(2)){if(await v(e))return;let{command:r,options:o,rest:i}=u(e);typeof o.home=="string"&&(process.env.OPENPOND_HOME=(await import("./chunks/dist-4OUZANXR.js")).resolveOpenPondHome({home:o.home}));let n=f({command:r,options:o});if(n==="version"){console.log(c());return}if(n==="check-update"){await(await import("./chunks/core-commands-WFTASSGL.js")).runCheckUpdate();return}if(n==="help"){(await import("./chunks/help-4BB2A5JC.js")).printHelp();return}let a=m(o),p=l(o);if(a&&(process.env.OPENPOND_ACCOUNT=a),p&&(process.env.OPENPOND_BASE_URL=p),n==="tui"){await(await import("./chunks/app-layer-JZTMHORT.js")).runOpenPondTerminalCommand(o,i);return}if(n==="ui"){await(await import("./chunks/app-layer-JZTMHORT.js")).runOpenPondServerCommand("web",o,i);return}await d({command:r,options:o,rest:i})||((await import("./chunks/help-4BB2A5JC.js")).printHelp(),process.exit(1))}t(C,"runOpenPondCli");async function v(e){if(e[0]==="__compile-hosted-profile")return await(await import("./chunks/hosted-profile-compiler-7ZWCIHPA.js")).runHostedProfileCompilerCli(e.slice(1)),!0;if(e[0]==="__app-server"){process.argv=[process.execPath,"openpond-app-server",...e.slice(1)];let[{createOpenPondAppServer:r},{runOpenPondAppServerCli:o}]=await Promise.all([import("./chunks/app-server-runtime-PDT6BJD2.js"),import("./chunks/cli-OP4EDGZN.js")]);return await o(r),!0}if(e[0]==="__server"){process.argv=[process.execPath,"openpond-server",...e.slice(1)];let[{createOpenPondServer:r},{runOpenPondServerCli:o}]=await Promise.all([import("./chunks/src-2NVS6PNZ.js"),import("./chunks/cli-OP4EDGZN.js")]),{createOpenPondAppServer:i}=await import("./chunks/app-server-runtime-PDT6BJD2.js");return await o({createOpenPondServer:r,createOpenPondAppServer:i}),!0}return e[0]==="__terminal"?(await(await import("./chunks/src-PASASTIA.js")).runOpenPondTerminalCli(e.slice(1)),!0):!1}t(v,"runEmbeddedCompanion");C().catch(e=>{let r=e instanceof Error?e.message:String(e),o=e.issue;if(process.argv.includes("--json")&&!(e instanceof Error&&e.name==="OpenPondChildProcessExitError"))console.log(JSON.stringify({error:o??{code:"CLI_ERROR",message:r}}));else if(o&&typeof o=="object"){let n=o;console.error(`${n.code}: ${n.message}
3
+ import{a as m,b as l}from"./chunks/chunk-BSHAIAXY.js";import{b as u}from"./chunks/chunk-FKVP26MC.js";import{a as c,j as d}from"./chunks/chunk-P5CFBE6Z.js";import"./chunks/chunk-XWPC3AN4.js";import{f as s}from"./chunks/chunk-3M53YXEI.js";import"./chunks/chunk-GLUWATL5.js";import{a as t}from"./chunks/chunk-FTQLQJQV.js";function f(e){return!e.command&&s(e.options.version)?"version":s(e.options.checkUpdate)?"check-update":!e.command&&s(e.options.help)?"help":!e.command&&s(e.options.tui)?"tui":e.command?"command":"ui"}t(f,"resolveCliTopLevelAction");async function C(e=process.argv.slice(2)){if(await v(e))return;let{command:r,options:o,rest:i}=u(e);typeof o.home=="string"&&(process.env.OPENPOND_HOME=(await import("./chunks/dist-4OUZANXR.js")).resolveOpenPondHome({home:o.home}));let n=f({command:r,options:o});if(n==="version"){console.log(c());return}if(n==="check-update"){await(await import("./chunks/core-commands-WFTASSGL.js")).runCheckUpdate();return}if(n==="help"){(await import("./chunks/help-4BB2A5JC.js")).printHelp();return}let a=m(o),p=l(o);if(a&&(process.env.OPENPOND_ACCOUNT=a),p&&(process.env.OPENPOND_BASE_URL=p),n==="tui"){await(await import("./chunks/app-layer-JZTMHORT.js")).runOpenPondTerminalCommand(o,i);return}if(n==="ui"){await(await import("./chunks/app-layer-JZTMHORT.js")).runOpenPondServerCommand("web",o,i);return}await d({command:r,options:o,rest:i})||((await import("./chunks/help-4BB2A5JC.js")).printHelp(),process.exit(1))}t(C,"runOpenPondCli");async function v(e){if(e[0]==="__compile-hosted-profile")return await(await import("./chunks/hosted-profile-compiler-35BQPVJ6.js")).runHostedProfileCompilerCli(e.slice(1)),!0;if(e[0]==="__app-server"){process.argv=[process.execPath,"openpond-app-server",...e.slice(1)];let[{createOpenPondAppServer:r},{runOpenPondAppServerCli:o}]=await Promise.all([import("./chunks/app-server-runtime-72NRJAB5.js"),import("./chunks/cli-ETZV6JZI.js")]);return await o(r),!0}if(e[0]==="__server"){process.argv=[process.execPath,"openpond-server",...e.slice(1)];let[{createOpenPondServer:r},{runOpenPondServerCli:o}]=await Promise.all([import("./chunks/src-J7NT5WEH.js"),import("./chunks/cli-ETZV6JZI.js")]),{createOpenPondAppServer:i}=await import("./chunks/app-server-runtime-72NRJAB5.js");return await o({createOpenPondServer:r,createOpenPondAppServer:i}),!0}return e[0]==="__terminal"?(await(await import("./chunks/src-PASASTIA.js")).runOpenPondTerminalCli(e.slice(1)),!0):!1}t(v,"runEmbeddedCompanion");C().catch(e=>{let r=e instanceof Error?e.message:String(e),o=e.issue;if(process.argv.includes("--json")&&!(e instanceof Error&&e.name==="OpenPondChildProcessExitError"))console.log(JSON.stringify({error:o??{code:"CLI_ERROR",message:r}}));else if(o&&typeof o=="object"){let n=o;console.error(`${n.code}: ${n.message}
4
4
  ${n.path}
5
5
  ${n.action}`)}else console.error(r);let i=typeof e.exitCode=="number"?e.exitCode:1;process.exit(i)});export{C as runOpenPondCli};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openpond",
3
- "version": "0.2.38",
3
+ "version": "0.2.39",
4
4
  "openpondReleaseVersioned": true,
5
5
  "license": "MIT",
6
6
  "description": "OpenPond CLI and local harness",