import type { App } from "vue"
import Editor from "./components/Editor.vue"
import EditorBlock from "./components/EditorBlock.vue"
import EditorSuggestionMenu from "./components/EditorSuggestionMenu.vue"
import EditorToolbar from "./components/EditorToolbar.vue"

import "katex/dist/katex.css"
import "./assets/style.css"

export type { EditorFocusTarget } from "./components/Editor.vue"
export type { ToolbarMode } from "./components/EditorToolbar.vue"
export type { FocusTarget } from "./composables/useFocusRegistry"
export type {
  KeyBinding,
  KeyboardAction,
  KeyboardConfig,
} from "./composables/useKeyboard"
export {
  defaultKeyBinding,
  useKeyboard,
  vimKeyBinding,
} from "./composables/useKeyboard"
export type {
  PatternClosePayload,
  PatternKind,
  PatternOpenPayload,
  PatternSession,
  PatternSpec,
  PatternUpdatePayload,
} from "./composables/usePatternPlugin"
export type {
  MentionData,
  MentionItem,
  SuggestionActionItem,
} from "./composables/useSuggestionGroups"
export {
  buildMentionGroups,
  buildSlashGroups,
  useMentionGroups,
  useSlashGroups,
} from "./composables/useSuggestionGroups"
export {
  extractEmbeddedId,
  generateBlockId,
  splitMarkdownIntoBlocks,
  stampBlockId,
} from "./lib/block-parser"
export { contentBlockId } from "./lib/block-id"
export { moveBlock } from "./lib/editor-operations"
export type { FormattingHandlers } from "./lib/formatting"
export type { MarkdownPattern } from "./lib/markdown-extensions"
export type {
  BlockRule,
  MarkdownRule,
  ParsedDecorations,
} from "./lib/markdown-rules"
export { MarkdownRuleEngine } from "./lib/markdown-rules"
export type {
  Entity,
  EntityKind,
  GraphProvider,
  Property,
  Relation,
} from "./services/graph"
export {
  registerComarkComponent,
  registerWidgetFactory,
  getWidgetFactory,
} from "./lib/comark-registry"
export { findChildByTypeName, findChildrenByTypeName } from "./lib/markdown-rules/inline-rules"
export { registerNodeView } from "./lib/node-view-registry"
export type {
  DeleteBlockOp,
  EditorOperation,
  ExecuteResult,
  IndentBlockOp,
  InsertBlockOp,
  MergeBlockOp,
  MoveBlockOp,
  OperationHistory,
  OutdentBlockOp,
  SetBlockContentOp,
  SplitBlockOp,
} from "./lib/operation-history"
export {
  computeInverse,
  createOperationHistory,
  setTimeSource,
} from "./lib/operation-history"
export type {
  EditorTheme,
  ThemeColors,
  ThemeInput,
  ThemeSyntax,
} from "./lib/theme"
export {
  resolveTheme,
  themePresets,
  themeToCSSVars,
} from "./lib/theme"

export { Editor, EditorBlock, EditorSuggestionMenu, EditorToolbar }

export default {
  install(app: App) {
    app.component("Editor", Editor)
    app.component("EditorBlock", EditorBlock)
    app.component("EditorSuggestionMenu", EditorSuggestionMenu)
    app.component("EditorToolbar", EditorToolbar)
  },
}
