const EVENTS_KEY = "__shooter_ws_events_clients";
const eventsClients = globalThis[EVENTS_KEY] || /* @__PURE__ */ new Set();
globalThis[EVENTS_KEY] = eventsClients;
const LISTENERS_KEY = "__shooter_ws_event_listeners";
const eventListeners = globalThis[LISTENERS_KEY] || /* @__PURE__ */ new Set();
globalThis[LISTENERS_KEY] = eventListeners;
function broadcastEvent(event) {
  const data = JSON.stringify({
    ...event,
    timestamp: (/* @__PURE__ */ new Date()).toISOString()
  });
  for (const ws of eventsClients) {
    if (ws.readyState === 1) {
      ws.send(data);
    }
  }
  for (const listener of eventListeners) {
    try {
      listener(event);
    } catch {
    }
  }
}
function getEventsClientCount() {
  return eventsClients.size;
}
const GUESTS_KEY = "__shooter_ws_guest_conns";
const guests = globalThis[GUESTS_KEY] || /* @__PURE__ */ new Map();
globalThis[GUESTS_KEY] = guests;
function closeGuests(terminalId) {
  const set = guests.get(terminalId);
  if (!set) {
    return 0;
  }
  let closed = 0;
  for (const ws of set) {
    try {
      ws.close(4001, "Share revoked");
      closed++;
    } catch {
    }
  }
  guests.delete(terminalId);
  return closed;
}

export { broadcastEvent as b, closeGuests as c, getEventsClientCount as g };
//# sourceMappingURL=guest-registry-Dxvd7p-g.js.map
