import { type Component, markRaw } from "vue";

export type NavigationItem = {
  key: string;
  label: string;
  icon: string | null;
  route: string | null;
  priority: number;
  badge: number | string | null;
  children: NavigationItem[];
};

export type ModuleInfo = {
  key: string;
  label: string | null;
  entry: string;
};

class ComponentRegistry {
  private components: Record<string, Component> = {};
  private pages: Record<string, Component> = {};

  registerComponent(name: string, component: Component): void {
    this.components[name] = markRaw(component);
  }

  registerPage(name: string, component: Component): void {
    this.pages[name] = markRaw(component);
  }

  resolveComponent(name: string): Component | null {
    return this.components[name] ?? null;
  }

  resolvePage(name: string): Component | null {
    return this.pages[name] ?? null;
  }
}

export const registry = new ComponentRegistry();

export type { ComponentRegistry };
