{"version":3,"file":"hocuspocus-server.cjs","names":["Y","Awareness","AuthMessageType","messageYjsSyncStep1","messageYjsSyncStep2","decoding","messageYjsUpdate","WsReadyStates","ResetConnection","Doc","Mutex","Awareness","crypto","ConnectionTimeout","Unauthorized","WsReadyStates","SocketIncomingMessage","decoding","ResetConnection","Forbidden","URLSearchParams","meta.version","ResetConnection","Doc","SkipFurtherHooksError","crypto","#id","#uint8Array","#arrayBuffer","#text","#blob","#json","#ws","crossws","meta.version"],"sources":["../src/IncomingMessage.ts","../src/types.ts","../src/OutgoingMessage.ts","../src/MessageReceiver.ts","../src/Connection.ts","../src/Document.ts","../package.json","../src/util/getParameters.ts","../src/ClientConnection.ts","../src/DirectConnection.ts","../src/util/debounce.ts","../src/Hocuspocus.ts","../../../node_modules/.pnpm/crossws@0.4.4/node_modules/crossws/dist/_chunks/rolldown-runtime.mjs","../../../node_modules/.pnpm/crossws@0.4.4/node_modules/crossws/dist/_chunks/adapter.mjs","../../../node_modules/.pnpm/crossws@0.4.4/node_modules/crossws/dist/_chunks/libs/ws.mjs","../../../node_modules/.pnpm/crossws@0.4.4/node_modules/crossws/dist/_chunks/peer.mjs","../../../node_modules/.pnpm/crossws@0.4.4/node_modules/crossws/dist/_chunks/_request.mjs","../../../node_modules/.pnpm/crossws@0.4.4/node_modules/crossws/dist/_chunks/error.mjs","../../../node_modules/.pnpm/crossws@0.4.4/node_modules/crossws/dist/adapters/node.mjs","../src/Server.ts"],"sourcesContent":["import type { Decoder } from \"lib0/decoding\";\nimport {\n\tcreateDecoder,\n\treadVarString,\n\treadVarUint,\n\treadVarUint8Array,\n} from \"lib0/decoding\";\nimport type { Encoder } from \"lib0/encoding\";\nimport {\n\tcreateEncoder,\n\tlength,\n\ttoUint8Array,\n\twriteVarString,\n\twriteVarUint,\n} from \"lib0/encoding\";\nimport type { MessageType } from \"./types.ts\";\n\nexport class IncomingMessage {\n\t/**\n\t * Access to the received message.\n\t */\n\tdecoder: Decoder;\n\n\t/**\n\t * Private encoder; can be undefined.\n\t *\n\t * Lazy creation of the encoder speeds up IncomingMessages that need only a decoder.\n\t */\n\tprivate encoderInternal?: Encoder;\n\n\tconstructor(input: any) {\n\t\tif (!(input instanceof Uint8Array)) {\n\t\t\tinput = new Uint8Array(input);\n\t\t}\n\n\t\tthis.decoder = createDecoder(input);\n\t}\n\n\tget encoder() {\n\t\tif (!this.encoderInternal) {\n\t\t\tthis.encoderInternal = createEncoder();\n\t\t}\n\t\treturn this.encoderInternal;\n\t}\n\n\treadVarUint8Array() {\n\t\treturn readVarUint8Array(this.decoder);\n\t}\n\n\tpeekVarUint8Array() {\n\t\tconst { pos } = this.decoder;\n\t\tconst result = readVarUint8Array(this.decoder);\n\t\tthis.decoder.pos = pos;\n\t\treturn result;\n\t}\n\n\treadVarUint() {\n\t\treturn readVarUint(this.decoder);\n\t}\n\n\treadVarString() {\n\t\treturn readVarString(this.decoder);\n\t}\n\n\ttoUint8Array() {\n\t\treturn toUint8Array(this.encoder);\n\t}\n\n\twriteVarUint(type: MessageType) {\n\t\twriteVarUint(this.encoder, type);\n\t}\n\n\twriteVarString(string: string) {\n\t\twriteVarString(this.encoder, string);\n\t}\n\n\tget length(): number {\n\t\treturn length(this.encoder);\n\t}\n}\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { Awareness } from \"y-protocols/awareness\";\nimport type Connection from \"./Connection.ts\";\nimport type Document from \"./Document.ts\";\nimport type { Hocuspocus } from \"./Hocuspocus.ts\";\n\nexport interface ConnectionTransactionOrigin {\n\tsource: \"connection\";\n\tconnection: Connection;\n}\n\nexport interface RedisTransactionOrigin {\n\tsource: \"redis\";\n}\n\nexport interface LocalTransactionOrigin {\n\tsource: \"local\";\n\tskipStoreHooks?: boolean;\n\tcontext?: any;\n}\n\nexport type TransactionOrigin =\n\t| ConnectionTransactionOrigin\n\t| RedisTransactionOrigin\n\t| LocalTransactionOrigin;\n\nexport function isTransactionOrigin(\n\torigin: unknown,\n): origin is TransactionOrigin {\n\treturn (\n\t\ttypeof origin === \"object\" &&\n\t\torigin !== null &&\n\t\t\"source\" in origin &&\n\t\t((origin as any).source === \"connection\" ||\n\t\t\t(origin as any).source === \"redis\" ||\n\t\t\t(origin as any).source === \"local\")\n\t);\n}\n\nexport function shouldSkipStoreHooks(origin: unknown): boolean {\n\tif (!isTransactionOrigin(origin)) return false;\n\tswitch (origin.source) {\n\t\tcase \"connection\":\n\t\t\treturn false;\n\t\tcase \"redis\":\n\t\t\treturn true;\n\t\tcase \"local\":\n\t\t\treturn origin.skipStoreHooks ?? false;\n\t}\n}\n\n/**\n * Minimal interface for any WebSocket-like object for WebSocket, Bun's ServerWebSocket, ws, Deno, etc.\n */\nexport interface WebSocketLike {\n\tsend(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;\n\tclose(code?: number, reason?: string): void;\n\treadyState: number;\n}\n\nexport enum MessageType {\n\tUnknown = -1,\n\tSync = 0,\n\tAwareness = 1,\n\tAuth = 2,\n\tQueryAwareness = 3,\n\tSyncReply = 4, // same as Sync, but won't trigger another 'SyncStep1'\n\tStateless = 5,\n\tBroadcastStateless = 6,\n\tCLOSE = 7,\n\tSyncStatus = 8,\n\tPing = 9,\n\tPong = 10,\n}\n\nexport interface AwarenessUpdate {\n\tadded: Array<any>;\n\tupdated: Array<any>;\n\tremoved: Array<any>;\n}\n\nexport interface ConnectionConfiguration {\n\treadOnly: boolean;\n\tisAuthenticated: boolean;\n}\n\nexport interface Extension<Context = any> {\n\tpriority?: number;\n\textensionName?: string;\n\tonConfigure?(data: onConfigurePayload): Promise<any>;\n\tonListen?(data: onListenPayload): Promise<any>;\n\tonUpgrade?(data: onUpgradePayload): Promise<any>;\n\tonConnect?(data: onConnectPayload<Context>): Promise<any>;\n\tconnected?(data: connectedPayload<Context>): Promise<any>;\n\tonAuthenticate?(data: onAuthenticatePayload<Context>): Promise<any>;\n\tonTokenSync?(data: onTokenSyncPayload<Context>): Promise<any>;\n\tonCreateDocument?(data: onCreateDocumentPayload<Context>): Promise<any>;\n\tonLoadDocument?(data: onLoadDocumentPayload<Context>): Promise<any>;\n\tafterLoadDocument?(data: afterLoadDocumentPayload<Context>): Promise<any>;\n\tbeforeHandleMessage?(data: beforeHandleMessagePayload<Context>): Promise<any>;\n\t/**\n\t * Fired after an inbound message has been handled (i.e. after the Yjs\n\t * update has been applied to the document). Fires whether the apply\n\t * resolved or threw, but not when `beforeHandleMessage` rejected the\n\t * message.\n\t */\n\tafterHandleMessage?(data: afterHandleMessagePayload<Context>): Promise<any>;\n\t/**\n\t * Fired before an inbound awareness update is applied to the document's\n\t * awareness state. The hook receives the decoded per-client `states` as a\n\t * mutable `Map` keyed by Yjs clientId. Mutate the map and the contained\n\t * state objects in place to rewrite fields, drop peers (`states.delete`),\n\t * or add synthetic ones (`states.set`); mutations are reflected in the\n\t * broadcast. Throw to reject the update without applying anything.\n\t *\n\t * Multiple extensions chain naturally: each extension sees the map as\n\t * mutated by previous extensions and can mutate it further.\n\t */\n\tbeforeHandleAwareness?(\n\t\tdata: beforeHandleAwarenessPayload<Context>,\n\t): Promise<any>;\n\tbeforeSync?(data: beforeSyncPayload<Context>): Promise<any>;\n\tbeforeBroadcastStateless?(\n\t\tdata: beforeBroadcastStatelessPayload,\n\t): Promise<any>;\n\tonStateless?(payload: onStatelessPayload): Promise<any>;\n\tonChange?(data: onChangePayload<Context>): Promise<any>;\n\tonStoreDocument?(data: onStoreDocumentPayload<Context>): Promise<any>;\n\tafterStoreDocument?(data: afterStoreDocumentPayload<Context>): Promise<any>;\n\tonAwarenessUpdate?(data: onAwarenessUpdatePayload<Context>): Promise<any>;\n\tonRequest?(data: onRequestPayload): Promise<any>;\n\tonDisconnect?(data: onDisconnectPayload<Context>): Promise<any>;\n\tbeforeUnloadDocument?(data: beforeUnloadDocumentPayload): Promise<any>;\n\tafterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;\n\tonDestroy?(data: onDestroyPayload): Promise<any>;\n}\n\nexport type HookName =\n\t| \"onConfigure\"\n\t| \"onListen\"\n\t| \"onUpgrade\"\n\t| \"onConnect\"\n\t| \"connected\"\n\t| \"onAuthenticate\"\n\t| \"onTokenSync\"\n\t| \"onCreateDocument\"\n\t| \"onLoadDocument\"\n\t| \"afterLoadDocument\"\n\t| \"beforeHandleMessage\"\n\t| \"afterHandleMessage\"\n\t| \"beforeHandleAwareness\"\n\t| \"beforeBroadcastStateless\"\n\t| \"beforeSync\"\n\t| \"onStateless\"\n\t| \"onChange\"\n\t| \"onStoreDocument\"\n\t| \"afterStoreDocument\"\n\t| \"onAwarenessUpdate\"\n\t| \"onRequest\"\n\t| \"onDisconnect\"\n\t| \"beforeUnloadDocument\"\n\t| \"afterUnloadDocument\"\n\t| \"onDestroy\";\n\nexport type HookPayloadByName<Context = any> = {\n\tonConfigure: onConfigurePayload;\n\tonListen: onListenPayload;\n\tonUpgrade: onUpgradePayload;\n\tonConnect: onConnectPayload<Context>;\n\tconnected: connectedPayload<Context>;\n\tonAuthenticate: onAuthenticatePayload<Context>;\n\tonTokenSync: onTokenSyncPayload<Context>;\n\tonCreateDocument: onCreateDocumentPayload<Context>;\n\tonLoadDocument: onLoadDocumentPayload<Context>;\n\tafterLoadDocument: afterLoadDocumentPayload<Context>;\n\tbeforeHandleMessage: beforeHandleMessagePayload<Context>;\n\tafterHandleMessage: afterHandleMessagePayload<Context>;\n\tbeforeHandleAwareness: beforeHandleAwarenessPayload<Context>;\n\tbeforeBroadcastStateless: beforeBroadcastStatelessPayload;\n\tbeforeSync: beforeSyncPayload<Context>;\n\tonStateless: onStatelessPayload;\n\tonChange: onChangePayload<Context>;\n\tonStoreDocument: onStoreDocumentPayload<Context>;\n\tafterStoreDocument: afterStoreDocumentPayload<Context>;\n\tonAwarenessUpdate: onAwarenessUpdatePayload<Context>;\n\tonRequest: onRequestPayload;\n\tonDisconnect: onDisconnectPayload<Context>;\n\tafterUnloadDocument: afterUnloadDocumentPayload;\n\tbeforeUnloadDocument: beforeUnloadDocumentPayload;\n\tonDestroy: onDestroyPayload;\n};\n\nexport interface Configuration<Context = any> extends Extension<Context> {\n\t/**\n\t * A name for the instance, used for logging.\n\t */\n\tname: string | null;\n\t/**\n\t * A list of hocuspocus extensions.\n\t */\n\textensions: Array<Extension>;\n\t/**\n\t * Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.\n\t */\n\ttimeout: number;\n\t/**\n\t * Debounces the call of the `onStoreDocument` hook for the given amount of time in ms.\n\t * Otherwise every single update would be persisted.\n\t */\n\tdebounce: number;\n\t/**\n\t * Makes sure to call `onStoreDocument` at least in the given amount of time (ms).\n\t */\n\tmaxDebounce: number;\n\t/**\n\t * By default, the servers show a start screen. If passed false, the server will start quietly.\n\t */\n\tquiet: boolean;\n\t/**\n\t * If set to false, respects the debounce time of `onStoreDocument` before unloading a document.\n\t * Otherwise, the document will be unloaded immediately.\n\t *\n\t * This prevents a client from DOSing the server by repeatedly connecting and disconnecting when\n\t * your onStoreDocument is rate-limited.\n\t */\n\tunloadImmediately: boolean;\n\n\t/**\n\t * Maximum number of bytes that may be buffered, across all documents, for a single\n\t * connection while it is still unauthenticated. Messages received before authentication\n\t * completes are queued in memory; without a limit an unauthenticated client could exhaust\n\t * server memory (see GHSA-xwhh-v746-pj9m). When the limit is exceeded the connection is closed.\n\t *\n\t * @default 5_242_880 (5 MiB)\n\t */\n\tmaxUnauthenticatedQueueSize: number;\n\t/**\n\t * Maximum number of messages that may be buffered, across all documents, for a single\n\t * connection while it is still unauthenticated. When the limit is exceeded the connection\n\t * is closed.\n\t *\n\t * @default 1_000\n\t */\n\tmaxUnauthenticatedQueueMessages: number;\n\t/**\n\t * Maximum number of distinct documents a single connection may open before any of them is\n\t * authenticated. Each pending document holds its own queue and hook payload, so an\n\t * unauthenticated client fanning out across many document names could otherwise exhaust\n\t * memory even while staying under the per-connection queue limits. When the limit is\n\t * exceeded the connection is closed.\n\t *\n\t * @default 100\n\t */\n\tmaxPendingDocuments: number;\n\n\t/**\n\t * options to pass to the ydoc document\n\t */\n\tyDocOptions: {\n\t\tgc: boolean; // enable or disable garbage collection (see https://github.com/yjs/yjs/blob/main/INTERNALS.md#deletions)\n\t\tgcFilter: () => boolean; // will be called before garbage collecting ; return false to keep it\n\t};\n}\n\nexport interface onStatelessPayload {\n\tconnection: Connection;\n\tdocumentName: string;\n\tdocument: Document;\n\tpayload: string;\n}\n\nexport interface onAuthenticatePayload<Context = any> {\n\tcontext: Context;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\trequest: Request;\n\tsocketId: string;\n\ttoken: string;\n\tconnectionConfig: ConnectionConfiguration;\n\tproviderVersion: string | null;\n}\n\nexport interface onTokenSyncPayload<Context = any> {\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n\ttoken: string;\n\tconnectionConfig: ConnectionConfiguration;\n\tconnection: Connection<Context>;\n}\n\nexport interface onCreateDocumentPayload<Context = any> {\n\tcontext: Context;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n\tconnectionConfig: ConnectionConfiguration;\n}\n\nexport interface onConnectPayload<Context = any> {\n\tcontext: Context;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequest: Request;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n\tconnectionConfig: ConnectionConfiguration;\n\tproviderVersion: string | null;\n}\n\nexport interface connectedPayload<Context = any> {\n\tcontext: Context;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequest: Request;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n\tconnectionConfig: ConnectionConfiguration;\n\tconnection: Connection<Context>;\n\tproviderVersion: string | null;\n}\n\nexport interface onLoadDocumentPayload<Context = any> {\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n\tconnectionConfig: ConnectionConfiguration;\n}\n\nexport interface afterLoadDocumentPayload<Context = any> {\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n\tconnectionConfig: ConnectionConfiguration;\n}\n\nexport interface onChangePayload<Context = any> {\n\tclientsCount: number;\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tupdate: Uint8Array;\n\tsocketId: string;\n\ttransactionOrigin: unknown;\n\tconnection?: Connection<Context>;\n}\n\nexport interface beforeHandleMessagePayload<Context = any> {\n\tclientsCount: number;\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tupdate: Uint8Array;\n\tsocketId: string;\n\tconnection: Connection<Context>;\n}\n\nexport interface afterHandleMessagePayload<Context = any> {\n\tclientsCount: number;\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tupdate: Uint8Array;\n\tsocketId: string;\n\tconnection: Connection<Context>;\n}\n\nexport interface beforeHandleAwarenessPayload<Context = any> {\n\tawareness: Awareness;\n\tclientsCount: number;\n\t/**\n\t * Connection context populated by `onAuthenticate`. `undefined` when the\n\t * update did not originate from a client connection (e.g. server-internal\n\t * writes via `DirectConnection`).\n\t */\n\tcontext: Context | undefined;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\t/**\n\t * Per-client awareness states decoded from the inbound update, keyed by\n\t * Yjs clientId. Mutate this map in place to rewrite the update: change\n\t * fields on a state object, `states.delete(clientId)` to drop a peer, or\n\t * `states.set(clientId, ...)` to add or replace one. The encoded update\n\t * sent to peers reflects whatever the map looks like after every hook in\n\t * the chain has run.\n\t */\n\tstates: Map<number, Record<string, any>>;\n\tsocketId: string;\n\t/**\n\t * The `TransactionOrigin` that will be passed to `applyAwarenessUpdate`.\n\t * Use `isTransactionOrigin(origin)` to discriminate sources. Matches the\n\t * `transactionOrigin` shape of `onAwarenessUpdatePayload`.\n\t */\n\ttransactionOrigin: unknown;\n\t/**\n\t * Convenience shortcut: `origin.connection` when `transactionOrigin` is a\n\t * `ConnectionTransactionOrigin`, otherwise `undefined`. Matches the\n\t * `connection?` shape of `onAwarenessUpdatePayload`.\n\t */\n\tconnection?: Connection<Context>;\n}\n\nexport interface beforeSyncPayload<Context = any> {\n\tclientsCount: number;\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tconnection: Connection<Context>;\n\t/**\n\t * The y-protocols/sync message type\n\t * @example\n\t * 0: SyncStep1\n\t * 1: SyncStep2\n\t * 2: YjsUpdate\n\t *\n\t * @see https://github.com/yjs/y-protocols/blob/master/sync.js#L13-L40\n\t */\n\ttype: number;\n\t/**\n\t * The payload of the y-sync message.\n\t */\n\tpayload: Uint8Array;\n}\n\nexport interface beforeBroadcastStatelessPayload {\n\tdocument: Document;\n\tdocumentName: string;\n\tpayload: string;\n}\n\nexport interface onStoreDocumentPayload<Context = any> {\n\tclientsCount: number;\n\tdocument: Document;\n\tlastContext: Context;\n\tlastTransactionOrigin: unknown;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type\nexport interface afterStoreDocumentPayload<Context = any>\n\textends onStoreDocumentPayload<Context> {}\n\nexport interface onAwarenessUpdatePayload<Context = any> {\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\ttransactionOrigin: unknown;\n\tconnection?: Connection<Context>;\n\tadded: number[];\n\tupdated: number[];\n\tremoved: number[];\n\tawareness: Awareness;\n\tstates: StatesArray;\n}\n\nexport type StatesArray = { clientId: number; [key: string | number]: any }[];\n\nexport interface fetchPayload<Context = any> {\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n\tconnectionConfig: ConnectionConfiguration;\n}\n\nexport interface storePayload<Context = any>\n\textends onStoreDocumentPayload<Context> {\n\tstate: Buffer;\n}\n\nexport interface onDisconnectPayload<Context = any> {\n\tclientsCount: number;\n\tcontext: Context;\n\tdocument: Document;\n\tdocumentName: string;\n\tinstance: Hocuspocus;\n\trequestHeaders: Headers;\n\trequestParameters: URLSearchParams;\n\tsocketId: string;\n}\n\nexport interface onRequestPayload {\n\trequest: IncomingMessage;\n\tresponse: ServerResponse;\n\tinstance: Hocuspocus;\n}\n\nexport interface onUpgradePayload {\n\trequest: IncomingMessage;\n\tsocket: any;\n\thead: any;\n\tinstance: Hocuspocus;\n}\n\nexport interface onListenPayload {\n\tinstance: Hocuspocus;\n\tconfiguration: Configuration;\n\tport: number;\n}\n\nexport interface onDestroyPayload {\n\tinstance: Hocuspocus;\n}\n\nexport interface onConfigurePayload {\n\tinstance: Hocuspocus;\n\tconfiguration: Configuration;\n\tversion: string;\n}\n\nexport interface afterUnloadDocumentPayload {\n\tinstance: Hocuspocus;\n\tdocumentName: string;\n}\n\nexport interface beforeUnloadDocumentPayload {\n\tinstance: Hocuspocus;\n\tdocumentName: string;\n\tdocument: Document;\n}\n\nexport interface DisconnectOptions {\n\t/**\n\t * When `true` (the default) the document is persisted immediately (no debouncing)\n\t * and unloaded from memory as the connection closes. When `false` the store is\n\t * scheduled via the debounce timer and the document is kept warm in memory, so a\n\t * follow-up direct connection reuses it and repeated writes coalesce. With\n\t * `false`, persistence is no longer guaranteed by the time `disconnect()`\n\t * resolves.\n\t */\n\tunloadImmediately?: boolean;\n}\n\nexport interface DirectConnection {\n\ttransact(transaction: (document: Document) => void): Promise<void>;\n\tdisconnect(options?: DisconnectOptions): Promise<void>;\n}\n","import type { Encoder } from \"lib0/encoding\";\nimport {\n\tcreateEncoder,\n\ttoUint8Array,\n\twriteVarString,\n\twriteVarUint,\n\twriteVarUint8Array,\n} from \"lib0/encoding\";\nimport type { Awareness } from \"y-protocols/awareness\";\nimport { encodeAwarenessUpdate } from \"y-protocols/awareness\";\nimport { writeSyncStep1, writeUpdate } from \"y-protocols/sync\";\n\nimport { writeAuthenticated, writePermissionDenied, writeTokenSyncRequest } from \"@hocuspocus/common\";\nimport type Document from \"./Document.ts\";\nimport { MessageType } from \"./types.ts\";\n\nexport class OutgoingMessage {\n\tencoder: Encoder;\n\n\ttype?: number;\n\n\tcategory?: string;\n\n\tconstructor(documentName: string) {\n\t\tthis.encoder = createEncoder();\n\n\t\twriteVarString(this.encoder, documentName);\n\t}\n\n\tcreateSyncMessage(): OutgoingMessage {\n\t\tthis.type = MessageType.Sync;\n\n\t\twriteVarUint(this.encoder, MessageType.Sync);\n\n\t\treturn this;\n\t}\n\n\tcreateSyncReplyMessage(): OutgoingMessage {\n\t\tthis.type = MessageType.SyncReply;\n\n\t\twriteVarUint(this.encoder, MessageType.SyncReply);\n\n\t\treturn this;\n\t}\n\n\tcreateAwarenessUpdateMessage(\n\t\tawareness: Awareness,\n\t\tchangedClients?: Array<any>,\n\t): OutgoingMessage {\n\t\tthis.type = MessageType.Awareness;\n\t\tthis.category = \"Update\";\n\n\t\tconst message = encodeAwarenessUpdate(\n\t\t\tawareness,\n\t\t\tchangedClients || Array.from(awareness.getStates().keys()),\n\t\t);\n\n\t\twriteVarUint(this.encoder, MessageType.Awareness);\n\t\twriteVarUint8Array(this.encoder, message);\n\n\t\treturn this;\n\t}\n\n\twriteQueryAwareness(): OutgoingMessage {\n\t\tthis.type = MessageType.QueryAwareness;\n\t\tthis.category = \"Update\";\n\n\t\twriteVarUint(this.encoder, MessageType.QueryAwareness);\n\n\t\treturn this;\n\t}\n\n\twriteTokenSyncRequest(): OutgoingMessage {\n\t\tthis.type = MessageType.Auth;\n\t\tthis.category = \"TokenSync\";\n\n\t\twriteVarUint(this.encoder, MessageType.Auth);\n\t\twriteTokenSyncRequest(this.encoder);\n\n\t\treturn this;\n\t}\n\n\twriteAuthenticated(readonly: boolean): OutgoingMessage {\n\t\tthis.type = MessageType.Auth;\n\t\tthis.category = \"Authenticated\";\n\n\t\twriteVarUint(this.encoder, MessageType.Auth);\n\t\twriteAuthenticated(this.encoder, readonly ? \"readonly\" : \"read-write\");\n\n\t\treturn this;\n\t}\n\n\twritePermissionDenied(reason: string): OutgoingMessage {\n\t\tthis.type = MessageType.Auth;\n\t\tthis.category = \"PermissionDenied\";\n\n\t\twriteVarUint(this.encoder, MessageType.Auth);\n\t\twritePermissionDenied(this.encoder, reason);\n\n\t\treturn this;\n\t}\n\n\twriteFirstSyncStepFor(document: Document): OutgoingMessage {\n\t\tthis.category = \"SyncStep1\";\n\n\t\twriteSyncStep1(this.encoder, document);\n\n\t\treturn this;\n\t}\n\n\twriteUpdate(update: Uint8Array): OutgoingMessage {\n\t\tthis.category = \"Update\";\n\n\t\twriteUpdate(this.encoder, update);\n\n\t\treturn this;\n\t}\n\n\twriteStateless(payload: string): OutgoingMessage {\n\t\tthis.category = \"Stateless\";\n\n\t\twriteVarUint(this.encoder, MessageType.Stateless);\n\t\twriteVarString(this.encoder, payload);\n\n\t\treturn this;\n\t}\n\n\twriteBroadcastStateless(payload: string): OutgoingMessage {\n\t\tthis.category = \"Stateless\";\n\n\t\twriteVarUint(this.encoder, MessageType.BroadcastStateless);\n\t\twriteVarString(this.encoder, payload);\n\n\t\treturn this;\n\t}\n\n\t// TODO: should this be write* or create* as method name?\n\twriteSyncStatus(updateSaved: boolean): OutgoingMessage {\n\t\tthis.category = \"SyncStatus\";\n\n\t\twriteVarUint(this.encoder, MessageType.SyncStatus);\n\t\twriteVarUint(this.encoder, updateSaved ? 1 : 0);\n\n\t\treturn this;\n\t}\n\n\twriteCloseMessage(reason: string): OutgoingMessage {\n\t\tthis.type = MessageType.CLOSE;\n\n\t\twriteVarUint(this.encoder, MessageType.CLOSE);\n\t\twriteVarString(this.encoder, reason);\n\n\t\treturn this;\n\t}\n\n\ttoUint8Array(): Uint8Array {\n\t\treturn toUint8Array(this.encoder);\n\t}\n}\n","import { AuthMessageType } from \"@hocuspocus/common\";\nimport * as decoding from \"lib0/decoding\";\nimport { readVarString } from \"lib0/decoding\";\nimport {\n\tAwareness,\n\tapplyAwarenessUpdate,\n\tencodeAwarenessUpdate,\n} from \"y-protocols/awareness\";\nimport {\n\tmessageYjsSyncStep1,\n\tmessageYjsSyncStep2,\n\tmessageYjsUpdate,\n\treadSyncStep1,\n\treadSyncStep2,\n\treadUpdate,\n} from \"y-protocols/sync\";\nimport * as Y from \"yjs\";\nimport type Connection from \"./Connection.ts\";\nimport type Document from \"./Document.ts\";\nimport type { IncomingMessage } from \"./IncomingMessage.ts\";\nimport { OutgoingMessage } from \"./OutgoingMessage.ts\";\nimport {\n\tMessageType,\n\ttype ConnectionTransactionOrigin,\n\ttype TransactionOrigin,\n} from \"./types.ts\";\n\nexport class MessageReceiver {\n\tmessage: IncomingMessage;\n\n\tdefaultTransactionOrigin?: TransactionOrigin;\n\n\tconstructor(\n\t\tmessage: IncomingMessage,\n\t\tdefaultTransactionOrigin?: TransactionOrigin,\n\t) {\n\t\tthis.message = message;\n\t\tthis.defaultTransactionOrigin = defaultTransactionOrigin;\n\t}\n\n\tpublic async apply(\n\t\tdocument: Document,\n\t\tconnection?: Connection,\n\t\treply?: (message: Uint8Array) => void,\n\t) {\n\t\tconst { message } = this;\n\t\tconst type = message.readVarUint();\n\t\tconst emptyMessageLength = message.length;\n\n\t\tswitch (type) {\n\t\t\tcase MessageType.Sync:\n\t\t\tcase MessageType.SyncReply: {\n\t\t\t\tmessage.writeVarUint(MessageType.Sync);\n\t\t\t\tawait this.readSyncMessage(\n\t\t\t\t\tmessage,\n\t\t\t\t\tdocument,\n\t\t\t\t\tconnection,\n\t\t\t\t\treply,\n\t\t\t\t\ttype !== MessageType.SyncReply,\n\t\t\t\t);\n\n\t\t\t\tif (message.length > emptyMessageLength + 1) {\n\t\t\t\t\tif (reply) {\n\t\t\t\t\t\treply(message.toUint8Array());\n\t\t\t\t\t} else if (connection) {\n\t\t\t\t\t\tconnection.send(message.toUint8Array());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase MessageType.Awareness: {\n\t\t\t\tlet update = message.readVarUint8Array();\n\n\t\t\t\tconst origin: TransactionOrigin = connection\n\t\t\t\t\t? ({\n\t\t\t\t\t\t\tsource: \"connection\",\n\t\t\t\t\t\t\tconnection,\n\t\t\t\t\t\t} satisfies ConnectionTransactionOrigin)\n\t\t\t\t\t: (this.defaultTransactionOrigin ?? { source: \"local\" });\n\n\t\t\t\t// Decode the inbound update into a scratch Awareness so the hook\n\t\t\t\t// chain sees a high-level Map<clientId, state>. Mutations to that\n\t\t\t\t// map (including `set`, `delete`, and field changes on each state\n\t\t\t\t// object) are picked up by the re-encode below and forwarded as\n\t\t\t\t// the broadcast payload. Hooks may also throw to reject the\n\t\t\t\t// update entirely.\n\t\t\t\tconst scratchDoc = new Y.Doc();\n\t\t\t\tconst scratch = new Awareness(scratchDoc);\n\t\t\t\ttry {\n\t\t\t\t\tapplyAwarenessUpdate(scratch, update, null);\n\n\t\t\t\t\tawait document.callbacks.beforeHandleAwareness(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t\tscratch.getStates(),\n\t\t\t\t\t\torigin,\n\t\t\t\t\t);\n\n\t\t\t\t\tupdate = encodeAwarenessUpdate(scratch, [\n\t\t\t\t\t\t...scratch.getStates().keys(),\n\t\t\t\t\t]);\n\t\t\t\t} finally {\n\t\t\t\t\tscratch.destroy();\n\t\t\t\t\tscratchDoc.destroy();\n\t\t\t\t}\n\n\t\t\t\tapplyAwarenessUpdate(document.awareness, update, origin);\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase MessageType.QueryAwareness: {\n\t\t\t\tthis.applyQueryAwarenessMessage(document, connection, reply);\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase MessageType.Stateless: {\n\t\t\t\tconnection?.callbacks.statelessCallback({\n\t\t\t\t\tconnection,\n\t\t\t\t\tdocumentName: document.name,\n\t\t\t\t\tdocument,\n\t\t\t\t\tpayload: readVarString(message.decoder),\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase MessageType.BroadcastStateless: {\n\t\t\t\t// Server-internal opcode used by @hocuspocus/extension-redis to\n\t\t\t\t// fan a stateless payload across server instances. The Redis path\n\t\t\t\t// invokes MessageReceiver without a `connection`, so a defined\n\t\t\t\t// `connection` here means this frame came from a WebSocket client\n\t\t\t\t// — which is never legitimate. Clients must use MessageType.Stateless\n\t\t\t\t// (opcode 5); the onStateless hook is the authorization point and\n\t\t\t\t// may call Document.broadcastStateless() to fan out if appropriate.\n\t\t\t\tif (connection) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"BroadcastStateless is a server-internal opcode and cannot be sent from a client\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst msg = message.readVarString();\n\t\t\t\tdocument.getConnections().forEach((c) => {\n\t\t\t\t\tc.sendStateless(msg);\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MessageType.CLOSE: {\n\t\t\t\tconnection?.close({\n\t\t\t\t\tcode: 1000,\n\t\t\t\t\treason: \"provider_initiated\",\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MessageType.Auth: {\n\t\t\t\tconst authType = message.readVarUint();\n\t\t\t\tif (authType === AuthMessageType.Token) {\n\t\t\t\t\tconnection?.callbacks.onTokenSyncCallback({\n\t\t\t\t\t\ttoken: message.readVarString(),\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconsole.error(\n\t\t\t\t\t\"Received an authentication message on a connection that is already fully authenticated. Probably your provider has been destroyed + recreated really fast.\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Unable to handle message of type ${type}: no handler defined! Are your provider/server versions aligned?`,\n\t\t\t\t);\n\t\t\t// Do nothing\n\t\t}\n\t}\n\n\tasync readSyncMessage(\n\t\tmessage: IncomingMessage,\n\t\tdocument: Document,\n\t\tconnection?: Connection,\n\t\treply?: (message: Uint8Array) => void,\n\t\trequestFirstSync = true,\n\t) {\n\t\tconst type = message.readVarUint();\n\t\tconst messageAddress = connection?.messageAddress ?? document.name;\n\n\t\tif (connection) {\n\t\t\tawait connection.callbacks.beforeSync(connection, {\n\t\t\t\ttype,\n\t\t\t\tpayload: message.peekVarUint8Array(),\n\t\t\t});\n\t\t}\n\n\t\tswitch (type) {\n\t\t\tcase messageYjsSyncStep1: {\n\t\t\t\treadSyncStep1(message.decoder, message.encoder, document);\n\n\t\t\t\t// When the server receives SyncStep1, it should reply with SyncStep2 immediately followed by SyncStep1.\n\t\t\t\tif (reply && requestFirstSync) {\n\t\t\t\t\tconst syncMessage = new OutgoingMessage(messageAddress)\n\t\t\t\t\t\t.createSyncReplyMessage()\n\t\t\t\t\t\t.writeFirstSyncStepFor(document);\n\n\t\t\t\t\treply(syncMessage.toUint8Array());\n\t\t\t\t} else if (connection) {\n\t\t\t\t\tconst syncMessage = new OutgoingMessage(messageAddress)\n\t\t\t\t\t\t.createSyncMessage()\n\t\t\t\t\t\t.writeFirstSyncStepFor(document);\n\n\t\t\t\t\tconnection.send(syncMessage.toUint8Array());\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase messageYjsSyncStep2: {\n\t\t\t\tif (connection?.readOnly) {\n\t\t\t\t\t// We're in read-only mode, so we can't apply the update.\n\t\t\t\t\t// Let's use snapshotContainsUpdate to see if the update actually contains changes.\n\t\t\t\t\t// If not, we can still ack the update\n\t\t\t\t\tconst snapshot = Y.snapshot(document);\n\t\t\t\t\tconst update = decoding.readVarUint8Array(message.decoder);\n\t\t\t\t\tif (Y.snapshotContainsUpdate(snapshot, update)) {\n\t\t\t\t\t\t// no new changes in update\n\t\t\t\t\t\tconst ackMessage = new OutgoingMessage(\n\t\t\t\t\t\t\tmessageAddress,\n\t\t\t\t\t\t).writeSyncStatus(true);\n\n\t\t\t\t\t\tconnection.send(ackMessage.toUint8Array());\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// new changes in update that we can't apply, because readOnly\n\t\t\t\t\t\tconst ackMessage = new OutgoingMessage(\n\t\t\t\t\t\t\tmessageAddress,\n\t\t\t\t\t\t).writeSyncStatus(false);\n\n\t\t\t\t\t\tconnection.send(ackMessage.toUint8Array());\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\treadSyncStep2(\n\t\t\t\t\tmessage.decoder,\n\t\t\t\t\tdocument,\n\t\t\t\t\tconnection\n\t\t\t\t\t\t? { source: \"connection\" as const, connection }\n\t\t\t\t\t\t: (this.defaultTransactionOrigin ?? { source: \"local\" as const }),\n\t\t\t\t);\n\n\t\t\t\tif (connection) {\n\t\t\t\t\tconnection.send(\n\t\t\t\t\t\tnew OutgoingMessage(messageAddress)\n\t\t\t\t\t\t\t.writeSyncStatus(true)\n\t\t\t\t\t\t\t.toUint8Array(),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase messageYjsUpdate: {\n\t\t\t\tif (connection?.readOnly) {\n\t\t\t\t\tconnection.send(\n\t\t\t\t\t\tnew OutgoingMessage(messageAddress)\n\t\t\t\t\t\t\t.writeSyncStatus(false)\n\t\t\t\t\t\t\t.toUint8Array(),\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\treadUpdate(\n\t\t\t\t\tmessage.decoder,\n\t\t\t\t\tdocument,\n\t\t\t\t\tconnection\n\t\t\t\t\t\t? { source: \"connection\" as const, connection }\n\t\t\t\t\t\t: (this.defaultTransactionOrigin ?? { source: \"local\" as const }),\n\t\t\t\t);\n\t\t\t\tif (connection) {\n\t\t\t\t\tconnection.send(\n\t\t\t\t\t\tnew OutgoingMessage(messageAddress)\n\t\t\t\t\t\t\t.writeSyncStatus(true)\n\t\t\t\t\t\t\t.toUint8Array(),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Received a message with an unknown type: ${type}`);\n\t\t}\n\n\t\treturn type;\n\t}\n\n\tapplyQueryAwarenessMessage(\n\t\tdocument: Document,\n\t\tconnection?: Connection,\n\t\treply?: (message: Uint8Array) => void,\n\t) {\n\t\tconst message = new OutgoingMessage(\n\t\t\tconnection?.messageAddress ?? document.name,\n\t\t).createAwarenessUpdateMessage(document.awareness);\n\n\t\tif (reply) {\n\t\t\treply(message.toUint8Array());\n\t\t}\n\t}\n}\n","import {\n\ttype CloseEvent,\n\tResetConnection,\n\tWsReadyStates,\n} from \"@hocuspocus/common\";\nimport type Document from \"./Document.ts\";\nimport { IncomingMessage } from \"./IncomingMessage.ts\";\nimport { MessageReceiver } from \"./MessageReceiver.ts\";\nimport { OutgoingMessage } from \"./OutgoingMessage.ts\";\nimport type {\n\tWebSocketLike,\n\tbeforeSyncPayload,\n\tonStatelessPayload,\n} from \"./types.ts\";\n\nexport class Connection<Context = any> {\n\twebSocket: WebSocketLike;\n\n\tcontext: Context;\n\n\tdocument: Document;\n\n\trequest: Request;\n\n\tcallbacks = {\n\t\tonClose: [(document: Document, event?: CloseEvent) => {}],\n\t\tbeforeHandleMessage: (connection: Connection, update: Uint8Array) =>\n\t\t\tPromise.resolve(),\n\t\tafterHandleMessage: (connection: Connection, update: Uint8Array) =>\n\t\t\tPromise.resolve(),\n\t\tbeforeSync: (\n\t\t\tconnection: Connection,\n\t\t\tpayload: Pick<beforeSyncPayload, \"type\" | \"payload\">,\n\t\t) => Promise.resolve(),\n\t\tstatelessCallback: (payload: onStatelessPayload) => Promise.resolve(),\n\t\tonTokenSyncCallback: (payload: { token: string }) => Promise.resolve(),\n\t};\n\n\tsocketId: string;\n\n\treadOnly: boolean;\n\n\tsessionId: string | null;\n\n\tproviderVersion: string | null;\n\n\t/**\n\t * The address string prefixed to outgoing messages.\n\t * Session-aware clients get `documentName\\0sessionId`; legacy clients get plain `documentName`.\n\t */\n\tget messageAddress(): string {\n\t\treturn this.sessionId\n\t\t\t? `${this.document.name}\\0${this.sessionId}`\n\t\t\t: this.document.name;\n\t}\n\n\tprivate messageQueue: Uint8Array[] = [];\n\n\tprivate processingPromise: Promise<void> = Promise.resolve();\n\n\t/**\n\t * Constructor.\n\t */\n\tconstructor(\n\t\tconnection: WebSocketLike,\n\t\trequest: Request,\n\t\tdocument: Document,\n\t\tsocketId: string,\n\t\tcontext: Context,\n\t\treadOnly = false,\n\t\tsessionId?: string | null,\n\t\tproviderVersion?: string | null,\n\t) {\n\t\tthis.webSocket = connection;\n\t\tthis.context = context;\n\t\tthis.document = document;\n\t\tthis.request = request;\n\t\tthis.socketId = socketId;\n\t\tthis.readOnly = readOnly;\n\t\tthis.sessionId = sessionId ?? null;\n\t\tthis.providerVersion = providerVersion ?? null;\n\n\t\tthis.document.addConnection(this);\n\n\t\tthis.sendCurrentAwareness();\n\t}\n\n\t/**\n\t * Set a callback that will be triggered when the connection is closed\n\t */\n\tonClose(\n\t\tcallback: (document: Document, event?: CloseEvent) => void,\n\t): Connection {\n\t\tthis.callbacks.onClose.push(callback);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered when an stateless message is received\n\t */\n\tonStatelessCallback(\n\t\tcallback: (payload: onStatelessPayload) => Promise<void>,\n\t): Connection {\n\t\tthis.callbacks.statelessCallback = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered before an message is handled\n\t */\n\tbeforeHandleMessage(\n\t\tcallback: (connection: Connection, update: Uint8Array) => Promise<any>,\n\t): Connection {\n\t\tthis.callbacks.beforeHandleMessage = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered after a message has been handled\n\t */\n\tafterHandleMessage(\n\t\tcallback: (connection: Connection, update: Uint8Array) => Promise<any>,\n\t): Connection {\n\t\tthis.callbacks.afterHandleMessage = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered before a sync message is handled\n\t */\n\tbeforeSync(\n\t\tcallback: (\n\t\t\tconnection: Connection,\n\t\t\tpayload: Pick<beforeSyncPayload, \"type\" | \"payload\">,\n\t\t) => Promise<any>,\n\t): Connection {\n\t\tthis.callbacks.beforeSync = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered when on token sync message is received\n\t */\n\tonTokenSyncCallback(\n\t\tcallback: (payload: { token: string }) => Promise<void>,\n\t): Connection {\n\t\tthis.callbacks.onTokenSyncCallback = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a promise that resolves when all queued messages have been processed.\n\t */\n\twaitForPendingMessages(): Promise<void> {\n\t\treturn this.processingPromise;\n\t}\n\n\t/**\n\t * Send the given message\n\t */\n\tsend(message: Uint8Array): void {\n\t\tif (\n\t\t\tthis.webSocket.readyState === WsReadyStates.Closing ||\n\t\t\tthis.webSocket.readyState === WsReadyStates.Closed\n\t\t) {\n\t\t\tthis.close();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tthis.webSocket.send(message);\n\t\t} catch (exception) {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/**\n\t * Send a stateless message with payload\n\t */\n\tpublic sendStateless(payload: string): void {\n\t\tconst message = new OutgoingMessage(this.messageAddress).writeStateless(\n\t\t\tpayload,\n\t\t);\n\n\t\tthis.send(message.toUint8Array());\n\t}\n\n\t/**\n\t * Request current token from the client\n\t */\n\tpublic requestToken(): void {\n\t\tconst message = new OutgoingMessage(\n\t\t\tthis.messageAddress,\n\t\t).writeTokenSyncRequest();\n\n\t\tthis.send(message.toUint8Array());\n\t}\n\n\t/**\n\t * Graceful wrapper around the WebSocket close method.\n\t */\n\tclose(event?: CloseEvent): void {\n\t\tif (this.document.hasConnection(this)) {\n\t\t\tthis.document.removeConnection(this);\n\t\t\tthis.callbacks.onClose.forEach(\n\t\t\t\t(callback: (arg0: Document, arg1?: CloseEvent) => any) =>\n\t\t\t\t\tcallback(this.document, event),\n\t\t\t);\n\n\t\t\tconst closeMessage = new OutgoingMessage(this.messageAddress);\n\t\t\tcloseMessage.writeCloseMessage(\n\t\t\t\tevent?.reason ?? \"Server closed the connection\",\n\t\t\t);\n\t\t\tthis.send(closeMessage.toUint8Array());\n\t\t}\n\t}\n\n\t/**\n\t * Send the current document awareness to the client, if any\n\t * @private\n\t */\n\tprivate sendCurrentAwareness(): void {\n\t\tif (!this.document.hasAwarenessStates()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst awarenessMessage = new OutgoingMessage(\n\t\t\tthis.messageAddress,\n\t\t).createAwarenessUpdateMessage(this.document.awareness);\n\n\t\tthis.send(awarenessMessage.toUint8Array());\n\t}\n\n\t/**\n\t * Handle an incoming message\n\t * @public\n\t */\n\tpublic handleMessage(data: Uint8Array): void {\n\t\tthis.messageQueue.push(data);\n\n\t\tif (this.messageQueue.length === 1) {\n\t\t\tthis.processingPromise = this.processMessages();\n\t\t}\n\t}\n\n\tprivate async processMessages() {\n\t\twhile (this.messageQueue.length > 0) {\n\t\t\tconst rawUpdate = this.messageQueue.at(0) as Uint8Array;\n\n\t\t\tconst message = new IncomingMessage(rawUpdate);\n\t\t\tconst rawKey = message.readVarString();\n\n\t\t\t// Accept messages addressed with either the plain documentName or documentName\\0sessionId\n\t\t\tconst sepIdx = rawKey.indexOf('\\0');\n\t\t\tconst documentName = sepIdx === -1 ? rawKey : rawKey.substring(0, sepIdx);\n\t\t\tif (documentName !== this.document.name) {\n\t\t\t\tthis.messageQueue.shift();\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Write the correct address so replies reach the right provider\n\t\t\tmessage.writeVarString(this.messageAddress);\n\n\t\t\ttry {\n\t\t\t\tawait this.callbacks.beforeHandleMessage(this, rawUpdate);\n\t\t\t\tconst receiver = new MessageReceiver(message);\n\n\t\t\t\ttry {\n\t\t\t\t\tawait receiver.apply(this.document, this);\n\t\t\t\t} finally {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.callbacks.afterHandleMessage(this, rawUpdate);\n\t\t\t\t\t} catch (afterError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`afterHandleMessage hook failed (while handling ${documentName})`,\n\t\t\t\t\t\t\tafterError,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: <explanation>\n\t\t\t} catch (e: any) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`closing connection ${this.socketId} (while handling ${documentName}) because of exception`,\n\t\t\t\t\te,\n\t\t\t\t);\n\t\t\t\tthis.close({\n\t\t\t\t\tcode: \"code\" in e && typeof e.code === 'number' ? e.code : ResetConnection.code,\n\t\t\t\t\treason: \"reason\" in e ? e.reason : ResetConnection.reason,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis.messageQueue.shift();\n\t\t}\n\t}\n}\n\nexport default Connection;\n","import { Mutex } from \"async-mutex\";\nimport {\n\tAwareness,\n\tapplyAwarenessUpdate,\n\tremoveAwarenessStates,\n} from \"y-protocols/awareness\";\nimport { Doc, applyUpdate, encodeStateAsUpdate } from \"yjs\";\nimport type Connection from \"./Connection.ts\";\nimport { OutgoingMessage } from \"./OutgoingMessage.ts\";\nimport { isTransactionOrigin } from \"./types.ts\";\nimport type {\n\tAwarenessUpdate,\n\tConnectionTransactionOrigin,\n\tTransactionOrigin,\n} from \"./types.ts\";\n\nexport class Document extends Doc {\n\tawareness: Awareness;\n\n\tcallbacks = {\n\t\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\t\tonUpdate: (document: Document, origin: unknown, update: Uint8Array) => {},\n\t\tbeforeBroadcastStateless: (document: Document, stateless: string) => {},\n\t\tbeforeHandleAwareness: (\n\t\t\tdocument: Document,\n\t\t\tstates: Map<number, Record<string, any>>,\n\t\t\ttransactionOrigin: unknown,\n\t\t) => Promise.resolve(),\n\t};\n\n\tconnections: Map<\n\t\tConnection,\n\t\t{\n\t\t\tclients: Set<any>;\n\t\t}\n\t> = new Map();\n\n\t// The number of direct (non-websocket) connections to this document\n\tdirectConnectionsCount = 0;\n\n\tname: string;\n\n\tisLoading: boolean;\n\n\tisDestroyed = false;\n\n\tsaveMutex = new Mutex();\n\n\tlastChangeTime = 0;\n\n\t/**\n\t * Constructor.\n\t */\n\tconstructor(name: string, yDocOptions?: object) {\n\t\tsuper(yDocOptions);\n\n\t\tthis.name = name;\n\n\t\tthis.awareness = new Awareness(this);\n\t\tthis.awareness.setLocalState(null);\n\n\t\tthis.awareness.on(\"update\", this.handleAwarenessUpdate.bind(this));\n\t\tthis.on(\"update\", this.handleUpdate.bind(this));\n\n\t\tthis.isLoading = true;\n\t}\n\n\t/**\n\t * Check if the Document (XMLFragment or Map) is empty\n\t */\n\tisEmpty(fieldName: string): boolean {\n\t\treturn !this.get(fieldName)._start && !this.get(fieldName)._map.size;\n\t}\n\n\t/**\n\t * Merge the given document(s) into this one\n\t */\n\tmerge(documents: Doc | Array<Doc>): Document {\n\t\t(Array.isArray(documents) ? documents : [documents]).forEach((document) => {\n\t\t\tapplyUpdate(this, encodeStateAsUpdate(document));\n\t\t});\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered when the document is updated\n\t */\n\tonUpdate(\n\t\tcallback: (document: Document, origin: unknown, update: Uint8Array) => void,\n\t): Document {\n\t\tthis.callbacks.onUpdate = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered before a stateless message is broadcasted\n\t */\n\tbeforeBroadcastStateless(\n\t\tcallback: (document: Document, stateless: string) => void,\n\t): Document {\n\t\tthis.callbacks.beforeBroadcastStateless = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered before an inbound awareness update\n\t * is applied to this document's awareness state. The callback receives the\n\t * document, the decoded per-client states as a mutable `Map`, and the\n\t * `TransactionOrigin` that will be forwarded to `applyAwarenessUpdate`.\n\t * Use `isTransactionOrigin(origin)` to discriminate sources. Mutate the\n\t * map in place (set/delete/field changes) to rewrite the update, or throw\n\t * to reject it entirely.\n\t */\n\tbeforeHandleAwareness(\n\t\tcallback: (\n\t\t\tdocument: Document,\n\t\t\tstates: Map<number, Record<string, any>>,\n\t\t\ttransactionOrigin: unknown,\n\t\t) => Promise<any>,\n\t): Document {\n\t\tthis.callbacks.beforeHandleAwareness = callback;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Register a connection and a set of clients on this document keyed by the\n\t * underlying websocket connection\n\t */\n\taddConnection(connection: Connection): Document {\n\t\tthis.connections.set(connection, {\n\t\t\tclients: new Set(),\n\t\t});\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Is the given connection registered on this document\n\t */\n\thasConnection(connection: Connection): boolean {\n\t\treturn this.connections.has(connection);\n\t}\n\n\t/**\n\t * Remove the given connection from this document\n\t */\n\tremoveConnection(connection: Connection): Document {\n\t\tconst entry = this.connections.get(connection);\n\t\tif (entry) {\n\t\t\tremoveAwarenessStates(\n\t\t\t\tthis.awareness,\n\t\t\t\tArray.from(entry.clients),\n\t\t\t\tnull,\n\t\t\t);\n\t\t}\n\n\t\tthis.connections.delete(connection);\n\n\t\treturn this;\n\t}\n\n\taddDirectConnection(): Document {\n\t\tthis.directConnectionsCount += 1;\n\n\t\treturn this;\n\t}\n\n\tremoveDirectConnection(): Document {\n\t\tif (this.directConnectionsCount > 0) {\n\t\t\tthis.directConnectionsCount -= 1;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the number of active connections for this document\n\t */\n\tgetConnectionsCount(): number {\n\t\treturn this.connections.size + this.directConnectionsCount;\n\t}\n\n\t/**\n\t * Get an array of registered connections\n\t */\n\tgetConnections(): Array<Connection> {\n\t\treturn Array.from(this.connections.keys());\n\t}\n\n\t/**\n\t * Get the client ids for the given connection instance\n\t */\n\tgetClients(connection: Connection): Set<any> {\n\t\tconst entry = this.connections.get(connection);\n\n\t\treturn entry?.clients === undefined ? new Set() : entry.clients;\n\t}\n\n\t/**\n\t * Has the document awareness states\n\t */\n\thasAwarenessStates(): boolean {\n\t\treturn this.awareness.getStates().size > 0;\n\t}\n\n\t/**\n\t * Apply the given awareness update\n\t */\n\tapplyAwarenessUpdate(connection: Connection, update: Uint8Array): Document {\n\t\tapplyAwarenessUpdate(this.awareness, update, {\n\t\t\tsource: \"connection\",\n\t\t\tconnection,\n\t\t} satisfies ConnectionTransactionOrigin);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Handle an awareness update and sync changes to clients\n\t * @private\n\t */\n\tprivate handleAwarenessUpdate(\n\t\t{ added, updated, removed }: AwarenessUpdate,\n\t\torigin: TransactionOrigin | null,\n\t): Document {\n\t\tconst changedClients = added.concat(updated, removed);\n\n\t\tconst originConnection: Connection | null =\n\t\t\tisTransactionOrigin(origin) && origin.source === \"connection\"\n\t\t\t\t? origin.connection\n\t\t\t\t: null;\n\n\t\tif (originConnection !== null) {\n\t\t\tconst entry = this.connections.get(originConnection);\n\n\t\t\tif (entry) {\n\t\t\t\tadded.forEach((clientId: any) => entry.clients.add(clientId));\n\t\t\t\tremoved.forEach((clientId: any) => entry.clients.delete(clientId));\n\t\t\t}\n\t\t}\n\n\t\tfor (const connection of this.getConnections()) {\n\t\t\tconst awarenessMessage = new OutgoingMessage(\n\t\t\t\tconnection.messageAddress,\n\t\t\t).createAwarenessUpdateMessage(this.awareness, changedClients);\n\n\t\t\tconnection.send(awarenessMessage.toUint8Array());\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Handle an updated document and sync changes to clients\n\t */\n\tprivate handleUpdate(update: Uint8Array, origin: unknown): Document {\n\t\tthis.callbacks.onUpdate(this, origin, update);\n\n\t\tfor (const connection of this.getConnections()) {\n\t\t\tconst message = new OutgoingMessage(connection.messageAddress)\n\t\t\t\t.createSyncMessage()\n\t\t\t\t.writeUpdate(update);\n\n\t\t\tconnection.send(message.toUint8Array());\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Broadcast stateless message to all connections\n\t */\n\tpublic broadcastStateless(\n\t\tpayload: string,\n\t\tfilter?: (conn: Connection) => boolean,\n\t): void {\n\t\tthis.callbacks.beforeBroadcastStateless(this, payload);\n\n\t\tconst connections = filter\n\t\t\t? this.getConnections().filter(filter)\n\t\t\t: this.getConnections();\n\n\t\tconnections.forEach((connection) => {\n\t\t\tconnection.sendStateless(payload);\n\t\t});\n\t}\n\n\tdestroy() {\n\t\tsuper.destroy();\n\t\tthis.isDestroyed = true;\n\t}\n}\n\nexport default Document;\n","","/**\n * Get parameters by the given request\n */\nexport function getParameters(request?: { url?: string }): URLSearchParams {\n\tconst url = request?.url;\n\tif (!url) {\n\t\treturn new URLSearchParams();\n\t}\n\t// Handle both full URLs (web Request) and path-only URLs (Node.js IncomingMessage)\n\tconst query = url.includes(\"://\")\n\t\t? new URL(url).searchParams\n\t\t: new URLSearchParams(url.split(\"?\")[1] || \"\");\n\treturn query;\n}\n","import crypto from \"node:crypto\";\nimport {\n\ttype CloseEvent,\n\tConnectionTimeout,\n\tForbidden,\n\tResetConnection,\n\tUnauthorized,\n\tWsReadyStates,\n} from \"@hocuspocus/common\";\nimport * as decoding from \"lib0/decoding\";\nimport Connection from \"./Connection.ts\";\nimport type Document from \"./Document.ts\";\nimport type { Hocuspocus } from \"./Hocuspocus.ts\";\nimport { IncomingMessage as SocketIncomingMessage } from \"./IncomingMessage.ts\";\nimport { OutgoingMessage } from \"./OutgoingMessage.ts\";\nimport type {\n\tConnectionConfiguration,\n\tWebSocketLike,\n\tafterHandleMessagePayload,\n\tbeforeHandleMessagePayload,\n\tbeforeSyncPayload,\n\tonDisconnectPayload,\n} from \"./types.ts\";\nimport { MessageType } from \"./types.ts\";\nimport { getParameters } from \"./util/getParameters.ts\";\n\n/**\n * The `ClientConnection` class is responsible for handling an incoming WebSocket\n *\n * TODO-refactor:\n * - use event handlers instead of calling hooks directly, hooks should probably be called from Hocuspocus.ts\n */\nexport class ClientConnection<Context = any> {\n\t// Map of established document connections, keyed by rawKey (composite or plain)\n\tprivate readonly documentConnections: Record<string, Connection<Context>> =\n\t\t{};\n\n\t// While the connection will be establishing messages will\n\t// be queued and handled later.\n\tprivate readonly incomingMessageQueue: Record<string, Uint8Array[]> = {};\n\n\t// Tracks the number of bytes buffered per document key, so the total amount\n\t// of unauthenticated buffered data can be bounded (see GHSA-xwhh-v746-pj9m).\n\tprivate readonly incomingMessageQueueBytes: Record<string, number> = {};\n\n\t// While the connection is establishing, keep track of which documents have received auth\n\tprivate readonly documentConnectionsEstablished = new Set<string>();\n\n\t// Hook payloads keyed by rawKey (composite or plain)\n\tprivate readonly hookPayloads: Record<\n\t\tstring,\n\t\t{\n\t\t\tinstance: Hocuspocus;\n\t\t\trequest: Request;\n\t\t\trequestHeaders: Headers;\n\t\t\trequestParameters: URLSearchParams;\n\t\t\tsocketId: string;\n\t\t\tconnectionConfig: ConnectionConfiguration;\n\t\t\tcontext: Context;\n\t\t\tproviderVersion: string | null;\n\t\t}\n\t> = {};\n\n\tprivate readonly callbacks = {\n\t\tonClose: [(document: Document, payload: onDisconnectPayload) => {}],\n\t};\n\n\t// Every new connection gets a unique identifier.\n\tprivate readonly socketId = crypto.randomUUID();\n\n\ttimeout: number;\n\n\tprivate readonly maxUnauthenticatedQueueSize: number;\n\n\tprivate readonly maxUnauthenticatedQueueMessages: number;\n\n\tprivate readonly maxPendingDocuments: number;\n\n\tpingInterval: NodeJS.Timeout;\n\n\tlastMessageReceivedAt = Date.now();\n\n\t// When the connection was opened. Used to enforce a pre-authentication\n\t// deadline that inbound traffic cannot refresh.\n\tprivate readonly connectionEstablishedAt = Date.now();\n\n\t// Set once any document on this connection has successfully authenticated.\n\t// Sticky on purpose: once a client has proven itself, the normal idle-timeout\n\t// logic applies for the rest of the socket's life, even if it later closes all\n\t// of its documents.\n\tprivate hasAuthenticated = false;\n\n\t// Set once the connection has been proactively torn down (timeout or a limit\n\t// breach). Guards against processing — and re-logging — frames that were\n\t// already in flight when we decided to close the socket.\n\tprivate terminated = false;\n\n\t/**\n\t * The `ClientConnection` class receives incoming WebSocket connections,\n\t * runs all hooks:\n\t *\n\t *  - onConnect for all connections\n\t *  - onAuthenticate only if required\n\t *\n\t * … and if nothings fails it'll fully establish the connection and\n\t * load the Document then.\n\t */\n\tconstructor(\n\t\tprivate readonly websocket: WebSocketLike,\n\t\tprivate readonly request: Request,\n\t\tprivate readonly documentProvider: {\n\t\t\tcreateDocument: Hocuspocus[\"createDocument\"];\n\t\t},\n\t\t// TODO: change to events\n\t\tprivate readonly hooks: Hocuspocus[\"hooks\"],\n\t\tprivate readonly opts: {\n\t\t\ttimeout: number;\n\t\t\tmaxUnauthenticatedQueueSize?: number;\n\t\t\tmaxUnauthenticatedQueueMessages?: number;\n\t\t\tmaxPendingDocuments?: number;\n\t\t},\n\t\tprivate readonly defaultContext: Context = {} as Context,\n\t) {\n\t\tthis.timeout = opts.timeout;\n\t\tthis.maxUnauthenticatedQueueSize =\n\t\t\topts.maxUnauthenticatedQueueSize ?? 5 * 1024 * 1024;\n\t\tthis.maxUnauthenticatedQueueMessages =\n\t\t\topts.maxUnauthenticatedQueueMessages ?? 1_000;\n\t\tthis.maxPendingDocuments = opts.maxPendingDocuments ?? 100;\n\t\tthis.pingInterval = setInterval(this.check, this.timeout);\n\t}\n\n\t/**\n\t * Handle WebSocket close event. Call this from your integration\n\t * when the WebSocket connection closes.\n\t */\n\thandleClose(event?: CloseEvent) {\n\t\tthis.close(event);\n\t\tclearInterval(this.pingInterval);\n\t}\n\n\tprivate close(event?: CloseEvent) {\n\t\tObject.values(this.documentConnections).forEach((connection) =>\n\t\t\tconnection.close(event),\n\t\t);\n\n\t\t// Release any buffered pre-authentication state. Without this, a\n\t\t// timed-out or rejected connection would keep its queued messages and\n\t\t// hook payloads in memory until the process exits (GHSA-xwhh-v746-pj9m).\n\t\tfor (const rawKey of Object.keys(this.incomingMessageQueue)) {\n\t\t\tdelete this.incomingMessageQueue[rawKey];\n\t\t\tdelete this.incomingMessageQueueBytes[rawKey];\n\t\t}\n\t\tfor (const rawKey of Object.keys(this.hookPayloads)) {\n\t\t\tdelete this.hookPayloads[rawKey];\n\t\t}\n\t\tthis.documentConnectionsEstablished.clear();\n\t}\n\n\t/**\n\t * Tear down the connection: release the established document connections and\n\t * the buffered pre-authentication state, then close the underlying socket.\n\t * Closing the socket is essential — otherwise an unauthenticated client can\n\t * keep the socket (and its resources) open even after a timeout fires.\n\t */\n\tprivate terminate(event?: CloseEvent) {\n\t\tif (this.terminated) {\n\t\t\treturn;\n\t\t}\n\t\tthis.terminated = true;\n\n\t\tthis.close(event);\n\n\t\tif (\n\t\t\tthis.websocket.readyState !== WsReadyStates.Closing &&\n\t\t\tthis.websocket.readyState !== WsReadyStates.Closed\n\t\t) {\n\t\t\tthis.websocket.close(event?.code, event?.reason);\n\t\t}\n\n\t\tclearInterval(this.pingInterval);\n\t}\n\n\t/**\n\t * Close the connection if no messages have been received within the timeout period.\n\t * This replaces application-level ping/pong to maintain backward compatibility\n\t * with older provider versions that don't understand Ping/Pong message types.\n\t * Awareness updates (~every 30s) keep active connections alive.\n\t */\n\tprivate check = () => {\n\t\t// Until the connection has authenticated at least one document, use an\n\t\t// absolute deadline based on when the connection opened. Inbound traffic\n\t\t// updates `lastMessageReceivedAt`, so a flood of unauthenticated frames\n\t\t// could otherwise refresh the timeout forever and keep the socket alive.\n\t\t// Once authenticated, fall back to the normal idle behavior — even if the\n\t\t// client later closes all of its documents — so an established client that\n\t\t// keeps its socket open is not closed based on the original open time.\n\t\tconst referenceTime = this.hasAuthenticated\n\t\t\t? this.lastMessageReceivedAt\n\t\t\t: this.connectionEstablishedAt;\n\n\t\tif (Date.now() - referenceTime > this.timeout) {\n\t\t\tthis.terminate(ConnectionTimeout);\n\t\t}\n\t};\n\n\t// Total bytes currently buffered for unauthenticated documents on this\n\t// connection. Derived on demand so the various cleanup paths only need to\n\t// delete their keys without keeping a running counter in sync.\n\tprivate getQueuedBytes(): number {\n\t\tlet total = 0;\n\t\tfor (const rawKey of Object.keys(this.incomingMessageQueueBytes)) {\n\t\t\ttotal += this.incomingMessageQueueBytes[rawKey];\n\t\t}\n\t\treturn total;\n\t}\n\n\t// Total number of messages currently buffered for unauthenticated documents.\n\tprivate getQueuedMessageCount(): number {\n\t\tlet total = 0;\n\t\tfor (const rawKey of Object.keys(this.incomingMessageQueue)) {\n\t\t\ttotal += this.incomingMessageQueue[rawKey].length;\n\t\t}\n\t\treturn total;\n\t}\n\n\t// Number of distinct documents on this connection that have not yet finished\n\t// authenticating. Each holds its own queue and hook payload, so this is capped\n\t// to prevent a single connection from amplifying memory usage by fanning out\n\t// across many document names. We count by `isAuthenticated` (not by whether an\n\t// Auth frame has been seen) so that sending an Auth frame first — which marks\n\t// the document as \"establishing\" but keeps its hook payload alive while a slow\n\t// `onAuthenticate` runs — cannot be used to bypass the limit.\n\tprivate getPendingDocumentCount(): number {\n\t\tlet total = 0;\n\t\tfor (const rawKey of Object.keys(this.hookPayloads)) {\n\t\t\tif (!this.hookPayloads[rawKey].connectionConfig.isAuthenticated) {\n\t\t\t\ttotal += 1;\n\t\t\t}\n\t\t}\n\t\treturn total;\n\t}\n\n\t/**\n\t * Set a callback that will be triggered when the connection is closed\n\t */\n\tpublic onClose(\n\t\tcallback: (document: Document, payload: onDisconnectPayload) => void,\n\t): ClientConnection {\n\t\tthis.callbacks.onClose.push(callback);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Create a new connection by the given request and document\n\t */\n\tprivate createConnection(\n\t\tconnection: WebSocketLike,\n\t\tdocument: Document,\n\t\thookPayload: (typeof this.hookPayloads)[string],\n\t\tsessionId: string | null,\n\t\tproviderVersion: string | null,\n\t): Connection {\n\t\tconst instance = new Connection(\n\t\t\tconnection,\n\t\t\thookPayload.request,\n\t\t\tdocument,\n\t\t\thookPayload.socketId,\n\t\t\thookPayload.context,\n\t\t\thookPayload.connectionConfig.readOnly,\n\t\t\tsessionId,\n\t\t\tproviderVersion,\n\t\t);\n\n\t\tinstance.onClose(async (document, event) => {\n\t\t\t// Wait for any pending message processing to complete before running\n\t\t\t// disconnect hooks. This ensures that document updates from queued messages\n\t\t\t// are applied (and their debounced onStoreDocument scheduled) before the\n\t\t\t// disconnect handler checks whether to call executeNow.\n\t\t\tawait instance.waitForPendingMessages();\n\n\t\t\tconst disconnectHookPayload: onDisconnectPayload = {\n\t\t\t\tinstance: this.documentProvider as Hocuspocus, // TODO, this will be removed when we use events instead of hooks for this class\n\t\t\t\tclientsCount: document.getConnectionsCount(),\n\t\t\t\tcontext: hookPayload.context,\n\t\t\t\tdocument,\n\t\t\t\tsocketId: hookPayload.socketId,\n\t\t\t\tdocumentName: document.name,\n\t\t\t\trequestHeaders: hookPayload.request.headers,\n\t\t\t\trequestParameters: getParameters(hookPayload.request),\n\t\t\t};\n\n\t\t\tawait this.hooks(\"onDisconnect\", disconnectHookPayload);\n\t\t\tthis.callbacks.onClose.forEach((callback) =>\n\t\t\t\tcallback(document, disconnectHookPayload),\n\t\t\t);\n\t\t});\n\n\t\tinstance.onStatelessCallback(async (payload) => {\n\t\t\ttry {\n\t\t\t\treturn await this.hooks(\"onStateless\", payload);\n\t\t\t} catch (error: any) {\n\t\t\t\tif (error?.message) {\n\t\t\t\t\t// if a hook rejects and the error is empty, do nothing\n\t\t\t\t\t// this is only meant to prevent later hooks and the\n\t\t\t\t\t// default handler to do something. if an error is present\n\t\t\t\t\t// just rethrow it\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tinstance.beforeHandleMessage((connection, update) => {\n\t\t\tconst beforeHandleMessagePayload: beforeHandleMessagePayload = {\n\t\t\t\tinstance: this.documentProvider as Hocuspocus, // TODO, this will be removed when we use events instead of hooks for this class\n\t\t\t\tclientsCount: document.getConnectionsCount(),\n\t\t\t\tcontext: hookPayload.context,\n\t\t\t\tdocument,\n\t\t\t\tsocketId: hookPayload.socketId,\n\t\t\t\tconnection,\n\t\t\t\tdocumentName: document.name,\n\t\t\t\trequestHeaders: hookPayload.request.headers,\n\t\t\t\trequestParameters: getParameters(hookPayload.request),\n\t\t\t\tupdate,\n\t\t\t};\n\n\t\t\treturn this.hooks(\"beforeHandleMessage\", beforeHandleMessagePayload);\n\t\t});\n\n\t\tinstance.afterHandleMessage((connection, update) => {\n\t\t\tconst afterHandleMessagePayload: afterHandleMessagePayload = {\n\t\t\t\tinstance: this.documentProvider as Hocuspocus,\n\t\t\t\tclientsCount: document.getConnectionsCount(),\n\t\t\t\tcontext: hookPayload.context,\n\t\t\t\tdocument,\n\t\t\t\tsocketId: hookPayload.socketId,\n\t\t\t\tconnection,\n\t\t\t\tdocumentName: document.name,\n\t\t\t\trequestHeaders: hookPayload.request.headers,\n\t\t\t\trequestParameters: getParameters(hookPayload.request),\n\t\t\t\tupdate,\n\t\t\t};\n\n\t\t\treturn this.hooks(\"afterHandleMessage\", afterHandleMessagePayload);\n\t\t});\n\n\t\tinstance.beforeSync((connection, payload) => {\n\t\t\tconst beforeSyncPayload: beforeSyncPayload = {\n\t\t\t\tclientsCount: document.getConnectionsCount(),\n\t\t\t\tcontext: hookPayload.context,\n\t\t\t\tdocument,\n\t\t\t\tdocumentName: document.name,\n\t\t\t\tconnection,\n\t\t\t\ttype: payload.type,\n\t\t\t\tpayload: payload.payload,\n\t\t\t};\n\n\t\t\treturn this.hooks(\"beforeSync\", beforeSyncPayload);\n\t\t});\n\n\t\treturn instance;\n\t}\n\n\t// Once all hooks are run, we'll fully establish the connection:\n\tprivate setUpNewConnection = async (rawKey: string, documentName: string, sessionId: string | null) => {\n\t\tconst hookPayload = this.hookPayloads[rawKey];\n\t\t// If no hook interrupts, create a document and connection\n\t\tconst document = await this.documentProvider.createDocument(\n\t\t\tdocumentName,\n\t\t\thookPayload.request,\n\t\t\thookPayload.socketId,\n\t\t\thookPayload.connectionConfig,\n\t\t\thookPayload.context,\n\t\t);\n\t\tconst connection = this.createConnection(this.websocket, document, hookPayload, sessionId, hookPayload.providerVersion);\n\n\t\tconnection.onClose((document, event) => {\n\t\t\tdelete this.hookPayloads[rawKey];\n\t\t\tdelete this.documentConnections[rawKey];\n\t\t\tdelete this.incomingMessageQueue[rawKey];\n\t\t\tdelete this.incomingMessageQueueBytes[rawKey];\n\t\t\tthis.documentConnectionsEstablished.delete(rawKey);\n\t\t});\n\n\t\tconnection.onTokenSyncCallback(async (payload) => {\n\t\t\ttry {\n\t\t\t\treturn await this.hooks(\n\t\t\t\t\t\"onTokenSync\",\n\t\t\t\t\t{\n\t\t\t\t\t\t...hookPayload,\n\t\t\t\t\t\t...payload,\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t\tconnection,\n\t\t\t\t\t\tdocumentName,\n\t\t\t\t\t},\n\t\t\t\t\t(contextAdditions: Partial<Context>) => {\n\t\t\t\t\t\thookPayload.context = {\n\t\t\t\t\t\t\t...hookPayload.context,\n\t\t\t\t\t\t\t...contextAdditions,\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (err: any) {\n\t\t\t\tconsole.error(err);\n\t\t\t\tconst error = { ...Unauthorized, ...err };\n\t\t\t\tconnection.close({ code: error.code, reason: error.reason });\n\t\t\t}\n\t\t});\n\n\t\tthis.documentConnections[rawKey] = connection;\n\n\t\t// If the WebSocket has already disconnected (wow, that was fast) – then\n\t\t// immediately call close to cleanup the connection and document in memory.\n\t\tif (\n\t\t\tthis.websocket.readyState === WsReadyStates.Closing ||\n\t\t\tthis.websocket.readyState === WsReadyStates.Closed\n\t\t) {\n\t\t\tthis.close();\n\t\t\treturn;\n\t\t}\n\n\t\t// Drain queued messages to the Connection. Once drained, the buffered\n\t\t// data is no longer needed (subsequent messages route straight to the\n\t\t// Connection), so release it and stop counting it against the queue\n\t\t// limits.\n\t\tthis.incomingMessageQueue[rawKey]?.forEach((input) => {\n\t\t\tconnection.handleMessage(input);\n\t\t});\n\t\tdelete this.incomingMessageQueue[rawKey];\n\t\tdelete this.incomingMessageQueueBytes[rawKey];\n\n\t\tawait this.hooks(\"connected\", {\n\t\t\t...hookPayload,\n\t\t\tdocumentName,\n\t\t\tcontext: hookPayload.context,\n\t\t\tconnection,\n\t\t});\n\t};\n\n\t// This listener handles authentication messages and queues everything else.\n\tprivate handleQueueingMessage = async (data: Uint8Array, rawKey: string, documentName: string) => {\n\t\ttry {\n\t\t\tconst tmpMsg = new SocketIncomingMessage(data);\n\n\t\t\tdecoding.readVarString(tmpMsg.decoder); // skip the message address (already extracted)\n\t\t\tconst type = decoding.readVarUint(tmpMsg.decoder);\n\n\t\t\tif (\n\t\t\t\t!(\n\t\t\t\t\ttype === MessageType.Auth &&\n\t\t\t\t\t!this.documentConnectionsEstablished.has(rawKey)\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Bound the amount of data buffered before authentication. An\n\t\t\t\t// unauthenticated client must not be able to grow this queue without\n\t\t\t\t// limit (GHSA-xwhh-v746-pj9m).\n\t\t\t\tconst queuedBytes = this.getQueuedBytes();\n\t\t\t\tconst queuedMessages = this.getQueuedMessageCount();\n\t\t\t\tconst exceedsBytes =\n\t\t\t\t\tqueuedBytes + data.byteLength > this.maxUnauthenticatedQueueSize;\n\t\t\t\tconst exceedsMessages =\n\t\t\t\t\tqueuedMessages + 1 > this.maxUnauthenticatedQueueMessages;\n\n\t\t\t\tif (exceedsBytes || exceedsMessages) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\texceedsBytes\n\t\t\t\t\t\t\t? `Hocuspocus: closing connection ${this.socketId}: unauthenticated message queue size limit exceeded for \"${documentName}\" (${queuedBytes + data.byteLength} > maxUnauthenticatedQueueSize ${this.maxUnauthenticatedQueueSize} bytes).`\n\t\t\t\t\t\t\t: `Hocuspocus: closing connection ${this.socketId}: unauthenticated message queue length limit exceeded for \"${documentName}\" (${queuedMessages + 1} > maxUnauthenticatedQueueMessages ${this.maxUnauthenticatedQueueMessages}).`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.terminate(ResetConnection);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.incomingMessageQueue[rawKey].push(data);\n\t\t\t\tthis.incomingMessageQueueBytes[rawKey] =\n\t\t\t\t\t(this.incomingMessageQueueBytes[rawKey] ?? 0) + data.byteLength;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Okay, we've got the authentication message we're waiting for:\n\t\t\tthis.documentConnectionsEstablished.add(rawKey);\n\n\t\t\t// The 2nd integer contains the submessage type\n\t\t\t// which will always be authentication when sent from client -> server\n\t\t\tdecoding.readVarUint(tmpMsg.decoder);\n\t\t\tconst token = decoding.readVarString(tmpMsg.decoder);\n\n\t\t\t// Try to read providerVersion (new protocol field)\n\t\t\tlet providerVersion: string | null = null;\n\t\t\tif (decoding.hasContent(tmpMsg.decoder)) {\n\t\t\t\tproviderVersion = decoding.readVarString(tmpMsg.decoder);\n\t\t\t}\n\n\t\t\t// Extract sessionId from the rawKey (documentName\\0sessionId) if present\n\t\t\tconst sepIdx = rawKey.indexOf('\\0');\n\t\t\tconst sessionId = sepIdx === -1 ? null : rawKey.substring(sepIdx + 1);\n\n\t\t\t// Response uses rawKey so session-aware clients can route correctly\n\t\t\tconst responseAddress = rawKey;\n\n\t\t\ttry {\n\t\t\t\tconst hookPayload = this.hookPayloads[rawKey];\n\t\t\t\thookPayload.providerVersion = providerVersion;\n\n\t\t\t\tawait this.hooks(\n\t\t\t\t\t\"onConnect\",\n\t\t\t\t\t{ ...hookPayload, documentName },\n\t\t\t\t\t(contextAdditions: Partial<Context>) => {\n\t\t\t\t\t\thookPayload.context = {\n\t\t\t\t\t\t\t...hookPayload.context,\n\t\t\t\t\t\t\t...contextAdditions,\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tawait this.hooks(\n\t\t\t\t\t\"onAuthenticate\",\n\t\t\t\t\t{\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t...hookPayload,\n\t\t\t\t\t\tdocumentName,\n\t\t\t\t\t},\n\t\t\t\t\t(contextAdditions: Partial<Context>) => {\n\t\t\t\t\t\thookPayload.context = {\n\t\t\t\t\t\t\t...hookPayload.context,\n\t\t\t\t\t\t\t...contextAdditions,\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\t// All `onAuthenticate` hooks passed.\n\t\t\t\thookPayload.connectionConfig.isAuthenticated = true;\n\t\t\t\tthis.hasAuthenticated = true;\n\n\t\t\t\t// Let the client know that authentication was successful.\n\t\t\t\tconst message = new OutgoingMessage(responseAddress).writeAuthenticated(\n\t\t\t\t\thookPayload.connectionConfig.readOnly,\n\t\t\t\t);\n\n\t\t\t\tthis.websocket.send(message.toUint8Array());\n\n\t\t\t\t// Time to actually establish the connection.\n\t\t\t\tawait this.setUpNewConnection(rawKey, documentName, sessionId);\n\t\t\t} catch (err: any) {\n\t\t\t\tconst error = err || Forbidden;\n\t\t\t\tconst message = new OutgoingMessage(responseAddress).writePermissionDenied(\n\t\t\t\t\terror.reason ?? \"permission-denied\",\n\t\t\t\t);\n\n\t\t\t\tthis.websocket.send(message.toUint8Array());\n\n\t\t\t\t// Clean up all state for this document so a retry is treated\n\t\t\t\t// as a fresh first connection attempt.\n\t\t\t\tthis.documentConnectionsEstablished.delete(rawKey);\n\t\t\t\tdelete this.hookPayloads[rawKey];\n\t\t\t\tdelete this.incomingMessageQueue[rawKey];\n\t\t\t\tdelete this.incomingMessageQueueBytes[rawKey];\n\t\t\t}\n\n\t\t\t// Catch errors due to failed decoding of data\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t\tthis.websocket.close(ResetConnection.code, ResetConnection.reason);\n\t\t}\n\t};\n\n\t/**\n\t * Handle an incoming WebSocket message. Call this from your integration\n\t * when the WebSocket receives a binary message.\n\t */\n\thandleMessage = (data: Uint8Array) => {\n\t\t// Ignore anything that arrives after we've decided to tear the connection\n\t\t// down (e.g. frames that were already in flight when a limit was breached).\n\t\tif (this.terminated) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lastMessageReceivedAt = Date.now();\n\n\t\ttry {\n\t\t\tconst tmpMsg = new SocketIncomingMessage(data);\n\n\t\t\tconst rawKey = decoding.readVarString(tmpMsg.decoder);\n\n\t\t\t// Extract the plain documentName (the raw key may be documentName\\0sessionId)\n\t\t\tconst sepIdx = rawKey.indexOf('\\0');\n\t\t\tconst documentName = sepIdx === -1 ? rawKey : rawKey.substring(0, sepIdx);\n\n\t\t\t// Look up by rawKey first (session-aware providers), then fall back\n\t\t\t// to plain documentName for backward compatibility with old providers\n\t\t\tconst connection = this.documentConnections[rawKey]\n\t\t\t\t?? this.documentConnections[documentName];\n\t\t\tif (connection) {\n\t\t\t\tconnection.handleMessage(data);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isFirst = this.incomingMessageQueue[rawKey] === undefined;\n\t\t\tif (isFirst) {\n\t\t\t\t// Cap the number of documents a single connection can open before\n\t\t\t\t// authenticating any of them. Each pending document allocates its own\n\t\t\t\t// queue and hook payload, so this prevents memory amplification by\n\t\t\t\t// fanning out across many document names (GHSA-xwhh-v746-pj9m).\n\t\t\t\tif (this.getPendingDocumentCount() >= this.maxPendingDocuments) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Hocuspocus: closing connection ${this.socketId}: too many pending unauthenticated documents (maxPendingDocuments ${this.maxPendingDocuments}). Last requested document: \"${documentName}\".`,\n\t\t\t\t\t);\n\t\t\t\t\tthis.terminate(ResetConnection);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.incomingMessageQueue[rawKey] = [];\n\t\t\t\tif (this.hookPayloads[rawKey]) {\n\t\t\t\t\tthrow new Error(\"first message, but hookPayloads exists\");\n\t\t\t\t}\n\n\t\t\t\tthis.hookPayloads[rawKey] = {\n\t\t\t\t\tinstance: this.documentProvider as Hocuspocus,\n\t\t\t\t\trequest: this.request,\n\t\t\t\t\tconnectionConfig: {\n\t\t\t\t\t\treadOnly: false,\n\t\t\t\t\t\tisAuthenticated: false,\n\t\t\t\t\t},\n\t\t\t\t\trequestHeaders: this.request.headers,\n\t\t\t\t\trequestParameters: getParameters(this.request),\n\t\t\t\t\tsocketId: this.socketId,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...this.defaultContext,\n\t\t\t\t\t},\n\t\t\t\t\tproviderVersion: null as string | null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.handleQueueingMessage(data, rawKey, documentName);\n\t\t} catch (closeError) {\n\t\t\t// catch is needed in case an invalid payload crashes the parsing of the Uint8Array\n\t\t\tconsole.error(closeError);\n\t\t\tthis.websocket.close(Unauthorized.code, Unauthorized.reason);\n\t\t}\n\t};\n}\n","import { URLSearchParams } from \"node:url\";\nimport type Document from \"./Document.ts\";\nimport type { Hocuspocus } from \"./Hocuspocus.ts\";\nimport type {\n\tDirectConnection as DirectConnectionInterface,\n\tDisconnectOptions,\n\tLocalTransactionOrigin,\n} from \"./types.ts\";\n\nexport class DirectConnection<Context = any>\n\timplements DirectConnectionInterface\n{\n\tdocument: Document | null = null;\n\n\tinstance!: Hocuspocus;\n\n\tcontext: Context;\n\n\t/**\n\t * Constructor.\n\t */\n\tconstructor(document: Document, instance: Hocuspocus, context?: Context) {\n\t\tthis.document = document;\n\t\tthis.instance = instance;\n\t\tthis.context = (context ?? {}) as Context;\n\n\t\tthis.document.addDirectConnection();\n\t}\n\n\tasync transact(transaction: (document: Document) => void) {\n\t\tif (!this.document) {\n\t\t\tthrow new Error(\"direct connection closed\");\n\t\t}\n\n\t\tthis.document.transact(\n\t\t\t(x) => {\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: <explanation>\n\t\t\t\ttransaction(this.document!);\n\t\t\t},\n\t\t\t{\n\t\t\t\tsource: \"local\",\n\t\t\t\tcontext: this.context,\n\t\t\t} satisfies LocalTransactionOrigin,\n\t\t);\n\t}\n\n\tasync disconnect(options?: DisconnectOptions) {\n\t\tif (this.document) {\n\t\t\t// Defaults to true regardless of the server-wide `unloadImmediately`\n\t\t\t// setting, so the historical \"durable on disconnect\" behavior is kept\n\t\t\t// unless a caller explicitly opts into keeping the document warm.\n\t\t\tconst unloadImmediately = options?.unloadImmediately ?? true;\n\n\t\t\tthis.document?.removeDirectConnection();\n\n\t\t\t// With unloadImmediately the document is persisted synchronously.\n\t\t\t// Otherwise the store is debounced, so the document stays warm in memory\n\t\t\t// and a follow-up direct connection can reuse it (coalescing writes),\n\t\t\t// mirroring how websocket connections behave on close.\n\t\t\tawait this.instance.storeDocumentHooks(\n\t\t\t\tthis.document,\n\t\t\t\t{\n\t\t\t\t\tclientsCount: this.document.getConnectionsCount(),\n\t\t\t\t\tlastContext: this.context,\n\t\t\t\t\tlastTransactionOrigin: {\n\t\t\t\t\t\tsource: \"local\",\n\t\t\t\t\t\tcontext: this.context,\n\t\t\t\t\t} satisfies LocalTransactionOrigin,\n\t\t\t\t\tdocument: this.document,\n\t\t\t\t\tdocumentName: this.document.name,\n\t\t\t\t\tinstance: this.instance,\n\t\t\t\t},\n\t\t\t\tunloadImmediately,\n\t\t\t);\n\n\t\t\t// If the direct connection was the only connection to the document\n\t\t\t// then we should trigger the onDisconnect hook for this doc. We only\n\t\t\t// unload it right away when unloadImmediately is set; otherwise the\n\t\t\t// debounced store above unloads it once it has flushed.\n\t\t\tif (\n\t\t\t\tthis.document.getConnectionsCount() === 0 &&\n\t\t\t\t!this.document.saveMutex.isLocked()\n\t\t\t) {\n\t\t\t\tawait this.instance.hooks(\"onDisconnect\", {\n\t\t\t\t\tinstance: this.instance,\n\t\t\t\t\tclientsCount: this.document.getConnectionsCount(),\n\t\t\t\t\tcontext: this.context,\n\t\t\t\t\tdocument: this.document,\n\t\t\t\t\tsocketId: \"server\",\n\t\t\t\t\tdocumentName: this.document.name,\n\t\t\t\t\trequestHeaders: new Headers(),\n\t\t\t\t\trequestParameters: new URLSearchParams(),\n\t\t\t\t});\n\n\t\t\t\tif (unloadImmediately) {\n\t\t\t\t\tawait this.instance.unloadDocument(this.document);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.document = null;\n\t\t}\n\t}\n}\n","export const useDebounce = () => {\n\tconst timers: Map<\n\t\tstring,\n\t\t{\n\t\t\ttimeout: NodeJS.Timeout;\n\t\t\tstart: number;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n\t\t\tfunc: () => any | Promise<() => any>;\n\t\t}\n\t> = new Map();\n\n\tconst runningExecutions: Map<string, Promise<any>> = new Map();\n\n\tconst debounce = async (\n\t\tid: string,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n\t\tfunc: () => any | Promise<() => any>,\n\t\tdebounce: number,\n\t\tmaxDebounce: number,\n\t) => {\n\t\tconst old = timers.get(id);\n\t\tconst start = old?.start || Date.now();\n\n\t\tconst run = async () => {\n\t\t\ttimers.delete(id);\n\n\t\t\tif (runningExecutions.has(id)) {\n\t\t\t\t// wait for previous execution to finish\n\t\t\t\tawait runningExecutions.get(id);\n\t\t\t}\n\n\t\t\tconst execution = func();\n\n\t\t\trunningExecutions.set(id, execution);\n\t\t\tconst executionResult = await execution;\n\t\t\trunningExecutions.delete(id);\n\n\t\t\treturn executionResult;\n\t\t};\n\n\t\tif (old?.timeout) {\n\t\t\tclearTimeout(old.timeout);\n\t\t}\n\n\t\tif (debounce === 0) {\n\t\t\treturn run();\n\t\t}\n\n\t\tif (Date.now() - start >= maxDebounce) {\n\t\t\treturn run();\n\t\t}\n\n\t\ttimers.set(id, {\n\t\t\tstart,\n\t\t\ttimeout: setTimeout(run, debounce),\n\t\t\tfunc: run,\n\t\t});\n\t};\n\n\tconst executeNow = (id: string) => {\n\t\tconst old = timers.get(id);\n\t\tif (old) {\n\t\t\tclearTimeout(old.timeout);\n\t\t\treturn old.func();\n\t\t}\n\t};\n\n\tconst isDebounced = (id: string): boolean => {\n\t\treturn timers.has(id);\n\t};\n\n\tconst isCurrentlyExecuting = (id: string): boolean => {\n\t\treturn runningExecutions.has(id);\n\t};\n\n\treturn { debounce, isDebounced, isCurrentlyExecuting, executeNow };\n};\n","import crypto from \"node:crypto\";\nimport { awarenessStatesToArray, ResetConnection, SkipFurtherHooksError } from \"@hocuspocus/common\";\nimport { applyUpdate, Doc, encodeStateAsUpdate } from \"yjs\";\nimport meta from \"../package.json\" with { type: \"json\" };\n\nimport { ClientConnection } from \"./ClientConnection.ts\";\nimport { DirectConnection } from \"./DirectConnection.ts\";\nimport Document from \"./Document.ts\";\nimport type { Server } from \"./Server.ts\";\nimport type {\n\tAwarenessUpdate,\n\tbeforeBroadcastStatelessPayload,\n\tConfiguration,\n\tConnectionConfiguration,\n\tHookName,\n\tHookPayloadByName,\n\tonChangePayload,\n\tonDisconnectPayload,\n\tonStoreDocumentPayload,\n\tWebSocketLike,\n} from \"./types.ts\";\nimport { isTransactionOrigin, shouldSkipStoreHooks } from \"./types.ts\";\nimport { useDebounce } from \"./util/debounce.ts\";\nimport { getParameters } from \"./util/getParameters.ts\";\n\nexport const defaultConfiguration = {\n\tname: null,\n\ttimeout: 60_000,\n\tdebounce: 2_000,\n\tmaxDebounce: 10_000,\n\tquiet: false,\n\tyDocOptions: {\n\t\tgc: true,\n\t\tgcFilter: () => true,\n\t},\n\tunloadImmediately: true,\n\tmaxUnauthenticatedQueueSize: 5 * 1024 * 1024,\n\tmaxUnauthenticatedQueueMessages: 1_000,\n\tmaxPendingDocuments: 100,\n};\n\nexport class Hocuspocus<Context = any> {\n\tconfiguration: Configuration<Context> = {\n\t\t...defaultConfiguration,\n\t\textensions: [],\n\t\tonConfigure: () => new Promise((r) => r(null)),\n\t\tonListen: () => new Promise((r) => r(null)),\n\t\tonUpgrade: () => new Promise((r) => r(null)),\n\t\tonConnect: () => new Promise((r) => r(null)),\n\t\tconnected: () => new Promise((r) => r(null)),\n\t\tbeforeHandleMessage: () => new Promise((r) => r(null)),\n\t\tafterHandleMessage: () => new Promise((r) => r(null)),\n\t\tbeforeHandleAwareness: () => new Promise<void>((r) => r()),\n\t\tbeforeSync: () => new Promise((r) => r(null)),\n\t\tbeforeBroadcastStateless: () => new Promise((r) => r(null)),\n\t\tonStateless: () => new Promise((r) => r(null)),\n\t\tonChange: () => new Promise((r) => r(null)),\n\t\tonCreateDocument: () => new Promise((r) => r(null)),\n\t\tonLoadDocument: () => new Promise((r) => r(null)),\n\t\tonStoreDocument: () => new Promise((r) => r(null)),\n\t\tafterStoreDocument: () => new Promise((r) => r(null)),\n\t\tonAwarenessUpdate: () => new Promise((r) => r(null)),\n\t\tonRequest: () => new Promise((r) => r(null)),\n\t\tonDisconnect: () => new Promise((r) => r(null)),\n\t\tonDestroy: () => new Promise((r) => r(null)),\n\t};\n\n\tloadingDocuments: Map<string, Promise<Document>> = new Map();\n\tunloadingDocuments: Map<string, Promise<void>> = new Map();\n\n\tdocuments: Map<string, Document> = new Map();\n\n\tserver?: Server;\n\n\tdebouncer = useDebounce();\n\n\tconstructor(configuration?: Partial<Configuration<Context>>) {\n\t\tif (configuration) {\n\t\t\tthis.configure(configuration);\n\t\t}\n\t}\n\n\t/**\n\t * Configure Hocuspocus\n\t */\n\tconfigure(\n\t\tconfiguration: Partial<Configuration<Context>>,\n\t): Hocuspocus<Context> {\n\t\tthis.configuration = {\n\t\t\t...this.configuration,\n\t\t\t...configuration,\n\t\t};\n\n\t\tthis.configuration.extensions.sort((a, b) => {\n\t\t\tconst one = typeof a.priority === \"undefined\" ? 100 : a.priority;\n\t\t\tconst two = typeof b.priority === \"undefined\" ? 100 : b.priority;\n\n\t\t\tif (one > two) {\n\t\t\t\treturn -1;\n\t\t\t}\n\n\t\t\tif (one < two) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t});\n\n\t\tthis.configuration.extensions.push({\n\t\t\tonConfigure: this.configuration.onConfigure,\n\t\t\tonListen: this.configuration.onListen,\n\t\t\tonUpgrade: this.configuration.onUpgrade,\n\t\t\tonConnect: this.configuration.onConnect,\n\t\t\tconnected: this.configuration.connected,\n\t\t\tonAuthenticate: this.configuration.onAuthenticate,\n\t\t\tonTokenSync: this.configuration.onTokenSync,\n\t\t\tonLoadDocument: this.configuration.onLoadDocument,\n\t\t\tafterLoadDocument: this.configuration.afterLoadDocument,\n\t\t\tbeforeHandleMessage: this.configuration.beforeHandleMessage,\n\t\t\tafterHandleMessage: this.configuration.afterHandleMessage,\n\t\t\tbeforeHandleAwareness: this.configuration.beforeHandleAwareness,\n\t\t\tbeforeBroadcastStateless: this.configuration.beforeBroadcastStateless,\n\t\t\tbeforeSync: this.configuration.beforeSync,\n\t\t\tonStateless: this.configuration.onStateless,\n\t\t\tonChange: this.configuration.onChange,\n\t\t\tonStoreDocument: this.configuration.onStoreDocument,\n\t\t\tafterStoreDocument: this.configuration.afterStoreDocument,\n\t\t\tonAwarenessUpdate: this.configuration.onAwarenessUpdate,\n\t\t\tonRequest: this.configuration.onRequest,\n\t\t\tbeforeUnloadDocument: this.configuration.beforeUnloadDocument,\n\t\t\tafterUnloadDocument: this.configuration.afterUnloadDocument,\n\t\t\tonDisconnect: this.configuration.onDisconnect,\n\t\t\tonDestroy: this.configuration.onDestroy,\n\t\t});\n\n\t\tthis.hooks(\"onConfigure\", {\n\t\t\tconfiguration: this.configuration,\n\t\t\tversion: meta.version,\n\t\t\tinstance: this,\n\t\t});\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the total number of active documents\n\t */\n\tgetDocumentsCount(): number {\n\t\treturn this.documents.size;\n\t}\n\n\t/**\n\t * Get the total number of active connections\n\t */\n\tgetConnectionsCount(): number {\n\t\tconst uniqueSocketIds = new Set<string>();\n\t\tconst totalDirectConnections = Array.from(this.documents.values()).reduce(\n\t\t\t(acc, document) => {\n\t\t\t\t// Accumulate unique socket IDs\n\t\t\t\tdocument.getConnections().forEach(({ socketId }) => {\n\t\t\t\t\tuniqueSocketIds.add(socketId);\n\t\t\t\t});\n\t\t\t\t// Accumulate direct connections\n\t\t\t\treturn acc + document.directConnectionsCount;\n\t\t\t},\n\t\t\t0,\n\t\t);\n\t\t// Return the sum of unique socket IDs and direct connections\n\t\treturn uniqueSocketIds.size + totalDirectConnections;\n\t}\n\n\t/**\n\t * Immediately execute all pending debounced onStoreDocument calls.\n\t * Useful during shutdown to ensure documents are persisted and unloaded\n\t * before the server exits, even when unloadImmediately is false.\n\t */\n\tflushPendingStores() {\n\t\tthis.documents.forEach((document: Document) => {\n\t\t\tconst debounceId = `onStoreDocument-${document.name}`;\n\t\t\tif (!document.isLoading && this.debouncer.isDebounced(debounceId)) {\n\t\t\t\tthis.debouncer.executeNow(debounceId);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Force close one or more connections\n\t */\n\tcloseConnections(documentName?: string) {\n\t\t// Iterate through all connections for all documents\n\t\t// and invoke their close method, which is a graceful\n\t\t// disconnect wrapper around the underlying websocket.close\n\t\tthis.documents.forEach((document: Document) => {\n\t\t\t// If a documentName was specified, bail if it doesn't match\n\t\t\tif (documentName && document.name !== documentName) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdocument.connections.forEach((_clients, connection) => {\n\t\t\t\tconnection.close(ResetConnection);\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * The `handleConnection` method receives incoming WebSocket connections,\n\t * runs all hooks:\n\t *\n\t *  - onConnect for all connections\n\t *  - onAuthenticate only if required\n\t *\n\t * … and if nothing fails it'll fully establish the connection and\n\t * load the Document then.\n\t */\n\thandleConnection(\n\t\tincoming: WebSocket | WebSocketLike,\n\t\trequest: Request,\n\t\tdefaultContext: Context = {} as Context,\n\t): ClientConnection {\n\t\tconst clientConnection = new ClientConnection(\n\t\t\tincoming,\n\t\t\trequest,\n\t\t\tthis,\n\t\t\tthis.hooks.bind(this),\n\t\t\t{\n\t\t\t\ttimeout: this.configuration.timeout,\n\t\t\t\tmaxUnauthenticatedQueueSize:\n\t\t\t\t\tthis.configuration.maxUnauthenticatedQueueSize,\n\t\t\t\tmaxUnauthenticatedQueueMessages:\n\t\t\t\t\tthis.configuration.maxUnauthenticatedQueueMessages,\n\t\t\t\tmaxPendingDocuments: this.configuration.maxPendingDocuments,\n\t\t\t},\n\t\t\tdefaultContext,\n\t\t);\n\t\tclientConnection.onClose(\n\t\t\t(document: Document, hookPayload: onDisconnectPayload) => {\n\t\t\t\t// Check if there are still no connections to the document, as these hooks\n\t\t\t\t// may take some time to resolve (e.g. database queries). If a\n\t\t\t\t// new connection were to come in during that time it would rely on the\n\t\t\t\t// document in the map that we remove now.\n\t\t\t\tif (document.getConnectionsCount() > 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If it’s the last connection, we need to make sure to store the\n\t\t\t\t// document. Use the debouncer executeNow helper, to run scheduled\n\t\t\t\t// onStoreDocument immediately and clear running timers.\n\t\t\t\t// If there is no scheduled run for this document there is no point in\n\t\t\t\t// triggering onStoreDocument hook, as everything seems to be stored already.\n\t\t\t\t// Only run this if the document has finished loading earlier (i.e. not to persist the empty\n\t\t\t\t// ydoc if the onLoadDocument hook returned an error)\n\t\t\t\tif (\n\t\t\t\t\t!document.isLoading &&\n\t\t\t\t\tthis.debouncer.isDebounced(`onStoreDocument-${document.name}`)\n\t\t\t\t) {\n\t\t\t\t\tif (this.configuration.unloadImmediately) {\n\t\t\t\t\t\tthis.debouncer.executeNow(`onStoreDocument-${document.name}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Remove document from memory immediately\n\t\t\t\t\tthis.unloadDocument(document);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\treturn clientConnection;\n\t}\n\n\t/**\n\t * Handle update of the given document\n\t *\n\t * \"connection\" is not necessarily type \"Connection\", it's the Yjs \"origin\" (which is \"Connection\" if\n\t * the update is incoming from the provider, but can be anything if the updates is originated from an extension.\n\t */\n\tprivate handleDocumentUpdate(\n\t\tdocument: Document,\n\t\torigin: unknown,\n\t\tupdate: Uint8Array,\n\t) {\n\t\tconst connection =\n\t\t\tisTransactionOrigin(origin) && origin.source === \"connection\"\n\t\t\t\t? origin.connection\n\t\t\t\t: undefined;\n\t\tconst request = connection?.request;\n\t\tconst context = isTransactionOrigin(origin)\n\t\t\t? origin.source === \"connection\"\n\t\t\t\t? origin.connection.context\n\t\t\t\t: origin.source === \"local\"\n\t\t\t\t\t? (origin.context ?? {})\n\t\t\t\t\t: {}\n\t\t\t: {};\n\n\t\tconst changePayload: onChangePayload = {\n\t\t\tinstance: this,\n\t\t\tclientsCount: document.getConnectionsCount(),\n\t\t\tdocument,\n\t\t\tdocumentName: document.name,\n\t\t\trequestHeaders: request?.headers ?? new Headers(),\n\t\t\trequestParameters: getParameters(request),\n\t\t\tsocketId: connection?.socketId ?? \"\",\n\t\t\tupdate,\n\t\t\ttransactionOrigin: origin,\n\t\t\tconnection: connection,\n\t\t\tcontext,\n\t\t};\n\n\t\tthis.hooks(\"onChange\", changePayload);\n\n\t\tif (shouldSkipStoreHooks(origin)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst storePayload: onStoreDocumentPayload = {\n\t\t\tinstance: this,\n\t\t\tclientsCount: document.getConnectionsCount(),\n\t\t\tdocument,\n\t\t\tlastContext: context,\n\t\t\tlastTransactionOrigin: origin,\n\t\t\tdocumentName: document.name,\n\t\t};\n\n\t\tthis.storeDocumentHooks(document, storePayload);\n\t}\n\n\t/**\n\t * Create a new document by the given request\n\t */\n\tpublic async createDocument(\n\t\tdocumentName: string,\n\t\trequest: Request,\n\t\tsocketId: string,\n\t\tconnection: ConnectionConfiguration,\n\t\tcontext?: Context,\n\t): Promise<Document> {\n\t\tif (!documentName.trim()) {\n\t\t\tthrow new Error(\"Document name must not be empty\");\n\t\t}\n\n\t\tconst existingLoadingDoc = this.loadingDocuments.get(documentName);\n\n\t\tif (existingLoadingDoc) {\n\t\t\treturn existingLoadingDoc;\n\t\t}\n\n\t\tconst existingDoc = this.documents.get(documentName);\n\t\tif (existingDoc) {\n\t\t\treturn Promise.resolve(existingDoc);\n\t\t}\n\n\t\tconst loadDocPromise = this.loadDocument(\n\t\t\tdocumentName,\n\t\t\trequest,\n\t\t\tsocketId,\n\t\t\tconnection,\n\t\t\tcontext,\n\t\t);\n\n\t\tthis.loadingDocuments.set(documentName, loadDocPromise);\n\n\t\ttry {\n\t\t\tconst doc = await loadDocPromise;\n\t\t\tthis.documents.set(documentName, doc);\n\t\t\tthis.loadingDocuments.delete(documentName);\n\t\t\treturn doc;\n\t\t} catch (e) {\n\t\t\tthis.loadingDocuments.delete(documentName);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\tasync loadDocument(\n\t\tdocumentName: string,\n\t\trequest: Request,\n\t\tsocketId: string,\n\t\tconnectionConfig: ConnectionConfiguration,\n\t\tcontext?: Context,\n\t): Promise<Document> {\n\t\tconst requestHeaders = request.headers;\n\t\tconst requestParameters = getParameters(request);\n\n\t\tconst resolvedContext = (context ?? {}) as Context;\n\n\t\tconst yDocOptions = await this.hooks(\"onCreateDocument\", {\n\t\t\tdocumentName,\n\t\t\trequestHeaders,\n\t\t\trequestParameters,\n\t\t\tconnectionConfig,\n\t\t\tcontext: resolvedContext,\n\t\t\tsocketId,\n\t\t\tinstance: this,\n\t\t});\n\n\t\tconst document = new Document(documentName, {\n\t\t\t...this.configuration.yDocOptions,\n\t\t\t...yDocOptions,\n\t\t});\n\n\t\tconst hookPayload = {\n\t\t\tinstance: this,\n\t\t\tcontext: resolvedContext,\n\t\t\tconnectionConfig,\n\t\t\tdocument,\n\t\t\tdocumentName,\n\t\t\tsocketId,\n\t\t\trequestHeaders,\n\t\t\trequestParameters,\n\t\t};\n\n\t\ttry {\n\t\t\tawait this.hooks(\n\t\t\t\t\"onLoadDocument\",\n\t\t\t\thookPayload,\n\t\t\t\t(loadedDocument: Doc | Uint8ArrayConstructor | undefined) => {\n\t\t\t\t\tif (loadedDocument instanceof Doc) {\n\t\t\t\t\t\tapplyUpdate(document, encodeStateAsUpdate(loadedDocument));\n\t\t\t\t\t} else if (loadedDocument instanceof Uint8Array) {\n\t\t\t\t\t\tapplyUpdate(document, loadedDocument);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tthis.closeConnections(documentName);\n\t\t\tthis.unloadDocument(document);\n\t\t\tthrow e;\n\t\t}\n\n\t\tdocument.isLoading = false;\n\n\t\tdocument.onUpdate(\n\t\t\t(document: Document, origin: unknown, update: Uint8Array) => {\n\t\t\t\tdocument.lastChangeTime = Date.now();\n\n\t\t\t\tthis.handleDocumentUpdate(document, origin, update);\n\t\t\t},\n\t\t);\n\n\t\tawait this.hooks(\"afterLoadDocument\", hookPayload);\n\n\t\tdocument.beforeBroadcastStateless(\n\t\t\t(document: Document, stateless: string) => {\n\t\t\t\tconst hookPayload: beforeBroadcastStatelessPayload = {\n\t\t\t\t\tdocument,\n\t\t\t\t\tdocumentName: document.name,\n\t\t\t\t\tpayload: stateless,\n\t\t\t\t};\n\n\t\t\t\tthis.hooks(\"beforeBroadcastStateless\", hookPayload);\n\t\t\t},\n\t\t);\n\n\t\tdocument.beforeHandleAwareness((document, states, transactionOrigin) => {\n\t\t\tconst connection =\n\t\t\t\tisTransactionOrigin(transactionOrigin) &&\n\t\t\t\ttransactionOrigin.source === \"connection\"\n\t\t\t\t\t? transactionOrigin.connection\n\t\t\t\t\t: undefined;\n\t\t\tconst request = connection?.request;\n\t\t\treturn this.hooks(\"beforeHandleAwareness\", {\n\t\t\t\tawareness: document.awareness,\n\t\t\t\tclientsCount: document.getConnectionsCount(),\n\t\t\t\tcontext: connection?.context,\n\t\t\t\tdocument,\n\t\t\t\tdocumentName: document.name,\n\t\t\t\tinstance: this,\n\t\t\t\trequestHeaders: request?.headers ?? new Headers(),\n\t\t\t\trequestParameters: request\n\t\t\t\t\t? getParameters(request)\n\t\t\t\t\t: new URLSearchParams(),\n\t\t\t\tsocketId: connection?.socketId ?? \"\",\n\t\t\t\ttransactionOrigin,\n\t\t\t\tconnection,\n\t\t\t\tstates,\n\t\t\t});\n\t\t});\n\n\t\tdocument.awareness.on(\n\t\t\t\"update\",\n\t\t\t(update: AwarenessUpdate, origin: unknown) => {\n\t\t\t\tthis.hooks(\"onAwarenessUpdate\", {\n\t\t\t\t\tdocument,\n\t\t\t\t\tdocumentName,\n\t\t\t\t\tinstance: this,\n\t\t\t\t\t...update,\n\t\t\t\t\ttransactionOrigin: origin,\n\t\t\t\t\tconnection:\n\t\t\t\t\t\tisTransactionOrigin(origin) && origin.source === \"connection\"\n\t\t\t\t\t\t\t? origin.connection\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tawareness: document.awareness,\n\t\t\t\t\tstates: awarenessStatesToArray(document.awareness.getStates()),\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\n\t\treturn document;\n\t}\n\n\tstoreDocumentHooks(\n\t\tdocument: Document,\n\t\thookPayload: onStoreDocumentPayload,\n\t\timmediately?: boolean,\n\t) {\n\t\tconst debounceId = `onStoreDocument-${document.name}`;\n\t\treturn this.debouncer.debounce(\n\t\t\tdebounceId,\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait document.saveMutex.runExclusive(async () => {\n\t\t\t\t\t\tawait this.hooks(\"onStoreDocument\", hookPayload);\n\t\t\t\t\t\tawait this.hooks(\"afterStoreDocument\", hookPayload);\n\t\t\t\t\t});\n\t\t\t\t} catch (error: any) {\n\t\t\t\t\tif (error instanceof SkipFurtherHooksError) {\n\t\t\t\t\t\t// Another extension handled this — proceed to unload\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\tif (this.shouldUnloadDocument(document)) {\n\t\t\t\t\t\t\t\tthis.unloadDocument(document);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, 0);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\"Caught error during storeDocumentHooks. Document stays in memory to avoid data loss\",\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tif (this.shouldUnloadDocument(document)) {\n\t\t\t\t\t\tthis.unloadDocument(document);\n\t\t\t\t\t}\n\t\t\t\t}, 0);\n\t\t\t},\n\t\t\timmediately ? 0 : this.configuration.debounce,\n\t\t\tthis.configuration.maxDebounce,\n\t\t);\n\t}\n\n\t/**\n\t * Run the given hook on all configured extensions.\n\t * Runs the given callback after each hook.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n\thooks<T extends HookName>(\n\t\tname: T,\n\t\tpayload: HookPayloadByName<Context>[T],\n\t\t// biome-ignore lint/complexity/noBannedTypes: <explanation>\n\t\tcallback: Function | null = null,\n\t): Promise<any> {\n\t\tconst { extensions } = this.configuration;\n\n\t\t// create a new `thenable` chain\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve\n\t\tlet chain = Promise.resolve();\n\n\t\textensions\n\t\t\t// get me all extensions which have the given hook\n\t\t\t.filter((extension) => typeof extension[name] === \"function\")\n\t\t\t// run through all the configured hooks\n\t\t\t.forEach((extension) => {\n\t\t\t\tchain = chain\n\t\t\t\t\t.then(() => (extension[name] as any)?.(payload))\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\t// make sure to log error messages\n\t\t\t\t\t\tif (error?.message) {\n\t\t\t\t\t\t\tconsole.error(`[${name}]`, error.message);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\n\t\t\t\tif (callback) {\n\t\t\t\t\tchain = chain.then((...args: any[]) => callback(...args));\n\t\t\t\t}\n\t\t\t});\n\n\t\treturn chain;\n\t}\n\n\tshouldUnloadDocument(document: Document): boolean {\n\t\tconst hasPendingWork =\n\t\t\tthis.debouncer.isDebounced(`onStoreDocument-${document.name}`) ||\n\t\t\tthis.debouncer.isCurrentlyExecuting(`onStoreDocument-${document.name}`) ||\n\t\t\tdocument.saveMutex.isLocked();\n\n\t\treturn hasPendingWork === false && document.getConnectionsCount() === 0;\n\t}\n\n\tasync unloadDocument(document: Document): Promise<any> {\n\t\tconst documentName = document.name;\n\n\t\tif (!this.shouldUnloadDocument(document)) return;\n\n\t\tif (!this.documents.has(documentName)) return;\n\n\t\tif (this.unloadingDocuments.has(documentName))\n\t\t\treturn this.unloadingDocuments.get(documentName);\n\n\t\t// we need to make sure that the logic runs just once, even if multiple clients disconnect together\n\t\tconst actualUnloadingLogic = async () => {\n\t\t\ttry {\n\t\t\t\tawait this.hooks(\"beforeUnloadDocument\", {\n\t\t\t\t\tinstance: this,\n\t\t\t\t\tdocumentName,\n\t\t\t\t\tdocument,\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// need sync check here as well, to avoid timing problems\n\t\t\tif (!this.shouldUnloadDocument(document)) return;\n\n\t\t\tthis.documents.delete(documentName);\n\t\t\tdocument.destroy();\n\t\t\tawait this.hooks(\"afterUnloadDocument\", { instance: this, documentName });\n\t\t};\n\n\t\tconst unloading = actualUnloadingLogic();\n\n\t\tthis.unloadingDocuments.set(documentName, Promise.resolve(unloading));\n\n\t\tawait unloading;\n\n\t\tthis.unloadingDocuments.delete(documentName);\n\t}\n\n\tasync openDirectConnection(\n\t\tdocumentName: string,\n\t\tcontext?: Context,\n\t): Promise<DirectConnection<Context>> {\n\t\tconst connectionConfig: ConnectionConfiguration = {\n\t\t\tisAuthenticated: true,\n\t\t\treadOnly: false,\n\t\t};\n\n\t\tconst document: Document = await this.createDocument(\n\t\t\tdocumentName,\n\t\t\tnew Request(\"http://localhost\"), // direct connection has no request params\n\t\t\tcrypto.randomUUID(),\n\t\t\tconnectionConfig,\n\t\t\tcontext,\n\t\t);\n\n\t\treturn new DirectConnection<Context>(document, this, context);\n\t}\n}\n","import { createRequire } from \"node:module\";\n\n//#region rolldown:runtime\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {\n\t\t\tkey = keys[i];\n\t\t\tif (!__hasOwnProp.call(to, key) && key !== except) {\n\t\t\t\t__defProp(to, key, {\n\t\t\t\t\tget: ((k) => from[k]).bind(null, key),\n\t\t\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n\tvalue: mod,\n\tenumerable: true\n}) : target, mod));\nvar __require = /* @__PURE__ */ createRequire(import.meta.url);\n\n//#endregion\nexport { __require as n, __toESM as r, __commonJSMin as t };","//#region src/hooks.ts\nvar AdapterHookable = class {\n\toptions;\n\tconstructor(options) {\n\t\tthis.options = options || {};\n\t}\n\tcallHook(name, arg1, arg2) {\n\t\tconst globalHook = this.options.hooks?.[name];\n\t\tconst globalPromise = globalHook?.(arg1, arg2);\n\t\tconst request = arg1.request || arg1;\n\t\tconst resolveHooksPromise = this.options.resolve?.(request);\n\t\tif (!resolveHooksPromise) return globalPromise;\n\t\tconst resolvePromise = resolveHooksPromise instanceof Promise ? resolveHooksPromise.then((hooks) => hooks?.[name]) : resolveHooksPromise?.[name];\n\t\treturn Promise.all([globalPromise, resolvePromise]).then(([globalRes, hook]) => {\n\t\t\tconst hookResPromise = hook?.(arg1, arg2);\n\t\t\treturn hookResPromise instanceof Promise ? hookResPromise.then((hookRes) => hookRes || globalRes) : hookResPromise || globalRes;\n\t\t});\n\t}\n\tasync upgrade(request) {\n\t\tlet namespace = this.options.getNamespace?.(request) ?? new URL(request.url).pathname;\n\t\tconst context = request.context || {};\n\t\ttry {\n\t\t\tconst res = await this.callHook(\"upgrade\", request);\n\t\t\tif (!res) return {\n\t\t\t\tcontext,\n\t\t\t\tnamespace\n\t\t\t};\n\t\t\tif (res.namespace) namespace = res.namespace;\n\t\t\tif (res.context) Object.assign(context, res.context);\n\t\t\tif (res instanceof Response) return {\n\t\t\t\tcontext,\n\t\t\t\tnamespace,\n\t\t\t\tendResponse: res\n\t\t\t};\n\t\t\tif (res.headers) return {\n\t\t\t\tcontext,\n\t\t\t\tnamespace,\n\t\t\t\tupgradeHeaders: res.headers\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst errResponse = error.response || error;\n\t\t\tif (errResponse instanceof Response) return {\n\t\t\t\tcontext,\n\t\t\t\tnamespace,\n\t\t\t\tendResponse: errResponse\n\t\t\t};\n\t\t\tthrow error;\n\t\t}\n\t\treturn {\n\t\t\tcontext,\n\t\t\tnamespace\n\t\t};\n\t}\n};\nfunction defineHooks(hooks) {\n\treturn hooks;\n}\n\n//#endregion\n//#region src/adapter.ts\nfunction adapterUtils(globalPeers) {\n\treturn {\n\t\tpeers: globalPeers,\n\t\tpublish(topic, message, options) {\n\t\t\tfor (const peers of options?.namespace ? [globalPeers.get(options.namespace) || []] : globalPeers.values()) {\n\t\t\t\tlet firstPeerWithTopic;\n\t\t\t\tfor (const peer of peers) if (peer.topics.has(topic)) {\n\t\t\t\t\tfirstPeerWithTopic = peer;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (firstPeerWithTopic) {\n\t\t\t\t\tfirstPeerWithTopic.send(message, options);\n\t\t\t\t\tfirstPeerWithTopic.publish(topic, message, options);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\nfunction getPeers(globalPeers, namespace) {\n\tif (!namespace) throw new Error(\"Websocket publish namespace missing.\");\n\tlet peers = globalPeers.get(namespace);\n\tif (!peers) {\n\t\tpeers = /* @__PURE__ */ new Set();\n\t\tglobalPeers.set(namespace, peers);\n\t}\n\treturn peers;\n}\nfunction defineWebSocketAdapter(factory) {\n\treturn factory;\n}\n\n//#endregion\nexport { defineHooks as a, AdapterHookable as i, defineWebSocketAdapter as n, getPeers as r, adapterUtils as t };","import { n as __require, r as __toESM, t as __commonJSMin } from \"../rolldown-runtime.mjs\";\n\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/constants.js\nvar require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst BINARY_TYPES = [\n\t\t\"nodebuffer\",\n\t\t\"arraybuffer\",\n\t\t\"fragments\"\n\t];\n\tconst hasBlob = typeof Blob !== \"undefined\";\n\tif (hasBlob) BINARY_TYPES.push(\"blob\");\n\tmodule.exports = {\n\t\tBINARY_TYPES,\n\t\tCLOSE_TIMEOUT: 3e4,\n\t\tEMPTY_BUFFER: Buffer.alloc(0),\n\t\tGUID: \"258EAFA5-E914-47DA-95CA-C5AB0DC85B11\",\n\t\thasBlob,\n\t\tkForOnEventAttribute: Symbol(\"kIsForOnEventAttribute\"),\n\t\tkListener: Symbol(\"kListener\"),\n\t\tkStatusCode: Symbol(\"status-code\"),\n\t\tkWebSocket: Symbol(\"websocket\"),\n\t\tNOOP: () => {}\n\t};\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/buffer-util.js\nvar require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst { EMPTY_BUFFER } = require_constants();\n\tconst FastBuffer = Buffer[Symbol.species];\n\t/**\n\t* Merges an array of buffers into a new buffer.\n\t*\n\t* @param {Buffer[]} list The array of buffers to concat\n\t* @param {Number} totalLength The total length of buffers in the list\n\t* @return {Buffer} The resulting buffer\n\t* @public\n\t*/\n\tfunction concat(list, totalLength) {\n\t\tif (list.length === 0) return EMPTY_BUFFER;\n\t\tif (list.length === 1) return list[0];\n\t\tconst target = Buffer.allocUnsafe(totalLength);\n\t\tlet offset = 0;\n\t\tfor (let i = 0; i < list.length; i++) {\n\t\t\tconst buf = list[i];\n\t\t\ttarget.set(buf, offset);\n\t\t\toffset += buf.length;\n\t\t}\n\t\tif (offset < totalLength) return new FastBuffer(target.buffer, target.byteOffset, offset);\n\t\treturn target;\n\t}\n\t/**\n\t* Masks a buffer using the given mask.\n\t*\n\t* @param {Buffer} source The buffer to mask\n\t* @param {Buffer} mask The mask to use\n\t* @param {Buffer} output The buffer where to store the result\n\t* @param {Number} offset The offset at which to start writing\n\t* @param {Number} length The number of bytes to mask.\n\t* @public\n\t*/\n\tfunction _mask(source, mask, output, offset, length) {\n\t\tfor (let i = 0; i < length; i++) output[offset + i] = source[i] ^ mask[i & 3];\n\t}\n\t/**\n\t* Unmasks a buffer using the given mask.\n\t*\n\t* @param {Buffer} buffer The buffer to unmask\n\t* @param {Buffer} mask The mask to use\n\t* @public\n\t*/\n\tfunction _unmask(buffer, mask) {\n\t\tfor (let i = 0; i < buffer.length; i++) buffer[i] ^= mask[i & 3];\n\t}\n\t/**\n\t* Converts a buffer to an `ArrayBuffer`.\n\t*\n\t* @param {Buffer} buf The buffer to convert\n\t* @return {ArrayBuffer} Converted buffer\n\t* @public\n\t*/\n\tfunction toArrayBuffer(buf) {\n\t\tif (buf.length === buf.buffer.byteLength) return buf.buffer;\n\t\treturn buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);\n\t}\n\t/**\n\t* Converts `data` to a `Buffer`.\n\t*\n\t* @param {*} data The data to convert\n\t* @return {Buffer} The buffer\n\t* @throws {TypeError}\n\t* @public\n\t*/\n\tfunction toBuffer(data) {\n\t\ttoBuffer.readOnly = true;\n\t\tif (Buffer.isBuffer(data)) return data;\n\t\tlet buf;\n\t\tif (data instanceof ArrayBuffer) buf = new FastBuffer(data);\n\t\telse if (ArrayBuffer.isView(data)) buf = new FastBuffer(data.buffer, data.byteOffset, data.byteLength);\n\t\telse {\n\t\t\tbuf = Buffer.from(data);\n\t\t\ttoBuffer.readOnly = false;\n\t\t}\n\t\treturn buf;\n\t}\n\tmodule.exports = {\n\t\tconcat,\n\t\tmask: _mask,\n\t\ttoArrayBuffer,\n\t\ttoBuffer,\n\t\tunmask: _unmask\n\t};\n\t/* istanbul ignore else  */\n\tif (!process.env.WS_NO_BUFFER_UTIL) try {\n\t\tconst bufferUtil = __require(\"bufferutil\");\n\t\tmodule.exports.mask = function(source, mask, output, offset, length) {\n\t\t\tif (length < 48) _mask(source, mask, output, offset, length);\n\t\t\telse bufferUtil.mask(source, mask, output, offset, length);\n\t\t};\n\t\tmodule.exports.unmask = function(buffer, mask) {\n\t\t\tif (buffer.length < 32) _unmask(buffer, mask);\n\t\t\telse bufferUtil.unmask(buffer, mask);\n\t\t};\n\t} catch (e) {}\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/limiter.js\nvar require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst kDone = Symbol(\"kDone\");\n\tconst kRun = Symbol(\"kRun\");\n\t/**\n\t* A very simple job queue with adjustable concurrency. Adapted from\n\t* https://github.com/STRML/async-limiter\n\t*/\n\tvar Limiter = class {\n\t\t/**\n\t\t* Creates a new `Limiter`.\n\t\t*\n\t\t* @param {Number} [concurrency=Infinity] The maximum number of jobs allowed\n\t\t*     to run concurrently\n\t\t*/\n\t\tconstructor(concurrency) {\n\t\t\tthis[kDone] = () => {\n\t\t\t\tthis.pending--;\n\t\t\t\tthis[kRun]();\n\t\t\t};\n\t\t\tthis.concurrency = concurrency || Infinity;\n\t\t\tthis.jobs = [];\n\t\t\tthis.pending = 0;\n\t\t}\n\t\t/**\n\t\t* Adds a job to the queue.\n\t\t*\n\t\t* @param {Function} job The job to run\n\t\t* @public\n\t\t*/\n\t\tadd(job) {\n\t\t\tthis.jobs.push(job);\n\t\t\tthis[kRun]();\n\t\t}\n\t\t/**\n\t\t* Removes a job from the queue and runs it if possible.\n\t\t*\n\t\t* @private\n\t\t*/\n\t\t[kRun]() {\n\t\t\tif (this.pending === this.concurrency) return;\n\t\t\tif (this.jobs.length) {\n\t\t\t\tconst job = this.jobs.shift();\n\t\t\t\tthis.pending++;\n\t\t\t\tjob(this[kDone]);\n\t\t\t}\n\t\t}\n\t};\n\tmodule.exports = Limiter;\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/permessage-deflate.js\nvar require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst zlib = __require(\"zlib\");\n\tconst bufferUtil = require_buffer_util();\n\tconst Limiter = require_limiter();\n\tconst { kStatusCode } = require_constants();\n\tconst FastBuffer = Buffer[Symbol.species];\n\tconst TRAILER = Buffer.from([\n\t\t0,\n\t\t0,\n\t\t255,\n\t\t255\n\t]);\n\tconst kPerMessageDeflate = Symbol(\"permessage-deflate\");\n\tconst kTotalLength = Symbol(\"total-length\");\n\tconst kCallback = Symbol(\"callback\");\n\tconst kBuffers = Symbol(\"buffers\");\n\tconst kError = Symbol(\"error\");\n\tlet zlibLimiter;\n\t/**\n\t* permessage-deflate implementation.\n\t*/\n\tvar PerMessageDeflate = class {\n\t\t/**\n\t\t* Creates a PerMessageDeflate instance.\n\t\t*\n\t\t* @param {Object} [options] Configuration options\n\t\t* @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support\n\t\t*     for, or request, a custom client window size\n\t\t* @param {Boolean} [options.clientNoContextTakeover=false] Advertise/\n\t\t*     acknowledge disabling of client context takeover\n\t\t* @param {Number} [options.concurrencyLimit=10] The number of concurrent\n\t\t*     calls to zlib\n\t\t* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the\n\t\t*     use of a custom server window size\n\t\t* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept\n\t\t*     disabling of server context takeover\n\t\t* @param {Number} [options.threshold=1024] Size (in bytes) below which\n\t\t*     messages should not be compressed if context takeover is disabled\n\t\t* @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on\n\t\t*     deflate\n\t\t* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on\n\t\t*     inflate\n\t\t* @param {Boolean} [isServer=false] Create the instance in either server or\n\t\t*     client mode\n\t\t* @param {Number} [maxPayload=0] The maximum allowed message length\n\t\t*/\n\t\tconstructor(options, isServer, maxPayload) {\n\t\t\tthis._maxPayload = maxPayload | 0;\n\t\t\tthis._options = options || {};\n\t\t\tthis._threshold = this._options.threshold !== void 0 ? this._options.threshold : 1024;\n\t\t\tthis._isServer = !!isServer;\n\t\t\tthis._deflate = null;\n\t\t\tthis._inflate = null;\n\t\t\tthis.params = null;\n\t\t\tif (!zlibLimiter) zlibLimiter = new Limiter(this._options.concurrencyLimit !== void 0 ? this._options.concurrencyLimit : 10);\n\t\t}\n\t\t/**\n\t\t* @type {String}\n\t\t*/\n\t\tstatic get extensionName() {\n\t\t\treturn \"permessage-deflate\";\n\t\t}\n\t\t/**\n\t\t* Create an extension negotiation offer.\n\t\t*\n\t\t* @return {Object} Extension parameters\n\t\t* @public\n\t\t*/\n\t\toffer() {\n\t\t\tconst params = {};\n\t\t\tif (this._options.serverNoContextTakeover) params.server_no_context_takeover = true;\n\t\t\tif (this._options.clientNoContextTakeover) params.client_no_context_takeover = true;\n\t\t\tif (this._options.serverMaxWindowBits) params.server_max_window_bits = this._options.serverMaxWindowBits;\n\t\t\tif (this._options.clientMaxWindowBits) params.client_max_window_bits = this._options.clientMaxWindowBits;\n\t\t\telse if (this._options.clientMaxWindowBits == null) params.client_max_window_bits = true;\n\t\t\treturn params;\n\t\t}\n\t\t/**\n\t\t* Accept an extension negotiation offer/response.\n\t\t*\n\t\t* @param {Array} configurations The extension negotiation offers/reponse\n\t\t* @return {Object} Accepted configuration\n\t\t* @public\n\t\t*/\n\t\taccept(configurations) {\n\t\t\tconfigurations = this.normalizeParams(configurations);\n\t\t\tthis.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations);\n\t\t\treturn this.params;\n\t\t}\n\t\t/**\n\t\t* Releases all resources used by the extension.\n\t\t*\n\t\t* @public\n\t\t*/\n\t\tcleanup() {\n\t\t\tif (this._inflate) {\n\t\t\t\tthis._inflate.close();\n\t\t\t\tthis._inflate = null;\n\t\t\t}\n\t\t\tif (this._deflate) {\n\t\t\t\tconst callback = this._deflate[kCallback];\n\t\t\t\tthis._deflate.close();\n\t\t\t\tthis._deflate = null;\n\t\t\t\tif (callback) callback(/* @__PURE__ */ new Error(\"The deflate stream was closed while data was being processed\"));\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t*  Accept an extension negotiation offer.\n\t\t*\n\t\t* @param {Array} offers The extension negotiation offers\n\t\t* @return {Object} Accepted configuration\n\t\t* @private\n\t\t*/\n\t\tacceptAsServer(offers) {\n\t\t\tconst opts = this._options;\n\t\t\tconst accepted = offers.find((params) => {\n\t\t\t\tif (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === \"number\" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === \"number\" && !params.client_max_window_bits) return false;\n\t\t\t\treturn true;\n\t\t\t});\n\t\t\tif (!accepted) throw new Error(\"None of the extension offers can be accepted\");\n\t\t\tif (opts.serverNoContextTakeover) accepted.server_no_context_takeover = true;\n\t\t\tif (opts.clientNoContextTakeover) accepted.client_no_context_takeover = true;\n\t\t\tif (typeof opts.serverMaxWindowBits === \"number\") accepted.server_max_window_bits = opts.serverMaxWindowBits;\n\t\t\tif (typeof opts.clientMaxWindowBits === \"number\") accepted.client_max_window_bits = opts.clientMaxWindowBits;\n\t\t\telse if (accepted.client_max_window_bits === true || opts.clientMaxWindowBits === false) delete accepted.client_max_window_bits;\n\t\t\treturn accepted;\n\t\t}\n\t\t/**\n\t\t* Accept the extension negotiation response.\n\t\t*\n\t\t* @param {Array} response The extension negotiation response\n\t\t* @return {Object} Accepted configuration\n\t\t* @private\n\t\t*/\n\t\tacceptAsClient(response) {\n\t\t\tconst params = response[0];\n\t\t\tif (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) throw new Error(\"Unexpected parameter \\\"client_no_context_takeover\\\"\");\n\t\t\tif (!params.client_max_window_bits) {\n\t\t\t\tif (typeof this._options.clientMaxWindowBits === \"number\") params.client_max_window_bits = this._options.clientMaxWindowBits;\n\t\t\t} else if (this._options.clientMaxWindowBits === false || typeof this._options.clientMaxWindowBits === \"number\" && params.client_max_window_bits > this._options.clientMaxWindowBits) throw new Error(\"Unexpected or invalid parameter \\\"client_max_window_bits\\\"\");\n\t\t\treturn params;\n\t\t}\n\t\t/**\n\t\t* Normalize parameters.\n\t\t*\n\t\t* @param {Array} configurations The extension negotiation offers/reponse\n\t\t* @return {Array} The offers/response with normalized parameters\n\t\t* @private\n\t\t*/\n\t\tnormalizeParams(configurations) {\n\t\t\tconfigurations.forEach((params) => {\n\t\t\t\tObject.keys(params).forEach((key) => {\n\t\t\t\t\tlet value = params[key];\n\t\t\t\t\tif (value.length > 1) throw new Error(`Parameter \"${key}\" must have only a single value`);\n\t\t\t\t\tvalue = value[0];\n\t\t\t\t\tif (key === \"client_max_window_bits\") {\n\t\t\t\t\t\tif (value !== true) {\n\t\t\t\t\t\t\tconst num = +value;\n\t\t\t\t\t\t\tif (!Number.isInteger(num) || num < 8 || num > 15) throw new TypeError(`Invalid value for parameter \"${key}\": ${value}`);\n\t\t\t\t\t\t\tvalue = num;\n\t\t\t\t\t\t} else if (!this._isServer) throw new TypeError(`Invalid value for parameter \"${key}\": ${value}`);\n\t\t\t\t\t} else if (key === \"server_max_window_bits\") {\n\t\t\t\t\t\tconst num = +value;\n\t\t\t\t\t\tif (!Number.isInteger(num) || num < 8 || num > 15) throw new TypeError(`Invalid value for parameter \"${key}\": ${value}`);\n\t\t\t\t\t\tvalue = num;\n\t\t\t\t\t} else if (key === \"client_no_context_takeover\" || key === \"server_no_context_takeover\") {\n\t\t\t\t\t\tif (value !== true) throw new TypeError(`Invalid value for parameter \"${key}\": ${value}`);\n\t\t\t\t\t} else throw new Error(`Unknown parameter \"${key}\"`);\n\t\t\t\t\tparams[key] = value;\n\t\t\t\t});\n\t\t\t});\n\t\t\treturn configurations;\n\t\t}\n\t\t/**\n\t\t* Decompress data. Concurrency limited.\n\t\t*\n\t\t* @param {Buffer} data Compressed data\n\t\t* @param {Boolean} fin Specifies whether or not this is the last fragment\n\t\t* @param {Function} callback Callback\n\t\t* @public\n\t\t*/\n\t\tdecompress(data, fin, callback) {\n\t\t\tzlibLimiter.add((done) => {\n\t\t\t\tthis._decompress(data, fin, (err, result) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tcallback(err, result);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t\t/**\n\t\t* Compress data. Concurrency limited.\n\t\t*\n\t\t* @param {(Buffer|String)} data Data to compress\n\t\t* @param {Boolean} fin Specifies whether or not this is the last fragment\n\t\t* @param {Function} callback Callback\n\t\t* @public\n\t\t*/\n\t\tcompress(data, fin, callback) {\n\t\t\tzlibLimiter.add((done) => {\n\t\t\t\tthis._compress(data, fin, (err, result) => {\n\t\t\t\t\tdone();\n\t\t\t\t\tcallback(err, result);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t\t/**\n\t\t* Decompress data.\n\t\t*\n\t\t* @param {Buffer} data Compressed data\n\t\t* @param {Boolean} fin Specifies whether or not this is the last fragment\n\t\t* @param {Function} callback Callback\n\t\t* @private\n\t\t*/\n\t\t_decompress(data, fin, callback) {\n\t\t\tconst endpoint = this._isServer ? \"client\" : \"server\";\n\t\t\tif (!this._inflate) {\n\t\t\t\tconst key = `${endpoint}_max_window_bits`;\n\t\t\t\tconst windowBits = typeof this.params[key] !== \"number\" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];\n\t\t\t\tthis._inflate = zlib.createInflateRaw({\n\t\t\t\t\t...this._options.zlibInflateOptions,\n\t\t\t\t\twindowBits\n\t\t\t\t});\n\t\t\t\tthis._inflate[kPerMessageDeflate] = this;\n\t\t\t\tthis._inflate[kTotalLength] = 0;\n\t\t\t\tthis._inflate[kBuffers] = [];\n\t\t\t\tthis._inflate.on(\"error\", inflateOnError);\n\t\t\t\tthis._inflate.on(\"data\", inflateOnData);\n\t\t\t}\n\t\t\tthis._inflate[kCallback] = callback;\n\t\t\tthis._inflate.write(data);\n\t\t\tif (fin) this._inflate.write(TRAILER);\n\t\t\tthis._inflate.flush(() => {\n\t\t\t\tconst err = this._inflate[kError];\n\t\t\t\tif (err) {\n\t\t\t\t\tthis._inflate.close();\n\t\t\t\t\tthis._inflate = null;\n\t\t\t\t\tcallback(err);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst data = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);\n\t\t\t\tif (this._inflate._readableState.endEmitted) {\n\t\t\t\t\tthis._inflate.close();\n\t\t\t\t\tthis._inflate = null;\n\t\t\t\t} else {\n\t\t\t\t\tthis._inflate[kTotalLength] = 0;\n\t\t\t\t\tthis._inflate[kBuffers] = [];\n\t\t\t\t\tif (fin && this.params[`${endpoint}_no_context_takeover`]) this._inflate.reset();\n\t\t\t\t}\n\t\t\t\tcallback(null, data);\n\t\t\t});\n\t\t}\n\t\t/**\n\t\t* Compress data.\n\t\t*\n\t\t* @param {(Buffer|String)} data Data to compress\n\t\t* @param {Boolean} fin Specifies whether or not this is the last fragment\n\t\t* @param {Function} callback Callback\n\t\t* @private\n\t\t*/\n\t\t_compress(data, fin, callback) {\n\t\t\tconst endpoint = this._isServer ? \"server\" : \"client\";\n\t\t\tif (!this._deflate) {\n\t\t\t\tconst key = `${endpoint}_max_window_bits`;\n\t\t\t\tconst windowBits = typeof this.params[key] !== \"number\" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key];\n\t\t\t\tthis._deflate = zlib.createDeflateRaw({\n\t\t\t\t\t...this._options.zlibDeflateOptions,\n\t\t\t\t\twindowBits\n\t\t\t\t});\n\t\t\t\tthis._deflate[kTotalLength] = 0;\n\t\t\t\tthis._deflate[kBuffers] = [];\n\t\t\t\tthis._deflate.on(\"data\", deflateOnData);\n\t\t\t}\n\t\t\tthis._deflate[kCallback] = callback;\n\t\t\tthis._deflate.write(data);\n\t\t\tthis._deflate.flush(zlib.Z_SYNC_FLUSH, () => {\n\t\t\t\tif (!this._deflate) return;\n\t\t\t\tlet data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);\n\t\t\t\tif (fin) data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4);\n\t\t\t\tthis._deflate[kCallback] = null;\n\t\t\t\tthis._deflate[kTotalLength] = 0;\n\t\t\t\tthis._deflate[kBuffers] = [];\n\t\t\t\tif (fin && this.params[`${endpoint}_no_context_takeover`]) this._deflate.reset();\n\t\t\t\tcallback(null, data);\n\t\t\t});\n\t\t}\n\t};\n\tmodule.exports = PerMessageDeflate;\n\t/**\n\t* The listener of the `zlib.DeflateRaw` stream `'data'` event.\n\t*\n\t* @param {Buffer} chunk A chunk of data\n\t* @private\n\t*/\n\tfunction deflateOnData(chunk) {\n\t\tthis[kBuffers].push(chunk);\n\t\tthis[kTotalLength] += chunk.length;\n\t}\n\t/**\n\t* The listener of the `zlib.InflateRaw` stream `'data'` event.\n\t*\n\t* @param {Buffer} chunk A chunk of data\n\t* @private\n\t*/\n\tfunction inflateOnData(chunk) {\n\t\tthis[kTotalLength] += chunk.length;\n\t\tif (this[kPerMessageDeflate]._maxPayload < 1 || this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload) {\n\t\t\tthis[kBuffers].push(chunk);\n\t\t\treturn;\n\t\t}\n\t\tthis[kError] = /* @__PURE__ */ new RangeError(\"Max payload size exceeded\");\n\t\tthis[kError].code = \"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH\";\n\t\tthis[kError][kStatusCode] = 1009;\n\t\tthis.removeListener(\"data\", inflateOnData);\n\t\tthis.reset();\n\t}\n\t/**\n\t* The listener of the `zlib.InflateRaw` stream `'error'` event.\n\t*\n\t* @param {Error} err The emitted error\n\t* @private\n\t*/\n\tfunction inflateOnError(err) {\n\t\tthis[kPerMessageDeflate]._inflate = null;\n\t\tif (this[kError]) {\n\t\t\tthis[kCallback](this[kError]);\n\t\t\treturn;\n\t\t}\n\t\terr[kStatusCode] = 1007;\n\t\tthis[kCallback](err);\n\t}\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/validation.js\nvar require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst { isUtf8 } = __require(\"buffer\");\n\tconst { hasBlob } = require_constants();\n\tconst tokenChars = [\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t1,\n\t\t0,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t0,\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t1,\n\t\t0,\n\t\t1,\n\t\t0\n\t];\n\t/**\n\t* Checks if a status code is allowed in a close frame.\n\t*\n\t* @param {Number} code The status code\n\t* @return {Boolean} `true` if the status code is valid, else `false`\n\t* @public\n\t*/\n\tfunction isValidStatusCode(code) {\n\t\treturn code >= 1e3 && code <= 1014 && code !== 1004 && code !== 1005 && code !== 1006 || code >= 3e3 && code <= 4999;\n\t}\n\t/**\n\t* Checks if a given buffer contains only correct UTF-8.\n\t* Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by\n\t* Markus Kuhn.\n\t*\n\t* @param {Buffer} buf The buffer to check\n\t* @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false`\n\t* @public\n\t*/\n\tfunction _isValidUTF8(buf) {\n\t\tconst len = buf.length;\n\t\tlet i = 0;\n\t\twhile (i < len) if ((buf[i] & 128) === 0) i++;\n\t\telse if ((buf[i] & 224) === 192) {\n\t\t\tif (i + 1 === len || (buf[i + 1] & 192) !== 128 || (buf[i] & 254) === 192) return false;\n\t\t\ti += 2;\n\t\t} else if ((buf[i] & 240) === 224) {\n\t\t\tif (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || buf[i] === 237 && (buf[i + 1] & 224) === 160) return false;\n\t\t\ti += 3;\n\t\t} else if ((buf[i] & 248) === 240) {\n\t\t\tif (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) return false;\n\t\t\ti += 4;\n\t\t} else return false;\n\t\treturn true;\n\t}\n\t/**\n\t* Determines whether a value is a `Blob`.\n\t*\n\t* @param {*} value The value to be tested\n\t* @return {Boolean} `true` if `value` is a `Blob`, else `false`\n\t* @private\n\t*/\n\tfunction isBlob(value) {\n\t\treturn hasBlob && typeof value === \"object\" && typeof value.arrayBuffer === \"function\" && typeof value.type === \"string\" && typeof value.stream === \"function\" && (value[Symbol.toStringTag] === \"Blob\" || value[Symbol.toStringTag] === \"File\");\n\t}\n\tmodule.exports = {\n\t\tisBlob,\n\t\tisValidStatusCode,\n\t\tisValidUTF8: _isValidUTF8,\n\t\ttokenChars\n\t};\n\tif (isUtf8) module.exports.isValidUTF8 = function(buf) {\n\t\treturn buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);\n\t};\n\telse if (!process.env.WS_NO_UTF_8_VALIDATE) try {\n\t\tconst isValidUTF8 = __require(\"utf-8-validate\");\n\t\tmodule.exports.isValidUTF8 = function(buf) {\n\t\t\treturn buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);\n\t\t};\n\t} catch (e) {}\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/receiver.js\nvar require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst { Writable } = __require(\"stream\");\n\tconst PerMessageDeflate = require_permessage_deflate();\n\tconst { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = require_constants();\n\tconst { concat, toArrayBuffer, unmask } = require_buffer_util();\n\tconst { isValidStatusCode, isValidUTF8 } = require_validation();\n\tconst FastBuffer = Buffer[Symbol.species];\n\tconst GET_INFO = 0;\n\tconst GET_PAYLOAD_LENGTH_16 = 1;\n\tconst GET_PAYLOAD_LENGTH_64 = 2;\n\tconst GET_MASK = 3;\n\tconst GET_DATA = 4;\n\tconst INFLATING = 5;\n\tconst DEFER_EVENT = 6;\n\t/**\n\t* HyBi Receiver implementation.\n\t*\n\t* @extends Writable\n\t*/\n\tvar Receiver = class extends Writable {\n\t\t/**\n\t\t* Creates a Receiver instance.\n\t\t*\n\t\t* @param {Object} [options] Options object\n\t\t* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether\n\t\t*     any of the `'message'`, `'ping'`, and `'pong'` events can be emitted\n\t\t*     multiple times in the same tick\n\t\t* @param {String} [options.binaryType=nodebuffer] The type for binary data\n\t\t* @param {Object} [options.extensions] An object containing the negotiated\n\t\t*     extensions\n\t\t* @param {Boolean} [options.isServer=false] Specifies whether to operate in\n\t\t*     client or server mode\n\t\t* @param {Number} [options.maxPayload=0] The maximum allowed message length\n\t\t* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or\n\t\t*     not to skip UTF-8 validation for text and close messages\n\t\t*/\n\t\tconstructor(options = {}) {\n\t\t\tsuper();\n\t\t\tthis._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;\n\t\t\tthis._binaryType = options.binaryType || BINARY_TYPES[0];\n\t\t\tthis._extensions = options.extensions || {};\n\t\t\tthis._isServer = !!options.isServer;\n\t\t\tthis._maxPayload = options.maxPayload | 0;\n\t\t\tthis._skipUTF8Validation = !!options.skipUTF8Validation;\n\t\t\tthis[kWebSocket] = void 0;\n\t\t\tthis._bufferedBytes = 0;\n\t\t\tthis._buffers = [];\n\t\t\tthis._compressed = false;\n\t\t\tthis._payloadLength = 0;\n\t\t\tthis._mask = void 0;\n\t\t\tthis._fragmented = 0;\n\t\t\tthis._masked = false;\n\t\t\tthis._fin = false;\n\t\t\tthis._opcode = 0;\n\t\t\tthis._totalPayloadLength = 0;\n\t\t\tthis._messageLength = 0;\n\t\t\tthis._fragments = [];\n\t\t\tthis._errored = false;\n\t\t\tthis._loop = false;\n\t\t\tthis._state = GET_INFO;\n\t\t}\n\t\t/**\n\t\t* Implements `Writable.prototype._write()`.\n\t\t*\n\t\t* @param {Buffer} chunk The chunk of data to write\n\t\t* @param {String} encoding The character encoding of `chunk`\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\t_write(chunk, encoding, cb) {\n\t\t\tif (this._opcode === 8 && this._state == GET_INFO) return cb();\n\t\t\tthis._bufferedBytes += chunk.length;\n\t\t\tthis._buffers.push(chunk);\n\t\t\tthis.startLoop(cb);\n\t\t}\n\t\t/**\n\t\t* Consumes `n` bytes from the buffered data.\n\t\t*\n\t\t* @param {Number} n The number of bytes to consume\n\t\t* @return {Buffer} The consumed bytes\n\t\t* @private\n\t\t*/\n\t\tconsume(n) {\n\t\t\tthis._bufferedBytes -= n;\n\t\t\tif (n === this._buffers[0].length) return this._buffers.shift();\n\t\t\tif (n < this._buffers[0].length) {\n\t\t\t\tconst buf = this._buffers[0];\n\t\t\t\tthis._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);\n\t\t\t\treturn new FastBuffer(buf.buffer, buf.byteOffset, n);\n\t\t\t}\n\t\t\tconst dst = Buffer.allocUnsafe(n);\n\t\t\tdo {\n\t\t\t\tconst buf = this._buffers[0];\n\t\t\t\tconst offset = dst.length - n;\n\t\t\t\tif (n >= buf.length) dst.set(this._buffers.shift(), offset);\n\t\t\t\telse {\n\t\t\t\t\tdst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);\n\t\t\t\t\tthis._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);\n\t\t\t\t}\n\t\t\t\tn -= buf.length;\n\t\t\t} while (n > 0);\n\t\t\treturn dst;\n\t\t}\n\t\t/**\n\t\t* Starts the parsing loop.\n\t\t*\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\tstartLoop(cb) {\n\t\t\tthis._loop = true;\n\t\t\tdo\n\t\t\t\tswitch (this._state) {\n\t\t\t\t\tcase GET_INFO:\n\t\t\t\t\t\tthis.getInfo(cb);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GET_PAYLOAD_LENGTH_16:\n\t\t\t\t\t\tthis.getPayloadLength16(cb);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GET_PAYLOAD_LENGTH_64:\n\t\t\t\t\t\tthis.getPayloadLength64(cb);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GET_MASK:\n\t\t\t\t\t\tthis.getMask();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase GET_DATA:\n\t\t\t\t\t\tthis.getData(cb);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase INFLATING:\n\t\t\t\t\tcase DEFER_EVENT:\n\t\t\t\t\t\tthis._loop = false;\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\twhile (this._loop);\n\t\t\tif (!this._errored) cb();\n\t\t}\n\t\t/**\n\t\t* Reads the first two bytes of a frame.\n\t\t*\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\tgetInfo(cb) {\n\t\t\tif (this._bufferedBytes < 2) {\n\t\t\t\tthis._loop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst buf = this.consume(2);\n\t\t\tif ((buf[0] & 48) !== 0) {\n\t\t\t\tcb(this.createError(RangeError, \"RSV2 and RSV3 must be clear\", true, 1002, \"WS_ERR_UNEXPECTED_RSV_2_3\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst compressed = (buf[0] & 64) === 64;\n\t\t\tif (compressed && !this._extensions[PerMessageDeflate.extensionName]) {\n\t\t\t\tcb(this.createError(RangeError, \"RSV1 must be clear\", true, 1002, \"WS_ERR_UNEXPECTED_RSV_1\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._fin = (buf[0] & 128) === 128;\n\t\t\tthis._opcode = buf[0] & 15;\n\t\t\tthis._payloadLength = buf[1] & 127;\n\t\t\tif (this._opcode === 0) {\n\t\t\t\tif (compressed) {\n\t\t\t\t\tcb(this.createError(RangeError, \"RSV1 must be clear\", true, 1002, \"WS_ERR_UNEXPECTED_RSV_1\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!this._fragmented) {\n\t\t\t\t\tcb(this.createError(RangeError, \"invalid opcode 0\", true, 1002, \"WS_ERR_INVALID_OPCODE\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis._opcode = this._fragmented;\n\t\t\t} else if (this._opcode === 1 || this._opcode === 2) {\n\t\t\t\tif (this._fragmented) {\n\t\t\t\t\tcb(this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, \"WS_ERR_INVALID_OPCODE\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis._compressed = compressed;\n\t\t\t} else if (this._opcode > 7 && this._opcode < 11) {\n\t\t\t\tif (!this._fin) {\n\t\t\t\t\tcb(this.createError(RangeError, \"FIN must be set\", true, 1002, \"WS_ERR_EXPECTED_FIN\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (compressed) {\n\t\t\t\t\tcb(this.createError(RangeError, \"RSV1 must be clear\", true, 1002, \"WS_ERR_UNEXPECTED_RSV_1\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {\n\t\t\t\t\tcb(this.createError(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, \"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcb(this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, \"WS_ERR_INVALID_OPCODE\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!this._fin && !this._fragmented) this._fragmented = this._opcode;\n\t\t\tthis._masked = (buf[1] & 128) === 128;\n\t\t\tif (this._isServer) {\n\t\t\t\tif (!this._masked) {\n\t\t\t\t\tcb(this.createError(RangeError, \"MASK must be set\", true, 1002, \"WS_ERR_EXPECTED_MASK\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (this._masked) {\n\t\t\t\tcb(this.createError(RangeError, \"MASK must be clear\", true, 1002, \"WS_ERR_UNEXPECTED_MASK\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16;\n\t\t\telse if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64;\n\t\t\telse this.haveLength(cb);\n\t\t}\n\t\t/**\n\t\t* Gets extended payload length (7+16).\n\t\t*\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\tgetPayloadLength16(cb) {\n\t\t\tif (this._bufferedBytes < 2) {\n\t\t\t\tthis._loop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._payloadLength = this.consume(2).readUInt16BE(0);\n\t\t\tthis.haveLength(cb);\n\t\t}\n\t\t/**\n\t\t* Gets extended payload length (7+64).\n\t\t*\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\tgetPayloadLength64(cb) {\n\t\t\tif (this._bufferedBytes < 8) {\n\t\t\t\tthis._loop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst buf = this.consume(8);\n\t\t\tconst num = buf.readUInt32BE(0);\n\t\t\tif (num > Math.pow(2, 21) - 1) {\n\t\t\t\tcb(this.createError(RangeError, \"Unsupported WebSocket frame: payload length > 2^53 - 1\", false, 1009, \"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);\n\t\t\tthis.haveLength(cb);\n\t\t}\n\t\t/**\n\t\t* Payload length has been read.\n\t\t*\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\thaveLength(cb) {\n\t\t\tif (this._payloadLength && this._opcode < 8) {\n\t\t\t\tthis._totalPayloadLength += this._payloadLength;\n\t\t\t\tif (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {\n\t\t\t\t\tcb(this.createError(RangeError, \"Max payload size exceeded\", false, 1009, \"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this._masked) this._state = GET_MASK;\n\t\t\telse this._state = GET_DATA;\n\t\t}\n\t\t/**\n\t\t* Reads mask bytes.\n\t\t*\n\t\t* @private\n\t\t*/\n\t\tgetMask() {\n\t\t\tif (this._bufferedBytes < 4) {\n\t\t\t\tthis._loop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._mask = this.consume(4);\n\t\t\tthis._state = GET_DATA;\n\t\t}\n\t\t/**\n\t\t* Reads data bytes.\n\t\t*\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\tgetData(cb) {\n\t\t\tlet data = EMPTY_BUFFER;\n\t\t\tif (this._payloadLength) {\n\t\t\t\tif (this._bufferedBytes < this._payloadLength) {\n\t\t\t\t\tthis._loop = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdata = this.consume(this._payloadLength);\n\t\t\t\tif (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) unmask(data, this._mask);\n\t\t\t}\n\t\t\tif (this._opcode > 7) {\n\t\t\t\tthis.controlMessage(data, cb);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this._compressed) {\n\t\t\t\tthis._state = INFLATING;\n\t\t\t\tthis.decompress(data, cb);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (data.length) {\n\t\t\t\tthis._messageLength = this._totalPayloadLength;\n\t\t\t\tthis._fragments.push(data);\n\t\t\t}\n\t\t\tthis.dataMessage(cb);\n\t\t}\n\t\t/**\n\t\t* Decompresses data.\n\t\t*\n\t\t* @param {Buffer} data Compressed data\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\tdecompress(data, cb) {\n\t\t\tthis._extensions[PerMessageDeflate.extensionName].decompress(data, this._fin, (err, buf) => {\n\t\t\t\tif (err) return cb(err);\n\t\t\t\tif (buf.length) {\n\t\t\t\t\tthis._messageLength += buf.length;\n\t\t\t\t\tif (this._messageLength > this._maxPayload && this._maxPayload > 0) {\n\t\t\t\t\t\tcb(this.createError(RangeError, \"Max payload size exceeded\", false, 1009, \"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._fragments.push(buf);\n\t\t\t\t}\n\t\t\t\tthis.dataMessage(cb);\n\t\t\t\tif (this._state === GET_INFO) this.startLoop(cb);\n\t\t\t});\n\t\t}\n\t\t/**\n\t\t* Handles a data message.\n\t\t*\n\t\t* @param {Function} cb Callback\n\t\t* @private\n\t\t*/\n\t\tdataMessage(cb) {\n\t\t\tif (!this._fin) {\n\t\t\t\tthis._state = GET_INFO;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst messageLength = this._messageLength;\n\t\t\tconst fragments = this._fragments;\n\t\t\tthis._totalPayloadLength = 0;\n\t\t\tthis._messageLength = 0;\n\t\t\tthis._fragmented = 0;\n\t\t\tthis._fragments = [];\n\t\t\tif (this._opcode === 2) {\n\t\t\t\tlet data;\n\t\t\t\tif (this._binaryType === \"nodebuffer\") data = concat(fragments, messageLength);\n\t\t\t\telse if (this._binaryType === \"arraybuffer\") data = toArrayBuffer(concat(fragments, messageLength));\n\t\t\t\telse if (this._binaryType === \"blob\") data = new Blob(fragments);\n\t\t\t\telse data = fragments;\n\t\t\t\tif (this._allowSynchronousEvents) {\n\t\t\t\t\tthis.emit(\"message\", data, true);\n\t\t\t\t\tthis._state = GET_INFO;\n\t\t\t\t} else {\n\t\t\t\t\tthis._state = DEFER_EVENT;\n\t\t\t\t\tsetImmediate(() => {\n\t\t\t\t\t\tthis.emit(\"message\", data, true);\n\t\t\t\t\t\tthis._state = GET_INFO;\n\t\t\t\t\t\tthis.startLoop(cb);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst buf = concat(fragments, messageLength);\n\t\t\t\tif (!this._skipUTF8Validation && !isValidUTF8(buf)) {\n\t\t\t\t\tcb(this.createError(Error, \"invalid UTF-8 sequence\", true, 1007, \"WS_ERR_INVALID_UTF8\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (this._state === INFLATING || this._allowSynchronousEvents) {\n\t\t\t\t\tthis.emit(\"message\", buf, false);\n\t\t\t\t\tthis._state = GET_INFO;\n\t\t\t\t} else {\n\t\t\t\t\tthis._state = DEFER_EVENT;\n\t\t\t\t\tsetImmediate(() => {\n\t\t\t\t\t\tthis.emit(\"message\", buf, false);\n\t\t\t\t\t\tthis._state = GET_INFO;\n\t\t\t\t\t\tthis.startLoop(cb);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t* Handles a control message.\n\t\t*\n\t\t* @param {Buffer} data Data to handle\n\t\t* @return {(Error|RangeError|undefined)} A possible error\n\t\t* @private\n\t\t*/\n\t\tcontrolMessage(data, cb) {\n\t\t\tif (this._opcode === 8) {\n\t\t\t\tif (data.length === 0) {\n\t\t\t\t\tthis._loop = false;\n\t\t\t\t\tthis.emit(\"conclude\", 1005, EMPTY_BUFFER);\n\t\t\t\t\tthis.end();\n\t\t\t\t} else {\n\t\t\t\t\tconst code = data.readUInt16BE(0);\n\t\t\t\t\tif (!isValidStatusCode(code)) {\n\t\t\t\t\t\tcb(this.createError(RangeError, `invalid status code ${code}`, true, 1002, \"WS_ERR_INVALID_CLOSE_CODE\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);\n\t\t\t\t\tif (!this._skipUTF8Validation && !isValidUTF8(buf)) {\n\t\t\t\t\t\tcb(this.createError(Error, \"invalid UTF-8 sequence\", true, 1007, \"WS_ERR_INVALID_UTF8\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tthis._loop = false;\n\t\t\t\t\tthis.emit(\"conclude\", code, buf);\n\t\t\t\t\tthis.end();\n\t\t\t\t}\n\t\t\t\tthis._state = GET_INFO;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this._allowSynchronousEvents) {\n\t\t\t\tthis.emit(this._opcode === 9 ? \"ping\" : \"pong\", data);\n\t\t\t\tthis._state = GET_INFO;\n\t\t\t} else {\n\t\t\t\tthis._state = DEFER_EVENT;\n\t\t\t\tsetImmediate(() => {\n\t\t\t\t\tthis.emit(this._opcode === 9 ? \"ping\" : \"pong\", data);\n\t\t\t\t\tthis._state = GET_INFO;\n\t\t\t\t\tthis.startLoop(cb);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t* Builds an error object.\n\t\t*\n\t\t* @param {function(new:Error|RangeError)} ErrorCtor The error constructor\n\t\t* @param {String} message The error message\n\t\t* @param {Boolean} prefix Specifies whether or not to add a default prefix to\n\t\t*     `message`\n\t\t* @param {Number} statusCode The status code\n\t\t* @param {String} errorCode The exposed error code\n\t\t* @return {(Error|RangeError)} The error\n\t\t* @private\n\t\t*/\n\t\tcreateError(ErrorCtor, message, prefix, statusCode, errorCode) {\n\t\t\tthis._loop = false;\n\t\t\tthis._errored = true;\n\t\t\tconst err = new ErrorCtor(prefix ? `Invalid WebSocket frame: ${message}` : message);\n\t\t\tError.captureStackTrace(err, this.createError);\n\t\t\terr.code = errorCode;\n\t\t\terr[kStatusCode] = statusCode;\n\t\t\treturn err;\n\t\t}\n\t};\n\tmodule.exports = Receiver;\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/sender.js\nvar require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst { Duplex: Duplex$3 } = __require(\"stream\");\n\tconst { randomFillSync } = __require(\"crypto\");\n\tconst PerMessageDeflate = require_permessage_deflate();\n\tconst { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();\n\tconst { isBlob, isValidStatusCode } = require_validation();\n\tconst { mask: applyMask, toBuffer } = require_buffer_util();\n\tconst kByteLength = Symbol(\"kByteLength\");\n\tconst maskBuffer = Buffer.alloc(4);\n\tconst RANDOM_POOL_SIZE = 8 * 1024;\n\tlet randomPool;\n\tlet randomPoolPointer = RANDOM_POOL_SIZE;\n\tconst DEFAULT = 0;\n\tconst DEFLATING = 1;\n\tconst GET_BLOB_DATA = 2;\n\t/**\n\t* HyBi Sender implementation.\n\t*/\n\tvar Sender = class Sender {\n\t\t/**\n\t\t* Creates a Sender instance.\n\t\t*\n\t\t* @param {Duplex} socket The connection socket\n\t\t* @param {Object} [extensions] An object containing the negotiated extensions\n\t\t* @param {Function} [generateMask] The function used to generate the masking\n\t\t*     key\n\t\t*/\n\t\tconstructor(socket, extensions, generateMask) {\n\t\t\tthis._extensions = extensions || {};\n\t\t\tif (generateMask) {\n\t\t\t\tthis._generateMask = generateMask;\n\t\t\t\tthis._maskBuffer = Buffer.alloc(4);\n\t\t\t}\n\t\t\tthis._socket = socket;\n\t\t\tthis._firstFragment = true;\n\t\t\tthis._compress = false;\n\t\t\tthis._bufferedBytes = 0;\n\t\t\tthis._queue = [];\n\t\t\tthis._state = DEFAULT;\n\t\t\tthis.onerror = NOOP;\n\t\t\tthis[kWebSocket] = void 0;\n\t\t}\n\t\t/**\n\t\t* Frames a piece of data according to the HyBi WebSocket protocol.\n\t\t*\n\t\t* @param {(Buffer|String)} data The data to frame\n\t\t* @param {Object} options Options object\n\t\t* @param {Boolean} [options.fin=false] Specifies whether or not to set the\n\t\t*     FIN bit\n\t\t* @param {Function} [options.generateMask] The function used to generate the\n\t\t*     masking key\n\t\t* @param {Boolean} [options.mask=false] Specifies whether or not to mask\n\t\t*     `data`\n\t\t* @param {Buffer} [options.maskBuffer] The buffer used to store the masking\n\t\t*     key\n\t\t* @param {Number} options.opcode The opcode\n\t\t* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be\n\t\t*     modified\n\t\t* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the\n\t\t*     RSV1 bit\n\t\t* @return {(Buffer|String)[]} The framed data\n\t\t* @public\n\t\t*/\n\t\tstatic frame(data, options) {\n\t\t\tlet mask;\n\t\t\tlet merge = false;\n\t\t\tlet offset = 2;\n\t\t\tlet skipMasking = false;\n\t\t\tif (options.mask) {\n\t\t\t\tmask = options.maskBuffer || maskBuffer;\n\t\t\t\tif (options.generateMask) options.generateMask(mask);\n\t\t\t\telse {\n\t\t\t\t\tif (randomPoolPointer === RANDOM_POOL_SIZE) {\n\t\t\t\t\t\t/* istanbul ignore else  */\n\t\t\t\t\t\tif (randomPool === void 0) randomPool = Buffer.alloc(RANDOM_POOL_SIZE);\n\t\t\t\t\t\trandomFillSync(randomPool, 0, RANDOM_POOL_SIZE);\n\t\t\t\t\t\trandomPoolPointer = 0;\n\t\t\t\t\t}\n\t\t\t\t\tmask[0] = randomPool[randomPoolPointer++];\n\t\t\t\t\tmask[1] = randomPool[randomPoolPointer++];\n\t\t\t\t\tmask[2] = randomPool[randomPoolPointer++];\n\t\t\t\t\tmask[3] = randomPool[randomPoolPointer++];\n\t\t\t\t}\n\t\t\t\tskipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0;\n\t\t\t\toffset = 6;\n\t\t\t}\n\t\t\tlet dataLength;\n\t\t\tif (typeof data === \"string\") if ((!options.mask || skipMasking) && options[kByteLength] !== void 0) dataLength = options[kByteLength];\n\t\t\telse {\n\t\t\t\tdata = Buffer.from(data);\n\t\t\t\tdataLength = data.length;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdataLength = data.length;\n\t\t\t\tmerge = options.mask && options.readOnly && !skipMasking;\n\t\t\t}\n\t\t\tlet payloadLength = dataLength;\n\t\t\tif (dataLength >= 65536) {\n\t\t\t\toffset += 8;\n\t\t\t\tpayloadLength = 127;\n\t\t\t} else if (dataLength > 125) {\n\t\t\t\toffset += 2;\n\t\t\t\tpayloadLength = 126;\n\t\t\t}\n\t\t\tconst target = Buffer.allocUnsafe(merge ? dataLength + offset : offset);\n\t\t\ttarget[0] = options.fin ? options.opcode | 128 : options.opcode;\n\t\t\tif (options.rsv1) target[0] |= 64;\n\t\t\ttarget[1] = payloadLength;\n\t\t\tif (payloadLength === 126) target.writeUInt16BE(dataLength, 2);\n\t\t\telse if (payloadLength === 127) {\n\t\t\t\ttarget[2] = target[3] = 0;\n\t\t\t\ttarget.writeUIntBE(dataLength, 4, 6);\n\t\t\t}\n\t\t\tif (!options.mask) return [target, data];\n\t\t\ttarget[1] |= 128;\n\t\t\ttarget[offset - 4] = mask[0];\n\t\t\ttarget[offset - 3] = mask[1];\n\t\t\ttarget[offset - 2] = mask[2];\n\t\t\ttarget[offset - 1] = mask[3];\n\t\t\tif (skipMasking) return [target, data];\n\t\t\tif (merge) {\n\t\t\t\tapplyMask(data, mask, target, offset, dataLength);\n\t\t\t\treturn [target];\n\t\t\t}\n\t\t\tapplyMask(data, mask, data, 0, dataLength);\n\t\t\treturn [target, data];\n\t\t}\n\t\t/**\n\t\t* Sends a close message to the other peer.\n\t\t*\n\t\t* @param {Number} [code] The status code component of the body\n\t\t* @param {(String|Buffer)} [data] The message component of the body\n\t\t* @param {Boolean} [mask=false] Specifies whether or not to mask the message\n\t\t* @param {Function} [cb] Callback\n\t\t* @public\n\t\t*/\n\t\tclose(code, data, mask, cb) {\n\t\t\tlet buf;\n\t\t\tif (code === void 0) buf = EMPTY_BUFFER;\n\t\t\telse if (typeof code !== \"number\" || !isValidStatusCode(code)) throw new TypeError(\"First argument must be a valid error code number\");\n\t\t\telse if (data === void 0 || !data.length) {\n\t\t\t\tbuf = Buffer.allocUnsafe(2);\n\t\t\t\tbuf.writeUInt16BE(code, 0);\n\t\t\t} else {\n\t\t\t\tconst length = Buffer.byteLength(data);\n\t\t\t\tif (length > 123) throw new RangeError(\"The message must not be greater than 123 bytes\");\n\t\t\t\tbuf = Buffer.allocUnsafe(2 + length);\n\t\t\t\tbuf.writeUInt16BE(code, 0);\n\t\t\t\tif (typeof data === \"string\") buf.write(data, 2);\n\t\t\t\telse buf.set(data, 2);\n\t\t\t}\n\t\t\tconst options = {\n\t\t\t\t[kByteLength]: buf.length,\n\t\t\t\tfin: true,\n\t\t\t\tgenerateMask: this._generateMask,\n\t\t\t\tmask,\n\t\t\t\tmaskBuffer: this._maskBuffer,\n\t\t\t\topcode: 8,\n\t\t\t\treadOnly: false,\n\t\t\t\trsv1: false\n\t\t\t};\n\t\t\tif (this._state !== DEFAULT) this.enqueue([\n\t\t\t\tthis.dispatch,\n\t\t\t\tbuf,\n\t\t\t\tfalse,\n\t\t\t\toptions,\n\t\t\t\tcb\n\t\t\t]);\n\t\t\telse this.sendFrame(Sender.frame(buf, options), cb);\n\t\t}\n\t\t/**\n\t\t* Sends a ping message to the other peer.\n\t\t*\n\t\t* @param {*} data The message to send\n\t\t* @param {Boolean} [mask=false] Specifies whether or not to mask `data`\n\t\t* @param {Function} [cb] Callback\n\t\t* @public\n\t\t*/\n\t\tping(data, mask, cb) {\n\t\t\tlet byteLength;\n\t\t\tlet readOnly;\n\t\t\tif (typeof data === \"string\") {\n\t\t\t\tbyteLength = Buffer.byteLength(data);\n\t\t\t\treadOnly = false;\n\t\t\t} else if (isBlob(data)) {\n\t\t\t\tbyteLength = data.size;\n\t\t\t\treadOnly = false;\n\t\t\t} else {\n\t\t\t\tdata = toBuffer(data);\n\t\t\t\tbyteLength = data.length;\n\t\t\t\treadOnly = toBuffer.readOnly;\n\t\t\t}\n\t\t\tif (byteLength > 125) throw new RangeError(\"The data size must not be greater than 125 bytes\");\n\t\t\tconst options = {\n\t\t\t\t[kByteLength]: byteLength,\n\t\t\t\tfin: true,\n\t\t\t\tgenerateMask: this._generateMask,\n\t\t\t\tmask,\n\t\t\t\tmaskBuffer: this._maskBuffer,\n\t\t\t\topcode: 9,\n\t\t\t\treadOnly,\n\t\t\t\trsv1: false\n\t\t\t};\n\t\t\tif (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([\n\t\t\t\tthis.getBlobData,\n\t\t\t\tdata,\n\t\t\t\tfalse,\n\t\t\t\toptions,\n\t\t\t\tcb\n\t\t\t]);\n\t\t\telse this.getBlobData(data, false, options, cb);\n\t\t\telse if (this._state !== DEFAULT) this.enqueue([\n\t\t\t\tthis.dispatch,\n\t\t\t\tdata,\n\t\t\t\tfalse,\n\t\t\t\toptions,\n\t\t\t\tcb\n\t\t\t]);\n\t\t\telse this.sendFrame(Sender.frame(data, options), cb);\n\t\t}\n\t\t/**\n\t\t* Sends a pong message to the other peer.\n\t\t*\n\t\t* @param {*} data The message to send\n\t\t* @param {Boolean} [mask=false] Specifies whether or not to mask `data`\n\t\t* @param {Function} [cb] Callback\n\t\t* @public\n\t\t*/\n\t\tpong(data, mask, cb) {\n\t\t\tlet byteLength;\n\t\t\tlet readOnly;\n\t\t\tif (typeof data === \"string\") {\n\t\t\t\tbyteLength = Buffer.byteLength(data);\n\t\t\t\treadOnly = false;\n\t\t\t} else if (isBlob(data)) {\n\t\t\t\tbyteLength = data.size;\n\t\t\t\treadOnly = false;\n\t\t\t} else {\n\t\t\t\tdata = toBuffer(data);\n\t\t\t\tbyteLength = data.length;\n\t\t\t\treadOnly = toBuffer.readOnly;\n\t\t\t}\n\t\t\tif (byteLength > 125) throw new RangeError(\"The data size must not be greater than 125 bytes\");\n\t\t\tconst options = {\n\t\t\t\t[kByteLength]: byteLength,\n\t\t\t\tfin: true,\n\t\t\t\tgenerateMask: this._generateMask,\n\t\t\t\tmask,\n\t\t\t\tmaskBuffer: this._maskBuffer,\n\t\t\t\topcode: 10,\n\t\t\t\treadOnly,\n\t\t\t\trsv1: false\n\t\t\t};\n\t\t\tif (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([\n\t\t\t\tthis.getBlobData,\n\t\t\t\tdata,\n\t\t\t\tfalse,\n\t\t\t\toptions,\n\t\t\t\tcb\n\t\t\t]);\n\t\t\telse this.getBlobData(data, false, options, cb);\n\t\t\telse if (this._state !== DEFAULT) this.enqueue([\n\t\t\t\tthis.dispatch,\n\t\t\t\tdata,\n\t\t\t\tfalse,\n\t\t\t\toptions,\n\t\t\t\tcb\n\t\t\t]);\n\t\t\telse this.sendFrame(Sender.frame(data, options), cb);\n\t\t}\n\t\t/**\n\t\t* Sends a data message to the other peer.\n\t\t*\n\t\t* @param {*} data The message to send\n\t\t* @param {Object} options Options object\n\t\t* @param {Boolean} [options.binary=false] Specifies whether `data` is binary\n\t\t*     or text\n\t\t* @param {Boolean} [options.compress=false] Specifies whether or not to\n\t\t*     compress `data`\n\t\t* @param {Boolean} [options.fin=false] Specifies whether the fragment is the\n\t\t*     last one\n\t\t* @param {Boolean} [options.mask=false] Specifies whether or not to mask\n\t\t*     `data`\n\t\t* @param {Function} [cb] Callback\n\t\t* @public\n\t\t*/\n\t\tsend(data, options, cb) {\n\t\t\tconst perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];\n\t\t\tlet opcode = options.binary ? 2 : 1;\n\t\t\tlet rsv1 = options.compress;\n\t\t\tlet byteLength;\n\t\t\tlet readOnly;\n\t\t\tif (typeof data === \"string\") {\n\t\t\t\tbyteLength = Buffer.byteLength(data);\n\t\t\t\treadOnly = false;\n\t\t\t} else if (isBlob(data)) {\n\t\t\t\tbyteLength = data.size;\n\t\t\t\treadOnly = false;\n\t\t\t} else {\n\t\t\t\tdata = toBuffer(data);\n\t\t\t\tbyteLength = data.length;\n\t\t\t\treadOnly = toBuffer.readOnly;\n\t\t\t}\n\t\t\tif (this._firstFragment) {\n\t\t\t\tthis._firstFragment = false;\n\t\t\t\tif (rsv1 && perMessageDeflate && perMessageDeflate.params[perMessageDeflate._isServer ? \"server_no_context_takeover\" : \"client_no_context_takeover\"]) rsv1 = byteLength >= perMessageDeflate._threshold;\n\t\t\t\tthis._compress = rsv1;\n\t\t\t} else {\n\t\t\t\trsv1 = false;\n\t\t\t\topcode = 0;\n\t\t\t}\n\t\t\tif (options.fin) this._firstFragment = true;\n\t\t\tconst opts = {\n\t\t\t\t[kByteLength]: byteLength,\n\t\t\t\tfin: options.fin,\n\t\t\t\tgenerateMask: this._generateMask,\n\t\t\t\tmask: options.mask,\n\t\t\t\tmaskBuffer: this._maskBuffer,\n\t\t\t\topcode,\n\t\t\t\treadOnly,\n\t\t\t\trsv1\n\t\t\t};\n\t\t\tif (isBlob(data)) if (this._state !== DEFAULT) this.enqueue([\n\t\t\t\tthis.getBlobData,\n\t\t\t\tdata,\n\t\t\t\tthis._compress,\n\t\t\t\topts,\n\t\t\t\tcb\n\t\t\t]);\n\t\t\telse this.getBlobData(data, this._compress, opts, cb);\n\t\t\telse if (this._state !== DEFAULT) this.enqueue([\n\t\t\t\tthis.dispatch,\n\t\t\t\tdata,\n\t\t\t\tthis._compress,\n\t\t\t\topts,\n\t\t\t\tcb\n\t\t\t]);\n\t\t\telse this.dispatch(data, this._compress, opts, cb);\n\t\t}\n\t\t/**\n\t\t* Gets the contents of a blob as binary data.\n\t\t*\n\t\t* @param {Blob} blob The blob\n\t\t* @param {Boolean} [compress=false] Specifies whether or not to compress\n\t\t*     the data\n\t\t* @param {Object} options Options object\n\t\t* @param {Boolean} [options.fin=false] Specifies whether or not to set the\n\t\t*     FIN bit\n\t\t* @param {Function} [options.generateMask] The function used to generate the\n\t\t*     masking key\n\t\t* @param {Boolean} [options.mask=false] Specifies whether or not to mask\n\t\t*     `data`\n\t\t* @param {Buffer} [options.maskBuffer] The buffer used to store the masking\n\t\t*     key\n\t\t* @param {Number} options.opcode The opcode\n\t\t* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be\n\t\t*     modified\n\t\t* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the\n\t\t*     RSV1 bit\n\t\t* @param {Function} [cb] Callback\n\t\t* @private\n\t\t*/\n\t\tgetBlobData(blob, compress, options, cb) {\n\t\t\tthis._bufferedBytes += options[kByteLength];\n\t\t\tthis._state = GET_BLOB_DATA;\n\t\t\tblob.arrayBuffer().then((arrayBuffer) => {\n\t\t\t\tif (this._socket.destroyed) {\n\t\t\t\t\tconst err = /* @__PURE__ */ new Error(\"The socket was closed while the blob was being read\");\n\t\t\t\t\tprocess.nextTick(callCallbacks, this, err, cb);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis._bufferedBytes -= options[kByteLength];\n\t\t\t\tconst data = toBuffer(arrayBuffer);\n\t\t\t\tif (!compress) {\n\t\t\t\t\tthis._state = DEFAULT;\n\t\t\t\t\tthis.sendFrame(Sender.frame(data, options), cb);\n\t\t\t\t\tthis.dequeue();\n\t\t\t\t} else this.dispatch(data, compress, options, cb);\n\t\t\t}).catch((err) => {\n\t\t\t\tprocess.nextTick(onError, this, err, cb);\n\t\t\t});\n\t\t}\n\t\t/**\n\t\t* Dispatches a message.\n\t\t*\n\t\t* @param {(Buffer|String)} data The message to send\n\t\t* @param {Boolean} [compress=false] Specifies whether or not to compress\n\t\t*     `data`\n\t\t* @param {Object} options Options object\n\t\t* @param {Boolean} [options.fin=false] Specifies whether or not to set the\n\t\t*     FIN bit\n\t\t* @param {Function} [options.generateMask] The function used to generate the\n\t\t*     masking key\n\t\t* @param {Boolean} [options.mask=false] Specifies whether or not to mask\n\t\t*     `data`\n\t\t* @param {Buffer} [options.maskBuffer] The buffer used to store the masking\n\t\t*     key\n\t\t* @param {Number} options.opcode The opcode\n\t\t* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be\n\t\t*     modified\n\t\t* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the\n\t\t*     RSV1 bit\n\t\t* @param {Function} [cb] Callback\n\t\t* @private\n\t\t*/\n\t\tdispatch(data, compress, options, cb) {\n\t\t\tif (!compress) {\n\t\t\t\tthis.sendFrame(Sender.frame(data, options), cb);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];\n\t\t\tthis._bufferedBytes += options[kByteLength];\n\t\t\tthis._state = DEFLATING;\n\t\t\tperMessageDeflate.compress(data, options.fin, (_, buf) => {\n\t\t\t\tif (this._socket.destroyed) {\n\t\t\t\t\tcallCallbacks(this, /* @__PURE__ */ new Error(\"The socket was closed while data was being compressed\"), cb);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis._bufferedBytes -= options[kByteLength];\n\t\t\t\tthis._state = DEFAULT;\n\t\t\t\toptions.readOnly = false;\n\t\t\t\tthis.sendFrame(Sender.frame(buf, options), cb);\n\t\t\t\tthis.dequeue();\n\t\t\t});\n\t\t}\n\t\t/**\n\t\t* Executes queued send operations.\n\t\t*\n\t\t* @private\n\t\t*/\n\t\tdequeue() {\n\t\t\twhile (this._state === DEFAULT && this._queue.length) {\n\t\t\t\tconst params = this._queue.shift();\n\t\t\t\tthis._bufferedBytes -= params[3][kByteLength];\n\t\t\t\tReflect.apply(params[0], this, params.slice(1));\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t* Enqueues a send operation.\n\t\t*\n\t\t* @param {Array} params Send operation parameters.\n\t\t* @private\n\t\t*/\n\t\tenqueue(params) {\n\t\t\tthis._bufferedBytes += params[3][kByteLength];\n\t\t\tthis._queue.push(params);\n\t\t}\n\t\t/**\n\t\t* Sends a frame.\n\t\t*\n\t\t* @param {(Buffer | String)[]} list The frame to send\n\t\t* @param {Function} [cb] Callback\n\t\t* @private\n\t\t*/\n\t\tsendFrame(list, cb) {\n\t\t\tif (list.length === 2) {\n\t\t\t\tthis._socket.cork();\n\t\t\t\tthis._socket.write(list[0]);\n\t\t\t\tthis._socket.write(list[1], cb);\n\t\t\t\tthis._socket.uncork();\n\t\t\t} else this._socket.write(list[0], cb);\n\t\t}\n\t};\n\tmodule.exports = Sender;\n\t/**\n\t* Calls queued callbacks with an error.\n\t*\n\t* @param {Sender} sender The `Sender` instance\n\t* @param {Error} err The error to call the callbacks with\n\t* @param {Function} [cb] The first callback\n\t* @private\n\t*/\n\tfunction callCallbacks(sender, err, cb) {\n\t\tif (typeof cb === \"function\") cb(err);\n\t\tfor (let i = 0; i < sender._queue.length; i++) {\n\t\t\tconst params = sender._queue[i];\n\t\t\tconst callback = params[params.length - 1];\n\t\t\tif (typeof callback === \"function\") callback(err);\n\t\t}\n\t}\n\t/**\n\t* Handles a `Sender` error.\n\t*\n\t* @param {Sender} sender The `Sender` instance\n\t* @param {Error} err The error\n\t* @param {Function} [cb] The first pending callback\n\t* @private\n\t*/\n\tfunction onError(sender, err, cb) {\n\t\tcallCallbacks(sender, err, cb);\n\t\tsender.onerror(err);\n\t}\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/event-target.js\nvar require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst { kForOnEventAttribute, kListener } = require_constants();\n\tconst kCode = Symbol(\"kCode\");\n\tconst kData = Symbol(\"kData\");\n\tconst kError = Symbol(\"kError\");\n\tconst kMessage = Symbol(\"kMessage\");\n\tconst kReason = Symbol(\"kReason\");\n\tconst kTarget = Symbol(\"kTarget\");\n\tconst kType = Symbol(\"kType\");\n\tconst kWasClean = Symbol(\"kWasClean\");\n\t/**\n\t* Class representing an event.\n\t*/\n\tvar Event = class {\n\t\t/**\n\t\t* Create a new `Event`.\n\t\t*\n\t\t* @param {String} type The name of the event\n\t\t* @throws {TypeError} If the `type` argument is not specified\n\t\t*/\n\t\tconstructor(type) {\n\t\t\tthis[kTarget] = null;\n\t\t\tthis[kType] = type;\n\t\t}\n\t\t/**\n\t\t* @type {*}\n\t\t*/\n\t\tget target() {\n\t\t\treturn this[kTarget];\n\t\t}\n\t\t/**\n\t\t* @type {String}\n\t\t*/\n\t\tget type() {\n\t\t\treturn this[kType];\n\t\t}\n\t};\n\tObject.defineProperty(Event.prototype, \"target\", { enumerable: true });\n\tObject.defineProperty(Event.prototype, \"type\", { enumerable: true });\n\t/**\n\t* Class representing a close event.\n\t*\n\t* @extends Event\n\t*/\n\tvar CloseEvent = class extends Event {\n\t\t/**\n\t\t* Create a new `CloseEvent`.\n\t\t*\n\t\t* @param {String} type The name of the event\n\t\t* @param {Object} [options] A dictionary object that allows for setting\n\t\t*     attributes via object members of the same name\n\t\t* @param {Number} [options.code=0] The status code explaining why the\n\t\t*     connection was closed\n\t\t* @param {String} [options.reason=''] A human-readable string explaining why\n\t\t*     the connection was closed\n\t\t* @param {Boolean} [options.wasClean=false] Indicates whether or not the\n\t\t*     connection was cleanly closed\n\t\t*/\n\t\tconstructor(type, options = {}) {\n\t\t\tsuper(type);\n\t\t\tthis[kCode] = options.code === void 0 ? 0 : options.code;\n\t\t\tthis[kReason] = options.reason === void 0 ? \"\" : options.reason;\n\t\t\tthis[kWasClean] = options.wasClean === void 0 ? false : options.wasClean;\n\t\t}\n\t\t/**\n\t\t* @type {Number}\n\t\t*/\n\t\tget code() {\n\t\t\treturn this[kCode];\n\t\t}\n\t\t/**\n\t\t* @type {String}\n\t\t*/\n\t\tget reason() {\n\t\t\treturn this[kReason];\n\t\t}\n\t\t/**\n\t\t* @type {Boolean}\n\t\t*/\n\t\tget wasClean() {\n\t\t\treturn this[kWasClean];\n\t\t}\n\t};\n\tObject.defineProperty(CloseEvent.prototype, \"code\", { enumerable: true });\n\tObject.defineProperty(CloseEvent.prototype, \"reason\", { enumerable: true });\n\tObject.defineProperty(CloseEvent.prototype, \"wasClean\", { enumerable: true });\n\t/**\n\t* Class representing an error event.\n\t*\n\t* @extends Event\n\t*/\n\tvar ErrorEvent = class extends Event {\n\t\t/**\n\t\t* Create a new `ErrorEvent`.\n\t\t*\n\t\t* @param {String} type The name of the event\n\t\t* @param {Object} [options] A dictionary object that allows for setting\n\t\t*     attributes via object members of the same name\n\t\t* @param {*} [options.error=null] The error that generated this event\n\t\t* @param {String} [options.message=''] The error message\n\t\t*/\n\t\tconstructor(type, options = {}) {\n\t\t\tsuper(type);\n\t\t\tthis[kError] = options.error === void 0 ? null : options.error;\n\t\t\tthis[kMessage] = options.message === void 0 ? \"\" : options.message;\n\t\t}\n\t\t/**\n\t\t* @type {*}\n\t\t*/\n\t\tget error() {\n\t\t\treturn this[kError];\n\t\t}\n\t\t/**\n\t\t* @type {String}\n\t\t*/\n\t\tget message() {\n\t\t\treturn this[kMessage];\n\t\t}\n\t};\n\tObject.defineProperty(ErrorEvent.prototype, \"error\", { enumerable: true });\n\tObject.defineProperty(ErrorEvent.prototype, \"message\", { enumerable: true });\n\t/**\n\t* Class representing a message event.\n\t*\n\t* @extends Event\n\t*/\n\tvar MessageEvent = class extends Event {\n\t\t/**\n\t\t* Create a new `MessageEvent`.\n\t\t*\n\t\t* @param {String} type The name of the event\n\t\t* @param {Object} [options] A dictionary object that allows for setting\n\t\t*     attributes via object members of the same name\n\t\t* @param {*} [options.data=null] The message content\n\t\t*/\n\t\tconstructor(type, options = {}) {\n\t\t\tsuper(type);\n\t\t\tthis[kData] = options.data === void 0 ? null : options.data;\n\t\t}\n\t\t/**\n\t\t* @type {*}\n\t\t*/\n\t\tget data() {\n\t\t\treturn this[kData];\n\t\t}\n\t};\n\tObject.defineProperty(MessageEvent.prototype, \"data\", { enumerable: true });\n\t/**\n\t* This provides methods for emulating the `EventTarget` interface. It's not\n\t* meant to be used directly.\n\t*\n\t* @mixin\n\t*/\n\tconst EventTarget = {\n\t\taddEventListener(type, handler, options = {}) {\n\t\t\tfor (const listener of this.listeners(type)) if (!options[kForOnEventAttribute] && listener[kListener] === handler && !listener[kForOnEventAttribute]) return;\n\t\t\tlet wrapper;\n\t\t\tif (type === \"message\") wrapper = function onMessage(data, isBinary) {\n\t\t\t\tconst event = new MessageEvent(\"message\", { data: isBinary ? data : data.toString() });\n\t\t\t\tevent[kTarget] = this;\n\t\t\t\tcallListener(handler, this, event);\n\t\t\t};\n\t\t\telse if (type === \"close\") wrapper = function onClose(code, message) {\n\t\t\t\tconst event = new CloseEvent(\"close\", {\n\t\t\t\t\tcode,\n\t\t\t\t\treason: message.toString(),\n\t\t\t\t\twasClean: this._closeFrameReceived && this._closeFrameSent\n\t\t\t\t});\n\t\t\t\tevent[kTarget] = this;\n\t\t\t\tcallListener(handler, this, event);\n\t\t\t};\n\t\t\telse if (type === \"error\") wrapper = function onError(error) {\n\t\t\t\tconst event = new ErrorEvent(\"error\", {\n\t\t\t\t\terror,\n\t\t\t\t\tmessage: error.message\n\t\t\t\t});\n\t\t\t\tevent[kTarget] = this;\n\t\t\t\tcallListener(handler, this, event);\n\t\t\t};\n\t\t\telse if (type === \"open\") wrapper = function onOpen() {\n\t\t\t\tconst event = new Event(\"open\");\n\t\t\t\tevent[kTarget] = this;\n\t\t\t\tcallListener(handler, this, event);\n\t\t\t};\n\t\t\telse return;\n\t\t\twrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];\n\t\t\twrapper[kListener] = handler;\n\t\t\tif (options.once) this.once(type, wrapper);\n\t\t\telse this.on(type, wrapper);\n\t\t},\n\t\tremoveEventListener(type, handler) {\n\t\t\tfor (const listener of this.listeners(type)) if (listener[kListener] === handler && !listener[kForOnEventAttribute]) {\n\t\t\t\tthis.removeListener(type, listener);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\tmodule.exports = {\n\t\tCloseEvent,\n\t\tErrorEvent,\n\t\tEvent,\n\t\tEventTarget,\n\t\tMessageEvent\n\t};\n\t/**\n\t* Call an event listener\n\t*\n\t* @param {(Function|Object)} listener The listener to call\n\t* @param {*} thisArg The value to use as `this`` when calling the listener\n\t* @param {Event} event The event to pass to the listener\n\t* @private\n\t*/\n\tfunction callListener(listener, thisArg, event) {\n\t\tif (typeof listener === \"object\" && listener.handleEvent) listener.handleEvent.call(listener, event);\n\t\telse listener.call(thisArg, event);\n\t}\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/extension.js\nvar require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst { tokenChars } = require_validation();\n\t/**\n\t* Adds an offer to the map of extension offers or a parameter to the map of\n\t* parameters.\n\t*\n\t* @param {Object} dest The map of extension offers or parameters\n\t* @param {String} name The extension or parameter name\n\t* @param {(Object|Boolean|String)} elem The extension parameters or the\n\t*     parameter value\n\t* @private\n\t*/\n\tfunction push(dest, name, elem) {\n\t\tif (dest[name] === void 0) dest[name] = [elem];\n\t\telse dest[name].push(elem);\n\t}\n\t/**\n\t* Parses the `Sec-WebSocket-Extensions` header into an object.\n\t*\n\t* @param {String} header The field value of the header\n\t* @return {Object} The parsed object\n\t* @public\n\t*/\n\tfunction parse(header) {\n\t\tconst offers = Object.create(null);\n\t\tlet params = Object.create(null);\n\t\tlet mustUnescape = false;\n\t\tlet isEscaping = false;\n\t\tlet inQuotes = false;\n\t\tlet extensionName;\n\t\tlet paramName;\n\t\tlet start = -1;\n\t\tlet code = -1;\n\t\tlet end = -1;\n\t\tlet i = 0;\n\t\tfor (; i < header.length; i++) {\n\t\t\tcode = header.charCodeAt(i);\n\t\t\tif (extensionName === void 0) if (end === -1 && tokenChars[code] === 1) {\n\t\t\t\tif (start === -1) start = i;\n\t\t\t} else if (i !== 0 && (code === 32 || code === 9)) {\n\t\t\t\tif (end === -1 && start !== -1) end = i;\n\t\t\t} else if (code === 59 || code === 44) {\n\t\t\t\tif (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\t\tif (end === -1) end = i;\n\t\t\t\tconst name = header.slice(start, end);\n\t\t\t\tif (code === 44) {\n\t\t\t\t\tpush(offers, name, params);\n\t\t\t\t\tparams = Object.create(null);\n\t\t\t\t} else extensionName = name;\n\t\t\t\tstart = end = -1;\n\t\t\t} else throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\telse if (paramName === void 0) if (end === -1 && tokenChars[code] === 1) {\n\t\t\t\tif (start === -1) start = i;\n\t\t\t} else if (code === 32 || code === 9) {\n\t\t\t\tif (end === -1 && start !== -1) end = i;\n\t\t\t} else if (code === 59 || code === 44) {\n\t\t\t\tif (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\t\tif (end === -1) end = i;\n\t\t\t\tpush(params, header.slice(start, end), true);\n\t\t\t\tif (code === 44) {\n\t\t\t\t\tpush(offers, extensionName, params);\n\t\t\t\t\tparams = Object.create(null);\n\t\t\t\t\textensionName = void 0;\n\t\t\t\t}\n\t\t\t\tstart = end = -1;\n\t\t\t} else if (code === 61 && start !== -1 && end === -1) {\n\t\t\t\tparamName = header.slice(start, i);\n\t\t\t\tstart = end = -1;\n\t\t\t} else throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\telse if (isEscaping) {\n\t\t\t\tif (tokenChars[code] !== 1) throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\t\tif (start === -1) start = i;\n\t\t\t\telse if (!mustUnescape) mustUnescape = true;\n\t\t\t\tisEscaping = false;\n\t\t\t} else if (inQuotes) if (tokenChars[code] === 1) {\n\t\t\t\tif (start === -1) start = i;\n\t\t\t} else if (code === 34 && start !== -1) {\n\t\t\t\tinQuotes = false;\n\t\t\t\tend = i;\n\t\t\t} else if (code === 92) isEscaping = true;\n\t\t\telse throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\telse if (code === 34 && header.charCodeAt(i - 1) === 61) inQuotes = true;\n\t\t\telse if (end === -1 && tokenChars[code] === 1) {\n\t\t\t\tif (start === -1) start = i;\n\t\t\t} else if (start !== -1 && (code === 32 || code === 9)) {\n\t\t\t\tif (end === -1) end = i;\n\t\t\t} else if (code === 59 || code === 44) {\n\t\t\t\tif (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\t\tif (end === -1) end = i;\n\t\t\t\tlet value = header.slice(start, end);\n\t\t\t\tif (mustUnescape) {\n\t\t\t\t\tvalue = value.replace(/\\\\/g, \"\");\n\t\t\t\t\tmustUnescape = false;\n\t\t\t\t}\n\t\t\t\tpush(params, paramName, value);\n\t\t\t\tif (code === 44) {\n\t\t\t\t\tpush(offers, extensionName, params);\n\t\t\t\t\tparams = Object.create(null);\n\t\t\t\t\textensionName = void 0;\n\t\t\t\t}\n\t\t\t\tparamName = void 0;\n\t\t\t\tstart = end = -1;\n\t\t\t} else throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t}\n\t\tif (start === -1 || inQuotes || code === 32 || code === 9) throw new SyntaxError(\"Unexpected end of input\");\n\t\tif (end === -1) end = i;\n\t\tconst token = header.slice(start, end);\n\t\tif (extensionName === void 0) push(offers, token, params);\n\t\telse {\n\t\t\tif (paramName === void 0) push(params, token, true);\n\t\t\telse if (mustUnescape) push(params, paramName, token.replace(/\\\\/g, \"\"));\n\t\t\telse push(params, paramName, token);\n\t\t\tpush(offers, extensionName, params);\n\t\t}\n\t\treturn offers;\n\t}\n\t/**\n\t* Builds the `Sec-WebSocket-Extensions` header field value.\n\t*\n\t* @param {Object} extensions The map of extensions and parameters to format\n\t* @return {String} A string representing the given object\n\t* @public\n\t*/\n\tfunction format(extensions) {\n\t\treturn Object.keys(extensions).map((extension) => {\n\t\t\tlet configurations = extensions[extension];\n\t\t\tif (!Array.isArray(configurations)) configurations = [configurations];\n\t\t\treturn configurations.map((params) => {\n\t\t\t\treturn [extension].concat(Object.keys(params).map((k) => {\n\t\t\t\t\tlet values = params[k];\n\t\t\t\t\tif (!Array.isArray(values)) values = [values];\n\t\t\t\t\treturn values.map((v) => v === true ? k : `${k}=${v}`).join(\"; \");\n\t\t\t\t})).join(\"; \");\n\t\t\t}).join(\", \");\n\t\t}).join(\", \");\n\t}\n\tmodule.exports = {\n\t\tformat,\n\t\tparse\n\t};\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/websocket.js\nvar require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst EventEmitter$1 = __require(\"events\");\n\tconst https = __require(\"https\");\n\tconst http$1 = __require(\"http\");\n\tconst net = __require(\"net\");\n\tconst tls = __require(\"tls\");\n\tconst { randomBytes, createHash: createHash$1 } = __require(\"crypto\");\n\tconst { Duplex: Duplex$2, Readable } = __require(\"stream\");\n\tconst { URL } = __require(\"url\");\n\tconst PerMessageDeflate = require_permessage_deflate();\n\tconst Receiver = require_receiver();\n\tconst Sender = require_sender();\n\tconst { isBlob } = require_validation();\n\tconst { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = require_constants();\n\tconst { EventTarget: { addEventListener, removeEventListener } } = require_event_target();\n\tconst { format, parse } = require_extension();\n\tconst { toBuffer } = require_buffer_util();\n\tconst kAborted = Symbol(\"kAborted\");\n\tconst protocolVersions = [8, 13];\n\tconst readyStates = [\n\t\t\"CONNECTING\",\n\t\t\"OPEN\",\n\t\t\"CLOSING\",\n\t\t\"CLOSED\"\n\t];\n\tconst subprotocolRegex = /^[!#$%&'*+\\-.0-9A-Z^_`|a-z~]+$/;\n\t/**\n\t* Class representing a WebSocket.\n\t*\n\t* @extends EventEmitter\n\t*/\n\tvar WebSocket = class WebSocket extends EventEmitter$1 {\n\t\t/**\n\t\t* Create a new `WebSocket`.\n\t\t*\n\t\t* @param {(String|URL)} address The URL to which to connect\n\t\t* @param {(String|String[])} [protocols] The subprotocols\n\t\t* @param {Object} [options] Connection options\n\t\t*/\n\t\tconstructor(address, protocols, options) {\n\t\t\tsuper();\n\t\t\tthis._binaryType = BINARY_TYPES[0];\n\t\t\tthis._closeCode = 1006;\n\t\t\tthis._closeFrameReceived = false;\n\t\t\tthis._closeFrameSent = false;\n\t\t\tthis._closeMessage = EMPTY_BUFFER;\n\t\t\tthis._closeTimer = null;\n\t\t\tthis._errorEmitted = false;\n\t\t\tthis._extensions = {};\n\t\t\tthis._paused = false;\n\t\t\tthis._protocol = \"\";\n\t\t\tthis._readyState = WebSocket.CONNECTING;\n\t\t\tthis._receiver = null;\n\t\t\tthis._sender = null;\n\t\t\tthis._socket = null;\n\t\t\tif (address !== null) {\n\t\t\t\tthis._bufferedAmount = 0;\n\t\t\t\tthis._isServer = false;\n\t\t\t\tthis._redirects = 0;\n\t\t\t\tif (protocols === void 0) protocols = [];\n\t\t\t\telse if (!Array.isArray(protocols)) if (typeof protocols === \"object\" && protocols !== null) {\n\t\t\t\t\toptions = protocols;\n\t\t\t\t\tprotocols = [];\n\t\t\t\t} else protocols = [protocols];\n\t\t\t\tinitAsClient(this, address, protocols, options);\n\t\t\t} else {\n\t\t\t\tthis._autoPong = options.autoPong;\n\t\t\t\tthis._closeTimeout = options.closeTimeout;\n\t\t\t\tthis._isServer = true;\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t* For historical reasons, the custom \"nodebuffer\" type is used by the default\n\t\t* instead of \"blob\".\n\t\t*\n\t\t* @type {String}\n\t\t*/\n\t\tget binaryType() {\n\t\t\treturn this._binaryType;\n\t\t}\n\t\tset binaryType(type) {\n\t\t\tif (!BINARY_TYPES.includes(type)) return;\n\t\t\tthis._binaryType = type;\n\t\t\tif (this._receiver) this._receiver._binaryType = type;\n\t\t}\n\t\t/**\n\t\t* @type {Number}\n\t\t*/\n\t\tget bufferedAmount() {\n\t\t\tif (!this._socket) return this._bufferedAmount;\n\t\t\treturn this._socket._writableState.length + this._sender._bufferedBytes;\n\t\t}\n\t\t/**\n\t\t* @type {String}\n\t\t*/\n\t\tget extensions() {\n\t\t\treturn Object.keys(this._extensions).join();\n\t\t}\n\t\t/**\n\t\t* @type {Boolean}\n\t\t*/\n\t\tget isPaused() {\n\t\t\treturn this._paused;\n\t\t}\n\t\t/**\n\t\t* @type {Function}\n\t\t*/\n\t\t/* istanbul ignore next */\n\t\tget onclose() {\n\t\t\treturn null;\n\t\t}\n\t\t/**\n\t\t* @type {Function}\n\t\t*/\n\t\t/* istanbul ignore next */\n\t\tget onerror() {\n\t\t\treturn null;\n\t\t}\n\t\t/**\n\t\t* @type {Function}\n\t\t*/\n\t\t/* istanbul ignore next */\n\t\tget onopen() {\n\t\t\treturn null;\n\t\t}\n\t\t/**\n\t\t* @type {Function}\n\t\t*/\n\t\t/* istanbul ignore next */\n\t\tget onmessage() {\n\t\t\treturn null;\n\t\t}\n\t\t/**\n\t\t* @type {String}\n\t\t*/\n\t\tget protocol() {\n\t\t\treturn this._protocol;\n\t\t}\n\t\t/**\n\t\t* @type {Number}\n\t\t*/\n\t\tget readyState() {\n\t\t\treturn this._readyState;\n\t\t}\n\t\t/**\n\t\t* @type {String}\n\t\t*/\n\t\tget url() {\n\t\t\treturn this._url;\n\t\t}\n\t\t/**\n\t\t* Set up the socket and the internal resources.\n\t\t*\n\t\t* @param {Duplex} socket The network socket between the server and client\n\t\t* @param {Buffer} head The first packet of the upgraded stream\n\t\t* @param {Object} options Options object\n\t\t* @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether\n\t\t*     any of the `'message'`, `'ping'`, and `'pong'` events can be emitted\n\t\t*     multiple times in the same tick\n\t\t* @param {Function} [options.generateMask] The function used to generate the\n\t\t*     masking key\n\t\t* @param {Number} [options.maxPayload=0] The maximum allowed message size\n\t\t* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or\n\t\t*     not to skip UTF-8 validation for text and close messages\n\t\t* @private\n\t\t*/\n\t\tsetSocket(socket, head, options) {\n\t\t\tconst receiver = new Receiver({\n\t\t\t\tallowSynchronousEvents: options.allowSynchronousEvents,\n\t\t\t\tbinaryType: this.binaryType,\n\t\t\t\textensions: this._extensions,\n\t\t\t\tisServer: this._isServer,\n\t\t\t\tmaxPayload: options.maxPayload,\n\t\t\t\tskipUTF8Validation: options.skipUTF8Validation\n\t\t\t});\n\t\t\tconst sender = new Sender(socket, this._extensions, options.generateMask);\n\t\t\tthis._receiver = receiver;\n\t\t\tthis._sender = sender;\n\t\t\tthis._socket = socket;\n\t\t\treceiver[kWebSocket] = this;\n\t\t\tsender[kWebSocket] = this;\n\t\t\tsocket[kWebSocket] = this;\n\t\t\treceiver.on(\"conclude\", receiverOnConclude);\n\t\t\treceiver.on(\"drain\", receiverOnDrain);\n\t\t\treceiver.on(\"error\", receiverOnError);\n\t\t\treceiver.on(\"message\", receiverOnMessage);\n\t\t\treceiver.on(\"ping\", receiverOnPing);\n\t\t\treceiver.on(\"pong\", receiverOnPong);\n\t\t\tsender.onerror = senderOnError;\n\t\t\tif (socket.setTimeout) socket.setTimeout(0);\n\t\t\tif (socket.setNoDelay) socket.setNoDelay();\n\t\t\tif (head.length > 0) socket.unshift(head);\n\t\t\tsocket.on(\"close\", socketOnClose);\n\t\t\tsocket.on(\"data\", socketOnData);\n\t\t\tsocket.on(\"end\", socketOnEnd);\n\t\t\tsocket.on(\"error\", socketOnError);\n\t\t\tthis._readyState = WebSocket.OPEN;\n\t\t\tthis.emit(\"open\");\n\t\t}\n\t\t/**\n\t\t* Emit the `'close'` event.\n\t\t*\n\t\t* @private\n\t\t*/\n\t\temitClose() {\n\t\t\tif (!this._socket) {\n\t\t\t\tthis._readyState = WebSocket.CLOSED;\n\t\t\t\tthis.emit(\"close\", this._closeCode, this._closeMessage);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this._extensions[PerMessageDeflate.extensionName]) this._extensions[PerMessageDeflate.extensionName].cleanup();\n\t\t\tthis._receiver.removeAllListeners();\n\t\t\tthis._readyState = WebSocket.CLOSED;\n\t\t\tthis.emit(\"close\", this._closeCode, this._closeMessage);\n\t\t}\n\t\t/**\n\t\t* Start a closing handshake.\n\t\t*\n\t\t*          +----------+   +-----------+   +----------+\n\t\t*     - - -|ws.close()|-->|close frame|-->|ws.close()|- - -\n\t\t*    |     +----------+   +-----------+   +----------+     |\n\t\t*          +----------+   +-----------+         |\n\t\t* CLOSING  |ws.close()|<--|close frame|<--+-----+       CLOSING\n\t\t*          +----------+   +-----------+   |\n\t\t*    |           |                        |   +---+        |\n\t\t*                +------------------------+-->|fin| - - - -\n\t\t*    |         +---+                      |   +---+\n\t\t*     - - - - -|fin|<---------------------+\n\t\t*              +---+\n\t\t*\n\t\t* @param {Number} [code] Status code explaining why the connection is closing\n\t\t* @param {(String|Buffer)} [data] The reason why the connection is\n\t\t*     closing\n\t\t* @public\n\t\t*/\n\t\tclose(code, data) {\n\t\t\tif (this.readyState === WebSocket.CLOSED) return;\n\t\t\tif (this.readyState === WebSocket.CONNECTING) {\n\t\t\t\tabortHandshake(this, this._req, \"WebSocket was closed before the connection was established\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this.readyState === WebSocket.CLOSING) {\n\t\t\t\tif (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) this._socket.end();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._readyState = WebSocket.CLOSING;\n\t\t\tthis._sender.close(code, data, !this._isServer, (err) => {\n\t\t\t\tif (err) return;\n\t\t\t\tthis._closeFrameSent = true;\n\t\t\t\tif (this._closeFrameReceived || this._receiver._writableState.errorEmitted) this._socket.end();\n\t\t\t});\n\t\t\tsetCloseTimer(this);\n\t\t}\n\t\t/**\n\t\t* Pause the socket.\n\t\t*\n\t\t* @public\n\t\t*/\n\t\tpause() {\n\t\t\tif (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;\n\t\t\tthis._paused = true;\n\t\t\tthis._socket.pause();\n\t\t}\n\t\t/**\n\t\t* Send a ping.\n\t\t*\n\t\t* @param {*} [data] The data to send\n\t\t* @param {Boolean} [mask] Indicates whether or not to mask `data`\n\t\t* @param {Function} [cb] Callback which is executed when the ping is sent\n\t\t* @public\n\t\t*/\n\t\tping(data, mask, cb) {\n\t\t\tif (this.readyState === WebSocket.CONNECTING) throw new Error(\"WebSocket is not open: readyState 0 (CONNECTING)\");\n\t\t\tif (typeof data === \"function\") {\n\t\t\t\tcb = data;\n\t\t\t\tdata = mask = void 0;\n\t\t\t} else if (typeof mask === \"function\") {\n\t\t\t\tcb = mask;\n\t\t\t\tmask = void 0;\n\t\t\t}\n\t\t\tif (typeof data === \"number\") data = data.toString();\n\t\t\tif (this.readyState !== WebSocket.OPEN) {\n\t\t\t\tsendAfterClose(this, data, cb);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mask === void 0) mask = !this._isServer;\n\t\t\tthis._sender.ping(data || EMPTY_BUFFER, mask, cb);\n\t\t}\n\t\t/**\n\t\t* Send a pong.\n\t\t*\n\t\t* @param {*} [data] The data to send\n\t\t* @param {Boolean} [mask] Indicates whether or not to mask `data`\n\t\t* @param {Function} [cb] Callback which is executed when the pong is sent\n\t\t* @public\n\t\t*/\n\t\tpong(data, mask, cb) {\n\t\t\tif (this.readyState === WebSocket.CONNECTING) throw new Error(\"WebSocket is not open: readyState 0 (CONNECTING)\");\n\t\t\tif (typeof data === \"function\") {\n\t\t\t\tcb = data;\n\t\t\t\tdata = mask = void 0;\n\t\t\t} else if (typeof mask === \"function\") {\n\t\t\t\tcb = mask;\n\t\t\t\tmask = void 0;\n\t\t\t}\n\t\t\tif (typeof data === \"number\") data = data.toString();\n\t\t\tif (this.readyState !== WebSocket.OPEN) {\n\t\t\t\tsendAfterClose(this, data, cb);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mask === void 0) mask = !this._isServer;\n\t\t\tthis._sender.pong(data || EMPTY_BUFFER, mask, cb);\n\t\t}\n\t\t/**\n\t\t* Resume the socket.\n\t\t*\n\t\t* @public\n\t\t*/\n\t\tresume() {\n\t\t\tif (this.readyState === WebSocket.CONNECTING || this.readyState === WebSocket.CLOSED) return;\n\t\t\tthis._paused = false;\n\t\t\tif (!this._receiver._writableState.needDrain) this._socket.resume();\n\t\t}\n\t\t/**\n\t\t* Send a data message.\n\t\t*\n\t\t* @param {*} data The message to send\n\t\t* @param {Object} [options] Options object\n\t\t* @param {Boolean} [options.binary] Specifies whether `data` is binary or\n\t\t*     text\n\t\t* @param {Boolean} [options.compress] Specifies whether or not to compress\n\t\t*     `data`\n\t\t* @param {Boolean} [options.fin=true] Specifies whether the fragment is the\n\t\t*     last one\n\t\t* @param {Boolean} [options.mask] Specifies whether or not to mask `data`\n\t\t* @param {Function} [cb] Callback which is executed when data is written out\n\t\t* @public\n\t\t*/\n\t\tsend(data, options, cb) {\n\t\t\tif (this.readyState === WebSocket.CONNECTING) throw new Error(\"WebSocket is not open: readyState 0 (CONNECTING)\");\n\t\t\tif (typeof options === \"function\") {\n\t\t\t\tcb = options;\n\t\t\t\toptions = {};\n\t\t\t}\n\t\t\tif (typeof data === \"number\") data = data.toString();\n\t\t\tif (this.readyState !== WebSocket.OPEN) {\n\t\t\t\tsendAfterClose(this, data, cb);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst opts = {\n\t\t\t\tbinary: typeof data !== \"string\",\n\t\t\t\tmask: !this._isServer,\n\t\t\t\tcompress: true,\n\t\t\t\tfin: true,\n\t\t\t\t...options\n\t\t\t};\n\t\t\tif (!this._extensions[PerMessageDeflate.extensionName]) opts.compress = false;\n\t\t\tthis._sender.send(data || EMPTY_BUFFER, opts, cb);\n\t\t}\n\t\t/**\n\t\t* Forcibly close the connection.\n\t\t*\n\t\t* @public\n\t\t*/\n\t\tterminate() {\n\t\t\tif (this.readyState === WebSocket.CLOSED) return;\n\t\t\tif (this.readyState === WebSocket.CONNECTING) {\n\t\t\t\tabortHandshake(this, this._req, \"WebSocket was closed before the connection was established\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this._socket) {\n\t\t\t\tthis._readyState = WebSocket.CLOSING;\n\t\t\t\tthis._socket.destroy();\n\t\t\t}\n\t\t}\n\t};\n\t/**\n\t* @constant {Number} CONNECTING\n\t* @memberof WebSocket\n\t*/\n\tObject.defineProperty(WebSocket, \"CONNECTING\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"CONNECTING\")\n\t});\n\t/**\n\t* @constant {Number} CONNECTING\n\t* @memberof WebSocket.prototype\n\t*/\n\tObject.defineProperty(WebSocket.prototype, \"CONNECTING\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"CONNECTING\")\n\t});\n\t/**\n\t* @constant {Number} OPEN\n\t* @memberof WebSocket\n\t*/\n\tObject.defineProperty(WebSocket, \"OPEN\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"OPEN\")\n\t});\n\t/**\n\t* @constant {Number} OPEN\n\t* @memberof WebSocket.prototype\n\t*/\n\tObject.defineProperty(WebSocket.prototype, \"OPEN\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"OPEN\")\n\t});\n\t/**\n\t* @constant {Number} CLOSING\n\t* @memberof WebSocket\n\t*/\n\tObject.defineProperty(WebSocket, \"CLOSING\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"CLOSING\")\n\t});\n\t/**\n\t* @constant {Number} CLOSING\n\t* @memberof WebSocket.prototype\n\t*/\n\tObject.defineProperty(WebSocket.prototype, \"CLOSING\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"CLOSING\")\n\t});\n\t/**\n\t* @constant {Number} CLOSED\n\t* @memberof WebSocket\n\t*/\n\tObject.defineProperty(WebSocket, \"CLOSED\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"CLOSED\")\n\t});\n\t/**\n\t* @constant {Number} CLOSED\n\t* @memberof WebSocket.prototype\n\t*/\n\tObject.defineProperty(WebSocket.prototype, \"CLOSED\", {\n\t\tenumerable: true,\n\t\tvalue: readyStates.indexOf(\"CLOSED\")\n\t});\n\t[\n\t\t\"binaryType\",\n\t\t\"bufferedAmount\",\n\t\t\"extensions\",\n\t\t\"isPaused\",\n\t\t\"protocol\",\n\t\t\"readyState\",\n\t\t\"url\"\n\t].forEach((property) => {\n\t\tObject.defineProperty(WebSocket.prototype, property, { enumerable: true });\n\t});\n\t[\n\t\t\"open\",\n\t\t\"error\",\n\t\t\"close\",\n\t\t\"message\"\n\t].forEach((method) => {\n\t\tObject.defineProperty(WebSocket.prototype, `on${method}`, {\n\t\t\tenumerable: true,\n\t\t\tget() {\n\t\t\t\tfor (const listener of this.listeners(method)) if (listener[kForOnEventAttribute]) return listener[kListener];\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tset(handler) {\n\t\t\t\tfor (const listener of this.listeners(method)) if (listener[kForOnEventAttribute]) {\n\t\t\t\t\tthis.removeListener(method, listener);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (typeof handler !== \"function\") return;\n\t\t\t\tthis.addEventListener(method, handler, { [kForOnEventAttribute]: true });\n\t\t\t}\n\t\t});\n\t});\n\tWebSocket.prototype.addEventListener = addEventListener;\n\tWebSocket.prototype.removeEventListener = removeEventListener;\n\tmodule.exports = WebSocket;\n\t/**\n\t* Initialize a WebSocket client.\n\t*\n\t* @param {WebSocket} websocket The client to initialize\n\t* @param {(String|URL)} address The URL to which to connect\n\t* @param {Array} protocols The subprotocols\n\t* @param {Object} [options] Connection options\n\t* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether any\n\t*     of the `'message'`, `'ping'`, and `'pong'` events can be emitted multiple\n\t*     times in the same tick\n\t* @param {Boolean} [options.autoPong=true] Specifies whether or not to\n\t*     automatically send a pong in response to a ping\n\t* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to wait\n\t*     for the closing handshake to finish after `websocket.close()` is called\n\t* @param {Function} [options.finishRequest] A function which can be used to\n\t*     customize the headers of each http request before it is sent\n\t* @param {Boolean} [options.followRedirects=false] Whether or not to follow\n\t*     redirects\n\t* @param {Function} [options.generateMask] The function used to generate the\n\t*     masking key\n\t* @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the\n\t*     handshake request\n\t* @param {Number} [options.maxPayload=104857600] The maximum allowed message\n\t*     size\n\t* @param {Number} [options.maxRedirects=10] The maximum number of redirects\n\t*     allowed\n\t* @param {String} [options.origin] Value of the `Origin` or\n\t*     `Sec-WebSocket-Origin` header\n\t* @param {(Boolean|Object)} [options.perMessageDeflate=true] Enable/disable\n\t*     permessage-deflate\n\t* @param {Number} [options.protocolVersion=13] Value of the\n\t*     `Sec-WebSocket-Version` header\n\t* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or\n\t*     not to skip UTF-8 validation for text and close messages\n\t* @private\n\t*/\n\tfunction initAsClient(websocket, address, protocols, options) {\n\t\tconst opts = {\n\t\t\tallowSynchronousEvents: true,\n\t\t\tautoPong: true,\n\t\t\tcloseTimeout: CLOSE_TIMEOUT,\n\t\t\tprotocolVersion: protocolVersions[1],\n\t\t\tmaxPayload: 100 * 1024 * 1024,\n\t\t\tskipUTF8Validation: false,\n\t\t\tperMessageDeflate: true,\n\t\t\tfollowRedirects: false,\n\t\t\tmaxRedirects: 10,\n\t\t\t...options,\n\t\t\tsocketPath: void 0,\n\t\t\thostname: void 0,\n\t\t\tprotocol: void 0,\n\t\t\ttimeout: void 0,\n\t\t\tmethod: \"GET\",\n\t\t\thost: void 0,\n\t\t\tpath: void 0,\n\t\t\tport: void 0\n\t\t};\n\t\twebsocket._autoPong = opts.autoPong;\n\t\twebsocket._closeTimeout = opts.closeTimeout;\n\t\tif (!protocolVersions.includes(opts.protocolVersion)) throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(\", \")})`);\n\t\tlet parsedUrl;\n\t\tif (address instanceof URL) parsedUrl = address;\n\t\telse try {\n\t\t\tparsedUrl = new URL(address);\n\t\t} catch (e) {\n\t\t\tthrow new SyntaxError(`Invalid URL: ${address}`);\n\t\t}\n\t\tif (parsedUrl.protocol === \"http:\") parsedUrl.protocol = \"ws:\";\n\t\telse if (parsedUrl.protocol === \"https:\") parsedUrl.protocol = \"wss:\";\n\t\twebsocket._url = parsedUrl.href;\n\t\tconst isSecure = parsedUrl.protocol === \"wss:\";\n\t\tconst isIpcUrl = parsedUrl.protocol === \"ws+unix:\";\n\t\tlet invalidUrlMessage;\n\t\tif (parsedUrl.protocol !== \"ws:\" && !isSecure && !isIpcUrl) invalidUrlMessage = \"The URL's protocol must be one of \\\"ws:\\\", \\\"wss:\\\", \\\"http:\\\", \\\"https:\\\", or \\\"ws+unix:\\\"\";\n\t\telse if (isIpcUrl && !parsedUrl.pathname) invalidUrlMessage = \"The URL's pathname is empty\";\n\t\telse if (parsedUrl.hash) invalidUrlMessage = \"The URL contains a fragment identifier\";\n\t\tif (invalidUrlMessage) {\n\t\t\tconst err = new SyntaxError(invalidUrlMessage);\n\t\t\tif (websocket._redirects === 0) throw err;\n\t\t\telse {\n\t\t\t\temitErrorAndClose(websocket, err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst defaultPort = isSecure ? 443 : 80;\n\t\tconst key = randomBytes(16).toString(\"base64\");\n\t\tconst request = isSecure ? https.request : http$1.request;\n\t\tconst protocolSet = /* @__PURE__ */ new Set();\n\t\tlet perMessageDeflate;\n\t\topts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);\n\t\topts.defaultPort = opts.defaultPort || defaultPort;\n\t\topts.port = parsedUrl.port || defaultPort;\n\t\topts.host = parsedUrl.hostname.startsWith(\"[\") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;\n\t\topts.headers = {\n\t\t\t...opts.headers,\n\t\t\t\"Sec-WebSocket-Version\": opts.protocolVersion,\n\t\t\t\"Sec-WebSocket-Key\": key,\n\t\t\tConnection: \"Upgrade\",\n\t\t\tUpgrade: \"websocket\"\n\t\t};\n\t\topts.path = parsedUrl.pathname + parsedUrl.search;\n\t\topts.timeout = opts.handshakeTimeout;\n\t\tif (opts.perMessageDeflate) {\n\t\t\tperMessageDeflate = new PerMessageDeflate(opts.perMessageDeflate !== true ? opts.perMessageDeflate : {}, false, opts.maxPayload);\n\t\t\topts.headers[\"Sec-WebSocket-Extensions\"] = format({ [PerMessageDeflate.extensionName]: perMessageDeflate.offer() });\n\t\t}\n\t\tif (protocols.length) {\n\t\t\tfor (const protocol of protocols) {\n\t\t\t\tif (typeof protocol !== \"string\" || !subprotocolRegex.test(protocol) || protocolSet.has(protocol)) throw new SyntaxError(\"An invalid or duplicated subprotocol was specified\");\n\t\t\t\tprotocolSet.add(protocol);\n\t\t\t}\n\t\t\topts.headers[\"Sec-WebSocket-Protocol\"] = protocols.join(\",\");\n\t\t}\n\t\tif (opts.origin) if (opts.protocolVersion < 13) opts.headers[\"Sec-WebSocket-Origin\"] = opts.origin;\n\t\telse opts.headers.Origin = opts.origin;\n\t\tif (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;\n\t\tif (isIpcUrl) {\n\t\t\tconst parts = opts.path.split(\":\");\n\t\t\topts.socketPath = parts[0];\n\t\t\topts.path = parts[1];\n\t\t}\n\t\tlet req;\n\t\tif (opts.followRedirects) {\n\t\t\tif (websocket._redirects === 0) {\n\t\t\t\twebsocket._originalIpc = isIpcUrl;\n\t\t\t\twebsocket._originalSecure = isSecure;\n\t\t\t\twebsocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;\n\t\t\t\tconst headers = options && options.headers;\n\t\t\t\toptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\theaders: {}\n\t\t\t\t};\n\t\t\t\tif (headers) for (const [key, value] of Object.entries(headers)) options.headers[key.toLowerCase()] = value;\n\t\t\t} else if (websocket.listenerCount(\"redirect\") === 0) {\n\t\t\t\tconst isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;\n\t\t\t\tif (!isSameHost || websocket._originalSecure && !isSecure) {\n\t\t\t\t\tdelete opts.headers.authorization;\n\t\t\t\t\tdelete opts.headers.cookie;\n\t\t\t\t\tif (!isSameHost) delete opts.headers.host;\n\t\t\t\t\topts.auth = void 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (opts.auth && !options.headers.authorization) options.headers.authorization = \"Basic \" + Buffer.from(opts.auth).toString(\"base64\");\n\t\t\treq = websocket._req = request(opts);\n\t\t\tif (websocket._redirects) websocket.emit(\"redirect\", websocket.url, req);\n\t\t} else req = websocket._req = request(opts);\n\t\tif (opts.timeout) req.on(\"timeout\", () => {\n\t\t\tabortHandshake(websocket, req, \"Opening handshake has timed out\");\n\t\t});\n\t\treq.on(\"error\", (err) => {\n\t\t\tif (req === null || req[kAborted]) return;\n\t\t\treq = websocket._req = null;\n\t\t\temitErrorAndClose(websocket, err);\n\t\t});\n\t\treq.on(\"response\", (res) => {\n\t\t\tconst location = res.headers.location;\n\t\t\tconst statusCode = res.statusCode;\n\t\t\tif (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {\n\t\t\t\tif (++websocket._redirects > opts.maxRedirects) {\n\t\t\t\t\tabortHandshake(websocket, req, \"Maximum redirects exceeded\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\treq.abort();\n\t\t\t\tlet addr;\n\t\t\t\ttry {\n\t\t\t\t\taddr = new URL(location, address);\n\t\t\t\t} catch (e) {\n\t\t\t\t\temitErrorAndClose(websocket, /* @__PURE__ */ new SyntaxError(`Invalid URL: ${location}`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tinitAsClient(websocket, addr, protocols, options);\n\t\t\t} else if (!websocket.emit(\"unexpected-response\", req, res)) abortHandshake(websocket, req, `Unexpected server response: ${res.statusCode}`);\n\t\t});\n\t\treq.on(\"upgrade\", (res, socket, head) => {\n\t\t\twebsocket.emit(\"upgrade\", res);\n\t\t\tif (websocket.readyState !== WebSocket.CONNECTING) return;\n\t\t\treq = websocket._req = null;\n\t\t\tconst upgrade = res.headers.upgrade;\n\t\t\tif (upgrade === void 0 || upgrade.toLowerCase() !== \"websocket\") {\n\t\t\t\tabortHandshake(websocket, socket, \"Invalid Upgrade header\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst digest = createHash$1(\"sha1\").update(key + GUID).digest(\"base64\");\n\t\t\tif (res.headers[\"sec-websocket-accept\"] !== digest) {\n\t\t\t\tabortHandshake(websocket, socket, \"Invalid Sec-WebSocket-Accept header\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst serverProt = res.headers[\"sec-websocket-protocol\"];\n\t\t\tlet protError;\n\t\t\tif (serverProt !== void 0) {\n\t\t\t\tif (!protocolSet.size) protError = \"Server sent a subprotocol but none was requested\";\n\t\t\t\telse if (!protocolSet.has(serverProt)) protError = \"Server sent an invalid subprotocol\";\n\t\t\t} else if (protocolSet.size) protError = \"Server sent no subprotocol\";\n\t\t\tif (protError) {\n\t\t\t\tabortHandshake(websocket, socket, protError);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (serverProt) websocket._protocol = serverProt;\n\t\t\tconst secWebSocketExtensions = res.headers[\"sec-websocket-extensions\"];\n\t\t\tif (secWebSocketExtensions !== void 0) {\n\t\t\t\tif (!perMessageDeflate) {\n\t\t\t\t\tabortHandshake(websocket, socket, \"Server sent a Sec-WebSocket-Extensions header but no extension was requested\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet extensions;\n\t\t\t\ttry {\n\t\t\t\t\textensions = parse(secWebSocketExtensions);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tabortHandshake(websocket, socket, \"Invalid Sec-WebSocket-Extensions header\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst extensionNames = Object.keys(extensions);\n\t\t\t\tif (extensionNames.length !== 1 || extensionNames[0] !== PerMessageDeflate.extensionName) {\n\t\t\t\t\tabortHandshake(websocket, socket, \"Server indicated an extension that was not requested\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tperMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tabortHandshake(websocket, socket, \"Invalid Sec-WebSocket-Extensions header\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\twebsocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;\n\t\t\t}\n\t\t\twebsocket.setSocket(socket, head, {\n\t\t\t\tallowSynchronousEvents: opts.allowSynchronousEvents,\n\t\t\t\tgenerateMask: opts.generateMask,\n\t\t\t\tmaxPayload: opts.maxPayload,\n\t\t\t\tskipUTF8Validation: opts.skipUTF8Validation\n\t\t\t});\n\t\t});\n\t\tif (opts.finishRequest) opts.finishRequest(req, websocket);\n\t\telse req.end();\n\t}\n\t/**\n\t* Emit the `'error'` and `'close'` events.\n\t*\n\t* @param {WebSocket} websocket The WebSocket instance\n\t* @param {Error} The error to emit\n\t* @private\n\t*/\n\tfunction emitErrorAndClose(websocket, err) {\n\t\twebsocket._readyState = WebSocket.CLOSING;\n\t\twebsocket._errorEmitted = true;\n\t\twebsocket.emit(\"error\", err);\n\t\twebsocket.emitClose();\n\t}\n\t/**\n\t* Create a `net.Socket` and initiate a connection.\n\t*\n\t* @param {Object} options Connection options\n\t* @return {net.Socket} The newly created socket used to start the connection\n\t* @private\n\t*/\n\tfunction netConnect(options) {\n\t\toptions.path = options.socketPath;\n\t\treturn net.connect(options);\n\t}\n\t/**\n\t* Create a `tls.TLSSocket` and initiate a connection.\n\t*\n\t* @param {Object} options Connection options\n\t* @return {tls.TLSSocket} The newly created socket used to start the connection\n\t* @private\n\t*/\n\tfunction tlsConnect(options) {\n\t\toptions.path = void 0;\n\t\tif (!options.servername && options.servername !== \"\") options.servername = net.isIP(options.host) ? \"\" : options.host;\n\t\treturn tls.connect(options);\n\t}\n\t/**\n\t* Abort the handshake and emit an error.\n\t*\n\t* @param {WebSocket} websocket The WebSocket instance\n\t* @param {(http.ClientRequest|net.Socket|tls.Socket)} stream The request to\n\t*     abort or the socket to destroy\n\t* @param {String} message The error message\n\t* @private\n\t*/\n\tfunction abortHandshake(websocket, stream, message) {\n\t\twebsocket._readyState = WebSocket.CLOSING;\n\t\tconst err = new Error(message);\n\t\tError.captureStackTrace(err, abortHandshake);\n\t\tif (stream.setHeader) {\n\t\t\tstream[kAborted] = true;\n\t\t\tstream.abort();\n\t\t\tif (stream.socket && !stream.socket.destroyed) stream.socket.destroy();\n\t\t\tprocess.nextTick(emitErrorAndClose, websocket, err);\n\t\t} else {\n\t\t\tstream.destroy(err);\n\t\t\tstream.once(\"error\", websocket.emit.bind(websocket, \"error\"));\n\t\t\tstream.once(\"close\", websocket.emitClose.bind(websocket));\n\t\t}\n\t}\n\t/**\n\t* Handle cases where the `ping()`, `pong()`, or `send()` methods are called\n\t* when the `readyState` attribute is `CLOSING` or `CLOSED`.\n\t*\n\t* @param {WebSocket} websocket The WebSocket instance\n\t* @param {*} [data] The data to send\n\t* @param {Function} [cb] Callback\n\t* @private\n\t*/\n\tfunction sendAfterClose(websocket, data, cb) {\n\t\tif (data) {\n\t\t\tconst length = isBlob(data) ? data.size : toBuffer(data).length;\n\t\t\tif (websocket._socket) websocket._sender._bufferedBytes += length;\n\t\t\telse websocket._bufferedAmount += length;\n\t\t}\n\t\tif (cb) {\n\t\t\tconst err = /* @__PURE__ */ new Error(`WebSocket is not open: readyState ${websocket.readyState} (${readyStates[websocket.readyState]})`);\n\t\t\tprocess.nextTick(cb, err);\n\t\t}\n\t}\n\t/**\n\t* The listener of the `Receiver` `'conclude'` event.\n\t*\n\t* @param {Number} code The status code\n\t* @param {Buffer} reason The reason for closing\n\t* @private\n\t*/\n\tfunction receiverOnConclude(code, reason) {\n\t\tconst websocket = this[kWebSocket];\n\t\twebsocket._closeFrameReceived = true;\n\t\twebsocket._closeMessage = reason;\n\t\twebsocket._closeCode = code;\n\t\tif (websocket._socket[kWebSocket] === void 0) return;\n\t\twebsocket._socket.removeListener(\"data\", socketOnData);\n\t\tprocess.nextTick(resume, websocket._socket);\n\t\tif (code === 1005) websocket.close();\n\t\telse websocket.close(code, reason);\n\t}\n\t/**\n\t* The listener of the `Receiver` `'drain'` event.\n\t*\n\t* @private\n\t*/\n\tfunction receiverOnDrain() {\n\t\tconst websocket = this[kWebSocket];\n\t\tif (!websocket.isPaused) websocket._socket.resume();\n\t}\n\t/**\n\t* The listener of the `Receiver` `'error'` event.\n\t*\n\t* @param {(RangeError|Error)} err The emitted error\n\t* @private\n\t*/\n\tfunction receiverOnError(err) {\n\t\tconst websocket = this[kWebSocket];\n\t\tif (websocket._socket[kWebSocket] !== void 0) {\n\t\t\twebsocket._socket.removeListener(\"data\", socketOnData);\n\t\t\tprocess.nextTick(resume, websocket._socket);\n\t\t\twebsocket.close(err[kStatusCode]);\n\t\t}\n\t\tif (!websocket._errorEmitted) {\n\t\t\twebsocket._errorEmitted = true;\n\t\t\twebsocket.emit(\"error\", err);\n\t\t}\n\t}\n\t/**\n\t* The listener of the `Receiver` `'finish'` event.\n\t*\n\t* @private\n\t*/\n\tfunction receiverOnFinish() {\n\t\tthis[kWebSocket].emitClose();\n\t}\n\t/**\n\t* The listener of the `Receiver` `'message'` event.\n\t*\n\t* @param {Buffer|ArrayBuffer|Buffer[])} data The message\n\t* @param {Boolean} isBinary Specifies whether the message is binary or not\n\t* @private\n\t*/\n\tfunction receiverOnMessage(data, isBinary) {\n\t\tthis[kWebSocket].emit(\"message\", data, isBinary);\n\t}\n\t/**\n\t* The listener of the `Receiver` `'ping'` event.\n\t*\n\t* @param {Buffer} data The data included in the ping frame\n\t* @private\n\t*/\n\tfunction receiverOnPing(data) {\n\t\tconst websocket = this[kWebSocket];\n\t\tif (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP);\n\t\twebsocket.emit(\"ping\", data);\n\t}\n\t/**\n\t* The listener of the `Receiver` `'pong'` event.\n\t*\n\t* @param {Buffer} data The data included in the pong frame\n\t* @private\n\t*/\n\tfunction receiverOnPong(data) {\n\t\tthis[kWebSocket].emit(\"pong\", data);\n\t}\n\t/**\n\t* Resume a readable stream\n\t*\n\t* @param {Readable} stream The readable stream\n\t* @private\n\t*/\n\tfunction resume(stream) {\n\t\tstream.resume();\n\t}\n\t/**\n\t* The `Sender` error event handler.\n\t*\n\t* @param {Error} The error\n\t* @private\n\t*/\n\tfunction senderOnError(err) {\n\t\tconst websocket = this[kWebSocket];\n\t\tif (websocket.readyState === WebSocket.CLOSED) return;\n\t\tif (websocket.readyState === WebSocket.OPEN) {\n\t\t\twebsocket._readyState = WebSocket.CLOSING;\n\t\t\tsetCloseTimer(websocket);\n\t\t}\n\t\tthis._socket.end();\n\t\tif (!websocket._errorEmitted) {\n\t\t\twebsocket._errorEmitted = true;\n\t\t\twebsocket.emit(\"error\", err);\n\t\t}\n\t}\n\t/**\n\t* Set a timer to destroy the underlying raw socket of a WebSocket.\n\t*\n\t* @param {WebSocket} websocket The WebSocket instance\n\t* @private\n\t*/\n\tfunction setCloseTimer(websocket) {\n\t\twebsocket._closeTimer = setTimeout(websocket._socket.destroy.bind(websocket._socket), websocket._closeTimeout);\n\t}\n\t/**\n\t* The listener of the socket `'close'` event.\n\t*\n\t* @private\n\t*/\n\tfunction socketOnClose() {\n\t\tconst websocket = this[kWebSocket];\n\t\tthis.removeListener(\"close\", socketOnClose);\n\t\tthis.removeListener(\"data\", socketOnData);\n\t\tthis.removeListener(\"end\", socketOnEnd);\n\t\twebsocket._readyState = WebSocket.CLOSING;\n\t\tif (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && this._readableState.length !== 0) {\n\t\t\tconst chunk = this.read(this._readableState.length);\n\t\t\twebsocket._receiver.write(chunk);\n\t\t}\n\t\twebsocket._receiver.end();\n\t\tthis[kWebSocket] = void 0;\n\t\tclearTimeout(websocket._closeTimer);\n\t\tif (websocket._receiver._writableState.finished || websocket._receiver._writableState.errorEmitted) websocket.emitClose();\n\t\telse {\n\t\t\twebsocket._receiver.on(\"error\", receiverOnFinish);\n\t\t\twebsocket._receiver.on(\"finish\", receiverOnFinish);\n\t\t}\n\t}\n\t/**\n\t* The listener of the socket `'data'` event.\n\t*\n\t* @param {Buffer} chunk A chunk of data\n\t* @private\n\t*/\n\tfunction socketOnData(chunk) {\n\t\tif (!this[kWebSocket]._receiver.write(chunk)) this.pause();\n\t}\n\t/**\n\t* The listener of the socket `'end'` event.\n\t*\n\t* @private\n\t*/\n\tfunction socketOnEnd() {\n\t\tconst websocket = this[kWebSocket];\n\t\twebsocket._readyState = WebSocket.CLOSING;\n\t\twebsocket._receiver.end();\n\t\tthis.end();\n\t}\n\t/**\n\t* The listener of the socket `'error'` event.\n\t*\n\t* @private\n\t*/\n\tfunction socketOnError() {\n\t\tconst websocket = this[kWebSocket];\n\t\tthis.removeListener(\"error\", socketOnError);\n\t\tthis.on(\"error\", NOOP);\n\t\tif (websocket) {\n\t\t\twebsocket._readyState = WebSocket.CLOSING;\n\t\t\tthis.destroy();\n\t\t}\n\t}\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/stream.js\nvar require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\trequire_websocket();\n\tconst { Duplex: Duplex$1 } = __require(\"stream\");\n\t/**\n\t* Emits the `'close'` event on a stream.\n\t*\n\t* @param {Duplex} stream The stream.\n\t* @private\n\t*/\n\tfunction emitClose(stream) {\n\t\tstream.emit(\"close\");\n\t}\n\t/**\n\t* The listener of the `'end'` event.\n\t*\n\t* @private\n\t*/\n\tfunction duplexOnEnd() {\n\t\tif (!this.destroyed && this._writableState.finished) this.destroy();\n\t}\n\t/**\n\t* The listener of the `'error'` event.\n\t*\n\t* @param {Error} err The error\n\t* @private\n\t*/\n\tfunction duplexOnError(err) {\n\t\tthis.removeListener(\"error\", duplexOnError);\n\t\tthis.destroy();\n\t\tif (this.listenerCount(\"error\") === 0) this.emit(\"error\", err);\n\t}\n\t/**\n\t* Wraps a `WebSocket` in a duplex stream.\n\t*\n\t* @param {WebSocket} ws The `WebSocket` to wrap\n\t* @param {Object} [options] The options for the `Duplex` constructor\n\t* @return {Duplex} The duplex stream\n\t* @public\n\t*/\n\tfunction createWebSocketStream(ws, options) {\n\t\tlet terminateOnDestroy = true;\n\t\tconst duplex = new Duplex$1({\n\t\t\t...options,\n\t\t\tautoDestroy: false,\n\t\t\temitClose: false,\n\t\t\tobjectMode: false,\n\t\t\twritableObjectMode: false\n\t\t});\n\t\tws.on(\"message\", function message(msg, isBinary) {\n\t\t\tconst data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;\n\t\t\tif (!duplex.push(data)) ws.pause();\n\t\t});\n\t\tws.once(\"error\", function error(err) {\n\t\t\tif (duplex.destroyed) return;\n\t\t\tterminateOnDestroy = false;\n\t\t\tduplex.destroy(err);\n\t\t});\n\t\tws.once(\"close\", function close() {\n\t\t\tif (duplex.destroyed) return;\n\t\t\tduplex.push(null);\n\t\t});\n\t\tduplex._destroy = function(err, callback) {\n\t\t\tif (ws.readyState === ws.CLOSED) {\n\t\t\t\tcallback(err);\n\t\t\t\tprocess.nextTick(emitClose, duplex);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet called = false;\n\t\t\tws.once(\"error\", function error(err) {\n\t\t\t\tcalled = true;\n\t\t\t\tcallback(err);\n\t\t\t});\n\t\t\tws.once(\"close\", function close() {\n\t\t\t\tif (!called) callback(err);\n\t\t\t\tprocess.nextTick(emitClose, duplex);\n\t\t\t});\n\t\t\tif (terminateOnDestroy) ws.terminate();\n\t\t};\n\t\tduplex._final = function(callback) {\n\t\t\tif (ws.readyState === ws.CONNECTING) {\n\t\t\t\tws.once(\"open\", function open() {\n\t\t\t\t\tduplex._final(callback);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (ws._socket === null) return;\n\t\t\tif (ws._socket._writableState.finished) {\n\t\t\t\tcallback();\n\t\t\t\tif (duplex._readableState.endEmitted) duplex.destroy();\n\t\t\t} else {\n\t\t\t\tws._socket.once(\"finish\", function finish() {\n\t\t\t\t\tcallback();\n\t\t\t\t});\n\t\t\t\tws.close();\n\t\t\t}\n\t\t};\n\t\tduplex._read = function() {\n\t\t\tif (ws.isPaused) ws.resume();\n\t\t};\n\t\tduplex._write = function(chunk, encoding, callback) {\n\t\t\tif (ws.readyState === ws.CONNECTING) {\n\t\t\t\tws.once(\"open\", function open() {\n\t\t\t\t\tduplex._write(chunk, encoding, callback);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tws.send(chunk, callback);\n\t\t};\n\t\tduplex.on(\"end\", duplexOnEnd);\n\t\tduplex.on(\"error\", duplexOnError);\n\t\treturn duplex;\n\t}\n\tmodule.exports = createWebSocketStream;\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/subprotocol.js\nvar require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst { tokenChars } = require_validation();\n\t/**\n\t* Parses the `Sec-WebSocket-Protocol` header into a set of subprotocol names.\n\t*\n\t* @param {String} header The field value of the header\n\t* @return {Set} The subprotocol names\n\t* @public\n\t*/\n\tfunction parse(header) {\n\t\tconst protocols = /* @__PURE__ */ new Set();\n\t\tlet start = -1;\n\t\tlet end = -1;\n\t\tlet i = 0;\n\t\tfor (; i < header.length; i++) {\n\t\t\tconst code = header.charCodeAt(i);\n\t\t\tif (end === -1 && tokenChars[code] === 1) {\n\t\t\t\tif (start === -1) start = i;\n\t\t\t} else if (i !== 0 && (code === 32 || code === 9)) {\n\t\t\t\tif (end === -1 && start !== -1) end = i;\n\t\t\t} else if (code === 44) {\n\t\t\t\tif (start === -1) throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t\t\tif (end === -1) end = i;\n\t\t\t\tconst protocol = header.slice(start, end);\n\t\t\t\tif (protocols.has(protocol)) throw new SyntaxError(`The \"${protocol}\" subprotocol is duplicated`);\n\t\t\t\tprotocols.add(protocol);\n\t\t\t\tstart = end = -1;\n\t\t\t} else throw new SyntaxError(`Unexpected character at index ${i}`);\n\t\t}\n\t\tif (start === -1 || end !== -1) throw new SyntaxError(\"Unexpected end of input\");\n\t\tconst protocol = header.slice(start, i);\n\t\tif (protocols.has(protocol)) throw new SyntaxError(`The \"${protocol}\" subprotocol is duplicated`);\n\t\tprotocols.add(protocol);\n\t\treturn protocols;\n\t}\n\tmodule.exports = { parse };\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/lib/websocket-server.js\nvar require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {\n\tconst EventEmitter = __require(\"events\");\n\tconst http = __require(\"http\");\n\tconst { Duplex } = __require(\"stream\");\n\tconst { createHash } = __require(\"crypto\");\n\tconst extension = require_extension();\n\tconst PerMessageDeflate = require_permessage_deflate();\n\tconst subprotocol = require_subprotocol();\n\tconst WebSocket = require_websocket();\n\tconst { CLOSE_TIMEOUT, GUID, kWebSocket } = require_constants();\n\tconst keyRegex = /^[+/0-9A-Za-z]{22}==$/;\n\tconst RUNNING = 0;\n\tconst CLOSING = 1;\n\tconst CLOSED = 2;\n\t/**\n\t* Class representing a WebSocket server.\n\t*\n\t* @extends EventEmitter\n\t*/\n\tvar WebSocketServer = class extends EventEmitter {\n\t\t/**\n\t\t* Create a `WebSocketServer` instance.\n\t\t*\n\t\t* @param {Object} options Configuration options\n\t\t* @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether\n\t\t*     any of the `'message'`, `'ping'`, and `'pong'` events can be emitted\n\t\t*     multiple times in the same tick\n\t\t* @param {Boolean} [options.autoPong=true] Specifies whether or not to\n\t\t*     automatically send a pong in response to a ping\n\t\t* @param {Number} [options.backlog=511] The maximum length of the queue of\n\t\t*     pending connections\n\t\t* @param {Boolean} [options.clientTracking=true] Specifies whether or not to\n\t\t*     track clients\n\t\t* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to\n\t\t*     wait for the closing handshake to finish after `websocket.close()` is\n\t\t*     called\n\t\t* @param {Function} [options.handleProtocols] A hook to handle protocols\n\t\t* @param {String} [options.host] The hostname where to bind the server\n\t\t* @param {Number} [options.maxPayload=104857600] The maximum allowed message\n\t\t*     size\n\t\t* @param {Boolean} [options.noServer=false] Enable no server mode\n\t\t* @param {String} [options.path] Accept only connections matching this path\n\t\t* @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable\n\t\t*     permessage-deflate\n\t\t* @param {Number} [options.port] The port where to bind the server\n\t\t* @param {(http.Server|https.Server)} [options.server] A pre-created HTTP/S\n\t\t*     server to use\n\t\t* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or\n\t\t*     not to skip UTF-8 validation for text and close messages\n\t\t* @param {Function} [options.verifyClient] A hook to reject connections\n\t\t* @param {Function} [options.WebSocket=WebSocket] Specifies the `WebSocket`\n\t\t*     class to use. It must be the `WebSocket` class or class that extends it\n\t\t* @param {Function} [callback] A listener for the `listening` event\n\t\t*/\n\t\tconstructor(options, callback) {\n\t\t\tsuper();\n\t\t\toptions = {\n\t\t\t\tallowSynchronousEvents: true,\n\t\t\t\tautoPong: true,\n\t\t\t\tmaxPayload: 100 * 1024 * 1024,\n\t\t\t\tskipUTF8Validation: false,\n\t\t\t\tperMessageDeflate: false,\n\t\t\t\thandleProtocols: null,\n\t\t\t\tclientTracking: true,\n\t\t\t\tcloseTimeout: CLOSE_TIMEOUT,\n\t\t\t\tverifyClient: null,\n\t\t\t\tnoServer: false,\n\t\t\t\tbacklog: null,\n\t\t\t\tserver: null,\n\t\t\t\thost: null,\n\t\t\t\tpath: null,\n\t\t\t\tport: null,\n\t\t\t\tWebSocket,\n\t\t\t\t...options\n\t\t\t};\n\t\t\tif (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) throw new TypeError(\"One and only one of the \\\"port\\\", \\\"server\\\", or \\\"noServer\\\" options must be specified\");\n\t\t\tif (options.port != null) {\n\t\t\t\tthis._server = http.createServer((req, res) => {\n\t\t\t\t\tconst body = http.STATUS_CODES[426];\n\t\t\t\t\tres.writeHead(426, {\n\t\t\t\t\t\t\"Content-Length\": body.length,\n\t\t\t\t\t\t\"Content-Type\": \"text/plain\"\n\t\t\t\t\t});\n\t\t\t\t\tres.end(body);\n\t\t\t\t});\n\t\t\t\tthis._server.listen(options.port, options.host, options.backlog, callback);\n\t\t\t} else if (options.server) this._server = options.server;\n\t\t\tif (this._server) {\n\t\t\t\tconst emitConnection = this.emit.bind(this, \"connection\");\n\t\t\t\tthis._removeListeners = addListeners(this._server, {\n\t\t\t\t\tlistening: this.emit.bind(this, \"listening\"),\n\t\t\t\t\terror: this.emit.bind(this, \"error\"),\n\t\t\t\t\tupgrade: (req, socket, head) => {\n\t\t\t\t\t\tthis.handleUpgrade(req, socket, head, emitConnection);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (options.perMessageDeflate === true) options.perMessageDeflate = {};\n\t\t\tif (options.clientTracking) {\n\t\t\t\tthis.clients = /* @__PURE__ */ new Set();\n\t\t\t\tthis._shouldEmitClose = false;\n\t\t\t}\n\t\t\tthis.options = options;\n\t\t\tthis._state = RUNNING;\n\t\t}\n\t\t/**\n\t\t* Returns the bound address, the address family name, and port of the server\n\t\t* as reported by the operating system if listening on an IP socket.\n\t\t* If the server is listening on a pipe or UNIX domain socket, the name is\n\t\t* returned as a string.\n\t\t*\n\t\t* @return {(Object|String|null)} The address of the server\n\t\t* @public\n\t\t*/\n\t\taddress() {\n\t\t\tif (this.options.noServer) throw new Error(\"The server is operating in \\\"noServer\\\" mode\");\n\t\t\tif (!this._server) return null;\n\t\t\treturn this._server.address();\n\t\t}\n\t\t/**\n\t\t* Stop the server from accepting new connections and emit the `'close'` event\n\t\t* when all existing connections are closed.\n\t\t*\n\t\t* @param {Function} [cb] A one-time listener for the `'close'` event\n\t\t* @public\n\t\t*/\n\t\tclose(cb) {\n\t\t\tif (this._state === CLOSED) {\n\t\t\t\tif (cb) this.once(\"close\", () => {\n\t\t\t\t\tcb(/* @__PURE__ */ new Error(\"The server is not running\"));\n\t\t\t\t});\n\t\t\t\tprocess.nextTick(emitClose, this);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (cb) this.once(\"close\", cb);\n\t\t\tif (this._state === CLOSING) return;\n\t\t\tthis._state = CLOSING;\n\t\t\tif (this.options.noServer || this.options.server) {\n\t\t\t\tif (this._server) {\n\t\t\t\t\tthis._removeListeners();\n\t\t\t\t\tthis._removeListeners = this._server = null;\n\t\t\t\t}\n\t\t\t\tif (this.clients) if (!this.clients.size) process.nextTick(emitClose, this);\n\t\t\t\telse this._shouldEmitClose = true;\n\t\t\t\telse process.nextTick(emitClose, this);\n\t\t\t} else {\n\t\t\t\tconst server = this._server;\n\t\t\t\tthis._removeListeners();\n\t\t\t\tthis._removeListeners = this._server = null;\n\t\t\t\tserver.close(() => {\n\t\t\t\t\temitClose(this);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t* See if a given request should be handled by this server instance.\n\t\t*\n\t\t* @param {http.IncomingMessage} req Request object to inspect\n\t\t* @return {Boolean} `true` if the request is valid, else `false`\n\t\t* @public\n\t\t*/\n\t\tshouldHandle(req) {\n\t\t\tif (this.options.path) {\n\t\t\t\tconst index = req.url.indexOf(\"?\");\n\t\t\t\tif ((index !== -1 ? req.url.slice(0, index) : req.url) !== this.options.path) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\t/**\n\t\t* Handle a HTTP Upgrade request.\n\t\t*\n\t\t* @param {http.IncomingMessage} req The request object\n\t\t* @param {Duplex} socket The network socket between the server and client\n\t\t* @param {Buffer} head The first packet of the upgraded stream\n\t\t* @param {Function} cb Callback\n\t\t* @public\n\t\t*/\n\t\thandleUpgrade(req, socket, head, cb) {\n\t\t\tsocket.on(\"error\", socketOnError);\n\t\t\tconst key = req.headers[\"sec-websocket-key\"];\n\t\t\tconst upgrade = req.headers.upgrade;\n\t\t\tconst version = +req.headers[\"sec-websocket-version\"];\n\t\t\tif (req.method !== \"GET\") {\n\t\t\t\tabortHandshakeOrEmitwsClientError(this, req, socket, 405, \"Invalid HTTP method\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (upgrade === void 0 || upgrade.toLowerCase() !== \"websocket\") {\n\t\t\t\tabortHandshakeOrEmitwsClientError(this, req, socket, 400, \"Invalid Upgrade header\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (key === void 0 || !keyRegex.test(key)) {\n\t\t\t\tabortHandshakeOrEmitwsClientError(this, req, socket, 400, \"Missing or invalid Sec-WebSocket-Key header\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (version !== 13 && version !== 8) {\n\t\t\t\tabortHandshakeOrEmitwsClientError(this, req, socket, 400, \"Missing or invalid Sec-WebSocket-Version header\", { \"Sec-WebSocket-Version\": \"13, 8\" });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!this.shouldHandle(req)) {\n\t\t\t\tabortHandshake(socket, 400);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst secWebSocketProtocol = req.headers[\"sec-websocket-protocol\"];\n\t\t\tlet protocols = /* @__PURE__ */ new Set();\n\t\t\tif (secWebSocketProtocol !== void 0) try {\n\t\t\t\tprotocols = subprotocol.parse(secWebSocketProtocol);\n\t\t\t} catch (err) {\n\t\t\t\tabortHandshakeOrEmitwsClientError(this, req, socket, 400, \"Invalid Sec-WebSocket-Protocol header\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst secWebSocketExtensions = req.headers[\"sec-websocket-extensions\"];\n\t\t\tconst extensions = {};\n\t\t\tif (this.options.perMessageDeflate && secWebSocketExtensions !== void 0) {\n\t\t\t\tconst perMessageDeflate = new PerMessageDeflate(this.options.perMessageDeflate, true, this.options.maxPayload);\n\t\t\t\ttry {\n\t\t\t\t\tconst offers = extension.parse(secWebSocketExtensions);\n\t\t\t\t\tif (offers[PerMessageDeflate.extensionName]) {\n\t\t\t\t\t\tperMessageDeflate.accept(offers[PerMessageDeflate.extensionName]);\n\t\t\t\t\t\textensions[PerMessageDeflate.extensionName] = perMessageDeflate;\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\tabortHandshakeOrEmitwsClientError(this, req, socket, 400, \"Invalid or unacceptable Sec-WebSocket-Extensions header\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.options.verifyClient) {\n\t\t\t\tconst info = {\n\t\t\t\t\torigin: req.headers[`${version === 8 ? \"sec-websocket-origin\" : \"origin\"}`],\n\t\t\t\t\tsecure: !!(req.socket.authorized || req.socket.encrypted),\n\t\t\t\t\treq\n\t\t\t\t};\n\t\t\t\tif (this.options.verifyClient.length === 2) {\n\t\t\t\t\tthis.options.verifyClient(info, (verified, code, message, headers) => {\n\t\t\t\t\t\tif (!verified) return abortHandshake(socket, code || 401, message, headers);\n\t\t\t\t\t\tthis.completeUpgrade(extensions, key, protocols, req, socket, head, cb);\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!this.options.verifyClient(info)) return abortHandshake(socket, 401);\n\t\t\t}\n\t\t\tthis.completeUpgrade(extensions, key, protocols, req, socket, head, cb);\n\t\t}\n\t\t/**\n\t\t* Upgrade the connection to WebSocket.\n\t\t*\n\t\t* @param {Object} extensions The accepted extensions\n\t\t* @param {String} key The value of the `Sec-WebSocket-Key` header\n\t\t* @param {Set} protocols The subprotocols\n\t\t* @param {http.IncomingMessage} req The request object\n\t\t* @param {Duplex} socket The network socket between the server and client\n\t\t* @param {Buffer} head The first packet of the upgraded stream\n\t\t* @param {Function} cb Callback\n\t\t* @throws {Error} If called more than once with the same socket\n\t\t* @private\n\t\t*/\n\t\tcompleteUpgrade(extensions, key, protocols, req, socket, head, cb) {\n\t\t\tif (!socket.readable || !socket.writable) return socket.destroy();\n\t\t\tif (socket[kWebSocket]) throw new Error(\"server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration\");\n\t\t\tif (this._state > RUNNING) return abortHandshake(socket, 503);\n\t\t\tconst headers = [\n\t\t\t\t\"HTTP/1.1 101 Switching Protocols\",\n\t\t\t\t\"Upgrade: websocket\",\n\t\t\t\t\"Connection: Upgrade\",\n\t\t\t\t`Sec-WebSocket-Accept: ${createHash(\"sha1\").update(key + GUID).digest(\"base64\")}`\n\t\t\t];\n\t\t\tconst ws = new this.options.WebSocket(null, void 0, this.options);\n\t\t\tif (protocols.size) {\n\t\t\t\tconst protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;\n\t\t\t\tif (protocol) {\n\t\t\t\t\theaders.push(`Sec-WebSocket-Protocol: ${protocol}`);\n\t\t\t\t\tws._protocol = protocol;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (extensions[PerMessageDeflate.extensionName]) {\n\t\t\t\tconst params = extensions[PerMessageDeflate.extensionName].params;\n\t\t\t\tconst value = extension.format({ [PerMessageDeflate.extensionName]: [params] });\n\t\t\t\theaders.push(`Sec-WebSocket-Extensions: ${value}`);\n\t\t\t\tws._extensions = extensions;\n\t\t\t}\n\t\t\tthis.emit(\"headers\", headers, req);\n\t\t\tsocket.write(headers.concat(\"\\r\\n\").join(\"\\r\\n\"));\n\t\t\tsocket.removeListener(\"error\", socketOnError);\n\t\t\tws.setSocket(socket, head, {\n\t\t\t\tallowSynchronousEvents: this.options.allowSynchronousEvents,\n\t\t\t\tmaxPayload: this.options.maxPayload,\n\t\t\t\tskipUTF8Validation: this.options.skipUTF8Validation\n\t\t\t});\n\t\t\tif (this.clients) {\n\t\t\t\tthis.clients.add(ws);\n\t\t\t\tws.on(\"close\", () => {\n\t\t\t\t\tthis.clients.delete(ws);\n\t\t\t\t\tif (this._shouldEmitClose && !this.clients.size) process.nextTick(emitClose, this);\n\t\t\t\t});\n\t\t\t}\n\t\t\tcb(ws, req);\n\t\t}\n\t};\n\tmodule.exports = WebSocketServer;\n\t/**\n\t* Add event listeners on an `EventEmitter` using a map of <event, listener>\n\t* pairs.\n\t*\n\t* @param {EventEmitter} server The event emitter\n\t* @param {Object.<String, Function>} map The listeners to add\n\t* @return {Function} A function that will remove the added listeners when\n\t*     called\n\t* @private\n\t*/\n\tfunction addListeners(server, map) {\n\t\tfor (const event of Object.keys(map)) server.on(event, map[event]);\n\t\treturn function removeListeners() {\n\t\t\tfor (const event of Object.keys(map)) server.removeListener(event, map[event]);\n\t\t};\n\t}\n\t/**\n\t* Emit a `'close'` event on an `EventEmitter`.\n\t*\n\t* @param {EventEmitter} server The event emitter\n\t* @private\n\t*/\n\tfunction emitClose(server) {\n\t\tserver._state = CLOSED;\n\t\tserver.emit(\"close\");\n\t}\n\t/**\n\t* Handle socket errors.\n\t*\n\t* @private\n\t*/\n\tfunction socketOnError() {\n\t\tthis.destroy();\n\t}\n\t/**\n\t* Close the connection when preconditions are not fulfilled.\n\t*\n\t* @param {Duplex} socket The socket of the upgrade request\n\t* @param {Number} code The HTTP response status code\n\t* @param {String} [message] The HTTP response body\n\t* @param {Object} [headers] Additional HTTP response headers\n\t* @private\n\t*/\n\tfunction abortHandshake(socket, code, message, headers) {\n\t\tmessage = message || http.STATUS_CODES[code];\n\t\theaders = {\n\t\t\tConnection: \"close\",\n\t\t\t\"Content-Type\": \"text/html\",\n\t\t\t\"Content-Length\": Buffer.byteLength(message),\n\t\t\t...headers\n\t\t};\n\t\tsocket.once(\"finish\", socket.destroy);\n\t\tsocket.end(`HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\\r\\n` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join(\"\\r\\n\") + \"\\r\\n\\r\\n\" + message);\n\t}\n\t/**\n\t* Emit a `'wsClientError'` event on a `WebSocketServer` if there is at least\n\t* one listener for it, otherwise call `abortHandshake()`.\n\t*\n\t* @param {WebSocketServer} server The WebSocket server\n\t* @param {http.IncomingMessage} req The request object\n\t* @param {Duplex} socket The socket of the upgrade request\n\t* @param {Number} code The HTTP response status code\n\t* @param {String} message The HTTP response body\n\t* @param {Object} [headers] The HTTP response headers\n\t* @private\n\t*/\n\tfunction abortHandshakeOrEmitwsClientError(server, req, socket, code, message, headers) {\n\t\tif (server.listenerCount(\"wsClientError\")) {\n\t\t\tconst err = new Error(message);\n\t\t\tError.captureStackTrace(err, abortHandshakeOrEmitwsClientError);\n\t\t\tserver.emit(\"wsClientError\", err, socket, req);\n\t\t} else abortHandshake(socket, code, message, headers);\n\t}\n}));\n\n//#endregion\n//#region node_modules/.pnpm/ws@8.19.0/node_modules/ws/wrapper.mjs\nvar import_stream = /* @__PURE__ */ __toESM(require_stream(), 1);\nvar import_receiver = /* @__PURE__ */ __toESM(require_receiver(), 1);\nvar import_sender = /* @__PURE__ */ __toESM(require_sender(), 1);\nvar import_websocket = /* @__PURE__ */ __toESM(require_websocket(), 1);\nvar import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server(), 1);\n\n//#endregion\nexport { import_websocket_server as n, import_websocket as t };","//#region src/utils.ts\nconst kNodeInspect = /* @__PURE__ */ Symbol.for(\"nodejs.util.inspect.custom\");\nfunction toBufferLike(val) {\n\tif (val === void 0 || val === null) return \"\";\n\tconst type = typeof val;\n\tif (type === \"string\") return val;\n\tif (type === \"number\" || type === \"boolean\" || type === \"bigint\") return val.toString();\n\tif (type === \"function\" || type === \"symbol\") return \"{}\";\n\tif (val instanceof Uint8Array || val instanceof ArrayBuffer) return val;\n\tif (isPlainObject(val)) return JSON.stringify(val);\n\treturn val;\n}\nfunction toString(val) {\n\tif (typeof val === \"string\") return val;\n\tconst data = toBufferLike(val);\n\tif (typeof data === \"string\") return data;\n\treturn `data:application/octet-stream;base64,${btoa(String.fromCharCode(...new Uint8Array(data)))}`;\n}\nfunction isPlainObject(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;\n\tif (Symbol.iterator in value) return false;\n\tif (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === \"[object Module]\";\n\treturn true;\n}\n\n//#endregion\n//#region src/message.ts\nvar Message = class {\n\t/** Access to the original [message event](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/message_event) if available. */\n\tevent;\n\t/** Access to the Peer that emitted the message. */\n\tpeer;\n\t/** Raw message data (can be of any type). */\n\trawData;\n\t#id;\n\t#uint8Array;\n\t#arrayBuffer;\n\t#blob;\n\t#text;\n\t#json;\n\tconstructor(rawData, peer, event) {\n\t\tthis.rawData = rawData || \"\";\n\t\tthis.peer = peer;\n\t\tthis.event = event;\n\t}\n\t/**\n\t* Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the message.\n\t*/\n\tget id() {\n\t\tif (!this.#id) this.#id = crypto.randomUUID();\n\t\treturn this.#id;\n\t}\n\t/**\n\t* Get data as [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) value.\n\t*\n\t* If raw data is in any other format or string, it will be automatically converted and encoded.\n\t*/\n\tuint8Array() {\n\t\tconst _uint8Array = this.#uint8Array;\n\t\tif (_uint8Array) return _uint8Array;\n\t\tconst rawData = this.rawData;\n\t\tif (rawData instanceof Uint8Array) return this.#uint8Array = rawData;\n\t\tif (rawData instanceof ArrayBuffer || rawData instanceof SharedArrayBuffer) {\n\t\t\tthis.#arrayBuffer = rawData;\n\t\t\treturn this.#uint8Array = new Uint8Array(rawData);\n\t\t}\n\t\tif (typeof rawData === \"string\") {\n\t\t\tthis.#text = rawData;\n\t\t\treturn this.#uint8Array = new TextEncoder().encode(this.#text);\n\t\t}\n\t\tif (Symbol.iterator in rawData) return this.#uint8Array = new Uint8Array(rawData);\n\t\tif (typeof rawData?.length === \"number\") return this.#uint8Array = new Uint8Array(rawData);\n\t\tif (rawData instanceof DataView) return this.#uint8Array = new Uint8Array(rawData.buffer, rawData.byteOffset, rawData.byteLength);\n\t\tthrow new TypeError(`Unsupported message type: ${Object.prototype.toString.call(rawData)}`);\n\t}\n\t/**\n\t* Get data as [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) value.\n\t*\n\t* If raw data is in any other format or string, it will be automatically converted and encoded.\n\t*/\n\tarrayBuffer() {\n\t\tconst _arrayBuffer = this.#arrayBuffer;\n\t\tif (_arrayBuffer) return _arrayBuffer;\n\t\tconst rawData = this.rawData;\n\t\tif (rawData instanceof ArrayBuffer || rawData instanceof SharedArrayBuffer) return this.#arrayBuffer = rawData;\n\t\treturn this.#arrayBuffer = this.uint8Array().buffer;\n\t}\n\t/**\n\t* Get data as [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) value.\n\t*\n\t* If raw data is in any other format or string, it will be automatically converted and encoded. */\n\tblob() {\n\t\tconst _blob = this.#blob;\n\t\tif (_blob) return _blob;\n\t\tconst rawData = this.rawData;\n\t\tif (rawData instanceof Blob) return this.#blob = rawData;\n\t\treturn this.#blob = new Blob([this.uint8Array()]);\n\t}\n\t/**\n\t* Get stringified text version of the message.\n\t*\n\t* If raw data is in any other format, it will be automatically converted and decoded.\n\t*/\n\ttext() {\n\t\tconst _text = this.#text;\n\t\tif (_text) return _text;\n\t\tconst rawData = this.rawData;\n\t\tif (typeof rawData === \"string\") return this.#text = rawData;\n\t\treturn this.#text = new TextDecoder().decode(this.uint8Array());\n\t}\n\t/**\n\t* Get parsed version of the message text with [`JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).\n\t*/\n\tjson() {\n\t\tconst _json = this.#json;\n\t\tif (_json) return _json;\n\t\treturn this.#json = JSON.parse(this.text());\n\t}\n\t/**\n\t* Message data (value varies based on `peer.websocket.binaryType`).\n\t*/\n\tget data() {\n\t\tswitch (this.peer?.websocket?.binaryType) {\n\t\t\tcase \"arraybuffer\": return this.arrayBuffer();\n\t\t\tcase \"blob\": return this.blob();\n\t\t\tcase \"nodebuffer\": return globalThis.Buffer ? Buffer.from(this.uint8Array()) : this.uint8Array();\n\t\t\tcase \"uint8array\": return this.uint8Array();\n\t\t\tcase \"text\": return this.text();\n\t\t\tdefault: return this.rawData;\n\t\t}\n\t}\n\ttoString() {\n\t\treturn this.text();\n\t}\n\t[Symbol.toPrimitive]() {\n\t\treturn this.text();\n\t}\n\t[kNodeInspect]() {\n\t\treturn { message: {\n\t\t\tid: this.id,\n\t\t\tpeer: this.peer,\n\t\t\ttext: this.text()\n\t\t} };\n\t}\n};\n\n//#endregion\n//#region src/peer.ts\nvar Peer = class {\n\t_internal;\n\t_topics;\n\t_id;\n\t#ws;\n\tconstructor(internal) {\n\t\tthis._topics = /* @__PURE__ */ new Set();\n\t\tthis._internal = internal;\n\t}\n\tget context() {\n\t\treturn this._internal.context ??= {};\n\t}\n\tget namespace() {\n\t\treturn this._internal.namespace;\n\t}\n\t/**\n\t* Unique random [uuid v4](https://developer.mozilla.org/en-US/docs/Glossary/UUID) identifier for the peer.\n\t*/\n\tget id() {\n\t\tif (!this._id) this._id = crypto.randomUUID();\n\t\treturn this._id;\n\t}\n\t/** IP address of the peer */\n\tget remoteAddress() {}\n\t/** upgrade request */\n\tget request() {\n\t\treturn this._internal.request;\n\t}\n\t/**\n\t* Get the [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) instance.\n\t*\n\t* **Note:** crossws adds polyfill for the following properties if native values are not available:\n\t* - `protocol`: Extracted from the `sec-websocket-protocol` header.\n\t* - `extensions`: Extracted from the `sec-websocket-extensions` header.\n\t* - `url`: Extracted from the request URL (http -> ws).\n\t* */\n\tget websocket() {\n\t\tif (!this.#ws) {\n\t\t\tconst _ws = this._internal.ws;\n\t\t\tconst _request = this._internal.request;\n\t\t\tthis.#ws = _request ? createWsProxy(_ws, _request) : _ws;\n\t\t}\n\t\treturn this.#ws;\n\t}\n\t/** All connected peers to the server */\n\tget peers() {\n\t\treturn this._internal.peers || /* @__PURE__ */ new Set();\n\t}\n\t/** All topics, this peer has been subscribed to. */\n\tget topics() {\n\t\treturn this._topics;\n\t}\n\t/** Abruptly close the connection */\n\tterminate() {\n\t\tthis.close();\n\t}\n\t/** Subscribe to a topic */\n\tsubscribe(topic) {\n\t\tthis._topics.add(topic);\n\t}\n\t/** Unsubscribe from a topic */\n\tunsubscribe(topic) {\n\t\tthis._topics.delete(topic);\n\t}\n\ttoString() {\n\t\treturn this.id;\n\t}\n\t[Symbol.toPrimitive]() {\n\t\treturn this.id;\n\t}\n\t[Symbol.toStringTag]() {\n\t\treturn \"WebSocket\";\n\t}\n\t[kNodeInspect]() {\n\t\treturn { peer: {\n\t\t\tid: this.id,\n\t\t\tip: this.remoteAddress\n\t\t} };\n\t}\n};\nfunction createWsProxy(ws, request) {\n\treturn new Proxy(ws, { get: (target, prop) => {\n\t\tconst value = Reflect.get(target, prop);\n\t\tif (!value) switch (prop) {\n\t\t\tcase \"protocol\": return request?.headers?.get(\"sec-websocket-protocol\") || \"\";\n\t\t\tcase \"extensions\": return request?.headers?.get(\"sec-websocket-extensions\") || \"\";\n\t\t\tcase \"url\": return request?.url?.replace(/^http/, \"ws\") || void 0;\n\t\t}\n\t\treturn value;\n\t} });\n}\n\n//#endregion\nexport { toString as i, Message as n, toBufferLike as r, Peer as t };","//#region src/_request.ts\nconst StubRequest = /* @__PURE__ */ (() => {\n\tclass StubRequest {\n\t\turl;\n\t\t_abortController;\n\t\t_headers;\n\t\t_init;\n\t\tconstructor(url, init = {}) {\n\t\t\tthis.url = url;\n\t\t\tthis._init = init;\n\t\t}\n\t\tget headers() {\n\t\t\tif (!this._headers) this._headers = new Headers(this._init?.headers);\n\t\t\treturn this._headers;\n\t\t}\n\t\tclone() {\n\t\t\treturn new StubRequest(this.url, this._init);\n\t\t}\n\t\tget method() {\n\t\t\treturn \"GET\";\n\t\t}\n\t\tget signal() {\n\t\t\tif (!this._abortController) this._abortController = new AbortController();\n\t\t\treturn this._abortController.signal;\n\t\t}\n\t\tget cache() {\n\t\t\treturn \"default\";\n\t\t}\n\t\tget credentials() {\n\t\t\treturn \"same-origin\";\n\t\t}\n\t\tget destination() {\n\t\t\treturn \"\";\n\t\t}\n\t\tget integrity() {\n\t\t\treturn \"\";\n\t\t}\n\t\tget keepalive() {\n\t\t\treturn false;\n\t\t}\n\t\tget redirect() {\n\t\t\treturn \"follow\";\n\t\t}\n\t\tget mode() {\n\t\t\treturn \"cors\";\n\t\t}\n\t\tget referrer() {\n\t\t\treturn \"about:client\";\n\t\t}\n\t\tget referrerPolicy() {\n\t\t\treturn \"\";\n\t\t}\n\t\tget body() {\n\t\t\treturn null;\n\t\t}\n\t\tget bodyUsed() {\n\t\t\treturn false;\n\t\t}\n\t\tarrayBuffer() {\n\t\t\treturn Promise.resolve(/* @__PURE__ */ new ArrayBuffer(0));\n\t\t}\n\t\tblob() {\n\t\t\treturn Promise.resolve(new Blob());\n\t\t}\n\t\tbytes() {\n\t\t\treturn Promise.resolve(new Uint8Array());\n\t\t}\n\t\tformData() {\n\t\t\treturn Promise.resolve(new FormData());\n\t\t}\n\t\tjson() {\n\t\t\treturn Promise.resolve(JSON.parse(\"\"));\n\t\t}\n\t\ttext() {\n\t\t\treturn Promise.resolve(\"\");\n\t\t}\n\t}\n\tObject.setPrototypeOf(StubRequest.prototype, globalThis.Request.prototype);\n\treturn StubRequest;\n})();\n\n//#endregion\nexport { StubRequest as t };","//#region src/error.ts\nvar WSError = class extends Error {\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.name = \"WSError\";\n\t}\n};\n\n//#endregion\nexport { WSError as t };","import \"../_chunks/rolldown-runtime.mjs\";\nimport { i as AdapterHookable, r as getPeers, t as adapterUtils } from \"../_chunks/adapter.mjs\";\nimport { n as import_websocket_server } from \"../_chunks/libs/ws.mjs\";\nimport { n as Message, r as toBufferLike, t as Peer } from \"../_chunks/peer.mjs\";\nimport { t as StubRequest } from \"../_chunks/_request.mjs\";\nimport { t as WSError } from \"../_chunks/error.mjs\";\n\n//#region src/adapters/node.ts\nconst nodeAdapter = (options = {}) => {\n\tif (\"Deno\" in globalThis || \"Bun\" in globalThis) throw new Error(\"[crossws] Using Node.js adapter in an incompatible environment.\");\n\tconst hooks = new AdapterHookable(options);\n\tconst globalPeers = /* @__PURE__ */ new Map();\n\tconst wss = options.wss || new import_websocket_server.default({\n\t\tnoServer: true,\n\t\thandleProtocols: () => false,\n\t\t...options.serverOptions\n\t});\n\twss.on(\"connection\", (ws, nodeReq) => {\n\t\tconst request = new NodeReqProxy(nodeReq);\n\t\tconst peers = getPeers(globalPeers, nodeReq._namespace);\n\t\tconst peer = new NodePeer({\n\t\t\tws,\n\t\t\trequest,\n\t\t\tpeers,\n\t\t\tnodeReq,\n\t\t\tnamespace: nodeReq._namespace\n\t\t});\n\t\tpeers.add(peer);\n\t\thooks.callHook(\"open\", peer);\n\t\tws.on(\"message\", (data) => {\n\t\t\tif (Array.isArray(data)) data = Buffer.concat(data);\n\t\t\thooks.callHook(\"message\", peer, new Message(data, peer));\n\t\t});\n\t\tws.on(\"error\", (error) => {\n\t\t\tpeers.delete(peer);\n\t\t\thooks.callHook(\"error\", peer, new WSError(error));\n\t\t});\n\t\tws.on(\"close\", (code, reason) => {\n\t\t\tpeers.delete(peer);\n\t\t\thooks.callHook(\"close\", peer, {\n\t\t\t\tcode,\n\t\t\t\treason: reason?.toString()\n\t\t\t});\n\t\t});\n\t});\n\twss.on(\"headers\", (outgoingHeaders, req) => {\n\t\tconst upgradeHeaders = req._upgradeHeaders;\n\t\tif (upgradeHeaders) for (const [key, value] of new Headers(upgradeHeaders)) outgoingHeaders.push(`${key}: ${value}`);\n\t});\n\treturn {\n\t\t...adapterUtils(globalPeers),\n\t\thandleUpgrade: async (nodeReq, socket, head, webRequest) => {\n\t\t\tconst request = webRequest || new NodeReqProxy(nodeReq);\n\t\t\tconst { upgradeHeaders, endResponse, context, namespace } = await hooks.upgrade(request);\n\t\t\tif (endResponse) return sendResponse(socket, endResponse);\n\t\t\tnodeReq._request = request;\n\t\t\tnodeReq._upgradeHeaders = upgradeHeaders;\n\t\t\tnodeReq._context = context;\n\t\t\tnodeReq._namespace = namespace;\n\t\t\twss.handleUpgrade(nodeReq, socket, head, (ws) => {\n\t\t\t\twss.emit(\"connection\", ws, nodeReq);\n\t\t\t});\n\t\t},\n\t\tcloseAll: (code, data, force) => {\n\t\t\tfor (const client of wss.clients) if (force) client.terminate();\n\t\t\telse client.close(code, data);\n\t\t}\n\t};\n};\nvar node_default = nodeAdapter;\nvar NodePeer = class extends Peer {\n\tget remoteAddress() {\n\t\treturn this._internal.nodeReq.socket?.remoteAddress;\n\t}\n\tget context() {\n\t\treturn this._internal.nodeReq._context;\n\t}\n\tsend(data, options) {\n\t\tconst dataBuff = toBufferLike(data);\n\t\tconst isBinary = typeof dataBuff !== \"string\";\n\t\tthis._internal.ws.send(dataBuff, {\n\t\t\tcompress: options?.compress,\n\t\t\tbinary: isBinary,\n\t\t\t...options\n\t\t});\n\t\treturn 0;\n\t}\n\tpublish(topic, data, options) {\n\t\tconst dataBuff = toBufferLike(data);\n\t\tconst isBinary = typeof data !== \"string\";\n\t\tconst sendOptions = {\n\t\t\tcompress: options?.compress,\n\t\t\tbinary: isBinary,\n\t\t\t...options\n\t\t};\n\t\tfor (const peer of this._internal.peers) if (peer !== this && peer._topics.has(topic)) peer._internal.ws.send(dataBuff, sendOptions);\n\t}\n\tclose(code, data) {\n\t\tthis._internal.ws.close(code, data);\n\t}\n\tterminate() {\n\t\tthis._internal.ws.terminate();\n\t}\n};\nvar NodeReqProxy = class extends StubRequest {\n\tconstructor(req) {\n\t\tconst host = req.headers[\"host\"] || \"localhost\";\n\t\tconst url = `${req.socket?.encrypted ?? req.headers[\"x-forwarded-proto\"] === \"https\" ? \"https\" : \"http\"}://${host}${req.url}`;\n\t\tsuper(url, { headers: req.headers });\n\t}\n};\nasync function sendResponse(socket, res) {\n\tconst head = [`HTTP/1.1 ${res.status || 200} ${res.statusText || \"\"}`, ...[...res.headers.entries()].map(([key, value]) => `${encodeURIComponent(key)}: ${encodeURIComponent(value)}`)];\n\tsocket.write(head.join(\"\\r\\n\") + \"\\r\\n\\r\\n\");\n\tif (res.body) for await (const chunk of res.body) socket.write(chunk);\n\treturn new Promise((resolve) => {\n\t\tsocket.end(() => {\n\t\t\tsocket.destroy();\n\t\t\tresolve();\n\t\t});\n\t});\n}\n\n//#endregion\nexport { node_default as default };","import type {\n\tServer as HTTPServer,\n\tIncomingMessage,\n\tServerResponse,\n} from \"node:http\";\nimport { createServer } from \"node:http\";\nimport type { AddressInfo } from \"node:net\";\nimport type { ListenOptions } from \"node:net\";\nimport crossws from \"crossws/adapters/node\";\nimport kleur from \"kleur\";\nimport meta from \"../package.json\" assert { type: \"json\" };\nimport { Hocuspocus, defaultConfiguration } from \"./Hocuspocus.ts\";\nimport type { Configuration, WebSocketLike, onListenPayload } from \"./types.ts\";\n\nexport interface ServerConfiguration<Context = any>\n\textends Configuration<Context> {\n\tport?: number;\n\taddress?: string;\n\tstopOnSignals?: boolean;\n\t/**\n\t * Options passed to the underlying WebSocket server (ws).\n\t * Supports all ws ServerOptions, e.g. { maxPayload: 1024 * 1024 }\n\t */\n\twebsocketOptions?: Record<string, any>;\n}\n\nexport const defaultServerConfiguration = {\n\tport: 80,\n\tstopOnSignals: true,\n};\n\nexport class Server<Context = any> {\n\thttpServer: HTTPServer;\n\n\tprivate crossws: ReturnType<typeof crossws>;\n\n\thocuspocus: Hocuspocus<Context>;\n\n\tconfiguration: ServerConfiguration<Context> = {\n\t\t...defaultConfiguration,\n\t\t...defaultServerConfiguration,\n\t\textensions: [],\n\t};\n\n\tconstructor(configuration?: Partial<ServerConfiguration<Context>>) {\n\t\tif (configuration) {\n\t\t\tthis.configuration = {\n\t\t\t\t...this.configuration,\n\t\t\t\t...configuration,\n\t\t\t};\n\t\t}\n\n\t\tthis.hocuspocus = new Hocuspocus(this.configuration);\n\t\tthis.hocuspocus.server = this;\n\n\t\tthis.httpServer = createServer(this.requestHandler);\n\t\tthis.crossws = crossws({\n\t\t\tserverOptions: this.configuration.websocketOptions,\n\t\t\thooks: {\n\t\t\t\topen: (peer) => {\n\t\t\t\t\tconst clientConnection = this.hocuspocus.handleConnection(\n\t\t\t\t\t\tpeer.websocket as unknown as WebSocketLike,\n\t\t\t\t\t\tpeer.request as Request,\n\t\t\t\t\t);\n\t\t\t\t\t(peer as any)._hocuspocus = clientConnection;\n\t\t\t\t},\n\t\t\t\tmessage: (peer, message) => {\n\t\t\t\t\t(peer as any)._hocuspocus?.handleMessage(message.uint8Array());\n\t\t\t\t},\n\t\t\t\tclose: (peer, event) => {\n\t\t\t\t\t(peer as any)._hocuspocus?.handleClose({\n\t\t\t\t\t\tcode: event.code,\n\t\t\t\t\t\treason: event.reason,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\terror: (peer, error) => {\n\t\t\t\t\tconsole.error(\"WebSocket error for peer:\", peer.id);\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tthis.setupHttpUpgrade();\n\t}\n\n\tprivate setupHttpUpgrade = () => {\n\t\tthis.httpServer.on(\"upgrade\", async (request, socket, head) => {\n\t\t\ttry {\n\t\t\t\tawait this.hocuspocus.hooks(\"onUpgrade\", {\n\t\t\t\t\trequest,\n\t\t\t\t\tsocket,\n\t\t\t\t\thead,\n\t\t\t\t\tinstance: this.hocuspocus,\n\t\t\t\t});\n\n\t\t\t\t// Let crossws handle the WebSocket upgrade\n\t\t\t\tthis.crossws.handleUpgrade(request, socket, head);\n\t\t\t} catch (error) {\n\t\t\t\t// if a hook rejects and the error is empty, do nothing\n\t\t\t\t// this is only meant to prevent later hooks and the\n\t\t\t\t// default handler to do something. if a error is present\n\t\t\t\t// just rethrow it\n\t\t\t\tif (error) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n\n\trequestHandler = async (\n\t\trequest: IncomingMessage,\n\t\tresponse: ServerResponse,\n\t) => {\n\t\ttry {\n\t\t\tawait this.hocuspocus.hooks(\"onRequest\", {\n\t\t\t\trequest,\n\t\t\t\tresponse,\n\t\t\t\tinstance: this.hocuspocus,\n\t\t\t});\n\n\t\t\t// default response if all prior hooks don't interfere\n\t\t\tresponse.writeHead(200, { \"Content-Type\": \"text/plain\" });\n\t\t\tresponse.end(\"Welcome to Hocuspocus!\");\n\t\t} catch (error) {\n\t\t\t// if a hook rejects and the error is empty, do nothing\n\t\t\t// this is only meant to prevent later hooks and the\n\t\t\t// default handler to do something. if a error is present\n\t\t\t// just rethrow it\n\t\t\tif (error) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t};\n\n\tasync listen(\n\t\tport?: number,\n\t\tcallback: any = null,\n\t): Promise<Hocuspocus<Context>> {\n\t\tif (port) {\n\t\t\tthis.configuration.port = port;\n\t\t}\n\n\t\tif (typeof callback === \"function\") {\n\t\t\tthis.hocuspocus.configuration.extensions.push({\n\t\t\t\tonListen: callback,\n\t\t\t});\n\t\t}\n\n\t\tif (this.configuration.stopOnSignals) {\n\t\t\tconst signalHandler = async () => {\n\t\t\t\tawait this.destroy();\n\t\t\t\tprocess.exit(0);\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", signalHandler);\n\t\t\tprocess.on(\"SIGQUIT\", signalHandler);\n\t\t\tprocess.on(\"SIGTERM\", signalHandler);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n\t\treturn new Promise((resolve: Function, reject: Function) => {\n\t\t\tconst listenOptions: ListenOptions = {\n\t\t\t\tport: this.configuration.port,\n\t\t\t\thost: this.configuration.address,\n\t\t\t};\n\n\t\t\tthis.httpServer.listen(\n\t\t\t\tlistenOptions,\n\t\t\t\tasync () => {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!this.configuration.quiet &&\n\t\t\t\t\t\tString(process.env.NODE_ENV) !== \"testing\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.showStartScreen();\n\t\t\t\t\t}\n\n\t\t\t\t\tconst onListenPayload = {\n\t\t\t\t\t\tinstance: this.hocuspocus,\n\t\t\t\t\t\tconfiguration: this.configuration,\n\t\t\t\t\t\tport: this.address.port,\n\t\t\t\t\t} as onListenPayload;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.hocuspocus.hooks(\"onListen\", onListenPayload);\n\t\t\t\t\t\tresolve(this.hocuspocus);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\treject(e);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tget address(): AddressInfo {\n\t\treturn (this.httpServer.address() || {\n\t\t\tport: this.configuration.port,\n\t\t\taddress: this.configuration.address ?? \"0.0.0.0\",\n\t\t\tfamily: \"IPv4\",\n\t\t}) as AddressInfo;\n\t}\n\n\tprivate destroyPromise?: Promise<void>;\n\n\tasync destroy(): Promise<void> {\n\t\t// Guard against multiple shutdowns (e.g. repeated SIGINT signals).\n\t\t// Subsequent callers await the same in-flight shutdown rather than\n\t\t// re-running close hooks on already-closed resources.\n\t\tthis.destroyPromise ??= this.runDestroy();\n\n\t\treturn this.destroyPromise;\n\t}\n\n\tprivate async runDestroy(): Promise<void> {\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tthis.httpServer.close();\n\n\t\t\ttry {\n\t\t\t\tthis.configuration.extensions.push({\n\t\t\t\t\tasync afterUnloadDocument({ instance }) {\n\t\t\t\t\t\tif (instance.getDocumentsCount() === 0) resolve();\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\t// Close all existing connections - this will trigger the close hook\n\t\t\t\tif (this.hocuspocus.getDocumentsCount() === 0) resolve();\n\n\t\t\t\tthis.hocuspocus.closeConnections();\n\n\t\t\t\t// Flush any remaining debounced stores so documents unload\n\t\t\t\t// promptly, even when unloadImmediately is false.\n\t\t\t\tthis.hocuspocus.flushPendingStores();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(error);\n\t\t\t}\n\t\t});\n\n\t\tawait this.hocuspocus.hooks(\"onDestroy\", { instance: this.hocuspocus });\n\t}\n\n\tget URL(): string {\n\t\treturn `${this.configuration.address ?? \"0.0.0.0\"}:${this.address.port}`;\n\t}\n\n\tget webSocketURL(): string {\n\t\treturn `ws://${this.URL}`;\n\t}\n\n\tget httpURL(): string {\n\t\treturn `http://${this.URL}`;\n\t}\n\n\tprivate showStartScreen() {\n\t\tconst name = this.configuration.name ? ` (${this.configuration.name})` : \"\";\n\n\t\tconsole.log();\n\t\tconsole.log(\n\t\t\t`  ${kleur.cyan(`Hocuspocus v${meta.version}${name}`)}${kleur.green(\" running at:\")}`,\n\t\t);\n\t\tconsole.log();\n\n\t\tconsole.log(`  > HTTP: ${kleur.cyan(`${this.httpURL}`)}`);\n\t\tconsole.log(`  > WebSocket: ${this.webSocketURL}`);\n\n\t\tconst extensions = this.configuration?.extensions\n\t\t\t.map((extension) => {\n\t\t\t\treturn extension.extensionName ?? extension.constructor?.name;\n\t\t\t})\n\t\t\t.filter((name) => name)\n\t\t\t.filter((name) => name !== \"Object\");\n\n\t\tif (!extensions.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.log();\n\t\tconsole.log(\"  Extensions:\");\n\n\t\textensions.forEach((name) => {\n\t\t\tconsole.log(`  - ${name}`);\n\t\t});\n\n\t\tconsole.log();\n\t\tconsole.log(`  ${kleur.green(\"Ready.\")}`);\n\t\tconsole.log();\n\t}\n}\n"],"x_google_ignoreList":[12,13,14,15,16,17,18],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAa,kBAAb,MAA6B;CAa5B,YAAY,OAAY;AACvB,MAAI,EAAE,iBAAiB,YACtB,SAAQ,IAAI,WAAW,MAAM;AAG9B,OAAK,2CAAwB,MAAM;;CAGpC,IAAI,UAAU;AACb,MAAI,CAAC,KAAK,gBACT,MAAK,oDAAiC;AAEvC,SAAO,KAAK;;CAGb,oBAAoB;AACnB,8CAAyB,KAAK,QAAQ;;CAGvC,oBAAoB;EACnB,MAAM,EAAE,QAAQ,KAAK;EACrB,MAAM,8CAA2B,KAAK,QAAQ;AAC9C,OAAK,QAAQ,MAAM;AACnB,SAAO;;CAGR,cAAc;AACb,wCAAmB,KAAK,QAAQ;;CAGjC,gBAAgB;AACf,0CAAqB,KAAK,QAAQ;;CAGnC,eAAe;AACd,yCAAoB,KAAK,QAAQ;;CAGlC,aAAa,MAAmB;AAC/B,kCAAa,KAAK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OAAK,UAAU,KAAK,MAAM;AAC1B,OAAK,iBAAiB,MAAM;;;;;;;;CAQ7B,SAAS,cAAc,OAAO;AAC7B,OAAK,iBAAiB,MAAM;AAC5B,MAAI,KAAK,oBAAoB,cAAc,KAAK,KAAK,iBAAiB,KAAK,oBAAoB,aAAa;AAC3G,QAAK,UAAU,KAAK,MAAM;AAC1B;;AAED,OAAK,0BAA0B,IAAI,WAAW,4BAA4B;AAC1E,OAAK,QAAQ,OAAO;AACpB,OAAK,QAAQ,eAAe;AAC5B,OAAK,eAAe,QAAQ,cAAc;AAC1C,OAAK,OAAO;;;;;;;;CAQb,SAAS,eAAe,KAAK;AAC5B,OAAK,oBAAoB,WAAW;AACpC,MAAI,KAAK,SAAS;AACjB,QAAK,WAAW,KAAK,QAAQ;AAC7B;;AAED,MAAI,eAAe;AACnB,OAAK,WAAW,IAAI;;GAEnB;AAIH,IAAI,qBAAqC,gCAAgB,SAAS,WAAW;CAC5E,MAAM,EAAE,WAAW,UAAU,SAAS;CACtC,MAAM,EAAE,YAAY,mBAAmB;CACvC,MAAM,aAAa;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA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