// Code generated by cmd/genprotocol from protocol/schema.json; DO NOT EDIT.
//
// Shared WebSocket protocol message type constants — single source of truth
// for both Server (Go) and Client (TypeScript). Edit protocol/schema.json
// and run `make protocol-generate` in Server/.
//
// Usage:  import { MessageType } from "@lib/protocolTypes";
//         ws.send({ type: MessageType.CHAT_SEND, payload: { ... } });

// The wire epoch this client speaks; sent in the auth frame and checked by
// the server. See docs/protocol.md, Compatibility.
export const PROTOCOL_EPOCH = 1;

// ---------------------------------------------------------------------------
// Server → Client message types
// ---------------------------------------------------------------------------

export const ServerMessageType = {
  AUTH_OK: "auth_ok",
  AUTH_ERROR: "auth_error",
  READY: "ready",
  CHAT_MESSAGE: "chat_message",
  CHAT_SEND_OK: "chat_send_ok",
  CHAT_EDITED: "chat_edited",
  CHAT_DELETED: "chat_deleted",
  CHAT_BULK_DELETED: "chat_bulk_deleted",
  REACTION_UPDATE: "reaction_update",
  TYPING: "typing",
  PRESENCE: "presence",
  CHANNEL_CREATE: "channel_create",
  CHANNEL_UPDATE: "channel_update",
  CHANNEL_DELETE: "channel_delete",
  VOICE_STATE: "voice_state",
  VOICE_CONFIG: "voice_config",
  VOICE_TOKEN: "voice_token",
  VOICE_LEAVE: "voice_leave", // broadcast (same string as client msg)
  VOICE_MOVED: "voice_moved",
  VOICE_DISCONNECTED: "voice_disconnected",
  MEMBER_JOIN: "member_join",
  MEMBER_UPDATE: "member_update",
  USER_UPDATE: "user_update",
  MEMBER_BAN: "member_ban",
  ROLES_UPDATE: "roles_update",
  EMOJI_UPDATE: "emoji_update",
  SERVER_RESTART: "server_restart",
  ERROR: "error",
  PONG: "pong",
  DM_CHANNEL_OPEN: "dm_channel_open",
  DM_CHANNEL_CLOSE: "dm_channel_close",
  CALL_INCOMING: "call_incoming",
  CALL_DECLINED: "call_declined",
  VOICE_E2EE_ANNOUNCE: "voice_e2ee_announce", // broadcast (same string as client msg)
  VOICE_E2EE_OFFER: "voice_e2ee_offer", // relay (same string as client msg)
  COMMAND_REPLY: "command_reply", // ephemeral plugin reply, sent only to the invoking client
  PLUGIN_BROADCAST: "plugin_broadcast", // plugin channel broadcast, gated by the sender's SEND_MESSAGES
} as const;

export type ServerMessageTypeValue = (typeof ServerMessageType)[keyof typeof ServerMessageType];

// ---------------------------------------------------------------------------
// Client → Server message types
// ---------------------------------------------------------------------------

export const ClientMessageType = {
  AUTH: "auth",
  CHAT_SEND: "chat_send",
  CHAT_EDIT: "chat_edit",
  CHAT_DELETE: "chat_delete",
  REACTION_ADD: "reaction_add",
  REACTION_REMOVE: "reaction_remove",
  TYPING_START: "typing_start",
  CHANNEL_FOCUS: "channel_focus",
  MARK_READ: "mark_read",
  PRESENCE_UPDATE: "presence_update",
  VOICE_JOIN: "voice_join",
  VOICE_LEAVE: "voice_leave",
  VOICE_MUTE: "voice_mute",
  VOICE_DEAFEN: "voice_deafen",
  VOICE_CAMERA: "voice_camera",
  VOICE_SCREENSHARE: "voice_screenshare",
  VOICE_MOD_MUTE: "voice_mod_mute",
  VOICE_MOD_DEAFEN: "voice_mod_deafen",
  VOICE_MOD_MOVE: "voice_mod_move",
  VOICE_MOD_KICK: "voice_mod_kick",
  PING: "ping",
  VOICE_TOKEN_REFRESH: "voice_token_refresh",
  VOICE_E2EE_ANNOUNCE: "voice_e2ee_announce",
  VOICE_E2EE_OFFER: "voice_e2ee_offer",
  CALL_RING: "call_ring",
  CALL_DECLINE: "call_decline",
  CHAT_COMMAND: "chat_command", // plugin slash-command dispatch (Phase C)
} as const;

export type ClientMessageTypeValue = (typeof ClientMessageType)[keyof typeof ClientMessageType];

// ---------------------------------------------------------------------------
// Unified MessageType — all message types in one object for convenience
// ---------------------------------------------------------------------------

export const MessageType = {
  ...ServerMessageType,
  ...ClientMessageType,
} as const;

export type MessageTypeValue = (typeof MessageType)[keyof typeof MessageType];
