import { jsx, jsxs } from "react/jsx-runtime";
import { Box } from "ink";
import { Header } from "./Header.js";
import { Sidebar } from "./Sidebar.js";
import { MainPane } from "./MainPane.js";
import { Footer, FooterProvider } from "./Footer.js";
import { CommandPalette } from "./CommandPalette.js";
import { HelpOverlay } from "./HelpOverlay.js";
import { useShellWidth } from "./width.js";
const DEFAULT_ROUTES = [
  { id: "browser", label: "Browser", group: "settings" },
  { id: "search", label: "Search engine", group: "settings" },
  { id: "llm", label: "LLM provider", group: "settings" },
  { id: "agents", label: "Agents", group: "settings" },
  { id: "cache", label: "Cache", group: "settings" },
  { id: "advanced", label: "Advanced", group: "settings" },
  { id: "verify", label: "Verify", group: "actions" },
  { id: "doctor", label: "Doctor", group: "actions" },
  { id: "export", label: "Export", group: "actions" },
  { id: "import", label: "Import", group: "actions" },
  { id: "uninstall", label: "Uninstall", group: "actions" }
];
function computeBreadcrumb(routeId, routes, paneTitle) {
  const rid = routeId ?? "home";
  if (rid === "home") return "Home";
  if (rid.startsWith("category:")) {
    return `Settings \u203A ${paneTitle}`;
  }
  if (rid.startsWith("action:")) {
    return `Actions \u203A ${paneTitle}`;
  }
  const route = routes.find((r) => r.id === rid);
  if (route) {
    const prefix = route.group === "settings" ? "Settings" : "Actions";
    return `${prefix} \u203A ${route.label}`;
  }
  return paneTitle;
}
function App(props) {
  const routes = props.routes ?? DEFAULT_ROUTES;
  const width = useShellWidth();
  const breadcrumb = width === "wide" ? void 0 : computeBreadcrumb(props.routeId, routes, props.paneTitle);
  return /* @__PURE__ */ jsx(FooterProvider, { children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", height: "100%", children: [
    /* @__PURE__ */ jsx(
      Header,
      {
        status: props.status,
        pending: props.pending,
        toast: props.toast,
        activityStore: props.activityStore,
        width,
        breadcrumb,
        saveLabel: props.saveLabel
      }
    ),
    /* @__PURE__ */ jsxs(Box, { flexGrow: 1, children: [
      width === "wide" && /* @__PURE__ */ jsx(
        Sidebar,
        {
          routes,
          activeRoute: props.activeRoute,
          dirtyByCategory: props.dirtyByCategory,
          onSelect: props.onSelectRoute,
          focused: props.focusedPane === "sidebar"
        }
      ),
      /* @__PURE__ */ jsx(MainPane, { title: props.paneTitle, focused: props.focusedPane === "main", routeId: props.routeId ?? props.activeRoute, children: props.children })
    ] }),
    /* @__PURE__ */ jsx(Footer, { width }),
    props.paletteOpen && props.paletteEntries && props.onPalettePick && props.onPaletteClose && /* @__PURE__ */ jsx(Box, { position: "absolute", marginLeft: 4, marginTop: 2, children: /* @__PURE__ */ jsx(
      CommandPalette,
      {
        entries: props.paletteEntries,
        onPick: props.onPalettePick,
        onClose: props.onPaletteClose
      }
    ) }),
    props.helpOpen && props.onHelpClose && /* @__PURE__ */ jsx(Box, { position: "absolute", marginLeft: 4, marginTop: 2, children: /* @__PURE__ */ jsx(HelpOverlay, { onClose: props.onHelpClose }) })
  ] }) });
}
export {
  App,
  DEFAULT_ROUTES
};
//# sourceMappingURL=App.js.map