chatroom-cli 1.98.0 → 1.98.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7661,7 +7661,7 @@ var init_simple_client_node = __esm(() => {
7661
7661
  NOOP
7662
7662
  } = require_constants();
7663
7663
  var {
7664
- EventTarget: { addEventListener, removeEventListener }
7664
+ EventTarget: { addEventListener: addEventListener2, removeEventListener: removeEventListener2 }
7665
7665
  } = require_event_target();
7666
7666
  var { format, parse } = require_extension();
7667
7667
  var { toBuffer } = require_buffer_util();
@@ -7990,8 +7990,8 @@ var init_simple_client_node = __esm(() => {
7990
7990
  }
7991
7991
  });
7992
7992
  });
7993
- WebSocket2.prototype.addEventListener = addEventListener;
7994
- WebSocket2.prototype.removeEventListener = removeEventListener;
7993
+ WebSocket2.prototype.addEventListener = addEventListener2;
7994
+ WebSocket2.prototype.removeEventListener = removeEventListener2;
7995
7995
  module.exports = WebSocket2;
7996
7996
  function initAsClient(websocket, address, protocols, options) {
7997
7997
  const opts = {
@@ -8153,9 +8153,9 @@ var init_simple_client_node = __esm(() => {
8153
8153
  emitErrorAndClose(websocket, err);
8154
8154
  });
8155
8155
  req.on("response", (res) => {
8156
- const location = res.headers.location;
8156
+ const location2 = res.headers.location;
8157
8157
  const statusCode = res.statusCode;
8158
- if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
8158
+ if (location2 && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
8159
8159
  if (++websocket._redirects > opts.maxRedirects) {
8160
8160
  abortHandshake(websocket, req, "Maximum redirects exceeded");
8161
8161
  return;
@@ -8163,9 +8163,9 @@ var init_simple_client_node = __esm(() => {
8163
8163
  req.abort();
8164
8164
  let addr;
8165
8165
  try {
8166
- addr = new URL2(location, address);
8166
+ addr = new URL2(location2, address);
8167
8167
  } catch (e) {
8168
- const err = new SyntaxError(`Invalid URL: ${location}`);
8168
+ const err = new SyntaxError(`Invalid URL: ${location2}`);
8169
8169
  emitErrorAndClose(websocket, err);
8170
8170
  return;
8171
8171
  }
@@ -12615,9 +12615,9 @@ ${prefix}}`;
12615
12615
  if (typeof stack2 === "string") {
12616
12616
  const locationMatchAll = stack2.matchAll(locationRegex);
12617
12617
  let match4 = false;
12618
- for (const [, location] of locationMatchAll) {
12618
+ for (const [, location2] of locationMatchAll) {
12619
12619
  match4 = true;
12620
- out.push(` at ${current.name} (${location})`);
12620
+ out.push(` at ${current.name} (${location2})`);
12621
12621
  }
12622
12622
  if (!match4) {
12623
12623
  out.push(` at ${current.name} (${stack2.replace(/^at /, "")})`);
@@ -52959,13 +52959,13 @@ var require_lib3 = __commonJS((exports, module) => {
52959
52959
  clearTimeout(reqTimeout);
52960
52960
  const headers = createHeadersLenient(res.headers);
52961
52961
  if (fetch2.isRedirect(res.statusCode)) {
52962
- const location = headers.get("Location");
52962
+ const location2 = headers.get("Location");
52963
52963
  let locationURL = null;
52964
52964
  try {
52965
- locationURL = location === null ? null : new URL$1(location, request2.url).toString();
52965
+ locationURL = location2 === null ? null : new URL$1(location2, request2.url).toString();
52966
52966
  } catch (err) {
52967
52967
  if (request2.redirect !== "manual") {
52968
- reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
52968
+ reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location2}`, "invalid-redirect"));
52969
52969
  finalize();
52970
52970
  return;
52971
52971
  }
@@ -67066,8 +67066,8 @@ var require_follow_redirects = __commonJS((exports, module) => {
67066
67066
  statusCode
67067
67067
  });
67068
67068
  }
67069
- var location = response.headers.location;
67070
- if (!location || this._options.followRedirects === false || statusCode < 300 || statusCode >= 400) {
67069
+ var location2 = response.headers.location;
67070
+ if (!location2 || this._options.followRedirects === false || statusCode < 300 || statusCode >= 400) {
67071
67071
  response.responseUrl = this._currentUrl;
67072
67072
  response.redirects = this._redirects;
67073
67073
  this.emit("response", response);
@@ -67095,8 +67095,8 @@ var require_follow_redirects = __commonJS((exports, module) => {
67095
67095
  var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
67096
67096
  var currentUrlParts = parseUrl2(this._currentUrl);
67097
67097
  var currentHost = currentHostHeader || currentUrlParts.host;
67098
- var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url2.format(Object.assign(currentUrlParts, { host: currentHost }));
67099
- var redirectUrl = resolveUrl(location, currentUrl);
67098
+ var currentUrl = /^\w+:/.test(location2) ? this._currentUrl : url2.format(Object.assign(currentUrlParts, { host: currentHost }));
67099
+ var redirectUrl = resolveUrl(location2, currentUrl);
67100
67100
  debug("redirecting to", redirectUrl.href);
67101
67101
  this._isRedirect = true;
67102
67102
  spreadUrlObject(redirectUrl, this._options);
@@ -67687,10 +67687,10 @@ var init_callbackify = __esm(() => {
67687
67687
  });
67688
67688
 
67689
67689
  // ../../node_modules/.pnpm/axios@1.19.0/node_modules/axios/lib/helpers/shouldBypassProxy.js
67690
- function shouldBypassProxy(location) {
67690
+ function shouldBypassProxy(location2) {
67691
67691
  let parsed;
67692
67692
  try {
67693
- parsed = new URL(location);
67693
+ parsed = new URL(location2);
67694
67694
  } catch (_err) {
67695
67695
  return false;
67696
67696
  }
@@ -68195,13 +68195,13 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
68195
68195
  return false;
68196
68196
  }
68197
68197
  }
68198
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
68198
+ function setProxy(options, configProxy, location2, isRedirect, configHttpsAgent, configHttpAgent) {
68199
68199
  let proxy = configProxy;
68200
68200
  const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
68201
68201
  if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
68202
- const proxyUrl = getProxyForUrl(location);
68202
+ const proxyUrl = getProxyForUrl(location2);
68203
68203
  if (proxyUrl) {
68204
- if (!shouldBypassProxy(location)) {
68204
+ if (!shouldBypassProxy(location2)) {
68205
68205
  proxy = new URL(proxyUrl);
68206
68206
  }
68207
68207
  }
@@ -68279,7 +68279,7 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
68279
68279
  options.hostname = proxyHost;
68280
68280
  options.host = proxyHost;
68281
68281
  options.port = readProxyField("port");
68282
- options.path = location;
68282
+ options.path = location2;
68283
68283
  const proxyProtocol = readProxyField("protocol");
68284
68284
  if (proxyProtocol) {
68285
68285
  options.protocol = proxyProtocol.includes(":") ? proxyProtocol : `${proxyProtocol}:`;
@@ -101360,7 +101360,7 @@ class AgentProcessManager {
101360
101360
  signal: undefined,
101361
101361
  agentHarness: undefined
101362
101362
  };
101363
- this.deps.backend.mutation(api.machines.recordAgentExited, exitArgs1).catch((err) => {
101363
+ this.deps.logEvent({ type: "agent.exited", timestamp: Date.now(), ...exitArgs1 }).catch((err) => {
101364
101364
  console.log(` ⚠️ Failed to record agent exit (idle cleanup): ${err.message}`);
101365
101365
  this.queueExitRetry({ role: opts.role, args: exitArgs1 });
101366
101366
  });
@@ -101540,7 +101540,7 @@ class AgentProcessManager {
101540
101540
  signal: opts.signal ?? undefined,
101541
101541
  agentHarness: ctx.harness
101542
101542
  };
101543
- this.deps.backend.mutation(api.machines.recordAgentExited, exitArgs2).catch((err) => {
101543
+ this.deps.logEvent({ type: "agent.exited", timestamp: Date.now(), ...exitArgs2 }).catch((err) => {
101544
101544
  console.log(` ⚠️ Failed to record agent exit event: ${err.message}`);
101545
101545
  this.queueExitRetry({ role: opts.role, args: exitArgs2 });
101546
101546
  });
@@ -101904,7 +101904,7 @@ class AgentProcessManager {
101904
101904
  }
101905
101905
  }
101906
101906
  recordAgentExitedOrQueueRetry(role, exitArgs, failureLog) {
101907
- this.deps.backend.mutation(api.machines.recordAgentExited, exitArgs).catch((err) => {
101907
+ this.deps.logEvent({ type: "agent.exited", timestamp: Date.now(), ...exitArgs }).catch((err) => {
101908
101908
  console.log(` ⚠️ ${failureLog}: ${err.message}`);
101909
101909
  this.queueExitRetry({ role, args: exitArgs });
101910
101910
  });
@@ -101932,7 +101932,7 @@ class AgentProcessManager {
101932
101932
  for (let i2 = this.exitRetryQueue.length - 1;i2 >= 0; i2--) {
101933
101933
  const item = this.exitRetryQueue[i2];
101934
101934
  try {
101935
- await this.deps.backend.mutation(api.machines.recordAgentExited, item.args);
101935
+ await this.deps.logEvent({ type: "agent.exited", timestamp: Date.now(), ...item.args });
101936
101936
  this.exitRetryQueue.splice(i2, 1);
101937
101937
  console.log(`[AgentProcessManager] ✅ Successfully retried agent exit event for ${item.role}`);
101938
101938
  } catch {}
@@ -102514,7 +102514,7 @@ class AgentProcessManager {
102514
102514
  signal: undefined,
102515
102515
  agentHarness: slot.harness
102516
102516
  };
102517
- this.deps.backend.mutation(api.machines.recordAgentExited, exitArgs3).catch((err) => {
102517
+ this.deps.logEvent({ type: "agent.exited", timestamp: Date.now(), ...exitArgs3 }).catch((err) => {
102518
102518
  console.log(` ⚠️ Failed to record agent exit event: ${err.message}`);
102519
102519
  this.queueExitRetry({ role: opts.role, args: exitArgs3 });
102520
102520
  });
@@ -102631,6 +102631,9 @@ function assembleDaemonSessionInit(args2) {
102631
102631
  deps.backend.mutation = (endpoint, args3) => client4.mutation(endpoint, args3);
102632
102632
  deps.backend.query = (endpoint, args3) => client4.query(endpoint, args3);
102633
102633
  deps.agentProcessManager = new AgentProcessManager({
102634
+ logEvent: activeLogEvent ?? (async () => {
102635
+ return;
102636
+ }),
102634
102637
  logSink: activeLogSink,
102635
102638
  agentServices,
102636
102639
  backend: deps.backend,
@@ -102678,6 +102681,7 @@ function getActiveLogSink() {
102678
102681
  }
102679
102682
  async function initDaemon(options = {}) {
102680
102683
  activeLogSink = options.logSink;
102684
+ activeLogEvent = options.logEvent;
102681
102685
  return exports_Effect.runPromise(initDaemonEffect);
102682
102686
  }
102683
102687
  var discoverModelsEffect = (agentServices) => exports_Effect.gen(function* () {
@@ -102811,7 +102815,7 @@ Run: ${formatAuthLoginCommand(convexUrl)}`);
102811
102815
  const cachedModels = yield* fetchCachedMachineModelsEffect(client4, typedSessionId, machineId);
102812
102816
  yield* connectDaemonEffect(client4, typedSessionId, machineId);
102813
102817
  return { typedSessionId, config: config4, machineId, agentServices, cachedModels };
102814
- }), activeLogSink, connectDaemonEffect = (client4, sessionId, machineId) => exports_Effect.tryPromise({
102818
+ }), activeLogSink, activeLogEvent, connectDaemonEffect = (client4, sessionId, machineId) => exports_Effect.tryPromise({
102815
102819
  try: () => client4.mutation(api.machines.updateDaemonStatus, {
102816
102820
  sessionId: asConvexSessionId(sessionId),
102817
102821
  machineId,
@@ -117410,7 +117414,7 @@ var init_resolve_logs_db_path = __esm(() => {
117410
117414
  });
117411
117415
 
117412
117416
  // src/infrastructure/log-server/log-schema.ts
117413
- var SCHEMA_VERSION = 1, MIGRATIONS;
117417
+ var SCHEMA_VERSION = 2, MIGRATIONS;
117414
117418
  var init_log_schema = __esm(() => {
117415
117419
  MIGRATIONS = [
117416
117420
  `CREATE TABLE IF NOT EXISTS schema_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL)`,
@@ -117423,7 +117427,15 @@ var init_log_schema = __esm(() => {
117423
117427
  message TEXT NOT NULL,
117424
117428
  metadata_json TEXT
117425
117429
  )`,
117426
- `CREATE INDEX IF NOT EXISTS idx_log_entries_source_id ON log_entries(source, id)`
117430
+ `CREATE INDEX IF NOT EXISTS idx_log_entries_source_id ON log_entries(source, id)`,
117431
+ `CREATE TABLE IF NOT EXISTS event_stream_entries (
117432
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
117433
+ timestamp INTEGER NOT NULL,
117434
+ type TEXT NOT NULL,
117435
+ payload_json TEXT NOT NULL
117436
+ )`,
117437
+ `CREATE INDEX IF NOT EXISTS idx_event_stream_entries_timestamp_id ON event_stream_entries(timestamp, id)`,
117438
+ `CREATE INDEX IF NOT EXISTS idx_event_stream_entries_chatroom_id ON event_stream_entries(json_extract(payload_json, '$.chatroomId'), id)`
117427
117439
  ];
117428
117440
  });
117429
117441
 
@@ -117461,6 +117473,35 @@ function appendBatch(db, entries2) {
117461
117473
  throw error51;
117462
117474
  }
117463
117475
  }
117476
+ function appendChatroomEvent(db, event) {
117477
+ db.prepare("INSERT INTO event_stream_entries(timestamp,type,payload_json) VALUES(?,?,?)").run(event.timestamp, event.type, JSON.stringify(event));
117478
+ }
117479
+ function queryEventStream(db, input) {
117480
+ const filters = [
117481
+ "AND json_extract(payload_json, '$.chatroomId') = ?",
117482
+ input.afterId !== undefined ? "AND id > ?" : "",
117483
+ input.beforeId !== undefined ? "AND id < ?" : "",
117484
+ input.type ? "AND type = ?" : "",
117485
+ input.fromTimestamp !== undefined ? "AND timestamp >= ?" : "",
117486
+ input.toTimestamp !== undefined ? "AND timestamp <= ?" : ""
117487
+ ].join(" ");
117488
+ const values3 = [
117489
+ input.chatroomId,
117490
+ ...input.afterId !== undefined ? [input.afterId] : [],
117491
+ ...input.beforeId !== undefined ? [input.beforeId] : [],
117492
+ ...input.type ? [input.type] : [],
117493
+ ...input.fromTimestamp !== undefined ? [input.fromTimestamp] : [],
117494
+ ...input.toTimestamp !== undefined ? [input.toTimestamp] : [],
117495
+ clamp4(input.limit)
117496
+ ];
117497
+ const rows2 = db.prepare(`SELECT * FROM event_stream_entries WHERE 1=1 ${filters} ORDER BY id DESC LIMIT ?`).all(...values3);
117498
+ return rows2.reverse().map((row) => ({
117499
+ id: Number(row.id),
117500
+ timestamp: Number(row.timestamp),
117501
+ type: row.type,
117502
+ payload: JSON.parse(row.payload_json)
117503
+ }));
117504
+ }
117464
117505
  function queryAfterId(db, afterId = 0, limit = 100, source, chatroomId, role, harness, fromTimestamp, toTimestamp) {
117465
117506
  const filters = [
117466
117507
  source ? "AND source = ?" : "",
@@ -117704,6 +117745,12 @@ function createLogRepository(db) {
117704
117745
  },
117705
117746
  listDimensions(limit = 100) {
117706
117747
  return listLogDimensions(db, limit);
117748
+ },
117749
+ writeChatroomEvent(event) {
117750
+ appendChatroomEvent(db, event);
117751
+ },
117752
+ queryEventStream(input) {
117753
+ return queryEventStream(db, input);
117707
117754
  }
117708
117755
  };
117709
117756
  }
@@ -119506,7 +119553,7 @@ var require_webtransport = __commonJS((exports) => {
119506
119553
  var engine_io_parser_1 = require_cjs();
119507
119554
  var debug2 = (0, debug_1.default)("engine:webtransport");
119508
119555
 
119509
- class WebTransport extends transport_1.Transport {
119556
+ class WebTransport2 extends transport_1.Transport {
119510
119557
  constructor(session2, stream4, reader) {
119511
119558
  super({ _query: { EIO: "4" } });
119512
119559
  this.session = session2;
@@ -119556,7 +119603,7 @@ var require_webtransport = __commonJS((exports) => {
119556
119603
  fn2 && fn2();
119557
119604
  }
119558
119605
  }
119559
- exports.WebTransport = WebTransport;
119606
+ exports.WebTransport = WebTransport2;
119560
119607
  });
119561
119608
 
119562
119609
  // ../../node_modules/.pnpm/engine.io@6.6.9/node_modules/engine.io/build/transports/index.js
@@ -121764,7 +121811,7 @@ var require_websocket3 = __commonJS((exports, module) => {
121764
121811
  NOOP
121765
121812
  } = require_constants3();
121766
121813
  var {
121767
- EventTarget: { addEventListener, removeEventListener }
121814
+ EventTarget: { addEventListener: addEventListener2, removeEventListener: removeEventListener2 }
121768
121815
  } = require_event_target2();
121769
121816
  var { format: format5, parse: parse8 } = require_extension2();
121770
121817
  var { toBuffer } = require_buffer_util2();
@@ -122094,8 +122141,8 @@ var require_websocket3 = __commonJS((exports, module) => {
122094
122141
  }
122095
122142
  });
122096
122143
  });
122097
- WebSocket2.prototype.addEventListener = addEventListener;
122098
- WebSocket2.prototype.removeEventListener = removeEventListener;
122144
+ WebSocket2.prototype.addEventListener = addEventListener2;
122145
+ WebSocket2.prototype.removeEventListener = removeEventListener2;
122099
122146
  module.exports = WebSocket2;
122100
122147
  function initAsClient(websocket, address, protocols, options) {
122101
122148
  const opts = {
@@ -122257,9 +122304,9 @@ var require_websocket3 = __commonJS((exports, module) => {
122257
122304
  emitErrorAndClose(websocket, err);
122258
122305
  });
122259
122306
  req.on("response", (res) => {
122260
- const location = res.headers.location;
122307
+ const location2 = res.headers.location;
122261
122308
  const statusCode = res.statusCode;
122262
- if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
122309
+ if (location2 && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
122263
122310
  if (++websocket._redirects > opts.maxRedirects) {
122264
122311
  abortHandshake(websocket, req, "Maximum redirects exceeded");
122265
122312
  return;
@@ -122267,9 +122314,9 @@ var require_websocket3 = __commonJS((exports, module) => {
122267
122314
  req.abort();
122268
122315
  let addr;
122269
122316
  try {
122270
- addr = new URL2(location, address);
122317
+ addr = new URL2(location2, address);
122271
122318
  } catch (e) {
122272
- const err = new SyntaxError(`Invalid URL: ${location}`);
122319
+ const err = new SyntaxError(`Invalid URL: ${location2}`);
122273
122320
  emitErrorAndClose(websocket, err);
122274
122321
  return;
122275
122322
  }
@@ -128171,7 +128218,7 @@ var init_normalize_error = __esm(() => {
128171
128218
  });
128172
128219
 
128173
128220
  // src/daemon/infrastructure/socket/schemas.ts
128174
- var harnessHistoryInputSchema, logHistoryInputSchema, logSourcesInputSchema;
128221
+ var harnessHistoryInputSchema, logHistoryInputSchema, logSourcesInputSchema, eventStreamHistoryInputSchema, chatroomEventIngestInputSchema;
128175
128222
  var init_schemas3 = __esm(() => {
128176
128223
  init_zod();
128177
128224
  harnessHistoryInputSchema = exports_external.object({
@@ -128194,8 +128241,29 @@ var init_schemas3 = __esm(() => {
128194
128241
  logSourcesInputSchema = exports_external.object({
128195
128242
  limit: exports_external.number().int().positive().max(1000).optional()
128196
128243
  });
128244
+ eventStreamHistoryInputSchema = exports_external.object({
128245
+ chatroomId: exports_external.string().min(1),
128246
+ afterId: exports_external.number().int().nonnegative().optional(),
128247
+ beforeId: exports_external.number().int().positive().optional(),
128248
+ type: exports_external.string().optional(),
128249
+ fromTimestamp: exports_external.number().int().nonnegative().optional(),
128250
+ toTimestamp: exports_external.number().int().nonnegative().optional(),
128251
+ limit: exports_external.number().int().positive().max(1000).optional()
128252
+ });
128253
+ chatroomEventIngestInputSchema = exports_external.object({
128254
+ type: exports_external.string().min(1),
128255
+ timestamp: exports_external.number(),
128256
+ chatroomId: exports_external.string().min(1).optional()
128257
+ }).passthrough();
128197
128258
  });
128198
128259
 
128260
+ // src/daemon/domain/usecase/event-stream-history.ts
128261
+ function createEventStreamHistoryUseCase(deps) {
128262
+ return (input) => ({
128263
+ entries: deps.reader.queryEventStream(input)
128264
+ });
128265
+ }
128266
+
128199
128267
  // src/daemon/domain/usecase/get-local-web-health.ts
128200
128268
  function getLocalWebHealth(port) {
128201
128269
  return { status: "ok", service: "v2-local-web", port };
@@ -128223,6 +128291,37 @@ function listLogSources(reader, limit = 100) {
128223
128291
  return { sources: reader.listSources(limit) };
128224
128292
  }
128225
128293
 
128294
+ // src/daemon/domain/usecase/log-dimensions.ts
128295
+ function createLogDimensionsUseCase(deps) {
128296
+ return (limit) => listLogDimensions2(deps.reader, limit);
128297
+ }
128298
+ var init_log_dimensions = () => {};
128299
+
128300
+ // src/daemon/domain/usecase/log-event-ingestion.ts
128301
+ function createLogEventIngestionUseCase(deps) {
128302
+ return (event) => {
128303
+ deps.writer.writeChatroomEvent(event);
128304
+ return { accepted: true };
128305
+ };
128306
+ }
128307
+
128308
+ // src/daemon/domain/usecase/log-history.ts
128309
+ function createLogHistoryUseCase(deps) {
128310
+ return (input) => listLogHistory(deps.reader, input);
128311
+ }
128312
+ var init_log_history = () => {};
128313
+
128314
+ // src/daemon/domain/usecase/log-sources.ts
128315
+ function createLogSourcesUseCase(deps) {
128316
+ return (limit) => listLogSources(deps.reader, limit);
128317
+ }
128318
+ var init_log_sources = () => {};
128319
+
128320
+ // src/daemon/domain/usecase/subscribe-log-stream.ts
128321
+ function createSubscribeLogStreamUseCase(deps) {
128322
+ return (onEvent) => deps.hub.subscribe(onEvent);
128323
+ }
128324
+
128226
128325
  // src/daemon/infrastructure/socket/register-handlers.ts
128227
128326
  function callAck(ack, response) {
128228
128327
  if (typeof ack === "function") {
@@ -128237,6 +128336,12 @@ function extractAck(args2) {
128237
128336
  return { payload: args2[0], ack: undefined };
128238
128337
  }
128239
128338
  function registerSocketHandlers(io2, deps) {
128339
+ const logHistory = deps.logRepo ? createLogHistoryUseCase({ reader: deps.logRepo }) : undefined;
128340
+ const eventStreamHistory = deps.logRepo ? createEventStreamHistoryUseCase({ reader: deps.logRepo }) : undefined;
128341
+ const logEventIngestion = deps.logRepo ? createLogEventIngestionUseCase({ writer: deps.logRepo }) : undefined;
128342
+ const logSources = deps.logRepo ? createLogSourcesUseCase({ reader: deps.logRepo }) : undefined;
128343
+ const logDimensions = deps.logRepo ? createLogDimensionsUseCase({ reader: deps.logRepo }) : undefined;
128344
+ const subscribeLogStream = deps.logStreamHub ? createSubscribeLogStreamUseCase({ hub: deps.logStreamHub }) : undefined;
128240
128345
  io2.on("connection", (socket) => {
128241
128346
  const streamUnsubs = [];
128242
128347
  socket.on("health.get", (...args2) => {
@@ -128274,23 +128379,45 @@ function registerSocketHandlers(io2, deps) {
128274
128379
  socket.on("logs.history", (...args2) => {
128275
128380
  const { payload, ack } = extractAck(args2);
128276
128381
  try {
128277
- if (!deps.logRepo)
128278
- throw new Error("log repository not configured");
128382
+ if (!logHistory)
128383
+ throw new Error("log history use case not configured");
128279
128384
  callAck(ack, {
128280
128385
  ok: true,
128281
- data: listLogHistory(deps.logRepo, logHistoryInputSchema.parse(payload ?? {}))
128386
+ data: logHistory(logHistoryInputSchema.parse(payload ?? {}))
128282
128387
  });
128283
128388
  } catch (err) {
128284
128389
  callAck(ack, { ok: false, error: normalizeError(err) });
128285
128390
  }
128286
128391
  });
128392
+ socket.on("eventStream.ingest", (...args2) => {
128393
+ const { payload, ack } = extractAck(args2);
128394
+ try {
128395
+ if (!logEventIngestion)
128396
+ throw new Error("log event ingestion use case not configured");
128397
+ const event = chatroomEventIngestInputSchema.parse(payload);
128398
+ callAck(ack, { ok: true, data: logEventIngestion(event) });
128399
+ } catch (err) {
128400
+ callAck(ack, { ok: false, error: normalizeError(err) });
128401
+ }
128402
+ });
128403
+ socket.on("eventStream.history", (...args2) => {
128404
+ const { payload, ack } = extractAck(args2);
128405
+ try {
128406
+ if (!eventStreamHistory)
128407
+ throw new Error("event stream use case not configured");
128408
+ const input = eventStreamHistoryInputSchema.parse(payload ?? {});
128409
+ callAck(ack, { ok: true, data: eventStreamHistory(input) });
128410
+ } catch (err) {
128411
+ callAck(ack, { ok: false, error: normalizeError(err) });
128412
+ }
128413
+ });
128287
128414
  socket.on("logs.sources", (...args2) => {
128288
128415
  const { payload, ack } = extractAck(args2);
128289
128416
  try {
128290
- if (!deps.logRepo)
128291
- throw new Error("log repository not configured");
128417
+ if (!logSources)
128418
+ throw new Error("log sources use case not configured");
128292
128419
  const parsed = logSourcesInputSchema.parse(payload ?? {});
128293
- callAck(ack, { ok: true, data: listLogSources(deps.logRepo, parsed.limit) });
128420
+ callAck(ack, { ok: true, data: logSources(parsed.limit) });
128294
128421
  } catch (err) {
128295
128422
  callAck(ack, { ok: false, error: normalizeError(err) });
128296
128423
  }
@@ -128298,10 +128425,10 @@ function registerSocketHandlers(io2, deps) {
128298
128425
  socket.on("logs.dimensions", (...args2) => {
128299
128426
  const { payload, ack } = extractAck(args2);
128300
128427
  try {
128301
- if (!deps.logRepo)
128302
- throw new Error("log repository not configured");
128428
+ if (!logDimensions)
128429
+ throw new Error("log dimensions use case not configured");
128303
128430
  const parsed = logSourcesInputSchema.parse(payload ?? {});
128304
- callAck(ack, { ok: true, data: listLogDimensions2(deps.logRepo, parsed.limit) });
128431
+ callAck(ack, { ok: true, data: logDimensions(parsed.limit) });
128305
128432
  } catch (err) {
128306
128433
  callAck(ack, { ok: false, error: normalizeError(err) });
128307
128434
  }
@@ -128330,9 +128457,9 @@ function registerSocketHandlers(io2, deps) {
128330
128457
  socket.on("logs.stream.subscribe", (...args2) => {
128331
128458
  const { ack } = extractAck(args2);
128332
128459
  try {
128333
- if (!deps.logStreamHub)
128334
- throw new Error("log stream hub not configured");
128335
- const unsub = deps.logStreamHub.subscribe((event) => socket.emit("logs.stream", event));
128460
+ if (!subscribeLogStream)
128461
+ throw new Error("log stream use case not configured");
128462
+ const unsub = subscribeLogStream((event) => socket.emit("logs.stream", event));
128336
128463
  streamUnsubs.push(unsub);
128337
128464
  callAck(ack, { ok: true, data: { subscribed: true } });
128338
128465
  } catch (err) {
@@ -128349,6 +128476,9 @@ var init_register_handlers = __esm(() => {
128349
128476
  init_normalize_error();
128350
128477
  init_schemas3();
128351
128478
  init_api3();
128479
+ init_log_dimensions();
128480
+ init_log_history();
128481
+ init_log_sources();
128352
128482
  });
128353
128483
 
128354
128484
  // src/daemon/local-web/server/create-local-web-server.ts
@@ -128424,15 +128554,3293 @@ function createLogStreamHub() {
128424
128554
  } };
128425
128555
  }
128426
128556
 
128427
- // src/daemon/entry/start-daemon.ts
128428
- async function startDaemon() {
128429
- const logStreamHub = createLogStreamHub();
128430
- const logServer = createLogServer(resolveLogsDbPath(), {
128431
- onWrite: (entry) => logStreamHub.publish(entry)
128557
+ // ../../node_modules/.pnpm/xmlhttprequest-ssl@2.1.2/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js
128558
+ var require_XMLHttpRequest = __commonJS((exports, module) => {
128559
+ var fs12 = __require("fs");
128560
+ var Url = __require("url");
128561
+ var spawn7 = __require("child_process").spawn;
128562
+ module.exports = XMLHttpRequest2;
128563
+ XMLHttpRequest2.XMLHttpRequest = XMLHttpRequest2;
128564
+ function XMLHttpRequest2(opts) {
128565
+ opts = opts || {};
128566
+ var self2 = this;
128567
+ var http3 = __require("http");
128568
+ var https2 = __require("https");
128569
+ var request2;
128570
+ var response;
128571
+ var settings = {};
128572
+ var disableHeaderCheck = false;
128573
+ var defaultHeaders2 = {
128574
+ "User-Agent": "node-XMLHttpRequest",
128575
+ Accept: "*/*"
128576
+ };
128577
+ var headers = Object.assign({}, defaultHeaders2);
128578
+ var forbiddenRequestHeaders = [
128579
+ "accept-charset",
128580
+ "accept-encoding",
128581
+ "access-control-request-headers",
128582
+ "access-control-request-method",
128583
+ "connection",
128584
+ "content-length",
128585
+ "content-transfer-encoding",
128586
+ "cookie",
128587
+ "cookie2",
128588
+ "date",
128589
+ "expect",
128590
+ "host",
128591
+ "keep-alive",
128592
+ "origin",
128593
+ "referer",
128594
+ "te",
128595
+ "trailer",
128596
+ "transfer-encoding",
128597
+ "upgrade",
128598
+ "via"
128599
+ ];
128600
+ var forbiddenRequestMethods = [
128601
+ "TRACE",
128602
+ "TRACK",
128603
+ "CONNECT"
128604
+ ];
128605
+ var sendFlag = false;
128606
+ var errorFlag = false;
128607
+ var abortedFlag = false;
128608
+ var listeners = {};
128609
+ this.UNSENT = 0;
128610
+ this.OPENED = 1;
128611
+ this.HEADERS_RECEIVED = 2;
128612
+ this.LOADING = 3;
128613
+ this.DONE = 4;
128614
+ this.readyState = this.UNSENT;
128615
+ this.onreadystatechange = null;
128616
+ this.responseText = "";
128617
+ this.responseXML = "";
128618
+ this.response = Buffer.alloc(0);
128619
+ this.status = null;
128620
+ this.statusText = null;
128621
+ var isAllowedHttpHeader = function(header) {
128622
+ return disableHeaderCheck || header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1;
128623
+ };
128624
+ var isAllowedHttpMethod = function(method) {
128625
+ return method && forbiddenRequestMethods.indexOf(method) === -1;
128626
+ };
128627
+ this.open = function(method, url3, async2, user, password) {
128628
+ this.abort();
128629
+ errorFlag = false;
128630
+ abortedFlag = false;
128631
+ if (!isAllowedHttpMethod(method)) {
128632
+ throw new Error("SecurityError: Request method not allowed");
128633
+ }
128634
+ settings = {
128635
+ method,
128636
+ url: url3.toString(),
128637
+ async: typeof async2 !== "boolean" ? true : async2,
128638
+ user: user || null,
128639
+ password: password || null
128640
+ };
128641
+ setState(this.OPENED);
128642
+ };
128643
+ this.setDisableHeaderCheck = function(state) {
128644
+ disableHeaderCheck = state;
128645
+ };
128646
+ this.setRequestHeader = function(header, value) {
128647
+ if (this.readyState != this.OPENED) {
128648
+ throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");
128649
+ }
128650
+ if (!isAllowedHttpHeader(header)) {
128651
+ console.warn('Refused to set unsafe header "' + header + '"');
128652
+ return false;
128653
+ }
128654
+ if (sendFlag) {
128655
+ throw new Error("INVALID_STATE_ERR: send flag is true");
128656
+ }
128657
+ headers[header] = value;
128658
+ return true;
128659
+ };
128660
+ this.getResponseHeader = function(header) {
128661
+ if (typeof header === "string" && this.readyState > this.OPENED && response.headers[header.toLowerCase()] && !errorFlag) {
128662
+ return response.headers[header.toLowerCase()];
128663
+ }
128664
+ return null;
128665
+ };
128666
+ this.getAllResponseHeaders = function() {
128667
+ if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {
128668
+ return "";
128669
+ }
128670
+ var result = "";
128671
+ for (var i2 in response.headers) {
128672
+ if (i2 !== "set-cookie" && i2 !== "set-cookie2") {
128673
+ result += i2 + ": " + response.headers[i2] + `\r
128674
+ `;
128675
+ }
128676
+ }
128677
+ return result.substr(0, result.length - 2);
128678
+ };
128679
+ this.getRequestHeader = function(name) {
128680
+ if (typeof name === "string" && headers[name]) {
128681
+ return headers[name];
128682
+ }
128683
+ return "";
128684
+ };
128685
+ this.send = function(data) {
128686
+ if (this.readyState != this.OPENED) {
128687
+ throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");
128688
+ }
128689
+ if (sendFlag) {
128690
+ throw new Error("INVALID_STATE_ERR: send has already been called");
128691
+ }
128692
+ var ssl = false, local = false;
128693
+ var url3 = Url.parse(settings.url);
128694
+ var host;
128695
+ switch (url3.protocol) {
128696
+ case "https:":
128697
+ ssl = true;
128698
+ case "http:":
128699
+ host = url3.hostname;
128700
+ break;
128701
+ case "file:":
128702
+ local = true;
128703
+ break;
128704
+ case undefined:
128705
+ case "":
128706
+ host = "localhost";
128707
+ break;
128708
+ default:
128709
+ throw new Error("Protocol not supported.");
128710
+ }
128711
+ if (local) {
128712
+ if (settings.method !== "GET") {
128713
+ throw new Error("XMLHttpRequest: Only GET method is supported");
128714
+ }
128715
+ if (settings.async) {
128716
+ fs12.readFile(unescape(url3.pathname), function(error51, data2) {
128717
+ if (error51) {
128718
+ self2.handleError(error51, error51.errno || -1);
128719
+ } else {
128720
+ self2.status = 200;
128721
+ self2.responseText = data2.toString("utf8");
128722
+ self2.response = data2;
128723
+ setState(self2.DONE);
128724
+ }
128725
+ });
128726
+ } else {
128727
+ try {
128728
+ this.response = fs12.readFileSync(unescape(url3.pathname));
128729
+ this.responseText = this.response.toString("utf8");
128730
+ this.status = 200;
128731
+ setState(self2.DONE);
128732
+ } catch (e) {
128733
+ this.handleError(e, e.errno || -1);
128734
+ }
128735
+ }
128736
+ return;
128737
+ }
128738
+ var port = url3.port || (ssl ? 443 : 80);
128739
+ var uri = url3.pathname + (url3.search ? url3.search : "");
128740
+ headers["Host"] = host;
128741
+ if (!(ssl && port === 443 || port === 80)) {
128742
+ headers["Host"] += ":" + url3.port;
128743
+ }
128744
+ if (settings.user) {
128745
+ if (typeof settings.password == "undefined") {
128746
+ settings.password = "";
128747
+ }
128748
+ var authBuf = new Buffer(settings.user + ":" + settings.password);
128749
+ headers["Authorization"] = "Basic " + authBuf.toString("base64");
128750
+ }
128751
+ if (settings.method === "GET" || settings.method === "HEAD") {
128752
+ data = null;
128753
+ } else if (data) {
128754
+ headers["Content-Length"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);
128755
+ var headersKeys = Object.keys(headers);
128756
+ if (!headersKeys.some(function(h) {
128757
+ return h.toLowerCase() === "content-type";
128758
+ })) {
128759
+ headers["Content-Type"] = "text/plain;charset=UTF-8";
128760
+ }
128761
+ } else if (settings.method === "POST") {
128762
+ headers["Content-Length"] = 0;
128763
+ }
128764
+ var agent = opts.agent || false;
128765
+ var options = {
128766
+ host,
128767
+ port,
128768
+ path: uri,
128769
+ method: settings.method,
128770
+ headers,
128771
+ agent
128772
+ };
128773
+ if (ssl) {
128774
+ options.pfx = opts.pfx;
128775
+ options.key = opts.key;
128776
+ options.passphrase = opts.passphrase;
128777
+ options.cert = opts.cert;
128778
+ options.ca = opts.ca;
128779
+ options.ciphers = opts.ciphers;
128780
+ options.rejectUnauthorized = opts.rejectUnauthorized === false ? false : true;
128781
+ }
128782
+ errorFlag = false;
128783
+ if (settings.async) {
128784
+ var doRequest = ssl ? https2.request : http3.request;
128785
+ sendFlag = true;
128786
+ self2.dispatchEvent("readystatechange");
128787
+ var responseHandler = function(resp2) {
128788
+ response = resp2;
128789
+ if (response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {
128790
+ settings.url = response.headers.location;
128791
+ var url4 = Url.parse(settings.url);
128792
+ host = url4.hostname;
128793
+ var newOptions = {
128794
+ hostname: url4.hostname,
128795
+ port: url4.port,
128796
+ path: url4.path,
128797
+ method: response.statusCode === 303 ? "GET" : settings.method,
128798
+ headers
128799
+ };
128800
+ if (ssl) {
128801
+ newOptions.pfx = opts.pfx;
128802
+ newOptions.key = opts.key;
128803
+ newOptions.passphrase = opts.passphrase;
128804
+ newOptions.cert = opts.cert;
128805
+ newOptions.ca = opts.ca;
128806
+ newOptions.ciphers = opts.ciphers;
128807
+ newOptions.rejectUnauthorized = opts.rejectUnauthorized === false ? false : true;
128808
+ }
128809
+ request2 = doRequest(newOptions, responseHandler).on("error", errorHandler);
128810
+ request2.end();
128811
+ return;
128812
+ }
128813
+ setState(self2.HEADERS_RECEIVED);
128814
+ self2.status = response.statusCode;
128815
+ response.on("data", function(chunk2) {
128816
+ if (chunk2) {
128817
+ var data2 = Buffer.from(chunk2);
128818
+ self2.response = Buffer.concat([self2.response, data2]);
128819
+ }
128820
+ if (sendFlag) {
128821
+ setState(self2.LOADING);
128822
+ }
128823
+ });
128824
+ response.on("end", function() {
128825
+ if (sendFlag) {
128826
+ sendFlag = false;
128827
+ setState(self2.DONE);
128828
+ self2.responseText = self2.response.toString("utf8");
128829
+ }
128830
+ });
128831
+ response.on("error", function(error51) {
128832
+ self2.handleError(error51);
128833
+ });
128834
+ };
128835
+ var errorHandler = function(error51) {
128836
+ if (request2.reusedSocket && error51.code === "ECONNRESET")
128837
+ return doRequest(options, responseHandler).on("error", errorHandler);
128838
+ self2.handleError(error51);
128839
+ };
128840
+ request2 = doRequest(options, responseHandler).on("error", errorHandler);
128841
+ if (opts.autoUnref) {
128842
+ request2.on("socket", (socket) => {
128843
+ socket.unref();
128844
+ });
128845
+ }
128846
+ if (data) {
128847
+ request2.write(data);
128848
+ }
128849
+ request2.end();
128850
+ self2.dispatchEvent("loadstart");
128851
+ } else {
128852
+ var contentFile = ".node-xmlhttprequest-content-" + process.pid;
128853
+ var syncFile = ".node-xmlhttprequest-sync-" + process.pid;
128854
+ fs12.writeFileSync(syncFile, "", "utf8");
128855
+ var execString = "var http = require('http'), https = require('https'), fs = require('fs');" + "var doRequest = http" + (ssl ? "s" : "") + ".request;" + "var options = " + JSON.stringify(options) + ";" + "var responseText = '';" + "var responseData = Buffer.alloc(0);" + "var req = doRequest(options, function(response) {" + "response.on('data', function(chunk) {" + " var data = Buffer.from(chunk);" + " responseText += data.toString('utf8');" + " responseData = Buffer.concat([responseData, data]);" + "});" + "response.on('end', function() {" + "fs.writeFileSync('" + contentFile + "', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText, data: responseData.toString('base64')}}), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" + "});" + "response.on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" + "});" + "}).on('error', function(error) {" + "fs.writeFileSync('" + contentFile + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" + "});" + (data ? "req.write('" + JSON.stringify(data).slice(1, -1).replace(/'/g, "\\'") + "');" : "") + "req.end();";
128856
+ var syncProc = spawn7(process.argv[0], ["-e", execString]);
128857
+ var statusText;
128858
+ while (fs12.existsSync(syncFile)) {}
128859
+ self2.responseText = fs12.readFileSync(contentFile, "utf8");
128860
+ syncProc.stdin.end();
128861
+ fs12.unlinkSync(contentFile);
128862
+ if (self2.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)) {
128863
+ var errorObj = JSON.parse(self2.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/, ""));
128864
+ self2.handleError(errorObj, 503);
128865
+ } else {
128866
+ self2.status = self2.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/, "$1");
128867
+ var resp = JSON.parse(self2.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/, "$1"));
128868
+ response = {
128869
+ statusCode: self2.status,
128870
+ headers: resp.data.headers
128871
+ };
128872
+ self2.responseText = resp.data.text;
128873
+ self2.response = Buffer.from(resp.data.data, "base64");
128874
+ setState(self2.DONE, true);
128875
+ }
128876
+ }
128877
+ };
128878
+ this.handleError = function(error51, status3) {
128879
+ this.status = status3 || 0;
128880
+ this.statusText = error51;
128881
+ this.responseText = error51.stack;
128882
+ errorFlag = true;
128883
+ setState(this.DONE);
128884
+ };
128885
+ this.abort = function() {
128886
+ if (request2) {
128887
+ request2.abort();
128888
+ request2 = null;
128889
+ }
128890
+ headers = Object.assign({}, defaultHeaders2);
128891
+ this.responseText = "";
128892
+ this.responseXML = "";
128893
+ this.response = Buffer.alloc(0);
128894
+ errorFlag = abortedFlag = true;
128895
+ if (this.readyState !== this.UNSENT && (this.readyState !== this.OPENED || sendFlag) && this.readyState !== this.DONE) {
128896
+ sendFlag = false;
128897
+ setState(this.DONE);
128898
+ }
128899
+ this.readyState = this.UNSENT;
128900
+ };
128901
+ this.addEventListener = function(event, callback) {
128902
+ if (!(event in listeners)) {
128903
+ listeners[event] = [];
128904
+ }
128905
+ listeners[event].push(callback);
128906
+ };
128907
+ this.removeEventListener = function(event, callback) {
128908
+ if (event in listeners) {
128909
+ listeners[event] = listeners[event].filter(function(ev) {
128910
+ return ev !== callback;
128911
+ });
128912
+ }
128913
+ };
128914
+ this.dispatchEvent = function(event) {
128915
+ if (typeof self2["on" + event] === "function") {
128916
+ if (this.readyState === this.DONE && settings.async)
128917
+ setTimeout(function() {
128918
+ self2["on" + event]();
128919
+ }, 0);
128920
+ else
128921
+ self2["on" + event]();
128922
+ }
128923
+ if (event in listeners) {
128924
+ for (let i2 = 0, len2 = listeners[event].length;i2 < len2; i2++) {
128925
+ if (this.readyState === this.DONE)
128926
+ setTimeout(function() {
128927
+ listeners[event][i2].call(self2);
128928
+ }, 0);
128929
+ else
128930
+ listeners[event][i2].call(self2);
128931
+ }
128932
+ }
128933
+ };
128934
+ var setState = function(state) {
128935
+ if (self2.readyState === state || self2.readyState === self2.UNSENT && abortedFlag)
128936
+ return;
128937
+ self2.readyState = state;
128938
+ if (settings.async || self2.readyState < self2.OPENED || self2.readyState === self2.DONE) {
128939
+ self2.dispatchEvent("readystatechange");
128940
+ }
128941
+ if (self2.readyState === self2.DONE) {
128942
+ let fire;
128943
+ if (abortedFlag)
128944
+ fire = "abort";
128945
+ else if (errorFlag)
128946
+ fire = "error";
128947
+ else
128948
+ fire = "load";
128949
+ self2.dispatchEvent(fire);
128950
+ self2.dispatchEvent("loadend");
128951
+ }
128952
+ };
128953
+ }
128954
+ });
128955
+
128956
+ // ../../node_modules/.pnpm/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/esm/commons.js
128957
+ var PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET;
128958
+ var init_commons = __esm(() => {
128959
+ PACKET_TYPES = Object.create(null);
128960
+ PACKET_TYPES["open"] = "0";
128961
+ PACKET_TYPES["close"] = "1";
128962
+ PACKET_TYPES["ping"] = "2";
128963
+ PACKET_TYPES["pong"] = "3";
128964
+ PACKET_TYPES["message"] = "4";
128965
+ PACKET_TYPES["upgrade"] = "5";
128966
+ PACKET_TYPES["noop"] = "6";
128967
+ PACKET_TYPES_REVERSE = Object.create(null);
128968
+ Object.keys(PACKET_TYPES).forEach((key) => {
128969
+ PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
128432
128970
  });
128433
- let init2;
128971
+ ERROR_PACKET = { type: "error", data: "parser error" };
128972
+ });
128973
+
128974
+ // ../../node_modules/.pnpm/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/esm/encodePacket.js
128975
+ function encodePacketToBinary(packet, callback) {
128976
+ if (packet.data instanceof ArrayBuffer || ArrayBuffer.isView(packet.data)) {
128977
+ return callback(toBuffer(packet.data, false));
128978
+ }
128979
+ encodePacket(packet, true, (encoded) => {
128980
+ if (!TEXT_ENCODER) {
128981
+ TEXT_ENCODER = new TextEncoder;
128982
+ }
128983
+ callback(TEXT_ENCODER.encode(encoded));
128984
+ });
128985
+ }
128986
+ var encodePacket = ({ type, data }, supportsBinary, callback) => {
128987
+ if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
128988
+ return callback(supportsBinary ? data : "b" + toBuffer(data, true).toString("base64"));
128989
+ }
128990
+ return callback(PACKET_TYPES[type] + (data || ""));
128991
+ }, toBuffer = (data, forceBufferConversion) => {
128992
+ if (Buffer.isBuffer(data) || data instanceof Uint8Array && !forceBufferConversion) {
128993
+ return data;
128994
+ } else if (data instanceof ArrayBuffer) {
128995
+ return Buffer.from(data);
128996
+ } else {
128997
+ return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
128998
+ }
128999
+ }, TEXT_ENCODER;
129000
+ var init_encodePacket = __esm(() => {
129001
+ init_commons();
129002
+ });
129003
+
129004
+ // ../../node_modules/.pnpm/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/esm/decodePacket.js
129005
+ var decodePacket = (encodedPacket, binaryType) => {
129006
+ if (typeof encodedPacket !== "string") {
129007
+ return {
129008
+ type: "message",
129009
+ data: mapBinary(encodedPacket, binaryType)
129010
+ };
129011
+ }
129012
+ const type = encodedPacket.charAt(0);
129013
+ if (type === "b") {
129014
+ const buffer = Buffer.from(encodedPacket.substring(1), "base64");
129015
+ return {
129016
+ type: "message",
129017
+ data: mapBinary(buffer, binaryType)
129018
+ };
129019
+ }
129020
+ if (!PACKET_TYPES_REVERSE[type]) {
129021
+ return ERROR_PACKET;
129022
+ }
129023
+ return encodedPacket.length > 1 ? {
129024
+ type: PACKET_TYPES_REVERSE[type],
129025
+ data: encodedPacket.substring(1)
129026
+ } : {
129027
+ type: PACKET_TYPES_REVERSE[type]
129028
+ };
129029
+ }, mapBinary = (data, binaryType) => {
129030
+ switch (binaryType) {
129031
+ case "arraybuffer":
129032
+ if (data instanceof ArrayBuffer) {
129033
+ return data;
129034
+ } else if (Buffer.isBuffer(data)) {
129035
+ return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
129036
+ } else {
129037
+ return data.buffer;
129038
+ }
129039
+ case "nodebuffer":
129040
+ default:
129041
+ if (Buffer.isBuffer(data)) {
129042
+ return data;
129043
+ } else {
129044
+ return Buffer.from(data);
129045
+ }
129046
+ }
129047
+ };
129048
+ var init_decodePacket = __esm(() => {
129049
+ init_commons();
129050
+ });
129051
+
129052
+ // ../../node_modules/.pnpm/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/esm/index.js
129053
+ function createPacketEncoderStream() {
129054
+ return new TransformStream({
129055
+ transform(packet, controller) {
129056
+ encodePacketToBinary(packet, (encodedPacket) => {
129057
+ const payloadLength = encodedPacket.length;
129058
+ let header;
129059
+ if (payloadLength < 126) {
129060
+ header = new Uint8Array(1);
129061
+ new DataView(header.buffer).setUint8(0, payloadLength);
129062
+ } else if (payloadLength < 65536) {
129063
+ header = new Uint8Array(3);
129064
+ const view = new DataView(header.buffer);
129065
+ view.setUint8(0, 126);
129066
+ view.setUint16(1, payloadLength);
129067
+ } else {
129068
+ header = new Uint8Array(9);
129069
+ const view = new DataView(header.buffer);
129070
+ view.setUint8(0, 127);
129071
+ view.setBigUint64(1, BigInt(payloadLength));
129072
+ }
129073
+ if (packet.data && typeof packet.data !== "string") {
129074
+ header[0] |= 128;
129075
+ }
129076
+ controller.enqueue(header);
129077
+ controller.enqueue(encodedPacket);
129078
+ });
129079
+ }
129080
+ });
129081
+ }
129082
+ function totalLength(chunks) {
129083
+ return chunks.reduce((acc, chunk2) => acc + chunk2.length, 0);
129084
+ }
129085
+ function concatChunks(chunks, size9) {
129086
+ if (chunks[0].length === size9) {
129087
+ return chunks.shift();
129088
+ }
129089
+ const buffer = new Uint8Array(size9);
129090
+ let j = 0;
129091
+ for (let i2 = 0;i2 < size9; i2++) {
129092
+ buffer[i2] = chunks[0][j++];
129093
+ if (j === chunks[0].length) {
129094
+ chunks.shift();
129095
+ j = 0;
129096
+ }
129097
+ }
129098
+ if (chunks.length && j < chunks[0].length) {
129099
+ chunks[0] = chunks[0].slice(j);
129100
+ }
129101
+ return buffer;
129102
+ }
129103
+ function createPacketDecoderStream(maxPayload, binaryType) {
129104
+ if (!TEXT_DECODER) {
129105
+ TEXT_DECODER = new TextDecoder;
129106
+ }
129107
+ const chunks = [];
129108
+ let state = 0;
129109
+ let expectedLength = -1;
129110
+ let isBinary = false;
129111
+ return new TransformStream({
129112
+ transform(chunk2, controller) {
129113
+ chunks.push(chunk2);
129114
+ while (true) {
129115
+ if (state === 0) {
129116
+ if (totalLength(chunks) < 1) {
129117
+ break;
129118
+ }
129119
+ const header = concatChunks(chunks, 1);
129120
+ isBinary = (header[0] & 128) === 128;
129121
+ expectedLength = header[0] & 127;
129122
+ if (expectedLength < 126) {
129123
+ state = 3;
129124
+ } else if (expectedLength === 126) {
129125
+ state = 1;
129126
+ } else {
129127
+ state = 2;
129128
+ }
129129
+ } else if (state === 1) {
129130
+ if (totalLength(chunks) < 2) {
129131
+ break;
129132
+ }
129133
+ const headerArray = concatChunks(chunks, 2);
129134
+ expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0);
129135
+ state = 3;
129136
+ } else if (state === 2) {
129137
+ if (totalLength(chunks) < 8) {
129138
+ break;
129139
+ }
129140
+ const headerArray = concatChunks(chunks, 8);
129141
+ const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length);
129142
+ const n = view.getUint32(0);
129143
+ if (n > Math.pow(2, 53 - 32) - 1) {
129144
+ controller.enqueue(ERROR_PACKET);
129145
+ break;
129146
+ }
129147
+ expectedLength = n * Math.pow(2, 32) + view.getUint32(4);
129148
+ state = 3;
129149
+ } else {
129150
+ if (totalLength(chunks) < expectedLength) {
129151
+ break;
129152
+ }
129153
+ const data = concatChunks(chunks, expectedLength);
129154
+ controller.enqueue(decodePacket(isBinary ? data : TEXT_DECODER.decode(data), binaryType));
129155
+ state = 0;
129156
+ }
129157
+ if (expectedLength === 0 || expectedLength > maxPayload) {
129158
+ controller.enqueue(ERROR_PACKET);
129159
+ break;
129160
+ }
129161
+ }
129162
+ }
129163
+ });
129164
+ }
129165
+ var SEPARATOR, encodePayload = (packets, callback) => {
129166
+ const length2 = packets.length;
129167
+ const encodedPackets = new Array(length2);
129168
+ let count3 = 0;
129169
+ packets.forEach((packet, i2) => {
129170
+ encodePacket(packet, false, (encodedPacket) => {
129171
+ encodedPackets[i2] = encodedPacket;
129172
+ if (++count3 === length2) {
129173
+ callback(encodedPackets.join(SEPARATOR));
129174
+ }
129175
+ });
129176
+ });
129177
+ }, decodePayload = (encodedPayload, binaryType) => {
129178
+ const encodedPackets = encodedPayload.split(SEPARATOR);
129179
+ const packets = [];
129180
+ for (let i2 = 0;i2 < encodedPackets.length; i2++) {
129181
+ const decodedPacket = decodePacket(encodedPackets[i2], binaryType);
129182
+ packets.push(decodedPacket);
129183
+ if (decodedPacket.type === "error") {
129184
+ break;
129185
+ }
129186
+ }
129187
+ return packets;
129188
+ }, TEXT_DECODER, protocol = 4;
129189
+ var init_esm2 = __esm(() => {
129190
+ init_encodePacket();
129191
+ init_decodePacket();
129192
+ init_commons();
129193
+ SEPARATOR = String.fromCharCode(30);
129194
+ });
129195
+
129196
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/globals.node.js
129197
+ function createCookieJar() {
129198
+ return new CookieJar;
129199
+ }
129200
+ function parse8(setCookieString) {
129201
+ const parts2 = setCookieString.split("; ");
129202
+ const i2 = parts2[0].indexOf("=");
129203
+ if (i2 === -1) {
129204
+ return;
129205
+ }
129206
+ const name = parts2[0].substring(0, i2).trim();
129207
+ if (!name.length) {
129208
+ return;
129209
+ }
129210
+ let value = parts2[0].substring(i2 + 1).trim();
129211
+ if (value.charCodeAt(0) === 34) {
129212
+ value = value.slice(1, -1);
129213
+ }
129214
+ const cookie = {
129215
+ name,
129216
+ value
129217
+ };
129218
+ for (let j = 1;j < parts2.length; j++) {
129219
+ const subParts = parts2[j].split("=");
129220
+ if (subParts.length !== 2) {
129221
+ continue;
129222
+ }
129223
+ const key = subParts[0].trim();
129224
+ const value2 = subParts[1].trim();
129225
+ switch (key) {
129226
+ case "Expires":
129227
+ cookie.expires = new Date(value2);
129228
+ break;
129229
+ case "Max-Age":
129230
+ const expiration = new Date;
129231
+ expiration.setUTCSeconds(expiration.getUTCSeconds() + parseInt(value2, 10));
129232
+ cookie.expires = expiration;
129233
+ break;
129234
+ default:
129235
+ }
129236
+ }
129237
+ return cookie;
129238
+ }
129239
+
129240
+ class CookieJar {
129241
+ constructor() {
129242
+ this._cookies = new Map;
129243
+ }
129244
+ parseCookies(values3) {
129245
+ if (!values3) {
129246
+ return;
129247
+ }
129248
+ values3.forEach((value) => {
129249
+ const parsed = parse8(value);
129250
+ if (parsed) {
129251
+ this._cookies.set(parsed.name, parsed);
129252
+ }
129253
+ });
129254
+ }
129255
+ get cookies() {
129256
+ const now = Date.now();
129257
+ this._cookies.forEach((cookie, name) => {
129258
+ var _a4;
129259
+ if (((_a4 = cookie.expires) === null || _a4 === undefined ? undefined : _a4.getTime()) < now) {
129260
+ this._cookies.delete(name);
129261
+ }
129262
+ });
129263
+ return this._cookies.entries();
129264
+ }
129265
+ addCookies(xhr) {
129266
+ const cookies = [];
129267
+ for (const [name, cookie] of this.cookies) {
129268
+ cookies.push(`${name}=${cookie.value}`);
129269
+ }
129270
+ if (cookies.length) {
129271
+ xhr.setDisableHeaderCheck(true);
129272
+ xhr.setRequestHeader("cookie", cookies.join("; "));
129273
+ }
129274
+ }
129275
+ appendCookies(headers) {
129276
+ for (const [name, cookie] of this.cookies) {
129277
+ headers.append("cookie", `${name}=${cookie.value}`);
129278
+ }
129279
+ }
129280
+ }
129281
+ var nextTick, globalThisShim, defaultBinaryType = "nodebuffer";
129282
+ var init_globals_node = __esm(() => {
129283
+ nextTick = process.nextTick;
129284
+ globalThisShim = global;
129285
+ });
129286
+
129287
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/util.js
129288
+ function pick5(obj, ...attr) {
129289
+ return attr.reduce((acc, k) => {
129290
+ if (obj.hasOwnProperty(k)) {
129291
+ acc[k] = obj[k];
129292
+ }
129293
+ return acc;
129294
+ }, {});
129295
+ }
129296
+ function installTimerFunctions(obj, opts) {
129297
+ if (opts.useNativeTimers) {
129298
+ obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim);
129299
+ obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim);
129300
+ } else {
129301
+ obj.setTimeoutFn = globalThisShim.setTimeout.bind(globalThisShim);
129302
+ obj.clearTimeoutFn = globalThisShim.clearTimeout.bind(globalThisShim);
129303
+ }
129304
+ }
129305
+ function byteLength2(obj) {
129306
+ if (typeof obj === "string") {
129307
+ return utf8Length(obj);
129308
+ }
129309
+ return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD);
129310
+ }
129311
+ function utf8Length(str) {
129312
+ let c = 0, length2 = 0;
129313
+ for (let i2 = 0, l = str.length;i2 < l; i2++) {
129314
+ c = str.charCodeAt(i2);
129315
+ if (c < 128) {
129316
+ length2 += 1;
129317
+ } else if (c < 2048) {
129318
+ length2 += 2;
129319
+ } else if (c < 55296 || c >= 57344) {
129320
+ length2 += 3;
129321
+ } else {
129322
+ i2++;
129323
+ length2 += 4;
129324
+ }
129325
+ }
129326
+ return length2;
129327
+ }
129328
+ function randomString2() {
129329
+ return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
129330
+ }
129331
+ var NATIVE_SET_TIMEOUT, NATIVE_CLEAR_TIMEOUT, BASE64_OVERHEAD = 1.33;
129332
+ var init_util3 = __esm(() => {
129333
+ init_globals_node();
129334
+ NATIVE_SET_TIMEOUT = globalThisShim.setTimeout;
129335
+ NATIVE_CLEAR_TIMEOUT = globalThisShim.clearTimeout;
129336
+ });
129337
+
129338
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js
129339
+ function encode5(obj) {
129340
+ let str = "";
129341
+ for (let i2 in obj) {
129342
+ if (obj.hasOwnProperty(i2)) {
129343
+ if (str.length)
129344
+ str += "&";
129345
+ str += encodeURIComponent(i2) + "=" + encodeURIComponent(obj[i2]);
129346
+ }
129347
+ }
129348
+ return str;
129349
+ }
129350
+ function decode5(qs) {
129351
+ let qry = {};
129352
+ let pairs = qs.split("&");
129353
+ for (let i2 = 0, l = pairs.length;i2 < l; i2++) {
129354
+ let pair = pairs[i2].split("=");
129355
+ qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
129356
+ }
129357
+ return qry;
129358
+ }
129359
+
129360
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transport.js
129361
+ var import_component_emitter, import_debug2, debug2, TransportError, Transport;
129362
+ var init_transport2 = __esm(() => {
129363
+ init_esm2();
129364
+ init_util3();
129365
+ import_component_emitter = __toESM(require_cjs2(), 1);
129366
+ import_debug2 = __toESM(require_src2(), 1);
129367
+ debug2 = import_debug2.default("engine.io-client:transport");
129368
+ TransportError = class TransportError extends Error {
129369
+ constructor(reason, description, context5) {
129370
+ super(reason);
129371
+ this.description = description;
129372
+ this.context = context5;
129373
+ this.type = "TransportError";
129374
+ }
129375
+ };
129376
+ Transport = class Transport extends import_component_emitter.Emitter {
129377
+ constructor(opts) {
129378
+ super();
129379
+ this.writable = false;
129380
+ installTimerFunctions(this, opts);
129381
+ this.opts = opts;
129382
+ this.query = opts.query;
129383
+ this.socket = opts.socket;
129384
+ this.supportsBinary = !opts.forceBase64;
129385
+ }
129386
+ onError(reason, description, context5) {
129387
+ super.emitReserved("error", new TransportError(reason, description, context5));
129388
+ return this;
129389
+ }
129390
+ open() {
129391
+ this.readyState = "opening";
129392
+ this.doOpen();
129393
+ return this;
129394
+ }
129395
+ close() {
129396
+ if (this.readyState === "opening" || this.readyState === "open") {
129397
+ this.doClose();
129398
+ this.onClose();
129399
+ }
129400
+ return this;
129401
+ }
129402
+ send(packets) {
129403
+ if (this.readyState === "open") {
129404
+ this.write(packets);
129405
+ } else {
129406
+ debug2("transport is not open, discarding packets");
129407
+ }
129408
+ }
129409
+ onOpen() {
129410
+ this.readyState = "open";
129411
+ this.writable = true;
129412
+ super.emitReserved("open");
129413
+ }
129414
+ onData(data) {
129415
+ const packet = decodePacket(data, this.socket.binaryType);
129416
+ this.onPacket(packet);
129417
+ }
129418
+ onPacket(packet) {
129419
+ super.emitReserved("packet", packet);
129420
+ }
129421
+ onClose(details) {
129422
+ this.readyState = "closed";
129423
+ super.emitReserved("close", details);
129424
+ }
129425
+ pause(onPause) {}
129426
+ createUri(schema, query = {}) {
129427
+ return schema + "://" + this._hostname() + this._port() + this.opts.path + this._query(query);
129428
+ }
129429
+ _hostname() {
129430
+ const hostname5 = this.opts.hostname;
129431
+ return hostname5.indexOf(":") === -1 ? hostname5 : "[" + hostname5 + "]";
129432
+ }
129433
+ _port() {
129434
+ if (this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80)) {
129435
+ return ":" + this.opts.port;
129436
+ } else {
129437
+ return "";
129438
+ }
129439
+ }
129440
+ _query(query) {
129441
+ const encodedQuery = encode5(query);
129442
+ return encodedQuery.length ? "?" + encodedQuery : "";
129443
+ }
129444
+ };
129445
+ });
129446
+
129447
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/polling.js
129448
+ var import_debug3, debug3, Polling;
129449
+ var init_polling = __esm(() => {
129450
+ init_transport2();
129451
+ init_util3();
129452
+ init_esm2();
129453
+ import_debug3 = __toESM(require_src2(), 1);
129454
+ debug3 = import_debug3.default("engine.io-client:polling");
129455
+ Polling = class Polling extends Transport {
129456
+ constructor() {
129457
+ super(...arguments);
129458
+ this._polling = false;
129459
+ }
129460
+ get name() {
129461
+ return "polling";
129462
+ }
129463
+ doOpen() {
129464
+ this._poll();
129465
+ }
129466
+ pause(onPause) {
129467
+ this.readyState = "pausing";
129468
+ const pause = () => {
129469
+ debug3("paused");
129470
+ this.readyState = "paused";
129471
+ onPause();
129472
+ };
129473
+ if (this._polling || !this.writable) {
129474
+ let total = 0;
129475
+ if (this._polling) {
129476
+ debug3("we are currently polling - waiting to pause");
129477
+ total++;
129478
+ this.once("pollComplete", function() {
129479
+ debug3("pre-pause polling complete");
129480
+ --total || pause();
129481
+ });
129482
+ }
129483
+ if (!this.writable) {
129484
+ debug3("we are currently writing - waiting to pause");
129485
+ total++;
129486
+ this.once("drain", function() {
129487
+ debug3("pre-pause writing complete");
129488
+ --total || pause();
129489
+ });
129490
+ }
129491
+ } else {
129492
+ pause();
129493
+ }
129494
+ }
129495
+ _poll() {
129496
+ debug3("polling");
129497
+ this._polling = true;
129498
+ this.doPoll();
129499
+ this.emitReserved("poll");
129500
+ }
129501
+ onData(data) {
129502
+ debug3("polling got data %s", data);
129503
+ const callback = (packet) => {
129504
+ if (this.readyState === "opening" && packet.type === "open") {
129505
+ this.onOpen();
129506
+ }
129507
+ if (packet.type === "close") {
129508
+ this.onClose({ description: "transport closed by the server" });
129509
+ return false;
129510
+ }
129511
+ this.onPacket(packet);
129512
+ };
129513
+ decodePayload(data, this.socket.binaryType).forEach(callback);
129514
+ if (this.readyState !== "closed") {
129515
+ this._polling = false;
129516
+ this.emitReserved("pollComplete");
129517
+ if (this.readyState === "open") {
129518
+ this._poll();
129519
+ } else {
129520
+ debug3('ignoring poll - transport state "%s"', this.readyState);
129521
+ }
129522
+ }
129523
+ }
129524
+ doClose() {
129525
+ const close2 = () => {
129526
+ debug3("writing close packet");
129527
+ this.write([{ type: "close" }]);
129528
+ };
129529
+ if (this.readyState === "open") {
129530
+ debug3("transport open - closing");
129531
+ close2();
129532
+ } else {
129533
+ debug3("transport not open - deferring close");
129534
+ this.once("open", close2);
129535
+ }
129536
+ }
129537
+ write(packets) {
129538
+ this.writable = false;
129539
+ encodePayload(packets, (data) => {
129540
+ this.doWrite(data, () => {
129541
+ this.writable = true;
129542
+ this.emitReserved("drain");
129543
+ });
129544
+ });
129545
+ }
129546
+ uri() {
129547
+ const schema = this.opts.secure ? "https" : "http";
129548
+ const query = this.query || {};
129549
+ if (this.opts.timestampRequests !== false) {
129550
+ query[this.opts.timestampParam] = randomString2();
129551
+ }
129552
+ if (!this.supportsBinary && !query.sid) {
129553
+ query.b64 = 1;
129554
+ }
129555
+ return this.createUri(schema, query);
129556
+ }
129557
+ };
129558
+ });
129559
+
129560
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js
129561
+ var value = false, hasCORS;
129562
+ var init_has_cors = __esm(() => {
129563
+ try {
129564
+ value = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest;
129565
+ } catch (err) {}
129566
+ hasCORS = value;
129567
+ });
129568
+
129569
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js
129570
+ function empty30() {}
129571
+ function unloadHandler() {
129572
+ for (let i2 in Request3.requests) {
129573
+ if (Request3.requests.hasOwnProperty(i2)) {
129574
+ Request3.requests[i2].abort();
129575
+ }
129576
+ }
129577
+ }
129578
+ function newRequest(opts) {
129579
+ const xdomain = opts.xdomain;
128434
129580
  try {
128435
- init2 = await initDaemon({ logSink: logServer });
129581
+ if (typeof XMLHttpRequest !== "undefined" && (!xdomain || hasCORS)) {
129582
+ return new XMLHttpRequest;
129583
+ }
129584
+ } catch (e) {}
129585
+ if (!xdomain) {
129586
+ try {
129587
+ return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
129588
+ } catch (e) {}
129589
+ }
129590
+ }
129591
+ var import_component_emitter2, import_debug4, debug4, BaseXHR, Request3, hasXHR2;
129592
+ var init_polling_xhr = __esm(() => {
129593
+ init_polling();
129594
+ init_util3();
129595
+ init_globals_node();
129596
+ init_has_cors();
129597
+ import_component_emitter2 = __toESM(require_cjs2(), 1);
129598
+ import_debug4 = __toESM(require_src2(), 1);
129599
+ debug4 = import_debug4.default("engine.io-client:polling");
129600
+ BaseXHR = class BaseXHR extends Polling {
129601
+ constructor(opts) {
129602
+ super(opts);
129603
+ if (typeof location !== "undefined") {
129604
+ const isSSL = location.protocol === "https:";
129605
+ let port = location.port;
129606
+ if (!port) {
129607
+ port = isSSL ? "443" : "80";
129608
+ }
129609
+ this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
129610
+ }
129611
+ }
129612
+ doWrite(data, fn2) {
129613
+ const req = this.request({
129614
+ method: "POST",
129615
+ data
129616
+ });
129617
+ req.on("success", fn2);
129618
+ req.on("error", (xhrStatus, context5) => {
129619
+ this.onError("xhr post error", xhrStatus, context5);
129620
+ });
129621
+ }
129622
+ doPoll() {
129623
+ debug4("xhr poll");
129624
+ const req = this.request();
129625
+ req.on("data", this.onData.bind(this));
129626
+ req.on("error", (xhrStatus, context5) => {
129627
+ this.onError("xhr poll error", xhrStatus, context5);
129628
+ });
129629
+ this.pollXhr = req;
129630
+ }
129631
+ };
129632
+ Request3 = class Request3 extends import_component_emitter2.Emitter {
129633
+ constructor(createRequest, uri, opts) {
129634
+ super();
129635
+ this.createRequest = createRequest;
129636
+ installTimerFunctions(this, opts);
129637
+ this._opts = opts;
129638
+ this._method = opts.method || "GET";
129639
+ this._uri = uri;
129640
+ this._data = opts.data !== undefined ? opts.data : null;
129641
+ this._create();
129642
+ }
129643
+ _create() {
129644
+ var _a4;
129645
+ const opts = pick5(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
129646
+ opts.xdomain = !!this._opts.xd;
129647
+ const xhr = this._xhr = this.createRequest(opts);
129648
+ try {
129649
+ debug4("xhr open %s: %s", this._method, this._uri);
129650
+ xhr.open(this._method, this._uri, true);
129651
+ try {
129652
+ if (this._opts.extraHeaders) {
129653
+ xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
129654
+ for (let i2 in this._opts.extraHeaders) {
129655
+ if (this._opts.extraHeaders.hasOwnProperty(i2)) {
129656
+ xhr.setRequestHeader(i2, this._opts.extraHeaders[i2]);
129657
+ }
129658
+ }
129659
+ }
129660
+ } catch (e) {}
129661
+ if (this._method === "POST") {
129662
+ try {
129663
+ xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
129664
+ } catch (e) {}
129665
+ }
129666
+ try {
129667
+ xhr.setRequestHeader("Accept", "*/*");
129668
+ } catch (e) {}
129669
+ (_a4 = this._opts.cookieJar) === null || _a4 === undefined || _a4.addCookies(xhr);
129670
+ if ("withCredentials" in xhr) {
129671
+ xhr.withCredentials = this._opts.withCredentials;
129672
+ }
129673
+ if (this._opts.requestTimeout) {
129674
+ xhr.timeout = this._opts.requestTimeout;
129675
+ }
129676
+ xhr.onreadystatechange = () => {
129677
+ var _a5;
129678
+ if (xhr.readyState === 3) {
129679
+ (_a5 = this._opts.cookieJar) === null || _a5 === undefined || _a5.parseCookies(xhr.getResponseHeader("set-cookie"));
129680
+ }
129681
+ if (xhr.readyState !== 4)
129682
+ return;
129683
+ if (xhr.status === 200 || xhr.status === 1223) {
129684
+ this._onLoad();
129685
+ } else {
129686
+ this.setTimeoutFn(() => {
129687
+ this._onError(typeof xhr.status === "number" ? xhr.status : 0);
129688
+ }, 0);
129689
+ }
129690
+ };
129691
+ debug4("xhr data %s", this._data);
129692
+ xhr.send(this._data);
129693
+ } catch (e) {
129694
+ this.setTimeoutFn(() => {
129695
+ this._onError(e);
129696
+ }, 0);
129697
+ return;
129698
+ }
129699
+ if (typeof document !== "undefined") {
129700
+ this._index = Request3.requestsCount++;
129701
+ Request3.requests[this._index] = this;
129702
+ }
129703
+ }
129704
+ _onError(err) {
129705
+ this.emitReserved("error", err, this._xhr);
129706
+ this._cleanup(true);
129707
+ }
129708
+ _cleanup(fromError) {
129709
+ if (typeof this._xhr === "undefined" || this._xhr === null) {
129710
+ return;
129711
+ }
129712
+ this._xhr.onreadystatechange = empty30;
129713
+ if (fromError) {
129714
+ try {
129715
+ this._xhr.abort();
129716
+ } catch (e) {}
129717
+ }
129718
+ if (typeof document !== "undefined") {
129719
+ delete Request3.requests[this._index];
129720
+ }
129721
+ this._xhr = null;
129722
+ }
129723
+ _onLoad() {
129724
+ const data = this._xhr.responseText;
129725
+ if (data !== null) {
129726
+ this.emitReserved("data", data);
129727
+ this.emitReserved("success");
129728
+ this._cleanup();
129729
+ }
129730
+ }
129731
+ abort() {
129732
+ this._cleanup();
129733
+ }
129734
+ };
129735
+ Request3.requestsCount = 0;
129736
+ Request3.requests = {};
129737
+ if (typeof document !== "undefined") {
129738
+ if (typeof attachEvent === "function") {
129739
+ attachEvent("onunload", unloadHandler);
129740
+ } else if (typeof addEventListener === "function") {
129741
+ const terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload";
129742
+ addEventListener(terminationEvent, unloadHandler, false);
129743
+ }
129744
+ }
129745
+ hasXHR2 = function() {
129746
+ const xhr = newRequest({
129747
+ xdomain: false
129748
+ });
129749
+ return xhr && xhr.responseType !== null;
129750
+ }();
129751
+ });
129752
+
129753
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js
129754
+ var XMLHttpRequestModule, XMLHttpRequest2, XHR;
129755
+ var init_polling_xhr_node = __esm(() => {
129756
+ init_polling_xhr();
129757
+ XMLHttpRequestModule = __toESM(require_XMLHttpRequest(), 1);
129758
+ XMLHttpRequest2 = XMLHttpRequestModule.default || XMLHttpRequestModule;
129759
+ XHR = class XHR extends BaseXHR {
129760
+ request(opts = {}) {
129761
+ var _a4;
129762
+ Object.assign(opts, { xd: this.xd, cookieJar: (_a4 = this.socket) === null || _a4 === undefined ? undefined : _a4._cookieJar }, this.opts);
129763
+ return new Request3((opts2) => new XMLHttpRequest2(opts2), this.uri(), opts);
129764
+ }
129765
+ };
129766
+ });
129767
+
129768
+ // ../../node_modules/.pnpm/ws@8.21.0/node_modules/ws/wrapper.mjs
129769
+ var import_stream13, import_extension2, import_permessage_deflate2, import_receiver2, import_sender2, import_subprotocol2, import_websocket2, import_websocket_server2;
129770
+ var init_wrapper2 = __esm(() => {
129771
+ import_stream13 = __toESM(require_stream2(), 1);
129772
+ import_extension2 = __toESM(require_extension2(), 1);
129773
+ import_permessage_deflate2 = __toESM(require_permessage_deflate2(), 1);
129774
+ import_receiver2 = __toESM(require_receiver2(), 1);
129775
+ import_sender2 = __toESM(require_sender2(), 1);
129776
+ import_subprotocol2 = __toESM(require_subprotocol2(), 1);
129777
+ import_websocket2 = __toESM(require_websocket3(), 1);
129778
+ import_websocket_server2 = __toESM(require_websocket_server2(), 1);
129779
+ });
129780
+
129781
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/websocket.js
129782
+ var import_debug5, debug5, isReactNative2, BaseWS, WebSocketCtor;
129783
+ var init_websocket = __esm(() => {
129784
+ init_transport2();
129785
+ init_util3();
129786
+ init_esm2();
129787
+ init_globals_node();
129788
+ import_debug5 = __toESM(require_src2(), 1);
129789
+ debug5 = import_debug5.default("engine.io-client:websocket");
129790
+ isReactNative2 = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
129791
+ BaseWS = class BaseWS extends Transport {
129792
+ get name() {
129793
+ return "websocket";
129794
+ }
129795
+ doOpen() {
129796
+ const uri = this.uri();
129797
+ const protocols = this.opts.protocols;
129798
+ const opts = isReactNative2 ? {} : pick5(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
129799
+ if (this.opts.extraHeaders) {
129800
+ opts.headers = this.opts.extraHeaders;
129801
+ }
129802
+ try {
129803
+ this.ws = this.createSocket(uri, protocols, opts);
129804
+ } catch (err) {
129805
+ return this.emitReserved("error", err);
129806
+ }
129807
+ this.ws.binaryType = this.socket.binaryType;
129808
+ this.addEventListeners();
129809
+ }
129810
+ addEventListeners() {
129811
+ this.ws.onopen = () => {
129812
+ if (this.opts.autoUnref) {
129813
+ this.ws._socket.unref();
129814
+ }
129815
+ this.onOpen();
129816
+ };
129817
+ this.ws.onclose = (closeEvent) => this.onClose({
129818
+ description: "websocket connection closed",
129819
+ context: closeEvent
129820
+ });
129821
+ this.ws.onmessage = (ev) => this.onData(ev.data);
129822
+ this.ws.onerror = (e) => this.onError("websocket error", e);
129823
+ }
129824
+ write(packets) {
129825
+ this.writable = false;
129826
+ for (let i2 = 0;i2 < packets.length; i2++) {
129827
+ const packet = packets[i2];
129828
+ const lastPacket = i2 === packets.length - 1;
129829
+ encodePacket(packet, this.supportsBinary, (data) => {
129830
+ try {
129831
+ this.doWrite(packet, data);
129832
+ } catch (e) {
129833
+ debug5("websocket closed before onclose event");
129834
+ }
129835
+ if (lastPacket) {
129836
+ nextTick(() => {
129837
+ this.writable = true;
129838
+ this.emitReserved("drain");
129839
+ }, this.setTimeoutFn);
129840
+ }
129841
+ });
129842
+ }
129843
+ }
129844
+ doClose() {
129845
+ if (typeof this.ws !== "undefined") {
129846
+ this.ws.onerror = () => {};
129847
+ this.ws.close();
129848
+ this.ws = null;
129849
+ }
129850
+ }
129851
+ uri() {
129852
+ const schema = this.opts.secure ? "wss" : "ws";
129853
+ const query = this.query || {};
129854
+ if (this.opts.timestampRequests) {
129855
+ query[this.opts.timestampParam] = randomString2();
129856
+ }
129857
+ if (!this.supportsBinary) {
129858
+ query.b64 = 1;
129859
+ }
129860
+ return this.createUri(schema, query);
129861
+ }
129862
+ };
129863
+ WebSocketCtor = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
129864
+ });
129865
+
129866
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js
129867
+ var WS;
129868
+ var init_websocket_node = __esm(() => {
129869
+ init_wrapper2();
129870
+ init_websocket();
129871
+ WS = class WS extends BaseWS {
129872
+ createSocket(uri, protocols, opts) {
129873
+ var _a4;
129874
+ if ((_a4 = this.socket) === null || _a4 === undefined ? undefined : _a4._cookieJar) {
129875
+ opts.headers = opts.headers || {};
129876
+ opts.headers.cookie = typeof opts.headers.cookie === "string" ? [opts.headers.cookie] : opts.headers.cookie || [];
129877
+ for (const [name, cookie] of this.socket._cookieJar.cookies) {
129878
+ opts.headers.cookie.push(`${name}=${cookie.value}`);
129879
+ }
129880
+ }
129881
+ return new import_websocket2.default(uri, protocols, opts);
129882
+ }
129883
+ doWrite(packet, data) {
129884
+ const opts = {};
129885
+ if (packet.options) {
129886
+ opts.compress = packet.options.compress;
129887
+ }
129888
+ if (this.opts.perMessageDeflate) {
129889
+ const len2 = typeof data === "string" ? Buffer.byteLength(data) : data.length;
129890
+ if (len2 < this.opts.perMessageDeflate.threshold) {
129891
+ opts.compress = false;
129892
+ }
129893
+ }
129894
+ this.ws.send(data, opts);
129895
+ }
129896
+ };
129897
+ });
129898
+
129899
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js
129900
+ var import_debug6, debug6, WT;
129901
+ var init_webtransport = __esm(() => {
129902
+ init_transport2();
129903
+ init_globals_node();
129904
+ init_esm2();
129905
+ import_debug6 = __toESM(require_src2(), 1);
129906
+ debug6 = import_debug6.default("engine.io-client:webtransport");
129907
+ WT = class WT extends Transport {
129908
+ get name() {
129909
+ return "webtransport";
129910
+ }
129911
+ doOpen() {
129912
+ try {
129913
+ this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
129914
+ } catch (err) {
129915
+ return this.emitReserved("error", err);
129916
+ }
129917
+ this._transport.closed.then(() => {
129918
+ debug6("transport closed gracefully");
129919
+ this.onClose();
129920
+ }).catch((err) => {
129921
+ debug6("transport closed due to %s", err);
129922
+ this.onError("webtransport error", err);
129923
+ });
129924
+ this._transport.ready.then(() => {
129925
+ this._transport.createBidirectionalStream().then((stream4) => {
129926
+ const decoderStream = createPacketDecoderStream(Number.MAX_SAFE_INTEGER, this.socket.binaryType);
129927
+ const reader = stream4.readable.pipeThrough(decoderStream).getReader();
129928
+ const encoderStream = createPacketEncoderStream();
129929
+ encoderStream.readable.pipeTo(stream4.writable);
129930
+ this._writer = encoderStream.writable.getWriter();
129931
+ const read = () => {
129932
+ reader.read().then(({ done: done9, value: value2 }) => {
129933
+ if (done9) {
129934
+ debug6("session is closed");
129935
+ return;
129936
+ }
129937
+ debug6("received chunk: %o", value2);
129938
+ this.onPacket(value2);
129939
+ read();
129940
+ }).catch((err) => {
129941
+ debug6("an error occurred while reading: %s", err);
129942
+ });
129943
+ };
129944
+ read();
129945
+ const packet = { type: "open" };
129946
+ if (this.query.sid) {
129947
+ packet.data = `{"sid":"${this.query.sid}"}`;
129948
+ }
129949
+ this._writer.write(packet).then(() => this.onOpen());
129950
+ });
129951
+ });
129952
+ }
129953
+ write(packets) {
129954
+ this.writable = false;
129955
+ for (let i2 = 0;i2 < packets.length; i2++) {
129956
+ const packet = packets[i2];
129957
+ const lastPacket = i2 === packets.length - 1;
129958
+ this._writer.write(packet).then(() => {
129959
+ if (lastPacket) {
129960
+ nextTick(() => {
129961
+ this.writable = true;
129962
+ this.emitReserved("drain");
129963
+ }, this.setTimeoutFn);
129964
+ }
129965
+ });
129966
+ }
129967
+ }
129968
+ doClose() {
129969
+ var _a4;
129970
+ (_a4 = this._transport) === null || _a4 === undefined || _a4.close();
129971
+ }
129972
+ };
129973
+ });
129974
+
129975
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/index.js
129976
+ var transports;
129977
+ var init_transports = __esm(() => {
129978
+ init_polling_xhr_node();
129979
+ init_websocket_node();
129980
+ init_webtransport();
129981
+ transports = {
129982
+ websocket: WS,
129983
+ webtransport: WT,
129984
+ polling: XHR
129985
+ };
129986
+ });
129987
+
129988
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js
129989
+ function parse9(str) {
129990
+ if (str.length > 8000) {
129991
+ throw "URI too long";
129992
+ }
129993
+ const src = str, b = str.indexOf("["), e = str.indexOf("]");
129994
+ if (b != -1 && e != -1) {
129995
+ str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ";") + str.substring(e, str.length);
129996
+ }
129997
+ let m = re.exec(str || ""), uri = {}, i2 = 14;
129998
+ while (i2--) {
129999
+ uri[parts2[i2]] = m[i2] || "";
130000
+ }
130001
+ if (b != -1 && e != -1) {
130002
+ uri.source = src;
130003
+ uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ":");
130004
+ uri.authority = uri.authority.replace("[", "").replace("]", "").replace(/;/g, ":");
130005
+ uri.ipv6uri = true;
130006
+ }
130007
+ uri.pathNames = pathNames(uri, uri["path"]);
130008
+ uri.queryKey = queryKey(uri, uri["query"]);
130009
+ return uri;
130010
+ }
130011
+ function pathNames(obj, path8) {
130012
+ const regx = /\/{2,9}/g, names = path8.replace(regx, "/").split("/");
130013
+ if (path8.slice(0, 1) == "/" || path8.length === 0) {
130014
+ names.splice(0, 1);
130015
+ }
130016
+ if (path8.slice(-1) == "/") {
130017
+ names.splice(names.length - 1, 1);
130018
+ }
130019
+ return names;
130020
+ }
130021
+ function queryKey(uri, query) {
130022
+ const data = {};
130023
+ query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function($0, $1, $2) {
130024
+ if ($1) {
130025
+ data[$1] = $2;
130026
+ }
130027
+ });
130028
+ return data;
130029
+ }
130030
+ var re, parts2;
130031
+ var init_parseuri = __esm(() => {
130032
+ re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
130033
+ parts2 = [
130034
+ "source",
130035
+ "protocol",
130036
+ "authority",
130037
+ "userInfo",
130038
+ "user",
130039
+ "password",
130040
+ "host",
130041
+ "port",
130042
+ "relative",
130043
+ "path",
130044
+ "directory",
130045
+ "file",
130046
+ "query",
130047
+ "anchor"
130048
+ ];
130049
+ });
130050
+
130051
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/socket.js
130052
+ var import_component_emitter3, import_debug7, debug7, withEventListeners, OFFLINE_EVENT_LISTENERS, SocketWithoutUpgrade, SocketWithUpgrade, Socket2;
130053
+ var init_socket = __esm(() => {
130054
+ init_transports();
130055
+ init_util3();
130056
+ init_parseuri();
130057
+ init_esm2();
130058
+ init_globals_node();
130059
+ import_component_emitter3 = __toESM(require_cjs2(), 1);
130060
+ import_debug7 = __toESM(require_src2(), 1);
130061
+ debug7 = import_debug7.default("engine.io-client:socket");
130062
+ withEventListeners = typeof addEventListener === "function" && typeof removeEventListener === "function";
130063
+ OFFLINE_EVENT_LISTENERS = [];
130064
+ if (withEventListeners) {
130065
+ addEventListener("offline", () => {
130066
+ debug7("closing %d connection(s) because the network was lost", OFFLINE_EVENT_LISTENERS.length);
130067
+ OFFLINE_EVENT_LISTENERS.forEach((listener) => listener());
130068
+ }, false);
130069
+ }
130070
+ SocketWithoutUpgrade = class SocketWithoutUpgrade extends import_component_emitter3.Emitter {
130071
+ constructor(uri, opts) {
130072
+ super();
130073
+ this.binaryType = defaultBinaryType;
130074
+ this.writeBuffer = [];
130075
+ this._prevBufferLen = 0;
130076
+ this._pingInterval = -1;
130077
+ this._pingTimeout = -1;
130078
+ this._maxPayload = -1;
130079
+ this._pingTimeoutTime = Infinity;
130080
+ if (uri && typeof uri === "object") {
130081
+ opts = uri;
130082
+ uri = null;
130083
+ }
130084
+ if (uri) {
130085
+ const parsedUri = parse9(uri);
130086
+ opts.hostname = parsedUri.host;
130087
+ opts.secure = parsedUri.protocol === "https" || parsedUri.protocol === "wss";
130088
+ opts.port = parsedUri.port;
130089
+ if (parsedUri.query)
130090
+ opts.query = parsedUri.query;
130091
+ } else if (opts.host) {
130092
+ opts.hostname = parse9(opts.host).host;
130093
+ }
130094
+ installTimerFunctions(this, opts);
130095
+ this.secure = opts.secure != null ? opts.secure : typeof location !== "undefined" && location.protocol === "https:";
130096
+ if (opts.hostname && !opts.port) {
130097
+ opts.port = this.secure ? "443" : "80";
130098
+ }
130099
+ this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
130100
+ this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : this.secure ? "443" : "80");
130101
+ this.transports = [];
130102
+ this._transportsByName = {};
130103
+ opts.transports.forEach((t) => {
130104
+ const transportName = t.prototype.name;
130105
+ this.transports.push(transportName);
130106
+ this._transportsByName[transportName] = t;
130107
+ });
130108
+ this.opts = Object.assign({
130109
+ path: "/engine.io",
130110
+ agent: false,
130111
+ withCredentials: false,
130112
+ upgrade: true,
130113
+ timestampParam: "t",
130114
+ rememberUpgrade: false,
130115
+ addTrailingSlash: true,
130116
+ rejectUnauthorized: true,
130117
+ perMessageDeflate: {
130118
+ threshold: 1024
130119
+ },
130120
+ transportOptions: {},
130121
+ closeOnBeforeunload: false
130122
+ }, opts);
130123
+ this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : "");
130124
+ if (typeof this.opts.query === "string") {
130125
+ this.opts.query = decode5(this.opts.query);
130126
+ }
130127
+ if (withEventListeners) {
130128
+ if (this.opts.closeOnBeforeunload) {
130129
+ this._beforeunloadEventListener = () => {
130130
+ if (this.transport) {
130131
+ this.transport.removeAllListeners();
130132
+ this.transport.close();
130133
+ }
130134
+ };
130135
+ addEventListener("beforeunload", this._beforeunloadEventListener, false);
130136
+ }
130137
+ if (this.hostname !== "localhost") {
130138
+ debug7("adding listener for the 'offline' event");
130139
+ this._offlineEventListener = () => {
130140
+ this._onClose("transport close", {
130141
+ description: "network connection lost"
130142
+ });
130143
+ };
130144
+ OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener);
130145
+ }
130146
+ }
130147
+ if (this.opts.withCredentials) {
130148
+ this._cookieJar = createCookieJar();
130149
+ }
130150
+ this._open();
130151
+ }
130152
+ createTransport(name) {
130153
+ debug7('creating transport "%s"', name);
130154
+ const query = Object.assign({}, this.opts.query);
130155
+ query.EIO = protocol;
130156
+ query.transport = name;
130157
+ if (this.id)
130158
+ query.sid = this.id;
130159
+ const opts = Object.assign({}, this.opts, {
130160
+ query,
130161
+ socket: this,
130162
+ hostname: this.hostname,
130163
+ secure: this.secure,
130164
+ port: this.port
130165
+ }, this.opts.transportOptions[name]);
130166
+ debug7("options: %j", opts);
130167
+ return new this._transportsByName[name](opts);
130168
+ }
130169
+ _open() {
130170
+ if (this.transports.length === 0) {
130171
+ this.setTimeoutFn(() => {
130172
+ this.emitReserved("error", "No transports available");
130173
+ }, 0);
130174
+ return;
130175
+ }
130176
+ const transportName = this.opts.rememberUpgrade && SocketWithoutUpgrade.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
130177
+ this.readyState = "opening";
130178
+ const transport2 = this.createTransport(transportName);
130179
+ transport2.open();
130180
+ this.setTransport(transport2);
130181
+ }
130182
+ setTransport(transport2) {
130183
+ debug7("setting transport %s", transport2.name);
130184
+ if (this.transport) {
130185
+ debug7("clearing existing transport %s", this.transport.name);
130186
+ this.transport.removeAllListeners();
130187
+ }
130188
+ this.transport = transport2;
130189
+ transport2.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (reason) => this._onClose("transport close", reason));
130190
+ }
130191
+ onOpen() {
130192
+ debug7("socket open");
130193
+ this.readyState = "open";
130194
+ SocketWithoutUpgrade.priorWebsocketSuccess = this.transport.name === "websocket";
130195
+ this.emitReserved("open");
130196
+ this.flush();
130197
+ }
130198
+ _onPacket(packet) {
130199
+ if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
130200
+ debug7('socket receive: type "%s", data "%s"', packet.type, packet.data);
130201
+ this.emitReserved("packet", packet);
130202
+ this.emitReserved("heartbeat");
130203
+ switch (packet.type) {
130204
+ case "open":
130205
+ this.onHandshake(JSON.parse(packet.data));
130206
+ break;
130207
+ case "ping":
130208
+ this._sendPacket("pong");
130209
+ this.emitReserved("ping");
130210
+ this.emitReserved("pong");
130211
+ this._resetPingTimeout();
130212
+ break;
130213
+ case "error":
130214
+ const err = new Error("server error");
130215
+ err.code = packet.data;
130216
+ this._onError(err);
130217
+ break;
130218
+ case "message":
130219
+ this.emitReserved("data", packet.data);
130220
+ this.emitReserved("message", packet.data);
130221
+ break;
130222
+ }
130223
+ } else {
130224
+ debug7('packet received with socket readyState "%s"', this.readyState);
130225
+ }
130226
+ }
130227
+ onHandshake(data) {
130228
+ this.emitReserved("handshake", data);
130229
+ this.id = data.sid;
130230
+ this.transport.query.sid = data.sid;
130231
+ this._pingInterval = data.pingInterval;
130232
+ this._pingTimeout = data.pingTimeout;
130233
+ this._maxPayload = data.maxPayload;
130234
+ this.onOpen();
130235
+ if (this.readyState === "closed")
130236
+ return;
130237
+ this._resetPingTimeout();
130238
+ }
130239
+ _resetPingTimeout() {
130240
+ this.clearTimeoutFn(this._pingTimeoutTimer);
130241
+ const delay3 = this._pingInterval + this._pingTimeout;
130242
+ this._pingTimeoutTime = Date.now() + delay3;
130243
+ this._pingTimeoutTimer = this.setTimeoutFn(() => {
130244
+ this._onClose("ping timeout");
130245
+ }, delay3);
130246
+ if (this.opts.autoUnref) {
130247
+ this._pingTimeoutTimer.unref();
130248
+ }
130249
+ }
130250
+ _onDrain() {
130251
+ this.writeBuffer.splice(0, this._prevBufferLen);
130252
+ this._prevBufferLen = 0;
130253
+ if (this.writeBuffer.length === 0) {
130254
+ this.emitReserved("drain");
130255
+ } else {
130256
+ this.flush();
130257
+ }
130258
+ }
130259
+ flush() {
130260
+ if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
130261
+ const packets = this._getWritablePackets();
130262
+ debug7("flushing %d packets in socket", packets.length);
130263
+ this.transport.send(packets);
130264
+ this._prevBufferLen = packets.length;
130265
+ this.emitReserved("flush");
130266
+ }
130267
+ }
130268
+ _getWritablePackets() {
130269
+ const shouldCheckPayloadSize = this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1;
130270
+ if (!shouldCheckPayloadSize) {
130271
+ return this.writeBuffer;
130272
+ }
130273
+ let payloadSize = 1;
130274
+ for (let i2 = 0;i2 < this.writeBuffer.length; i2++) {
130275
+ const data = this.writeBuffer[i2].data;
130276
+ if (data) {
130277
+ payloadSize += byteLength2(data);
130278
+ }
130279
+ if (i2 > 0 && payloadSize > this._maxPayload) {
130280
+ debug7("only send %d out of %d packets", i2, this.writeBuffer.length);
130281
+ return this.writeBuffer.slice(0, i2);
130282
+ }
130283
+ payloadSize += 2;
130284
+ }
130285
+ debug7("payload size is %d (max: %d)", payloadSize, this._maxPayload);
130286
+ return this.writeBuffer;
130287
+ }
130288
+ _hasPingExpired() {
130289
+ if (!this._pingTimeoutTime)
130290
+ return true;
130291
+ const hasExpired = Date.now() > this._pingTimeoutTime;
130292
+ if (hasExpired) {
130293
+ debug7("throttled timer detected, scheduling connection close");
130294
+ this._pingTimeoutTime = 0;
130295
+ nextTick(() => {
130296
+ this._onClose("ping timeout");
130297
+ }, this.setTimeoutFn);
130298
+ }
130299
+ return hasExpired;
130300
+ }
130301
+ write(msg, options, fn2) {
130302
+ this._sendPacket("message", msg, options, fn2);
130303
+ return this;
130304
+ }
130305
+ send(msg, options, fn2) {
130306
+ this._sendPacket("message", msg, options, fn2);
130307
+ return this;
130308
+ }
130309
+ _sendPacket(type, data, options, fn2) {
130310
+ if (typeof data === "function") {
130311
+ fn2 = data;
130312
+ data = undefined;
130313
+ }
130314
+ if (typeof options === "function") {
130315
+ fn2 = options;
130316
+ options = null;
130317
+ }
130318
+ if (this.readyState === "closing" || this.readyState === "closed") {
130319
+ return;
130320
+ }
130321
+ options = options || {};
130322
+ options.compress = options.compress !== false;
130323
+ const packet = {
130324
+ type,
130325
+ data,
130326
+ options
130327
+ };
130328
+ this.emitReserved("packetCreate", packet);
130329
+ this.writeBuffer.push(packet);
130330
+ if (fn2)
130331
+ this.once("flush", fn2);
130332
+ this.flush();
130333
+ }
130334
+ close() {
130335
+ const close2 = () => {
130336
+ this._onClose("forced close");
130337
+ debug7("socket closing - telling transport to close");
130338
+ this.transport.close();
130339
+ };
130340
+ const cleanupAndClose = () => {
130341
+ this.off("upgrade", cleanupAndClose);
130342
+ this.off("upgradeError", cleanupAndClose);
130343
+ close2();
130344
+ };
130345
+ const waitForUpgrade = () => {
130346
+ this.once("upgrade", cleanupAndClose);
130347
+ this.once("upgradeError", cleanupAndClose);
130348
+ };
130349
+ if (this.readyState === "opening" || this.readyState === "open") {
130350
+ this.readyState = "closing";
130351
+ if (this.writeBuffer.length) {
130352
+ this.once("drain", () => {
130353
+ if (this.upgrading) {
130354
+ waitForUpgrade();
130355
+ } else {
130356
+ close2();
130357
+ }
130358
+ });
130359
+ } else if (this.upgrading) {
130360
+ waitForUpgrade();
130361
+ } else {
130362
+ close2();
130363
+ }
130364
+ }
130365
+ return this;
130366
+ }
130367
+ _onError(err) {
130368
+ debug7("socket error %j", err);
130369
+ SocketWithoutUpgrade.priorWebsocketSuccess = false;
130370
+ if (this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening") {
130371
+ debug7("trying next transport");
130372
+ this.transports.shift();
130373
+ return this._open();
130374
+ }
130375
+ this.emitReserved("error", err);
130376
+ this._onClose("transport error", err);
130377
+ }
130378
+ _onClose(reason, description) {
130379
+ if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
130380
+ debug7('socket close with reason: "%s"', reason);
130381
+ this.clearTimeoutFn(this._pingTimeoutTimer);
130382
+ this.transport.removeAllListeners("close");
130383
+ this.transport.close();
130384
+ this.transport.removeAllListeners();
130385
+ if (withEventListeners) {
130386
+ if (this._beforeunloadEventListener) {
130387
+ removeEventListener("beforeunload", this._beforeunloadEventListener, false);
130388
+ }
130389
+ if (this._offlineEventListener) {
130390
+ const i2 = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener);
130391
+ if (i2 !== -1) {
130392
+ debug7("removing listener for the 'offline' event");
130393
+ OFFLINE_EVENT_LISTENERS.splice(i2, 1);
130394
+ }
130395
+ }
130396
+ }
130397
+ this.readyState = "closed";
130398
+ this.id = null;
130399
+ this.emitReserved("close", reason, description);
130400
+ this.writeBuffer = [];
130401
+ this._prevBufferLen = 0;
130402
+ }
130403
+ }
130404
+ };
130405
+ SocketWithoutUpgrade.protocol = protocol;
130406
+ SocketWithUpgrade = class SocketWithUpgrade extends SocketWithoutUpgrade {
130407
+ constructor() {
130408
+ super(...arguments);
130409
+ this._upgrades = [];
130410
+ }
130411
+ onOpen() {
130412
+ super.onOpen();
130413
+ if (this.readyState === "open" && this.opts.upgrade) {
130414
+ debug7("starting upgrade probes");
130415
+ for (let i2 = 0;i2 < this._upgrades.length; i2++) {
130416
+ this._probe(this._upgrades[i2]);
130417
+ }
130418
+ }
130419
+ }
130420
+ _probe(name) {
130421
+ debug7('probing transport "%s"', name);
130422
+ let transport2 = this.createTransport(name);
130423
+ let failed = false;
130424
+ SocketWithoutUpgrade.priorWebsocketSuccess = false;
130425
+ const onTransportOpen = () => {
130426
+ if (failed)
130427
+ return;
130428
+ debug7('probe transport "%s" opened', name);
130429
+ transport2.send([{ type: "ping", data: "probe" }]);
130430
+ transport2.once("packet", (msg) => {
130431
+ if (failed)
130432
+ return;
130433
+ if (msg.type === "pong" && msg.data === "probe") {
130434
+ debug7('probe transport "%s" pong', name);
130435
+ this.upgrading = true;
130436
+ this.emitReserved("upgrading", transport2);
130437
+ if (!transport2)
130438
+ return;
130439
+ SocketWithoutUpgrade.priorWebsocketSuccess = transport2.name === "websocket";
130440
+ debug7('pausing current transport "%s"', this.transport.name);
130441
+ this.transport.pause(() => {
130442
+ if (failed)
130443
+ return;
130444
+ if (this.readyState === "closed")
130445
+ return;
130446
+ debug7("changing transport and sending upgrade packet");
130447
+ cleanup();
130448
+ this.setTransport(transport2);
130449
+ transport2.send([{ type: "upgrade" }]);
130450
+ this.emitReserved("upgrade", transport2);
130451
+ transport2 = null;
130452
+ this.upgrading = false;
130453
+ this.flush();
130454
+ });
130455
+ } else {
130456
+ debug7('probe transport "%s" failed', name);
130457
+ const err = new Error("probe error");
130458
+ err.transport = transport2.name;
130459
+ this.emitReserved("upgradeError", err);
130460
+ }
130461
+ });
130462
+ };
130463
+ function freezeTransport() {
130464
+ if (failed)
130465
+ return;
130466
+ failed = true;
130467
+ cleanup();
130468
+ transport2.close();
130469
+ transport2 = null;
130470
+ }
130471
+ const onerror = (err) => {
130472
+ const error51 = new Error("probe error: " + err);
130473
+ error51.transport = transport2.name;
130474
+ freezeTransport();
130475
+ debug7('probe transport "%s" failed because of error: %s', name, err);
130476
+ this.emitReserved("upgradeError", error51);
130477
+ };
130478
+ function onTransportClose() {
130479
+ onerror("transport closed");
130480
+ }
130481
+ function onclose() {
130482
+ onerror("socket closed");
130483
+ }
130484
+ function onupgrade(to) {
130485
+ if (transport2 && to.name !== transport2.name) {
130486
+ debug7('"%s" works - aborting "%s"', to.name, transport2.name);
130487
+ freezeTransport();
130488
+ }
130489
+ }
130490
+ const cleanup = () => {
130491
+ transport2.removeListener("open", onTransportOpen);
130492
+ transport2.removeListener("error", onerror);
130493
+ transport2.removeListener("close", onTransportClose);
130494
+ this.off("close", onclose);
130495
+ this.off("upgrading", onupgrade);
130496
+ };
130497
+ transport2.once("open", onTransportOpen);
130498
+ transport2.once("error", onerror);
130499
+ transport2.once("close", onTransportClose);
130500
+ this.once("close", onclose);
130501
+ this.once("upgrading", onupgrade);
130502
+ if (this._upgrades.indexOf("webtransport") !== -1 && name !== "webtransport") {
130503
+ this.setTimeoutFn(() => {
130504
+ if (!failed) {
130505
+ transport2.open();
130506
+ }
130507
+ }, 200);
130508
+ } else {
130509
+ transport2.open();
130510
+ }
130511
+ }
130512
+ onHandshake(data) {
130513
+ this._upgrades = this._filterUpgrades(data.upgrades);
130514
+ super.onHandshake(data);
130515
+ }
130516
+ _filterUpgrades(upgrades) {
130517
+ const filteredUpgrades = [];
130518
+ for (let i2 = 0;i2 < upgrades.length; i2++) {
130519
+ if (~this.transports.indexOf(upgrades[i2]))
130520
+ filteredUpgrades.push(upgrades[i2]);
130521
+ }
130522
+ return filteredUpgrades;
130523
+ }
130524
+ };
130525
+ Socket2 = class Socket2 extends SocketWithUpgrade {
130526
+ constructor(uri, opts = {}) {
130527
+ const isOptionsOnly = typeof uri === "object";
130528
+ const o = isOptionsOnly ? { ...uri } : { ...opts };
130529
+ if (!o.transports || o.transports && typeof o.transports[0] === "string") {
130530
+ o.transports = (o.transports || ["polling", "websocket", "webtransport"]).map((transportName) => transports[transportName]).filter((t) => !!t);
130531
+ }
130532
+ super(isOptionsOnly ? o : uri, o);
130533
+ }
130534
+ };
130535
+ });
130536
+
130537
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js
130538
+ var init_polling_fetch = __esm(() => {
130539
+ init_polling();
130540
+ });
130541
+
130542
+ // ../../node_modules/.pnpm/engine.io-client@6.6.6/node_modules/engine.io-client/build/esm-debug/index.js
130543
+ var protocol2;
130544
+ var init_esm_debug = __esm(() => {
130545
+ init_socket();
130546
+ init_socket();
130547
+ init_transport2();
130548
+ init_transports();
130549
+ init_util3();
130550
+ init_parseuri();
130551
+ init_globals_node();
130552
+ init_polling_fetch();
130553
+ init_polling_xhr_node();
130554
+ init_polling_xhr();
130555
+ init_websocket_node();
130556
+ init_websocket();
130557
+ init_webtransport();
130558
+ protocol2 = Socket2.protocol;
130559
+ });
130560
+
130561
+ // ../../node_modules/.pnpm/socket.io-client@4.8.3/node_modules/socket.io-client/build/esm-debug/url.js
130562
+ function url3(uri, path8 = "", loc) {
130563
+ let obj = uri;
130564
+ loc = loc || typeof location !== "undefined" && location;
130565
+ if (uri == null)
130566
+ uri = loc.protocol + "//" + loc.host;
130567
+ if (typeof uri === "string") {
130568
+ if (uri.charAt(0) === "/") {
130569
+ if (uri.charAt(1) === "/") {
130570
+ uri = loc.protocol + uri;
130571
+ } else {
130572
+ uri = loc.host + uri;
130573
+ }
130574
+ }
130575
+ if (!/^(https?|wss?):\/\//.test(uri)) {
130576
+ debug8("protocol-less url %s", uri);
130577
+ if (typeof loc !== "undefined") {
130578
+ uri = loc.protocol + "//" + uri;
130579
+ } else {
130580
+ uri = "https://" + uri;
130581
+ }
130582
+ }
130583
+ debug8("parse %s", uri);
130584
+ obj = parse9(uri);
130585
+ }
130586
+ if (!obj.port) {
130587
+ if (/^(http|ws)$/.test(obj.protocol)) {
130588
+ obj.port = "80";
130589
+ } else if (/^(http|ws)s$/.test(obj.protocol)) {
130590
+ obj.port = "443";
130591
+ }
130592
+ }
130593
+ obj.path = obj.path || "/";
130594
+ const ipv63 = obj.host.indexOf(":") !== -1;
130595
+ const host = ipv63 ? "[" + obj.host + "]" : obj.host;
130596
+ obj.id = obj.protocol + "://" + host + ":" + obj.port + path8;
130597
+ obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
130598
+ return obj;
130599
+ }
130600
+ var import_debug8, debug8;
130601
+ var init_url = __esm(() => {
130602
+ init_esm_debug();
130603
+ import_debug8 = __toESM(require_src2(), 1);
130604
+ debug8 = import_debug8.default("socket.io-client:url");
130605
+ });
130606
+
130607
+ // ../../node_modules/.pnpm/socket.io-parser@4.2.7/node_modules/socket.io-parser/build/esm-debug/is-binary.js
130608
+ function isBinary(obj) {
130609
+ return withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj)) || withNativeBlob && obj instanceof Blob || withNativeFile && obj instanceof File;
130610
+ }
130611
+ function hasBinary(obj, toJSON2) {
130612
+ if (!obj || typeof obj !== "object") {
130613
+ return false;
130614
+ }
130615
+ if (Array.isArray(obj)) {
130616
+ for (let i2 = 0, l = obj.length;i2 < l; i2++) {
130617
+ if (hasBinary(obj[i2])) {
130618
+ return true;
130619
+ }
130620
+ }
130621
+ return false;
130622
+ }
130623
+ if (isBinary(obj)) {
130624
+ return true;
130625
+ }
130626
+ if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) {
130627
+ return hasBinary(obj.toJSON(), true);
130628
+ }
130629
+ for (const key in obj) {
130630
+ if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
130631
+ return true;
130632
+ }
130633
+ }
130634
+ return false;
130635
+ }
130636
+ var withNativeArrayBuffer, isView = (obj) => {
130637
+ return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj.buffer instanceof ArrayBuffer;
130638
+ }, toString3, withNativeBlob, withNativeFile;
130639
+ var init_is_binary = __esm(() => {
130640
+ withNativeArrayBuffer = typeof ArrayBuffer === "function";
130641
+ toString3 = Object.prototype.toString;
130642
+ withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && toString3.call(Blob) === "[object BlobConstructor]";
130643
+ withNativeFile = typeof File === "function" || typeof File !== "undefined" && toString3.call(File) === "[object FileConstructor]";
130644
+ });
130645
+
130646
+ // ../../node_modules/.pnpm/socket.io-parser@4.2.7/node_modules/socket.io-parser/build/esm-debug/binary.js
130647
+ function deconstructPacket(packet) {
130648
+ const buffers = [];
130649
+ const packetData = packet.data;
130650
+ const pack2 = packet;
130651
+ pack2.data = _deconstructPacket(packetData, buffers);
130652
+ pack2.attachments = buffers.length;
130653
+ return { packet: pack2, buffers };
130654
+ }
130655
+ function _deconstructPacket(data, buffers, toJSON2) {
130656
+ if (!data)
130657
+ return data;
130658
+ if (isBinary(data)) {
130659
+ const placeholder = { _placeholder: true, num: buffers.length };
130660
+ buffers.push(data);
130661
+ return placeholder;
130662
+ } else if (Array.isArray(data)) {
130663
+ const newData = new Array(data.length);
130664
+ for (let i2 = 0;i2 < data.length; i2++) {
130665
+ newData[i2] = _deconstructPacket(data[i2], buffers);
130666
+ }
130667
+ return newData;
130668
+ } else if (typeof data === "object" && !(data instanceof Date)) {
130669
+ if (data.toJSON && typeof data.toJSON === "function" && !toJSON2) {
130670
+ return _deconstructPacket(data.toJSON(), buffers, true);
130671
+ }
130672
+ const newData = {};
130673
+ for (const key in data) {
130674
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
130675
+ newData[key] = _deconstructPacket(data[key], buffers);
130676
+ }
130677
+ }
130678
+ return newData;
130679
+ }
130680
+ return data;
130681
+ }
130682
+ function reconstructPacket(packet, buffers) {
130683
+ packet.data = _reconstructPacket(packet.data, buffers);
130684
+ delete packet.attachments;
130685
+ return packet;
130686
+ }
130687
+ function _reconstructPacket(data, buffers) {
130688
+ if (!data)
130689
+ return data;
130690
+ if (data && data._placeholder === true) {
130691
+ const isIndexValid = typeof data.num === "number" && data.num >= 0 && data.num < buffers.length;
130692
+ if (isIndexValid) {
130693
+ return buffers[data.num];
130694
+ } else {
130695
+ throw new Error("illegal attachments");
130696
+ }
130697
+ } else if (Array.isArray(data)) {
130698
+ for (let i2 = 0;i2 < data.length; i2++) {
130699
+ data[i2] = _reconstructPacket(data[i2], buffers);
130700
+ }
130701
+ } else if (typeof data === "object") {
130702
+ for (const key in data) {
130703
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
130704
+ data[key] = _reconstructPacket(data[key], buffers);
130705
+ }
130706
+ }
130707
+ }
130708
+ return data;
130709
+ }
130710
+ var init_binary = __esm(() => {
130711
+ init_is_binary();
130712
+ });
130713
+
130714
+ // ../../node_modules/.pnpm/socket.io-parser@4.2.7/node_modules/socket.io-parser/build/esm-debug/index.js
130715
+ var exports_esm_debug = {};
130716
+ __export(exports_esm_debug, {
130717
+ protocol: () => protocol3,
130718
+ isPacketValid: () => isPacketValid,
130719
+ PacketType: () => PacketType,
130720
+ Encoder: () => Encoder,
130721
+ Decoder: () => Decoder
130722
+ });
130723
+
130724
+ class Encoder {
130725
+ constructor(replacer) {
130726
+ this.replacer = replacer;
130727
+ }
130728
+ encode(obj) {
130729
+ debug9("encoding packet %j", obj);
130730
+ if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
130731
+ if (hasBinary(obj)) {
130732
+ return this.encodeAsBinary({
130733
+ type: obj.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK,
130734
+ nsp: obj.nsp,
130735
+ data: obj.data,
130736
+ id: obj.id
130737
+ });
130738
+ }
130739
+ }
130740
+ return [this.encodeAsString(obj)];
130741
+ }
130742
+ encodeAsString(obj) {
130743
+ let str = "" + obj.type;
130744
+ if (obj.type === PacketType.BINARY_EVENT || obj.type === PacketType.BINARY_ACK) {
130745
+ str += obj.attachments + "-";
130746
+ }
130747
+ if (obj.nsp && obj.nsp !== "/") {
130748
+ str += obj.nsp + ",";
130749
+ }
130750
+ if (obj.id != null) {
130751
+ str += obj.id;
130752
+ }
130753
+ if (obj.data != null) {
130754
+ str += JSON.stringify(obj.data, this.replacer);
130755
+ }
130756
+ debug9("encoded %j as %s", obj, str);
130757
+ return str;
130758
+ }
130759
+ encodeAsBinary(obj) {
130760
+ const deconstruction = deconstructPacket(obj);
130761
+ const pack2 = this.encodeAsString(deconstruction.packet);
130762
+ const buffers = deconstruction.buffers;
130763
+ buffers.unshift(pack2);
130764
+ return buffers;
130765
+ }
130766
+ }
130767
+
130768
+ class BinaryReconstructor {
130769
+ constructor(packet) {
130770
+ this.packet = packet;
130771
+ this.buffers = [];
130772
+ this.reconPack = packet;
130773
+ }
130774
+ takeBinaryData(binData) {
130775
+ this.buffers.push(binData);
130776
+ if (this.buffers.length === this.reconPack.attachments) {
130777
+ const packet = reconstructPacket(this.reconPack, this.buffers);
130778
+ this.finishedReconstruction();
130779
+ return packet;
130780
+ }
130781
+ return null;
130782
+ }
130783
+ finishedReconstruction() {
130784
+ this.reconPack = null;
130785
+ this.buffers = [];
130786
+ }
130787
+ }
130788
+ function isNamespaceValid(nsp) {
130789
+ return typeof nsp === "string";
130790
+ }
130791
+ function isAckIdValid(id3) {
130792
+ return id3 === undefined || isInteger(id3);
130793
+ }
130794
+ function isObject4(value2) {
130795
+ return Object.prototype.toString.call(value2) === "[object Object]";
130796
+ }
130797
+ function isDataValid(type, payload) {
130798
+ switch (type) {
130799
+ case PacketType.CONNECT:
130800
+ return payload === undefined || isObject4(payload);
130801
+ case PacketType.DISCONNECT:
130802
+ return payload === undefined;
130803
+ case PacketType.EVENT:
130804
+ return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS.indexOf(payload[0]) === -1);
130805
+ case PacketType.ACK:
130806
+ return Array.isArray(payload);
130807
+ case PacketType.CONNECT_ERROR:
130808
+ return typeof payload === "string" || isObject4(payload);
130809
+ default:
130810
+ return false;
130811
+ }
130812
+ }
130813
+ function isPacketValid(packet) {
130814
+ return isNamespaceValid(packet.nsp) && isAckIdValid(packet.id) && isDataValid(packet.type, packet.data);
130815
+ }
130816
+ var import_component_emitter4, import_debug9, debug9, RESERVED_EVENTS, protocol3 = 5, PacketType, Decoder, isInteger;
130817
+ var init_esm_debug2 = __esm(() => {
130818
+ init_binary();
130819
+ init_is_binary();
130820
+ import_component_emitter4 = __toESM(require_cjs2(), 1);
130821
+ import_debug9 = __toESM(require_src2(), 1);
130822
+ debug9 = import_debug9.default("socket.io-parser");
130823
+ RESERVED_EVENTS = [
130824
+ "connect",
130825
+ "connect_error",
130826
+ "disconnect",
130827
+ "disconnecting",
130828
+ "newListener",
130829
+ "removeListener"
130830
+ ];
130831
+ (function(PacketType2) {
130832
+ PacketType2[PacketType2["CONNECT"] = 0] = "CONNECT";
130833
+ PacketType2[PacketType2["DISCONNECT"] = 1] = "DISCONNECT";
130834
+ PacketType2[PacketType2["EVENT"] = 2] = "EVENT";
130835
+ PacketType2[PacketType2["ACK"] = 3] = "ACK";
130836
+ PacketType2[PacketType2["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
130837
+ PacketType2[PacketType2["BINARY_EVENT"] = 5] = "BINARY_EVENT";
130838
+ PacketType2[PacketType2["BINARY_ACK"] = 6] = "BINARY_ACK";
130839
+ })(PacketType || (PacketType = {}));
130840
+ Decoder = class Decoder extends import_component_emitter4.Emitter {
130841
+ constructor(opts) {
130842
+ super();
130843
+ this.opts = Object.assign({
130844
+ reviver: undefined,
130845
+ maxAttachments: 10
130846
+ }, typeof opts === "function" ? { reviver: opts } : opts);
130847
+ }
130848
+ add(obj) {
130849
+ let packet;
130850
+ if (typeof obj === "string") {
130851
+ if (this.reconstructor) {
130852
+ throw new Error("got plaintext data when reconstructing a packet");
130853
+ }
130854
+ packet = this.decodeString(obj);
130855
+ const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
130856
+ if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
130857
+ packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
130858
+ this.reconstructor = new BinaryReconstructor(packet);
130859
+ } else {
130860
+ super.emitReserved("decoded", packet);
130861
+ }
130862
+ } else if (isBinary(obj) || obj.base64) {
130863
+ if (!this.reconstructor) {
130864
+ throw new Error("got binary data when not reconstructing a packet");
130865
+ } else {
130866
+ packet = this.reconstructor.takeBinaryData(obj);
130867
+ if (packet) {
130868
+ this.reconstructor = null;
130869
+ super.emitReserved("decoded", packet);
130870
+ }
130871
+ }
130872
+ } else {
130873
+ throw new Error("Unknown type: " + obj);
130874
+ }
130875
+ }
130876
+ decodeString(str) {
130877
+ let i2 = 0;
130878
+ const p = {
130879
+ type: Number(str.charAt(0))
130880
+ };
130881
+ if (PacketType[p.type] === undefined) {
130882
+ throw new Error("unknown packet type " + p.type);
130883
+ }
130884
+ if (p.type === PacketType.BINARY_EVENT || p.type === PacketType.BINARY_ACK) {
130885
+ const start3 = i2 + 1;
130886
+ while (str.charAt(++i2) !== "-" && i2 != str.length) {}
130887
+ const buf = str.substring(start3, i2);
130888
+ if (buf != Number(buf) || str.charAt(i2) !== "-") {
130889
+ throw new Error("Illegal attachments");
130890
+ }
130891
+ const n = Number(buf);
130892
+ if (!isInteger(n) || n < 1) {
130893
+ throw new Error("Illegal attachments");
130894
+ } else if (n > this.opts.maxAttachments) {
130895
+ throw new Error("too many attachments");
130896
+ }
130897
+ p.attachments = n;
130898
+ }
130899
+ if (str.charAt(i2 + 1) === "/") {
130900
+ const start3 = i2 + 1;
130901
+ while (++i2) {
130902
+ const c = str.charAt(i2);
130903
+ if (c === ",")
130904
+ break;
130905
+ if (i2 === str.length)
130906
+ break;
130907
+ }
130908
+ p.nsp = str.substring(start3, i2);
130909
+ } else {
130910
+ p.nsp = "/";
130911
+ }
130912
+ const next4 = str.charAt(i2 + 1);
130913
+ if (next4 !== "" && Number(next4) == next4) {
130914
+ const start3 = i2 + 1;
130915
+ while (++i2) {
130916
+ const c = str.charAt(i2);
130917
+ if (c == null || Number(c) != c) {
130918
+ --i2;
130919
+ break;
130920
+ }
130921
+ if (i2 === str.length)
130922
+ break;
130923
+ }
130924
+ p.id = Number(str.substring(start3, i2 + 1));
130925
+ }
130926
+ if (str.charAt(++i2)) {
130927
+ const payload = this.tryParse(str.substr(i2));
130928
+ if (Decoder.isPayloadValid(p.type, payload)) {
130929
+ p.data = payload;
130930
+ } else {
130931
+ throw new Error("invalid payload");
130932
+ }
130933
+ }
130934
+ debug9("decoded %s as %j", str, p);
130935
+ return p;
130936
+ }
130937
+ tryParse(str) {
130938
+ try {
130939
+ return JSON.parse(str, this.opts.reviver);
130940
+ } catch (e) {
130941
+ return false;
130942
+ }
130943
+ }
130944
+ static isPayloadValid(type, payload) {
130945
+ switch (type) {
130946
+ case PacketType.CONNECT:
130947
+ return isObject4(payload);
130948
+ case PacketType.DISCONNECT:
130949
+ return payload === undefined;
130950
+ case PacketType.CONNECT_ERROR:
130951
+ return typeof payload === "string" || isObject4(payload);
130952
+ case PacketType.EVENT:
130953
+ case PacketType.BINARY_EVENT:
130954
+ return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS.indexOf(payload[0]) === -1);
130955
+ case PacketType.ACK:
130956
+ case PacketType.BINARY_ACK:
130957
+ return Array.isArray(payload);
130958
+ }
130959
+ }
130960
+ destroy() {
130961
+ if (this.reconstructor) {
130962
+ this.reconstructor.finishedReconstruction();
130963
+ this.reconstructor = null;
130964
+ }
130965
+ }
130966
+ };
130967
+ isInteger = Number.isInteger || function(value2) {
130968
+ return typeof value2 === "number" && isFinite(value2) && Math.floor(value2) === value2;
130969
+ };
130970
+ });
130971
+
130972
+ // ../../node_modules/.pnpm/socket.io-client@4.8.3/node_modules/socket.io-client/build/esm-debug/on.js
130973
+ function on(obj, ev, fn2) {
130974
+ obj.on(ev, fn2);
130975
+ return function subDestroy() {
130976
+ obj.off(ev, fn2);
130977
+ };
130978
+ }
130979
+
130980
+ // ../../node_modules/.pnpm/socket.io-client@4.8.3/node_modules/socket.io-client/build/esm-debug/socket.js
130981
+ var import_component_emitter5, import_debug10, debug10, RESERVED_EVENTS2, Socket3;
130982
+ var init_socket2 = __esm(() => {
130983
+ init_esm_debug2();
130984
+ import_component_emitter5 = __toESM(require_cjs2(), 1);
130985
+ import_debug10 = __toESM(require_src2(), 1);
130986
+ debug10 = import_debug10.default("socket.io-client:socket");
130987
+ RESERVED_EVENTS2 = Object.freeze({
130988
+ connect: 1,
130989
+ connect_error: 1,
130990
+ disconnect: 1,
130991
+ disconnecting: 1,
130992
+ newListener: 1,
130993
+ removeListener: 1
130994
+ });
130995
+ Socket3 = class Socket3 extends import_component_emitter5.Emitter {
130996
+ constructor(io2, nsp, opts) {
130997
+ super();
130998
+ this.connected = false;
130999
+ this.recovered = false;
131000
+ this.receiveBuffer = [];
131001
+ this.sendBuffer = [];
131002
+ this._queue = [];
131003
+ this._queueSeq = 0;
131004
+ this.ids = 0;
131005
+ this.acks = {};
131006
+ this.flags = {};
131007
+ this.io = io2;
131008
+ this.nsp = nsp;
131009
+ if (opts && opts.auth) {
131010
+ this.auth = opts.auth;
131011
+ }
131012
+ this._opts = Object.assign({}, opts);
131013
+ if (this.io._autoConnect)
131014
+ this.open();
131015
+ }
131016
+ get disconnected() {
131017
+ return !this.connected;
131018
+ }
131019
+ subEvents() {
131020
+ if (this.subs)
131021
+ return;
131022
+ const io2 = this.io;
131023
+ this.subs = [
131024
+ on(io2, "open", this.onopen.bind(this)),
131025
+ on(io2, "packet", this.onpacket.bind(this)),
131026
+ on(io2, "error", this.onerror.bind(this)),
131027
+ on(io2, "close", this.onclose.bind(this))
131028
+ ];
131029
+ }
131030
+ get active() {
131031
+ return !!this.subs;
131032
+ }
131033
+ connect() {
131034
+ if (this.connected)
131035
+ return this;
131036
+ this.subEvents();
131037
+ if (!this.io["_reconnecting"])
131038
+ this.io.open();
131039
+ if (this.io._readyState === "open")
131040
+ this.onopen();
131041
+ return this;
131042
+ }
131043
+ open() {
131044
+ return this.connect();
131045
+ }
131046
+ send(...args2) {
131047
+ args2.unshift("message");
131048
+ this.emit.apply(this, args2);
131049
+ return this;
131050
+ }
131051
+ emit(ev, ...args2) {
131052
+ var _a4, _b2, _c;
131053
+ if (RESERVED_EVENTS2.hasOwnProperty(ev)) {
131054
+ throw new Error('"' + ev.toString() + '" is a reserved event name');
131055
+ }
131056
+ args2.unshift(ev);
131057
+ if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {
131058
+ this._addToQueue(args2);
131059
+ return this;
131060
+ }
131061
+ const packet = {
131062
+ type: PacketType.EVENT,
131063
+ data: args2
131064
+ };
131065
+ packet.options = {};
131066
+ packet.options.compress = this.flags.compress !== false;
131067
+ if (typeof args2[args2.length - 1] === "function") {
131068
+ const id3 = this.ids++;
131069
+ debug10("emitting packet with ack id %d", id3);
131070
+ const ack = args2.pop();
131071
+ this._registerAckCallback(id3, ack);
131072
+ packet.id = id3;
131073
+ }
131074
+ const isTransportWritable = (_b2 = (_a4 = this.io.engine) === null || _a4 === undefined ? undefined : _a4.transport) === null || _b2 === undefined ? undefined : _b2.writable;
131075
+ const isConnected = this.connected && !((_c = this.io.engine) === null || _c === undefined ? undefined : _c._hasPingExpired());
131076
+ const discardPacket = this.flags.volatile && !isTransportWritable;
131077
+ if (discardPacket) {
131078
+ debug10("discard packet as the transport is not currently writable");
131079
+ } else if (isConnected) {
131080
+ this.notifyOutgoingListeners(packet);
131081
+ this.packet(packet);
131082
+ } else {
131083
+ this.sendBuffer.push(packet);
131084
+ }
131085
+ this.flags = {};
131086
+ return this;
131087
+ }
131088
+ _registerAckCallback(id3, ack) {
131089
+ var _a4;
131090
+ const timeout3 = (_a4 = this.flags.timeout) !== null && _a4 !== undefined ? _a4 : this._opts.ackTimeout;
131091
+ if (timeout3 === undefined) {
131092
+ this.acks[id3] = ack;
131093
+ return;
131094
+ }
131095
+ const timer = this.io.setTimeoutFn(() => {
131096
+ delete this.acks[id3];
131097
+ for (let i2 = 0;i2 < this.sendBuffer.length; i2++) {
131098
+ if (this.sendBuffer[i2].id === id3) {
131099
+ debug10("removing packet with ack id %d from the buffer", id3);
131100
+ this.sendBuffer.splice(i2, 1);
131101
+ }
131102
+ }
131103
+ debug10("event with ack id %d has timed out after %d ms", id3, timeout3);
131104
+ ack.call(this, new Error("operation has timed out"));
131105
+ }, timeout3);
131106
+ const fn2 = (...args2) => {
131107
+ this.io.clearTimeoutFn(timer);
131108
+ ack.apply(this, args2);
131109
+ };
131110
+ fn2.withError = true;
131111
+ this.acks[id3] = fn2;
131112
+ }
131113
+ emitWithAck(ev, ...args2) {
131114
+ return new Promise((resolve8, reject) => {
131115
+ const fn2 = (arg1, arg2) => {
131116
+ return arg1 ? reject(arg1) : resolve8(arg2);
131117
+ };
131118
+ fn2.withError = true;
131119
+ args2.push(fn2);
131120
+ this.emit(ev, ...args2);
131121
+ });
131122
+ }
131123
+ _addToQueue(args2) {
131124
+ let ack;
131125
+ if (typeof args2[args2.length - 1] === "function") {
131126
+ ack = args2.pop();
131127
+ }
131128
+ const packet = {
131129
+ id: this._queueSeq++,
131130
+ tryCount: 0,
131131
+ pending: false,
131132
+ args: args2,
131133
+ flags: Object.assign({ fromQueue: true }, this.flags)
131134
+ };
131135
+ args2.push((err, ...responseArgs) => {
131136
+ if (packet !== this._queue[0]) {
131137
+ return debug10("packet [%d] already acknowledged", packet.id);
131138
+ }
131139
+ const hasError = err !== null;
131140
+ if (hasError) {
131141
+ if (packet.tryCount > this._opts.retries) {
131142
+ debug10("packet [%d] is discarded after %d tries", packet.id, packet.tryCount);
131143
+ this._queue.shift();
131144
+ if (ack) {
131145
+ ack(err);
131146
+ }
131147
+ }
131148
+ } else {
131149
+ debug10("packet [%d] was successfully sent", packet.id);
131150
+ this._queue.shift();
131151
+ if (ack) {
131152
+ ack(null, ...responseArgs);
131153
+ }
131154
+ }
131155
+ packet.pending = false;
131156
+ return this._drainQueue();
131157
+ });
131158
+ this._queue.push(packet);
131159
+ this._drainQueue();
131160
+ }
131161
+ _drainQueue(force = false) {
131162
+ debug10("draining queue");
131163
+ if (!this.connected || this._queue.length === 0) {
131164
+ return;
131165
+ }
131166
+ const packet = this._queue[0];
131167
+ if (packet.pending && !force) {
131168
+ debug10("packet [%d] has already been sent and is waiting for an ack", packet.id);
131169
+ return;
131170
+ }
131171
+ packet.pending = true;
131172
+ packet.tryCount++;
131173
+ debug10("sending packet [%d] (try n°%d)", packet.id, packet.tryCount);
131174
+ this.flags = packet.flags;
131175
+ this.emit.apply(this, packet.args);
131176
+ }
131177
+ packet(packet) {
131178
+ packet.nsp = this.nsp;
131179
+ this.io._packet(packet);
131180
+ }
131181
+ onopen() {
131182
+ debug10("transport is open - connecting");
131183
+ if (typeof this.auth == "function") {
131184
+ this.auth((data) => {
131185
+ this._sendConnectPacket(data);
131186
+ });
131187
+ } else {
131188
+ this._sendConnectPacket(this.auth);
131189
+ }
131190
+ }
131191
+ _sendConnectPacket(data) {
131192
+ this.packet({
131193
+ type: PacketType.CONNECT,
131194
+ data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, data) : data
131195
+ });
131196
+ }
131197
+ onerror(err) {
131198
+ if (!this.connected) {
131199
+ this.emitReserved("connect_error", err);
131200
+ }
131201
+ }
131202
+ onclose(reason, description) {
131203
+ debug10("close (%s)", reason);
131204
+ this.connected = false;
131205
+ delete this.id;
131206
+ this.emitReserved("disconnect", reason, description);
131207
+ this._clearAcks();
131208
+ }
131209
+ _clearAcks() {
131210
+ Object.keys(this.acks).forEach((id3) => {
131211
+ const isBuffered = this.sendBuffer.some((packet) => String(packet.id) === id3);
131212
+ if (!isBuffered) {
131213
+ const ack = this.acks[id3];
131214
+ delete this.acks[id3];
131215
+ if (ack.withError) {
131216
+ ack.call(this, new Error("socket has been disconnected"));
131217
+ }
131218
+ }
131219
+ });
131220
+ }
131221
+ onpacket(packet) {
131222
+ const sameNamespace = packet.nsp === this.nsp;
131223
+ if (!sameNamespace)
131224
+ return;
131225
+ switch (packet.type) {
131226
+ case PacketType.CONNECT:
131227
+ if (packet.data && packet.data.sid) {
131228
+ this.onconnect(packet.data.sid, packet.data.pid);
131229
+ } else {
131230
+ this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
131231
+ }
131232
+ break;
131233
+ case PacketType.EVENT:
131234
+ case PacketType.BINARY_EVENT:
131235
+ this.onevent(packet);
131236
+ break;
131237
+ case PacketType.ACK:
131238
+ case PacketType.BINARY_ACK:
131239
+ this.onack(packet);
131240
+ break;
131241
+ case PacketType.DISCONNECT:
131242
+ this.ondisconnect();
131243
+ break;
131244
+ case PacketType.CONNECT_ERROR:
131245
+ this.destroy();
131246
+ const err = new Error(packet.data.message);
131247
+ err.data = packet.data.data;
131248
+ this.emitReserved("connect_error", err);
131249
+ break;
131250
+ }
131251
+ }
131252
+ onevent(packet) {
131253
+ const args2 = packet.data || [];
131254
+ debug10("emitting event %j", args2);
131255
+ if (packet.id != null) {
131256
+ debug10("attaching ack callback to event");
131257
+ args2.push(this.ack(packet.id));
131258
+ }
131259
+ if (this.connected) {
131260
+ this.emitEvent(args2);
131261
+ } else {
131262
+ this.receiveBuffer.push(Object.freeze(args2));
131263
+ }
131264
+ }
131265
+ emitEvent(args2) {
131266
+ if (this._anyListeners && this._anyListeners.length) {
131267
+ const listeners = this._anyListeners.slice();
131268
+ for (const listener of listeners) {
131269
+ listener.apply(this, args2);
131270
+ }
131271
+ }
131272
+ super.emit.apply(this, args2);
131273
+ if (this._pid && args2.length && typeof args2[args2.length - 1] === "string") {
131274
+ this._lastOffset = args2[args2.length - 1];
131275
+ }
131276
+ }
131277
+ ack(id3) {
131278
+ const self2 = this;
131279
+ let sent = false;
131280
+ return function(...args2) {
131281
+ if (sent)
131282
+ return;
131283
+ sent = true;
131284
+ debug10("sending ack %j", args2);
131285
+ self2.packet({
131286
+ type: PacketType.ACK,
131287
+ id: id3,
131288
+ data: args2
131289
+ });
131290
+ };
131291
+ }
131292
+ onack(packet) {
131293
+ const ack = this.acks[packet.id];
131294
+ if (typeof ack !== "function") {
131295
+ debug10("bad ack %s", packet.id);
131296
+ return;
131297
+ }
131298
+ delete this.acks[packet.id];
131299
+ debug10("calling ack %s with %j", packet.id, packet.data);
131300
+ if (ack.withError) {
131301
+ packet.data.unshift(null);
131302
+ }
131303
+ ack.apply(this, packet.data);
131304
+ }
131305
+ onconnect(id3, pid) {
131306
+ debug10("socket connected with id %s", id3);
131307
+ this.id = id3;
131308
+ this.recovered = pid && this._pid === pid;
131309
+ this._pid = pid;
131310
+ this.connected = true;
131311
+ this.emitBuffered();
131312
+ this._drainQueue(true);
131313
+ this.emitReserved("connect");
131314
+ }
131315
+ emitBuffered() {
131316
+ this.receiveBuffer.forEach((args2) => this.emitEvent(args2));
131317
+ this.receiveBuffer = [];
131318
+ this.sendBuffer.forEach((packet) => {
131319
+ this.notifyOutgoingListeners(packet);
131320
+ this.packet(packet);
131321
+ });
131322
+ this.sendBuffer = [];
131323
+ }
131324
+ ondisconnect() {
131325
+ debug10("server disconnect (%s)", this.nsp);
131326
+ this.destroy();
131327
+ this.onclose("io server disconnect");
131328
+ }
131329
+ destroy() {
131330
+ if (this.subs) {
131331
+ this.subs.forEach((subDestroy) => subDestroy());
131332
+ this.subs = undefined;
131333
+ }
131334
+ this.io["_destroy"](this);
131335
+ }
131336
+ disconnect() {
131337
+ if (this.connected) {
131338
+ debug10("performing disconnect (%s)", this.nsp);
131339
+ this.packet({ type: PacketType.DISCONNECT });
131340
+ }
131341
+ this.destroy();
131342
+ if (this.connected) {
131343
+ this.onclose("io client disconnect");
131344
+ }
131345
+ return this;
131346
+ }
131347
+ close() {
131348
+ return this.disconnect();
131349
+ }
131350
+ compress(compress) {
131351
+ this.flags.compress = compress;
131352
+ return this;
131353
+ }
131354
+ get volatile() {
131355
+ this.flags.volatile = true;
131356
+ return this;
131357
+ }
131358
+ timeout(timeout3) {
131359
+ this.flags.timeout = timeout3;
131360
+ return this;
131361
+ }
131362
+ onAny(listener) {
131363
+ this._anyListeners = this._anyListeners || [];
131364
+ this._anyListeners.push(listener);
131365
+ return this;
131366
+ }
131367
+ prependAny(listener) {
131368
+ this._anyListeners = this._anyListeners || [];
131369
+ this._anyListeners.unshift(listener);
131370
+ return this;
131371
+ }
131372
+ offAny(listener) {
131373
+ if (!this._anyListeners) {
131374
+ return this;
131375
+ }
131376
+ if (listener) {
131377
+ const listeners = this._anyListeners;
131378
+ for (let i2 = 0;i2 < listeners.length; i2++) {
131379
+ if (listener === listeners[i2]) {
131380
+ listeners.splice(i2, 1);
131381
+ return this;
131382
+ }
131383
+ }
131384
+ } else {
131385
+ this._anyListeners = [];
131386
+ }
131387
+ return this;
131388
+ }
131389
+ listenersAny() {
131390
+ return this._anyListeners || [];
131391
+ }
131392
+ onAnyOutgoing(listener) {
131393
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
131394
+ this._anyOutgoingListeners.push(listener);
131395
+ return this;
131396
+ }
131397
+ prependAnyOutgoing(listener) {
131398
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
131399
+ this._anyOutgoingListeners.unshift(listener);
131400
+ return this;
131401
+ }
131402
+ offAnyOutgoing(listener) {
131403
+ if (!this._anyOutgoingListeners) {
131404
+ return this;
131405
+ }
131406
+ if (listener) {
131407
+ const listeners = this._anyOutgoingListeners;
131408
+ for (let i2 = 0;i2 < listeners.length; i2++) {
131409
+ if (listener === listeners[i2]) {
131410
+ listeners.splice(i2, 1);
131411
+ return this;
131412
+ }
131413
+ }
131414
+ } else {
131415
+ this._anyOutgoingListeners = [];
131416
+ }
131417
+ return this;
131418
+ }
131419
+ listenersAnyOutgoing() {
131420
+ return this._anyOutgoingListeners || [];
131421
+ }
131422
+ notifyOutgoingListeners(packet) {
131423
+ if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
131424
+ const listeners = this._anyOutgoingListeners.slice();
131425
+ for (const listener of listeners) {
131426
+ listener.apply(this, packet.data);
131427
+ }
131428
+ }
131429
+ }
131430
+ };
131431
+ });
131432
+
131433
+ // ../../node_modules/.pnpm/socket.io-client@4.8.3/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js
131434
+ function Backoff(opts) {
131435
+ opts = opts || {};
131436
+ this.ms = opts.min || 100;
131437
+ this.max = opts.max || 1e4;
131438
+ this.factor = opts.factor || 2;
131439
+ this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
131440
+ this.attempts = 0;
131441
+ }
131442
+ var init_backo2 = __esm(() => {
131443
+ Backoff.prototype.duration = function() {
131444
+ var ms = this.ms * Math.pow(this.factor, this.attempts++);
131445
+ if (this.jitter) {
131446
+ var rand = Math.random();
131447
+ var deviation = Math.floor(rand * this.jitter * ms);
131448
+ ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
131449
+ }
131450
+ return Math.min(ms, this.max) | 0;
131451
+ };
131452
+ Backoff.prototype.reset = function() {
131453
+ this.attempts = 0;
131454
+ };
131455
+ Backoff.prototype.setMin = function(min4) {
131456
+ this.ms = min4;
131457
+ };
131458
+ Backoff.prototype.setMax = function(max6) {
131459
+ this.max = max6;
131460
+ };
131461
+ Backoff.prototype.setJitter = function(jitter) {
131462
+ this.jitter = jitter;
131463
+ };
131464
+ });
131465
+
131466
+ // ../../node_modules/.pnpm/socket.io-client@4.8.3/node_modules/socket.io-client/build/esm-debug/manager.js
131467
+ var import_component_emitter6, import_debug11, debug11, Manager;
131468
+ var init_manager2 = __esm(() => {
131469
+ init_esm_debug();
131470
+ init_socket2();
131471
+ init_esm_debug2();
131472
+ init_backo2();
131473
+ import_component_emitter6 = __toESM(require_cjs2(), 1);
131474
+ import_debug11 = __toESM(require_src2(), 1);
131475
+ debug11 = import_debug11.default("socket.io-client:manager");
131476
+ Manager = class Manager extends import_component_emitter6.Emitter {
131477
+ constructor(uri, opts) {
131478
+ var _a4;
131479
+ super();
131480
+ this.nsps = {};
131481
+ this.subs = [];
131482
+ if (uri && typeof uri === "object") {
131483
+ opts = uri;
131484
+ uri = undefined;
131485
+ }
131486
+ opts = opts || {};
131487
+ opts.path = opts.path || "/socket.io";
131488
+ this.opts = opts;
131489
+ installTimerFunctions(this, opts);
131490
+ this.reconnection(opts.reconnection !== false);
131491
+ this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
131492
+ this.reconnectionDelay(opts.reconnectionDelay || 1000);
131493
+ this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
131494
+ this.randomizationFactor((_a4 = opts.randomizationFactor) !== null && _a4 !== undefined ? _a4 : 0.5);
131495
+ this.backoff = new Backoff({
131496
+ min: this.reconnectionDelay(),
131497
+ max: this.reconnectionDelayMax(),
131498
+ jitter: this.randomizationFactor()
131499
+ });
131500
+ this.timeout(opts.timeout == null ? 20000 : opts.timeout);
131501
+ this._readyState = "closed";
131502
+ this.uri = uri;
131503
+ const _parser = opts.parser || exports_esm_debug;
131504
+ this.encoder = new _parser.Encoder;
131505
+ this.decoder = new _parser.Decoder;
131506
+ this._autoConnect = opts.autoConnect !== false;
131507
+ if (this._autoConnect)
131508
+ this.open();
131509
+ }
131510
+ reconnection(v3) {
131511
+ if (!arguments.length)
131512
+ return this._reconnection;
131513
+ this._reconnection = !!v3;
131514
+ if (!v3) {
131515
+ this.skipReconnect = true;
131516
+ }
131517
+ return this;
131518
+ }
131519
+ reconnectionAttempts(v3) {
131520
+ if (v3 === undefined)
131521
+ return this._reconnectionAttempts;
131522
+ this._reconnectionAttempts = v3;
131523
+ return this;
131524
+ }
131525
+ reconnectionDelay(v3) {
131526
+ var _a4;
131527
+ if (v3 === undefined)
131528
+ return this._reconnectionDelay;
131529
+ this._reconnectionDelay = v3;
131530
+ (_a4 = this.backoff) === null || _a4 === undefined || _a4.setMin(v3);
131531
+ return this;
131532
+ }
131533
+ randomizationFactor(v3) {
131534
+ var _a4;
131535
+ if (v3 === undefined)
131536
+ return this._randomizationFactor;
131537
+ this._randomizationFactor = v3;
131538
+ (_a4 = this.backoff) === null || _a4 === undefined || _a4.setJitter(v3);
131539
+ return this;
131540
+ }
131541
+ reconnectionDelayMax(v3) {
131542
+ var _a4;
131543
+ if (v3 === undefined)
131544
+ return this._reconnectionDelayMax;
131545
+ this._reconnectionDelayMax = v3;
131546
+ (_a4 = this.backoff) === null || _a4 === undefined || _a4.setMax(v3);
131547
+ return this;
131548
+ }
131549
+ timeout(v3) {
131550
+ if (!arguments.length)
131551
+ return this._timeout;
131552
+ this._timeout = v3;
131553
+ return this;
131554
+ }
131555
+ maybeReconnectOnOpen() {
131556
+ if (!this._reconnecting && this._reconnection && this.backoff.attempts === 0) {
131557
+ this.reconnect();
131558
+ }
131559
+ }
131560
+ open(fn2) {
131561
+ debug11("readyState %s", this._readyState);
131562
+ if (~this._readyState.indexOf("open"))
131563
+ return this;
131564
+ debug11("opening %s", this.uri);
131565
+ this.engine = new Socket2(this.uri, this.opts);
131566
+ const socket = this.engine;
131567
+ const self2 = this;
131568
+ this._readyState = "opening";
131569
+ this.skipReconnect = false;
131570
+ const openSubDestroy = on(socket, "open", function() {
131571
+ self2.onopen();
131572
+ fn2 && fn2();
131573
+ });
131574
+ const onError3 = (err) => {
131575
+ debug11("error");
131576
+ this.cleanup();
131577
+ this._readyState = "closed";
131578
+ this.emitReserved("error", err);
131579
+ if (fn2) {
131580
+ fn2(err);
131581
+ } else {
131582
+ this.maybeReconnectOnOpen();
131583
+ }
131584
+ };
131585
+ const errorSub = on(socket, "error", onError3);
131586
+ if (this._timeout !== false) {
131587
+ const timeout3 = this._timeout;
131588
+ debug11("connect attempt will timeout after %d", timeout3);
131589
+ const timer = this.setTimeoutFn(() => {
131590
+ debug11("connect attempt timed out after %d", timeout3);
131591
+ openSubDestroy();
131592
+ onError3(new Error("timeout"));
131593
+ socket.close();
131594
+ }, timeout3);
131595
+ if (this.opts.autoUnref) {
131596
+ timer.unref();
131597
+ }
131598
+ this.subs.push(() => {
131599
+ this.clearTimeoutFn(timer);
131600
+ });
131601
+ }
131602
+ this.subs.push(openSubDestroy);
131603
+ this.subs.push(errorSub);
131604
+ return this;
131605
+ }
131606
+ connect(fn2) {
131607
+ return this.open(fn2);
131608
+ }
131609
+ onopen() {
131610
+ debug11("open");
131611
+ this.cleanup();
131612
+ this._readyState = "open";
131613
+ this.emitReserved("open");
131614
+ const socket = this.engine;
131615
+ this.subs.push(on(socket, "ping", this.onping.bind(this)), on(socket, "data", this.ondata.bind(this)), on(socket, "error", this.onerror.bind(this)), on(socket, "close", this.onclose.bind(this)), on(this.decoder, "decoded", this.ondecoded.bind(this)));
131616
+ }
131617
+ onping() {
131618
+ this.emitReserved("ping");
131619
+ }
131620
+ ondata(data) {
131621
+ try {
131622
+ this.decoder.add(data);
131623
+ } catch (e) {
131624
+ this.onclose("parse error", e);
131625
+ }
131626
+ }
131627
+ ondecoded(packet) {
131628
+ nextTick(() => {
131629
+ this.emitReserved("packet", packet);
131630
+ }, this.setTimeoutFn);
131631
+ }
131632
+ onerror(err) {
131633
+ debug11("error", err);
131634
+ this.emitReserved("error", err);
131635
+ }
131636
+ socket(nsp, opts) {
131637
+ let socket = this.nsps[nsp];
131638
+ if (!socket) {
131639
+ socket = new Socket3(this, nsp, opts);
131640
+ this.nsps[nsp] = socket;
131641
+ } else if (this._autoConnect && !socket.active) {
131642
+ socket.connect();
131643
+ }
131644
+ return socket;
131645
+ }
131646
+ _destroy(socket) {
131647
+ const nsps = Object.keys(this.nsps);
131648
+ for (const nsp of nsps) {
131649
+ const socket2 = this.nsps[nsp];
131650
+ if (socket2.active) {
131651
+ debug11("socket %s is still active, skipping close", nsp);
131652
+ return;
131653
+ }
131654
+ }
131655
+ this._close();
131656
+ }
131657
+ _packet(packet) {
131658
+ debug11("writing packet %j", packet);
131659
+ const encodedPackets = this.encoder.encode(packet);
131660
+ for (let i2 = 0;i2 < encodedPackets.length; i2++) {
131661
+ this.engine.write(encodedPackets[i2], packet.options);
131662
+ }
131663
+ }
131664
+ cleanup() {
131665
+ debug11("cleanup");
131666
+ this.subs.forEach((subDestroy) => subDestroy());
131667
+ this.subs.length = 0;
131668
+ this.decoder.destroy();
131669
+ }
131670
+ _close() {
131671
+ debug11("disconnect");
131672
+ this.skipReconnect = true;
131673
+ this._reconnecting = false;
131674
+ this.onclose("forced close");
131675
+ }
131676
+ disconnect() {
131677
+ return this._close();
131678
+ }
131679
+ onclose(reason, description) {
131680
+ var _a4;
131681
+ debug11("closed due to %s", reason);
131682
+ this.cleanup();
131683
+ (_a4 = this.engine) === null || _a4 === undefined || _a4.close();
131684
+ this.backoff.reset();
131685
+ this._readyState = "closed";
131686
+ this.emitReserved("close", reason, description);
131687
+ if (this._reconnection && !this.skipReconnect) {
131688
+ this.reconnect();
131689
+ }
131690
+ }
131691
+ reconnect() {
131692
+ if (this._reconnecting || this.skipReconnect)
131693
+ return this;
131694
+ const self2 = this;
131695
+ if (this.backoff.attempts >= this._reconnectionAttempts) {
131696
+ debug11("reconnect failed");
131697
+ this.backoff.reset();
131698
+ this.emitReserved("reconnect_failed");
131699
+ this._reconnecting = false;
131700
+ } else {
131701
+ const delay3 = this.backoff.duration();
131702
+ debug11("will wait %dms before reconnect attempt", delay3);
131703
+ this._reconnecting = true;
131704
+ const timer = this.setTimeoutFn(() => {
131705
+ if (self2.skipReconnect)
131706
+ return;
131707
+ debug11("attempting reconnect");
131708
+ this.emitReserved("reconnect_attempt", self2.backoff.attempts);
131709
+ if (self2.skipReconnect)
131710
+ return;
131711
+ self2.open((err) => {
131712
+ if (err) {
131713
+ debug11("reconnect attempt error");
131714
+ self2._reconnecting = false;
131715
+ self2.reconnect();
131716
+ this.emitReserved("reconnect_error", err);
131717
+ } else {
131718
+ debug11("reconnect success");
131719
+ self2.onreconnect();
131720
+ }
131721
+ });
131722
+ }, delay3);
131723
+ if (this.opts.autoUnref) {
131724
+ timer.unref();
131725
+ }
131726
+ this.subs.push(() => {
131727
+ this.clearTimeoutFn(timer);
131728
+ });
131729
+ }
131730
+ }
131731
+ onreconnect() {
131732
+ const attempt = this.backoff.attempts;
131733
+ this._reconnecting = false;
131734
+ this.backoff.reset();
131735
+ this.emitReserved("reconnect", attempt);
131736
+ }
131737
+ };
131738
+ });
131739
+
131740
+ // ../../node_modules/.pnpm/socket.io-client@4.8.3/node_modules/socket.io-client/build/esm-debug/index.js
131741
+ function lookup2(uri, opts) {
131742
+ if (typeof uri === "object") {
131743
+ opts = uri;
131744
+ uri = undefined;
131745
+ }
131746
+ opts = opts || {};
131747
+ const parsed = url3(uri, opts.path || "/socket.io");
131748
+ const source = parsed.source;
131749
+ const id3 = parsed.id;
131750
+ const path8 = parsed.path;
131751
+ const sameNamespace = cache[id3] && path8 in cache[id3]["nsps"];
131752
+ const newConnection = opts.forceNew || opts["force new connection"] || opts.multiplex === false || sameNamespace;
131753
+ let io2;
131754
+ if (newConnection) {
131755
+ debug12("ignoring socket cache for %s", source);
131756
+ io2 = new Manager(source, opts);
131757
+ } else {
131758
+ if (!cache[id3]) {
131759
+ debug12("new io instance for %s", source);
131760
+ cache[id3] = new Manager(source, opts);
131761
+ }
131762
+ io2 = cache[id3];
131763
+ }
131764
+ if (parsed.query && !opts.query) {
131765
+ opts.query = parsed.queryKey;
131766
+ }
131767
+ return io2.socket(parsed.path, opts);
131768
+ }
131769
+ var import_debug12, debug12, cache;
131770
+ var init_esm_debug3 = __esm(() => {
131771
+ init_url();
131772
+ init_manager2();
131773
+ init_socket2();
131774
+ init_esm_debug2();
131775
+ init_esm_debug();
131776
+ import_debug12 = __toESM(require_src2(), 1);
131777
+ debug12 = import_debug12.default("socket.io-client");
131778
+ cache = {};
131779
+ Object.assign(lookup2, {
131780
+ Manager,
131781
+ Socket: Socket3,
131782
+ io: lookup2,
131783
+ connect: lookup2
131784
+ });
131785
+ });
131786
+
131787
+ // src/daemon/local-web/client/lib/socket.ts
131788
+ async function ensureConnected(s) {
131789
+ if (!s.connected) {
131790
+ await new Promise((resolve8, reject) => {
131791
+ const onConnect = () => {
131792
+ cleanup();
131793
+ resolve8();
131794
+ };
131795
+ const onError3 = (err) => {
131796
+ cleanup();
131797
+ reject(err);
131798
+ };
131799
+ const cleanup = () => {
131800
+ s.off("connect", onConnect);
131801
+ s.off("connect_error", onError3);
131802
+ };
131803
+ s.on("connect", onConnect);
131804
+ s.on("connect_error", onError3);
131805
+ s.connect();
131806
+ });
131807
+ }
131808
+ }
131809
+ async function ingestChatroomEvent(event, port) {
131810
+ if (!daemonSocket) {
131811
+ daemonSocket = lookup2(`http://127.0.0.1:${port}`, { transports: ["websocket"], autoConnect: true });
131812
+ }
131813
+ const s = daemonSocket;
131814
+ await ensureConnected(s);
131815
+ const response = await s.emitWithAck("eventStream.ingest", event);
131816
+ if (!response.ok) {
131817
+ throw new Error(response.error?.message ?? "Failed to ingest chatroom event");
131818
+ }
131819
+ }
131820
+ var daemonSocket = null;
131821
+ var init_socket3 = __esm(() => {
131822
+ init_esm_debug3();
131823
+ });
131824
+
131825
+ // src/daemon/entry/start-daemon.ts
131826
+ async function startDaemon() {
131827
+ let resolveBoundPort;
131828
+ const localWebPortReady = new Promise((resolve8) => {
131829
+ resolveBoundPort = resolve8;
131830
+ });
131831
+ const logStreamHub = createLogStreamHub();
131832
+ const logServer = createLogServer(resolveLogsDbPath(), {
131833
+ onWrite: (entry) => logStreamHub.publish(entry)
131834
+ });
131835
+ let init2;
131836
+ try {
131837
+ init2 = await initDaemon({
131838
+ logSink: logServer,
131839
+ logEvent: async (event) => {
131840
+ const port = await localWebPortReady;
131841
+ return ingestChatroomEvent(event, port);
131842
+ }
131843
+ });
128436
131844
  } catch (error51) {
128437
131845
  logServer.close();
128438
131846
  throw error51;
@@ -128454,6 +131862,7 @@ async function startDaemon() {
128454
131862
  backend: init2.backend,
128455
131863
  sessionId: init2.sessionId
128456
131864
  });
131865
+ resolveBoundPort(localWeb.port);
128457
131866
  const subscribers = startAllSubscribers({
128458
131867
  wsClient: wsClient2,
128459
131868
  sessionId: asConvexSessionId(init2.sessionId),
@@ -128490,6 +131899,7 @@ var init_start_daemon = __esm(() => {
128490
131899
  init_persistence();
128491
131900
  init_log_repository();
128492
131901
  init_create_local_web_server();
131902
+ init_socket3();
128493
131903
  });
128494
131904
 
128495
131905
  // src/commands/machine/daemon-start/index.ts
@@ -129282,12 +132692,12 @@ handoffCommandGroup.command("view-template").description("Print the handoff mess
129282
132692
  });
129283
132693
  handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").requiredOption("--next-role <nextRole>", "Role to hand off to").action(async (options) => {
129284
132694
  await maybeRequireAuth();
129285
- const { decode: decode5 } = await Promise.resolve().then(() => exports_decode);
132695
+ const { decode: decode6 } = await Promise.resolve().then(() => exports_decode);
129286
132696
  const stdinContent = await readStdin();
129287
132697
  let message;
129288
132698
  try {
129289
132699
  const { HANDOFF_STDIN_DELIMITER: HANDOFF_STDIN_DELIMITER2, validateStdinHeredocBody: validateStdinHeredocBody2 } = await Promise.resolve().then(() => (init_stdin_heredoc(), exports_stdin_heredoc));
129290
- const result = decode5(stdinContent, { singleParam: "message" });
132700
+ const result = decode6(stdinContent, { singleParam: "message" });
129291
132701
  message = result.message;
129292
132702
  validateStdinHeredocBody2(message, HANDOFF_STDIN_DELIMITER2);
129293
132703
  } catch (err) {
@@ -129308,12 +132718,12 @@ handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").
129308
132718
  var agenticQueryCommand = program2.command("agentic-query").description("Agentic search/ask query commands");
129309
132719
  agenticQueryCommand.command("complete").description("Submit the structured agentic query result markdown").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--query-id <id>", "Agentic query identifier").action(async (options) => {
129310
132720
  await maybeRequireAuth();
129311
- const { decode: decode5 } = await Promise.resolve().then(() => exports_decode);
132721
+ const { decode: decode6 } = await Promise.resolve().then(() => exports_decode);
129312
132722
  const stdinContent = await readStdin();
129313
132723
  let result;
129314
132724
  try {
129315
132725
  const { AGENTIC_QUERY_STDIN_DELIMITER: AGENTIC_QUERY_STDIN_DELIMITER2, validateStdinHeredocBody: validateStdinHeredocBody2 } = await Promise.resolve().then(() => (init_stdin_heredoc(), exports_stdin_heredoc));
129316
- const decoded = decode5(stdinContent, { singleParam: "result" });
132726
+ const decoded = decode6(stdinContent, { singleParam: "result" });
129317
132727
  let body = decoded.result;
129318
132728
  body = body.replace(/^(---RESULT---\s*)+/i, "").trim();
129319
132729
  validateStdinHeredocBody2(body, AGENTIC_QUERY_STDIN_DELIMITER2);
@@ -129335,12 +132745,12 @@ agenticQueryCommand.command("complete").description("Submit the structured agent
129335
132745
  var enhancerCommand = program2.command("enhancer").description("Handoff enhancer commands");
129336
132746
  enhancerCommand.command("complete").description("Submit the enhanced handoff markdown").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--job-id <id>", "Enhancer job identifier").action(async (options) => {
129337
132747
  await maybeRequireAuth();
129338
- const { decode: decode5 } = await Promise.resolve().then(() => exports_decode);
132748
+ const { decode: decode6 } = await Promise.resolve().then(() => exports_decode);
129339
132749
  const stdinContent = await readStdin();
129340
132750
  let body;
129341
132751
  try {
129342
132752
  const { ENHANCER_STDIN_DELIMITER: ENHANCER_STDIN_DELIMITER2, HANDOFF_MESSAGE_MARKER: HANDOFF_MESSAGE_MARKER2, validateStdinHeredocBody: validateStdinHeredocBody2 } = await Promise.resolve().then(() => (init_stdin_heredoc(), exports_stdin_heredoc));
129343
- const decoded = decode5(stdinContent, { singleParam: "result" });
132753
+ const decoded = decode6(stdinContent, { singleParam: "result" });
129344
132754
  body = decoded.result;
129345
132755
  body = body.replace(new RegExp(`^(${HANDOFF_MESSAGE_MARKER2}\\s*)+`, "i"), "").trim();
129346
132756
  validateStdinHeredocBody2(body, ENHANCER_STDIN_DELIMITER2);
@@ -129707,4 +133117,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
129707
133117
  });
129708
133118
  program2.parse();
129709
133119
 
129710
- //# debugId=7848C1A022D1F30A64756E2164756E21
133120
+ //# debugId=2985C1A25A95ABE964756E2164756E21