import { $ as defineWebSocketHandler, a0 as unregisterClient, a1 as handleMessage, a2 as registerClient } from '../nitro/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'stream';
import 'events';
import 'http';
import 'crypto';
import 'buffer';
import 'zlib';
import 'https';
import 'net';
import 'tls';
import 'url';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'vue-router';
import '@prisma/client';
import '@prisma/adapter-better-sqlite3';
import 'fs';
import 'path';
import 'fs/promises';
import 'child_process';
import 'node:child_process';
import 'node:url';

const _ws = defineWebSocketHandler({
  open(peer) {
    registerClient(peer);
  },
  message(peer, message) {
    try {
      const parsed = JSON.parse(message.text());
      handleMessage(peer, parsed);
    } catch (e) {
      console.error("[WS] Parse error:", e);
    }
  },
  close(peer) {
    unregisterClient(peer);
  },
  error(peer, error) {
    console.error("[WS] Peer error:", peer.id, error);
  }
});

export { _ws as default };
//# sourceMappingURL=_ws.mjs.map
