"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import {
  AlertTriangle,
  BadgeQuestionMark,
  Database,
  ExternalLink,
  FileQuestion,
  Lightbulb,
  Loader2,
  PanelRightOpen,
  Search
} from "lucide-react";
import { useT } from "@open-mercato/shared/lib/i18n/context";
import { cn } from "@open-mercato/shared/lib/utils";
import { apiCall } from "../backend/utils/apiCall.js";
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle
} from "../primitives/dialog.js";
import { Button } from "../primitives/button.js";
import { IconButton } from "../primitives/icon-button.js";
import { Kbd, KbdShortcut } from "../primitives/kbd.js";
import { useAiDock } from "./AiDock.js";
import { useAiChatSessions } from "./AiChatSessions.js";
import { ChatPaneTabs } from "./ChatPaneTabs.js";
import { AiIcon } from "./AiIcon.js";
const LazyAiChat = React.lazy(async () => {
  const mod = await import("./AiChat.js");
  return { default: mod.AiChat };
});
const DEFAULT_AGENTS_ENDPOINT = "/api/ai_assistant/ai/agents";
const DEFAULT_HEALTH_ENDPOINT = "/api/ai_assistant/health";
const AI_ASSISTANT_DOCS_URL = "https://docs.openmercato.com/framework/ai-assistant/overview";
const AI_ASSISTANT_SETTINGS_DOCS_URL = "https://docs.openmercato.com/framework/ai-assistant/settings";
const AI_ASSISTANT_LAUNCHER_OPEN_EVENT = "om:open-ai-assistant-launcher";
function isMutationCapable(policy) {
  return policy === "confirm-required" || policy === "destructive-confirm-required";
}
function normalizeAgents(payload) {
  if (!payload || !Array.isArray(payload.agents)) return [];
  const result = [];
  for (const raw of payload.agents) {
    if (!raw || typeof raw.id !== "string" || raw.id.length === 0) continue;
    if (typeof raw.label !== "string" || raw.label.length === 0) continue;
    result.push({
      id: raw.id,
      label: raw.label,
      description: typeof raw.description === "string" ? raw.description : null,
      moduleId: typeof raw.moduleId === "string" ? raw.moduleId : null,
      mutationPolicy: typeof raw.mutationPolicy === "string" ? raw.mutationPolicy : null,
      keywords: Array.isArray(raw.keywords) ? raw.keywords.filter((value) => typeof value === "string" && value.length > 0) : [],
      suggestions: Array.isArray(raw.suggestions) ? raw.suggestions.map((suggestion) => {
        if (!suggestion) return null;
        if (typeof suggestion.label !== "string" || typeof suggestion.prompt !== "string") {
          return null;
        }
        if (!suggestion.label || !suggestion.prompt) return null;
        return { label: suggestion.label, prompt: suggestion.prompt };
      }).filter((suggestion) => suggestion !== null) : []
    });
  }
  return result;
}
function matchesQuery(agent, query) {
  if (!query) return true;
  const needle = query.trim().toLowerCase();
  if (!needle) return true;
  if (agent.label.toLowerCase().includes(needle)) return true;
  if (agent.id.toLowerCase().includes(needle)) return true;
  if (agent.description && agent.description.toLowerCase().includes(needle)) return true;
  if (agent.moduleId && agent.moduleId.toLowerCase().includes(needle)) return true;
  if (agent.keywords && agent.keywords.some((keyword) => keyword.toLowerCase().includes(needle))) return true;
  return false;
}
function isTextEntryTarget(target) {
  if (!target || !(target instanceof HTMLElement)) return false;
  const tag = target.tagName;
  if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
  if (target.isContentEditable) return true;
  return false;
}
function AiAssistantLauncher({
  variant: _variant = "topbar",
  agentsEndpoint = DEFAULT_AGENTS_ENDPOINT,
  healthEndpoint = DEFAULT_HEALTH_ENDPOINT,
  skipHealthCheck = false,
  disableGlobalShortcut = false,
  className
}) {
  const t = useT();
  const dock = useAiDock();
  const [healthy, setHealthy] = React.useState(skipHealthCheck ? true : null);
  const [agents, setAgents] = React.useState([]);
  const [agentsLoaded, setAgentsLoaded] = React.useState(false);
  const [agentsError, setAgentsError] = React.useState(null);
  const [aiConfigured, setAiConfigured] = React.useState(null);
  const [pickerOpen, setPickerOpen] = React.useState(false);
  const [activeAgent, setActiveAgent] = React.useState(null);
  const [chatOpen, setChatOpen] = React.useState(false);
  const [query, setQuery] = React.useState("");
  const [highlight, setHighlight] = React.useState(0);
  React.useEffect(() => {
    if (skipHealthCheck) return;
    let cancelled = false;
    apiCall(healthEndpoint, {
      credentials: "same-origin",
      headers: { "x-om-forbidden-redirect": "0", "x-om-unauthorized-redirect": "0" }
    }).then((call) => {
      if (cancelled) return;
      if (!call.ok) {
        setHealthy(true);
        return;
      }
      const body = call.result;
      if (body && typeof body === "object" && body.healthy === false) {
        setHealthy(false);
        return;
      }
      setHealthy(true);
    }).catch(() => {
      if (cancelled) return;
      setHealthy(true);
    });
    return () => {
      cancelled = true;
    };
  }, [healthEndpoint, skipHealthCheck]);
  React.useEffect(() => {
    if (agentsLoaded) return;
    let cancelled = false;
    apiCall(agentsEndpoint, {
      credentials: "same-origin",
      headers: { "x-om-forbidden-redirect": "0", "x-om-unauthorized-redirect": "0" }
    }).then((call) => {
      if (cancelled) return;
      if (!call.ok) {
        setAgents([]);
        setAgentsError(`agents endpoint returned ${call.status}`);
        setAgentsLoaded(true);
        return;
      }
      if (call.result) {
        setAgents(normalizeAgents(call.result));
        setAgentsError(null);
        if (typeof call.result.aiConfigured === "boolean") {
          setAiConfigured(call.result.aiConfigured);
        }
      } else {
        setAgents([]);
        setAgentsError("Empty agents response");
      }
      setAgentsLoaded(true);
    }).catch((error) => {
      if (cancelled) return;
      setAgents([]);
      setAgentsError(error instanceof Error ? error.message : String(error));
      setAgentsLoaded(true);
    });
    return () => {
      cancelled = true;
    };
  }, [agentsEndpoint, agentsLoaded]);
  const filteredAgents = React.useMemo(
    () => agents.filter((agent) => matchesQuery(agent, query)),
    [agents, query]
  );
  React.useEffect(() => {
    if (filteredAgents.length === 0) {
      if (highlight !== 0) setHighlight(0);
      return;
    }
    if (highlight >= filteredAgents.length) setHighlight(0);
  }, [filteredAgents, highlight]);
  const openPicker = React.useCallback(() => {
    setQuery("");
    setHighlight(0);
    setPickerOpen(true);
  }, []);
  React.useEffect(() => {
    if (typeof window === "undefined") return;
    const listener = () => openPicker();
    window.addEventListener(AI_ASSISTANT_LAUNCHER_OPEN_EVENT, listener);
    return () => window.removeEventListener(AI_ASSISTANT_LAUNCHER_OPEN_EVENT, listener);
  }, [openPicker]);
  const handleSelectAgent = React.useCallback((agent) => {
    if (dock.state.assistant?.agent === agent.id) {
      dock.dock(dock.state.assistant);
      setPickerOpen(false);
      setChatOpen(false);
      return;
    }
    setActiveAgent(agent);
    setPickerOpen(false);
    setChatOpen(true);
  }, [dock]);
  React.useEffect(() => {
    if (disableGlobalShortcut) return;
    if (typeof window === "undefined") return;
    if (healthy !== true) return;
    if (!agentsLoaded || agents.length === 0) return;
    const listener = (event) => {
      const isModifier = event.metaKey || event.ctrlKey;
      if (!isModifier) return;
      if (event.shiftKey || event.altKey) return;
      if (event.key !== "l" && event.key !== "L") return;
      if (isTextEntryTarget(event.target)) return;
      event.preventDefault();
      openPicker();
    };
    window.addEventListener("keydown", listener);
    return () => window.removeEventListener("keydown", listener);
  }, [agents.length, agentsLoaded, disableGlobalShortcut, healthy, openPicker]);
  const handlePickerKeyDown = React.useCallback(
    (event) => {
      if (aiConfigured === false || filteredAgents.length === 0) {
        if (event.key === "Escape") {
          setPickerOpen(false);
        }
        return;
      }
      if (event.key === "ArrowDown") {
        event.preventDefault();
        setHighlight((current) => (current + 1) % filteredAgents.length);
      } else if (event.key === "ArrowUp") {
        event.preventDefault();
        setHighlight((current) => (current - 1 + filteredAgents.length) % filteredAgents.length);
      } else if (event.key === "Enter") {
        event.preventDefault();
        const target = filteredAgents[highlight] ?? filteredAgents[0];
        if (target) handleSelectAgent(target);
      } else if (event.key === "Escape") {
        setPickerOpen(false);
      }
    },
    [aiConfigured, filteredAgents, handleSelectAgent, highlight]
  );
  const triggerLabel = t("ai_assistant.launcher.triggerAriaLabel", "Open AI assistant");
  const dialogTitle = t("ai_assistant.launcher.dialogTitle", "AI assistants");
  const dialogDescription = t(
    "ai_assistant.launcher.dialogDescription",
    "Pick an assistant. Use \u2191/\u2193 to navigate, Enter to launch, Esc to close."
  );
  const placeholder = t("ai_assistant.launcher.searchPlaceholder", "Search assistants...");
  const emptyText = t("ai_assistant.launcher.empty", "No assistants match your search.");
  const noneText = t(
    "ai_assistant.launcher.none",
    "No assistants are available for your account."
  );
  const writesBadge = t("ai_assistant.launcher.writesBadge", "Can write");
  const launcherSuggestions = React.useMemo(
    () => {
      const generic = [
        {
          label: t("ai_assistant.launcher.welcome.suggestion1", "What can you help me with?"),
          prompt: "What can you help me with on this tenant?",
          icon: /* @__PURE__ */ jsx(BadgeQuestionMark, { className: "size-4 text-foreground" })
        },
        {
          label: t("ai_assistant.launcher.welcome.suggestion2", "Show what data you can access"),
          prompt: "Describe the data you can read for this tenant \u2014 entities, fields, and limits.",
          icon: /* @__PURE__ */ jsx(Database, { className: "size-4 text-foreground" })
        },
        {
          label: t("ai_assistant.launcher.welcome.suggestion3", "Suggest things to try"),
          prompt: "Suggest five concrete questions I could ask you that would surface useful insights for this tenant.",
          icon: /* @__PURE__ */ jsx(Lightbulb, { className: "size-4 text-foreground" })
        },
        {
          label: t("ai_assistant.launcher.welcome.suggestion4", "How do I use this assistant?"),
          prompt: "Walk me through how to use this assistant: when to ask, what tools you call, and how confirmations work.",
          icon: /* @__PURE__ */ jsx(FileQuestion, { className: "size-4 text-foreground" })
        }
      ];
      return [...activeAgent?.suggestions ?? [], ...generic];
    },
    [t, activeAgent]
  );
  const launcherContextItems = React.useMemo(() => [], []);
  const shouldRender = healthy !== false && agentsLoaded && agents.length > 0;
  if (!shouldRender) return null;
  const shortLabel = t("ai_assistant.launcher.triggerLabel", "AI");
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsxs(
      Button,
      {
        type: "button",
        variant: "ghost",
        size: "sm",
        onClick: openPicker,
        className: cn("hidden sm:inline-flex items-center gap-2 text-foreground [&_svg]:text-foreground", className),
        "data-ai-launcher-trigger": "",
        "aria-label": triggerLabel,
        title: triggerLabel,
        children: [
          /* @__PURE__ */ jsx(AiIcon, { className: "size-4 text-foreground" }),
          /* @__PURE__ */ jsx("span", { children: shortLabel }),
          /* @__PURE__ */ jsx("span", { className: "ml-2 rounded border px-1 text-xs text-muted-foreground", children: "\u2318L" })
        ]
      }
    ),
    /* @__PURE__ */ jsx(
      IconButton,
      {
        type: "button",
        variant: "ghost",
        size: "sm",
        className: "sm:hidden text-foreground [&_svg]:text-foreground",
        onClick: openPicker,
        "aria-label": triggerLabel,
        "data-ai-launcher-trigger-mobile": "",
        children: /* @__PURE__ */ jsx(AiIcon, { className: "size-4 text-foreground" })
      }
    ),
    /* @__PURE__ */ jsx(Dialog, { open: pickerOpen, onOpenChange: setPickerOpen, children: /* @__PURE__ */ jsxs(
      DialogContent,
      {
        className: "sm:max-w-lg p-0 gap-0 overflow-hidden",
        "data-ai-launcher-picker": "",
        onKeyDown: handlePickerKeyDown,
        children: [
          /* @__PURE__ */ jsxs(DialogHeader, { className: "px-4 pt-4 pb-2", children: [
            /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2 text-base", children: [
              /* @__PURE__ */ jsx(AiIcon, { className: "size-4" }),
              dialogTitle
            ] }),
            /* @__PURE__ */ jsx(DialogDescription, { className: "text-xs", children: dialogDescription })
          ] }),
          /* @__PURE__ */ jsx("div", { className: "border-y border-border bg-muted/30 px-3 py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
            /* @__PURE__ */ jsx(
              Search,
              {
                className: "pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 text-muted-foreground",
                "aria-hidden": true
              }
            ),
            /* @__PURE__ */ jsx(
              "input",
              {
                autoFocus: true,
                type: "text",
                value: query,
                onChange: (event) => {
                  setQuery(event.target.value);
                  setHighlight(0);
                },
                placeholder,
                className: "w-full rounded-md border border-input bg-background px-8 py-1.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40",
                "data-ai-launcher-search-input": ""
              }
            )
          ] }) }),
          /* @__PURE__ */ jsx(
            "div",
            {
              className: "max-h-80 overflow-y-auto py-1",
              "data-ai-launcher-list": "",
              role: "listbox",
              "aria-label": dialogTitle,
              children: aiConfigured === false ? /* @__PURE__ */ jsx(AiProviderSetupPanel, { t }) : filteredAgents.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-4 py-6 text-center text-xs text-muted-foreground", children: agents.length === 0 ? noneText : emptyText }) : filteredAgents.map((agent, index) => {
                const isActive = index === highlight;
                const writes = isMutationCapable(agent.mutationPolicy);
                return /* @__PURE__ */ jsxs(
                  "button",
                  {
                    type: "button",
                    role: "option",
                    "aria-selected": isActive,
                    onMouseEnter: () => setHighlight(index),
                    onClick: () => handleSelectAgent(agent),
                    "data-ai-launcher-agent-id": agent.id,
                    "data-active": isActive ? "true" : "false",
                    className: cn(
                      "flex w-full items-start gap-3 px-3 py-2 text-left text-sm transition-colors",
                      isActive ? "bg-accent text-accent-foreground" : "hover:bg-accent/60"
                    ),
                    children: [
                      /* @__PURE__ */ jsx("span", { className: "mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-brand-violet/10", children: /* @__PURE__ */ jsx(AiIcon, { className: "size-3.5" }) }),
                      /* @__PURE__ */ jsxs("span", { className: "flex-1 min-w-0 space-y-0.5", children: [
                        /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
                          /* @__PURE__ */ jsx("span", { className: "truncate font-medium leading-tight", children: agent.label }),
                          /* @__PURE__ */ jsx(
                            "span",
                            {
                              className: "inline-flex items-center rounded-full border border-border bg-secondary px-1.5 py-0 text-[10px] font-medium uppercase tracking-wide text-secondary-foreground",
                              "data-ai-beta-chip": "",
                              children: t("ai_assistant.chat.betaChip", "beta")
                            }
                          ),
                          writes ? /* @__PURE__ */ jsx(
                            "span",
                            {
                              className: "inline-flex items-center rounded-full border border-border bg-secondary px-1.5 py-0 text-[10px] font-medium text-secondary-foreground",
                              "data-ai-launcher-writes": "",
                              children: writesBadge
                            }
                          ) : null
                        ] }),
                        agent.description ? /* @__PURE__ */ jsx("span", { className: "block truncate text-xs text-muted-foreground", children: agent.description }) : null,
                        /* @__PURE__ */ jsx("span", { className: "block truncate font-mono text-[10px] text-muted-foreground/80", children: agent.id })
                      ] })
                    ]
                  },
                  agent.id
                );
              })
            }
          ),
          /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 border-t border-border px-3 py-2 text-[11px] text-muted-foreground", children: [
            /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
              /* @__PURE__ */ jsx(KbdShortcut, { keys: ["\u2191", "\u2193"] }),
              " ",
              t("ai_assistant.launcher.hint.navigate", "Navigate"),
              /* @__PURE__ */ jsx("span", { className: "mx-1 text-border", children: "\xB7" }),
              /* @__PURE__ */ jsx(Kbd, { children: "Enter" }),
              " ",
              t("ai_assistant.launcher.hint.launch", "Launch"),
              /* @__PURE__ */ jsx("span", { className: "mx-1 text-border", children: "\xB7" }),
              /* @__PURE__ */ jsx(Kbd, { children: "Esc" }),
              " ",
              t("ai_assistant.launcher.hint.close", "Close")
            ] }),
            /* @__PURE__ */ jsx("span", { className: "hidden sm:inline-flex items-center gap-1", children: /* @__PURE__ */ jsx(KbdShortcut, { keys: ["\u2318", "L"] }) })
          ] }),
          agentsError ? /* @__PURE__ */ jsxs(
            "div",
            {
              className: "border-t border-status-error-border bg-status-error-bg px-3 py-1.5 text-[11px] text-status-error-foreground",
              "data-ai-launcher-error": "",
              children: [
                /* @__PURE__ */ jsx(Loader2, { className: "mr-1 inline size-3 animate-spin", "aria-hidden": true }),
                agentsError
              ]
            }
          ) : null
        ]
      }
    ) }),
    /* @__PURE__ */ jsx(Dialog, { open: chatOpen, onOpenChange: setChatOpen, children: /* @__PURE__ */ jsxs(
      DialogContent,
      {
        className: cn(
          // Mobile: full-screen sheet (matches per-page assistant
          // triggers). Desktop (≥sm): right-anchored side sheet so the
          // chat doesn't appear randomly cropped or off-center.
          // The Dialog primitive applies a centering transform at the
          // sm breakpoint (`sm:top-1/2 sm:left-1/2 sm:-translate-x-1/2
          // sm:-translate-y-1/2 sm:inset-auto`); each piece must be
          // overridden at the same breakpoint or the panel renders half
          // off the viewport on the left.
          "top-0 left-0 right-0 bottom-0 translate-x-0 translate-y-0 max-w-none w-screen h-svh max-h-svh rounded-none",
          "sm:top-0 sm:bottom-0 sm:right-0 sm:left-auto sm:translate-x-0 sm:translate-y-0",
          "sm:max-w-xl sm:w-[36rem] sm:rounded-l-2xl sm:h-screen sm:max-h-screen",
          "flex flex-col gap-3 p-4 z-[70]"
        ),
        "data-ai-launcher-sheet": "",
        children: [
          /* @__PURE__ */ jsxs(DialogHeader, { children: [
            /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 pr-8", children: [
              /* @__PURE__ */ jsx(
                IconButton,
                {
                  type: "button",
                  variant: "ghost",
                  size: "sm",
                  "aria-label": t("ai_assistant.launcher.sheet.dock", "Dock to side"),
                  title: t("ai_assistant.launcher.sheet.dock", "Dock to side"),
                  onClick: () => {
                    if (!activeAgent) return;
                    dock.dock({
                      agent: activeAgent.id,
                      label: activeAgent.label,
                      description: activeAgent.moduleId ?? t("ai_assistant.launcher.dock.subtitle", "AI assistant"),
                      pageContext: {},
                      placeholder: t(
                        "ai_assistant.launcher.composerPlaceholder",
                        "Ask anything\u2026"
                      ),
                      suggestions: launcherSuggestions,
                      contextItems: launcherContextItems,
                      welcomeTitle: activeAgent.label,
                      welcomeDescription: activeAgent.description ?? t(
                        "ai_assistant.launcher.welcome.fallback",
                        "How can I help?"
                      )
                    });
                    setChatOpen(false);
                  },
                  "data-ai-launcher-dock": "",
                  className: "hidden lg:inline-flex shrink-0",
                  children: /* @__PURE__ */ jsx(PanelRightOpen, { className: "size-4", "aria-hidden": true })
                }
              ),
              /* @__PURE__ */ jsxs(DialogTitle, { className: "flex-1 min-w-0 flex items-center gap-2", children: [
                /* @__PURE__ */ jsx(AiIcon, { className: "size-4 shrink-0" }),
                /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: activeAgent?.label ?? dialogTitle }),
                /* @__PURE__ */ jsx(
                  "span",
                  {
                    className: "inline-flex shrink-0 items-center rounded-full border border-border bg-secondary px-1.5 py-0 text-[10px] font-medium uppercase tracking-wide text-secondary-foreground",
                    "data-ai-beta-chip": "",
                    children: t("ai_assistant.chat.betaChip", "beta")
                  }
                )
              ] })
            ] }),
            activeAgent?.description ? /* @__PURE__ */ jsx(DialogDescription, { children: activeAgent.description }) : null
          ] }),
          activeAgent ? /* @__PURE__ */ jsx(
            LauncherChatBody,
            {
              activeAgent,
              suggestions: launcherSuggestions,
              contextItems: launcherContextItems,
              welcomeFallback: t(
                "ai_assistant.launcher.welcome.fallback",
                "How can I help?"
              ),
              placeholder: t(
                "ai_assistant.launcher.composerPlaceholder",
                "Ask anything\u2026"
              )
            }
          ) : null
        ]
      }
    ) })
  ] });
}
function LauncherChatBody({
  activeAgent,
  suggestions,
  contextItems,
  welcomeFallback,
  placeholder
}) {
  const sessions = useAiChatSessions();
  const session = sessions.getActiveSession(activeAgent.id);
  React.useEffect(() => {
    if (!session) sessions.ensureSession(activeAgent.id);
  }, [activeAgent.id, session, sessions]);
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(ChatPaneTabs, { agentId: activeAgent.id, className: "border-b" }),
    /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1", "data-ai-launcher-chat-container": "", children: session ? /* @__PURE__ */ jsx(React.Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
      LazyAiChat,
      {
        agent: activeAgent.id,
        conversationId: session.conversationId,
        pageContext: {},
        className: "h-full",
        placeholder,
        suggestions,
        contextItems,
        welcomeTitle: activeAgent.label,
        welcomeDescription: activeAgent.description ?? welcomeFallback
      },
      session.id
    ) }) : null })
  ] });
}
var AiAssistantLauncher_default = AiAssistantLauncher;
function AiProviderSetupPanel({ t }) {
  return /* @__PURE__ */ jsx("div", { className: "px-4 py-5", "data-ai-launcher-provider-setup": "", children: /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-status-warning-border bg-status-warning-bg p-4 text-status-warning-text", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
    /* @__PURE__ */ jsx("span", { className: "mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full bg-background/70 text-status-warning-icon", children: /* @__PURE__ */ jsx(AlertTriangle, { className: "size-4", "aria-hidden": true }) }),
    /* @__PURE__ */ jsxs("div", { className: "min-w-0 space-y-3", children: [
      /* @__PURE__ */ jsxs("div", { children: [
        /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: t("ai_assistant.launcher.setup.title", "Configure an AI provider to use assistants") }),
        /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs leading-5 text-status-warning-text/90", children: t(
          "ai_assistant.launcher.setup.body",
          "AI assistants are installed, but no provider key is configured. Set OPENCODE_PROVIDER and one matching API key in your .env file, then restart the app."
        ) })
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-status-warning-border/70 bg-background/80 p-3 font-mono text-[11px] leading-5 text-foreground", children: [
        /* @__PURE__ */ jsx("div", { children: "OPENCODE_PROVIDER=anthropic" }),
        /* @__PURE__ */ jsx("div", { children: "ANTHROPIC_API_KEY=..." }),
        /* @__PURE__ */ jsx("div", { className: "mt-2 text-muted-foreground", children: "# or" }),
        /* @__PURE__ */ jsx("div", { children: "OPENCODE_PROVIDER=openai" }),
        /* @__PURE__ */ jsx("div", { children: "OPENAI_API_KEY=..." }),
        /* @__PURE__ */ jsx("div", { className: "mt-2 text-muted-foreground", children: "# or" }),
        /* @__PURE__ */ jsx("div", { children: "OPENCODE_PROVIDER=google" }),
        /* @__PURE__ */ jsx("div", { children: "GOOGLE_GENERATIVE_AI_API_KEY=..." })
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
        /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "outline", children: /* @__PURE__ */ jsxs("a", { href: AI_ASSISTANT_DOCS_URL, target: "_blank", rel: "noreferrer", children: [
          t("ai_assistant.launcher.setup.docs", "AI assistant docs"),
          /* @__PURE__ */ jsx(ExternalLink, { className: "ml-1 size-3", "aria-hidden": true })
        ] }) }),
        /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant: "ghost", children: /* @__PURE__ */ jsxs("a", { href: AI_ASSISTANT_SETTINGS_DOCS_URL, target: "_blank", rel: "noreferrer", children: [
          t("ai_assistant.launcher.setup.settingsDocs", "Provider settings"),
          /* @__PURE__ */ jsx(ExternalLink, { className: "ml-1 size-3", "aria-hidden": true })
        ] }) })
      ] })
    ] })
  ] }) }) });
}
export {
  AI_ASSISTANT_LAUNCHER_OPEN_EVENT,
  AiAssistantLauncher,
  AiAssistantLauncher_default as default
};
//# sourceMappingURL=AiAssistantLauncher.js.map
