@shawnstack/quickforge 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +12 -12
  2. package/bin/quickforge.mjs +9 -0
  3. package/dist/assets/AgentProfilesPage-DUmXUxjA.js +1 -0
  4. package/dist/assets/ChatPanelHost-Syx0SSLe.js +242 -0
  5. package/dist/assets/PluginsPage-kiBq0gOT.js +1 -0
  6. package/dist/assets/ScheduledTasksPage-Dw4-tgp9.js +2 -0
  7. package/dist/assets/SharedConversationPage-CaE9bNb9.js +1 -0
  8. package/dist/assets/TerminalDock-BYJcp8Ts.js +2 -0
  9. package/dist/assets/WorkspaceInspector-Bzmv8Cvi.js +3 -0
  10. package/dist/assets/WorkspaceReaderDialog-BJo_KEWi.js +1 -0
  11. package/dist/assets/diff-line-counts-BZoYp5ai.js +10 -0
  12. package/dist/assets/icons-47L5YLKz.js +1 -0
  13. package/dist/assets/index-CqfScETb.js +1200 -0
  14. package/dist/assets/index-DzkBgHZf.css +3 -0
  15. package/dist/assets/{monaco-DG4TcBMc.js → monaco-CGq6uVF1.js} +1 -1
  16. package/dist/assets/{react-vendor-CiCXOLb5.js → react-vendor-DunfCFfp.js} +1 -1
  17. package/dist/favicon.svg +16 -1
  18. package/dist/index.html +5 -5
  19. package/dist/manifest.webmanifest +30 -30
  20. package/package.json +3 -2
  21. package/server/acp/server.mjs +921 -0
  22. package/server/agent-manager.mjs +283 -45
  23. package/server/agent-profile-files.mjs +179 -0
  24. package/server/agent-profiles.mjs +59 -5
  25. package/server/approval-store.mjs +13 -1
  26. package/server/auto-compaction.mjs +111 -112
  27. package/server/channels/process-channel.mjs +278 -0
  28. package/server/channels/providers/wechat.mjs +271 -0
  29. package/server/channels/registry.mjs +58 -0
  30. package/server/context-usage.mjs +108 -0
  31. package/server/custom-commands.mjs +157 -28
  32. package/server/frontmatter.mjs +167 -0
  33. package/server/index.mjs +52 -3
  34. package/server/mcp/registry.mjs +40 -0
  35. package/server/project-config.mjs +43 -6
  36. package/server/routes/agent-profiles.mjs +6 -2
  37. package/server/routes/agent.mjs +13 -2
  38. package/server/routes/channels.mjs +145 -0
  39. package/server/routes/mcp.mjs +7 -1
  40. package/server/routes/models.mjs +68 -0
  41. package/server/routes/project.mjs +34 -4
  42. package/server/routes/scheduled-tasks.mjs +6 -5
  43. package/server/routes/shared-conversation.mjs +1 -1
  44. package/server/routes/storage.mjs +4 -2
  45. package/server/routes/system.mjs +27 -0
  46. package/server/routes/tools.mjs +17 -6
  47. package/server/routes/workspace.mjs +138 -0
  48. package/server/session-utils.mjs +10 -2
  49. package/server/storage.mjs +30 -2
  50. package/server/subagents.mjs +8 -6
  51. package/server/system-prompt.mjs +3 -2
  52. package/server/tools/definitions.mjs +19 -1
  53. package/server/tools/index.mjs +83 -0
  54. package/server/utils/package-update.mjs +156 -0
  55. package/dist/assets/AgentProfilesPage-C79teCgh.js +0 -1
  56. package/dist/assets/ChatPanelHost-BjdIshtX.js +0 -195
  57. package/dist/assets/PluginsPage-Dt7Iiddo.js +0 -1
  58. package/dist/assets/ScheduledTasksPage-C047y3p3.js +0 -2
  59. package/dist/assets/SharedConversationPage-8X8kfztQ.js +0 -1
  60. package/dist/assets/TerminalDock-CEuJNf0m.js +0 -2
  61. package/dist/assets/WorkspaceInspector-BIa5gLVs.js +0 -3
  62. package/dist/assets/WorkspaceReaderDialog-bTeERaGd.js +0 -6
  63. package/dist/assets/icons-Dsc5yL3l.js +0 -1
  64. package/dist/assets/index-CPAWYhzz.css +0 -3
  65. package/dist/assets/index-YTL26wyJ.js +0 -814
@@ -1,814 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatPanelHost-BjdIshtX.js","assets/rolldown-runtime-DWdDZTNf.js","assets/pi-web-ui-CBet4bMl.js","assets/pi-ai-Cx633yhb.js","assets/lit-vendor-Dr3cpBGF.js","assets/icons-Dsc5yL3l.js","assets/react-vendor-CiCXOLb5.js","assets/plugin-api-YfYj_Bd7.js","assets/logger-B65Akg8A.js","assets/TerminalDock-CEuJNf0m.js","assets/xterm-5XDrJ343.js","assets/xterm-BrP-ENHg.css","assets/ScheduledTasksPage-C047y3p3.js","assets/AgentProfilesPage-C79teCgh.js","assets/PluginsPage-Dt7Iiddo.js","assets/SharedConversationPage-8X8kfztQ.js","assets/WorkspaceInspector-BIa5gLVs.js","assets/WorkspaceReaderDialog-bTeERaGd.js","assets/monaco-DG4TcBMc.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{$ as t,A as n,B as r,F as i,G as a,H as o,I as s,J as c,L as l,M as u,N as d,O as f,P as p,S as m,T as h,V as g,X as _,Y as v,Z as y,_ as b,a as x,b as S,d as C,et as w,f as T,g as E,h as D,i as O,it as k,k as ee,l as A,m as j,n as M,nt as N,o as te,p as P,q as ne,rt as F,s as re,u as ie,v as ae,w as I,x as oe,y as L}from"./icons-Dsc5yL3l.js";import{i as se,n as ce,r as le}from"./react-vendor-CiCXOLb5.js";import{f as ue,p as R}from"./lit-vendor-Dr3cpBGF.js";import{n as de,r as fe,t as pe}from"./css-utils-rkE68RDy.js";import{_ as me,a as he,d as z,f as ge,g as _e,h as ve,i as ye,m as be,n as xe,o as Se,p as Ce,r as we,t as Te,u as Ee}from"./pi-web-ui-CBet4bMl.js";import{_ as De,p as Oe,y as ke}from"./pi-ai-Cx633yhb.js";import{t as B}from"./logger-B65Akg8A.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var V=e(k(),1),Ae=le(),je=`language`,Me=[`en`,`zh`],H={en:{language:`Language`,displayLanguage:`Display language`,languageDescription:`Choose the display language for 速构 QuickForge. The page will reload to apply the change.`,simplifiedChinese:`Simplified Chinese`,english:`English`,apply:`Apply`,noLanguageChange:`The selected language is already active.`,newChat:`New chat`,loadingChatWorkspace:`Loading chat workspace...`,localServiceUnavailableTitle:`Local QuickForge service unavailable`,localServiceUnavailableDescription:`QuickForge requires the local service for storage. Start QuickForge with npm run dev or the quickforge command, then reload this page.`,project:`Project`,projects:`Projects`,loadingProject:`Loading project...`,addProject:`Add project`,noProjects:`No projects yet.`,expandProject:`Expand project`,collapseProject:`Collapse project`,expandAllProjects:`Expand all projects`,collapseAllProjects:`Collapse all projects`,dragToReorder:`Drag to reorder`,newProjectChat:`New project chat`,projectChat:`Project chat`,normalChat:`Chat`,conversations:`Conversations`,noConversations:`No conversations`,filter:`Filter`,selecting:`Selecting...`,chooseFolder:`Choose folder`,selectProjectDirectory:`Select project directory`,selectProjectDirectoryDescription:`Browse local folders or paste a path, then choose the folder to add it as a project.`,quickAccess:`Quick access`,path:`Path`,go:`Go`,parentDirectory:`Parent directory`,noFolders:`No folders in this directory.`,selectThisFolder:`Select this folder`,folderPickerPathPlaceholder:`Enter or paste a folder path`,filesystemRootsFailed:`Failed to load filesystem roots.`,directoryLoadFailed:`Failed to load directory.`,noSavedConversations:`No saved conversations yet.`,rename:`Rename`,renameSession:`Rename conversation`,sessionName:`Conversation name`,deleteProject:`Delete project`,deleteProjectConfirm:`Are you sure you want to delete project "{name}"? Its conversations will be kept.`,deleteSession:`Delete session`,deleteSessionConfirm:`Are you sure you want to delete this conversation? This cannot be undone.`,confirm:`Confirm`,confirmDelete:`Delete`,settings:`Settings`,toggleSidebar:`Toggle sidebar`,failedToSelectProjectDirectory:`Failed to select project directory.`,projectSwitchFailed:`Failed to switch to the project for this conversation. Workspace tools were not started.`,copy:`Copy`,copied:`Copied`,rollback:`Rollback`,retry:`Retry`,reloadPage:`Reload page`,fork:`Fork`,forkConversation:`Fork conversation from here`,yoloEnabledTitle:`Workspace access enabled: local tools can use this project`,yoloDisabledTitle:`Workspace access locked: local tools are blocked`,planModeLabel:`Plan`,planModeEnabledTitle:`Plan mode enabled: send the next message as /plan. Click to remove. Shortcut: Shift+Tab`,planModeDisabledTitle:`Plan mode: send the next message as /plan. Shortcut: Shift+Tab`,composerPlaceholder:`Describe what you want to build, change, or debug...`,assistantWaitingThinking:`Thinking`,assistantWaitingOrganizing:`Organizing the answer`,assistantWaitingContinuing:`This may take a little longer`,assistantWaitingAriaLabel:`Assistant is preparing a response`,customCommandsHint:`Custom commands`,customCommandsEmptyHint:`No project commands yet.`,customCommandsListDescription:`List project custom commands`,customCommandsNewDescription:`Create a project custom command`,planCommandDescription:`Create a plan first; this turn cannot edit files or run commands.`,reviewCommandDescription:`Review pending code changes before commit; this turn cannot edit files.`,compactCommandDescription:`Create a new chat with this conversation compacted to reduce context usage.`,clearCommandDescription:`Clear the current chat history and context without calling the model.`,yoloBlockedReason:`Local tool {name} was blocked because YOLO mode is disabled. Enable YOLO mode inside the input box to grant local project access.`,globalToolBlockedReason:`Local tool {name} was blocked because this is a normal chat with no project attached. Start or open a project chat to use workspace tools.`,noActiveProjectToolBlockedReason:`Local tool {name} was blocked because there is no active project. Add or select a project to use workspace tools.`,generationStillRunning:`Generation is still running. Stop it or wait until it finishes before rolling back.`,noConversationTurnToRollback:`There is no conversation turn to roll back.`,rollbackConfirmTitle:`Confirm rollback?`,rollbackConfirm:`Roll back to before this message? This message and all following conversation history will be removed, and the message content will be restored to the composer.`,sharedRollbackConfirmTitle:`Confirm shared conversation rollback?`,sharedRollbackConfirm:`This will directly modify the sharer's original conversation. This message and all following conversation history will be removed, and the message content will be restored to the composer.`,confirmRollback:`Confirm rollback`,rollingBack:`Rolling back...`,rollbackFailed:`Rollback failed.`,retryFailed:`Retry failed.`,copyFailed:`Copy failed. Please check clipboard permissions.`,errorBoundaryTitle:`Something went wrong`,errorBoundaryUnexpected:`An unexpected error occurred.`,errorBoundaryTryAgain:`Try again`,execute:`Run`,addCustomModelFirst:`Please add a custom model in Settings and make sure the model ID is filled in before saving.`,modelSetupRequired:`Please add a model before starting a new chat.`,modelSetupTitle:`No model configured yet`,modelSetupDescription:`Add an OpenAI-Compatible or Anthropic-compatible model to start chatting. QuickForge will only use models that you configure.`,modelSetupSupports:`Supports LiteLLM, OpenRouter, DeepSeek, Qwen, Zhipu, Ollama, and most /v1/chat/completions services.`,modelSetupLocalStorage:`Providers, model IDs, and API keys are stored locally by the QuickForge service on this machine.`,modelSetupAddModel:`Add model`,modelSetupUseLiteLlmExample:`Use LiteLLM example`,firstUseGuideTitle:`Start with a safe workflow`,firstUseGuideDescription:`Add a project, ask QuickForge to understand it, and use /plan before granting local tool access for code changes.`,firstUseGuideStepModel:`Confirm the model you want to use.`,firstUseGuideStepProject:`Add a local project so AI can use workspace context.`,firstUseGuideStepPlan:`Use /plan first; that turn cannot edit files or run commands.`,firstUseGuideConfigureModel:`Configure model`,firstUseGuideAddProject:`Add project`,firstUseGuideUsePrompt:`Try example prompt`,firstUseGuideCopyPrompt:`Copy /plan example`,firstUseGuideDismiss:`Got it`,firstUseGuideProjectPrompt:`/plan Read this project and explain its structure, run commands, and main risks. Do not modify files yet.`,firstUseGuideGeneralPrompt:`/plan Break this request into implementation steps and risks first. Do not modify files yet.`,defaultOptions:`Default Options`,defaultOptionsDescription:`Configure the default model, thinking level, tool display, and appearance for new chats and scheduled tasks.`,defaultModel:`Default model`,defaultThinkingLevel:`Default thinking level`,toolDisplay:`Tool Display`,showToolDetails:`Show detailed tool JSON`,expandToolsByDefault:`Expand tool calls by default`,showToolDetailsDescription:`When disabled, tool input and details JSON are hidden. Console output, status, summaries, and diffs remain visible.`,fontSize:`Font size`,fontSizeDescription:`Adjust the global base font size and common body text size.`,baseFontSize:`Base font size (px)`,bodyFontSize:`Body text size (px)`,bodyFontSizeNote:`Applies to the Tailwind text-sm utility used by common interface text.`,toolDetailsHidden:`Tool details are hidden. Enable detailed tool JSON in Settings to view full parameters.`,toolArgsSummary:`Arguments summary`,saveDefaultOptions:`Save defaults`,saving:`Saving...`,defaultOptionsSaved:`Default options saved`,contextManagement:`Context Management`,autoCompactEnabled:`Automatically compact context`,autoCompactRequireConfirmation:`Ask before compacting automatically`,autoCompactTriggerNote:`Checks run before each model request. Lower the threshold or reduce the model Context Window to test triggering.`,autoCompactThresholdPercent:`Compact when context reaches (%)`,autoCompactKeepRecentTurns:`Keep recent user turns`,autoCompactDescription:`When the estimated next request reaches the configured share of the model context window, QuickForge summarizes older history and continues the current task. This uses one extra model call.`,autoCompactHistoryPreserved:`The full chat history remains visible; only the context sent to the model is compacted.`,thinkingLevel:`Thinking level`,thinkingOff:`Off`,thinkingLow:`Low`,thinkingMedium:`Medium`,thinkingHigh:`High`,thinkingXHigh:`XHigh`,currentConfiguration:`Current configuration`,thinkingSupported:`Thinking`,thinkingNotSupported:`This model does not support thinking levels.`,thinkingRequiresReasoningModel:`Thinking levels require a reasoning / thinking model.`,customModels:`Custom Models`,customModelsTitle:`Custom models`,customModelsDescription:`Only use custom OpenAI-Compatible models that you configure.`,addModel:`Add model`,editModel:`Edit model`,delete:`Delete`,editCustomModel:`Edit custom model`,addCustomModel:`Add custom model`,providerName:`Provider name`,providerNamePlaceholder:`e.g., LiteLLM`,protocolType:`Protocol type`,protocolHelp:`Use OpenAI Compatible for LiteLLM, OpenRouter, and most /v1/chat/completions services. Use Anthropic Messages only for the direct Anthropic API.`,apiKey:`API Key`,apiKeyPlaceholder:`Leave empty if not required`,showApiKey:`Show API Key`,hideApiKey:`Hide API Key`,customHeaders:`Custom Headers JSON`,customHeadersPlaceholder:`{
3
- "X-Custom-Header": "value"
4
- }`,customHeadersHelp:`Optional provider-level HTTP headers. Must be a JSON object with string values. Headers are saved locally with this model configuration.`,invalidHeadersJson:`Custom headers must be a valid JSON object with string key-value pairs.`,modelId:`Model ID`,modelIdPlaceholder:`e.g., anthropic/claude-sonnet-4`,contextWindow:`Context Window`,maxTokens:`Max Tokens`,reasoningModel:`Reasoning / Thinking model (DeepSeek V4, Qwen, etc.)`,providerProtocol:`Protocol`,model:`Model`,noModelAdded:`No model added`,modelsCount:`{count} model(s)`,modelIndex:`Model #{index}`,modelsList:`Models`,atLeastOneModel:`At least one model is required.`,duplicateModelId:`Duplicate model IDs are not allowed.`,cancel:`Cancel`,save:`Save`,yes:`Yes`,no:`No`,loading:`Loading...`,noCustomModels:`No custom models yet. Click "Add model".`,fillProviderBaseUrlModel:`Please fill in provider name and Base URL.`,saveCustomModelFailed:`Failed to save custom model.`,confirmDeleteProvider:`Delete {name}?`,deleteFailed:`Delete failed.`,selectCustomModel:`Select custom model`,close:`Close`,searchModels:`Search models...`,noMatchingCustomModels:`No matching custom models`,readFile:`Read File`,searchFiles:`Search Files`,writeFile:`Write File`,editFile:`Edit File`,runCommand:`Run Command`,executeInTerminal:`Run in terminal`,confirmExecuteCommandTitle:`Run command in terminal?`,confirmExecuteMultipleCommands:`This will run multiple lines in your local terminal. Continue?`,confirmExecuteDangerousCommand:`This command may modify your system, publish packages, push code, or run a remote script. Continue?`,terminalCommandExecuteFailed:`Failed to run command in terminal.`,runSubagent:`Run subagent`,subagentGeneral:`General`,subagentExplore:`Explore`,subagentRunning:`{name} running`,subagentCompleted:`{name} completed`,subagentFailed:`{name} failed`,subagentTask:`Task`,subagentContext:`Context`,subagentExpectedOutput:`Expected output`,subagentResult:`Result`,subagentToolCalls:`Tool calls`,subagentToolApprovalWaiting:`{source} requests approval: {toolName}`,toolApprovalSourceSubagent:`Source: {source} subagent`,activateSkill:`Activate Skill`,readSkillResource:`Read Skill Resource`,yoloModeSyncFailed:`Failed to sync YOLO mode. The previous state has been restored.`,toolApprovalFailed:`Failed to submit tool approval. Please try again.`,toolApprovalSubmitting:`Submitting...`,terminateCommand:`Terminate`,terminateCommandTitle:`Terminate this running command`,commandTerminateRequested:`Terminating...`,running:`Running`,done:`Done`,error:`Error`,taskCompleted:`Task completed`,taskError:`Task error`,called:`Called`,input:`Input`,output:`Output`,details:`Details`,scheduledTasks:`Scheduled Tasks`,scheduledTasksDescription:`Tasks are saved in the local backend service and run by the cron expression parsed by AI.`,createTask:`Create task`,editTask:`Edit`,cancelEditTask:`Cancel edit`,saveTask:`Save task`,taskScheduleDescriptionLabel:`Schedule description`,taskScheduleDescriptionPlaceholder:`e.g., Every day at 9 AM, send this to AI: generate my daily sales report.`,quickAiParseTask:`AI parses this description into a cron expression. The system stores and runs by cron.`,taskTitleLabel:`Task name`,taskTitlePlaceholder:`e.g., Daily work summary`,promptContentLabel:`AI will send this content`,promptContentPlaceholder:`Write the exact content that should be sent to AI when this task runs.`,taskEnabledSwitch:`Enable this task`,taskInstructionPlaceholder:`e.g., Generate a daily sales report at 9 AM every day`,aiParseTask:`AI Parse`,confirmCreate:`Confirm create`,taskList:`Task list`,noScheduledTasks:`No scheduled tasks yet. Enter a natural language instruction above to create one.`,taskEnabled:`Enabled`,taskRunning:`Running`,taskPaused:`Paused`,taskFinished:`Completed`,taskFailed:`Failed`,executeNow:`Run now`,enable:`Enable`,pauseTask:`Pause`,deleteTask:`Delete`,recentExecutions:`Recent executions`,executionSuccess:`Success`,executionRunning:`Running`,nextExecution:`Next`,lastExecution:`Last`,noModelAvailable:`No models available`,noProjectBound:`No project`,aiParsed:`AI parsed, please confirm`,taskName:`Task name`,executionRule:`Execution rule`,nextExecutionTime:`Next execution`,taskProject:`Project`,taskThinkingLevel:`Thinking`,aiInstruction:`AI instruction`,taskModel:`Model`,taskThinking:`Thinking`,taskProjectLabel:`Project`,taskExecutionMode:`Execution mode`,taskExecutionModeSerial:`Serial`,taskExecutionModeParallel:`Parallel`,taskExecutionModeHelp:`This only controls whether the same task may overlap. Different scheduled tasks still run in parallel.`,tasksCount:`{total} tasks, {enabled} enabled`,confirmDeleteTask:`Are you sure you want to delete this scheduled task? This cannot be undone.`,waitingForResult:`Waiting for result`,autoRun:`Auto`,manualRun:`Manual test`,runInputContent:`Sent to AI`,runAiResult:`AI result`,runDuration:`Duration: `,taskListTab:`Task list`,executionHistoryTab:`Execution history`,agentsTab:`Agents`,agentsDescription:`Create reusable Agent Profiles for scheduled tasks and run_subagent delegation.`,createAgent:`Create agent`,editAgent:`Edit agent`,builtinAgent:`Built-in`,builtinAgentReadonly:`Built-in agents are read-only in this version.`,enabledAsSubagent:`Enabled as subagent`,noDescription:`No description.`,maxRuntimeMs:`Max runtime: `,maxToolCalls:`Max tool calls: `,defaultAgent:`Default Agent`,executionAgent:`Execution Agent: `,agentName:`Agent name`,agentLabel:`Display name`,agentLabelPlaceholder:`e.g., Code Review Agent`,agentDescription:`Description`,agentSystemPrompt:`System prompt`,allowedTools:`Allowed tools`,highRiskTool:`High risk`,confirmDeleteAgent:`Are you sure you want to delete this custom agent? Scheduled tasks using it will fall back to the default agent.`,aiFillAgent:`AI fill`,aiFillAgentDescription:`Describe the agent you want. AI will only fill agent name, display name, description, and system prompt.`,aiFillAgentPlaceholder:`e.g., Create a read-only code review agent focused on architecture, bugs, and test coverage.`,aiFillAgentLoading:`Generating...`,aiFillAgentNoModel:`Please configure a default model first.`,aiFillAgentFailed:`AI fill failed. Please check model configuration and API key, then try again.`,aiFillAgentInputRequired:`Please describe the agent you want to create.`,taskContent:`Task content`,viewDetails:`View details`,moreActions:`More actions`,historyFilters:`Filters`,allTasks:`All tasks`,allStatuses:`All statuses`,allTriggers:`All triggers`,triggerType:`Trigger`,keyword:`Keyword`,keywordPlaceholder:`Search input, result, or error`,startTime:`Start time`,endTime:`End time`,query:`Search`,reset:`Reset`,previousPage:`Previous`,nextPage:`Next`,pageSize:`{size} / page`,paginationSummary:`Page {page} / {pages}, {total} total`,noExecutionHistory:`No execution history yet.`,viewConversation:`View conversation`,createdAt:`Created at`,status:`Status`,search:`Search`,searchDialog:`Search conversations...`,noSearchResults:`No matching conversations found`,searchHint:`Enter keywords to search loaded conversations`,scheduledTasksLabel:`Scheduled Tasks`,skills:`Skills`,mcp:`MCP`,mcpServers:`MCP Servers`,plugins:`Plugins`,pluginMentionHeader:`Plugins`,composerAddMenu:`Add`,composerAddAttachment:`Attachment`,composerAddPlugins:`Plugins`,composerAddBack:`Back`,pluginOpenaiDocumentsName:`Documents`,pluginOpenaiDocumentsDescription:`Create and edit document artifacts`,pluginOpenaiSpreadsheetsName:`Spreadsheets`,pluginOpenaiSpreadsheetsDescription:`Create, analyze, and structure spreadsheet files`,pluginOpenaiPresentationsName:`Presentations`,pluginOpenaiPresentationsDescription:`Create and edit presentations`,pluginsDescription:`Manage local QuickForge plugins. This first version supports manifest-based plugins that contribute Agent tools.`,pluginsReload:`Reload plugins`,loadingPlugins:`Loading plugins...`,noPlugins:`No plugins found`,noPluginsDescription:`Place a plugin folder with plugin.json under one of these search paths, then reload.`,pluginsCount:`{total} plugins, {enabled} enabled`,pluginToolsCount:`{count} tools`,pluginPermissionsCount:`{count} permissions`,pluginDetails:`Plugin details`,pluginVersion:`Version`,pluginStatusLoaded:`Loaded`,pluginStatusDisabled:`Disabled`,pluginStatusError:`Error`,pluginTools:`Tools`,pluginPermissions:`Declared permissions`,pluginNoTools:`No tools declared.`,pluginNoPermissions:`No permissions declared.`,pluginTrustedNotice:`Plugins are local trusted Node.js code in this MVP; permissions are displayed for review and future enforcement.`,pluginDiscoveryErrors:`Plugin discovery errors`,enablePlugin:`Enable`,disablePlugin:`Disable`,pluginsLoadFailed:`Failed to load plugins.`,pluginsSaveFailed:`Failed to update plugin.`,manageMcpServers:`Manage MCP servers`,mcpNoServersTitle:`MCP server management is ready for setup`,mcpNoServersDescription:`No MCP servers yet. Paste an mcpServers JSON configuration on the right to add one.`,mcpStdioTransport:`stdio transport`,mcpStdioTransportDescription:`First implementation should support local command-based MCP servers such as filesystem, git, or internal tool wrappers.`,mcpPermissionModel:`Tool permissions`,mcpPermissionModelDescription:`External MCP tools should be namespaced and controlled before they are exposed to the agent.`,mcpComingSoonNote:`Backend MCP client integration will be added separately.`,mcpConfiguredServers:`Configured servers`,mcpReconnect:`Reconnect`,mcpAddServer:`Add server`,mcpEditServer:`Edit server`,mcpServerName:`Server name`,mcpCommand:`Command`,mcpTransport:`Transport`,mcpUrl:`URL`,mcpArgs:`Arguments, one per line`,mcpCwd:`Working directory`,mcpEnv:`Environment variables, KEY=value per line`,mcpToolsCount:`{count} tools`,mcpInvalidEnvLine:`Environment variables must use KEY=value, one per line.`,mcpLoadFailed:`Failed to load MCP servers.`,mcpSaveFailed:`Failed to save MCP server.`,mcpDeleteFailed:`Failed to delete MCP server.`,mcpReconnectFailed:`Failed to reconnect MCP servers.`,mcpDeleteConfirm:`Delete MCP server "{name}"?`,mcpImportConfig:`Import MCP JSON`,mcpImportConfigDescription:"Paste an MCP JSON configuration in mcpServers format. QuickForge supports stdio, HTTP, and SSE transports. For remote servers, headers are accepted and resolved from backend environment variables when using ${...}.",mcpUseExample:`Use example`,mcpImportUpdate:`Import / update`,mcpReplaceAll:`Replace all`,mcpReplaceConfirm:`This will remove MCP servers that are not included in the JSON. Continue?`,mcpInvalidJson:`MCP configuration must be valid JSON.`,mcpInvalidConfigJson:`MCP configuration must contain a mcpServers object.`,mcpEmptyConfigJson:`mcpServers cannot be empty.`,mcpInvalidServerName:`Invalid MCP server name: {name}. Use lowercase letters, numbers, and hyphens only.`,mcpInvalidServerConfig:`MCP server "{name}" must be an object.`,mcpInvalidTransport:`MCP server "{name}" transport must be stdio, http, or sse.`,mcpMissingCommand:`MCP server "{name}" requires command for stdio transport.`,mcpMissingUrl:`MCP server "{name}" requires url for HTTP/SSE transport.`,mcpArgsMustBeArray:`MCP server "{name}" args must be an array.`,mcpEnvMustBeObject:`MCP server "{name}" env must be an object.`,mcpHeadersMustBeObject:`MCP server "{name}" headers must be an object.`,optional:`Optional`,globalSkills:`Global Skills`,projectSkills:`Project Skills`,projectCommands:`Project Commands`,projectCommandsDescription:`Configure extra Markdown slash-command directories for the current project. QuickForge reads <project>/.claude/commands, <project>/.opencode/commands, and <project>/.ai/commands first, then these directories in order; later duplicate command names override earlier ones.`,selectProjectForCommands:`Please select or add a project before configuring project commands.`,commandDirectory:`Command directory`,commandDirectories:`Command directories`,commandDirectoryPlaceholder:`.claude/commands
5
- .opencode/commands
6
- D:\\shared\\ai-commands`,commandDirectoryHelp:`One directory per line. Supports relative paths and absolute paths. Relative paths are resolved from the current project root. Leave empty to use the built-in compatible command directories only.`,commandDirectoryExamples:`Examples`,projectCommandsSaved:`Project command settings saved.`,manageSkills:`Manage skills`,manageGlobalSkills:`Manage global skills`,manageProjectSkills:`Manage project skills`,openFolder:`Open folder`,openInExplorer:`Open in Explorer`,openInExplorerFailed:`Failed to open the project folder.`,moreOptions:`More options`,pinSession:`Pin conversation`,unpinSession:`Unpin conversation`,shareSession:`Share conversation`,selectProjectForSkills:`Please select or add a project before managing skills.`,skillsDescription:`Select reusable Agent Skills enabled for project "{project}". QuickForge discloses only name/description in the prompt; full SKILL.md instructions are loaded on demand with activate_skill.`,globalSkillsDescription:`Select reusable Agent Skills enabled globally for QuickForge. Skills are discovered from ~/.claude/skills, ~/.opencode/skills, ~/.agents/skills, and ~/.quickforge/skills. Only the catalog is injected into new chats; instructions load on demand.`,projectSkillsDescription:`Select project Agent Skills for "{project}". Project skills are discovered from .claude/skills, .opencode/skills, .agents/skills, and .quickforge/skills; they override global skills with the same name and load on demand in new project chats.`,searchSkills:`Search skills...`,availableSkills:`Available skills`,selectedSkillsCount:`{count} selected`,noMatchingSkills:`No matching skills found`,skillSearchPaths:`Search paths`,failedToLoadSkills:`Failed to load skills.`,failedToSaveSkills:`Failed to save skills.`,readSkill:`Read skill`,readSkillContent:`Read skill content`,backToSkillList:`Back to skill list`,failedToReadSkill:`Failed to read skill content.`,noSkillContent:`This skill has no readable content.`,requestFailed:`Request failed`,backupRestore:`Backup & Restore`,backupRestoreDescription:`Export or restore QuickForge settings, providers, projects, scheduled tasks, and conversations. Imports create a safety backup on the local service before writing data. Backups may contain sensitive conversations, local paths, code snippets, and optionally API keys.`,exportData:`Export data`,exportDataDescription:`Download a JSON backup that you can keep or move to another QuickForge installation. API keys are excluded unless you explicitly include them.`,exportScope:`Export scope`,exportScopeAll:`Everything`,exportScopeConfig:`Configuration only`,exportScopeSessions:`Conversations only`,includeApiKeys:`Include API keys`,includeApiKeysDescription:`API keys are sensitive. Only enable this for private encrypted storage or trusted migration.`,backupExportSecretsConfirm:`This backup will contain API keys. Do not commit it to Git or share it with untrusted people. Continue?`,exportBackup:`Export backup`,backupExported:`Backup exported.`,backupExportFailed:`Backup export failed.`,importData:`Import data`,importDataDescription:`Restore a previously exported JSON backup. The file will be inspected first, then matching sections in the current local data will be replaced.`,importBackup:`Import backup`,backupInspectTitle:`Backup preview`,backupInspectExportedAt:`Exported at`,backupInspectVersion:`Version`,backupInspectScope:`Scope`,backupInspectSecrets:`Contains API keys`,backupInspectSections:`Sections`,backupInspectFailed:`Backup inspection failed.`,backupInspected:`Backup inspected. Choose what to restore below.`,selectRestoreSections:`Select data to restore`,confirmImportSelected:`Import selected data`,selectAtLeastOneRestoreSection:`Select at least one data section to restore.`,restoreSettings:`Settings`,restoreSettingsDescription:`App preferences such as language and default options.`,restoreProviderKeys:`API keys`,restoreProviderKeysDescription:`Sensitive provider API keys. Restoring replaces current saved keys.`,restoreCustomProviders:`Custom providers and models`,restoreCustomProvidersDescription:`Custom model providers, endpoints, model IDs, and related configuration.`,restoreProjects:`Projects`,restoreProjectsDescription:`Project list, active project, and selected skills.`,restoreScheduledTasks:`Scheduled tasks`,restoreScheduledTasksDescription:`Saved scheduled AI tasks.`,restoreConversations:`Conversations`,restoreConversationsDescription:`Conversation history and metadata. This is restored as one consistent unit.`,backupImportConfirm:`Importing will replace matching local QuickForge data. A safety backup will be created first. Continue?`,backupImported:`Backup imported. The app will reload.`,backupImportFailed:`Backup import failed.`,backupSafetyBackupPath:`Safety backup saved at`,backendService:`Backend Service`,backendServiceDescription:`Restart the local QuickForge backend service. Running generations will be interrupted and the page will reconnect automatically.`,backendServiceStatus:`Service status`,restartBackendService:`Restart backend service`,restartBackendServiceDescription:`Use this when the local backend is stuck or after changing environment-level service settings.`,restartBackendConfirm:`Restart the backend service now? Running generations will be interrupted and the page will reconnect automatically.`,backendRestarting:`Backend is restarting...`,backendRestarted:`Backend restarted. Reloading...`,backendRestartFailed:`Backend restart failed.`,backendRestartTimeout:`Backend restart timed out. Please restart QuickForge manually.`,backendRestartUnsupported:`This launch mode does not support restarting from the UI. Please restart QuickForge manually.`,serviceMode:`Mode`,servicePid:`PID`,serviceStartedAt:`Started at`,serviceDataDir:`Data directory`,serviceWorkspace:`Workspace`,terminalShell:`Terminal shell`,terminalShellDescription:`QuickForge auto-detects common macOS, Windows, and Linux shells. Pick the checked default, or add a custom command/path only when it is missing. QUICKFORGE_TERMINAL_SHELL still takes priority.`,terminalShellAutoDetectedHint:`Detected entries are shown automatically for this computer.`,terminalShellDefault:`Default shell`,terminalShellSaved:`Terminal shell setting saved. New terminal sessions will use it.`,terminalShellProfilesSaved:`Terminal shell profiles saved.`,terminalShellCommand:`Custom shell command or path`,terminalShellCommandPlaceholder:`C:\\Program Files\\Git\\bin\\bash.exe`,terminalShellAdd:`Add`,terminalShellSetDefault:`Set as default`,terminalShellDefaultBadge:`Default`,terminalShellDetected:`Detected`,terminalShellNoDetected:`No shell was detected. Add a custom shell command or path below.`,terminalShellProfileRequired:`Enter a shell command or executable path before saving.`,terminalShellDeleteConfirm:`Delete terminal shell profile "{name}"?`,terminalNew:`New terminal`,terminalNewWith:`New terminal with`,terminalNewWithProfile:`New terminal: {name}`,terminalSelectShell:`Choose shell for new terminal`,terminalCollapse:`Collapse terminal`,terminalFullscreen:`Fullscreen terminal`,terminalExitFullscreen:`Exit fullscreen`,terminalStarting:`Starting terminal...`,terminalUnavailable:`Terminal unavailable`,terminalNoSessions:`No terminal sessions`,terminalCreateFailed:`Failed to create terminal`,terminalCloseFailed:`Failed to close terminal`,terminalConnectionFailed:`Failed to connect to terminal.`,terminalConnectionClosedUnexpectedly:`Terminal connection closed unexpectedly.`,terminalCloseSession:`Close {name}`,workspaceNoFilesToDisplay:`No files to display.`,workspaceNoWorkingTreeChanges:`No working tree changes.`,workspaceStatusAdded:`Added`,workspaceStatusDeleted:`Deleted`,workspaceStatusRenamed:`Renamed`,workspaceStatusUntracked:`Untracked`,workspaceStatusConflict:`Conflict`,workspaceStatusModified:`Modified`,lanAccess:`LAN Access`,lanAccessDescription:`Allow trusted devices on the same LAN to access the full QuickForge app after entering a password.`,lanAccessRiskWarning:`High risk: LAN devices that pass this password can access your conversations, projects, and available tools. Enable only on trusted networks.`,lanAccessStatus:`LAN access status`,lanAccessEnabled:`Full LAN access`,lanAccessPassword:`Access password`,lanAccessActiveDevices:`Unlocked devices`,lanAccessUrls:`LAN URLs`,lanAccessAllowFull:`Allow LAN devices to access full QuickForge`,lanAccessPasswordPlaceholder:`At least 8 characters`,lanAccessPasswordPlaceholderConfigured:`Leave empty to keep current password`,lanAccessSessionTtl:`Login validity`,lanAccessRevokeAll:`Sign out all LAN devices`,lanAccessRevokeAllConfirm:`Sign out all unlocked LAN devices now?`,lanAccessEnableConfirm:`Enable full LAN access? Only continue on a trusted network.`,lanAccessPasswordRequired:`Set an access password before enabling LAN access.`,lanAccessPasswordTooShort:`The access password must be at least 8 characters.`,lanAccessSaved:`LAN access settings saved.`,lanAccessRevoked:`All LAN devices have been signed out.`,enabled:`Enabled`,disabled:`Disabled`,configured:`Configured`,notConfigured:`Not configured`,generatePassword:`Generate password`,hour:`hour`,hours:`hours`,days:`days`,toolApprovalWaiting:`Waiting for approval: {toolName}`,autoCompactApprovalWaiting:`Context reached {percent}% of the {threshold}% threshold. Compact now?`,autoCompactApprovalPreview:`QuickForge will summarize older history and continue with the summary plus the latest {keepRecentTurns} user turn(s). Full chat history remains visible.`,autoCompactFailed:`Automatic context compaction failed; continuing with the current history.`,contextCompactedTimelineLabel:`Earlier context is summarized for the model`,contextCompactedLabel:`Compressed context`,contextCompactedTooltip:`This chat is using a summarized context for model requests while keeping the full history visible.`,contextCompactedViewSummary:`View summary`,contextCompactedHideSummary:`Hide summary`,contextCompactedSummaryTitle:`Summary used by the model`,contextCompactedCopySummary:`Copy summary`,toolApprovalAccept:`✓ Accept`,toolApprovalReject:`✗ Reject`,toolApprovalTimeout:`Timeout`,toolApprovalTruncated:`... (truncated)`,processed:`Processed`,processing:`Processing`,processFailed:`Failed`,processAborted:`Aborted`,expandProcess:`Expand processing details`,collapseProcess:`Collapse processing details`,relativeMinuteShort:`{count}m`,relativeHourShort:`{count}h`,relativeDayShort:`{count}d`,relativeWeekShort:`{count}w`,relativeYearShort:`{count}y`},zh:{language:`语言`,displayLanguage:`界面语言`,languageDescription:`选择速构 QuickForge 的界面显示语言。切换后页面会刷新以应用到所有组件。`,simplifiedChinese:`简体中文`,english:`English`,apply:`应用`,noLanguageChange:`当前已经是所选语言。`,newChat:`新建对话`,loadingChatWorkspace:`正在加载聊天工作区...`,localServiceUnavailableTitle:`QuickForge 本地服务不可用`,localServiceUnavailableDescription:`QuickForge 需要通过本地服务进行存储。请使用 npm run dev 或 quickforge 命令启动后刷新此页面。`,project:`项目`,projects:`项目`,loadingProject:`正在加载项目...`,addProject:`添加项目`,noProjects:`暂无项目。`,expandProject:`展开项目`,collapseProject:`折叠项目`,expandAllProjects:`展开所有项目`,collapseAllProjects:`折叠所有项目`,dragToReorder:`拖拽排序`,newProjectChat:`新建项目对话`,projectChat:`项目对话`,normalChat:`普通对话`,conversations:`对话`,noConversations:`暂无对话`,filter:`筛选`,selecting:`选择中...`,chooseFolder:`选择文件夹`,selectProjectDirectory:`选择项目目录`,selectProjectDirectoryDescription:`浏览本地文件夹或粘贴路径,然后选择一个文件夹作为项目。`,quickAccess:`快捷入口`,path:`路径`,go:`前往`,parentDirectory:`上级目录`,noFolders:`该目录下没有文件夹。`,selectThisFolder:`选择此文件夹`,folderPickerPathPlaceholder:`输入或粘贴文件夹路径`,filesystemRootsFailed:`加载文件系统入口失败。`,directoryLoadFailed:`加载目录失败。`,noSavedConversations:`暂无保存的对话。`,deleteProject:`删除项目`,deleteProjectConfirm:`确定要删除项目「{name}」吗?该项目的对话记录将保留。`,deleteSession:`删除会话`,deleteSessionConfirm:`确定要删除该对话吗?删除后不可恢复。`,confirm:`确认`,confirmDelete:`确认删除`,rename:`重命名`,renameSession:`重命名对话`,sessionName:`对话名称`,settings:`设置`,toggleSidebar:`切换侧边栏`,failedToSelectProjectDirectory:`选择项目目录失败。`,projectSwitchFailed:`切换到该对话绑定的项目失败,工作区工具未启动。`,copy:`复制`,copied:`已复制`,rollback:`回滚`,retry:`重试`,reloadPage:`刷新页面`,fork:`分支`,forkConversation:`从此处分支新对话`,yoloEnabledTitle:`工作区授权已开启:本地工具可使用当前项目`,yoloDisabledTitle:`工作区授权已锁定:本地工具已阻止`,planModeLabel:`计划`,planModeEnabledTitle:`计划模式已开启:下一条消息会按 /plan 发送。点击可移除。快捷键:Shift+Tab`,planModeDisabledTitle:`计划模式:下一条消息按 /plan 发送。快捷键:Shift+Tab`,composerPlaceholder:`描述你想构建、修改或排查的问题...`,assistantWaitingThinking:`正在思考`,assistantWaitingOrganizing:`正在整理答案`,assistantWaitingContinuing:`内容较多,正在继续处理`,assistantWaitingAriaLabel:`AI 正在准备回复`,customCommandsHint:`自定义指令`,customCommandsEmptyHint:`还没有项目指令。`,customCommandsListDescription:`列出项目自定义指令`,customCommandsNewDescription:`创建项目自定义指令`,planCommandDescription:`先生成计划;本轮禁止编辑文件或运行命令。`,reviewCommandDescription:`提交前自检待提交代码;本轮禁止编辑文件。`,compactCommandDescription:`基于当前对话创建压缩后的新对话,减少上下文占用。`,clearCommandDescription:`清除当前对话历史和上下文,不调用模型。`,yoloBlockedReason:`本地工具 {name} 已被阻止,因为 YOLO 模式已关闭。请在输入框内启用 YOLO 模式以授予本地项目访问权限。`,globalToolBlockedReason:`本地工具 {name} 已被阻止,因为这是未绑定项目的普通对话。请新建或打开项目对话后使用工作区工具。`,noActiveProjectToolBlockedReason:`本地工具 {name} 已被阻止,因为当前没有激活项目。请添加或选择项目后再使用工作区工具。`,generationStillRunning:`生成仍在进行中。请停止生成或等待完成后再回滚。`,noConversationTurnToRollback:`没有可回滚的对话轮次。`,rollbackConfirmTitle:`确认回滚?`,rollbackConfirm:`确定回滚到这条消息之前吗?该消息及其之后的对话记录会被移除,消息内容会恢复到输入框。`,sharedRollbackConfirmTitle:`确认回滚分享对话?`,sharedRollbackConfirm:`该操作会直接影响分享者本机中的原始对话。该消息及其之后的对话记录会被移除,消息内容会恢复到输入框。`,confirmRollback:`确认回滚`,rollingBack:`回滚中...`,rollbackFailed:`回滚失败。`,retryFailed:`重试失败。`,copyFailed:`复制失败,请检查剪贴板权限。`,errorBoundaryTitle:`出错了`,errorBoundaryUnexpected:`发生了意外错误。`,errorBoundaryTryAgain:`重试`,execute:`执行`,addCustomModelFirst:`请先在设置里添加自定义模型,并确保填写了模型 ID 后保存。`,modelSetupRequired:`请先添加模型后再新建对话。`,modelSetupTitle:`还没有配置模型`,modelSetupDescription:`添加一个 OpenAI-Compatible 或 Anthropic 兼容模型后即可开始对话。QuickForge 只会使用你自己配置的模型。`,modelSetupSupports:`支持 LiteLLM、OpenRouter、DeepSeek、通义千问、智谱、Ollama,以及大多数 /v1/chat/completions 服务。`,modelSetupLocalStorage:`提供商、模型 ID 和 API Key 会由本机 QuickForge 本地服务保存。`,modelSetupAddModel:`添加模型`,modelSetupUseLiteLlmExample:`使用 LiteLLM 示例配置`,firstUseGuideTitle:`从安全工作流开始`,firstUseGuideDescription:`添加项目后,先让 QuickForge 理解项目;涉及代码修改时,建议先用 /plan 生成计划,再授权本地工具执行。`,firstUseGuideStepModel:`确认要使用的模型配置。`,firstUseGuideStepProject:`添加本地项目,让 AI 使用工作区上下文。`,firstUseGuideStepPlan:`先使用 /plan;该轮不会编辑文件或运行命令。`,firstUseGuideConfigureModel:`配置模型`,firstUseGuideAddProject:`添加项目`,firstUseGuideUsePrompt:`试用示例提示词`,firstUseGuideCopyPrompt:`复制 /plan 示例`,firstUseGuideDismiss:`我知道了`,firstUseGuideProjectPrompt:`/plan 阅读这个项目,说明项目结构、运行方式和主要风险。先不要修改文件。`,firstUseGuideGeneralPrompt:`/plan 先把这个需求拆成实现步骤和风险点。暂时不要修改文件。`,defaultOptions:`默认选项`,defaultOptionsDescription:`配置新建对话和定时任务默认使用的模型、思考等级、工具展示和外观。`,defaultModel:`默认模型`,defaultThinkingLevel:`默认思考等级`,toolDisplay:`工具展示`,showToolDetails:`显示 Tool 详细 JSON`,expandToolsByDefault:`默认展开 Tool 调用`,showToolDetailsDescription:`关闭后将隐藏 Tool 参数和 details JSON,但仍会显示控制台输出、状态、摘要和 diff。`,fontSize:`字号`,fontSizeDescription:`调整全局基础字号和常用正文字号。`,baseFontSize:`基础字号(px)`,bodyFontSize:`正文字号(px)`,bodyFontSizeNote:`应用到界面常用文字使用的 Tailwind text-sm 工具类。`,toolDetailsHidden:`Tool 详细信息已隐藏。可在设置中开启“显示 Tool 详细 JSON”查看完整参数。`,toolArgsSummary:`参数摘要`,saveDefaultOptions:`保存默认选项`,saving:`保存中...`,defaultOptionsSaved:`默认选项已保存`,contextManagement:`上下文管理`,autoCompactEnabled:`自动压缩上下文`,autoCompactRequireConfirmation:`自动压缩前先询问确认`,autoCompactTriggerNote:`系统会在每次请求模型前检查。测试时可降低阈值,或调小模型 Context Window。`,autoCompactThresholdPercent:`上下文达到多少百分比时压缩`,autoCompactKeepRecentTurns:`保留最近用户回合数`,autoCompactDescription:`当预计下一次请求达到模型上下文窗口的指定比例时,QuickForge 会总结较早历史并继续当前任务。该过程会额外消耗一次模型调用。`,autoCompactHistoryPreserved:`完整聊天历史仍会保留在界面中;只有发送给模型的上下文会被压缩。`,thinkingLevel:`思考等级`,thinkingOff:`关`,thinkingLow:`低`,thinkingMedium:`中`,thinkingHigh:`高`,thinkingXHigh:`极高`,currentConfiguration:`当前配置`,thinkingSupported:`支持思考`,thinkingNotSupported:`该模型不支持思考等级。`,thinkingRequiresReasoningModel:`思考等级需要推理/思考模型。`,customModels:`自定义模型`,customModelsTitle:`自定义模型`,customModelsDescription:`只使用你配置的自定义 OpenAI-Compatible 模型。`,addModel:`添加模型`,editModel:`编辑模型`,delete:`删除`,editCustomModel:`编辑自定义模型`,addCustomModel:`添加自定义模型`,providerName:`提供商名称`,providerNamePlaceholder:`例如:LiteLLM`,protocolType:`协议类型`,protocolHelp:`LiteLLM、OpenRouter、大多数 /v1/chat/completions 服务请选择 OpenAI Compatible;直连 Anthropic API 才选 Anthropic Messages。`,apiKey:`API Key`,apiKeyPlaceholder:`没有可以留空`,showApiKey:`查看 API Key`,hideApiKey:`隐藏 API Key`,customHeaders:`自定义 Headers JSON`,customHeadersPlaceholder:`{
7
- "X-Custom-Header": "value"
8
- }`,customHeadersHelp:`可选的提供商级 HTTP Headers。必须是值为字符串的 JSON 对象,会随模型配置保存在本地。`,invalidHeadersJson:`自定义 Headers 必须是有效 JSON 对象,并且键和值都必须是字符串。`,modelId:`模型 ID`,modelIdPlaceholder:`例如:anthropic/claude-sonnet-4`,contextWindow:`Context Window`,maxTokens:`Max Tokens`,reasoningModel:`推理/思考模型(DeepSeek V4、Qwen 等)`,providerProtocol:`协议`,model:`模型`,noModelAdded:`未添加模型`,modelsCount:`{count} 个模型`,modelIndex:`模型 #{index}`,modelsList:`模型列表`,atLeastOneModel:`至少需要一个模型。`,duplicateModelId:`模型 ID 不能重复。`,cancel:`取消`,save:`保存`,yes:`是`,no:`否`,loading:`加载中...`,noCustomModels:`还没有自定义模型,请点击"添加模型"。`,fillProviderBaseUrlModel:`请填写提供商名称和 Base URL。`,saveCustomModelFailed:`保存自定义模型失败。`,confirmDeleteProvider:`确定删除 {name} 吗?`,deleteFailed:`删除失败。`,selectCustomModel:`选择自定义模型`,close:`关闭`,searchModels:`搜索模型...`,noMatchingCustomModels:`没有匹配的自定义模型`,readFile:`读取文件`,searchFiles:`搜索文件`,writeFile:`写入文件`,editFile:`编辑文件`,runCommand:`运行命令`,executeInTerminal:`在终端中执行`,confirmExecuteCommandTitle:`在终端中执行命令?`,confirmExecuteMultipleCommands:`即将在本地终端中执行多行命令,是否继续?`,confirmExecuteDangerousCommand:`该命令可能修改系统、发布包、推送代码或执行远程脚本,是否继续?`,terminalCommandExecuteFailed:`在终端中执行命令失败。`,runSubagent:`运行 subagent`,subagentGeneral:`General`,subagentExplore:`Explore`,subagentRunning:`{name} 运行中`,subagentCompleted:`{name} 已完成`,subagentFailed:`{name} 失败`,subagentTask:`任务`,subagentContext:`上下文`,subagentExpectedOutput:`期望输出`,subagentResult:`结果`,subagentToolCalls:`工具调用`,subagentToolApprovalWaiting:`{source} 请求审批:{toolName}`,toolApprovalSourceSubagent:`来源:{source} subagent`,activateSkill:`激活技能`,readSkillResource:`读取技能资源`,yoloModeSyncFailed:`同步 YOLO 模式失败,已恢复为之前的状态。`,toolApprovalFailed:`提交工具审批失败,请重试。`,toolApprovalSubmitting:`提交中...`,terminateCommand:`终止`,terminateCommandTitle:`终止这个正在运行的命令`,commandTerminateRequested:`正在终止...`,running:`运行中`,done:`完成`,error:`错误`,taskCompleted:`对话任务完成`,taskError:`对话任务出错`,called:`已调用`,input:`输入`,output:`输出`,details:`详情`,scheduledTasks:`定时任务`,scheduledTasksDescription:`任务保存在本地后台服务中,并按 AI 解析出的 cron 表达式执行。`,createTask:`创建任务`,editTask:`编辑`,cancelEditTask:`取消编辑`,saveTask:`保存任务`,taskScheduleDescriptionLabel:`定时描述`,taskScheduleDescriptionPlaceholder:`例如:每天早上 9 点,把这段内容发给 AI:帮我生成销售日报。`,quickAiParseTask:`AI 会把这段描述解析为 cron 表达式,系统只保存并按 cron 执行。`,taskTitleLabel:`任务名称`,taskTitlePlaceholder:`例如:每日工作总结`,promptContentLabel:`AI 将发送的内容`,promptContentPlaceholder:`填写到点后原样发送给 AI 的内容。`,taskEnabledSwitch:`启用这个任务`,taskInstructionPlaceholder:`例如:每天早上 9 点帮我生成销售日报`,aiParseTask:`AI 解析任务`,confirmCreate:`确认创建`,taskList:`任务列表`,noScheduledTasks:`还没有定时任务。先输入一句自然语言指令创建一个。`,taskEnabled:`启用中`,taskRunning:`执行中`,taskPaused:`已暂停`,taskFinished:`已完成`,taskFailed:`执行失败`,executeNow:`立即执行`,enable:`启用`,pauseTask:`暂停`,deleteTask:`删除`,recentExecutions:`最近执行记录`,executionSuccess:`成功`,executionRunning:`执行中`,nextExecution:`下一次:`,lastExecution:`上次:`,noModelAvailable:`暂无可用模型`,noProjectBound:`不绑定项目`,aiParsed:`AI 已解析,请确认`,taskName:`任务名称:`,executionRule:`执行规则:`,nextExecutionTime:`下一次执行:`,taskProject:`项目:`,taskThinkingLevel:`思考:`,aiInstruction:`AI 指令:`,taskModel:`模型`,taskThinking:`思考`,taskProjectLabel:`项目`,taskExecutionMode:`执行模式`,taskExecutionModeSerial:`串行`,taskExecutionModeParallel:`并行`,taskExecutionModeHelp:`该设置只控制同一个任务是否允许重叠执行;不同定时任务之间仍可并行执行。`,tasksCount:`共 {total} 个任务,{enabled} 个启用中`,confirmDeleteTask:`确定要删除这个定时任务吗?删除后不可恢复。`,waitingForResult:`等待结果`,autoRun:`自动执行`,manualRun:`手动测试`,runInputContent:`发送给 AI 的内容`,runAiResult:`AI 结果`,runDuration:`耗时:`,taskListTab:`任务列表`,executionHistoryTab:`执行历史`,agentsTab:`Agents`,agentsDescription:`创建可复用的 Agent Profile,用于定时任务和 run_subagent 委派。`,createAgent:`创建 Agent`,editAgent:`编辑 Agent`,builtinAgent:`内置`,builtinAgentReadonly:`内置 Agent 在当前版本中只读。`,enabledAsSubagent:`允许作为 sub agent`,noDescription:`暂无描述。`,maxRuntimeMs:`最大运行时间:`,maxToolCalls:`最大工具调用:`,defaultAgent:`默认 Agent`,executionAgent:`执行 Agent:`,agentName:`Agent 名称`,agentLabel:`显示名称`,agentLabelPlaceholder:`例如:代码审查 Agent`,agentDescription:`描述`,agentSystemPrompt:`系统提示词`,allowedTools:`可用工具`,highRiskTool:`高风险`,confirmDeleteAgent:`确定删除这个自定义 Agent 吗?使用它的定时任务将回退到默认 Agent。`,aiFillAgent:`AI 填充`,aiFillAgentDescription:`描述你想创建的 Agent,AI 只会填充 Agent 名称、显示名称、描述和系统提示词。`,aiFillAgentPlaceholder:`例如:生成一个只读代码审查 Agent,重点检查架构、潜在 bug 和测试覆盖。`,aiFillAgentLoading:`生成中...`,aiFillAgentNoModel:`请先配置默认模型。`,aiFillAgentFailed:`AI 填充失败,请检查模型配置和 API Key 后重试。`,aiFillAgentInputRequired:`请描述你想创建的 Agent。`,taskContent:`任务内容`,viewDetails:`查看详情`,moreActions:`更多操作`,historyFilters:`筛选条件`,allTasks:`全部任务`,allStatuses:`全部状态`,allTriggers:`全部触发方式`,triggerType:`触发方式`,keyword:`关键词`,keywordPlaceholder:`搜索输入、结果或错误`,startTime:`开始时间`,endTime:`结束时间`,query:`查询`,reset:`重置`,previousPage:`上一页`,nextPage:`下一页`,pageSize:`每页 {size} 条`,paginationSummary:`第 {page} / {pages} 页,共 {total} 条`,noExecutionHistory:`暂无执行历史。`,viewConversation:`查看对话`,createdAt:`创建时间`,status:`状态`,search:`搜索`,searchDialog:`搜索对话记录...`,noSearchResults:`没有找到相关对话`,searchHint:`输入关键词搜索已加载的对话记录`,scheduledTasksLabel:`定时任务`,skills:`技能`,mcp:`MCP`,mcpServers:`MCP 服务`,plugins:`插件`,pluginMentionHeader:`插件`,composerAddMenu:`添加`,composerAddAttachment:`附件`,composerAddPlugins:`插件`,composerAddBack:`返回`,pluginOpenaiDocumentsName:`文档`,pluginOpenaiDocumentsDescription:`创建和编辑文档产物`,pluginOpenaiSpreadsheetsName:`表格`,pluginOpenaiSpreadsheetsDescription:`创建、分析和整理表格文件`,pluginOpenaiPresentationsName:`演示文稿`,pluginOpenaiPresentationsDescription:`创建和编辑演示文稿`,pluginsDescription:`管理本地 QuickForge 插件。当前首版支持通过 manifest 声明并贡献 Agent 工具的插件。`,pluginsReload:`重新加载插件`,loadingPlugins:`正在加载插件...`,noPlugins:`未发现插件`,noPluginsDescription:`将包含 plugin.json 的插件目录放到以下任一搜索路径,然后重新加载。`,pluginsCount:`共 {total} 个插件,{enabled} 个已启用`,pluginToolsCount:`{count} 个工具`,pluginPermissionsCount:`{count} 个权限`,pluginDetails:`插件详情`,pluginVersion:`版本`,pluginStatusLoaded:`已加载`,pluginStatusDisabled:`已停用`,pluginStatusError:`错误`,pluginTools:`工具`,pluginPermissions:`声明权限`,pluginNoTools:`未声明工具。`,pluginNoPermissions:`未声明权限。`,pluginTrustedNotice:`首版插件属于本地可信 Node.js 代码;权限目前用于展示和后续强校验。`,pluginDiscoveryErrors:`插件发现错误`,enablePlugin:`启用`,disablePlugin:`禁用`,pluginsLoadFailed:`加载插件失败。`,pluginsSaveFailed:`更新插件失败。`,manageMcpServers:`管理 MCP 服务`,mcpNoServersTitle:`MCP 服务管理入口已就绪`,mcpNoServersDescription:`还没有 MCP 服务。请在右侧粘贴 mcpServers JSON 配置进行添加。`,mcpStdioTransport:`stdio 传输`,mcpStdioTransportDescription:`首版建议支持基于本地命令的 MCP 服务,例如 filesystem、git 或内部工具封装。`,mcpPermissionModel:`工具权限`,mcpPermissionModelDescription:`外部 MCP 工具暴露给 Agent 前,应先做命名空间隔离和权限控制。`,mcpComingSoonNote:`后端 MCP Client 集成将单独实现。`,mcpConfiguredServers:`已配置服务`,mcpReconnect:`重新连接`,mcpAddServer:`添加服务`,mcpEditServer:`编辑服务`,mcpServerName:`服务名称`,mcpCommand:`命令`,mcpTransport:`传输方式`,mcpUrl:`URL`,mcpArgs:`参数,每行一个`,mcpCwd:`工作目录`,mcpEnv:`环境变量,每行 KEY=value`,mcpToolsCount:`{count} 个工具`,mcpInvalidEnvLine:`环境变量必须按每行 KEY=value 填写。`,mcpLoadFailed:`加载 MCP 服务失败。`,mcpSaveFailed:`保存 MCP 服务失败。`,mcpDeleteFailed:`删除 MCP 服务失败。`,mcpReconnectFailed:`重新连接 MCP 服务失败。`,mcpDeleteConfirm:`确定删除 MCP 服务「{name}」吗?`,mcpImportConfig:`导入 MCP JSON`,mcpImportConfigDescription:"直接粘贴 mcpServers 格式的 MCP JSON 配置。QuickForge 支持 stdio、HTTP 和 SSE 传输;远程服务可使用 headers,并支持通过 ${...} 从后端进程环境变量读取。",mcpUseExample:`使用示例`,mcpImportUpdate:`导入 / 更新`,mcpReplaceAll:`替换全部`,mcpReplaceConfirm:`这会删除当前未包含在 JSON 中的 MCP 服务,确定继续吗?`,mcpInvalidJson:`MCP 配置必须是合法 JSON。`,mcpInvalidConfigJson:`MCP 配置必须包含 mcpServers 对象。`,mcpEmptyConfigJson:`mcpServers 不能为空。`,mcpInvalidServerName:`MCP 服务名称无效:{name}。请只使用小写字母、数字和连字符。`,mcpInvalidServerConfig:`MCP 服务「{name}」必须是对象。`,mcpInvalidTransport:`MCP 服务「{name}」的传输方式必须是 stdio、http 或 sse。`,mcpMissingCommand:`MCP 服务「{name}」使用 stdio 传输时必须提供 command。`,mcpMissingUrl:`MCP 服务「{name}」使用 HTTP/SSE 传输时必须提供 url。`,mcpArgsMustBeArray:`MCP 服务「{name}」的 args 必须是数组。`,mcpEnvMustBeObject:`MCP 服务「{name}」的 env 必须是对象。`,mcpHeadersMustBeObject:`MCP 服务「{name}」的 headers 必须是对象。`,optional:`可选`,globalSkills:`全局技能`,projectSkills:`项目技能`,projectCommands:`项目 Commands`,projectCommandsDescription:`为当前项目配置额外的 Markdown slash command 目录。QuickForge 会先读取 <project>/.claude/commands、<project>/.opencode/commands 和 <project>/.ai/commands,再按顺序读取这些目录;同名 command 以后面的目录覆盖前面的目录。`,selectProjectForCommands:`请先选择或添加一个项目,再配置项目 Commands。`,commandDirectory:`Command 目录`,commandDirectories:`Command 目录`,commandDirectoryPlaceholder:`.claude/commands
9
- .opencode/commands
10
- D:\\shared\\ai-commands`,commandDirectoryHelp:`一行一个目录。支持相对路径和绝对路径。相对路径会基于当前项目根目录解析。留空则只使用内置兼容 Command 目录。`,commandDirectoryExamples:`示例`,projectCommandsSaved:`项目 Command 设置已保存。`,manageSkills:`管理技能`,manageGlobalSkills:`管理全局技能`,manageProjectSkills:`管理项目技能`,openFolder:`打开文件夹`,openInExplorer:`在资源管理器打开`,openInExplorerFailed:`打开项目目录失败。`,moreOptions:`更多选项`,pinSession:`置顶对话`,unpinSession:`取消置顶`,shareSession:`分享对话`,selectProjectForSkills:`请先选择或添加一个项目,再管理技能。`,skillsDescription:`选择项目「{project}」启用的 Agent Skills。QuickForge 只在提示词中披露名称/描述;完整 SKILL.md 指令会在需要时通过 activate_skill 按需加载。`,globalSkillsDescription:`选择 QuickForge 全局启用的 Agent Skills。技能会从 ~/.claude/skills、~/.opencode/skills、~/.agents/skills 和 ~/.quickforge/skills 发现。新对话只注入目录,完整指令按需加载。`,projectSkillsDescription:`选择项目「{project}」启用的 Agent Skills。项目技能从 .claude/skills、.opencode/skills、.agents/skills 和 .quickforge/skills 发现;同名项目技能会覆盖全局技能,并只在新项目对话中按需加载。`,searchSkills:`搜索技能...`,availableSkills:`可用技能`,selectedSkillsCount:`已选择 {count} 个`,noMatchingSkills:`没有匹配的技能`,skillSearchPaths:`搜索路径`,failedToLoadSkills:`加载技能失败。`,failedToSaveSkills:`保存技能失败。`,readSkill:`阅读技能`,readSkillContent:`阅读技能内容`,backToSkillList:`返回技能列表`,failedToReadSkill:`读取技能内容失败。`,noSkillContent:`该技能没有可阅读的内容。`,requestFailed:`请求失败`,backupRestore:`备份与恢复`,backupRestoreDescription:`导出或恢复 QuickForge 的设置、模型提供商、项目、定时任务和对话。导入前本地服务会先创建一份安全备份。备份可能包含敏感对话、本机路径、代码片段,并可选包含 API Key。`,exportData:`导出数据`,exportDataDescription:`下载 JSON 备份文件,可自行保存或迁移到其他 QuickForge 安装。默认不包含 API Key,除非你明确勾选。`,exportScope:`导出范围`,exportScopeAll:`全部数据`,exportScopeConfig:`仅配置`,exportScopeSessions:`仅对话`,includeApiKeys:`包含 API Key`,includeApiKeysDescription:`API Key 属于敏感信息。仅在私密加密保存或可信迁移时启用。`,backupExportSecretsConfirm:`此备份将包含 API Key。请不要提交到 Git 或分享给不可信人员。是否继续?`,exportBackup:`导出备份`,backupExported:`备份已导出。`,backupExportFailed:`导出备份失败。`,importData:`导入数据`,importDataDescription:`恢复之前导出的 JSON 备份。系统会先检查文件内容,然后替换当前本地数据中对应的部分。`,importBackup:`导入备份`,backupInspectTitle:`备份预览`,backupInspectExportedAt:`导出时间`,backupInspectVersion:`版本`,backupInspectScope:`范围`,backupInspectSecrets:`包含 API Key`,backupInspectSections:`数据项`,backupInspectFailed:`检查备份失败。`,backupInspected:`备份已检查,请在下方选择要恢复的数据。`,selectRestoreSections:`选择要恢复的数据`,confirmImportSelected:`导入所选数据`,selectAtLeastOneRestoreSection:`请至少选择一个要恢复的数据项。`,restoreSettings:`设置`,restoreSettingsDescription:`语言、默认选项等应用偏好设置。`,restoreProviderKeys:`API Key`,restoreProviderKeysDescription:`敏感的模型提供商 API Key。恢复后会替换当前保存的密钥。`,restoreCustomProviders:`自定义提供商和模型`,restoreCustomProvidersDescription:`自定义模型提供商、端点、模型 ID 及相关配置。`,restoreProjects:`项目`,restoreProjectsDescription:`项目列表、当前项目和已选择的技能。`,restoreScheduledTasks:`定时任务`,restoreScheduledTasksDescription:`已保存的 AI 定时任务。`,restoreConversations:`对话`,restoreConversationsDescription:`对话历史和元数据。会作为一个一致的整体恢复。`,backupImportConfirm:`导入会替换当前 QuickForge 本地数据中对应的部分。系统会先创建安全备份。是否继续?`,backupImported:`备份已导入,应用即将刷新。`,backupImportFailed:`导入备份失败。`,backupSafetyBackupPath:`安全备份保存位置`,backendService:`后端服务`,backendServiceDescription:`重启 QuickForge 本地后端服务。正在运行的生成会被中断,页面会自动重新连接。`,backendServiceStatus:`服务状态`,restartBackendService:`重启后端服务`,restartBackendServiceDescription:`当本地后端卡住,或调整了服务级环境配置后,可以在这里重启。`,restartBackendConfirm:`确定现在重启后端服务吗?正在运行的生成会被中断,页面会自动重新连接。`,backendRestarting:`后端正在重启...`,backendRestarted:`后端已重启,正在刷新页面...`,backendRestartFailed:`后端重启失败。`,backendRestartTimeout:`后端重启超时,请手动重启 QuickForge。`,backendRestartUnsupported:`当前启动方式不支持从界面重启,请手动重启 QuickForge。`,serviceMode:`模式`,servicePid:`PID`,serviceStartedAt:`启动时间`,serviceDataDir:`数据目录`,serviceWorkspace:`工作区`,terminalShell:`终端 Shell`,terminalShellDescription:`QuickForge 会自动识别这台电脑上常见的 macOS、Windows 和 Linux Shell。勾选默认项即可;只有缺少时才需要添加自定义命令或路径。QUICKFORGE_TERMINAL_SHELL 仍会优先生效。`,terminalShellAutoDetectedHint:`已识别的条目会自动显示在列表中。`,terminalShellDefault:`默认 Shell`,terminalShellSaved:`终端 Shell 设置已保存,新建终端会话会使用该设置。`,terminalShellProfilesSaved:`终端 Shell 配置已保存。`,terminalShellCommand:`自定义 Shell 命令或路径`,terminalShellCommandPlaceholder:`C:\\Program Files\\Git\\bin\\bash.exe`,terminalShellAdd:`添加`,terminalShellSetDefault:`设为默认`,terminalShellDefaultBadge:`默认`,terminalShellDetected:`已识别`,terminalShellNoDetected:`未识别到可用 Shell,请在下方添加自定义 Shell 命令或路径。`,terminalShellProfileRequired:`保存前请输入 Shell 命令或可执行文件路径。`,terminalShellDeleteConfirm:`确定删除终端 Shell 配置“{name}”吗?`,terminalNew:`新建终端`,terminalNewWith:`新建终端使用`,terminalNewWithProfile:`新建终端:{name}`,terminalSelectShell:`选择 Shell 新建终端`,terminalCollapse:`收起终端`,terminalFullscreen:`全屏终端`,terminalExitFullscreen:`退出全屏`,terminalStarting:`正在启动终端...`,terminalUnavailable:`终端不可用`,terminalNoSessions:`没有终端会话`,terminalCreateFailed:`创建终端失败`,terminalCloseFailed:`关闭终端失败`,terminalConnectionFailed:`连接终端失败。`,terminalConnectionClosedUnexpectedly:`终端连接异常断开。`,terminalCloseSession:`关闭 {name}`,workspaceNoFilesToDisplay:`没有可显示的文件。`,workspaceNoWorkingTreeChanges:`工作区没有变更。`,workspaceStatusAdded:`新增`,workspaceStatusDeleted:`删除`,workspaceStatusRenamed:`重命名`,workspaceStatusUntracked:`未跟踪`,workspaceStatusConflict:`冲突`,workspaceStatusModified:`修改`,lanAccess:`局域网访问`,lanAccessDescription:`允许同一局域网内可信设备在输入密码后访问完整 QuickForge。`,lanAccessRiskWarning:`高风险:通过密码的局域网设备可以访问你的对话、项目和可用工具。请只在可信网络中开启。`,lanAccessStatus:`局域网访问状态`,lanAccessEnabled:`完整局域网访问`,lanAccessPassword:`访问密码`,lanAccessActiveDevices:`已解锁设备`,lanAccessUrls:`局域网地址`,lanAccessAllowFull:`允许局域网设备访问完整 QuickForge`,lanAccessPasswordPlaceholder:`至少 8 个字符`,lanAccessPasswordPlaceholderConfigured:`留空则保留当前密码`,lanAccessSessionTtl:`登录有效期`,lanAccessRevokeAll:`踢掉所有局域网设备`,lanAccessRevokeAllConfirm:`确定要让所有已解锁的局域网设备退出登录吗?`,lanAccessEnableConfirm:`确定开启完整局域网访问吗?请仅在可信网络中继续。`,lanAccessPasswordRequired:`开启局域网访问前请先设置访问密码。`,lanAccessPasswordTooShort:`访问密码至少需要 8 个字符。`,lanAccessSaved:`局域网访问设置已保存。`,lanAccessRevoked:`所有局域网设备已退出登录。`,enabled:`已开启`,disabled:`已关闭`,configured:`已设置`,notConfigured:`未设置`,generatePassword:`生成密码`,hour:`小时`,hours:`小时`,days:`天`,toolApprovalWaiting:`等待审批:{toolName}`,autoCompactApprovalWaiting:`上下文已达到 {percent}%(阈值 {threshold}%),是否现在压缩?`,autoCompactApprovalPreview:`QuickForge 会总结较早历史,并使用摘要加最近 {keepRecentTurns} 个用户回合继续任务。完整聊天历史仍会保留在界面中。`,autoCompactFailed:`自动上下文压缩失败,将继续使用当前历史。`,contextCompactedTimelineLabel:`较早上下文已整理为摘要供模型使用`,contextCompactedLabel:`已压缩上下文`,contextCompactedTooltip:`此对话的模型请求正在使用摘要上下文,完整聊天历史仍会保留在界面中。`,contextCompactedViewSummary:`查看摘要`,contextCompactedHideSummary:`收起摘要`,contextCompactedSummaryTitle:`模型正在使用的压缩摘要`,contextCompactedCopySummary:`复制摘要`,toolApprovalAccept:`✓ 允许`,toolApprovalReject:`✗ 拒绝`,toolApprovalTimeout:`超时时间`,toolApprovalTruncated:`...(内容已截断)`,processed:`已处理`,processing:`处理中`,processFailed:`处理出错`,processAborted:`已中止`,expandProcess:`展开处理详情`,collapseProcess:`收起处理详情`,relativeMinuteShort:`{count}分`,relativeHourShort:`{count}小时`,relativeDayShort:`{count}天`,relativeWeekShort:`{count}周`,relativeYearShort:`{count}年`}},Ne={...Ce.en,"Configure API keys for LLM providers. Keys are stored locally in your browser.":`Configure API keys for LLM providers. Keys are stored by the local QuickForge service on this machine.`,"Settings are stored locally in your browser":`Settings are stored by the local QuickForge service on this machine`,"Storage Permission Required":`Local Service Required`,"This app needs persistent storage to save your conversations":`This app needs the local QuickForge service to save your conversations`,"Without persistent storage, your browser may delete saved conversations when it needs disk space. Granting this permission ensures your chat history is preserved.":`QuickForge saves data to local files through the local service on this machine so your chat history is preserved.`,"Your conversations will be saved locally in your browser":`Your conversations will be saved to local files by the local QuickForge service`,"Cloud LLM providers with predefined models. API keys are stored locally in your browser.":`Cloud LLM providers with predefined models. API keys are stored by the local QuickForge service on this machine.`},Pe={...Ce.en,Free:`免费`,"Input Required":`需要输入`,Cancel:`取消`,Confirm:`确认`,"Select Model":`选择模型`,"Search models...":`搜索模型...`,Format:`格式`,Thinking:`思考`,Vision:`视觉`,You:`你`,Assistant:`助手`,"Thinking...":`正在思考...`,"Type your message...":`输入你的消息...`,"API Keys Configuration":`API Key 配置`,"Configure API keys for LLM providers. Keys are stored locally in your browser.":`配置 LLM 提供商的 API Key。密钥会由本机 QuickForge 本地服务保存。`,Configured:`已配置`,"Not configured":`未配置`,"✓ Valid":`✓ 有效`,"✗ Invalid":`✗ 无效`,"Testing...":`测试中...`,Update:`更新`,Test:`测试`,Remove:`移除`,Save:`保存`,"Update API key":`更新 API Key`,"Enter API key":`输入 API Key`,"Type a message...":`输入消息...`,"Failed to fetch file":`获取文件失败`,"Invalid source type":`无效的来源类型`,PDF:`PDF`,Document:`文档`,Presentation:`演示文稿`,Spreadsheet:`电子表格`,Text:`文本`,"Error loading file":`加载文件出错`,"No text content available":`没有可用的文本内容`,"Failed to load PDF":`加载 PDF 失败`,"Failed to load document":`加载文档失败`,"Failed to load spreadsheet":`加载电子表格失败`,"Error loading PDF":`加载 PDF 出错`,"Error loading document":`加载文档出错`,"Error loading spreadsheet":`加载电子表格出错`,"Preview not available for this file type.":`此文件类型不支持预览。`,"Click the download button above to view it on your computer.":`点击上方下载按钮在电脑上查看。`,"No content available":`没有可用内容`,"Failed to display text content":`显示文本内容失败`,"API keys are required to use AI models. Get your keys from the provider's website.":`使用 AI 模型需要 API Key。请从提供商网站获取。`,console:`控制台`,"Copy output":`复制输出`,"Copied!":`已复制!`,"Error:":`错误:`,"Request aborted":`请求已中止`,Call:`调用`,Result:`结果`,"(no result)":`(无结果)`,"Waiting for tool result…":`等待工具结果…`,"Call was aborted; no result.":`调用已中止,没有结果。`,"No session available":`没有可用会话`,"No session set":`未设置会话`,"Preparing tool parameters...":`正在准备工具参数...`,"(no output)":`(无输出)`,Input:`输入`,Output:`输出`,"Writing expression...":`正在写入表达式...`,"Waiting for expression...":`等待表达式...`,Calculating:`计算中`,"Getting current time in":`正在获取当前时间:`,"Getting current date and time":`正在获取当前日期和时间`,"Waiting for command...":`等待命令...`,"Writing command...":`正在写入命令...`,"Running command...":`正在运行命令...`,"Command failed:":`命令失败:`,"Enter Auth Token":`输入认证令牌`,"Please enter your auth token.":`请输入你的认证令牌。`,"Execution aborted":`执行已中止`,"Code parameter is required":`需要代码参数`,"Unknown error":`未知错误`,"Code executed successfully (no output)":`代码执行成功(无输出)`,"Execution failed":`执行失败`,"JavaScript REPL":`JavaScript REPL`,"JavaScript code to execute":`要执行的 JavaScript 代码`,"Writing JavaScript code...":`正在写入 JavaScript 代码...`,"Executing JavaScript":`正在执行 JavaScript`,"Preparing JavaScript...":`正在准备 JavaScript...`,"Preparing command...":`正在准备命令...`,"Preparing calculation...":`正在准备计算...`,"Preparing tool...":`正在准备工具...`,"Getting time...":`正在获取时间...`,"Processing artifact...":`正在处理产物...`,"Preparing artifact...":`正在准备产物...`,"Processing artifact":`正在处理产物`,"Processed artifact":`已处理产物`,"Creating artifact":`正在创建产物`,"Created artifact":`已创建产物`,"Updating artifact":`正在更新产物`,"Updated artifact":`已更新产物`,"Rewriting artifact":`正在重写产物`,"Rewrote artifact":`已重写产物`,"Getting artifact":`正在获取产物`,"Got artifact":`已获取产物`,"Deleting artifact":`正在删除产物`,"Deleted artifact":`已删除产物`,"Getting logs":`正在获取日志`,"Got logs":`已获取日志`,"An error occurred":`发生错误`,"Copy logs":`复制日志`,"Autoscroll enabled":`已启用自动滚动`,"Autoscroll disabled":`已关闭自动滚动`,Processing:`处理中`,Create:`创建`,Rewrite:`重写`,Get:`获取`,Delete:`删除`,"Get logs":`获取日志`,"Show artifacts":`显示产物`,"Close artifacts":`关闭产物`,Artifacts:`产物`,"Copy HTML":`复制 HTML`,"Download HTML":`下载 HTML`,"Reload HTML":`重新加载 HTML`,"Copy SVG":`复制 SVG`,"Download SVG":`下载 SVG`,"Copy Markdown":`复制 Markdown`,"Download Markdown":`下载 Markdown`,Download:`下载`,"No logs for {filename}":`{filename} 没有日志`,"API Keys Settings":`API Key 设置`,Settings:`设置`,"API Keys":`API Key`,"Settings are stored locally in your browser":`设置会由本机 QuickForge 本地服务保存`,Clear:`清除`,"API Key Required":`需要 API Key`,"Enter your API key for {provider}":`输入 {provider} 的 API Key`,Off:`关闭`,Minimal:`最小`,Low:`低`,Medium:`中`,High:`高`,"Storage Permission Required":`需要本地服务`,"This app needs persistent storage to save your conversations":`此应用需要 QuickForge 本地服务来保存你的对话`,"Why is this needed?":`为什么需要?`,"Without persistent storage, your browser may delete saved conversations when it needs disk space. Granting this permission ensures your chat history is preserved.":`QuickForge 会通过本机本地服务把数据保存到本地文件中,确保聊天历史可持久保留。`,"What this means:":`这意味着:`,"Your conversations will be saved locally in your browser":`你的对话会由本机 QuickForge 本地服务保存到本地文件`,"Data will not be deleted automatically to free up space":`数据不会被自动删除来释放空间`,"You can still manually clear data at any time":`你仍然可以随时手动清除数据`,"No data is sent to external servers":`不会向外部服务器发送数据`,"Continue Anyway":`仍然继续`,"Requesting...":`请求中...`,"Grant Permission":`授予权限`,Sessions:`会话`,"Load a previous conversation":`加载之前的对话`,"No sessions yet":`暂无会话`,"Delete this session?":`删除此会话?`,Today:`今天`,Yesterday:`昨天`,"{days} days ago":`{days} 天前`,messages:`条消息`,tokens:`tokens`,"Drop files here":`将文件拖到这里`,"Providers & Models":`提供商与模型`,"Cloud Providers":`云提供商`,"Cloud LLM providers with predefined models. API keys are stored locally in your browser.":`带有预定义模型的云 LLM 提供商。API Key 会由本机 QuickForge 本地服务保存。`,"Custom Providers":`自定义提供商`,"User-configured servers with auto-discovered or manually defined models.":`用户配置的服务器,支持自动发现或手动定义模型。`,"Add Provider":`添加提供商`,"No custom providers configured. Click 'Add Provider' to get started.":`尚未配置自定义提供商。点击"添加提供商"开始。`,Models:`模型`,"auto-discovered":`自动发现`,Refresh:`刷新`,Edit:`编辑`,"Are you sure you want to delete this provider?":`确定删除这个提供商吗?`,"Edit Provider":`编辑提供商`,"Provider Name":`提供商名称`,"e.g., My Ollama Server":`例如:我的 Ollama 服务`,"Provider Type":`提供商类型`,"Base URL":`Base URL`,"e.g., http://localhost:11434":`例如:http://localhost:11434`,"API Key (Optional)":`API Key(可选)`,"Leave empty if not required":`不需要可以留空`,"Test Connection":`测试连接`,Discovered:`已发现`,models:`个模型`,and:`以及`,more:`更多`,"For manual provider types, add models after saving the provider.":`手动提供商类型需要保存提供商后再添加模型。`,"Please fill in all required fields":`请填写所有必填项`,"Failed to save provider":`保存提供商失败`,"OpenAI Completions Compatible":`OpenAI Completions 兼容`,"OpenAI Responses Compatible":`OpenAI Responses 兼容`,"Anthropic Messages Compatible":`Anthropic Messages 兼容`,"Checking...":`检查中...`,Disconnected:`未连接`,"*":`*`,Copy:`复制`,"Copy code":`复制代码`,Close:`关闭`,Preview:`预览`,Code:`代码`,"Loading...":`加载中...`,"Select an option":`选择一个选项`,"Mode 1":`模式 1`,"Mode 2":`模式 2`,Required:`必填`,Optional:`可选`},Fe=Ie();function Ie(){return typeof navigator<`u`&&navigator.language.toLowerCase().startsWith(`zh`)?`zh`:`en`}function Le(e){return typeof e==`string`&&Me.includes(e)}function Re(e){typeof document>`u`||(document.documentElement.lang=e===`zh`?`zh-CN`:`en`,document.documentElement.dir=`ltr`)}function ze(e){let t=e===`zh`?Pe:Ne;for(let e of Object.keys(Ce))Ce[e]=t}function Be(e){Fe=e,ze(e),Re(e)}Ce.zh=Pe,Be(Fe);function U(){return Fe}function W(e,t){let n=H[U()][e]??H.en[e];if(!t)return n;for(let[e,r]of Object.entries(t))n=n.replaceAll(`{${e}}`,String(r));return n}function Ve(){return U()===`zh`?`zh-CN`:`en-US`}async function He(e){let t=await e.settings.get(je),n=Le(t)?t:Ie();return Le(t)||await e.settings.set(je,n),Be(n),n}async function Ue(e,t){return t===U()?!1:(await e.settings.set(je,t),Be(t),window.location.reload(),!0)}var We=new Set([`off`,`low`,`medium`,`high`,`xhigh`]),Ge=[{value:`off`,label:()=>me(`Off`)},{value:`low`,label:()=>me(`Low`)},{value:`medium`,label:()=>me(`Medium`)},{value:`high`,label:()=>me(`High`)},{value:`xhigh`,label:()=>U()===`zh`?`极高`:`XHigh`}];function Ke(e){return typeof e==`string`&&We.has(e)}function qe(e){return Array.from(e.querySelectorAll(`.flex.gap-2.items-center`)).find(e=>e.querySelector(`button[role="combobox"]`)||e.querySelector(`[data-quickforge-thinking-selector]`))}function Je(e,t){ue(be({value:Ke(t.thinkingLevel)?t.thinkingLevel:`off`,placeholder:me(`Off`),options:Ge.map(e=>({value:e.value,label:e.label(),icon:ve(_e,`sm`)})),onChange:e=>{let n=Ke(e)?e:`off`;t.thinkingLevel=n,t.onThinkingChange?.(n),t.requestUpdate?.()},width:`80px`,size:`sm`,variant:`ghost`,fitContent:!0}),e)}function Ye(e){let t=e;Ke(t.thinkingLevel)||(t.thinkingLevel=`off`,t.onThinkingChange?.(`off`));let n=qe(e);if(!n)return;let r=n.querySelector(`[data-quickforge-thinking-selector]`);if(r){Je(r,t);return}let i=n.querySelector(`button[role="combobox"]`);if(!i)return;i.style.display=`none`,i.setAttribute(`aria-hidden`,`true`);let a=document.createElement(`span`);a.dataset.quickforgeThinkingSelector=`true`,i.insertAdjacentElement(`afterend`,a),Je(a,t)}function Xe(e={}){let{hideSelector:t=!1}=e,n=()=>{let e=customElements.get(`message-editor`);if(!e?.prototype.render||e.prototype.render.__quickforgePatched)return;let n=e.prototype.render;e.prototype.render=function(){let e=n.call(this);return queueMicrotask(()=>{if(t){let e=this;e.showThinkingSelector!==!1&&(e.showThinkingSelector=!1,e.requestUpdate?.());return}Ye(this)}),e},e.prototype.render.__quickforgePatched=!0};if(customElements.get(`message-editor`)){n();return}customElements.whenDefined(`message-editor`).then(n).catch(()=>{})}function Ze(e){return new Promise((t,n)=>{let r=document.createElement(`textarea`);r.value=e,r.style.position=`fixed`,r.style.left=`-9999px`,r.style.top=`-9999px`,r.style.opacity=`0`,document.body.append(r),r.select();try{document.execCommand(`copy`)?t():n(Error(`execCommand("copy") returned false`))}catch(e){n(e)}finally{r.remove()}})}function Qe(){navigator.clipboard||Object.defineProperty(navigator,`clipboard`,{value:{writeText:Ze,readText:()=>Promise.reject(Error(`Clipboard read is not available in non-secure contexts`)),read:()=>Promise.reject(Error(`Clipboard read is not available in non-secure contexts`)),write:()=>Promise.reject(Error(`Clipboard write is not available in non-secure contexts`))},configurable:!0,enumerable:!0,writable:!1})}function G(...e){return fe(de(e))}var K=ce(),$e=pe(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-input bg-background hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 px-4 py-2`,sm:`h-8 rounded-md px-3`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}}),q=V.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,K.jsx)(`button`,{className:G($e({variant:t,size:n,className:e})),ref:i,...r}));q.displayName=`Button`;var et=class extends V.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){B.error(`ErrorBoundary caught an error:`,e,t)}handleRetry=()=>{this.setState({error:null})};handleReload=()=>{window.location.reload()};render(){return this.state.error?this.props.fallback?this.props.fallback:(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,K.jsxs)(`div`,{className:`max-w-md rounded-lg border border-border bg-card p-5 shadow-sm text-center`,children:[(0,K.jsx)(`h1`,{className:`text-base font-semibold`,children:W(`errorBoundaryTitle`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground break-all`,children:this.state.error.message||W(`errorBoundaryUnexpected`)}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,size:`sm`,onClick:this.handleRetry,children:W(`errorBoundaryTryAgain`)}),(0,K.jsx)(q,{variant:`default`,size:`sm`,onClick:this.handleReload,children:W(`reloadPage`)})]})]})}):this.props.children}};async function tt(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function nt({open:e,initialPath:t,disabled:n,onOpenChange:r,onSelect:a}){let o=(0,V.useRef)(null),[s,c]=(0,V.useState)([]),[l,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)([]),[v,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(``),T=async e=>{if(e.trim()){b(!0),w(``);try{let t=await tt(await fetch(`/api/filesystem/directories?path=${encodeURIComponent(e.trim())}`));d(t.path),p(t.path),h(t.parent),_(Array.isArray(t.directories)?t.directories:[])}catch(e){w(e instanceof Error?e.message:W(`directoryLoadFailed`))}finally{b(!1)}}};return(0,V.useEffect)(()=>{if(!e)return;let n=!1;return(async()=>{b(!0),w(``);try{let e=await tt(await fetch(`/api/filesystem/roots`));if(n)return;let r=Array.isArray(e.roots)?e.roots:[];c(r);let i=t||r[0]?.path||``;i&&await T(i)}catch(e){n||w(e instanceof Error?e.message:W(`filesystemRootsFailed`))}finally{n||b(!1)}})(),window.setTimeout(()=>o.current?.focus(),0),()=>{n=!0}},[t,e]),(0,V.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&!x&&r(!1)};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[r,e,x]),e?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:e=>{e.target===e.currentTarget&&!x&&r(!1)},children:(0,K.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-2xl flex-col rounded-lg border border-border bg-background shadow-xl`,children:[(0,K.jsxs)(`div`,{className:`border-b border-border p-4`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:W(`selectProjectDirectory`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:W(`selectProjectDirectoryDescription`)})]}),(0,K.jsxs)(`div`,{className:`space-y-4 overflow-y-auto p-4`,children:[s.length>0?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:W(`quickAccess`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:s.map(e=>(0,K.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>T(e.path),disabled:v||x,children:e.name},`${e.name}:${e.path}`))})]}):null,(0,K.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),T(f)},children:[(0,K.jsx)(`label`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,htmlFor:`project-path-input`,children:W(`path`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{id:`project-path-input`,ref:o,className:G(`min-w-0 flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground shadow-sm`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`),value:f,onChange:e=>p(e.target.value),placeholder:W(`folderPickerPathPlaceholder`),disabled:v||x}),(0,K.jsx)(q,{type:`submit`,variant:`outline`,disabled:v||x||!f.trim(),children:W(`go`)})]})]}),C?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:C}):null,(0,K.jsxs)(`div`,{className:`rounded-md border border-border`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium`,title:l,children:l||W(`loading`)}),v?(0,K.jsx)(u,{className:`size-4 shrink-0 animate-spin text-muted-foreground`}):null]}),(0,K.jsxs)(`div`,{className:`max-h-80 overflow-y-auto p-1`,children:[m?(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm hover:bg-secondary disabled:opacity-50`,onClick:()=>T(m),disabled:v||x,children:[(0,K.jsx)(y,{className:`size-4 text-muted-foreground`}),(0,K.jsx)(`span`,{children:W(`parentDirectory`)})]}):null,!v&&g.length===0?(0,K.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:W(`noFolders`)}):null,g.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm hover:bg-secondary disabled:opacity-50`,onClick:()=>T(e.path),disabled:v||x,title:e.path,children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border p-4`,children:[(0,K.jsx)(q,{type:`button`,variant:`outline`,onClick:()=>r(!1),disabled:x,children:W(`cancel`)}),(0,K.jsx)(q,{type:`button`,onClick:async()=>{let e=f.trim()||l;if(!(!e||x||n)){S(!0),w(``);try{await a(e),r(!1)}catch(e){w(e instanceof Error?e.message:W(`failedToSelectProjectDirectory`))}finally{S(!1)}}},disabled:v||x||n||!(f.trim()||l),children:W(x?`selecting`:`selectThisFolder`)})]})]})}):null}async function rt(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function it({open:e,scope:n,project:r,onOpenChange:i,onSaved:a}){let[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(()=>new Set),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[b,x]=(0,V.useState)(``),S=n===`project`,[C,w]=(0,V.useState)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(!1),[k,ee]=(0,V.useState)(``),A=(0,V.useCallback)(()=>{w(null),E(null),ee(``)},[]),j=(0,V.useCallback)(()=>{A(),i(!1)},[i,A]);(0,V.useEffect)(()=>{if(!e||S&&!r)return;let t=!1;return(async()=>{g(!0),x(``);try{let e=S?`/api/skills?projectId=${encodeURIComponent(r.id)}`:`/api/skills?scope=global`,n=await rt(await fetch(e));if(t)return;s(Array.isArray(n.skills)?n.skills:[]),l(new Set(Array.isArray(n.selectedSkills)?n.selectedSkills:[])),m(Array.isArray(n.searchPaths)?n.searchPaths:[])}catch(e){t||x(e instanceof Error?e.message:W(`failedToLoadSkills`))}finally{t||g(!1)}})(),()=>{t=!0}},[e,r,S]),(0,V.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(C?A():_||j())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[j,e,_,C,A]);let M=(0,V.useMemo)(()=>{let e=d.trim().toLowerCase();return e?o.filter(t=>[t.name,t.displayName,t.description,t.source,t.compatibility,t.allowedTools,...t.tags??[],...t.triggers??[]].filter(Boolean).join(` `).toLowerCase().includes(e)):o},[d,o]),N=async e=>{w(e),E(null),ee(``),O(!0);try{let t=new URLSearchParams({name:e});S&&r?(t.set(`scope`,`project`),t.set(`projectId`,r.id)):t.set(`scope`,`global`),E(await rt(await fetch(`/api/skills/content?${t}`)))}catch(e){ee(e instanceof Error?e.message:W(`failedToReadSkill`))}finally{O(!1)}},te=()=>{A()};if(!e||S&&!r)return null;let ne=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=async()=>{if(!_){v(!0),x(``);try{let e=await rt(await fetch(S?`/api/skills/project`:`/api/skills/global`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(S?{projectId:r.id,selectedSkills:[...c]}:{selectedSkills:[...c]})}));a({scope:n,project:S?e.projects?.find(e=>e.id===r.id)??{...r,skills:e.selectedSkills}:void 0,projects:e.projects,selectedSkills:e.selectedSkills}),j()}catch(e){x(e instanceof Error?e.message:W(`failedToSaveSkills`))}finally{v(!1)}}},ie=W(S?`projectSkills`:`globalSkills`),ae=S?W(`projectSkillsDescription`,{project:r.name}):W(`globalSkillsDescription`),I=!!C;return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:e=>{e.target===e.currentTarget&&!_&&j()},children:(0,K.jsxs)(`div`,{className:`flex max-h-[85vh] w-full max-w-2xl flex-col rounded-lg border border-border bg-background shadow-xl`,children:[(0,K.jsx)(`div`,{className:`border-b border-border p-4`,children:I?(0,K.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors`,onClick:te,children:[(0,K.jsx)(y,{className:`size-4`}),W(`backToSkillList`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:ie}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:ae}),p.length?(0,K.jsxs)(`p`,{className:`mt-2 break-all text-xs text-muted-foreground/65`,children:[W(`skillSearchPaths`),`: `,p.join(` · `)]}):null]})}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:I?D?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground`,children:[(0,K.jsx)(u,{className:`size-4 animate-spin`}),W(`loading`)]}):k?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:k}):T?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-sm space-y-1`,children:[(0,K.jsxs)(`div`,{className:`font-medium text-foreground/90`,children:[T.displayName||T.name,T.version?(0,K.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`v`,T.version]}):null]}),T.description?(0,K.jsx)(`div`,{className:`text-muted-foreground/70`,children:T.description}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5 text-xs text-muted-foreground/60`,children:[T.source?(0,K.jsx)(`span`,{children:T.source}):null,T.compatibility?(0,K.jsxs)(`span`,{children:[`· `,T.compatibility]}):null,T.allowedTools?(0,K.jsxs)(`span`,{children:[`· `,T.allowedTools]}):null,T.license?(0,K.jsxs)(`span`,{children:[`· `,T.license]}):null]}),T.tags?.length?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:T.tags.map(e=>(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:e},e))}):null,T.triggers?.length?(0,K.jsxs)(`div`,{className:`text-xs text-muted-foreground/60`,children:[`Triggers: `,T.triggers.join(`, `)]}):null]}),T.instructions?(0,K.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded-md border border-border bg-muted/30 px-4 py-3 text-sm leading-6 text-foreground/80 font-mono`,children:T.instructions}):(0,K.jsx)(`div`,{className:`py-4 text-center text-sm text-muted-foreground`,children:W(`noSkillContent`)})]}):null:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-input bg-background px-3 py-2`,children:[(0,K.jsx)(P,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:W(`searchSkills`),className:`min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/45`,disabled:h||_})]}),b?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null,(0,K.jsxs)(`div`,{className:`rounded-md border border-border`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:W(`availableSkills`)}),(0,K.jsx)(`span`,{children:W(`selectedSkillsCount`,{count:c.size})})]}),(0,K.jsx)(`div`,{className:`max-h-[46vh] overflow-y-auto p-1`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-8 text-sm text-muted-foreground`,children:[(0,K.jsx)(u,{className:`size-4 animate-spin`}),W(`loading`)]}):M.length===0?(0,K.jsx)(`div`,{className:`px-3 py-8 text-center text-sm text-muted-foreground`,children:W(`noMatchingSkills`)}):M.map(e=>{let n=c.has(e.name);return(0,K.jsxs)(`div`,{className:G(`flex w-full items-start gap-3 rounded-md px-3 py-3 text-left text-sm transition-colors hover:bg-secondary disabled:opacity-50`,n&&`bg-secondary/70`),children:[(0,K.jsx)(`button`,{type:`button`,className:G(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded border border-input`,n&&`border-primary bg-primary text-primary-foreground`),onClick:()=>ne(e.name),disabled:_,"aria-label":n?`Deselect ${e.name}`:`Select ${e.name}`,children:n?(0,K.jsx)(t,{className:`size-3.5`}):null}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 cursor-pointer`,onClick:()=>ne(e.name),children:[(0,K.jsx)(`span`,{className:`block truncate font-medium text-foreground/90`,children:e.displayName||e.name}),e.description?(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-muted-foreground/70`,children:e.description}):null,(0,K.jsxs)(`span`,{className:`mt-1 flex flex-wrap gap-1 text-[11px] text-muted-foreground/60`,children:[e.source?(0,K.jsx)(`span`,{children:e.source}):null,e.compatibility?(0,K.jsxs)(`span`,{children:[`· `,e.compatibility]}):null,e.allowedTools?(0,K.jsxs)(`span`,{children:[`· `,e.allowedTools]}):null]}),e.tags?.length?(0,K.jsx)(`span`,{className:`mt-2 flex flex-wrap gap-1`,children:e.tags.slice(0,5).map(e=>(0,K.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`,children:e},e))}):null]}),(0,K.jsx)(`button`,{type:`button`,className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-secondary hover:text-foreground`,onClick:()=>void N(e.name),disabled:_||D,title:W(`readSkill`),"aria-label":`${W(`readSkill`)}: ${e.displayName||e.name}`,children:(0,K.jsx)(F,{className:`size-4`})})]},e.name)})})]})]})}),I?null:(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border p-4`,children:[(0,K.jsx)(q,{type:`button`,variant:`outline`,onClick:j,disabled:_,children:W(`cancel`)}),(0,K.jsx)(q,{type:`button`,onClick:re,disabled:h||_,children:W(_?`saving`:`save`)})]})]})})}var at=se();function ot({title:e,description:t,actions:n,onCancel:r}){let i=(0,V.useRef)(null),a=(0,V.useRef)(!1),o=(0,V.useCallback)(()=>{a.current||(a.current=!0,r())},[r]),s=(0,V.useCallback)(e=>{a.current||(a.current=!0,e.onClick())},[]);return(0,V.useEffect)(()=>{i.current?.focus();let e=e=>{if(e.key===`Escape`&&o(),e.key===`Enter`){let e;for(let t=n.length-1;t>=0;t--)if(n[t].enter!==!1){e=n[t];break}e&&s(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,s,n]),(0,at.createPortal)((0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 px-4 py-6`,onMouseDown:e=>{e.target===e.currentTarget&&o()},children:(0,K.jsxs)(`div`,{className:G(`w-full max-w-[420px] rounded-2xl border border-border bg-background p-5 shadow-xl`),role:`dialog`,"aria-modal":`true`,"aria-labelledby":e?`message-dialog-title`:void 0,"aria-describedby":`message-dialog-description`,onMouseDown:e=>e.stopPropagation(),children:[e?(0,K.jsx)(`h2`,{id:`message-dialog-title`,className:`text-base font-semibold text-foreground/90`,children:e}):null,(0,K.jsx)(`p`,{id:`message-dialog-description`,className:G(`text-sm leading-6 text-muted-foreground/72`,e?`mt-2`:void 0),children:t}),(0,K.jsx)(`div`,{className:`mt-6 flex justify-end gap-2`,children:n.map((e,t)=>(0,K.jsx)(q,{ref:e.autoFocus?i:void 0,variant:e.variant,size:`sm`,onClick:()=>s(e),children:e.label},`${e.label}-${t}`))})]})}),document.body)}function st(e){return new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,Ae.createRoot)(n);function i(){r.unmount(),setTimeout(()=>n.remove(),0)}function a(e){i(),t(e)}r.render(e(a))})}function ct(e){return st(t=>(0,K.jsx)(ot,{title:e.title,description:e.description,onCancel:()=>t(!1),actions:[{label:e.cancelLabel??`Cancel`,variant:`outline`,onClick:()=>t(!1),autoFocus:e.variant===`destructive`},{label:e.confirmLabel??`Confirm`,variant:e.variant===`destructive`?`destructive`:`default`,autoFocus:e.variant!==`destructive`,enter:e.variant!==`destructive`,onClick:()=>t(!0)}]}))}function J(e){let t=typeof e==`string`?{description:e}:e;return st(e=>(0,K.jsx)(ot,{title:t.title,description:t.description,onCancel:()=>e(),actions:[{label:t.confirmLabel??`OK`,autoFocus:!0,onClick:()=>e()}]}))}var lt=`{
11
- "mcpServers": {
12
- "zai-mcp-server": {
13
- "type": "stdio",
14
- "command": "npx",
15
- "args": [
16
- "-y",
17
- "@z_ai/mcp-server"
18
- ],
19
- "env": {
20
- "Z_AI_API_KEY": "\${Z_AI_API_KEY}",
21
- "Z_AI_MODE": "ZHIPU"
22
- }
23
- }
24
- }
25
- }`;async function ut(e){let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`HTTP ${e.status}`);return t}function dt(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function ft(e){let t;try{t=JSON.parse(e)}catch{throw Error(W(`mcpInvalidJson`))}if(!dt(t)||!dt(t.mcpServers))throw Error(W(`mcpInvalidConfigJson`));let n=Object.entries(t.mcpServers);if(n.length===0)throw Error(W(`mcpEmptyConfigJson`));for(let[e,t]of n){if(!/^(?!.*--)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(e))throw Error(W(`mcpInvalidServerName`,{name:e}));if(!dt(t))throw Error(W(`mcpInvalidServerConfig`,{name:e}));let n=String(t.transport||t.type||`stdio`);if(![`stdio`,`http`,`sse`].includes(n))throw Error(W(`mcpInvalidTransport`,{name:e}));if(n===`stdio`&&typeof t.command!=`string`)throw Error(W(`mcpMissingCommand`,{name:e}));if(n!==`stdio`&&typeof t.url!=`string`)throw Error(W(`mcpMissingUrl`,{name:e}));if(t.args!==void 0&&!Array.isArray(t.args))throw Error(W(`mcpArgsMustBeArray`,{name:e}));if(t.env!==void 0&&!dt(t.env))throw Error(W(`mcpEnvMustBeObject`,{name:e}));if(t.headers!==void 0&&!dt(t.headers))throw Error(W(`mcpHeadersMustBeObject`,{name:e}))}return t}function pt(e){let t={type:e.transport||`stdio`,enabled:e.enabled};return e.transport===`stdio`?(t.command=e.command,t.args=e.args||[],e.cwd&&(t.cwd=e.cwd),e.env&&Object.keys(e.env).length>0&&(t.env=e.env)):(t.url=e.url||``,e.env&&Object.keys(e.env).length>0&&(t.headers=e.env)),JSON.stringify({mcpServers:{[e.name]:t}},null,2)}function mt(e){return e===`connected`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-destructive/12 text-destructive`:e===`disabled`?`bg-muted text-muted-foreground`:`bg-amber-500/12 text-amber-700 dark:text-amber-300`}function ht({open:e,onOpenChange:t}){let[n,r]=(0,V.useState)([]),[i,a]=(0,V.useState)(lt),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(``),h=async()=>{s(!0),m(``);try{let e=await ut(await fetch(`/api/mcp/servers`));r(Array.isArray(e.servers)?e.servers:[])}catch(e){m(e instanceof Error?e.message:W(`mcpLoadFailed`))}finally{s(!1)}};if((0,V.useEffect)(()=>{if(!e)return;let t=window.setTimeout(()=>{h()},0);return()=>window.clearTimeout(t)},[e]),!e)return null;let g=async e=>{if(!c&&!(e===`replace`&&!await ct({description:W(`mcpReplaceConfirm`),confirmLabel:W(`mcpReplaceAll`),cancelLabel:W(`cancel`)}))){l(!0),m(``);try{let t=ft(i),n=await ut(await fetch(`/api/mcp/config`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({mode:e,...t})}));r(Array.isArray(n.servers)?n.servers:[])}catch(e){m(e instanceof Error?e.message:W(`mcpSaveFailed`))}finally{l(!1)}}},_=async e=>{if(await ct({description:W(`mcpDeleteConfirm`,{name:e}),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`})){m(``);try{let t=await ut(await fetch(`/api/mcp/servers/${encodeURIComponent(e)}`,{method:`DELETE`}));r(Array.isArray(t.servers)?t.servers:[])}catch(e){m(e instanceof Error?e.message:W(`mcpDeleteFailed`))}}},v=async e=>{if(!d){f(e.name),m(``);try{let t=await ut(await fetch(`/api/mcp/servers/${encodeURIComponent(e.name)}/enabled`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})}));r(Array.isArray(t.servers)?t.servers:[])}catch(e){m(e instanceof Error?e.message:W(`mcpSaveFailed`))}finally{f(null)}}};return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`mcp-servers-title`,onClick:e=>{e.target===e.currentTarget&&!c&&t(!1)},children:(0,K.jsxs)(`div`,{className:`flex max-h-[88vh] w-full max-w-5xl flex-col rounded-lg border border-border bg-background shadow-xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border p-4`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full bg-muted/40 text-muted-foreground`,children:(0,K.jsx)(b,{className:`size-4`})}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(`h2`,{id:`mcp-servers-title`,className:`text-base font-semibold text-foreground`,children:W(`mcpServers`)})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0 rounded-full text-muted-foreground`,onClick:()=>t(!1),disabled:c,"aria-label":W(`close`),children:(0,K.jsx)(M,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[p?(0,K.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:p}):null,(0,K.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_28rem]`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground/90`,children:W(`mcpConfiguredServers`)}),(0,K.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:async()=>{s(!0),m(``);try{let e=await ut(await fetch(`/api/mcp/reconnect`,{method:`POST`}));r(Array.isArray(e.servers)?e.servers:[])}catch(e){m(e instanceof Error?e.message:W(`mcpReconnectFailed`))}finally{s(!1)}},disabled:o,children:[o?(0,K.jsx)(u,{className:`mr-1.5 size-3.5 animate-spin`}):(0,K.jsx)(j,{className:`mr-1.5 size-3.5`}),W(`mcpReconnect`)]})]}),o&&n.length===0?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-lg border border-border py-8 text-sm text-muted-foreground`,children:[(0,K.jsx)(u,{className:`size-4 animate-spin`}),W(`loading`)]}):n.length===0?(0,K.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/15 p-4 text-sm text-muted-foreground/72`,children:W(`mcpNoServersDescription`)}):n.map(e=>(0,K.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.name}),(0,K.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-[11px] ${mt(e.status)}`,children:e.status||`unknown`}),(0,K.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60`,children:W(`mcpToolsCount`,{count:e.toolCount??0})})]}),(0,K.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground/65`,children:e.transport===`stdio`?`${e.command} ${(e.args||[]).join(` `)}`:e.url}),e.error?(0,K.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:e.error}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,disabled:d===e.name,className:G(`relative h-6 w-11 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60`,e.enabled?`bg-emerald-500`:`bg-muted-foreground/30`),onClick:()=>{v(e)},title:e.enabled?W(`pauseTask`):W(`enable`),children:(0,K.jsx)(`span`,{className:G(`absolute left-0.5 top-0.5 size-5 rounded-full bg-white shadow transition-transform`,e.enabled?`translate-x-5`:`translate-x-0`)})}),(0,K.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground`,onClick:()=>{a(pt(e)),m(``)},"aria-label":W(`editTask`),title:W(`editTask`),children:(0,K.jsx)(oe,{className:`size-4`})}),(0,K.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-destructive`,onClick:()=>{_(e.name)},"aria-label":W(`delete`),title:W(`delete`),children:(0,K.jsx)(x,{className:`size-4`})})]})]}),e.tools?.length?(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.tools.slice(0,12).map(e=>(0,K.jsx)(`span`,{className:`rounded-md bg-muted/50 px-1.5 py-0.5 text-[11px] text-muted-foreground/75`,title:e.quickForgeName,children:e.name},e.quickForgeName))}):null]},e.name))]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-border p-3`,children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-foreground/90`,children:W(`mcpImportConfig`)}),(0,K.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(lt),m(``)},children:W(`mcpUseExample`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-5 text-muted-foreground/72`,children:W(`mcpImportConfigDescription`)}),(0,K.jsx)(`textarea`,{className:`min-h-96 w-full resize-y rounded-md border border-input bg-background px-2 py-1.5 font-mono text-xs text-foreground outline-none focus:border-ring`,value:i,onChange:e=>a(e.target.value),spellCheck:!1}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsxs)(q,{type:`button`,className:`w-full`,onClick:()=>{g(`merge`)},disabled:c||!i.trim(),children:[c?(0,K.jsx)(u,{className:`mr-1.5 size-4 animate-spin`}):(0,K.jsx)(E,{className:`mr-1.5 size-4`}),W(`mcpImportUpdate`)]}),(0,K.jsx)(q,{type:`button`,variant:`outline`,className:`w-full`,onClick:()=>{g(`replace`)},disabled:c||!i.trim(),children:W(`mcpReplaceAll`)})]})]})]})]})]})]})})}var gt=new Set;function _t(e){return typeof e[Symbol.iterator]==`function`}var vt=class{baseUrl;blockedStores;storeOverrides;fakeProviderKeys;constructor(e=``,t=gt){this.baseUrl=e,_t(t)?(this.blockedStores=new Set(t),this.storeOverrides={},this.fakeProviderKeys=new Set):(this.blockedStores=new Set(t.blockedStores??gt),this.storeOverrides=t.storeOverrides??{},this.fakeProviderKeys=new Set(t.fakeProviderKeys??[]))}assertStoreAccess(e){if(this.blockedStores.has(e))throw Error(`This storage area is not available in the current page.`)}static async isAvailable(e=``){let t=new AbortController,n=window.setTimeout(()=>t.abort(),1e3);try{let n=await fetch(`${e}/api/health`,{method:`GET`,cache:`no-store`,signal:t.signal});return n.ok?(await n.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(n)}}path(...e){return`${this.baseUrl}/api/storage/${e.map(e=>encodeURIComponent(e)).join(`/`)}`}async request(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Local storage request failed: ${n.status}`);return r}async get(e,t){if(e===`provider-keys`&&this.fakeProviderKeys.has(t))return`shared-server-managed-key`;let n=this.storeOverrides[e];return n?.get?n.get(t):(this.assertStoreAccess(e),(await this.request(this.path(e,`key`,t))).value??null)}async set(e,t,n){this.assertStoreAccess(e),await this.request(this.path(e,`key`,t),{method:`PUT`,body:JSON.stringify({value:n})})}async delete(e,t){this.assertStoreAccess(e),await this.request(this.path(e,`key`,t),{method:`DELETE`})}async keys(e,t){if(e===`provider-keys`&&this.fakeProviderKeys.size>0)return[...this.fakeProviderKeys];let n=this.storeOverrides[e];if(n?.keys)return n.keys(t);this.assertStoreAccess(e);let r=t?`?prefix=${encodeURIComponent(t)}`:``;return(await this.request(`${this.path(e,`keys`)}${r}`)).keys}async getAllFromIndex(e,t,n=`asc`){return this.assertStoreAccess(e),(await this.request(`${this.path(e,`index`,t)}?direction=${encodeURIComponent(n)}`)).values}async fetchPaginatedFromIndex(e,t,n){this.assertStoreAccess(e);let r=new URLSearchParams;return r.set(`direction`,n.direction||`desc`),r.set(`limit`,String(n.limit)),r.set(`offset`,String(n.offset)),n.scope&&r.set(`scope`,n.scope),n.projectId&&r.set(`projectId`,n.projectId),this.request(`${this.path(e,`index`,t)}?${r.toString()}`)}async clear(e){this.assertStoreAccess(e),await this.request(this.path(e),{method:`DELETE`})}async has(e,t){if(e===`provider-keys`&&this.fakeProviderKeys.has(t))return!0;let n=this.storeOverrides[e];return n?.has?n.has(t):(this.assertStoreAccess(e),(await this.request(this.path(e,`has`,t))).exists)}async transaction(e,t,n){for(let t of e)t===`provider-keys`&&this.fakeProviderKeys.size>0||this.storeOverrides[t]||this.assertStoreAccess(t);return n({get:(e,t)=>this.get(e,t),set:(e,t,n)=>this.set(e,t,n),delete:(e,t)=>this.delete(e,t)})}async getQuotaInfo(){return this.request(`${this.baseUrl}/api/storage/quota`)}async requestPersistence(){return!0}};function Y(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<e.length;t+=1)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`));return`${t.slice(0,4).join(``)}-${t.slice(4,6).join(``)}-${t.slice(6,8).join(``)}-${t.slice(8,10).join(``)}-${t.slice(10).join(``)}`}var yt=`active-model`,bt=`yolo-mode`,xt=`yolo-mode-project:`,St=`default-options`,Ct={id:`default-litellm-anthropic`,name:`LiteLLM Anthropic`,baseUrl:`http://localhost:4000/v1`,apiKey:``,modelId:`anthropic/claude-sonnet-4`,contextWindow:2e5,maxTokens:8192};function wt(e,t,n=``){let r=e.toLowerCase(),i=t.toLowerCase(),a=n.toLowerCase();return r.includes(`deepseek-v4`)&&(a.includes(`deepseek`)||i.includes(`api.deepseek.com`)||i.includes(`deepseek.com`))}function Tt(){return{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:`deepseek`}}var Et={low:`high`,medium:`high`,high:`high`,xhigh:`max`};function Dt(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n.includes(`deepseek`)||r.includes(`api.deepseek.com`)||r.includes(`deepseek.com`)?`deepseek`:r.includes(`openrouter.ai`)?`openrouter`:n===`zai`||r.includes(`bigmodel.cn`)||r.includes(`z.ai`)?`zai`:`openai`}function Ot(e){let t={...e.compat,...e.reasoning===!0&&e.compat?.supportsReasoningEffort===void 0?{supportsReasoningEffort:!0}:{},thinkingFormat:e.compat?.thinkingFormat??Dt(e.provider,e.baseUrl)};return{...e,compat:t}}function kt(e){if(e.api!==`openai-completions`)return e;let t=Ot(e);return wt(t.id,t.baseUrl,t.provider)?{...t,reasoning:!0,thinkingLevelMap:{...t.thinkingLevelMap,...Et},compat:{...t.compat,supportsReasoningEffort:!0,...Tt()}}:t}function At(e){let t=e.baseUrl.trim().replace(/\/$/,``),n=e.modelId.trim(),r=e.name.trim(),i=wt(n,t,r),a=e.reasoning===!0||i;return kt({id:n,name:`${n} (${r})`,api:`openai-completions`,provider:r,baseUrl:t,reasoning:a,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||Ct.contextWindow,maxTokens:Number(e.maxTokens)||Ct.maxTokens,thinkingLevelMap:i?Et:void 0,compat:{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:a,supportsUsageInStreaming:!1,supportsStrictMode:!1,maxTokensField:`max_tokens`,...i?Tt():{}}})}function jt(){return{settings:new Te,providerKeys:new we,sessions:new xe,customProviders:new ye}}function Mt(e,t){e.settings.setBackend(t),e.providerKeys.setBackend(t),e.sessions.setBackend(t),e.customProviders.setBackend(t)}async function Nt(e){if(!await vt.isAvailable())throw Error(`QuickForge local service is unavailable.`);return new vt(``,e)}async function Pt(e={}){let t=jt(),n=await Nt(e.blockedStores);Mt(t,n);let r=new Ee(t.settings,t.providerKeys,t.sessions,t.customProviders,n);return ge(r),r}async function Ft(e,t){await e.settings.set(yt,kt(t))}function It(e){return e?.reasoning?`medium`:`off`}function Lt(e){return e===`off`||e===`low`||e===`medium`||e===`high`||e===`xhigh`}async function Rt(e,t){await e.settings.set(St,{model:t.model?kt(t.model):void 0,thinkingLevel:Lt(t.thinkingLevel)?t.thinkingLevel:void 0})}async function zt(e){let t=await e.settings.get(St);return!t||typeof t!=`object`?{}:{model:t.model?kt(t.model):void 0,thinkingLevel:Lt(t.thinkingLevel)?t.thinkingLevel:void 0}}async function Bt(e){let t=await e.settings.get(yt);return!t||typeof t!=`object`||!t.id||!t.provider||!t.api||!t.baseUrl?null:kt(t)}function Vt(e,t){return(e??``).trim().replace(/\/$/,``)===(t??``).trim().replace(/\/$/,``)}function Ht(e,t){return e.id===t.id&&e.provider===t.provider&&e.api===t.api&&Vt(e.baseUrl,t.baseUrl)}function Ut(e){let t=e;return!!(t?.id&&t.provider&&t.api&&t.baseUrl)}function Wt(e){return e.flatMap(e=>e.models??[]).filter(Ut).map(e=>kt(e))}async function Gt(e){return Wt(await e.customProviders.getAll())}async function X(e){let t=await Gt(e);if(t.length===0)return null;let n=await Bt(e);if(n){let e=t.find(e=>Ht(e,n));if(e)return e}return t[0]}function Kt(e,t){return e.customProviders.getAll().then(e=>{for(let n of e){let e=(n.models??[]).find(e=>e.id===t.id&&e.api===t.api&&e.provider===t.provider&&Vt(e.baseUrl,t.baseUrl));if(e)return e}})}async function qt(e,t){try{let n=await Kt(e,t);if(n)return n.reasoning===!0?kt(n):n}catch(e){B.warn(`Failed to resolve configured model:`,e)}return kt(t)}async function Jt(e,t,n){let r=n?`${xt}${n}`:bt;await e.settings.set(r,t)}async function Yt(e,t){if(t){let n=`${xt}${t}`,r=await e.settings.get(n);if(r!=null)return r===!0||r===`true`}let n=await e.settings.get(bt);return n==null?(await Jt(e,!0),!0):n===!0||n===`true`}async function Xt(e,t,n){let r=t.id||Y(),i={id:r,name:t.name.trim(),type:`openai-completions`,baseUrl:n.baseUrl,apiKey:t.apiKey.trim()||void 0,models:[n]};return await e.customProviders.set(i),t.apiKey.trim()&&await e.providerKeys.set(n.provider,t.apiKey.trim()),r}function Zt(e){return e?.scope===`project`?`project`:`global`}function Qt(e){return e===`New chat`?W(`newChat`):e}function $t({hasProject:e,onConfigureModel:t,onAddProject:n,onCopyExamplePrompt:r,onDismiss:i}){return(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-20 flex items-center justify-center bg-background/35 p-3 backdrop-blur-sm sm:p-6`,children:(0,K.jsx)(`div`,{className:`pointer-events-auto w-full max-w-4xl rounded-2xl border border-border bg-background/95 p-5 shadow-lg backdrop-blur-md sm:p-6`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary`,children:(0,K.jsx)(N,{className:`size-5`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground sm:text-lg`,children:W(`firstUseGuideTitle`)}),(0,K.jsx)(`p`,{className:`mt-1.5 text-sm leading-6 text-muted-foreground`,children:W(`firstUseGuideDescription`)})]}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`-mr-1 -mt-1 size-7 shrink-0`,onClick:i,"aria-label":W(`firstUseGuideDismiss`),children:(0,K.jsx)(M,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`mt-4 grid gap-3 text-sm text-muted-foreground sm:grid-cols-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2.5 rounded-xl border border-border/70 bg-muted/15 p-3`,children:[(0,K.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{children:W(`firstUseGuideStepModel`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2.5 rounded-xl border border-border/70 bg-muted/15 p-3`,children:[(0,K.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{children:W(`firstUseGuideStepProject`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2.5 rounded-xl border border-border/70 bg-muted/15 p-3`,children:[(0,K.jsx)(A,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{children:W(`firstUseGuideStepPlan`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2.5`,children:[(0,K.jsxs)(q,{size:`sm`,onClick:t,children:[(0,K.jsx)(C,{className:`size-4`}),W(`firstUseGuideConfigureModel`)]}),(0,K.jsxs)(q,{size:`sm`,variant:e?`outline`:`default`,onClick:n,children:[(0,K.jsx)(s,{className:`size-4`}),W(`firstUseGuideAddProject`)]}),(0,K.jsxs)(q,{size:`sm`,variant:`outline`,onClick:r,children:[(0,K.jsx)(f,{className:`size-4`}),W(`firstUseGuideCopyPrompt`)]}),(0,K.jsx)(q,{size:`sm`,variant:`ghost`,onClick:i,children:W(`firstUseGuideDismiss`)})]})]})]})})})}function en({onAddModel:e,onUseExample:t}){return(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-6`,children:(0,K.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-border bg-card/80 p-6 text-center shadow-sm backdrop-blur`,children:[(0,K.jsx)(`div`,{className:`mx-auto flex size-12 items-center justify-center rounded-2xl bg-primary/10 text-primary`,children:(0,K.jsx)(N,{className:`size-6`})}),(0,K.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-foreground`,children:W(`modelSetupTitle`)}),(0,K.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:W(`modelSetupDescription`)}),(0,K.jsxs)(`div`,{className:`mt-5 grid gap-3 rounded-xl border border-border/70 bg-muted/25 p-4 text-left text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:W(`modelSetupSupports`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-primary`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:W(`modelSetupLocalStorage`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex flex-col justify-center gap-3 sm:flex-row`,children:[(0,K.jsxs)(q,{onClick:e,className:`gap-2`,children:[(0,K.jsx)(E,{className:`size-4`}),W(`modelSetupAddModel`)]}),(0,K.jsx)(q,{variant:`outline`,onClick:t,children:W(`modelSetupUseLiteLlmExample`)})]})]})})}function tn(){var e=[...arguments];return(0,V.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var nn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function rn(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function an(e){return`nodeType`in e}function on(e){return e?rn(e)?e:an(e)?e.ownerDocument?.defaultView??window:window:window}function sn(e){let{Document:t}=on(e);return e instanceof t}function cn(e){return rn(e)?!1:e instanceof on(e).HTMLElement}function ln(e){return e instanceof on(e).SVGElement}function un(e){return e?rn(e)?e.document:an(e)?sn(e)?e:cn(e)||ln(e)?e.ownerDocument:document:document:document}var dn=nn?V.useLayoutEffect:V.useEffect;function fn(e){let t=(0,V.useRef)(e);return dn(()=>{t.current=e}),(0,V.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function pn(){let e=(0,V.useRef)(null);return[(0,V.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,V.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function mn(e,t){t===void 0&&(t=[e]);let n=(0,V.useRef)(e);return dn(()=>{n.current!==e&&(n.current=e)},t),n}function hn(e,t){let n=(0,V.useRef)();return(0,V.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function gn(e){let t=fn(e),n=(0,V.useRef)(null);return[n,(0,V.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function _n(e){let t=(0,V.useRef)();return(0,V.useEffect)(()=>{t.current=e},[e]),t.current}var vn={};function yn(e,t){return(0,V.useMemo)(()=>{if(t)return t;let n=vn[e]==null?0:vn[e]+1;return vn[e]=n,e+`-`+n},[e,t])}function bn(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var xn=bn(1),Sn=bn(-1);function Cn(e){return`clientX`in e&&`clientY`in e}function wn(e){if(!e)return!1;let{KeyboardEvent:t}=on(e.target);return t&&e instanceof t}function Tn(e){if(!e)return!1;let{TouchEvent:t}=on(e.target);return t&&e instanceof t}function En(e){if(Tn(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Cn(e)?{x:e.clientX,y:e.clientY}:null}var Dn=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[Dn.Translate.toString(e),Dn.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),On=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function kn(e){return e.matches(On)?e:e.querySelector(On)}var An={display:`none`};function jn(e){let{id:t,value:n}=e;return V.createElement(`div`,{id:t,style:An},n)}function Mn(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return V.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function Nn(){let[e,t]=(0,V.useState)(``);return{announce:(0,V.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Pn=(0,V.createContext)(null);function Fn(e){let t=(0,V.useContext)(Pn);(0,V.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function In(){let[e]=(0,V.useState)(()=>new Set),t=(0,V.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,V.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Ln={draggable:`
26
- To pick up a draggable item, press the space bar.
27
- While dragging, use the arrow keys to move the item.
28
- Press space again to drop the item in its new position, or press escape to cancel.
29
- `},Rn={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function zn(e){let{announcements:t=Rn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Ln}=e,{announce:a,announcement:o}=Nn(),s=yn(`DndLiveRegion`),[c,l]=(0,V.useState)(!1);if((0,V.useEffect)(()=>{l(!0)},[]),Fn((0,V.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=V.createElement(V.Fragment,null,V.createElement(jn,{id:r,value:i.draggable}),V.createElement(Mn,{id:s,announcement:o}));return n?(0,at.createPortal)(u,n):u}var Z;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(Z||={});function Bn(){}function Vn(e,t){return(0,V.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Hn(){var e=[...arguments];return(0,V.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Un=Object.freeze({x:0,y:0});function Wn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Gn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Kn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function qn(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Jn(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var Yn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Jn(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Wn(Jn(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Gn)};function Xn(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Zn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Xn(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Kn)};function Qn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function $n(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Un}function er(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var tr=er(1);function nr(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function rr(e,t,n){let r=nr(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var ir={ignoreTransform:!1};function ar(e,t){t===void 0&&(t=ir);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=on(e).getComputedStyle(e);t&&(n=rr(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function or(e){return ar(e,{ignoreTransform:!0})}function sr(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function cr(e,t){return t===void 0&&(t=on(e).getComputedStyle(e)),t.position===`fixed`}function lr(e,t){t===void 0&&(t=on(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function ur(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(sn(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!cn(i)||ln(i)||n.includes(i))return n;let a=on(e).getComputedStyle(i);return i!==e&&lr(i,a)&&n.push(i),cr(i,a)?n:r(i.parentNode)}return e?r(e):n}function dr(e){let[t]=ur(e,1);return t??null}function fr(e){return!nn||!e?null:rn(e)?e:an(e)?sn(e)||e===un(e).scrollingElement?window:cn(e)?e:null:null}function pr(e){return rn(e)?e.scrollX:e.scrollLeft}function mr(e){return rn(e)?e.scrollY:e.scrollTop}function hr(e){return{x:pr(e),y:mr(e)}}var Q;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Q||={});function gr(e){return!nn||!e?!1:e===document.scrollingElement}function _r(e){let t={x:0,y:0},n=gr(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var vr={x:.2,y:.2};function yr(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=vr);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=_r(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Q.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Q.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Q.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Q.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function br(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function xr(e){return e.reduce((e,t)=>xn(e,hr(t)),Un)}function Sr(e){return e.reduce((e,t)=>e+pr(t),0)}function Cr(e){return e.reduce((e,t)=>e+mr(t),0)}function wr(e,t){if(t===void 0&&(t=ar),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);dr(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Tr=[[`x`,[`left`,`right`],Sr],[`y`,[`top`,`bottom`],Cr]],Er=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=ur(t),r=xr(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Tr)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},Dr=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Or(e){let{EventTarget:t}=on(e);return e instanceof t?e:un(e)}function kr(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Ar;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Ar||={});function jr(e){e.preventDefault()}function Mr(e){e.stopPropagation()}var $;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})($||={});var Nr={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},Pr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case $.Right:return{...n,x:n.x+25};case $.Left:return{...n,x:n.x-25};case $.Down:return{...n,y:n.y+25};case $.Up:return{...n,y:n.y-25}}},Fr=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Dr(un(t)),this.windowListeners=new Dr(on(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ar.Resize,this.handleCancel),this.windowListeners.add(Ar.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ar.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&wr(n),t(Un)}handleKeyDown(e){if(wn(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Nr,coordinateGetter:a=Pr,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:Un;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Sn(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=_r(n),p=br(n),m={x:Math.min(i===$.Right?p.right-p.width/2:p.right,Math.max(i===$.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===$.Down?p.bottom-p.height/2:p.bottom,Math.max(i===$.Down?p.top:p.top+p.height/2,u.y))},h=i===$.Right&&!s||i===$.Left&&!c,g=i===$.Down&&!l||i===$.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===$.Right&&e<=d.x||i===$.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===$.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===$.Down&&e<=d.y||i===$.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===$.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,xn(Sn(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Fr.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Nr,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Ir(e){return!!(e&&`distance`in e)}function Lr(e){return!!(e&&`delay`in e)}var Rr=class{constructor(e,t,n){n===void 0&&(n=Or(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=un(i),this.documentListeners=new Dr(this.document),this.listeners=new Dr(n),this.windowListeners=new Dr(on(i)),this.initialCoordinates=En(r)??Un,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Ar.Resize,this.handleCancel),this.windowListeners.add(Ar.DragStart,jr),this.windowListeners.add(Ar.VisibilityChange,this.handleCancel),this.windowListeners.add(Ar.ContextMenu,jr),this.documentListeners.add(Ar.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Lr(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Ir(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Ar.Click,Mr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ar.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=En(e)??Un,s=Sn(n,o);if(!t&&a){if(Ir(a)){if(a.tolerance!=null&&kr(s,a.tolerance))return this.handleCancel();if(kr(s,a.distance))return this.handleStart()}if(Lr(a)&&kr(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===$.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},zr={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Br=class extends Rr{constructor(e){let{event:t}=e,n=un(t.target);super(e,zr,n)}};Br.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Vr={move:{name:`mousemove`},end:{name:`mouseup`}},Hr;(function(e){e[e.RightClick=2]=`RightClick`})(Hr||={});var Ur=class extends Rr{constructor(e){super(e,Vr,un(e.event.target))}};Ur.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Hr.RightClick?!1:(r?.({event:n}),!0)}}];var Wr={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Gr=class extends Rr{constructor(e){super(e,Wr)}static setup(){return window.addEventListener(Wr.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Wr.move.name,e)};function e(){}}};Gr.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Kr;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Kr||={});var qr;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(qr||={});function Jr(e){let{acceleration:t,activator:n=Kr.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=qr.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Xr({delta:d,disabled:!a}),[m,h]=pn(),g=(0,V.useRef)({x:0,y:0}),_=(0,V.useRef)({x:0,y:0}),v=(0,V.useMemo)(()=>{switch(n){case Kr.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Kr.DraggableRect:return i}},[n,i,c]),y=(0,V.useRef)(null),b=(0,V.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,V.useMemo)(()=>s===qr.TreeOrder?[...l].reverse():l,[s,l]);(0,V.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=yr(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Yr={x:{[Q.Backward]:!1,[Q.Forward]:!1},y:{[Q.Backward]:!1,[Q.Forward]:!1}};function Xr(e){let{delta:t,disabled:n}=e,r=_n(t);return hn(e=>{if(n||!r||!e)return Yr;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Q.Backward]:e.x[Q.Backward]||i.x===-1,[Q.Forward]:e.x[Q.Forward]||i.x===1},y:{[Q.Backward]:e.y[Q.Backward]||i.y===-1,[Q.Forward]:e.y[Q.Forward]||i.y===1}}},[n,t,r])}function Zr(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return hn(e=>t==null?null:r??e??null,[r,t])}function Qr(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var $r;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})($r||={});var ei;(function(e){e.Optimized=`optimized`})(ei||={});var ti=new Map;function ni(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,V.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,V.useRef)(e),d=g(),f=mn(d),p=(0,V.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,V.useRef)(null),h=hn(t=>{if(d&&!n)return ti;if(!t||t===ti||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Er(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,V.useEffect)(()=>{u.current=e},[e]),(0,V.useEffect)(()=>{d||p()},[n,d]),(0,V.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,V.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case $r.Always:return!1;case $r.BeforeDragging:return n;default:return!n}}}function ri(e,t){return hn(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function ii(e,t){return ri(e,t)}function ai(e){let{callback:t,disabled:n}=e,r=fn(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function oi(e){let{callback:t,disabled:n}=e,r=fn(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function si(e){return new Er(ar(e),e)}function ci(e,t,n){t===void 0&&(t=si);let[r,i]=(0,V.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=ai({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=oi({callback:a});return dn(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function li(e){return $n(e,ri(e))}var ui=[];function di(e){let t=(0,V.useRef)(e),n=hn(n=>e?n&&n!==ui&&e&&t.current&&e.parentNode===t.current.parentNode?n:ur(e):ui,[e]);return(0,V.useEffect)(()=>{t.current=e},[e]),n}function fi(e){let[t,n]=(0,V.useState)(null),r=(0,V.useRef)(e),i=(0,V.useCallback)(e=>{let t=fr(e.target);t&&n(e=>e?(e.set(t,hr(t)),new Map(e)):null)},[]);return(0,V.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=fr(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,hr(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{fr(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,V.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>xn(e,t),Un):xr(e):Un,[e,t])}function pi(e,t){t===void 0&&(t=[]);let n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{n.current=null},t),(0,V.useEffect)(()=>{let t=e!==Un;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Sn(e,n.current):Un}function mi(e){(0,V.useEffect)(()=>{if(!nn)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function hi(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function gi(e){return(0,V.useMemo)(()=>e?sr(e):null,[e])}var _i=[];function vi(e,t){t===void 0&&(t=ar);let[n]=e,r=gi(n?on(n):null),[i,a]=(0,V.useState)(_i);function o(){a(()=>e.length?e.map(e=>gr(e)?r:new Er(t(e),e)):_i)}let s=oi({callback:o});return dn(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function yi(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return cn(t)?t:e}function bi(e){let{measure:t}=e,[n,r]=(0,V.useState)(null),i=oi({callback:(0,V.useCallback)(e=>{for(let{target:n}of e)if(cn(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=gn((0,V.useCallback)(e=>{let n=yi(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,V.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var xi=[{sensor:Br,options:{}},{sensor:Fr,options:{}}],Si={current:{}},Ci={draggable:{measure:or},droppable:{measure:or,strategy:$r.WhileDragging,frequency:ei.Optimized},dragOverlay:{measure:ar}},wi=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Ti={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new wi,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Bn},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ci,measureDroppableContainers:Bn,windowRect:null,measuringScheduled:!1},Ei={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Bn,draggableNodes:new Map,over:null,measureDroppableContainers:Bn},Di=(0,V.createContext)(Ei),Oi=(0,V.createContext)(Ti);function ki(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new wi}}}function Ai(e,t){switch(t.type){case Z.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Z.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Z.DragEnd:case Z.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Z.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new wi(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Z.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new wi(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Z.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new wi(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ji(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,V.useContext)(Di),a=_n(r),o=_n(n?.id);return(0,V.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!wn(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=kn(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Mi(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Ni(e){return(0,V.useMemo)(()=>({draggable:{...Ci.draggable,...e?.draggable},droppable:{...Ci.droppable,...e?.droppable},dragOverlay:{...Ci.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Pi(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,V.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;dn(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=$n(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=dr(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Fi=(0,V.createContext)({...Un,scaleX:1,scaleY:1}),Ii;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Ii||={});var Li=(0,V.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=xi,collisionDetection:o=Zn,measuring:s,modifiers:c,...l}=e,[u,d]=(0,V.useReducer)(Ai,void 0,ki),[f,p]=In(),[m,h]=(0,V.useState)(Ii.Uninitialized),g=m===Ii.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,V.useRef)({initial:null,translated:null}),C=(0,V.useMemo)(()=>_==null?null:{id:_,data:x?.data??Si,rect:S},[_,x]),w=(0,V.useRef)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),k=mn(l,Object.values(l)),ee=yn(`DndDescribedBy`,t),A=(0,V.useMemo)(()=>b.getEnabled(),[b]),j=Ni(s),{droppableRects:M,measureDroppableContainers:N,measuringScheduled:te}=ni(A,{dragging:g,dependencies:[y.x,y.y],config:j.droppable}),P=Zr(v,_),ne=(0,V.useMemo)(()=>D?En(D):null,[D]),F=ke(),re=ii(P,j.draggable.measure);Pi({activeNode:_==null?null:v.get(_),config:F.layoutShiftCompensation,initialRect:re,measure:j.draggable.measure});let ie=ci(P,j.draggable.measure,re),ae=ci(P?P.parentElement:null),I=(0,V.useRef)({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:M,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(I.current.over?.id),L=bi({measure:j.dragOverlay.measure}),se=L.nodeRef.current??P,ce=g?L.rect??ie:null,le=!!(L.nodeRef.current&&L.rect),ue=li(le?null:ie),R=gi(se?on(se):null),de=di(g?oe??P:null),fe=vi(de),pe=Mi(c,{transform:{x:y.x-ue.x,y:y.y-ue.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:ie,containerNodeRect:ae,draggingNodeRect:ce,over:I.current.over,overlayNodeRect:L.rect,scrollableAncestors:de,scrollableAncestorRects:fe,windowRect:R}),me=ne?xn(ne,y):null,he=fi(de),z=pi(he),ge=pi(he,[ie]),_e=xn(pe,z),ve=ce?tr(ce,pe):null,ye=C&&ve?o({active:C,collisionRect:ve,droppableRects:M,droppableContainers:A,pointerCoordinates:me}):null,be=qn(ye,`id`),[xe,Se]=(0,V.useState)(null),Ce=Qn(le?pe:xn(pe,ge),xe?.rect??null,ie),we=(0,V.useRef)(null),Te=(0,V.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;we.current=new n({active:w.current,activeNode:i,event:a,options:r,context:I,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,at.unstable_batchedUpdates)(()=>{r?.(i),h(Ii.Initializing),d({type:Z.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(we.current),O(a)})},onMove(e){d({type:Z.DragMove,coordinates:e})},onEnd:o(Z.DragEnd),onCancel:o(Z.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=I.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Z.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Z.DragCancel)}w.current=null,(0,at.unstable_batchedUpdates)(()=>{d({type:e}),h(Ii.Uninitialized),Se(null),E(null),O(null),we.current=null;let t=e===Z.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ee=Qr(a,(0,V.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Te(n,t))},[v,Te]));mi(a),dn(()=>{ie&&m===Ii.Initializing&&h(Ii.Initialized)},[ie,m]),(0,V.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=I.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:_e.x,y:_e.y},over:i};(0,at.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[_e.x,_e.y]),(0,V.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=I.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(be),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,at.unstable_batchedUpdates)(()=>{Se(s),a?.(c),f({type:`onDragOver`,event:c})})},[be]),dn(()=>{I.current={activatorEvent:D,active:C,activeNode:P,collisionRect:ve,collisions:ye,droppableRects:M,draggableNodes:v,draggingNode:se,draggingNodeRect:ce,droppableContainers:b,over:xe,scrollableAncestors:de,scrollAdjustedTranslate:_e},S.current={initial:ce,translated:ve}},[C,P,ye,ve,v,se,ce,M,b,xe,de,_e]),Jr({...F,delta:y,draggingRect:ve,pointerCoordinates:me,scrollableAncestors:de,scrollableAncestorRects:fe});let De=(0,V.useMemo)(()=>({active:C,activeNode:P,activeNodeRect:ie,activatorEvent:D,collisions:ye,containerNodeRect:ae,dragOverlay:L,draggableNodes:v,droppableContainers:b,droppableRects:M,over:xe,measureDroppableContainers:N,scrollableAncestors:de,scrollableAncestorRects:fe,measuringConfiguration:j,measuringScheduled:te,windowRect:R}),[C,P,ie,D,ye,ae,L,v,b,M,xe,N,de,fe,j,te,R]),Oe=(0,V.useMemo)(()=>({activatorEvent:D,activators:Ee,active:C,activeNodeRect:ie,ariaDescribedById:{draggable:ee},dispatch:d,draggableNodes:v,over:xe,measureDroppableContainers:N}),[D,Ee,C,ie,d,ee,v,xe,N]);return V.createElement(Pn.Provider,{value:p},V.createElement(Di.Provider,{value:Oe},V.createElement(Oi.Provider,{value:De},V.createElement(Fi.Provider,{value:Ce},i)),V.createElement(ji,{disabled:n?.restoreFocus===!1})),V.createElement(zn,{...n,hiddenTextDescribedById:ee}));function ke(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Ri=(0,V.createContext)(null),zi=`button`,Bi=`Draggable`;function Vi(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=yn(Bi),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,V.useContext)(Di),{role:p=zi,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,V.useContext)(g?Fi:Ri),[v,y]=gn(),[b,x]=gn(),S=hi(o,t),C=mn(n);return dn(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,V.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===zi?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Hi(){return(0,V.useContext)(Oi)}var Ui=`Droppable`,Wi={timeout:25};function Gi(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=yn(Ui),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,V.useContext)(Di),u=(0,V.useRef)({disabled:n}),d=(0,V.useRef)(!1),f=(0,V.useRef)(null),p=(0,V.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Wi,...i},_=mn(h??r),v=oi({callback:(0,V.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=gn((0,V.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=mn(t);return(0,V.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,V.useEffect)(()=>(s({type:Z.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Z.UnregisterDroppable,key:a,id:r})),[r]),(0,V.useEffect)(()=>{n!==u.current.disabled&&(s({type:Z.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Ki(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function qi(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Ji(e){return e!==null&&e>=0}function Yi(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Xi(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var Zi=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=Ki(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},Qi={scaleX:1,scaleY:1},$i=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...Qi}:null}let s=ea(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...Qi}:r<t&&r>=a?{x:0,y:o.height+s,...Qi}:{x:0,y:0,...Qi}};function ea(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var ta=`Sortable`,na=V.createContext({activeIndex:-1,containerId:ta,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Zi,disabled:{draggable:!1,droppable:!1}});function ra(e){let{children:t,id:n,items:r,strategy:i=Zi,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=Hi(),d=yn(ta,n),f=s.rect!==null,p=(0,V.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,V.useRef)(p),v=!Yi(p,_.current),y=g!==-1&&h===-1||v,b=Xi(a);dn(()=>{v&&m&&u(p)},[v,p,m,u]),(0,V.useEffect)(()=>{_.current=p},[p]);let x=(0,V.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:qi(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return V.createElement(na.Provider,{value:x},t)}var ia=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return Ki(n,r,i).indexOf(t)},aa=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},oa={duration:200,easing:`ease`},sa=`transform`,ca=Dn.Transition.toString({property:sa,duration:0,easing:`linear`}),la={roleDescription:`sortable`};function ua(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,V.useState)(null),s=(0,V.useRef)(n);return dn(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=ar(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,V.useEffect)(()=>{a&&o(null)},[a]),a}function da(e){let{animateLayoutChanges:t=aa,attributes:n,disabled:r,data:i,getNewIndex:a=ia,id:o,strategy:s,resizeObserverConfig:c,transition:l=oa}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,V.useContext)(na),y=fa(r,p),b=u.indexOf(o),x=(0,V.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,V.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=Gi({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:ee,setNodeRef:A,listeners:j,isDragging:M,over:N,setActivatorNodeRef:te,transform:P}=Vi({id:o,data:x,attributes:{...la,...n},disabled:y.draggable}),ne=tn(E,A),F=!!D,re=F&&!m&&Ji(f)&&Ji(g),ie=!_&&M,ae=re?(ie&&re?P:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,I=Ji(f)&&Ji(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,oe=D?.id,L=(0,V.useRef)({activeId:oe,items:u,newIndex:I,containerId:d}),se=u!==L.current.items,ce=t({active:D,containerId:d,isDragging:M,isSorting:F,id:o,index:b,items:u,newIndex:L.current.newIndex,previousItems:L.current.items,previousContainerId:L.current.containerId,transition:l,wasDragging:L.current.activeId!=null}),le=ua({disabled:!ce,index:b,node:w,rect:C});return(0,V.useEffect)(()=>{F&&L.current.newIndex!==I&&(L.current.newIndex=I),d!==L.current.containerId&&(L.current.containerId=d),u!==L.current.items&&(L.current.items=u)},[F,I,d,u]),(0,V.useEffect)(()=>{if(oe===L.current.activeId)return;if(oe!=null&&L.current.activeId==null){L.current.activeId=oe;return}let e=setTimeout(()=>{L.current.activeId=oe},50);return()=>clearTimeout(e)},[oe]),{active:D,activeIndex:f,attributes:ee,data:x,rect:C,index:b,newIndex:I,items:u,isOver:T,isSorting:F,isDragging:M,listeners:j,node:w,overIndex:g,over:N,setNodeRef:ne,setActivatorNodeRef:te,setDroppableNodeRef:E,setDraggableNodeRef:A,transform:le??ae,transition:ue()};function ue(){if(le||se&&L.current.newIndex===b)return ca;if(!(ie&&!wn(O)||!l)&&(F||ce))return Dn.Transition.toString({...l,property:sa})}}function fa(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}$.Down,$.Right,$.Up,$.Left;function pa(e,t){let n=(0,V.useRef)(null),r=(0,V.useRef)(e);(0,V.useEffect)(()=>{r.current=e},[e]);let i=(0,V.useCallback)(e=>{n.current=e},[]);return(0,V.useEffect)(()=>{let e=n.current;if(!e||!t)return;let i=new IntersectionObserver(e=>{e[0]?.isIntersecting&&r.current()},{root:null,rootMargin:`100px`,threshold:0});return i.observe(e),()=>i.disconnect()},[t]),i}var ma=60*1e3,ha=60*ma,ga=24*ha,_a=7*ga,va=365*ga,ya=360,ba=192,xa=120;function Sa(e){let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);return n<ha?W(`relativeMinuteShort`,{count:Math.max(1,Math.floor(n/ma))}):n<ga?W(`relativeHourShort`,{count:Math.floor(n/ha)}):n<_a?W(`relativeDayShort`,{count:Math.floor(n/ga)}):n<va?W(`relativeWeekShort`,{count:Math.floor(n/_a)}):W(`relativeYearShort`,{count:Math.floor(n/va)})}function Ca({onLoadMore:e,enabled:t}){let n=pa(e,t);return t?(0,K.jsx)(`div`,{ref:n,className:`flex items-center justify-center py-1`,children:(0,K.jsx)(u,{className:`size-3 animate-spin text-muted-foreground/45`})}):null}function wa({id:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=da({id:e});return(0,K.jsx)(`div`,{ref:i,style:{transform:Dn.Transform.toString(a),transition:o},className:G(s&&`relative z-50 opacity-40`),children:t({listeners:r,attributes:n})})}var Ta=(0,V.memo)(function({sidebarOpen:e,variant:t=`desktop`,scheduledTasksActive:n,agentProfilesActive:a,pluginsActive:o,projectsCollapsed:s,conversationsCollapsed:f,projects:m,expandedProjectIds:g,activeProject:y,currentSessionId:C,globalSessions:O,sessionsForProject:k,globalHasMore:A,globalLoading:j,onLoadMoreGlobal:M,projectHasMore:te,projectLoading:ne,projectLoaded:F,onLoadMoreProject:ie,sessionTaskStatus:oe,selectingProject:L,onToggleProjectsCollapsed:se,onToggleConversationsCollapsed:ce,onToggleProjectExpanded:le,onToggleAllProjectsExpanded:ue,onReorderProjects:R,onSelectProjectDirectory:de,onStartNewProjectChat:fe,onOpenGlobalSkills:pe,onOpenMcpServers:me,onOpenProjectSkills:he,onOpenProjectInExplorer:z,onDeleteProject:ge,onLoadSession:_e,onTogglePinSession:ve,onRenameSession:ye,onDeleteSession:be,onStartNewGlobalChat:xe,onOpenScheduledTasks:Se,onOpenAgentProfiles:Ce,onOpenPlugins:we,onOpenSettings:Te,onToggleSidebar:Ee,currentSessionHoverInfo:De}){let Oe=`mb-1 flex w-full items-center gap-1 rounded-lg px-2 py-1 text-sm font-medium leading-5 text-muted-foreground/72 transition-colors hover:bg-[color-mix(in_oklab,var(--muted)_52%,transparent)]`,ke=`flex min-w-0 flex-1 items-center gap-1 text-left transition-colors hover:text-foreground/80`,B=`size-4 shrink-0 transition-transform duration-200 ease-out motion-reduce:transition-none`,Ae=`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,je=`grid-rows-[1fr] opacity-100`,Me=`pointer-events-none grid-rows-[0fr] opacity-0`,H=`min-h-0 overflow-hidden`,Ne=`hover:shadow-[0_8px_18px_-14px_rgb(15_23_42_/_0.5)]`,Pe=`group relative flex items-center gap-2 overflow-hidden rounded-lg px-2 py-1.5 text-left transition-all duration-160 ease-out hover:-translate-y-px active:translate-y-0 hover:shadow-[0_10px_26px_-18px_rgb(15_23_42_/_0.48)]`,Fe=`bg-[color-mix(in_oklab,var(--muted)_70%,transparent)] text-foreground/92 shadow-[0_10px_26px_-20px_rgb(15_23_42_/_0.36)]`,Ie=`text-muted-foreground/72 hover:bg-[color-mix(in_oklab,var(--muted)_52%,transparent)] hover:text-foreground/86`,Le=`text-muted-foreground/76 hover:bg-[color-mix(in_oklab,var(--muted)_52%,transparent)] hover:text-foreground/90`,Re=`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-colors group-hover:text-foreground/70`,ze=`size-7 shrink-0 rounded-full text-muted-foreground/55 transition-all duration-160 ease-out hover:-translate-y-px hover:bg-[color-mix(in_oklab,var(--muted)_52%,transparent)] hover:text-foreground/85 active:translate-y-0 ${Ne}`,Be=`pointer-events-none absolute inset-y-0 right-1 flex items-center gap-px rounded-r-lg bg-gradient-to-l from-background via-background/95 to-transparent pl-4 opacity-0 transition-opacity duration-160 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100`,U=`size-6 shrink-0 rounded-full text-muted-foreground/55 transition-all duration-160 ease-out hover:-translate-y-px hover:bg-[color-mix(in_oklab,var(--muted)_52%,transparent)] hover:text-foreground/85 active:translate-y-0 ${Ne}`,Ve=`size-6 shrink-0 rounded-full text-muted-foreground/55 transition-all duration-160 ease-out hover:-translate-y-px hover:bg-destructive/14 hover:text-destructive/90 active:translate-y-0 ${Ne}`,He=`truncate text-sm leading-5`,Ue=`flex min-w-0 flex-1 items-center gap-2 text-left`,We=`flex min-w-0 flex-1 items-center gap-1 truncate transition-[padding] duration-160 group-hover:pr-14 group-focus-within:pr-14`,Ge=`relative z-10 inline-flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-opacity duration-160 transition-colors hover:bg-[color-mix(in_oklab,var(--muted)_52%,transparent)] hover:text-foreground/85`,Ke=`group-hover:opacity-0 group-focus-within:opacity-0`,qe=`font-medium text-foreground/92`,Je=`shrink-0 text-[11px] leading-4 text-muted-foreground/55 transition-opacity duration-160`,Ye=`mt-2 flex items-center gap-2 text-sm leading-5 text-muted-foreground/72`,Xe=t===`mobile`,[Ze,Qe]=(0,V.useState)(!1),[$e,et]=(0,V.useState)(``),[tt,nt]=(0,V.useState)(null),[rt,it]=(0,V.useState)(null),[ot,st]=(0,V.useState)(null),[ct,J]=(0,V.useState)(null),[lt,ut]=(0,V.useState)(null),[dt,ft]=(0,V.useState)(null),[pt,mt]=(0,V.useState)(null),[ht,gt]=(0,V.useState)(null),_t=(0,V.useRef)(null),vt=(0,V.useRef)(null),Y=Hn(Vn(Br,{activationConstraint:{distance:6}})),yt=(0,V.useCallback)(e=>({...e.transform,x:0}),[]),bt=(0,V.useMemo)(()=>m.map(e=>e.id),[m]),xt=(0,V.useMemo)(()=>m.find(e=>e.id===tt),[tt,m]),St=(0,V.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=bt.indexOf(t.id),i=bt.indexOf(n.id);if(r===-1||i===-1)return;let a=[...bt];a.splice(r,1),a.splice(i,0,t.id),R(a)},[bt,R]),Ct=(0,V.useRef)(null),wt=(0,V.useMemo)(()=>{let e=m.flatMap(e=>k(e.id).map(t=>({session:t,projectName:e.name}))),t=O.map(e=>({session:e,projectName:``})),n=new Set;return[...e,...t].filter(({session:e})=>n.has(e.id)?!1:(n.add(e.id),!0))},[O,m,k]),Tt=$e.trim()?wt.filter(({session:e,projectName:t})=>`${Qt(e.title)} ${t}`.toLowerCase().includes($e.trim().toLowerCase())).slice(0,8):[],Et=()=>{Qe(!0),window.setTimeout(()=>Ct.current?.focus(),0)},Dt=e=>{_e(e),Qe(!1),et(``)},Ot=(e,t)=>{if(Xe)return;let n=e.currentTarget.getBoundingClientRect();gt({sessionId:t,x:Math.max(8,Math.min(n.right+8,window.innerWidth-392)),y:n.top+n.height/2})},kt=e=>{gt(t=>t?.sessionId===e?null:t)},At=(e,t)=>{e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();st(null),nt(e=>e===t?(it(null),null):(it({x:Math.max(8,Math.min(n.right-ba,window.innerWidth-ba-8)),y:Math.max(8,Math.min(n.bottom+4,window.innerHeight-xa-8))}),t))},jt=(0,V.useCallback)(()=>{nt(null),it(null),st(null)},[]),Mt=(e,t)=>{e.stopPropagation(),st(t)},Nt=(e,t)=>{e.stopPropagation(),nt(null),it(null),J(t),vt.current!==null&&window.clearTimeout(vt.current),vt.current=window.setTimeout(()=>{vt.current=null,st(e=>e===t?null:e),Promise.resolve(ge(t)).catch(()=>{J(e=>e===t?null:e)})},ya)},Pt=(e,t)=>{e.currentTarget.blur(),ut(t),ve(t)},Ft=(e,t)=>{e.stopPropagation(),e.currentTarget.blur(),ft(t)},It=(e,t)=>{e.stopPropagation(),mt(t),kt(t),_t.current!==null&&window.clearTimeout(_t.current),_t.current=window.setTimeout(()=>{_t.current=null,ft(e=>e===t?null:e),Promise.resolve(be(t)).catch(()=>{mt(e=>e===t?null:e)})},ya)};return(0,V.useEffect)(()=>()=>{_t.current!==null&&window.clearTimeout(_t.current),vt.current!==null&&window.clearTimeout(vt.current)},[]),(0,V.useEffect)(()=>{if(tt)return window.addEventListener(`click`,jt),window.addEventListener(`blur`,jt),window.addEventListener(`resize`,jt),()=>{window.removeEventListener(`click`,jt),window.removeEventListener(`blur`,jt),window.removeEventListener(`resize`,jt)}},[tt,jt]),(0,K.jsxs)(`aside`,{className:G(`relative z-10 min-h-0 shrink-0 overflow-hidden border-r border-border bg-background transition-[width] duration-200 ease-out motion-reduce:transition-none`,Xe?`flex h-full flex-col w-80 max-w-[85vw]`:`hidden md:flex md:flex-col`,e?`w-80`:`w-14`),children:[(0,K.jsxs)(`div`,{className:`shrink-0 px-3 pt-3 pb-1`,children:[(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`w-full`,Ie),onClick:Ee,"aria-label":W(`toggleSidebar`),children:[(0,K.jsxs)(`span`,{className:G(Re,`relative`),children:[(0,K.jsx)(re,{className:G(`size-4 transition-opacity duration-160`,!e&&`group-hover:opacity-0`)}),e?null:(0,K.jsx)(I,{className:`absolute size-4 opacity-0 transition-opacity duration-160 group-hover:opacity-100`})]}),(0,K.jsx)(`span`,{className:G(`ml-auto inline-flex size-6 items-center justify-center text-muted-foreground/55 transition-opacity duration-100 group-hover:text-foreground/70`,!e&&`opacity-0`),children:(0,K.jsx)(h,{className:`size-4`})})]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`mt-4 w-full`,Ie),onClick:Et,"aria-label":W(`search`),children:[(0,K.jsx)(`span`,{className:Re,children:(0,K.jsx)(P,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:He,children:W(`search`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`w-full`,Ie),onClick:pe,"aria-label":W(`manageGlobalSkills`),title:W(`manageGlobalSkills`),children:[(0,K.jsx)(`span`,{className:Re,children:(0,K.jsx)(D,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:He,children:W(`skills`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`w-full`,Ie),onClick:me,"aria-label":W(`manageMcpServers`),title:W(`manageMcpServers`),children:[(0,K.jsx)(`span`,{className:Re,children:(0,K.jsx)(b,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:He,children:W(`mcp`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`w-full`,n?Fe:Ie),onClick:Se,"aria-label":W(`scheduledTasksLabel`),children:[(0,K.jsx)(`span`,{className:Re,children:(0,K.jsx)(w,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:G(He,n&&qe),children:W(`scheduledTasksLabel`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`w-full`,a?Fe:Ie),onClick:Ce,"aria-label":W(`agentsTab`),title:W(`agentsTab`),children:[(0,K.jsx)(`span`,{className:Re,children:(0,K.jsx)(N,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:G(He,a&&qe),children:W(`agentsTab`)}):null]}),(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`w-full`,o?Fe:Ie),onClick:we,"aria-label":W(`plugins`),title:W(`plugins`),children:[(0,K.jsx)(`span`,{className:Re,children:(0,K.jsx)(D,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:G(He,o&&qe),children:W(`plugins`)}):null]})]}),e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`shrink-0 px-3 max-h-[55%] flex flex-col min-h-0 overflow-hidden`,children:(0,K.jsxs)(`div`,{className:`shrink-0 mb-0.5`,children:[(0,K.jsxs)(`div`,{className:Oe,children:[(0,K.jsxs)(`button`,{type:`button`,className:ke,onClick:se,"aria-expanded":!s,children:[(0,K.jsx)(_,{className:G(B,!s&&`rotate-90`)}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:W(`projects`)})]}),m.length>0&&(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:ze,onClick:ue,"aria-label":g.size===m.length?W(`collapseAllProjects`):W(`expandAllProjects`),children:g.size===m.length?(0,K.jsx)(v,{className:`size-4`}):(0,K.jsx)(c,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:ze,onClick:de,disabled:L,"aria-label":W(`addProject`),children:(0,K.jsx)(E,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:G(Ae,`flex-1 min-h-0`,s?Me:je),children:(0,K.jsx)(`div`,{className:H,children:(0,K.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`space-y-0.5`,children:m.length===0?(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`noProjects`)}):(0,K.jsx)(Li,{sensors:Y,collisionDetection:Yn,onDragEnd:St,modifiers:[yt],children:(0,K.jsx)(ra,{items:bt,strategy:$i,children:m.map(e=>{let t=k(e.id),n=g.has(e.id),a=y?.id===e.id,o=F(e.id),s=tt===e.id,c=ct===e.id;return(0,K.jsx)(wa,{id:e.id,children:({listeners:d,attributes:f})=>(0,K.jsx)(`div`,{className:G(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,c?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,K.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:G(Pe,a?`text-foreground/84 hover:bg-[color-mix(in_oklab,var(--muted)_52%,transparent)]`:Ie,s&&`z-20 overflow-visible`,c&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),style:{touchAction:`none`},...d,...f,children:[(0,K.jsx)(`button`,{type:`button`,className:Re,onClick:()=>le(e.id),"aria-label":W(n?`collapseProject`:`expandProject`),children:n?(0,K.jsx)(l,{className:`size-4`}):(0,K.jsx)(i,{className:`size-4`})}),(0,K.jsx)(`button`,{className:`flex min-w-0 flex-1 items-center text-left`,type:`button`,title:e.path,onClick:()=>le(e.id),children:(0,K.jsx)(`span`,{className:G(He,a&&`font-medium text-foreground/84`),children:e.name})}),(0,K.jsxs)(`div`,{className:Be,children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:U,onClick:t=>At(t,e.id),"aria-label":W(`moreOptions`),"aria-expanded":s,children:(0,K.jsx)(r,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:U,onClick:()=>fe(e),"aria-label":W(`newProjectChat`),children:(0,K.jsx)(ee,{className:`size-4`})})]})]}),(0,K.jsx)(`div`,{className:G(Ae,n?je:Me),children:(0,K.jsx)(`div`,{className:H,children:(0,K.jsx)(`div`,{className:`mt-0.5 space-y-0.5 pl-8 max-h-[35vh] overflow-y-auto`,children:t.length===0&&!o||t.length===0&&ne(e.id)?(0,K.jsxs)(`div`,{className:`flex items-center px-2 py-1.5 text-xs text-muted-foreground/55`,children:[(0,K.jsx)(u,{className:`mr-1.5 size-3 animate-spin`}),W(`loadingChatWorkspace`)]}):t.length===0&&!te(e.id)?(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground/55`,children:W(`noConversations`)}):(0,K.jsxs)(K.Fragment,{children:[t.map(e=>{let t=C===e.id,n=lt===e.id,r=pt===e.id;return(0,K.jsx)(`div`,{className:G(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,r?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,K.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,K.jsxs)(`div`,{className:G(Pe,`gap-1`,t?Fe:Le,r&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>Ot(t,e.id),onMouseLeave:()=>{ut(t=>t===e.id?null:t),r||ft(t=>t===e.id?null:t),kt(e.id)},children:[(0,K.jsxs)(`button`,{className:Ue,type:`button`,onClick:()=>_e(e.id),children:[(0,K.jsxs)(`div`,{className:We,children:[oe(e)===`running`?(0,K.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,K.jsx)(`span`,{className:G(He,t&&qe),children:Qt(e.title)})]}),e.pinnedAt?(0,K.jsx)(`button`,{type:`button`,className:G(Ge,!n&&Ke),onClick:t=>{t.stopPropagation(),ve(e.id)},"aria-label":W(`unpinSession`),title:W(`unpinSession`),children:(0,K.jsx)(ae,{className:`size-3`})}):null,(0,K.jsx)(`span`,{className:G(Je,!n&&Ke),children:Sa(e.lastModified)})]}),(0,K.jsx)(`div`,{className:G(Be,n&&`hidden`),children:dt===e.id?(0,K.jsx)(q,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>It(t,e.id),"aria-label":W(`confirmDelete`),title:W(`confirmDelete`),children:W(`confirm`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:U,onClick:t=>Pt(t,e.id),"aria-label":e.pinnedAt?W(`unpinSession`):W(`pinSession`),children:(0,K.jsx)(ae,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:U,onClick:()=>ye(e.id,e.title),"aria-label":W(`renameSession`),children:(0,K.jsx)(S,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ve,onClick:t=>Ft(t,e.id),"aria-label":W(`deleteSession`),children:(0,K.jsx)(x,{className:`size-3.5`})})]})})]})})},e.id)}),(0,K.jsx)(Ca,{onLoadMore:()=>ie(e.id),enabled:te(e.id)&&!ne(e.id)})]})})})})]})})},e.id)})})})})})})})]})}),(0,K.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col px-3 pb-3`,children:[(0,K.jsxs)(`div`,{className:Oe,children:[(0,K.jsxs)(`button`,{type:`button`,className:ke,onClick:ce,"aria-expanded":!f,children:[(0,K.jsx)(_,{className:G(B,!f&&`rotate-90`)}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:W(`conversations`)})]}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:ze,onClick:xe,"aria-label":W(`newChat`),children:(0,K.jsx)(ee,{className:`size-4`})})]}),(0,K.jsx)(`div`,{className:G(Ae,`flex-1 min-h-0`,f?Me:je),children:(0,K.jsx)(`div`,{className:H,children:(0,K.jsx)(`div`,{className:`h-full overflow-y-auto`,children:O.length===0&&!A?(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`noSavedConversations`)}):(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[O.map(e=>{let t=C===e.id,n=lt===e.id,r=pt===e.id;return(0,K.jsx)(`div`,{className:G(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,r?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,K.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,K.jsxs)(`div`,{className:G(Pe,t?Fe:Le,r&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>Ot(t,e.id),onMouseLeave:()=>{ut(t=>t===e.id?null:t),r||ft(t=>t===e.id?null:t),kt(e.id)},children:[(0,K.jsxs)(`button`,{className:Ue,type:`button`,onClick:()=>_e(e.id),children:[(0,K.jsxs)(`div`,{className:We,children:[oe(e)===`running`?(0,K.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,K.jsx)(`span`,{className:G(He,t&&qe),children:Qt(e.title)})]}),e.pinnedAt?(0,K.jsx)(`button`,{type:`button`,className:G(Ge,!n&&Ke),onClick:t=>{t.stopPropagation(),ve(e.id)},"aria-label":W(`unpinSession`),title:W(`unpinSession`),children:(0,K.jsx)(ae,{className:`size-3`})}):null,(0,K.jsx)(`span`,{className:G(Je,!n&&Ke),children:Sa(e.lastModified)})]}),(0,K.jsx)(`div`,{className:G(Be,n&&`hidden`),children:dt===e.id?(0,K.jsx)(q,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>It(t,e.id),"aria-label":W(`confirmDelete`),title:W(`confirmDelete`),children:W(`confirm`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:U,onClick:t=>Pt(t,e.id),"aria-label":e.pinnedAt?W(`unpinSession`):W(`pinSession`),children:(0,K.jsx)(ae,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:U,onClick:()=>ye(e.id,e.title),"aria-label":W(`renameSession`),children:(0,K.jsx)(S,{className:`size-3.5`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:Ve,onClick:t=>Ft(t,e.id),"aria-label":W(`deleteSession`),children:(0,K.jsx)(x,{className:`size-4`})})]})})]})})},e.id)}),(0,K.jsx)(Ca,{onLoadMore:M,enabled:A&&!j})]})})})})]})]}):null,(0,K.jsx)(`div`,{className:`mt-auto shrink-0 border-t border-border px-3 py-3`,children:(0,K.jsxs)(`button`,{type:`button`,className:G(Pe,`w-full`,Ie),onClick:Te,"aria-label":W(`settings`),title:W(`settings`),children:[(0,K.jsx)(`span`,{className:Re,children:(0,K.jsx)(T,{className:`size-4`})}),e?(0,K.jsx)(`span`,{className:He,children:W(`settings`)}):null]})}),ht?(()=>{let e=wt.find(e=>e.session.id===ht.sessionId)?.session;if(!e)return null;let t=De?.sessionId===e.id;return(0,K.jsxs)(`div`,{className:`pointer-events-none fixed z-50 w-[min(24rem,calc(100vw-1rem))] max-w-sm rounded-2xl border border-border bg-card px-4 py-3 text-left shadow-xl`,style:{left:ht.x,top:ht.y,transform:`translateY(-50%)`},children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium leading-5 text-foreground/92`,children:Qt(e.title)}),t&&De?.gitBranch?(0,K.jsxs)(`div`,{className:Ye,children:[(0,K.jsx)(d,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`span`,{className:`truncate`,children:De.gitBranch})]}):null,t&&De?.context?(0,K.jsxs)(`div`,{className:Ye,title:De.context.title,children:[(0,K.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:De.context.color}}),(0,K.jsx)(`span`,{className:`truncate`,children:De.context.label})]}):null]})})():null,xt&&rt?(0,at.createPortal)((0,K.jsxs)(`div`,{className:`fixed z-50 min-w-48 overflow-hidden rounded-lg border border-border bg-background p-1 shadow-xl`,style:{left:rt.x,top:rt.y},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,title:W(`openInExplorer`),"aria-label":W(`openInExplorer`),onClick:()=>{jt(),z(xt)},children:[(0,K.jsx)(l,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,K.jsx)(`span`,{children:W(`openFolder`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:()=>{jt(),he(xt)},children:[(0,K.jsx)(D,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,K.jsx)(`span`,{children:W(`manageProjectSkills`)})]}),ot===xt.id?(0,K.jsx)(`button`,{type:`button`,className:`flex w-full items-center justify-center gap-2 whitespace-nowrap rounded-md bg-destructive px-2 py-1.5 text-left text-sm font-medium text-destructive-foreground transition-colors hover:bg-destructive/90`,"aria-label":W(`confirmDelete`),onClick:e=>Nt(e,xt.id),children:(0,K.jsx)(`span`,{children:W(`confirm`)})}):(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-destructive transition-colors hover:bg-destructive/10`,"aria-label":W(`deleteProject`),onClick:e=>Mt(e,xt.id),children:[(0,K.jsx)(x,{className:`size-4 shrink-0`}),(0,K.jsx)(`span`,{children:W(`deleteProject`)})]})]}),document.body):null,Ze?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-background/50 px-4 pt-[12vh] backdrop-blur-sm`,role:`dialog`,"aria-modal":`true`,onMouseDown:()=>Qe(!1),children:(0,K.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-border bg-card p-3 shadow-xl`,onMouseDown:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-input bg-background px-3 py-2`,children:[(0,K.jsx)(P,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,K.jsx)(`input`,{ref:Ct,value:$e,onChange:e=>et(e.target.value),onKeyDown:e=>{e.key===`Escape`&&Qe(!1)},placeholder:W(`searchDialog`),className:`min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/45`})]}),(0,K.jsx)(`div`,{className:`mt-2 max-h-[50vh] overflow-y-auto`,children:$e.trim()?Tt.length>0?Tt.map(({session:e,projectName:t})=>(0,K.jsxs)(`button`,{type:`button`,className:`block w-full rounded-xl px-3 py-2 text-left transition-colors hover:bg-muted/60`,onClick:()=>Dt(e.id),children:[(0,K.jsx)(`div`,{className:`truncate text-sm text-foreground/90`,children:Qt(e.title)}),(0,K.jsxs)(`div`,{className:`truncate text-[11px] text-muted-foreground/55`,children:[t||W(`normalChat`),` · `,Sa(e.lastModified)]})]},e.id)):(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`noSearchResults`)}):(0,K.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:W(`searchHint`)})})]})}):null]})});function Ea(){let[e,t]=(0,V.useState)(),[n,r]=(0,V.useState)([]),[i,a]=(0,V.useState)(()=>new Set),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1);return{activeProject:e,projects:n,expandedProjectIds:i,selectingProject:o,projectPickerOpen:c,loadProject:(0,V.useCallback)(async()=>{try{let e=await fetch(`/api/project`);if(!e.ok)return;let n=await e.json();t(n.project),r(Array.isArray(n.projects)?n.projects:[]),a(e=>{let t=new Set(e);for(let e of Array.isArray(n.projects)?n.projects:[])t.add(e.id);return t})}catch(e){B.error(`Failed to load project:`,e)}},[]),switchActiveProject:(0,V.useCallback)(async e=>{let n=await fetch(`/api/project/active`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e})}),i=await n.json().catch(()=>null);if(!n.ok)throw Error(i?.error||`Project switch failed with HTTP ${n.status}`);return t(i.project),r(Array.isArray(i.projects)?i.projects:[]),a(e=>{let t=new Set(e);for(let e of Array.isArray(i.projects)?i.projects:[])t.add(e.id);return t}),i.project},[]),handleSelectProjectPath:(0,V.useCallback)(async e=>{s(!0);try{let n=await fetch(`/api/project/path`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e})}),i=await n.json().catch(()=>null);if(!n.ok)throw Error(i?.error||`Project selection failed with HTTP ${n.status}`);i?.project&&(t(i.project),r(Array.isArray(i.projects)?i.projects:[]),a(e=>{let t=new Set(e);for(let e of Array.isArray(i.projects)?i.projects:[])t.add(e.id);return t}))}catch(e){throw B.error(`Failed to select project:`,e),e}finally{s(!1)}},[]),selectProjectDirectory:(0,V.useCallback)(()=>{l(!0)},[]),setProjectPickerOpen:l,toggleProjectExpanded:(0,V.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),toggleAllProjectsExpanded:(0,V.useCallback)(()=>{a(e=>e.size===n.length&&n.length>0?new Set:new Set(n.map(e=>e.id)))},[n]),reorderProjects:(0,V.useCallback)(async e=>{r(t=>{let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){let e=n.get(t);e&&(r.push(e),n.delete(t))}return r});try{let t=await fetch(`/api/project/reorder`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({orderedIds:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Reorder failed with HTTP ${t.status}`);Array.isArray(n?.projects)&&r(n.projects)}catch(e){B.error(`Failed to reorder projects:`,e)}},[]),setActiveProject:t,setProjects:r,setExpandedProjectIds:a}}function Da(){let[e,t]=(0,V.useState)(!1);return{yoloMode:e,setYoloMode:t,initialize:(0,V.useCallback)(async e=>{let n=await Yt(e);return t(n),n},[])}}var Oa=`quickforge-sync`;function ka(e){let t=(0,V.useRef)(e);(0,V.useEffect)(()=>{t.current=e});let n=(0,V.useRef)(Y()),r=(0,V.useRef)(null);(0,V.useEffect)(()=>{if(typeof BroadcastChannel<`u`)try{let e=new BroadcastChannel(Oa);r.current=e;let i=e=>{let r=e.data;if(!(!r||r.sourceTabId===n.current))switch(r.type){case`sessions-changed`:t.current.onSessionsChanged();break;case`projects-changed`:t.current.onProjectsChanged();break;case`settings-changed`:t.current.onSettingsChanged();break}};return e.addEventListener(`message`,i),()=>{e.removeEventListener(`message`,i),e.close()}}catch{r.current=null}},[]),(0,V.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&(t.current.onSessionsChanged(),t.current.onProjectsChanged())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[]);let i=(0,V.useCallback)(e=>{let t={type:e,sourceTabId:n.current,timestamp:Date.now()};r.current?.postMessage(t)},[]);return{notifySessionsChanged:(0,V.useCallback)(()=>i(`sessions-changed`),[i]),notifyProjectsChanged:(0,V.useCallback)(()=>i(`projects-changed`),[i]),notifySettingsChanged:(0,V.useCallback)(()=>i(`settings-changed`),[i])}}function Aa(e,t){let n=t.toolCallId;if(t.role===`toolResult`&&typeof n==`string`){let r=e.findIndex(e=>e.role===`toolResult`&&e.toolCallId===n);if(r>=0){let n=e.slice();return n[r]=t,n}}if(t.role===`assistant`){let n=t.timestamp;if(n!==void 0){let r=e.findIndex(e=>e.role===`assistant`&&e.timestamp===n);if(r>=0){let n=e.slice();return n[r]=t,n}}}let r=e.slice(),i=r.length-1;return i>=0&&r[i]?.role===t.role?r[i]=t:r.push(t),r}function ja(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function Ma(e){if(!ja(e))return;let t=e.quickforgeTiming;if(!ja(t))return;let n=typeof t.startedAt==`number`?t.startedAt:void 0,r=typeof t.finishedAt==`number`?t.finishedAt:void 0,i=typeof t.durationMs==`number`?t.durationMs:void 0;if(!(n===void 0&&r===void 0&&i===void 0))return{startedAt:n,finishedAt:r,durationMs:i}}function Na(e,t){return ja(e)?{...e,quickforgeTiming:t}:{quickforgeTiming:t}}function Pa(e,t){let n=e.quickforgeTiming??Ma(e.partialResult?.details)??{startedAt:Date.now()};return{...e,partialResult:e.partialResult??{content:[],details:{quickforgeTiming:n,sessionId:t,toolCallId:e.toolCallId}}}}function Fa(e,t,n){if(!t.toolCallId||!t.toolName)return e;let r=n?t.partialResult:t.result;if(!r)return e;let i=Ma(r.details)??t.quickforgeTiming;if(!i){let n=e.findIndex(e=>e.role===`toolResult`&&e.toolCallId===t.toolCallId);n>=0&&(i=Ma(e[n].details))}let a=i?Na(r.details,i):r.details,o=ja(a)?{...a,sessionId:a.sessionId??t.sessionId,toolCallId:a.toolCallId??t.toolCallId}:a;return Aa(e,{role:`toolResult`,toolCallId:t.toolCallId,toolName:t.toolName,content:r.content??[],details:o,isError:n?!1:t.isError,timestamp:Date.now()})}function Ia(){return``}var La=5e3,Ra=15e3,za=new class{eventSource=null;handlersBySession=new Map;baseUrl=``;reconnectTimer=null;reconnectDelay=1e3;directBaseUrl=Ia();fallbackBaseUrl=``;subscribe(e,t,n){this.fallbackBaseUrl=t;let r=this.directBaseUrl||this.fallbackBaseUrl;(!this.eventSource||this.baseUrl!==r)&&(this.disconnect(),this.baseUrl=r,this.connect());let i=this.handlersBySession.get(e);return i||(i=new Set,this.handlersBySession.set(e,i)),i.add(n),()=>{let t=this.handlersBySession.get(e);t?.delete(n),t?.size===0&&this.handlersBySession.delete(e),this.handlersBySession.size===0&&this.globalHandlers.size===0&&this.disconnect()}}globalHandlers=new Set;subscribeAll(e,t){this.fallbackBaseUrl=e;let n=this.directBaseUrl||this.fallbackBaseUrl;return(!this.eventSource||this.baseUrl!==n)&&(this.disconnect(),this.baseUrl=n,this.connect()),this.globalHandlers.add(t),()=>{this.globalHandlers.delete(t),this.handlersBySession.size===0&&this.globalHandlers.size===0&&this.disconnect()}}connect(){let e=`${this.baseUrl}/api/agents/events`;this.eventSource=new EventSource(e),this.eventSource.onopen=()=>{this.reconnectDelay=1e3};let t=[`state`,`agent_start`,`agent_end`,`message_start`,`message_end`,`turn_start`,`turn_end`,`message_update`,`tool_execution_start`,`tool_execution_update`,`tool_execution_end`,`error`,`title_updated`,`session_forked`,`scheduled_task_notification`,`scheduled_task_started`,`tool_approval_required`,`auto_compact_threshold_reached`,`auto_compact_approval_required`,`auto_compact_completed`,`auto_compact_failed`,`messages_replaced`],n=e=>t=>{try{let n=JSON.parse(t.data),r=n.sessionId;if(!r&&e!==`scheduled_task_notification`)return;let i=e?{type:e,...n}:n;r?this.emit(r,i):this.emitGlobal(i)}catch{}};this.eventSource.onmessage=n();for(let e of t)this.eventSource.addEventListener(e,n(e));this.eventSource.onerror=()=>{if(this.eventSource?.close(),this.eventSource=null,this.baseUrl===this.directBaseUrl&&this.fallbackBaseUrl!==this.directBaseUrl){this.baseUrl=this.fallbackBaseUrl,this.connect();return}this.scheduleReconnect()}}scheduleReconnect(){this.reconnectTimer||this.handlersBySession.size===0&&this.globalHandlers.size===0||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,!(this.handlersBySession.size===0&&this.globalHandlers.size===0)&&(this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.connect())},this.reconnectDelay))}emitGlobal(e){for(let t of this.globalHandlers)try{t(e)}catch{}}emit(e,t){this.emitGlobal(t);let n=this.handlersBySession.get(e);if(n)for(let e of n)try{e(t)}catch{}}disconnect(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.eventSource?.close(),this.eventSource=null}};async function Ba(e=``){let t=await fetch(`${e}/api/agents`,{cache:`no-store`});if(!t.ok)return[];let n=await t.json().catch(()=>null);return Array.isArray(n?.sessions)?n.sessions:[]}function Va(e,t=``){return za.subscribeAll(t,e)}var Ha=class e{state;streamFn=Oe;getApiKey;sessionId;listeners=new Set;unsubscribeSse;baseUrl;disposed=!1;_syncingThinkingLevel=!1;pollTimer=null;refreshPromise=null;statusPromise=null;lastSseEventAt=Date.now();lastServerStateVersion=0;nextPromptCapabilities=[];stateVersion=0;constructor(e){this.sessionId=e.sessionId,this.baseUrl=e.baseUrl??``;let t=e.initialState??{};this.lastServerStateVersion=typeof t.stateVersion==`number`?t.stateVersion:0;let n={systemPrompt:t.systemPrompt??``,model:t.model??null,thinkingLevel:t.thinkingLevel??`off`,messages:t.messages?.slice()??[],tools:t.tools??[],yoloMode:t.yoloMode??!1,isStreaming:t.isStreaming??!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null};this.state=new Proxy(n,{set:(e,t,n)=>{let r=e[t];return e[t]=n,t===`thinkingLevel`&&!this._syncingThinkingLevel&&n!==r&&this.updateThinkingLevel(n),!0}}),this.unsubscribeSse=za.subscribe(this.sessionId,this.baseUrl,e=>this.handleSseEvent(e)),this.state.isStreaming&&this.startStateWatchdog()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(e){this.nextPromptCapabilities=Array.isArray(e)?e.slice(0,4):[]}async prompt(e){if(this.disposed)return;let t;t=typeof e==`string`?{role:`user`,content:e,timestamp:Date.now()}:Array.isArray(e)?[...e].reverse().find(e=>e.role===`user`||e.role===`user-with-attachments`)??e[e.length-1]:e;let n=this.nextPromptCapabilities;this.nextPromptCapabilities=[];let r=t;this.state.messages=[...this.state.messages,r],this.state.contextUsage=null,this.emitToListeners({type:`message_start`,message:r}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`}));let i=new AbortController,a=setTimeout(()=>i.abort(),3e4),o=this.state.messages.length,s=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/prompt`;fetch(s,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:r,selectedCapabilities:n}),signal:i.signal}).then(e=>{if(clearTimeout(a),!e.ok)throw Error(`Failed to send prompt: HTTP ${e.status}`)}).catch(e=>{clearTimeout(a);let t=e instanceof Error?e.message:String(e);B.error(`Failed to send prompt:`,e),this.state.messages.length===o+1&&(this.state.messages=this.state.messages.slice(0,-1)),this.state.errorMessage=t,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.stopStateWatchdog(),this.emitToListeners({type:`error`,error:t}),this.emitToListeners({type:`agent_end`,messages:this.state.messages})}),this.startStateWatchdog()}abort(){let e=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/abort`;fetch(e,{method:`POST`}).catch(e=>{B.error(`Failed to abort:`,e)})}steer(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/steer`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:e})}).catch(e=>{B.error(`Failed to send steer:`,e)})}followUp(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/follow-up`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:e})}).catch(e=>{B.error(`Failed to send follow-up:`,e)})}reset(){this.state.messages=[],this.state.errorMessage=void 0,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set}async updateYoloMode(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/yolo-mode`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({yoloMode:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to sync YOLO mode: HTTP ${n.status}`)}this.state.yoloMode=e}async updateModel(e){this.state.model=e,this.state.contextUsage=null;let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/model`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:e})}).catch(e=>{B.error(`Failed to sync model update to server:`,e)})}async updateThinkingLevel(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/thinking-level`;fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({thinkingLevel:e})}).catch(e=>{B.error(`Failed to sync thinking level update to server:`,e)})}async rollback(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/rollback`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({messageIndex:e})}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Failed to roll back: HTTP ${n.status}`);return r}async continue(){let e=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/continue`,t=await fetch(e,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||`Failed to continue: HTTP ${t.status}`)}this.state.isStreaming=!0,this.state.errorMessage=void 0,this.startStateWatchdog()}async approveToolCall(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/approve-tool`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({toolCallId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to approve tool call: HTTP ${n.status}`)}}async rejectToolCall(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/reject-tool`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({toolCallId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to reject tool call: HTTP ${n.status}`)}}async approveAutoCompact(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/approve-auto-compact`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({approvalId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to approve auto compact: HTTP ${n.status}`)}}async rejectAutoCompact(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/reject-auto-compact`,n=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({approvalId:e})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error||`Failed to reject auto compact: HTTP ${n.status}`)}}dispose(){this.disposed=!0,this.pollTimer&&=(clearInterval(this.pollTimer),null),this.statusPromise=null,this.unsubscribeSse?.(),this.unsubscribeSse=void 0,this.listeners.clear()}handleSseEvent(e){switch(this.noteSseEvent(e),e.type){case`state`:{let t=e;t.systemPrompt!==void 0&&(this.state.systemPrompt=t.systemPrompt),t.messages&&(t.messages.length>this.state.messages.length||!this.state.isStreaming&&t.messages.length===this.state.messages.length)&&(this.state.messages=t.messages,this.stateVersion++),t.model&&(this.state.model=t.model),t.thinkingLevel&&(this._syncingThinkingLevel=!0,this.state.thinkingLevel=t.thinkingLevel,this._syncingThinkingLevel=!1),t.yoloMode!==void 0&&(this.state.yoloMode=!!t.yoloMode),t.tools&&(this.state.tools=t.tools),t.contextCompaction!==void 0&&(this.state.contextCompaction=t.contextCompaction),t.contextUsage===void 0?t.messages&&(this.state.contextUsage=null):this.state.contextUsage=t.contextUsage;let n=this.state.isStreaming;t.isStreaming!==void 0&&(n=this.state.isStreaming,this.state.isStreaming=t.isStreaming,t.isStreaming?this.startStateWatchdog():this.stopStateWatchdog()),t.isStreaming?(this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`})):n&&(this.stateVersion++,this.emitToListeners({type:`agent_end`,messages:this.state.messages}));return}case`agent_start`:this.state.isStreaming=!0,this.state.errorMessage=void 0,this.startStateWatchdog();break;case`agent_end`:{this.stopStateWatchdog();let t=e;if(t.messages&&t.messages.length>=this.state.messages.length){this.state.messages=t.messages,this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.state.isStreaming=!1,this.state.streamingMessage=void 0,t.errorMessage&&(this.state.errorMessage=t.errorMessage),this.stateVersion++,this.emitToListeners(e);return}this.refreshStateFromServer({forceMessages:!0}).finally(()=>{this.state.isStreaming=!1,this.state.streamingMessage=void 0,t.errorMessage&&(this.state.errorMessage=t.errorMessage),this.emitToListeners(e)});return}case`message_end`:{let t=e;if(t.message){this.state.messages=Aa(this.state.messages,t.message),this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.stateVersion++,this.emitToListeners(e);return}if(t.messages&&t.messages.length>=this.state.messages.length){this.state.messages=t.messages,this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.stateVersion++,this.emitToListeners(e);return}this.refreshStateFromServer().finally(()=>{this.emitToListeners(e)});return}case`turn_end`:{let t=e;if(t.messages&&t.messages.length>=this.state.messages.length){this.state.messages=t.messages,this.state.contextUsage=t.contextUsage===void 0?null:t.contextUsage,this.stateVersion++,this.emitToListeners(e);return}this.refreshStateFromServer().finally(()=>{this.emitToListeners(e)});return}case`messages_replaced`:{let t=e;t.messages&&(this.state.messages=t.messages,this.state.streamingMessage=void 0,this.stateVersion++),t.contextCompaction!==void 0&&(this.state.contextCompaction=t.contextCompaction),t.contextUsage===void 0?t.messages&&(this.state.contextUsage=null):this.state.contextUsage=t.contextUsage;break}case`error`:{this.stopStateWatchdog();let t=e.error;this.state.errorMessage=t||`Unknown error`,this.state.isStreaming=!1;break}case`title_updated`:break;case`session_forked`:break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=Fa(this.state.messages,Pa(t,this.sessionId),!0),this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]),this.stateVersion++);break}case`tool_execution_update`:{let t=e;this.state.messages=Fa(this.state.messages,t,!0),t.toolCallId&&(this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId])),this.stateVersion++;break}case`tool_execution_end`:{let t=e;if(this.state.messages=Fa(this.state.messages,t,!1),t.toolCallId){let e=new Set(this.state.pendingToolCalls);e.delete(t.toolCallId),this.state.pendingToolCalls=e}this.stateVersion++;break}case`auto_compact_completed`:{let t=e;t.contextCompaction!==void 0&&(this.state.contextCompaction=t.contextCompaction),t.contextUsage!==void 0&&(this.state.contextUsage=t.contextUsage);break}case`auto_compact_failed`:case`message_start`:case`message_update`:case`turn_start`:case`tool_approval_required`:case`auto_compact_threshold_reached`:case`auto_compact_approval_required`:break}this.emitToListeners(e)}emitToListeners(e){for(let t of this.listeners)try{t(e)}catch{}}noteSseEvent(e){this.lastSseEventAt=Date.now();let t=e.stateVersion;typeof t==`number`&&Number.isFinite(t)&&(this.lastServerStateVersion=Math.max(this.lastServerStateVersion,t))}startStateWatchdog(){this.pollTimer||this.disposed||(this.lastSseEventAt=Date.now(),this.pollTimer=setInterval(()=>{if(this.disposed||!this.state.isStreaming){this.stopStateWatchdog();return}Date.now()-this.lastSseEventAt<Ra||this.refreshStatusFromServer()},La))}stopStateWatchdog(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}async refreshStatusFromServer(){return this.statusPromise||=this._doRefreshStatusFromServer().finally(()=>{this.statusPromise=null}),this.statusPromise}async _doRefreshStatusFromServer(){let e=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/status`;try{let t=await fetch(e);if(!t.ok){t.status===404&&this.state.isStreaming&&(this.state.isStreaming=!1,this.stopStateWatchdog(),this.emitToListeners({type:`agent_end`,messages:this.state.messages}));return}let n=await t.json();this.lastSseEventAt=Date.now();let r=typeof n.stateVersion==`number`&&Number.isFinite(n.stateVersion)?n.stateVersion:this.lastServerStateVersion;if(n.isStreaming===!1){this.stopStateWatchdog(),await this.refreshStateFromServer({notify:!0,forceMessages:!0});return}n.isStreaming===!0&&(this.state.isStreaming=!0,this.state.errorMessage=n.errorMessage),r>this.lastServerStateVersion&&await this.refreshStateFromServer({notify:!0,forceMessages:!0})}catch{}}async refreshStateFromServer(e){return this.refreshPromise||=this._doRefreshStateFromServer(e).finally(()=>{this.refreshPromise=null}),this.refreshPromise}async _doRefreshStateFromServer(e){let t=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/state`;try{let n=this.stateVersion,r=await fetch(t);if(!r.ok){r.status===404&&this.state.isStreaming&&(this.state.isStreaming=!1,this.stopStateWatchdog(),this.emitToListeners({type:`agent_end`,messages:this.state.messages}));return}let i=await r.json();if(typeof i.stateVersion==`number`&&Number.isFinite(i.stateVersion)&&(this.lastServerStateVersion=Math.max(this.lastServerStateVersion,i.stateVersion)),!e?.forceMessages&&n!==this.stateVersion)return;let a=!!(i.messages&&(e?.forceMessages||i.messages.length>this.state.messages.length||!this.state.isStreaming&&i.messages.length===this.state.messages.length));if(a&&(this.state.messages=i.messages,this.state.contextUsage=i.contextUsage===void 0?null:i.contextUsage,this.stateVersion++),i.systemPrompt!==void 0&&(this.state.systemPrompt=i.systemPrompt),i.model&&(this.state.model=i.model),i.thinkingLevel&&(this._syncingThinkingLevel=!0,this.state.thinkingLevel=i.thinkingLevel,this._syncingThinkingLevel=!1),i.yoloMode!==void 0&&(this.state.yoloMode=!!i.yoloMode),i.tools&&(this.state.tools=i.tools),i.contextCompaction!==void 0&&(this.state.contextCompaction=i.contextCompaction),i.contextUsage!==void 0&&(this.state.contextUsage=i.contextUsage),i.isStreaming!==void 0){let t=this.state.isStreaming;if(this.state.isStreaming=!!i.isStreaming,i.isStreaming?(this.state.errorMessage=void 0,t||this.emitToListeners({type:`agent_start`})):this.stopStateWatchdog(),e?.notify&&t&&!i.isStreaming){this.stateVersion++,this.emitToListeners({type:`agent_end`,messages:this.state.messages});return}}if(e?.notify)if(i.isStreaming&&a){let e=this.state.messages[this.state.messages.length-1];e&&this.emitToListeners({type:`message_update`,message:e})}else i.isStreaming||this.emitToListeners({type:`message_end`})}catch{}}static async create(t,n={}){let r=n.baseUrl??``,i=await fetch(`${r}/api/agents/${encodeURIComponent(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({scope:n.scope??`global`,projectId:n.projectId,yoloMode:n.yoloMode??!1,model:n.model,thinkingLevel:n.thinkingLevel??`off`,messages:n.messages??[],title:n.title??`New chat`,contextCompaction:n.contextCompaction})});if(!i.ok){let e=await i.json().catch(()=>({error:`Failed to create agent`}));throw Error(e.error||`Failed to create agent`)}let a={};try{let e=await fetch(`${r}/api/agents/${encodeURIComponent(t)}/state`);e.ok&&(a=await e.json())}catch{}return new e({sessionId:t,baseUrl:r,initialState:{systemPrompt:a.systemPrompt??``,model:a.model??n.model??null,thinkingLevel:a.thinkingLevel??n.thinkingLevel??`off`,messages:a.messages??n.messages??[],tools:a.tools??[],yoloMode:!!(a.yoloMode??n.yoloMode),isStreaming:!!a.isStreaming,errorMessage:a.errorMessage,contextCompaction:a.contextCompaction,contextUsage:a.contextUsage,stateVersion:a.stateVersion}})}},Ua=class{sessionId;streamFn=Oe;getApiKey;scope;project;createAgent;listeners=new Set;disposed=!1;realAgentPromise;promotedAgent;state;constructor(e){this.sessionId=`pending-${Y()}`,this.scope=e.scope,this.project=e.project,this.createAgent=e.createAgent,this.state={systemPrompt:``,model:e.model,thinkingLevel:e.thinkingLevel,messages:[],tools:[],yoloMode:e.yoloMode,isStreaming:!1,pendingToolCalls:new Set,contextCompaction:null,contextUsage:null}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async prompt(e){this.disposed||await(await this.ensureRealAgent()).prompt(e)}abort(){this.realAgentPromise?.then(e=>e.abort())}reset(){this.state.messages=[],this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set,this.state.errorMessage=void 0}async rollback(){throw Error(`Cannot roll back a pending chat`)}async continue(){await(await this.ensureRealAgent()).continue()}async approveToolCall(){throw Error(`No pending tool call`)}async rejectToolCall(){throw Error(`No pending tool call`)}async approveAutoCompact(){throw Error(`No pending auto compact request`)}async rejectAutoCompact(){throw Error(`No pending auto compact request`)}async updateYoloMode(e){this.state.yoloMode=e;let t=await this.realAgentPromise;t&&await t.updateYoloMode(e)}async updateModel(e){this.state.model=e;let t=await this.realAgentPromise;t&&await t.updateModel(e)}async updateThinkingLevel(e){this.state.thinkingLevel=e;let t=await this.realAgentPromise;t&&await t.updateThinkingLevel(e)}dispose(){this.disposed=!0,this.listeners.clear(),this.promotedAgent||this.realAgentPromise?.then(e=>{this.promotedAgent!==e&&e.dispose()}).catch(()=>{})}promoteTo(e){this.promotedAgent=e,this.listeners.clear()}async ensureRealAgent(){if(!this.realAgentPromise){let e=Y();this.realAgentPromise=this.createAgent({model:this.state.model,thinkingLevel:this.state.thinkingLevel,tools:[]},e,{scope:this.scope,project:this.project,attachToView:!0,yoloMode:this.state.yoloMode}).then(e=>(this.disposed&&this.promotedAgent!==e&&e.dispose(),e))}return this.realAgentPromise}};function Wa(e,t=` `){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`&&`text`in e&&typeof e.text==`string`).map(e=>e.text).join(t):``}function Ga(e){return e.role===`assistant`?Wa(e.content,`
30
-
31
- `).trim():``}function Ka(e,t){let n=t;if(e[t]?.role===`assistant`){for(let r=t-1;r>=0;r--)if(e[r].role===`user`||e[r].role===`user-with-attachments`){n=r;break}}let r=e[n];return!r||r.role!==`user`&&r.role!==`user-with-attachments`?-1:n}function qa(e){return e.role!==`user`&&e.role!==`user-with-attachments`?``:typeof e.content==`string`?e.content:Wa(e.content,`
32
-
33
- `)}async function Ja(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove()}function Ya(e){let t=e.find(e=>e.role===`user`||e.role===`user-with-attachments`);if(!t||t.role!==`user`&&t.role!==`user-with-attachments`)return`New chat`;let n=t.content,r=(typeof n==`string`?n:Wa(n)).trim().replace(/\s+/g,` `);return r?r.length>46?`${r.slice(0,43)}...`:r:`New chat`}function Xa(e){return e===`New chat`||e===W(`newChat`)}function Za(e){return e.some(e=>e.role===`user`||e.role===`user-with-attachments`)}function Qa(e){return Za(e)&&e.some(e=>e.role===`assistant`)}function $a(e){let t=e;if(t?.role!==`user`)return!1;let n=t.content;return(typeof n==`string`?n:Array.isArray(n)?n.filter(e=>e?.type===`text`).map(e=>String(e.text??``)).join(`
34
- `):``).includes(`<compact_summary>`)}function eo(e){let t=e.findIndex($a);return t<0?null:{summaryMessage:e[t],compactedUpToIndex:Math.min(e.length,t+2)}}function to(e){let{storageRef:t,activeModelRef:n,yoloModeRef:r,activeProjectRef:i,setYoloMode:a,switchActiveProject:o,sessions:s,refreshSessions:c}=e,l=(0,V.useRef)(null),u=(0,V.useRef)(new Map),d=(0,V.useRef)(`global`),f=(0,V.useRef)(void 0),p=(0,V.useRef)(`New chat`),m=(0,V.useRef)(void 0),h=(0,V.useRef)(null),g=(0,V.useRef)(e.onTaskComplete);(0,V.useEffect)(()=>{g.current=e.onTaskComplete});let[_,v]=(0,V.useState)(null),[y,b]=(0,V.useState)(),[x,S]=(0,V.useState)(`New chat`),[C,w]=(0,V.useState)(`global`),[T,E]=(0,V.useState)(),[D,O]=(0,V.useState)({}),[k,ee]=(0,V.useState)(0),A=(0,V.useCallback)((e,t)=>{!e||e===t||[...u.current.values()].some(t=>t.agent===e)||e.dispose()},[u]),j=(0,V.useCallback)(async e=>{if(f.current===e.sessionId){let t=e.agent.state.messages,n=e.title;Xa(n)&&(n=Ya(t)),m.current=e.createdAt??new Date().toISOString(),p.current=n,S(n)}await c({broadcast:!0})},[c]),M=(0,V.useCallback)(e=>{A(l.current,e.agent),d.current=e.scope,f.current=e.sessionId,m.current=e.createdAt,p.current=e.title,w(e.scope),b(e.sessionId),S(e.title),E(e.project),l.current=e.agent,v(e.agent);let t=new URL(window.location.href);t.searchParams.set(`session`,e.sessionId),window.history.replaceState({},``,t)},[A]),N=(0,V.useCallback)(async(e,o=Y(),s)=>{let m=l.current,_=u.current.get(o);if(_)return s?.attachToView!==!1&&(A(m,_.agent),M(_)),_.agent;let v=s?.scope??d.current,y=v===`project`?s?.project??i.current:void 0,b=new Date().toISOString(),{model:x,thinkingLevel:C,tools:w,...T}=e??{},E=t.current,D=E?await zt(E):{},k=x??D.model??n.current,ee=E?await qt(E,k):kt(k),N=C??D.thinkingLevel??It(ee);n.current=ee;let te=s?.yoloMode??r.current;r.current=te,a(te);let P=await Ha.create(o,{scope:v,projectId:y?.id,yoloMode:te,model:ee,thinkingLevel:N,messages:T.messages??[],title:s?.title,contextCompaction:T.contextCompaction});T.contextCompaction&&!P.state.contextCompaction&&(P.state.contextCompaction=T.contextCompaction);let ne=P.state.isStreaming?`running`:P.state.errorMessage?`error`:`idle`,F={sessionId:P.sessionId,agent:P,scope:v,project:y,title:s?.title??`New chat`,createdAt:s?.createdAt??b,status:ne,startedAt:b,unsubscribe:()=>void 0};return F.unsubscribe=P.subscribe(e=>{if(e.type===`agent_start`&&(F.status=`running`,F.startedAt=F.startedAt??new Date().toISOString(),F.finishedAt=void 0,O(e=>({...e,[F.sessionId]:F.status}))),e.type===`message_end`&&(P.state.messages=[...P.state.messages]),e.type===`agent_end`){let t=F.status===`running`,n=e;F.status=n.status===`aborted`?`aborted`:n.errorMessage||P.state.errorMessage?`error`:`idle`,F.finishedAt=new Date().toISOString(),O(e=>({...e,[F.sessionId]:F.status})),j(F).catch(e=>B.error(`Failed to sync session UI:`,e)),t&&g.current?.(F.sessionId,F.title,F.status)}if(e.type===`title_updated`){let t=e;t.title&&(F.title=t.title),F.sessionId===f.current&&t.title&&(p.current=t.title,S(t.title)),c({broadcast:!0}).catch(e=>B.error(`Failed to refresh sessions:`,e))}if(e.type===`session_forked`){let t=e;if(!t.targetSessionId)return;c({broadcast:!0}).catch(e=>B.error(`Failed to refresh sessions:`,e)),h.current?.(t.targetSessionId,{title:t.title,createdAt:t.createdAt,scope:t.scope,projectId:t.projectId??void 0})}}),u.current.set(o,F),F.status!==`idle`&&O(e=>({...e,[F.sessionId]:F.status})),s?.attachToView!==!1&&(m instanceof Ua?m.promoteTo(F.agent):l.current===m&&A(m,F.agent),M(F)),P.state.messages.length>0&&await c({broadcast:!0}),P},[M,A,c,j,t,n,r,i,a]),te=(0,V.useCallback)(async e=>{let i=t.current,a=i?await zt(i):{},o=a.model??n.current,s=i?await qt(i,o):kt(o),c=a.thinkingLevel??It(s);n.current=s;let u=e.scope,h=u===`project`?e.project:void 0,g=new Ua({scope:u,project:h,model:s,thinkingLevel:c,yoloMode:r.current,createAgent:N});A(l.current),d.current=u,f.current=void 0,m.current=void 0,p.current=`New chat`,w(u),b(void 0),S(`New chat`),E(h),l.current=g,v(g);let _=new URL(window.location.href);return _.searchParams.delete(`session`),window.history.replaceState({},``,_),g},[n,N,A,t,r]),P=(0,V.useCallback)(async(e,r)=>{let a=u.current.get(e);if(a){if(a.scope===`project`&&a.project?.id&&i.current?.id!==a.project.id)try{await o(a.project.id)}catch(e){B.error(`Failed to switch project for running session:`,e)}M(a);return}let c=t.current;if(!c){await N({tools:[]},e,{scope:r?.scope??`global`,attachToView:!0,createdAt:r?.createdAt,title:r?.title});return}let l=await c.sessions.get(e);if(!l)return;let d=s.find(t=>t.id===e)??await c.sessions.getMetadata(e),f=r?.scope??Zt(d??l),p=r?.projectId??d?.projectId??l.projectId,m;if(f===`project`&&p){let e=p;if(i.current?.id!==e)try{m=await o(e)}catch(e){B.error(`Failed to switch project for session:`,e),J(W(`projectSwitchFailed`));return}else m=i.current}n.current=l.model,await N({model:l.model,thinkingLevel:l.thinkingLevel,messages:l.messages,contextCompaction:l.contextCompaction??eo(l.messages)},l.id,{scope:f,project:m,attachToView:!0,createdAt:l.createdAt??r?.createdAt,title:l.title??r?.title,yoloMode:l.yoloMode===!0})},[M,N,s,o,t,n,i]);return(0,V.useEffect)(()=>{h.current=P},[P]),{agentRef:l,taskMapRef:u,currentSessionIdRef:f,currentChatScopeRef:d,agent:_,currentSessionId:y,currentTitle:x,chatScope:C,currentToolProject:T,taskStatuses:D,chatPanelRevision:k,createAgent:N,startDeferredSession:te,loadSession:P,syncSessionUI:j,setChatPanelRevision:ee,setCurrentAgentMessages:(0,V.useCallback)(e=>{l.current&&(l.current.state.messages=e)},[]),updateCurrentAgentModel:(0,V.useCallback)(e=>{l.current&&(l.current.state.model=e,l.current.updateModel(e).catch(e=>{B.error(`Failed to sync model to server:`,e)}))},[]),setCurrentTitleRef:(0,V.useCallback)(e=>{p.current=e},[])}}var no=20;function ro(e){if(!e)return 0;let t=new Date(e).getTime();return Number.isNaN(t)?0:t}function io(e){return[...e].sort((e,t)=>{let n=ro(t.pinnedAt)-ro(e.pinnedAt);return n===0?e.pinnedAt&&!t.pinnedAt?-1:!e.pinnedAt&&t.pinnedAt?1:ro(t.lastModified)-ro(e.lastModified):n})}function ao({backendRef:e,expandedProjectIds:t,onBroadcastSessionsChanged:n}){let[r,i]=(0,V.useState)({items:[],total:0,loading:!1}),[a,o]=(0,V.useState)({}),s=(0,V.useRef)(a),c=(0,V.useRef)(t);(0,V.useEffect)(()=>{s.current=a},[a]),(0,V.useEffect)(()=>{c.current=t},[t]);let l=(0,V.useMemo)(()=>[...r.items,...Object.values(a).flatMap(e=>e.items)],[r.items,a]),u=(0,V.useCallback)(async t=>{let n=e.current;if(n){i(e=>({...e,loading:!0}));try{let e=await n.fetchPaginatedFromIndex(`sessions-metadata`,`lastModified`,{direction:`desc`,limit:no,offset:t,scope:`global`});i(n=>({items:io(t===0?e.values:[...n.items,...e.values]),total:e.total,loading:!1}))}catch{i(e=>({...e,loading:!1}))}}},[e]),d=(0,V.useCallback)(async(t,n)=>{let r=e.current;if(r){o(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!0}}});try{let e=await r.fetchPaginatedFromIndex(`sessions-metadata`,`lastModified`,{direction:`desc`,limit:no,offset:n,scope:`project`,projectId:t});o(r=>{let i=r[t]?.items??[];return{...r,[t]:{items:io(n===0?e.values:[...i,...e.values]),total:e.total,loading:!1}}})}catch{o(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!1}}})}}},[e]),f=(0,V.useCallback)(async e=>{await u(0);let t=new Set([...Object.keys(s.current),...c.current]);t.size===0?o({}):(o(e=>{let n={};for(let r of t)n[r]={...e[r]??{items:[],total:0},loading:!0};return n}),await Promise.all([...t].map(e=>d(e,0)))),e?.broadcast&&n?.()},[u,d,n]),p=(0,V.useCallback)(e=>a[e]?.items??[],[a]),m=(0,V.useCallback)(e=>{let t=a[e];return t?t.items.length<t.total:!0},[a]),h=(0,V.useCallback)(e=>a[e]?.loading??!1,[a]),g=(0,V.useCallback)(e=>e in a,[a]),_=(0,V.useCallback)(()=>{u(r.items.length)},[r.items.length,u]),v=(0,V.useCallback)(e=>{let t=a[e];d(e,t?.items.length??0)},[d,a]);return{allLoadedSessions:l,globalSessions:r.items,sessionsForProject:p,globalHasMore:r.items.length<r.total,projectHasMore:m,globalLoading:r.loading,projectLoading:h,projectLoaded:g,loadGlobalSessions:u,loadProjectSessions:d,refreshSessions:f,loadMoreGlobal:_,loadMoreProject:v}}function oo(){let[e,t]=(0,V.useState)([]),n=(0,V.useCallback)(e=>{t(t=>[...t,{...e,id:Y(),createdAt:Date.now()}])},[]);return{toasts:e,handleTaskComplete:(0,V.useCallback)((e,t,r)=>{n({sessionId:e,title:t,status:r})},[n]),addToast:n,dismissToast:(0,V.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[])}}var so=`tool-display-settings`,co={showToolDetails:!1,expandToolsByDefault:!1},lo={...co};function uo(e){if(!e||typeof e!=`object`)return{...co};let t=e;return{showToolDetails:t.showToolDetails===!0,expandToolsByDefault:t.expandToolsByDefault===!0}}function fo(){return lo}async function po(e){let t=uo(await e.settings.get(so));return lo=t,t}async function mo(e,t){let n=uo(t);await e.settings.set(so,n),lo=n}var ho=`font-size-settings`,go={baseFontSizePx:14,bodyFontSizePx:12};function _o(e,t,n,r){let i=Number(e);return Number.isFinite(i)?Math.min(r,Math.max(n,Math.round(i))):t}function vo(e){if(!e||typeof e!=`object`)return{...go};let t=e;return{baseFontSizePx:_o(t.baseFontSizePx,go.baseFontSizePx,12,18),bodyFontSizePx:_o(t.bodyFontSizePx,go.bodyFontSizePx,11,16)}}function yo(e){if(typeof document>`u`)return;let t=vo(e),n=document.documentElement;n.style.fontSize=`${t.baseFontSizePx}px`,n.style.setProperty(`--text-sm`,`${t.bodyFontSizePx}px`),n.style.setProperty(`--text-sm--line-height`,String(16/t.bodyFontSizePx))}async function bo(e){return vo(await e.settings.get(ho))}async function xo(e){let t=await bo(e);return yo(t),t}async function So(e,t){let n=vo(t);await e.settings.set(ho,n),yo(n)}function Co({storageRef:e,backendRef:t,activeModelRef:n,yoloModeRef:r,activeProjectRef:i,setYoloMode:a,taskMapRef:o,loadGlobalSessions:s,loadProject:c,initYoloMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}){let[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(),[v,y]=(0,V.useState)(0),b=(0,V.useRef)({loadGlobalSessions:s,loadProject:c,initYoloMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p});return(0,V.useEffect)(()=>{b.current={loadGlobalSessions:s,loadProject:c,initYoloMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}}),(0,V.useEffect)(()=>{let s=!1;async function c(){let{loadGlobalSessions:o,loadProject:c,initYoloMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}=b.current;try{h(!1),_(void 0);let m=await Pt();if(s)return;e.current=m,p?.(m),t.current=m.backend,await He(m),await po(m),await xo(m),await Promise.all([o(0),c()]),r.current=await l(m);let g=await X(m),v=await zt(m);g&&(n.current=v.model??g);let y=new URLSearchParams(window.location.search).get(`session`);if(y){let e=await m.sessions.get(y);if(e){let t=await m.sessions.getMetadata(e.id),o=Zt(t??e),s;if(o===`project`&&(t?.projectId||e.projectId)){let n=t?.projectId??e.projectId;if(i.current?.id!==n)try{s=await u(n)}catch(e){B.error(`Failed to switch project for initial session:`,e),J(W(`projectSwitchFailed`)),g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},Y(),{scope:`global`,attachToView:!0}):f(!0),h(!0);return}else s=i.current}n.current=e.model;let c=e.yoloMode===!0;r.current=c,a(c),await d({model:e.model,thinkingLevel:e.thinkingLevel,messages:e.messages,tools:[]},e.id,{scope:o,project:s,attachToView:!0,createdAt:e.createdAt,title:e.title,yoloMode:c})}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},Y(),{scope:`global`,attachToView:!0}):f(!0)}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},Y(),{scope:`global`,attachToView:!0}):f(!0);h(!0)}catch(e){B.error(`Failed to bootstrap QuickForge:`,e),s||_(W(`localServiceUnavailableDescription`))}}c();let l=o.current;return()=>{s=!0;for(let e of l.values())e.unsubscribe(),e.agent.dispose();l.clear()}},[e,t,n,r,i,a,o,v]),{ready:m,startupError:g,retryBootstrap:(0,V.useCallback)(()=>{h(!1),_(void 0),y(e=>e+1)},[])}}var wo=()=>({modelId:``,contextWindow:Ct.contextWindow,maxTokens:Ct.maxTokens,reasoning:!0}),To=()=>({name:Ct.name,baseUrl:Ct.baseUrl,apiKey:``,headersJson:`{}`,protocol:`openai-completions`,models:[wo()]}),Eo=class extends Se{providers=[];form=To();editingProviderId;formOpen=!1;loading=!0;apiKeyVisible=!1;autoEditProviderName=null;async connectedCallback(){if(super.connectedCallback(),await this.loadProviders(),this.autoEditProviderName){let e=this.providers.find(e=>e.name===this.autoEditProviderName);e&&await this.openEditForm(e),this.autoEditProviderName=null}}getTabName(){return W(`customModels`)}async loadProviders(){this.loading=!0,this.requestUpdate();try{this.providers=await z().customProviders.getAll()}catch(e){B.error(`Failed to load custom providers:`,e),this.providers=[]}finally{this.loading=!1,this.requestUpdate()}}openAddForm(){this.editingProviderId=void 0,this.form=To(),this.apiKeyVisible=!1,this.formOpen=!0,this.requestUpdate()}async openEditForm(e){let t=await z().providerKeys.get(e.name)??e.apiKey??``,n=e.models??[],r=n.length>0?n.map(e=>({modelId:e.id,contextWindow:e.contextWindow??Ct.contextWindow,maxTokens:e.maxTokens??Ct.maxTokens,reasoning:e.reasoning===!0})):[wo()];this.editingProviderId=e.id,this.form={providerId:e.id,id:e.id,name:e.name,baseUrl:e.baseUrl,apiKey:t,headersJson:JSON.stringify(n[0]?.headers??{},null,2),protocol:e.type===`anthropic-messages`?`anthropic-messages`:`openai-completions`,models:r},this.apiKeyVisible=!1,this.formOpen=!0,this.requestUpdate()}closeForm(){this.formOpen=!1,this.editingProviderId=void 0,this.form=To(),this.apiKeyVisible=!1,this.requestUpdate()}toggleApiKeyVisibility(){this.apiKeyVisible=!this.apiKeyVisible,this.requestUpdate()}updateForm(e,t){this.form={...this.form,[e]:t},this.requestUpdate()}updateModelField(e,t,n){let r=this.form.models.map((r,i)=>i===e?{...r,[t]:n}:r);this.form={...this.form,models:r},this.requestUpdate()}addModelRow(){this.form={...this.form,models:[...this.form.models,wo()]},this.requestUpdate()}removeModelRow(e){let t=this.form.models.filter((t,n)=>n!==e);this.form={...this.form,models:t},this.requestUpdate()}parseHeadersJson(){let e=this.form.headersJson.trim();if(!e)return{};let t;try{t=JSON.parse(e)}catch{return J(W(`invalidHeadersJson`)),null}if(!t||typeof t!=`object`||Array.isArray(t))return J(W(`invalidHeadersJson`)),null;let n={};for(let[e,r]of Object.entries(t)){if(!e.trim()||typeof r!=`string`)return J(W(`invalidHeadersJson`)),null;n[e]=r}return n}buildModel(e,t){let n=this.form.name.trim(),r=this.form.baseUrl.trim(),i=e.reasoning===!0,a=r.includes(`api.deepseek.com`);return kt({id:e.modelId,name:`${e.modelId} (${n})`,api:this.form.protocol,provider:n,baseUrl:r.replace(/\/$/,``),reasoning:i,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:Number(e.contextWindow)||Ct.contextWindow,maxTokens:Number(e.maxTokens)||Ct.maxTokens,headers:Object.keys(t).length>0?t:void 0,thinkingLevelMap:a&&i?{low:`high`,medium:`high`,high:`high`,xhigh:`max`}:void 0,compat:this.form.protocol===`openai-completions`?{supportsStore:!1,supportsDeveloperRole:!1,supportsReasoningEffort:i,supportsUsageInStreaming:!1,supportsStrictMode:!1,maxTokensField:`max_tokens`,...a&&i?{requiresReasoningContentOnAssistantMessages:!0,thinkingFormat:`deepseek`}:{}}:void 0})}async saveModel(){let e=this.form.name.trim(),t=this.form.baseUrl.trim();if(!e||!t){J(W(`fillProviderBaseUrlModel`));return}let n=this.form.models.filter(e=>e.modelId.trim());if(n.length===0){J(W(`atLeastOneModel`));return}let r=n.map(e=>e.modelId.trim());if(new Set(r).size!==r.length){J(W(`duplicateModelId`));return}let i=this.parseHeadersJson();if(!i)return;let a=n.map(e=>this.buildModel(e,i)),o=this.form.apiKey.trim(),s=this.editingProviderId?this.providers.find(e=>e.id===this.editingProviderId):void 0,c={id:this.editingProviderId??Y(),name:e,type:this.form.protocol,baseUrl:a[0].baseUrl,apiKey:o||void 0,models:a};try{let e=z();await e.customProviders.set(c),s&&s.name!==c.name&&await e.providerKeys.delete(s.name),o?await e.providerKeys.set(c.name,o):await e.providerKeys.delete(c.name),this.closeForm(),await this.loadProviders()}catch(e){B.error(`Failed to save custom model:`,e),J(W(`saveCustomModelFailed`))}}async deleteProvider(e){if(await ct({description:W(`confirmDeleteProvider`,{name:e.name}),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`}))try{let t=z();await t.customProviders.delete(e.id),await t.providerKeys.delete(e.name),await this.loadProviders()}catch(e){B.error(`Failed to delete custom provider:`,e),J(W(`deleteFailed`))}}renderProvider(e){let t=e.models??[],n=t.length;return R`
35
- <div class="rounded-lg border border-border p-4">
36
- <div class="flex items-start justify-between gap-4">
37
- <div class="min-w-0 flex-1">
38
- <div class="text-sm font-medium text-foreground">${e.name}</div>
39
- <div class="mt-1 break-all text-xs text-muted-foreground">${e.baseUrl}</div>
40
- <div class="mt-2 text-xs text-muted-foreground">
41
- ${W(`providerProtocol`)}: ${e.type===`anthropic-messages`?`Anthropic Messages`:`OpenAI Compatible`}
42
- </div>
43
- ${n===0?R`<div class="mt-1 text-xs text-muted-foreground">${W(`noModelAdded`)}</div>`:R`
44
- <div class="mt-2 text-xs text-muted-foreground">${W(`modelsCount`,{count:n})}</div>
45
- <div class="mt-1 flex flex-wrap gap-1">
46
- ${t.map(e=>R`
47
- <span class="inline-flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-0.5 text-xs text-foreground">
48
- <span class="font-medium">${e.id}</span>
49
- <span class="text-muted-foreground">${e.contextWindow}/${e.maxTokens}</span>
50
- </span>
51
- `)}
52
- </div>
53
- `}
54
- </div>
55
- <div class="flex shrink-0 gap-2">
56
- <button
57
- class="rounded-md px-3 py-1.5 text-sm hover:bg-secondary"
58
- type="button"
59
- @click=${()=>this.openEditForm(e)}
60
- >
61
- ${W(`editModel`)}
62
- </button>
63
- <button
64
- class="rounded-md px-3 py-1.5 text-sm text-destructive hover:bg-secondary"
65
- type="button"
66
- @click=${()=>this.deleteProvider(e)}
67
- >
68
- ${W(`delete`)}
69
- </button>
70
- </div>
71
- </div>
72
- </div>
73
- `}renderModelRow(e,t){return R`
74
- <div class="rounded-md border border-border p-3">
75
- <div class="mb-2 flex items-center justify-between">
76
- <span class="text-xs font-medium text-muted-foreground">${W(`modelIndex`,{index:t+1})}</span>
77
- ${this.form.models.length>1?R`
78
- <button
79
- class="rounded px-1.5 py-0.5 text-xs text-muted-foreground hover:text-destructive hover:bg-secondary"
80
- type="button"
81
- @click=${()=>this.removeModelRow(t)}
82
- >
83
-
84
- </button>
85
- `:``}
86
- </div>
87
- <div class="grid gap-3">
88
- <label class="grid gap-1 text-xs">
89
- <span class="text-muted-foreground">${W(`modelId`)}</span>
90
- <input
91
- class="rounded-md border border-input bg-background px-3 py-1.5 text-sm"
92
- .value=${e.modelId}
93
- @input=${e=>this.updateModelField(t,`modelId`,e.target.value)}
94
- placeholder=${W(`modelIdPlaceholder`)}
95
- />
96
- </label>
97
- <div class="grid grid-cols-2 gap-3">
98
- <label class="grid gap-1 text-xs">
99
- <span class="text-muted-foreground">${W(`contextWindow`)}</span>
100
- <input
101
- class="rounded-md border border-input bg-background px-3 py-1.5 text-sm"
102
- .value=${String(e.contextWindow)}
103
- type="number"
104
- @input=${e=>this.updateModelField(t,`contextWindow`,Number(e.target.value))}
105
- />
106
- </label>
107
- <label class="grid gap-1 text-xs">
108
- <span class="text-muted-foreground">${W(`maxTokens`)}</span>
109
- <input
110
- class="rounded-md border border-input bg-background px-3 py-1.5 text-sm"
111
- .value=${String(e.maxTokens)}
112
- type="number"
113
- @input=${e=>this.updateModelField(t,`maxTokens`,Number(e.target.value))}
114
- />
115
- </label>
116
- </div>
117
- <label class="mt-3 flex items-center gap-2 text-xs">
118
- <input
119
- class="rounded border-border"
120
- type="checkbox"
121
- .checked=${e.reasoning}
122
- @change=${e=>this.updateModelField(t,`reasoning`,e.target.checked)}
123
- />
124
- <span class="text-muted-foreground">${W(`reasoningModel`)}</span>
125
- </label>
126
- </div>
127
- </div>
128
- `}renderForm(){return R`
129
- <div class="rounded-lg border border-border p-4">
130
- <div class="mb-4 text-sm font-semibold text-foreground">
131
- ${this.editingProviderId?W(`editCustomModel`):W(`addCustomModel`)}
132
- </div>
133
-
134
- <div class="grid gap-4">
135
- <label class="grid gap-1.5 text-sm">
136
- <span class="text-foreground">${W(`providerName`)}</span>
137
- <input
138
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
139
- .value=${this.form.name}
140
- @input=${e=>this.updateForm(`name`,e.target.value)}
141
- placeholder=${W(`providerNamePlaceholder`)}
142
- />
143
- </label>
144
-
145
- <label class="grid gap-1.5 text-sm">
146
- <span class="text-foreground">${W(`protocolType`)}</span>
147
- <select
148
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
149
- .value=${this.form.protocol}
150
- @change=${e=>this.updateForm(`protocol`,e.target.value)}
151
- >
152
- <option value="openai-completions">OpenAI Compatible / Chat Completions</option>
153
- <option value="anthropic-messages">Anthropic Messages</option>
154
- </select>
155
- <span class="text-xs text-muted-foreground">
156
- ${W(`protocolHelp`)}
157
- </span>
158
- </label>
159
-
160
- <label class="grid gap-1.5 text-sm">
161
- <span class="text-foreground">Base URL</span>
162
- <input
163
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
164
- .value=${this.form.baseUrl}
165
- @input=${e=>this.updateForm(`baseUrl`,e.target.value)}
166
- placeholder=${this.form.protocol===`anthropic-messages`?`e.g., https://api.anthropic.com`:`e.g., http://localhost:4000/v1`}
167
- />
168
- </label>
169
-
170
- <label class="grid gap-1.5 text-sm">
171
- <span class="text-foreground">${W(`apiKey`)}</span>
172
- <div class="relative">
173
- <input
174
- class="w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-sm"
175
- .value=${this.form.apiKey}
176
- type=${this.apiKeyVisible?`text`:`password`}
177
- @input=${e=>this.updateForm(`apiKey`,e.target.value)}
178
- placeholder=${W(`apiKeyPlaceholder`)}
179
- />
180
- <button
181
- class="absolute inset-y-0 right-0 flex w-10 items-center justify-center rounded-r-md text-muted-foreground hover:text-foreground/85 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
182
- type="button"
183
- title=${this.apiKeyVisible?W(`hideApiKey`):W(`showApiKey`)}
184
- aria-label=${this.apiKeyVisible?W(`hideApiKey`):W(`showApiKey`)}
185
- aria-pressed=${this.apiKeyVisible?`true`:`false`}
186
- @click=${()=>this.toggleApiKeyVisibility()}
187
- >
188
- ${this.apiKeyVisible?R`<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.53 13.53 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" y1="2" x2="22" y2="22"/><path d="M8.53 8.53A5 5 0 0 0 12 17a5 5 0 0 0 3.47-8.53"/></svg>`:R`<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>`}
189
- </button>
190
- </div>
191
- </label>
192
-
193
- <label class="grid gap-1.5 text-sm">
194
- <span class="text-foreground">${W(`customHeaders`)}</span>
195
- <textarea
196
- class="min-h-24 rounded-md border border-input bg-background px-3 py-2 font-mono text-sm"
197
- .value=${this.form.headersJson}
198
- @input=${e=>this.updateForm(`headersJson`,e.target.value)}
199
- placeholder=${W(`customHeadersPlaceholder`)}
200
- ></textarea>
201
- <span class="text-xs text-muted-foreground">
202
- ${W(`customHeadersHelp`)}
203
- </span>
204
- </label>
205
-
206
- <div class="grid gap-3">
207
- <div class="flex items-center justify-between">
208
- <span class="text-sm font-medium text-foreground">${W(`modelsList`)}</span>
209
- <button
210
- class="rounded-md px-2 py-1 text-xs hover:bg-secondary"
211
- type="button"
212
- @click=${()=>this.addModelRow()}
213
- >
214
- + ${W(`addModel`)}
215
- </button>
216
- </div>
217
- ${this.form.models.map((e,t)=>this.renderModelRow(e,t))}
218
- </div>
219
- </div>
220
-
221
- <div class="mt-4 flex justify-end gap-2">
222
- <button class="rounded-md px-3 py-2 text-sm hover:bg-secondary" type="button" @click=${()=>this.closeForm()}>
223
- ${W(`cancel`)}
224
- </button>
225
- <button
226
- class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground"
227
- type="button"
228
- @click=${()=>this.saveModel()}
229
- >
230
- ${W(`save`)}
231
- </button>
232
- </div>
233
- </div>
234
- `}render(){return R`
235
- <div class="flex flex-col gap-6">
236
- <div class="flex items-center justify-between gap-4">
237
- <div>
238
- <h3 class="mb-2 text-sm font-semibold text-foreground">${W(`customModelsTitle`)}</h3>
239
- <p class="text-sm text-muted-foreground">${W(`customModelsDescription`)}</p>
240
- </div>
241
- <button
242
- class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground"
243
- type="button"
244
- @click=${()=>this.openAddForm()}
245
- >
246
- ${W(`addModel`)}
247
- </button>
248
- </div>
249
-
250
- ${this.formOpen?this.renderForm():``}
251
-
252
- ${this.loading?R`<div class="py-8 text-center text-sm text-muted-foreground">${W(`loading`)}</div>`:this.providers.length===0?R`<div class="py-8 text-center text-sm text-muted-foreground">${W(`noCustomModels`)}</div>`:R`<div class="flex flex-col gap-3">${this.providers.map(e=>this.renderProvider(e))}</div>`}
253
- </div>
254
- `}},Do=`quickforge-custom-providers-only-tab`;customElements.get(Do)||customElements.define(Do,Eo);function Oo(e){let t=document.createElement(Do);return e&&(t.autoEditProviderName=e),t}var ko=class extends Se{selectedLanguage=U();getTabName(){return W(`language`)}updateLanguage(e){this.selectedLanguage=e===`zh`?`zh`:`en`,this.requestUpdate()}async applyLanguage(){await Ue(z(),this.selectedLanguage)||J(W(`noLanguageChange`))}render(){return R`
255
- <div class="flex flex-col gap-6">
256
- <div>
257
- <h3 class="mb-2 text-sm font-semibold text-foreground">${W(`language`)}</h3>
258
- <p class="text-sm text-muted-foreground">${W(`languageDescription`)}</p>
259
- </div>
260
-
261
- <label class="grid max-w-sm gap-1.5 text-sm">
262
- <span class="text-foreground">${W(`displayLanguage`)}</span>
263
- <select
264
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
265
- .value=${this.selectedLanguage}
266
- @change=${e=>this.updateLanguage(e.target.value)}
267
- >
268
- <option value="zh">${W(`simplifiedChinese`)}</option>
269
- <option value="en">${W(`english`)}</option>
270
- </select>
271
- </label>
272
-
273
- <div>
274
- <button
275
- class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground"
276
- type="button"
277
- @click=${()=>this.applyLanguage()}
278
- >
279
- ${W(`apply`)}
280
- </button>
281
- </div>
282
- </div>
283
- `}},Ao=`quickforge-language-settings-tab`;customElements.get(Ao)||customElements.define(Ao,ko);function jo(){return document.createElement(Ao)}var Mo=`auto-compact-settings`,No={enabled:!1,thresholdPercent:80,keepRecentTurns:2,minSourceChars:1600,requireConfirmation:!0};function Po(e,t,n,r){let i=Number(e);return Number.isFinite(i)?Math.min(r,Math.max(n,Math.round(i))):t}function Fo(e){if(!e||typeof e!=`object`)return{...No};let t=e;return{enabled:t.enabled===!0,thresholdPercent:Po(t.thresholdPercent,No.thresholdPercent,50,95),keepRecentTurns:Po(t.keepRecentTurns,No.keepRecentTurns,1,20),minSourceChars:Po(t.minSourceChars,No.minSourceChars,0,2e5),requireConfirmation:t.requireConfirmation!==!1}}async function Io(e){return Fo(await e.settings.get(Mo))}async function Lo(e,t){await e.settings.set(Mo,Fo(t))}var Ro=[{value:`off`,label:()=>W(`thinkingOff`)},{value:`low`,label:()=>W(`thinkingLow`)},{value:`medium`,label:()=>W(`thinkingMedium`)},{value:`high`,label:()=>W(`thinkingHigh`)},{value:`xhigh`,label:()=>W(`thinkingXHigh`)}];function zo(e){return(e??``).trim().replace(/\/$/,``)}function Bo(e){return JSON.stringify([e.provider,e.id,e.api,zo(e.baseUrl)])}function Vo(e){return`${e.provider} / ${e.id}`}var Ho=class extends Se{models=[];selectedModel;thinkingLevel=`off`;showToolDetails=!1;expandToolsByDefault=!1;autoCompactEnabled=!1;autoCompactRequireConfirmation=!0;autoCompactThresholdPercent=80;autoCompactThresholdPercentInput=`80`;autoCompactKeepRecentTurns=2;baseFontSizePx=14;bodyFontSizePx=12;loading=!0;saved=!1;error=``;getTabName(){return W(`defaultOptions`)}async connectedCallback(){super.connectedCallback(),await this.loadSettings()}updated(){this.syncSelectValues()}syncSelectValues(){let e=this.querySelector(`[data-default-model-select]`);e&&this.selectedModel&&(e.value=Bo(this.selectedModel));let t=this.querySelector(`[data-default-thinking-select]`);t&&(t.value=this.thinkingLevel)}async loadSettings(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=z(),[t,n,r,i,a]=await Promise.all([Gt(e),zt(e),po(e),Io(e),bo(e)]);this.models=t,this.selectedModel=n.model?t.find(e=>Bo(e)===Bo(n.model))??n.model:t[0],this.thinkingLevel=n.thinkingLevel??It(this.selectedModel),this.showToolDetails=r.showToolDetails,this.expandToolsByDefault=r.expandToolsByDefault,this.autoCompactEnabled=i.enabled,this.autoCompactRequireConfirmation=i.requireConfirmation,this.autoCompactThresholdPercent=i.thresholdPercent,this.autoCompactThresholdPercentInput=String(i.thresholdPercent),this.autoCompactKeepRecentTurns=i.keepRecentTurns,this.baseFontSizePx=a.baseFontSizePx,this.bodyFontSizePx=a.bodyFontSizePx}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}updateModel(e){let t=this.models.find(t=>Bo(t)===e);this.selectedModel=t,this.thinkingLevel=It(t),this.saved=!1,this.requestUpdate()}updateThinkingLevel(e){this.thinkingLevel=Ro.some(t=>t.value===e)?e:`off`,this.saved=!1,this.requestUpdate()}updateShowToolDetails(e){this.showToolDetails=e,this.saved=!1,this.requestUpdate()}updateExpandToolsByDefault(e){this.expandToolsByDefault=e,this.saved=!1,this.requestUpdate()}updateAutoCompactEnabled(e){this.autoCompactEnabled=e,this.saved=!1,this.requestUpdate()}updateAutoCompactRequireConfirmation(e){this.autoCompactRequireConfirmation=e,this.saved=!1,this.requestUpdate()}updateAutoCompactThresholdPercent(e){this.autoCompactThresholdPercentInput=e;let t=Number(e);e!==``&&Number.isFinite(t)&&(this.autoCompactThresholdPercent=t),this.saved=!1,this.requestUpdate()}updateAutoCompactKeepRecentTurns(e){this.autoCompactKeepRecentTurns=Number(e)||2,this.saved=!1,this.requestUpdate()}updateBaseFontSize(e){this.baseFontSizePx=Number(e)||14,this.saved=!1,this.requestUpdate()}updateBodyFontSize(e){this.bodyFontSizePx=Number(e)||12,this.saved=!1,this.requestUpdate()}modelOptions(){if(!this.selectedModel)return this.models;let e=Bo(this.selectedModel);return this.models.some(t=>Bo(t)===e)?this.models:[this.selectedModel,...this.models]}async save(){try{let e=this.selectedModel?.reasoning?this.thinkingLevel:`off`;await Rt(z(),{model:this.selectedModel,thinkingLevel:e}),await mo(z(),{showToolDetails:this.showToolDetails,expandToolsByDefault:this.expandToolsByDefault}),await Lo(z(),{enabled:this.autoCompactEnabled,thresholdPercent:this.autoCompactThresholdPercent,keepRecentTurns:this.autoCompactKeepRecentTurns,minSourceChars:1600,requireConfirmation:this.autoCompactRequireConfirmation}),await So(z(),{baseFontSizePx:this.baseFontSizePx,bodyFontSizePx:this.bodyFontSizePx}),await this.loadSettings(),this.saved=!0,this.error=``,this.requestUpdate()}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`),this.requestUpdate()}}render(){return this.loading?R`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:R`
284
- <div class="flex flex-col gap-6">
285
- <div>
286
- <h3 class="mb-2 text-sm font-semibold text-foreground">${W(`defaultOptions`)}</h3>
287
- <p class="text-sm text-muted-foreground">${W(`defaultOptionsDescription`)}</p>
288
- </div>
289
-
290
- <label class="grid max-w-md gap-1.5 text-sm">
291
- <span class="text-foreground">${W(`defaultModel`)}</span>
292
- <select
293
- data-default-model-select
294
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
295
- .value=${this.selectedModel?Bo(this.selectedModel):``}
296
- @change=${e=>this.updateModel(e.target.value)}
297
- >
298
- ${this.modelOptions().length===0?R`<option value="">${W(`noModelAvailable`)}</option>`:this.modelOptions().map(e=>R`
299
- <option .value=${Bo(e)}>${Vo(e)}</option>
300
- `)}
301
- </select>
302
- </label>
303
-
304
- <label class="grid max-w-sm gap-1.5 text-sm">
305
- <span class="text-foreground">${W(`defaultThinkingLevel`)}</span>
306
- <select
307
- data-default-thinking-select
308
- class="rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60"
309
- .value=${this.thinkingLevel}
310
- ?disabled=${!this.selectedModel?.reasoning}
311
- @change=${e=>this.updateThinkingLevel(e.target.value)}
312
- >
313
- ${Ro.map(e=>R`
314
- <option .value=${e.value}>${e.label()}</option>
315
- `)}
316
- </select>
317
- ${this.selectedModel?.reasoning?null:R`<span class="text-xs text-muted-foreground">${W(`thinkingRequiresReasoningModel`)}</span>`}
318
- </label>
319
-
320
- <div class="grid max-w-xl gap-3 rounded-lg border border-border p-4">
321
- <div>
322
- <h4 class="text-sm font-medium text-foreground">${W(`toolDisplay`)}</h4>
323
- <p class="mt-1 text-xs text-muted-foreground">${W(`showToolDetailsDescription`)}</p>
324
- </div>
325
- <label class="flex items-center gap-2 text-sm text-foreground">
326
- <input
327
- type="checkbox"
328
- class="size-4 rounded border-input"
329
- .checked=${this.showToolDetails}
330
- @change=${e=>this.updateShowToolDetails(e.target.checked)}
331
- />
332
- <span>${W(`showToolDetails`)}</span>
333
- </label>
334
- <label class="flex items-center gap-2 text-sm text-foreground">
335
- <input
336
- type="checkbox"
337
- class="size-4 rounded border-input"
338
- .checked=${this.expandToolsByDefault}
339
- @change=${e=>this.updateExpandToolsByDefault(e.target.checked)}
340
- />
341
- <span>${W(`expandToolsByDefault`)}</span>
342
- </label>
343
- </div>
344
-
345
- <div class="grid max-w-xl gap-3 rounded-lg border border-border p-4">
346
- <div>
347
- <h4 class="text-sm font-medium text-foreground">${W(`fontSize`)}</h4>
348
- <p class="mt-1 text-xs text-muted-foreground">${W(`fontSizeDescription`)}</p>
349
- </div>
350
- <label class="grid max-w-xs gap-1.5 text-sm">
351
- <span class="text-foreground">${W(`baseFontSize`)}</span>
352
- <input
353
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
354
- type="number"
355
- min="12"
356
- max="18"
357
- step="1"
358
- .value=${String(this.baseFontSizePx)}
359
- @input=${e=>this.updateBaseFontSize(e.target.value)}
360
- />
361
- </label>
362
- <label class="grid max-w-xs gap-1.5 text-sm">
363
- <span class="text-foreground">${W(`bodyFontSize`)}</span>
364
- <input
365
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
366
- type="number"
367
- min="11"
368
- max="16"
369
- step="1"
370
- .value=${String(this.bodyFontSizePx)}
371
- @input=${e=>this.updateBodyFontSize(e.target.value)}
372
- />
373
- <span class="text-xs text-muted-foreground">${W(`bodyFontSizeNote`)}</span>
374
- </label>
375
- </div>
376
-
377
- <div class="grid max-w-xl gap-3 rounded-lg border border-border p-4">
378
- <div>
379
- <h4 class="text-sm font-medium text-foreground">${W(`contextManagement`)}</h4>
380
- <p class="mt-1 text-xs text-muted-foreground">${W(`autoCompactDescription`)}</p>
381
- </div>
382
- <label class="flex items-center gap-2 text-sm text-foreground">
383
- <input
384
- type="checkbox"
385
- class="size-4 rounded border-input"
386
- .checked=${this.autoCompactEnabled}
387
- @change=${e=>this.updateAutoCompactEnabled(e.target.checked)}
388
- />
389
- <span>${W(`autoCompactEnabled`)}</span>
390
- </label>
391
- <p class="text-xs text-muted-foreground">${W(`autoCompactTriggerNote`)}</p>
392
- <label class="flex items-center gap-2 text-sm text-foreground">
393
- <input
394
- type="checkbox"
395
- class="size-4 rounded border-input disabled:opacity-60"
396
- .checked=${this.autoCompactRequireConfirmation}
397
- ?disabled=${!this.autoCompactEnabled}
398
- @change=${e=>this.updateAutoCompactRequireConfirmation(e.target.checked)}
399
- />
400
- <span>${W(`autoCompactRequireConfirmation`)}</span>
401
- </label>
402
- <label class="grid max-w-xs gap-1.5 text-sm">
403
- <span class="text-foreground">${W(`autoCompactThresholdPercent`)}</span>
404
- <input
405
- class="rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60"
406
- type="number"
407
- min="50"
408
- max="95"
409
- step="1"
410
- .value=${this.autoCompactThresholdPercentInput}
411
- ?disabled=${!this.autoCompactEnabled}
412
- @input=${e=>this.updateAutoCompactThresholdPercent(e.target.value)}
413
- />
414
- </label>
415
- <label class="grid max-w-xs gap-1.5 text-sm">
416
- <span class="text-foreground">${W(`autoCompactKeepRecentTurns`)}</span>
417
- <input
418
- class="rounded-md border border-input bg-background px-3 py-2 text-sm disabled:opacity-60"
419
- type="number"
420
- min="1"
421
- max="20"
422
- step="1"
423
- .value=${String(this.autoCompactKeepRecentTurns)}
424
- ?disabled=${!this.autoCompactEnabled}
425
- @input=${e=>this.updateAutoCompactKeepRecentTurns(e.target.value)}
426
- />
427
- <span class="text-xs text-muted-foreground">${W(`autoCompactHistoryPreserved`)}</span>
428
- </label>
429
- </div>
430
-
431
- <div class="flex items-center gap-3">
432
- <button
433
- class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
434
- type="button"
435
- ?disabled=${!this.selectedModel}
436
- @click=${()=>this.save()}
437
- >
438
- ${W(`saveDefaultOptions`)}
439
- </button>
440
- ${this.saved?R`<span class="text-sm text-muted-foreground">${W(`defaultOptionsSaved`)}</span>`:null}
441
- ${this.error?R`<span class="text-sm text-destructive">${this.error}</span>`:null}
442
- </div>
443
- </div>
444
- `}},Uo=`quickforge-default-options-settings-tab`;customElements.get(Uo)||customElements.define(Uo,Ho);function Wo(){return document.createElement(Uo)}var Go=`quickforge-backup`,Ko=[{id:`settings`,countKey:`settings`,label:()=>W(`restoreSettings`),description:()=>W(`restoreSettingsDescription`)},{id:`providerKeys`,countKey:`providerKeys`,label:()=>W(`restoreProviderKeys`),description:()=>W(`restoreProviderKeysDescription`)},{id:`customProviders`,countKey:`customProviders`,label:()=>W(`restoreCustomProviders`),description:()=>W(`restoreCustomProvidersDescription`)},{id:`projects`,countKey:`projects`,label:()=>W(`restoreProjects`),description:()=>W(`restoreProjectsDescription`)},{id:`scheduledTasks`,countKey:`scheduledTasks`,label:()=>W(`restoreScheduledTasks`),description:()=>W(`restoreScheduledTasksDescription`)},{id:`conversations`,countKey:`sessions`,label:()=>W(`restoreConversations`),description:()=>W(`restoreConversationsDescription`)}];function qo(e,t){let n=new Blob([`${JSON.stringify(t,null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}function Jo(){return new Date().toISOString().replace(/[:.]/g,`-`)}function Yo(e){return e?Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`, `):``}function Xo(e){return Ko.filter(t=>(e.sections?.[t.countKey]??0)>0)}var Zo=class extends Se{exportScope=`all`;includeSecrets=!1;busy=!1;message=``;error=``;safetyBackupPath=``;pendingImport=null;getTabName(){return W(`backupRestore`)}setScope(e){this.exportScope=e===`config`||e===`sessions`?e:`all`,this.exportScope===`sessions`&&(this.includeSecrets=!1),this.clearStatus(),this.requestUpdate()}clearStatus(){this.message=``,this.error=``,this.safetyBackupPath=``}setIncludeSecrets(e){this.includeSecrets=e&&this.exportScope!==`sessions`,this.message=``,this.error=``,this.requestUpdate()}async exportBackup(){if(!(this.includeSecrets&&!await ct({description:W(`backupExportSecretsConfirm`),confirmLabel:W(`exportBackup`),cancelLabel:W(`cancel`)}))){this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=new URLSearchParams({scope:this.exportScope,includeSecrets:this.includeSecrets?`1`:`0`}),t=await fetch(`/api/backup/export?${e.toString()}`,{cache:`no-store`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||W(`backupExportFailed`));let r=this.includeSecrets?`with-secrets`:`no-secrets`;qo(`${Go}-${this.exportScope}-${r}-${Jo()}.json`,n),this.message=W(`backupExported`)}catch(e){this.error=e instanceof Error?e.message:W(`backupExportFailed`)}finally{this.busy=!1,this.requestUpdate()}}}async inspectBackup(e){let t=await fetch(`/api/backup/inspect`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||W(`backupInspectFailed`));if(!n)throw Error(W(`backupInspectFailed`));return n}async importBackupFromFile(e){this.busy=!0,this.clearStatus(),this.pendingImport=null,this.requestUpdate();try{let t=await e.text(),n=JSON.parse(t),r=await this.inspectBackup(n),i=new Set(Xo(r).map(e=>e.id));this.pendingImport={backup:n,inspect:r,selectedSections:i},this.message=W(`backupInspected`)}catch(e){this.error=e instanceof Error?e.message:W(`backupImportFailed`)}finally{this.busy=!1,this.requestUpdate()}}togglePendingSection(e,t){this.pendingImport&&(t?this.pendingImport.selectedSections.add(e):this.pendingImport.selectedSections.delete(e),this.message=``,this.error=``,this.requestUpdate())}cancelPendingImport(){this.pendingImport=null,this.message=``,this.error=``,this.requestUpdate()}async confirmPendingImport(){if(this.pendingImport){if(this.pendingImport.selectedSections.size===0){this.error=W(`selectAtLeastOneRestoreSection`),this.requestUpdate();return}this.busy=!0,this.clearStatus(),this.requestUpdate();try{let e=await fetch(`/api/backup/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({backup:this.pendingImport.backup,sections:[...this.pendingImport.selectedSections]})}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`backupImportFailed`));let n=Yo(t?.summary);this.safetyBackupPath=t?.safetyBackupPath||``,this.pendingImport=null,this.message=n?`${W(`backupImported`)} ${n}`:W(`backupImported`),window.setTimeout(()=>window.location.reload(),1500)}catch(e){this.error=e instanceof Error?e.message:W(`backupImportFailed`)}finally{this.busy=!1,this.requestUpdate()}}}handleFileChange(e){let t=e.target,n=t.files?.[0];t.value=``,n&&this.importBackupFromFile(n)}renderPendingImport(){if(!this.pendingImport)return null;let{inspect:e,selectedSections:t}=this.pendingImport,n=Xo(e);return R`
445
- <section class="rounded-lg border border-amber-500/30 bg-amber-500/5 p-4">
446
- <h4 class="text-sm font-semibold text-foreground">${W(`backupInspectTitle`)}</h4>
447
- <dl class="mt-3 grid gap-1 text-sm text-muted-foreground">
448
- <div><span class="text-foreground">${W(`backupInspectExportedAt`)}:</span> ${e.exportedAt||`-`}</div>
449
- <div><span class="text-foreground">${W(`backupInspectVersion`)}:</span> ${e.version??`-`}</div>
450
- <div><span class="text-foreground">${W(`backupInspectScope`)}:</span> ${e.scope||`-`}</div>
451
- <div><span class="text-foreground">${W(`backupInspectSecrets`)}:</span> ${e.includeSecrets?W(`yes`):W(`no`)}</div>
452
- </dl>
453
-
454
- ${e.warnings?.length?R`
455
- <div class="mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300">
456
- ${e.warnings.map(e=>R`<div>⚠ ${e}</div>`)}
457
- </div>
458
- `:null}
459
-
460
- <div class="mt-4">
461
- <div class="text-sm font-medium text-foreground">${W(`selectRestoreSections`)}</div>
462
- <div class="mt-2 grid gap-2">
463
- ${n.map(n=>R`
464
- <label class="flex items-start gap-2 rounded-md border border-border bg-background/60 p-3 text-sm">
465
- <input
466
- class="mt-1"
467
- type="checkbox"
468
- .checked=${t.has(n.id)}
469
- ?disabled=${this.busy}
470
- @change=${e=>this.togglePendingSection(n.id,e.target.checked)}
471
- />
472
- <span>
473
- <span class="block text-foreground">${n.label()} (${e.sections?.[n.countKey]??0})</span>
474
- <span class="block text-xs text-muted-foreground">${n.description()}</span>
475
- </span>
476
- </label>
477
- `)}
478
- </div>
479
- </div>
480
-
481
- <div class="mt-4 flex flex-wrap gap-2">
482
- <button
483
- class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
484
- type="button"
485
- ?disabled=${this.busy||t.size===0}
486
- @click=${()=>this.confirmPendingImport()}
487
- >
488
- ${this.busy?W(`loading`):W(`confirmImportSelected`)}
489
- </button>
490
- <button
491
- class="rounded-md border border-input px-3 py-2 text-sm hover:bg-muted/60 disabled:opacity-60"
492
- type="button"
493
- ?disabled=${this.busy}
494
- @click=${()=>this.cancelPendingImport()}
495
- >
496
- ${W(`cancel`)}
497
- </button>
498
- </div>
499
- </section>
500
- `}render(){return R`
501
- <div class="flex flex-col gap-6">
502
- <div>
503
- <h3 class="mb-2 text-sm font-semibold text-foreground">${W(`backupRestore`)}</h3>
504
- <p class="text-sm text-muted-foreground">${W(`backupRestoreDescription`)}</p>
505
- </div>
506
-
507
- <section class="rounded-lg border border-border p-4">
508
- <h4 class="text-sm font-semibold text-foreground">${W(`exportData`)}</h4>
509
- <p class="mt-1 text-sm text-muted-foreground">${W(`exportDataDescription`)}</p>
510
-
511
- <label class="mt-4 grid max-w-sm gap-1.5 text-sm">
512
- <span class="text-foreground">${W(`exportScope`)}</span>
513
- <select
514
- class="rounded-md border border-input bg-background px-3 py-2 text-sm"
515
- .value=${this.exportScope}
516
- ?disabled=${this.busy}
517
- @change=${e=>this.setScope(e.target.value)}
518
- >
519
- <option value="all">${W(`exportScopeAll`)}</option>
520
- <option value="config">${W(`exportScopeConfig`)}</option>
521
- <option value="sessions">${W(`exportScopeSessions`)}</option>
522
- </select>
523
- </label>
524
-
525
- <label class="mt-4 flex max-w-sm items-start gap-2 text-sm text-foreground ${this.exportScope===`sessions`?`opacity-60`:``}">
526
- <input
527
- class="mt-1"
528
- type="checkbox"
529
- .checked=${this.includeSecrets}
530
- ?disabled=${this.busy||this.exportScope===`sessions`}
531
- @change=${e=>this.setIncludeSecrets(e.target.checked)}
532
- />
533
- <span>
534
- <span class="block">${W(`includeApiKeys`)}</span>
535
- <span class="block text-xs text-muted-foreground">${W(`includeApiKeysDescription`)}</span>
536
- </span>
537
- </label>
538
-
539
- <button
540
- class="mt-4 rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
541
- type="button"
542
- ?disabled=${this.busy}
543
- @click=${()=>this.exportBackup()}
544
- >
545
- ${this.busy?W(`loading`):W(`exportBackup`)}
546
- </button>
547
- </section>
548
-
549
- <section class="rounded-lg border border-border p-4">
550
- <h4 class="text-sm font-semibold text-foreground">${W(`importData`)}</h4>
551
- <p class="mt-1 text-sm text-muted-foreground">${W(`importDataDescription`)}</p>
552
-
553
- <label class="mt-4 inline-flex cursor-pointer rounded-md border border-input px-3 py-2 text-sm hover:bg-muted/60 ${this.busy?`pointer-events-none opacity-60`:``}">
554
- <input
555
- class="hidden"
556
- type="file"
557
- accept="application/json,.json"
558
- ?disabled=${this.busy}
559
- @change=${e=>this.handleFileChange(e)}
560
- />
561
- ${W(`importBackup`)}
562
- </label>
563
- </section>
564
-
565
- ${this.renderPendingImport()}
566
- ${this.message?R`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
567
- ${this.safetyBackupPath?R`<div class="rounded-md border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground">${W(`backupSafetyBackupPath`)}: <code>${this.safetyBackupPath}</code></div>`:null}
568
- ${this.error?R`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
569
- </div>
570
- `}},Qo=`quickforge-backup-settings-tab`;customElements.get(Qo)||customElements.define(Qo,Zo);function $o(){return document.createElement(Qo)}var es=3e4,ts=800;function ns(e){return new Promise(t=>window.setTimeout(t,e))}function rs(e){if(!e)return`-`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(Ve())}function is(){return`custom_${globalThis.crypto?.randomUUID?.().slice(0,8)||Date.now().toString(36)}`}function as(e){let t=e.trim(),n=t.split(/[\\/]/).pop()?.replace(/^"|"$/g,``)||t;return/^bash(\.exe)?$/i.test(n)?`Bash`:/^zsh$/i.test(n)?`Zsh`:/^fish$/i.test(n)?`Fish`:/^cmd(\.exe)?$/i.test(n)?`Command Prompt`:/^powershell(\.exe)?$/i.test(n)?`Windows PowerShell`:/^pwsh(\.exe)?$/i.test(n)?`PowerShell 7+`:n||`Custom Shell`}var os=R`
571
- <svg class="size-3.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
572
- <path d="M3.5 8.2 6.6 11.3 12.7 4.7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
573
- </svg>
574
- `,ss=R`
575
- <svg class="size-3.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
576
- <circle cx="8" cy="8" r="4.8" stroke="currentColor" stroke-width="1.5" />
577
- </svg>
578
- `,cs=R`
579
- <svg class="size-3.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
580
- <path d="M4.5 4.5 11.5 11.5M11.5 4.5 4.5 11.5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" />
581
- </svg>
582
- `,ls=class extends Se{status;loading=!0;restarting=!1;message=``;error=``;terminalShellConfig={terminalShell:`auto`,defaultProfileId:`auto`,profiles:[]};customShellCommand=``;getTabName(){return W(`backendService`)}async connectedCallback(){super.connectedCallback(),await Promise.all([this.loadStatus(),this.loadTerminalShell()])}customShellProfiles(){return this.terminalShellConfig.profiles.filter(e=>!e.builtin)}async loadTerminalShell(){try{let e=await fetch(`/api/system/terminal-shell`,{cache:`no-store`}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`requestFailed`));this.terminalShellConfig={terminalShell:t?.terminalShell||`auto`,defaultProfileId:t?.defaultProfileId||`auto`,profiles:Array.isArray(t?.profiles)?t.profiles:[]}}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.requestUpdate()}}async saveTerminalShellConfig(e,t=this.customShellProfiles(),n=W(`terminalShellSaved`)){try{let r=await fetch(`/api/system/terminal-shell`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultProfileId:e,profiles:t})}),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||W(`requestFailed`));this.terminalShellConfig=i,this.message=n,this.error=``}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.requestUpdate()}}async addCustomTerminalShell(){let e=this.customShellCommand.trim();if(!e){this.error=W(`terminalShellProfileRequired`),this.requestUpdate();return}let t=[...this.customShellProfiles(),{id:is(),name:as(e),command:e,builtin:!1}];this.customShellCommand=``,await this.saveTerminalShellConfig(this.terminalShellConfig.defaultProfileId,t,W(`terminalShellProfilesSaved`))}async deleteCustomTerminalShell(e){let t=this.terminalShellConfig.profiles.find(t=>t.id===e);if(!t||t.builtin||!await ct({description:W(`terminalShellDeleteConfirm`,{name:t.name}),confirmLabel:W(`confirmDelete`),cancelLabel:W(`cancel`),variant:`destructive`}))return;let n=this.customShellProfiles().filter(t=>t.id!==e),r=this.terminalShellConfig.defaultProfileId===e?`auto`:this.terminalShellConfig.defaultProfileId;await this.saveTerminalShellConfig(r,n,W(`terminalShellProfilesSaved`))}async loadStatus(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=await fetch(`/api/health`,{cache:`no-store`}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`requestFailed`));this.status=t}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}async pollUntilRestarted(e){let t=Date.now();for(;Date.now()-t<es;){await ns(ts);try{let t=await fetch(`/api/health?restartPoll=${Date.now()}`,{cache:`no-store`}),n=await t.json().catch(()=>null);if(t.ok&&n?.ok&&n.bootId&&n.bootId!==e){this.message=W(`backendRestarted`),this.requestUpdate(),window.setTimeout(()=>window.location.reload(),300);return}}catch{}}throw Error(W(`backendRestartTimeout`))}async restartService(){if(!this.status||this.restarting||!await ct({description:W(`restartBackendConfirm`),confirmLabel:W(`restartBackendService`),cancelLabel:W(`cancel`)}))return;this.restarting=!0,this.message=W(`backendRestarting`),this.error=``,this.requestUpdate();let e=this.status.bootId;try{let t=await fetch(`/api/system/restart`,{method:`POST`,headers:{"x-quickforge-action":`restart`}}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||W(`backendRestartFailed`));await this.pollUntilRestarted(e)}catch(e){this.error=e instanceof Error?e.message:W(`backendRestartFailed`),this.message=``,this.restarting=!1,this.requestUpdate()}}statusRows(){return this.status?R`
583
- <dl class="grid gap-3 text-sm">
584
- ${[[W(`serviceMode`),this.status.mode],[W(`servicePid`),String(this.status.pid)],[W(`serviceStartedAt`),rs(this.status.startedAt)],[W(`serviceDataDir`),this.status.dataDir],[W(`serviceWorkspace`),this.status.workspaceRoot]].map(([e,t])=>R`
585
- <div class="grid gap-1 sm:grid-cols-[120px_1fr] sm:gap-3">
586
- <dt class="text-muted-foreground">${e}</dt>
587
- <dd class="min-w-0 break-all text-foreground">${t}</dd>
588
- </div>
589
- `)}
590
- </dl>
591
- `:null}shellProfileRow(e,t=!1){let n=e.id===this.terminalShellConfig.defaultProfileId||this.terminalShellConfig.defaultProfileId===`auto`&&t;return R`
592
- <div class="flex min-w-0 items-center gap-3 border-b px-1.5 py-2 last:border-b-0 hover:bg-muted/5" style="border-bottom-color: color-mix(in oklab, var(--border) 32%, transparent);">
593
- <div class="min-w-0 flex-1">
594
- <div class="truncate text-sm font-medium text-foreground/90">${e.name}</div>
595
- <div class="truncate font-mono text-xs text-muted-foreground/55" title=${e.command}>${e.command}</div>
596
- </div>
597
- <div class="flex shrink-0 items-center gap-1">
598
- ${n?R`
599
- <span class="inline-flex size-7 items-center justify-center rounded-md text-emerald-500/85" title=${W(`terminalShellDefaultBadge`)} aria-label=${W(`terminalShellDefaultBadge`)}>
600
- ${os}
601
- </span>
602
- `:R`
603
- <button
604
- class="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground/55 hover:bg-muted/20 hover:text-foreground/85"
605
- type="button"
606
- title=${W(`terminalShellSetDefault`)}
607
- aria-label=${W(`terminalShellSetDefault`)}
608
- @click=${()=>this.saveTerminalShellConfig(e.id)}
609
- >
610
- ${ss}
611
- </button>
612
- `}
613
- ${e.builtin?null:R`
614
- <button
615
- class="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground/55 hover:bg-destructive/10 hover:text-destructive"
616
- type="button"
617
- title=${W(`delete`)}
618
- aria-label=${W(`delete`)}
619
- @click=${()=>this.deleteCustomTerminalShell(e.id)}
620
- >
621
- ${cs}
622
- </button>
623
- `}
624
- </div>
625
- </div>
626
- `}terminalShellSettings(){let e=this.terminalShellConfig.profiles;return R`
627
- <section class="rounded-lg border border-border p-4">
628
- <div>
629
- <h4 class="text-sm font-semibold text-foreground">${W(`terminalShell`)}</h4>
630
- <p class="mt-1 max-w-2xl text-sm text-muted-foreground">${W(`terminalShellDescription`)}</p>
631
- <p class="mt-1 text-xs text-muted-foreground/60">${W(`terminalShellAutoDetectedHint`)}</p>
632
- </div>
633
-
634
- <div class="mt-4 overflow-hidden rounded-lg border bg-transparent" style="border-color: color-mix(in oklab, var(--border) 36%, transparent);">
635
- ${e.length>0?e.map((e,t)=>this.shellProfileRow(e,t===0)):R`<div class="px-2 py-3 text-sm text-muted-foreground">${W(`terminalShellNoDetected`)}</div>`}
636
- </div>
637
-
638
- <div class="mt-3 grid gap-2 sm:grid-cols-[1fr_auto] sm:items-end">
639
- <label class="grid gap-1 text-sm">
640
- <span class="text-xs text-muted-foreground/70">${W(`terminalShellCommand`)}</span>
641
- <input
642
- class="h-9 rounded-md border border-border bg-background px-3 font-mono text-sm text-foreground outline-none focus:border-ring"
643
- type="text"
644
- .value=${this.customShellCommand}
645
- placeholder=${W(`terminalShellCommandPlaceholder`)}
646
- @input=${e=>{this.customShellCommand=e.target.value}}
647
- />
648
- </label>
649
- <button
650
- class="h-9 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-60"
651
- type="button"
652
- title=${W(`terminalShellAdd`)}
653
- aria-label=${W(`terminalShellAdd`)}
654
- @click=${()=>this.addCustomTerminalShell()}
655
- >
656
- ${W(`terminalShellAdd`)}
657
- </button>
658
- </div>
659
- </section>
660
- `}render(){if(this.loading)return R`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`;let e=this.status?.restartUnsupportedReason||W(`backendRestartUnsupported`),t=this.restarting||!this.status?.restartSupported;return R`
661
- <div class="flex flex-col gap-6">
662
- <div>
663
- <h3 class="mb-2 text-sm font-semibold text-foreground">${W(`backendService`)}</h3>
664
- <p class="text-sm text-muted-foreground">${W(`backendServiceDescription`)}</p>
665
- </div>
666
-
667
- <section class="rounded-lg border border-border p-4">
668
- <h4 class="text-sm font-semibold text-foreground">${W(`backendServiceStatus`)}</h4>
669
- <div class="mt-4">${this.statusRows()}</div>
670
- </section>
671
-
672
- ${this.terminalShellSettings()}
673
-
674
- <section class="rounded-lg border border-border p-4">
675
- <h4 class="text-sm font-semibold text-foreground">${W(`restartBackendService`)}</h4>
676
- <p class="mt-1 text-sm text-muted-foreground">${W(`restartBackendServiceDescription`)}</p>
677
-
678
- ${this.status?.restartSupported?null:R`<div class="mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300">${e}</div>`}
679
-
680
- <button
681
- class="mt-4 rounded-md bg-destructive px-3 py-2 text-sm text-destructive-foreground disabled:opacity-60"
682
- type="button"
683
- ?disabled=${t}
684
- @click=${()=>this.restartService()}
685
- >
686
- ${this.restarting?W(`backendRestarting`):W(`restartBackendService`)}
687
- </button>
688
- </section>
689
-
690
- ${this.message?R`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
691
- ${this.error?R`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
692
- </div>
693
- `}},us=`quickforge-service-settings-tab`;customElements.get(us)||customElements.define(us,ls);function ds(){return document.createElement(us)}function fs(){return Array.from({length:16},()=>`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%^&*`[Math.floor(Math.random()*65)]).join(``)}var ps=class extends Se{loading=!0;saving=!1;enabled=!1;hasPassword=!1;password=``;sessionTtlHours=12;activeTokenCount=0;lanUrls=[];error=``;message=``;getTabName(){return W(`lanAccess`)}async connectedCallback(){super.connectedCallback(),await this.loadStatus()}async request(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||W(`requestFailed`));return r}applyStatus(e){this.enabled=!!e.enabled,this.hasPassword=!!e.hasPassword,this.sessionTtlHours=Number(e.sessionTtlHours||12),this.activeTokenCount=Number(e.activeTokenCount||0),this.lanUrls=Array.isArray(e.lanUrls)?e.lanUrls:[]}async loadStatus(){this.loading=!0,this.error=``,this.requestUpdate();try{this.applyStatus(await this.request(`/api/lan-access/status`))}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}updatePassword(e){this.password=e,this.requestUpdate()}updateEnabled(e){this.enabled=e,this.requestUpdate()}updateTtl(e){this.sessionTtlHours=Number(e)||12,this.requestUpdate()}async saveSettings(){if(!this.saving){if(this.enabled&&!this.hasPassword&&!this.password.trim()){this.error=W(`lanAccessPasswordRequired`),this.requestUpdate();return}if(this.password.trim()&&this.password.trim().length<8){this.error=W(`lanAccessPasswordTooShort`),this.requestUpdate();return}if(!(this.enabled&&!await ct({description:W(`lanAccessEnableConfirm`),confirmLabel:W(`enabled`),cancelLabel:W(`cancel`)}))){this.saving=!0,this.error=``,this.message=``,this.requestUpdate();try{let e=await this.request(`/api/lan-access/settings`,{method:`PUT`,body:JSON.stringify({enabled:this.enabled,password:this.password.trim()||void 0,sessionTtlHours:this.sessionTtlHours})});this.applyStatus(e),this.password=``,this.message=W(`lanAccessSaved`)}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.saving=!1,this.requestUpdate()}}}}async revokeAll(){if(await ct({description:W(`lanAccessRevokeAllConfirm`),confirmLabel:W(`lanAccessRevokeAll`),cancelLabel:W(`cancel`),variant:`destructive`})){this.saving=!0,this.error=``,this.message=``,this.requestUpdate();try{let e=await this.request(`/api/lan-access/revoke-all`,{method:`POST`});this.applyStatus(e),this.message=W(`lanAccessRevoked`)}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.saving=!1,this.requestUpdate()}}}render(){return this.loading?R`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:R`
694
- <div class="flex flex-col gap-6">
695
- <div>
696
- <h3 class="mb-2 text-sm font-semibold text-foreground">${W(`lanAccess`)}</h3>
697
- <p class="text-sm text-muted-foreground">${W(`lanAccessDescription`)}</p>
698
- </div>
699
-
700
- <section class="rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-sm text-amber-800 dark:text-amber-200">
701
- ${W(`lanAccessRiskWarning`)}
702
- </section>
703
-
704
- <section class="rounded-lg border border-border p-4">
705
- <h4 class="text-sm font-semibold text-foreground">${W(`lanAccessStatus`)}</h4>
706
- <dl class="mt-4 grid gap-3 text-sm">
707
- <div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
708
- <dt class="text-muted-foreground">${W(`lanAccessEnabled`)}</dt>
709
- <dd>${this.enabled?W(`enabled`):W(`disabled`)}</dd>
710
- </div>
711
- <div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
712
- <dt class="text-muted-foreground">${W(`lanAccessPassword`)}</dt>
713
- <dd>${this.hasPassword?W(`configured`):W(`notConfigured`)}</dd>
714
- </div>
715
- <div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
716
- <dt class="text-muted-foreground">${W(`lanAccessActiveDevices`)}</dt>
717
- <dd>${this.activeTokenCount}</dd>
718
- </div>
719
- <div class="grid gap-1 sm:grid-cols-[140px_1fr] sm:gap-3">
720
- <dt class="text-muted-foreground">${W(`lanAccessUrls`)}</dt>
721
- <dd class="min-w-0 break-all">${this.lanUrls.length?this.lanUrls.map(e=>R`<div>${e}</div>`):`-`}</dd>
722
- </div>
723
- </dl>
724
- </section>
725
-
726
- <section class="rounded-lg border border-border p-4">
727
- <label class="flex items-center gap-2 text-sm font-medium text-foreground">
728
- <input type="checkbox" .checked=${this.enabled} @change=${e=>this.updateEnabled(e.target.checked)} />
729
- ${W(`lanAccessAllowFull`)}
730
- </label>
731
-
732
- <label class="mt-4 block text-sm font-medium text-foreground">
733
- ${W(`lanAccessPassword`)}
734
- <div class="mt-2 flex flex-col gap-3 sm:flex-row">
735
- <input class="h-10 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm" type="password" .value=${this.password} @input=${e=>this.updatePassword(e.target.value)} placeholder=${this.hasPassword?W(`lanAccessPasswordPlaceholderConfigured`):W(`lanAccessPasswordPlaceholder`)} />
736
- <button class="rounded-md border border-input px-3 py-2 text-sm" type="button" @click=${()=>this.updatePassword(fs())}>${W(`generatePassword`)}</button>
737
- </div>
738
- </label>
739
-
740
- <label class="mt-4 block text-sm font-medium text-foreground">
741
- ${W(`lanAccessSessionTtl`)}
742
- <select class="mt-2 h-10 w-full rounded-md border border-input bg-background px-3 text-sm" .value=${String(this.sessionTtlHours)} @change=${e=>this.updateTtl(e.target.value)}>
743
- <option value="1">1 ${W(`hour`)}</option>
744
- <option value="12">12 ${W(`hours`)}</option>
745
- <option value="24">24 ${W(`hours`)}</option>
746
- <option value="168">7 ${W(`days`)}</option>
747
- </select>
748
- </label>
749
-
750
- <div class="mt-4 flex flex-wrap gap-2">
751
- <button class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60" type="button" ?disabled=${this.saving} @click=${()=>this.saveSettings()}>${this.saving?W(`saving`):W(`save`)}</button>
752
- <button class="rounded-md border border-destructive/40 px-3 py-2 text-sm text-destructive disabled:opacity-60" type="button" ?disabled=${this.saving} @click=${()=>this.revokeAll()}>${W(`lanAccessRevokeAll`)}</button>
753
- </div>
754
- </section>
755
-
756
- ${this.message?R`<div class="rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">${this.message}</div>`:null}
757
- ${this.error?R`<div class="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive">${this.error}</div>`:null}
758
- </div>
759
- `}},ms=`quickforge-lan-access-settings-tab`;customElements.get(ms)||customElements.define(ms,ps);function hs(){return document.createElement(ms)}var gs=class extends Se{loading=!0;saving=!1;saved=!1;error=``;project;commandDir=``;getTabName(){return W(`projectCommands`)}async connectedCallback(){super.connectedCallback(),await this.loadProject()}async loadProject(){this.loading=!0,this.error=``,this.requestUpdate();try{let e=await fetch(`/api/project`),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`requestFailed`));this.project=t?.project,this.commandDir=typeof this.project?.commandDir==`string`?this.project.commandDir:``}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.loading=!1,this.requestUpdate()}}updateCommandDir(e){this.commandDir=e,this.saved=!1,this.requestUpdate()}async save(){if(!(!this.project||this.saving)){this.saving=!0,this.saved=!1,this.error=``,this.requestUpdate();try{let e=await fetch(`/api/project/${encodeURIComponent(this.project.id)}/command-dir`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({commandDir:this.commandDir})}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||W(`requestFailed`));this.project=t?.project??this.project,this.commandDir=typeof this.project?.commandDir==`string`?this.project.commandDir:``,this.saved=!0}catch(e){this.error=e instanceof Error?e.message:W(`requestFailed`)}finally{this.saving=!1,this.requestUpdate()}}}render(){return this.loading?R`<div class="text-sm text-muted-foreground">${W(`loading`)}</div>`:this.project?R`
760
- <div class="flex flex-col gap-6">
761
- <div>
762
- <h3 class="mb-2 text-sm font-semibold text-foreground">${W(`projectCommands`)}</h3>
763
- <p class="text-sm text-muted-foreground">${W(`projectCommandsDescription`)}</p>
764
- </div>
765
-
766
- <div class="grid gap-1.5 text-sm">
767
- <span class="text-foreground">${W(`project`)}</span>
768
- <div class="break-all rounded-md border border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground">
769
- ${this.project.name} · ${this.project.path}
770
- </div>
771
- </div>
772
-
773
- <label class="grid max-w-xl gap-1.5 text-sm">
774
- <span class="text-foreground">${W(`commandDirectories`)}</span>
775
- <textarea
776
- class="min-h-28 rounded-md border border-input bg-background px-3 py-2 text-sm"
777
- .value=${this.commandDir}
778
- placeholder=${W(`commandDirectoryPlaceholder`)}
779
- @input=${e=>this.updateCommandDir(e.target.value)}
780
- ></textarea>
781
- <span class="text-xs leading-5 text-muted-foreground">${W(`commandDirectoryHelp`)}</span>
782
- </label>
783
-
784
- <div class="rounded-lg border border-border p-4 text-xs leading-5 text-muted-foreground">
785
- <div class="mb-1 font-medium text-foreground">${W(`commandDirectoryExamples`)}</div>
786
- <ul class="list-disc space-y-1 pl-5">
787
- <li>.ai/commands</li>
788
- <li>.claude/commands</li>
789
- <li>.opencode/commands</li>
790
- <li>D:\\shared\\ai-commands</li>
791
- </ul>
792
- </div>
793
-
794
- <div class="flex items-center gap-3">
795
- <button
796
- class="rounded-md bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-60"
797
- type="button"
798
- ?disabled=${this.saving}
799
- @click=${()=>this.save()}
800
- >
801
- ${this.saving?W(`saving`):W(`save`)}
802
- </button>
803
- ${this.saved?R`<span class="text-sm text-muted-foreground">${W(`projectCommandsSaved`)}</span>`:null}
804
- ${this.error?R`<span class="text-sm text-destructive">${this.error}</span>`:null}
805
- </div>
806
- </div>
807
- `:R`
808
- <div class="flex flex-col gap-3">
809
- <h3 class="text-sm font-semibold text-foreground">${W(`projectCommands`)}</h3>
810
- <p class="text-sm text-muted-foreground">${W(`selectProjectForCommands`)}</p>
811
- ${this.error?R`<div class="text-sm text-destructive">${this.error}</div>`:null}
812
- </div>
813
- `}},_s=`quickforge-project-commands-settings-tab`;customElements.get(_s)||customElements.define(_s,gs);function vs(){return document.createElement(_s)}var ys=[`off`,`low`,`medium`,`high`,`xhigh`];function bs(e){switch(e){case`low`:return W(`thinkingLow`);case`medium`:return W(`thinkingMedium`);case`high`:return W(`thinkingHigh`);case`xhigh`:return W(`thinkingXHigh`);default:return W(`thinkingOff`)}}function xs(e){return`${e.provider} / ${e.id}`}function Ss(e,t){let n=document.createElement(`button`);return n.type=`button`,n.className=e,n.textContent=t,n}var Cs=`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>`;function ws(e,t,n,r,i={}){let a=t.map(e=>({provider:e.provider,id:e.id,model:e})),o=i.thinkingLevel??`off`,s=document.createElement(`div`);s.className=`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`;let c=document.createElement(`div`);c.className=`flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden rounded-lg border border-border bg-background text-foreground shadow-xl`;let l=document.createElement(`div`);l.className=`border-b border-border p-4`;let u=document.createElement(`div`);u.className=`mb-3 flex items-center justify-between gap-3`;let d=document.createElement(`div`);d.className=`text-sm font-semibold`,d.textContent=W(`selectCustomModel`);let f=Ss(`rounded-md px-2 py-1 text-sm text-muted-foreground hover:bg-secondary`,W(`close`));f.onclick=()=>s.remove(),u.append(d,f);let p=document.createElement(`input`);p.className=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,p.placeholder=W(`searchModels`),l.append(u,p);let m=document.createElement(`div`);m.className=`mt-3 rounded-lg border border-border bg-muted/20 p-3`;let h=document.createElement(`div`);h.className=`text-xs font-medium text-muted-foreground`,h.textContent=W(`currentConfiguration`);let g=document.createElement(`div`);g.className=`mt-1 truncate text-sm font-medium`,g.textContent=e?xs(e):W(`noModelAdded`);let _=document.createElement(`div`);_.className=`mt-3 flex flex-wrap items-center gap-1.5`;let v=document.createElement(`span`);v.className=`mr-1 text-xs text-muted-foreground`,v.textContent=W(`thinkingLevel`);let y=()=>{if(_.replaceChildren(v),e?.reasoning!==!0){let e=document.createElement(`span`);e.className=`text-xs text-muted-foreground`,e.textContent=W(`thinkingNotSupported`),_.append(e);return}for(let e of ys){let t=Ss(`rounded-full border px-2.5 py-1 text-xs transition-colors ${o===e?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`}`,bs(e));t.onclick=()=>{o=e,i.onThinkingLevelSelect?.(e),y()},_.append(t)}};m.append(h,g,_),l.append(m),y();let b=document.createElement(`div`);b.className=`min-h-0 flex-1 overflow-y-auto`;let x=()=>{let t=p.value.trim().toLowerCase();b.replaceChildren();let c=a.filter(({model:e})=>t?xs(e).toLowerCase().includes(t):!0).sort((t,n)=>{let r=De(e,t.model),i=De(e,n.model);return r&&!i?-1:!r&&i?1:xs(t.model).localeCompare(xs(n.model))});if(c.length===0){let e=document.createElement(`div`);e.className=`p-8 text-center text-sm text-muted-foreground`,e.textContent=W(`noMatchingCustomModels`),b.append(e);return}for(let{model:t}of c){let a=Ss(`w-full border-b border-border px-4 py-3 text-left hover:bg-muted`,``),c=document.createElement(`div`);c.className=`flex items-center justify-between gap-2`;let l=document.createElement(`div`);l.className=`min-w-0 truncate text-sm font-medium`,l.textContent=t.id;let u=document.createElement(`div`);u.className=`flex shrink-0 items-center gap-1.5`;let d=document.createElement(`div`);if(d.className=`rounded-md border border-border px-2 py-0.5 text-xs text-muted-foreground`,d.textContent=t.provider,u.append(d),r){let e=document.createElement(`button`);e.type=`button`,e.className=`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-secondary hover:text-foreground`,e.innerHTML=Cs,e.setAttribute(`aria-label`,W(`editModel`)),e.onclick=e=>{e.stopPropagation(),s.remove(),r(t)},u.append(e)}c.append(l,u);let f=document.createElement(`div`);if(f.className=`mt-1 text-xs text-muted-foreground`,f.textContent=`${t.api} · ${t.contextWindow}/${t.maxTokens}${t.reasoning?` · ${W(`thinkingSupported`)}`:``}`,De(e,t)){let e=document.createElement(`span`);e.className=`ml-2 text-green-500`,e.textContent=`✓`,l.append(e)}a.append(c,f),a.onclick=()=>{!t.reasoning&&o!==`off`&&(o=`off`,i.onThinkingLevelSelect?.(`off`)),n(t),g.textContent=xs(t),s.remove()},b.append(a)}};p.oninput=x,s.onclick=e=>{e.target===s&&s.remove()},c.onclick=e=>e.stopPropagation(),c.append(l,b),s.append(c),document.body.append(s),x(),p.focus()}function Ts({storageRef:e,activeModelRef:t,agentRef:n,createAgent:r,updateCurrentAgentModel:i,setChatPanelRevision:a,needsModelSetup:o,setNeedsModelSetup:s,setRestoredDraft:c,notifySettingsChanged:l}){let u=(0,V.useCallback)(async()=>{let o=e.current;if(!o)return!1;let c=await X(o);return c?(t.current=c,s(!1),await Ft(o,c),n.current?(i(c),a(e=>e+1)):await r({model:c,tools:[]},Y(),{scope:`global`,attachToView:!0}),l(),!0):(s(!0),!1)},[e,t,n,r,i,a,s,l]),d=(0,V.useCallback)(e=>{he.open([jo(),Wo(),Oo(),vs(),$o(),ds(),hs()],()=>{(o||!n.current)&&u().catch(e=>B.error(`Failed to activate configured model:`,e))}),window.setTimeout(()=>{let t=document.querySelector(`settings-dialog`);t&&(t.activeTabIndex=e===`defaults`?1:2,t.requestUpdate?.())},0)},[u,o,n]),f=(0,V.useCallback)(()=>{d(`customModels`)},[d]);return{activateConfiguredModel:u,openModelSettings:f,openDefaultOptionsSettings:(0,V.useCallback)(()=>{d(`defaults`)},[d]),activateLiteLlmExampleModel:(0,V.useCallback)(async()=>{let o=e.current;if(!o)return;let c=At(Ct);await Xt(o,Ct,c),await Ft(o,c),t.current=c,s(!1),n.current?(i(c),a(e=>e+1)):await r({model:c,tools:[]},Y(),{scope:`global`,attachToView:!0}),l()},[e,t,n,r,i,a,s,l]),openCustomModelSelector:(0,V.useCallback)(async()=>{let r=e.current,o=n.current;if(!r||!o)return;let s=document.querySelector(`agent-interface message-editor textarea`)?.value??``,l=Wt(await r.customProviders.getAll());if(l.length===0){await ct({description:W(`addCustomModelFirst`),confirmLabel:W(`modelSetupAddModel`),cancelLabel:W(`cancel`)})&&f();return}ws(o.state.model??t.current,l,e=>{let n=e,l=n.reasoning?o.state.thinkingLevel:`off`;o.state.thinkingLevel!==l&&(o.state.thinkingLevel=l,o.updateThinkingLevel(l).catch(e=>{B.error(`Failed to sync thinking level to server:`,e)})),t.current=n,i(n),s&&c({id:Date.now(),sessionId:o.sessionId,text:s}),a(e=>e+1),Ft(r,n).catch(e=>{B.error(`Failed to save active model:`,e)})},async e=>{await he.open([jo(),Wo(),Oo(e.provider),vs(),$o(),ds(),hs()]);let t=document.querySelector(`settings-dialog`);t&&(t.activeTabIndex=2,t.requestUpdate?.())},{thinkingLevel:o.state.thinkingLevel,onThinkingLevelSelect:e=>{o.state.thinkingLevel=e,o.updateThinkingLevel(e).catch(e=>{B.error(`Failed to sync thinking level to server:`,e)}),a(e=>e+1)}})},[e,t,n,i,a,c,f])}}function Es(){let e=new URL(window.location.href);e.searchParams.delete(`session`),window.history.replaceState({},``,e)}function Ds(e){return!!(e&&!e.state.isStreaming&&e.state.messages.length===0)}function Os({storageRef:e,activeModelRef:t,activeProjectRef:n,currentChatScopeRef:r,currentSessionIdRef:i,taskMapRef:a,agentRef:o,startDeferredSession:s,createAgent:c,syncSessionUI:l,setCurrentAgentMessages:u,setChatPanelRevision:d,refreshSessions:f,needsModelSetup:p,switchActiveProject:m,closeWorkspacePage:h,setRestoredDraft:g}){let _=(0,V.useCallback)(async()=>{if(p){J(W(`modelSetupRequired`));return}h(),!(Ds(o.current)&&r.current===`global`)&&(g(void 0),Es(),await s({scope:`global`}))},[o,r,p,g,h,s]),v=(0,V.useCallback)(async e=>{if(p){J(W(`modelSetupRequired`));return}h();let t=e??n.current;t&&(Ds(o.current)&&r.current===`project`&&n.current?.id===t.id||(n.current?.id!==t.id&&await m(t.id),g(void 0),Es(),await s({scope:`project`,project:t})))},[n,o,r,p,g,h,s,m]),y=(0,V.useCallback)(async s=>{let p=o.current;if(!p)return;if(p.state.isStreaming){J(W(`generationStillRunning`));return}let m=Ka(p.state.messages,s),h=m>=0?p.state.messages[m]:void 0;if(m<0||!h){J(W(`noConversationTurnToRollback`));return}let _={id:Date.now(),sessionId:p.sessionId,text:qa(h),attachments:h.role===`user-with-attachments`?h.attachments:void 0},v=p.state.messages.slice(0,m);try{v=(await p.rollback(s)).session.messages??v}catch(e){B.error(`Failed to rollback conversation:`,e),J(e instanceof Error?e.message:W(`rollbackFailed`));return}u(v);let y=i.current?a.current.get(i.current):void 0;if(Qa(v)&&y){_&&g(_),d(e=>e+1),l(y).catch(e=>B.error(`Failed to sync session UI:`,e));return}let b=e.current,x=i.current,S=r.current,C=S===`project`?n.current:void 0,w=p.state.model??t.current,T=p.state.thinkingLevel;if(x){let e=a.current.get(x);e?.unsubscribe(),e?.agent.dispose(),a.current.delete(x)}if(b&&x)try{await b.sessions.delete(x),await f({broadcast:!0})}catch(e){B.error(`Failed to delete rolled back empty session:`,e)}let E=Y();await c({model:w,thinkingLevel:T,messages:[],tools:[]},E,{scope:S,project:C,attachToView:!0,title:`New chat`}),g({..._,sessionId:E}),d(e=>e+1)},[t,n,o,c,r,i,f,d,u,g,e,l,a]),b=(0,V.useCallback)(async e=>{try{await Ja(e)}catch(e){throw B.error(`Failed to copy answer:`,e),J(W(`copyFailed`)),e}},[]),x=(0,V.useCallback)(async i=>{let a=o.current;if(!a)return;if(a.state.isStreaming){J(W(`generationStillRunning`));return}let s=a.state.messages.slice(0,i+1);if(!Za(s))return;let l=r.current,u=l===`project`?n.current:void 0,d=Y(),p=Ya(s),m=e.current;await c({model:a.state.model??t.current,thinkingLevel:a.state.thinkingLevel,messages:s,tools:[]},d,{scope:l,project:u,attachToView:!0,title:p}),m&&f({broadcast:!0}).catch(e=>B.error(`Failed to refresh sessions:`,e))},[t,n,o,c,r,f,e]);return{startNewGlobalChat:_,startNewProjectChat:v,rollbackFromMessage:y,retryFromMessage:(0,V.useCallback)(async e=>{let t=o.current;if(!t)return;if(t.state.isStreaming){J(W(`generationStillRunning`));return}let n=t.state.messages;if(e<0||e>=n.length)return;let r=n[e];if(r.role!==`user`&&r.role!==`user-with-attachments`)return;u(n.slice(0,e+1)),d(e=>e+1);try{await t.continue()}catch(e){B.error(`Failed to retry:`,e),J(e instanceof Error?e.message:W(`retryFailed`));return}let s=i.current?a.current.get(i.current):void 0;s&&(l(s).catch(e=>B.error(`Failed to sync session UI after retry:`,e)),d(e=>e+1))},[o,i,d,u,l,a]),copyAnswer:b,forkFromMessage:x}}function ks({activeProjectRef:e,refreshSessions:t,notifyProjectsChanged:n,setActiveProject:r,setProjects:i,setExpandedProjectIds:a,setChatPanelRevision:o}){return{deleteProjectInline:(0,V.useCallback)(async s=>{let c=await fetch(`/api/project/${encodeURIComponent(s)}`,{method:`DELETE`}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to delete project`);r(l.project),i(l.projects),a(e=>{let t=new Set(e);return t.delete(s),t}),await t({broadcast:!0}),n(),e.current?.id===s&&(e.current=l.project,o(e=>e+1))},[e,t,n,r,i,a,o])}}var As=V.forwardRef(({className:e,type:t,...n},r)=>(0,K.jsx)(`input`,{type:t,className:G(`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));As.displayName=`Input`;function js({options:e,onResolve:t}){let n=(0,V.useRef)(null),[r,i]=(0,V.useState)(e.defaultValue??``),a=(0,V.useRef)(r);return(0,V.useEffect)(()=>{a.current=r},[r]),(0,V.useEffect)(()=>{n.current?.focus(),n.current?.select()},[]),(0,V.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t(null),e.key===`Enter`&&a.current.trim()&&t(a.current.trim())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,at.createPortal)((0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:e=>{e.target===e.currentTarget&&t(null)},children:(0,K.jsxs)(`div`,{className:G(`w-full max-w-sm rounded-lg border border-border bg-background p-6 shadow-lg`,`mx-4`),children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e.title}),e.description?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.description}):null,(0,K.jsx)(`div`,{className:`mt-4`,children:(0,K.jsx)(As,{ref:n,value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder,className:`w-full`})}),(0,K.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>t(null),children:e.cancelLabel??`Cancel`}),(0,K.jsx)(q,{size:`sm`,onClick:()=>r.trim()?t(r.trim()):void 0,disabled:!r.trim(),children:e.confirmLabel??`Save`})]})]})}),document.body)}function Ms(e){return new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,Ae.createRoot)(n);function i(){r.unmount(),setTimeout(()=>n.remove(),0)}function a(e){i(),t(e)}r.render((0,K.jsx)(js,{options:e,onResolve:a}))})}function Ns({storageRef:e,taskMapRef:t,currentSessionIdRef:n,loadAgentSession:r,setCurrentTitleRef:i,refreshSessions:a,closeWorkspacePage:o,startNewGlobalChat:s}){return{loadSession:(0,V.useCallback)(e=>{o(),r(e)},[r,o]),renameSession:(0,V.useCallback)(async(t,r)=>{let o=e.current;if(!o)return;let s=await Ms({title:W(`renameSession`),description:W(`sessionName`),defaultValue:r,confirmLabel:W(`save`),cancelLabel:W(`cancel`)});if(!s||s===r)return;let c=await o.sessions.get(t);if(!c)return;let l=await o.sessions.getMetadata(t);l&&(await o.sessions.save(c,{...l,title:s}),await a({broadcast:!0}),n.current===t&&i(s))},[n,a,i,e]),togglePinSession:(0,V.useCallback)(async t=>{let n=e.current;if(!n)return;let r=await n.sessions.get(t);if(!r)return;let i=await n.sessions.getMetadata(t);if(!i)return;let o=i.pinnedAt?void 0:new Date().toISOString(),s={...r,pinnedAt:o},c={...i,pinnedAt:o};await n.sessions.save(s,c),await a({broadcast:!0})},[a,e]),deleteSession:(0,V.useCallback)(async r=>{let i=e.current;if(!i)return;let c=t.current.get(r);c?.unsubscribe(),c?.agent.dispose(),t.current.delete(r),await i.sessions.delete(r),await a({broadcast:!0}),n.current===r&&(o(),await s())},[n,a,o,s,e,t]),startNewGlobalSession:(0,V.useCallback)(()=>{o(),s()},[o,s])}}function Ps({storageRef:e,yoloModeRef:t,setYoloMode:n,agentRef:r,setChatPanelRevision:i,notifySettingsChanged:a}){return{toggleYoloMode:(0,V.useCallback)(()=>{let o=e.current,s=r.current,c=t.current,l=!c;n(l),t.current=l;let u=()=>{t.current=c,n(c),i(e=>e+1)};(async()=>{try{s&&await s.updateYoloMode(l),o&&await Jt(o,l),i(e=>e+1),a()}catch(e){B.error(`Failed to sync YOLO mode:`,e),u(),J(e instanceof Error?e.message:W(`yoloModeSyncFailed`))}})()},[r,a,i,n,e,t])}}function Fs(){let[e,t]=(0,V.useState)(!0),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(),[w,T]=(0,V.useState)(!1),[E,D]=(0,V.useState)(),[O,k]=(0,V.useState)(!1);return{sidebarOpen:e,setSidebarOpen:t,mobileSidebarOpen:n,setMobileSidebarOpen:r,projectsCollapsed:i,setProjectsCollapsed:a,conversationsCollapsed:o,setConversationsCollapsed:s,mcpServersDialogOpen:c,setMcpServersDialogOpen:l,skillsDialog:u,setSkillsDialog:d,shareDialogOpen:f,setShareDialogOpen:p,conversationMenuOpen:m,setConversationMenuOpen:h,workspaceInspectorOpen:g,setWorkspaceInspectorOpen:_,workspaceInspectorFocusTarget:v,setWorkspaceInspectorFocusTarget:y,inlineReaderOpen:b,setInlineReaderOpen:x,inlineReaderFile:S,setInlineReaderFile:C,inlineReaderLoading:w,setInlineReaderLoading:T,inlineReaderError:E,setInlineReaderError:D,firstUseGuideDismissed:O,setFirstUseGuideDismissed:k,toggleProjectsCollapsed:(0,V.useCallback)(()=>a(e=>!e),[]),toggleConversationsCollapsed:(0,V.useCallback)(()=>s(e=>!e),[])}}function Is(e){return e===`running`||e===`idle`||e===`error`||e===`aborted`?e:void 0}function Ls(e){let[t,n]=(0,V.useState)({}),r=(0,V.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),i=(0,V.useMemo)(()=>e.map(e=>e.id).sort().join(`
814
- `),[e]),a=(0,V.useCallback)(async()=>{if(r.size===0){n({});return}try{let e=await Ba(),t=new Map(e.map(e=>[e.sessionId,Is(e.status)]).filter(e=>!!e[1]));n(e=>{let n={};for(let i of r){let r=t.get(i),a=e[i];r?n[i]=r:a===`running`?n[i]=`idle`:a&&a!==`idle`&&(n[i]=a)}return n})}catch(e){B.error(`Failed to refresh visible agent statuses:`,e)}},[r]);return(0,V.useEffect)(()=>{let e=window.setTimeout(()=>{a()},0);return()=>window.clearTimeout(e)},[a,i]),(0,V.useEffect)(()=>Va(e=>{let t=e.sessionId;if(!(!t||!r.has(t))){if(e.type===`agent_start`){n(e=>({...e,[t]:`running`}));return}if(e.type===`agent_end`){let r=Is(e.status)===`aborted`?`aborted`:e.errorMessage?`error`:`idle`;n(e=>({...e,[t]:r}))}}}),[r]),(0,V.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&a()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a]),t}function Rs(e){return e===`idle`?{tone:`success`,message:W(`taskCompleted`)}:e===`error`?{tone:`error`,message:W(`taskError`)}:e===`aborted`?{tone:`aborted`,message:W(`processAborted`)}:e===`running`?{tone:`running`,message:W(`taskRunning`)}:{tone:`neutral`,message:W(`taskRunning`)}}function zs({toast:e,onDismiss:t,onClick:n}){let[r,i]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),c=(0,V.useRef)(null);(0,V.useEffect)(()=>{let n=window.setTimeout(()=>i(!0),10);return c.current=window.setTimeout(()=>{s(!0),c.current=window.setTimeout(()=>t(e.id),200)},5e3),()=>{window.clearTimeout(n),c.current!==null&&window.clearTimeout(c.current)}},[e.id,t]);let l=()=>{s(!0),c.current!==null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>t(e.id),200)},u=Rs(e.status),d=u.tone===`error`,f=u.tone===`success`,p=G(`size-5`,d&&`text-destructive`,f&&`text-emerald-500`,u.tone===`aborted`&&`text-amber-600`,u.tone===`running`&&`text-blue-600`,u.tone===`neutral`&&`text-muted-foreground`);return(0,K.jsxs)(`div`,{role:`alert`,onClick:()=>n(e.sessionId),className:G(`pointer-events-auto flex w-80 cursor-pointer items-start gap-3 rounded-xl border border-border bg-background p-3 shadow-lg transition-all duration-200 ease-out`,r&&!o?`translate-x-0 opacity-100`:`translate-x-4 opacity-0`),children:[(0,K.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:f?(0,K.jsx)(ne,{className:p}):(0,K.jsx)(a,{className:p})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.title}),(0,K.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-xs text-muted-foreground`,children:e.message||u.message})]}),(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},className:`shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground`,"aria-label":W(`close`),children:(0,K.jsx)(M,{className:`size-4`})})]})}function Bs({toasts:e,onDismiss:t,onClick:n}){return e.length===0?null:(0,K.jsx)(`div`,{className:`pointer-events-none fixed right-4 top-16 z-50 flex flex-col gap-2`,children:e.map(e=>(0,K.jsx)(zs,{toast:e,onDismiss:t,onClick:n},e.id))})}async function Vs(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}function Hs(e){if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let t=new Uint8Array(1);return crypto.getRandomValues(t),e[t[0]%e.length]}return e[Math.floor(Math.random()*e.length)]}function Us(){let e=()=>Array.from({length:6},()=>Hs(`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`)).join(``);return`${e()}-${e()}`}function Ws(e=24){return new Date(Date.now()+e*60*60*1e3).toISOString()}async function Gs(e){return Vs(`/api/shares`,{method:`POST`,body:JSON.stringify(e)})}async function Ks(e){return Vs(`/api/shares${e?`?sessionId=${encodeURIComponent(e)}`:``}`)}async function qs(e){return Vs(`/api/shares/${encodeURIComponent(e)}`,{method:`DELETE`})}async function Js(e){return Vs(`/api/shared/${encodeURIComponent(e)}/meta`)}async function Ys(e,t=``){return Vs(`/api/shared/${encodeURIComponent(e)}/unlock`,{method:`POST`,body:JSON.stringify({password:t})})}async function Xs(e){return Vs(`/api/shared/${encodeURIComponent(e)}/models`)}function Zs({open:e,sessionId:t,title:n,onOpenChange:r}){let i=(0,V.useId)(),[a,s]=(0,V.useState)(`read`),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(`24h`),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)([]),[v,y]=(0,V.useState)(!1),[b,S]=(0,V.useState)(),C=(0,V.useMemo)(()=>{if(u!==`never`)return Ws(u===`1h`?1:u===`7d`?168:24)},[u]);if((0,V.useEffect)(()=>{!e||!t||Ks(t).then(e=>_(e.shares)).catch(e=>S(e instanceof Error?e.message:`Failed to load shares`))},[e,t]),!e)return null;let w=a===`operate`,T=!!t&&(a!==`operate`||f&&c.trim()),E=async()=>{if(!(!t||!T)){if(w&&!c.trim()){S(`可操作分享必须设置密码。`);return}y(!0),S(void 0);try{let e=await Gs({sessionId:t,permission:a,password:c.trim(),expiresAt:C});h(e.url),await Ja(e.url),p(!1),_((await Ks(t)).shares)}catch(e){S(e instanceof Error?e.message:`Failed to create share`)}finally{y(!1)}}},D=async e=>{let t=e.url||`${window.location.origin}/share/${encodeURIComponent(e.id)}`;h(t),await Ja(t)},k=async e=>{try{await qs(e),_(t=>t.map(t=>t.id===e?{...t,revokedAt:new Date().toISOString()}:t))}catch(e){S(e instanceof Error?e.message:`Failed to revoke share`)}};return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onMouseDown:e=>{e.target===e.currentTarget&&r(!1)},children:(0,K.jsxs)(`div`,{className:`flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-border bg-background shadow-2xl`,onMouseDown:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`shrink-0 border-b border-border px-5 py-4`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold`,children:`分享到局域网`}),(0,K.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`当前对话:`,n,`。同一个对话只会有一个固定分享链接;只读分享密码可选,可操作分享必须设置密码。`]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`权限`}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`rounded-xl border p-3 text-left text-sm ${a===`read`?`border-primary bg-primary/10`:`border-border`}`,onClick:()=>s(`read`),children:[(0,K.jsx)(`div`,{className:`font-medium`,children:`仅阅读`}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:`只能查看这一个对话。`})]}),(0,K.jsxs)(`button`,{type:`button`,className:`rounded-xl border p-3 text-left text-sm ${a===`operate`?`border-red-400 bg-red-50 text-red-950`:`border-border`}`,onClick:()=>s(`operate`),children:[(0,K.jsx)(`div`,{className:`font-medium text-red-700`,children:`可操作(高危)`}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-red-700`,children:`允许对方操作这个原对话,禁止 Fork。`})]})]})]}),a===`operate`?(0,K.jsxs)(`div`,{className:`rounded-xl border border-red-300 bg-red-50 p-3 text-sm text-red-900`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2 font-semibold`,children:[(0,K.jsx)(O,{className:`mt-0.5 size-4`}),`高危可操作权限`]}),(0,K.jsx)(`p`,{className:`mt-2 text-xs leading-5`,children:`拥有链接和密码的人只能操作这一个原对话,但对方的消息、停止生成、回滚、模型/思考等级选择、YOLO 状态下可用工具等操作会按正常对话权限直接影响你的本机原对话。可操作分享必须设置密码。`}),(0,K.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-xs font-medium`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),`我已了解风险,仍然允许可操作权限。`]})]}):null,(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`label`,{htmlFor:i,className:`block text-sm font-medium`,children:w?`密码(可操作必填)`:`密码(可选)`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,K.jsx)(`input`,{id:i,value:c,onChange:e=>l(e.target.value),className:`h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 text-sm`,placeholder:w?`可操作分享必须设置密码`:`留空则打开链接无需密码`}),(0,K.jsxs)(q,{variant:`outline`,className:`h-10 sm:shrink-0`,onClick:()=>l(Us()),children:[(0,K.jsx)(j,{className:`mr-2 size-4`}),`生成密码`]})]}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:w?`可操作分享必须设置非空密码;修改密码后旧密码和已解锁状态会失效。`:`留空保存会取消密码保护;填写新密码保存后旧密码和已解锁状态会失效。`})]}),(0,K.jsxs)(`label`,{className:`block text-sm font-medium`,children:[`有效期`,(0,K.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),className:`mt-2 h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:[(0,K.jsx)(`option`,{value:`1h`,children:`1 小时`}),(0,K.jsx)(`option`,{value:`24h`,children:`24 小时`}),(0,K.jsx)(`option`,{value:`7d`,children:`7 天`}),(0,K.jsx)(`option`,{value:`never`,children:`永久,需手动撤销`})]})]}),m?(0,K.jsxs)(`div`,{className:`rounded-xl border border-emerald-300 bg-emerald-50 p-3 text-sm text-emerald-900`,children:[`已复制到剪切板。`,(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto whitespace-pre-wrap text-xs`,children:m})]}):null,b?(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:b}):null,g.length?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`已有分享`}),(0,K.jsx)(`div`,{className:`space-y-2`,children:g.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border p-2 text-xs`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`truncate font-mono`,children:e.id}),(0,K.jsxs)(`div`,{className:`text-muted-foreground`,children:[e.permission===`operate`?`可操作`:`只读`,` · `,e.hasPassword?`有密码`:`无密码`,` · `,e.revokedAt?`已撤销`:e.expiresAt?`到期 ${new Date(e.expiresAt).toLocaleString()}`:`永久`]})]}),e.revokedAt?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>void D(e),"aria-label":`复制分享链接`,title:`复制分享链接`,children:(0,K.jsx)(o,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`text-destructive`,onClick:()=>void k(e.id),"aria-label":`撤销分享`,title:`撤销分享`,children:(0,K.jsx)(x,{className:`size-4`})})]})]},e.id))})]}):null]})}),(0,K.jsx)(`div`,{className:`shrink-0 border-t border-border px-5 py-4`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,onClick:()=>r(!1),children:W(`cancel`)}),(0,K.jsxs)(q,{variant:a===`operate`?`destructive`:`default`,disabled:!T||v,onClick:()=>void E(),title:a===`operate`&&!c.trim()?`可操作分享必须设置密码`:void 0,children:[(0,K.jsx)(o,{className:`mr-2 size-4`}),a===`operate`?`保存配置并复制高危可操作链接`:`保存配置并复制链接`]})]})})]})})}async function Qs(e){let t=await fetch(e,{cache:`no-store`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Request failed: ${t.status}`);return n}async function $s(e,t){let n=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}function ec(e){return`projectId=${encodeURIComponent(e)}`}function tc(e){return Qs(`/api/workspace/tree?${ec(e)}`)}function nc(e,t){return Qs(`/api/workspace/file?${ec(e)}&path=${encodeURIComponent(t)}`)}function rc(e,t){return $s(`/api/workspace/resolve-path`,{projectId:e,path:t})}function ic(e){return Qs(`/api/git/status?${ec(e)}`)}function ac(e,t){return Qs(`/api/git/file-diff?${ec(e)}&path=${encodeURIComponent(t)}`)}var oc=(0,V.lazy)(()=>ke(()=>import(`./ChatPanelHost-BjdIshtX.js`).then(e=>({default:e.ChatPanelHost})),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),sc=(0,V.lazy)(()=>ke(()=>import(`./TerminalDock-CEuJNf0m.js`).then(e=>({default:e.TerminalDock})),__vite__mapDeps([9,1,10,11,5,6]))),cc=(0,V.lazy)(()=>ke(()=>import(`./ScheduledTasksPage-C047y3p3.js`).then(e=>({default:e.ScheduledTasksPage})),__vite__mapDeps([12,1,5,6]))),lc=(0,V.lazy)(()=>ke(()=>import(`./AgentProfilesPage-C79teCgh.js`).then(e=>({default:e.AgentProfilesPage})),__vite__mapDeps([13,1,5,6]))),uc=(0,V.lazy)(()=>ke(()=>import(`./PluginsPage-Dt7Iiddo.js`).then(e=>({default:e.PluginsPage})),__vite__mapDeps([14,1,5,6,7]))),dc=(0,V.lazy)(()=>ke(()=>import(`./SharedConversationPage-8X8kfztQ.js`).then(e=>({default:e.SharedConversationPage})),__vite__mapDeps([15,1,3,2,4,5,6,0,7,8]))),fc=(0,V.lazy)(()=>ke(()=>import(`./WorkspaceInspector-BIa5gLVs.js`).then(e=>({default:e.WorkspaceInspector})),__vite__mapDeps([16,1,5,6,17,18]))),pc=(0,V.lazy)(()=>ke(()=>import(`./WorkspaceReaderDialog-bTeERaGd.js`).then(e=>({default:e.WorkspaceReaderDialog})),__vite__mapDeps([17,1,18,5,6])));function mc(){return(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:W(`loading`)})}function hc(){return null}function gc(e){return e===`idle`||e===`running`||e===`error`||e===`aborted`}function _c(e){return e.type===`scheduled_task_notification`}function vc(e){return e.type===`scheduled_task_started`}function yc(){let e=(0,V.useRef)(null),t=(0,V.useRef)(At(Ct)),i=(0,V.useRef)(!1),a=(0,V.useRef)(void 0),{activeProject:o,projects:s,expandedProjectIds:c,selectingProject:l,projectPickerOpen:u,loadProject:d,switchActiveProject:f,handleSelectProjectPath:p,selectProjectDirectory:h,setProjectPickerOpen:g,toggleProjectExpanded:_,toggleAllProjectsExpanded:v,reorderProjects:y,setActiveProject:b,setProjects:x,setExpandedProjectIds:C}=Ea(),{yoloMode:w,setYoloMode:T,initialize:E}=Da(),D=Fs(),[O,k]=(0,V.useState)(!1),[ee,A]=(0,V.useState)(),[j,M]=(0,V.useState)(`chat`),[N,P]=(0,V.useState)(!1),[ne,F]=(0,V.useState)(null),[re,I]=(0,V.useState)(),oe=(0,V.useRef)(0),[se,ce]=(0,V.useState)(null),{toasts:le,handleTaskComplete:ue,addToast:R,dismissToast:de}=oo(),fe=j===`scheduledTasks`,pe=j===`agentProfiles`,me=j===`plugins`,he=j!==`chat`,z=(0,V.useCallback)(()=>M(`chat`),[]),ge=(0,V.useRef)(null),_e=(0,V.useRef)(null),{allLoadedSessions:ve,globalSessions:ye,sessionsForProject:be,globalHasMore:xe,projectHasMore:Se,globalLoading:Ce,projectLoading:we,projectLoaded:Te,loadGlobalSessions:Ee,loadProjectSessions:De,refreshSessions:Oe,loadMoreGlobal:ke,loadMoreProject:Ae}=ao({backendRef:_e,expandedProjectIds:c,onBroadcastSessionsChanged:(0,V.useCallback)(()=>ge.current?.notifySessionsChanged(),[])}),je=ka({onSessionsChanged:()=>{Oe()},onProjectsChanged:()=>{d()},onSettingsChanged:()=>{Oe()}});(0,V.useEffect)(()=>{i.current=w},[w]),(0,V.useEffect)(()=>{a.current=o},[o]),(0,V.useEffect)(()=>{ge.current=je},[je]);let Me=(0,V.useCallback)((e,t)=>{I({sessionId:e,...t})},[]),H=to({storageRef:e,activeModelRef:t,yoloModeRef:i,activeProjectRef:a,setYoloMode:T,switchActiveProject:f,sessions:ve,refreshSessions:Oe,onTaskComplete:ue}),{createAgent:Ne,startDeferredSession:Pe,loadSession:Fe,syncSessionUI:Ie,setCurrentAgentMessages:Le,updateCurrentAgentModel:Re,setChatPanelRevision:ze,setCurrentTitleRef:Be,agentRef:U,taskMapRef:Ve,currentSessionIdRef:He,currentChatScopeRef:Ue}=H,We=(0,V.useCallback)(e=>{e&&(z(),Fe(e))},[z,Fe]),Ge=(0,V.useCallback)(e=>{e.trim()&&(z(),A({id:Date.now(),sessionId:U.current?.sessionId,text:e}))},[U,z]),Ke=(0,V.useCallback)(()=>{H.currentToolProject?.id&&(z(),D.setWorkspaceInspectorFocusTarget({tab:`git`,nonce:Date.now()}),D.setWorkspaceInspectorOpen(!0))},[H.currentToolProject?.id,z,D]),qe=(0,V.useCallback)(async e=>{let t=H.currentToolProject?.id;if(!t){R({sessionId:H.currentSessionId??``,title:`无法打开文件`,status:`error`,message:`当前对话没有关联项目。`});return}D.setInlineReaderOpen(!0),D.setInlineReaderLoading(!0),D.setInlineReaderError(void 0),D.setInlineReaderFile(void 0);try{let n=await nc(t,(await rc(t,e)).relativePath);D.setInlineReaderFile(n)}catch(e){let t=e instanceof Error?e.message:`打开文件失败`;D.setInlineReaderError(t),R({sessionId:H.currentSessionId??``,title:`无法打开文件`,status:`error`,message:t})}finally{D.setInlineReaderLoading(!1)}},[R,H.currentSessionId,H.currentToolProject?.id,D]);(0,V.useEffect)(()=>Va(e=>{if(vc(e)){let t=typeof e.projectId==`string`?e.projectId:void 0;t&&(C(e=>{let n=new Set(e);return n.add(t),n}),De(t,0)),Oe({broadcast:!0});return}if((e.type===`agent_end`||e.type===`title_updated`||e.type===`session_forked`)&&Oe({broadcast:!0}),!_c(e))return;let t=typeof e.sessionId==`string`?e.sessionId:void 0,n=typeof e.title==`string`?e.title:W(`scheduledTasks`),r=gc(e.status)?e.status:`idle`,i=typeof e.message==`string`?e.message:void 0;R({sessionId:t??``,title:n,status:r,message:i})}),[R,De,Oe,C]);let{ready:Je,startupError:Ye,retryBootstrap:Xe}=Co({storageRef:e,backendRef:_e,activeModelRef:t,yoloModeRef:i,activeProjectRef:a,setYoloMode:T,taskMapRef:Ve,loadGlobalSessions:Ee,loadProject:d,initYoloMode:E,switchActiveProject:f,createAgent:Ne,setNeedsModelSetup:k,onStorageReady:ce});(0,V.useEffect)(()=>{if(Je)for(let e of c)!Te(e)&&!we(e)&&De(e,0)},[Je,c,Te,we,De]);let{startNewGlobalChat:Ze,startNewProjectChat:Qe,rollbackFromMessage:G,retryFromMessage:$e,copyAnswer:tt,forkFromMessage:rt}=Os({storageRef:e,activeModelRef:t,activeProjectRef:a,currentChatScopeRef:Ue,currentSessionIdRef:He,taskMapRef:Ve,agentRef:U,createAgent:Ne,startDeferredSession:Pe,syncSessionUI:Ie,setCurrentAgentMessages:Le,setChatPanelRevision:ze,refreshSessions:Oe,needsModelSetup:O,switchActiveProject:f,closeWorkspacePage:z,setRestoredDraft:A}),{deleteProjectInline:at}=ks({activeProjectRef:a,refreshSessions:Oe,notifyProjectsChanged:je.notifyProjectsChanged,setActiveProject:b,setProjects:x,setExpandedProjectIds:C,setChatPanelRevision:ze}),{toggleYoloMode:ot}=Ps({storageRef:e,yoloModeRef:i,setYoloMode:T,agentRef:U,setChatPanelRevision:ze,notifySettingsChanged:je.notifySettingsChanged}),st=(0,V.useCallback)(async e=>{let t=U.current;if(!t)throw Error(W(`toolApprovalFailed`));try{await t.approveToolCall(e)}catch(e){throw B.error(`Failed to approve tool call:`,e),e instanceof Error?e:Error(W(`toolApprovalFailed`))}},[U]),lt=(0,V.useCallback)(async e=>{let t=U.current;if(!t)throw Error(W(`toolApprovalFailed`));try{await t.rejectToolCall(e)}catch(e){throw B.error(`Failed to reject tool call:`,e),e instanceof Error?e:Error(W(`toolApprovalFailed`))}},[U]),ut=(0,V.useCallback)(async e=>{let t=U.current;if(!t?.approveAutoCompact)throw Error(W(`toolApprovalFailed`));await t.approveAutoCompact(e)},[U]),dt=(0,V.useCallback)(async e=>{let t=U.current;if(!t?.rejectAutoCompact)throw Error(W(`toolApprovalFailed`));await t.rejectAutoCompact(e)},[U]),{loadSession:ft,renameSession:pt,togglePinSession:mt,deleteSession:gt,startNewGlobalSession:_t}=Ns({storageRef:e,taskMapRef:Ve,currentSessionIdRef:He,loadAgentSession:Fe,setCurrentTitleRef:Be,refreshSessions:Oe,closeWorkspacePage:z,startNewGlobalChat:Ze}),{openModelSettings:vt,openDefaultOptionsSettings:Y,activateLiteLlmExampleModel:yt,openCustomModelSelector:bt}=Ts({storageRef:e,activeModelRef:t,agentRef:U,createAgent:Ne,updateCurrentAgentModel:Re,setChatPanelRevision:ze,needsModelSetup:O,setNeedsModelSetup:k,setRestoredDraft:A,notifySettingsChanged:je.notifySettingsChanged}),xt=(0,V.useMemo)(()=>[...ye,...s.flatMap(e=>be(e.id))],[ye,s,be]),St=!!(0,V.useMemo)(()=>{if(H.currentSessionId)return xt.find(e=>e.id===H.currentSessionId)},[H.currentSessionId,xt])?.pinnedAt,wt=Ls(xt),Tt=(0,V.useCallback)(e=>H.taskStatuses[e.id]??wt[e.id]??e.taskStatus??`idle`,[H.taskStatuses,wt]);(0,V.useEffect)(()=>{if(!D.conversationMenuOpen)return;let e=()=>D.setConversationMenuOpen(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[D,D.conversationMenuOpen]),(0,V.useEffect)(()=>{let e=e=>{let t=e.detail,n=typeof t?.command==`string`?t.command.trim():``;n&&(async()=>{(t?.confirm||t?.dangerous)&&!await ct({title:W(`confirmExecuteCommandTitle`),description:t?.dangerous?W(`confirmExecuteDangerousCommand`):W(`confirmExecuteMultipleCommands`),confirmLabel:W(`executeInTerminal`),cancelLabel:W(`cancel`),variant:t?.dangerous?`destructive`:`default`})||(P(!0),F({id:++oe.current,command:n,execute:!0}))})().catch(e=>{B.error(`Failed to execute markdown command:`,e),J(e instanceof Error?e.message:W(`terminalCommandExecuteFailed`))})};return window.addEventListener(`quickforge:execute-markdown-command`,e),()=>window.removeEventListener(`quickforge:execute-markdown-command`,e)},[]);let Et=(0,V.useCallback)(e=>{F(t=>t?.id===e?null:t)},[]),Dt=(0,V.useCallback)(()=>{D.setFirstUseGuideDismissed(!0)},[D]),Ot=(0,V.useCallback)(()=>{let e=H.currentToolProject?.id?W(`firstUseGuideProjectPrompt`):W(`firstUseGuideGeneralPrompt`);navigator.clipboard.writeText(e).then(()=>R({sessionId:H.currentSessionId??``,title:W(`copied`),status:`idle`,message:e})).catch(e=>{B.error(`Failed to copy first-use guide prompt:`,e),J(W(`copyFailed`))})},[R,H.currentSessionId,H.currentToolProject?.id]),kt=!!se&&!D.firstUseGuideDismissed&&!N&&s.length===0&&ye.length===0,jt=(0,V.useCallback)(()=>{let e=H.currentSessionId;e&&(D.setConversationMenuOpen(!1),mt(e))},[H.currentSessionId,mt,D]),Mt=(0,V.useCallback)(()=>{let e=H.currentSessionId;e&&(D.setConversationMenuOpen(!1),pt(e,H.currentTitle))},[H.currentSessionId,H.currentTitle,pt,D]),Nt=(0,V.useCallback)(()=>{D.setConversationMenuOpen(!1),D.setShareDialogOpen(!0)},[D]),{setSkillsDialog:Pt,setMcpServersDialogOpen:Ft,setSidebarOpen:It}=D,Lt=(0,V.useCallback)(()=>{Pt({scope:`global`})},[Pt]),Rt=(0,V.useCallback)(e=>{Pt({scope:`project`,project:e})},[Pt]),zt=(0,V.useCallback)(async e=>{let t=await fetch(`/api/project/${encodeURIComponent(e.id)}/open-in-explorer`,{method:`POST`});if(t.ok)return;let n=await t.json().catch(()=>null);throw Error(n?.error||W(`openInExplorerFailed`))},[]),Bt=(0,V.useCallback)(()=>{Ft(!0)},[Ft]),Vt=(0,V.useCallback)(e=>{zt(e).catch(e=>{B.error(`Failed to open project in explorer:`,e),J(e instanceof Error?e.message:W(`openInExplorerFailed`))})},[zt]),Ht=(0,V.useCallback)(()=>M(`scheduledTasks`),[M]),Ut=(0,V.useCallback)(()=>M(`agentProfiles`),[M]),Wt=(0,V.useCallback)(()=>M(`plugins`),[M]),Gt=(0,V.useCallback)(()=>It(e=>!e),[It]),X=(0,V.useCallback)(()=>{D.setMobileSidebarOpen(!1)},[D]),Kt=(0,V.useCallback)(e=>{X(),ft(e)},[X,ft]),qt=(0,V.useCallback)(()=>{X(),_t()},[X,_t]),Jt=(0,V.useCallback)(e=>{X(),Qe(e)},[X,Qe]),Yt=(0,V.useCallback)(()=>{X(),M(`scheduledTasks`)},[X]),Xt=(0,V.useCallback)(()=>{X(),M(`agentProfiles`)},[X]),Zt=(0,V.useCallback)(()=>{X(),Lt()},[X,Lt]),tn=(0,V.useCallback)(()=>{X(),D.setMcpServersDialogOpen(!0)},[X,D]),nn=(0,V.useCallback)(e=>{X(),Rt(e)},[X,Rt]),rn=(0,V.useCallback)(e=>{if(e.scope===`project`&&e.project&&e.projects){x(e.projects),D.setSkillsDialog({scope:`project`,project:e.project}),a.current?.id===e.project.id&&(b(e.project),a.current=e.project),je.notifyProjectsChanged();return}je.notifyProjectsChanged()},[je,b,x,D]),an=(0,K.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-muted-foreground`,children:W(`loadingChatWorkspace`)});return Ye?(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,K.jsxs)(`div`,{className:`max-w-md rounded-lg border border-border bg-card p-5 shadow-sm text-center`,children:[(0,K.jsx)(`h1`,{className:`text-base font-semibold`,children:W(`localServiceUnavailableTitle`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:Ye}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,K.jsx)(q,{variant:`outline`,size:`sm`,onClick:Xe,children:W(`retry`)}),(0,K.jsx)(q,{variant:`default`,size:`sm`,onClick:()=>window.location.reload(),children:W(`reloadPage`)})]})]})}):!Je||!H.agent&&!O?(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background text-foreground`,children:(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:W(`loadingChatWorkspace`)})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex h-screen min-h-0 bg-background text-foreground`,children:[(0,K.jsx)(Ta,{sidebarOpen:D.sidebarOpen,scheduledTasksActive:fe,agentProfilesActive:pe,pluginsActive:me,projectsCollapsed:D.projectsCollapsed,conversationsCollapsed:D.conversationsCollapsed,projects:s,expandedProjectIds:c,activeProject:o,currentSessionId:H.currentSessionId,globalSessions:ye,sessionsForProject:be,globalHasMore:xe,globalLoading:Ce,onLoadMoreGlobal:ke,projectHasMore:Se,projectLoading:we,projectLoaded:Te,onLoadMoreProject:Ae,sessionTaskStatus:Tt,selectingProject:l,onToggleProjectsCollapsed:D.toggleProjectsCollapsed,onToggleConversationsCollapsed:D.toggleConversationsCollapsed,onToggleProjectExpanded:_,onToggleAllProjectsExpanded:v,onReorderProjects:y,onSelectProjectDirectory:h,onStartNewProjectChat:Qe,onOpenGlobalSkills:Lt,onOpenMcpServers:Bt,onOpenProjectSkills:Rt,onOpenProjectInExplorer:Vt,onDeleteProject:at,onLoadSession:ft,onTogglePinSession:mt,onRenameSession:pt,onDeleteSession:gt,onStartNewGlobalChat:_t,onOpenScheduledTasks:Ht,onOpenAgentProfiles:Ut,onOpenPlugins:Wt,onOpenSettings:Y,onToggleSidebar:Gt,currentSessionHoverInfo:re}),D.mobileSidebarOpen?(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 md:hidden`,role:`dialog`,"aria-modal":`true`,children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-background/65 backdrop-blur-sm`,onClick:X,"aria-label":W(`toggleSidebar`)}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 left-0 max-w-[85vw] shadow-2xl`,children:(0,K.jsx)(Ta,{variant:`mobile`,sidebarOpen:!0,scheduledTasksActive:fe,agentProfilesActive:pe,pluginsActive:me,projectsCollapsed:D.projectsCollapsed,conversationsCollapsed:D.conversationsCollapsed,projects:s,expandedProjectIds:c,activeProject:o,currentSessionId:H.currentSessionId,globalSessions:ye,sessionsForProject:be,globalHasMore:xe,globalLoading:Ce,onLoadMoreGlobal:ke,projectHasMore:Se,projectLoading:we,projectLoaded:Te,onLoadMoreProject:Ae,sessionTaskStatus:Tt,selectingProject:l,onToggleProjectsCollapsed:D.toggleProjectsCollapsed,onToggleConversationsCollapsed:D.toggleConversationsCollapsed,onToggleProjectExpanded:_,onToggleAllProjectsExpanded:v,onReorderProjects:y,onSelectProjectDirectory:()=>{X(),h()},onStartNewProjectChat:Jt,onOpenGlobalSkills:Zt,onOpenMcpServers:tn,onOpenProjectSkills:nn,onOpenProjectInExplorer:e=>{X(),zt(e).catch(e=>{B.error(`Failed to open project in explorer:`,e),J(e instanceof Error?e.message:W(`openInExplorerFailed`))})},onDeleteProject:at,onLoadSession:Kt,onTogglePinSession:mt,onRenameSession:pt,onDeleteSession:gt,onStartNewGlobalChat:qt,onOpenScheduledTasks:Yt,onOpenAgentProfiles:Xt,onOpenPlugins:()=>{X(),M(`plugins`)},onOpenSettings:()=>{X(),Y()},onToggleSidebar:X,currentSessionHoverInfo:re})})]}):null,(0,K.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:()=>D.setMobileSidebarOpen(!0),"aria-label":W(`toggleSidebar`),children:(0,K.jsx)(n,{className:`size-4`})}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:fe?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`AI Workspace`}),(0,K.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:W(`scheduledTasks`)})]}):pe?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`AI Workspace`}),(0,K.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:W(`agentsTab`)})]}):me?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`AI Workspace`}),(0,K.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:W(`plugins`)})]}):(0,K.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center`,children:[H.currentToolProject?.name?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm font-semibold text-muted-foreground/72`,children:H.currentToolProject.name}),(0,K.jsx)(`div`,{className:`mx-1 shrink-0 text-sm text-muted-foreground/45`,children:`/`})]}):null,(0,K.jsx)(`div`,{className:`min-w-0 truncate text-sm font-semibold`,children:Qt(H.currentTitle)}),(0,K.jsxs)(`div`,{className:`relative ml-0.5 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:()=>D.setConversationMenuOpen(e=>!e),disabled:!H.currentSessionId||O,"aria-label":W(`moreOptions`),"aria-expanded":D.conversationMenuOpen,children:(0,K.jsx)(r,{className:`size-4`})}),D.conversationMenuOpen?(0,K.jsxs)(`div`,{className:`absolute left-0 top-8 z-30 min-w-44 rounded-lg border border-border bg-card p-1 shadow-xl`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:jt,children:[St?(0,K.jsx)(L,{className:`size-4`}):(0,K.jsx)(ae,{className:`size-4`}),(0,K.jsx)(`span`,{children:W(St?`unpinSession`:`pinSession`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:Mt,children:[(0,K.jsx)(S,{className:`size-4`}),(0,K.jsx)(`span`,{children:W(`renameSession`)})]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted`,onClick:Nt,children:[(0,K.jsx)(ie,{className:`size-4`}),(0,K.jsx)(`span`,{children:W(`shareSession`)})]})]}):null]})]})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>D.setWorkspaceInspectorOpen(e=>!e),disabled:!H.currentToolProject?.id||he||O,"aria-label":`Workspace`,title:`Workspace`,className:`hidden lg:inline-flex`,children:(0,K.jsx)(m,{className:`size-4`})}),(0,K.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>P(e=>!e),disabled:he||O,"aria-label":`终端`,title:`终端`,className:N?`bg-accent text-accent-foreground`:void 0,children:(0,K.jsx)(te,{className:`size-4`})})]}),(0,K.jsx)(`section`,{className:`relative flex min-h-0 flex-1 flex-col`,children:fe?(0,K.jsx)(V.Suspense,{fallback:an,children:(0,K.jsx)(cc,{onOpenSession:We})}):pe?(0,K.jsx)(V.Suspense,{fallback:an,children:(0,K.jsx)(lc,{})}):me?(0,K.jsx)(V.Suspense,{fallback:an,children:(0,K.jsx)(uc,{})}):O?(0,K.jsx)(en,{onAddModel:vt,onUseExample:()=>{yt().catch(e=>B.error(`Failed to use LiteLLM example:`,e))}}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,K.jsx)(et,{children:(0,K.jsx)(V.Suspense,{fallback:(0,K.jsx)(mc,{}),children:(0,K.jsx)(oc,{agent:H.agent,onModelSelect:bt,revision:H.chatPanelRevision,yoloMode:w,workspaceToolsEnabled:!!H.currentToolProject?.id,project:H.currentToolProject,projectId:H.currentToolProject?.id,chatScope:H.chatScope,storage:se,onToggleYoloMode:ot,onRollbackFromMessage:G,onRetryFromMessage:$e,onCopyAnswer:tt,onForkFromMessage:rt,onApproveToolCall:st,onRejectToolCall:lt,onApproveAutoCompact:ut,onRejectAutoCompact:dt,onOpenWorkspaceGitChanges:Ke,onOpenLocalFilePath:qe,onContextUsageDisplayChange:Me,disableFork:!1,restoredDraft:ee})})})}),kt?(0,K.jsx)($t,{hasProject:!!H.currentToolProject?.id,onConfigureModel:vt,onAddProject:h,onCopyExamplePrompt:Ot,onDismiss:Dt}):null,N?(0,K.jsx)(V.Suspense,{fallback:null,children:(0,K.jsx)(sc,{project:H.currentToolProject,pendingCommand:ne,onPendingCommandHandled:Et,onCollapse:()=>P(!1)})}):null]})})]}),D.workspaceInspectorOpen&&H.currentToolProject?.id?(0,K.jsx)(V.Suspense,{fallback:(0,K.jsx)(hc,{}),children:(0,K.jsx)(fc,{project:H.currentToolProject,open:!0,onOpenChange:D.setWorkspaceInspectorOpen,onDraftRequest:Ge,focusTarget:D.workspaceInspectorFocusTarget})}):null,D.inlineReaderOpen?(0,K.jsx)(V.Suspense,{fallback:(0,K.jsx)(hc,{}),children:(0,K.jsx)(pc,{open:!0,mode:`file`,file:D.inlineReaderFile,loading:D.inlineReaderLoading,error:D.inlineReaderError,onOpenChange:D.setInlineReaderOpen,onDraftRequest:Ge})}):null]}),(0,K.jsx)(nt,{open:u,initialPath:o?.path,disabled:l,onOpenChange:g,onSelect:p}),(0,K.jsx)(it,{open:!!D.skillsDialog,scope:D.skillsDialog?.scope??`global`,project:D.skillsDialog?.project,onOpenChange:e=>{e||D.setSkillsDialog(void 0)},onSaved:rn}),(0,K.jsx)(ht,{open:D.mcpServersDialogOpen,onOpenChange:D.setMcpServersDialogOpen}),(0,K.jsx)(Zs,{open:D.shareDialogOpen,sessionId:H.currentSessionId,title:Qt(H.currentTitle),onOpenChange:D.setShareDialogOpen}),(0,K.jsx)(Bs,{toasts:le,onDismiss:de,onClick:We})]})}function bc(){let e=window.location.pathname.match(/^\/share\/([^/]+)\/?$/)?.[1];return e?(0,K.jsx)(V.Suspense,{fallback:(0,K.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background text-sm text-muted-foreground`,children:W(`loadingChatWorkspace`)}),children:(0,K.jsx)(dc,{shareId:decodeURIComponent(e)})}):(0,K.jsx)(yc,{})}Xe({hideSelector:!0}),Qe(),window.addEventListener(`error`,e=>{B.error(`Uncaught error:`,e.error??e.message)}),window.addEventListener(`unhandledrejection`,e=>{B.error(`Unhandled promise rejection:`,e.reason)}),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`).catch(()=>{})}),(0,Ae.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(V.StrictMode,{children:(0,K.jsx)(et,{children:(0,K.jsx)(bc,{})})}));export{vt as C,G as D,q as E,W as O,X as S,ct as T,Fa as _,Js as a,Pt as b,ws as c,Ja as d,qa as f,Aa as g,Pa as h,tc as i,fo as l,Ma as m,ic as n,Xs as o,Ka as p,nc as r,Ys as s,ac as t,Ga as u,It as v,J as w,zt as x,Gt as y};