export interface DevToolbarApp {
  id: string;
  name: string;
  icon?: string;
  entrypoint?: string;
  order?: number;
}

export interface DevToolbarRegistry {
  registerApp(app: DevToolbarApp): void;
  unregisterApp(id: string): void;
  getApps(): DevToolbarApp[];
}

export function createDevToolbarRegistry(): DevToolbarRegistry {
  const apps = new Map<string, DevToolbarApp>();
  return {
    registerApp(app) {
      apps.set(app.id, app);
    },
    unregisterApp(id) {
      apps.delete(id);
    },
    getApps() {
      return [...apps.values()].sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
    },
  };
}
