@shawnstack/quickforge 1.7.2 → 1.7.3
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.
- package/README.md +1 -0
- package/bin/quickforge.mjs +2 -0
- package/dist/assets/{AgentProfilesPage-BFgyFa5e.js → AgentProfilesPage-D7pbg8nm.js} +1 -1
- package/dist/assets/{ChatPanelHost-Cld9HcVz.js → ChatPanelHost-wfGCaCzD.js} +62 -62
- package/dist/assets/{PluginsPage-DEMqwhOA.js → PluginsPage-NAGroBm3.js} +1 -1
- package/dist/assets/{ScheduledTasksPage-DTP_gedp.js → ScheduledTasksPage-Bp0MNfQD.js} +2 -2
- package/dist/assets/{SettingsWorkspacePage-Dr9zT5Bs.js → SettingsWorkspacePage-BtJZMIsZ.js} +350 -269
- package/dist/assets/{SharedConversationPage-op3DRwcw.js → SharedConversationPage-Ce3KoVZt.js} +1 -1
- package/dist/assets/{TerminalDock-BL_UovwU.js → TerminalDock-4eUuXP7X.js} +2 -2
- package/dist/assets/WorkspaceInspector-kM3BRPjY.js +13 -0
- package/dist/assets/{index-yV1wtqTr.js → index-C6k5taeb.js} +8 -8
- package/dist/assets/index-CzN8NSKC.css +3 -0
- package/dist/assets/{mcp-servers-dialog-Bp6kbIup.js → mcp-servers-dialog-BQbFywVL.js} +2 -2
- package/dist/assets/{skills-dialog-DiJAUfvW.js → skills-dialog-REBeTFSH.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +4 -1
- package/server/ai-http-logger.mjs +6 -6
- package/server/ai-provider-options.mjs +8 -0
- package/server/index.mjs +7 -2
- package/server/network-proxy.mjs +384 -0
- package/server/public-api.mjs +4 -0
- package/server/routes/agent-profiles.mjs +2 -0
- package/server/routes/models.mjs +1 -0
- package/server/routes/scheduled-tasks.mjs +2 -0
- package/server/routes/system.mjs +26 -0
- package/server/routes/workspace.mjs +2 -0
- package/server/session-utils.mjs +2 -0
- package/dist/assets/WorkspaceInspector-73dhAime.js +0 -13
- package/dist/assets/index-Cu2bBHLv.css +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatPanelHost-
|
|
2
|
-
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{At as t,B as n,C as r,Ct as i,D as a,Dt as o,F as s,G as c,H as l,I as u,J as d,K as f,Mt as p,Nt as m,O as h,Ot as g,P as _,Pt as v,S as y,St as b,T as x,Tt as S,V as C,X as w,Y as T,Z as E,_ as D,_t as O,a as k,b as ee,bt as A,c as j,d as te,dt as M,et as N,f as P,ft as F,ht as I,i as L,it as R,k as ne,l as z,lt as re,m as B,n as ie,o as ae,p as oe,pt as se,q as ce,s as le,st as ue,vt as de,w as fe,wt as pe,x as me,xt as he,yt as ge,z as _e}from"./icons-BP8YOS-Z.js";import{i as ve,n as ye,r as be,t as xe}from"./react-vendor-Dr5xvL-e.js";import{f as Se,p as Ce,u as we}from"./lit-vendor-Dr3cpBGF.js";import{n as Te,r as Ee,t as De}from"./css-utils-rkE68RDy.js";import{C as Oe,D as ke,E as Ae,S as je,T as Me,b as Ne,d as Pe,f as Fe,p as Ie,u as Le,w as Re}from"./pi-web-ui-DoRGtREc.js";import{J as ze,U as Be,W as Ve}from"./pi-ai-Cr3rpCXT.js";import{t as V}from"./logger-B65Akg8A.js";import{t as He}from"./skills-dialog-DiJAUfvW.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 H=e(v(),1),Ue=be(),We=`language`,Ge=[`en`,`zh`],Ke={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`,startNewChat:`Start new chat`,newChatEmptyTitle:`What do you want to get done today?`,chooseProject:`Select project`,searchProjects:`Search projects`,newProject:`Add project`,createBlankProject:`Add project`,useExistingFolder:`Select project directory`,useNoProject:`No project`,noMatchingProjects:`No matching projects`,loadingChatWorkspace:`Loading chat workspace...`,loadingConversation:`Loading conversation...`,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`,pinnedConversations:`Pinned`,noConversations:`No conversations`,filterSort:`Filter and sort`,sidebarView:`View`,sidebarViewByProject:`By project`,sidebarViewTimeline:`Timeline`,sortBy:`Sort by`,sortByUpdatedAt:`Updated time`,sortByCreatedAt:`Created time`,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.`,deleteSessionFailed:`Failed to delete conversation.`,archiveSession:`Archive conversation`,confirmArchive:`Archive`,archivedConversations:`Archived conversations`,archivedConversationsDescription:`Archived conversations are hidden from the sidebar. Restore them here or delete them permanently.`,searchArchivedConversations:`Search archived conversations`,noArchivedConversations:`No archived conversations yet.`,archivedAt:`Archived at`,lastModified:`Last modified`,restoreSession:`Restore`,restoreSessionFailed:`Failed to restore conversation.`,sessionRestored:`Conversation restored.`,sessionNotFound:`Conversation not found.`,deletePermanently:`Delete`,deleteAll:`Delete all`,deleteArchivedSessionConfirm:`Permanently delete "{title}"? This cannot be undone.`,deleteAllArchivedSessionsConfirm:`Permanently delete all archived conversations? This cannot be undone.`,archivedSessionDeleted:`Archived conversation deleted.`,archivedSessionsDeleted:`Archived conversations deleted.`,allProjects:`All projects`,unknownProject:`Unknown project`,conversationCount:`{count} conversations`,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`,svgDisplayMode:`SVG display mode`,svgPreviewMode:`Preview`,svgSourceMode:`Source`,svgEnlargePreview:`Click to enlarge SVG preview`,copySvgSource:`Copy SVG source`,downloadSvg:`Download SVG`,mermaidPreviewLabel:`Mermaid diagram preview`,mermaidEnlargePreview:`Click to enlarge Mermaid diagram`,copyMermaidSource:`Copy Mermaid source`,downloadMermaidSvg:`Download Mermaid SVG`,mermaidRendering:`Rendering Mermaid diagram...`,mermaidRenderFailed:`Could not render this Mermaid diagram. Source is shown instead.`,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`,agentAccessMenuLabel:`Agent access mode`,agentAccessDefaultLabel:`Default permissions`,agentAccessFullLabel:`Full access`,agentAccessDefaultTitle:`Default permissions: work inside the current repository; ask before actions that may affect the system.`,agentAccessFullTitle:`Full access: developer-level authorization; tools can run automatically within the configured workspace boundaries.`,agentAccessModeSyncFailed:`Failed to sync Agent access mode.`,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 do`,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`,initCommandDescription:`Generate or update a concise AGENTS.md contributor guide for the current repository.`,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.`,summaryCommandDescription:`Create a new chat with this conversation summarized to reduce context usage.`,compactCommandDescription:`Compact this conversation context in place using the same rolling summary as auto-compaction.`,clearCommandDescription:`Clear the current chat history and context without calling the model.`,helpCommandDescription:`Show all available commands and their usage.`,yoloBlockedReason:`Local tool {name} was blocked by the current Agent permission mode. Switch to Full access or approve the tool call when prompted.`,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:`General`,defaultOptionsDescription:`Configure language, default model, thinking level, tool display, and context management for new chats and scheduled tasks.`,memory:`Memory`,memoryDescription:`Let QuickForge remember useful preferences and habits across chats and projects.`,globalMemory:`Global memory`,globalMemoryDescription:`When enabled, QuickForge uses existing memory and can proactively remember durable preferences, habits, background, workflows, and goals that may help in future conversations.`,globalMemoryInfo:`Memory is stored locally and shared by all chats and projects. QuickForge avoids temporary task details, uncertain inferences, and sensitive credentials. Turn memory off to stop future reads and writes while keeping the existing file.`,memoryFile:`Memory file`,memoryFileDescription:`Saved as a readable Markdown file in the local QuickForge data directory.`,memoryCurrentSessionNote:`Changes are loaded by running chats before their next message. Turning memory off stops future reads and writes while keeping the existing file.`,memoryEnabledSaved:`Global memory enabled.`,memoryDisabledSaved:`Global memory disabled. Existing memory was kept.`,memoryContent:`Memory content`,memoryContentDescription:`View or edit the complete free-form Markdown document. Content and formatting are saved exactly as written.`,memoryContentDisabledDescription:`Turn global memory on to edit and save this file. Existing content remains available after reloading.`,memoryReload:`Reload`,memorySave:`Save memory`,memoryReloaded:`Memory reloaded.`,memoryContentSaved:`Global memory saved.`,memoryContentEmpty:`Global user memory is empty.`,defaultModel:`Default model`,defaultModelDescription:`Used by new chats and scheduled tasks unless overridden.`,defaultThinkingLevel:`Default thinking level`,defaultThinkingLevelDescription:`Choose the default reasoning effort for supported models.`,toolDisplay:`Tool display`,toolDisplayModeDescription:`Compact shows summaries with details collapsed. Detailed shows full parameters and details with tool calls expanded.`,toolDisplayCompact:`Compact`,toolDisplayDetailed:`Detailed`,showContextUsage:`Show context usage`,showContextUsageDescription:`Show the context usage ring and details next to the model selector.`,fontSize:`Font size`,fontSizeDescription:`Adjust interface and conversation text size.`,fontSizeRangeDescription:`Drag to preview immediately; release to save.`,appearance:`Appearance`,appearanceDescription:`Customize the interface theme and font size.`,theme:`Theme`,themeDescription:`Switch between light and dark. Changes apply instantly.`,lightTheme:`Light`,darkTheme:`Dark`,appearanceSaved:`Appearance saved`,interfaceFontSize:`Interface font size`,messageFontSize:`Conversation font size`,messageFontSizeNote:`Applies to the main text in chat messages.`,fontSizeSaved:`Font size saved`,toolDetailsHidden:`Tool details are hidden in compact mode. Switch Tool display to Detailed in Settings to view full parameters.`,toolArgsSummary:`Arguments summary`,saveDefaultOptions:`Save defaults`,saving:`Saving...`,defaultOptionsSaved:`Default options saved`,contextManagement:`Context Management`,contextUsageTitle:`Context usage`,contextUsageAriaLabel:`Context usage: {percent}%. Show details`,contextUsageTotal:`{used} / {limit} tokens`,contextUsageInputLabel:`Input / context`,contextUsageReservedOutputLabel:`Reserved output`,contextUsageSystemPromptLabel:`System prompt`,contextUsageToolsSchemaLabel:`Tools schema`,contextUsageMessagesLabel:`Messages`,contextUsageSourceServerShort:`Server calculated`,contextUsageSourceLocalShort:`Local estimate`,contextUsageScopeCompactedShort:`Compacted model context`,contextUsageScopeFullShort:`Full model context`,contextUsageUsed:`Context used: {percent}% ({used} / {limit} tokens)`,contextUsageInput:`Input/context: {tokens} ({source})`,contextUsageSourceProvider:`provider context`,contextUsageSourceMixed:`provider/local mixed context`,contextUsageSourceEstimated:`estimated context`,contextUsageLocalEstimate:`Local estimate: {tokens}`,contextUsageSystemPrompt:` System prompt: {tokens}`,contextUsageToolsSchema:` Tools schema: {tokens}`,contextUsageMessages:` Messages: {tokens}`,contextUsageProviderBaseline:` Provider usage baseline: {tokens}`,contextUsageTrailingMessages:` Trailing messages after usage: {tokens}`,contextUsageReservedOutput:`Reserved output: {tokens}`,contextUsageServerCalculated:`Source: server calculated via pi-agent-core/pi-ai`,contextUsageScopeCompacted:`Scope: compacted model context, not full visible chat history`,contextUsageScopeFull:`Scope: full model context`,contextUsageEffectiveMessages:`Messages: {effective} effective / {visible} visible`,contextUsageProviderTokens:`Provider context tokens: {tokens}`,autoCompactEnabled:`Automatically compact context`,autoCompactRequireConfirmation:`Ask before compacting automatically`,autoCompactRequireConfirmationDescription:`Ask for approval before QuickForge summarizes older history.`,autoCompactTriggerNote:`Checks run before each model request. Lower the threshold or reduce the model Context Window to test triggering.`,autoCompactThresholdPercent:`Compact when context reaches (%)`,autoCompactThresholdDescription:`Percentage of the model context window that triggers compaction.`,autoCompactKeepRecentTurns:`Keep recent user turns`,autoCompactKeepRecentTurnsDescription:`Recent turns stay in full detail after older context is summarized.`,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.`,autoArchiveEnabled:`Automatically archive old conversations`,autoArchiveTriggerNote:`Conversations not updated for more than 30 days are moved to Archived conversations.`,autoArchiveDescription:`Archived conversations are not deleted. Turning this off only stops future automatic archiving; existing archived conversations can still be viewed and restored.`,autoArchiveSaved:`Automatic archive setting saved`,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:`{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatPanelHost-wfGCaCzD.js","assets/rolldown-runtime-DWdDZTNf.js","assets/pi-web-ui-DoRGtREc.js","assets/pi-ai-Cr3rpCXT.js","assets/lit-vendor-Dr3cpBGF.js","assets/icons-BP8YOS-Z.js","assets/react-vendor-Dr5xvL-e.js","assets/plugin-api-BbUkYm3Y.js","assets/logger-B65Akg8A.js","assets/mermaid-renderer-BmbSAmpG.js","assets/SharedConversationPage-Ce3KoVZt.js","assets/WorkspaceInspector-kM3BRPjY.js","assets/monaco-BTsVCDWS.js","assets/TerminalDock-4eUuXP7X.js","assets/xterm-CGiQzDiR.js","assets/xterm-BrP-ENHg.css","assets/SettingsWorkspacePage-BtJZMIsZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{At as t,B as n,C as r,Ct as i,D as a,Dt as o,F as s,G as c,H as l,I as u,J as d,K as f,Mt as p,Nt as m,O as h,Ot as g,P as _,Pt as v,S as y,St as b,T as x,Tt as S,V as C,X as w,Y as T,Z as E,_ as D,_t as O,a as k,b as ee,bt as A,c as j,d as te,dt as M,et as N,f as P,ft as F,ht as I,i as L,it as R,k as ne,l as z,lt as re,m as B,n as ie,o as ae,p as oe,pt as se,q as ce,s as le,st as ue,vt as de,w as fe,wt as pe,x as me,xt as he,yt as ge,z as _e}from"./icons-BP8YOS-Z.js";import{i as ve,n as ye,r as be,t as xe}from"./react-vendor-Dr5xvL-e.js";import{f as Se,p as Ce,u as we}from"./lit-vendor-Dr3cpBGF.js";import{n as Te,r as Ee,t as De}from"./css-utils-rkE68RDy.js";import{C as Oe,D as ke,E as Ae,S as je,T as Me,b as Ne,d as Pe,f as Fe,p as Ie,u as Le,w as Re}from"./pi-web-ui-DoRGtREc.js";import{J as ze,U as Be,W as Ve}from"./pi-ai-Cr3rpCXT.js";import{t as V}from"./logger-B65Akg8A.js";import{t as He}from"./skills-dialog-REBeTFSH.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 H=e(v(),1),Ue=be(),We=`language`,Ge=[`en`,`zh`],Ke={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`,startNewChat:`Start new chat`,newChatEmptyTitle:`What do you want to get done today?`,chooseProject:`Select project`,searchProjects:`Search projects`,newProject:`Add project`,createBlankProject:`Add project`,useExistingFolder:`Select project directory`,useNoProject:`No project`,noMatchingProjects:`No matching projects`,loadingChatWorkspace:`Loading chat workspace...`,loadingConversation:`Loading conversation...`,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`,pinnedConversations:`Pinned`,noConversations:`No conversations`,filterSort:`Filter and sort`,sidebarView:`View`,sidebarViewByProject:`By project`,sidebarViewTimeline:`Timeline`,sortBy:`Sort by`,sortByUpdatedAt:`Updated time`,sortByCreatedAt:`Created time`,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.`,deleteSessionFailed:`Failed to delete conversation.`,archiveSession:`Archive conversation`,confirmArchive:`Archive`,archivedConversations:`Archived conversations`,archivedConversationsDescription:`Archived conversations are hidden from the sidebar. Restore them here or delete them permanently.`,searchArchivedConversations:`Search archived conversations`,noArchivedConversations:`No archived conversations yet.`,archivedAt:`Archived at`,lastModified:`Last modified`,restoreSession:`Restore`,restoreSessionFailed:`Failed to restore conversation.`,sessionRestored:`Conversation restored.`,sessionNotFound:`Conversation not found.`,deletePermanently:`Delete`,deleteAll:`Delete all`,deleteArchivedSessionConfirm:`Permanently delete "{title}"? This cannot be undone.`,deleteAllArchivedSessionsConfirm:`Permanently delete all archived conversations? This cannot be undone.`,archivedSessionDeleted:`Archived conversation deleted.`,archivedSessionsDeleted:`Archived conversations deleted.`,allProjects:`All projects`,unknownProject:`Unknown project`,conversationCount:`{count} conversations`,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`,svgDisplayMode:`SVG display mode`,svgPreviewMode:`Preview`,svgSourceMode:`Source`,svgEnlargePreview:`Click to enlarge SVG preview`,copySvgSource:`Copy SVG source`,downloadSvg:`Download SVG`,mermaidPreviewLabel:`Mermaid diagram preview`,mermaidEnlargePreview:`Click to enlarge Mermaid diagram`,copyMermaidSource:`Copy Mermaid source`,downloadMermaidSvg:`Download Mermaid SVG`,mermaidRendering:`Rendering Mermaid diagram...`,mermaidRenderFailed:`Could not render this Mermaid diagram. Source is shown instead.`,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`,agentAccessMenuLabel:`Agent access mode`,agentAccessDefaultLabel:`Default permissions`,agentAccessFullLabel:`Full access`,agentAccessDefaultTitle:`Default permissions: work inside the current repository; ask before actions that may affect the system.`,agentAccessFullTitle:`Full access: developer-level authorization; tools can run automatically within the configured workspace boundaries.`,agentAccessModeSyncFailed:`Failed to sync Agent access mode.`,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 do`,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`,initCommandDescription:`Generate or update a concise AGENTS.md contributor guide for the current repository.`,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.`,summaryCommandDescription:`Create a new chat with this conversation summarized to reduce context usage.`,compactCommandDescription:`Compact this conversation context in place using the same rolling summary as auto-compaction.`,clearCommandDescription:`Clear the current chat history and context without calling the model.`,helpCommandDescription:`Show all available commands and their usage.`,yoloBlockedReason:`Local tool {name} was blocked by the current Agent permission mode. Switch to Full access or approve the tool call when prompted.`,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:`General`,defaultOptionsDescription:`Configure language, default model, thinking level, tool display, and context management for new chats and scheduled tasks.`,memory:`Memory`,memoryDescription:`Let QuickForge remember useful preferences and habits across chats and projects.`,globalMemory:`Global memory`,globalMemoryDescription:`When enabled, QuickForge uses existing memory and can proactively remember durable preferences, habits, background, workflows, and goals that may help in future conversations.`,globalMemoryInfo:`Memory is stored locally and shared by all chats and projects. QuickForge avoids temporary task details, uncertain inferences, and sensitive credentials. Turn memory off to stop future reads and writes while keeping the existing file.`,memoryFile:`Memory file`,memoryFileDescription:`Saved as a readable Markdown file in the local QuickForge data directory.`,memoryCurrentSessionNote:`Changes are loaded by running chats before their next message. Turning memory off stops future reads and writes while keeping the existing file.`,memoryEnabledSaved:`Global memory enabled.`,memoryDisabledSaved:`Global memory disabled. Existing memory was kept.`,memoryContent:`Memory content`,memoryContentDescription:`View or edit the complete free-form Markdown document. Content and formatting are saved exactly as written.`,memoryContentDisabledDescription:`Turn global memory on to edit and save this file. Existing content remains available after reloading.`,memoryReload:`Reload`,memorySave:`Save memory`,memoryReloaded:`Memory reloaded.`,memoryContentSaved:`Global memory saved.`,memoryContentEmpty:`Global user memory is empty.`,defaultModel:`Default model`,defaultModelDescription:`Used by new chats and scheduled tasks unless overridden.`,defaultThinkingLevel:`Default thinking level`,defaultThinkingLevelDescription:`Choose the default reasoning effort for supported models.`,toolDisplay:`Tool display`,toolDisplayModeDescription:`Compact shows summaries with details collapsed. Detailed shows full parameters and details with tool calls expanded.`,toolDisplayCompact:`Compact`,toolDisplayDetailed:`Detailed`,showContextUsage:`Show context usage`,showContextUsageDescription:`Show the context usage ring and details next to the model selector.`,fontSize:`Font size`,fontSizeDescription:`Adjust interface and conversation text size.`,fontSizeRangeDescription:`Drag to preview immediately; release to save.`,appearance:`Appearance`,appearanceDescription:`Customize the interface theme and font size.`,theme:`Theme`,themeDescription:`Switch between light and dark. Changes apply instantly.`,lightTheme:`Light`,darkTheme:`Dark`,appearanceSaved:`Appearance saved`,interfaceFontSize:`Interface font size`,messageFontSize:`Conversation font size`,messageFontSizeNote:`Applies to the main text in chat messages.`,fontSizeSaved:`Font size saved`,toolDetailsHidden:`Tool details are hidden in compact mode. Switch Tool display to Detailed in Settings to view full parameters.`,toolArgsSummary:`Arguments summary`,saveDefaultOptions:`Save defaults`,saving:`Saving...`,defaultOptionsSaved:`Default options saved`,networkConnection:`Network connection`,networkProxyMode:`Proxy mode`,networkProxyDirect:`Direct`,networkProxySystem:`Follow system`,networkProxyManual:`Manual proxy`,networkProxyDescription:`Controls supported external HTTP requests made by QuickForge. Localhost always connects directly. Follow system reads the actual operating-system proxy configuration, including PAC/WPAD when supported; it does not use proxy environment variables.`,networkProxyAddress:`Proxy address`,networkProxyAddressDescription:`Enter an HTTP or HTTPS proxy URL with a port. Paths, query strings, fragments, and proxy credentials are not supported.`,networkProxyAddressRequired:`Enter a proxy address before saving.`,networkProxyAddressInvalid:`Enter a valid HTTP or HTTPS proxy address.`,networkProxyAddressProtocolError:`Only HTTP and HTTPS proxy addresses are supported.`,networkProxyAddressPortError:`The proxy address must include a host and port.`,networkProxyAddressCredentialsError:`Proxy credentials are not supported in the address.`,networkProxyAddressPathError:`The proxy address cannot contain a path, query string, or fragment.`,networkProxySave:`Save proxy`,networkProxyRefresh:`Reload system proxy`,networkProxyRefreshDescription:`Reload the current operating-system proxy configuration and close existing network connections.`,networkProxyStatus:`Source: {source}; runtime: {runtime}.`,networkProxyUnsupported:`The operating-system proxy is not supported by this runtime.`,networkProxyLoadFailed:`Unable to load the current proxy configuration. Proxy controls are disabled.`,networkProxySaved:`Network proxy setting saved`,networkProxyRefreshed:`System proxy reloaded`,contextManagement:`Context Management`,contextUsageTitle:`Context usage`,contextUsageAriaLabel:`Context usage: {percent}%. Show details`,contextUsageTotal:`{used} / {limit} tokens`,contextUsageInputLabel:`Input / context`,contextUsageReservedOutputLabel:`Reserved output`,contextUsageSystemPromptLabel:`System prompt`,contextUsageToolsSchemaLabel:`Tools schema`,contextUsageMessagesLabel:`Messages`,contextUsageSourceServerShort:`Server calculated`,contextUsageSourceLocalShort:`Local estimate`,contextUsageScopeCompactedShort:`Compacted model context`,contextUsageScopeFullShort:`Full model context`,contextUsageUsed:`Context used: {percent}% ({used} / {limit} tokens)`,contextUsageInput:`Input/context: {tokens} ({source})`,contextUsageSourceProvider:`provider context`,contextUsageSourceMixed:`provider/local mixed context`,contextUsageSourceEstimated:`estimated context`,contextUsageLocalEstimate:`Local estimate: {tokens}`,contextUsageSystemPrompt:` System prompt: {tokens}`,contextUsageToolsSchema:` Tools schema: {tokens}`,contextUsageMessages:` Messages: {tokens}`,contextUsageProviderBaseline:` Provider usage baseline: {tokens}`,contextUsageTrailingMessages:` Trailing messages after usage: {tokens}`,contextUsageReservedOutput:`Reserved output: {tokens}`,contextUsageServerCalculated:`Source: server calculated via pi-agent-core/pi-ai`,contextUsageScopeCompacted:`Scope: compacted model context, not full visible chat history`,contextUsageScopeFull:`Scope: full model context`,contextUsageEffectiveMessages:`Messages: {effective} effective / {visible} visible`,contextUsageProviderTokens:`Provider context tokens: {tokens}`,autoCompactEnabled:`Automatically compact context`,autoCompactRequireConfirmation:`Ask before compacting automatically`,autoCompactRequireConfirmationDescription:`Ask for approval before QuickForge summarizes older history.`,autoCompactTriggerNote:`Checks run before each model request. Lower the threshold or reduce the model Context Window to test triggering.`,autoCompactThresholdPercent:`Compact when context reaches (%)`,autoCompactThresholdDescription:`Percentage of the model context window that triggers compaction.`,autoCompactKeepRecentTurns:`Keep recent user turns`,autoCompactKeepRecentTurnsDescription:`Recent turns stay in full detail after older context is summarized.`,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.`,autoArchiveEnabled:`Automatically archive old conversations`,autoArchiveTriggerNote:`Conversations not updated for more than 30 days are moved to Archived conversations.`,autoArchiveDescription:`Archived conversations are not deleted. Turning this off only stops future automatic archiving; existing archived conversations can still be viewed and restored.`,autoArchiveSaved:`Automatic archive setting saved`,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
3
|
"X-Custom-Header": "value"
|
|
4
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.)`,imageInputModel:`Image input / vision model`,imageInputModelHelp:`Enable only when the model documentation confirms image input support. When disabled, attached images are omitted before the request is sent so non-vision models do not fail.`,providerProtocol:`Protocol`,model:`Model`,reasoning:`Reasoning`,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`,back:`Back`,more:`More`,searchModels:`Search models...`,searchSettings:`Search settings...`,noSettingsResults:`No matching settings found`,noMatchingCustomModels:`No matching custom models`,presets:`Quick templates`,presetOpenai:`OpenAI`,presetDeepseek:`DeepSeek`,presetGlm:`Zhipu GLM`,presetOllama:`Local Ollama`,presetLitellm:`LiteLLM Proxy`,presetCustom:`Custom`,providerAdvanced:`Advanced options`,expandModel:`Adjust context window, max tokens, reasoning, image input`,addHeader:`Add header`,headerName:`Header name`,headerValue:`Value`,removeHeader:`Remove header`,testConnection:`Test connection`,testingConnection:`Testing...`,connectionOk:`Connection OK`,connectionFailed:`Connection failed`,testRequiresFields:`Fill in Base URL and at least one model ID.`,readFile:`Read File`,manageGlobalMemory:`Manage Memory`,searchFiles:`Search Files`,writeFile:`Write File`,editFile:`Edit File`,runCommand:`Run Command`,presentFiles:`Present Files`,generateImage:`Generate Image`,generatingImage:`Generating image...`,generatedImageAlt:`Generated image {index}`,openGeneratedImage:`Open generated image`,downloadGeneratedImage:`Download generated image`,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 Agent access 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.`,builtinAgentModelSettings:`Model settings`,builtinAgentModelOnly:`This built-in Agent is system-managed. Only its model can be changed.`,readonlyAgentDescription:`This Agent is loaded from a read-only source and cannot be edited here.`,enabledAsSubagent:`Enabled as subagent`,enableAsSubagent:`Enable as subagent`,disableAsSubagent:`Disable 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`,agentModelMode:`Model mode`,agentModelInherit:`Inherit parent model`,agentModelFixed:`Use fixed model`,agentFixedModel:`Fixed model`,agentThinkingLevel:`Thinking level`,agentThinkingInherit:`Inherit caller setting`,agentThinkingDescription:`When the runtime model does not support reasoning, this automatically falls back to Off.`,agentThinkingUnsupported:`The selected fixed model does not support reasoning, so thinking is Off.`,allowedTools:`Allowed tools`,agentSourcePath:`Source path`,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`,mcpNoServersDescription:`No MCP servers configured yet. Click "Add server" or paste an mcpServers JSON on the right.`,mcpConfiguredServers:`Configured servers`,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`,mcpLoadFailed:`Failed to load MCP servers.`,mcpSaveFailed:`Failed to save MCP server.`,mcpDeleteFailed:`Failed to delete MCP server.`,mcpReconnectFailed:`Failed to reconnect MCP server.`,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.`,mcpHeaders:`Headers, KEY=value per line`,mcpReconnectServer:`Reconnect`,mcpMoreTools:`+{count}`,mcpNamePlaceholder:`e.g. my-server`,mcpUrlPlaceholder:`https://example.com/mcp`,mcpCommandPlaceholder:`e.g. npx`,mcpTabServer:`Server`,mcpTabJson:`JSON`,optional:`Optional`,globalSkills:`Global Skills`,projectSkills:`Project Skills`,help:`Help`,projectCommands:`Project Commands`,projectCommandsDescription:`Configure extra Markdown slash-command directories for the current project. QuickForge also reads user-level commands from ~/.quickforge/commands/ (shared across all projects), then project directories .claude/commands, .opencode/commands, .ai/commands, and these configured directories in order. Later duplicate command names override earlier ones.`,projectCommandsProjectDescription:`Choose the project whose command directories should be configured.`,selectProjectForCommands:`Please select or add a project before configuring project commands.`,commandDirectory:`Command directory`,commandDirectories:`Command directories`,commandDirectoriesDescription:`Add one directory per line. Relative paths are resolved from the selected project root.`,commandDirectoryPlaceholder:`.claude/commands
|
|
5
5
|
.opencode/commands
|
|
@@ -9,7 +9,7 @@ Changed files:
|
|
|
9
9
|
{list}`,workspaceCommitMessagePrompt:`Please generate a concise Conventional Commit message for the current Git changes. Include a one-line subject and an optional short body if useful.
|
|
10
10
|
|
|
11
11
|
Changed files:
|
|
12
|
-
{list}`,unknown:`Unknown`,webPreview:`Web Preview`,artifactPreview:`Artifacts`,artifactPreviewFiles:`Show artifact files`,artifactPreviewEmpty:`No artifact files to preview.`,artifactPreviewLoadFailed:`Failed to load artifact preview.`,artifactPreviewUnsupported:`Preview unavailable for this file`,artifactPreviewUnsupportedDescription:`This file type cannot be displayed in the browser preview. Open it in a supported app or use the Reader when available.`,previewChecking:`Checking preview...`,previewErrorNotFoundTitle:`File not found`,previewErrorNotFoundDescription:`The file may have been deleted, moved, or renamed. Check the path and try again.`,previewErrorTooLargeTitle:`File is too large to preview`,previewErrorTooLargeDescription:`This file exceeds the browser preview size limit. Open it with another application.`,previewErrorPermissionTitle:`Unable to access this file`,previewErrorPermissionDescription:`The path is restricted or QuickForge does not have permission to read it.`,previewErrorServiceTitle:`Preview service unavailable`,previewErrorServiceDescription:`QuickForge could not prepare this preview. Check the local service and try again.`,previewErrorUnknownTitle:`Unable to preview this file`,previewErrorUnknownDescription:`An unexpected error occurred while preparing the preview. You can retry or inspect the details below.`,previewErrorDetails:`Error details`,previewErrorStatusCode:`Status code`,previewErrorCode:`Error code`,previewErrorFilePath:`File path`,previewErrorRawMessage:`Original error`,artifactPreviewViewSource:`View source`,artifactPreviewPin:`Pin artifact tools`,artifactPreviewUnpin:`Unpin artifact tools`,artifacts:`Artifacts`,previewArtifact:`Preview artifact`,previewUrl:`Preview URL`,previewUrlPlaceholder:`Enter URL`,openPreview:`Open`,refreshPreview:`Refresh preview`,openInBrowser:`Open in browser`,zoom:`Zoom`,zoomIn:`Zoom in`,zoomOut:`Zoom out`,resetZoom:`Reset zoom`,invalidPreviewUrl:`Please enter a valid http:// or https:// URL.`,noPreviewUrlTitle:`Start browsing`,noPreviewUrlDescription:`Enter a URL to open a page.`,workspaceStatusAdded:`Added`,workspaceStatusDeleted:`Deleted`,workspaceStatusRenamed:`Renamed`,workspaceStatusUntracked:`Untracked`,workspaceStatusConflict:`Conflict`,workspaceStatusModified:`Modified`,copyPath:`Copy path`,copyContent:`Copy content`,copyFileContent:`Copy file content`,copyDiffContent:`Copy diff content`,readerMoreActions:`More file actions`,readerOpen:`Open`,enableWordWrap:`Enable word wrap`,showFileNavigation:`Show file navigation`,hideFileNavigation:`Hide file navigation`,askAiAboutThis:`Ask AI about this`,readerFileMarkdownPrompt:"Please read the Markdown document `{path}` in the current workspace. Summarize its purpose, key sections, important instructions, outdated or risky parts, and suggest concise improvements.",readerFilePrompt:"Please inspect `{path}` in the current workspace and explain its role, important implementation details, and any risks or improvement opportunities.",readerDiffPrompt:"Please review the working-tree changes in `{path}`. Summarize what changed, point out possible bugs or regressions, and suggest focused verification steps.",openingReader:`Opening...`,markdownPreview:`Preview`,markdownSource:`Source`,viewMarkdownSource:`View source`,returnToMarkdownPreview:`Back to preview`,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`,lanAccessEnabledDescription:`Whether full access from LAN devices is currently enabled.`,lanAccessPassword:`Access password`,lanAccessPasswordStatusDescription:`Password status for LAN sign-in.`,lanAccessActiveDevices:`Unlocked devices`,lanAccessActiveDevicesDescription:`Devices with an active LAN access session.`,lanAccessUrls:`LAN URLs`,lanAccessUrlsDescription:`Open one of these addresses from another trusted device on this network.`,lanAccessAllowFull:`Allow LAN devices to access full QuickForge`,lanAccessAllowFullDescription:`Enable only on trusted networks; authenticated LAN devices can use the full app.`,lanAccessPasswordPlaceholder:`At least 8 characters`,lanAccessPasswordPlaceholderConfigured:`Leave empty to keep current password`,lanAccessSessionTtl:`Login validity`,lanAccessSessionTtlDescription:`How long a LAN device stays signed in after entering the password.`,lanAccessActions:`Actions`,lanAccessActionsDescription:`Save access settings or sign out all LAN devices.`,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`,processExecuted:`Executed`,processExecuting:`Executing`,processGroupToolsCalled:`{count} tool calls`,processGroupCommandsRan:`{count} commands`,processGroupFilesEdited:`Edited {count} files`,processFailed:`Failed`,processAborted:`Aborted`,processDurationSeconds:`{seconds}s`,processDurationMinutesSeconds:`{minutes}m {seconds}s`,processThinking:`Thinking process`,processCommandsRan:`Ran {count} commands`,processFilesEdited:`Edited {count} files`,processToolsCalled:`Called {count} tools`,processToolsFailedCount:`{count} failed`,expandProcess:`Expand processing details`,collapseProcess:`Collapse processing details`,expandProcessTools:`Expand tool activity`,collapseProcessTools:`Collapse tool activity`,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:`新建对话`,startNewChat:`新对话`,newChatEmptyTitle:`今天想推进什么?`,chooseProject:`选择项目`,searchProjects:`搜索项目`,newProject:`添加项目`,createBlankProject:`添加项目`,useExistingFolder:`选择项目目录`,useNoProject:`无项目`,noMatchingProjects:`没有匹配的项目`,loadingChatWorkspace:`正在加载聊天工作区...`,loadingConversation:`正在加载对话...`,localServiceUnavailableTitle:`QuickForge 本地服务不可用`,localServiceUnavailableDescription:`QuickForge 需要通过本地服务进行存储。请使用 npm run dev 或 quickforge 命令启动后刷新此页面。`,project:`项目`,projects:`项目`,loadingProject:`正在加载项目...`,addProject:`添加项目`,noProjects:`暂无项目。`,expandProject:`展开项目`,collapseProject:`折叠项目`,expandAllProjects:`展开所有项目`,collapseAllProjects:`折叠所有项目`,dragToReorder:`拖拽排序`,newProjectChat:`新建项目对话`,projectChat:`项目对话`,normalChat:`普通对话`,conversations:`对话`,pinnedConversations:`置顶`,noConversations:`暂无对话`,filterSort:`筛选与排序`,sidebarView:`视图`,sidebarViewByProject:`按项目`,sidebarViewTimeline:`时间线`,sortBy:`排序方式`,sortByUpdatedAt:`更新时间`,sortByCreatedAt:`创建时间`,filter:`筛选`,selecting:`选择中...`,chooseFolder:`选择文件夹`,selectProjectDirectory:`选择项目目录`,selectProjectDirectoryDescription:`浏览本地文件夹或粘贴路径,然后选择一个文件夹作为项目。`,quickAccess:`快捷入口`,path:`路径`,go:`前往`,parentDirectory:`上级目录`,noFolders:`该目录下没有文件夹。`,selectThisFolder:`选择此文件夹`,folderPickerPathPlaceholder:`输入或粘贴文件夹路径`,filesystemRootsFailed:`加载文件系统入口失败。`,directoryLoadFailed:`加载目录失败。`,noSavedConversations:`暂无保存的对话。`,deleteProject:`删除项目`,deleteProjectConfirm:`确定要删除项目「{name}」吗?该项目的对话记录将保留。`,deleteSession:`删除会话`,deleteSessionConfirm:`确定要删除该对话吗?删除后不可恢复。`,deleteSessionFailed:`删除对话失败。`,archiveSession:`归档对话`,confirmArchive:`确认归档`,archivedConversations:`已归档对话`,archivedConversationsDescription:`已归档的对话会从侧边栏隐藏,你可以在这里恢复或永久删除。`,searchArchivedConversations:`搜索已归档对话`,noArchivedConversations:`暂无已归档对话。`,archivedAt:`归档时间`,lastModified:`最后更新`,restoreSession:`恢复`,restoreSessionFailed:`恢复对话失败。`,sessionRestored:`对话已恢复。`,sessionNotFound:`未找到该对话。`,deletePermanently:`删除`,deleteAll:`全部删除`,deleteArchivedSessionConfirm:`确定要永久删除「{title}」吗?此操作不可恢复。`,deleteAllArchivedSessionsConfirm:`确定要永久删除所有已归档对话吗?此操作不可恢复。`,archivedSessionDeleted:`已归档对话已删除。`,archivedSessionsDeleted:`已归档对话已删除。`,allProjects:`所有项目`,unknownProject:`未知项目`,conversationCount:`{count} 个对话`,confirm:`确认`,confirmDelete:`确认删除`,rename:`重命名`,renameSession:`重命名对话`,sessionName:`对话名称`,settings:`设置`,toggleSidebar:`切换侧边栏`,failedToSelectProjectDirectory:`选择项目目录失败。`,projectSwitchFailed:`切换到该对话绑定的项目失败,工作区工具未启动。`,copy:`复制`,copied:`已复制`,svgDisplayMode:`SVG 显示模式`,svgPreviewMode:`预览`,svgSourceMode:`源码`,svgEnlargePreview:`点击放大 SVG 预览`,copySvgSource:`复制 SVG 源码`,downloadSvg:`下载 SVG`,mermaidPreviewLabel:`Mermaid 图表预览`,mermaidEnlargePreview:`点击放大 Mermaid 图表`,copyMermaidSource:`复制 Mermaid 源码`,downloadMermaidSvg:`下载 Mermaid SVG`,mermaidRendering:`正在渲染 Mermaid 图表...`,mermaidRenderFailed:`无法渲染此 Mermaid 图表,已保留源码。`,rollback:`回滚`,retry:`重试`,reloadPage:`刷新页面`,fork:`分支`,forkConversation:`从此处分支新对话`,yoloEnabledTitle:`工作区授权已开启:本地工具可使用当前项目`,yoloDisabledTitle:`工作区授权已锁定:本地工具已阻止`,agentAccessMenuLabel:`Agent 权限模式`,agentAccessDefaultLabel:`默认权限`,agentAccessFullLabel:`完全访问权限`,agentAccessDefaultTitle:`默认权限:仅在当前代码仓库内工作,可能影响系统的操作需要确认。`,agentAccessFullTitle:`完全访问权限:等同开发者授权,工具可在既有工作区边界内自动执行。`,agentAccessModeSyncFailed:`同步 Agent 权限模式失败。`,planModeLabel:`计划`,planModeEnabledTitle:`计划模式已开启:下一条消息会按 /plan 发送。点击可移除。快捷键:Shift+Tab`,planModeDisabledTitle:`计划模式:下一条消息按 /plan 发送。快捷键:Shift+Tab`,composerPlaceholder:`描述你想做的事`,assistantWaitingThinking:`正在思考`,assistantWaitingOrganizing:`正在整理答案`,assistantWaitingContinuing:`内容较多,正在继续处理`,assistantWaitingAriaLabel:`AI 正在准备回复`,customCommandsHint:`自定义指令`,customCommandsEmptyHint:`还没有项目指令。`,customCommandsListDescription:`列出项目自定义指令`,customCommandsNewDescription:`创建项目自定义指令`,initCommandDescription:`为当前仓库生成或更新简洁的 AGENTS.md 贡献者指南。`,planCommandDescription:`先生成计划;本轮禁止编辑文件或运行命令。`,reviewCommandDescription:`提交前自检待提交代码;本轮禁止编辑文件。`,summaryCommandDescription:`基于当前对话创建总结后的新对话,减少上下文占用。`,compactCommandDescription:`在当前对话内压缩上下文,使用与自动压缩一致的滚动摘要。`,clearCommandDescription:`清除当前对话历史和上下文,不调用模型。`,helpCommandDescription:`显示所有可用命令及其用法。`,yoloBlockedReason:`本地工具 {name} 已被当前 Agent 权限模式阻止。请切换到完全访问权限,或在弹出审批时确认该工具调用。`,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:`配置界面语言,以及新建对话和定时任务默认使用的模型、思考等级、工具展示和上下文管理。`,memory:`记忆`,memoryDescription:`让 QuickForge 跨对话和项目记住有用的偏好与习惯。`,globalMemory:`全局记忆`,globalMemoryDescription:`开启后,QuickForge 会使用已有记忆,并可从对话中主动记住对未来有帮助的长期偏好、习惯、背景、工作方式和目标。`,globalMemoryInfo:`记忆保存在本机,并由所有对话和项目共享。QuickForge 会避开临时任务细节、不确定推断和敏感凭据。关闭记忆后停止后续读取和写入,但保留已有文件。`,memoryFile:`记忆文件`,memoryFileDescription:`以可读的 Markdown 文件保存在本机 QuickForge 数据目录中。`,memoryCurrentSessionNote:`修改会在运行中对话发送下一条消息前加载。关闭后停止后续读取和写入,但保留已有文件。`,memoryEnabledSaved:`全局记忆已开启。`,memoryDisabledSaved:`全局记忆已关闭,已有记忆已保留。`,memoryContent:`记忆内容`,memoryContentDescription:`查看或编辑完整的自由 Markdown 文档,内容和格式会按原文保存。`,memoryContentDisabledDescription:`开启全局记忆后才能编辑和保存。关闭时仍可重新加载查看已有内容。`,memoryReload:`重新加载`,memorySave:`保存记忆`,memoryReloaded:`记忆已重新加载。`,memoryContentSaved:`全局记忆已保存。`,memoryContentEmpty:`全局用户记忆为空。`,defaultModel:`默认模型`,defaultModelDescription:`新建对话和定时任务默认使用的模型,可在具体场景中覆盖。`,defaultThinkingLevel:`默认思考等级`,defaultThinkingLevelDescription:`为支持 reasoning 的模型选择默认思考强度。`,toolDisplay:`Tool 显示模式`,toolDisplayModeDescription:`简洁模式显示摘要并默认收起详情;详细模式显示完整参数和 details,并默认展开 Tool 调用。`,toolDisplayCompact:`简洁`,toolDisplayDetailed:`详细`,showContextUsage:`显示上下文用量`,showContextUsageDescription:`在模型选择器旁显示上下文用量圆环及详情。`,fontSize:`字号`,fontSizeDescription:`调整界面和对话文字大小。`,fontSizeRangeDescription:`拖动时即时预览,松开后保存。`,appearance:`外观`,appearanceDescription:`自定义界面的主题和字号。`,theme:`主题`,themeDescription:`在浅色和深色之间切换,即时生效。`,lightTheme:`浅色`,darkTheme:`深色`,appearanceSaved:`外观已保存`,interfaceFontSize:`界面字号`,messageFontSize:`对话字号`,messageFontSizeNote:`应用到聊天消息里的主要正文。`,fontSizeSaved:`字号已保存`,toolDetailsHidden:`简洁模式已隐藏 Tool 详细信息。可在设置中将“Tool 显示模式”切换为“详细”查看完整参数。`,toolArgsSummary:`参数摘要`,saveDefaultOptions:`保存默认选项`,saving:`保存中...`,defaultOptionsSaved:`默认选项已保存`,contextManagement:`上下文管理`,contextUsageTitle:`上下文用量`,contextUsageAriaLabel:`上下文已使用 {percent}%,查看详情`,contextUsageTotal:`{used} / {limit} tokens`,contextUsageInputLabel:`输入 / 上下文`,contextUsageReservedOutputLabel:`预留输出`,contextUsageSystemPromptLabel:`系统提示词`,contextUsageToolsSchemaLabel:`工具定义`,contextUsageMessagesLabel:`消息`,contextUsageSourceServerShort:`服务端计算`,contextUsageSourceLocalShort:`本地估算`,contextUsageScopeCompactedShort:`压缩后模型上下文`,contextUsageScopeFullShort:`完整模型上下文`,contextUsageUsed:`上下文已使用:{percent}%({used} / {limit} tokens)`,contextUsageInput:`输入/上下文:{tokens}({source})`,contextUsageSourceProvider:`提供商上下文`,contextUsageSourceMixed:`提供商/本地混合上下文`,contextUsageSourceEstimated:`本地估算上下文`,contextUsageLocalEstimate:`本地估算:{tokens}`,contextUsageSystemPrompt:` 系统提示词:{tokens}`,contextUsageToolsSchema:` 工具定义:{tokens}`,contextUsageMessages:` 消息:{tokens}`,contextUsageProviderBaseline:` 提供商用量基线:{tokens}`,contextUsageTrailingMessages:` 用量基线后的消息:{tokens}`,contextUsageReservedOutput:`预留输出:{tokens}`,contextUsageServerCalculated:`数据来源:服务端通过 pi-agent-core/pi-ai 计算`,contextUsageScopeCompacted:`统计范围:模型压缩后的上下文,不是界面中可见的完整聊天历史`,contextUsageScopeFull:`统计范围:完整模型上下文`,contextUsageEffectiveMessages:`消息:{effective} 条有效 / {visible} 条可见`,contextUsageProviderTokens:`提供商上下文 Token:{tokens}`,autoCompactEnabled:`自动压缩上下文`,autoCompactRequireConfirmation:`自动压缩前先询问确认`,autoCompactRequireConfirmationDescription:`在 QuickForge 总结较早历史前先请求确认。`,autoCompactTriggerNote:`系统会在每次请求模型前检查。测试时可降低阈值,或调小模型 Context Window。`,autoCompactThresholdPercent:`上下文达到多少百分比时压缩`,autoCompactThresholdDescription:`触发压缩的模型上下文窗口占比。`,autoCompactKeepRecentTurns:`保留最近用户回合数`,autoCompactKeepRecentTurnsDescription:`较早上下文总结后,最近回合仍保留完整内容。`,autoCompactDescription:`当预计下一次请求达到模型上下文窗口的指定比例时,QuickForge 会总结较早历史并继续当前任务。该过程会额外消耗一次模型调用。`,autoCompactHistoryPreserved:`完整聊天历史仍会保留在界面中;只有发送给模型的上下文会被压缩。`,autoArchiveEnabled:`自动归档历史对话`,autoArchiveTriggerNote:`最后更新超过 30 天的对话会移入“已归档对话”。`,autoArchiveDescription:`归档不会删除对话。关闭后只停止后续自动归档,已有归档仍可查看和恢复。`,autoArchiveSaved:`自动归档设置已保存`,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:`{
|
|
12
|
+
{list}`,unknown:`Unknown`,webPreview:`Web Preview`,artifactPreview:`Artifacts`,artifactPreviewFiles:`Show artifact files`,artifactPreviewEmpty:`No artifact files to preview.`,artifactPreviewLoadFailed:`Failed to load artifact preview.`,artifactPreviewUnsupported:`Preview unavailable for this file`,artifactPreviewUnsupportedDescription:`This file type cannot be displayed in the browser preview. Open it in a supported app or use the Reader when available.`,previewChecking:`Checking preview...`,previewErrorNotFoundTitle:`File not found`,previewErrorNotFoundDescription:`The file may have been deleted, moved, or renamed. Check the path and try again.`,previewErrorTooLargeTitle:`File is too large to preview`,previewErrorTooLargeDescription:`This file exceeds the browser preview size limit. Open it with another application.`,previewErrorPermissionTitle:`Unable to access this file`,previewErrorPermissionDescription:`The path is restricted or QuickForge does not have permission to read it.`,previewErrorServiceTitle:`Preview service unavailable`,previewErrorServiceDescription:`QuickForge could not prepare this preview. Check the local service and try again.`,previewErrorUnknownTitle:`Unable to preview this file`,previewErrorUnknownDescription:`An unexpected error occurred while preparing the preview. You can retry or inspect the details below.`,previewErrorDetails:`Error details`,previewErrorStatusCode:`Status code`,previewErrorCode:`Error code`,previewErrorFilePath:`File path`,previewErrorRawMessage:`Original error`,artifactPreviewViewSource:`View source`,artifactPreviewPin:`Pin artifact tools`,artifactPreviewUnpin:`Unpin artifact tools`,artifacts:`Artifacts`,previewArtifact:`Preview artifact`,previewUrl:`Preview URL`,previewUrlPlaceholder:`Enter URL`,openPreview:`Open`,refreshPreview:`Refresh preview`,openInBrowser:`Open in browser`,zoom:`Zoom`,zoomIn:`Zoom in`,zoomOut:`Zoom out`,resetZoom:`Reset zoom`,invalidPreviewUrl:`Please enter a valid http:// or https:// URL.`,noPreviewUrlTitle:`Start browsing`,noPreviewUrlDescription:`Enter a URL to open a page.`,workspaceStatusAdded:`Added`,workspaceStatusDeleted:`Deleted`,workspaceStatusRenamed:`Renamed`,workspaceStatusUntracked:`Untracked`,workspaceStatusConflict:`Conflict`,workspaceStatusModified:`Modified`,copyPath:`Copy path`,copyContent:`Copy content`,copyFileContent:`Copy file content`,copyDiffContent:`Copy diff content`,readerMoreActions:`More file actions`,readerOpen:`Open`,enableWordWrap:`Enable word wrap`,showFileNavigation:`Show file navigation`,hideFileNavigation:`Hide file navigation`,askAiAboutThis:`Ask AI about this`,readerFileMarkdownPrompt:"Please read the Markdown document `{path}` in the current workspace. Summarize its purpose, key sections, important instructions, outdated or risky parts, and suggest concise improvements.",readerFilePrompt:"Please inspect `{path}` in the current workspace and explain its role, important implementation details, and any risks or improvement opportunities.",readerDiffPrompt:"Please review the working-tree changes in `{path}`. Summarize what changed, point out possible bugs or regressions, and suggest focused verification steps.",openingReader:`Opening...`,markdownPreview:`Preview`,markdownSource:`Source`,viewMarkdownSource:`View source`,returnToMarkdownPreview:`Back to preview`,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`,lanAccessEnabledDescription:`Whether full access from LAN devices is currently enabled.`,lanAccessPassword:`Access password`,lanAccessPasswordStatusDescription:`Password status for LAN sign-in.`,lanAccessActiveDevices:`Unlocked devices`,lanAccessActiveDevicesDescription:`Devices with an active LAN access session.`,lanAccessUrls:`LAN URLs`,lanAccessUrlsDescription:`Open one of these addresses from another trusted device on this network.`,lanAccessAllowFull:`Allow LAN devices to access full QuickForge`,lanAccessAllowFullDescription:`Enable only on trusted networks; authenticated LAN devices can use the full app.`,lanAccessPasswordPlaceholder:`At least 8 characters`,lanAccessPasswordPlaceholderConfigured:`Leave empty to keep current password`,lanAccessSessionTtl:`Login validity`,lanAccessSessionTtlDescription:`How long a LAN device stays signed in after entering the password.`,lanAccessActions:`Actions`,lanAccessActionsDescription:`Save access settings or sign out all LAN devices.`,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`,processExecuted:`Executed`,processExecuting:`Executing`,processGroupToolsCalled:`{count} tool calls`,processGroupCommandsRan:`{count} commands`,processGroupFilesEdited:`Edited {count} files`,processFailed:`Failed`,processAborted:`Aborted`,processDurationSeconds:`{seconds}s`,processDurationMinutesSeconds:`{minutes}m {seconds}s`,processThinking:`Thinking process`,processCommandsRan:`Ran {count} commands`,processFilesEdited:`Edited {count} files`,processToolsCalled:`Called {count} tools`,processToolsFailedCount:`{count} failed`,expandProcess:`Expand processing details`,collapseProcess:`Collapse processing details`,expandProcessTools:`Expand tool activity`,collapseProcessTools:`Collapse tool activity`,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:`新建对话`,startNewChat:`新对话`,newChatEmptyTitle:`今天想推进什么?`,chooseProject:`选择项目`,searchProjects:`搜索项目`,newProject:`添加项目`,createBlankProject:`添加项目`,useExistingFolder:`选择项目目录`,useNoProject:`无项目`,noMatchingProjects:`没有匹配的项目`,loadingChatWorkspace:`正在加载聊天工作区...`,loadingConversation:`正在加载对话...`,localServiceUnavailableTitle:`QuickForge 本地服务不可用`,localServiceUnavailableDescription:`QuickForge 需要通过本地服务进行存储。请使用 npm run dev 或 quickforge 命令启动后刷新此页面。`,project:`项目`,projects:`项目`,loadingProject:`正在加载项目...`,addProject:`添加项目`,noProjects:`暂无项目。`,expandProject:`展开项目`,collapseProject:`折叠项目`,expandAllProjects:`展开所有项目`,collapseAllProjects:`折叠所有项目`,dragToReorder:`拖拽排序`,newProjectChat:`新建项目对话`,projectChat:`项目对话`,normalChat:`普通对话`,conversations:`对话`,pinnedConversations:`置顶`,noConversations:`暂无对话`,filterSort:`筛选与排序`,sidebarView:`视图`,sidebarViewByProject:`按项目`,sidebarViewTimeline:`时间线`,sortBy:`排序方式`,sortByUpdatedAt:`更新时间`,sortByCreatedAt:`创建时间`,filter:`筛选`,selecting:`选择中...`,chooseFolder:`选择文件夹`,selectProjectDirectory:`选择项目目录`,selectProjectDirectoryDescription:`浏览本地文件夹或粘贴路径,然后选择一个文件夹作为项目。`,quickAccess:`快捷入口`,path:`路径`,go:`前往`,parentDirectory:`上级目录`,noFolders:`该目录下没有文件夹。`,selectThisFolder:`选择此文件夹`,folderPickerPathPlaceholder:`输入或粘贴文件夹路径`,filesystemRootsFailed:`加载文件系统入口失败。`,directoryLoadFailed:`加载目录失败。`,noSavedConversations:`暂无保存的对话。`,deleteProject:`删除项目`,deleteProjectConfirm:`确定要删除项目「{name}」吗?该项目的对话记录将保留。`,deleteSession:`删除会话`,deleteSessionConfirm:`确定要删除该对话吗?删除后不可恢复。`,deleteSessionFailed:`删除对话失败。`,archiveSession:`归档对话`,confirmArchive:`确认归档`,archivedConversations:`已归档对话`,archivedConversationsDescription:`已归档的对话会从侧边栏隐藏,你可以在这里恢复或永久删除。`,searchArchivedConversations:`搜索已归档对话`,noArchivedConversations:`暂无已归档对话。`,archivedAt:`归档时间`,lastModified:`最后更新`,restoreSession:`恢复`,restoreSessionFailed:`恢复对话失败。`,sessionRestored:`对话已恢复。`,sessionNotFound:`未找到该对话。`,deletePermanently:`删除`,deleteAll:`全部删除`,deleteArchivedSessionConfirm:`确定要永久删除「{title}」吗?此操作不可恢复。`,deleteAllArchivedSessionsConfirm:`确定要永久删除所有已归档对话吗?此操作不可恢复。`,archivedSessionDeleted:`已归档对话已删除。`,archivedSessionsDeleted:`已归档对话已删除。`,allProjects:`所有项目`,unknownProject:`未知项目`,conversationCount:`{count} 个对话`,confirm:`确认`,confirmDelete:`确认删除`,rename:`重命名`,renameSession:`重命名对话`,sessionName:`对话名称`,settings:`设置`,toggleSidebar:`切换侧边栏`,failedToSelectProjectDirectory:`选择项目目录失败。`,projectSwitchFailed:`切换到该对话绑定的项目失败,工作区工具未启动。`,copy:`复制`,copied:`已复制`,svgDisplayMode:`SVG 显示模式`,svgPreviewMode:`预览`,svgSourceMode:`源码`,svgEnlargePreview:`点击放大 SVG 预览`,copySvgSource:`复制 SVG 源码`,downloadSvg:`下载 SVG`,mermaidPreviewLabel:`Mermaid 图表预览`,mermaidEnlargePreview:`点击放大 Mermaid 图表`,copyMermaidSource:`复制 Mermaid 源码`,downloadMermaidSvg:`下载 Mermaid SVG`,mermaidRendering:`正在渲染 Mermaid 图表...`,mermaidRenderFailed:`无法渲染此 Mermaid 图表,已保留源码。`,rollback:`回滚`,retry:`重试`,reloadPage:`刷新页面`,fork:`分支`,forkConversation:`从此处分支新对话`,yoloEnabledTitle:`工作区授权已开启:本地工具可使用当前项目`,yoloDisabledTitle:`工作区授权已锁定:本地工具已阻止`,agentAccessMenuLabel:`Agent 权限模式`,agentAccessDefaultLabel:`默认权限`,agentAccessFullLabel:`完全访问权限`,agentAccessDefaultTitle:`默认权限:仅在当前代码仓库内工作,可能影响系统的操作需要确认。`,agentAccessFullTitle:`完全访问权限:等同开发者授权,工具可在既有工作区边界内自动执行。`,agentAccessModeSyncFailed:`同步 Agent 权限模式失败。`,planModeLabel:`计划`,planModeEnabledTitle:`计划模式已开启:下一条消息会按 /plan 发送。点击可移除。快捷键:Shift+Tab`,planModeDisabledTitle:`计划模式:下一条消息按 /plan 发送。快捷键:Shift+Tab`,composerPlaceholder:`描述你想做的事`,assistantWaitingThinking:`正在思考`,assistantWaitingOrganizing:`正在整理答案`,assistantWaitingContinuing:`内容较多,正在继续处理`,assistantWaitingAriaLabel:`AI 正在准备回复`,customCommandsHint:`自定义指令`,customCommandsEmptyHint:`还没有项目指令。`,customCommandsListDescription:`列出项目自定义指令`,customCommandsNewDescription:`创建项目自定义指令`,initCommandDescription:`为当前仓库生成或更新简洁的 AGENTS.md 贡献者指南。`,planCommandDescription:`先生成计划;本轮禁止编辑文件或运行命令。`,reviewCommandDescription:`提交前自检待提交代码;本轮禁止编辑文件。`,summaryCommandDescription:`基于当前对话创建总结后的新对话,减少上下文占用。`,compactCommandDescription:`在当前对话内压缩上下文,使用与自动压缩一致的滚动摘要。`,clearCommandDescription:`清除当前对话历史和上下文,不调用模型。`,helpCommandDescription:`显示所有可用命令及其用法。`,yoloBlockedReason:`本地工具 {name} 已被当前 Agent 权限模式阻止。请切换到完全访问权限,或在弹出审批时确认该工具调用。`,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:`配置界面语言,以及新建对话和定时任务默认使用的模型、思考等级、工具展示和上下文管理。`,memory:`记忆`,memoryDescription:`让 QuickForge 跨对话和项目记住有用的偏好与习惯。`,globalMemory:`全局记忆`,globalMemoryDescription:`开启后,QuickForge 会使用已有记忆,并可从对话中主动记住对未来有帮助的长期偏好、习惯、背景、工作方式和目标。`,globalMemoryInfo:`记忆保存在本机,并由所有对话和项目共享。QuickForge 会避开临时任务细节、不确定推断和敏感凭据。关闭记忆后停止后续读取和写入,但保留已有文件。`,memoryFile:`记忆文件`,memoryFileDescription:`以可读的 Markdown 文件保存在本机 QuickForge 数据目录中。`,memoryCurrentSessionNote:`修改会在运行中对话发送下一条消息前加载。关闭后停止后续读取和写入,但保留已有文件。`,memoryEnabledSaved:`全局记忆已开启。`,memoryDisabledSaved:`全局记忆已关闭,已有记忆已保留。`,memoryContent:`记忆内容`,memoryContentDescription:`查看或编辑完整的自由 Markdown 文档,内容和格式会按原文保存。`,memoryContentDisabledDescription:`开启全局记忆后才能编辑和保存。关闭时仍可重新加载查看已有内容。`,memoryReload:`重新加载`,memorySave:`保存记忆`,memoryReloaded:`记忆已重新加载。`,memoryContentSaved:`全局记忆已保存。`,memoryContentEmpty:`全局用户记忆为空。`,defaultModel:`默认模型`,defaultModelDescription:`新建对话和定时任务默认使用的模型,可在具体场景中覆盖。`,defaultThinkingLevel:`默认思考等级`,defaultThinkingLevelDescription:`为支持 reasoning 的模型选择默认思考强度。`,toolDisplay:`Tool 显示模式`,toolDisplayModeDescription:`简洁模式显示摘要并默认收起详情;详细模式显示完整参数和 details,并默认展开 Tool 调用。`,toolDisplayCompact:`简洁`,toolDisplayDetailed:`详细`,showContextUsage:`显示上下文用量`,showContextUsageDescription:`在模型选择器旁显示上下文用量圆环及详情。`,fontSize:`字号`,fontSizeDescription:`调整界面和对话文字大小。`,fontSizeRangeDescription:`拖动时即时预览,松开后保存。`,appearance:`外观`,appearanceDescription:`自定义界面的主题和字号。`,theme:`主题`,themeDescription:`在浅色和深色之间切换,即时生效。`,lightTheme:`浅色`,darkTheme:`深色`,appearanceSaved:`外观已保存`,interfaceFontSize:`界面字号`,messageFontSize:`对话字号`,messageFontSizeNote:`应用到聊天消息里的主要正文。`,fontSizeSaved:`字号已保存`,toolDetailsHidden:`简洁模式已隐藏 Tool 详细信息。可在设置中将“Tool 显示模式”切换为“详细”查看完整参数。`,toolArgsSummary:`参数摘要`,saveDefaultOptions:`保存默认选项`,saving:`保存中...`,defaultOptionsSaved:`默认选项已保存`,networkConnection:`网络连接`,networkProxyMode:`代理模式`,networkProxyDirect:`直连`,networkProxySystem:`跟随系统`,networkProxyManual:`手动代理`,networkProxyDescription:`控制 QuickForge 自身受支持的外部 HTTP 请求,本地地址始终直连。“跟随系统”会读取操作系统真实代理配置,并在系统支持时处理 PAC/WPAD;不会使用代理环境变量冒充系统代理。`,networkProxyAddress:`代理地址`,networkProxyAddressDescription:`填写包含端口的 HTTP 或 HTTPS 代理地址。不支持路径、查询参数、片段和代理账号密码。`,networkProxyAddressRequired:`请先填写代理地址。`,networkProxyAddressInvalid:`请输入有效的 HTTP 或 HTTPS 代理地址。`,networkProxyAddressProtocolError:`仅支持 HTTP 和 HTTPS 代理地址。`,networkProxyAddressPortError:`代理地址必须包含主机和端口。`,networkProxyAddressCredentialsError:`代理地址暂不支持账号密码。`,networkProxyAddressPathError:`代理地址不能包含路径、查询参数或片段。`,networkProxySave:`保存代理`,networkProxyRefresh:`重新读取系统代理`,networkProxyRefreshDescription:`重新读取操作系统当前代理配置,并关闭已有网络连接。`,networkProxyStatus:`来源:{source};运行环境:{runtime}。`,networkProxyUnsupported:`当前运行环境不支持读取操作系统代理。`,networkProxyLoadFailed:`无法读取当前代理配置,代理控件已禁用。`,networkProxySaved:`网络代理设置已保存`,networkProxyRefreshed:`已重新读取系统代理`,contextManagement:`上下文管理`,contextUsageTitle:`上下文用量`,contextUsageAriaLabel:`上下文已使用 {percent}%,查看详情`,contextUsageTotal:`{used} / {limit} tokens`,contextUsageInputLabel:`输入 / 上下文`,contextUsageReservedOutputLabel:`预留输出`,contextUsageSystemPromptLabel:`系统提示词`,contextUsageToolsSchemaLabel:`工具定义`,contextUsageMessagesLabel:`消息`,contextUsageSourceServerShort:`服务端计算`,contextUsageSourceLocalShort:`本地估算`,contextUsageScopeCompactedShort:`压缩后模型上下文`,contextUsageScopeFullShort:`完整模型上下文`,contextUsageUsed:`上下文已使用:{percent}%({used} / {limit} tokens)`,contextUsageInput:`输入/上下文:{tokens}({source})`,contextUsageSourceProvider:`提供商上下文`,contextUsageSourceMixed:`提供商/本地混合上下文`,contextUsageSourceEstimated:`本地估算上下文`,contextUsageLocalEstimate:`本地估算:{tokens}`,contextUsageSystemPrompt:` 系统提示词:{tokens}`,contextUsageToolsSchema:` 工具定义:{tokens}`,contextUsageMessages:` 消息:{tokens}`,contextUsageProviderBaseline:` 提供商用量基线:{tokens}`,contextUsageTrailingMessages:` 用量基线后的消息:{tokens}`,contextUsageReservedOutput:`预留输出:{tokens}`,contextUsageServerCalculated:`数据来源:服务端通过 pi-agent-core/pi-ai 计算`,contextUsageScopeCompacted:`统计范围:模型压缩后的上下文,不是界面中可见的完整聊天历史`,contextUsageScopeFull:`统计范围:完整模型上下文`,contextUsageEffectiveMessages:`消息:{effective} 条有效 / {visible} 条可见`,contextUsageProviderTokens:`提供商上下文 Token:{tokens}`,autoCompactEnabled:`自动压缩上下文`,autoCompactRequireConfirmation:`自动压缩前先询问确认`,autoCompactRequireConfirmationDescription:`在 QuickForge 总结较早历史前先请求确认。`,autoCompactTriggerNote:`系统会在每次请求模型前检查。测试时可降低阈值,或调小模型 Context Window。`,autoCompactThresholdPercent:`上下文达到多少百分比时压缩`,autoCompactThresholdDescription:`触发压缩的模型上下文窗口占比。`,autoCompactKeepRecentTurns:`保留最近用户回合数`,autoCompactKeepRecentTurnsDescription:`较早上下文总结后,最近回合仍保留完整内容。`,autoCompactDescription:`当预计下一次请求达到模型上下文窗口的指定比例时,QuickForge 会总结较早历史并继续当前任务。该过程会额外消耗一次模型调用。`,autoCompactHistoryPreserved:`完整聊天历史仍会保留在界面中;只有发送给模型的上下文会被压缩。`,autoArchiveEnabled:`自动归档历史对话`,autoArchiveTriggerNote:`最后更新超过 30 天的对话会移入“已归档对话”。`,autoArchiveDescription:`归档不会删除对话。关闭后只停止后续自动归档,已有归档仍可查看和恢复。`,autoArchiveSaved:`自动归档设置已保存`,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:`{
|
|
13
13
|
"X-Custom-Header": "value"
|
|
14
14
|
}`,customHeadersHelp:`可选的提供商级 HTTP Headers。必须是值为字符串的 JSON 对象,会随模型配置保存在本地。`,invalidHeadersJson:`自定义 Headers 必须是有效 JSON 对象,并且键和值都必须是字符串。`,modelId:`模型 ID`,modelIdPlaceholder:`例如:anthropic/claude-sonnet-4`,contextWindow:`Context Window`,maxTokens:`Max Tokens`,reasoningModel:`推理/思考模型(DeepSeek V4、Qwen 等)`,imageInputModel:`图片输入 / 视觉模型`,imageInputModelHelp:`仅在模型文档确认支持图片输入时开启。关闭后,请求发送前会省略附件图片,避免非视觉模型报错。`,providerProtocol:`协议`,model:`模型`,reasoning:`推理`,noModelAdded:`未添加模型`,modelsCount:`{count} 个模型`,modelIndex:`模型 #{index}`,modelsList:`模型列表`,atLeastOneModel:`至少需要一个模型。`,duplicateModelId:`模型 ID 不能重复。`,cancel:`取消`,save:`保存`,yes:`是`,no:`否`,loading:`加载中...`,noCustomModels:`还没有自定义模型,请点击"添加模型"。`,fillProviderBaseUrlModel:`请填写提供商名称和 Base URL。`,saveCustomModelFailed:`保存自定义模型失败。`,confirmDeleteProvider:`确定删除 {name} 吗?`,deleteFailed:`删除失败。`,selectCustomModel:`选择自定义模型`,close:`关闭`,back:`返回`,more:`更多`,searchModels:`搜索模型...`,searchSettings:`搜索设置...`,noSettingsResults:`没有匹配的设置`,noMatchingCustomModels:`没有匹配的自定义模型`,presets:`快速模板`,presetOpenai:`OpenAI`,presetDeepseek:`DeepSeek`,presetGlm:`智谱 GLM`,presetOllama:`本地 Ollama`,presetLitellm:`LiteLLM 代理`,presetCustom:`自定义`,providerAdvanced:`高级选项`,expandModel:`调整上下文窗口、最大输出、推理、图片输入`,addHeader:`添加请求头`,headerName:`请求头名称`,headerValue:`值`,removeHeader:`移除请求头`,testConnection:`测试连接`,testingConnection:`测试中…`,connectionOk:`连接成功`,connectionFailed:`连接失败`,testRequiresFields:`请填写 Base URL 和至少一个模型 ID。`,readFile:`读取文件`,manageGlobalMemory:`管理记忆`,searchFiles:`搜索文件`,writeFile:`写入文件`,editFile:`编辑文件`,runCommand:`运行命令`,presentFiles:`展示文件`,generateImage:`生成图片`,generatingImage:`正在生成图片…`,generatedImageAlt:`生成的图片 {index}`,openGeneratedImage:`打开生成图片`,downloadGeneratedImage:`下载生成图片`,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:`同步 Agent 权限模式失败,已恢复为之前的状态。`,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:`智能体`,agentsDescription:`创建可复用的智能体配置,用于定时任务和 run_subagent 委派。`,createAgent:`创建智能体`,editAgent:`编辑智能体`,builtinAgent:`内置`,builtinAgentReadonly:`内置智能体在当前版本中只读。`,builtinAgentModelSettings:`模型设置`,builtinAgentModelOnly:`该内置智能体由系统管理,仅允许修改使用的模型。`,readonlyAgentDescription:`该智能体来自只读来源,无法在此编辑。`,enabledAsSubagent:`允许作为 sub agent`,enableAsSubagent:`启用作为 sub agent`,disableAsSubagent:`禁用作为 sub agent`,noDescription:`暂无描述。`,maxRuntimeMs:`最大运行时间:`,maxToolCalls:`最大工具调用:`,defaultAgent:`默认智能体`,executionAgent:`执行智能体:`,agentName:`智能体名称`,agentLabel:`显示名称`,agentLabelPlaceholder:`例如:代码审查智能体`,agentDescription:`描述`,agentSystemPrompt:`系统提示词`,agentModelMode:`模型模式`,agentModelInherit:`继承主模型`,agentModelFixed:`使用固定模型`,agentFixedModel:`固定模型`,agentThinkingLevel:`思考等级`,agentThinkingInherit:`继承调用方设置`,agentThinkingDescription:`运行时模型不支持推理时,将自动降级为关闭。`,agentThinkingUnsupported:`所选固定模型不支持推理,思考等级将关闭。`,allowedTools:`可用工具`,agentSourcePath:`来源路径`,highRiskTool:`高风险`,confirmDeleteAgent:`确定删除这个自定义智能体吗?使用它的定时任务将回退到默认智能体。`,aiFillAgent:`AI 填充`,aiFillAgentDescription:`描述你想创建的智能体,AI 只会填充智能体名称、显示名称、描述和系统提示词。`,aiFillAgentPlaceholder:`例如:生成一个只读代码审查智能体,重点检查架构、潜在 bug 和测试覆盖。`,aiFillAgentLoading:`生成中...`,aiFillAgentNoModel:`请先配置默认模型。`,aiFillAgentFailed:`AI 填充失败,请检查模型配置和 API Key 后重试。`,aiFillAgentInputRequired:`请描述你想创建的智能体。`,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 服务`,mcpNoServersDescription:`还没有配置 MCP 服务。点击「添加服务」,或在右侧粘贴 mcpServers JSON 配置。`,mcpConfiguredServers:`已配置服务`,mcpAddServer:`添加服务`,mcpEditServer:`编辑服务`,mcpServerName:`服务名称`,mcpCommand:`命令`,mcpTransport:`传输方式`,mcpUrl:`URL`,mcpArgs:`参数,每行一个`,mcpCwd:`工作目录`,mcpEnv:`环境变量,每行 KEY=value`,mcpToolsCount:`{count} 个工具`,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 必须是对象。`,mcpHeaders:`Headers,每行 KEY=value`,mcpReconnectServer:`重连`,mcpMoreTools:`+{count}`,mcpNamePlaceholder:`例如 my-server`,mcpUrlPlaceholder:`https://example.com/mcp`,mcpCommandPlaceholder:`例如 npx`,mcpTabServer:`服务`,mcpTabJson:`JSON`,optional:`可选`,globalSkills:`全局技能`,projectSkills:`项目技能`,help:`帮助`,projectCommands:`项目命令`,projectCommandsDescription:`为当前项目配置额外的 Markdown slash command 目录。QuickForge 还会读取用户级目录 ~/.quickforge/commands/(所有项目共享),然后依次读取项目目录 .claude/commands、.opencode/commands、.ai/commands 及此处的配置目录;同名 command 以后面的目录覆盖前面的目录。`,projectCommandsProjectDescription:`选择要配置命令目录的项目。`,selectProjectForCommands:`请先选择或添加一个项目,再配置项目命令。`,commandDirectory:`命令目录`,commandDirectories:`命令目录`,commandDirectoriesDescription:`一行添加一个目录。相对路径会基于所选项目根目录解析。`,commandDirectoryPlaceholder:`.claude/commands
|
|
15
15
|
.opencode/commands
|
|
@@ -57,10 +57,10 @@ D:\\shared\\ai-commands`,commandDirectoryHelp:`一行一个目录。支持相对
|
|
|
57
57
|
To pick up a draggable item, press the space bar.
|
|
58
58
|
While dragging, use the arrow keys to move the item.
|
|
59
59
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
60
|
-
`},wr={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 Tr(e){let{announcements:t=wr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Cr}=e,{announce:a,announcement:o}=yr(),s=or(`DndLiveRegion`),[c,l]=(0,H.useState)(!1);if((0,H.useEffect)(()=>{l(!0)},[]),xr((0,H.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=H.createElement(H.Fragment,null,H.createElement(_r,{id:r,value:i.draggable}),H.createElement(vr,{id:s,announcement:o}));return n?(0,Vn.createPortal)(u,n):u}var Er;(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`})(Er||={});function Dr(){}function Or(e,t){return(0,H.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function kr(){var e=[...arguments];return(0,H.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Ar=Object.freeze({x:0,y:0});function jr(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Mr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Nr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Pr(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Fr(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 Ir=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Fr(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=jr(Fr(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Mr)};function Lr(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 Rr=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=Lr(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Nr)};function zr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Br(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ar}function Vr(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 Hr=Vr(1);function Ur(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 Wr(e,t,n){let r=Ur(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 Gr={ignoreTransform:!1};function Kr(e,t){t===void 0&&(t=Gr);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=qn(e).getComputedStyle(e);t&&(n=Wr(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 qr(e){return Kr(e,{ignoreTransform:!0})}function Jr(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Yr(e,t){return t===void 0&&(t=qn(e).getComputedStyle(e)),t.position===`fixed`}function Xr(e,t){t===void 0&&(t=qn(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 Zr(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Jn(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Yn(i)||Xn(i)||n.includes(i))return n;let a=qn(e).getComputedStyle(i);return i!==e&&Xr(i,a)&&n.push(i),Yr(i,a)?n:r(i.parentNode)}return e?r(e):n}function Qr(e){let[t]=Zr(e,1);return t??null}function $r(e){return!Wn||!e?null:Gn(e)?e:Kn(e)?Jn(e)||e===Zn(e).scrollingElement?window:Yn(e)?e:null:null}function ei(e){return Gn(e)?e.scrollX:e.scrollLeft}function ti(e){return Gn(e)?e.scrollY:e.scrollTop}function ni(e){return{x:ei(e),y:ti(e)}}var ri;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(ri||={});function ii(e){return!Wn||!e?!1:e===document.scrollingElement}function ai(e){let t={x:0,y:0},n=ii(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 oi={x:.2,y:.2};function si(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=oi);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=ai(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=ri.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=ri.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=ri.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=ri.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function ci(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 li(e){return e.reduce((e,t)=>cr(e,ni(t)),Ar)}function ui(e){return e.reduce((e,t)=>e+ei(t),0)}function di(e){return e.reduce((e,t)=>e+ti(t),0)}function fi(e,t){if(t===void 0&&(t=Kr),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Qr(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var pi=[[`x`,[`left`,`right`],ui],[`y`,[`top`,`bottom`],di]],mi=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=Zr(t),r=li(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of pi)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})}},hi=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 gi(e){let{EventTarget:t}=qn(e);return e instanceof t?e:Zn(e)}function _i(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 vi;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(vi||={});function yi(e){e.preventDefault()}function bi(e){e.stopPropagation()}var Q;(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`})(Q||={});var xi={start:[Q.Space,Q.Enter],cancel:[Q.Esc],end:[Q.Space,Q.Enter,Q.Tab]},Si=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Q.Right:return{...n,x:n.x+25};case Q.Left:return{...n,x:n.x-25};case Q.Down:return{...n,y:n.y+25};case Q.Up:return{...n,y:n.y-25}}},Ci=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 hi(Zn(t)),this.windowListeners=new hi(qn(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vi.Resize,this.handleCancel),this.windowListeners.add(vi.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vi.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&fi(n),t(Ar)}handleKeyDown(e){if(dr(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=xi,coordinateGetter:a=Si,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}:Ar;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=lr(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}=ai(n),p=ci(n),m={x:Math.min(i===Q.Right?p.right-p.width/2:p.right,Math.max(i===Q.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Q.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Q.Down?p.top:p.top+p.height/2,u.y))},h=i===Q.Right&&!s||i===Q.Left&&!c,g=i===Q.Down&&!l||i===Q.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Q.Right&&e<=d.x||i===Q.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Q.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===Q.Down&&e<=d.y||i===Q.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Q.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,cr(lr(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()}};Ci.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=xi,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 wi(e){return!!(e&&`distance`in e)}function Ti(e){return!!(e&&`delay`in e)}var Ei=class{constructor(e,t,n){n===void 0&&(n=gi(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=Zn(i),this.documentListeners=new hi(this.document),this.listeners=new hi(n),this.windowListeners=new hi(qn(i)),this.initialCoordinates=pr(r)??Ar,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(vi.Resize,this.handleCancel),this.windowListeners.add(vi.DragStart,yi),this.windowListeners.add(vi.VisibilityChange,this.handleCancel),this.windowListeners.add(vi.ContextMenu,yi),this.documentListeners.add(vi.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ti(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(wi(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(vi.Click,bi,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vi.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=pr(e)??Ar,s=lr(n,o);if(!t&&a){if(wi(a)){if(a.tolerance!=null&&_i(s,a.tolerance))return this.handleCancel();if(_i(s,a.distance))return this.handleStart()}if(Ti(a)&&_i(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===Q.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Di={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Oi=class extends Ei{constructor(e){let{event:t}=e,n=Zn(t.target);super(e,Di,n)}};Oi.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 ki={move:{name:`mousemove`},end:{name:`mouseup`}},Ai;(function(e){e[e.RightClick=2]=`RightClick`})(Ai||={});var ji=class extends Ei{constructor(e){super(e,ki,Zn(e.event.target))}};ji.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Ai.RightClick?!1:(r?.({event:n}),!0)}}];var Mi={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Ni=class extends Ei{constructor(e){super(e,Mi)}static setup(){return window.addEventListener(Mi.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Mi.move.name,e)};function e(){}}};Ni.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 Pi;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Pi||={});var Fi;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Fi||={});function Ii(e){let{acceleration:t,activator:n=Pi.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Fi.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Ri({delta:d,disabled:!a}),[m,h]=er(),g=(0,H.useRef)({x:0,y:0}),_=(0,H.useRef)({x:0,y:0}),v=(0,H.useMemo)(()=>{switch(n){case Pi.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Pi.DraggableRect:return i}},[n,i,c]),y=(0,H.useRef)(null),b=(0,H.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,H.useMemo)(()=>s===Fi.TreeOrder?[...l].reverse():l,[s,l]);(0,H.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}=si(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 Li={x:{[ri.Backward]:!1,[ri.Forward]:!1},y:{[ri.Backward]:!1,[ri.Forward]:!1}};function Ri(e){let{delta:t,disabled:n}=e,r=ir(t);return nr(e=>{if(n||!r||!e)return Li;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[ri.Backward]:e.x[ri.Backward]||i.x===-1,[ri.Forward]:e.x[ri.Forward]||i.x===1},y:{[ri.Backward]:e.y[ri.Backward]||i.y===-1,[ri.Forward]:e.y[ri.Forward]||i.y===1}}},[n,t,r])}function zi(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return nr(e=>t==null?null:r??e??null,[r,t])}function Bi(e,t){return(0,H.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 Vi;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Vi||={});var Hi;(function(e){e.Optimized=`optimized`})(Hi||={});var Ui=new Map;function Wi(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,H.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,H.useRef)(e),d=g(),f=tr(d),p=(0,H.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,H.useRef)(null),h=nr(t=>{if(d&&!n)return Ui;if(!t||t===Ui||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 mi(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,H.useEffect)(()=>{u.current=e},[e]),(0,H.useEffect)(()=>{d||p()},[n,d]),(0,H.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,H.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 Vi.Always:return!1;case Vi.BeforeDragging:return n;default:return!n}}}function Gi(e,t){return nr(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Ki(e,t){return Gi(e,t)}function qi(e){let{callback:t,disabled:n}=e,r=$n(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Ji(e){let{callback:t,disabled:n}=e,r=$n(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Yi(e){return new mi(Kr(e),e)}function Xi(e,t,n){t===void 0&&(t=Yi);let[r,i]=(0,H.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=qi({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=Ji({callback:a});return Qn(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Zi(e){return Br(e,Gi(e))}var Qi=[];function $i(e){let t=(0,H.useRef)(e),n=nr(n=>e?n&&n!==Qi&&e&&t.current&&e.parentNode===t.current.parentNode?n:Zr(e):Qi,[e]);return(0,H.useEffect)(()=>{t.current=e},[e]),n}function ea(e){let[t,n]=(0,H.useState)(null),r=(0,H.useRef)(e),i=(0,H.useCallback)(e=>{let t=$r(e.target);t&&n(e=>e?(e.set(t,ni(t)),new Map(e)):null)},[]);return(0,H.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=$r(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,ni(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=>{$r(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,H.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>cr(e,t),Ar):li(e):Ar,[e,t])}function ta(e,t){t===void 0&&(t=[]);let n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{n.current=null},t),(0,H.useEffect)(()=>{let t=e!==Ar;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?lr(e,n.current):Ar}function na(e){(0,H.useEffect)(()=>{if(!Wn)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 ra(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function ia(e){return(0,H.useMemo)(()=>e?Jr(e):null,[e])}var aa=[];function oa(e,t){t===void 0&&(t=Kr);let[n]=e,r=ia(n?qn(n):null),[i,a]=(0,H.useState)(aa);function o(){a(()=>e.length?e.map(e=>ii(e)?r:new mi(t(e),e)):aa)}let s=Ji({callback:o});return Qn(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function sa(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Yn(t)?t:e}function ca(e){let{measure:t}=e,[n,r]=(0,H.useState)(null),i=Ji({callback:(0,H.useCallback)(e=>{for(let{target:n}of e)if(Yn(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=rr((0,H.useCallback)(e=>{let n=sa(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,H.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var la=[{sensor:Oi,options:{}},{sensor:Ci,options:{}}],ua={current:{}},da={draggable:{measure:qr},droppable:{measure:qr,strategy:Vi.WhileDragging,frequency:Hi.Optimized},dragOverlay:{measure:Kr}},fa=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}},pa={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new fa,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Dr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:da,measureDroppableContainers:Dr,windowRect:null,measuringScheduled:!1},ma={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Dr,draggableNodes:new Map,over:null,measureDroppableContainers:Dr},ha=(0,H.createContext)(ma),ga=(0,H.createContext)(pa);function _a(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new fa}}}function va(e,t){switch(t.type){case Er.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Er.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 Er.DragEnd:case Er.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Er.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new fa(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Er.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 fa(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Er.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new fa(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ya(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,H.useContext)(ha),a=ir(r),o=ir(n?.id);return(0,H.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!dr(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=hr(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function ba(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function xa(e){return(0,H.useMemo)(()=>({draggable:{...da.draggable,...e?.draggable},droppable:{...da.droppable,...e?.droppable},dragOverlay:{...da.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Sa(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,H.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Qn(()=>{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=Br(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=Qr(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Ca=(0,H.createContext)({...Ar,scaleX:1,scaleY:1}),wa;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(wa||={});var Ta=(0,H.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=la,collisionDetection:o=Rr,measuring:s,modifiers:c,...l}=e,[u,d]=(0,H.useReducer)(va,void 0,_a),[f,p]=Sr(),[m,h]=(0,H.useState)(wa.Uninitialized),g=m===wa.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,H.useRef)({initial:null,translated:null}),C=(0,H.useMemo)(()=>_==null?null:{id:_,data:x?.data??ua,rect:S},[_,x]),w=(0,H.useRef)(null),[T,E]=(0,H.useState)(null),[D,O]=(0,H.useState)(null),k=tr(l,Object.values(l)),ee=or(`DndDescribedBy`,t),A=(0,H.useMemo)(()=>b.getEnabled(),[b]),j=xa(s),{droppableRects:te,measureDroppableContainers:M,measuringScheduled:N}=Wi(A,{dragging:g,dependencies:[y.x,y.y],config:j.droppable}),P=zi(v,_),F=(0,H.useMemo)(()=>D?pr(D):null,[D]),I=Oe(),L=Ki(P,j.draggable.measure);Sa({activeNode:_==null?null:v.get(_),config:I.layoutShiftCompensation,initialRect:L,measure:j.draggable.measure});let R=Xi(P,j.draggable.measure,L),ne=Xi(P?P.parentElement:null),z=(0,H.useRef)({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=b.getNodeFor(z.current.over?.id),B=ca({measure:j.dragOverlay.measure}),ie=B.nodeRef.current??P,ae=g?B.rect??R:null,oe=!!(B.nodeRef.current&&B.rect),se=Zi(oe?null:R),ce=ia(ie?qn(ie):null),le=$i(g?re??P:null),ue=oa(le),de=ba(c,{transform:{x:y.x-se.x,y:y.y-se.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:R,containerNodeRect:ne,draggingNodeRect:ae,over:z.current.over,overlayNodeRect:B.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),fe=F?cr(F,y):null,pe=ea(le),me=ta(pe),he=ta(pe,[R]),ge=cr(de,me),_e=ae?Hr(ae,de):null,ve=C&&_e?o({active:C,collisionRect:_e,droppableRects:te,droppableContainers:A,pointerCoordinates:fe}):null,ye=Pr(ve,`id`),[be,xe]=(0,H.useState)(null),Se=zr(oe?de:cr(de,he),be?.rect??null,R),Ce=(0,H.useRef)(null),we=(0,H.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;Ce.current=new n({active:w.current,activeNode:i,event:a,options:r,context:z,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,Vn.unstable_batchedUpdates)(()=>{r?.(i),h(wa.Initializing),d({type:Er.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ce.current),O(a)})},onMove(e){d({type:Er.DragMove,coordinates:e})},onEnd:o(Er.DragEnd),onCancel:o(Er.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=z.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Er.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Er.DragCancel)}w.current=null,(0,Vn.unstable_batchedUpdates)(()=>{d({type:e}),h(wa.Uninitialized),xe(null),E(null),O(null),Ce.current=null;let t=e===Er.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Te=Bi(a,(0,H.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,we(n,t))},[v,we]));na(a),Qn(()=>{R&&m===wa.Initializing&&h(wa.Initialized)},[R,m]),(0,H.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=z.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,Vn.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,H.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=z.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ye),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,Vn.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[ye]),Qn(()=>{z.current={activatorEvent:D,active:C,activeNode:P,collisionRect:_e,collisions:ve,droppableRects:te,draggableNodes:v,draggingNode:ie,draggingNodeRect:ae,droppableContainers:b,over:be,scrollableAncestors:le,scrollAdjustedTranslate:ge},S.current={initial:ae,translated:_e}},[C,P,ve,_e,v,ie,ae,te,b,be,le,ge]),Ii({...I,delta:y,draggingRect:_e,pointerCoordinates:fe,scrollableAncestors:le,scrollableAncestorRects:ue});let Ee=(0,H.useMemo)(()=>({active:C,activeNode:P,activeNodeRect:R,activatorEvent:D,collisions:ve,containerNodeRect:ne,dragOverlay:B,draggableNodes:v,droppableContainers:b,droppableRects:te,over:be,measureDroppableContainers:M,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:j,measuringScheduled:N,windowRect:ce}),[C,P,R,D,ve,ne,B,v,b,te,be,M,le,ue,j,N,ce]),De=(0,H.useMemo)(()=>({activatorEvent:D,activators:Te,active:C,activeNodeRect:R,ariaDescribedById:{draggable:ee},dispatch:d,draggableNodes:v,over:be,measureDroppableContainers:M}),[D,Te,C,R,d,ee,v,be,M]);return H.createElement(br.Provider,{value:p},H.createElement(ha.Provider,{value:De},H.createElement(ga.Provider,{value:Ee},H.createElement(Ca.Provider,{value:Se},i)),H.createElement(ya,{disabled:n?.restoreFocus===!1})),H.createElement(Tr,{...n,hiddenTextDescribedById:ee}));function Oe(){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}}}),Ea=(0,H.createContext)(null),Da=`button`,Oa=`Draggable`;function ka(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=or(Oa),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,H.useContext)(ha),{role:p=Da,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,H.useContext)(g?Ca:Ea),[v,y]=rr(),[b,x]=rr(),S=ra(o,t),C=tr(n);return Qn(()=>(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,H.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Da?!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 Aa(){return(0,H.useContext)(ga)}var ja=`Droppable`,Ma={timeout:25};function Na(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=or(ja),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,H.useContext)(ha),u=(0,H.useRef)({disabled:n}),d=(0,H.useRef)(!1),f=(0,H.useRef)(null),p=(0,H.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Ma,...i},_=tr(h??r),v=Ji({callback:(0,H.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]=rr((0,H.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=tr(t);return(0,H.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,H.useEffect)(()=>(s({type:Er.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Er.UnregisterDroppable,key:a,id:r})),[r]),(0,H.useEffect)(()=>{n!==u.current.disabled&&(s({type:Er.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 Pa(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Fa(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Ia(e){return e!==null&&e>=0}function La(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 Ra(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var za=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=Pa(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}},Ba={scaleX:1,scaleY:1},Va=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,...Ba}:null}let s=Ha(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...Ba}:r<t&&r>=a?{x:0,y:o.height+s,...Ba}:{x:0,y:0,...Ba}};function Ha(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 Ua=`Sortable`,Wa=H.createContext({activeIndex:-1,containerId:Ua,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:za,disabled:{draggable:!1,droppable:!1}});function Ga(e){let{children:t,id:n,items:r,strategy:i=za,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=Aa(),d=or(Ua,n),f=s.rect!==null,p=(0,H.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,H.useRef)(p),v=!La(p,_.current),y=g!==-1&&h===-1||v,b=Ra(a);Qn(()=>{v&&m&&u(p)},[v,p,m,u]),(0,H.useEffect)(()=>{_.current=p},[p]);let x=(0,H.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:Fa(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return H.createElement(Wa.Provider,{value:x},t)}var Ka=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return Pa(n,r,i).indexOf(t)},qa=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},Ja={duration:200,easing:`ease`},Ya=`transform`,Xa=Z.Transition.toString({property:Ya,duration:0,easing:`linear`}),Za={roleDescription:`sortable`};function Qa(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,H.useState)(null),s=(0,H.useRef)(n);return Qn(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=Kr(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,H.useEffect)(()=>{a&&o(null)},[a]),a}function $a(e){let{animateLayoutChanges:t=qa,attributes:n,disabled:r,data:i,getNewIndex:a=Ka,id:o,strategy:s,resizeObserverConfig:c,transition:l=Ja}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,H.useContext)(Wa),y=eo(r,p),b=u.indexOf(o),x=(0,H.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,H.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=Na({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:ee,setNodeRef:A,listeners:j,isDragging:te,over:M,setActivatorNodeRef:N,transform:P}=ka({id:o,data:x,attributes:{...Za,...n},disabled:y.draggable}),F=Un(E,A),I=!!D,L=I&&!m&&Ia(f)&&Ia(g),R=!_&&te,ne=L?(R&&L?P:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,z=Ia(f)&&Ia(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,re=D?.id,B=(0,H.useRef)({activeId:re,items:u,newIndex:z,containerId:d}),ie=u!==B.current.items,ae=t({active:D,containerId:d,isDragging:te,isSorting:I,id:o,index:b,items:u,newIndex:B.current.newIndex,previousItems:B.current.items,previousContainerId:B.current.containerId,transition:l,wasDragging:B.current.activeId!=null}),oe=Qa({disabled:!ae,index:b,node:w,rect:C});return(0,H.useEffect)(()=>{I&&B.current.newIndex!==z&&(B.current.newIndex=z),d!==B.current.containerId&&(B.current.containerId=d),u!==B.current.items&&(B.current.items=u)},[I,z,d,u]),(0,H.useEffect)(()=>{if(re===B.current.activeId)return;if(re!=null&&B.current.activeId==null){B.current.activeId=re;return}let e=setTimeout(()=>{B.current.activeId=re},50);return()=>clearTimeout(e)},[re]),{active:D,activeIndex:f,attributes:ee,data:x,rect:C,index:b,newIndex:z,items:u,isOver:T,isSorting:I,isDragging:te,listeners:j,node:w,overIndex:g,over:M,setNodeRef:F,setActivatorNodeRef:N,setDroppableNodeRef:E,setDraggableNodeRef:A,transform:oe??ne,transition:se()};function se(){if(oe||ie&&B.current.newIndex===b)return Xa;if(!(R&&!dr(O)||!l)&&(I||ae))return Z.Transition.toString({...l,property:Ya})}}function eo(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}Q.Down,Q.Right,Q.Up,Q.Left;function to(e){let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function no(e,t){let n=(0,H.useRef)(null),r=(0,H.useRef)(e);(0,H.useEffect)(()=>{r.current=e},[e]);let i=(0,H.useCallback)(e=>{n.current=e},[]);return(0,H.useEffect)(()=>{let e=n.current;if(!e||!t)return;let i=to(e),a=new IntersectionObserver(e=>{e[0]?.isIntersecting&&r.current()},{root:i,rootMargin:`100px`,threshold:0});return a.observe(e),()=>a.disconnect()},[t]),i}var ro=60*1e3,io=60*ro,ao=24*io,oo=7*ao,so=365*ao,co=360,lo=300,uo=192,fo=120,po=224,mo=244,ho=320,go=320,_o=520,vo=.5;function yo(){return typeof window>`u`?_o:Math.max(go,Math.min(_o,window.innerWidth*vo))}function bo(e){return Math.min(yo(),Math.max(go,e))}function xo(e){if(!e)return``;let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);return n<io?U(`relativeMinuteShort`,{count:Math.max(1,Math.floor(n/ro))}):n<ao?U(`relativeHourShort`,{count:Math.floor(n/io)}):n<oo?U(`relativeDayShort`,{count:Math.floor(n/ao)}):n<so?U(`relativeWeekShort`,{count:Math.floor(n/oo)}):U(`relativeYearShort`,{count:Math.floor(n/so)})}function So(e){if(!e)return!1;let t=e.trim();return!t||t===`undefined`||t===`null`||t===`false`?!1:!Number.isNaN(Date.parse(t))}function Co({onLoadMore:e,enabled:t}){let r=no(e,t);return t?(0,G.jsx)(`div`,{ref:r,className:`flex items-center justify-center py-1`,children:(0,G.jsx)(n,{className:`size-3 animate-spin text-muted-foreground/45`})}):null}function wo({id:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=$a({id:e});return(0,G.jsx)(`div`,{ref:i,style:{transform:Z.Transform.toString(a),transition:o},className:W(s&&`relative z-50 opacity-40`),children:t({listeners:r,attributes:n})})}var To=(0,H.memo)(function({sidebarOpen:e,variant:t=`desktop`,projectsCollapsed:a,pinnedCollapsed:c,conversationsCollapsed:l,projects:u,expandedProjectIds:f,activeProject:m,currentSessionId:_,loadingSessionId:v,sessionViewMode:b,sessionSortMode:x,globalSessions:C,pinnedSessions:w,pinnedHasMore:O,pinnedLoading:ee,sessionsForProject:j,projectTimelineSessions:te,projectTimelineHasMore:M,projectTimelineLoading:N,globalHasMore:P,globalLoading:I,onLoadMoreGlobal:L,onLoadMorePinned:re,projectHasMore:ie,projectLoading:ae,projectLoaded:oe,onLoadMoreProject:le,onLoadMoreProjectTimeline:ue,sessionTaskStatus:fe,selectingProject:he,onTogglePinnedCollapsed:_e,onToggleProjectsCollapsed:ve,onToggleConversationsCollapsed:ye,onToggleProjectExpanded:be,onToggleAllProjectsExpanded:xe,onReorderProjects:Se,onSelectProjectDirectory:Ce,onStartNewProjectChat:we,onOpenGlobalSkills:Te,onOpenAgents:Ee,onOpenScheduledTasks:De,onOpenProjectSkills:Oe,onOpenProjectInExplorer:ke,onDeleteProject:Ae,onLoadSession:je,onSessionViewModeChange:Me,onSessionSortModeChange:Ne,onTogglePinSession:Pe,onDeleteSession:Fe,onStartNewGlobalChat:Ie,onOpenSettings:Le,onOpenUpdate:Re,onDismissUpdate:ze,updateAvailable:Be,latestVersion:Ve,currentVersion:V,onToggleSidebar:He,currentSessionHoverInfo:Ue}){let We=`hover:bg-[var(--quickforge-sidebar-hover-bg)]`,Ge=`quickforge-sidebar-section-header group mb-1 flex w-full items-center gap-1 rounded-lg px-2 py-1 text-sm font-[350] leading-5 text-muted-foreground/50 transition-colors ${We}`,Ke=`quickforge-sidebar-section-toggle flex min-w-0 flex-1 items-center gap-1 text-left transition-colors`,qe=`quickforge-sidebar-section-icon size-4 shrink-0 text-current opacity-0 transition-[transform,opacity] duration-200 ease-out group-hover:opacity-100 group-focus-within:opacity-100 motion-reduce:transition-none`,Je=`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,Ye=`grid-rows-[1fr] opacity-100`,Xe=`pointer-events-none grid-rows-[0fr] opacity-0`,Ze=`min-h-0 overflow-hidden`,Qe=`group relative flex items-center gap-2 overflow-hidden rounded-lg py-1.5 text-left transition-[background-color,color,box-shadow] duration-160 ease-out ${e?`px-2`:`justify-center px-0`} `,$e=`group relative flex items-center gap-2 overflow-hidden py-1.5 text-left transition-[background-color,color,box-shadow] duration-160 ease-out ${e?`px-2`:`justify-center px-0`}`,et=`bg-[var(--quickforge-sidebar-hover-bg)] text-foreground/84 shadow-[0_8px_22px_-20px_rgb(15_23_42_/_0.32)]`,tt=`text-foreground/80 ${We}`,nt=`text-muted-foreground/68 ${We} hover:text-foreground/80`,rt=`text-muted-foreground/70 ${We} hover:text-foreground/82`,it=`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-colors group-hover:text-foreground/70`,at=`size-7 shrink-0 rounded-full text-muted-foreground/55 transition-[background-color,color,box-shadow,opacity] duration-160 ease-out ${We} hover:text-foreground/85 `,ot=`quickforge-sidebar-section-icon ${at} pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100`,st=`pointer-events-none absolute inset-y-0 right-1 z-20 flex items-center gap-px rounded-r-lg bg-gradient-to-l from-[var(--quickforge-sidebar-hover-bg)] via-[var(--quickforge-sidebar-hover-bg)]/95 to-transparent pl-4 opacity-0 transition-opacity duration-160`,ct=`${st} group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100`,lt=`${st} group-hover:pointer-events-auto group-hover:opacity-100`,ut=`size-6 shrink-0 rounded-full text-muted-foreground/55 transition-[background-color,color,box-shadow] duration-160 ease-out ${We} hover:text-foreground/85 `,dt=`truncate text-sm font-[350] leading-5`,ft=`flex min-w-0 flex-1 items-center gap-2 text-left`,pt=`flex min-w-0 flex-1 items-center gap-1 truncate`,mt=e=>v===e?(0,G.jsx)(n,{className:`size-3 shrink-0 animate-spin text-muted-foreground/55`,"aria-hidden":`true`}):null,ht=`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 ${We} hover:text-foreground/85`,gt=`group-hover:pointer-events-none group-hover:opacity-0 group-focus-within:pointer-events-none group-focus-within:opacity-0`,_t=`font-[350] text-foreground/84`,vt=`quickforge-sidebar-session-time shrink-0 text-[11px] leading-4 transition-opacity duration-160`,yt=`px-3 pb-1 pt-2 text-xs font-[350] leading-4 text-muted-foreground/50`,bt=`flex w-full items-center gap-3 whitespace-nowrap rounded-xl px-3 py-2.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted/45`,xt=`mt-2 flex items-center gap-2 text-sm leading-5 text-muted-foreground/72`,St=t===`mobile`,[Ct,wt]=(0,H.useState)(!1),[Tt,Et]=(0,H.useState)(``),[Dt,Ot]=(0,H.useState)(null),[kt,q]=(0,H.useState)(null),[At,J]=(0,H.useState)(!1),[Y,jt]=(0,H.useState)(null),[X,Nt]=(0,H.useState)(null),[Pt,Ft]=(0,H.useState)(null),[It,Lt]=(0,H.useState)(null),[Rt,zt]=(0,H.useState)(null),[Bt,Vt]=(0,H.useState)(null),[Ht,Ut]=(0,H.useState)(null),[Wt,Gt]=(0,H.useState)(ho),[Kt,qt]=(0,H.useState)(!1),Jt=(0,H.useRef)(null),Yt=(0,H.useRef)(null),Xt=(0,H.useRef)(null),Zt=(0,H.useRef)(null),Qt=(0,H.useRef)(null),$t=(0,H.useRef)(null),en=(0,H.useRef)(null),tn=kr(Or(Oi,{activationConstraint:{distance:6}})),nn=(0,H.useCallback)(e=>({...e.transform,x:0}),[]),rn=(0,H.useMemo)(()=>u.map(e=>e.id),[u]),an=(0,H.useMemo)(()=>u.find(e=>e.id===Dt),[Dt,u]),on=(0,H.useMemo)(()=>new Map(u.map(e=>[e.id,e.name])),[u]),sn=(0,H.useMemo)(()=>{let e=new Set;return te.filter(t=>e.has(t.id)?!1:(e.add(t.id),!0)).map(e=>({session:e,projectName:e.projectId?on.get(e.projectId)??U(`unknownProject`):U(`unknownProject`)}))},[on,te]),cn=(0,H.useMemo)(()=>w.filter(e=>So(e.pinnedAt)).map(e=>({session:e,sourceName:e.scope===`project`?e.projectId?on.get(e.projectId)??U(`unknownProject`):U(`unknownProject`):U(`normalChat`)})),[w,on]),ln=(0,H.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=rn.indexOf(t.id),i=rn.indexOf(n.id);if(r===-1||i===-1)return;let a=[...rn];a.splice(r,1),a.splice(i,0,t.id),Se(a)},[rn,Se]),un=(0,H.useRef)(null),dn=(0,H.useMemo)(()=>{let e=cn.map(({session:e,sourceName:t})=>({session:e,projectName:t})),t=u.flatMap(e=>j(e.id).map(t=>({session:t,projectName:e.name}))),n=te.map(e=>({session:e,projectName:e.projectId?on.get(e.projectId)??U(`unknownProject`):U(`unknownProject`)})),r=C.map(e=>({session:e,projectName:``})),i=new Set;return[...e,...t,...n,...r].filter(({session:e})=>i.has(e.id)?!1:(i.add(e.id),!0))},[C,cn,on,te,u,j]),fn=Tt.trim()?dn.filter(({session:e,projectName:t})=>`${Mt(e.title)} ${t}`.toLowerCase().includes(Tt.trim().toLowerCase())).slice(0,8):[],pn=()=>{wt(!0),window.setTimeout(()=>un.current?.focus(),0)},mn=e=>{je(e),wt(!1),Et(``)},hn=()=>{en.current!==null&&(window.clearTimeout(en.current),en.current=null)},gn=(e,t)=>{if(St)return;let n=e.currentTarget.getBoundingClientRect(),r=Math.max(8,Math.min(n.right+8,window.innerWidth-392)),i=n.top+n.height/2;hn(),en.current=window.setTimeout(()=>{en.current=null,Ut({sessionId:t,x:r,y:i})},lo)},_n=e=>{hn(),Ut(t=>t?.sessionId===e?null:t)},vn=(e,t)=>{e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();Nt(null),Ot(e=>e===t?(q(null),null):(q({x:Math.max(8,Math.min(n.right-uo,window.innerWidth-uo-8)),y:Math.max(8,Math.min(n.bottom+4,window.innerHeight-fo-8))}),t))},yn=e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();Ot(null),q(null),J(e=>e?(jt(null),!1):(jt({x:Math.max(8,Math.min(t.right-po,window.innerWidth-po-8)),y:Math.max(8,Math.min(t.bottom+6,window.innerHeight-mo-8))}),!0))},bn=(0,H.useCallback)(()=>{J(!1),jt(null)},[]),xn=e=>{Me(e),bn()},Sn=e=>{Ne(e),bn()},Cn=(0,H.useCallback)(()=>{Ot(null),q(null),Nt(null)},[]),wn=(e,t)=>{e.stopPropagation(),Nt(t)},Tn=(e,t)=>{e.stopPropagation(),Ot(null),q(null),Ft(t),$t.current!==null&&window.clearTimeout($t.current),$t.current=window.setTimeout(()=>{$t.current=null,Nt(e=>e===t?null:e),Promise.resolve(Ae(t)).catch(()=>{Ft(e=>e===t?null:e)})},co)},En=(e,t)=>{e.currentTarget.blur(),Lt(t),Pe(t)},Dn=(e,t)=>{e.stopPropagation(),e.currentTarget.blur(),zt(t)},On=(e,t)=>{e.stopPropagation(),Vt(t),_n(t),Qt.current!==null&&window.clearTimeout(Qt.current),Qt.current=window.setTimeout(()=>{Qt.current=null,zt(e=>e===t?null:e),Promise.resolve(Fe(t)).catch(()=>{Vt(e=>e===t?null:e)})},co)},kn=(0,H.useCallback)(()=>{let e=Zt.current;e&&(document.body.style.cursor=e.cursor,document.body.style.userSelect=e.userSelect,Zt.current=null)},[]),An=(0,H.useCallback)(e=>{if(Yt.current=null,Xt.current!==null&&(window.cancelAnimationFrame(Xt.current),Xt.current=null),typeof e==`number`){let t=bo(e);Jt.current&&(Jt.current.style.width=`${t}px`),Gt(t)}kn(),qt(!1)},[kn]);function jn(e){let t=Jt.current?.getBoundingClientRect().width??Wt;Yt.current={startX:e.clientX,startWidth:t,currentWidth:t},Zt.current={cursor:document.body.style.cursor,userSelect:document.body.style.userSelect},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,qt(!0),e.preventDefault(),e.stopPropagation();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}function Mn(e){let t=Yt.current;!t||!Jt.current||(t.currentWidth=bo(t.startWidth+e.clientX-t.startX),Xt.current===null&&(Xt.current=window.requestAnimationFrame(()=>{Xt.current=null;let e=Yt.current;!e||!Jt.current||(Jt.current.style.width=`${e.currentWidth}px`)})))}function Nn(e){let t=Yt.current?.currentWidth;An(t);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}function Pn(){An(ho)}return(0,H.useEffect)(()=>()=>{Qt.current!==null&&window.clearTimeout(Qt.current),$t.current!==null&&window.clearTimeout($t.current),en.current!==null&&window.clearTimeout(en.current),Xt.current!==null&&window.cancelAnimationFrame(Xt.current),Yt.current=null,kn()},[kn]),(0,H.useEffect)(()=>{if(!St&&e)return;let t=window.requestAnimationFrame(()=>An());return()=>window.cancelAnimationFrame(t)},[An,St,e]),(0,H.useEffect)(()=>{if(St)return;let e=()=>{An(bo(Yt.current?.currentWidth??Wt))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[An,St,Wt]),(0,H.useEffect)(()=>{if(Dt)return window.addEventListener(`click`,Cn),window.addEventListener(`blur`,Cn),window.addEventListener(`resize`,Cn),()=>{window.removeEventListener(`click`,Cn),window.removeEventListener(`blur`,Cn),window.removeEventListener(`resize`,Cn)}},[Dt,Cn]),(0,H.useEffect)(()=>{if(At)return window.addEventListener(`click`,bn),window.addEventListener(`blur`,bn),window.addEventListener(`resize`,bn),()=>{window.removeEventListener(`click`,bn),window.removeEventListener(`blur`,bn),window.removeEventListener(`resize`,bn)}},[At,bn]),(0,G.jsxs)(`aside`,{ref:Jt,className:W(`relative z-10 min-h-0 shrink-0 overflow-hidden border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-[var(--quickforge-sidebar-bg)] transition-[width] duration-200 ease-out motion-reduce:transition-none`,St?`flex h-full w-80 max-w-[85vw] flex-col`:`hidden md:flex md:flex-col`,!St&&!e?`w-14`:void 0,Kt&&`transition-none`),style:!St&&e?{width:Wt,minWidth:go,maxWidth:`min(${_o}px, ${vo*100}vw)`}:void 0,children:[!St&&e?(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":go,"aria-valuemax":yo(),"aria-valuenow":Math.round(Wt),className:W(`group absolute inset-y-0 right-0 z-30 w-2 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-border/20`,Kt&&`bg-border/25`),onDoubleClick:Pn,onPointerDown:jn,onPointerMove:Mn,onPointerUp:Nn,onPointerCancel:Nn,children:(0,G.jsx)(`span`,{className:W(`absolute inset-y-0 right-0 w-px bg-border/70 opacity-0 transition-opacity`,Kt?`opacity-100`:`group-hover:opacity-100`)})}):null,(0,G.jsxs)(`div`,{className:`shrink-0 px-3 pt-3 pb-1`,children:[(0,G.jsx)(`div`,{className:W(Qe,`w-full`),children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(`img`,{src:`/favicon.svg`,alt:``,"aria-hidden":`true`,className:`size-5`})}),(0,G.jsx)(`button`,{type:`button`,className:W(at,`ml-auto inline-flex items-center justify-center`),onClick:He,"aria-label":U(`toggleSidebar`),title:U(`toggleSidebar`),children:(0,G.jsx)(h,{className:`size-4`})})]}):(0,G.jsxs)(`button`,{type:`button`,className:W(at,`group/toggle relative inline-flex items-center justify-center`),onClick:He,"aria-label":U(`toggleSidebar`),title:U(`toggleSidebar`),children:[(0,G.jsx)(`img`,{src:`/favicon.svg`,alt:``,"aria-hidden":`true`,className:`size-5 transition-opacity duration-160 group-hover/toggle:opacity-0 group-focus-visible/toggle:opacity-0`}),(0,G.jsx)(ne,{className:`absolute size-4 opacity-0 transition-opacity duration-160 group-hover/toggle:opacity-100 group-focus-visible/toggle:opacity-100`})]})}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`mt-4 w-full`,nt),onClick:Ie,"aria-label":U(`startNewChat`),title:U(`startNewChat`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(s,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`startNewChat`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:pn,"aria-label":U(`search`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(D,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`search`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:De,"aria-label":U(`scheduledTasks`),title:U(`scheduledTasks`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(S,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`scheduledTasks`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:Te,"aria-label":U(`manageGlobalSkills`),title:U(`manageGlobalSkills`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(g,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`skills`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:Ee,"aria-label":U(`agentsTab`),title:U(`agentsTab`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(o,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`agentsTab`)}):null]})]}),e?(0,G.jsxs)(G.Fragment,{children:[cn.length>0||ee?(0,G.jsxs)(`div`,{className:`shrink-0 px-3 pb-1 max-h-[28%] flex flex-col min-h-0 overflow-hidden`,children:[(0,G.jsx)(`div`,{className:Ge,children:(0,G.jsxs)(`button`,{type:`button`,className:Ke,onClick:_e,"aria-expanded":!c,children:[(0,G.jsx)(`span`,{className:`truncate`,children:U(`pinnedConversations`)}),(0,G.jsx)(A,{className:W(qe,!c&&`rotate-90`)})]})}),(0,G.jsx)(`div`,{className:W(Je,`flex-1 min-h-0`,c?Xe:Ye),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`space-y-0.5`,children:cn.length===0?(0,G.jsxs)(`div`,{className:`flex items-center px-3 py-3 text-xs text-muted-foreground/55`,children:[(0,G.jsx)(n,{className:`mr-1.5 size-3 animate-spin`}),U(`loadingChatWorkspace`)]}):(0,G.jsxs)(G.Fragment,{children:[cn.map(({session:e})=>{let t=_===e.id,n=It===e.id,i=Bt===e.id;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>gn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),_n(e.id)},children:[(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-busy":v===e.id,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>je(e.id),onKeyDown:t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),je(e.id))},children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]})}),(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}),(0,G.jsx)(`span`,{className:W(vt,!n&>),children:xo(e.pinnedAt)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>On(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>En(t,e.id),"aria-label":U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>Dn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-3.5`})})]})})]})})},e.id)}),(0,G.jsx)(Co,{onLoadMore:re,enabled:O&&!ee})]})})})})})]}):null,(0,G.jsx)(`div`,{className:`shrink-0 px-3 max-h-[55%] flex flex-col min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:`mb-0.5 flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:Ge,children:[(0,G.jsxs)(`button`,{type:`button`,className:Ke,onClick:ve,"aria-expanded":!a,children:[(0,G.jsx)(`span`,{className:`truncate`,children:U(`projects`)}),(0,G.jsx)(A,{className:W(qe,!a&&`rotate-90`)})]}),u.length>0&&(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ot,onClick:yn,"aria-label":U(`filterSort`),title:U(`filterSort`),"aria-haspopup":`menu`,"aria-expanded":At,children:(0,G.jsx)(z,{className:`size-4`})}),u.length>0&&(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ot,onClick:xe,"aria-label":f.size===u.length?U(`collapseAllProjects`):U(`expandAllProjects`),children:f.size===u.length?(0,G.jsx)(ge,{className:`size-4`}):(0,G.jsx)(de,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ot,onClick:Ce,disabled:he,"aria-label":U(`addProject`),children:(0,G.jsx)(y,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:W(Je,`flex-1 min-h-0`,a?Xe:Ye),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`space-y-0.5`,children:u.length===0?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noProjects`)}):b===`timeline`?sn.length===0?N?(0,G.jsxs)(`div`,{className:`flex items-center px-3 py-3 text-xs text-muted-foreground/55`,children:[(0,G.jsx)(n,{className:`mr-1.5 size-3 animate-spin`}),U(`loadingChatWorkspace`)]}):(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noConversations`)}):(0,G.jsxs)(G.Fragment,{children:[sn.map(({session:e})=>{let t=_===e.id,n=It===e.id,i=Bt===e.id,a=x===`createdAt`?e.createdAt:e.lastModified;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>gn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),_n(e.id)},children:[(0,G.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-2 text-left`,type:`button`,"aria-busy":v===e.id,onClick:()=>je(e.id),children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]})}),e.pinnedAt?(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}):null,(0,G.jsx)(`span`,{className:W(vt,!n&>),children:xo(a)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>On(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>En(t,e.id),"aria-label":e.pinnedAt?U(`unpinSession`):U(`pinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>Dn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-3.5`})})]})})]})})},e.id)}),(0,G.jsx)(Co,{onLoadMore:ue,enabled:M&&!N})]}):(0,G.jsx)(Ta,{sensors:tn,collisionDetection:Ir,onDragEnd:ln,modifiers:[nn],children:(0,G.jsx)(Ga,{items:rn,strategy:Va,children:u.map(e=>{let t=j(e.id),i=f.has(e.id),a=m?.id===e.id,o=oe(e.id),c=Dt===e.id,l=Pt===e.id;return(0,G.jsx)(wo,{id:e.id,children:({listeners:u,attributes:d})=>(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,l?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:W(Qe,a?tt:nt,c&&`z-20 overflow-visible`,l&&`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`},...u,...d,children:[(0,G.jsx)(`button`,{type:`button`,className:it,onClick:()=>be(e.id),"aria-label":U(i?`collapseProject`:`expandProject`),children:i?(0,G.jsx)(E,{className:`size-4`}):(0,G.jsx)(T,{className:`size-4`})}),(0,G.jsx)(`button`,{className:`flex min-w-0 flex-1 items-center text-left`,type:`button`,title:e.path,onClick:()=>be(e.id),children:(0,G.jsx)(`span`,{className:W(dt,a&&`font-[350] text-foreground/80`),children:e.name})}),(0,G.jsxs)(`div`,{className:lt,children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>vn(t,e.id),"aria-label":U(`moreOptions`),"aria-expanded":c,children:(0,G.jsx)(R,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:()=>we(e),"aria-label":U(`newProjectChat`),children:(0,G.jsx)(s,{className:`size-4`})})]})]}),(0,G.jsx)(`div`,{className:W(Je,i?Ye:Xe),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.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&&ae(e.id)?(0,G.jsxs)(`div`,{className:`flex items-center px-2 py-1.5 text-xs text-muted-foreground/55`,children:[(0,G.jsx)(n,{className:`mr-1.5 size-3 animate-spin`}),U(`loadingChatWorkspace`)]}):t.length===0&&!ie(e.id)?(0,G.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground/55`,children:U(`noConversations`)}):(0,G.jsxs)(G.Fragment,{children:[t.map(e=>{let t=_===e.id,n=It===e.id,i=Bt===e.id;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,`gap-1`,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>gn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),_n(e.id)},children:[(0,G.jsxs)(`button`,{className:ft,type:`button`,"aria-busy":v===e.id,onClick:()=>je(e.id),children:[(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]}),e.pinnedAt?(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}):null,(0,G.jsx)(`span`,{className:W(vt,!n&>),children:xo(x===`createdAt`?e.createdAt:e.lastModified)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>On(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>En(t,e.id),"aria-label":e.pinnedAt?U(`unpinSession`):U(`pinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>Dn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-3.5`})})]})})]})})},e.id)}),(0,G.jsx)(Co,{onLoadMore:()=>le(e.id),enabled:ie(e.id)&&!ae(e.id)})]})})})})]})})},e.id)})})})})})})})]})}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col px-3 pb-3`,children:[(0,G.jsxs)(`div`,{className:Ge,children:[(0,G.jsxs)(`button`,{type:`button`,className:Ke,onClick:ye,"aria-expanded":!l,children:[(0,G.jsx)(`span`,{className:`truncate`,children:U(`conversations`)}),(0,G.jsx)(A,{className:W(qe,!l&&`rotate-90`)})]}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:W(at,`quickforge-sidebar-section-icon`),onClick:Ie,"aria-label":U(`newChat`),children:(0,G.jsx)(s,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:W(Je,`flex-1 min-h-0`,l?Xe:Ye),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.jsx)(`div`,{className:`h-full overflow-y-auto`,children:C.length===0&&!P?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noSavedConversations`)}):(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[C.map(e=>{let t=_===e.id,n=It===e.id,i=Bt===e.id;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>gn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),_n(e.id)},children:[(0,G.jsxs)(`button`,{className:ft,type:`button`,"aria-busy":v===e.id,onClick:()=>je(e.id),children:[(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]}),e.pinnedAt?(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}):null,(0,G.jsx)(`span`,{className:W(vt,!n&>),children:xo(x===`createdAt`?e.createdAt:e.lastModified)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>On(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>En(t,e.id),"aria-label":e.pinnedAt?U(`unpinSession`):U(`pinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>Dn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-4`})})]})})]})})},e.id)}),(0,G.jsx)(Co,{onLoadMore:L,enabled:P&&!I})]})})})})]})]}):null,(0,G.jsxs)(`div`,{className:`mt-auto shrink-0 border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 py-3`,children:[Be&&Ve?(0,G.jsxs)(`button`,{type:`button`,className:W($e,`relative mb-2 w-full border border-primary/30 bg-primary/5 text-primary hover:bg-primary/10`),onClick:Re,"aria-label":U(`newVersionAvailable`,{version:Ve}),title:U(`newVersionAvailable`,{version:Ve}),children:[(0,G.jsx)(`span`,{className:W(it,`text-primary/80`),children:(0,G.jsx)(F,{className:`size-4`})}),e?(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-xs font-medium leading-tight`,children:U(`newVersionAvailable`,{version:Ve})}),V?(0,G.jsx)(`span`,{className:`block truncate text-[11px] leading-tight text-primary/70`,children:U(`newVersionAvailableSub`,{current:V})}):null]}):null,e&&ze?(0,G.jsx)(`span`,{className:`shrink-0 rounded-full px-1.5 py-0.5 text-[11px] text-primary/60 transition-colors hover:bg-primary/15 hover:text-primary`,role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),ze()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),ze())},children:U(`updateLater`)}):null,e?null:(0,G.jsx)(`span`,{className:`absolute right-1 top-1 size-2 rounded-full bg-primary`})]}):null,(0,G.jsxs)(`button`,{type:`button`,className:W($e,`min-h-9 w-full shrink-0 rounded-lg`,nt),onClick:Le,"aria-label":U(`settings`),title:U(`settings`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(B,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`settings`)}):null]})]}),Ht?(()=>{let e=dn.find(e=>e.session.id===Ht.sessionId)?.session;if(!e)return null;let t=Ue?.sessionId===e.id;return(0,G.jsxs)(`div`,{className:`pointer-events-none fixed z-50 w-[min(24rem,calc(100vw-1rem))] max-w-sm rounded-2xl border border-border bg-popover px-4 py-3 text-left shadow-quickforge`,style:{left:Ht.x,top:Ht.y,transform:`translateY(-50%)`},children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium leading-5 text-foreground/92`,children:Mt(e.title)}),t&&Ue?.gitBranch?(0,G.jsxs)(`div`,{className:xt,children:[(0,G.jsx)(ce,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,G.jsx)(`span`,{className:`truncate`,children:Ue.gitBranch})]}):null,t&&Ue?.context?(0,G.jsxs)(`div`,{className:xt,title:Ue.context.title,children:[(0,G.jsx)(d,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,G.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:Ue.context.color}}),(0,G.jsx)(`span`,{className:`truncate`,children:Ue.context.label})]}):null]})})():null,At&&Y?(0,Vn.createPortal)((0,G.jsxs)(`div`,{className:`fixed z-50 overflow-hidden rounded-2xl border border-border bg-background p-1.5 shadow-quickforge`,style:{left:Y.x,top:Y.y,width:po},role:`menu`,"aria-label":U(`filterSort`),onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:yt,children:U(`sidebarView`)}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":b===`project`,className:bt,onClick:()=>xn(`project`),children:[(0,G.jsx)(T,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sidebarViewByProject`)}),b===`project`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":b===`timeline`,className:bt,onClick:()=>xn(`timeline`),children:[(0,G.jsx)(se,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sidebarViewTimeline`)}),b===`timeline`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]}),(0,G.jsx)(`div`,{className:`my-1 border-t`,style:{borderColor:`color-mix(in oklab, var(--muted-foreground) 50%, transparent)`}}),(0,G.jsx)(`div`,{className:yt,children:U(`sortBy`)}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":x===`updatedAt`,className:bt,onClick:()=>Sn(`updatedAt`),children:[(0,G.jsx)(se,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sortByUpdatedAt`)}),x===`updatedAt`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":x===`createdAt`,className:bt,onClick:()=>Sn(`createdAt`),children:[(0,G.jsx)(pe,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sortByCreatedAt`)}),x===`createdAt`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]})]}),document.body):null,an&&kt?(0,Vn.createPortal)((0,G.jsxs)(`div`,{className:`fixed z-50 min-w-48 overflow-hidden rounded-lg border border-border bg-background p-1 shadow-quickforge`,style:{left:kt.x,top:kt.y},onClick:e=>e.stopPropagation(),children:[(0,G.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:U(`openInExplorer`),"aria-label":U(`openInExplorer`),onClick:()=>{Cn(),ke(an)},children:[(0,G.jsx)(E,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{children:U(`openFolder`)})]}),(0,G.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:()=>{Cn(),Oe(an)},children:[(0,G.jsx)(me,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{children:U(`manageProjectSkills`)})]}),X===an.id?(0,G.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":U(`confirmDelete`),onClick:e=>Tn(e,an.id),children:(0,G.jsx)(`span`,{children:U(`confirm`)})}):(0,G.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":U(`deleteProject`),onClick:e=>wn(e,an.id),children:[(0,G.jsx)(k,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{children:U(`deleteProject`)})]})]}),document.body):null,Ct?(0,G.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:()=>wt(!1),children:(0,G.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-border bg-popover p-3 shadow-quickforge`,onMouseDown:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-input bg-background px-3 py-2`,children:[(0,G.jsx)(D,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,G.jsx)(`input`,{ref:un,value:Tt,onChange:e=>Et(e.target.value),onKeyDown:e=>{e.key===`Escape`&&wt(!1)},placeholder:U(`searchDialog`),className:`min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/45`})]}),(0,G.jsx)(`div`,{className:`mt-2 max-h-[50vh] overflow-y-auto`,children:Tt.trim()?fn.length>0?fn.map(({session:e,projectName:t})=>(0,G.jsxs)(`button`,{type:`button`,"aria-busy":v===e.id,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left transition-colors hover:bg-muted/28`,onClick:()=>mn(e.id),children:[mt(e.id),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-sm text-foreground/90`,children:Mt(e.title)}),(0,G.jsxs)(`span`,{className:`block truncate text-[11px] text-muted-foreground/55`,children:[t||U(`normalChat`),` · `,xo(e.lastModified)]})]})]},e.id)):(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noSearchResults`)}):(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`searchHint`)})})]})}):null]})});function Eo(){let[e,t]=(0,H.useState)(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(),[o,s]=(0,H.useState)(()=>new Set),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1);return{activeProject:e,projects:n,defaultWorkspace:i,expandedProjectIds:o,selectingProject:c,projectPickerOpen:u,loadProject:(0,H.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(typeof n.defaultWorkspaceRoot==`string`&&n.defaultWorkspaceRoot?{id:`default`,name:`workspace`,path:n.defaultWorkspaceRoot,lastOpenedAt:``}:void 0),s(e=>{let t=new Set(e);for(let e of Array.isArray(n.projects)?n.projects:[])t.add(e.id);return t})}catch(e){V.error(`Failed to load project:`,e)}},[]),switchActiveProject:(0,H.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:[]),s(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,H.useCallback)(async e=>{l(!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:[]),s(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 V.error(`Failed to select project:`,e),e}finally{l(!1)}},[]),selectProjectDirectory:(0,H.useCallback)(()=>{d(!0)},[]),setProjectPickerOpen:d,toggleProjectExpanded:(0,H.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),toggleAllProjectsExpanded:(0,H.useCallback)(()=>{s(e=>e.size===n.length&&n.length>0?new Set:new Set(n.map(e=>e.id)))},[n]),reorderProjects:(0,H.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){V.error(`Failed to reorder projects:`,e)}},[]),setActiveProject:t,setProjects:r,setExpandedProjectIds:s}}function Do(){let[e,t]=(0,H.useState)(`default`);return{agentAccessMode:e,setAgentAccessMode:t,initialize:(0,H.useCallback)(async e=>{let n=await fn(e);return t(n),n},[])}}var Oo=`quickforge-sync`;function ko(e){let t=(0,H.useRef)(e);(0,H.useEffect)(()=>{t.current=e});let n=(0,H.useRef)(q()),r=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(typeof BroadcastChannel<`u`)try{let e=new BroadcastChannel(Oo);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,H.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&(t.current.onSessionsChanged(),t.current.onProjectsChanged())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[]);let i=(0,H.useCallback)(e=>{let t={type:e,sourceTabId:n.current,timestamp:Date.now()};r.current?.postMessage(t)},[]);return{notifySessionsChanged:(0,H.useCallback)(()=>i(`sessions-changed`),[i]),notifyProjectsChanged:(0,H.useCallback)(()=>i(`projects-changed`),[i]),notifySettingsChanged:(0,H.useCallback)(()=>i(`settings-changed`),[i])}}function Ao(e){return e===`assistant`||e===`user`||e===`user-with-attachments`}function jo(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}return[...e,t]}if(Ao(t.role)){let n=t.timestamp;if(n!==void 0){let r=e.findIndex(e=>e.role===t.role&&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 Mo(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function No(e){if(!Mo(e))return;let t=e.quickforgeTiming;if(!Mo(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 Po(e,t){return Mo(e)?{...e,quickforgeTiming:t}:{quickforgeTiming:t}}function Fo(e,t){let n=e.quickforgeTiming??No(e.partialResult?.details)??{startedAt:Date.now()};return{...e,partialResult:e.partialResult??{content:[],details:{quickforgeTiming:n,sessionId:t,toolCallId:e.toolCallId}}}}function Io(e,t,n){if(!t.toolCallId||!t.toolName)return e;let r=n?t.partialResult:t.result;if(!r)return e;let i=No(r.details)??t.quickforgeTiming;if(!i){let n=e.findIndex(e=>e.role===`toolResult`&&e.toolCallId===t.toolCallId);n>=0&&(i=No(e[n].details))}let a=i?Po(r.details,i):r.details,o=Mo(a)?{...a,sessionId:a.sessionId??t.sessionId,toolCallId:a.toolCallId??t.toolCallId}:a;return jo(e,{role:`toolResult`,toolCallId:t.toolCallId,toolName:t.toolName,content:r.content??[],details:o,isError:n?!1:t.isError,timestamp:Date.now()})}function Lo(){return``}var Ro=5e3,zo=15e3,Bo=new class{eventSource=null;handlersBySession=new Map;baseUrl=``;reconnectTimer=null;reconnectDelay=1e3;directBaseUrl=Lo();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`,`session_created`,`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 Vo(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 Ho(e,t=``){return Bo.subscribeAll(t,e)}var Uo=class e{state;streamFn=Be;getApiKey;sessionId;listeners=new Set;unsubscribeSse;baseUrl;disposed=!1;_syncingThinkingLevel=!1;pollTimer=null;refreshPromise=null;statusPromise=null;lastSseEventAt=Date.now();lastServerStateVersion=0;nextPromptCapabilities=[];planMode=!1;onPlanModeConsumed;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??[],accessMode:J(t.accessMode,At(t.yoloMode)),yoloMode:Y(J(t.accessMode,At(t.yoloMode))),isStreaming:t.isStreaming??!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null,pendingToolApproval:t.pendingToolApproval??null,pendingAutoCompactApproval:t.pendingAutoCompactApproval??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=Bo.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):[]}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed)return;if(this.state.isStreaming){V.warn(`Ignored prompt while agent is already streaming`);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,r=this.planMode?{type:`plan`}:void 0;if(this.nextPromptCapabilities=[],this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}let i=this.state.messages.length,a=t;this.state.messages=[...this.state.messages,a],this.state.contextUsage=null,this.emitToListeners({type:`message_start`,message:a}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`}));let o=new AbortController,s=setTimeout(()=>o.abort(),3e4),c=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/prompt`;fetch(c,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:a,selectedCapabilities:n,command:r}),signal:o.signal}).then(e=>{if(clearTimeout(s),!e.ok)throw Error(`Failed to send prompt: HTTP ${e.status}`)}).catch(e=>{clearTimeout(s);let t=e instanceof Error?e.message:String(e);V.error(`Failed to send prompt:`,e),this.state.messages.length===i+1&&this.state.messages[this.state.messages.length-1]===a&&(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=>{V.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=>{V.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=>{V.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,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null}async updateAccessMode(e){let t=J(e),n=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/access-mode`,r=await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accessMode:t})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||`Failed to sync Agent access mode: HTTP ${r.status}`)}this.state.accessMode=t,this.state.yoloMode=Y(t)}async updateYoloMode(e){await this.updateAccessMode(e?`full-access`:`default`)}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=>{V.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=>{V.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}`)}this.state.pendingToolApproval?.toolCallId===e&&(this.state.pendingToolApproval=null)}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}`)}this.state.pendingToolApproval?.toolCallId===e&&(this.state.pendingToolApproval=null)}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}`)}this.state.pendingAutoCompactApproval?.approvalId===e&&(this.state.pendingAutoCompactApproval=null)}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}`)}this.state.pendingAutoCompactApproval?.approvalId===e&&(this.state.pendingAutoCompactApproval=null)}dispose(){this.disposed=!0,this.pollTimer&&=(clearInterval(this.pollTimer),null),this.statusPromise=null,this.unsubscribeSse?.(),this.unsubscribeSse=void 0,this.listeners.clear()}handleSseEvent(e){if(this.noteSseEvent(e)){switch(e.type){case`state`:{let t=e;if(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.accessMode!==void 0||t.yoloMode!==void 0){let e=J(t.accessMode,At(t.yoloMode));this.state.accessMode=e,this.state.yoloMode=Y(e)}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,t.pendingToolApproval!==void 0&&(this.state.pendingToolApproval=t.pendingToolApproval),t.pendingAutoCompactApproval!==void 0&&(this.state.pendingAutoCompactApproval=t.pendingAutoCompactApproval);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.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,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,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,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,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,t.errorMessage&&(this.state.errorMessage=t.errorMessage),this.emitToListeners(e)});return}case`message_end`:{let t=e;if(t.message){this.state.messages=jo(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`:{let t=e.error;this.state.errorMessage=t||`Unknown error`,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null;break}case`title_updated`:break;case`session_forked`:break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=Io(this.state.messages,Fo(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=Io(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=Io(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`auto_compact_threshold_reached`:break;case`tool_approval_required`:{let t=e;typeof t.toolCallId==`string`&&typeof t.toolName==`string`&&(this.state.pendingToolApproval=t,this.state.pendingAutoCompactApproval=null);break}case`auto_compact_approval_required`:{let t=e;typeof t.approvalId==`string`&&(this.state.pendingAutoCompactApproval=t,this.state.pendingToolApproval=null);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;if(typeof t==`number`&&Number.isFinite(t)){if(t<this.lastServerStateVersion)return!1;this.lastServerStateVersion=t}return!0}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<zo||this.refreshStatusFromServer()},Ro))}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){let e=this.state.isStreaming;this.stopStateWatchdog(),await this.refreshStateFromServer({notify:!0,forceMessages:!0}),e&&this.state.isStreaming&&(this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,this.emitToListeners({type:`agent_end`,messages:this.state.messages}));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(),a=typeof i.stateVersion==`number`&&Number.isFinite(i.stateVersion)?i.stateVersion:void 0;if(a!==void 0&&a<this.lastServerStateVersion||n!==this.stateVersion)return;a!==void 0&&(this.lastServerStateVersion=a);let o=!!(i.messages&&(e?.forceMessages||i.messages.length>this.state.messages.length||!this.state.isStreaming&&i.messages.length===this.state.messages.length));if(o&&(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.accessMode!==void 0||i.yoloMode!==void 0){let e=J(i.accessMode,At(i.yoloMode));this.state.accessMode=e,this.state.yoloMode=Y(e)}if(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.pendingToolApproval!==void 0&&(this.state.pendingToolApproval=i.pendingToolApproval),i.pendingAutoCompactApproval!==void 0&&(this.state.pendingAutoCompactApproval=i.pendingAutoCompactApproval),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(),this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null),e?.notify&&t&&!i.isStreaming){this.stateVersion++,this.emitToListeners({type:`agent_end`,messages:this.state.messages});return}}if(e?.notify)if(i.isStreaming&&o){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,accessMode:n.accessMode,yoloMode:n.yoloMode??Y(J(n.accessMode)),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??[],accessMode:J(a.accessMode,n.accessMode??a.yoloMode??n.yoloMode),yoloMode:!!(a.yoloMode??n.yoloMode),isStreaming:!!a.isStreaming,errorMessage:a.errorMessage,contextCompaction:a.contextCompaction,contextUsage:a.contextUsage,pendingToolApproval:a.pendingToolApproval,pendingAutoCompactApproval:a.pendingAutoCompactApproval,stateVersion:a.stateVersion}})}},Wo=class{sessionId;streamFn=Be;getApiKey;scope;project;createAgent;listeners=new Set;disposed=!1;realAgentPromise;promotedAgent;nextPromptCapabilities=[];planMode=!1;onPlanModeConsumed;state;constructor(e){this.sessionId=`pending-${q()}`,this.scope=e.scope,this.project=e.project,this.createAgent=e.createAgent;let t=J(e.accessMode,e.yoloMode?`full-access`:`default`);this.state={systemPrompt:``,model:e.model,thinkingLevel:e.thinkingLevel,messages:[],tools:[],accessMode:t,yoloMode:Y(t),isStreaming:!1,pendingToolCalls:new Set,contextCompaction:null,contextUsage:null}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(e){this.nextPromptCapabilities=Array.isArray(e)?e.slice(0,4):[]}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed||this.state.isStreaming)return;let t=this.normalizePromptInput(e),n=this.state.messages.length;this.state.messages=[...this.state.messages,t],this.state.contextUsage=null,this.emitToListeners({type:`message_start`,message:t}),this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`});let r;try{r=await this.ensureRealAgent()}catch(e){this.state.messages.length===n+1&&this.state.messages[this.state.messages.length-1]===t&&(this.state.messages=this.state.messages.slice(0,-1));let r=e instanceof Error?e.message:String(e);throw this.state.errorMessage=r,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.emitToListeners({type:`error`,error:r}),this.emitToListeners({type:`agent_end`,messages:this.state.messages}),e}r.setNextPromptCapabilities(this.nextPromptCapabilities),r.setPlanMode(this.planMode,this.onPlanModeConsumed),this.nextPromptCapabilities=[],this.planMode=!1,this.onPlanModeConsumed=void 0,await r.prompt(t)}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 updateAccessMode(e){let t=J(e);this.state.accessMode=t,this.state.yoloMode=Y(t);let n=await this.realAgentPromise;n&&await n.updateAccessMode(t)}async updateYoloMode(e){await this.updateAccessMode(e?`full-access`:`default`)}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()}normalizePromptInput(e){return 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}emitToListeners(e){for(let t of this.listeners)try{t(e)}catch{}}async ensureRealAgent(){if(!this.realAgentPromise){let e=q();this.realAgentPromise=this.createAgent({model:this.state.model,thinkingLevel:this.state.thinkingLevel,tools:[]},e,{scope:this.scope,project:this.project,attachToView:!0,accessMode:this.state.accessMode,yoloMode:this.state.yoloMode}).then(e=>(this.disposed&&this.promotedAgent!==e&&e.dispose(),e))}return this.realAgentPromise}};function Go(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 Ko(e){return e.role===`assistant`?Go(e.content,`
|
|
60
|
+
`},wr={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 Tr(e){let{announcements:t=wr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Cr}=e,{announce:a,announcement:o}=yr(),s=or(`DndLiveRegion`),[c,l]=(0,H.useState)(!1);if((0,H.useEffect)(()=>{l(!0)},[]),xr((0,H.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=H.createElement(H.Fragment,null,H.createElement(_r,{id:r,value:i.draggable}),H.createElement(vr,{id:s,announcement:o}));return n?(0,Vn.createPortal)(u,n):u}var Er;(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`})(Er||={});function Dr(){}function Or(e,t){return(0,H.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function kr(){var e=[...arguments];return(0,H.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Ar=Object.freeze({x:0,y:0});function jr(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Mr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Nr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Pr(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Fr(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 Ir=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Fr(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=jr(Fr(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Mr)};function Lr(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 Rr=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=Lr(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Nr)};function zr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Br(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ar}function Vr(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 Hr=Vr(1);function Ur(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 Wr(e,t,n){let r=Ur(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 Gr={ignoreTransform:!1};function Kr(e,t){t===void 0&&(t=Gr);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=qn(e).getComputedStyle(e);t&&(n=Wr(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 qr(e){return Kr(e,{ignoreTransform:!0})}function Jr(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Yr(e,t){return t===void 0&&(t=qn(e).getComputedStyle(e)),t.position===`fixed`}function Xr(e,t){t===void 0&&(t=qn(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 Zr(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Jn(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Yn(i)||Xn(i)||n.includes(i))return n;let a=qn(e).getComputedStyle(i);return i!==e&&Xr(i,a)&&n.push(i),Yr(i,a)?n:r(i.parentNode)}return e?r(e):n}function Qr(e){let[t]=Zr(e,1);return t??null}function $r(e){return!Wn||!e?null:Gn(e)?e:Kn(e)?Jn(e)||e===Zn(e).scrollingElement?window:Yn(e)?e:null:null}function ei(e){return Gn(e)?e.scrollX:e.scrollLeft}function ti(e){return Gn(e)?e.scrollY:e.scrollTop}function ni(e){return{x:ei(e),y:ti(e)}}var ri;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(ri||={});function ii(e){return!Wn||!e?!1:e===document.scrollingElement}function ai(e){let t={x:0,y:0},n=ii(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 oi={x:.2,y:.2};function si(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=oi);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=ai(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=ri.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=ri.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=ri.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=ri.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function ci(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 li(e){return e.reduce((e,t)=>cr(e,ni(t)),Ar)}function ui(e){return e.reduce((e,t)=>e+ei(t),0)}function di(e){return e.reduce((e,t)=>e+ti(t),0)}function fi(e,t){if(t===void 0&&(t=Kr),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Qr(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var pi=[[`x`,[`left`,`right`],ui],[`y`,[`top`,`bottom`],di]],mi=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=Zr(t),r=li(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of pi)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})}},hi=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 gi(e){let{EventTarget:t}=qn(e);return e instanceof t?e:Zn(e)}function _i(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 vi;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(vi||={});function yi(e){e.preventDefault()}function bi(e){e.stopPropagation()}var Q;(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`})(Q||={});var xi={start:[Q.Space,Q.Enter],cancel:[Q.Esc],end:[Q.Space,Q.Enter,Q.Tab]},Si=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Q.Right:return{...n,x:n.x+25};case Q.Left:return{...n,x:n.x-25};case Q.Down:return{...n,y:n.y+25};case Q.Up:return{...n,y:n.y-25}}},Ci=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 hi(Zn(t)),this.windowListeners=new hi(qn(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vi.Resize,this.handleCancel),this.windowListeners.add(vi.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vi.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&fi(n),t(Ar)}handleKeyDown(e){if(dr(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=xi,coordinateGetter:a=Si,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}:Ar;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=lr(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}=ai(n),p=ci(n),m={x:Math.min(i===Q.Right?p.right-p.width/2:p.right,Math.max(i===Q.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Q.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Q.Down?p.top:p.top+p.height/2,u.y))},h=i===Q.Right&&!s||i===Q.Left&&!c,g=i===Q.Down&&!l||i===Q.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Q.Right&&e<=d.x||i===Q.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Q.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===Q.Down&&e<=d.y||i===Q.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Q.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,cr(lr(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()}};Ci.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=xi,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 wi(e){return!!(e&&`distance`in e)}function Ti(e){return!!(e&&`delay`in e)}var Ei=class{constructor(e,t,n){n===void 0&&(n=gi(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=Zn(i),this.documentListeners=new hi(this.document),this.listeners=new hi(n),this.windowListeners=new hi(qn(i)),this.initialCoordinates=pr(r)??Ar,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(vi.Resize,this.handleCancel),this.windowListeners.add(vi.DragStart,yi),this.windowListeners.add(vi.VisibilityChange,this.handleCancel),this.windowListeners.add(vi.ContextMenu,yi),this.documentListeners.add(vi.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ti(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(wi(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(vi.Click,bi,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vi.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=pr(e)??Ar,s=lr(n,o);if(!t&&a){if(wi(a)){if(a.tolerance!=null&&_i(s,a.tolerance))return this.handleCancel();if(_i(s,a.distance))return this.handleStart()}if(Ti(a)&&_i(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===Q.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Di={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Oi=class extends Ei{constructor(e){let{event:t}=e,n=Zn(t.target);super(e,Di,n)}};Oi.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 ki={move:{name:`mousemove`},end:{name:`mouseup`}},Ai;(function(e){e[e.RightClick=2]=`RightClick`})(Ai||={});var ji=class extends Ei{constructor(e){super(e,ki,Zn(e.event.target))}};ji.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Ai.RightClick?!1:(r?.({event:n}),!0)}}];var Mi={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Ni=class extends Ei{constructor(e){super(e,Mi)}static setup(){return window.addEventListener(Mi.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Mi.move.name,e)};function e(){}}};Ni.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 Pi;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Pi||={});var Fi;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Fi||={});function Ii(e){let{acceleration:t,activator:n=Pi.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Fi.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Ri({delta:d,disabled:!a}),[m,h]=er(),g=(0,H.useRef)({x:0,y:0}),_=(0,H.useRef)({x:0,y:0}),v=(0,H.useMemo)(()=>{switch(n){case Pi.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Pi.DraggableRect:return i}},[n,i,c]),y=(0,H.useRef)(null),b=(0,H.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,H.useMemo)(()=>s===Fi.TreeOrder?[...l].reverse():l,[s,l]);(0,H.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}=si(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 Li={x:{[ri.Backward]:!1,[ri.Forward]:!1},y:{[ri.Backward]:!1,[ri.Forward]:!1}};function Ri(e){let{delta:t,disabled:n}=e,r=ir(t);return nr(e=>{if(n||!r||!e)return Li;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[ri.Backward]:e.x[ri.Backward]||i.x===-1,[ri.Forward]:e.x[ri.Forward]||i.x===1},y:{[ri.Backward]:e.y[ri.Backward]||i.y===-1,[ri.Forward]:e.y[ri.Forward]||i.y===1}}},[n,t,r])}function zi(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return nr(e=>t==null?null:r??e??null,[r,t])}function Bi(e,t){return(0,H.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 Vi;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Vi||={});var Hi;(function(e){e.Optimized=`optimized`})(Hi||={});var Ui=new Map;function Wi(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,H.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,H.useRef)(e),d=g(),f=tr(d),p=(0,H.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,H.useRef)(null),h=nr(t=>{if(d&&!n)return Ui;if(!t||t===Ui||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 mi(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,H.useEffect)(()=>{u.current=e},[e]),(0,H.useEffect)(()=>{d||p()},[n,d]),(0,H.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,H.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 Vi.Always:return!1;case Vi.BeforeDragging:return n;default:return!n}}}function Gi(e,t){return nr(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Ki(e,t){return Gi(e,t)}function qi(e){let{callback:t,disabled:n}=e,r=$n(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Ji(e){let{callback:t,disabled:n}=e,r=$n(t),i=(0,H.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,H.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Yi(e){return new mi(Kr(e),e)}function Xi(e,t,n){t===void 0&&(t=Yi);let[r,i]=(0,H.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=qi({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=Ji({callback:a});return Qn(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Zi(e){return Br(e,Gi(e))}var Qi=[];function $i(e){let t=(0,H.useRef)(e),n=nr(n=>e?n&&n!==Qi&&e&&t.current&&e.parentNode===t.current.parentNode?n:Zr(e):Qi,[e]);return(0,H.useEffect)(()=>{t.current=e},[e]),n}function ea(e){let[t,n]=(0,H.useState)(null),r=(0,H.useRef)(e),i=(0,H.useCallback)(e=>{let t=$r(e.target);t&&n(e=>e?(e.set(t,ni(t)),new Map(e)):null)},[]);return(0,H.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=$r(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,ni(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=>{$r(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,H.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>cr(e,t),Ar):li(e):Ar,[e,t])}function ta(e,t){t===void 0&&(t=[]);let n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{n.current=null},t),(0,H.useEffect)(()=>{let t=e!==Ar;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?lr(e,n.current):Ar}function na(e){(0,H.useEffect)(()=>{if(!Wn)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 ra(e,t){return(0,H.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function ia(e){return(0,H.useMemo)(()=>e?Jr(e):null,[e])}var aa=[];function oa(e,t){t===void 0&&(t=Kr);let[n]=e,r=ia(n?qn(n):null),[i,a]=(0,H.useState)(aa);function o(){a(()=>e.length?e.map(e=>ii(e)?r:new mi(t(e),e)):aa)}let s=Ji({callback:o});return Qn(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function sa(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Yn(t)?t:e}function ca(e){let{measure:t}=e,[n,r]=(0,H.useState)(null),i=Ji({callback:(0,H.useCallback)(e=>{for(let{target:n}of e)if(Yn(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=rr((0,H.useCallback)(e=>{let n=sa(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,H.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var la=[{sensor:Oi,options:{}},{sensor:Ci,options:{}}],ua={current:{}},da={draggable:{measure:qr},droppable:{measure:qr,strategy:Vi.WhileDragging,frequency:Hi.Optimized},dragOverlay:{measure:Kr}},fa=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}},pa={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new fa,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Dr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:da,measureDroppableContainers:Dr,windowRect:null,measuringScheduled:!1},ma={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Dr,draggableNodes:new Map,over:null,measureDroppableContainers:Dr},ha=(0,H.createContext)(ma),ga=(0,H.createContext)(pa);function _a(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new fa}}}function va(e,t){switch(t.type){case Er.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Er.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 Er.DragEnd:case Er.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Er.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new fa(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Er.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 fa(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Er.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new fa(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ya(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,H.useContext)(ha),a=ir(r),o=ir(n?.id);return(0,H.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!dr(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=hr(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function ba(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function xa(e){return(0,H.useMemo)(()=>({draggable:{...da.draggable,...e?.draggable},droppable:{...da.droppable,...e?.droppable},dragOverlay:{...da.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Sa(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,H.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Qn(()=>{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=Br(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=Qr(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Ca=(0,H.createContext)({...Ar,scaleX:1,scaleY:1}),wa;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(wa||={});var Ta=(0,H.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=la,collisionDetection:o=Rr,measuring:s,modifiers:c,...l}=e,[u,d]=(0,H.useReducer)(va,void 0,_a),[f,p]=Sr(),[m,h]=(0,H.useState)(wa.Uninitialized),g=m===wa.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,H.useRef)({initial:null,translated:null}),C=(0,H.useMemo)(()=>_==null?null:{id:_,data:x?.data??ua,rect:S},[_,x]),w=(0,H.useRef)(null),[T,E]=(0,H.useState)(null),[D,O]=(0,H.useState)(null),k=tr(l,Object.values(l)),ee=or(`DndDescribedBy`,t),A=(0,H.useMemo)(()=>b.getEnabled(),[b]),j=xa(s),{droppableRects:te,measureDroppableContainers:M,measuringScheduled:N}=Wi(A,{dragging:g,dependencies:[y.x,y.y],config:j.droppable}),P=zi(v,_),F=(0,H.useMemo)(()=>D?pr(D):null,[D]),I=Oe(),L=Ki(P,j.draggable.measure);Sa({activeNode:_==null?null:v.get(_),config:I.layoutShiftCompensation,initialRect:L,measure:j.draggable.measure});let R=Xi(P,j.draggable.measure,L),ne=Xi(P?P.parentElement:null),z=(0,H.useRef)({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=b.getNodeFor(z.current.over?.id),B=ca({measure:j.dragOverlay.measure}),ie=B.nodeRef.current??P,ae=g?B.rect??R:null,oe=!!(B.nodeRef.current&&B.rect),se=Zi(oe?null:R),ce=ia(ie?qn(ie):null),le=$i(g?re??P:null),ue=oa(le),de=ba(c,{transform:{x:y.x-se.x,y:y.y-se.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:R,containerNodeRect:ne,draggingNodeRect:ae,over:z.current.over,overlayNodeRect:B.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),fe=F?cr(F,y):null,pe=ea(le),me=ta(pe),he=ta(pe,[R]),ge=cr(de,me),_e=ae?Hr(ae,de):null,ve=C&&_e?o({active:C,collisionRect:_e,droppableRects:te,droppableContainers:A,pointerCoordinates:fe}):null,ye=Pr(ve,`id`),[be,xe]=(0,H.useState)(null),Se=zr(oe?de:cr(de,he),be?.rect??null,R),Ce=(0,H.useRef)(null),we=(0,H.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;Ce.current=new n({active:w.current,activeNode:i,event:a,options:r,context:z,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,Vn.unstable_batchedUpdates)(()=>{r?.(i),h(wa.Initializing),d({type:Er.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ce.current),O(a)})},onMove(e){d({type:Er.DragMove,coordinates:e})},onEnd:o(Er.DragEnd),onCancel:o(Er.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=z.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Er.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Er.DragCancel)}w.current=null,(0,Vn.unstable_batchedUpdates)(()=>{d({type:e}),h(wa.Uninitialized),xe(null),E(null),O(null),Ce.current=null;let t=e===Er.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Te=Bi(a,(0,H.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,we(n,t))},[v,we]));na(a),Qn(()=>{R&&m===wa.Initializing&&h(wa.Initialized)},[R,m]),(0,H.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=z.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,Vn.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,H.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=z.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ye),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,Vn.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[ye]),Qn(()=>{z.current={activatorEvent:D,active:C,activeNode:P,collisionRect:_e,collisions:ve,droppableRects:te,draggableNodes:v,draggingNode:ie,draggingNodeRect:ae,droppableContainers:b,over:be,scrollableAncestors:le,scrollAdjustedTranslate:ge},S.current={initial:ae,translated:_e}},[C,P,ve,_e,v,ie,ae,te,b,be,le,ge]),Ii({...I,delta:y,draggingRect:_e,pointerCoordinates:fe,scrollableAncestors:le,scrollableAncestorRects:ue});let Ee=(0,H.useMemo)(()=>({active:C,activeNode:P,activeNodeRect:R,activatorEvent:D,collisions:ve,containerNodeRect:ne,dragOverlay:B,draggableNodes:v,droppableContainers:b,droppableRects:te,over:be,measureDroppableContainers:M,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:j,measuringScheduled:N,windowRect:ce}),[C,P,R,D,ve,ne,B,v,b,te,be,M,le,ue,j,N,ce]),De=(0,H.useMemo)(()=>({activatorEvent:D,activators:Te,active:C,activeNodeRect:R,ariaDescribedById:{draggable:ee},dispatch:d,draggableNodes:v,over:be,measureDroppableContainers:M}),[D,Te,C,R,d,ee,v,be,M]);return H.createElement(br.Provider,{value:p},H.createElement(ha.Provider,{value:De},H.createElement(ga.Provider,{value:Ee},H.createElement(Ca.Provider,{value:Se},i)),H.createElement(ya,{disabled:n?.restoreFocus===!1})),H.createElement(Tr,{...n,hiddenTextDescribedById:ee}));function Oe(){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}}}),Ea=(0,H.createContext)(null),Da=`button`,Oa=`Draggable`;function ka(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=or(Oa),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,H.useContext)(ha),{role:p=Da,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,H.useContext)(g?Ca:Ea),[v,y]=rr(),[b,x]=rr(),S=ra(o,t),C=tr(n);return Qn(()=>(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,H.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Da?!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 Aa(){return(0,H.useContext)(ga)}var ja=`Droppable`,Ma={timeout:25};function Na(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=or(ja),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,H.useContext)(ha),u=(0,H.useRef)({disabled:n}),d=(0,H.useRef)(!1),f=(0,H.useRef)(null),p=(0,H.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Ma,...i},_=tr(h??r),v=Ji({callback:(0,H.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]=rr((0,H.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=tr(t);return(0,H.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,H.useEffect)(()=>(s({type:Er.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Er.UnregisterDroppable,key:a,id:r})),[r]),(0,H.useEffect)(()=>{n!==u.current.disabled&&(s({type:Er.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 Pa(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Fa(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function Ia(e){return e!==null&&e>=0}function La(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 Ra(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var za={scaleX:1,scaleY:1},Ba=e=>{let{rects:t,activeNodeRect:n,activeIndex:r,overIndex:i,index:a}=e,o=t[r]??n;if(!o)return null;let s=Va(t,a,r);if(a===r){let e=t[i];return e?{x:r<i?e.left+e.width-(o.left+o.width):e.left-o.left,y:0,...za}:null}return a>r&&a<=i?{x:-o.width-s,y:0,...za}:a<r&&a>=i?{x:o.width+s,y:0,...za}:{x:0,y:0,...za}};function Va(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return!r||!i&&!a?0:n<t?i?r.left-(i.left+i.width):a.left-(r.left+r.width):a?a.left-(r.left+r.width):r.left-(i.left+i.width)}var Ha=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=Pa(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}},Ua={scaleX:1,scaleY:1},Wa=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,...Ua}:null}let s=Ga(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...Ua}:r<t&&r>=a?{x:0,y:o.height+s,...Ua}:{x:0,y:0,...Ua}};function Ga(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 Ka=`Sortable`,qa=H.createContext({activeIndex:-1,containerId:Ka,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Ha,disabled:{draggable:!1,droppable:!1}});function Ja(e){let{children:t,id:n,items:r,strategy:i=Ha,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=Aa(),d=or(Ka,n),f=s.rect!==null,p=(0,H.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,H.useRef)(p),v=!La(p,_.current),y=g!==-1&&h===-1||v,b=Ra(a);Qn(()=>{v&&m&&u(p)},[v,p,m,u]),(0,H.useEffect)(()=>{_.current=p},[p]);let x=(0,H.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:Fa(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return H.createElement(qa.Provider,{value:x},t)}var Ya=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return Pa(n,r,i).indexOf(t)},Xa=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},Za={duration:200,easing:`ease`},Qa=`transform`,$a=Z.Transition.toString({property:Qa,duration:0,easing:`linear`}),eo={roleDescription:`sortable`};function to(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,H.useState)(null),s=(0,H.useRef)(n);return Qn(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=Kr(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,H.useEffect)(()=>{a&&o(null)},[a]),a}function no(e){let{animateLayoutChanges:t=Xa,attributes:n,disabled:r,data:i,getNewIndex:a=Ya,id:o,strategy:s,resizeObserverConfig:c,transition:l=Za}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,H.useContext)(qa),y=ro(r,p),b=u.indexOf(o),x=(0,H.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,H.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=Na({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:ee,setNodeRef:A,listeners:j,isDragging:te,over:M,setActivatorNodeRef:N,transform:P}=ka({id:o,data:x,attributes:{...eo,...n},disabled:y.draggable}),F=Un(E,A),I=!!D,L=I&&!m&&Ia(f)&&Ia(g),R=!_&&te,ne=L?(R&&L?P:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,z=Ia(f)&&Ia(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,re=D?.id,B=(0,H.useRef)({activeId:re,items:u,newIndex:z,containerId:d}),ie=u!==B.current.items,ae=t({active:D,containerId:d,isDragging:te,isSorting:I,id:o,index:b,items:u,newIndex:B.current.newIndex,previousItems:B.current.items,previousContainerId:B.current.containerId,transition:l,wasDragging:B.current.activeId!=null}),oe=to({disabled:!ae,index:b,node:w,rect:C});return(0,H.useEffect)(()=>{I&&B.current.newIndex!==z&&(B.current.newIndex=z),d!==B.current.containerId&&(B.current.containerId=d),u!==B.current.items&&(B.current.items=u)},[I,z,d,u]),(0,H.useEffect)(()=>{if(re===B.current.activeId)return;if(re!=null&&B.current.activeId==null){B.current.activeId=re;return}let e=setTimeout(()=>{B.current.activeId=re},50);return()=>clearTimeout(e)},[re]),{active:D,activeIndex:f,attributes:ee,data:x,rect:C,index:b,newIndex:z,items:u,isOver:T,isSorting:I,isDragging:te,listeners:j,node:w,overIndex:g,over:M,setNodeRef:F,setActivatorNodeRef:N,setDroppableNodeRef:E,setDraggableNodeRef:A,transform:oe??ne,transition:se()};function se(){if(oe||ie&&B.current.newIndex===b)return $a;if(!(R&&!dr(O)||!l)&&(I||ae))return Z.Transition.toString({...l,property:Qa})}}function ro(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}Q.Down,Q.Right,Q.Up,Q.Left;function io(e){let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return null}function ao(e,t){let n=(0,H.useRef)(null),r=(0,H.useRef)(e);(0,H.useEffect)(()=>{r.current=e},[e]);let i=(0,H.useCallback)(e=>{n.current=e},[]);return(0,H.useEffect)(()=>{let e=n.current;if(!e||!t)return;let i=io(e),a=new IntersectionObserver(e=>{e[0]?.isIntersecting&&r.current()},{root:i,rootMargin:`100px`,threshold:0});return a.observe(e),()=>a.disconnect()},[t]),i}var oo=60*1e3,so=60*oo,co=24*so,lo=7*co,uo=365*co,fo=360,po=300,mo=192,ho=120,go=224,_o=244,vo=320,yo=320,bo=520,xo=.5;function So(){return typeof window>`u`?bo:Math.max(yo,Math.min(bo,window.innerWidth*xo))}function Co(e){return Math.min(So(),Math.max(yo,e))}function wo(e){if(!e)return``;let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);return n<so?U(`relativeMinuteShort`,{count:Math.max(1,Math.floor(n/oo))}):n<co?U(`relativeHourShort`,{count:Math.floor(n/so)}):n<lo?U(`relativeDayShort`,{count:Math.floor(n/co)}):n<uo?U(`relativeWeekShort`,{count:Math.floor(n/lo)}):U(`relativeYearShort`,{count:Math.floor(n/uo)})}function To(e){if(!e)return!1;let t=e.trim();return!t||t===`undefined`||t===`null`||t===`false`?!1:!Number.isNaN(Date.parse(t))}function Eo({onLoadMore:e,enabled:t}){let r=ao(e,t);return t?(0,G.jsx)(`div`,{ref:r,className:`flex items-center justify-center py-1`,children:(0,G.jsx)(n,{className:`size-3 animate-spin text-muted-foreground/45`})}):null}function Do({id:e,children:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=no({id:e});return(0,G.jsx)(`div`,{ref:i,style:{transform:Z.Translate.toString(a),transition:s?void 0:o},className:W(s&&`relative z-50 opacity-40`),children:t({listeners:r,attributes:n})})}var Oo=(0,H.memo)(function({sidebarOpen:e,variant:t=`desktop`,projectsCollapsed:a,pinnedCollapsed:c,conversationsCollapsed:l,projects:u,expandedProjectIds:f,activeProject:m,currentSessionId:_,loadingSessionId:v,sessionViewMode:b,sessionSortMode:x,globalSessions:C,pinnedSessions:w,pinnedHasMore:O,pinnedLoading:ee,sessionsForProject:j,projectTimelineSessions:te,projectTimelineHasMore:M,projectTimelineLoading:N,globalHasMore:P,globalLoading:I,onLoadMoreGlobal:L,onLoadMorePinned:re,projectHasMore:ie,projectLoading:ae,projectLoaded:oe,onLoadMoreProject:le,onLoadMoreProjectTimeline:ue,sessionTaskStatus:fe,selectingProject:he,onTogglePinnedCollapsed:_e,onToggleProjectsCollapsed:ve,onToggleConversationsCollapsed:ye,onToggleProjectExpanded:be,onToggleAllProjectsExpanded:xe,onReorderProjects:Se,onSelectProjectDirectory:Ce,onStartNewProjectChat:we,onOpenGlobalSkills:Te,onOpenAgents:Ee,onOpenScheduledTasks:De,onOpenProjectSkills:Oe,onOpenProjectInExplorer:ke,onDeleteProject:Ae,onLoadSession:je,onSessionViewModeChange:Me,onSessionSortModeChange:Ne,onTogglePinSession:Pe,onDeleteSession:Fe,onStartNewGlobalChat:Ie,onOpenSettings:Le,onOpenUpdate:Re,onDismissUpdate:ze,updateAvailable:Be,latestVersion:Ve,currentVersion:V,onToggleSidebar:He,currentSessionHoverInfo:Ue}){let We=`hover:bg-[var(--quickforge-sidebar-hover-bg)]`,Ge=`quickforge-sidebar-section-header group mb-1 flex w-full items-center gap-1 rounded-lg px-2 py-1 text-sm font-[350] leading-5 text-muted-foreground/50 transition-colors ${We}`,Ke=`quickforge-sidebar-section-toggle flex min-w-0 flex-1 items-center gap-1 text-left transition-colors`,qe=`quickforge-sidebar-section-icon size-4 shrink-0 text-current opacity-0 transition-[transform,opacity] duration-200 ease-out group-hover:opacity-100 group-focus-within:opacity-100 motion-reduce:transition-none`,Je=`grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,Ye=`grid-rows-[1fr] opacity-100`,Xe=`pointer-events-none grid-rows-[0fr] opacity-0`,Ze=`min-h-0 overflow-hidden`,Qe=`group relative flex items-center gap-2 overflow-hidden rounded-lg py-1.5 text-left transition-[background-color,color,box-shadow] duration-160 ease-out ${e?`px-2`:`justify-center px-0`} `,$e=`group relative flex items-center gap-2 overflow-hidden py-1.5 text-left transition-[background-color,color,box-shadow] duration-160 ease-out ${e?`px-2`:`justify-center px-0`}`,et=`bg-[var(--quickforge-sidebar-hover-bg)] text-foreground/84 shadow-[0_8px_22px_-20px_rgb(15_23_42_/_0.32)]`,tt=`text-foreground/80 ${We}`,nt=`text-muted-foreground/68 ${We} hover:text-foreground/80`,rt=`text-muted-foreground/70 ${We} hover:text-foreground/82`,it=`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground/55 transition-colors group-hover:text-foreground/70`,at=`size-7 shrink-0 rounded-full text-muted-foreground/55 transition-[background-color,color,box-shadow,opacity] duration-160 ease-out ${We} hover:text-foreground/85 `,ot=`quickforge-sidebar-section-icon ${at} pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100`,st=`pointer-events-none absolute inset-y-0 right-1 z-20 flex items-center gap-px rounded-r-lg bg-gradient-to-l from-[var(--quickforge-sidebar-hover-bg)] via-[var(--quickforge-sidebar-hover-bg)]/95 to-transparent pl-4 opacity-0 transition-opacity duration-160`,ct=`${st} group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100`,lt=`${st} group-hover:pointer-events-auto group-hover:opacity-100`,ut=`size-6 shrink-0 rounded-full text-muted-foreground/55 transition-[background-color,color,box-shadow] duration-160 ease-out ${We} hover:text-foreground/85 `,dt=`truncate text-sm font-[350] leading-5`,ft=`flex min-w-0 flex-1 items-center gap-2 text-left`,pt=`flex min-w-0 flex-1 items-center gap-1 truncate`,mt=e=>v===e?(0,G.jsx)(n,{className:`size-3 shrink-0 animate-spin text-muted-foreground/55`,"aria-hidden":`true`}):null,ht=`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 ${We} hover:text-foreground/85`,gt=`group-hover:pointer-events-none group-hover:opacity-0 group-focus-within:pointer-events-none group-focus-within:opacity-0`,_t=`font-[350] text-foreground/84`,vt=`quickforge-sidebar-session-time shrink-0 text-[11px] leading-4 transition-opacity duration-160`,yt=`px-3 pb-1 pt-2 text-xs font-[350] leading-4 text-muted-foreground/50`,bt=`flex w-full items-center gap-3 whitespace-nowrap rounded-xl px-3 py-2.5 text-left text-sm text-foreground/86 transition-colors hover:bg-muted/45`,xt=`mt-2 flex items-center gap-2 text-sm leading-5 text-muted-foreground/72`,St=t===`mobile`,[Ct,wt]=(0,H.useState)(!1),[Tt,Et]=(0,H.useState)(``),[Dt,Ot]=(0,H.useState)(null),[kt,q]=(0,H.useState)(null),[At,J]=(0,H.useState)(!1),[Y,jt]=(0,H.useState)(null),[X,Nt]=(0,H.useState)(null),[Pt,Ft]=(0,H.useState)(null),[It,Lt]=(0,H.useState)(null),[Rt,zt]=(0,H.useState)(null),[Bt,Vt]=(0,H.useState)(null),[Ht,Ut]=(0,H.useState)(null),[Wt,Gt]=(0,H.useState)(!1),[Kt,qt]=(0,H.useState)(vo),[Jt,Yt]=(0,H.useState)(!1),Xt=(0,H.useRef)(null),Zt=(0,H.useRef)(null),Qt=(0,H.useRef)(null),$t=(0,H.useRef)(null),en=(0,H.useRef)(null),tn=(0,H.useRef)(null),nn=(0,H.useRef)(null),rn=kr(Or(Oi,{activationConstraint:{distance:6}})),an=(0,H.useCallback)(e=>({...e.transform,x:0}),[]),on=(0,H.useMemo)(()=>u.map(e=>e.id),[u]),sn=(0,H.useMemo)(()=>u.find(e=>e.id===Dt),[Dt,u]),cn=(0,H.useMemo)(()=>new Map(u.map(e=>[e.id,e.name])),[u]),ln=(0,H.useMemo)(()=>{let e=new Set;return te.filter(t=>e.has(t.id)?!1:(e.add(t.id),!0)).map(e=>({session:e,projectName:e.projectId?cn.get(e.projectId)??U(`unknownProject`):U(`unknownProject`)}))},[cn,te]),un=(0,H.useMemo)(()=>w.filter(e=>To(e.pinnedAt)).map(e=>({session:e,sourceName:e.scope===`project`?e.projectId?cn.get(e.projectId)??U(`unknownProject`):U(`unknownProject`):U(`normalChat`)})),[w,cn]),dn=(0,H.useCallback)(()=>{Gt(!0),Ot(null),q(null),nn.current!==null&&(window.clearTimeout(nn.current),nn.current=null),Ut(null)},[]),fn=(0,H.useCallback)(()=>{Gt(!1)},[]),pn=(0,H.useCallback)(e=>{fn();let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=on.indexOf(t.id),i=on.indexOf(n.id);if(r===-1||i===-1)return;let a=[...on];a.splice(r,1),a.splice(i,0,t.id),Se(a)},[fn,on,Se]),mn=(0,H.useRef)(null),hn=(0,H.useMemo)(()=>{let e=un.map(({session:e,sourceName:t})=>({session:e,projectName:t})),t=u.flatMap(e=>j(e.id).map(t=>({session:t,projectName:e.name}))),n=te.map(e=>({session:e,projectName:e.projectId?cn.get(e.projectId)??U(`unknownProject`):U(`unknownProject`)})),r=C.map(e=>({session:e,projectName:``})),i=new Set;return[...e,...t,...n,...r].filter(({session:e})=>i.has(e.id)?!1:(i.add(e.id),!0))},[C,un,cn,te,u,j]),gn=Tt.trim()?hn.filter(({session:e,projectName:t})=>`${Mt(e.title)} ${t}`.toLowerCase().includes(Tt.trim().toLowerCase())).slice(0,8):[],_n=()=>{wt(!0),window.setTimeout(()=>mn.current?.focus(),0)},vn=e=>{je(e),wt(!1),Et(``)},yn=()=>{nn.current!==null&&(window.clearTimeout(nn.current),nn.current=null)},bn=(e,t)=>{if(St)return;let n=e.currentTarget.getBoundingClientRect(),r=Math.max(8,Math.min(n.right+8,window.innerWidth-392)),i=n.top+n.height/2;yn(),nn.current=window.setTimeout(()=>{nn.current=null,Ut({sessionId:t,x:r,y:i})},po)},xn=e=>{yn(),Ut(t=>t?.sessionId===e?null:t)},Sn=(e,t)=>{e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();Nt(null),Ot(e=>e===t?(q(null),null):(q({x:Math.max(8,Math.min(n.right-mo,window.innerWidth-mo-8)),y:Math.max(8,Math.min(n.bottom+4,window.innerHeight-ho-8))}),t))},Cn=e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();Ot(null),q(null),J(e=>e?(jt(null),!1):(jt({x:Math.max(8,Math.min(t.right-go,window.innerWidth-go-8)),y:Math.max(8,Math.min(t.bottom+6,window.innerHeight-_o-8))}),!0))},wn=(0,H.useCallback)(()=>{J(!1),jt(null)},[]),Tn=e=>{Me(e),wn()},En=e=>{Ne(e),wn()},Dn=(0,H.useCallback)(()=>{Ot(null),q(null),Nt(null)},[]),On=(e,t)=>{e.stopPropagation(),Nt(t)},kn=(e,t)=>{e.stopPropagation(),Ot(null),q(null),Ft(t),tn.current!==null&&window.clearTimeout(tn.current),tn.current=window.setTimeout(()=>{tn.current=null,Nt(e=>e===t?null:e),Promise.resolve(Ae(t)).catch(()=>{Ft(e=>e===t?null:e)})},fo)},An=(e,t)=>{e.currentTarget.blur(),Lt(t),Pe(t)},jn=(e,t)=>{e.stopPropagation(),e.currentTarget.blur(),zt(t)},Mn=(e,t)=>{e.stopPropagation(),Vt(t),xn(t),en.current!==null&&window.clearTimeout(en.current),en.current=window.setTimeout(()=>{en.current=null,zt(e=>e===t?null:e),Promise.resolve(Fe(t)).catch(()=>{Vt(e=>e===t?null:e)})},fo)},Nn=(0,H.useCallback)(()=>{let e=$t.current;e&&(document.body.style.cursor=e.cursor,document.body.style.userSelect=e.userSelect,$t.current=null)},[]),Pn=(0,H.useCallback)(e=>{if(Zt.current=null,Qt.current!==null&&(window.cancelAnimationFrame(Qt.current),Qt.current=null),typeof e==`number`){let t=Co(e);Xt.current&&(Xt.current.style.width=`${t}px`),qt(t)}Nn(),Yt(!1)},[Nn]);function Fn(e){let t=Xt.current?.getBoundingClientRect().width??Kt;Zt.current={startX:e.clientX,startWidth:t,currentWidth:t},$t.current={cursor:document.body.style.cursor,userSelect:document.body.style.userSelect},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,Yt(!0),e.preventDefault(),e.stopPropagation();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}function In(e){let t=Zt.current;!t||!Xt.current||(t.currentWidth=Co(t.startWidth+e.clientX-t.startX),Qt.current===null&&(Qt.current=window.requestAnimationFrame(()=>{Qt.current=null;let e=Zt.current;!e||!Xt.current||(Xt.current.style.width=`${e.currentWidth}px`)})))}function Ln(e){let t=Zt.current?.currentWidth;Pn(t);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}function Rn(){Pn(vo)}return(0,H.useEffect)(()=>()=>{en.current!==null&&window.clearTimeout(en.current),tn.current!==null&&window.clearTimeout(tn.current),nn.current!==null&&window.clearTimeout(nn.current),Qt.current!==null&&window.cancelAnimationFrame(Qt.current),Zt.current=null,Nn()},[Nn]),(0,H.useEffect)(()=>{if(!St&&e)return;let t=window.requestAnimationFrame(()=>Pn());return()=>window.cancelAnimationFrame(t)},[Pn,St,e]),(0,H.useEffect)(()=>{if(St)return;let e=()=>{Pn(Co(Zt.current?.currentWidth??Kt))};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[Pn,St,Kt]),(0,H.useEffect)(()=>{if(Dt)return window.addEventListener(`click`,Dn),window.addEventListener(`blur`,Dn),window.addEventListener(`resize`,Dn),()=>{window.removeEventListener(`click`,Dn),window.removeEventListener(`blur`,Dn),window.removeEventListener(`resize`,Dn)}},[Dt,Dn]),(0,H.useEffect)(()=>{if(At)return window.addEventListener(`click`,wn),window.addEventListener(`blur`,wn),window.addEventListener(`resize`,wn),()=>{window.removeEventListener(`click`,wn),window.removeEventListener(`blur`,wn),window.removeEventListener(`resize`,wn)}},[At,wn]),(0,G.jsxs)(`aside`,{ref:Xt,className:W(`relative z-10 min-h-0 shrink-0 overflow-hidden border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-[var(--quickforge-sidebar-bg)] transition-[width] duration-200 ease-out motion-reduce:transition-none`,St?`flex h-full w-80 max-w-[85vw] flex-col`:`hidden md:flex md:flex-col`,!St&&!e?`w-14`:void 0,Jt&&`transition-none`),style:!St&&e?{width:Kt,minWidth:yo,maxWidth:`min(${bo}px, ${xo*100}vw)`}:void 0,children:[!St&&e?(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":yo,"aria-valuemax":So(),"aria-valuenow":Math.round(Kt),className:W(`group absolute inset-y-0 right-0 z-30 w-2 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-border/20`,Jt&&`bg-border/25`),onDoubleClick:Rn,onPointerDown:Fn,onPointerMove:In,onPointerUp:Ln,onPointerCancel:Ln,children:(0,G.jsx)(`span`,{className:W(`absolute inset-y-0 right-0 w-px bg-border/70 opacity-0 transition-opacity`,Jt?`opacity-100`:`group-hover:opacity-100`)})}):null,(0,G.jsxs)(`div`,{className:`shrink-0 px-3 pt-3 pb-1`,children:[(0,G.jsx)(`div`,{className:W(Qe,`w-full`),children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(`img`,{src:`/favicon.svg`,alt:``,"aria-hidden":`true`,className:`size-5`})}),(0,G.jsx)(`button`,{type:`button`,className:W(at,`ml-auto inline-flex items-center justify-center`),onClick:He,"aria-label":U(`toggleSidebar`),title:U(`toggleSidebar`),children:(0,G.jsx)(h,{className:`size-4`})})]}):(0,G.jsxs)(`button`,{type:`button`,className:W(at,`group/toggle relative inline-flex items-center justify-center`),onClick:He,"aria-label":U(`toggleSidebar`),title:U(`toggleSidebar`),children:[(0,G.jsx)(`img`,{src:`/favicon.svg`,alt:``,"aria-hidden":`true`,className:`size-5 transition-opacity duration-160 group-hover/toggle:opacity-0 group-focus-visible/toggle:opacity-0`}),(0,G.jsx)(ne,{className:`absolute size-4 opacity-0 transition-opacity duration-160 group-hover/toggle:opacity-100 group-focus-visible/toggle:opacity-100`})]})}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`mt-4 w-full`,nt),onClick:Ie,"aria-label":U(`startNewChat`),title:U(`startNewChat`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(s,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`startNewChat`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:_n,"aria-label":U(`search`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(D,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`search`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:De,"aria-label":U(`scheduledTasks`),title:U(`scheduledTasks`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(S,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`scheduledTasks`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:Te,"aria-label":U(`manageGlobalSkills`),title:U(`manageGlobalSkills`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(g,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`skills`)}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:W(Qe,`w-full`,nt),onClick:Ee,"aria-label":U(`agentsTab`),title:U(`agentsTab`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(o,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`agentsTab`)}):null]})]}),e?(0,G.jsxs)(G.Fragment,{children:[un.length>0||ee?(0,G.jsxs)(`div`,{className:`shrink-0 px-3 pb-1 max-h-[28%] flex flex-col min-h-0 overflow-hidden`,children:[(0,G.jsx)(`div`,{className:Ge,children:(0,G.jsxs)(`button`,{type:`button`,className:Ke,onClick:_e,"aria-expanded":!c,children:[(0,G.jsx)(`span`,{className:`truncate`,children:U(`pinnedConversations`)}),(0,G.jsx)(A,{className:W(qe,!c&&`rotate-90`)})]})}),(0,G.jsx)(`div`,{className:W(Je,`flex-1 min-h-0`,c?Xe:Ye),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`space-y-0.5`,children:un.length===0?(0,G.jsxs)(`div`,{className:`flex items-center px-3 py-3 text-xs text-muted-foreground/55`,children:[(0,G.jsx)(n,{className:`mr-1.5 size-3 animate-spin`}),U(`loadingChatWorkspace`)]}):(0,G.jsxs)(G.Fragment,{children:[un.map(({session:e})=>{let t=_===e.id,n=It===e.id,i=Bt===e.id;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>bn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),xn(e.id)},children:[(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-busy":v===e.id,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>je(e.id),onKeyDown:t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),je(e.id))},children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]})}),(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}),(0,G.jsx)(`span`,{className:W(vt,!n&>),children:wo(e.pinnedAt)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>Mn(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>An(t,e.id),"aria-label":U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>jn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-3.5`})})]})})]})})},e.id)}),(0,G.jsx)(Eo,{onLoadMore:re,enabled:O&&!ee})]})})})})})]}):null,(0,G.jsx)(`div`,{className:`shrink-0 px-3 max-h-[55%] flex flex-col min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:`mb-0.5 flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:Ge,children:[(0,G.jsxs)(`button`,{type:`button`,className:Ke,onClick:ve,"aria-expanded":!a,children:[(0,G.jsx)(`span`,{className:`truncate`,children:U(`projects`)}),(0,G.jsx)(A,{className:W(qe,!a&&`rotate-90`)})]}),u.length>0&&(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ot,onClick:Cn,"aria-label":U(`filterSort`),title:U(`filterSort`),"aria-haspopup":`menu`,"aria-expanded":At,children:(0,G.jsx)(z,{className:`size-4`})}),u.length>0&&(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ot,onClick:xe,"aria-label":f.size===u.length?U(`collapseAllProjects`):U(`expandAllProjects`),children:f.size===u.length?(0,G.jsx)(ge,{className:`size-4`}):(0,G.jsx)(de,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ot,onClick:Ce,disabled:he,"aria-label":U(`addProject`),children:(0,G.jsx)(y,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:W(Je,`flex-1 min-h-0`,a?Xe:Ye),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.jsx)(`div`,{className:`h-full overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`space-y-0.5`,children:u.length===0?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noProjects`)}):b===`timeline`?ln.length===0?N?(0,G.jsxs)(`div`,{className:`flex items-center px-3 py-3 text-xs text-muted-foreground/55`,children:[(0,G.jsx)(n,{className:`mr-1.5 size-3 animate-spin`}),U(`loadingChatWorkspace`)]}):(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noConversations`)}):(0,G.jsxs)(G.Fragment,{children:[ln.map(({session:e})=>{let t=_===e.id,n=It===e.id,i=Bt===e.id,a=x===`createdAt`?e.createdAt:e.lastModified;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>bn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),xn(e.id)},children:[(0,G.jsxs)(`button`,{className:`flex min-w-0 flex-1 items-center gap-2 text-left`,type:`button`,"aria-busy":v===e.id,onClick:()=>je(e.id),children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]})}),e.pinnedAt?(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}):null,(0,G.jsx)(`span`,{className:W(vt,!n&>),children:wo(a)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>Mn(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>An(t,e.id),"aria-label":e.pinnedAt?U(`unpinSession`):U(`pinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>jn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-3.5`})})]})})]})})},e.id)}),(0,G.jsx)(Eo,{onLoadMore:ue,enabled:M&&!N})]}):(0,G.jsx)(Ta,{sensors:rn,collisionDetection:Ir,onDragStart:dn,onDragEnd:pn,onDragCancel:fn,measuring:{droppable:{strategy:Vi.Always}},modifiers:[an],children:(0,G.jsx)(Ja,{items:on,strategy:Wa,children:u.map(e=>{let t=j(e.id),i=!Wt&&f.has(e.id),a=m?.id===e.id,o=oe(e.id),c=Dt===e.id,l=Pt===e.id;return(0,G.jsx)(Do,{id:e.id,children:({listeners:u,attributes:d})=>(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,l?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:W(Qe,a?tt:nt,c&&`z-20 overflow-visible`,l&&`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`},...u,...d,children:[(0,G.jsx)(`button`,{type:`button`,className:it,onClick:()=>be(e.id),"aria-label":U(i?`collapseProject`:`expandProject`),children:i?(0,G.jsx)(E,{className:`size-4`}):(0,G.jsx)(T,{className:`size-4`})}),(0,G.jsx)(`button`,{className:`flex min-w-0 flex-1 items-center text-left`,type:`button`,title:e.path,onClick:()=>be(e.id),children:(0,G.jsx)(`span`,{className:W(dt,a&&`font-[350] text-foreground/80`),children:e.name})}),(0,G.jsxs)(`div`,{className:lt,children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>Sn(t,e.id),"aria-label":U(`moreOptions`),"aria-expanded":c,children:(0,G.jsx)(R,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:()=>we(e),"aria-label":U(`newProjectChat`),children:(0,G.jsx)(s,{className:`size-4`})})]})]}),(0,G.jsx)(`div`,{className:W(Je,Wt&&`transition-none`,i?Ye:Xe),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.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&&ae(e.id)?(0,G.jsxs)(`div`,{className:`flex items-center px-2 py-1.5 text-xs text-muted-foreground/55`,children:[(0,G.jsx)(n,{className:`mr-1.5 size-3 animate-spin`}),U(`loadingChatWorkspace`)]}):t.length===0&&!ie(e.id)?(0,G.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground/55`,children:U(`noConversations`)}):(0,G.jsxs)(G.Fragment,{children:[t.map(e=>{let t=_===e.id,n=It===e.id,i=Bt===e.id;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,`gap-1`,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>bn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),xn(e.id)},children:[(0,G.jsxs)(`button`,{className:ft,type:`button`,"aria-busy":v===e.id,onClick:()=>je(e.id),children:[(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]}),e.pinnedAt?(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}):null,(0,G.jsx)(`span`,{className:W(vt,!n&>),children:wo(x===`createdAt`?e.createdAt:e.lastModified)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>Mn(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>An(t,e.id),"aria-label":e.pinnedAt?U(`unpinSession`):U(`pinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>jn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-3.5`})})]})})]})})},e.id)}),(0,G.jsx)(Eo,{onLoadMore:()=>le(e.id),enabled:ie(e.id)&&!ae(e.id)})]})})})})]})})},e.id)})})})})})})})]})}),(0,G.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col px-3 pb-3`,children:[(0,G.jsxs)(`div`,{className:Ge,children:[(0,G.jsxs)(`button`,{type:`button`,className:Ke,onClick:ye,"aria-expanded":!l,children:[(0,G.jsx)(`span`,{className:`truncate`,children:U(`conversations`)}),(0,G.jsx)(A,{className:W(qe,!l&&`rotate-90`)})]}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:W(at,`quickforge-sidebar-section-icon`),onClick:Ie,"aria-label":U(`newChat`),children:(0,G.jsx)(s,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:W(Je,`flex-1 min-h-0`,l?Xe:Ye),children:(0,G.jsx)(`div`,{className:Ze,children:(0,G.jsx)(`div`,{className:`h-full overflow-y-auto`,children:C.length===0&&!P?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noSavedConversations`)}):(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[C.map(e=>{let t=_===e.id,n=It===e.id,i=Bt===e.id;return(0,G.jsx)(`div`,{className:W(`grid transition-[grid-template-rows,opacity,transform] duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,i?`grid-rows-[0fr] -translate-x-1 opacity-0`:`grid-rows-[1fr] translate-x-0 opacity-100`),children:(0,G.jsx)(`div`,{className:`min-h-0 overflow-hidden`,children:(0,G.jsxs)(`div`,{className:W(Qe,t?et:rt,i&&`pointer-events-none scale-[0.98] opacity-0 duration-[360ms] ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`),onMouseEnter:t=>bn(t,e.id),onMouseLeave:()=>{Lt(t=>t===e.id?null:t),i||zt(t=>t===e.id?null:t),xn(e.id)},children:[(0,G.jsxs)(`button`,{className:ft,type:`button`,"aria-busy":v===e.id,onClick:()=>je(e.id),children:[(0,G.jsxs)(`div`,{className:pt,children:[mt(e.id),fe(e)===`running`?(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-emerald-500`}):null,(0,G.jsx)(`span`,{className:W(dt,t&&_t),children:Mt(e.title)})]}),e.pinnedAt?(0,G.jsx)(`button`,{type:`button`,className:W(ht,!n&>),onClick:t=>{t.stopPropagation(),Pe(e.id)},"aria-label":U(`unpinSession`),title:U(`unpinSession`),children:(0,G.jsx)(r,{className:`size-3`})}):null,(0,G.jsx)(`span`,{className:W(vt,!n&>),children:wo(x===`createdAt`?e.createdAt:e.lastModified)})]}),(0,G.jsx)(`div`,{className:W(ct,n&&`hidden`),children:Rt===e.id?(0,G.jsx)(K,{variant:`destructive`,size:`sm`,className:`h-6 rounded-full px-2 text-xs`,onClick:t=>Mn(t,e.id),"aria-label":U(`confirmArchive`),title:U(`confirmArchive`),children:U(`confirm`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>An(t,e.id),"aria-label":e.pinnedAt?U(`unpinSession`):U(`pinSession`),children:(0,G.jsx)(r,{className:`size-3.5`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:ut,onClick:t=>jn(t,e.id),"aria-label":U(`archiveSession`),children:(0,G.jsx)(p,{className:`size-4`})})]})})]})})},e.id)}),(0,G.jsx)(Eo,{onLoadMore:L,enabled:P&&!I})]})})})})]})]}):null,(0,G.jsxs)(`div`,{className:`mt-auto shrink-0 border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 py-3`,children:[Be&&Ve?(0,G.jsxs)(`button`,{type:`button`,className:W($e,`relative mb-2 w-full border border-primary/30 bg-primary/5 text-primary hover:bg-primary/10`),onClick:Re,"aria-label":U(`newVersionAvailable`,{version:Ve}),title:U(`newVersionAvailable`,{version:Ve}),children:[(0,G.jsx)(`span`,{className:W(it,`text-primary/80`),children:(0,G.jsx)(F,{className:`size-4`})}),e?(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-xs font-medium leading-tight`,children:U(`newVersionAvailable`,{version:Ve})}),V?(0,G.jsx)(`span`,{className:`block truncate text-[11px] leading-tight text-primary/70`,children:U(`newVersionAvailableSub`,{current:V})}):null]}):null,e&&ze?(0,G.jsx)(`span`,{className:`shrink-0 rounded-full px-1.5 py-0.5 text-[11px] text-primary/60 transition-colors hover:bg-primary/15 hover:text-primary`,role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),ze()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),ze())},children:U(`updateLater`)}):null,e?null:(0,G.jsx)(`span`,{className:`absolute right-1 top-1 size-2 rounded-full bg-primary`})]}):null,(0,G.jsxs)(`button`,{type:`button`,className:W($e,`min-h-9 w-full shrink-0 rounded-lg`,nt),onClick:Le,"aria-label":U(`settings`),title:U(`settings`),children:[(0,G.jsx)(`span`,{className:it,children:(0,G.jsx)(B,{className:`size-4`})}),e?(0,G.jsx)(`span`,{className:dt,children:U(`settings`)}):null]})]}),Ht?(()=>{let e=hn.find(e=>e.session.id===Ht.sessionId)?.session;if(!e)return null;let t=Ue?.sessionId===e.id;return(0,G.jsxs)(`div`,{className:`pointer-events-none fixed z-50 w-[min(24rem,calc(100vw-1rem))] max-w-sm rounded-2xl border border-border bg-popover px-4 py-3 text-left shadow-quickforge`,style:{left:Ht.x,top:Ht.y,transform:`translateY(-50%)`},children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium leading-5 text-foreground/92`,children:Mt(e.title)}),t&&Ue?.gitBranch?(0,G.jsxs)(`div`,{className:xt,children:[(0,G.jsx)(ce,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,G.jsx)(`span`,{className:`truncate`,children:Ue.gitBranch})]}):null,t&&Ue?.context?(0,G.jsxs)(`div`,{className:xt,title:Ue.context.title,children:[(0,G.jsx)(d,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,G.jsx)(`span`,{className:`size-2 shrink-0 rounded-full`,style:{backgroundColor:Ue.context.color}}),(0,G.jsx)(`span`,{className:`truncate`,children:Ue.context.label})]}):null]})})():null,At&&Y?(0,Vn.createPortal)((0,G.jsxs)(`div`,{className:`fixed z-50 overflow-hidden rounded-2xl border border-border bg-background p-1.5 shadow-quickforge`,style:{left:Y.x,top:Y.y,width:go},role:`menu`,"aria-label":U(`filterSort`),onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:yt,children:U(`sidebarView`)}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":b===`project`,className:bt,onClick:()=>Tn(`project`),children:[(0,G.jsx)(T,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sidebarViewByProject`)}),b===`project`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":b===`timeline`,className:bt,onClick:()=>Tn(`timeline`),children:[(0,G.jsx)(se,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sidebarViewTimeline`)}),b===`timeline`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]}),(0,G.jsx)(`div`,{className:`my-1 border-t`,style:{borderColor:`color-mix(in oklab, var(--muted-foreground) 50%, transparent)`}}),(0,G.jsx)(`div`,{className:yt,children:U(`sortBy`)}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":x===`updatedAt`,className:bt,onClick:()=>En(`updatedAt`),children:[(0,G.jsx)(se,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sortByUpdatedAt`)}),x===`updatedAt`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]}),(0,G.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":x===`createdAt`,className:bt,onClick:()=>En(`createdAt`),children:[(0,G.jsx)(pe,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:U(`sortByCreatedAt`)}),x===`createdAt`?(0,G.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground/70`}):(0,G.jsx)(`span`,{className:`size-4 shrink-0`})]})]}),document.body):null,sn&&kt?(0,Vn.createPortal)((0,G.jsxs)(`div`,{className:`fixed z-50 min-w-48 overflow-hidden rounded-lg border border-border bg-background p-1 shadow-quickforge`,style:{left:kt.x,top:kt.y},onClick:e=>e.stopPropagation(),children:[(0,G.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:U(`openInExplorer`),"aria-label":U(`openInExplorer`),onClick:()=>{Dn(),ke(sn)},children:[(0,G.jsx)(E,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{children:U(`openFolder`)})]}),(0,G.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:()=>{Dn(),Oe(sn)},children:[(0,G.jsx)(me,{className:`size-4 shrink-0 text-muted-foreground/70`}),(0,G.jsx)(`span`,{children:U(`manageProjectSkills`)})]}),X===sn.id?(0,G.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":U(`confirmDelete`),onClick:e=>kn(e,sn.id),children:(0,G.jsx)(`span`,{children:U(`confirm`)})}):(0,G.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":U(`deleteProject`),onClick:e=>On(e,sn.id),children:[(0,G.jsx)(k,{className:`size-4 shrink-0`}),(0,G.jsx)(`span`,{children:U(`deleteProject`)})]})]}),document.body):null,Ct?(0,G.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:()=>wt(!1),children:(0,G.jsxs)(`div`,{className:`w-full max-w-xl rounded-2xl border border-border bg-popover p-3 shadow-quickforge`,onMouseDown:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl border border-input bg-background px-3 py-2`,children:[(0,G.jsx)(D,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,G.jsx)(`input`,{ref:mn,value:Tt,onChange:e=>Et(e.target.value),onKeyDown:e=>{e.key===`Escape`&&wt(!1)},placeholder:U(`searchDialog`),className:`min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground/45`})]}),(0,G.jsx)(`div`,{className:`mt-2 max-h-[50vh] overflow-y-auto`,children:Tt.trim()?gn.length>0?gn.map(({session:e,projectName:t})=>(0,G.jsxs)(`button`,{type:`button`,"aria-busy":v===e.id,className:`flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left transition-colors hover:bg-muted/28`,onClick:()=>vn(e.id),children:[mt(e.id),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-sm text-foreground/90`,children:Mt(e.title)}),(0,G.jsxs)(`span`,{className:`block truncate text-[11px] text-muted-foreground/55`,children:[t||U(`normalChat`),` · `,wo(e.lastModified)]})]})]},e.id)):(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`noSearchResults`)}):(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground/55`,children:U(`searchHint`)})})]})}):null]})});function ko(){let[e,t]=(0,H.useState)(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(),[o,s]=(0,H.useState)(()=>new Set),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1);return{activeProject:e,projects:n,defaultWorkspace:i,expandedProjectIds:o,selectingProject:c,projectPickerOpen:u,loadProject:(0,H.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(typeof n.defaultWorkspaceRoot==`string`&&n.defaultWorkspaceRoot?{id:`default`,name:`workspace`,path:n.defaultWorkspaceRoot,lastOpenedAt:``}:void 0),s(e=>{let t=new Set(e);for(let e of Array.isArray(n.projects)?n.projects:[])t.add(e.id);return t})}catch(e){V.error(`Failed to load project:`,e)}},[]),switchActiveProject:(0,H.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:[]),s(new Set([e])),i.project},[]),handleSelectProjectPath:(0,H.useCallback)(async e=>{l(!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:[]),s(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 V.error(`Failed to select project:`,e),e}finally{l(!1)}},[]),selectProjectDirectory:(0,H.useCallback)(()=>{d(!0)},[]),setProjectPickerOpen:d,toggleProjectExpanded:(0,H.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),toggleAllProjectsExpanded:(0,H.useCallback)(()=>{s(e=>e.size===n.length&&n.length>0?new Set:new Set(n.map(e=>e.id)))},[n]),reorderProjects:(0,H.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){V.error(`Failed to reorder projects:`,e)}},[]),setActiveProject:t,setProjects:r,setExpandedProjectIds:s}}function Ao(){let[e,t]=(0,H.useState)(`default`);return{agentAccessMode:e,setAgentAccessMode:t,initialize:(0,H.useCallback)(async e=>{let n=await fn(e);return t(n),n},[])}}var jo=`quickforge-sync`;function Mo(e){let t=(0,H.useRef)(e);(0,H.useEffect)(()=>{t.current=e});let n=(0,H.useRef)(q()),r=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(typeof BroadcastChannel<`u`)try{let e=new BroadcastChannel(jo);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,H.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&(t.current.onSessionsChanged(),t.current.onProjectsChanged())};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[]);let i=(0,H.useCallback)(e=>{let t={type:e,sourceTabId:n.current,timestamp:Date.now()};r.current?.postMessage(t)},[]);return{notifySessionsChanged:(0,H.useCallback)(()=>i(`sessions-changed`),[i]),notifyProjectsChanged:(0,H.useCallback)(()=>i(`projects-changed`),[i]),notifySettingsChanged:(0,H.useCallback)(()=>i(`settings-changed`),[i])}}function No(e){return e===`assistant`||e===`user`||e===`user-with-attachments`}function Po(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}return[...e,t]}if(No(t.role)){let n=t.timestamp;if(n!==void 0){let r=e.findIndex(e=>e.role===t.role&&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 Fo(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function Io(e){if(!Fo(e))return;let t=e.quickforgeTiming;if(!Fo(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 Lo(e,t){return Fo(e)?{...e,quickforgeTiming:t}:{quickforgeTiming:t}}function Ro(e,t){let n=e.quickforgeTiming??Io(e.partialResult?.details)??{startedAt:Date.now()};return{...e,partialResult:e.partialResult??{content:[],details:{quickforgeTiming:n,sessionId:t,toolCallId:e.toolCallId}}}}function zo(e,t,n){if(!t.toolCallId||!t.toolName)return e;let r=n?t.partialResult:t.result;if(!r)return e;let i=Io(r.details)??t.quickforgeTiming;if(!i){let n=e.findIndex(e=>e.role===`toolResult`&&e.toolCallId===t.toolCallId);n>=0&&(i=Io(e[n].details))}let a=i?Lo(r.details,i):r.details,o=Fo(a)?{...a,sessionId:a.sessionId??t.sessionId,toolCallId:a.toolCallId??t.toolCallId}:a;return Po(e,{role:`toolResult`,toolCallId:t.toolCallId,toolName:t.toolName,content:r.content??[],details:o,isError:n?!1:t.isError,timestamp:Date.now()})}function Bo(){return``}var Vo=5e3,Ho=15e3,Uo=new class{eventSource=null;handlersBySession=new Map;baseUrl=``;reconnectTimer=null;reconnectDelay=1e3;directBaseUrl=Bo();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`,`session_created`,`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 Wo(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 Go(e,t=``){return Uo.subscribeAll(t,e)}var Ko=class e{state;streamFn=Be;getApiKey;sessionId;listeners=new Set;unsubscribeSse;baseUrl;disposed=!1;_syncingThinkingLevel=!1;pollTimer=null;refreshPromise=null;statusPromise=null;lastSseEventAt=Date.now();lastServerStateVersion=0;nextPromptCapabilities=[];planMode=!1;onPlanModeConsumed;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??[],accessMode:J(t.accessMode,At(t.yoloMode)),yoloMode:Y(J(t.accessMode,At(t.yoloMode))),isStreaming:t.isStreaming??!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null,pendingToolApproval:t.pendingToolApproval??null,pendingAutoCompactApproval:t.pendingAutoCompactApproval??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=Uo.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):[]}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed)return;if(this.state.isStreaming){V.warn(`Ignored prompt while agent is already streaming`);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,r=this.planMode?{type:`plan`}:void 0;if(this.nextPromptCapabilities=[],this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}let i=this.state.messages.length,a=t;this.state.messages=[...this.state.messages,a],this.state.contextUsage=null,this.emitToListeners({type:`message_start`,message:a}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`}));let o=new AbortController,s=setTimeout(()=>o.abort(),3e4),c=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/prompt`;fetch(c,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:a,selectedCapabilities:n,command:r}),signal:o.signal}).then(e=>{if(clearTimeout(s),!e.ok)throw Error(`Failed to send prompt: HTTP ${e.status}`)}).catch(e=>{clearTimeout(s);let t=e instanceof Error?e.message:String(e);V.error(`Failed to send prompt:`,e),this.state.messages.length===i+1&&this.state.messages[this.state.messages.length-1]===a&&(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=>{V.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=>{V.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=>{V.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,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null}async updateAccessMode(e){let t=J(e),n=`${this.baseUrl}/api/agents/${encodeURIComponent(this.sessionId)}/access-mode`,r=await fetch(n,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accessMode:t})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(e?.error||`Failed to sync Agent access mode: HTTP ${r.status}`)}this.state.accessMode=t,this.state.yoloMode=Y(t)}async updateYoloMode(e){await this.updateAccessMode(e?`full-access`:`default`)}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=>{V.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=>{V.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}`)}this.state.pendingToolApproval?.toolCallId===e&&(this.state.pendingToolApproval=null)}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}`)}this.state.pendingToolApproval?.toolCallId===e&&(this.state.pendingToolApproval=null)}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}`)}this.state.pendingAutoCompactApproval?.approvalId===e&&(this.state.pendingAutoCompactApproval=null)}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}`)}this.state.pendingAutoCompactApproval?.approvalId===e&&(this.state.pendingAutoCompactApproval=null)}dispose(){this.disposed=!0,this.pollTimer&&=(clearInterval(this.pollTimer),null),this.statusPromise=null,this.unsubscribeSse?.(),this.unsubscribeSse=void 0,this.listeners.clear()}handleSseEvent(e){if(this.noteSseEvent(e)){switch(e.type){case`state`:{let t=e;if(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.accessMode!==void 0||t.yoloMode!==void 0){let e=J(t.accessMode,At(t.yoloMode));this.state.accessMode=e,this.state.yoloMode=Y(e)}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,t.pendingToolApproval!==void 0&&(this.state.pendingToolApproval=t.pendingToolApproval),t.pendingAutoCompactApproval!==void 0&&(this.state.pendingAutoCompactApproval=t.pendingAutoCompactApproval);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.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,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,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,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,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,t.errorMessage&&(this.state.errorMessage=t.errorMessage),this.emitToListeners(e)});return}case`message_end`:{let t=e;if(t.message){this.state.messages=Po(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`:{let t=e.error;this.state.errorMessage=t||`Unknown error`,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null;break}case`title_updated`:break;case`session_forked`:break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=zo(this.state.messages,Ro(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=zo(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=zo(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`auto_compact_threshold_reached`:break;case`tool_approval_required`:{let t=e;typeof t.toolCallId==`string`&&typeof t.toolName==`string`&&(this.state.pendingToolApproval=t,this.state.pendingAutoCompactApproval=null);break}case`auto_compact_approval_required`:{let t=e;typeof t.approvalId==`string`&&(this.state.pendingAutoCompactApproval=t,this.state.pendingToolApproval=null);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;if(typeof t==`number`&&Number.isFinite(t)){if(t<this.lastServerStateVersion)return!1;this.lastServerStateVersion=t}return!0}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<Ho||this.refreshStatusFromServer()},Vo))}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){let e=this.state.isStreaming;this.stopStateWatchdog(),await this.refreshStateFromServer({notify:!0,forceMessages:!0}),e&&this.state.isStreaming&&(this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null,this.emitToListeners({type:`agent_end`,messages:this.state.messages}));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(),a=typeof i.stateVersion==`number`&&Number.isFinite(i.stateVersion)?i.stateVersion:void 0;if(a!==void 0&&a<this.lastServerStateVersion||n!==this.stateVersion)return;a!==void 0&&(this.lastServerStateVersion=a);let o=!!(i.messages&&(e?.forceMessages||i.messages.length>this.state.messages.length||!this.state.isStreaming&&i.messages.length===this.state.messages.length));if(o&&(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.accessMode!==void 0||i.yoloMode!==void 0){let e=J(i.accessMode,At(i.yoloMode));this.state.accessMode=e,this.state.yoloMode=Y(e)}if(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.pendingToolApproval!==void 0&&(this.state.pendingToolApproval=i.pendingToolApproval),i.pendingAutoCompactApproval!==void 0&&(this.state.pendingAutoCompactApproval=i.pendingAutoCompactApproval),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(),this.state.pendingToolApproval=null,this.state.pendingAutoCompactApproval=null),e?.notify&&t&&!i.isStreaming){this.stateVersion++,this.emitToListeners({type:`agent_end`,messages:this.state.messages});return}}if(e?.notify)if(i.isStreaming&&o){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,accessMode:n.accessMode,yoloMode:n.yoloMode??Y(J(n.accessMode)),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??[],accessMode:J(a.accessMode,n.accessMode??a.yoloMode??n.yoloMode),yoloMode:!!(a.yoloMode??n.yoloMode),isStreaming:!!a.isStreaming,errorMessage:a.errorMessage,contextCompaction:a.contextCompaction,contextUsage:a.contextUsage,pendingToolApproval:a.pendingToolApproval,pendingAutoCompactApproval:a.pendingAutoCompactApproval,stateVersion:a.stateVersion}})}},qo=class{sessionId;streamFn=Be;getApiKey;scope;project;createAgent;listeners=new Set;disposed=!1;realAgentPromise;promotedAgent;nextPromptCapabilities=[];planMode=!1;onPlanModeConsumed;state;constructor(e){this.sessionId=`pending-${q()}`,this.scope=e.scope,this.project=e.project,this.createAgent=e.createAgent;let t=J(e.accessMode,e.yoloMode?`full-access`:`default`);this.state={systemPrompt:``,model:e.model,thinkingLevel:e.thinkingLevel,messages:[],tools:[],accessMode:t,yoloMode:Y(t),isStreaming:!1,pendingToolCalls:new Set,contextCompaction:null,contextUsage:null}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(e){this.nextPromptCapabilities=Array.isArray(e)?e.slice(0,4):[]}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed||this.state.isStreaming)return;let t=this.normalizePromptInput(e),n=this.state.messages.length;this.state.messages=[...this.state.messages,t],this.state.contextUsage=null,this.emitToListeners({type:`message_start`,message:t}),this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emitToListeners({type:`agent_start`});let r;try{r=await this.ensureRealAgent()}catch(e){this.state.messages.length===n+1&&this.state.messages[this.state.messages.length-1]===t&&(this.state.messages=this.state.messages.slice(0,-1));let r=e instanceof Error?e.message:String(e);throw this.state.errorMessage=r,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.emitToListeners({type:`error`,error:r}),this.emitToListeners({type:`agent_end`,messages:this.state.messages}),e}r.setNextPromptCapabilities(this.nextPromptCapabilities),r.setPlanMode(this.planMode,this.onPlanModeConsumed),this.nextPromptCapabilities=[],this.planMode=!1,this.onPlanModeConsumed=void 0,await r.prompt(t)}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 updateAccessMode(e){let t=J(e);this.state.accessMode=t,this.state.yoloMode=Y(t);let n=await this.realAgentPromise;n&&await n.updateAccessMode(t)}async updateYoloMode(e){await this.updateAccessMode(e?`full-access`:`default`)}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()}normalizePromptInput(e){return 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}emitToListeners(e){for(let t of this.listeners)try{t(e)}catch{}}async ensureRealAgent(){if(!this.realAgentPromise){let e=q();this.realAgentPromise=this.createAgent({model:this.state.model,thinkingLevel:this.state.thinkingLevel,tools:[]},e,{scope:this.scope,project:this.project,attachToView:!0,accessMode:this.state.accessMode,yoloMode:this.state.yoloMode}).then(e=>(this.disposed&&this.promotedAgent!==e&&e.dispose(),e))}return this.realAgentPromise}};function Jo(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 Yo(e){return e.role===`assistant`?Jo(e.content,`
|
|
61
61
|
|
|
62
|
-
`).trim():``}function
|
|
62
|
+
`).trim():``}function Xo(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 Zo(e){return e.role!==`user`&&e.role!==`user-with-attachments`?``:typeof e.content==`string`?e.content:Jo(e.content,`
|
|
63
63
|
|
|
64
|
-
`)}async function
|
|
65
|
-
`):``).includes(`<compact_summary>`)}function ls(e){let t=e.findIndex(cs);return t<0?null:{summaryMessage:e[t],compactedUpToIndex:Math.min(e.length,t+2)}}function us(e){let{storageRef:t,activeModelRef:n,agentAccessModeRef:r,activeProjectRef:i,defaultWorkspaceRef:a,setAgentAccessMode:o,switchActiveProject:s,sessions:c,refreshSessions:l,updateSessionTitle:u}=e,d=(0,H.useRef)(null),f=(0,H.useRef)(new Map),p=(0,H.useRef)(`global`),m=(0,H.useRef)(void 0),h=(0,H.useRef)(`New chat`),g=(0,H.useRef)(void 0),_=(0,H.useRef)(null),v=(0,H.useRef)(0),y=(0,H.useRef)(Promise.resolve()),b=(0,H.useRef)(e.onTaskComplete);(0,H.useEffect)(()=>{b.current=e.onTaskComplete});let[x,S]=(0,H.useState)(null),[C,w]=(0,H.useState)(),[T,E]=(0,H.useState)(`New chat`),[D,O]=(0,H.useState)(`global`),[k,ee]=(0,H.useState)(),[A,j]=(0,H.useState)({}),[te,M]=(0,H.useState)(0),[N,P]=(0,H.useState)(),F=(0,H.useCallback)(e=>{e.length!==0&&j(t=>{let n={...t},r=!1;for(let t of e)Object.prototype.hasOwnProperty.call(n,t)&&(delete n[t],r=!0);return r?n:t})},[]),I=(0,H.useCallback)(e=>{let t=ns(f.current.values(),e);for(let e of t)rs(f.current,e);F(t)},[F]),L=(0,H.useCallback)((e,t)=>{!e||e===t||[...f.current.values()].some(t=>t.agent===e)||e.dispose()},[f]),R=(0,H.useCallback)(async e=>{if(m.current===e.sessionId){let t=e.agent.state.messages,n=e.title;Zo(n)&&(n=Xo(t)),g.current=e.createdAt??new Date().toISOString(),h.current=n,E(n)}await l({broadcast:!0})},[l]),ne=(0,H.useCallback)(e=>{L(d.current,e.agent),ts(e),p.current=e.scope,m.current=e.sessionId,g.current=e.createdAt,h.current=e.title,O(e.scope),w(e.sessionId),E(e.title),ee(e.project),d.current=e.agent,S(e.agent);let t=new URL(window.location.href);t.searchParams.set(`session`,e.sessionId),window.history.replaceState({},``,t)},[L]),z=(0,H.useCallback)(async(e,s=q(),c)=>{let g=d.current,v=f.current.get(s);if(v)return c?.attachToView!==!1&&c?.shouldAttachToView?.()!==!1&&(L(g,v.agent),ne(v)),v.agent;let y=c?.scope??p.current,x=y===`project`?c?.project??i.current:c?.project??a.current;if(y===`project`&&!x?.id)throw Error(`Cannot create project chat without an active project.`);let S=new Date().toISOString(),{model:C,thinkingLevel:w,tools:T,...D}=e??{},O=t.current,k=O?await en(O):{},ee=C??k.model??n.current,A=O?await un(O,ee):Wt(ee),te=w??k.thinkingLevel??Zt(A);n.current=A;let M=J(c?.accessMode,c?.yoloMode??r.current);r.current=M,o(M);let N=await Uo.create(s,{scope:y,projectId:y===`project`?x?.id:void 0,accessMode:M,yoloMode:Y(M),model:A,thinkingLevel:te,messages:D.messages??[],title:c?.title,contextCompaction:D.contextCompaction});D.contextCompaction&&!N.state.contextCompaction&&(N.state.contextCompaction=D.contextCompaction);let P=N.state.isStreaming?`running`:N.state.errorMessage?`error`:`idle`,F={sessionId:N.sessionId,agent:N,scope:y,project:x,title:c?.title??`New chat`,createdAt:c?.createdAt??S,status:P,startedAt:S,lastAccessedAt:Date.now(),unsubscribe:()=>void 0};return F.unsubscribe=N.subscribe(e=>{if(e.type===`agent_start`&&(F.status=`running`,F.startedAt=F.startedAt??new Date().toISOString(),F.finishedAt=void 0,j(e=>({...e,[F.sessionId]:F.status}))),e.type===`message_end`&&(N.state.messages=[...N.state.messages]),e.type===`agent_end`){let t=F.status===`running`,n=e;F.status=n.status===`aborted`?`aborted`:n.errorMessage||N.state.errorMessage?`error`:`idle`,F.finishedAt=new Date().toISOString(),ts(F),j(e=>({...e,[F.sessionId]:F.status})),R(F).catch(e=>V.error(`Failed to sync session UI:`,e)),t&&b.current?.(F.sessionId,F.title,F.status),I(m.current)}if(e.type===`title_updated`){let t=e;t.title&&(F.title=t.title),F.sessionId===m.current&&t.title&&(h.current=t.title,E(t.title)),t.title&&u(F.sessionId,t.title)}if(e.type===`session_forked`){let t=e;if(!t.targetSessionId)return;l({broadcast:!0}).catch(e=>V.error(`Failed to refresh sessions:`,e)),_.current?.(t.targetSessionId,{title:t.title,createdAt:t.createdAt,scope:t.scope,projectId:t.projectId??void 0})}}),f.current.set(s,F),F.status!==`idle`&&j(e=>({...e,[F.sessionId]:F.status})),c?.attachToView!==!1&&c?.shouldAttachToView?.()!==!1&&(g instanceof Wo?g.promoteTo(F.agent):d.current===g&&L(g,F.agent),ne(F)),I(m.current),c?.refreshSessions!==!1&&N.state.messages.length>0&&await l({broadcast:!0}),N},[ne,L,I,l,R,u,t,n,r,i,a,o]),re=(0,H.useCallback)(async e=>{let i=t.current,o=i?await en(i):{},s=o.model??n.current,c=i?await un(i,s):Wt(s),l=o.thinkingLevel??Zt(c);n.current=c;let u=e.scope,f=u===`project`?e.project:e.project??a.current,_=new Wo({scope:u,project:f,model:c,thinkingLevel:l,accessMode:r.current,yoloMode:Y(r.current),createAgent:z});_.subscribe(e=>{d.current===_&&(e.type===`message_start`||e.type===`agent_end`)&&M(e=>e+1)}),L(d.current),p.current=u,m.current=void 0,g.current=void 0,h.current=`New chat`,O(u),w(void 0),E(`New chat`),ee(f),d.current=_,S(_);let v=new URL(window.location.href);return v.searchParams.delete(`session`),window.history.replaceState({},``,v),_},[n,z,a,L,t,r]),B=(0,H.useCallback)(async(e,r)=>{let a=++v.current,o=()=>v.current===a;P(e);let l=y.current.catch(()=>void 0).then(async()=>{if(!o())return;let a=f.current.get(e);if(a){if(a.scope===`project`&&a.project?.id&&i.current?.id!==a.project.id)try{await s(a.project.id)}catch(e){V.error(`Failed to switch project for running session:`,e)}o()&&(ne(a),I(a.sessionId));return}let l=t.current;if(!l){await z({tools:[]},e,{scope:r?.scope??`global`,attachToView:!0,shouldAttachToView:o,createdAt:r?.createdAt,title:r?.title});return}let u=await l.sessions.get(e);if(!u||!o())return;let d=c.find(t=>t.id===e)??await l.sessions.getMetadata(e);if(!o())return;let p=r?.scope??jt(d??u),m=r?.projectId??d?.projectId??u.projectId,h;if(p===`project`&&m){let e=m;if(i.current?.id!==e)try{h=await s(e)}catch(e){V.error(`Failed to switch project for session:`,e),o()&&$(U(`projectSwitchFailed`));return}else h=i.current}o()&&(n.current=u.model,await z({model:u.model,thinkingLevel:u.thinkingLevel,messages:u.messages,contextCompaction:u.contextCompaction??ls(u.messages)},u.id,{scope:p,project:h,attachToView:!0,shouldAttachToView:o,createdAt:u.createdAt??r?.createdAt,title:u.title??r?.title,accessMode:J(u.accessMode,u.yoloMode),refreshSessions:!1}))});y.current=l;try{await l}finally{o()&&P(void 0)}},[ne,z,I,c,s,t,n,i]);return(0,H.useEffect)(()=>{_.current=B},[B]),{agentRef:d,taskMapRef:f,currentSessionIdRef:m,currentChatScopeRef:p,agent:x,currentSessionId:C,currentTitle:T,chatScope:D,currentToolProject:k,taskStatuses:A,chatPanelRevision:te,loadingSessionId:N,createAgent:z,startDeferredSession:re,loadSession:B,syncSessionUI:R,setChatPanelRevision:M,setCurrentAgentMessages:(0,H.useCallback)(e=>{d.current&&(d.current.state.messages=e)},[]),updateCurrentAgentModel:(0,H.useCallback)(e=>{d.current&&(d.current.state.model=e,d.current.updateModel(e).catch(e=>{V.error(`Failed to sync model to server:`,e)}))},[]),setCurrentTitleRef:(0,H.useCallback)(e=>{h.current=e,E(e)},[])}}function ds(e){if(!e)return 0;let t=new Date(e).getTime();return Number.isNaN(t)?0:t}function fs(e,t){let n=t===`createdAt`?`createdAt`:`lastModified`;return[...e].sort((e,t)=>{let r=ds(t.pinnedAt)-ds(e.pinnedAt);return r===0?e.pinnedAt&&!t.pinnedAt?-1:!e.pinnedAt&&t.pinnedAt?1:ds(t[n])-ds(e[n]):r})}function ps(e){let t=new Set;return e.filter(e=>t.has(e.id)?!1:(t.add(e.id),!0))}function ms(e,t,n){let r=e.items.some(e=>e.id===t.id);return{...e,items:fs(ps([t,...e.items.filter(e=>e.id!==t.id)]),n),total:r?e.total:e.total+1}}function hs(e,t,n){return e.items.some(e=>e.id===t)?{...e,items:e.items.map(e=>e.id===t?{...e,title:n}:e)}:e}var gs=20;function _s(e){if(!e)return!1;let t=e.trim();return!t||t===`undefined`||t===`null`||t===`false`?!1:!Number.isNaN(Date.parse(t))}function vs({backendRef:e,expandedProjectIds:t,externalProjectIds:n,viewMode:r,sortMode:i,onBroadcastSessionsChanged:a}){let[o,s]=(0,H.useState)({items:[],total:0,loading:!1}),[c,l]=(0,H.useState)({items:[],total:0,loading:!1}),[u,d]=(0,H.useState)({}),[f,p]=(0,H.useState)({items:[],total:0,loading:!1}),m=(0,H.useRef)(u),h=(0,H.useRef)(t),g=(0,H.useRef)(n??new Set),_=(0,H.useRef)(0);(0,H.useEffect)(()=>{m.current=u},[u]),(0,H.useEffect)(()=>{h.current=t},[t]),(0,H.useEffect)(()=>{g.current=n??new Set},[n]);let v=(0,H.useCallback)(()=>(_.current+=1,_.current),[]),y=(0,H.useCallback)(e=>e===_.current,[]),b=(0,H.useMemo)(()=>ps([...c.items,...o.items,...Object.values(u).flatMap(e=>e.items),...f.items]),[c.items,o.items,u,f.items]),x=(0,H.useCallback)(async(t,n=_.current)=>{let r=e.current;if(r){l(e=>({...e,loading:!0}));try{let e=await r.fetchPaginatedFromIndex(`sessions-metadata`,`pinnedAt`,{direction:`desc`,limit:gs,offset:t,pinned:`only`});if(!y(n))return;let a=e.values.filter(e=>_s(e.pinnedAt));l(n=>({items:fs(t===0?a:ps([...n.items,...a]),i),total:e.total,loading:!1}))}catch{if(!y(n))return;l(e=>({...e,loading:!1}))}}},[e,y,i]),S=(0,H.useCallback)(async(t,n=_.current)=>{let r=e.current;if(r){s(e=>({...e,loading:!0}));try{let e=i===`createdAt`?`createdAt`:`lastModified`,a=await r.fetchPaginatedFromIndex(`sessions-metadata`,e,{direction:`desc`,limit:gs,offset:t,scope:`global`});if(!y(n))return;s(e=>({items:fs(t===0?a.values:ps([...e.items,...a.values]),i),total:a.total,loading:!1}))}catch{if(!y(n))return;s(e=>({...e,loading:!1}))}}},[e,y,i]),C=(0,H.useCallback)(async(t,n,r=_.current)=>{let a=e.current;if(a){d(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!0}}});try{let e=i===`createdAt`?`createdAt`:`lastModified`,o=await a.fetchPaginatedFromIndex(`sessions-metadata`,e,{direction:`desc`,limit:gs,offset:n,scope:`project`,projectId:t});if(!y(r))return;d(e=>{let r=e[t]?.items??[];return{...e,[t]:{items:fs(n===0?o.values:ps([...r,...o.values]),i),total:o.total,loading:!1}}})}catch{if(!y(r))return;d(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!1}}})}}},[e,y,i]),w=(0,H.useCallback)(async(t,n=_.current)=>{let r=e.current;if(r){p(e=>({...e,loading:!0}));try{let e=i===`createdAt`?`createdAt`:`lastModified`,a=await r.fetchPaginatedFromIndex(`sessions-metadata`,e,{direction:`desc`,limit:gs,offset:t,scope:`projects`});if(!y(n))return;p(e=>({items:fs(t===0?a.values:ps([...e.items,...a.values]),i),total:a.total,loading:!1}))}catch{if(!y(n))return;p(e=>({...e,loading:!1}))}}},[e,y,i]),T=(0,H.useCallback)(async e=>{let t=v();if(await x(0,t),!y(t)||(await S(0,t),!y(t)))return;if(r===`timeline`){d(e=>{let t={};for(let[n,r]of Object.entries(e))t[n]={...r,loading:!1};return t}),await w(0,t),e?.broadcast&&y(t)&&a?.();return}p(e=>({...e,loading:!1}));let n=new Set([...Object.keys(m.current),...h.current,...g.current]);n.size===0?d({}):(d(e=>{let t={};for(let r of n)t[r]={...e[r]??{items:[],total:0},loading:!0};return t}),await Promise.all([...n].map(e=>C(e,0,t)))),e?.broadcast&&y(t)&&a?.()},[y,S,x,C,w,v,a,r]),E=(0,H.useCallback)(e=>{if(_s(e.pinnedAt)&&l(t=>ms(t,e,i)),e.scope===`project`&&e.projectId){d(t=>{let n=t[e.projectId];return n?{...t,[e.projectId]:ms(n,e,i)}:t}),r===`timeline`&&p(t=>ms(t,e,i));return}s(t=>ms(t,e,i))},[i,r]),D=(0,H.useCallback)((e,t)=>{l(n=>hs(n,e,t)),s(n=>hs(n,e,t)),p(n=>hs(n,e,t)),d(n=>{let r=!1,i=Object.fromEntries(Object.entries(n).map(([n,i])=>{let a=hs(i,e,t);return a!==i&&(r=!0),[n,a]}));return r?i:n})},[]),O=(0,H.useCallback)(e=>u[e]?.items??[],[u]),k=(0,H.useCallback)(e=>{let t=u[e];return t?t.items.length<t.total:!0},[u]),ee=(0,H.useCallback)(e=>u[e]?.loading??!1,[u]),A=(0,H.useCallback)(e=>e in u,[u]),j=(0,H.useCallback)(()=>{c.loading||c.items.length>=c.total||x(c.items.length)},[x,c.items.length,c.loading,c.total]),te=(0,H.useCallback)(()=>{S(o.items.length)},[o.items.length,S]),M=(0,H.useCallback)(e=>{let t=u[e];C(e,t?.items.length??0)},[C,u]),N=(0,H.useCallback)(()=>{f.loading||f.items.length>=f.total||w(f.items.length)},[w,f.items.length,f.loading,f.total]);return(0,H.useEffect)(()=>{Promise.resolve().then(()=>T())},[T]),{allLoadedSessions:b,pinnedSessions:c.items,pinnedHasMore:c.items.length<c.total,pinnedLoading:c.loading,globalSessions:o.items,sessionsForProject:O,projectTimelineSessions:f.items,projectTimelineHasMore:f.items.length<f.total,projectTimelineLoading:f.loading,globalHasMore:o.items.length<o.total,projectHasMore:k,globalLoading:o.loading,projectLoading:ee,projectLoaded:A,loadGlobalSessions:S,loadProjectSessions:C,refreshSessions:T,upsertSessionMetadata:E,updateSessionTitle:D,loadMorePinned:j,loadMoreGlobal:te,loadMoreProject:M,loadMoreProjectTimeline:N}}function ys(){let[e,t]=(0,H.useState)([]),n=(0,H.useCallback)(e=>{t(t=>[...t,{...e,id:q(),createdAt:Date.now()}])},[]);return{toasts:e,handleTaskComplete:(0,H.useCallback)((e,t,r)=>{n({sessionId:e,title:t,status:r})},[n]),addToast:n,dismissToast:(0,H.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[])}}var bs=`tool-display-settings`,xs={toolDisplayMode:`compact`,showContextUsage:!1},Ss={...xs};function Cs(e){if(!e||typeof e!=`object`)return{...xs};let t=e;return{toolDisplayMode:t.toolDisplayMode===`detailed`?`detailed`:`compact`,showContextUsage:t.showContextUsage===!0}}function ws(){return Ss}async function Ts(e){let t=Cs(await e.settings.get(bs));return Ss=t,t}async function Es(e,t){let n=Cs(t);await e.settings.set(bs,n),Ss=n}var Ds=`font-size-settings`,Os=`font-size-settings-force-13px-v1`,ks={min:12,max:18},As={interfaceFontSizePx:13,messageFontSizePx:13},js=`quickforge:font-size-settings-changed`;function Ms(){if(typeof document>`u`)return As.interfaceFontSizePx;let e=Number.parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)?e:As.interfaceFontSizePx}function Ns(e=Ms()){let t=Fs(e-1,13,ks.min,ks.max);return{fontSize:t,lineHeight:Math.round(t*1.54)}}function Ps(e=Ms()){return{fontSize:Fs(e-2,12,ks.min,ks.max),lineHeight:1.2}}function Fs(e,t,n,r){let i=Number(e);return Number.isFinite(i)?Math.min(r,Math.max(n,Math.round(i))):t}function Is(e){if(!e||typeof e!=`object`)return{...As};let t=e;return{interfaceFontSizePx:Fs(t.interfaceFontSizePx??t.baseFontSizePx??t.bodyFontSizePx,As.interfaceFontSizePx,ks.min,ks.max),messageFontSizePx:Fs(t.messageFontSizePx,As.messageFontSizePx,ks.min,ks.max)}}function Ls(e){if(typeof document>`u`)return;let t=Is(e),n=document.documentElement;n.style.fontSize=`${t.interfaceFontSizePx}px`,n.style.setProperty(`--quickforge-message-font-size`,`${t.messageFontSizePx}px`),n.style.setProperty(`--quickforge-message-line-height`,`1.625`),window.dispatchEvent(new CustomEvent(js,{detail:t}))}async function Rs(e){if(!await e.settings.get(Os)){let t={...As};return await e.settings.set(Ds,t),await e.settings.set(Os,!0),t}return Is(await e.settings.get(Ds))}async function zs(e){let t=await Rs(e);return Ls(t),t}async function Bs(e,t){let n=Is(t);await e.settings.set(Ds,n),Ls(n)}var Vs=`appearance-settings`,Hs={theme:`light`};function Us(e){return!e||typeof e!=`object`?{...Hs}:{theme:e.theme===`dark`?`dark`:`light`}}function Ws(e){if(typeof document>`u`)return;let t=Us(e),n=document.documentElement;n.classList.toggle(`dark`,t.theme===`dark`),n.style.setProperty(`color-scheme`,t.theme)}function Gs(){return typeof document>`u`?Hs.theme:document.documentElement.classList.contains(`dark`)?`dark`:`light`}async function Ks(e){return Us(await e.settings.get(Vs))}async function qs(e){let t=await Ks(e);return Ws(t),t}async function Js(e,t){let n=Us(t);await e.settings.set(Vs,n),Ws(n)}function Ys({storageRef:e,backendRef:t,activeModelRef:n,agentAccessModeRef:r,activeProjectRef:i,setAgentAccessMode:a,taskMapRef:o,loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}){let[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(),[v,y]=(0,H.useState)(0),b=(0,H.useRef)({loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p});return(0,H.useEffect)(()=>{b.current={loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}}),(0,H.useEffect)(()=>{let s=!1;async function c(){let{loadGlobalSessions:o,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}=b.current;try{h(!1),_(void 0);let m=await Yt();if(s)return;e.current=m,p?.(m),t.current=m.backend,await rt(m),await Ts(m),await qs(m),await zs(m),await Promise.all([o(0),c()]),r.current=await l(m);let g=await cn(m),v=await en(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=jt(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){V.error(`Failed to switch project for initial session:`,e),$(U(`projectSwitchFailed`)),g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},q(),{scope:`global`,attachToView:!0}):f(!0),h(!0);return}else s=i.current}n.current=e.model;let c=J(e.accessMode,e.yoloMode);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,accessMode:c})}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},q(),{scope:`global`,attachToView:!0}):f(!0)}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},q(),{scope:`global`,attachToView:!0}):f(!0);h(!0)}catch(e){V.error(`Failed to bootstrap QuickForge:`,e),s||_(U(`localServiceUnavailableDescription`))}}c();let l=o.current;return()=>{s=!0,is(l)}},[e,t,n,r,i,a,o,v]),{ready:m,startupError:g,retryBootstrap:(0,H.useCallback)(()=>{h(!1),_(void 0),y(e=>e+1)},[])}}var Xs=`update-check-settings`,Zs={frequency:`startup`,lastCheckAt:null,ignoredVersion:null};function Qs(e){if(!e||typeof e!=`object`)return{...Zs};let t=e;return{frequency:[`startup`,`daily`,`weekly`,`off`].includes(t.frequency)?t.frequency:Zs.frequency,lastCheckAt:typeof t.lastCheckAt==`string`?t.lastCheckAt:null,ignoredVersion:typeof t.ignoredVersion==`string`?t.ignoredVersion:null}}var $s=1440*60*1e3;function ec(e,t=Date.now()){switch(e.frequency){case`off`:return!1;case`startup`:return!0;case`daily`:case`weekly`:{if(!e.lastCheckAt)return!0;let n=Date.parse(e.lastCheckAt);if(Number.isNaN(n))return!0;let r=e.frequency===`daily`?$s:7*$s;return t-n>=r}default:return!1}}async function tc(e){return Qs(await e.settings.get(Xs))}async function nc(e,t){await e.settings.set(Xs,Qs(t))}var rc={status:`idle`,updateAvailable:!1};function ic(){if(typeof document>`u`)return!1;let e=window;return document.body.classList.contains(`quickforge-desktop-app`)||e.__quickforgeDesktopApp===!0}function ac(e,t){let[n,r]=(0,H.useState)(rc),i=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{if(!t||i.current||ic())return;let n=e.current;n&&(i.current=!0,(async()=>{let e;try{e=await tc(n)}catch(e){V.error(`Failed to load update-check settings:`,e);return}if(ec(e)){r(e=>({...e,status:`checking`}));try{let t=await fetch(`/api/system/update/check`,{cache:`no-store`});if(!t.ok){r(e=>({...e,status:`error`}));return}let i=await t.json(),a=i.updateAvailable&&i.latestVersion!==e.ignoredVersion;try{await nc(n,{...e,lastCheckAt:new Date().toISOString()})}catch(e){V.error(`Failed to persist last update-check time:`,e)}r({status:`done`,currentVersion:i.currentVersion,latestVersion:i.latestVersion,updateAvailable:a})}catch(e){V.error(`Startup update check failed:`,e),r(e=>({...e,status:`error`}))}}})())},[t,e]),{result:n,dismissUpdate:(0,H.useCallback)(()=>{let t=e.current,i=n.latestVersion;!t||!i||(r(e=>({...e,updateAvailable:!1})),(async()=>{try{await nc(t,{...await tc(t),ignoredVersion:i})}catch(e){V.error(`Failed to persist ignored update version:`,e)}})())},[n.latestVersion,e])}}var oc=[`low`,`medium`,`high`,`xhigh`];function sc(e){switch(e){case`low`:return U(`thinkingLow`);case`medium`:return U(`thinkingMedium`);case`high`:return U(`thinkingHigh`);case`xhigh`:return U(`thinkingXHigh`);default:return U(`thinkingOff`)}}function cc(e){return e.id}function lc(e,t=``){let n=document.createElement(`button`);return n.type=`button`,n.className=e,n.textContent=t,n}function uc(e){document.querySelectorAll(`.quickforge-model-menu, .quickforge-model-submenu`).forEach(e=>{e.__quickforgeCleanup?.(),e.remove()}),e?.setAttribute(`aria-expanded`,`false`)}function dc(e){return e??document.querySelector(`.quickforge-model-trigger`)}function fc(e,t){let n=dc(t),r=Math.min(260,window.innerWidth-24);e.style.width=`${r}px`;let i=e.offsetHeight||360;if(!n){e.style.left=`${Math.max(12,Math.round((window.innerWidth-r)/2))}px`,e.style.top=`${Math.max(12,Math.round((window.innerHeight-i)/2))}px`;return}let a=n.getBoundingClientRect(),o=Math.max(12,Math.min(a.right-r,window.innerWidth-r-12)),s=a.top-i-8,c=a.bottom+8,l=s>=12?s:Math.min(c,window.innerHeight-i-12);e.style.left=`${o}px`,e.style.top=`${Math.max(12,l)}px`}function pc(e,t){let n=Math.min(252,window.innerWidth-24);e.style.width=`${n}px`;let r=t.getBoundingClientRect(),i=e.offsetHeight||320,a=r.left-n-0>=12?r.left-n-0:Math.min(r.right+0,window.innerWidth-n-12),o=Math.max(12,Math.min(r.top,window.innerHeight-i-12));e.style.left=`${a}px`,e.style.top=`${o}px`}function mc(e){let t=lc(`quickforge-model-menu-item`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(!!e.selected)),e.disabled&&(t.disabled=!0);let n=document.createElement(`span`);n.className=`quickforge-model-menu-item-label`,n.textContent=e.label;let r=document.createElement(`span`);return r.className=`quickforge-model-menu-item-suffix`,r.textContent=e.chevron?`›`:e.selected?`✓`:``,t.append(n,r),e.onPointerDown&&(t.onpointerdown=e.onPointerDown),e.onPointerEnter&&(t.onpointerenter=e.onPointerEnter),t}function hc(e,t,n,r,i={}){let a=dc(i.anchor);if(document.querySelector(`.quickforge-model-menu`)){uc(a);return}let o=i.thinkingLevel??`off`,s=e,c=null,l=document.createElement(`div`);l.className=`quickforge-model-menu`,l.setAttribute(`role`,`menu`),l.setAttribute(`aria-label`,U(`selectCustomModel`));let u=()=>{c?.remove(),c=document.createElement(`div`),c.className=`quickforge-model-submenu`,c.setAttribute(`role`,`menu`),c.setAttribute(`aria-label`,U(`model`));let e=document.createElement(`div`);e.className=`quickforge-model-menu-header`,e.textContent=U(`model`),c.append(e);let r=[...t].sort((e,t)=>cc(e).localeCompare(cc(t)));for(let e of r)c.append(mc({label:cc(e),selected:Ve(s,e),onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),!e.reasoning&&o!==`off`&&(o=`off`,i.onThinkingLevelSelect?.(`off`)),s=e,n(e),uc(a)}}));c.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.body.append(c),pc(c,l)},d=()=>{l.replaceChildren();let e=document.createElement(`div`);if(e.className=`quickforge-model-menu-header`,e.textContent=U(`reasoning`),l.append(e),s?.reasoning===!0)for(let e of oc)l.append(mc({label:sc(e),selected:o===e,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),o=e,i.onThinkingLevelSelect?.(e),d(),fc(l,a)}}));else{let e=document.createElement(`div`);e.className=`quickforge-model-menu-note`,e.textContent=U(`thinkingNotSupported`),l.append(e)}let t=document.createElement(`div`);t.className=`quickforge-model-menu-separator`,l.append(t),l.append(mc({label:s?cc(s):U(`noModelAdded`),chevron:!0,onPointerEnter:u,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),u()}}))},f=()=>uc(a),p=e=>{if(e.type===`resize`||e.type===`scroll`){fc(l,a),c&&pc(c,l);return}if(e instanceof KeyboardEvent){if(e.key!==`Escape`)return;e.preventDefault()}else{let t=e.target;if(l.contains(t)||c?.contains(t)||a?.contains(t))return}f()};l.__quickforgeCleanup=()=>{document.removeEventListener(`pointerdown`,p,!0),document.removeEventListener(`keydown`,p,!0),window.removeEventListener(`resize`,p,!0),window.removeEventListener(`scroll`,p,!0)},l.addEventListener(`pointerdown`,e=>e.stopPropagation()),d(),document.body.append(l),fc(l,a),a?.setAttribute(`aria-expanded`,`true`),document.addEventListener(`pointerdown`,p,!0),document.addEventListener(`keydown`,p,!0),window.addEventListener(`resize`,p,!0),window.addEventListener(`scroll`,p,!0)}function gc({storageRef:e,activeModelRef:t,agentRef:n,createAgent:r,updateCurrentAgentModel:i,setChatPanelRevision:a,setNeedsModelSetup:o,setRestoredDraft:s,notifySettingsChanged:c,openSettingsPage:l}){let u=(0,H.useCallback)(async()=>{let s=e.current;if(!s)return!1;let l=await cn(s);return l?(t.current=l,o(!1),await Xt(s,l),n.current?(i(l),a(e=>e+1)):await r({model:l,tools:[]},q(),{scope:`global`,attachToView:!0}),c(),!0):(o(!0),!1)},[e,t,n,r,i,a,o,c]),d=(0,H.useCallback)((e,t)=>{l(e,t)},[l]),f=(0,H.useCallback)(()=>{d(`customModels`)},[d]);return{activateConfiguredModel:u,openModelSettings:f,openDefaultOptionsSettings:(0,H.useCallback)(()=>{d(`defaults`)},[d]),openAboutSettings:(0,H.useCallback)(()=>{d(`about`)},[d]),activateLiteLlmExampleModel:(0,H.useCallback)(async()=>{let s=e.current;if(!s)return;let l=Gt(Rt);await pn(s,Rt,l),await Xt(s,l),t.current=l,o(!1),n.current?(i(l),a(e=>e+1)):await r({model:l,tools:[]},q(),{scope:`global`,attachToView:!0}),c()},[e,t,n,r,i,a,o,c]),openCustomModelSelector:(0,H.useCallback)(async r=>{let o=e.current,c=n.current;if(!o||!c)return;let l=r instanceof HTMLElement?r:r?.currentTarget instanceof HTMLElement?r.currentTarget:document.querySelector(`.quickforge-model-trigger`),u=document.querySelector(`agent-interface message-editor textarea`),p=document.querySelector(`agent-interface message-editor`),m=u?.value??``,h=p?.attachments?[...p.attachments]:[],g=on(await o.customProviders.getAll());if(g.length===0){await ss({description:U(`addCustomModelFirst`),confirmLabel:U(`modelSetupAddModel`),cancelLabel:U(`cancel`)})&&f();return}hc(c.state.model??t.current,g,e=>{let n=e,r=n.reasoning?c.state.thinkingLevel:`off`;c.state.thinkingLevel!==r&&(c.state.thinkingLevel=r,c.updateThinkingLevel(r).catch(e=>{V.error(`Failed to sync thinking level to server:`,e)})),t.current=n,i(n),(m||h.length>0)&&s({id:Date.now(),sessionId:c.sessionId,text:m,attachments:h}),a(e=>e+1),Xt(o,n).catch(e=>{V.error(`Failed to save active model:`,e)})},async e=>{d(`customModels`,e.provider)},{thinkingLevel:c.state.thinkingLevel,anchor:l,onThinkingLevelSelect:e=>{c.state.thinkingLevel=e,c.updateThinkingLevel(e).catch(e=>{V.error(`Failed to sync thinking level to server:`,e)}),a(e=>e+1)}})},[e,t,n,i,a,s,f,d])}}function _c(){let e=new URL(window.location.href);e.searchParams.delete(`session`),window.history.replaceState({},``,e)}function vc(e){return!!(e&&!e.state.isStreaming&&e.state.messages.length===0)}function yc({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,H.useCallback)(async()=>{if(p){$(U(`modelSetupRequired`));return}h(),!(vc(o.current)&&r.current===`global`)&&(g(void 0),_c(),await s({scope:`global`}))},[o,r,p,g,h,s]),v=(0,H.useCallback)(async e=>{if(p){$(U(`modelSetupRequired`));return}h();let t=e??n.current;t&&(vc(o.current)&&r.current===`project`&&n.current?.id===t.id||(n.current?.id!==t.id&&await m(t.id),g(void 0),_c(),await s({scope:`project`,project:t})))},[n,o,r,p,g,h,s,m]),y=(0,H.useCallback)(async s=>{let p=o.current;if(!p)return;if(p.state.isStreaming){$(U(`generationStillRunning`));return}let m=qo(p.state.messages,s),h=m>=0?p.state.messages[m]:void 0;if(m<0||!h){$(U(`noConversationTurnToRollback`));return}let _={id:Date.now(),sessionId:p.sessionId,text:Jo(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){V.error(`Failed to rollback conversation:`,e),$(e instanceof Error?e.message:U(`rollbackFailed`));return}u(v);let y=i.current?a.current.get(i.current):void 0;if($o(v)&&y){_&&g(_),d(e=>e+1),l(y).catch(e=>V.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&&rs(a.current,x),b&&x)try{await b.sessions.delete(x),await f({broadcast:!0})}catch(e){V.error(`Failed to delete rolled back empty session:`,e)}let E=q();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,H.useCallback)(async e=>{try{await Yo(e)}catch(e){throw V.error(`Failed to copy answer:`,e),$(U(`copyFailed`)),e}},[]),x=(0,H.useCallback)(async i=>{let a=o.current;if(!a)return;if(a.state.isStreaming){$(U(`generationStillRunning`));return}let s=a.state.messages.slice(0,i+1);if(!Qo(s))return;let l=r.current,u=l===`project`?n.current:void 0,d=q(),p=Xo(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=>V.error(`Failed to refresh sessions:`,e))},[t,n,o,c,r,f,e]);return{startNewGlobalChat:_,startNewProjectChat:v,rollbackFromMessage:y,retryFromMessage:(0,H.useCallback)(async e=>{let t=o.current;if(!t)return;if(t.state.isStreaming){$(U(`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){V.error(`Failed to retry:`,e),$(e instanceof Error?e.message:U(`retryFailed`));return}let s=i.current?a.current.get(i.current):void 0;s&&(l(s).catch(e=>V.error(`Failed to sync session UI after retry:`,e)),d(e=>e+1))},[o,i,d,u,l,a]),copyAnswer:b,forkFromMessage:x}}function bc({activeProjectRef:e,refreshSessions:t,notifyProjectsChanged:n,setActiveProject:r,setProjects:i,setExpandedProjectIds:a,setChatPanelRevision:o}){return{deleteProjectInline:(0,H.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 xc=H.forwardRef(({className:e,type:t,...n},r)=>(0,G.jsx)(`input`,{type:t,className:W(`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:border-primary focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));xc.displayName=`Input`;function Sc({options:e,onResolve:t}){let n=(0,H.useRef)(null),[r,i]=(0,H.useState)(e.defaultValue??``),a=(0,H.useRef)(r);return(0,H.useEffect)(()=>{a.current=r},[r]),(0,H.useEffect)(()=>{n.current?.focus(),n.current?.select()},[]),(0,H.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,Vn.createPortal)((0,G.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,G.jsxs)(`div`,{className:W(`w-full max-w-sm rounded-lg border border-border bg-background p-6 shadow-quickforge`,`mx-4`),children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e.title}),e.description?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.description}):null,(0,G.jsx)(`div`,{className:`mt-4`,children:(0,G.jsx)(xc,{ref:n,value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder,className:`w-full`})}),(0,G.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,G.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>t(null),children:e.cancelLabel??`Cancel`}),(0,G.jsx)(K,{size:`sm`,onClick:()=>r.trim()?t(r.trim()):void 0,disabled:!r.trim(),children:e.confirmLabel??`Save`})]})]})}),document.body)}function Cc(e){return new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,Ue.createRoot)(n);function i(){r.unmount(),setTimeout(()=>n.remove(),0)}function a(e){i(),t(e)}r.render((0,G.jsx)(Sc,{options:e,onResolve:a}))})}function wc({storageRef:e,taskMapRef:t,currentSessionIdRef:n,loadAgentSession:r,setCurrentTitleRef:i,refreshSessions:a,updateSessionTitle:o,closeWorkspacePage:s,startNewGlobalChat:c}){return{loadSession:(0,H.useCallback)(e=>{s(),r(e)},[r,s]),renameSession:(0,H.useCallback)(async(t,r)=>{if(!e.current)return;let a=await Cc({title:U(`renameSession`),description:U(`sessionName`),defaultValue:r,confirmLabel:U(`save`),cancelLabel:U(`cancel`)});if(!a||a===r)return;let s=await fetch(`/api/agents/${encodeURIComponent(t)}/title`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:a})});if(!s.ok)throw Error(`Failed to rename session: HTTP ${s.status}`);o(t,a),n.current===t&&i(a)},[n,i,e,o]),togglePinSession:(0,H.useCallback)(async t=>{let n=e.current;if(!n)return;let r=await n.sessions.getMetadata(t);if(!r)return;let i=r.pinnedAt?void 0:new Date().toISOString(),o={...r,pinnedAt:i};await n.backend.set(`sessions-metadata`,t,o),await a({broadcast:!0})},[a,e]),archiveSession:(0,H.useCallback)(async r=>{let i=e.current;if(!i)return;rs(t.current,r);let o=await i.sessions.get(r);if(!o)return;let l=await i.sessions.getMetadata(r);if(!l)return;let u=new Date().toISOString(),d={...o,archivedAt:u},f={...l,archivedAt:u};await i.sessions.save(d,f),await a({broadcast:!0}),n.current===r&&(s(),await c())},[n,a,s,c,e,t]),startNewGlobalSession:(0,H.useCallback)(()=>{s(),c()},[s,c])}}var Tc=e=>e===`full-access`;function Ec({storageRef:e,agentAccessModeRef:t,setAgentAccessMode:n,agentRef:r,setChatPanelRevision:i,notifySettingsChanged:a}){let o=(0,H.useCallback)(o=>{let s=e.current,c=r.current,l=t.current;if(l===o)return;n(o),t.current=o;let u=()=>{t.current=l,n(l),i(e=>e+1)};(async()=>{try{c&&await c.updateAccessMode(o),s&&await dn(s,o),i(e=>e+1),a()}catch(e){V.error(`Failed to sync agent access mode:`,e),u(),$(e instanceof Error?e.message:U(`agentAccessModeSyncFailed`))}})()},[t,r,a,n,i,e]);return{setAccessMode:o,toggleYoloMode:(0,H.useCallback)(()=>{o(Tc(t.current)?`default`:`full-access`)},[t,o])}}function Dc(){let[e,t]=(0,H.useState)(!0),[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(!1),[O,k]=(0,H.useState)(`defaults`),[ee,A]=(0,H.useState)();return{sidebarOpen:e,setSidebarOpen:t,mobileSidebarOpen:n,setMobileSidebarOpen:r,projectsCollapsed:i,setProjectsCollapsed:a,pinnedCollapsed:o,setPinnedCollapsed:s,conversationsCollapsed:c,setConversationsCollapsed:l,skillsDialog:u,setSkillsDialog:d,shareDialogOpen:f,setShareDialogOpen:p,conversationMenuOpen:m,setConversationMenuOpen:h,workspaceInspectorOpen:g,setWorkspaceInspectorOpen:_,workspaceInspectorRequest:v,setWorkspaceInspectorRequest:y,artifactPreviewOpen:b,setArtifactPreviewOpen:x,activeArtifactPath:S,setActiveArtifactPath:C,firstUseGuideDismissed:w,setFirstUseGuideDismissed:T,settingsDialogOpen:E,setSettingsDialogOpen:D,settingsInitialTab:O,setSettingsInitialTab:k,settingsCustomProvider:ee,setSettingsCustomProvider:A,toggleProjectsCollapsed:(0,H.useCallback)(()=>a(e=>!e),[]),togglePinnedCollapsed:(0,H.useCallback)(()=>s(e=>!e),[]),toggleConversationsCollapsed:(0,H.useCallback)(()=>l(e=>!e),[])}}function Oc(e){return e===`running`||e===`idle`||e===`error`||e===`aborted`?e:void 0}function kc(e){let[t,n]=(0,H.useState)({}),r=(0,H.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),i=(0,H.useMemo)(()=>e.map(e=>e.id).sort().join(`
|
|
66
|
-
`),[e]),a=(0,H.useCallback)(async()=>{if(r.size===0){n({});return}try{let e=await Vo(),t=new Map(e.map(e=>[e.sessionId,Oc(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){V.error(`Failed to refresh visible agent statuses:`,e)}},[r]);return(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{a()},0);return()=>window.clearTimeout(e)},[a,i]),(0,H.useEffect)(()=>Ho(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=Oc(e.status)===`aborted`?`aborted`:e.errorMessage?`error`:`idle`;n(e=>({...e,[t]:r}))}}}),[r]),(0,H.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&a()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a]),t}function Ac({ready:e,currentToolProjectId:t,projects:n,activeProject:r,recoveringProjectId:i}){return!e||!t||t===`default`||n.some(e=>e.id===t)||i===t?{type:`none`}:r?{type:`project`,deletedProjectId:t,project:r}:{type:`global`,deletedProjectId:t}}function jc(e,t,n){return e.projectId===t&&e.requestId===n}var Mc=new Set([`write_file`,`edit_file`,`run_command`,`run_subagent`]);function Nc(e,t,n){return e.type!==`tool_execution_end`||!t||e.sessionId!==t||!n?!1:typeof e.toolName==`string`&&Mc.has(e.toolName)}function Pc(e){return e===`idle`?{tone:`success`,message:U(`taskCompleted`)}:e===`error`?{tone:`error`,message:U(`taskError`)}:e===`aborted`?{tone:`aborted`,message:U(`processAborted`)}:e===`running`?{tone:`running`,message:U(`taskRunning`)}:{tone:`neutral`,message:U(`taskRunning`)}}function Fc({toast:e,onDismiss:t,onClick:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null);(0,H.useEffect)(()=>{let n=window.setTimeout(()=>i(!0),10);return s.current=window.setTimeout(()=>{o(!0),s.current=window.setTimeout(()=>t(e.id),200)},5e3),()=>{window.clearTimeout(n),s.current!==null&&window.clearTimeout(s.current)}},[e.id,t]);let c=()=>{o(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>t(e.id),200)},l=Pc(e.status),u=l.tone===`error`,d=l.tone===`success`,f=W(`size-5`,u&&`text-destructive`,d&&`text-emerald-500`,l.tone===`aborted`&&`text-amber-600`,l.tone===`running`&&`text-blue-600`,l.tone===`neutral`&&`text-muted-foreground`);return(0,G.jsxs)(`div`,{role:`alert`,onClick:()=>n(e.sessionId),className:W(`pointer-events-auto flex w-80 cursor-pointer items-start gap-3 rounded-xl border border-border bg-background p-3 shadow-quickforge transition-all duration-200 ease-out`,r&&!a?`translate-x-0 opacity-100`:`translate-x-4 opacity-0`),children:[(0,G.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:d?(0,G.jsx)(O,{className:f}):(0,G.jsx)(I,{className:f})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.title}),(0,G.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-xs text-muted-foreground`,children:e.message||l.message})]}),(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},className:`shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground`,"aria-label":U(`close`),children:(0,G.jsx)(ie,{className:`size-4`})})]})}function Ic({toasts:e,onDismiss:t,onClick:n}){return e.length===0?null:(0,G.jsx)(`div`,{className:`pointer-events-none fixed right-4 top-16 z-50 flex flex-col gap-2`,children:e.map(e=>(0,G.jsx)(Fc,{toast:e,onDismiss:t,onClick:n},e.id))})}async function Lc(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 Rc(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 zc(e){return`projectId=${encodeURIComponent(e)}`}function Bc(e){return Lc(`/api/workspace/tree?${zc(e)}`)}function Vc(e,t){return Lc(`/api/workspace/file?${zc(e)}&path=${encodeURIComponent(t)}`)}function Hc(e,t){return Rc(`/api/workspace/resolve-path`,{projectId:e,path:t})}function Uc(e,t,n){return Rc(`/api/workspace/open-external`,{projectId:e,path:t,target:n})}function Wc(e){return Lc(`/api/git/status?${zc(e)}`)}function Gc(e,t){return Lc(`/api/git/file-diff?${zc(e)}&path=${encodeURIComponent(t)}`)}function Kc(e,t){return Rc(`/api/git/stage`,{projectId:e,path:t})}function qc(e){return Rc(`/api/git/stage-all`,{projectId:e})}function Jc(e,t){return Rc(`/api/git/unstage`,{projectId:e,path:t})}function Yc(e){return Rc(`/api/git/unstage-all`,{projectId:e})}function Xc(e,t){return Rc(`/api/git/restore`,{projectId:e,path:t})}function Zc(e){return Rc(`/api/git/restore-all`,{projectId:e})}function Qc(e){return Lc(`/api/git/branches?${zc(e)}`)}function $c(e,t){return Rc(`/api/git/checkout`,{projectId:e,branch:t})}function el(e,t){return Rc(`/api/git/create-branch`,{projectId:e,branch:t})}function tl(e){return Lc(`/api/git/log?${zc(e)}`)}function nl(e,t,n,r){return Rc(`/api/git/generate-commit-message`,{projectId:e,model:t,thinkingLevel:n,includeUnstaged:r})}function rl(e,t,n){return Rc(`/api/git/commit`,{projectId:e,message:t,includeUnstaged:n})}function il(e){return Rc(`/api/git/push`,{projectId:e})}function al(e,t,n){return Rc(`/api/git/commit-and-push`,{projectId:e,message:t,includeUnstaged:n})}function ol({projectId:e,currentBranch:t,dirtyCount:r=0,className:i,onCheckout:a,onCreated:o,onOpenGraph:s,onOpenChanges:l}){let u=(0,H.useRef)(null),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)([]),[h,g]=(0,H.useState)(!0),[_,v]=(0,H.useState)(),[b,x]=(0,H.useState)(),S=(0,H.useCallback)(async()=>{g(!0),v(void 0);try{m((await Qc(e)).branches)}catch(e){v(e instanceof Error?e.message:U(`gitBranchesFailed`))}finally{g(!1)}},[e]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{S(),u.current?.focus()},0);return()=>window.clearTimeout(e)},[S]);let C=(0,H.useMemo)(()=>{let e=d.trim().toLowerCase();return e?p.filter(t=>t.name.toLowerCase().includes(e)):p},[p,d]),w=(0,H.useCallback)(async e=>{if(!(e.current||b)){x(e.name);try{await a(e.name),await S()}finally{x(void 0)}}},[b,a,S]),T=(0,H.useCallback)(async()=>{let t=await Cc({title:U(`createBranchTitle`),description:U(`createBranchDescription`),placeholder:U(`createBranchPlaceholder`),confirmLabel:U(`createAndCheckoutBranch`),cancelLabel:U(`cancel`)});if(t){x(t);try{let n=await el(e,t);o?.(n),await S()}catch(e){$(e instanceof Error?e.message:U(`gitCheckoutFailed`))}finally{x(void 0)}}},[o,e,S]);return(0,G.jsxs)(`div`,{className:W(`absolute left-0 top-10 z-40 w-[340px] overflow-hidden rounded-2xl border border-border bg-popover shadow-quickforge`,i),onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:`border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] p-3`,children:(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(D,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/70`}),(0,G.jsx)(xc,{ref:u,value:d,onChange:e=>f(e.target.value),placeholder:U(`searchBranches`),className:`h-10 rounded-xl border-transparent bg-background pl-9 text-sm shadow-none focus-visible:border-border`})]})}),l?(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-center gap-2 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 py-3 text-sm text-muted-foreground transition-colors hover:bg-muted/20 hover:text-foreground`,onClick:l,children:[(0,G.jsx)(`span`,{children:U(`uncommittedChanges`)}),(0,G.jsx)(`span`,{children:U(`filesCount`,{count:r})})]}):null,(0,G.jsx)(`div`,{className:`max-h-[340px] overflow-y-auto p-2`,children:h?(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-8 text-sm text-muted-foreground`,children:[(0,G.jsx)(n,{className:`size-4 animate-spin`}),(0,G.jsx)(`span`,{children:U(`loading`)})]}):_?(0,G.jsx)(`div`,{className:`rounded-xl bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:_}):C.length===0?(0,G.jsx)(`div`,{className:`rounded-xl bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:U(`noBranchesFound`)}):C.map(e=>{let r=e.current||e.name===t,i=b===e.name;return(0,G.jsxs)(`button`,{type:`button`,className:W(`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors`,r?`bg-muted text-foreground`:`text-foreground/88 hover:bg-muted/70`),onClick:()=>void w(e),disabled:r||!!b,title:e.name,children:[i?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(ce,{className:W(`size-4 shrink-0`,r?`text-foreground`:`text-muted-foreground`)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),r?(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:U(`currentBranch`)}):null]},`${e.remote?`remote`:`local`}:${e.name}`)})}),o||s?(0,G.jsxs)(`div`,{className:`border-t-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] p-2`,children:[o?(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm text-foreground/88 transition-colors hover:bg-muted/70`,onClick:()=>void T(),disabled:!!b,children:[(0,G.jsx)(y,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`createAndCheckoutBranchEllipsis`)})]}):null,s?(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm text-foreground/88 transition-colors hover:bg-muted/70`,onClick:s,children:[(0,G.jsx)(c,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitGraph`)})]}):null]}):null]})}function sl(e){return e?.detached===!0||e?.branch===`HEAD`||!!e?.branch?.startsWith(`HEAD `)}function cl(e,t){return e?.files?.length?e.files.filter(e=>!e.conflict&&(t||e.staged)):[]}function ll(e,t,n){return!!(e?.isGitRepository&&!e.counts?.conflicts&&!sl(e)&&n.trim()&&cl(e,t).length)}function ul(e){return(e?.files??[]).reduce((e,t)=>(e.additions+=t.additions??0,e.deletions+=t.deletions??0,e),{additions:0,deletions:0})}function dl(e){return e.conflict?`!`:e.status===`untracked`?`?`:e.status===`added`?`A`:e.status===`deleted`?`D`:e.status===`renamed`?`R`:`M`}function fl({open:e,projectId:r,status:a,onClose:o,onCheckout:s,onRefreshStatus:c,onStatusChange:l,onCompleted:u}){let[d,p]=(0,H.useState)(``),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!0),[C,w]=(0,H.useState)(),[T,E]=(0,H.useState)(``),[D,O]=(0,H.useState)(``),[k,ee]=(0,H.useState)(),[A,te]=(0,H.useState)(`off`),N=(0,H.useMemo)(()=>ul(a),[a]),P=(0,H.useMemo)(()=>cl(a,m),[m,a]),F=(0,H.useMemo)(()=>new Set(P.map(e=>e.path)),[P]),I=a?.counts?.total??a?.files.length??0,L=sl(a),R=!x&&ll(a,m,d);if((0,H.useEffect)(()=>{if(!e)return;let t=!1;return c().then(e=>{!t&&!e&&E(U(`gitStatusRefreshFailed`))}).finally(()=>{t||S(!1)}),()=>{t=!0}},[c,e,r]),(0,H.useEffect)(()=>{if(!e)return;let t=!1;async function n(){try{let e=await Yt(),n=await sn(e),r=await en(e),i=r.model??await cn(e)??n[0];if(t||!i)return;ee(i),te(r.thinkingLevel??Zt(i))}catch{}}return n(),()=>{t=!0}},[e]),(0,H.useEffect)(()=>{if(!g)return;let e=()=>_(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[g]),(0,H.useEffect)(()=>{if(!e)return;function t(e){e.key===`Escape`&&!C&&(_(!1),o())}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[C,o,e]),!e)return null;async function ne(){if(!r){E(U(`gitCommitNoProject`));return}if(!k){E(U(`gitCommitNoModel`));return}if(!P.length){E(U(`gitNoStagedChanges`));return}w(`generate`),E(``);try{p((await nl(r,k,A,m)).message)}catch(e){E(e instanceof Error?e.message:U(`gitGenerateCommitMessageFailed`))}finally{w(void 0)}}async function z(e){if(r){if(e!==`push`){if(!d.trim()){E(U(`gitCommitMessageRequired`));return}if(!R){E(U(L?`gitDetachedHeadBlocked`:`gitNoStagedChanges`));return}}if(L){E(U(`gitDetachedHeadBlocked`));return}w(e),E(``);try{if(e===`push`){let e=await il(r);O(``),u(e);return}if(e===`commit-push`){let e=await al(r,d.trim(),m);if(!e.pushed){l(e),p(``),O(e.pushError||U(`gitOperationFailed`));return}p(``),u(e);return}let t=await rl(r,d.trim(),m);p(``),u(t)}catch(e){E(e instanceof Error?e.message:U(`gitOperationFailed`))}finally{w(void 0)}}}return(0,Vn.createPortal)((0,G.jsx)(`div`,{className:`fixed inset-0 z-[80] flex items-center justify-center bg-black/50 px-6 py-8`,role:`dialog`,"aria-modal":`true`,onMouseDown:e=>{e.target===e.currentTarget&&!C&&(_(!1),o())},children:(0,G.jsxs)(`div`,{className:`flex max-h-[min(700px,calc(100vh-64px))] w-full max-w-[760px] flex-col overflow-hidden rounded-3xl border border-[color-mix(in_oklab,var(--border)_42%,transparent)] bg-background shadow-2xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex max-w-[280px] items-center gap-2.5 rounded-xl px-2 py-1.5 text-base text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>_(e=>!e),disabled:!r||!!C,"aria-label":U(`gitBranchMenu`),"aria-haspopup":`menu`,"aria-expanded":g,children:[(0,G.jsx)(ce,{className:`size-5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:a?.branch||U(`unknown`)}),(0,G.jsx)(b,{className:`size-4 shrink-0`})]}),g&&r?(0,G.jsx)(ol,{projectId:r,currentBranch:a?.branch,className:`top-11`,onCheckout:async e=>{await s(e),_(!1)}}):null]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-base font-medium`,children:[(0,G.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,N.additions]}),(0,G.jsxs)(`span`,{className:`text-red-600`,children:[`-`,N.deletions]}),(0,G.jsx)(`button`,{type:`button`,className:`ml-2 rounded-full p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>{_(!1),o()},disabled:!!C,"aria-label":U(`close`),children:(0,G.jsx)(ie,{className:`size-5`})})]})]}),(0,G.jsxs)(`div`,{className:`relative min-h-44 px-6 pb-4`,children:[(0,G.jsx)(`textarea`,{value:d,onChange:e=>{p(e.target.value),E(``)},onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),!C&&R&&z(`commit`))},placeholder:U(`gitCommitMessagePlaceholder`),disabled:!!C,className:`min-h-40 w-full resize-none bg-transparent pr-12 text-base leading-7 text-foreground/90 outline-none placeholder:text-muted-foreground/72 disabled:opacity-60`}),(0,G.jsx)(`button`,{type:`button`,className:W(`absolute right-6 top-0 rounded-full p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,C===`generate`&&`pointer-events-none`),onClick:()=>void ne(),disabled:!!C||x||!P.length||L,title:U(`gitGenerateCommitMessage`),"aria-label":U(`gitGenerateCommitMessage`),children:C===`generate`?(0,G.jsx)(n,{className:`size-5 animate-spin`}):(0,G.jsx)(j,{className:`size-5`})})]}),(0,G.jsxs)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_24%,transparent)] px-6 py-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 items-center gap-3 text-foreground/92`,children:[(0,G.jsx)(`button`,{type:`button`,className:W(`flex size-5 shrink-0 items-center justify-center rounded-md border transition-colors`,m?`border-black bg-black text-white`:`border-border bg-background text-transparent`),onClick:()=>{h(e=>!e),O(``),E(``)},disabled:!!C||x,"aria-pressed":m,children:(0,G.jsx)(i,{className:`size-3.5`})}),(0,G.jsx)(`span`,{children:U(`gitIncludeUnstagedChanges`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>y(e=>!e),disabled:!I,children:[(0,G.jsx)(`span`,{children:U(`gitCommitFilesSummary`,{selected:P.length,total:I})}),(0,G.jsx)(b,{className:W(`size-4 transition-transform`,v&&`rotate-180`)})]})]}),m?(0,G.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:U(`gitIncludeUnstagedWarning`)}):null,v?(0,G.jsx)(`div`,{className:`mt-3 max-h-44 space-y-1 overflow-y-auto border-t border-[color-mix(in_oklab,var(--border)_24%,transparent)] pt-3`,children:(a?.files??[]).map(e=>{let t=F.has(e.path);return(0,G.jsxs)(`div`,{className:W(`flex items-center gap-2 rounded-lg px-2 py-1.5`,!t&&`opacity-45`),children:[(0,G.jsx)(`span`,{className:`w-4 shrink-0 text-center font-mono text-xs text-muted-foreground`,children:dl(e)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.path,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),t?null:(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:U(`gitFileNotIncluded`)})]},`${e.oldPath??``}:${e.path}`)})}):null]}),x?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-muted/55 px-4 py-3 text-sm text-muted-foreground`,children:U(`gitRefreshingStatus`)}):null,L?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:U(`gitDetachedHeadBlocked`)}):null,D?(0,G.jsxs)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:U(`gitCommitSucceededPushFailed`)}),(0,G.jsx)(`div`,{className:`mt-1 break-words text-xs opacity-90`,children:D})]}):null,T?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:T}):null,a?.counts?.conflicts?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:U(`gitCommitConflictsBlocked`)}):null,(0,G.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-6 py-4`,children:D?(0,G.jsxs)(`button`,{type:`button`,className:`flex h-12 w-full items-center gap-3 rounded-2xl bg-muted/70 px-3 text-left transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45`,disabled:!!C||L,onClick:()=>void z(`push`),children:[C===`push`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitRetryPush`)})]}):(0,G.jsxs)(`div`,{className:`space-y-1.5 text-base`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-3 text-left transition-colors hover:bg-muted/55 disabled:cursor-not-allowed disabled:opacity-45`,disabled:!!C||!R,onClick:()=>void z(`commit`),children:[C===`commit`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(f,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitCommitOnly`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-12 w-full items-center gap-3 rounded-2xl bg-muted/70 px-3 text-left transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45`,disabled:!!C||!R,onClick:()=>void z(`commit-push`),children:[C===`commit-push`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(M,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`flex-1`,children:U(`gitCommitAndPush`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-3 text-left text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35`,disabled:!!C||x||L,onClick:()=>void z(`push`),children:[C===`push`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitPushOnly`)})]})]})})]})}),document.body)}function pl(e){return e.files.reduce((e,t)=>(e.additions+=t.additions??0,e.deletions+=t.deletions??0,e),{additions:0,deletions:0})}function ml({projectId:e,status:t,expanded:n,onExpandedChange:r,onOpenChanges:i,onOpenCommitPush:a,onCheckout:o,onCreated:s,onOpenGraph:c}){let l=(0,H.useRef)(null),[u,d]=(0,H.useState)(!1),f=(0,H.useMemo)(()=>pl(t),[t]),p=t.counts?.total??t.files.length;return(0,H.useEffect)(()=>{if(!u)return;function e(e){l.current?.contains(e.target)||d(!1)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]),t.isGitRepository?(0,G.jsxs)(`div`,{ref:l,className:`relative`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`button`,{type:`button`,className:W(`inline-flex size-9 items-center justify-center rounded-2xl bg-transparent text-muted-foreground/85 transition-colors hover:bg-muted/45 hover:text-foreground/90`,n&&`bg-muted/45 text-foreground/90`),onClick:()=>r(!n),"aria-label":U(`togglePinnedSummary`),title:U(`togglePinnedSummary`),"aria-expanded":n,children:(0,G.jsx)(C,{className:`size-[18px]`})}),n?(0,G.jsxs)(`div`,{className:`absolute -right-20 top-11 z-40 w-[280px] rounded-3xl border border-[color-mix(in_oklab,var(--border)_38%,transparent)] bg-background p-4 text-foreground shadow-quickforge`,children:[(0,G.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:U(`environmentInfo`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-foreground/85`,children:[(0,G.jsx)(`button`,{type:`button`,className:`rounded-full p-1.5 transition-colors hover:bg-muted`,"aria-label":U(`more`),title:U(`more`),children:(0,G.jsx)(R,{className:`size-4`})}),(0,G.jsx)(`button`,{type:`button`,className:`rounded-full p-1.5 transition-colors hover:bg-muted`,onClick:()=>{d(!1),r(!1)},"aria-label":U(`gitToolsCollapse`),title:U(`gitToolsCollapse`),children:(0,G.jsx)(ie,{className:`size-4`})})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-2.5 text-left text-foreground/88 transition-colors hover:bg-muted/45 hover:text-foreground`,onClick:i,children:[(0,G.jsx)(N,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`flex-1 font-medium`,children:U(`gitToolsChanges`)}),(0,G.jsxs)(`span`,{className:`font-medium text-emerald-600`,children:[`+`,f.additions]}),(0,G.jsxs)(`span`,{className:`font-medium text-red-600`,children:[`-`,f.deletions]})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-2.5 text-left text-foreground/88 transition-colors hover:bg-muted/45 hover:text-foreground`,onClick:()=>d(e=>!e),"aria-expanded":u,children:[(0,G.jsx)(ce,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:t.branch||U(`unknown`)}),(0,G.jsx)(b,{className:W(`size-4 shrink-0 text-muted-foreground transition-transform`,u&&`rotate-180`)})]}),u?(0,G.jsx)(ol,{projectId:e,currentBranch:t.branch,dirtyCount:p,className:`left-auto right-full top-0 mr-3`,onCheckout:async e=>{await o(e),d(!1)},onCreated:e=>{s(e),d(!1)},onOpenGraph:()=>{d(!1),c()},onOpenChanges:()=>{d(!1),i()}}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-2.5 text-left text-foreground/88 transition-colors hover:bg-muted/45 hover:text-foreground`,onClick:a,children:[(0,G.jsx)(z,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`font-medium`,children:U(`gitToolsCommitOrPush`)})]})]})]}):null]}):null}function hl(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(nt(),{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}).format(t)}function gl(e){return e.type===`head`?`border-amber-500 text-foreground`:e.type===`tag`?`border-emerald-600 text-emerald-700 dark:text-emerald-300`:e.type===`remote`?`border-border bg-muted/40 text-muted-foreground`:`border-border bg-muted/30 text-muted-foreground`}function _l({decoration:e}){return(0,G.jsxs)(`span`,{className:W(`inline-flex h-6 items-center gap-1 rounded-lg border px-2 text-xs`,gl(e)),children:[e.type===`tag`?(0,G.jsx)(ae,{className:`size-3`}):(0,G.jsx)(ce,{className:`size-3`}),(0,G.jsx)(`span`,{children:e.name})]})}function vl({index:e,isLast:t}){return(0,G.jsxs)(`div`,{className:`relative flex h-full min-h-14 w-full justify-center`,"aria-hidden":`true`,children:[t?null:(0,G.jsx)(`div`,{className:`absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-amber-500/20`}),e>0?(0,G.jsx)(`div`,{className:`absolute left-1/2 top-0 h-1/2 w-px -translate-x-1/2 bg-amber-500/20`}):null,(0,G.jsx)(`div`,{className:W(`relative z-10 mt-5 rounded-full border bg-background`,e===0?`size-3.5 border-2 border-amber-500/80`:`size-2.5 border-amber-500/65`)})]})}function yl({projectId:e,projectName:t,onClose:r}){let[i,a]=(0,H.useState)([]),[o,s]=(0,H.useState)(!0),[l,u]=(0,H.useState)(),d=(0,H.useCallback)(async()=>{s(!0),u(void 0);try{a((await tl(e)).commits)}catch(e){u(e instanceof Error?e.message:U(`gitGraphFailed`))}finally{s(!1)}},[e]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{d()},0);return()=>window.clearTimeout(e)},[d]),(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let f=(0,H.useMemo)(()=>i,[i]);return(0,Vn.createPortal)((0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-6 backdrop-blur-sm`,onClick:e=>e.target===e.currentTarget?r():void 0,children:(0,G.jsxs)(`div`,{className:`flex h-[78vh] w-[86vw] max-w-[1500px] flex-col overflow-hidden rounded-2xl border border-border bg-background shadow-quickforge`,children:[(0,G.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5`,children:[(0,G.jsx)(c,{className:`size-5 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-base font-medium text-foreground`,children:U(`gitGraph`)}),(0,G.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t})]}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>void d(),"aria-label":U(`refresh`),disabled:o,children:o?(0,G.jsx)(n,{className:`size-4 animate-spin`}):(0,G.jsx)(ee,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`size-8`,onClick:r,"aria-label":U(`close`),children:(0,G.jsx)(ie,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[72px_minmax(360px,1fr)_160px_140px_120px] border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-muted/20 text-sm font-medium text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`graphColumn`)}),(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`description`)}),(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`date`)}),(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`author`)}),(0,G.jsx)(`div`,{className:`px-5 py-3`,children:U(`commit`)})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:o?(0,G.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(n,{className:`size-4 animate-spin`}),(0,G.jsx)(`span`,{children:U(`loading`)})]}):l?(0,G.jsx)(`div`,{className:`m-5 rounded-2xl border border-border bg-muted/30 p-5 text-sm text-muted-foreground`,children:l}):f.length===0?(0,G.jsx)(`div`,{className:`m-5 rounded-2xl border border-border bg-muted/30 p-5 text-sm text-muted-foreground`,children:U(`noGitCommits`)}):f.map((e,t)=>(0,G.jsxs)(`div`,{className:W(`grid min-h-14 grid-cols-[72px_minmax(360px,1fr)_160px_140px_120px] border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] text-sm`,e.decorations.some(e=>e.type===`head`||e.name===`HEAD`)?`bg-muted/28`:`bg-background`),children:[(0,G.jsx)(vl,{index:t,isLast:t===f.length-1}),(0,G.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 px-5 py-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.decorations.map(t=>(0,G.jsx)(_l,{decoration:t},`${e.hash}:${t.type}:${t.name}`)),(0,G.jsx)(`span`,{className:`min-w-0 break-words text-foreground/90`,children:e.subject})]})}),(0,G.jsx)(`div`,{className:`flex items-center border-l-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3 text-muted-foreground`,children:hl(e.date)}),(0,G.jsx)(`div`,{className:`flex min-w-0 items-center border-l-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3 text-muted-foreground`,children:(0,G.jsx)(`span`,{className:`truncate`,children:e.author})}),(0,G.jsx)(`div`,{className:`flex items-center border-l-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3 font-mono text-muted-foreground`,children:e.shortHash})]},e.hash))})]})}),document.body)}async function bl(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 xl(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 Sl(){let e=()=>Array.from({length:6},()=>xl(`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`)).join(``);return`${e()}-${e()}`}function Cl(e=24){return new Date(Date.now()+e*60*60*1e3).toISOString()}async function wl(e){return bl(`/api/shares`,{method:`POST`,body:JSON.stringify(e)})}async function Tl(e){return bl(`/api/shares${e?`?sessionId=${encodeURIComponent(e)}`:``}`)}async function El(e){return bl(`/api/shares/${encodeURIComponent(e)}`,{method:`DELETE`})}async function Dl(e){return bl(`/api/shared/${encodeURIComponent(e)}/meta`)}async function Ol(e,t=``){return bl(`/api/shared/${encodeURIComponent(e)}/unlock`,{method:`POST`,body:JSON.stringify({password:t})})}async function kl(e){return bl(`/api/shared/${encodeURIComponent(e)}/models`)}function Al({open:e,sessionId:t,title:n,onOpenChange:r}){let i=(0,H.useId)(),[a,o]=(0,H.useState)(`read`),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(`24h`),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)([]),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(),x=(0,H.useMemo)(()=>{if(l!==`never`)return Cl(l===`1h`?1:l===`7d`?168:24)},[l]);if((0,H.useEffect)(()=>{!e||!t||Tl(t).then(e=>g(e.shares)).catch(e=>b(e instanceof Error?e.message:`Failed to load shares`))},[e,t]),!e)return null;let S=a===`operate`,C=!!t&&(a!==`operate`||d&&s.trim()),w=async()=>{if(!(!t||!C)){if(S&&!s.trim()){b(`可操作分享必须设置密码。`);return}v(!0),b(void 0);try{let e=await wl({sessionId:t,permission:a,password:s.trim(),expiresAt:x});m(e.url),await Yo(e.url),f(!1),g((await Tl(t)).shares)}catch(e){b(e instanceof Error?e.message:`Failed to create share`)}finally{v(!1)}}},T=async e=>{let t=e.url||`${window.location.origin}/share/${encodeURIComponent(e.id)}`;m(t),await Yo(t)},E=async e=>{try{await El(e),g(t=>t.map(t=>t.id===e?{...t,revokedAt:new Date().toISOString()}:t))}catch(e){b(e instanceof Error?e.message:`Failed to revoke share`)}};return(0,G.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,G.jsxs)(`div`,{className:`flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-border bg-background shadow-quickforge`,onMouseDown:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border px-5 py-4`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:`分享到局域网`}),(0,G.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`当前对话:`,n,`。同一个对话只会有一个固定分享链接;只读分享密码可选,可操作分享必须设置密码。`]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`权限`}),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`rounded-xl border p-3 text-left text-sm ${a===`read`?`border-primary bg-primary/10`:`border-border`}`,onClick:()=>o(`read`),children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`仅阅读`}),(0,G.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:`只能查看这一个对话。`})]}),(0,G.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:()=>o(`operate`),children:[(0,G.jsx)(`div`,{className:`font-medium text-red-700`,children:`可操作(高危)`}),(0,G.jsx)(`div`,{className:`mt-1 text-xs text-red-700`,children:`允许对方操作这个原对话,禁止 Fork。`})]})]})]}),a===`operate`?(0,G.jsxs)(`div`,{className:`rounded-xl border border-red-300 bg-red-50 p-3 text-sm text-red-900`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2 font-semibold`,children:[(0,G.jsx)(L,{className:`mt-0.5 size-4`}),`高危可操作权限`]}),(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5`,children:`拥有链接和密码的人只能操作这一个原对话,但对方的消息、停止生成、回滚、模型/思考等级选择、YOLO 状态下可用工具等操作会按正常对话权限直接影响你的本机原对话。可操作分享必须设置密码。`}),(0,G.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-xs font-medium`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`我已了解风险,仍然允许可操作权限。`]})]}):null,(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{htmlFor:i,className:`block text-sm font-medium`,children:S?`密码(可操作必填)`:`密码(可选)`}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,G.jsx)(`input`,{id:i,value:s,onChange:e=>c(e.target.value),className:`h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 text-sm`,placeholder:S?`可操作分享必须设置密码`:`留空则打开链接无需密码`}),(0,G.jsxs)(K,{variant:`outline`,className:`h-10 sm:shrink-0`,onClick:()=>c(Sl()),children:[(0,G.jsx)(ee,{className:`mr-2 size-4`}),`生成密码`]})]}),(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:S?`可操作分享必须设置非空密码;修改密码后旧密码和已解锁状态会失效。`:`留空保存会取消密码保护;填写新密码保存后旧密码和已解锁状态会失效。`})]}),(0,G.jsxs)(`label`,{className:`block text-sm font-medium`,children:[`有效期`,(0,G.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`mt-2 h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`1h`,children:`1 小时`}),(0,G.jsx)(`option`,{value:`24h`,children:`24 小时`}),(0,G.jsx)(`option`,{value:`7d`,children:`7 天`}),(0,G.jsx)(`option`,{value:`never`,children:`永久,需手动撤销`})]})]}),p?(0,G.jsxs)(`div`,{className:`rounded-xl border border-emerald-300 bg-emerald-50 p-3 text-sm text-emerald-900`,children:[`已复制到剪切板。`,(0,G.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto whitespace-pre-wrap text-xs`,children:p})]}):null,y?(0,G.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:y}):null,h.length?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`已有分享`}),(0,G.jsx)(`div`,{className:`space-y-2`,children:h.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border p-2 text-xs`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-mono`,children:e.id}),(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>void T(e),"aria-label":`复制分享链接`,title:`复制分享链接`,children:(0,G.jsx)(re,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`text-destructive`,onClick:()=>void E(e.id),"aria-label":`撤销分享`,title:`撤销分享`,children:(0,G.jsx)(k,{className:`size-4`})})]})]},e.id))})]}):null]})}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border px-5 py-4`,children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(K,{variant:`outline`,onClick:()=>r(!1),children:U(`cancel`)}),(0,G.jsxs)(K,{variant:a===`operate`?`destructive`:`default`,disabled:!C||_,onClick:()=>void w(),title:a===`operate`&&!s.trim()?`可操作分享必须设置密码`:void 0,children:[(0,G.jsx)(re,{className:`mr-2 size-4`}),a===`operate`?`保存配置并复制高危可操作链接`:`保存配置并复制链接`]})]})})]})})}function jl(e){let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).pop()||t||`artifact`}function Ml(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|bmp|ico)$/i.test(t)?`image`:t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|xml|yml|yaml|toml|ini|py|rb|go|rs|java|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function Nl(e){return Ml(e)!==`unknown`}var Pl=/\.(svg|png|jpe?g|webp|gif|ico)$/i;function Fl(e){return Ml(e)===`html`||Pl.test(e)}function Il(e,t){let n=t.replace(/\\/g,`/`);return!e?.trim()||n.startsWith(`/`)||/^[a-zA-Z]:\//.test(n)?t:`${e.trim().replace(/\\/g,`/`).replace(/\/+$/,``)}/${n.replace(/^\/+/,``)}`}function Ll(e,t,n){let r=t.replace(/\\/g,`/`),i=r.match(/^\/+/)?.[0]??``,a=i+r.slice(i.length).split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`),o=`/api/workspace/preview/${encodeURIComponent(e)}/${a}`;return n?`${o}?r=${n}`:o}function Rl(e){return e.replace(/\\/g,`/`).toLowerCase()}function zl(e){let t=jl(e.path).toLowerCase();return e.defaultPreview?0:e.explicit&&e.preview?1:e.explicit?2:t===`index.html`?3:e.kind===`html`?4:e.kind===`image`?5:e.kind===`markdown`?6:e.kind===`code`?7:20}function Bl(e){let t=new Map;for(let n of e){if(!n.path)continue;let e=Rl(n.path),r=n.kind??Ml(n.path),i=t.get(e),a=n.preview??Nl(n.path),o=n.source===`present_files`||n.presentation===`explicit`;if(!i){t.set(e,{id:e,path:n.path,title:n.title,description:n.description,kind:r,preview:a,defaultPreview:!!n.defaultPreview,explicit:o,addedLines:n.addedLines,removedLines:n.removedLines,sources:[n.source],toolCallIds:n.toolCallId?[n.toolCallId]:[]});continue}i.preview=i.preview||a,i.defaultPreview=i.defaultPreview||!!n.defaultPreview,i.explicit=i.explicit||o,i.title=n.title||i.title,i.description=n.description||i.description,typeof n.addedLines==`number`&&(i.addedLines=(i.addedLines??0)+n.addedLines),typeof n.removedLines==`number`&&(i.removedLines=(i.removedLines??0)+n.removedLines),i.kind=i.kind===`unknown`?r:i.kind,i.sources.includes(n.source)||i.sources.push(n.source),n.toolCallId&&!i.toolCallIds.includes(n.toolCallId)&&i.toolCallIds.push(n.toolCallId)}return[...t.values()].sort((e,t)=>zl(e)-zl(t))}function Vl(e){let t=Bl(e).filter(e=>e.preview&&e.explicit);if(t.length<=1)return t[0];let n=new Map;for(let t=0;t<e.length;t++){let r=e[t]?.toolCallId;r&&n.set(r,t)}let r=e=>{let t=e.toolCallIds,r=-1;for(let e of t){let t=n.get(e);typeof t==`number`&&t>r&&(r=t)}return r};return[...t].sort((e,t)=>r(t)-r(e))[0]}var Hl=(0,H.lazy)(()=>ze(()=>import(`./ChatPanelHost-Cld9HcVz.js`).then(e=>({default:e.ChatPanelHost})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Ul=(0,H.lazy)(()=>ze(()=>import(`./SharedConversationPage-op3DRwcw.js`).then(e=>({default:e.SharedConversationPage})),__vite__mapDeps([10,1,3,2,4,5,6,0,7,8,9]))),Wl=(0,H.lazy)(()=>ze(()=>import(`./WorkspaceInspector-73dhAime.js`).then(e=>({default:e.WorkspaceInspector})),__vite__mapDeps([11,1,12,5,6,13,14,15,9,3]))),Gl=(0,H.lazy)(()=>ze(()=>import(`./TerminalDock-BL_UovwU.js`).then(e=>({default:e.TerminalDock})),__vite__mapDeps([13,1,14,15,5,6]))),Kl=(0,H.lazy)(()=>ze(()=>import(`./SettingsWorkspacePage-Dr9zT5Bs.js`).then(e=>({default:e.SettingsWorkspacePage})),__vite__mapDeps([16,1,3,2,4,5,6,8]))),ql=`quickforge:auto-preview-seen-signatures`,Jl=200,Yl=`https://github.com/shawnstack/quickforge/releases/latest`,Xl=1350,Zl=280,Ql=150;function $l(){if(typeof window>`u`)return new Set;try{let e=window.sessionStorage.getItem(ql),t=e?JSON.parse(e):void 0;return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`&&e.length>0)):new Set}catch{return new Set}}function eu(e){return $l().has(e)}function tu(e){if(!(typeof window>`u`))try{let t=[...$l(),e].slice(-Jl);window.sessionStorage.setItem(ql,JSON.stringify(t))}catch{}}function nu(){return(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:U(`loading`)})}function ru(){return null}function iu({exiting:e=!1}){let t=U(`loadingChatWorkspace`);return(0,G.jsxs)(`div`,{className:W(`quickforge-startup-splash`,e&&`quickforge-startup-splash-exit`),role:`status`,"aria-label":t,children:[(0,G.jsxs)(`svg`,{className:`quickforge-startup-splash-icon`,viewBox:`0 0 64 64`,fill:`none`,"aria-hidden":`true`,children:[(0,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`startupIconStroke`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#9ca3af`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#4b5563`})]}),(0,G.jsxs)(`linearGradient`,{id:`startupIconBolt`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#374151`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#0f172a`})]})]}),(0,G.jsx)(`polygon`,{className:`quickforge-startup-splash-outline`,points:`32,6 52.78,18 52.78,42 32,54 11.22,42 11.22,18`,fill:`none`,stroke:`url(#startupIconStroke)`,strokeWidth:`4.5`,strokeLinejoin:`round`}),(0,G.jsx)(`polygon`,{className:`quickforge-startup-splash-outline-final`,points:`32,6 52.78,18 52.78,42 32,54 11.22,42 11.22,18`,fill:`none`,stroke:`url(#startupIconStroke)`,strokeWidth:`4.5`,strokeLinejoin:`round`}),(0,G.jsx)(`path`,{className:`quickforge-startup-splash-bolt`,d:`M37.2 13 L22 34 L30.6 34 L26.8 50 L42.8 26 L33.8 26 Z`,fill:`url(#startupIconBolt)`}),(0,G.jsx)(`path`,{className:`quickforge-startup-splash-bolt-trace`,d:`M37.2 13 L22 34 L30.6 34 L26.8 50 L42.8 26 L33.8 26 Z`,fill:`none`,stroke:`#f8fafc`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,G.jsx)(`path`,{className:`quickforge-startup-splash-bolt-highlight`,d:`M37.2 13 L22 34 L30.6 34 L33.8 26 Z`,fill:`#e5e7eb`})]}),(0,G.jsx)(`span`,{className:`sr-only`,children:t})]})}function au(e){return e===`idle`||e===`running`||e===`error`||e===`aborted`}function ou(e){return e.type===`scheduled_task_notification`}function su(e){return e.type===`scheduled_task_started`}function cu(e){return e===`starting`||e===`waiting_scan`||e===`running`||e===`stopping`}function lu(e){return Array.isArray(e.channels)?e.channels.some(e=>cu(e.status)):cu(e.snapshot?.status)||cu(e.status)}function uu(e){return[...Array.isArray(e.channels)?e.channels:[],...e.snapshot?[e.snapshot]:[]].filter(e=>cu(e.status)).map(e=>e.launchWorkspace).filter(e=>e?.kind===`project`&&typeof e.id==`string`&&e.id.length>0).map(e=>e.id)}function du(){let e=(0,H.useRef)(null),t=(0,H.useRef)(Gt(Rt)),i=(0,H.useRef)(`default`),o=(0,H.useRef)(void 0),s=(0,H.useRef)(void 0),{activeProject:c,projects:d,defaultWorkspace:f,expandedProjectIds:p,selectingProject:m,projectPickerOpen:h,loadProject:g,switchActiveProject:_,handleSelectProjectPath:v,selectProjectDirectory:y,setProjectPickerOpen:S,toggleProjectExpanded:C,toggleAllProjectsExpanded:w,reorderProjects:E,setActiveProject:D,setProjects:O,setExpandedProjectIds:k}=Eo(),{agentAccessMode:A,setAgentAccessMode:j,initialize:te}=Do(),M=Dc(),{setArtifactPreviewOpen:N,setWorkspaceInspectorOpen:F,setWorkspaceInspectorRequest:I}=M,[L,ne]=(0,H.useState)(!1),[z,re]=(0,H.useState)(),[B,ie]=(0,H.useState)(!1),[ae,oe]=(0,H.useState)(null),[se,ue]=(0,H.useState)(!1),[de,pe]=(0,H.useState)(!1),[me,he]=(0,H.useState)({artifacts:[]}),[ge,ve]=(0,H.useState)(`project`),[ye,be]=(0,H.useState)(`updatedAt`),xe=(0,H.useRef)(``),[Se,Ce]=(0,H.useState)(),[we,Te]=(0,H.useState)(),Ee=(0,H.useRef)(0),De=(0,H.useRef)(void 0),[Oe,ke]=(0,H.useState)(!1),[Ae,je]=(0,H.useState)(!1),[Me,Ne]=(0,H.useState)(!1),[Pe,Fe]=(0,H.useState)(!1),[Ie,Le]=(0,H.useState)(()=>new Set),Re=(0,H.useRef)(0),ze=(0,H.useRef)(0),Be=(0,H.useRef)(0),Ve=(0,H.useRef)(void 0),[Ue,We]=(0,H.useState)(null),[Ge,Ke]=(0,H.useState)(!1),[qe,Je]=(0,H.useState)(!1),[Ye,Xe]=(0,H.useState)(),{toasts:Ze,handleTaskComplete:Qe,addToast:$e,dismissToast:et}=ys(),tt=(0,H.useCallback)(()=>void 0,[]),nt=(0,H.useCallback)(()=>ie(!1),[]),rt=(0,H.useCallback)(()=>{ie(!1),window.open(Yl,`_blank`,`noopener,noreferrer`)},[]),it=(0,H.useCallback)(()=>{ie(!1),window.open(`quickforge://exit`,`_blank`,`noopener,noreferrer`)},[]),at=(0,H.useRef)(null),ot=(0,H.useRef)(null),{allLoadedSessions:st,pinnedSessions:ct,pinnedHasMore:lt,pinnedLoading:ut,globalSessions:dt,sessionsForProject:ft,globalHasMore:pt,projectTimelineSessions:mt,projectTimelineHasMore:gt,projectTimelineLoading:vt,projectHasMore:yt,globalLoading:bt,projectLoading:xt,projectLoaded:St,loadGlobalSessions:wt,loadProjectSessions:Tt,refreshSessions:Et,upsertSessionMetadata:Dt,updateSessionTitle:Ot,loadMorePinned:kt,loadMoreGlobal:q,loadMoreProject:At,loadMoreProjectTimeline:J}=vs({backendRef:ot,expandedProjectIds:p,externalProjectIds:Ie,viewMode:ge,sortMode:ye,onBroadcastSessionsChanged:(0,H.useCallback)(()=>at.current?.notifySessionsChanged(),[])}),Y=ko({onSessionsChanged:()=>{Et()},onProjectsChanged:()=>{g()},onSettingsChanged:()=>{Et()}});(0,H.useEffect)(()=>{i.current=A},[A]),(0,H.useEffect)(()=>{o.current=c},[c]),(0,H.useEffect)(()=>{s.current=f},[f]),(0,H.useEffect)(()=>{at.current=Y},[Y]),(0,H.useEffect)(()=>{let e=window.setTimeout(()=>Ke(!0),Xl);return()=>window.clearTimeout(e)},[]);let jt=(0,H.useCallback)((e,t)=>{Ce(n=>n?.sessionId===e&&kn(n,t)?n:{sessionId:e,...t})},[]),X=us({storageRef:e,activeModelRef:t,agentAccessModeRef:i,activeProjectRef:o,defaultWorkspaceRef:s,setAgentAccessMode:j,switchActiveProject:_,sessions:st,refreshSessions:Et,updateSessionTitle:Ot,onTaskComplete:Qe});(0,H.useEffect)(()=>{if(!X.loadingSessionId){let e=window.setTimeout(()=>Xe(void 0),0);return()=>window.clearTimeout(e)}let e=X.loadingSessionId,t=window.setTimeout(()=>Xe(e),Ql);return()=>window.clearTimeout(t)},[X.loadingSessionId]);let{createAgent:Nt,startDeferredSession:Pt,loadSession:Ft,syncSessionUI:It,setCurrentAgentMessages:Lt,updateCurrentAgentModel:zt,setChatPanelRevision:Bt,setCurrentTitleRef:Vt,agentRef:Ht,taskMapRef:Ut,currentSessionIdRef:Wt,currentChatScopeRef:Kt}=X;(0,H.useEffect)(()=>{De.current=X.currentToolProject?.id,Ee.current+=1,Be.current+=1},[X.currentToolProject?.id]);let qt=(0,H.useCallback)(e=>{e&&Ft(e)},[Ft]);(0,H.useEffect)(()=>{let e=e=>{let t=e.detail;typeof t?.sessionId==`string`&&qt(t.sessionId)};return window.addEventListener(`quickforge:open-session-from-settings`,e),()=>window.removeEventListener(`quickforge:open-session-from-settings`,e)},[qt]);let Jt=(0,H.useCallback)(e=>{re(t=>t?.id===e?void 0:t)},[]),Yt=(0,H.useCallback)(e=>{ze.current+=1,I({...e,id:ze.current}),F(!0)},[F,I]),Xt=(0,H.useCallback)(e=>{I(t=>t?.id===e?void 0:t)},[I]),Zt=(0,H.useCallback)(()=>{let e=X.currentToolProject?.id;e&&(N(!1),Yt({projectId:e,kind:`review`,view:`changes`}))},[X.currentToolProject?.id,Yt,N]),Qt=(0,H.useCallback)(async()=>{let e=X.currentToolProject?.id,t=Ee.current+1;if(Ee.current=t,!e){Te(void 0);return}try{let n=await Wc(e);return jc({projectId:e,requestId:t},De.current,Ee.current)?(Te(n),n):void 0}catch(n){if(!jc({projectId:e,requestId:t},De.current,Ee.current))return;V.warn(`Failed to refresh title git status:`,n),Te(void 0);return}},[X.currentToolProject?.id]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{Qt()},0);return()=>window.clearTimeout(e)},[Qt]),(0,H.useEffect)(()=>{let e,t=Ho(t=>{Nc(t,Wt.current,De.current)&&(e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,Qt()},400))});return()=>{e!==void 0&&window.clearTimeout(e),t()}},[X.currentSessionId,Wt,Qt]);let $t=(0,H.useCallback)(async e=>{let t=X.currentToolProject?.id;if(!t)return;let n=Ee.current+1;Ee.current=n;try{let r=await $c(t,e);if(!jc({projectId:t,requestId:n},De.current,Ee.current))return;Te(r),ke(!1),$e({sessionId:X.currentSessionId??``,title:U(`gitBranchSwitched`),status:`idle`,message:e})}catch(e){if(!jc({projectId:t,requestId:n},De.current,Ee.current))return;throw V.error(`Failed to checkout git branch:`,e),$(e instanceof Error?e.message:U(`gitCheckoutFailed`)),e}},[$e,X.currentSessionId,X.currentToolProject?.id]),en=(0,H.useCallback)(e=>{Te(e),ke(!1),$e({sessionId:X.currentSessionId??``,title:U(`gitBranchCreated`),status:`idle`,message:e.branch??``})},[$e,X.currentSessionId]),tn=(0,H.useCallback)(e=>{Te(e),$e({sessionId:X.currentSessionId??``,title:U(`gitOperationCompleted`),status:`idle`,message:e.branch??``})},[$e,X.currentSessionId]),nn=(0,H.useCallback)(async e=>{let t=X.currentToolProject?.id;if(!t){$e({sessionId:X.currentSessionId??``,title:`无法打开文件`,status:`error`,message:`当前对话没有关联项目。`});return}let n=Be.current+1;Be.current=n;try{let r=await Hc(t,e);if(!jc({projectId:t,requestId:n},De.current,Be.current))return;Yt({projectId:t,kind:`reader`,path:r.relativePath})}catch(e){if(!jc({projectId:t,requestId:n},De.current,Be.current))return;let r=e instanceof Error?e.message:`打开文件失败`;$e({sessionId:X.currentSessionId??``,title:`无法打开文件`,status:`error`,message:r})}},[$e,X.currentSessionId,X.currentToolProject?.id,Yt]),rn=(0,H.useCallback)((e,t)=>{let n=X.currentToolProject;!n||n.id!==e||!Fl(t)||(N(!1),Yt({projectId:e,kind:`browser`,url:Il(n.path,t)}))},[X.currentToolProject,Yt,N]);(0,H.useEffect)(()=>{let e=X.currentToolProject,t=e?.id;if(!t||me.projectId!==t||me.sessionId!==X.currentSessionId)return;let n=Vl(me.artifacts);if(!n?.path)return;let r=n.toolCallIds[n.toolCallIds.length-1],i=`${t}:${n.path}:${n.defaultPreview?`default`:n.explicit?`explicit`:`inferred`}:${r??``}`;if(i!==xe.current){if(eu(i)){xe.current=i;return}xe.current=i,tu(i),queueMicrotask(()=>{N(!1),n.kind===`markdown`||n.kind===`code`?Yt({projectId:t,kind:`reader`,path:n.path}):Yt({projectId:t,kind:`browser`,url:Il(e.path,n.path)})})}},[X.currentSessionId,X.currentToolProject,me,Yt,N]),(0,H.useEffect)(()=>{xe.current=``,N(!1),I(void 0)},[X.currentToolProject?.id,N,I]),(0,H.useEffect)(()=>{if(!rn)return;let e=e=>{let t=e.detail,n=X.currentToolProject?.id;n&&t&&typeof t.path==`string`&&rn(n,t.path)};return window.addEventListener(`quickforge:preview-artifact`,e),()=>window.removeEventListener(`quickforge:preview-artifact`,e)},[X.currentToolProject?.id,rn]),(0,H.useEffect)(()=>Ho(e=>{if(su(e)){let t=typeof e.projectId==`string`?e.projectId:void 0;t&&(k(e=>{let n=new Set(e);return n.add(t),n}),Tt(t,0)),Et({broadcast:!0});return}if(e.type===`session_created`){let t=e.metadata;t?.id&&Dt(t)}else if(e.type===`title_updated`){let t=typeof e.sessionId==`string`?e.sessionId:void 0,n=typeof e.title==`string`?e.title:void 0;t&&n&&Ot(t,n)}else (e.type===`agent_end`||e.type===`session_forked`)&&Et({broadcast:!0});if(!ou(e))return;let t=typeof e.sessionId==`string`?e.sessionId:void 0,n=typeof e.title==`string`?e.title:U(`scheduledTasks`),r=au(e.status)?e.status:`idle`,i=typeof e.message==`string`?e.message:void 0;$e({sessionId:t??``,title:n,status:r,message:i})}),[$e,Tt,Et,k,Ot,Dt]);let{ready:an,startupError:on,retryBootstrap:sn}=Ys({storageRef:e,backendRef:ot,activeModelRef:t,agentAccessModeRef:i,activeProjectRef:o,setAgentAccessMode:j,taskMapRef:Ut,loadGlobalSessions:wt,loadProject:g,initAgentAccessMode:te,switchActiveProject:_,createAgent:Nt,setNeedsModelSetup:ne,onStorageReady:We}),cn=ac(e,an),ln=an&&Ge&&!!(X.agent||L);(0,H.useEffect)(()=>{if(!ln)return;let e=window.setTimeout(()=>Je(!0),Zl);return()=>window.clearTimeout(e)},[ln]),(0,H.useEffect)(()=>{if(!an)return;let e=0,t,n=(t=[])=>{let n=Date.now();if(t.length>0&&Le(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),!(n-e<5e3)){e=n,g(),Et();for(let e of t)Tt(e,0)}},r=e=>{if(!e){t&&window.clearInterval(t),t=void 0;return}t||=window.setInterval(n,15e3)},i=new EventSource(`/api/channels/events`),a=e=>{try{let t=JSON.parse(e.data),i=uu(t);lu(t)?(r(!0),n(i)):(t.type===`snapshot`||t.type===`status`)&&r(!1)}catch{}};return i.addEventListener(`snapshot`,a),i.addEventListener(`status`,a),i.addEventListener(`log`,a),()=>{i.close(),t&&window.clearInterval(t)}},[g,Tt,an,Et]),(0,H.useEffect)(()=>{if(an)for(let e of p)!St(e)&&!xt(e)&&Tt(e,0)},[an,p,St,xt,Tt]);let{startNewGlobalChat:un,startNewProjectChat:dn,rollbackFromMessage:fn,retryFromMessage:pn,copyAnswer:mn,forkFromMessage:hn}=yc({storageRef:e,activeModelRef:t,activeProjectRef:o,currentChatScopeRef:Kt,currentSessionIdRef:Wt,taskMapRef:Ut,agentRef:Ht,createAgent:Nt,startDeferredSession:Pt,syncSessionUI:It,setCurrentAgentMessages:Lt,setChatPanelRevision:Bt,refreshSessions:Et,needsModelSetup:L,switchActiveProject:_,closeWorkspacePage:tt,setRestoredDraft:re}),{deleteProjectInline:gn}=bc({activeProjectRef:o,refreshSessions:Et,notifyProjectsChanged:Y.notifyProjectsChanged,setActiveProject:D,setProjects:O,setExpandedProjectIds:k,setChatPanelRevision:Bt});(0,H.useEffect)(()=>{let e=Ac({ready:an,currentToolProjectId:X.currentToolProject?.id,projects:d,activeProject:c,recoveringProjectId:Ve.current});if(e.type===`none`){let e=X.currentToolProject?.id;Ve.current&&Ve.current!==e&&(Ve.current=void 0);return}Ve.current=e.deletedProjectId,he({artifacts:[]}),I(void 0),N(!1),oe(null),ue(!1),Be.current+=1,Pt(e.type===`project`?{scope:`project`,project:e.project}:{scope:`global`}).catch(e=>{Ve.current=void 0,V.error(`Failed to recover after the current project was deleted:`,e)})},[c,X.currentToolProject?.id,d,an,N,I,Pt]);let{setAccessMode:_n}=Ec({storageRef:e,agentAccessModeRef:i,setAgentAccessMode:j,agentRef:Ht,setChatPanelRevision:Bt,notifySettingsChanged:Y.notifySettingsChanged}),vn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t)throw Error(U(`toolApprovalFailed`));try{await t.approveToolCall(e)}catch(e){throw V.error(`Failed to approve tool call:`,e),e instanceof Error?e:Error(U(`toolApprovalFailed`))}},[Ht]),yn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t)throw Error(U(`toolApprovalFailed`));try{await t.rejectToolCall(e)}catch(e){throw V.error(`Failed to reject tool call:`,e),e instanceof Error?e:Error(U(`toolApprovalFailed`))}},[Ht]),bn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t?.approveAutoCompact)throw Error(U(`toolApprovalFailed`));await t.approveAutoCompact(e)},[Ht]),xn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t?.rejectAutoCompact)throw Error(U(`toolApprovalFailed`));await t.rejectAutoCompact(e)},[Ht]),{loadSession:Sn,renameSession:Cn,togglePinSession:wn,archiveSession:Tn,startNewGlobalSession:En}=wc({storageRef:e,taskMapRef:Ut,currentSessionIdRef:Wt,loadAgentSession:Ft,setCurrentTitleRef:Vt,refreshSessions:Et,updateSessionTitle:Ot,closeWorkspacePage:tt,startNewGlobalChat:un}),Dn=(0,H.useCallback)((e,t)=>{M.setSettingsInitialTab(e),M.setSettingsCustomProvider(t),M.setSettingsDialogOpen(!0),M.setMobileSidebarOpen(!1)},[M]),{activateConfiguredModel:On,openModelSettings:An,openDefaultOptionsSettings:jn,openAboutSettings:Mn,activateLiteLlmExampleModel:Nn,openCustomModelSelector:Pn}=gc({storageRef:e,activeModelRef:t,agentRef:Ht,createAgent:Nt,updateCurrentAgentModel:zt,setChatPanelRevision:Bt,setNeedsModelSetup:ne,setRestoredDraft:re,notifySettingsChanged:Y.notifySettingsChanged,openSettingsPage:Dn}),Fn=(0,H.useCallback)(()=>{M.setSettingsDialogOpen(!1),M.setSettingsCustomProvider(void 0),(L||!Ht.current)&&On().catch(e=>V.error(`Failed to activate configured model:`,e))},[On,Ht,L,M]),In=(0,H.useCallback)(()=>{ie(!1),Mn()},[Mn]),Ln=(0,H.useMemo)(()=>st,[st]),Rn=!!(0,H.useMemo)(()=>{if(X.currentSessionId)return Ln.find(e=>e.id===X.currentSessionId)},[X.currentSessionId,Ln])?.pinnedAt,Vn=kc(Ln),Un=(0,H.useCallback)(e=>X.taskStatuses[e.id]??Vn[e.id]??e.taskStatus??`idle`,[X.taskStatuses,Vn]);(0,H.useEffect)(()=>{if(B)return window.addEventListener(`click`,nt),window.addEventListener(`blur`,nt),()=>{window.removeEventListener(`click`,nt),window.removeEventListener(`blur`,nt)}},[nt,B]),(0,H.useEffect)(()=>{if(!M.conversationMenuOpen)return;let e=()=>M.setConversationMenuOpen(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[M,M.conversationMenuOpen]),(0,H.useEffect)(()=>{if(!Oe)return;let e=()=>ke(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[Oe]),(0,H.useEffect)(()=>{let e=e=>{let t=e.detail,n=typeof t?.command==`string`?t.command.trim():``;n&&(async()=>{(t?.confirm||t?.dangerous)&&!await ss({title:U(`confirmExecuteCommandTitle`),description:t?.dangerous?U(`confirmExecuteDangerousCommand`):U(`confirmExecuteMultipleCommands`),confirmLabel:U(`executeInTerminal`),cancelLabel:U(`cancel`),variant:t?.dangerous?`destructive`:`default`})||(N(!1),ue(!0),oe({id:++Re.current,command:n,execute:!0}))})().catch(e=>{V.error(`Failed to execute markdown command:`,e),$(e instanceof Error?e.message:U(`terminalCommandExecuteFailed`))})};return window.addEventListener(`quickforge:execute-markdown-command`,e),()=>window.removeEventListener(`quickforge:execute-markdown-command`,e)},[N]);let Wn=(0,H.useCallback)(e=>{oe(t=>t?.id===e?null:t)},[]),Gn=(0,H.useCallback)(()=>{M.setFirstUseGuideDismissed(!0)},[M]),Kn=(0,H.useCallback)(()=>{let e=X.currentToolProject?.id?U(`firstUseGuideProjectPrompt`):U(`firstUseGuideGeneralPrompt`);navigator.clipboard.writeText(e).then(()=>$e({sessionId:X.currentSessionId??``,title:U(`copied`),status:`idle`,message:e})).catch(e=>{V.error(`Failed to copy first-use guide prompt:`,e),$(U(`copyFailed`))})},[$e,X.currentSessionId,X.currentToolProject?.id]),qn=!L&&!!X.agent&&!X.agent?.state.isStreaming&&(X.agent?.state.messages.length??0)===0,Jn=(0,H.useCallback)(e=>{dn(e)},[dn]),Yn=(0,H.useCallback)(()=>{En()},[En]),Xn=(0,H.useCallback)(()=>{y()},[y]),Zn=!!Ue&&!M.firstUseGuideDismissed&&!qn&&d.length===0&&dt.length===0,Qn=(0,H.useCallback)(()=>{let e=X.currentSessionId;e&&(M.setConversationMenuOpen(!1),wn(e))},[X.currentSessionId,wn,M]),$n=(0,H.useCallback)(()=>{let e=X.currentSessionId;e&&(M.setConversationMenuOpen(!1),Cn(e,X.currentTitle))},[X.currentSessionId,X.currentTitle,Cn,M]),er=(0,H.useCallback)(()=>{M.setConversationMenuOpen(!1),M.setShareDialogOpen(!0)},[M]),{setSkillsDialog:tr,setSidebarOpen:nr}=M,rr=(0,H.useCallback)(()=>{Dn(`skills`)},[Dn]),ir=(0,H.useCallback)(()=>{Dn(`agents`)},[Dn]),ar=(0,H.useCallback)(()=>{Dn(`scheduledTasks`)},[Dn]),or=(0,H.useCallback)(e=>{tr({scope:`project`,project:e})},[tr]),sr=(0,H.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||U(`openInExplorerFailed`))},[]),cr=(0,H.useCallback)(async e=>{let t=await fetch(`/api/project/${encodeURIComponent(e.id)}/open-in-vscode`,{method:`POST`});if(t.ok)return;let n=await t.json().catch(()=>null);throw Error(n?.error||U(`openInVSCodeFailed`))},[]),lr=(0,H.useCallback)(async e=>{let t=await fetch(`/api/project/${encodeURIComponent(e.id)}/open-in-idea`,{method:`POST`});if(t.ok)return;let n=await t.json().catch(()=>null);throw Error(n?.error||U(`openInIDEAFailed`))},[]),ur=(0,H.useCallback)(e=>{sr(e).catch(e=>{V.error(`Failed to open project in explorer:`,e),$(e instanceof Error?e.message:U(`openInExplorerFailed`))})},[sr]),dr=(0,H.useCallback)(e=>{cr(e).catch(e=>{V.error(`Failed to open project in VS Code:`,e),$(e instanceof Error?e.message:U(`openInVSCodeFailed`))})},[cr]),fr=(0,H.useCallback)(e=>{lr(e).catch(e=>{V.error(`Failed to open project in IntelliJ IDEA:`,e),$(e instanceof Error?e.message:U(`openInIDEAFailed`))})},[lr]),pr=(0,H.useCallback)(()=>nr(e=>!e),[nr]),Z=(0,H.useCallback)(()=>{M.setMobileSidebarOpen(!1)},[M]),mr=(0,H.useCallback)(e=>{Z(),Sn(e)},[Z,Sn]),hr=(0,H.useCallback)(()=>{Z(),En()},[Z,En]),gr=(0,H.useCallback)(e=>{Z(),dn(e)},[Z,dn]),_r=(0,H.useCallback)(()=>{Z(),rr()},[Z,rr]),vr=(0,H.useCallback)(()=>{Z(),ir()},[Z,ir]),yr=(0,H.useCallback)(()=>{Z(),ar()},[Z,ar]),br=(0,H.useCallback)(e=>{Z(),or(e)},[Z,or]),xr=(0,H.useCallback)(e=>{if(e.scope===`project`&&e.project&&e.projects){O(e.projects),M.setSkillsDialog({scope:`project`,project:e.project}),o.current?.id===e.project.id&&(D(e.project),o.current=e.project),Y.notifyProjectsChanged();return}Y.notifyProjectsChanged()},[Y,D,O,M]);return on?(0,G.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,G.jsxs)(`div`,{className:`max-w-md rounded-lg border border-border bg-background p-5 text-center`,children:[(0,G.jsx)(`h1`,{className:`text-base font-semibold`,children:U(`localServiceUnavailableTitle`)}),(0,G.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:on}),(0,G.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,G.jsx)(K,{variant:`outline`,size:`sm`,onClick:sn,children:U(`retry`)}),(0,G.jsx)(K,{variant:`default`,size:`sm`,onClick:()=>window.location.reload(),children:U(`reloadPage`)})]})]})}):!ln||!qe?(0,G.jsx)(iu,{exiting:ln}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`quickforge-desktop-titlebar fixed left-0 right-0 top-0 z-40 hidden h-8 items-center px-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`quickforge-desktop-titlebar-trigger inline-flex h-8 translate-y-1 items-center gap-2.5 rounded-none px-3 text-[13px] font-medium leading-none text-foreground/90 transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),ie(e=>!e)},"aria-haspopup":`menu`,"aria-expanded":B,children:[(0,G.jsxs)(`svg`,{className:`h-[18px] w-[18px] shrink-0`,viewBox:`0 0 64 64`,"aria-hidden":`true`,children:[(0,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`titlebarIconStroke`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#9ca3af`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#4b5563`})]}),(0,G.jsxs)(`linearGradient`,{id:`titlebarIconBolt`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#374151`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#0f172a`})]})]}),(0,G.jsx)(`polygon`,{points:`32,6 52.78,18 52.78,42 32,54 11.22,42 11.22,18`,fill:`none`,stroke:`url(#titlebarIconStroke)`,strokeWidth:`4.5`,strokeLinejoin:`round`}),(0,G.jsx)(`path`,{d:`M37.2 13 L22 34 L30.6 34 L26.8 50 L42.8 26 L33.8 26 Z`,fill:`url(#titlebarIconBolt)`}),(0,G.jsx)(`path`,{d:`M37.2 13 L22 34 L30.6 34 L33.8 26 Z`,fill:`#e5e7eb`,opacity:`0.4`})]}),(0,G.jsx)(`span`,{children:`QuickForge`})]}),B&&(0,G.jsxs)(`div`,{className:`quickforge-desktop-titlebar-menu absolute left-2 top-8 min-w-40 overflow-hidden rounded-md border border-border bg-popover py-1 text-[13px] text-popover-foreground shadow-lg`,role:`menu`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-8 w-full items-center gap-2.5 px-3 text-left hover:bg-accent hover:text-accent-foreground`,role:`menuitem`,onClick:In,children:[(0,G.jsx)(l,{className:`size-4`}),(0,G.jsx)(`span`,{children:U(`about`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-8 w-full items-center gap-2.5 px-3 text-left hover:bg-accent hover:text-accent-foreground`,role:`menuitem`,onClick:rt,children:[(0,G.jsx)(ee,{className:`size-4`}),(0,G.jsx)(`span`,{children:U(`desktopUpdate`)})]}),(0,G.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-8 w-full items-center gap-2.5 px-3 text-left text-destructive hover:bg-destructive/10`,role:`menuitem`,onClick:it,children:[(0,G.jsx)(_e,{className:`size-4`}),(0,G.jsx)(`span`,{children:U(`desktopExit`)})]})]})]}),!M.settingsDialogOpen&&(0,G.jsxs)(`div`,{className:W(`quickforge-window-toolbar fixed right-2 z-30 flex items-center gap-1`,de&&`pointer-events-none invisible`),"aria-hidden":de||void 0,"aria-label":U(`workspacePanel`),children:[M.workspaceInspectorOpen?null:(0,G.jsx)(Ct,{project:X.currentToolProject,disabled:L,onOpenInExplorer:ur,onOpenInVSCode:dr,onOpenInIDEA:fr}),!M.workspaceInspectorOpen&&X.currentToolProject?.id&&we?.isGitRepository?(0,G.jsx)(ml,{projectId:X.currentToolProject.id,status:we,expanded:Ae,onExpandedChange:je,onOpenChanges:()=>{je(!1),Zt()},onOpenCommitPush:()=>{je(!1),Ne(!0)},onCheckout:$t,onCreated:en,onOpenGraph:()=>Fe(!0)}):null,(0,G.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>{N(!1),ue(e=>!e)},disabled:!X.currentToolProject?.id||L,"aria-label":U(se?`terminalCollapse`:`rightPanelTerminal`),title:U(se?`terminalCollapse`:`rightPanelTerminal`),className:W(`rounded-[10px] text-muted-foreground/85 hover:bg-muted/45 hover:text-foreground/90 disabled:opacity-40`,se?`bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground`:void 0),children:(0,G.jsx)(le,{className:`size-[18px] stroke-[1.85]`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>{N(!1),M.setWorkspaceInspectorOpen(e=>!e)},disabled:!X.currentToolProject?.id||L,"aria-label":M.workspaceInspectorOpen?U(`workspaceCollapseRightPanel`):U(`workspaceExpandRightPanel`),title:M.workspaceInspectorOpen?U(`workspaceCollapseRightPanel`):U(`workspaceExpandRightPanel`),className:W(`hidden rounded-[10px] text-muted-foreground/85 hover:bg-muted/45 hover:text-foreground/90 disabled:opacity-40 lg:inline-flex`,M.workspaceInspectorOpen?`bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground`:void 0),children:(0,G.jsx)(a,{className:`size-[18px] stroke-[1.85]`})})]}),M.settingsDialogOpen?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(nu,{}),children:(0,G.jsx)(Kl,{initialTab:M.settingsInitialTab,customProvider:M.settingsCustomProvider,onBack:Fn})}):(0,G.jsxs)(`div`,{className:`flex h-screen min-h-0 bg-[var(--quickforge-sidebar-bg)] text-foreground`,children:[(0,G.jsx)(To,{sidebarOpen:M.sidebarOpen,projectsCollapsed:M.projectsCollapsed,pinnedCollapsed:M.pinnedCollapsed,conversationsCollapsed:M.conversationsCollapsed,projects:d,expandedProjectIds:p,activeProject:c,currentSessionId:X.currentSessionId,loadingSessionId:X.loadingSessionId,sessionViewMode:ge,sessionSortMode:ye,globalSessions:dt,pinnedSessions:ct,pinnedHasMore:lt,pinnedLoading:ut,sessionsForProject:ft,projectTimelineSessions:mt,projectTimelineHasMore:gt,projectTimelineLoading:vt,globalHasMore:pt,globalLoading:bt,onLoadMoreGlobal:q,onLoadMorePinned:kt,projectHasMore:yt,projectLoading:xt,projectLoaded:St,onLoadMoreProject:At,onLoadMoreProjectTimeline:J,sessionTaskStatus:Un,selectingProject:m,onTogglePinnedCollapsed:M.togglePinnedCollapsed,onToggleProjectsCollapsed:M.toggleProjectsCollapsed,onToggleConversationsCollapsed:M.toggleConversationsCollapsed,onToggleProjectExpanded:C,onToggleAllProjectsExpanded:w,onReorderProjects:E,onSelectProjectDirectory:y,onStartNewProjectChat:dn,onOpenGlobalSkills:rr,onOpenAgents:ir,onOpenScheduledTasks:ar,onOpenProjectSkills:or,onOpenProjectInExplorer:ur,onDeleteProject:gn,onLoadSession:Sn,onSessionViewModeChange:ve,onSessionSortModeChange:be,onTogglePinSession:wn,onDeleteSession:Tn,onStartNewGlobalChat:En,onOpenSettings:jn,updateAvailable:cn.result.updateAvailable,latestVersion:cn.result.latestVersion,currentVersion:cn.result.currentVersion,onOpenUpdate:Mn,onDismissUpdate:cn.dismissUpdate,onToggleSidebar:pr,currentSessionHoverInfo:Se}),M.mobileSidebarOpen?(0,G.jsxs)(`div`,{className:`fixed inset-0 z-50 md:hidden`,role:`dialog`,"aria-modal":`true`,children:[(0,G.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-background/65 backdrop-blur-sm`,onClick:Z,"aria-label":U(`toggleSidebar`)}),(0,G.jsx)(`div`,{className:`absolute inset-y-0 left-0 max-w-[85vw] shadow-quickforge`,children:(0,G.jsx)(To,{variant:`mobile`,sidebarOpen:!0,projectsCollapsed:M.projectsCollapsed,pinnedCollapsed:M.pinnedCollapsed,conversationsCollapsed:M.conversationsCollapsed,projects:d,expandedProjectIds:p,activeProject:c,currentSessionId:X.currentSessionId,loadingSessionId:X.loadingSessionId,sessionViewMode:ge,sessionSortMode:ye,globalSessions:dt,pinnedSessions:ct,pinnedHasMore:lt,pinnedLoading:ut,sessionsForProject:ft,projectTimelineSessions:mt,projectTimelineHasMore:gt,projectTimelineLoading:vt,globalHasMore:pt,globalLoading:bt,onLoadMoreGlobal:q,onLoadMorePinned:kt,projectHasMore:yt,projectLoading:xt,projectLoaded:St,onLoadMoreProject:At,onLoadMoreProjectTimeline:J,sessionTaskStatus:Un,selectingProject:m,onTogglePinnedCollapsed:M.togglePinnedCollapsed,onToggleProjectsCollapsed:M.toggleProjectsCollapsed,onToggleConversationsCollapsed:M.toggleConversationsCollapsed,onToggleProjectExpanded:C,onToggleAllProjectsExpanded:w,onReorderProjects:E,onSelectProjectDirectory:()=>{Z(),y()},onStartNewProjectChat:gr,onOpenGlobalSkills:_r,onOpenAgents:vr,onOpenScheduledTasks:yr,onOpenProjectSkills:br,onOpenProjectInExplorer:e=>{Z(),sr(e).catch(e=>{V.error(`Failed to open project in explorer:`,e),$(e instanceof Error?e.message:U(`openInExplorerFailed`))})},onDeleteProject:gn,onLoadSession:mr,onSessionViewModeChange:ve,onSessionSortModeChange:be,onTogglePinSession:wn,onDeleteSession:Tn,onStartNewGlobalChat:hr,onOpenSettings:()=>{Z(),jn()},updateAvailable:cn.result.updateAvailable,latestVersion:cn.result.latestVersion,currentVersion:cn.result.currentVersion,onOpenUpdate:()=>{Z(),Mn()},onDismissUpdate:cn.dismissUpdate,onToggleSidebar:Z,currentSessionHoverInfo:Se})})]}):null,(0,G.jsxs)(`main`,{className:W(`flex min-w-0 flex-1 flex-col bg-[var(--quickforge-main-bg)] md:overflow-hidden md:rounded-tl-2xl`),children:[(0,G.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 pr-20`,children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:()=>M.setMobileSidebarOpen(!0),"aria-label":U(`toggleSidebar`),children:(0,G.jsx)(u,{className:`size-[18px]`})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`min-w-0 truncate text-sm font-semibold text-foreground/92`,children:Mt(X.currentTitle)}),X.currentToolProject?.name?(0,G.jsxs)(`div`,{className:`inline-flex h-9 max-w-[220px] shrink-0 items-center gap-2 rounded-full bg-muted/55 px-3 text-sm text-foreground/88`,title:X.currentToolProject.name,children:[(0,G.jsx)(T,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:X.currentToolProject.name})]}):null,X.currentToolProject?.id&&we?.isGitRepository&&we.branch?(0,G.jsxs)(`div`,{className:`relative shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex h-9 max-w-[220px] items-center gap-2 rounded-full bg-muted/55 px-3 text-sm text-foreground/88 transition-colors hover:bg-muted`,onClick:()=>ke(e=>!e),"aria-label":U(`gitBranchMenu`),"aria-expanded":Oe,children:[(0,G.jsx)(ce,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:we.branch}),(0,G.jsx)(b,{className:`size-4 text-muted-foreground`})]}),Oe?(0,G.jsx)(ol,{projectId:X.currentToolProject.id,currentBranch:we.branch,dirtyCount:we.counts?.total??0,onCheckout:$t,onCreated:en,onOpenGraph:()=>{ke(!1),Fe(!0)},onOpenChanges:()=>{ke(!1),Zt()}}):null]}):null,(0,G.jsxs)(`div`,{className:`relative shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:()=>M.setConversationMenuOpen(e=>!e),disabled:!X.currentSessionId||L,"aria-label":U(`moreOptions`),"aria-expanded":M.conversationMenuOpen,children:(0,G.jsx)(R,{className:`size-[18px]`})}),M.conversationMenuOpen?(0,G.jsxs)(`div`,{className:`absolute left-0 top-8 z-30 min-w-44 rounded-lg border border-border bg-popover p-1 shadow-quickforge`,children:[(0,G.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:Qn,children:[Rn?(0,G.jsx)(fe,{className:`size-[18px]`}):(0,G.jsx)(r,{className:`size-[18px]`}),(0,G.jsx)(`span`,{children:U(Rn?`unpinSession`:`pinSession`)})]}),(0,G.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:$n,children:[(0,G.jsx)(x,{className:`size-[18px]`}),(0,G.jsx)(`span`,{children:U(`renameSession`)})]}),(0,G.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:er,children:[(0,G.jsx)(P,{className:`size-[18px]`}),(0,G.jsx)(`span`,{children:U(`shareSession`)})]})]}):null]})]})})]}),(0,G.jsxs)(`section`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[Ye&&Ye===X.loadingSessionId?(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center bg-background/55 backdrop-blur-[1px]`,role:`status`,"aria-live":`polite`,"aria-label":U(`loadingConversation`),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground/72`,children:[(0,G.jsx)(n,{className:`size-4 animate-spin`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:U(`loadingConversation`)})]})}):null,L?(0,G.jsx)(Bn,{onAddModel:An,onUseExample:()=>{Nn().catch(e=>V.error(`Failed to use LiteLLM example:`,e))}}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:W(`flex min-h-0 flex-1 flex-col`,qn?`quickforge-empty-chat`:void 0),children:[qn?(0,G.jsx)(`div`,{className:`quickforge-empty-chat-hero`,"aria-hidden":`true`,children:(0,G.jsx)(`h1`,{className:`quickforge-empty-chat-title`,children:U(`newChatEmptyTitle`)})}):null,(0,G.jsx)(ht,{children:(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(nu,{}),children:(0,G.jsx)(Hl,{agent:X.agent,onModelSelect:Pn,revision:X.chatPanelRevision,agentAccessMode:A,workspaceToolsEnabled:!!X.currentToolProject?.id,project:X.currentToolProject,projectId:X.currentToolProject?.id,chatScope:X.chatScope,onAccessModeChange:_n,onRollbackFromMessage:fn,onRetryFromMessage:pn,onCopyAnswer:mn,onForkFromMessage:hn,onApproveToolCall:vn,onRejectToolCall:yn,onApproveAutoCompact:bn,onRejectAutoCompact:xn,onOpenWorkspaceGitChanges:Zt,onOpenLocalFilePath:nn,onArtifactsChange:e=>{he({projectId:X.currentToolProject?.id,sessionId:X.currentSessionId,artifacts:e})},onContextUsageDisplayChange:jt,disableFork:!1,restoredDraft:z,onRestoredDraftConsumed:Jt,newChatEmptyState:qn})})}),qn?(0,G.jsx)(Hn,{projects:d,selectedProject:X.currentToolProject,chatScope:X.chatScope,onSelectProject:Jn,onClearProject:Yn,onNewProject:Xn}):null]}),Zn?(0,G.jsx)(zn,{hasProject:!!X.currentToolProject?.id,onConfigureModel:An,onAddProject:y,onCopyExamplePrompt:Kn,onDismiss:Gn}):null]})]}),se&&X.currentToolProject?.id?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(nu,{}),children:(0,G.jsx)(Gl,{project:X.currentToolProject,pendingCommand:ae,onPendingCommandHandled:Wn,onCollapse:()=>ue(!1)})}):null]}),X.currentToolProject?.id?(0,G.jsxs)(G.Fragment,{children:[M.workspaceInspectorOpen?(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`hidden w-px shrink-0 bg-[color-mix(in_oklab,var(--border)_30%,var(--quickforge-sidebar-bg))] lg:block`}):null,(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(ru,{}),children:(0,G.jsx)(Wl,{project:X.currentToolProject,open:M.workspaceInspectorOpen,onOpenChange:M.setWorkspaceInspectorOpen,onOpenCommitPush:()=>Ne(!0),onOpenProjectInExplorer:ur,onOpenProjectInVSCode:dr,onOpenProjectInIDEA:fr,onPreviewArtifact:rn,request:M.workspaceInspectorRequest,onRequestHandled:Xt,artifacts:me.projectId===X.currentToolProject.id&&me.sessionId===X.currentSessionId?me.artifacts:[],globalTerminalOpen:se,onShowGlobalTerminal:()=>{N(!1),ue(!0)},onFullscreenChange:pe},X.currentToolProject.id)})]}):null,Pe&&X.currentToolProject?.id?(0,G.jsx)(yl,{projectId:X.currentToolProject.id,projectName:X.currentToolProject.name,onClose:()=>Fe(!1)}):null,Me?(0,G.jsx)(fl,{open:!0,projectId:X.currentToolProject?.id,status:we,onClose:()=>Ne(!1),onCheckout:$t,onRefreshStatus:Qt,onStatusChange:Te,onCompleted:tn},X.currentToolProject?.id??`git-commit`):null]}),(0,G.jsx)(_t,{open:h,initialPath:c?.path,disabled:m,onOpenChange:S,onSelect:v}),(0,G.jsx)(He,{open:!!M.skillsDialog,scope:M.skillsDialog?.scope??`global`,project:M.skillsDialog?.project,onOpenChange:e=>{e||M.setSkillsDialog(void 0)},onSaved:xr}),(0,G.jsx)(Al,{open:M.shareDialogOpen,sessionId:X.currentSessionId,title:Mt(X.currentTitle),onOpenChange:M.setShareDialogOpen}),(0,G.jsx)(Ic,{toasts:Ze,onDismiss:et,onClick:qt})]})}function fu(){let e=window.location.pathname.match(/^\/share\/([^/]+)\/?$/)?.[1];return e?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background text-sm text-muted-foreground`,children:U(`loadingChatWorkspace`)}),children:(0,G.jsx)(Ul,{shareId:decodeURIComponent(e)})}):(0,G.jsx)(du,{})}dt({hideSelector:!0}),pt(),window.addEventListener(`error`,e=>{V.error(`Uncaught error:`,e.error??e.message)}),window.addEventListener(`unhandledrejection`,e=>{V.error(`Unhandled promise rejection:`,e.reason)}),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`).catch(()=>{})}),(0,Ue.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(H.StrictMode,{children:(0,G.jsx)(m,{strokeWidth:1.75,children:(0,G.jsx)(ht,{children:(0,G.jsx)(fu,{})})})}));export{gn as $,js as A,$ as B,tc as C,Js as D,Ks as E,Is as F,qo as G,Ko as H,Bs as I,jo as J,No as K,ws as L,Ns as M,Ps as N,As as O,Rs as P,vn as Q,Ts as R,Zs as S,Gs as T,Yo as U,ss as V,Jo as W,Rn as X,Io as Y,_n as Z,Kc as _,tt as _t,Ll as a,en as at,xc as b,Ol as c,$t as ct,Vc as d,kt as dt,hn as et,Bc as f,Et as ft,qc as g,it as gt,Xc as h,W as ht,Bl as i,Yt as it,Ls as j,ks as k,Gc as l,Mt as lt,Zc as m,K as mt,Ml as n,Zt as nt,Dl as o,cn as ot,Uc as p,Ct as pt,Fo as q,Fl as r,sn as rt,kl as s,Wt as st,jl as t,Rt as tt,Wc as u,q as ut,Yc as v,nt as vt,nc as w,hc as x,Jc as y,U as yt,Es as z};
|
|
64
|
+
`)}async function Qo(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 $o(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:Jo(n)).trim().replace(/\s+/g,` `);return r?r.length>46?`${r.slice(0,43)}...`:r:`New chat`}function es(e){return e===`New chat`||e===U(`newChat`)}function ts(e){return e.some(e=>e.role===`user`||e.role===`user-with-attachments`)}function ns(e){return ts(e)&&e.some(e=>e.role===`assistant`)}var rs=new Set([`idle`,`error`,`aborted`]);function is(e,t=Date.now()){e.lastAccessedAt=t}function as(e,t,n=5){let r=Array.from(e).filter(e=>e.sessionId!==t&&e.status!==`running`&&!e.agent.state.isStreaming&&rs.has(e.status));return r.length<=n?[]:(r.sort((e,t)=>(e.lastAccessedAt??0)-(t.lastAccessedAt??0)),r.slice(0,r.length-n).map(e=>e.sessionId))}function os(e,t){let n=e.get(t);return n?(n.unsubscribe(),n.agent.dispose(),e.delete(t),!0):!1}function ss(e){for(let t of[...e.keys()])os(e,t)}function cs({title:e,description:t,actions:n,onCancel:r}){let i=(0,H.useRef)(null),a=(0,H.useRef)(!1),o=(0,H.useCallback)(()=>{a.current||(a.current=!0,r())},[r]),s=(0,H.useCallback)(e=>{a.current||(a.current=!0,e.onClick())},[]);return(0,H.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,Vn.createPortal)((0,G.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,G.jsxs)(`div`,{className:W(`w-full max-w-[420px] rounded-2xl border border-border bg-background p-5 shadow-quickforge`),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,G.jsx)(`h2`,{id:`message-dialog-title`,className:`text-base font-semibold text-foreground/90`,children:e}):null,(0,G.jsx)(`p`,{id:`message-dialog-description`,className:W(`text-sm leading-6 text-muted-foreground/72`,e?`mt-2`:void 0),children:t}),(0,G.jsx)(`div`,{className:`mt-6 flex justify-end gap-2`,children:n.map((e,t)=>(0,G.jsx)(K,{ref:e.autoFocus?i:void 0,variant:e.variant,size:`sm`,onClick:()=>s(e),children:e.label},`${e.label}-${t}`))})]})}),document.body)}function ls(e){return new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,Ue.createRoot)(n);function i(){r.unmount(),setTimeout(()=>n.remove(),0)}function a(e){i(),t(e)}r.render(e(a))})}function us(e){return ls(t=>(0,G.jsx)(cs,{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 $(e){let t=typeof e==`string`?{description:e}:e;return ls(e=>(0,G.jsx)(cs,{title:t.title,description:t.description,onCancel:()=>e(),actions:[{label:t.confirmLabel??`OK`,autoFocus:!0,onClick:()=>e()}]}))}function ds(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(`
|
|
65
|
+
`):``).includes(`<compact_summary>`)}function fs(e){let t=e.findIndex(ds);return t<0?null:{summaryMessage:e[t],compactedUpToIndex:Math.min(e.length,t+2)}}function ps(e){let{storageRef:t,activeModelRef:n,agentAccessModeRef:r,activeProjectRef:i,defaultWorkspaceRef:a,setAgentAccessMode:o,switchActiveProject:s,sessions:c,refreshSessions:l,updateSessionTitle:u}=e,d=(0,H.useRef)(null),f=(0,H.useRef)(new Map),p=(0,H.useRef)(`global`),m=(0,H.useRef)(void 0),h=(0,H.useRef)(`New chat`),g=(0,H.useRef)(void 0),_=(0,H.useRef)(null),v=(0,H.useRef)(0),y=(0,H.useRef)(Promise.resolve()),b=(0,H.useRef)(e.onTaskComplete);(0,H.useEffect)(()=>{b.current=e.onTaskComplete});let[x,S]=(0,H.useState)(null),[C,w]=(0,H.useState)(),[T,E]=(0,H.useState)(`New chat`),[D,O]=(0,H.useState)(`global`),[k,ee]=(0,H.useState)(),[A,j]=(0,H.useState)({}),[te,M]=(0,H.useState)(0),[N,P]=(0,H.useState)(),F=(0,H.useCallback)(e=>{e.length!==0&&j(t=>{let n={...t},r=!1;for(let t of e)Object.prototype.hasOwnProperty.call(n,t)&&(delete n[t],r=!0);return r?n:t})},[]),I=(0,H.useCallback)(e=>{let t=as(f.current.values(),e);for(let e of t)os(f.current,e);F(t)},[F]),L=(0,H.useCallback)((e,t)=>{!e||e===t||[...f.current.values()].some(t=>t.agent===e)||e.dispose()},[f]),R=(0,H.useCallback)(async e=>{if(m.current===e.sessionId){let t=e.agent.state.messages,n=e.title;es(n)&&(n=$o(t)),g.current=e.createdAt??new Date().toISOString(),h.current=n,E(n)}await l({broadcast:!0})},[l]),ne=(0,H.useCallback)(e=>{L(d.current,e.agent),is(e),p.current=e.scope,m.current=e.sessionId,g.current=e.createdAt,h.current=e.title,O(e.scope),w(e.sessionId),E(e.title),ee(e.project),d.current=e.agent,S(e.agent);let t=new URL(window.location.href);t.searchParams.set(`session`,e.sessionId),window.history.replaceState({},``,t)},[L]),z=(0,H.useCallback)(async(e,s=q(),c)=>{let g=d.current,v=f.current.get(s);if(v)return c?.attachToView!==!1&&c?.shouldAttachToView?.()!==!1&&(L(g,v.agent),ne(v)),v.agent;let y=c?.scope??p.current,x=y===`project`?c?.project??i.current:c?.project??a.current;if(y===`project`&&!x?.id)throw Error(`Cannot create project chat without an active project.`);let S=new Date().toISOString(),{model:C,thinkingLevel:w,tools:T,...D}=e??{},O=t.current,k=O?await en(O):{},ee=C??k.model??n.current,A=O?await un(O,ee):Wt(ee),te=w??k.thinkingLevel??Zt(A);n.current=A;let M=J(c?.accessMode,c?.yoloMode??r.current);r.current=M,o(M);let N=await Ko.create(s,{scope:y,projectId:y===`project`?x?.id:void 0,accessMode:M,yoloMode:Y(M),model:A,thinkingLevel:te,messages:D.messages??[],title:c?.title,contextCompaction:D.contextCompaction});D.contextCompaction&&!N.state.contextCompaction&&(N.state.contextCompaction=D.contextCompaction);let P=N.state.isStreaming?`running`:N.state.errorMessage?`error`:`idle`,F={sessionId:N.sessionId,agent:N,scope:y,project:x,title:c?.title??`New chat`,createdAt:c?.createdAt??S,status:P,startedAt:S,lastAccessedAt:Date.now(),unsubscribe:()=>void 0};return F.unsubscribe=N.subscribe(e=>{if(e.type===`agent_start`&&(F.status=`running`,F.startedAt=F.startedAt??new Date().toISOString(),F.finishedAt=void 0,j(e=>({...e,[F.sessionId]:F.status}))),e.type===`message_end`&&(N.state.messages=[...N.state.messages]),e.type===`agent_end`){let t=F.status===`running`,n=e;F.status=n.status===`aborted`?`aborted`:n.errorMessage||N.state.errorMessage?`error`:`idle`,F.finishedAt=new Date().toISOString(),is(F),j(e=>({...e,[F.sessionId]:F.status})),R(F).catch(e=>V.error(`Failed to sync session UI:`,e)),t&&b.current?.(F.sessionId,F.title,F.status),I(m.current)}if(e.type===`title_updated`){let t=e;t.title&&(F.title=t.title),F.sessionId===m.current&&t.title&&(h.current=t.title,E(t.title)),t.title&&u(F.sessionId,t.title)}if(e.type===`session_forked`){let t=e;if(!t.targetSessionId)return;l({broadcast:!0}).catch(e=>V.error(`Failed to refresh sessions:`,e)),_.current?.(t.targetSessionId,{title:t.title,createdAt:t.createdAt,scope:t.scope,projectId:t.projectId??void 0})}}),f.current.set(s,F),F.status!==`idle`&&j(e=>({...e,[F.sessionId]:F.status})),c?.attachToView!==!1&&c?.shouldAttachToView?.()!==!1&&(g instanceof qo?g.promoteTo(F.agent):d.current===g&&L(g,F.agent),ne(F)),I(m.current),c?.refreshSessions!==!1&&N.state.messages.length>0&&await l({broadcast:!0}),N},[ne,L,I,l,R,u,t,n,r,i,a,o]),re=(0,H.useCallback)(async e=>{let i=t.current,o=i?await en(i):{},s=o.model??n.current,c=i?await un(i,s):Wt(s),l=o.thinkingLevel??Zt(c);n.current=c;let u=e.scope,f=u===`project`?e.project:e.project??a.current,_=new qo({scope:u,project:f,model:c,thinkingLevel:l,accessMode:r.current,yoloMode:Y(r.current),createAgent:z});_.subscribe(e=>{d.current===_&&(e.type===`message_start`||e.type===`agent_end`)&&M(e=>e+1)}),L(d.current),p.current=u,m.current=void 0,g.current=void 0,h.current=`New chat`,O(u),w(void 0),E(`New chat`),ee(f),d.current=_,S(_);let v=new URL(window.location.href);return v.searchParams.delete(`session`),window.history.replaceState({},``,v),_},[n,z,a,L,t,r]),B=(0,H.useCallback)(async(e,r)=>{let a=++v.current,o=()=>v.current===a;P(e);let l=y.current.catch(()=>void 0).then(async()=>{if(!o())return;let a=f.current.get(e);if(a){if(a.scope===`project`&&a.project?.id&&i.current?.id!==a.project.id)try{await s(a.project.id)}catch(e){V.error(`Failed to switch project for running session:`,e)}o()&&(ne(a),I(a.sessionId));return}let l=t.current;if(!l){await z({tools:[]},e,{scope:r?.scope??`global`,attachToView:!0,shouldAttachToView:o,createdAt:r?.createdAt,title:r?.title});return}let u=await l.sessions.get(e);if(!u||!o())return;let d=c.find(t=>t.id===e)??await l.sessions.getMetadata(e);if(!o())return;let p=r?.scope??jt(d??u),m=r?.projectId??d?.projectId??u.projectId,h;if(p===`project`&&m){let e=m;if(i.current?.id!==e)try{h=await s(e)}catch(e){V.error(`Failed to switch project for session:`,e),o()&&$(U(`projectSwitchFailed`));return}else h=i.current}o()&&(n.current=u.model,await z({model:u.model,thinkingLevel:u.thinkingLevel,messages:u.messages,contextCompaction:u.contextCompaction??fs(u.messages)},u.id,{scope:p,project:h,attachToView:!0,shouldAttachToView:o,createdAt:u.createdAt??r?.createdAt,title:u.title??r?.title,accessMode:J(u.accessMode,u.yoloMode),refreshSessions:!1}))});y.current=l;try{await l}finally{o()&&P(void 0)}},[ne,z,I,c,s,t,n,i]);return(0,H.useEffect)(()=>{_.current=B},[B]),{agentRef:d,taskMapRef:f,currentSessionIdRef:m,currentChatScopeRef:p,agent:x,currentSessionId:C,currentTitle:T,chatScope:D,currentToolProject:k,taskStatuses:A,chatPanelRevision:te,loadingSessionId:N,createAgent:z,startDeferredSession:re,loadSession:B,syncSessionUI:R,setChatPanelRevision:M,setCurrentAgentMessages:(0,H.useCallback)(e=>{d.current&&(d.current.state.messages=e)},[]),updateCurrentAgentModel:(0,H.useCallback)(e=>{d.current&&(d.current.state.model=e,d.current.updateModel(e).catch(e=>{V.error(`Failed to sync model to server:`,e)}))},[]),setCurrentTitleRef:(0,H.useCallback)(e=>{h.current=e,E(e)},[])}}function ms(e){if(!e)return 0;let t=new Date(e).getTime();return Number.isNaN(t)?0:t}function hs(e,t){let n=t===`createdAt`?`createdAt`:`lastModified`;return[...e].sort((e,t)=>{let r=ms(t.pinnedAt)-ms(e.pinnedAt);return r===0?e.pinnedAt&&!t.pinnedAt?-1:!e.pinnedAt&&t.pinnedAt?1:ms(t[n])-ms(e[n]):r})}function gs(e){let t=new Set;return e.filter(e=>t.has(e.id)?!1:(t.add(e.id),!0))}function _s(e,t,n){let r=e.items.some(e=>e.id===t.id);return{...e,items:hs(gs([t,...e.items.filter(e=>e.id!==t.id)]),n),total:r?e.total:e.total+1}}function vs(e,t,n){return e.items.some(e=>e.id===t)?{...e,items:e.items.map(e=>e.id===t?{...e,title:n}:e)}:e}var ys=20;function bs(e){if(!e)return!1;let t=e.trim();return!t||t===`undefined`||t===`null`||t===`false`?!1:!Number.isNaN(Date.parse(t))}function xs({backendRef:e,expandedProjectIds:t,externalProjectIds:n,viewMode:r,sortMode:i,onBroadcastSessionsChanged:a}){let[o,s]=(0,H.useState)({items:[],total:0,loading:!1}),[c,l]=(0,H.useState)({items:[],total:0,loading:!1}),[u,d]=(0,H.useState)({}),[f,p]=(0,H.useState)({items:[],total:0,loading:!1}),m=(0,H.useRef)(u),h=(0,H.useRef)(t),g=(0,H.useRef)(n??new Set),_=(0,H.useRef)(0);(0,H.useEffect)(()=>{m.current=u},[u]),(0,H.useEffect)(()=>{h.current=t},[t]),(0,H.useEffect)(()=>{g.current=n??new Set},[n]);let v=(0,H.useCallback)(()=>(_.current+=1,_.current),[]),y=(0,H.useCallback)(e=>e===_.current,[]),b=(0,H.useMemo)(()=>gs([...c.items,...o.items,...Object.values(u).flatMap(e=>e.items),...f.items]),[c.items,o.items,u,f.items]),x=(0,H.useCallback)(async(t,n=_.current)=>{let r=e.current;if(r){l(e=>({...e,loading:!0}));try{let e=await r.fetchPaginatedFromIndex(`sessions-metadata`,`pinnedAt`,{direction:`desc`,limit:ys,offset:t,pinned:`only`});if(!y(n))return;let a=e.values.filter(e=>bs(e.pinnedAt));l(n=>({items:hs(t===0?a:gs([...n.items,...a]),i),total:e.total,loading:!1}))}catch{if(!y(n))return;l(e=>({...e,loading:!1}))}}},[e,y,i]),S=(0,H.useCallback)(async(t,n=_.current)=>{let r=e.current;if(r){s(e=>({...e,loading:!0}));try{let e=i===`createdAt`?`createdAt`:`lastModified`,a=await r.fetchPaginatedFromIndex(`sessions-metadata`,e,{direction:`desc`,limit:ys,offset:t,scope:`global`});if(!y(n))return;s(e=>({items:hs(t===0?a.values:gs([...e.items,...a.values]),i),total:a.total,loading:!1}))}catch{if(!y(n))return;s(e=>({...e,loading:!1}))}}},[e,y,i]),C=(0,H.useCallback)(async(t,n,r=_.current)=>{let a=e.current;if(a){d(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!0}}});try{let e=i===`createdAt`?`createdAt`:`lastModified`,o=await a.fetchPaginatedFromIndex(`sessions-metadata`,e,{direction:`desc`,limit:ys,offset:n,scope:`project`,projectId:t});if(!y(r))return;d(e=>{let r=e[t]?.items??[];return{...e,[t]:{items:hs(n===0?o.values:gs([...r,...o.values]),i),total:o.total,loading:!1}}})}catch{if(!y(r))return;d(e=>{let n=e[t];return{...e,[t]:{...n??{items:[],total:0},loading:!1}}})}}},[e,y,i]),w=(0,H.useCallback)(async(t,n=_.current)=>{let r=e.current;if(r){p(e=>({...e,loading:!0}));try{let e=i===`createdAt`?`createdAt`:`lastModified`,a=await r.fetchPaginatedFromIndex(`sessions-metadata`,e,{direction:`desc`,limit:ys,offset:t,scope:`projects`});if(!y(n))return;p(e=>({items:hs(t===0?a.values:gs([...e.items,...a.values]),i),total:a.total,loading:!1}))}catch{if(!y(n))return;p(e=>({...e,loading:!1}))}}},[e,y,i]),T=(0,H.useCallback)(async e=>{let t=v();if(await x(0,t),!y(t)||(await S(0,t),!y(t)))return;if(r===`timeline`){d(e=>{let t={};for(let[n,r]of Object.entries(e))t[n]={...r,loading:!1};return t}),await w(0,t),e?.broadcast&&y(t)&&a?.();return}p(e=>({...e,loading:!1}));let n=new Set([...Object.keys(m.current),...h.current,...g.current]);n.size===0?d({}):(d(e=>{let t={};for(let r of n)t[r]={...e[r]??{items:[],total:0},loading:!0};return t}),await Promise.all([...n].map(e=>C(e,0,t)))),e?.broadcast&&y(t)&&a?.()},[y,S,x,C,w,v,a,r]),E=(0,H.useCallback)(e=>{if(bs(e.pinnedAt)&&l(t=>_s(t,e,i)),e.scope===`project`&&e.projectId){d(t=>{let n=t[e.projectId];return n?{...t,[e.projectId]:_s(n,e,i)}:t}),r===`timeline`&&p(t=>_s(t,e,i));return}s(t=>_s(t,e,i))},[i,r]),D=(0,H.useCallback)((e,t)=>{l(n=>vs(n,e,t)),s(n=>vs(n,e,t)),p(n=>vs(n,e,t)),d(n=>{let r=!1,i=Object.fromEntries(Object.entries(n).map(([n,i])=>{let a=vs(i,e,t);return a!==i&&(r=!0),[n,a]}));return r?i:n})},[]),O=(0,H.useCallback)(e=>u[e]?.items??[],[u]),k=(0,H.useCallback)(e=>{let t=u[e];return t?t.items.length<t.total:!0},[u]),ee=(0,H.useCallback)(e=>u[e]?.loading??!1,[u]),A=(0,H.useCallback)(e=>e in u,[u]),j=(0,H.useCallback)(()=>{c.loading||c.items.length>=c.total||x(c.items.length)},[x,c.items.length,c.loading,c.total]),te=(0,H.useCallback)(()=>{S(o.items.length)},[o.items.length,S]),M=(0,H.useCallback)(e=>{let t=u[e];C(e,t?.items.length??0)},[C,u]),N=(0,H.useCallback)(()=>{f.loading||f.items.length>=f.total||w(f.items.length)},[w,f.items.length,f.loading,f.total]);return(0,H.useEffect)(()=>{Promise.resolve().then(()=>T())},[T]),{allLoadedSessions:b,pinnedSessions:c.items,pinnedHasMore:c.items.length<c.total,pinnedLoading:c.loading,globalSessions:o.items,sessionsForProject:O,projectTimelineSessions:f.items,projectTimelineHasMore:f.items.length<f.total,projectTimelineLoading:f.loading,globalHasMore:o.items.length<o.total,projectHasMore:k,globalLoading:o.loading,projectLoading:ee,projectLoaded:A,loadGlobalSessions:S,loadProjectSessions:C,refreshSessions:T,upsertSessionMetadata:E,updateSessionTitle:D,loadMorePinned:j,loadMoreGlobal:te,loadMoreProject:M,loadMoreProjectTimeline:N}}function Ss(){let[e,t]=(0,H.useState)([]),n=(0,H.useCallback)(e=>{t(t=>[...t,{...e,id:q(),createdAt:Date.now()}])},[]);return{toasts:e,handleTaskComplete:(0,H.useCallback)((e,t,r)=>{n({sessionId:e,title:t,status:r})},[n]),addToast:n,dismissToast:(0,H.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[])}}var Cs=`tool-display-settings`,ws={toolDisplayMode:`compact`,showContextUsage:!1},Ts={...ws};function Es(e){if(!e||typeof e!=`object`)return{...ws};let t=e;return{toolDisplayMode:t.toolDisplayMode===`detailed`?`detailed`:`compact`,showContextUsage:t.showContextUsage===!0}}function Ds(){return Ts}async function Os(e){let t=Es(await e.settings.get(Cs));return Ts=t,t}async function ks(e,t){let n=Es(t);await e.settings.set(Cs,n),Ts=n}var As=`font-size-settings`,js=`font-size-settings-force-13px-v1`,Ms={min:12,max:18},Ns={interfaceFontSizePx:13,messageFontSizePx:13},Ps=`quickforge:font-size-settings-changed`;function Fs(){if(typeof document>`u`)return Ns.interfaceFontSizePx;let e=Number.parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)?e:Ns.interfaceFontSizePx}function Is(e=Fs()){let t=Rs(e-1,13,Ms.min,Ms.max);return{fontSize:t,lineHeight:Math.round(t*1.54)}}function Ls(e=Fs()){return{fontSize:Rs(e-2,12,Ms.min,Ms.max),lineHeight:1.2}}function Rs(e,t,n,r){let i=Number(e);return Number.isFinite(i)?Math.min(r,Math.max(n,Math.round(i))):t}function zs(e){if(!e||typeof e!=`object`)return{...Ns};let t=e;return{interfaceFontSizePx:Rs(t.interfaceFontSizePx??t.baseFontSizePx??t.bodyFontSizePx,Ns.interfaceFontSizePx,Ms.min,Ms.max),messageFontSizePx:Rs(t.messageFontSizePx,Ns.messageFontSizePx,Ms.min,Ms.max)}}function Bs(e){if(typeof document>`u`)return;let t=zs(e),n=document.documentElement;n.style.fontSize=`${t.interfaceFontSizePx}px`,n.style.setProperty(`--quickforge-message-font-size`,`${t.messageFontSizePx}px`),n.style.setProperty(`--quickforge-message-line-height`,`1.625`),window.dispatchEvent(new CustomEvent(Ps,{detail:t}))}async function Vs(e){if(!await e.settings.get(js)){let t={...Ns};return await e.settings.set(As,t),await e.settings.set(js,!0),t}return zs(await e.settings.get(As))}async function Hs(e){let t=await Vs(e);return Bs(t),t}async function Us(e,t){let n=zs(t);await e.settings.set(As,n),Bs(n)}var Ws=`appearance-settings`,Gs={theme:`light`};function Ks(e){return!e||typeof e!=`object`?{...Gs}:{theme:e.theme===`dark`?`dark`:`light`}}function qs(e){if(typeof document>`u`)return;let t=Ks(e),n=document.documentElement;n.classList.toggle(`dark`,t.theme===`dark`),n.style.setProperty(`color-scheme`,t.theme)}function Js(){return typeof document>`u`?Gs.theme:document.documentElement.classList.contains(`dark`)?`dark`:`light`}async function Ys(e){return Ks(await e.settings.get(Ws))}async function Xs(e){let t=await Ys(e);return qs(t),t}async function Zs(e,t){let n=Ks(t);await e.settings.set(Ws,n),qs(n)}function Qs({storageRef:e,backendRef:t,activeModelRef:n,agentAccessModeRef:r,activeProjectRef:i,setAgentAccessMode:a,taskMapRef:o,loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}){let[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(),[v,y]=(0,H.useState)(0),b=(0,H.useRef)({loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p});return(0,H.useEffect)(()=>{b.current={loadGlobalSessions:s,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}}),(0,H.useEffect)(()=>{let s=!1;async function c(){let{loadGlobalSessions:o,loadProject:c,initAgentAccessMode:l,switchActiveProject:u,createAgent:d,setNeedsModelSetup:f,onStorageReady:p}=b.current;try{h(!1),_(void 0);let m=await Yt();if(s)return;e.current=m,p?.(m),t.current=m.backend,await rt(m),await Os(m),await Xs(m),await Hs(m),await Promise.all([o(0),c()]),r.current=await l(m);let g=await cn(m),v=await en(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=jt(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){V.error(`Failed to switch project for initial session:`,e),$(U(`projectSwitchFailed`)),g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},q(),{scope:`global`,attachToView:!0}):f(!0),h(!0);return}else s=i.current}n.current=e.model;let c=J(e.accessMode,e.yoloMode);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,accessMode:c})}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},q(),{scope:`global`,attachToView:!0}):f(!0)}else g?await d({model:v.model??g,thinkingLevel:v.thinkingLevel,tools:[]},q(),{scope:`global`,attachToView:!0}):f(!0);h(!0)}catch(e){V.error(`Failed to bootstrap QuickForge:`,e),s||_(U(`localServiceUnavailableDescription`))}}c();let l=o.current;return()=>{s=!0,ss(l)}},[e,t,n,r,i,a,o,v]),{ready:m,startupError:g,retryBootstrap:(0,H.useCallback)(()=>{h(!1),_(void 0),y(e=>e+1)},[])}}var $s=`update-check-settings`,ec={frequency:`startup`,lastCheckAt:null,ignoredVersion:null};function tc(e){if(!e||typeof e!=`object`)return{...ec};let t=e;return{frequency:[`startup`,`daily`,`weekly`,`off`].includes(t.frequency)?t.frequency:ec.frequency,lastCheckAt:typeof t.lastCheckAt==`string`?t.lastCheckAt:null,ignoredVersion:typeof t.ignoredVersion==`string`?t.ignoredVersion:null}}var nc=1440*60*1e3;function rc(e,t=Date.now()){switch(e.frequency){case`off`:return!1;case`startup`:return!0;case`daily`:case`weekly`:{if(!e.lastCheckAt)return!0;let n=Date.parse(e.lastCheckAt);if(Number.isNaN(n))return!0;let r=e.frequency===`daily`?nc:7*nc;return t-n>=r}default:return!1}}async function ic(e){return tc(await e.settings.get($s))}async function ac(e,t){await e.settings.set($s,tc(t))}var oc={status:`idle`,updateAvailable:!1};function sc(){if(typeof document>`u`)return!1;let e=window;return document.body.classList.contains(`quickforge-desktop-app`)||e.__quickforgeDesktopApp===!0}function cc(e,t){let[n,r]=(0,H.useState)(oc),i=(0,H.useRef)(!1);return(0,H.useEffect)(()=>{if(!t||i.current||sc())return;let n=e.current;n&&(i.current=!0,(async()=>{let e;try{e=await ic(n)}catch(e){V.error(`Failed to load update-check settings:`,e);return}if(rc(e)){r(e=>({...e,status:`checking`}));try{let t=await fetch(`/api/system/update/check`,{cache:`no-store`});if(!t.ok){r(e=>({...e,status:`error`}));return}let i=await t.json(),a=i.updateAvailable&&i.latestVersion!==e.ignoredVersion;try{await ac(n,{...e,lastCheckAt:new Date().toISOString()})}catch(e){V.error(`Failed to persist last update-check time:`,e)}r({status:`done`,currentVersion:i.currentVersion,latestVersion:i.latestVersion,updateAvailable:a})}catch(e){V.error(`Startup update check failed:`,e),r(e=>({...e,status:`error`}))}}})())},[t,e]),{result:n,dismissUpdate:(0,H.useCallback)(()=>{let t=e.current,i=n.latestVersion;!t||!i||(r(e=>({...e,updateAvailable:!1})),(async()=>{try{await ac(t,{...await ic(t),ignoredVersion:i})}catch(e){V.error(`Failed to persist ignored update version:`,e)}})())},[n.latestVersion,e])}}var lc=[`low`,`medium`,`high`,`xhigh`];function uc(e){switch(e){case`low`:return U(`thinkingLow`);case`medium`:return U(`thinkingMedium`);case`high`:return U(`thinkingHigh`);case`xhigh`:return U(`thinkingXHigh`);default:return U(`thinkingOff`)}}function dc(e){return e.id}function fc(e,t=``){let n=document.createElement(`button`);return n.type=`button`,n.className=e,n.textContent=t,n}function pc(e){document.querySelectorAll(`.quickforge-model-menu, .quickforge-model-submenu`).forEach(e=>{e.__quickforgeCleanup?.(),e.remove()}),e?.setAttribute(`aria-expanded`,`false`)}function mc(e){return e??document.querySelector(`.quickforge-model-trigger`)}function hc(e,t){let n=mc(t),r=Math.min(260,window.innerWidth-24);e.style.width=`${r}px`;let i=e.offsetHeight||360;if(!n){e.style.left=`${Math.max(12,Math.round((window.innerWidth-r)/2))}px`,e.style.top=`${Math.max(12,Math.round((window.innerHeight-i)/2))}px`;return}let a=n.getBoundingClientRect(),o=Math.max(12,Math.min(a.right-r,window.innerWidth-r-12)),s=a.top-i-8,c=a.bottom+8,l=s>=12?s:Math.min(c,window.innerHeight-i-12);e.style.left=`${o}px`,e.style.top=`${Math.max(12,l)}px`}function gc(e,t){let n=Math.min(252,window.innerWidth-24);e.style.width=`${n}px`;let r=t.getBoundingClientRect(),i=e.offsetHeight||320,a=r.left-n-0>=12?r.left-n-0:Math.min(r.right+0,window.innerWidth-n-12),o=Math.max(12,Math.min(r.top,window.innerHeight-i-12));e.style.left=`${a}px`,e.style.top=`${o}px`}function _c(e){let t=fc(`quickforge-model-menu-item`);t.setAttribute(`role`,`menuitemradio`),t.setAttribute(`aria-checked`,String(!!e.selected)),e.disabled&&(t.disabled=!0);let n=document.createElement(`span`);n.className=`quickforge-model-menu-item-label`,n.textContent=e.label;let r=document.createElement(`span`);return r.className=`quickforge-model-menu-item-suffix`,r.textContent=e.chevron?`›`:e.selected?`✓`:``,t.append(n,r),e.onPointerDown&&(t.onpointerdown=e.onPointerDown),e.onPointerEnter&&(t.onpointerenter=e.onPointerEnter),t}function vc(e,t,n,r,i={}){let a=mc(i.anchor);if(document.querySelector(`.quickforge-model-menu`)){pc(a);return}let o=i.thinkingLevel??`off`,s=e,c=null,l=document.createElement(`div`);l.className=`quickforge-model-menu`,l.setAttribute(`role`,`menu`),l.setAttribute(`aria-label`,U(`selectCustomModel`));let u=()=>{c?.remove(),c=document.createElement(`div`),c.className=`quickforge-model-submenu`,c.setAttribute(`role`,`menu`),c.setAttribute(`aria-label`,U(`model`));let e=document.createElement(`div`);e.className=`quickforge-model-menu-header`,e.textContent=U(`model`),c.append(e);let r=[...t].sort((e,t)=>dc(e).localeCompare(dc(t)));for(let e of r)c.append(_c({label:dc(e),selected:Ve(s,e),onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),!e.reasoning&&o!==`off`&&(o=`off`,i.onThinkingLevelSelect?.(`off`)),s=e,n(e),pc(a)}}));c.addEventListener(`pointerdown`,e=>e.stopPropagation()),document.body.append(c),gc(c,l)},d=()=>{l.replaceChildren();let e=document.createElement(`div`);if(e.className=`quickforge-model-menu-header`,e.textContent=U(`reasoning`),l.append(e),s?.reasoning===!0)for(let e of lc)l.append(_c({label:uc(e),selected:o===e,onPointerDown:t=>{t.preventDefault(),t.stopPropagation(),o=e,i.onThinkingLevelSelect?.(e),d(),hc(l,a)}}));else{let e=document.createElement(`div`);e.className=`quickforge-model-menu-note`,e.textContent=U(`thinkingNotSupported`),l.append(e)}let t=document.createElement(`div`);t.className=`quickforge-model-menu-separator`,l.append(t),l.append(_c({label:s?dc(s):U(`noModelAdded`),chevron:!0,onPointerEnter:u,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),u()}}))},f=()=>pc(a),p=e=>{if(e.type===`resize`||e.type===`scroll`){hc(l,a),c&&gc(c,l);return}if(e instanceof KeyboardEvent){if(e.key!==`Escape`)return;e.preventDefault()}else{let t=e.target;if(l.contains(t)||c?.contains(t)||a?.contains(t))return}f()};l.__quickforgeCleanup=()=>{document.removeEventListener(`pointerdown`,p,!0),document.removeEventListener(`keydown`,p,!0),window.removeEventListener(`resize`,p,!0),window.removeEventListener(`scroll`,p,!0)},l.addEventListener(`pointerdown`,e=>e.stopPropagation()),d(),document.body.append(l),hc(l,a),a?.setAttribute(`aria-expanded`,`true`),document.addEventListener(`pointerdown`,p,!0),document.addEventListener(`keydown`,p,!0),window.addEventListener(`resize`,p,!0),window.addEventListener(`scroll`,p,!0)}function yc({storageRef:e,activeModelRef:t,agentRef:n,createAgent:r,updateCurrentAgentModel:i,setChatPanelRevision:a,setNeedsModelSetup:o,setRestoredDraft:s,notifySettingsChanged:c,openSettingsPage:l}){let u=(0,H.useCallback)(async()=>{let s=e.current;if(!s)return!1;let l=await cn(s);return l?(t.current=l,o(!1),await Xt(s,l),n.current?(i(l),a(e=>e+1)):await r({model:l,tools:[]},q(),{scope:`global`,attachToView:!0}),c(),!0):(o(!0),!1)},[e,t,n,r,i,a,o,c]),d=(0,H.useCallback)((e,t)=>{l(e,t)},[l]),f=(0,H.useCallback)(()=>{d(`customModels`)},[d]);return{activateConfiguredModel:u,openModelSettings:f,openDefaultOptionsSettings:(0,H.useCallback)(()=>{d(`defaults`)},[d]),openAboutSettings:(0,H.useCallback)(()=>{d(`about`)},[d]),activateLiteLlmExampleModel:(0,H.useCallback)(async()=>{let s=e.current;if(!s)return;let l=Gt(Rt);await pn(s,Rt,l),await Xt(s,l),t.current=l,o(!1),n.current?(i(l),a(e=>e+1)):await r({model:l,tools:[]},q(),{scope:`global`,attachToView:!0}),c()},[e,t,n,r,i,a,o,c]),openCustomModelSelector:(0,H.useCallback)(async r=>{let o=e.current,c=n.current;if(!o||!c)return;let l=r instanceof HTMLElement?r:r?.currentTarget instanceof HTMLElement?r.currentTarget:document.querySelector(`.quickforge-model-trigger`),u=document.querySelector(`agent-interface message-editor textarea`),p=document.querySelector(`agent-interface message-editor`),m=u?.value??``,h=p?.attachments?[...p.attachments]:[],g=on(await o.customProviders.getAll());if(g.length===0){await us({description:U(`addCustomModelFirst`),confirmLabel:U(`modelSetupAddModel`),cancelLabel:U(`cancel`)})&&f();return}vc(c.state.model??t.current,g,e=>{let n=e,r=n.reasoning?c.state.thinkingLevel:`off`;c.state.thinkingLevel!==r&&(c.state.thinkingLevel=r,c.updateThinkingLevel(r).catch(e=>{V.error(`Failed to sync thinking level to server:`,e)})),t.current=n,i(n),(m||h.length>0)&&s({id:Date.now(),sessionId:c.sessionId,text:m,attachments:h}),a(e=>e+1),Xt(o,n).catch(e=>{V.error(`Failed to save active model:`,e)})},async e=>{d(`customModels`,e.provider)},{thinkingLevel:c.state.thinkingLevel,anchor:l,onThinkingLevelSelect:e=>{c.state.thinkingLevel=e,c.updateThinkingLevel(e).catch(e=>{V.error(`Failed to sync thinking level to server:`,e)}),a(e=>e+1)}})},[e,t,n,i,a,s,f,d])}}function bc(){let e=new URL(window.location.href);e.searchParams.delete(`session`),window.history.replaceState({},``,e)}function xc(e){return!!(e&&!e.state.isStreaming&&e.state.messages.length===0)}function Sc({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,H.useCallback)(async()=>{if(p){$(U(`modelSetupRequired`));return}h(),!(xc(o.current)&&r.current===`global`)&&(g(void 0),bc(),await s({scope:`global`}))},[o,r,p,g,h,s]),v=(0,H.useCallback)(async e=>{if(p){$(U(`modelSetupRequired`));return}h();let t=e??n.current;t&&(xc(o.current)&&r.current===`project`&&n.current?.id===t.id||(n.current?.id!==t.id&&await m(t.id),g(void 0),bc(),await s({scope:`project`,project:t})))},[n,o,r,p,g,h,s,m]),y=(0,H.useCallback)(async s=>{let p=o.current;if(!p)return;if(p.state.isStreaming){$(U(`generationStillRunning`));return}let m=Xo(p.state.messages,s),h=m>=0?p.state.messages[m]:void 0;if(m<0||!h){$(U(`noConversationTurnToRollback`));return}let _={id:Date.now(),sessionId:p.sessionId,text:Zo(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){V.error(`Failed to rollback conversation:`,e),$(e instanceof Error?e.message:U(`rollbackFailed`));return}u(v);let y=i.current?a.current.get(i.current):void 0;if(ns(v)&&y){_&&g(_),d(e=>e+1),l(y).catch(e=>V.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&&os(a.current,x),b&&x)try{await b.sessions.delete(x),await f({broadcast:!0})}catch(e){V.error(`Failed to delete rolled back empty session:`,e)}let E=q();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,H.useCallback)(async e=>{try{await Qo(e)}catch(e){throw V.error(`Failed to copy answer:`,e),$(U(`copyFailed`)),e}},[]),x=(0,H.useCallback)(async i=>{let a=o.current;if(!a)return;if(a.state.isStreaming){$(U(`generationStillRunning`));return}let s=a.state.messages.slice(0,i+1);if(!ts(s))return;let l=r.current,u=l===`project`?n.current:void 0,d=q(),p=$o(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=>V.error(`Failed to refresh sessions:`,e))},[t,n,o,c,r,f,e]);return{startNewGlobalChat:_,startNewProjectChat:v,rollbackFromMessage:y,retryFromMessage:(0,H.useCallback)(async e=>{let t=o.current;if(!t)return;if(t.state.isStreaming){$(U(`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){V.error(`Failed to retry:`,e),$(e instanceof Error?e.message:U(`retryFailed`));return}let s=i.current?a.current.get(i.current):void 0;s&&(l(s).catch(e=>V.error(`Failed to sync session UI after retry:`,e)),d(e=>e+1))},[o,i,d,u,l,a]),copyAnswer:b,forkFromMessage:x}}function Cc({activeProjectRef:e,refreshSessions:t,notifyProjectsChanged:n,setActiveProject:r,setProjects:i,setExpandedProjectIds:a,setChatPanelRevision:o}){return{deleteProjectInline:(0,H.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 wc=H.forwardRef(({className:e,type:t,...n},r)=>(0,G.jsx)(`input`,{type:t,className:W(`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:border-primary focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));wc.displayName=`Input`;function Tc({options:e,onResolve:t}){let n=(0,H.useRef)(null),[r,i]=(0,H.useState)(e.defaultValue??``),a=(0,H.useRef)(r);return(0,H.useEffect)(()=>{a.current=r},[r]),(0,H.useEffect)(()=>{n.current?.focus(),n.current?.select()},[]),(0,H.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,Vn.createPortal)((0,G.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,G.jsxs)(`div`,{className:W(`w-full max-w-sm rounded-lg border border-border bg-background p-6 shadow-quickforge`,`mx-4`),children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:e.title}),e.description?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e.description}):null,(0,G.jsx)(`div`,{className:`mt-4`,children:(0,G.jsx)(wc,{ref:n,value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder,className:`w-full`})}),(0,G.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,G.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>t(null),children:e.cancelLabel??`Cancel`}),(0,G.jsx)(K,{size:`sm`,onClick:()=>r.trim()?t(r.trim()):void 0,disabled:!r.trim(),children:e.confirmLabel??`Save`})]})]})}),document.body)}function Ec(e){return new Promise(t=>{let n=document.createElement(`div`);document.body.appendChild(n);let r=(0,Ue.createRoot)(n);function i(){r.unmount(),setTimeout(()=>n.remove(),0)}function a(e){i(),t(e)}r.render((0,G.jsx)(Tc,{options:e,onResolve:a}))})}function Dc({storageRef:e,taskMapRef:t,currentSessionIdRef:n,loadAgentSession:r,setCurrentTitleRef:i,refreshSessions:a,updateSessionTitle:o,closeWorkspacePage:s,startNewGlobalChat:c}){return{loadSession:(0,H.useCallback)(e=>{s(),r(e)},[r,s]),renameSession:(0,H.useCallback)(async(t,r)=>{if(!e.current)return;let a=await Ec({title:U(`renameSession`),description:U(`sessionName`),defaultValue:r,confirmLabel:U(`save`),cancelLabel:U(`cancel`)});if(!a||a===r)return;let s=await fetch(`/api/agents/${encodeURIComponent(t)}/title`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:a})});if(!s.ok)throw Error(`Failed to rename session: HTTP ${s.status}`);o(t,a),n.current===t&&i(a)},[n,i,e,o]),togglePinSession:(0,H.useCallback)(async t=>{let n=e.current;if(!n)return;let r=await n.sessions.getMetadata(t);if(!r)return;let i=r.pinnedAt?void 0:new Date().toISOString(),o={...r,pinnedAt:i};await n.backend.set(`sessions-metadata`,t,o),await a({broadcast:!0})},[a,e]),archiveSession:(0,H.useCallback)(async r=>{let i=e.current;if(!i)return;os(t.current,r);let o=await i.sessions.get(r);if(!o)return;let l=await i.sessions.getMetadata(r);if(!l)return;let u=new Date().toISOString(),d={...o,archivedAt:u},f={...l,archivedAt:u};await i.sessions.save(d,f),await a({broadcast:!0}),n.current===r&&(s(),await c())},[n,a,s,c,e,t]),startNewGlobalSession:(0,H.useCallback)(()=>{s(),c()},[s,c])}}var Oc=e=>e===`full-access`;function kc({storageRef:e,agentAccessModeRef:t,setAgentAccessMode:n,agentRef:r,setChatPanelRevision:i,notifySettingsChanged:a}){let o=(0,H.useCallback)(o=>{let s=e.current,c=r.current,l=t.current;if(l===o)return;n(o),t.current=o;let u=()=>{t.current=l,n(l),i(e=>e+1)};(async()=>{try{c&&await c.updateAccessMode(o),s&&await dn(s,o),i(e=>e+1),a()}catch(e){V.error(`Failed to sync agent access mode:`,e),u(),$(e instanceof Error?e.message:U(`agentAccessModeSyncFailed`))}})()},[t,r,a,n,i,e]);return{setAccessMode:o,toggleYoloMode:(0,H.useCallback)(()=>{o(Oc(t.current)?`default`:`full-access`)},[t,o])}}function Ac(){let[e,t]=(0,H.useState)(!0),[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(!1),[O,k]=(0,H.useState)(`defaults`),[ee,A]=(0,H.useState)();return{sidebarOpen:e,setSidebarOpen:t,mobileSidebarOpen:n,setMobileSidebarOpen:r,projectsCollapsed:i,setProjectsCollapsed:a,pinnedCollapsed:o,setPinnedCollapsed:s,conversationsCollapsed:c,setConversationsCollapsed:l,skillsDialog:u,setSkillsDialog:d,shareDialogOpen:f,setShareDialogOpen:p,conversationMenuOpen:m,setConversationMenuOpen:h,workspaceInspectorOpen:g,setWorkspaceInspectorOpen:_,workspaceInspectorRequest:v,setWorkspaceInspectorRequest:y,artifactPreviewOpen:b,setArtifactPreviewOpen:x,activeArtifactPath:S,setActiveArtifactPath:C,firstUseGuideDismissed:w,setFirstUseGuideDismissed:T,settingsDialogOpen:E,setSettingsDialogOpen:D,settingsInitialTab:O,setSettingsInitialTab:k,settingsCustomProvider:ee,setSettingsCustomProvider:A,toggleProjectsCollapsed:(0,H.useCallback)(()=>a(e=>!e),[]),togglePinnedCollapsed:(0,H.useCallback)(()=>s(e=>!e),[]),toggleConversationsCollapsed:(0,H.useCallback)(()=>l(e=>!e),[])}}function jc(e){return e===`running`||e===`idle`||e===`error`||e===`aborted`?e:void 0}function Mc(e){let[t,n]=(0,H.useState)({}),r=(0,H.useMemo)(()=>new Set(e.map(e=>e.id)),[e]),i=(0,H.useMemo)(()=>e.map(e=>e.id).sort().join(`
|
|
66
|
+
`),[e]),a=(0,H.useCallback)(async()=>{if(r.size===0){n({});return}try{let e=await Wo(),t=new Map(e.map(e=>[e.sessionId,jc(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){V.error(`Failed to refresh visible agent statuses:`,e)}},[r]);return(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{a()},0);return()=>window.clearTimeout(e)},[a,i]),(0,H.useEffect)(()=>Go(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=jc(e.status)===`aborted`?`aborted`:e.errorMessage?`error`:`idle`;n(e=>({...e,[t]:r}))}}}),[r]),(0,H.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&a()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[a]),t}function Nc({ready:e,currentToolProjectId:t,projects:n,activeProject:r,recoveringProjectId:i}){return!e||!t||t===`default`||n.some(e=>e.id===t)||i===t?{type:`none`}:r?{type:`project`,deletedProjectId:t,project:r}:{type:`global`,deletedProjectId:t}}function Pc(e,t,n){return e.projectId===t&&e.requestId===n}var Fc=new Set([`write_file`,`edit_file`,`run_command`,`run_subagent`]);function Ic(e,t,n){return e.type!==`tool_execution_end`||!t||e.sessionId!==t||!n?!1:typeof e.toolName==`string`&&Fc.has(e.toolName)}function Lc(e){return e===`idle`?{tone:`success`,message:U(`taskCompleted`)}:e===`error`?{tone:`error`,message:U(`taskError`)}:e===`aborted`?{tone:`aborted`,message:U(`processAborted`)}:e===`running`?{tone:`running`,message:U(`taskRunning`)}:{tone:`neutral`,message:U(`taskRunning`)}}function Rc({toast:e,onDismiss:t,onClick:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null);(0,H.useEffect)(()=>{let n=window.setTimeout(()=>i(!0),10);return s.current=window.setTimeout(()=>{o(!0),s.current=window.setTimeout(()=>t(e.id),200)},5e3),()=>{window.clearTimeout(n),s.current!==null&&window.clearTimeout(s.current)}},[e.id,t]);let c=()=>{o(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>t(e.id),200)},l=Lc(e.status),u=l.tone===`error`,d=l.tone===`success`,f=W(`size-5`,u&&`text-destructive`,d&&`text-emerald-500`,l.tone===`aborted`&&`text-amber-600`,l.tone===`running`&&`text-blue-600`,l.tone===`neutral`&&`text-muted-foreground`);return(0,G.jsxs)(`div`,{role:`alert`,onClick:()=>n(e.sessionId),className:W(`pointer-events-auto flex w-80 cursor-pointer items-start gap-3 rounded-xl border border-border bg-background p-3 shadow-quickforge transition-all duration-200 ease-out`,r&&!a?`translate-x-0 opacity-100`:`translate-x-4 opacity-0`),children:[(0,G.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:d?(0,G.jsx)(O,{className:f}):(0,G.jsx)(I,{className:f})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-medium text-foreground/90`,children:e.title}),(0,G.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-xs text-muted-foreground`,children:e.message||l.message})]}),(0,G.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},className:`shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground`,"aria-label":U(`close`),children:(0,G.jsx)(ie,{className:`size-4`})})]})}function zc({toasts:e,onDismiss:t,onClick:n}){return e.length===0?null:(0,G.jsx)(`div`,{className:`pointer-events-none fixed right-4 top-16 z-50 flex flex-col gap-2`,children:e.map(e=>(0,G.jsx)(Rc,{toast:e,onDismiss:t,onClick:n},e.id))})}async function Bc(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 Vc(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 Hc(e){return`projectId=${encodeURIComponent(e)}`}function Uc(e){return Bc(`/api/workspace/tree?${Hc(e)}`)}function Wc(e,t){return Bc(`/api/workspace/file?${Hc(e)}&path=${encodeURIComponent(t)}`)}function Gc(e,t){return Vc(`/api/workspace/resolve-path`,{projectId:e,path:t})}function Kc(e,t,n){return Vc(`/api/workspace/open-external`,{projectId:e,path:t,target:n})}function qc(e){return Bc(`/api/git/status?${Hc(e)}`)}function Jc(e,t){return Bc(`/api/git/file-diff?${Hc(e)}&path=${encodeURIComponent(t)}`)}function Yc(e,t){return Vc(`/api/git/stage`,{projectId:e,path:t})}function Xc(e){return Vc(`/api/git/stage-all`,{projectId:e})}function Zc(e,t){return Vc(`/api/git/unstage`,{projectId:e,path:t})}function Qc(e){return Vc(`/api/git/unstage-all`,{projectId:e})}function $c(e,t){return Vc(`/api/git/restore`,{projectId:e,path:t})}function el(e){return Vc(`/api/git/restore-all`,{projectId:e})}function tl(e){return Bc(`/api/git/branches?${Hc(e)}`)}function nl(e,t){return Vc(`/api/git/checkout`,{projectId:e,branch:t})}function rl(e,t){return Vc(`/api/git/create-branch`,{projectId:e,branch:t})}function il(e){return Bc(`/api/git/log?${Hc(e)}`)}function al(e,t,n,r){return Vc(`/api/git/generate-commit-message`,{projectId:e,model:t,thinkingLevel:n,includeUnstaged:r})}function ol(e,t,n){return Vc(`/api/git/commit`,{projectId:e,message:t,includeUnstaged:n})}function sl(e){return Vc(`/api/git/push`,{projectId:e})}function cl(e,t,n){return Vc(`/api/git/commit-and-push`,{projectId:e,message:t,includeUnstaged:n})}function ll({projectId:e,currentBranch:t,dirtyCount:r=0,className:i,onCheckout:a,onCreated:o,onOpenGraph:s,onOpenChanges:l}){let u=(0,H.useRef)(null),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)([]),[h,g]=(0,H.useState)(!0),[_,v]=(0,H.useState)(),[b,x]=(0,H.useState)(),S=(0,H.useCallback)(async()=>{g(!0),v(void 0);try{m((await tl(e)).branches)}catch(e){v(e instanceof Error?e.message:U(`gitBranchesFailed`))}finally{g(!1)}},[e]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{S(),u.current?.focus()},0);return()=>window.clearTimeout(e)},[S]);let C=(0,H.useMemo)(()=>{let e=d.trim().toLowerCase();return e?p.filter(t=>t.name.toLowerCase().includes(e)):p},[p,d]),w=(0,H.useCallback)(async e=>{if(!(e.current||b)){x(e.name);try{await a(e.name),await S()}finally{x(void 0)}}},[b,a,S]),T=(0,H.useCallback)(async()=>{let t=await Ec({title:U(`createBranchTitle`),description:U(`createBranchDescription`),placeholder:U(`createBranchPlaceholder`),confirmLabel:U(`createAndCheckoutBranch`),cancelLabel:U(`cancel`)});if(t){x(t);try{let n=await rl(e,t);o?.(n),await S()}catch(e){$(e instanceof Error?e.message:U(`gitCheckoutFailed`))}finally{x(void 0)}}},[o,e,S]);return(0,G.jsxs)(`div`,{className:W(`absolute left-0 top-10 z-40 w-[340px] overflow-hidden rounded-2xl border border-border bg-popover shadow-quickforge`,i),onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:`border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] p-3`,children:(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(D,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground/70`}),(0,G.jsx)(wc,{ref:u,value:d,onChange:e=>f(e.target.value),placeholder:U(`searchBranches`),className:`h-10 rounded-xl border-transparent bg-background pl-9 text-sm shadow-none focus-visible:border-border`})]})}),l?(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-center gap-2 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 py-3 text-sm text-muted-foreground transition-colors hover:bg-muted/20 hover:text-foreground`,onClick:l,children:[(0,G.jsx)(`span`,{children:U(`uncommittedChanges`)}),(0,G.jsx)(`span`,{children:U(`filesCount`,{count:r})})]}):null,(0,G.jsx)(`div`,{className:`max-h-[340px] overflow-y-auto p-2`,children:h?(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-8 text-sm text-muted-foreground`,children:[(0,G.jsx)(n,{className:`size-4 animate-spin`}),(0,G.jsx)(`span`,{children:U(`loading`)})]}):_?(0,G.jsx)(`div`,{className:`rounded-xl bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:_}):C.length===0?(0,G.jsx)(`div`,{className:`rounded-xl bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:U(`noBranchesFound`)}):C.map(e=>{let r=e.current||e.name===t,i=b===e.name;return(0,G.jsxs)(`button`,{type:`button`,className:W(`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm transition-colors`,r?`bg-muted text-foreground`:`text-foreground/88 hover:bg-muted/70`),onClick:()=>void w(e),disabled:r||!!b,title:e.name,children:[i?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(ce,{className:W(`size-4 shrink-0`,r?`text-foreground`:`text-muted-foreground`)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),r?(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:U(`currentBranch`)}):null]},`${e.remote?`remote`:`local`}:${e.name}`)})}),o||s?(0,G.jsxs)(`div`,{className:`border-t-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] p-2`,children:[o?(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm text-foreground/88 transition-colors hover:bg-muted/70`,onClick:()=>void T(),disabled:!!b,children:[(0,G.jsx)(y,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`createAndCheckoutBranchEllipsis`)})]}):null,s?(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm text-foreground/88 transition-colors hover:bg-muted/70`,onClick:s,children:[(0,G.jsx)(c,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitGraph`)})]}):null]}):null]})}function ul(e){return e?.detached===!0||e?.branch===`HEAD`||!!e?.branch?.startsWith(`HEAD `)}function dl(e,t){return e?.files?.length?e.files.filter(e=>!e.conflict&&(t||e.staged)):[]}function fl(e,t,n){return!!(e?.isGitRepository&&!e.counts?.conflicts&&!ul(e)&&n.trim()&&dl(e,t).length)}function pl(e){return(e?.files??[]).reduce((e,t)=>(e.additions+=t.additions??0,e.deletions+=t.deletions??0,e),{additions:0,deletions:0})}function ml(e){return e.conflict?`!`:e.status===`untracked`?`?`:e.status===`added`?`A`:e.status===`deleted`?`D`:e.status===`renamed`?`R`:`M`}function hl({open:e,projectId:r,status:a,onClose:o,onCheckout:s,onRefreshStatus:c,onStatusChange:l,onCompleted:u}){let[d,p]=(0,H.useState)(``),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!0),[C,w]=(0,H.useState)(),[T,E]=(0,H.useState)(``),[D,O]=(0,H.useState)(``),[k,ee]=(0,H.useState)(),[A,te]=(0,H.useState)(`off`),N=(0,H.useMemo)(()=>pl(a),[a]),P=(0,H.useMemo)(()=>dl(a,m),[m,a]),F=(0,H.useMemo)(()=>new Set(P.map(e=>e.path)),[P]),I=a?.counts?.total??a?.files.length??0,L=ul(a),R=!x&&fl(a,m,d);if((0,H.useEffect)(()=>{if(!e)return;let t=!1;return c().then(e=>{!t&&!e&&E(U(`gitStatusRefreshFailed`))}).finally(()=>{t||S(!1)}),()=>{t=!0}},[c,e,r]),(0,H.useEffect)(()=>{if(!e)return;let t=!1;async function n(){try{let e=await Yt(),n=await sn(e),r=await en(e),i=r.model??await cn(e)??n[0];if(t||!i)return;ee(i),te(r.thinkingLevel??Zt(i))}catch{}}return n(),()=>{t=!0}},[e]),(0,H.useEffect)(()=>{if(!g)return;let e=()=>_(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[g]),(0,H.useEffect)(()=>{if(!e)return;function t(e){e.key===`Escape`&&!C&&(_(!1),o())}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[C,o,e]),!e)return null;async function ne(){if(!r){E(U(`gitCommitNoProject`));return}if(!k){E(U(`gitCommitNoModel`));return}if(!P.length){E(U(`gitNoStagedChanges`));return}w(`generate`),E(``);try{p((await al(r,k,A,m)).message)}catch(e){E(e instanceof Error?e.message:U(`gitGenerateCommitMessageFailed`))}finally{w(void 0)}}async function z(e){if(r){if(e!==`push`){if(!d.trim()){E(U(`gitCommitMessageRequired`));return}if(!R){E(U(L?`gitDetachedHeadBlocked`:`gitNoStagedChanges`));return}}if(L){E(U(`gitDetachedHeadBlocked`));return}w(e),E(``);try{if(e===`push`){let e=await sl(r);O(``),u(e);return}if(e===`commit-push`){let e=await cl(r,d.trim(),m);if(!e.pushed){l(e),p(``),O(e.pushError||U(`gitOperationFailed`));return}p(``),u(e);return}let t=await ol(r,d.trim(),m);p(``),u(t)}catch(e){E(e instanceof Error?e.message:U(`gitOperationFailed`))}finally{w(void 0)}}}return(0,Vn.createPortal)((0,G.jsx)(`div`,{className:`fixed inset-0 z-[80] flex items-center justify-center bg-black/50 px-6 py-8`,role:`dialog`,"aria-modal":`true`,onMouseDown:e=>{e.target===e.currentTarget&&!C&&(_(!1),o())},children:(0,G.jsxs)(`div`,{className:`flex max-h-[min(700px,calc(100vh-64px))] w-full max-w-[760px] flex-col overflow-hidden rounded-3xl border border-[color-mix(in_oklab,var(--border)_42%,transparent)] bg-background shadow-2xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex max-w-[280px] items-center gap-2.5 rounded-xl px-2 py-1.5 text-base text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>_(e=>!e),disabled:!r||!!C,"aria-label":U(`gitBranchMenu`),"aria-haspopup":`menu`,"aria-expanded":g,children:[(0,G.jsx)(ce,{className:`size-5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:a?.branch||U(`unknown`)}),(0,G.jsx)(b,{className:`size-4 shrink-0`})]}),g&&r?(0,G.jsx)(ll,{projectId:r,currentBranch:a?.branch,className:`top-11`,onCheckout:async e=>{await s(e),_(!1)}}):null]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-base font-medium`,children:[(0,G.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,N.additions]}),(0,G.jsxs)(`span`,{className:`text-red-600`,children:[`-`,N.deletions]}),(0,G.jsx)(`button`,{type:`button`,className:`ml-2 rounded-full p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>{_(!1),o()},disabled:!!C,"aria-label":U(`close`),children:(0,G.jsx)(ie,{className:`size-5`})})]})]}),(0,G.jsxs)(`div`,{className:`relative min-h-44 px-6 pb-4`,children:[(0,G.jsx)(`textarea`,{value:d,onChange:e=>{p(e.target.value),E(``)},onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),!C&&R&&z(`commit`))},placeholder:U(`gitCommitMessagePlaceholder`),disabled:!!C,className:`min-h-40 w-full resize-none bg-transparent pr-12 text-base leading-7 text-foreground/90 outline-none placeholder:text-muted-foreground/72 disabled:opacity-60`}),(0,G.jsx)(`button`,{type:`button`,className:W(`absolute right-6 top-0 rounded-full p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,C===`generate`&&`pointer-events-none`),onClick:()=>void ne(),disabled:!!C||x||!P.length||L,title:U(`gitGenerateCommitMessage`),"aria-label":U(`gitGenerateCommitMessage`),children:C===`generate`?(0,G.jsx)(n,{className:`size-5 animate-spin`}):(0,G.jsx)(j,{className:`size-5`})})]}),(0,G.jsxs)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_24%,transparent)] px-6 py-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 items-center gap-3 text-foreground/92`,children:[(0,G.jsx)(`button`,{type:`button`,className:W(`flex size-5 shrink-0 items-center justify-center rounded-md border transition-colors`,m?`border-black bg-black text-white`:`border-border bg-background text-transparent`),onClick:()=>{h(e=>!e),O(``),E(``)},disabled:!!C||x,"aria-pressed":m,children:(0,G.jsx)(i,{className:`size-3.5`})}),(0,G.jsx)(`span`,{children:U(`gitIncludeUnstagedChanges`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-1.5 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>y(e=>!e),disabled:!I,children:[(0,G.jsx)(`span`,{children:U(`gitCommitFilesSummary`,{selected:P.length,total:I})}),(0,G.jsx)(b,{className:W(`size-4 transition-transform`,v&&`rotate-180`)})]})]}),m?(0,G.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:U(`gitIncludeUnstagedWarning`)}):null,v?(0,G.jsx)(`div`,{className:`mt-3 max-h-44 space-y-1 overflow-y-auto border-t border-[color-mix(in_oklab,var(--border)_24%,transparent)] pt-3`,children:(a?.files??[]).map(e=>{let t=F.has(e.path);return(0,G.jsxs)(`div`,{className:W(`flex items-center gap-2 rounded-lg px-2 py-1.5`,!t&&`opacity-45`),children:[(0,G.jsx)(`span`,{className:`w-4 shrink-0 text-center font-mono text-xs text-muted-foreground`,children:ml(e)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.path,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),t?null:(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:U(`gitFileNotIncluded`)})]},`${e.oldPath??``}:${e.path}`)})}):null]}),x?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-muted/55 px-4 py-3 text-sm text-muted-foreground`,children:U(`gitRefreshingStatus`)}):null,L?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:U(`gitDetachedHeadBlocked`)}):null,D?(0,G.jsxs)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:U(`gitCommitSucceededPushFailed`)}),(0,G.jsx)(`div`,{className:`mt-1 break-words text-xs opacity-90`,children:D})]}):null,T?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:T}):null,a?.counts?.conflicts?(0,G.jsx)(`div`,{className:`mx-6 mb-3 rounded-2xl bg-destructive/10 px-4 py-3 text-sm text-destructive`,children:U(`gitCommitConflictsBlocked`)}):null,(0,G.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-6 py-4`,children:D?(0,G.jsxs)(`button`,{type:`button`,className:`flex h-12 w-full items-center gap-3 rounded-2xl bg-muted/70 px-3 text-left transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45`,disabled:!!C||L,onClick:()=>void z(`push`),children:[C===`push`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitRetryPush`)})]}):(0,G.jsxs)(`div`,{className:`space-y-1.5 text-base`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-3 text-left transition-colors hover:bg-muted/55 disabled:cursor-not-allowed disabled:opacity-45`,disabled:!!C||!R,onClick:()=>void z(`commit`),children:[C===`commit`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(f,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitCommitOnly`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-12 w-full items-center gap-3 rounded-2xl bg-muted/70 px-3 text-left transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45`,disabled:!!C||!R,onClick:()=>void z(`commit-push`),children:[C===`commit-push`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(M,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`flex-1`,children:U(`gitCommitAndPush`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-3 text-left text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-35`,disabled:!!C||x||L,onClick:()=>void z(`push`),children:[C===`push`?(0,G.jsx)(n,{className:`size-4 shrink-0 animate-spin`}):(0,G.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{children:U(`gitPushOnly`)})]})]})})]})}),document.body)}function gl(e){return e.files.reduce((e,t)=>(e.additions+=t.additions??0,e.deletions+=t.deletions??0,e),{additions:0,deletions:0})}function _l({projectId:e,status:t,expanded:n,onExpandedChange:r,onOpenChanges:i,onOpenCommitPush:a,onCheckout:o,onCreated:s,onOpenGraph:c}){let l=(0,H.useRef)(null),[u,d]=(0,H.useState)(!1),f=(0,H.useMemo)(()=>gl(t),[t]),p=t.counts?.total??t.files.length;return(0,H.useEffect)(()=>{if(!u)return;function e(e){l.current?.contains(e.target)||d(!1)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]),t.isGitRepository?(0,G.jsxs)(`div`,{ref:l,className:`relative`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`button`,{type:`button`,className:W(`inline-flex size-9 items-center justify-center rounded-2xl bg-transparent text-muted-foreground/85 transition-colors hover:bg-muted/45 hover:text-foreground/90`,n&&`bg-muted/45 text-foreground/90`),onClick:()=>r(!n),"aria-label":U(`togglePinnedSummary`),title:U(`togglePinnedSummary`),"aria-expanded":n,children:(0,G.jsx)(C,{className:`size-[18px]`})}),n?(0,G.jsxs)(`div`,{className:`absolute -right-10 top-11 z-40 w-[min(15rem,calc(100vw-1rem))] rounded-3xl border border-[color-mix(in_oklab,var(--border)_38%,transparent)] bg-background p-4 text-foreground shadow-quickforge lg:-right-20`,children:[(0,G.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-muted-foreground`,children:U(`environmentInfo`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-foreground/85`,children:[(0,G.jsx)(`button`,{type:`button`,className:`rounded-full p-1.5 transition-colors hover:bg-muted`,"aria-label":U(`more`),title:U(`more`),children:(0,G.jsx)(R,{className:`size-4`})}),(0,G.jsx)(`button`,{type:`button`,className:`rounded-full p-1.5 transition-colors hover:bg-muted`,onClick:()=>{d(!1),r(!1)},"aria-label":U(`gitToolsCollapse`),title:U(`gitToolsCollapse`),children:(0,G.jsx)(ie,{className:`size-4`})})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-2.5 text-left text-foreground/88 transition-colors hover:bg-muted/45 hover:text-foreground`,onClick:i,children:[(0,G.jsx)(N,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`flex-1 font-medium`,children:U(`gitToolsChanges`)}),(0,G.jsxs)(`span`,{className:`font-medium text-emerald-600`,children:[`+`,f.additions]}),(0,G.jsxs)(`span`,{className:`font-medium text-red-600`,children:[`-`,f.deletions]})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-2.5 text-left text-foreground/88 transition-colors hover:bg-muted/45 hover:text-foreground`,onClick:()=>d(e=>!e),"aria-expanded":u,children:[(0,G.jsx)(ce,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:t.branch||U(`unknown`)}),(0,G.jsx)(b,{className:W(`size-4 shrink-0 text-muted-foreground transition-transform`,u&&`rotate-180`)})]}),u?(0,G.jsx)(ll,{projectId:e,currentBranch:t.branch,dirtyCount:p,className:`left-auto right-0 top-full mt-2 w-[min(340px,calc(100vw-1rem))] lg:right-full lg:top-0 lg:mr-3 lg:mt-0`,onCheckout:async e=>{await o(e),d(!1)},onCreated:e=>{s(e),d(!1)},onOpenGraph:()=>{d(!1),c()},onOpenChanges:()=>{d(!1),i()}}):null]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-11 w-full items-center gap-3 rounded-2xl px-2.5 text-left text-foreground/88 transition-colors hover:bg-muted/45 hover:text-foreground`,onClick:a,children:[(0,G.jsx)(z,{className:`size-4 shrink-0 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`font-medium`,children:U(`gitToolsCommitOrPush`)})]})]})]}):null]}):null}function vl(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(nt(),{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}).format(t)}function yl(e){return e.type===`head`?`border-amber-500 text-foreground`:e.type===`tag`?`border-emerald-600 text-emerald-700 dark:text-emerald-300`:e.type===`remote`?`border-border bg-muted/40 text-muted-foreground`:`border-border bg-muted/30 text-muted-foreground`}function bl({decoration:e}){return(0,G.jsxs)(`span`,{className:W(`inline-flex h-6 items-center gap-1 rounded-lg border px-2 text-xs`,yl(e)),children:[e.type===`tag`?(0,G.jsx)(ae,{className:`size-3`}):(0,G.jsx)(ce,{className:`size-3`}),(0,G.jsx)(`span`,{children:e.name})]})}function xl({index:e,isLast:t}){return(0,G.jsxs)(`div`,{className:`relative flex h-full min-h-14 w-full justify-center`,"aria-hidden":`true`,children:[t?null:(0,G.jsx)(`div`,{className:`absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-amber-500/20`}),e>0?(0,G.jsx)(`div`,{className:`absolute left-1/2 top-0 h-1/2 w-px -translate-x-1/2 bg-amber-500/20`}):null,(0,G.jsx)(`div`,{className:W(`relative z-10 mt-5 rounded-full border bg-background`,e===0?`size-3.5 border-2 border-amber-500/80`:`size-2.5 border-amber-500/65`)})]})}function Sl({projectId:e,projectName:t,onClose:r}){let[i,a]=(0,H.useState)([]),[o,s]=(0,H.useState)(!0),[l,u]=(0,H.useState)(),d=(0,H.useCallback)(async()=>{s(!0),u(void 0);try{a((await il(e)).commits)}catch(e){u(e instanceof Error?e.message:U(`gitGraphFailed`))}finally{s(!1)}},[e]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{d()},0);return()=>window.clearTimeout(e)},[d]),(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let f=(0,H.useMemo)(()=>i,[i]);return(0,Vn.createPortal)((0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-6 backdrop-blur-sm`,onClick:e=>e.target===e.currentTarget?r():void 0,children:(0,G.jsxs)(`div`,{className:`flex h-[78vh] w-[86vw] max-w-[1500px] flex-col overflow-hidden rounded-2xl border border-border bg-background shadow-quickforge`,children:[(0,G.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5`,children:[(0,G.jsx)(c,{className:`size-5 text-muted-foreground`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-base font-medium text-foreground`,children:U(`gitGraph`)}),(0,G.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t})]}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>void d(),"aria-label":U(`refresh`),disabled:o,children:o?(0,G.jsx)(n,{className:`size-4 animate-spin`}):(0,G.jsx)(ee,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`size-8`,onClick:r,"aria-label":U(`close`),children:(0,G.jsx)(ie,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[72px_minmax(360px,1fr)_160px_140px_120px] border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-muted/20 text-sm font-medium text-muted-foreground`,children:[(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`graphColumn`)}),(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`description`)}),(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`date`)}),(0,G.jsx)(`div`,{className:`border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3`,children:U(`author`)}),(0,G.jsx)(`div`,{className:`px-5 py-3`,children:U(`commit`)})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:o?(0,G.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(n,{className:`size-4 animate-spin`}),(0,G.jsx)(`span`,{children:U(`loading`)})]}):l?(0,G.jsx)(`div`,{className:`m-5 rounded-2xl border border-border bg-muted/30 p-5 text-sm text-muted-foreground`,children:l}):f.length===0?(0,G.jsx)(`div`,{className:`m-5 rounded-2xl border border-border bg-muted/30 p-5 text-sm text-muted-foreground`,children:U(`noGitCommits`)}):f.map((e,t)=>(0,G.jsxs)(`div`,{className:W(`grid min-h-14 grid-cols-[72px_minmax(360px,1fr)_160px_140px_120px] border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] text-sm`,e.decorations.some(e=>e.type===`head`||e.name===`HEAD`)?`bg-muted/28`:`bg-background`),children:[(0,G.jsx)(xl,{index:t,isLast:t===f.length-1}),(0,G.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 px-5 py-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.decorations.map(t=>(0,G.jsx)(bl,{decoration:t},`${e.hash}:${t.type}:${t.name}`)),(0,G.jsx)(`span`,{className:`min-w-0 break-words text-foreground/90`,children:e.subject})]})}),(0,G.jsx)(`div`,{className:`flex items-center border-l-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3 text-muted-foreground`,children:vl(e.date)}),(0,G.jsx)(`div`,{className:`flex min-w-0 items-center border-l-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3 text-muted-foreground`,children:(0,G.jsx)(`span`,{className:`truncate`,children:e.author})}),(0,G.jsx)(`div`,{className:`flex items-center border-l-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-5 py-3 font-mono text-muted-foreground`,children:e.shortHash})]},e.hash))})]})}),document.body)}async function Cl(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 wl(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 Tl(){let e=()=>Array.from({length:6},()=>wl(`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`)).join(``);return`${e()}-${e()}`}function El(e=24){return new Date(Date.now()+e*60*60*1e3).toISOString()}async function Dl(e){return Cl(`/api/shares`,{method:`POST`,body:JSON.stringify(e)})}async function Ol(e){return Cl(`/api/shares${e?`?sessionId=${encodeURIComponent(e)}`:``}`)}async function kl(e){return Cl(`/api/shares/${encodeURIComponent(e)}`,{method:`DELETE`})}async function Al(e){return Cl(`/api/shared/${encodeURIComponent(e)}/meta`)}async function jl(e,t=``){return Cl(`/api/shared/${encodeURIComponent(e)}/unlock`,{method:`POST`,body:JSON.stringify({password:t})})}async function Ml(e){return Cl(`/api/shared/${encodeURIComponent(e)}/models`)}function Nl({open:e,sessionId:t,title:n,onOpenChange:r}){let i=(0,H.useId)(),[a,o]=(0,H.useState)(`read`),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(`24h`),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)([]),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(),x=(0,H.useMemo)(()=>{if(l!==`never`)return El(l===`1h`?1:l===`7d`?168:24)},[l]);if((0,H.useEffect)(()=>{!e||!t||Ol(t).then(e=>g(e.shares)).catch(e=>b(e instanceof Error?e.message:`Failed to load shares`))},[e,t]),!e)return null;let S=a===`operate`,C=!!t&&(a!==`operate`||d&&s.trim()),w=async()=>{if(!(!t||!C)){if(S&&!s.trim()){b(`可操作分享必须设置密码。`);return}v(!0),b(void 0);try{let e=await Dl({sessionId:t,permission:a,password:s.trim(),expiresAt:x});m(e.url),await Qo(e.url),f(!1),g((await Ol(t)).shares)}catch(e){b(e instanceof Error?e.message:`Failed to create share`)}finally{v(!1)}}},T=async e=>{let t=e.url||`${window.location.origin}/share/${encodeURIComponent(e.id)}`;m(t),await Qo(t)},E=async e=>{try{await kl(e),g(t=>t.map(t=>t.id===e?{...t,revokedAt:new Date().toISOString()}:t))}catch(e){b(e instanceof Error?e.message:`Failed to revoke share`)}};return(0,G.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,G.jsxs)(`div`,{className:`flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-border bg-background shadow-quickforge`,onMouseDown:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border px-5 py-4`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:`分享到局域网`}),(0,G.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`当前对话:`,n,`。同一个对话只会有一个固定分享链接;只读分享密码可选,可操作分享必须设置密码。`]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`权限`}),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`rounded-xl border p-3 text-left text-sm ${a===`read`?`border-primary bg-primary/10`:`border-border`}`,onClick:()=>o(`read`),children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`仅阅读`}),(0,G.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:`只能查看这一个对话。`})]}),(0,G.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:()=>o(`operate`),children:[(0,G.jsx)(`div`,{className:`font-medium text-red-700`,children:`可操作(高危)`}),(0,G.jsx)(`div`,{className:`mt-1 text-xs text-red-700`,children:`允许对方操作这个原对话,禁止 Fork。`})]})]})]}),a===`operate`?(0,G.jsxs)(`div`,{className:`rounded-xl border border-red-300 bg-red-50 p-3 text-sm text-red-900`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2 font-semibold`,children:[(0,G.jsx)(L,{className:`mt-0.5 size-4`}),`高危可操作权限`]}),(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5`,children:`拥有链接和密码的人只能操作这一个原对话,但对方的消息、停止生成、回滚、模型/思考等级选择、YOLO 状态下可用工具等操作会按正常对话权限直接影响你的本机原对话。可操作分享必须设置密码。`}),(0,G.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-xs font-medium`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`我已了解风险,仍然允许可操作权限。`]})]}):null,(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{htmlFor:i,className:`block text-sm font-medium`,children:S?`密码(可操作必填)`:`密码(可选)`}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,G.jsx)(`input`,{id:i,value:s,onChange:e=>c(e.target.value),className:`h-10 w-full min-w-0 rounded-md border border-input bg-background px-3 text-sm`,placeholder:S?`可操作分享必须设置密码`:`留空则打开链接无需密码`}),(0,G.jsxs)(K,{variant:`outline`,className:`h-10 sm:shrink-0`,onClick:()=>c(Tl()),children:[(0,G.jsx)(ee,{className:`mr-2 size-4`}),`生成密码`]})]}),(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:S?`可操作分享必须设置非空密码;修改密码后旧密码和已解锁状态会失效。`:`留空保存会取消密码保护;填写新密码保存后旧密码和已解锁状态会失效。`})]}),(0,G.jsxs)(`label`,{className:`block text-sm font-medium`,children:[`有效期`,(0,G.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`mt-2 h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:[(0,G.jsx)(`option`,{value:`1h`,children:`1 小时`}),(0,G.jsx)(`option`,{value:`24h`,children:`24 小时`}),(0,G.jsx)(`option`,{value:`7d`,children:`7 天`}),(0,G.jsx)(`option`,{value:`never`,children:`永久,需手动撤销`})]})]}),p?(0,G.jsxs)(`div`,{className:`rounded-xl border border-emerald-300 bg-emerald-50 p-3 text-sm text-emerald-900`,children:[`已复制到剪切板。`,(0,G.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto whitespace-pre-wrap text-xs`,children:p})]}):null,y?(0,G.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:y}):null,h.length?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`已有分享`}),(0,G.jsx)(`div`,{className:`space-y-2`,children:h.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border p-2 text-xs`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-mono`,children:e.id}),(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>void T(e),"aria-label":`复制分享链接`,title:`复制分享链接`,children:(0,G.jsx)(re,{className:`size-4`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`text-destructive`,onClick:()=>void E(e.id),"aria-label":`撤销分享`,title:`撤销分享`,children:(0,G.jsx)(k,{className:`size-4`})})]})]},e.id))})]}):null]})}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border px-5 py-4`,children:(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(K,{variant:`outline`,onClick:()=>r(!1),children:U(`cancel`)}),(0,G.jsxs)(K,{variant:a===`operate`?`destructive`:`default`,disabled:!C||_,onClick:()=>void w(),title:a===`operate`&&!s.trim()?`可操作分享必须设置密码`:void 0,children:[(0,G.jsx)(re,{className:`mr-2 size-4`}),a===`operate`?`保存配置并复制高危可操作链接`:`保存配置并复制链接`]})]})})]})})}function Pl(e){let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).pop()||t||`artifact`}function Fl(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)?`html`:/\.(svg|png|jpe?g|webp|gif|bmp|ico)$/i.test(t)?`image`:t.endsWith(`.md`)||t.endsWith(`.mdx`)?`markdown`:/\.(ts|tsx|js|jsx|mjs|cjs|css|scss|less|json|jsonc|txt|xml|yml|yaml|toml|ini|py|rb|go|rs|java|c|h|cpp|hpp|cs|php|sh|bash|zsh|ps1)$/i.test(t)?`code`:`unknown`}function Il(e){return Fl(e)!==`unknown`}var Ll=/\.(svg|png|jpe?g|webp|gif|ico)$/i;function Rl(e){return Fl(e)===`html`||Ll.test(e)}function zl(e,t){let n=t.replace(/\\/g,`/`);return!e?.trim()||n.startsWith(`/`)||/^[a-zA-Z]:\//.test(n)?t:`${e.trim().replace(/\\/g,`/`).replace(/\/+$/,``)}/${n.replace(/^\/+/,``)}`}function Bl(e,t,n){let r=t.replace(/\\/g,`/`),i=r.match(/^\/+/)?.[0]??``,a=i+r.slice(i.length).split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`),o=`/api/workspace/preview/${encodeURIComponent(e)}/${a}`;return n?`${o}?r=${n}`:o}function Vl(e){return e.replace(/\\/g,`/`).toLowerCase()}function Hl(e){let t=Pl(e.path).toLowerCase();return e.defaultPreview?0:e.explicit&&e.preview?1:e.explicit?2:t===`index.html`?3:e.kind===`html`?4:e.kind===`image`?5:e.kind===`markdown`?6:e.kind===`code`?7:20}function Ul(e){let t=new Map;for(let n of e){if(!n.path)continue;let e=Vl(n.path),r=n.kind??Fl(n.path),i=t.get(e),a=n.preview??Il(n.path),o=n.source===`present_files`||n.presentation===`explicit`;if(!i){t.set(e,{id:e,path:n.path,title:n.title,description:n.description,kind:r,preview:a,defaultPreview:!!n.defaultPreview,explicit:o,addedLines:n.addedLines,removedLines:n.removedLines,sources:[n.source],toolCallIds:n.toolCallId?[n.toolCallId]:[]});continue}i.preview=i.preview||a,i.defaultPreview=i.defaultPreview||!!n.defaultPreview,i.explicit=i.explicit||o,i.title=n.title||i.title,i.description=n.description||i.description,typeof n.addedLines==`number`&&(i.addedLines=(i.addedLines??0)+n.addedLines),typeof n.removedLines==`number`&&(i.removedLines=(i.removedLines??0)+n.removedLines),i.kind=i.kind===`unknown`?r:i.kind,i.sources.includes(n.source)||i.sources.push(n.source),n.toolCallId&&!i.toolCallIds.includes(n.toolCallId)&&i.toolCallIds.push(n.toolCallId)}return[...t.values()].sort((e,t)=>Hl(e)-Hl(t))}function Wl(e){let t=Ul(e).filter(e=>e.preview&&e.explicit);if(t.length<=1)return t[0];let n=new Map;for(let t=0;t<e.length;t++){let r=e[t]?.toolCallId;r&&n.set(r,t)}let r=e=>{let t=e.toolCallIds,r=-1;for(let e of t){let t=n.get(e);typeof t==`number`&&t>r&&(r=t)}return r};return[...t].sort((e,t)=>r(t)-r(e))[0]}var Gl=(0,H.lazy)(()=>ze(()=>import(`./ChatPanelHost-wfGCaCzD.js`).then(e=>({default:e.ChatPanelHost})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Kl=(0,H.lazy)(()=>ze(()=>import(`./SharedConversationPage-Ce3KoVZt.js`).then(e=>({default:e.SharedConversationPage})),__vite__mapDeps([10,1,3,2,4,5,6,0,7,8,9]))),ql=(0,H.lazy)(()=>ze(()=>import(`./WorkspaceInspector-kM3BRPjY.js`).then(e=>({default:e.WorkspaceInspector})),__vite__mapDeps([11,1,12,5,6,13,14,15,9,3]))),Jl=(0,H.lazy)(()=>ze(()=>import(`./TerminalDock-4eUuXP7X.js`).then(e=>({default:e.TerminalDock})),__vite__mapDeps([13,1,14,15,5,6]))),Yl=(0,H.lazy)(()=>ze(()=>import(`./SettingsWorkspacePage-BtJZMIsZ.js`).then(e=>({default:e.SettingsWorkspacePage})),__vite__mapDeps([16,1,3,2,4,5,6,8]))),Xl=`quickforge:auto-preview-seen-signatures`,Zl=200,Ql=`https://github.com/shawnstack/quickforge/releases/latest`,$l=1350,eu=280,tu=150;function nu(){if(typeof window>`u`)return new Set;try{let e=window.sessionStorage.getItem(Xl),t=e?JSON.parse(e):void 0;return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`&&e.length>0)):new Set}catch{return new Set}}function ru(e){return nu().has(e)}function iu(e){if(!(typeof window>`u`))try{let t=[...nu(),e].slice(-Zl);window.sessionStorage.setItem(Xl,JSON.stringify(t))}catch{}}function au(){return(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:U(`loading`)})}function ou(){return null}function su({exiting:e=!1}){let t=U(`loadingChatWorkspace`);return(0,G.jsxs)(`div`,{className:W(`quickforge-startup-splash`,e&&`quickforge-startup-splash-exit`),role:`status`,"aria-label":t,children:[(0,G.jsxs)(`svg`,{className:`quickforge-startup-splash-icon`,viewBox:`0 0 64 64`,fill:`none`,"aria-hidden":`true`,children:[(0,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`startupIconStroke`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#9ca3af`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#4b5563`})]}),(0,G.jsxs)(`linearGradient`,{id:`startupIconBolt`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#374151`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#0f172a`})]})]}),(0,G.jsx)(`polygon`,{className:`quickforge-startup-splash-outline`,points:`32,6 52.78,18 52.78,42 32,54 11.22,42 11.22,18`,fill:`none`,stroke:`url(#startupIconStroke)`,strokeWidth:`4.5`,strokeLinejoin:`round`}),(0,G.jsx)(`polygon`,{className:`quickforge-startup-splash-outline-final`,points:`32,6 52.78,18 52.78,42 32,54 11.22,42 11.22,18`,fill:`none`,stroke:`url(#startupIconStroke)`,strokeWidth:`4.5`,strokeLinejoin:`round`}),(0,G.jsx)(`path`,{className:`quickforge-startup-splash-bolt`,d:`M37.2 13 L22 34 L30.6 34 L26.8 50 L42.8 26 L33.8 26 Z`,fill:`url(#startupIconBolt)`}),(0,G.jsx)(`path`,{className:`quickforge-startup-splash-bolt-trace`,d:`M37.2 13 L22 34 L30.6 34 L26.8 50 L42.8 26 L33.8 26 Z`,fill:`none`,stroke:`#f8fafc`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,G.jsx)(`path`,{className:`quickforge-startup-splash-bolt-highlight`,d:`M37.2 13 L22 34 L30.6 34 L33.8 26 Z`,fill:`#e5e7eb`})]}),(0,G.jsx)(`span`,{className:`sr-only`,children:t})]})}function cu(e){return e===`idle`||e===`running`||e===`error`||e===`aborted`}function lu(e){return e.type===`scheduled_task_notification`}function uu(e){return e.type===`scheduled_task_started`}function du(e){return e===`starting`||e===`waiting_scan`||e===`running`||e===`stopping`}function fu(e){return Array.isArray(e.channels)?e.channels.some(e=>du(e.status)):du(e.snapshot?.status)||du(e.status)}function pu(e){return[...Array.isArray(e.channels)?e.channels:[],...e.snapshot?[e.snapshot]:[]].filter(e=>du(e.status)).map(e=>e.launchWorkspace).filter(e=>e?.kind===`project`&&typeof e.id==`string`&&e.id.length>0).map(e=>e.id)}function mu(){let e=(0,H.useRef)(null),t=(0,H.useRef)(Gt(Rt)),i=(0,H.useRef)(`default`),o=(0,H.useRef)(void 0),s=(0,H.useRef)(void 0),{activeProject:c,projects:d,defaultWorkspace:f,expandedProjectIds:p,selectingProject:m,projectPickerOpen:h,loadProject:g,switchActiveProject:_,handleSelectProjectPath:v,selectProjectDirectory:y,setProjectPickerOpen:S,toggleProjectExpanded:C,toggleAllProjectsExpanded:w,reorderProjects:E,setActiveProject:D,setProjects:O,setExpandedProjectIds:k}=ko(),{agentAccessMode:A,setAgentAccessMode:j,initialize:te}=Ao(),M=Ac(),{setArtifactPreviewOpen:N,setWorkspaceInspectorOpen:F,setWorkspaceInspectorRequest:I}=M,[L,ne]=(0,H.useState)(!1),[z,re]=(0,H.useState)(),[B,ie]=(0,H.useState)(!1),[ae,oe]=(0,H.useState)(null),[se,ue]=(0,H.useState)(!1),[de,pe]=(0,H.useState)(!1),[me,he]=(0,H.useState)({artifacts:[]}),[ge,ve]=(0,H.useState)(`project`),[ye,be]=(0,H.useState)(`updatedAt`),xe=(0,H.useRef)(``),[Se,Ce]=(0,H.useState)(),[we,Te]=(0,H.useState)(),Ee=(0,H.useRef)(0),De=(0,H.useRef)(void 0),[Oe,ke]=(0,H.useState)(!1),[Ae,je]=(0,H.useState)(!1),[Me,Ne]=(0,H.useState)(!1),[Pe,Fe]=(0,H.useState)(!1),[Ie,Le]=(0,H.useState)(()=>new Set),Re=(0,H.useRef)(0),ze=(0,H.useRef)(0),Be=(0,H.useRef)(0),Ve=(0,H.useRef)(void 0),[Ue,We]=(0,H.useState)(null),[Ge,Ke]=(0,H.useState)(!1),[qe,Je]=(0,H.useState)(!1),[Ye,Xe]=(0,H.useState)(),{toasts:Ze,handleTaskComplete:Qe,addToast:$e,dismissToast:et}=Ss(),tt=(0,H.useCallback)(()=>void 0,[]),nt=(0,H.useCallback)(()=>ie(!1),[]),rt=(0,H.useCallback)(()=>{ie(!1),window.open(Ql,`_blank`,`noopener,noreferrer`)},[]),it=(0,H.useCallback)(()=>{ie(!1),window.open(`quickforge://exit`,`_blank`,`noopener,noreferrer`)},[]),at=(0,H.useRef)(null),ot=(0,H.useRef)(null),{allLoadedSessions:st,pinnedSessions:ct,pinnedHasMore:lt,pinnedLoading:ut,globalSessions:dt,sessionsForProject:ft,globalHasMore:pt,projectTimelineSessions:mt,projectTimelineHasMore:gt,projectTimelineLoading:vt,projectHasMore:yt,globalLoading:bt,projectLoading:xt,projectLoaded:St,loadGlobalSessions:wt,loadProjectSessions:Tt,refreshSessions:Et,upsertSessionMetadata:Dt,updateSessionTitle:Ot,loadMorePinned:kt,loadMoreGlobal:q,loadMoreProject:At,loadMoreProjectTimeline:J}=xs({backendRef:ot,expandedProjectIds:p,externalProjectIds:Ie,viewMode:ge,sortMode:ye,onBroadcastSessionsChanged:(0,H.useCallback)(()=>at.current?.notifySessionsChanged(),[])}),Y=Mo({onSessionsChanged:()=>{Et()},onProjectsChanged:()=>{g()},onSettingsChanged:()=>{Et()}});(0,H.useEffect)(()=>{i.current=A},[A]),(0,H.useEffect)(()=>{o.current=c},[c]),(0,H.useEffect)(()=>{s.current=f},[f]),(0,H.useEffect)(()=>{at.current=Y},[Y]),(0,H.useEffect)(()=>{let e=window.setTimeout(()=>Ke(!0),$l);return()=>window.clearTimeout(e)},[]);let jt=(0,H.useCallback)((e,t)=>{Ce(n=>n?.sessionId===e&&kn(n,t)?n:{sessionId:e,...t})},[]),X=ps({storageRef:e,activeModelRef:t,agentAccessModeRef:i,activeProjectRef:o,defaultWorkspaceRef:s,setAgentAccessMode:j,switchActiveProject:_,sessions:st,refreshSessions:Et,updateSessionTitle:Ot,onTaskComplete:Qe});(0,H.useEffect)(()=>{if(!X.loadingSessionId){let e=window.setTimeout(()=>Xe(void 0),0);return()=>window.clearTimeout(e)}let e=X.loadingSessionId,t=window.setTimeout(()=>Xe(e),tu);return()=>window.clearTimeout(t)},[X.loadingSessionId]);let{createAgent:Nt,startDeferredSession:Pt,loadSession:Ft,syncSessionUI:It,setCurrentAgentMessages:Lt,updateCurrentAgentModel:zt,setChatPanelRevision:Bt,setCurrentTitleRef:Vt,agentRef:Ht,taskMapRef:Ut,currentSessionIdRef:Wt,currentChatScopeRef:Kt}=X;(0,H.useEffect)(()=>{De.current=X.currentToolProject?.id,Ee.current+=1,Be.current+=1},[X.currentToolProject?.id]);let qt=(0,H.useCallback)(e=>{e&&Ft(e)},[Ft]);(0,H.useEffect)(()=>{let e=e=>{let t=e.detail;typeof t?.sessionId==`string`&&qt(t.sessionId)};return window.addEventListener(`quickforge:open-session-from-settings`,e),()=>window.removeEventListener(`quickforge:open-session-from-settings`,e)},[qt]);let Jt=(0,H.useCallback)(e=>{re(t=>t?.id===e?void 0:t)},[]),Yt=(0,H.useCallback)(e=>{ze.current+=1,I({...e,id:ze.current}),F(!0)},[F,I]),Xt=(0,H.useCallback)(e=>{I(t=>t?.id===e?void 0:t)},[I]),Zt=(0,H.useCallback)(()=>{let e=X.currentToolProject?.id;e&&(N(!1),Yt({projectId:e,kind:`review`,view:`changes`}))},[X.currentToolProject?.id,Yt,N]),Qt=(0,H.useCallback)(async()=>{let e=X.currentToolProject?.id,t=Ee.current+1;if(Ee.current=t,!e){Te(void 0);return}try{let n=await qc(e);return Pc({projectId:e,requestId:t},De.current,Ee.current)?(Te(n),n):void 0}catch(n){if(!Pc({projectId:e,requestId:t},De.current,Ee.current))return;V.warn(`Failed to refresh title git status:`,n),Te(void 0);return}},[X.currentToolProject?.id]);(0,H.useEffect)(()=>{let e=window.setTimeout(()=>{Qt()},0);return()=>window.clearTimeout(e)},[Qt]),(0,H.useEffect)(()=>{let e,t=Go(t=>{Ic(t,Wt.current,De.current)&&(e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,Qt()},400))});return()=>{e!==void 0&&window.clearTimeout(e),t()}},[X.currentSessionId,Wt,Qt]);let $t=(0,H.useCallback)(async e=>{let t=X.currentToolProject?.id;if(!t)return;let n=Ee.current+1;Ee.current=n;try{let r=await nl(t,e);if(!Pc({projectId:t,requestId:n},De.current,Ee.current))return;Te(r),ke(!1),$e({sessionId:X.currentSessionId??``,title:U(`gitBranchSwitched`),status:`idle`,message:e})}catch(e){if(!Pc({projectId:t,requestId:n},De.current,Ee.current))return;throw V.error(`Failed to checkout git branch:`,e),$(e instanceof Error?e.message:U(`gitCheckoutFailed`)),e}},[$e,X.currentSessionId,X.currentToolProject?.id]),en=(0,H.useCallback)(e=>{Te(e),ke(!1),$e({sessionId:X.currentSessionId??``,title:U(`gitBranchCreated`),status:`idle`,message:e.branch??``})},[$e,X.currentSessionId]),tn=(0,H.useCallback)(e=>{Te(e),$e({sessionId:X.currentSessionId??``,title:U(`gitOperationCompleted`),status:`idle`,message:e.branch??``})},[$e,X.currentSessionId]),nn=(0,H.useCallback)(async e=>{let t=X.currentToolProject?.id;if(!t){$e({sessionId:X.currentSessionId??``,title:`无法打开文件`,status:`error`,message:`当前对话没有关联项目。`});return}let n=Be.current+1;Be.current=n;try{let r=await Gc(t,e);if(!Pc({projectId:t,requestId:n},De.current,Be.current))return;Yt({projectId:t,kind:`reader`,path:r.relativePath})}catch(e){if(!Pc({projectId:t,requestId:n},De.current,Be.current))return;let r=e instanceof Error?e.message:`打开文件失败`;$e({sessionId:X.currentSessionId??``,title:`无法打开文件`,status:`error`,message:r})}},[$e,X.currentSessionId,X.currentToolProject?.id,Yt]),rn=(0,H.useCallback)((e,t)=>{let n=X.currentToolProject;!n||n.id!==e||!Rl(t)||(N(!1),Yt({projectId:e,kind:`browser`,url:zl(n.path,t)}))},[X.currentToolProject,Yt,N]);(0,H.useEffect)(()=>{let e=X.currentToolProject,t=e?.id;if(!t||me.projectId!==t||me.sessionId!==X.currentSessionId)return;let n=Wl(me.artifacts);if(!n?.path)return;let r=n.toolCallIds[n.toolCallIds.length-1],i=`${t}:${n.path}:${n.defaultPreview?`default`:n.explicit?`explicit`:`inferred`}:${r??``}`;if(i!==xe.current){if(ru(i)){xe.current=i;return}xe.current=i,iu(i),queueMicrotask(()=>{N(!1),n.kind===`markdown`||n.kind===`code`?Yt({projectId:t,kind:`reader`,path:n.path}):Yt({projectId:t,kind:`browser`,url:zl(e.path,n.path)})})}},[X.currentSessionId,X.currentToolProject,me,Yt,N]),(0,H.useEffect)(()=>{xe.current=``,N(!1),I(void 0)},[X.currentToolProject?.id,N,I]),(0,H.useEffect)(()=>{if(!rn)return;let e=e=>{let t=e.detail,n=X.currentToolProject?.id;n&&t&&typeof t.path==`string`&&rn(n,t.path)};return window.addEventListener(`quickforge:preview-artifact`,e),()=>window.removeEventListener(`quickforge:preview-artifact`,e)},[X.currentToolProject?.id,rn]),(0,H.useEffect)(()=>Go(e=>{if(uu(e)){let t=typeof e.projectId==`string`?e.projectId:void 0;t&&(k(e=>{let n=new Set(e);return n.add(t),n}),Tt(t,0)),Et({broadcast:!0});return}if(e.type===`session_created`){let t=e.metadata;t?.id&&Dt(t)}else if(e.type===`title_updated`){let t=typeof e.sessionId==`string`?e.sessionId:void 0,n=typeof e.title==`string`?e.title:void 0;t&&n&&Ot(t,n)}else (e.type===`agent_end`||e.type===`session_forked`)&&Et({broadcast:!0});if(!lu(e))return;let t=typeof e.sessionId==`string`?e.sessionId:void 0,n=typeof e.title==`string`?e.title:U(`scheduledTasks`),r=cu(e.status)?e.status:`idle`,i=typeof e.message==`string`?e.message:void 0;$e({sessionId:t??``,title:n,status:r,message:i})}),[$e,Tt,Et,k,Ot,Dt]);let{ready:an,startupError:on,retryBootstrap:sn}=Qs({storageRef:e,backendRef:ot,activeModelRef:t,agentAccessModeRef:i,activeProjectRef:o,setAgentAccessMode:j,taskMapRef:Ut,loadGlobalSessions:wt,loadProject:g,initAgentAccessMode:te,switchActiveProject:_,createAgent:Nt,setNeedsModelSetup:ne,onStorageReady:We}),cn=cc(e,an),ln=an&&Ge&&!!(X.agent||L);(0,H.useEffect)(()=>{if(!ln)return;let e=window.setTimeout(()=>Je(!0),eu);return()=>window.clearTimeout(e)},[ln]),(0,H.useEffect)(()=>{if(!an)return;let e=0,t,n=(t=[])=>{let n=Date.now();if(t.length>0&&Le(e=>{let n=new Set(e);for(let e of t)n.add(e);return n}),!(n-e<5e3)){e=n,g(),Et();for(let e of t)Tt(e,0)}},r=e=>{if(!e){t&&window.clearInterval(t),t=void 0;return}t||=window.setInterval(n,15e3)},i=new EventSource(`/api/channels/events`),a=e=>{try{let t=JSON.parse(e.data),i=pu(t);fu(t)?(r(!0),n(i)):(t.type===`snapshot`||t.type===`status`)&&r(!1)}catch{}};return i.addEventListener(`snapshot`,a),i.addEventListener(`status`,a),i.addEventListener(`log`,a),()=>{i.close(),t&&window.clearInterval(t)}},[g,Tt,an,Et]),(0,H.useEffect)(()=>{if(an)for(let e of p)!St(e)&&!xt(e)&&Tt(e,0)},[an,p,St,xt,Tt]);let{startNewGlobalChat:un,startNewProjectChat:dn,rollbackFromMessage:fn,retryFromMessage:pn,copyAnswer:mn,forkFromMessage:hn}=Sc({storageRef:e,activeModelRef:t,activeProjectRef:o,currentChatScopeRef:Kt,currentSessionIdRef:Wt,taskMapRef:Ut,agentRef:Ht,createAgent:Nt,startDeferredSession:Pt,syncSessionUI:It,setCurrentAgentMessages:Lt,setChatPanelRevision:Bt,refreshSessions:Et,needsModelSetup:L,switchActiveProject:_,closeWorkspacePage:tt,setRestoredDraft:re}),{deleteProjectInline:gn}=Cc({activeProjectRef:o,refreshSessions:Et,notifyProjectsChanged:Y.notifyProjectsChanged,setActiveProject:D,setProjects:O,setExpandedProjectIds:k,setChatPanelRevision:Bt});(0,H.useEffect)(()=>{let e=Nc({ready:an,currentToolProjectId:X.currentToolProject?.id,projects:d,activeProject:c,recoveringProjectId:Ve.current});if(e.type===`none`){let e=X.currentToolProject?.id;Ve.current&&Ve.current!==e&&(Ve.current=void 0);return}Ve.current=e.deletedProjectId,he({artifacts:[]}),I(void 0),N(!1),oe(null),ue(!1),Be.current+=1,Pt(e.type===`project`?{scope:`project`,project:e.project}:{scope:`global`}).catch(e=>{Ve.current=void 0,V.error(`Failed to recover after the current project was deleted:`,e)})},[c,X.currentToolProject?.id,d,an,N,I,Pt]);let{setAccessMode:_n}=kc({storageRef:e,agentAccessModeRef:i,setAgentAccessMode:j,agentRef:Ht,setChatPanelRevision:Bt,notifySettingsChanged:Y.notifySettingsChanged}),vn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t)throw Error(U(`toolApprovalFailed`));try{await t.approveToolCall(e)}catch(e){throw V.error(`Failed to approve tool call:`,e),e instanceof Error?e:Error(U(`toolApprovalFailed`))}},[Ht]),yn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t)throw Error(U(`toolApprovalFailed`));try{await t.rejectToolCall(e)}catch(e){throw V.error(`Failed to reject tool call:`,e),e instanceof Error?e:Error(U(`toolApprovalFailed`))}},[Ht]),bn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t?.approveAutoCompact)throw Error(U(`toolApprovalFailed`));await t.approveAutoCompact(e)},[Ht]),xn=(0,H.useCallback)(async e=>{let t=Ht.current;if(!t?.rejectAutoCompact)throw Error(U(`toolApprovalFailed`));await t.rejectAutoCompact(e)},[Ht]),{loadSession:Sn,renameSession:Cn,togglePinSession:wn,archiveSession:Tn,startNewGlobalSession:En}=Dc({storageRef:e,taskMapRef:Ut,currentSessionIdRef:Wt,loadAgentSession:Ft,setCurrentTitleRef:Vt,refreshSessions:Et,updateSessionTitle:Ot,closeWorkspacePage:tt,startNewGlobalChat:un}),Dn=(0,H.useCallback)((e,t)=>{M.setSettingsInitialTab(e),M.setSettingsCustomProvider(t),M.setSettingsDialogOpen(!0),M.setMobileSidebarOpen(!1)},[M]),{activateConfiguredModel:On,openModelSettings:An,openDefaultOptionsSettings:jn,openAboutSettings:Mn,activateLiteLlmExampleModel:Nn,openCustomModelSelector:Pn}=yc({storageRef:e,activeModelRef:t,agentRef:Ht,createAgent:Nt,updateCurrentAgentModel:zt,setChatPanelRevision:Bt,setNeedsModelSetup:ne,setRestoredDraft:re,notifySettingsChanged:Y.notifySettingsChanged,openSettingsPage:Dn}),Fn=(0,H.useCallback)(()=>{M.setSettingsDialogOpen(!1),M.setSettingsCustomProvider(void 0),(L||!Ht.current)&&On().catch(e=>V.error(`Failed to activate configured model:`,e))},[On,Ht,L,M]),In=(0,H.useCallback)(()=>{ie(!1),Mn()},[Mn]),Ln=(0,H.useMemo)(()=>st,[st]),Rn=!!(0,H.useMemo)(()=>{if(X.currentSessionId)return Ln.find(e=>e.id===X.currentSessionId)},[X.currentSessionId,Ln])?.pinnedAt,Vn=Mc(Ln),Un=(0,H.useCallback)(e=>X.taskStatuses[e.id]??Vn[e.id]??e.taskStatus??`idle`,[X.taskStatuses,Vn]);(0,H.useEffect)(()=>{if(B)return window.addEventListener(`click`,nt),window.addEventListener(`blur`,nt),()=>{window.removeEventListener(`click`,nt),window.removeEventListener(`blur`,nt)}},[nt,B]),(0,H.useEffect)(()=>{if(!M.conversationMenuOpen)return;let e=()=>M.setConversationMenuOpen(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[M,M.conversationMenuOpen]),(0,H.useEffect)(()=>{if(!Oe)return;let e=()=>ke(!1);return window.addEventListener(`click`,e),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`blur`,e)}},[Oe]),(0,H.useEffect)(()=>{let e=e=>{let t=e.detail,n=typeof t?.command==`string`?t.command.trim():``;n&&(async()=>{(t?.confirm||t?.dangerous)&&!await us({title:U(`confirmExecuteCommandTitle`),description:t?.dangerous?U(`confirmExecuteDangerousCommand`):U(`confirmExecuteMultipleCommands`),confirmLabel:U(`executeInTerminal`),cancelLabel:U(`cancel`),variant:t?.dangerous?`destructive`:`default`})||(N(!1),ue(!0),oe({id:++Re.current,command:n,execute:!0}))})().catch(e=>{V.error(`Failed to execute markdown command:`,e),$(e instanceof Error?e.message:U(`terminalCommandExecuteFailed`))})};return window.addEventListener(`quickforge:execute-markdown-command`,e),()=>window.removeEventListener(`quickforge:execute-markdown-command`,e)},[N]);let Wn=(0,H.useCallback)(e=>{oe(t=>t?.id===e?null:t)},[]),Gn=(0,H.useCallback)(()=>{M.setFirstUseGuideDismissed(!0)},[M]),Kn=(0,H.useCallback)(()=>{let e=X.currentToolProject?.id?U(`firstUseGuideProjectPrompt`):U(`firstUseGuideGeneralPrompt`);navigator.clipboard.writeText(e).then(()=>$e({sessionId:X.currentSessionId??``,title:U(`copied`),status:`idle`,message:e})).catch(e=>{V.error(`Failed to copy first-use guide prompt:`,e),$(U(`copyFailed`))})},[$e,X.currentSessionId,X.currentToolProject?.id]),qn=!L&&!!X.agent&&!X.agent?.state.isStreaming&&(X.agent?.state.messages.length??0)===0,Jn=(0,H.useCallback)(e=>{dn(e)},[dn]),Yn=(0,H.useCallback)(()=>{En()},[En]),Xn=(0,H.useCallback)(()=>{y()},[y]),Zn=!!Ue&&!M.firstUseGuideDismissed&&!qn&&d.length===0&&dt.length===0,Qn=(0,H.useCallback)(()=>{let e=X.currentSessionId;e&&(M.setConversationMenuOpen(!1),wn(e))},[X.currentSessionId,wn,M]),$n=(0,H.useCallback)(()=>{let e=X.currentSessionId;e&&(M.setConversationMenuOpen(!1),Cn(e,X.currentTitle))},[X.currentSessionId,X.currentTitle,Cn,M]),er=(0,H.useCallback)(()=>{M.setConversationMenuOpen(!1),M.setShareDialogOpen(!0)},[M]),{setSkillsDialog:tr,setSidebarOpen:nr}=M,rr=(0,H.useCallback)(()=>{Dn(`skills`)},[Dn]),ir=(0,H.useCallback)(()=>{Dn(`agents`)},[Dn]),ar=(0,H.useCallback)(()=>{Dn(`scheduledTasks`)},[Dn]),or=(0,H.useCallback)(e=>{tr({scope:`project`,project:e})},[tr]),sr=(0,H.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||U(`openInExplorerFailed`))},[]),cr=(0,H.useCallback)(async e=>{let t=await fetch(`/api/project/${encodeURIComponent(e.id)}/open-in-vscode`,{method:`POST`});if(t.ok)return;let n=await t.json().catch(()=>null);throw Error(n?.error||U(`openInVSCodeFailed`))},[]),lr=(0,H.useCallback)(async e=>{let t=await fetch(`/api/project/${encodeURIComponent(e.id)}/open-in-idea`,{method:`POST`});if(t.ok)return;let n=await t.json().catch(()=>null);throw Error(n?.error||U(`openInIDEAFailed`))},[]),ur=(0,H.useCallback)(e=>{sr(e).catch(e=>{V.error(`Failed to open project in explorer:`,e),$(e instanceof Error?e.message:U(`openInExplorerFailed`))})},[sr]),dr=(0,H.useCallback)(e=>{cr(e).catch(e=>{V.error(`Failed to open project in VS Code:`,e),$(e instanceof Error?e.message:U(`openInVSCodeFailed`))})},[cr]),fr=(0,H.useCallback)(e=>{lr(e).catch(e=>{V.error(`Failed to open project in IntelliJ IDEA:`,e),$(e instanceof Error?e.message:U(`openInIDEAFailed`))})},[lr]),pr=(0,H.useCallback)(()=>nr(e=>!e),[nr]),Z=(0,H.useCallback)(()=>{M.setMobileSidebarOpen(!1)},[M]),mr=(0,H.useCallback)(e=>{Z(),Sn(e)},[Z,Sn]),hr=(0,H.useCallback)(()=>{Z(),En()},[Z,En]),gr=(0,H.useCallback)(e=>{Z(),dn(e)},[Z,dn]),_r=(0,H.useCallback)(()=>{Z(),rr()},[Z,rr]),vr=(0,H.useCallback)(()=>{Z(),ir()},[Z,ir]),yr=(0,H.useCallback)(()=>{Z(),ar()},[Z,ar]),br=(0,H.useCallback)(e=>{Z(),or(e)},[Z,or]),xr=(0,H.useCallback)(e=>{if(e.scope===`project`&&e.project&&e.projects){O(e.projects),M.setSkillsDialog({scope:`project`,project:e.project}),o.current?.id===e.project.id&&(D(e.project),o.current=e.project),Y.notifyProjectsChanged();return}Y.notifyProjectsChanged()},[Y,D,O,M]);return on?(0,G.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,G.jsxs)(`div`,{className:`max-w-md rounded-lg border border-border bg-background p-5 text-center`,children:[(0,G.jsx)(`h1`,{className:`text-base font-semibold`,children:U(`localServiceUnavailableTitle`)}),(0,G.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:on}),(0,G.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,G.jsx)(K,{variant:`outline`,size:`sm`,onClick:sn,children:U(`retry`)}),(0,G.jsx)(K,{variant:`default`,size:`sm`,onClick:()=>window.location.reload(),children:U(`reloadPage`)})]})]})}):!ln||!qe?(0,G.jsx)(su,{exiting:ln}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`quickforge-desktop-titlebar fixed left-0 right-0 top-0 z-40 hidden h-8 items-center px-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`quickforge-desktop-titlebar-trigger inline-flex h-8 translate-y-1 items-center gap-2.5 rounded-none px-3 text-[13px] font-medium leading-none text-foreground/90 transition-colors hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),ie(e=>!e)},"aria-haspopup":`menu`,"aria-expanded":B,children:[(0,G.jsxs)(`svg`,{className:`h-[18px] w-[18px] shrink-0`,viewBox:`0 0 64 64`,"aria-hidden":`true`,children:[(0,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`titlebarIconStroke`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#9ca3af`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#4b5563`})]}),(0,G.jsxs)(`linearGradient`,{id:`titlebarIconBolt`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0`,stopColor:`#374151`}),(0,G.jsx)(`stop`,{offset:`1`,stopColor:`#0f172a`})]})]}),(0,G.jsx)(`polygon`,{points:`32,6 52.78,18 52.78,42 32,54 11.22,42 11.22,18`,fill:`none`,stroke:`url(#titlebarIconStroke)`,strokeWidth:`4.5`,strokeLinejoin:`round`}),(0,G.jsx)(`path`,{d:`M37.2 13 L22 34 L30.6 34 L26.8 50 L42.8 26 L33.8 26 Z`,fill:`url(#titlebarIconBolt)`}),(0,G.jsx)(`path`,{d:`M37.2 13 L22 34 L30.6 34 L33.8 26 Z`,fill:`#e5e7eb`,opacity:`0.4`})]}),(0,G.jsx)(`span`,{children:`QuickForge`})]}),B&&(0,G.jsxs)(`div`,{className:`quickforge-desktop-titlebar-menu absolute left-2 top-8 min-w-40 overflow-hidden rounded-md border border-border bg-popover py-1 text-[13px] text-popover-foreground shadow-lg`,role:`menu`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex h-8 w-full items-center gap-2.5 px-3 text-left hover:bg-accent hover:text-accent-foreground`,role:`menuitem`,onClick:In,children:[(0,G.jsx)(l,{className:`size-4`}),(0,G.jsx)(`span`,{children:U(`about`)})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-8 w-full items-center gap-2.5 px-3 text-left hover:bg-accent hover:text-accent-foreground`,role:`menuitem`,onClick:rt,children:[(0,G.jsx)(ee,{className:`size-4`}),(0,G.jsx)(`span`,{children:U(`desktopUpdate`)})]}),(0,G.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,G.jsxs)(`button`,{type:`button`,className:`flex h-8 w-full items-center gap-2.5 px-3 text-left text-destructive hover:bg-destructive/10`,role:`menuitem`,onClick:it,children:[(0,G.jsx)(_e,{className:`size-4`}),(0,G.jsx)(`span`,{children:U(`desktopExit`)})]})]})]}),!M.settingsDialogOpen&&(0,G.jsxs)(`div`,{className:W(`quickforge-window-toolbar fixed right-2 z-30 flex items-center gap-1`,de&&`pointer-events-none invisible`),"aria-hidden":de||void 0,"aria-label":U(`workspacePanel`),children:[M.workspaceInspectorOpen?null:(0,G.jsx)(Ct,{project:X.currentToolProject,disabled:L,onOpenInExplorer:ur,onOpenInVSCode:dr,onOpenInIDEA:fr}),!M.workspaceInspectorOpen&&X.currentToolProject?.id&&we?.isGitRepository?(0,G.jsx)(_l,{projectId:X.currentToolProject.id,status:we,expanded:Ae,onExpandedChange:je,onOpenChanges:()=>{je(!1),Zt()},onOpenCommitPush:()=>{je(!1),Ne(!0)},onCheckout:$t,onCreated:en,onOpenGraph:()=>Fe(!0)}):null,(0,G.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>{N(!1),ue(e=>!e)},disabled:!X.currentToolProject?.id||L,"aria-label":U(se?`terminalCollapse`:`rightPanelTerminal`),title:U(se?`terminalCollapse`:`rightPanelTerminal`),className:W(`rounded-[10px] text-muted-foreground/85 hover:bg-muted/45 hover:text-foreground/90 disabled:opacity-40`,se?`bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground`:void 0),children:(0,G.jsx)(le,{className:`size-[18px] stroke-[1.85]`})}),(0,G.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>{N(!1),M.setWorkspaceInspectorOpen(e=>!e)},disabled:!X.currentToolProject?.id||L,"aria-label":M.workspaceInspectorOpen?U(`workspaceCollapseRightPanel`):U(`workspaceExpandRightPanel`),title:M.workspaceInspectorOpen?U(`workspaceCollapseRightPanel`):U(`workspaceExpandRightPanel`),className:W(`hidden rounded-[10px] text-muted-foreground/85 hover:bg-muted/45 hover:text-foreground/90 disabled:opacity-40 lg:inline-flex`,M.workspaceInspectorOpen?`bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground`:void 0),children:(0,G.jsx)(a,{className:`size-[18px] stroke-[1.85]`})})]}),M.settingsDialogOpen?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(au,{}),children:(0,G.jsx)(Yl,{initialTab:M.settingsInitialTab,customProvider:M.settingsCustomProvider,onBack:Fn})}):(0,G.jsxs)(`div`,{className:`flex h-screen min-h-0 bg-[var(--quickforge-sidebar-bg)] text-foreground`,children:[(0,G.jsx)(Oo,{sidebarOpen:M.sidebarOpen,projectsCollapsed:M.projectsCollapsed,pinnedCollapsed:M.pinnedCollapsed,conversationsCollapsed:M.conversationsCollapsed,projects:d,expandedProjectIds:p,activeProject:c,currentSessionId:X.currentSessionId,loadingSessionId:X.loadingSessionId,sessionViewMode:ge,sessionSortMode:ye,globalSessions:dt,pinnedSessions:ct,pinnedHasMore:lt,pinnedLoading:ut,sessionsForProject:ft,projectTimelineSessions:mt,projectTimelineHasMore:gt,projectTimelineLoading:vt,globalHasMore:pt,globalLoading:bt,onLoadMoreGlobal:q,onLoadMorePinned:kt,projectHasMore:yt,projectLoading:xt,projectLoaded:St,onLoadMoreProject:At,onLoadMoreProjectTimeline:J,sessionTaskStatus:Un,selectingProject:m,onTogglePinnedCollapsed:M.togglePinnedCollapsed,onToggleProjectsCollapsed:M.toggleProjectsCollapsed,onToggleConversationsCollapsed:M.toggleConversationsCollapsed,onToggleProjectExpanded:C,onToggleAllProjectsExpanded:w,onReorderProjects:E,onSelectProjectDirectory:y,onStartNewProjectChat:dn,onOpenGlobalSkills:rr,onOpenAgents:ir,onOpenScheduledTasks:ar,onOpenProjectSkills:or,onOpenProjectInExplorer:ur,onDeleteProject:gn,onLoadSession:Sn,onSessionViewModeChange:ve,onSessionSortModeChange:be,onTogglePinSession:wn,onDeleteSession:Tn,onStartNewGlobalChat:En,onOpenSettings:jn,updateAvailable:cn.result.updateAvailable,latestVersion:cn.result.latestVersion,currentVersion:cn.result.currentVersion,onOpenUpdate:Mn,onDismissUpdate:cn.dismissUpdate,onToggleSidebar:pr,currentSessionHoverInfo:Se}),M.mobileSidebarOpen?(0,G.jsxs)(`div`,{className:`fixed inset-0 z-50 md:hidden`,role:`dialog`,"aria-modal":`true`,children:[(0,G.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-background/65 backdrop-blur-sm`,onClick:Z,"aria-label":U(`toggleSidebar`)}),(0,G.jsx)(`div`,{className:`absolute inset-y-0 left-0 max-w-[85vw] shadow-quickforge`,children:(0,G.jsx)(Oo,{variant:`mobile`,sidebarOpen:!0,projectsCollapsed:M.projectsCollapsed,pinnedCollapsed:M.pinnedCollapsed,conversationsCollapsed:M.conversationsCollapsed,projects:d,expandedProjectIds:p,activeProject:c,currentSessionId:X.currentSessionId,loadingSessionId:X.loadingSessionId,sessionViewMode:ge,sessionSortMode:ye,globalSessions:dt,pinnedSessions:ct,pinnedHasMore:lt,pinnedLoading:ut,sessionsForProject:ft,projectTimelineSessions:mt,projectTimelineHasMore:gt,projectTimelineLoading:vt,globalHasMore:pt,globalLoading:bt,onLoadMoreGlobal:q,onLoadMorePinned:kt,projectHasMore:yt,projectLoading:xt,projectLoaded:St,onLoadMoreProject:At,onLoadMoreProjectTimeline:J,sessionTaskStatus:Un,selectingProject:m,onTogglePinnedCollapsed:M.togglePinnedCollapsed,onToggleProjectsCollapsed:M.toggleProjectsCollapsed,onToggleConversationsCollapsed:M.toggleConversationsCollapsed,onToggleProjectExpanded:C,onToggleAllProjectsExpanded:w,onReorderProjects:E,onSelectProjectDirectory:()=>{Z(),y()},onStartNewProjectChat:gr,onOpenGlobalSkills:_r,onOpenAgents:vr,onOpenScheduledTasks:yr,onOpenProjectSkills:br,onOpenProjectInExplorer:e=>{Z(),sr(e).catch(e=>{V.error(`Failed to open project in explorer:`,e),$(e instanceof Error?e.message:U(`openInExplorerFailed`))})},onDeleteProject:gn,onLoadSession:mr,onSessionViewModeChange:ve,onSessionSortModeChange:be,onTogglePinSession:wn,onDeleteSession:Tn,onStartNewGlobalChat:hr,onOpenSettings:()=>{Z(),jn()},updateAvailable:cn.result.updateAvailable,latestVersion:cn.result.latestVersion,currentVersion:cn.result.currentVersion,onOpenUpdate:()=>{Z(),Mn()},onDismissUpdate:cn.dismissUpdate,onToggleSidebar:Z,currentSessionHoverInfo:Se})})]}):null,(0,G.jsxs)(`main`,{className:W(`flex min-w-0 flex-1 flex-col bg-[var(--quickforge-main-bg)] md:overflow-hidden md:rounded-tl-2xl`),children:[(0,G.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b border-[color-mix(in_oklab,var(--border)_34%,transparent)] px-3 pr-20`,children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:()=>M.setMobileSidebarOpen(!0),"aria-label":U(`toggleSidebar`),children:(0,G.jsx)(u,{className:`size-[18px]`})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`min-w-0 truncate text-sm font-semibold text-foreground/92`,children:Mt(X.currentTitle)}),X.currentToolProject?.name?(0,G.jsxs)(`div`,{className:`inline-flex h-9 max-w-[220px] shrink-0 items-center gap-2 rounded-full bg-muted/55 px-3 text-sm text-foreground/88`,title:X.currentToolProject.name,children:[(0,G.jsx)(T,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:X.currentToolProject.name})]}):null,X.currentToolProject?.id&&we?.isGitRepository&&we.branch?(0,G.jsxs)(`div`,{className:`relative shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex h-9 max-w-[220px] items-center gap-2 rounded-full bg-muted/55 px-3 text-sm text-foreground/88 transition-colors hover:bg-muted`,onClick:()=>ke(e=>!e),"aria-label":U(`gitBranchMenu`),"aria-expanded":Oe,children:[(0,G.jsx)(ce,{className:`size-4 text-muted-foreground`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:we.branch}),(0,G.jsx)(b,{className:`size-4 text-muted-foreground`})]}),Oe?(0,G.jsx)(ll,{projectId:X.currentToolProject.id,currentBranch:we.branch,dirtyCount:we.counts?.total??0,onCheckout:$t,onCreated:en,onOpenGraph:()=>{ke(!1),Fe(!0)},onOpenChanges:()=>{ke(!1),Zt()}}):null]}):null,(0,G.jsxs)(`div`,{className:`relative shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(K,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:()=>M.setConversationMenuOpen(e=>!e),disabled:!X.currentSessionId||L,"aria-label":U(`moreOptions`),"aria-expanded":M.conversationMenuOpen,children:(0,G.jsx)(R,{className:`size-[18px]`})}),M.conversationMenuOpen?(0,G.jsxs)(`div`,{className:`absolute left-0 top-8 z-30 min-w-44 rounded-lg border border-border bg-popover p-1 shadow-quickforge`,children:[(0,G.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:Qn,children:[Rn?(0,G.jsx)(fe,{className:`size-[18px]`}):(0,G.jsx)(r,{className:`size-[18px]`}),(0,G.jsx)(`span`,{children:U(Rn?`unpinSession`:`pinSession`)})]}),(0,G.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:$n,children:[(0,G.jsx)(x,{className:`size-[18px]`}),(0,G.jsx)(`span`,{children:U(`renameSession`)})]}),(0,G.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:er,children:[(0,G.jsx)(P,{className:`size-[18px]`}),(0,G.jsx)(`span`,{children:U(`shareSession`)})]})]}):null]})]})})]}),(0,G.jsxs)(`section`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[Ye&&Ye===X.loadingSessionId?(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center bg-background/55 backdrop-blur-[1px]`,role:`status`,"aria-live":`polite`,"aria-label":U(`loadingConversation`),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground/72`,children:[(0,G.jsx)(n,{className:`size-4 animate-spin`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:U(`loadingConversation`)})]})}):null,L?(0,G.jsx)(Bn,{onAddModel:An,onUseExample:()=>{Nn().catch(e=>V.error(`Failed to use LiteLLM example:`,e))}}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:W(`flex min-h-0 flex-1 flex-col`,qn?`quickforge-empty-chat`:void 0),children:[qn?(0,G.jsx)(`div`,{className:`quickforge-empty-chat-hero`,"aria-hidden":`true`,children:(0,G.jsx)(`h1`,{className:`quickforge-empty-chat-title`,children:U(`newChatEmptyTitle`)})}):null,(0,G.jsx)(ht,{children:(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(au,{}),children:(0,G.jsx)(Gl,{agent:X.agent,onModelSelect:Pn,revision:X.chatPanelRevision,agentAccessMode:A,workspaceToolsEnabled:!!X.currentToolProject?.id,project:X.currentToolProject,projectId:X.currentToolProject?.id,chatScope:X.chatScope,onAccessModeChange:_n,onRollbackFromMessage:fn,onRetryFromMessage:pn,onCopyAnswer:mn,onForkFromMessage:hn,onApproveToolCall:vn,onRejectToolCall:yn,onApproveAutoCompact:bn,onRejectAutoCompact:xn,onOpenWorkspaceGitChanges:Zt,onOpenLocalFilePath:nn,onArtifactsChange:e=>{he({projectId:X.currentToolProject?.id,sessionId:X.currentSessionId,artifacts:e})},onContextUsageDisplayChange:jt,disableFork:!1,restoredDraft:z,onRestoredDraftConsumed:Jt,newChatEmptyState:qn})})}),qn?(0,G.jsx)(Hn,{projects:d,selectedProject:X.currentToolProject,chatScope:X.chatScope,onSelectProject:Jn,onClearProject:Yn,onNewProject:Xn}):null]}),Zn?(0,G.jsx)(zn,{hasProject:!!X.currentToolProject?.id,onConfigureModel:An,onAddProject:y,onCopyExamplePrompt:Kn,onDismiss:Gn}):null]})]}),se&&X.currentToolProject?.id?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(au,{}),children:(0,G.jsx)(Jl,{project:X.currentToolProject,pendingCommand:ae,onPendingCommandHandled:Wn,onCollapse:()=>ue(!1)})}):null]}),X.currentToolProject?.id?(0,G.jsxs)(G.Fragment,{children:[M.workspaceInspectorOpen?(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`hidden w-px shrink-0 bg-[color-mix(in_oklab,var(--border)_30%,var(--quickforge-sidebar-bg))] lg:block`}):null,(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(ou,{}),children:(0,G.jsx)(ql,{project:X.currentToolProject,open:M.workspaceInspectorOpen,onOpenChange:M.setWorkspaceInspectorOpen,onOpenCommitPush:()=>Ne(!0),onOpenProjectInExplorer:ur,onOpenProjectInVSCode:dr,onOpenProjectInIDEA:fr,onPreviewArtifact:rn,request:M.workspaceInspectorRequest,onRequestHandled:Xt,artifacts:me.projectId===X.currentToolProject.id&&me.sessionId===X.currentSessionId?me.artifacts:[],globalTerminalOpen:se,onShowGlobalTerminal:()=>{N(!1),ue(!0)},onFullscreenChange:pe},X.currentToolProject.id)})]}):null,Pe&&X.currentToolProject?.id?(0,G.jsx)(Sl,{projectId:X.currentToolProject.id,projectName:X.currentToolProject.name,onClose:()=>Fe(!1)}):null,Me?(0,G.jsx)(hl,{open:!0,projectId:X.currentToolProject?.id,status:we,onClose:()=>Ne(!1),onCheckout:$t,onRefreshStatus:Qt,onStatusChange:Te,onCompleted:tn},X.currentToolProject?.id??`git-commit`):null]}),(0,G.jsx)(_t,{open:h,initialPath:c?.path,disabled:m,onOpenChange:S,onSelect:v}),(0,G.jsx)(He,{open:!!M.skillsDialog,scope:M.skillsDialog?.scope??`global`,project:M.skillsDialog?.project,onOpenChange:e=>{e||M.setSkillsDialog(void 0)},onSaved:xr}),(0,G.jsx)(Nl,{open:M.shareDialogOpen,sessionId:X.currentSessionId,title:Mt(X.currentTitle),onOpenChange:M.setShareDialogOpen}),(0,G.jsx)(zc,{toasts:Ze,onDismiss:et,onClick:qt})]})}function hu(){let e=window.location.pathname.match(/^\/share\/([^/]+)\/?$/)?.[1];return e?(0,G.jsx)(H.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-background text-sm text-muted-foreground`,children:U(`loadingChatWorkspace`)}),children:(0,G.jsx)(Kl,{shareId:decodeURIComponent(e)})}):(0,G.jsx)(mu,{})}dt({hideSelector:!0}),pt(),window.addEventListener(`error`,e=>{V.error(`Uncaught error:`,e.error??e.message)}),window.addEventListener(`unhandledrejection`,e=>{V.error(`Unhandled promise rejection:`,e.reason)}),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`).catch(()=>{})}),(0,Ue.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(H.StrictMode,{children:(0,G.jsx)(m,{strokeWidth:1.75,children:(0,G.jsx)(ht,{children:(0,G.jsx)(hu,{})})})}));export{Ta as $,Ps as A,$ as B,ic as C,K as Ct,Zs as D,nt as Dt,Ys as E,tt as Et,zs as F,Xo as G,Yo as H,Us as I,Po as J,Io as K,Ds as L,Is as M,Ls as N,Ns as O,U as Ot,Vs as P,no as Q,Os as R,ec as S,Ct as St,Js as T,it as Tt,Qo as U,us as V,Zo as W,Ja as X,zo as Y,Ba as Z,Yc as _,$t as _t,Bl as a,Rn as at,wc as b,kt as bt,jl as c,gn as ct,Wc as d,Zt as dt,Oi as et,Uc as f,sn as ft,Xc as g,Wt as gt,$c as h,cn as ht,Ul as i,Z as it,Bs as j,Ms as k,Jc as l,hn as lt,el as m,en as mt,Fl as n,Or as nt,Al as o,_n as ot,Kc as p,Yt as pt,Ro as q,Rl as r,kr as rt,Ml as s,vn as st,Pl as t,Ir as tt,qc as u,Rt as ut,Qc as v,Mt as vt,ac as w,W as wt,vc as x,Et as xt,Zc as y,q as yt,ks as z};
|