/**
 * Core types for the IM editor (mentions, files, emojis).
 */

export type MentionType = 'user' | 'channel' | 'ai' | 'repo' | 'command' | 'special_here' | 'special_channel';

export interface MentionItem {
  id: string;
  label: string;
  type: MentionType;
  avatar?: string;
  description?: string; // shown under label in suggestion dropdown
}

export interface FileData {
  id: string;
  name: string;
  url: string;
  size?: number;
  type: string;
  status?: 'uploading' | 'done' | 'error';
  progress?: number;
}

/** Output AST produced by the editor on send */
export interface MessageAST {
  type: 'doc';
  content: EditorNode[];
}

export type EditorNode = TextNode | MentionNode | FileNode | EmojiNode | HardBreakNode;

export interface TextNode {
  type: 'text';
  text: string;
}

export interface MentionNode {
  type: 'mention';
  attrs: {
    id: string;
    label: string;
    type: MentionType;
  };
}

export interface FileNode {
  type: 'file';
  attrs: {
    id: string;
    name: string;
    url: string;
    size: number;
    type: string;
    status: string;
  };
}

export interface EmojiNode {
  type: 'emoji';
  attrs: {
    name: string;
    url: string;
  };
}

export interface HardBreakNode {
  type: 'hardBreak';
}
