pisper 0.6.27 → 0.6.28
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/package.json +6 -6
- package/web/.vite/manifest.json +825 -665
- package/web/assets/{AppDialog-BSwETcOe.js → AppDialog-Cjnspn8J.js} +1 -1
- package/web/assets/{AppOverlays-_EStnaiK.js → AppOverlays-ielr5J2J.js} +1 -1
- package/web/assets/AssetsPage-BC1mYvQw.js +1 -0
- package/web/assets/BoardPage-BS3oBeRU.js +3 -0
- package/web/assets/{ChannelsPage-BlTQXqjl.js → ChannelsPage-DOysYIcY.js} +1 -1
- package/web/assets/{ChatAppearancePage-DzAq4wj8.js → ChatAppearancePage-DqNJD2hC.js} +1 -1
- package/web/assets/{ChatHistoryPage-B4v3MEb8.js → ChatHistoryPage-DcTFMdWO.js} +1 -1
- package/web/assets/ChatPage-DaKslieG.js +553 -0
- package/web/assets/ConfigPage-Cg93xSDY.js +7 -0
- package/web/assets/{DesktopWindowControls-gaFTmZN5.js → DesktopWindowControls-Zz88RwFF.js} +1 -1
- package/web/assets/{FeaturePage-IWVjXcVp.js → FeaturePage-bqByIxYg.js} +1 -1
- package/web/assets/{FileAttachmentPreview-DxwMjwfS.js → FileAttachmentPreview-Dc92kq62.js} +1 -1
- package/web/assets/{FloatingWidgets-D8VLtEFT.js → FloatingWidgets-CwJuWUMz.js} +1 -1
- package/web/assets/FocusRuntimeControls-huHLWDdy.js +1 -0
- package/web/assets/{GitDiffViewer-CEMK-4P4.js → GitDiffViewer-b4QqrnGx.js} +1 -1
- package/web/assets/{ManageProjectsDialog-BxB9J7IY.js → ManageProjectsDialog-DpwUwosB.js} +1 -1
- package/web/assets/{MarkdownMessage-gnw-y810.js → MarkdownMessage-BEmTlPSn.js} +1 -1
- package/web/assets/McpPage-COTq4Jjj.js +1 -0
- package/web/assets/{MemoryEvolution-DG9gtC6n.js → MemoryEvolution-CNi44VEB.js} +1 -1
- package/web/assets/MemoryPage-fUDrPE_v.js +2 -0
- package/web/assets/{MobileNavigation-Chysgboq.js → MobileNavigation-BvCRGO5c.js} +1 -1
- package/web/assets/MorePage-BuKQ5rBF.js +1 -0
- package/web/assets/NewFolderDialog-Btk5x-Ar.js +1 -0
- package/web/assets/{PageHeader-DK5D_R5_.js → PageHeader-BjhZ50ed.js} +1 -1
- package/web/assets/{PhoneDrawer-BbjnEawt.js → PhoneDrawer-Cs-ka4ZZ.js} +1 -1
- package/web/assets/{PhoneMenuButton-mlilY9bo.js → PhoneMenuButton-CTlyYTpl.js} +1 -1
- package/web/assets/{PhoneTopBar-CEnUC7MQ.js → PhoneTopBar-Cx2DM1ne.js} +1 -1
- package/web/assets/PluginsPage-B9Xlbo-c.js +1 -0
- package/web/assets/{SafeModePrompt-CalnTUf0.js → SafeModePrompt-BCrBZdI6.js} +1 -1
- package/web/assets/{SchedulesPage-CgHGU15C.js → SchedulesPage-Eh7MyRAr.js} +1 -1
- package/web/assets/SessionBrowserPane-Zeec5cZP.js +2 -0
- package/web/assets/SessionContextPanel-CVKmX-do.js +2 -0
- package/web/assets/{SessionHome-DVWSDkiq.js → SessionHome-CJR_Ufgl.js} +1 -1
- package/web/assets/SessionInspector-D5tmy63H.js +1 -0
- package/web/assets/{SessionShell-McHYcUMD.js → SessionShell-w3sKK33I.js} +1 -1
- package/web/assets/{SettingsSidebar-B6B_0bT6.js → SettingsSidebar-CseRAdbZ.js} +1 -1
- package/web/assets/{ShortcutHelpDialog-BuPN71vl.js → ShortcutHelpDialog-R4Gx-9DQ.js} +1 -1
- package/web/assets/{ShortcutKeys-DNpsGYcw.js → ShortcutKeys-DksC1OkE.js} +1 -1
- package/web/assets/{SidebarUpdateStatus-B9E-HRrS.js → SidebarUpdateStatus-BCd1eq_6.js} +1 -1
- package/web/assets/{SkillsPage-Ffz15Nmx.js → SkillsPage-Bn2y_EfT.js} +1 -1
- package/web/assets/{TaskProcessesPane-ML4UTyA9.js → TaskProcessesPane-FwGhuWob.js} +1 -1
- package/web/assets/{TaskTerminalView-CEWghfPZ.js → TaskTerminalView-Cd4PIsW7.js} +1 -1
- package/web/assets/{TerminalPanel-Dq1eeEaE.js → TerminalPanel-48zgvDnP.js} +1 -1
- package/web/assets/{WebDesktopPet-C5oPRBKd.js → WebDesktopPet-gSDBRZ3C.js} +1 -1
- package/web/assets/WorkflowsPage-Cs8PPuKK.js +1 -0
- package/web/assets/{WorkspacePicker-CZP9fnUA.js → WorkspacePicker-93gmdtjf.js} +1 -1
- package/web/assets/{alert-firawb0H.js → alert-DRIrgNI4.js} +1 -1
- package/web/assets/api-AeFmYDtL.js +1 -0
- package/web/assets/{app-update-HRbiPDT4.js → app-update-Cf9JJ7WK.js} +1 -1
- package/web/assets/{approval-confirm-C0RA-dqX.js → approval-confirm-D-cfu-xY.js} +1 -1
- package/web/assets/board-messages-D6AWGHuF.js +1 -0
- package/web/assets/board-projects-CjfuDvHx.js +1 -0
- package/web/assets/bots-store-vErH7x9u.js +1 -0
- package/web/assets/chat-api-CSAs7Y6E.js +1 -0
- package/web/assets/{client-store-DvE_NEoR.js → client-store-B5wZ2IWH.js} +1 -1
- package/web/assets/{config-search-Cr0TsTRS.js → config-search-eh2zQyZD.js} +1 -1
- package/web/assets/desktop-hosts-BNXtrr7R.js +191 -0
- package/web/assets/{dialog-9LXtFD-0.js → dialog-BDNbY1pW.js} +1 -1
- package/web/assets/event-stream-Dh7h5sXJ.js +2 -0
- package/web/assets/{events-oPlZB-qC.js → events-CuVwhRWu.js} +1 -1
- package/web/assets/{focus-session-composer-bits-VRvsf-4b.js → focus-session-composer-bits-Dkc0qSzm.js} +1 -1
- package/web/assets/folder-paths-BKS24lJ6.js +1 -0
- package/web/assets/{hosts-5EeWX76B.js → hosts-B_02vF1S.js} +1 -1
- package/web/assets/http-Bp65Kb4t.js +2 -0
- package/web/assets/http-response-PZN5QIRk.js +1 -0
- package/web/assets/i18n-D80GstlU.js +1 -0
- package/web/assets/index-BnQCk-QI.css +2 -0
- package/web/assets/{index-rOrQSojS.js → index-CiRnxTh1.js} +2 -2
- package/web/assets/machine-messages-Y3INM-Uy.js +1 -0
- package/web/assets/machines-api-08M8wQiu.js +1 -0
- package/web/assets/{memory-api-sER80Rta.js → memory-api-DSpQSQ5N.js} +1 -1
- package/web/assets/mount-app-DRohHSG7.js +9 -0
- package/web/assets/{mutation-CEbxdVYy.js → mutation-b4pPvB7p.js} +1 -1
- package/web/assets/{palette-navigation-HbVGltCo.js → palette-navigation-C8WTTMd3.js} +1 -1
- package/web/assets/permission-rules-api-D931wxo9.js +1 -0
- package/web/assets/{pick-system-directory-CWhZCX6d.js → pick-system-directory-CaiscVfr.js} +1 -1
- package/web/assets/placements-BERPVxJD.js +2 -0
- package/web/assets/{popover-DlJP3VbH.js → popover-BKgOyW2Z.js} +1 -1
- package/web/assets/public-CEKKZh7R.js +2 -0
- package/web/assets/{public-D4ziZ0_l.js → public-CwI1S0by.js} +1 -1
- package/web/assets/{public-Pwc0VWsG.js → public-D9GopZqN.js} +2 -2
- package/web/assets/{web-preview-DIo7zGil.js → public-DrlrVRdl.js} +1 -1
- package/web/assets/{public-components-DzeaQBwj.js → public-components-BX9oxLC6.js} +1 -1
- package/web/assets/public-diff-DpNMZ8NJ.js +1 -0
- package/web/assets/public-events-CLCgth5h.js +1 -0
- package/web/assets/public-flags-DaG3PoAy.js +1 -0
- package/web/assets/public-folder-dialog-_QoxpOd4.js +1 -0
- package/web/assets/{public-greeting-BTftKeXA.js → public-greeting-hvhJuZMw.js} +1 -1
- package/web/assets/{public-session-BQEMyJz3.js → public-session-DUzugr9Y.js} +1 -1
- package/web/assets/{public-sidebar-TnRh2L95.js → public-sidebar-QGIKY-SE.js} +1 -1
- package/web/assets/query-DFQayLF5.js +1 -0
- package/web/assets/runtime-capabilities-B7qveLBm.js +1 -0
- package/web/assets/{runtime-capabilities-store-SnV1V9_K.js → runtime-capabilities-store-Bd3gWIM7.js} +1 -1
- package/web/assets/{safe-mode-instance-D5jkqqdG.js → safe-mode-instance-B7_JMLGQ.js} +1 -1
- package/web/assets/safe-mode-sentinel-B_NPQ0qy.js +1 -0
- package/web/assets/{session-change-summary-api-orjhsMHB.js → session-change-summary-api-BHpd8dcW.js} +1 -1
- package/web/assets/{session-home-CwRaSks0.js → session-home-BmAnhROp.js} +1 -1
- package/web/assets/session-inspector-store-DHEIlh_X.js +1 -0
- package/web/assets/{session-organization-api-BbD_xU9l.js → session-organization-api-D9hTSIh7.js} +1 -1
- package/web/assets/session-scope-yI3Hi_8F.js +1 -0
- package/web/assets/{session-tree-actions-wrMgK5VF.js → session-tree-actions-BhCOaiTd.js} +1 -1
- package/web/assets/{session-tree-summary-BO-Oz0d-.js → session-tree-summary-BLv-bkYC.js} +1 -1
- package/web/assets/session-web-preview-guvsmkWE.js +1 -0
- package/web/assets/session-workspaces-Brm-8lHh.js +1 -0
- package/web/assets/{settings-navigation-DiP_AM1C.js → settings-navigation-C6_RpGgI.js} +1 -1
- package/web/assets/{shortcuts-BmJZiLby.js → shortcuts-Dsd4mjfP.js} +1 -1
- package/web/assets/side-chat-context-scyCH7W7.js +7 -0
- package/web/assets/{sidebar-COyrGoC_.js → sidebar-BKgF_JcM.js} +1 -1
- package/web/assets/{sidebar-store-CRsJYE3n.js → sidebar-store-DHwAOBnN.js} +1 -1
- package/web/assets/{speech-session-BUTlvobj.js → speech-session-B7DFYRtL.js} +1 -1
- package/web/assets/{startup-queries-Cz_Djz3X.js → startup-queries-BlA4Hayt.js} +1 -1
- package/web/assets/tool-labels-D-3gybP7.js +1 -0
- package/web/assets/{use-i18n-CaxKosZm.js → use-i18n-BVRhlQ1v.js} +1 -1
- package/web/assets/{use-open-bot-BcuoHEet.js → use-open-bot-DyXtOatN.js} +1 -1
- package/web/assets/{use-studio-actions-D0_lMh6m.js → use-studio-actions-DEeR_rS9.js} +1 -1
- package/web/assets/{useCatalogProjects-B10EehnV.js → useCatalogProjects-BD5GyCxg.js} +1 -1
- package/web/assets/useMachines-CwX7YqNe.js +1 -0
- package/web/assets/useNativeBrowser-C0j3zafh.js +1 -0
- package/web/assets/useNewProjectPicker-COxPJj6n.js +2 -0
- package/web/assets/{useNow-BZ7RxPrw.js → useNow-CfPk0uIz.js} +1 -1
- package/web/assets/{usePhoneShell-0IX6-LbH.js → usePhoneShell-BpuKJgci.js} +1 -1
- package/web/assets/{useQuery-DdcpUQhO.js → useQuery-DfOU-27z.js} +1 -1
- package/web/assets/useSessionListQuery-CURESPBn.js +2 -0
- package/web/assets/{useSessionRowActions-DCeaGwuL.js → useSessionRowActions-DoCwFh8w.js} +1 -1
- package/web/assets/{useSidebarModel-DNcSN-4f.js → useSidebarModel-CY79-mYl.js} +1 -1
- package/web/assets/web-preview-C7DdG9JP.js +1 -0
- package/web/assets/{web-preview-events-BvZrLClr.js → web-preview-events-D7F0Z-Hy.js} +1 -1
- package/web/assets/{workspace-order-store-BYpf9Z59.js → workspace-order-store-C-jYrC0l.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/AssetsPage-V8CwPJ-g.js +0 -1
- package/web/assets/BoardPage-CeCxAAr2.js +0 -3
- package/web/assets/ChatPage-D8Etebyo.js +0 -553
- package/web/assets/ConfigPage-Dgp9JPFH.js +0 -5
- package/web/assets/FocusRuntimeControls-DLdIWv0j.js +0 -1
- package/web/assets/McpPage-C0czFuy7.js +0 -1
- package/web/assets/MemoryPage-CGpPJtAj.js +0 -2
- package/web/assets/MorePage-CxS1EaML.js +0 -1
- package/web/assets/NewFolderDialog-Dgo2ZRmr.js +0 -1
- package/web/assets/PluginsPage-CcrK4yJY.js +0 -1
- package/web/assets/SessionBrowserPane-BISoBe8t.js +0 -2
- package/web/assets/SessionContextPanel-C9F4h-Qa.js +0 -2
- package/web/assets/SessionInspector-BUBN0O36.js +0 -1
- package/web/assets/WorkflowsPage-BSlpEhf2.js +0 -1
- package/web/assets/api-MVoWVwmh.js +0 -3
- package/web/assets/board-messages-BptuVfY-.js +0 -1
- package/web/assets/board-projects-DF-0RkuW.js +0 -1
- package/web/assets/bots-store-BmFj9w2F.js +0 -1
- package/web/assets/chat-api-D9RzUTQi.js +0 -1
- package/web/assets/folder-paths-DlIGURu0.js +0 -1
- package/web/assets/i18n-Cl3sIF9G.js +0 -1
- package/web/assets/index-l96Dl6z6.css +0 -2
- package/web/assets/mount-app-COPez7JX.js +0 -9
- package/web/assets/permission-rules-api-M-EIynsN.js +0 -1
- package/web/assets/placements-BDYSXHzl.js +0 -2
- package/web/assets/public-BDWkdvCh.js +0 -1
- package/web/assets/public-diff-C6x0INNk.js +0 -1
- package/web/assets/public-events-BXREjvNl.js +0 -1
- package/web/assets/public-flags-Dvf3q-4D.js +0 -1
- package/web/assets/query-Bj-DUNYq.js +0 -1
- package/web/assets/runtime-capabilities-CHYOF_hE.js +0 -1
- package/web/assets/safe-mode-sentinel-B3v6JZTG.js +0 -1
- package/web/assets/session-scope-CFKKqbrz.js +0 -1
- package/web/assets/session-workspaces-Csgpuzxd.js +0 -1
- package/web/assets/side-chat-context-DhztplBz.js +0 -7
- package/web/assets/tool-labels-Bexnwp5q.js +0 -1
- package/web/assets/useNewProjectPicker-CD-xwRhH.js +0 -2
- package/web/assets/useSessionListQuery-DXeYJTOA.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,n,r}from"./vendor-react-DwNgTV1j.js";import{d as i,u as a}from"./i18n-Cl3sIF9G.js";import{t as o}from"./use-i18n-CaxKosZm.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./braces-DQcXLGFF.js";import{t as l}from"./check-2vYc6QaP.js";import{t as u}from"./chevron-right-C3t2Rckj.js";import{t as d}from"./chevrons-up-down-C2sEPdAh.js";import{i as f}from"./focus-session-composer-bits-VRvsf-4b.js";import{t as p}from"./search-D0mqDaf_.js";import{i as m,t as h}from"./dist-41X0pdUs.js";import{c as g,n as _}from"./dist-BsRXXcSL.js";import{a as v,o as y,r as b,t as x}from"./dist-BHkR6BLP.js";import{i as S,n as C,t as w}from"./popover-DlJP3VbH.js";import{t as T}from"./slider-De8rWVNs.js";import{t as E}from"./utils-C8uzG5AZ.js";import{n as D,o as O,r as k,t as A}from"./sheet-BTaIEX4w.js";import{r as j}from"./format-DMJQzoZ7.js";import{i as M}from"./run-activity-CwfO0cui.js";import"./dialog-9LXtFD-0.js";import{n as N,t as P}from"./input-group-h8z63MzW.js";import{t as F}from"./model-display-kDwvtxrW.js";var I=s(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),L=s(`square-slash`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),R=e(t(),1);function ee(e){let t=e.match(/^\/btw(?:\s+([\s\S]*))?$/);return t?(t[1]||``).trim():null}function z(e,t,n,r){return n.length?[{invocation:`/${e}`,description:t},...n.map(t=>({invocation:`/${e} ${t.value}`,description:t.label,current:t.current,run:()=>r(t.value)}))]:[]}function te({t:e,models:t,model:n,onModel:r,thinkingLevels:i,thinkingLevel:a,thinkingLabel:o,onThinking:s,executionModes:c,executionMode:l,executionLabel:u,onExecutionMode:d,runModes:f,runMode:p,runModeLabel:m,onRunMode:h}){return[...z(`model`,e(`chat:commands.builtin.model`),t.map(e=>({value:e.key,label:e.providerName?`${e.label} · ${e.providerName}`:e.label,current:e.key===n})),r),...z(`effort`,e(`chat:commands.builtin.effort`),i.map(e=>({value:e,label:o(e),current:e===a})),s),...z(`approval`,e(`chat:commands.builtin.approval`),c.map(e=>({value:e,label:u(e),current:e===l})),d),...f.length>1?z(`run`,e(`chat:commands.builtin.run`),f.map(e=>({value:e,label:m(e),current:e===p})),h):[]]}function ne(e,t,n){let r=e=>e.toLocaleLowerCase(n),i=r(t),a=i.search(/\s/);if(a<0)return e.filter(e=>!e.invocation.includes(` `)&&r(`${e.invocation} ${e.description}`).includes(i));let o=`/${i.slice(0,a)} `,s=i.slice(a).trim();return e.filter(e=>r(e.invocation).startsWith(o)&&r(`${e.invocation} ${e.description}`).includes(s))}var re=10485760,ie=20971520,ae=new Set([`txt`,`md`,`json`,`js`,`jsx`,`ts`,`tsx`,`css`,`html`,`xml`,`yaml`,`yml`,`csv`,`log`,`py`,`java`,`go`,`rs`,`sh`,`ps1`,`toml`,`sql`]),oe=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),se=new Set([`pdf`,`docx`,`pptx`,`xlsx`,`odt`,`odp`,`ods`,`rtf`,`epub`]),ce=[`image/*`,`text/*`,`application/json`,...[...oe,...ae,...se].map(e=>`.${e}`)].join(`,`);function le(e){let t=[...e?.files||[]];return t.length?t:[...e?.items||[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile?.()).filter(e=>!!e)}function ue(e){return[...e?.types||[]].includes(`Files`)}function de(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(String(i.result).split(`,`)[1]||``),i.onerror=()=>r(i.error||Error(t(`chat:attachments.couldNotReadFile`))),i.readAsDataURL(e)})}function fe(e){return e.toLowerCase().split(`.`).at(-1)||``}async function pe(e,t){let n=[...e].slice(0,8),r=[];for(let e of n){if(e.size>re)throw Error(t(`chat:attachments.nameExceedsThe10MBLimit`,{name:e.name}));let n=fe(e.name),i={id:`${e.name}-${e.lastModified}-${e.size}`,name:e.name,mimeType:e.type||`application/octet-stream`,size:e.size};if(e.type.startsWith(`image/`)||oe.has(n))r.push({...i,kind:`image`,data:await de(e,t)});else if(e.type.startsWith(`text/`)||e.type===`application/json`||ae.has(n))r.push({...i,kind:`text`,text:await e.text()});else if(se.has(n))r.push({...i,kind:`document`,extension:n,data:await de(e,t)});else throw Error(t(`chat:attachments.nameIsNotSupportedChooseAnImageOrTextCodeFile`,{name:e.name}))}return r}function me(e){return e.split(/[\\/]/).filter(Boolean).at(-1)||e}function he(e){return[...e].map(e=>String(e||``).trim()).filter(Boolean).slice(0,8).map(e=>({id:`path:${e}`,kind:`path`,name:me(e),path:e}))}function ge(e=[],t,n){let r=(0,R.useCallback)((e,t)=>i(e,a(),t),[]),[o,s]=(0,R.useState)(()=>[...e]),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)([]),f=(0,R.useRef)(new Map),p=(0,R.useRef)(0),m=(0,R.useRef)(n);m.current=n,(0,R.useEffect)(()=>{let e=f.current;return d([]),l(``),()=>{for(let t of e.values())t.cancelled=!0;e.clear()}},[n]);let h=(0,R.useRef)([...e]),g=(0,R.useCallback)(e=>{h.current=e,s(e),t?.(e)},[t]),_=(0,R.useCallback)(async e=>{let t=n,i=[...e||[]].slice(0,8).map(e=>{let t=`preparing-${++p.current}`,n={name:e.name,cancelled:!1};return f.current.set(t,n),{id:t,job:n,file:e}}),a=()=>d([...f.current].map(([e,t])=>({id:e,name:t.name})));a(),l(``);let o=!1;for(let{id:e,job:n,file:s}of i)try{let i=await pe([s],r);if(n.cancelled||m.current!==t||!f.current.has(e))continue;let a=[...h.current,...i].slice(0,8);if(a.filter(e=>e.kind!==`path`).reduce((e,t)=>e+(t.size||0),0)>ie)throw Error(r(`chat:attachments.totalAttachmentSizeCannotExceed20MB`));g(a),o=!0}catch(e){!n.cancelled&&m.current===t&&l(e instanceof Error?e.message:String(e))}finally{f.current.delete(e),m.current===t&&a()}return o},[n,g,r]);return{attachments:o,attachmentError:c,preparingAttachments:u,addFiles:_,pasteFiles:(0,R.useCallback)(e=>{let t=le(e.clipboardData);t.length&&(e.preventDefault(),_(t))},[_]),dropFiles:(0,R.useCallback)(e=>{if(!ue(e.dataTransfer))return;e.preventDefault();let t=le(e.dataTransfer);t.length&&_(t)},[_]),removeAttachment:(0,R.useCallback)(e=>{let t=f.current.get(e);if(t){t.cancelled=!0,f.current.delete(e),d([...f.current].map(([e,t])=>({id:e,name:t.name})));return}g(h.current.filter(t=>t.id!==e))},[g]),clearAttachments:(0,R.useCallback)(()=>{for(let e of f.current.values())e.cancelled=!0;f.current.clear(),d([]),g([])},[g]),addAttachments:(0,R.useCallback)(e=>{if(m.current!==n)return;l(``);let t=[...h.current];for(let n of e)t.some(e=>e.id===n.id)||t.push(n);g(t.slice(0,8))},[n,g]),replaceAttachments:g,setError:(0,R.useCallback)(e=>{l(e instanceof Error?e.message:String(e||``))},[])}}var _e=`new-task`,B=new Map,V=new Map;function ve(e,t){let n=t.match(/^\/[^\s]*(?:\s+([\s\S]*))?$/),r=(n?n[1]||``:t).trim();return`${e}${r?` ${r}`:` `}`}function ye(e){return{text:e?.text||``,attachments:[...e?.attachments||[]]}}function H(e){return ye(B.get(e))}function U(e,t){if(!e)return;let n={...H(e),...t};n.attachments=[...n.attachments];let r=H(e);r.text===n.text&&r.attachments.length===n.attachments.length&&r.attachments.every((e,t)=>e===n.attachments[t])||(r.text!==n.text&&V.set(e,(V.get(e)||0)+1),B.delete(e),!(!n.text&&!n.attachments.length)&&B.set(e,n))}function be(e){V.set(e,(V.get(e)||0)+1),B.delete(e)}function xe(e,t){let n=[...e.attachments],r=new Set(n.map(e=>e.id));for(let e of t.attachments){let t=e.id;if(!t||r.has(t)){let n=1;do t=`${e.id||`attachment`}-restored-${n++}`;while(r.has(t))}r.add(t),n.push({...e,id:t})}return{text:e.text&&t.text?`${e.text}\n${t.text}`:e.text||t.text,attachments:n}}function Se(e){let t=(0,R.useRef)(e);t.current=e;let n=(0,R.useRef)(!0);(0,R.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);let r=(0,R.useRef)(H(e)),[i,a]=(0,R.useState)(r.current.text),o=(0,R.useCallback)(t=>U(e,{attachments:t}),[e]),s=ge(r.current.attachments,o,e),c=s.replaceAttachments,l=s.clearAttachments;return(0,R.useEffect)(()=>{let t=H(e);a(t.text),c(t.attachments)},[c,e]),{value:i,updateValue:(0,R.useCallback)(t=>{a(t),U(e,{text:t})},[e]),selection:s,clearDraft:(0,R.useCallback)(()=>{let r=H(e);r.text!==i||r.attachments.length!==s.attachments.length||r.attachments.some((e,t)=>e!==s.attachments[t])||(be(e),!(!n.current||t.current!==e)&&(a(``),l()))},[l,s.attachments,e,i]),restoreDraft:(0,R.useCallback)(r=>{let i=xe(H(e),r);return U(e,i),!n.current||t.current!==e?!1:(a(i.text),c(i.attachments),!0)},[c,e]),captureSubmission:(0,R.useCallback)(()=>{let r=H(e),i=V.get(e)||0,o=!1;return{accept(){if(o)return;o=!0;let s=H(e),l={text:(V.get(e)||0)===i?``:s.text,attachments:s.attachments.filter(e=>!r.attachments.includes(e))};U(e,l),!(!n.current||t.current!==e)&&(a(l.text),c(l.attachments))}}},[c,e])}}var Ce=e(n(),1);function we({anchor:e,menu:t,viewport:n,placement:r=`top`,align:i=`start`,maxHeight:a=1/0}){let o=n.top+8,s=Math.max(o,n.top+n.height-8),c=n.left+8,l=Math.max(c,n.left+n.width-8),u={top:Math.max(0,Math.min(e.top,s)-o-8),bottom:Math.max(0,s-Math.max(e.bottom,o)-8)},d=Math.min(t.height,a),f=r===`top`?`bottom`:`top`,p=d>u[r]&&u[f]>u[r]?f:r,m=Math.min(a,u[p]),h=Math.min(d,m),g=Math.min(t.width,l-c);return{side:p,left:Math.max(c,Math.min(i===`end`?e.right-g:e.left,l-g)),top:Math.max(o,Math.min(p===`top`?e.top-8-h:e.bottom+8,s-h)),width:g,maxHeight:m}}var W=r();function Te({open:e,anchorRef:t,menuRef:n,placement:r=`top`,align:i=`start`,matchAnchorWidth:a=!1,maxHeight:o,id:s,className:c,role:l,ariaLabel:u,onClose:d,children:f}){return(0,R.useEffect)(()=>{if(!e||!d)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),d())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,d]),(0,R.useLayoutEffect)(()=>{if(!e)return;let s=()=>{let e=n.current,s=t.current;if(!e||!s)return;let c=s.getBoundingClientRect(),l=window.visualViewport;e.style.width=a?`${c.width}px`:``;let u=we({anchor:c,menu:{width:e.getBoundingClientRect().width,height:e.scrollHeight},viewport:{left:l?.offsetLeft??0,top:l?.offsetTop??0,width:l?.width??window.innerWidth,height:l?.height??window.innerHeight},placement:r,align:i,maxHeight:o});e.dataset.side=u.side,e.style.maxHeight=`${u.maxHeight}px`,e.style.overflowY=`auto`,e.style.width=`${u.width}px`,e.style.top=`${u.top}px`,e.style.bottom=`auto`,e.style.right=`auto`,e.style.left=`${u.left}px`};s();let c=null,l=()=>{c===null&&(c=window.requestAnimationFrame(()=>{c=null,s()}))},u=typeof ResizeObserver>`u`?null:new ResizeObserver(l);return n.current&&u?.observe(n.current),t.current&&u?.observe(t.current),window.addEventListener(`resize`,s),window.addEventListener(`scroll`,s,!0),window.visualViewport?.addEventListener(`resize`,l),window.visualViewport?.addEventListener(`scroll`,l),()=>{u?.disconnect(),c!==null&&window.cancelAnimationFrame(c),window.removeEventListener(`resize`,s),window.removeEventListener(`scroll`,s,!0),window.visualViewport?.removeEventListener(`resize`,l),window.visualViewport?.removeEventListener(`scroll`,l)}},[e,t,n,r,i,a,o]),e?(0,Ce.createPortal)((0,W.jsx)(`div`,{ref:n,id:s,className:c,style:{position:`fixed`,zIndex:65},role:l,"aria-label":u,children:f}),document.body):null}function Ee({resourceKey:e,loadCommands:t,builtinCommands:n=[],value:r,onChange:i,inputRef:a,placement:s=`top`}){let{t:u,language:d}=o(),f=(0,R.useId)(),p=(0,R.useRef)(null),m=r.match(/^\/([^\n]{0,120})$/),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(null),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(0),T=m?.[1]||``,E=/\s/.test(T),D=(0,R.useRef)(t);D.current=t;let O=(0,R.useMemo)(()=>ne(n,T,d),[n,d,T]),k=!!(m&&h!==r&&(!E||O.length));(0,R.useEffect)(()=>{g(``),v(null),S(!1)},[e]),(0,R.useEffect)(()=>{if(!k||_)return;let e=!0;return b(!0),S(!1),D.current().then(t=>{e&&v(t.commands||[])}).catch(()=>{e&&(v([]),S(!0))}).finally(()=>e&&b(!1)),()=>{e=!1}},[_,k,e]);let A=(0,R.useMemo)(()=>{let e=O.map(e=>({kind:`builtin`,command:e}));if(E)return e;let t=T.toLocaleLowerCase(d),n=(_||[]).filter(e=>!t||`${e.invocation} ${e.name} ${e.description}`.toLocaleLowerCase(d).includes(t));return[...e,...n.map(e=>({kind:`resource`,command:e}))]},[E,O,_,d,T]);(0,R.useEffect)(()=>{w(0)},[T,_]);let j=()=>{g(r)},M=e=>{if(e.kind===`builtin`){let t=e.command.run?``:`${e.command.invocation} `;i(t),g(``),w(0),e.command.run&&e.command.run(),requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(t.length,t.length))});return}let t=ve(e.command.invocation,r);i(t),g(t),requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(t.length,t.length),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})};(0,R.useEffect)(()=>{if(!k)return;let e=e=>{if(document.activeElement===a.current){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),j();return}A.length&&(e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),w(e=>(e+1)%A.length)):e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),w(e=>(e-1+A.length)%A.length)):(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),M(A[Math.min(C,A.length-1)])))}};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)}),(0,R.useEffect)(()=>{let e=a.current;if(!k||!e)return;let t={role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":`true`,"aria-controls":f,"aria-activedescendant":A.length?`${f}-${Math.min(C,A.length-1)}`:``},n=Object.keys(t).map(t=>[t,e.getAttribute(t)]);for(let[n,r]of Object.entries(t))r?e.setAttribute(n,r):e.removeAttribute(n);return()=>{for(let[t,r]of n)t&&(r===null?e.removeAttribute(t):e.setAttribute(t,r))}},[C,a,f,k,A.length]);let N={user:u(`chat:commands.scope.user`),project:u(`chat:commands.scope.project`),package:u(`chat:commands.scope.package`),custom:u(`chat:commands.scope.custom`)};return(0,W.jsx)(Te,{open:k,anchorRef:a,menuRef:p,placement:s,matchAnchorWidth:!0,maxHeight:330,id:f,role:`listbox`,ariaLabel:u(`chat:commands.open`),className:`permission-mode-menu composer-command-menu overflow-y-auto rounded-md bg-solid p-1 text-content shadow-float`,children:(0,W.jsxs)(`div`,{className:`chat-resource-list composer-command-list flex min-h-0 [flex:1_1_0] flex-col gap-px overflow-y-auto [overscroll-behavior:contain] [scrollbar-gutter:stable] [touch-action:pan-y] [&_>_button]:grid [&_>_button]:w-full [&_>_button]:cursor-pointer [&_>_button]:grid-cols-[28px_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-2 [&_>_button]:rounded-sm [&_>_button]:px-1.5 [&_>_button]:py-1 [&_>_button]:text-left [&_>_button]:text-content [&_>_button.active]:bg-surface-hover max-[650px]:[&_>_button]:min-h-11 [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_strong]:truncate [&_strong]:font-mono [&_strong]:text-[13px] [&_strong]:font-medium [&_small]:truncate [&_small]:font-sans [&_small]:text-xs [&_small]:font-normal [&_small]:text-content-muted [&_em]:text-xs [&_em]:whitespace-nowrap [&_em]:text-content-muted [&_em]:not-italic [&_>_p]:m-auto [&_>_p]:px-2 [&_>_p]:py-1.5 [&_>_p]:text-xs [&_>_p]:text-content-muted`,children:[A.map((e,t)=>{let{command:n}=e,r=e.kind===`builtin`?e.command.current?l:L:e.command.source===`prompt`?I:c,i=e.kind===`resource`?e.command:null;return(0,W.jsxs)(`button`,{type:`button`,role:`option`,id:`${f}-${t}`,"aria-selected":t===C,className:t===C?`active`:``,onMouseEnter:()=>w(t),onMouseDown:e=>e.preventDefault(),onClick:()=>M(e),children:[(0,W.jsx)(`span`,{className:`list-icon grid size-7 place-items-center rounded-sm bg-surface-muted text-content-secondary`,children:(0,W.jsx)(r,{size:15})}),(0,W.jsxs)(`span`,{className:`composer-command-copy`,children:[(0,W.jsxs)(`strong`,{children:[n.invocation,i?.argumentHint&&(0,W.jsxs)(`small`,{children:[` `,i.argumentHint]})]}),(0,W.jsx)(`small`,{children:n.description||u(`chat:commands.noDescription`)})]}),(0,W.jsx)(`em`,{children:i?(0,W.jsxs)(W.Fragment,{children:[i.source===`prompt`?u(`chat:commands.prompt`):u(`chat:commands.skill`),` · `,N[i.scope]]}):e.kind===`builtin`&&e.command.current?u(`chat:commands.builtin.current`):u(`chat:commands.builtin.label`)})]},`${e.kind}:${n.invocation}`)}),!A.length&&(0,W.jsx)(`p`,{children:u(y?`chat:commands.loading`:x?`chat:commands.loadError`:`chat:commands.empty`)})]})})}function De({levels:e,value:t,labelFor:n,onCommit:r,disabled:i=!1,ariaLabel:a,title:o,trailing:s,className:c}){let[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(!1),p=(0,R.useRef)(!1),m=Math.max(0,e.indexOf(t)),h=l??m,g=n(e[h]||t),_=i||d||e.length<2,v=e.join(`|`);(0,R.useEffect)(()=>{u(null)},[t,v]);let y=async n=>{let i=e[n];if(_||p.current||!i||i===t){u(null);return}p.current=!0,f(!0);try{await r(i)}finally{p.current=!1,f(!1),u(null)}};return(0,W.jsxs)(`div`,{className:E(`min-w-0`,c),children:[(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 px-0.5 pb-1`,children:[o&&(0,W.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:o}),(0,W.jsxs)(`span`,{className:`ml-auto flex min-w-0 items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`truncate text-[13px] leading-5 font-medium text-accent-fg`,"aria-live":`polite`,children:g}),s]})]}),(0,W.jsx)(T,{className:E(`h-7`,`[&_[data-slot=slider-range]]:bg-[linear-gradient(90deg,var(--star-border),var(--star))]`,`[&_[data-slot=slider-thumb]]:size-4 [&_[data-slot=slider-thumb]]:bg-[radial-gradient(circle,var(--star)_0_2px,var(--key-bg)_2.5px)]`),showSteps:!0,min:0,max:Math.max(1,e.length-1),step:1,value:[h],disabled:_,"aria-label":a,valueText:g,onValueChange:([e])=>u(e),onValueCommit:([e])=>void y(e)}),e.length>1&&(0,W.jsxs)(`div`,{className:`flex justify-between px-0.5 pt-0.5 text-xs text-content-faint`,"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{children:n(e[0])}),(0,W.jsx)(`span`,{children:n(e.at(-1)||``)})]})]})}var Oe=96,ke=.6,Ae=`10%`;function je({onDismiss:e,className:t}){let n=(0,R.useRef)(null),r=e=>{e.sheet.style.transform=``,e.sheet.style.transition=``},i=e=>{if(e.button!==0)return;let t=e.currentTarget.closest(`[data-slot="sheet-content"]`);t&&(e.currentTarget.setPointerCapture?.(e.pointerId),t.style.transition=`none`,n.current={pointerId:e.pointerId,startY:e.clientY,startAt:performance.now(),sheet:t,offset:0})},a=e=>{let t=n.current;!t||t.pointerId!==e.pointerId||(t.offset=Math.max(0,e.clientY-t.startY),t.sheet.style.transform=`translateY(${t.offset}px)`)},o=t=>{let{sheet:n}=t;n.style.setProperty(`--tw-exit-translate-y`,`calc(${t.offset}px + ${Ae})`);let i=()=>{n.removeEventListener(`animationstart`,a),r(t),n.style.removeProperty(`--tw-exit-translate-y`)},a=e=>{e.target===n&&n.dataset.state!==`closed`&&i()};n.addEventListener(`animationstart`,a),e(),requestAnimationFrame(()=>{n.isConnected&&n.dataset.state!==`closed`&&i()})},s=e=>{let t=n.current;if(!t||t.pointerId!==e.pointerId)return;n.current=null;let i=t.offset/Math.max(1,performance.now()-t.startAt);if(t.offset>=Oe||t.offset>24&&i>=ke){o(t);return}r(t)},c=()=>{let e=n.current;n.current=null,e&&r(e)};return(0,W.jsx)(`div`,{"aria-hidden":`true`,"data-sheet-drag-handle":!0,className:E(`flex h-8 w-full flex-none cursor-grab touch-none items-start justify-center select-none active:cursor-grabbing`,t),onPointerDown:i,onPointerMove:a,onPointerUp:s,onPointerCancel:c,onLostPointerCapture:c,children:(0,W.jsx)(`span`,{className:`mt-2.5 h-1 w-9 rounded-full bg-stroke-strong`})})}function Me({sheet:e,title:t,trigger:n,children:r,open:i,onOpenChange:a,align:o,side:s,sideOffset:c,className:l,sheetClassName:u}){let[d,f]=(0,R.useState)(!1),p=i??d,m=e=>{i===void 0&&f(e),a?.(e)};return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(h,{"aria-haspopup":`dialog`,"aria-expanded":p,onClick:()=>m(!0),children:n}),(0,W.jsx)(A,{open:p,onOpenChange:m,children:(0,W.jsxs)(D,{side:`bottom`,showCloseButton:!1,"data-popover-sheet":!0,className:E(`max-h-[85dvh] gap-1 overflow-y-auto rounded-t-(--r-sheet) px-3 pt-1 pb-[calc(12px+var(--pisper-safe-area-bottom))]`,u),children:[(0,W.jsx)(je,{onDismiss:()=>m(!1)}),(0,W.jsx)(O,{className:`px-2 pt-1 pb-1 text-base font-semibold`,children:t}),(0,W.jsx)(k,{className:`sr-only`,children:t}),r]})})]}):(0,W.jsxs)(w,{open:p,onOpenChange:m,children:[(0,W.jsx)(S,{asChild:!0,children:n}),(0,W.jsx)(C,{align:o,side:s,sideOffset:c,className:l,children:r})]})}var Ne=1,Pe=.9,Fe=.8,Ie=.17,Le=.1,Re=.999,ze=.9999,Be=.99,Ve=/[\\\/_+.#"@\[\(\{&]/,He=/[\\\/_+.#"@\[\(\{&]/g,Ue=/[\s-]/,We=/[\s-]/g;function Ge(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Ne:Be;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Ge(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Ne:Ve.test(e.charAt(l-1))?(d*=Fe,p=e.slice(i,l-1).match(He),p&&i>0&&(d*=Re**+p.length)):Ue.test(e.charAt(l-1))?(d*=Pe,m=e.slice(i,l-1).match(We),m&&i>0&&(d*=Re**+m.length)):(d*=Ie,i>0&&(d*=Re**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=ze)),(d<Le&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Ge(e,t,n,r,l+1,a+2,o),f*Le>d&&(d=f*Le)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Ke(e){return e.toLowerCase().replace(We,` `)}function qe(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Ge(e,t,Ke(e),Ke(t),0,0,{})}var G=`[cmdk-group=""]`,Je=`[cmdk-group-items=""]`,Ye=`[cmdk-group-heading=""]`,Xe=`[cmdk-item=""]`,Ze=`${Xe}:not([aria-disabled="true"])`,Qe=`cmdk-item-select`,K=`data-value`,$e=(e,t,n)=>qe(e,t,n),et=R.createContext(void 0),q=()=>R.useContext(et),tt=R.createContext(void 0),nt=()=>R.useContext(tt),rt=R.createContext(void 0),it=R.forwardRef((e,t)=>{let n=X(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=X(()=>new Set),i=X(()=>new Map),a=X(()=>new Map),o=X(()=>new Set),s=ht(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:v=!0,...y}=e,b=_(),x=_(),S=_(),C=R.useRef(null),w=_t();Y(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,T.emit()}},[u]),Y(()=>{w(6,j)},[]);let T=R.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)A(),O(),w(1,k);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(S);e?e.focus():(i=document.getElementById(b))==null||i.focus()}if(w(7,()=>{n.current.selectedItemId=M()?.id,T.emit()}),r||w(5,j),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}T.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),E=R.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,D(t,r)),w(2,()=>{O(),T.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),w(3,()=>{A(),O(),n.current.value||k(),T.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=M();w(4,()=>{A(),t?.getAttribute(`id`)===e&&k(),T.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:b,inputId:S,labelId:x,listInnerRef:C}),[]);function D(e,t){let r=s.current?.filter??$e;return e?r(e,n.current.search,t):0}function O(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=C.current;N().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Je);t?t.appendChild(e.parentElement===t?e:e.closest(`${Je} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Je} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=C.current?.querySelector(`${G}[${K}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function k(){let e=N().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(K);T.setState(`value`,e||void 0)}function A(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=D(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function j(){var e;let t=M();t&&(t.parentElement?.firstChild===t&&((e=t.closest(G)?.querySelector(Ye))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function M(){return C.current?.querySelector(`${Xe}[aria-selected="true"]`)}function N(){return Array.from(C.current?.querySelectorAll(Ze)||[])}function P(e){let t=N()[e];t&&T.setState(`value`,t.getAttribute(K))}function F(e){var t;let n=M(),r=N(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&T.setState(`value`,a.getAttribute(K))}function I(e){let t=M()?.closest(G),n;for(;t&&!n;)t=e>0?pt(t,G):mt(t,G),n=t?.querySelector(Ze);n?T.setState(`value`,n.getAttribute(K)):F(e)}let L=()=>P(N().length-1),ee=e=>{e.preventDefault(),e.metaKey?L():e.altKey?I(1):F(1)},z=e=>{e.preventDefault(),e.metaKey?P(0):e.altKey?I(-1):F(-1)};return R.createElement(g.div,{ref:t,tabIndex:-1,...y,"cmdk-root":``,onKeyDown:e=>{var t;(t=y.onKeyDown)==null||t.call(y,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:v&&e.ctrlKey&&ee(e);break;case`ArrowDown`:ee(e);break;case`p`:case`k`:v&&e.ctrlKey&&z(e);break;case`ArrowUp`:z(e);break;case`Home`:e.preventDefault(),P(0);break;case`End`:e.preventDefault(),L();break;case`Enter`:{e.preventDefault();let t=M();if(t){let e=new Event(Qe);t.dispatchEvent(e)}}}}},R.createElement(`label`,{"cmdk-label":``,htmlFor:E.inputId,id:E.labelId,style:yt},c),Q(e,e=>R.createElement(tt.Provider,{value:T},R.createElement(et.Provider,{value:E},e))))}),at=R.forwardRef((e,t)=>{let n=_(),r=R.useRef(null),i=R.useContext(rt),a=q(),o=ht(e),s=o.current?.forceMount??i?.forceMount;Y(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=gt(n,r,[e.value,e.children,r],e.keywords),l=nt(),u=Z(e=>e.value&&e.value===c.current),d=Z(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);R.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Qe,f),()=>t.removeEventListener(Qe,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:h,value:v,onSelect:y,forceMount:b,keywords:x,...S}=e;return R.createElement(g.div,{ref:m(r,t),...S,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!u,"data-disabled":!!h,"data-selected":!!u,onPointerMove:h||a.getDisablePointerSelection()?void 0:p,onClick:h?void 0:f},e.children)}),ot=R.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=_(),s=R.useRef(null),c=R.useRef(null),l=_(),u=q(),d=Z(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Y(()=>u.group(o),[]),gt(o,s,[e.value,e.heading,c]);let f=R.useMemo(()=>({id:o,forceMount:i}),[i]);return R.createElement(g.div,{ref:m(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&R.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Q(e,e=>R.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},R.createElement(rt.Provider,{value:f},e))))}),st=R.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=R.useRef(null),a=Z(e=>!e.search);return!n&&!a?null:R.createElement(g.div,{ref:m(i,t),...r,"cmdk-separator":``,role:`separator`})}),ct=R.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=nt(),o=Z(e=>e.search),s=Z(e=>e.selectedItemId),c=q();return R.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),R.createElement(g.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),lt=R.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=R.useRef(null),o=R.useRef(null),s=Z(e=>e.selectedItemId),c=q();return R.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),R.createElement(g.div,{ref:m(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Q(e,e=>R.createElement(`div`,{ref:m(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),ut=R.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return R.createElement(x,{open:n,onOpenChange:r},R.createElement(y,{container:o},R.createElement(v,{"cmdk-overlay":``,className:i}),R.createElement(b,{"aria-label":e.label,"cmdk-dialog":``,className:a},R.createElement(it,{ref:t,...s}))))}),dt=R.forwardRef((e,t)=>Z(e=>e.filtered.count===0)?R.createElement(g.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),ft=R.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return R.createElement(g.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Q(e,e=>R.createElement(`div`,{"aria-hidden":!0},e)))}),J=Object.assign(it,{List:lt,Item:at,Input:ct,Group:ot,Separator:st,Dialog:ut,Empty:dt,Loading:ft});function pt(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function mt(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function ht(e){let t=R.useRef(e);return Y(()=>{t.current=e}),t}var Y=typeof window>`u`?R.useEffect:R.useLayoutEffect;function X(e){let t=R.useRef();return t.current===void 0&&(t.current=e()),t}function Z(e){let t=nt(),n=()=>e(t.snapshot());return R.useSyncExternalStore(t.subscribe,n,n)}function gt(e,t,n,r=[]){let i=R.useRef(),a=q();return Y(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(K,s),i.current=s}),i}var _t=()=>{let[e,t]=R.useState(),n=X(()=>new Map);return Y(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function vt(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Q({asChild:e,children:t},n){return e&&R.isValidElement(t)?R.cloneElement(vt(t),{ref:t.ref},n(t.props.children)):n(t)}var yt={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function bt({className:e,...t}){return(0,W.jsx)(J,{"data-slot":`command`,className:E(`flex size-full flex-col overflow-hidden rounded-md! bg-popover p-1 text-popover-foreground`,e),...t})}function xt({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1 pb-0`,children:(0,W.jsxs)(P,{className:`h-8! rounded-sm! border-stroke bg-surface-subtle shadow-none! *:data-[slot=input-group-addon]:pl-2!`,children:[(0,W.jsx)(J.Input,{"data-slot":`command-input`,className:E(`w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,W.jsx)(N,{children:(0,W.jsx)(p,{className:`size-4 shrink-0 opacity-50`})})]})})}function St({className:e,...t}){return(0,W.jsx)(J.List,{"data-slot":`command-list`,className:E(`no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none`,e),...t})}function Ct({className:e,...t}){return(0,W.jsx)(J.Empty,{"data-slot":`command-empty`,className:E(`py-6 text-center text-sm`,e),...t})}function wt({className:e,...t}){return(0,W.jsx)(J.Group,{"data-slot":`command-group`,className:E(`overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function Tt({className:e,children:t,...n}){return(0,W.jsxs)(J.Item,{"data-slot":`command-item`,className:E(`group/command-item relative flex min-h-7.5 max-[650px]:min-h-11 pointer-coarse:min-h-11 cursor-default items-center gap-2 rounded-sm px-2 py-1 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-accent data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground`,e),...n,children:[t,(0,W.jsx)(l,{className:`ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100`})]})}function Et(e,t){let n=t.find(t=>t.key===e);return n?`${n.providerName} · ${n.label}`:e.split(`/`).at(-1)||e}function Dt({model:e,availableModels:t,sessionUsage:n,contextUsage:r}){let{t:i,language:a}=o(),s=n?.timing&&typeof n.timing==`object`?n.timing:null,c=Math.max(0,Number(s?.firstTokenSamples)||0),l=Math.max(0,Number(s?.requests)||0),u=c>0?Number(s?.firstTokenTotalMs)/c:null,d=l>0?Number(s?.durationTotalMs)/l:null,f=r?.tokens==null?null:Math.max(0,Number(r.tokens)||0),p=!!n?.cacheReported,m=[[i(`chat:focusSession.statCurrentModel`),e?Et(e,t||[]):`—`],[i(`chat:focusSession.statContextTokens`),f==null?`—`:`${j(f)} / ${j(r?.contextWindow)}`],[i(`chat:focusSession.statInputTokens`),j(n?.input)],[i(`chat:focusSession.statOutputTokens`),j(n?.output)],[i(`chat:focusSession.statCacheReadTokens`),p?j(n?.cacheRead):`—`],[i(`chat:focusSession.statCacheWriteTokens`),p?j(n?.cacheWrite):`—`],[i(`chat:focusSession.statReasoningTokens`),j(n?.reasoning)],[i(`chat:focusSession.statProcessedTokens`),j(n?.processedTokens)],[i(`chat:focusSession.statRequests`),String(Math.max(0,Number(n?.requests)||0))],[i(`chat:focusSession.statAvgFirstToken`),u==null?`—`:M(u,a)],[i(`chat:focusSession.statAvgDuration`),d==null?`—`:M(d,a)]];return(0,W.jsxs)(`div`,{className:`session-stats-panel grid gap-[3px]`,"aria-label":i(`chat:focusSession.sessionStats`),children:[m.map(([e,t])=>(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-[10px] text-[length:var(--app-small-size)]`,children:[(0,W.jsx)(`span`,{className:`min-w-0 shrink-0 text-[var(--text-muted)]`,children:e}),(0,W.jsx)(`strong`,{className:`min-w-0 truncate text-right font-[500] text-[var(--text)] [font-variant-numeric:tabular-nums]`,children:t})]},e)),(0,W.jsx)(`small`,{className:`text-[var(--text-secondary)] text-[length:var(--app-small-size)] leading-normal`,children:i(`chat:focusSession.sessionStatsHint`)})]})}function Ot({usage:e,sessionUsage:t,model:n,availableModels:r,onThresholdChange:i}){let{t:a}=o(),s=Number(e?.contextWindow)||0,c=e?.compactAtPercent==null?80:Number(e.compactAtPercent),l=Number.isFinite(c)?Math.round(c):80,[d,f]=(0,R.useState)(l),[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)(``),_=(0,R.useRef)(l),v=(0,R.useRef)(void 0);(0,R.useEffect)(()=>{window.clearTimeout(v.current),f(l),_.current=l},[l]),(0,R.useEffect)(()=>()=>window.clearTimeout(v.current),[]);let y=e?.percent!=null&&Number.isFinite(Number(e.percent))?Math.max(0,Number(e?.percent)):null,b=Math.max(0,Number(t?.processedTokens)||0),x=Number(t?.cacheHitRate),S=t?.cacheHitRate!=null&&Number.isFinite(x),C=s?`${e?.tokens==null?`—`:j(e.tokens)} / ${j(s)}${y==null?``:` · ${Math.round(y)}%`}`:``,w=e?.autoCompactEnabled&&e.compactionCapacityPercent!=null?a(`chat:focusSession.contextUsageToCompactionTokensPercent`,{percent:Math.round(Number(e.compactionCapacityPercent)),tokens:j(e.remainingBeforeCompaction)}):``,E=async e=>{let t=Math.min(95,Math.max(10,Math.round(e)));if(f(t),!(!i||t===_.current)){m(!0),g(``);try{await i(t),_.current=t}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},D=e=>{window.clearTimeout(v.current),f(e),v.current=window.setTimeout(()=>void E(e),250)},O=e=>{window.clearTimeout(v.current),E(e)},k=(e,t,n,r)=>(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,"data-usage-row":n,title:r,children:[(0,W.jsx)(`span`,{className:`shrink-0 text-content-muted`,children:e}),(0,W.jsx)(`strong`,{className:`min-w-0 truncate text-right font-medium text-content tabular-nums`,children:t})]});return(0,W.jsxs)(`div`,{className:`context-usage-section grid gap-1.5 border-t border-stroke-soft px-2 pt-2 pb-1.5`,"data-context-usage":!0,children:[C&&(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[k(a(`board:composer.contextUsage`),C,`context`),(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`block h-[3px] overflow-hidden rounded-full bg-surface-active`,children:(0,W.jsx)(`span`,{className:`block h-full rounded-full bg-content-secondary`,style:{width:`${Math.min(100,y||0)}%`}})})]}),b>0&&k(a(`board:composer.sessionTokens`),a(`board:composer.tokens`,{tokens:j(b)}),`tokens`),k(a(`board:composer.cacheHitLabel`),S?`${Math.round(Math.max(0,x))}%`:`—`,`cache`,S?void 0:a(`chat:focusSession.cacheHitRateUnavailable`)),s>0&&(0,W.jsxs)(`details`,{className:`group/usage min-w-0 text-xs`,onToggle:e=>{let t=e.currentTarget;t.open&&requestAnimationFrame(()=>t.scrollIntoView({block:`nearest`}))},children:[(0,W.jsxs)(`summary`,{className:`flex min-h-7 cursor-pointer list-none items-center gap-1 rounded-sm text-content-secondary hover:text-content focus-visible:outline-2 focus-visible:outline-focus max-[650px]:min-h-11 [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(u,{size:13,"aria-hidden":`true`,className:`transition-transform duration-(--d-fast) group-open/usage:rotate-90`}),a(`chat:focusSession.sessionStats`)]}),(0,W.jsxs)(`div`,{className:`grid gap-2 pt-1.5`,children:[(0,W.jsx)(Dt,{model:n,availableModels:r,sessionUsage:t,contextUsage:e}),w&&(0,W.jsx)(`small`,{className:`text-content-muted`,children:w}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between font-medium text-content`,children:[(0,W.jsx)(`span`,{children:a(`chat:focusSession.autoCompactionThreshold`)}),(0,W.jsxs)(`output`,{className:`tabular-nums`,children:[d,`%`]})]}),(0,W.jsx)(T,{min:10,max:95,step:1,value:[d],className:`h-5 w-full`,"aria-label":a(`chat:focusSession.autoCompactionThreshold`),valueText:`${d}%`,disabled:p,onValueChange:([e])=>D(e),onValueCommit:([e])=>O(e)}),(0,W.jsx)(`small`,{className:h?`text-danger`:`text-content-muted`,children:h||(p?a(`chat:focusSession.savingCompactionThreshold`):`\xA0`)})]})]})]})}function $(e,t){return{off:e(`chat:focusSession.thinkingLabel.off`),minimal:e(`chat:focusSession.thinkingLabel.minimal`),low:e(`chat:focusSession.thinkingLabel.low`),medium:e(`chat:focusSession.thinkingLabel.medium`),high:e(`chat:focusSession.thinkingLabel.high`),xhigh:e(`chat:focusSession.thinkingLabel.xhigh`),max:e(`chat:focusSession.thinkingLabel.max`)}[t]||t}function kt({model:e,models:t,onModelChange:n,thinkingLevel:r,levels:i,status:a,message:s,onThinkingChange:c,modelDisabled:l,thinkingDisabled:u,deferred:p=!1,pendingModel:m=!1,usage:h,sheet:g=!1,side:_=`top`,thinkingIsDefault:v=!1,onThinkingReset:y,triggerClassName:b}){let{t:x}=o(),[S,C]=(0,R.useState)(!1),w=t.find(t=>t.key===e),T=t.map(e=>e.label),D=w?.label||e.split(`/`).at(-1)||``,O=D?F(D,T):x(`chat:focusSession.toolbarModel`),k=[...t.reduce((e,t)=>{let n=e.get(t.providerName)||[];return n.push(t),e.set(t.providerName,n)},new Map)],A=a!==`unsupported`&&i.length>0,j=A?$(x,r||i[0]):`—`,M=m?x(`chat:focusSession.thinkingAfterModelSwitch`):A?j:s||x(a===`unsupported`?`chat:focusSession.thinkingLevelUnsupported`:`chat:focusSession.loadingThinkingLevels`),N=u||S||!A||i.length<2,P=`${x(`chat:focusSession.modelAndThinking`)} · ${Et(e,t)} · ${M}`;return(0,W.jsxs)(Me,{sheet:g,title:x(`chat:focusSession.modelAndThinking`),align:`end`,side:_,sideOffset:8,className:`model-effort-popover w-[272px] max-w-[calc(100vw_-_24px)] gap-0 p-1`,trigger:(0,W.jsxs)(`button`,{type:`button`,className:E(`model-effort-pill inline-flex h-[30px] min-w-0 max-w-[260px] cursor-pointer items-center gap-1.5 rounded-sm border border-transparent pr-1.5 pl-2.5 text-[13px] text-content transition-colors hover:bg-surface-hover disabled:cursor-default disabled:opacity-60 aria-expanded:bg-surface-hover max-[650px]:h-9 max-[650px]:gap-1 max-[650px]:rounded-full max-[650px]:bg-surface-muted max-[650px]:dark:bg-surface-active max-[650px]:px-3 max-[650px]:text-sm min-[651px]:pointer-coarse:h-11`,f,b),"aria-label":P,title:P,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate font-medium max-[650px]:hidden`,children:O}),(0,W.jsx)(`span`,{className:`hidden font-medium whitespace-nowrap max-[650px]:inline`,children:x(`chat:focusSession.modelChipShort`)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`text-content-faint max-[650px]:hidden`,children:`·`}),(0,W.jsx)(`span`,{className:`shrink-0 text-content-muted max-[650px]:hidden`,children:A?$(x,r||i[0]):`—`}),(0,W.jsx)(d,{size:14,className:`shrink-0 text-content-muted max-[650px]:hidden`,"aria-hidden":`true`})]}),children:[(0,W.jsxs)(`div`,{className:`model-effort-model flex flex-col gap-1 p-1.5 pb-2`,children:[(0,W.jsx)(`span`,{className:`px-0.5 text-xs font-medium text-content-muted`,children:x(`chat:focusSession.toolbarModel`)}),(0,W.jsxs)(bt,{defaultValue:e,filter:(e,t,n)=>+!![e,...n||[]].join(` `).toLowerCase().includes(t.trim().toLowerCase()),className:`rounded-sm! border border-stroke-soft bg-transparent p-0`,"aria-label":x(`chat:focusSession.currentChatModel`),children:[t.length>6&&(0,W.jsx)(xt,{placeholder:x(`chat:focusSession.searchModels`)}),(0,W.jsxs)(St,{className:`max-h-56`,children:[(0,W.jsx)(Ct,{className:`py-4 text-xs text-content-muted`,children:t.length?x(`chat:focusSession.noMatchingModels`):x(`chat:focusSession.noModelsAvailable`)}),!w&&e&&(0,W.jsx)(wt,{children:(0,W.jsx)(Tt,{value:e,"data-checked":!0,disabled:!0,children:(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:O})})}),k.map(([t,r])=>(0,W.jsx)(wt,{heading:t,children:r.map(t=>{let r=F(t.label,T);return(0,W.jsx)(Tt,{value:t.key,keywords:[t.label,t.providerName],"data-checked":t.key===e,disabled:l||S,onSelect:()=>{t.key!==e&&n(t.key)},children:(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-col`,title:t.label,children:[(0,W.jsx)(`span`,{className:`wrap-anywhere`,children:r}),r!==t.label&&(0,W.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:t.label})]})},t.key)})},t))]})]})]}),A&&(0,W.jsx)(De,{className:`border-t border-stroke-soft p-1.5 pt-2`,title:x(`chat:focusSession.thinkingLevelTitle`),levels:i,value:r,labelFor:e=>$(x,e),onCommit:async e=>{C(!0);try{await c(e)}finally{C(!1)}},disabled:N,ariaLabel:x(`chat:focusSession.currentThinkingLevel`),trailing:v?(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-content-faint`,children:x(`chat:focusSession.thinkingModelDefault`)}):y?(0,W.jsx)(`button`,{type:`button`,className:`shrink-0 cursor-pointer rounded-sm text-xs text-content-muted underline-offset-2 hover:text-content hover:underline focus-visible:outline-2 focus-visible:outline-focus`,onClick:y,children:x(`chat:focusSession.thinkingReset`)}):void 0}),p&&(0,W.jsx)(`p`,{className:`px-2 pt-1 pb-2 text-xs leading-4 text-content-muted`,role:`status`,children:x(`chat:focusSession.runtimeSelectionDeferred`)}),(!A||i.length===1)&&(0,W.jsx)(`p`,{className:`border-t border-stroke-soft px-2 pt-2 pb-1.5 text-xs leading-relaxed text-content-muted`,role:`status`,children:A?x(`chat:focusSession.thinkingLevelFixed`,{level:j}):M}),h]})}export{je as a,be as c,ce as d,ue as f,I as g,ee as h,Me as i,ve as l,te as m,kt as n,Ee as o,he as p,$ as r,_e as s,Ot as t,Se as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-CaxKosZm.js";import{D as i,S as a,h as o,o as s,u as c,v as l,x as u}from"./query-Bj-DUNYq.js";import{r as d,t as f}from"./useQuery-DdcpUQhO.js";import{n as p}from"./mutation-CEbxdVYy.js";import{t as m}from"./queryOptions-Dfvzj6n2.js";import{a as h,l as g}from"./api-MVoWVwmh.js";import{t as _}from"./check-2vYc6QaP.js";import{t as v}from"./copy-DHmIFc52.js";import{t as ee}from"./key-round-C29uZbsf.js";import{t as y}from"./plus-fQbSqB1n.js";import{t as b}from"./refresh-cw-TbWxTY4K.js";import{t as x}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as S}from"./server-BgNvmqwJ.js";import{t as C}from"./trash-2-CNrPOoPR.js";import{t as w}from"./wrench-6pg6_bqI.js";import{t as T}from"./x-07u4-129.js";import{t as E}from"./more-pages-D_PnxLN0.js";import{t as D}from"./switch-D_G8wFhs.js";import{t as O}from"./utils-C8uzG5AZ.js";import{n as k,t as A}from"./button-CCcCN8tE.js";import{s as te}from"./shortcuts-BmJZiLby.js";import{a as j}from"./format-DMJQzoZ7.js";import{a as M,i as N,l as P,o as F,s as ne,t as re}from"./dialog-9LXtFD-0.js";import{t as I}from"./textarea-DmATpOqT.js";import{n as L,t as R}from"./PageState-Cz6vFMXv.js";import{t as z}from"./alert-firawb0H.js";import{a as ie,i as B,n as V,o as ae,r as oe,s as se}from"./FeaturePage-IWVjXcVp.js";var ce=class extends i{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),u(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&c(t.mutationKey)!==c(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??p();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){s.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},H=e(t(),1);function le(e,t){let n=d(t);return ue({filters:{...e,status:`pending`}},n).length}function U(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function ue(e={},t){let n=d(t).getMutationCache(),r=H.useRef(e),i=H.useRef(null);return i.current===null&&(i.current=U(n,e)),H.useEffect(()=>{r.current=e}),H.useSyncExternalStore(H.useCallback(e=>n.subscribe(()=>{let t=l(i.current,U(n,r.current));i.current!==t&&(i.current=t,s.schedule(e))}),[n]),()=>i.current,()=>i.current)}function de(e,t){let n=d(t),[r]=H.useState(()=>new ce(n,e));H.useEffect(()=>{r.setOptions(e)},[r,e]);let i=H.useSyncExternalStore(H.useCallback(e=>r.subscribe(s.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),c=H.useCallback((e,t)=>{r.mutate(e,t).catch(o)},[r]);if(i.error&&a(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:c,mutateAsync:i.mutate}}function W(e){if(!e||typeof e!=`object`||Array.isArray(e))throw g();return Object.fromEntries(Object.entries(e))}function G(e,t=!1){if(e==null&&!t)return``;if(typeof e!=`string`||t&&!e)throw g();return e}function K(e,t=0){if(e==null)return t;if(typeof e!=`number`||!Number.isFinite(e))throw g();return e}function q(e){if(typeof e!=`boolean`)throw g();return e}function fe(e,t){if(e===void 0)return[];if(!Array.isArray(e))throw g();return e.map(t)}function pe(e){let t=W(e);return{id:G(t.id,!0),name:G(t.name,!0),status:G(t.status),transport:G(t.transport),endpoint:G(t.endpoint),command:G(t.command),workingDirectory:G(t.workingDirectory),enabled:q(t.enabled),error:G(t.error),latencyMs:t.latencyMs==null?null:K(t.latencyMs),lastPingAt:G(t.lastPingAt),auth:G(t.auth),authCount:K(t.authCount)}}function me(e){let t=W(e);return{serviceId:G(t.serviceId,!0),serviceName:G(t.serviceName),name:G(t.name,!0),piName:G(t.piName,!0),description:G(t.description),enabled:q(t.enabled),serviceEnabled:q(t.serviceEnabled),risk:G(t.risk)}}function he(e){let t=W(e);return{id:G(t.id,!0),serviceId:G(t.serviceId,!0),toolName:G(t.toolName),timestamp:G(t.timestamp),status:G(t.status),error:G(t.error),durationMs:K(t.durationMs)}}function J(e){let t=W(e);if(!Array.isArray(t.services))throw g();let n=t.metrics===void 0?{}:W(t.metrics);return{services:t.services.map(pe),tools:fe(t.tools,me),calls:fe(t.calls,he),metrics:{totalServices:K(n.totalServices),onlineServices:K(n.onlineServices),availableTools:K(n.availableTools),restrictedTools:K(n.restrictedTools),errorRate:K(n.errorRate)}}}var Y=e=>`/api/mcp/${encodeURIComponent(e)}`,X={dashboard:e=>h(`/api/mcp?refresh=0`,{signal:e,parse:J}),add:e=>h(`/api/mcp`,{method:`POST`,body:{spec:e},parse:J}),setServerEnabled:(e,t)=>h(Y(e),{method:`PATCH`,body:{enabled:t},parse:J}),setToolEnabled:(e,t,n)=>h(`${Y(e)}/tools/${encodeURIComponent(t)}`,{method:`PATCH`,body:{enabled:n},parse:J}),test:e=>h(`${Y(e)}/test`,{method:`POST`,body:{},parse:J}),remove:async e=>(await h(Y(e),{method:`DELETE`}),X.dashboard())};function ge(e){if(!e||typeof e!=`object`||Array.isArray(e))throw g();return Object.fromEntries(Object.entries(e))}function _e(e){let t=ge(e);if(typeof t.enabled!=`boolean`||typeof t.listening!=`boolean`||typeof t.host!=`string`||typeof t.port!=`number`||!Number.isInteger(t.port)||typeof t.url!=`string`||t.error!==null&&typeof t.error!=`string`)throw g();return{enabled:t.enabled,listening:t.listening,host:t.host,port:t.port,url:t.url,error:t.error}}function ve(e){let t=ge(e);if(typeof t.url!=`string`||!t.url||typeof t.token!=`string`||!t.token)throw g();return{url:t.url,token:t.token}}var Z={status:e=>h(`/api/mcp-host`,{signal:e,parse:_e}),setEnabled:e=>h(`/api/mcp-host`,{method:`PATCH`,body:{enabled:e},parse:_e}),credentials:e=>h(`/api/mcp-host/credentials`,{method:`POST`,body:{},signal:e,parse:ve}),rotateToken:e=>h(`/api/mcp-host/rotate-token`,{method:`POST`,body:{},signal:e,parse:ve})},Q=n(),ye=[`mcp-host`,`status`];function be(e){return JSON.stringify({mcpServers:{pisper:{url:e.url,headers:{Authorization:`Bearer ${e.token}`}}}},null,2)}function xe({notify:e,requestConfirm:t}){let{t:n}=r(),i=d(),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(``),_=(0,H.useRef)(null),y=(0,H.useRef)(null),x=typeof window<`u`&&!!window.__PISPER_MOBILE_APP__,C=f({queryKey:ye,queryFn:({signal:e})=>Z.status(e),enabled:!x&&!a,refetchInterval:15e3});if((0,H.useEffect)(()=>()=>{_.current?.abort()},[]),x)return null;let w=C.data,T=p?be(p):``,E=()=>{_.current?.abort(),_.current=null,m(null),g(``),u(!1)},te=async()=>{_.current?.abort();let e=new AbortController;_.current=e,c(!0),m(null),g(``),u(!0);try{let t=await Z.credentials(e.signal);e.signal.aborted||m(t)}catch(t){e.signal.aborted||g(t instanceof Error?t.message:n(`mcp:hostLoadFailed`))}finally{_.current===e&&(_.current=null,c(!1))}},j=async t=>{o(!0);try{let r=await Z.setEnabled(t);i.setQueryData(ye,r),t||E(),e(r.error||n(t?`mcp:hostEnabledNotice`:`mcp:hostDisabledNotice`),r.error?`error`:`success`)}catch(t){e(t instanceof Error?t.message:n(`mcp:hostUpdateFailed`),`error`)}finally{o(!1)}},L=async()=>{if(t&&!await t({title:n(`mcp:hostRotateTitle`),message:n(`mcp:hostRotateWarning`),confirmLabel:n(`mcp:hostRotate`),tone:`danger`}))return;_.current?.abort();let r=new AbortController;_.current=r,c(!0),g(``),m(null);try{let t=await Z.rotateToken(r.signal);r.signal.aborted||(m(t),e(n(`mcp:hostRotatedNotice`),`success`))}catch(e){r.signal.aborted||g(e instanceof Error?e.message:n(`mcp:hostRotateFailed`))}finally{_.current===r&&(_.current=null,c(!1))}},R=async()=>{try{await navigator.clipboard.writeText(T),e(n(`mcp:hostCopied`),`success`)}catch{y.current?.select(),e(n(`mcp:hostCopyManually`),`error`)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{className:`mcp-host mt-7`,children:(0,Q.jsx)(B,{"data-mcp-host":!0,icon:(0,Q.jsx)(S,{}),name:n(`mcp:hostTitle`),description:n(`mcp:hostDescription`),status:w&&(0,Q.jsxs)(`span`,{className:O(`flex items-center gap-1.5`,!w.listening&&w.enabled&&`font-medium text-st-attn`),children:[!w.listening&&w.enabled&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),w.listening?n(`mcp:hostReady`):w.enabled?n(`mcp:hostUnavailable`):n(`mcp:disabled`)]}),actions:(0,Q.jsx)(D,{checked:!!w?.enabled,disabled:!w||a,"aria-label":n(`mcp:hostEnabled`),title:n(`mcp:hostEnabled`),onCheckedChange:e=>void j(e)}),detail:C.isPending||C.error||w?.error||w?.listening?(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[C.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-content-muted`,children:n(`mcp:loading`)}),C.error&&(0,Q.jsxs)(z,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:C.error.message}),(0,Q.jsx)(A,{size:`sm`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:()=>void C.refetch(),children:n(`mcp:retry`)})]}),w?.error&&(0,Q.jsx)(z,{role:`status`,className:`text-xs text-muted-foreground`,children:w.error}),w?.listening&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,Q.jsx)(`code`,{className:`max-w-full min-w-0 rounded-xs border border-stroke bg-code px-2 py-0.5 font-mono text-xs break-all text-content`,children:w.url}),(0,Q.jsxs)(A,{size:`sm`,variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void te(),children:[(0,Q.jsx)(ee,{"data-icon":`inline-start`}),n(`mcp:hostShowConfig`)]})]})]}):void 0})}),(0,Q.jsx)(re,{open:l,onOpenChange:e=>!e&&E(),children:(0,Q.jsxs)(N,{className:`min-w-0 grid-cols-[minmax(0,1fr)] sm:max-w-xl`,children:[(0,Q.jsxs)(ne,{className:`min-w-0 pr-8 text-left`,children:[(0,Q.jsx)(P,{children:n(`mcp:hostConfigTitle`)}),(0,Q.jsx)(M,{className:`leading-5`,children:n(`mcp:hostConfigDescription`)})]}),s&&(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-content-muted`,children:[(0,Q.jsx)(k,{}),n(`mcp:hostLoadingConfig`)]}),h&&(0,Q.jsx)(z,{role:`alert`,className:`text-sm text-muted-foreground`,children:h}),p&&(0,Q.jsx)(I,{ref:y,value:T,readOnly:!0,spellCheck:!1,"aria-label":n(`mcp:hostConfigTitle`),className:`h-52 max-h-[45dvh] resize-y bg-code font-mono text-xs [overflow-wrap:anywhere]`,onFocus:e=>e.currentTarget.select()}),(0,Q.jsxs)(F,{className:`min-w-0 flex-wrap`,children:[(0,Q.jsxs)(A,{variant:`secondary`,disabled:s,onClick:()=>void L(),children:[(0,Q.jsx)(b,{"data-icon":`inline-start`}),n(`mcp:hostRotate`)]}),(0,Q.jsxs)(A,{disabled:!p||s,onClick:()=>void R(),children:[(0,Q.jsx)(v,{"data-icon":`inline-start`}),n(`mcp:hostCopyConfig`)]})]})]})})]})}var $=[`mcp`,`dashboard`],Se=[`mcp`,`change`];function Ce(){return m({queryKey:$,queryFn:({signal:e})=>X.dashboard(e),staleTime:0,retry:!1})}function we(e){return{mutationKey:Se,scope:{id:`mcp-dashboard`},retry:!1,mutationFn:async t=>(await e.cancelQueries({queryKey:$}),t()),onSuccess:t=>e.setQueryData($,t),onSettled:()=>e.invalidateQueries({queryKey:$})}}function Te(){let e=d(),t=le({mutationKey:Se})>0,n=f({...Ce(),enabled:!t,refetchInterval:!t&&1e4}),r=de(we(e));return{data:n.data,loading:n.isPending,error:r.error||n.error,busy:t,change:r.mutateAsync,reload:()=>(r.reset(),n.refetch())}}var Ee=`grid grid-cols-[88px_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs [&_dd]:min-w-0 [&_dd]:[overflow-wrap:anywhere] [&_dd]:text-content-soft [&_dt]:text-content-muted [&>div]:contents`;function De(e,t){return e===`online`?[t(`mcp:online`),!1]:e===`connecting`?[t(`mcp:connecting`),!1]:e===`unauthorized`?[t(`mcp:unauthorized`),!0]:e===`disabled`?[t(`mcp:disabled`),!1]:[t(`mcp:offline`),!0]}function Oe(e,t){return e===`high`||e===`高风险`?t(`mcp:highRisk`):e===`medium`||e===`中风险`?t(`mcp:mediumRisk`):e===`low`||e===`低风险`?t(`mcp:lowRisk`):String(e||``)}function ke(e,t){return e.auth===`headers`?t(`mcp:countRequestHeaders`,{count:e.authCount}):e.auth===`environment`?t(`mcp:configuredEnvironmentVariables`):e.auth===`local`?t(`mcp:localProcess`):t(`mcp:none`)}function Ae({notify:e,onBack:t,requestText:n,requestConfirm:i}){let{t:a,language:o}=r(),s=te(`focusSearch`),{data:c,busy:l,loading:u,error:d,change:f,reload:p}=Te(),[m,h]=(0,H.useState)(``),[g,v]=(0,H.useState)(``),ee=(0,H.useCallback)(async()=>{let t=await n?.({title:a(`mcp:addMCPService`),message:a(`mcp:enterAStreamableHTTPURLAStdioCommandOrJSONContainingHeadersEnv`),inputLabel:a(`mcp:serverConfiguration`),placeholder:`https://server.example.com/mcp`,maxLength:12e3,confirmLabel:a(`mcp:continue`)});if(t?.trim()&&await i?.({title:a(`mcp:connectMCPServer`),message:a(`mcp:mcpServersCanExposeToolsThatPerformExternalActionsConnectOnlyToServersYouTrust`),confirmLabel:a(`mcp:connect`),tone:`danger`})!==!1)try{let n=await f(()=>X.add(t));v(n.services.at(-1)?.id||``),e(a(`mcp:mcpServerAdded`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},[f,e,i,n,a]),k=m.trim().toLowerCase(),M=c?.services||[],N=M.filter(e=>`${e.name} ${e.endpoint}`.toLowerCase().includes(k)),P=(c?.tools||[]).filter(e=>`${e.name} ${e.serviceName} ${e.description}`.toLowerCase().includes(k)),F=c?.metrics||{totalServices:0,onlineServices:0,availableTools:0,restrictedTools:0,errorRate:0},ne=async(t,n)=>{try{await f(()=>X.setToolEnabled(t.serviceId,t.name,n))}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},re=async(t,n)=>{try{await f(()=>X.setServerEnabled(t.id,n)),e(a(n?`mcp:mcpServerEnabled`:`mcp:mcpServerDisabled`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},I=async t=>{try{await f(()=>X.test(t.id)),e(a(`mcp:mcpConnectionTestPassed`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},ce=async t=>{if(await i?.({title:a(`mcp:deleteMCPServer`),message:a(`mcp:afterDeletionToolsFromThisServerWillBeRemovedFromSubsequentAgentRuns`),confirmLabel:a(`mcp:delete`),tone:`danger`})!==!1)try{await f(()=>X.remove(t.id)),v(``),e(a(`mcp:mcpServerDeleted`),`success`)}catch(t){e(t instanceof Error?t.message:String(t),`error`)}},le=e=>{let t=(c?.calls||[]).filter(t=>t.serviceId===e.id);return(0,Q.jsxs)(`div`,{className:`mcp-service-detail grid gap-3`,children:[(0,Q.jsx)(`p`,{className:O(`text-xs leading-normal [overflow-wrap:anywhere]`,e.error?`font-mono text-content-secondary`:`text-content-muted`),children:e.error||a(`mcp:thisServerExposesToolsThroughAStandardMCPTransportEnabledToolsAreRegisteredInNewAgentRuntimes`)}),(0,Q.jsx)(`dl`,{className:Ee,children:[[a(`mcp:transport`),e.transport===`stdio`?`stdio`:e.transport===`sse`?`HTTP + SSE`:`Streamable HTTP`,!1],...e.transport===`stdio`?[[a(`mcp:executable`),e.command||`—`,!0],[a(`mcp:workingDirectory`),e.workingDirectory||`—`,!0]]:[[a(`mcp:serverAddress`),e.endpoint||`—`,!0]],[a(`mcp:latency`),e.latencyMs==null?`—`:`${e.latencyMs} ms`,!1],[a(`mcp:lastPing`),e.lastPingAt?j(e.lastPingAt,o):`—`,!1],[a(`mcp:authentication`),ke(e,a),!1]].map(([e,t,n])=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{children:e}),(0,Q.jsx)(`dd`,{className:n?`font-mono`:`tabular-nums`,children:t})]},e))}),(0,Q.jsxs)(`section`,{className:`mcp-calls-panel min-w-0`,"aria-label":a(`mcp:recentCalls`),children:[(0,Q.jsxs)(`h3`,{className:`mb-1 text-xs font-medium text-content-muted tabular-nums`,children:[a(`mcp:recentCalls`),t.length>0&&(0,Q.jsxs)(`span`,{children:[` · `,Math.min(t.length,8)]})]}),t.length?(0,Q.jsx)(`ul`,{role:`list`,className:`m-0 list-none divide-y divide-stroke p-0`,children:t.slice(0,8).map(e=>{let t=e.status===`ok`;return(0,Q.jsxs)(`li`,{className:O(`activity-row grid min-h-10 min-w-0 grid-cols-[16px_minmax(0,1fr)_auto] items-center gap-2.5 py-1.5`,t?`completed`:`failed`),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-4 place-items-center text-content-muted [&_svg]:size-3.5 [&_svg]:stroke-[2]`,children:t?(0,Q.jsx)(_,{}):(0,Q.jsx)(T,{})}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`strong`,{className:`truncate font-mono text-xs font-medium text-content`,children:e.toolName}),(0,Q.jsx)(`small`,{className:`truncate text-xs text-content-muted`,children:t?a(`mcp:callSucceeded`):e.error||a(`mcp:callFailed`)})]}),(0,Q.jsxs)(`span`,{className:`flex flex-col items-end text-xs text-content-muted tabular-nums`,children:[(0,Q.jsxs)(`span`,{className:`text-content-secondary`,children:[e.durationMs,` ms`]}),(0,Q.jsx)(`span`,{children:j(e.timestamp,o)})]})]},e.id)})}):(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 py-1 text-xs text-content-muted`,children:[(0,Q.jsx)(x,{className:`size-3.5`,"aria-hidden":`true`}),a(`mcp:noRecentCalls`)]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,Q.jsxs)(A,{size:`sm`,variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,disabled:l,onClick:()=>void ce(e),children:[(0,Q.jsx)(C,{"data-icon":`inline-start`}),a(`mcp:delete`)]}),(0,Q.jsxs)(A,{size:`sm`,variant:`secondary`,className:`max-[650px]:h-11`,loading:l,disabled:!e.enabled||l,onClick:()=>void I(e),children:[(0,Q.jsx)(b,{"data-icon":`inline-start`}),a(`mcp:testConnection`)]})]})]})};return(0,Q.jsxs)(oe,{title:a(`navigation:navigation.mcp`),description:a(`mcp:lede`),back:t&&{label:a(`navigation:sidebar.features`),ariaLabel:a(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,Q.jsx)(se,{search:(0,Q.jsx)(ie,{id:E,value:m,onValueChange:h,placeholder:a(`navigation:pageHeader.searchServicesOrTools`),shortcut:s,clearLabel:a(`navigation:more.clearSearch`)}),actions:(0,Q.jsxs)(A,{type:`button`,className:`h-9`,"data-mcp-add":!0,disabled:l,onClick:()=>void ee(),children:[(0,Q.jsx)(y,{}),a(`navigation:pageHeader.addService`)]})}),children:[(0,Q.jsx)(xe,{notify:e,requestConfirm:i}),u&&!c&&!d?(0,Q.jsx)(L,{kind:`loading`,title:a(`mcp:loading`)}):!c&&d?(0,Q.jsx)(L,{kind:`error`,title:a(`mcp:loadFailed`),description:d.message,action:(0,Q.jsx)(A,{variant:`secondary`,className:`max-[650px]:h-11`,disabled:l,onClick:()=>void p(),children:a(`mcp:retry`)})}):c&&(0,Q.jsxs)(Q.Fragment,{children:[d&&(0,Q.jsxs)(z,{role:`status`,className:`mt-4 flex min-w-0 items-center justify-between gap-3 text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,Q.jsx)(`span`,{children:d.message}),(0,Q.jsx)(A,{variant:`ghost`,className:`max-[650px]:h-11`,disabled:l,onClick:()=>void p(),children:a(`mcp:retry`)})]}),(0,Q.jsx)(ae,{className:`mcp-services`,title:a(`mcp:services`),count:N.length,meta:M.length>0&&a(`mcp:serviceSummary`,{online:F.onlineServices,total:F.totalServices,rate:F.errorRate}),children:N.length?(0,Q.jsx)(V,{children:N.map(e=>{let[t,n]=De(e.status,a),r=e.transport===`stdio`?e.workingDirectory||e.command:e.endpoint;return(0,Q.jsx)(B,{className:`service-row`,"data-mcp-service":e.id,icon:(0,Q.jsx)(S,{}),name:e.name,description:(0,Q.jsx)(`span`,{className:`font-mono text-xs`,title:r,children:r}),status:(0,Q.jsxs)(`span`,{"data-mcp-status":e.status||`offline`,className:O(`flex items-center gap-1.5`,n&&`font-medium text-st-attn`),children:[n&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),t]}),actions:(0,Q.jsx)(D,{checked:e.enabled,disabled:l,"aria-label":a(`mcp:toggleServiceName`,{name:e.name}),onCheckedChange:t=>void re(e,t)}),expanded:g===e.id,onExpandedChange:t=>v(t?e.id:``),toggleLabel:a(`mcp:toggleServiceDetails`,{name:e.name}),detail:le(e)},e.id)})}):(0,Q.jsx)(R,{icon:S,title:a(`mcp:noServerConfigured`),description:M.length?void 0:a(`mcp:emptyAddHint`)})}),(0,Q.jsx)(ae,{className:`mcp-tools-panel`,title:a(`mcp:toolCapabilities`),count:P.length,meta:F.restrictedTools>0&&a(`mcp:toolSummary`,{count:F.restrictedTools}),children:P.length?(0,Q.jsx)(V,{children:P.map(e=>(0,Q.jsx)(B,{className:`tool-row`,"data-mcp-tool":e.piName,icon:(0,Q.jsx)(w,{}),name:(0,Q.jsx)(`span`,{className:`font-mono`,children:e.name}),description:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.serviceName}),e.description&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,e.description]})]}),status:Oe(e.risk,a),actions:(0,Q.jsx)(D,{checked:!!e.enabled,disabled:l||!e.serviceEnabled,"aria-label":a(`mcp:toggleToolName`,{name:e.name}),onCheckedChange:t=>void ne(e,t)})},e.piName))}):(0,Q.jsx)(R,{compact:!0,icon:w,title:a(`mcp:noToolsAvailable`)})})]})]})}export{Ae as McpPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryEvolution-DG9gtC6n.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CaxKosZm.js","assets/i18n-Cl3sIF9G.js","assets/vendor-router-CSN_DGvx.js","assets/index-rOrQSojS.js","assets/index-l96Dl6z6.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/info-DATxy0fb.js","assets/pause-CYWpPg1R.js","assets/play-DNDjDNGn.js","assets/x-07u4-129.js","assets/popover-DlJP3VbH.js","assets/dist-41X0pdUs.js","assets/dist-BsRXXcSL.js","assets/es2015-DTZdOI9P.js","assets/dist-BRjj4UeB.js","assets/dist-OB2r6Xsr.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/dialog-9LXtFD-0.js","assets/dist-BHkR6BLP.js","assets/button-CCcCN8tE.js","assets/slider-De8rWVNs.js","assets/dist-DzGQ7sLi.js","assets/dist-BS3ekNDj.js","assets/segmented-control-xkrEOP_d.js","assets/dist-BaBySQmo.js","assets/PageState-Cz6vFMXv.js","assets/motion-DTR4ZVle.js","assets/memory-api-sER80Rta.js","assets/api-MVoWVwmh.js","assets/abort-signal-f4JsiYKX.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{t as r}from"./index-rOrQSojS.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{f as o}from"./routes-DIeaqWVc.js";import{t as s}from"./use-i18n-CaxKosZm.js";import{t as c}from"./storage-DtvZ_lEu.js";import{u as l}from"./api-MVoWVwmh.js";import{t as u}from"./createLucideIcon-Cd-3GVxJ.js";import{t as d}from"./archive-ojKJT7Fp.js";import{t as f}from"./book-open-BuHHD9os.js";import{t as p}from"./ellipsis-CfGKfbq6.js";import{t as m}from"./file-code-corner-BnE1ljT0.js";import{n as h,r as g,t as _}from"./undo-2-C-xQ0UVT.js";import{t as v}from"./pencil-U08v_vV9.js";import{t as y}from"./pin-off-BpRu_vrC.js";import{t as b}from"./pin-CU0FG0lI.js";import{t as x}from"./plus-fQbSqB1n.js";import{t as S}from"./refresh-cw-TbWxTY4K.js";import{t as C}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as w}from"./rotate-ccw-C0v8V77_.js";import{t as T}from"./sliders-horizontal-Dryf1XyC.js";import{t as E}from"./trash-2-CNrPOoPR.js";import{t as D}from"./triangle-alert-CE1q54ci.js";import{t as ee}from"./x-07u4-129.js";import{t as te}from"./more-pages-D_PnxLN0.js";import{c as ne,i as O,p as k,r as re,t as ie}from"./dropdown-menu-Ds0gD8S8.js";import{i as A,n as ae,r as oe,t as se}from"./tabs-DsgBuvJv.js";import{t as ce}from"./segmented-control-xkrEOP_d.js";import{t as j}from"./utils-C8uzG5AZ.js";import{n as M,t as N}from"./button-CCcCN8tE.js";import{s as le}from"./shortcuts-BmJZiLby.js";import{a as P,i as F,l as ue,o as I,s as L,t as de}from"./dialog-9LXtFD-0.js";import{t as R}from"./input-CPw-zkYh.js";import{t as fe}from"./textarea-DmATpOqT.js";import{n as z,t as B}from"./PageState-Cz6vFMXv.js";import{a as pe,i as me,n as he,o as ge,r as _e,s as ve,t as ye}from"./FeaturePage-IWVjXcVp.js";import{n as V}from"./field-DoLEb0np.js";import{t as be}from"./AppSelect-DQYKUW5E.js";import{t as H}from"./badge-CWB3lj2H.js";import{i as U}from"./app-primitives-Drz_SjnR.js";import{a as xe,c as Se,f as W,g as G,h as Ce,i as we,l as K,m as Te,n as Ee,o as De,p as Oe,r as ke,s as Ae,t as je,u as Me}from"./memory-api-sER80Rta.js";var Ne=u(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Pe=u(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Fe=u(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),Ie=u(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Le=u(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Re=u(`milestone`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M12 3v3`,key:`1n5kay`}],[`path`,{d:`M18.172 6a2 2 0 0 1 1.414.586l2.06 2.06a1.207 1.207 0 0 1 0 1.708l-2.06 2.06a2 2 0 0 1-1.414.586H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1z`,key:`8gz4t4`}]]),ze=u(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),q=e(i(),1),Be={concept:g,file:m,risk:D,preference:T,decision:Re,fact:f,task:h};function Ve(e,t){return t(e===`file`?`memory:memoryPage.fileType`:e===`risk`?`memory:memoryPage.riskType`:e===`preference`?`memory:memoryPage.preferenceType`:e===`decision`?`memory:memoryPage.decisionType`:e===`fact`?`memory:memoryPage.factType`:e===`task`?`memory:memoryPage.taskType`:`memory:memoryPage.conceptType`)}function He(e,t){return t(e===`manual`?`memory:memoryPage.sourceManual`:e===`user_confirmed`?`memory:memoryPage.sourceUserRequest`:e===`agent`?`memory:memoryPage.sourceAgent`:e===`tool_verified`?`memory:memoryPage.sourceTool`:e===`external`?`memory:memoryPage.sourceExternal`:`memory:memoryPage.sourceConversation`)}function Ue(e,t){return t(e===`assistant`?`memory:memoryPage.roleAssistant`:e===`tool`?`memory:memoryPage.roleTool`:e===`external`?`memory:memoryPage.roleExternal`:e===`manual`?`memory:memoryPage.roleManual`:`memory:memoryPage.roleUser`)}function We(e,t){return[e.pinned&&t(`memory:memoryPage.pinnedBadge`),e.status===`stale`&&t(`memory:memoryPage.staleBadge`),e.tainted&&t(`memory:memoryPage.taintedBadge`),e.status===`archived`&&t(`memory:memoryPage.archivedBadge`),e.status===`superseded`&&t(`memory:memoryPage.supersededBadge`)].filter(e=>!!e)}function J(e,t){return e?.kind===`global`?t(`memory:memoryPage.globalMemorySpace`):e?.name||``}function Y(e,t=`zh-CN`){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(n)}function Ge(e,t=`zh-CN`){if(!e)return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(t,{year:`numeric`,month:`2-digit`,day:`2-digit`}).format(n)}function Ke(e,t){let n={add:{icon:x,label:()=>t(`memory:memoryPage.eventAdd`)},supersede:{icon:ze,label:()=>t(`memory:memoryPage.eventSupersede`)},merge:{icon:Ie,label:()=>t(`memory:memoryPage.eventMerge`)},archive:{icon:d,label:()=>t(`memory:memoryPage.eventArchive`)},expire:{icon:Pe,label:()=>t(`memory:memoryPage.eventExpire`)},stale:{icon:D,label:()=>t(`memory:memoryPage.eventStale`)},confirm:{icon:Ne,label:()=>t(`memory:memoryPage.eventConfirm`)},restore:{icon:w,label:()=>t(`memory:memoryPage.eventRestore`)},edit:{icon:v,label:()=>t(`memory:memoryPage.eventEdit`)},pin:{icon:b,label:()=>t(`memory:memoryPage.eventPin`)},unpin:{icon:y,label:()=>t(`memory:memoryPage.eventUnpin`)},delete:{icon:E,label:()=>t(`memory:memoryPage.eventDelete`)},purge:{icon:Fe,label:()=>t(`memory:memoryPage.eventPurge`)},undo:{icon:_,label:()=>t(`memory:memoryPage.eventUndo`)},reinforce:{icon:S,label:()=>t(`memory:memoryPage.eventReinforce`)},migrate:{icon:C,label:()=>t(`memory:memoryPage.eventMigrate`)},consolidate:{icon:Ie,label:()=>t(`memory:memoryPage.eventConsolidate`)}}[e];return n?{icon:n.icon,label:n.label()}:{icon:C,label:t(`memory:memoryPage.eventGeneric`)}}function qe(e,t){return e===`user`||e===`manual`||e===`user_confirmed`?t(`memory:memoryPage.actorYou`):[`consolidator`,`reconcile`,`lifecycle`].includes(e)?t(`memory:memoryPage.actorConsolidator`):t(e===`conversation`?`memory:memoryPage.actorConversation`:e===`agent`||e===`tool_verified`?`memory:memoryPage.actorAgent`:e===`external`?`memory:memoryPage.sourceExternal`:`memory:memoryPage.actorSystem`)}function Je(e,t){if(e===`same_identity`)return t(`memory:memoryPage.reasonSameIdentity`);if(e===`lower_authority_conflict`)return t(`memory:memoryPage.reasonLowerAuthority`);if(e===`expired`||e===`retention_expired`)return t(`memory:memoryPage.reasonExpired`);if(e===`unused`||e===`low_utility`)return t(`memory:memoryPage.reasonLowUtility`);if(e===`user_deleted`)return t(`memory:memoryPage.reasonUserDeleted`);if(e===`user_requested`)return t(`memory:memoryPage.reasonUserRequested`);let n=/^digests:(\d+) merged:(\d+)$/.exec(e);if(n){let e=Number(n[1]),r=Number(n[2]);return e&&r?t(`memory:memoryPage.reasonConsolidatedBoth`,{digests:e,merged:r}):r?t(`memory:memoryPage.reasonConsolidatedMerged`,{merged:r}):t(`memory:memoryPage.reasonConsolidatedDigests`,{digests:e})}let r=/^promoted (\d+) pending candidates$/.exec(e);return r?t(`memory:memoryPage.reasonPromoted`,{count:Number(r[1])}):e}var X=a(),Ye=50;function Xe({spaceId:e,refreshKey:t,onChanged:n}){let{t:r,language:i}=s(),[a,o]=(0,q.useState)([]),[c,u]=(0,q.useState)(!0),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(``),S=(0,q.useRef)(0),C=e===`all`?``:e,w=(0,q.useCallback)(async()=>{let e=++S.current;u(!0),y(``);try{let t=await Me({spaceId:C,limit:Ye});if(e!==S.current)return;o(t.events),m(t.events.length>=Ye),g(!1)}catch(t){if(e!==S.current)return;t instanceof l&&t.status===404?g(!0):y(t instanceof Error?t.message:String(t))}finally{e===S.current&&u(!1)}},[C]);(0,q.useEffect)(()=>(w(),()=>{S.current+=1}),[w,t]);let T=async()=>{let e=a.at(-1)?.at;if(!e||d)return;let t=S.current;f(!0);try{let n=await Me({spaceId:C,before:e,limit:Ye});if(t!==S.current)return;o(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.events.filter(e=>!t.has(e.id))]}),m(n.events.length>=Ye)}catch(e){t===S.current&&y(e instanceof Error?e.message:String(e))}finally{f(!1)}},E=async e=>{if(!b){x(e.id),y(``);try{await Ce(e.id),await n(r(`memory:memoryPage.eventUndone`))}catch(e){y(e instanceof Error?e.message:String(e))}finally{x(``)}}};return h?(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.activityUnsupported`)}):c&&!a.length?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):v&&!a.length?(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.activityLoadFailed`),description:v,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void w(),children:r(`common:pageTemplate.retry`)})}):a.length?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[v&&(0,X.jsx)(ye,{className:`mt-0`,children:v}),(0,X.jsx)(he,{children:a.map(e=>{let{icon:t,label:n}=Ke(e.action,r),a=e.reason?Je(e.reason,r):``;return(0,X.jsx)(me,{"data-memory-event":e.action,icon:(0,X.jsx)(t,{}),name:n,description:[...new Set(e.titles||[])].join(`、`)||void 0,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Y(e.at,i),` · `,qe(e.actor,r),a?` · ${a}`:``]}),status:e.undoneAt?r(`memory:memoryPage.undone`):void 0,actions:e.undoable?(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,disabled:!!b,"aria-label":`${r(`memory:memoryPage.undo`)}: ${n}`,onClick:()=>void E(e),children:[(0,X.jsx)(_,{}),r(`memory:memoryPage.undo`)]}):void 0},e.id)})}),p&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:d,disabled:d,onClick:()=>void T(),children:r(`memory:memoryPage.loadMore`)})})]}):(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.noActivity`)})}var Z=`flex min-h-[34px] min-w-0 items-center justify-between gap-4 border-t border-stroke-soft text-sm [&>dd]:min-w-0 [&>dd]:truncate [&>dd]:text-right [&>dd]:text-content [&>dt]:shrink-0 [&>dt]:text-content-muted`;function Ze({labels:e}){return(0,X.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:e.map(e=>(0,X.jsx)(H,{children:e},e))})}function Qe({id:e,fallback:t=null,spaces:n,refreshKey:r=0,withHeading:i=!1,onClose:a,onEdit:o,onChanged:c,onDeleted:l,requestConfirm:u}){let{t:d,language:f}=s(),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!0),[_,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(``),[T,D]=(0,q.useState)(!1),[te,ne]=(0,q.useState)(0);(0,q.useEffect)(()=>{let t=new AbortController;return g(!0),x(``),K(e,t.signal).then(e=>{t.signal.aborted||(m(e),g(!1))}).catch(e=>{t.signal.aborted||(x(e instanceof Error?e.message:String(e)),g(!1))}),()=>t.abort()},[e,r,te]);let O=(0,q.useCallback)(async(e,t)=>{D(!0),C(``);try{await e(),await c(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}},[c]),k=p?.item?.id===e?p.item:t,re=p?.item?.id===e?p.history:[],ie=async()=>{if(k&&await u({title:d(`memory:memoryPage.deleteMemory`),message:d(`memory:memoryPage.deleteMemoryName`,{name:k.title}),confirmLabel:d(`memory:memoryPage.delete`)})){D(!0),C(``);try{await xe(k.id),await l(d(`memory:memoryPage.memoryDeleted`))}catch(e){C(e instanceof Error?e.message:String(e)),D(!1)}}};if(!k)return(0,X.jsx)(`div`,{className:`flex min-h-16 items-center gap-2 text-xs text-content-muted`,children:h?(0,X.jsx)(M,{className:`size-4`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{className:`my-0`,children:_||d(`memory:memoryPage.detailLoadFailed`)}),(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>ne(e=>e+1),children:d(`memory:memoryPage.retry`)})]})});let A=n.find(e=>e.id===k.spaceId),ae=k.status===`active`||k.status===`stale`||!k.status,oe=We(k,d);return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,"aria-busy":h||T||void 0,children:[i&&(0,X.jsxs)(`header`,{className:`flex min-w-0 items-start gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h3`,{className:`text-[15px] leading-6 font-medium break-words text-content`,children:k.title}),oe.length>0&&(0,X.jsx)(Ze,{labels:oe})]}),a&&(0,X.jsx)(N,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`-mt-0.5 flex-none max-[650px]:size-11`,"aria-label":d(`memory:memoryPage.closeDetail`),onClick:a,children:(0,X.jsx)(ee,{})})]}),(0,X.jsx)(`p`,{className:`text-[13px] leading-normal break-words whitespace-pre-wrap text-content-secondary`,children:k.content}),k.status===`stale`&&(0,X.jsx)(`p`,{className:`text-xs leading-normal text-content-muted`,children:d(`memory:memoryPage.staleHint`)}),k.tainted&&(0,X.jsx)(`p`,{className:`text-xs leading-normal text-content-muted`,children:d(`memory:memoryPage.taintedHint`)}),(0,X.jsxs)(`dl`,{className:`m-0`,children:[(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.memoryType`)}),(0,X.jsx)(`dd`,{children:Ve(k.type,d)})]}),A&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.memorySpace`)}),(0,X.jsx)(`dd`,{children:J(A,d)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.source`)}),(0,X.jsx)(`dd`,{children:He(k.sourceType,d)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.validFrom`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.validFrom,f)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.validTo`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:k.validTo?Y(k.validTo,f):d(`memory:memoryPage.stillValid`)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.created`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.createdAt,f)})]}),(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.confirmCount`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:k.confirmCount??1})]}),k.expiresAt&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.expires`)}),(0,X.jsx)(`dd`,{className:`tabular-nums`,children:Y(k.expiresAt,f)})]}),k.sourcePath&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.relatedFilePath`)}),(0,X.jsx)(`dd`,{className:`font-mono text-xs`,title:k.sourcePath,children:k.sourcePath})]}),k.archiveReason&&(0,X.jsxs)(`div`,{className:Z,children:[(0,X.jsx)(`dt`,{children:d(`memory:memoryPage.archiveReason`)}),(0,X.jsx)(`dd`,{title:Je(k.archiveReason,d),children:Je(k.archiveReason,d)})]})]}),k.evidence&&(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":d(`memory:memoryPage.evidence`),children:[(0,X.jsxs)(`h4`,{className:`mb-1 text-xs font-medium text-content-muted`,children:[d(`memory:memoryPage.evidenceFrom`),` · `,Ue(k.evidenceRole,d)]}),(0,X.jsx)(`blockquote`,{className:`m-0 border-l-2 border-stroke pl-2.5 text-xs leading-normal break-words whitespace-pre-wrap text-content-secondary`,children:k.evidence})]}),re.length>1&&(0,X.jsxs)(`section`,{className:`min-w-0`,"aria-label":d(`memory:memoryPage.versionHistory`),children:[(0,X.jsxs)(`h4`,{className:`mb-1 text-xs font-medium text-content-muted tabular-nums`,children:[d(`memory:memoryPage.versionHistory`),` · `,re.length]}),(0,X.jsx)(`ol`,{"data-memory-history":!0,className:`m-0 flex list-none flex-col p-0`,children:re.map(e=>{let t=e.status===`active`||e.status===`stale`;return(0,X.jsxs)(`li`,{"aria-current":e.id===k.id||void 0,className:j(`flex min-w-0 flex-col gap-0.5 border-t border-stroke-soft py-1.5 text-xs leading-normal`,!t&&`text-content-muted`),children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 tabular-nums`,children:[Ge(e.validFrom,f),t&&(0,X.jsx)(H,{children:d(`memory:memoryPage.currentVersion`)})]}),(0,X.jsx)(`span`,{className:`break-words whitespace-pre-wrap`,children:e.content})]},e.id)})})]}),S&&(0,X.jsx)(U,{className:`my-0`,children:S}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,X.jsxs)(N,{variant:`ghost`,size:`sm`,className:`text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,disabled:T,onClick:()=>void ie(),children:[(0,X.jsx)(E,{}),d(`memory:memoryPage.delete`)]}),ae?(0,X.jsxs)(X.Fragment,{children:[k.status===`stale`&&(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,`confirm`),d(`memory:memoryPage.confirmed`)),children:[(0,X.jsx)(Ne,{}),d(`memory:memoryPage.confirmStillValid`)]}),(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,k.pinned?`unpin`:`pin`),k.pinned?d(`memory:memoryPage.unpinned`):d(`memory:memoryPage.pinned`)),children:[k.pinned?(0,X.jsx)(y,{}):(0,X.jsx)(b,{}),k.pinned?d(`memory:memoryPage.unpin`):d(`memory:memoryPage.pin`)]}),(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>o(k),children:[(0,X.jsx)(v,{}),d(`memory:memoryPage.edit`)]})]}):(0,X.jsxs)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:T,onClick:()=>void O(()=>Oe(k.id,`restore`),d(`memory:memoryPage.restored`)),children:[(0,X.jsx)(w,{}),d(`memory:memoryPage.restore`)]})]})]})}var $e=[`concept`,`file`,`risk`,`preference`,`decision`,`fact`,`task`],et=[.3,.5,.8,1];function tt(e){let t=e??.5;return et.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function nt(e){return e instanceof Error?e.message:String(e)}function rt({spaces:e,node:t,initialSpaceId:n,onClose:r,onSaved:i}){let{t:a}=s(),[o,c]=(0,q.useState)({spaceId:t?.spaceId||n||e[0]?.id||``,title:t?.title||``,content:t?.content||``,type:t?.type||`concept`,sourcePath:t?.sourcePath||``,importance:tt(t?.importance)}),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(``),p=a(t?`memory:memoryPage.editMemory`:`memory:memoryPage.addMemory`),m=async e=>{if(e.preventDefault(),!l){u(!0),f(``);try{t?await G(t.id,o):await ke(o),await i(a(t?`memory:memoryPage.memoryUpdated`:`memory:memoryPage.memoryCreated`))}catch(e){f(nt(e))}finally{u(!1)}}};return(0,X.jsx)(de,{open:!0,busy:l,onOpenChange:e=>!e&&r(),children:(0,X.jsx)(F,{size:`compact`,children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-3`,onSubmit:e=>void m(e),children:[(0,X.jsxs)(L,{children:[(0,X.jsx)(ue,{children:p}),(0,X.jsx)(P,{children:a(`memory:memoryPage.memoryDialogHint`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryTitle`),(0,X.jsx)(R,{value:o.title,onChange:e=>c({...o,title:e.target.value}),placeholder:a(`memory:memoryPage.forExampleProjectUIConstraints`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryContent`),(0,X.jsx)(fe,{value:o.content,onChange:e=>c({...o,content:e.target.value}),placeholder:a(`memory:memoryPage.recordStandaloneReusableMemoryForFutureChats`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memorySpace`),(0,X.jsx)(be,{value:o.spaceId,onChange:e=>c({...o,spaceId:e.target.value}),children:e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:J(e,a)},e.id))})]}),(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-x-2.5 gap-y-3 sm:grid-cols-2`,children:[(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.memoryType`),(0,X.jsx)(be,{value:o.type,onChange:e=>c({...o,type:e.target.value}),children:$e.map(e=>(0,X.jsx)(`option`,{value:e,children:Ve(e,a)},e))})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.importance`),(0,X.jsxs)(be,{value:o.importance,onChange:e=>c({...o,importance:Number(e.target.value)}),children:[(0,X.jsx)(`option`,{value:`0.3`,children:a(`memory:memoryPage.normal`)}),(0,X.jsx)(`option`,{value:`0.5`,children:a(`memory:memoryPage.common`)}),(0,X.jsx)(`option`,{value:`0.8`,children:a(`memory:memoryPage.important`)}),(0,X.jsx)(`option`,{value:`1`,children:a(`memory:memoryPage.strict`)})]})]})]}),(0,X.jsxs)(V,{variant:`control`,children:[a(`memory:memoryPage.relatedFilePath`),(0,X.jsx)(R,{value:o.sourcePath,onChange:e=>c({...o,sourcePath:e.target.value}),placeholder:a(`memory:memoryPage.optionalForExampleECodeProjectREADMEMd`)})]}),d&&(0,X.jsx)(U,{children:d}),(0,X.jsxs)(I,{children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:l,onClick:r,children:a(`memory:memoryPage.cancel`)}),(0,X.jsxs)(N,{type:`submit`,size:`dialogAction`,disabled:l||!o.spaceId||!o.title.trim()||!o.content.trim(),children:[l&&(0,X.jsx)(M,{className:`text-current`}),a(l?`memory:memoryPage.saving`:`memory:memoryPage.save`)]})]})]})})})}function it({space:e,onClose:t,onSaved:n}){let{t:r}=s(),[i,a]=(0,q.useState)(e?.name||``),[o,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(``),d=r(e?`memory:memoryPage.renameMemorySpace`:`memory:memoryPage.newMemorySpace`),f=async t=>{if(t.preventDefault(),!o){c(!0),u(``);try{await n(e?await Te(e.id,i):await we(i),r(e?`memory:memoryPage.memorySpaceRenamed`:`memory:memoryPage.memorySpaceCreated`))}catch(e){u(nt(e))}finally{c(!1)}}};return(0,X.jsx)(de,{open:!0,busy:o,onOpenChange:e=>!e&&t(),children:(0,X.jsx)(F,{size:`compact`,children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-3`,onSubmit:e=>void f(e),children:[(0,X.jsxs)(L,{children:[(0,X.jsx)(ue,{children:d}),(0,X.jsx)(P,{children:r(`memory:memoryPage.memorySpaceHint`)})]}),(0,X.jsxs)(V,{variant:`control`,children:[r(`memory:memoryPage.memorySpaceName`),(0,X.jsx)(R,{value:i,onChange:e=>a(e.target.value),placeholder:r(`memory:memoryPage.forExampleProductDesignGuidelines`),autoFocus:!0})]}),l&&(0,X.jsx)(U,{children:l}),(0,X.jsxs)(I,{children:[(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:o,onClick:t,children:r(`memory:memoryPage.cancel`)}),(0,X.jsxs)(N,{type:`submit`,size:`dialogAction`,disabled:o||!i.trim(),children:[o&&(0,X.jsx)(M,{className:`text-current`}),r(o?`memory:memoryPage.saving`:`memory:memoryPage.save`)]})]})]})})})}var at=30;function ot({digest:e}){let{t}=s(),r=n(),[i,a]=(0,q.useState)([]);return(0,q.useEffect)(()=>{let t=new AbortController;return K(e.id,t.signal).then(e=>a(e.children||[]),()=>a([])),()=>t.abort()},[e.id]),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsx)(`p`,{className:`m-0 text-sm leading-relaxed break-words whitespace-pre-wrap`,children:e.text}),i.length>0&&(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`m-0 text-xs font-medium text-content-muted`,children:t(`memory:memoryPage.sessionFacts`)}),(0,X.jsx)(`ul`,{className:`m-0 mt-1 list-disc pl-4 text-sm leading-relaxed`,children:i.map(e=>(0,X.jsx)(`li`,{className:`break-words`,children:e.title},e.id))})]}),e.sessionAvailable&&(0,X.jsx)(`div`,{children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,onClick:()=>r(o(e.sessionId)),children:t(`memory:memoryPage.openSession`)})})]})}function st({spaceId:e,spaces:t,refreshKey:n}){let{t:r,language:i}=s(),[a,o]=(0,q.useState)([]),[c,u]=(0,q.useState)(!0),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(``),x=(0,q.useRef)(0),S=e===`all`?``:e,C=(0,q.useCallback)(async()=>{let e=++x.current;u(!0),v(``);try{let t=await W({spaceId:S,limit:at});if(e!==x.current)return;o(t.sessions),m(t.sessions.length>=at),g(!1)}catch(t){if(e!==x.current)return;t instanceof l&&t.status===404?g(!0):v(t instanceof Error?t.message:String(t))}finally{e===x.current&&u(!1)}},[S]);(0,q.useEffect)(()=>(C(),()=>{x.current+=1}),[C,n]);let w=async()=>{let e=a.at(-1)?.windowEnd;if(!e||d)return;let t=x.current;f(!0);try{let n=await W({spaceId:S,before:e,limit:at});if(t!==x.current)return;o(e=>{let t=new Set(e.map(e=>e.id));return[...e,...n.sessions.filter(e=>!t.has(e.id))]}),m(n.sessions.length>=at)}catch(e){t===x.current&&v(e instanceof Error?e.message:String(e))}finally{f(!1)}};return h?(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.sessionsUnsupported`)}):c&&!a.length?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):_&&!a.length?(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.sessionsLoadFailed`),description:_,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void C(),children:r(`common:pageTemplate.retry`)})}):a.length?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[_&&(0,X.jsx)(ye,{className:`mt-0`,children:_}),(0,X.jsx)(he,{children:a.map(n=>{let a=n.sessionName||r(`memory:memoryPage.sessionUntitled`),o=t.find(e=>e.id===n.spaceId);return(0,X.jsx)(me,{"data-memory-session":n.sessionId,icon:(0,X.jsx)(Le,{}),name:a,description:y===n.id?void 0:n.text,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Y(n.windowEnd,i),e===`all`&&o?` · ${J(o,r)}`:``]}),expanded:y===n.id,onExpandedChange:e=>b(e?n.id:``),toggleLabel:a,detail:(0,X.jsx)(ot,{digest:n})},n.id)})}),p&&(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:d,disabled:d,onClick:()=>void w(),children:r(`memory:memoryPage.loadMore`)})})]}):(0,X.jsx)(B,{compact:!0,title:r(`memory:memoryPage.noSessionDigests`)})}var ct=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate());function lt(e){let t=ct(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()-(t.getDay()+6)%7)}function ut(e,t,n=Date.now()){let r=new Date(n),i=ct(r).getTime(),a=i-864e5,o=lt(r).getTime(),s=new Map,c=(e,t)=>{let n=s.get(e.key);n?n.items.push(t):s.set(e.key,{...e,items:[t]})};for(let n of e){let e=Date.parse(t(n)||``);if(Number.isNaN(e))c({key:`unknown`,kind:`unknown`},n);else if(e>=i)c({key:`today`,kind:`today`},n);else if(e>=a)c({key:`yesterday`,kind:`yesterday`},n);else if(e>=o)c({key:`week`,kind:`week`},n);else{let t=new Date(e);c({key:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}`,kind:`month`,month:new Date(t.getFullYear(),t.getMonth(),1)},n)}}return[...s.values()]}var dt=(0,q.lazy)(()=>t(()=>import(`./MemoryEvolution-DG9gtC6n.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]))),Q=`all`;function ft(){try{let e=r.getItem(c.memoryView);return e===`timeline`||e===`sessions`||e===`activity`?e:`evolution`}catch{return`evolution`}}function pt(e){try{r.setItem(c.memoryView,e)}catch{}}function $(e){return e instanceof Error?e.message:String(e)}var mt={spaces:[],selectedSpaceId:``,nodes:[]};function ht({notify:e,onBack:t,requestConfirm:n}){let{t:r,language:i}=s(),a=le(`focusSearch`),[o,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(ft),[d,f]=(0,q.useState)(Q),[m,h]=(0,q.useState)(`current`),[g,_]=(0,q.useState)(mt),[v,y]=(0,q.useState)(!0),[b,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(``),[ee,j]=(0,q.useState)(``),[M,P]=(0,q.useState)(null),[F,ue]=(0,q.useState)(0),[I,L]=(0,q.useState)(null),[de,R]=(0,q.useState)(null),[fe,V]=(0,q.useState)(!1),H=(0,q.useRef)(0),U=(0,q.useCallback)(async()=>{let e=++H.current;y(!0),D(``);try{let t=await Se({spaceId:d,query:o,status:m});if(e!==H.current)return;_(t),T(!0),t.selectedSpaceId&&t.selectedSpaceId!==d&&f(t.selectedSpaceId)}catch(t){e===H.current&&D($(t))}finally{e===H.current&&y(!1)}},[o,d,m]);(0,q.useEffect)(()=>(U(),()=>{H.current+=1}),[U,F]);let xe=async()=>{let e=g.nodes.at(-1),t=e?.validFrom||e?.createdAt;if(!t||b)return;let n=H.current;C(!0);try{let e=await Se({spaceId:d,status:m,before:t});if(n!==H.current)return;_(t=>{let n=new Set(t.nodes.map(e=>e.id));return{...e,nodes:[...t.nodes,...e.nodes.filter(e=>!n.has(e.id))]}})}catch(e){n===H.current&&D($(e))}finally{C(!1)}},W=(0,q.useCallback)(()=>ue(e=>e+1),[]),G=(0,q.useCallback)(t=>{e(t),W()},[e,W]),Ce=(0,q.useCallback)(e=>{j(``),P(null),G(e)},[G]),we=(0,q.useMemo)(()=>[...g.spaces].sort((e,t)=>Number(t.kind===`global`)-Number(e.kind===`global`)),[g.spaces]),K=g.spaces.find(e=>e.id===d)||null,Te=!!o.trim(),Oe=(0,q.useMemo)(()=>ut(g.nodes,e=>e.validFrom||e.createdAt),[g.nodes]),ke=e=>{let t=e;u(t),pt(t)},Me=e=>{c(e),j(``),e.trim()&&l!==`timeline`&&u(`timeline`)},Ne=e=>{f(e),j(``),P(null)},Pe=async()=>{if(K&&await n({title:r(`memory:memoryPage.deleteMemorySpace`),message:r(`memory:memoryPage.deleteMemorySpaceNameAndAllMemoriesInIt`,{name:J(K,r)}),confirmLabel:r(`memory:memoryPage.delete`)}))try{await De(K.id),Ne(Q),G(r(`memory:memoryPage.memorySpaceDeleted`))}catch(e){D($(e))}},Fe=async()=>{try{let{markdown:t}=await Ae(d===Q?``:d),n=URL.createObjectURL(new Blob([t],{type:`text/markdown;charset=utf-8`})),i=document.createElement(`a`);i.href=n,i.download=`pisper-memory-${new Date().toISOString().slice(0,10)}.md`,i.click(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),e(r(`memory:memoryPage.exported`))}catch(e){D($(e))}},Ie=async()=>{if(!fe){V(!0),D(``);try{let e=await Ee();G(e.ran?r(`memory:memoryPage.consolidated`):r(`memory:memoryPage.nothingToConsolidate`))}catch(e){D($(e))}finally{V(!1)}}},Le=async()=>{if(await n({title:r(`memory:memoryPage.clearEpisodes`),message:r(`memory:memoryPage.clearEpisodesConfirm`),confirmLabel:r(`memory:memoryPage.clearEpisodesAction`)}))try{let{cleared:e}=await je(d===Q?``:d);G(r(`memory:memoryPage.episodesCleared`,{count:e}))}catch(e){D($(e))}},Re=!!K&&K?.kind!==`global`,ze=e=>(0,X.jsx)(Qe,{id:e.id,fallback:e,spaces:g.spaces,refreshKey:F,onEdit:L,onChanged:G,onDeleted:Ce,requestConfirm:n}),Ue=e=>{let t=Be[e.type]||Be.concept,n=We(e,r),a=g.spaces.find(t=>t.id===e.spaceId);return(0,X.jsx)(me,{"data-memory-node":e.id,icon:(0,X.jsx)(t,{}),name:e.title,nameMeta:Ve(e.type,r),description:ee===e.id?void 0:e.content,meta:(0,X.jsxs)(`span`,{className:`truncate tabular-nums`,children:[Ge(e.validFrom||e.createdAt,i),d===Q&&a?` · ${J(a,r)}`:``,` · ${He(e.sourceType,r)}`]}),status:n.length?(0,X.jsx)(Ze,{labels:n}):void 0,expanded:ee===e.id,onExpandedChange:t=>j(t?e.id:``),toggleLabel:e.title,detail:ze(e)},e.id)},Y=e=>e.kind===`today`?r(`memory:memoryPage.groupToday`):e.kind===`yesterday`?r(`memory:memoryPage.groupYesterday`):e.kind===`week`?r(`memory:memoryPage.groupThisWeek`):e.kind===`unknown`||!e.month?r(`memory:memoryPage.groupUnknown`):new Intl.DateTimeFormat(i,{year:`numeric`,month:`long`}).format(e.month),Ke=r(Te?`memory:memoryPage.noMatchingMemories`:m===`archived`?`memory:memoryPage.noArchivedMemories`:m===`history`?`memory:memoryPage.noHistoryVersions`:`memory:memoryPage.noMemoriesInSpace`);return(0,X.jsx)(se,{asChild:!0,value:l,onValueChange:ke,className:`gap-0`,children:(0,X.jsxs)(_e,{title:r(`navigation:navigation.memory`),description:r(`memory:memoryPage.lede`),back:t&&{label:r(`navigation:sidebar.features`),ariaLabel:r(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,X.jsx)(ve,{search:(0,X.jsx)(pe,{id:te,value:o,onValueChange:Me,placeholder:r(`navigation:pageHeader.searchMemoriesOrFiles`),shortcut:a,clearLabel:r(`navigation:more.clearSearch`)}),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(N,{type:`button`,className:`h-9`,disabled:!w,onClick:()=>L({spaceId:d===Q?`global`:d}),children:[(0,X.jsx)(x,{}),r(`memory:memoryPage.addMemory`)]}),(0,X.jsxs)(ie,{children:[(0,X.jsx)(k,{asChild:!0,children:(0,X.jsx)(N,{type:`button`,variant:`secondary`,size:`icon-lg`,className:`max-[650px]:max-w-11`,disabled:!w,"aria-label":r(`memory:memoryPage.moreActions`),title:r(`memory:memoryPage.moreActions`),children:(0,X.jsx)(p,{})})}),(0,X.jsxs)(re,{align:`end`,children:[(0,X.jsx)(O,{onSelect:()=>R(`new`),children:r(`memory:memoryPage.newMemorySpace`)}),(0,X.jsx)(O,{disabled:!Re,onSelect:()=>K&&R(K),children:r(`memory:memoryPage.renameMemorySpace`)}),(0,X.jsx)(O,{variant:`destructive`,disabled:!Re,onSelect:()=>void Pe(),children:r(`memory:memoryPage.deleteMemorySpace`)}),(0,X.jsx)(ne,{}),(0,X.jsx)(O,{onSelect:()=>void Fe(),children:r(`memory:memoryPage.exportMarkdown`)}),(0,X.jsx)(O,{disabled:fe,onSelect:()=>void Ie(),children:r(`memory:memoryPage.consolidateNow`)}),(0,X.jsx)(O,{onSelect:()=>void Le(),children:r(`memory:memoryPage.clearEpisodes`)})]})]})]}),filters:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(oe,{"aria-label":r(`memory:memoryPage.viewsLabel`),children:[(0,X.jsx)(A,{value:`evolution`,children:r(`memory:memoryPage.evolutionView`)}),(0,X.jsx)(A,{value:`timeline`,children:r(`memory:memoryPage.timelineView`)}),(0,X.jsx)(A,{value:`sessions`,children:r(`memory:memoryPage.sessionsView`)}),(0,X.jsx)(A,{value:`activity`,children:r(`memory:memoryPage.activityView`)})]}),(0,X.jsxs)(be,{className:`w-[200px] max-w-full max-[650px]:w-full`,"aria-label":r(`memory:memoryPage.memorySpace`),value:d,disabled:!w,onChange:e=>Ne(e.target.value),children:[(0,X.jsx)(`option`,{value:Q,children:r(`memory:memoryPage.allSpaces`)}),we.map(e=>(0,X.jsx)(`option`,{value:e.id,children:`${J(e,r)} · ${e.nodeCount}`},e.id))]})]}),l===`timeline`&&w&&(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[Te?(0,X.jsxs)(`p`,{className:`m-0 text-[13px] font-medium text-content-muted tabular-nums`,children:[r(`memory:memoryPage.searchResults`),` · `,g.nodes.length]}):(0,X.jsx)(ce,{"aria-label":r(`memory:memoryPage.statusFilterLabel`),value:m,onValueChange:e=>{h(e),j(``)},options:[{value:`current`,label:r(`memory:memoryPage.statusCurrent`),count:g.counts?.current},{value:`archived`,label:r(`memory:memoryPage.statusArchived`),count:g.counts?.archived},{value:`history`,label:r(`memory:memoryPage.statusHistory`),count:g.counts?.history}]}),(0,X.jsx)(N,{variant:`ghost`,size:`icon-sm`,className:`text-content-muted max-[650px]:size-11`,loading:v,disabled:v,"aria-label":r(`memory:memoryPage.refresh`),title:r(`memory:memoryPage.refresh`),onClick:W,children:(0,X.jsx)(S,{})})]})]})}),children:[!w&&v?(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}):w?(0,X.jsxs)(X.Fragment,{children:[E&&(0,X.jsx)(ye,{children:E}),(0,X.jsxs)(`div`,{className:`mt-5 min-w-0`,"aria-busy":v,children:[(0,X.jsxs)(ae,{value:`evolution`,className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsx)(q.Suspense,{fallback:(0,X.jsx)(z,{kind:`loading`,title:r(`common:pageTemplate.loading`)}),children:(0,X.jsx)(dt,{spaceId:d,refreshKey:F,selectedId:M,onSelect:P})}),(0,X.jsx)(`div`,{role:`region`,"data-memory-detail":!0,"aria-label":r(`memory:memoryPage.selectedMemory`),className:`min-w-0 rounded-[var(--r-md)] border border-stroke px-4 py-3`,children:M?(0,X.jsx)(Qe,{id:M,spaces:g.spaces,refreshKey:F,withHeading:!0,onClose:()=>P(null),onEdit:L,onChanged:G,onDeleted:Ce,requestConfirm:n}):(0,X.jsx)(`p`,{className:`m-0 text-xs leading-normal text-content-muted`,children:r(`memory:memoryPage.selectAMemoryToViewDetails`)})})]}),(0,X.jsxs)(ae,{value:`timeline`,className:`min-w-0`,"data-memory-timeline":!0,children:[g.nodes.length?Te?(0,X.jsx)(he,{children:g.nodes.map(Ue)}):Oe.map(e=>(0,X.jsx)(ge,{"data-memory-group":e.key,className:`mt-5 first:mt-0`,title:Y(e),count:e.items.length,children:(0,X.jsx)(he,{children:e.items.map(Ue)})},e.key)):(0,X.jsx)(B,{compact:!0,title:Ke}),!Te&&g.hasMore&&(0,X.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,X.jsx)(N,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,loading:b,disabled:b,onClick:()=>void xe(),children:r(`memory:memoryPage.loadMore`)})})]}),(0,X.jsx)(ae,{value:`sessions`,className:`min-w-0`,children:(0,X.jsx)(st,{spaceId:d,spaces:g.spaces,refreshKey:F})}),(0,X.jsx)(ae,{value:`activity`,className:`min-w-0`,children:(0,X.jsx)(Xe,{spaceId:d,refreshKey:F,onChanged:G})})]})]}):(0,X.jsx)(z,{kind:`error`,title:r(`memory:memoryPage.loadFailed`),description:E,action:(0,X.jsx)(N,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>void U(),children:r(`common:pageTemplate.retry`)})}),I&&(0,X.jsx)(rt,{spaces:we,node:`id`in I?I:null,initialSpaceId:I.spaceId,onClose:()=>L(null),onSaved:e=>{L(null),G(e)}}),de&&(0,X.jsx)(it,{space:de===`new`?null:de,onClose:()=>R(null),onSaved:(e,t)=>{R(null),Ne(e.id),G(t)}})]})})}export{ht as MemoryPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-CaxKosZm.js";import{t as i}from"./useQuery-DdcpUQhO.js";import{a,l as o}from"./api-MVoWVwmh.js";import{a as s,n as c,t as l}from"./runtime-capabilities-CHYOF_hE.js";import{t as u}from"./runtime-capabilities-store-SnV1V9_K.js";import{m as d}from"./placements-BDYSXHzl.js";import{t as ee}from"./client-store-DvE_NEoR.js";import{t as f}from"./usePhoneShell-0IX6-LbH.js";import{t as p}from"./createLucideIcon-Cd-3GVxJ.js";import{t as m}from"./app-window-CPNdvYNt.js";import{t as h}from"./blocks-Olsdp5Lp.js";import{t as g}from"./bot-B3TaBp_T.js";import{t as _}from"./brain-qxhnKqYP.js";import{t as v}from"./calendar-clock-VIxTaqqy.js";import{t as y}from"./chevron-right-C3t2Rckj.js";import{t as b}from"./image-BY_c3FYU.js";import{t as x}from"./monitor-smartphone-B1gIjItA.js";import{t as S}from"./plug-BsIeHRwC.js";import{t as C}from"./plus-fQbSqB1n.js";import{t as w}from"./radio-tower-jGQwrFWB.js";import{t as T}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as E}from"./search-D0mqDaf_.js";import{t as te}from"./server-BgNvmqwJ.js";import{t as ne}from"./sparkles-S_eeuqn9.js";import{t as re}from"./workflow-Bg94dy8I.js";import{t as D}from"./x-07u4-129.js";import{t as O}from"./brand-DIEc3fK8.js";import{i as k}from"./more-pages-D_PnxLN0.js";import{t as A}from"./utils-C8uzG5AZ.js";import{t as j}from"./button-CCcCN8tE.js";import{t as M}from"./kbd-CAufZTkl.js";import{g as ie}from"./events-oPlZB-qC.js";import{n as N,r as P}from"./config-search-Cr0TsTRS.js";import{s as F}from"./shortcuts-BmJZiLby.js";var I=p(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),L=e(t(),1),R=`add:component`;function z(e,{capabilities:t=l,mobileApp:n=!1,components:r=[]}={}){let i=(e,n,r,i)=>s(t,e)?{key:`page:${e}`,label:n,description:r,icon:i,destination:{type:`page`,id:e}}:null,a=e=>c(t,e,{mobileApp:n}),o=a(`remote-access`),u=a(`desktop-pet`),d=[a(`mobile-server`).supported?{key:`config:mobile-server`,label:e(`config:configPage.mobileServer`),description:e(`navigation:more.mobileServerHint`),icon:x,destination:{type:`config`,id:`mobile-server`}}:o.supported?{key:`config:remote-access`,label:e(`config:configPage.remoteAccess`),description:e(`navigation:more.remoteAccessHint`),icon:x,destination:{type:`config`,id:`remote-access`}}:null,u.supported||u.reason===`desktop-only`?{key:`config:desktop-pet`,label:e(`config:configPage.desktopPet`),description:e(`navigation:more.desktopPetHint`),icon:g,destination:{type:`config`,id:`desktop-pet`},...u.supported?{}:{disabledReason:e(`navigation:more.desktopOnly`)}}:null];return[{id:`sessions`,label:e(`navigation:more.groupSessions`),tiles:[i(`chatHistory`,e(`navigation:navigation.chatHistory`),e(`navigation:more.chatHistoryHint`),T),i(`assets`,e(`navigation:navigation.assets`),e(`navigation:more.assetsHint`),b),i(`memory`,e(`navigation:navigation.memory`),e(`navigation:more.memoryHint`),_)]},{id:`automation`,label:e(`navigation:more.groupAutomation`),tiles:[i(`workflows`,e(`navigation:navigation.workflows`),e(`navigation:more.workflowsHint`),re),i(`schedules`,e(`navigation:navigation.schedules`),e(`navigation:more.schedulesHint`),v),i(`channels`,e(`navigation:navigation.channels`),e(`navigation:more.channelsHint`),w)]},{id:`extensions`,label:e(`navigation:more.groupExtensions`),tiles:[i(`plugins`,e(`navigation:navigation.plugins`),e(`navigation:more.pluginsHint`),S),i(`skills`,e(`navigation:navigation.skills`),e(`navigation:more.skillsHint`),ne),i(`mcp`,e(`navigation:navigation.mcp`),e(`navigation:more.mcpHint`),te),{key:`page:components`,label:e(`navigation:shell.components`),description:e(`navigation:more.componentStudioHint`),icon:h,destination:{type:`page`,id:`components`}}]},{id:`devices`,label:e(`navigation:more.groupDevices`),tiles:d},{id:`components`,label:e(`navigation:more.groupComponents`),tiles:[...r.map(t=>({key:`component:${t.id}`,label:t.name,description:t.description||e(`navigation:more.componentHint`),icon:m,destination:{type:`component`,id:t.id}})),{key:R,label:e(`navigation:more.addComponent`),description:e(`navigation:more.addComponentHint`),icon:C,destination:{type:`page`,id:`components`}}]}].map(e=>({id:e.id,label:e.label,tiles:e.tiles.filter(e=>e!==null)})).filter(e=>e.tiles.length>0)}function B(e,t,n){let r=t.trim().toLocaleLowerCase(n);return r?e.map(e=>({...e,tiles:e.tiles.filter(t=>[t.label,t.description,e.label].some(e=>e.toLocaleLowerCase(n).includes(r)))})).filter(e=>e.tiles.length>0):[...e]}var V=new Set([`connected`,`connecting`,`reconnecting`]);function H(e){let t=e&&typeof e==`object`?e.connections:null;if(!t||typeof t!=`object`||Array.isArray(t))throw o();let n=0;for(let e of Object.values(t)){if(!e||typeof e!=`object`)continue;let{enabled:t,status:r}=e;t!==!1&&(typeof r!=`string`||!V.has(r))&&(n+=1)}return n}function U(e){return a(`/api/channels`,{signal:e,parse:H})}function W(e){let t=e&&typeof e==`object`?e.metrics:null,n=t&&typeof t==`object`?t.onlineServices:void 0;if(typeof n!=`number`||!Number.isFinite(n)||n<0)throw o();return Math.floor(n)}function G(e){return a(`/api/mcp?refresh=0`,{signal:e,parse:W})}function K(e){let t=e&&typeof e==`object`?e.tasks:null;if(!Array.isArray(t))throw o();return t.filter(e=>e&&typeof e==`object`&&e.enabled===!0).length}function q(e){return a(`/api/schedules`,{signal:e,parse:K})}function J(e){let t=e&&typeof e==`object`?e.limits:null,n=t&&typeof t==`object`?t.running:void 0;if(typeof n!=`number`||!Number.isFinite(n)||n<0)throw o();return Math.floor(n)}function ae(e){return a(`/api/workflows`,{signal:e,parse:J})}var Y=[{key:`page:workflows`,load:ae,tone:`run`,interval:15e3},{key:`page:schedules`,load:q,tone:`neutral`,interval:6e4},{key:`page:channels`,load:U,tone:`attn`,interval:3e4},{key:`page:mcp`,load:G,tone:`neutral`,interval:6e4}];function X(e,t){return i({queryKey:[`more-tile-badge`,e.key],queryFn:({signal:t})=>e.load(t),enabled:t,staleTime:1e4,refetchInterval:t?e.interval:!1,retry:!1}).data}function oe(e,t){let n=[X(Y[0],t.has(Y[0].key)),X(Y[1],t.has(Y[1].key)),X(Y[2],t.has(Y[2].key)),X(Y[3],t.has(Y[3].key))],r=[t=>e(`navigation:more.badgeRunning`,{count:t}),t=>e(`navigation:more.badgeEnabled`,{count:t}),t=>e(`navigation:more.badgeDisconnected`,{count:t}),t=>e(`navigation:more.badgeOnline`,{count:t})],i=new Map;return Y.forEach((e,a)=>{let o=n[a];typeof o==`number`&&o>0&&t.has(e.key)&&i.set(e.key,{label:r[a](o),tone:e.tone})}),i}var Z=n(),se=6,Q=`[data-more-tile]`,$=``;function ce(e,t){return e?.querySelector(`[data-more-tile="${CSS.escape(t)}"]`)??null}function le({onOpen:e}){let{t,language:n}=r(),i=(0,L.useId)(),[a,o]=(0,L.useState)(``),s=F(`commandPalette`),c=F(`focusSearch`),l=u(e=>e.capabilities),p=ee(e=>e.client===`mobile-app`),m=f(),h=t(`navigation:more.title`),g=d(),_=(0,L.useMemo)(()=>g.items.map(({componentId:e,name:t,description:n})=>({id:e,name:t,description:n})),[g.items]),v=(0,L.useMemo)(()=>z(t,{capabilities:l,mobileApp:p,components:_}),[l,_,p,t]),b=(0,L.useMemo)(()=>B(v,a,n),[v,n,a]),x=oe(t,(0,L.useMemo)(()=>new Set(v.flatMap(e=>e.tiles.map(e=>e.key))),[v])),S=(0,L.useMemo)(()=>a.trim()?P(a,n,{capabilities:l,mobileApp:p}).slice(0,se):[],[l,n,p,a]);(0,L.useEffect)(()=>(document.title=`${h} · ${O}`,()=>{document.title=O}),[h]);let C=t=>{if(t.entry.card===`interface-custom-ui`){e({type:`page`,id:`components`});return}N(t.entry.card,t.entry.section,{targetId:t.entry.targetId,targetText:t.title,expandGroup:t.entry.expandGroup}),e({type:`config`,id:t.entry.section})},w=(0,Z.jsxs)(j,{variant:`outline`,className:`h-auto min-h-11 w-full justify-start gap-2.5 py-2 text-left whitespace-normal`,"data-more-palette-search":!0,onClick:()=>ie(a.trim()),children:[m?(0,Z.jsx)(E,{className:`flex-none`,"aria-hidden":`true`}):(0,Z.jsx)(I,{className:`flex-none`,"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-content`,children:t(`navigation:more.searchPalette`,{query:a.trim()})}),(0,Z.jsx)(`span`,{className:`text-xs font-normal text-content-muted`,children:t(`navigation:more.searchPaletteHint`)})]})]}),T=`mb-2 text-[13px] font-medium text-content-muted`;return(0,L.useLayoutEffect)(()=>{let e=document.querySelector(`[data-features-index]`),t=$;$=``;let n=0,r=0,i=!t,a=()=>{let o=ce(e,t);o?(o.focus(),i=!0):(n+=1)<20?r=requestAnimationFrame(a):i=!0};return t&&(r=requestAnimationFrame(a)),()=>{cancelAnimationFrame(r),i||($=t);let n=document.activeElement,a=n instanceof HTMLElement&&e?.contains(n)?n.closest(Q):null;a?.dataset.moreTile&&($=a.dataset.moreTile)}},[]),(0,Z.jsxs)(`div`,{"data-features-index":!0,className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[!m&&(0,Z.jsx)(`div`,{"data-window-drag-region":!0,"aria-hidden":`true`,className:`h-[52px] flex-none`}),(0,Z.jsx)(`div`,{"data-features-scroller":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,onKeyDown:ue,children:(0,Z.jsxs)(`div`,{"data-features-column":!0,className:`mx-auto flex w-full max-w-[808px] flex-col px-6 pb-16 max-[650px]:px-4 max-[650px]:pt-4 max-[650px]:pb-8`,children:[(0,Z.jsxs)(`header`,{"data-focus-region":`header`,className:`flex flex-col`,children:[(0,Z.jsx)(`h1`,{id:i,className:A(`text-2xl leading-8 font-semibold tracking-[-.01em] text-content`,m&&`sr-only`),children:h}),(0,Z.jsx)(`p`,{className:A(`mt-1 text-sm text-content-muted`,m&&`hidden`),children:s&&!m?t(`navigation:more.lede`,{shortcut:s}):t(`navigation:more.ledeNoShortcut`)}),(0,Z.jsxs)(`label`,{className:A(`relative mt-5 flex h-9 w-full items-center gap-2 rounded-[var(--r-md)] border border-control bg-panel px-3 text-content-muted focus-within:border-focus focus-within:ring-3 focus-within:ring-focus-ring max-[650px]:h-11`,m&&`mt-0`),children:[(0,Z.jsx)(E,{className:`size-4 flex-none`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:t(`navigation:more.search`)}),(0,Z.jsx)(`input`,{id:k,type:`search`,value:a,placeholder:t(`navigation:more.search`),"aria-keyshortcuts":c||void 0,className:`w-full min-w-0 border-0 bg-transparent text-[length:var(--app-font-size)] text-content caret-focus outline-none max-[650px]:text-[16px] [&::-webkit-search-cancel-button]:hidden`,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&a)e.preventDefault(),e.stopPropagation(),o(``);else if(e.key===`ArrowDown`){let t=e.currentTarget.closest(`[data-features-scroller]`)?.querySelector(Q);t&&(e.preventDefault(),e.stopPropagation(),t.focus())}}}),a?(0,Z.jsx)(`button`,{type:`button`,className:`grid size-6 flex-none place-items-center rounded-xs text-content-muted hover:bg-surface-hover hover:text-content focus-visible:outline-2 focus-visible:outline-focus pointer-coarse:size-11`,"aria-label":t(`navigation:more.clearSearch`),onClick:()=>o(``),children:(0,Z.jsx)(D,{className:`size-3.5`,"aria-hidden":`true`})}):c&&(0,Z.jsx)(M,{className:`flex-none pointer-coarse:hidden`,children:c})]})]}),b.length===0&&S.length===0?(0,Z.jsxs)(`div`,{role:`status`,"data-features-empty":!0,className:`flex flex-col items-center gap-2 py-16 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-content`,children:t(`navigation:more.noResults`)}),(0,Z.jsx)(`p`,{className:`max-w-sm text-xs text-content-muted`,children:t(`navigation:more.noResultsHint`,{shortcut:s||`⌘K`})}),(0,Z.jsxs)(`div`,{className:`mt-2 flex w-full max-w-sm flex-col gap-2`,children:[w,(0,Z.jsx)(j,{variant:`secondary`,className:`min-h-11`,onClick:()=>o(``),children:t(`navigation:more.clearSearch`)})]})]}):b.map(n=>{let r=`${i}-${n.id}`;return(0,Z.jsxs)(`section`,{"data-more-group":n.id,"aria-labelledby":r,className:`mt-7 flex flex-col`,children:[(0,Z.jsx)(`h2`,{id:r,className:T,children:n.label}),(0,Z.jsx)(`ul`,{className:`grid grid-cols-2 gap-2 max-[650px]:grid-cols-1`,children:n.tiles.map(t=>(0,Z.jsx)(`li`,{className:`min-w-0`,children:(0,Z.jsx)(de,{tile:t,badge:x.get(t.key),onOpen:e})},t.key))}),n.id===`components`&&!a&&g.isLoading&&(0,Z.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-content-muted`,children:t(`navigation:more.componentsLoading`)}),n.id===`components`&&!a&&!!g.error&&(0,Z.jsxs)(`p`,{role:`alert`,className:`mt-2 flex items-center gap-2 text-xs text-content-muted`,children:[t(`navigation:more.componentsError`),(0,Z.jsx)(j,{variant:`ghost`,size:`xs`,onClick:g.refetch,children:t(`navigation:more.retry`)})]})]},n.id)}),a.trim()&&(b.length>0||S.length>0)&&(0,Z.jsxs)(`section`,{"aria-labelledby":`${i}-search`,className:`mt-7 flex flex-col`,children:[(0,Z.jsx)(`h2`,{id:`${i}-search`,className:T,children:t(`navigation:more.settingsResults`)}),S.length>0&&(0,Z.jsx)(`ul`,{"data-more-settings-results":!0,className:`mb-2 flex flex-col divide-y divide-stroke-soft overflow-hidden rounded-card border border-stroke`,children:S.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full min-w-0 items-center gap-3 px-3.5 py-2 text-left transition-colors duration-(--d-fast) hover:bg-surface-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus`,onClick:()=>C(e),children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm text-content`,children:e.title}),e.sectionTitle!==e.title&&(0,Z.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:e.sectionTitle})]}),(0,Z.jsx)(y,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`})]})},e.entry.id))}),w]})]})})]})}function ue(e){let t=e.target;if(!(t instanceof HTMLElement)||!t.matches(Q)||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let n=[...e.currentTarget.querySelectorAll(Q)],r=n.indexOf(t);if(r<0)return;let i;if(e.key===`ArrowRight`)i=n[r+1];else if(e.key===`ArrowLeft`)i=n[r-1];else if(e.key===`Home`)i=n[0];else if(e.key===`End`)i=n.at(-1);else if(e.key===`ArrowDown`||e.key===`ArrowUp`){let r=t.getBoundingClientRect(),a=e.key===`ArrowDown`,o=r.left+r.width/2,s=n.map(e=>({tile:e,box:e.getBoundingClientRect()})).filter(({box:e})=>a?e.top>=r.bottom-1:e.bottom<=r.top+1);if(s.length>0){let e=a?Math.min(...s.map(({box:e})=>e.top)):Math.max(...s.map(({box:e})=>e.top));i=s.filter(({box:t})=>Math.abs(t.top-e)<2).sort((e,t)=>Math.abs(e.box.left+e.box.width/2-o)-Math.abs(t.box.left+t.box.width/2-o))[0]?.tile}else if(!a){document.getElementById(k)?.focus(),e.preventDefault();return}}else return;e.preventDefault(),i?.focus()}function de({tile:e,badge:t,onOpen:n}){let{t:i}=r(),a=e.icon,o=!!e.disabledReason,s=e.key===R;return(0,Z.jsxs)(`button`,{type:`button`,"data-more-tile":e.key,"aria-disabled":o||void 0,"aria-label":o?i(`navigation:more.disabledTile`,{label:e.label,reason:e.disabledReason}):void 0,className:A(`flex min-h-16 w-full min-w-0 items-center gap-3 rounded-card border px-3.5 py-2.5 text-left transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus max-[650px]:min-h-14 max-[650px]:py-2`,s?`border-dashed border-stroke-strong`:`border-stroke`,o?`cursor-not-allowed`:`hover:bg-surface-hover`),onClick:()=>{o||($=e.key,n(e.destination))},children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:A(`grid size-[34px] flex-none place-items-center rounded-[var(--r-md)] max-[650px]:size-8`,s?`text-content-muted`:`bg-surface-subtle text-content-secondary`,o&&`text-content-muted`),children:(0,Z.jsx)(a,{className:`size-[18px]`,strokeWidth:1.75})}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{className:A(`truncate text-sm font-medium text-content`,(o||s)&&`text-content-secondary`),children:e.label}),(0,Z.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:e.disabledReason||e.description})]}),t&&!o&&(0,Z.jsxs)(`span`,{"data-more-badge":t.tone,className:A(`flex max-w-[45%] flex-none items-center gap-1.5 text-xs whitespace-nowrap tabular-nums`,t.tone===`attn`?`font-medium text-st-attn`:`text-content-muted`),children:[t.tone===`attn`&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-st-attn-fill`}),(0,Z.jsx)(`span`,{className:`truncate`,children:t.label})]})]})}export{le as MorePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-CaxKosZm.js";import{u as i}from"./api-MVoWVwmh.js";import{t as a}from"./folder-open-FIShC5Qk.js";import{i as o}from"./workspace-order-store-BYpf9Z59.js";import{t as s}from"./triangle-alert-CE1q54ci.js";import{n as c,t as l}from"./button-CCcCN8tE.js";import{a as u,i as d,l as f,o as p,s as m,t as h}from"./dialog-9LXtFD-0.js";import{t as g}from"./input-CPw-zkYh.js";import{i as _,n as v,r as y,t as b}from"./input-group-h8z63MzW.js";import{t as x}from"./pick-system-directory-CWhZCX6d.js";import{r as S,t as C}from"./folder-paths-DlIGURu0.js";import{n as w,t as T}from"./alert-firawb0H.js";import{n as E,t as D}from"./field-DoLEb0np.js";var O=e(t(),1),k=n();function A(e,t){switch(e){case`folder_name_required`:return t(`board:folder.error.nameRequired`);case`folder_name_invalid`:return t(`board:folder.error.nameInvalid`);case`folder_parent_missing`:case`folder_parent_invalid`:return t(`board:folder.error.parentMissing`);case`folder_exists_as_file`:return t(`board:folder.error.existsAsFile`);case`folder_permission_denied`:return t(`board:folder.error.permission`);default:return``}}function j({open:e,initialParent:t,onOpenChange:n,onCreated:j,onCloseAutoFocus:M}){let{t:N}=r(),[P,F]=(0,O.useState)(t),[I,L]=(0,O.useState)(``),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(``),K=(0,O.useRef)(0),q=(0,O.useRef)(!1),J=(0,O.useRef)(null),Y=R||B;(0,O.useEffect)(()=>{K.current+=1,q.current=!1,e&&(F(t),L(``),z(!1),V(!1),U(!1),G(``))},[t,e]);let X=async()=>{if(q.current)return;q.current=!0;let e=K.current;V(!0),G(``);try{let t=await x(P.trim(),N(`board:folder.browseTitle`));if(e!==K.current)return;t.status===`picked`?F(t.path):t.status===`unavailable`&&(U(!0),J.current?.focus())}catch(t){e===K.current&&G(t instanceof Error?t.message:String(t))}finally{e===K.current&&(q.current=!1,V(!1))}},Z=async e=>{if(e.preventDefault(),q.current||!I.trim())return;q.current=!0;let t=K.current;z(!0),G(``);try{let e=await S(P.trim(),I.trim());if(t!==K.current)return;j(e.path),n(!1)}catch(e){if(t!==K.current)return;let n=A(e instanceof i?e.data?.code:void 0,N);G(n||(e instanceof Error&&e.message?N(`board:folder.error.failedWithReason`,{reason:e.message}):N(`board:folder.error.failed`)))}finally{t===K.current&&(q.current=!1,z(!1))}},Q=I.trim()?C(P,I.trim()):``;return(0,k.jsx)(h,{open:e,onOpenChange:e=>!q.current&&n(e),children:(0,k.jsxs)(d,{showCloseButton:!Y,"aria-describedby":`board-new-folder`,onCloseAutoFocus:M,"data-new-folder-dialog":!0,children:[(0,k.jsxs)(m,{children:[(0,k.jsx)(f,{children:N(`board:folder.title`)}),(0,k.jsx)(u,{id:`board-new-folder`,children:N(`board:folder.description`)})]}),(0,k.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:e=>void Z(e),children:[(0,k.jsxs)(E,{variant:`control`,children:[N(`board:folder.parent`),(0,k.jsxs)(b,{className:`max-[650px]:h-11`,children:[(0,k.jsx)(_,{ref:J,className:`font-mono text-xs`,value:P,disabled:Y,placeholder:N(`board:folder.parentPlaceholder`),"data-new-folder-parent":!0,onChange:e=>F(e.target.value)}),(0,k.jsx)(v,{align:`inline-end`,children:(0,k.jsxs)(y,{size:`xs`,disabled:Y,"data-new-folder-browse":!0,onClick:()=>void X(),children:[B?(0,k.jsx)(c,{className:`text-current`}):(0,k.jsx)(a,{}),N(`board:folder.browse`)]})})]})]}),H&&(0,k.jsx)(D,{className:`-mt-2`,children:N(`board:folder.browseUnavailable`)}),(0,k.jsxs)(E,{variant:`control`,children:[N(`board:folder.name`),(0,k.jsx)(g,{autoFocus:!0,className:`max-[650px]:h-11`,value:I,disabled:Y,placeholder:N(`board:folder.namePlaceholder`),autoComplete:`off`,spellCheck:!1,"data-new-folder-name":!0,onChange:e=>{L(e.target.value),W&&G(``)}})]}),Q&&(0,k.jsx)(`p`,{className:`-mt-2 truncate font-mono text-xs text-content-muted`,title:Q,children:N(`board:folder.preview`,{path:Q})}),W&&(0,k.jsxs)(T,{variant:`destructive`,children:[(0,k.jsx)(s,{}),(0,k.jsx)(w,{className:`min-w-0 break-words`,children:W})]}),(0,k.jsxs)(p,{children:[(0,k.jsx)(l,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:Y,onClick:()=>n(!1),children:N(`common:ui.cancel`)}),(0,k.jsxs)(l,{type:`submit`,size:`dialogAction`,disabled:Y||!I.trim(),children:[R?(0,k.jsx)(c,{className:`text-current`}):(0,k.jsx)(o,{}),N(R?`board:folder.creating`:`board:folder.create`)]})]})]})]})})}export{j as NewFolderDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-CaxKosZm.js";import{t as i}from"./api-MVoWVwmh.js";import{i as a}from"./runtime-capabilities-CHYOF_hE.js";import{t as o}from"./runtime-capabilities-store-SnV1V9_K.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./circle-check-iEdCm3Pw.js";import{t as l}from"./earth-Ddy13fHh.js";import{t as u}from"./external-link-CEQqPcqc.js";import{t as d}from"./eye-uWAPXNzJ.js";import{t as f}from"./file-code-corner-BnE1ljT0.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./image-BY_c3FYU.js";import{t as h}from"./package-BOmkLaKS.js";import{t as g}from"./plug-BsIeHRwC.js";import{t as _}from"./save-CHBB52P8.js";import{t as v}from"./search-D0mqDaf_.js";import{t as y}from"./server-BgNvmqwJ.js";import{t as ee}from"./shield-alert-oZqX6MNu.js";import{t as te}from"./trash-2-CNrPOoPR.js";import{t as b}from"./triangle-alert-CE1q54ci.js";import{t as x}from"./more-pages-D_PnxLN0.js";import{a as S}from"./dist-41X0pdUs.js";import{o as C,s as w}from"./dist-BsRXXcSL.js";import{a as T,c as ne,i as E,l as D,n as O,o as k,r as re,s as ie,t as ae}from"./dist-BHkR6BLP.js";import{t as A}from"./utils-C8uzG5AZ.js";import{n as oe,t as j}from"./button-CCcCN8tE.js";import{s as se}from"./shortcuts-BmJZiLby.js";import{a as M,i as N,l as P,o as F,s as I,t as L}from"./dialog-9LXtFD-0.js";import{t as R}from"./input-CPw-zkYh.js";import{t as ce}from"./pick-system-directory-CWhZCX6d.js";import{n as le,t as ue}from"./PageState-Cz6vFMXv.js";import{a as de,i as z,n as B,o as V,r as fe,s as pe,t as H}from"./FeaturePage-IWVjXcVp.js";import{t as U}from"./AppSelect-DQYKUW5E.js";import{c as me,i as he,s as ge}from"./app-primitives-Drz_SjnR.js";import{a as W,i as _e,n as ve,o as ye,r as G,s as be,t as xe}from"./tool-labels-Bexnwp5q.js";var K=s(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),q=e(t(),1),J=n(),Y=Object.defineProperty,X=(e,t)=>Y(e,`name`,{value:t,configurable:!0}),[Se,Ce]=w(`AlertDialog`,[D]),Z=D(),we=X(e=>{let{__scopeAlertDialog:t,...n}=e,r=Z(t);return(0,J.jsx)(ae,{...r,...n,modal:!0})},`AlertDialog`);q.forwardRef(X(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=Z(n);return(0,J.jsx)(ne,{...i,...r,ref:t})},`AlertDialogTrigger`));var Te=X(e=>{let{__scopeAlertDialog:t,...n}=e,r=Z(t);return(0,J.jsx)(k,{...r,...n})},`AlertDialogPortal`),Q=q.forwardRef(X(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=Z(n);return(0,J.jsx)(T,{...i,...r,ref:t})},`AlertDialogOverlay`)),[Ee,$]=Se(`AlertDialogContent`),De=q.forwardRef(X(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=Z(n),o=q.useRef(null),s=S(t,o),c=q.useRef(null);return(0,J.jsx)(Ee,{scope:n,cancelRef:c,children:(0,J.jsx)(re,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:C(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),Oe=q.forwardRef(X(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=Z(n);return(0,J.jsx)(ie,{...i,...r,ref:t})},`AlertDialogTitle`)),ke=q.forwardRef(X(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=Z(n);return(0,J.jsx)(E,{...i,...r,ref:t})},`AlertDialogDescription`)),Ae=q.forwardRef(X(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=Z(n);return(0,J.jsx)(O,{...i,...r,ref:t})},`AlertDialogAction`)),je=`AlertDialogCancel`,Me=q.forwardRef(X(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=$(je,n),a=Z(n),o=S(t,i);return(0,J.jsx)(O,{...a,...r,ref:o})},`AlertDialogCancel`)),Ne=we,Pe=Te,Fe=Q,Ie=De,Le=Ae,Re=Me,ze=Oe,Be=ke;function Ve({...e}){return(0,J.jsx)(Ne,{"data-slot":`alert-dialog`,...e})}function He({...e}){return(0,J.jsx)(Pe,{"data-slot":`alert-dialog-portal`,...e})}function Ue({className:e,...t}){return(0,J.jsx)(Fe,{"data-slot":`alert-dialog-overlay`,className:A(`fixed inset-0 z-50 bg-[var(--overlay-scrim)] duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function We({className:e,size:t=`default`,...n}){return(0,J.jsxs)(He,{children:[(0,J.jsx)(Ue,{}),(0,J.jsx)(Ie,{"data-slot":`alert-dialog-content`,"data-size":t,className:A(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100vh-2rem)] supports-[height:100dvh]:max-h-[calc(100dvh-2rem)] w-full -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto overscroll-contain rounded-xl bg-popover p-4 text-popover-foreground shadow-float duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...n})]})}function Ge({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:A(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function Ke({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:A(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t border-stroke bg-surface-subtle px-4 py-3 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function qe({className:e,...t}){return(0,J.jsx)(ze,{"data-slot":`alert-dialog-title`,className:A(`font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function Je({className:e,...t}){return(0,J.jsx)(Be,{"data-slot":`alert-dialog-description`,className:A(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function Ye({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,J.jsx)(j,{variant:t,size:n,asChild:!0,children:(0,J.jsx)(Le,{"data-slot":`alert-dialog-action`,className:A(e),...r})})}function Xe({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,J.jsx)(j,{variant:t,size:n,asChild:!0,children:(0,J.jsx)(Re,{"data-slot":`alert-dialog-cancel`,className:A(e),...r})})}function Ze(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Qe({open:e,onOpenChange:t,onInstalled:n}){let{t:a}=r(),[o,s]=(0,q.useState)(``),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(!1),[m,h]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e||(s(``),u(null),f(!1),h(``))},[e]),(0,J.jsx)(L,{open:e,onOpenChange:e=>!d&&t(e),children:(0,J.jsxs)(N,{className:`z-[220] sm:max-w-xl`,overlayClassName:`z-[220]`,children:[(0,J.jsxs)(I,{children:[(0,J.jsxs)(P,{className:`flex items-center gap-2`,children:[(0,J.jsx)(K,{className:`size-4 text-content-secondary`}),a(`plugins:pluginsPage.installLocalPlugin`)]}),(0,J.jsx)(M,{children:a(`plugins:pluginsPage.installLocalPluginDescription`)})]}),(0,J.jsxs)(`div`,{className:`grid gap-3`,children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[a(`plugins:pluginsPage.pluginDirectory`),(0,J.jsxs)(`span`,{className:`flex min-w-0 gap-2`,children:[(0,J.jsx)(R,{className:`min-w-0 flex-1 font-mono text-xs max-[650px]:h-11`,value:o,disabled:d,placeholder:a(`plugins:pluginsPage.pluginDirectoryPlaceholder`),onChange:e=>{s(e.target.value),u(null)}}),(0,J.jsx)(j,{type:`button`,variant:`secondary`,size:`icon`,className:`size-[34px] shrink-0 max-[650px]:size-11`,title:a(`plugins:pluginsPage.chooseDirectory`),"aria-label":a(`plugins:pluginsPage.chooseDirectory`),onClick:async()=>{h(``);try{let e=await ce(o,a(`plugins:pluginsPage.chooseDirectory`));e.status===`picked`?(s(e.path),u(null)):e.status===`unavailable`&&h(a(`common:workspacePicker.systemPickerUnavailable`))}catch(e){h(e instanceof Error?e.message:String(e))}},children:(0,J.jsx)(p,{})})]})]}),l&&(0,J.jsxs)(`div`,{className:`grid gap-3 overflow-hidden rounded-md border border-stroke bg-surface-subtle p-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,J.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-sm bg-success-soft text-success`,children:(0,J.jsx)(c,{className:`size-4`})}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`strong`,{className:`block truncate text-sm font-medium text-content`,children:l.plugin.name}),(0,J.jsxs)(`small`,{className:`block truncate font-mono text-xs text-content-muted tabular-nums`,children:[l.plugin.id,` · v`,l.plugin.version,` · `,l.fileCount,` `,a(`plugins:pluginsPage.files`),` · `,Ze(l.byteCount)]})]})]}),(0,J.jsx)(`div`,{className:`grid gap-1.5`,children:l.plugin.capabilities.map(e=>(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-t border-stroke-soft pt-2 text-xs`,children:[(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`strong`,{className:`block font-medium text-content`,children:e.label}),(0,J.jsx)(`small`,{className:`text-xs text-content-muted`,children:e.description})]}),(0,J.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-content-secondary`,children:e.name})]},e.name))}),(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm bg-warning-soft p-2.5 text-xs leading-5 text-warning-strong`,children:[(0,J.jsx)(b,{className:`mt-0.5 shrink-0`,size:15}),(0,J.jsx)(`span`,{children:a(`plugins:pluginsPage.localPluginSecurityWarning`)})]})]}),m&&(0,J.jsxs)(he,{className:`m-0`,children:[(0,J.jsx)(b,{size:14}),(0,J.jsx)(`span`,{children:m})]})]}),(0,J.jsxs)(F,{children:[(0,J.jsx)(j,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:d,onClick:()=>t(!1),children:a(`common:ui.cancel`)}),(0,J.jsxs)(j,{type:`button`,size:`dialogAction`,disabled:d||!l&&!o.trim(),onClick:l?async()=>{if(!(!l||d)){f(!0),h(``);try{await i(`/api/plugins/install`,{method:`POST`,body:JSON.stringify({inspectionId:l.inspectionId})}),await n(),t(!1)}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}}}:async()=>{if(!(!o.trim()||d)){f(!0),h(``);try{u(await i(`/api/plugins/inspect`,{method:`POST`,body:JSON.stringify({path:o.trim()})}))}catch(e){u(null),h(e instanceof Error?e.message:String(e))}finally{f(!1)}}},children:[d?(0,J.jsx)(oe,{className:`text-current`}):l?(0,J.jsx)(K,{}):(0,J.jsx)(c,{}),a(d?`plugins:pluginsPage.processing`:l?`plugins:pluginsPage.installPlugin`:`plugins:pluginsPage.inspectPlugin`)]})]})]})})}var $e=[`tool`,`prompt`,`skill`];function et(e){let t=Array.isArray(e.resourceTypes)?e.resourceTypes.filter(e=>$e.includes(e)):[];return t.length?t:[`tool`]}function tt(e,t){return{tool:t(`plugins:pluginsPage.extensionType.tool`),prompt:t(`plugins:pluginsPage.extensionType.prompt`),skill:t(`plugins:pluginsPage.extensionType.skill`)}[e]}var nt=[`all`,`builtin`,`local`],rt={read:d,ls:p,grep:v,find:v,edit:f,write:f,bash:y,web_search:l,browser_automation:l,generate_visual:m};function it(e,t){return t(e===`builtin`?`plugins:pluginsPage.builtIn`:e===`local`?`plugins:pluginsPage.local`:`plugins:pluginsPage.all`)}function at(e){return e.flatMap(e=>e.managedExternally?[]:e.capabilities.filter(e=>e.enabled).map(e=>e.name))}function ot(e){return e.filter(e=>!e.managedExternally||e.source===`pi`).flatMap(e=>e.capabilities.map(t=>({...t,pluginId:e.id,pluginName:e.name,pluginDescription:e.description,pluginVersion:e.version,pluginSource:e.source,pluginBuiltIn:e.builtIn,pluginPermissions:e.permissions||[],pluginSystemAccess:!!e.systemAccess})))}function st(e){return e.find(e=>e.source===`pi`&&e.name===`Computer Use`)?.enabled!==!1}function ct(e){return Object.fromEntries(e.filter(e=>e.source===`pi`&&e.name!==`Computer Use`&&!!e.packageSource).map(e=>[e.packageSource,e.enabled!==!1]))}function lt(e,t){return[...e].sort().join(`\0`)===[...t].sort().join(`\0`)}function ut(e,t){return W({id:e.name,name:e.label},t)}function dt(e,t){return e.pluginSource===`pi`?e.pluginName:G(e.pluginName,t)}function ft({value:e,testing:t,onChange:n,onTest:i}){let{t:a}=r();return(0,J.jsxs)(`div`,{className:`plugin-tool-config grid gap-2.5 border-t border-stroke pt-3 [&_label]:grid [&_label]:gap-1.5 [&_label]:text-xs [&_label]:font-medium [&_label]:text-content-secondary`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,J.jsxs)(`label`,{children:[a(`plugins:pluginsPage.defaultLanguage`),(0,J.jsxs)(U,{value:e.language,onChange:t=>n({...e,language:t.target.value}),children:[(0,J.jsx)(`option`,{value:`auto`,children:a(`plugins:pluginsPage.auto`)}),(0,J.jsx)(`option`,{value:`zh-CN`,children:a(`plugins:pluginsPage.simplifiedChinese`)}),(0,J.jsx)(`option`,{value:`en-US`,children:a(`plugins:pluginsPage.english`)})]})]}),(0,J.jsxs)(`label`,{children:[a(`plugins:pluginsPage.safeSearch`),(0,J.jsxs)(U,{value:e.safeSearch,onChange:t=>n({...e,safeSearch:Number(t.target.value)}),children:[(0,J.jsx)(`option`,{value:0,children:a(`plugins:pluginsPage.off`)}),(0,J.jsx)(`option`,{value:1,children:a(`plugins:pluginsPage.moderate`)}),(0,J.jsx)(`option`,{value:2,children:a(`plugins:pluginsPage.strict`)})]})]}),(0,J.jsxs)(`label`,{children:[a(`plugins:pluginsPage.resultCount`),(0,J.jsx)(R,{type:`number`,min:`1`,max:`12`,className:`tabular-nums`,value:e.maxResults,onChange:t=>n({...e,maxResults:Number(t.target.value)})})]})]}),(0,J.jsxs)(j,{type:`button`,variant:`secondary`,className:`justify-self-end max-[650px]:h-11`,loading:t,disabled:t,onClick:i,children:[(0,J.jsx)(l,{}),a(t?`plugins:pluginsPage.testing`:`plugins:pluginsPage.testConnection`)]})]})}function pt({query:e,notify:t,requestText:n,requestConfirm:a}){let{t:o}=r(),[s,c]=(0,q.useState)(``),[l,d]=(0,q.useState)(null),[f,p]=(0,q.useState)([]),[m,g]=(0,q.useState)(!1),[_,y]=(0,q.useState)(``),[ee,b]=(0,q.useState)(``),x=(0,q.useCallback)(async(e=``)=>{g(!0),b(``);try{let[t,n]=await Promise.all([i(`/api/extensions/market?name=${encodeURIComponent(e)}`),i(`/api/extensions`)]);d(t),p(n.packages||[])}catch(e){b(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,q.useEffect)(()=>{x(``)},[x]);let S=(l?.packages||[]).filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e.trim().toLowerCase())),C=async e=>{if(await a?.({title:o(`plugins:pluginsPage.installExtension`),message:o(`plugins:pluginsPage.extensionSecurityWarning`,{name:e}),confirmLabel:o(`plugins:pluginsPage.installExtension`),tone:`danger`})!==!1){y(e);try{let n=/^(?:[.~\\/]|[A-Za-z]:[\\/])/.test(e)||/^(?:npm:|https?:\/\/|git\+)/i.test(e)?e:`npm:${e}`,r=await i(`/api/extensions/install`,{method:`POST`,body:JSON.stringify({source:n})});p(r.packages||[]),t(o(`plugins:pluginsPage.extensionInstalled`),`success`)}catch(e){t(e instanceof Error?e.message:String(e),`error`)}finally{y(``)}}},w=async()=>{let e=await n?.({title:o(`plugins:pluginsPage.installExtension`),message:o(`plugins:pluginsPage.extensionSourceHelp`),inputLabel:o(`plugins:pluginsPage.extensionSource`),placeholder:`npm:@scope/package or https://github.com/…`,maxLength:2e3});e?.trim()&&await C(e.trim())},T=async e=>{if(await a?.({title:o(`plugins:pluginsPage.uninstallExtension`),message:o(`plugins:pluginsPage.uninstallExtensionDescription`,{name:e.name}),confirmLabel:o(`plugins:pluginsPage.uninstallExtension`),tone:`danger`})!==!1){y(e.source);try{await i(`/api/extensions`,{method:`DELETE`,body:JSON.stringify({source:e.source,scope:e.scope})}),await x(s),t(o(`plugins:pluginsPage.extensionUninstalled`),`success`)}catch(e){t(e instanceof Error?e.message:String(e),`error`)}finally{y(``)}}},ne=$e.map(e=>({type:e,items:f.filter(t=>et(t).includes(e))})).filter(e=>e.items.length>0);return(0,J.jsxs)(J.Fragment,{children:[ne.map(e=>(0,J.jsx)(V,{className:`plugin-installed-extensions`,title:`${o(`plugins:pluginsPage.installedExtensions`)} · ${tt(e.type,o)}`,count:e.items.length,children:(0,J.jsx)(B,{children:e.items.map(t=>(0,J.jsx)(z,{icon:(0,J.jsx)(h,{}),name:(0,J.jsx)(`span`,{className:`font-mono`,children:t.name}),nameMeta:`v${t.version}`,description:(0,J.jsx)(`span`,{className:`font-mono text-xs`,children:t.source}),actions:(0,J.jsxs)(j,{type:`button`,variant:`ghost`,size:`sm`,className:`text-content-muted hover:bg-danger-soft hover:text-danger`,loading:_===t.source,disabled:!!_,onClick:()=>void T(t),children:[(0,J.jsx)(te,{}),o(`plugins:pluginsPage.uninstallExtension`)]})},`${e.type}:${t.scope}:${t.source}`))})},e.type)),(0,J.jsxs)(V,{className:`plugin-market`,title:o(`plugins:pluginsPage.extensionMarket`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(j,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,J.jsxs)(`a`,{href:`https://pi.dev/packages`,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(u,{}),o(`plugins:pluginsPage.openPackageCatalog`)]})}),(0,J.jsxs)(j,{type:`button`,variant:`secondary`,size:`sm`,onClick:w,disabled:!!_,children:[(0,J.jsx)(K,{}),o(`plugins:pluginsPage.installExtension`)]})]}),children:[(0,J.jsxs)(`form`,{className:`mb-3 flex min-w-0 gap-2`,onSubmit:e=>{e.preventDefault(),x(s)},children:[(0,J.jsx)(R,{className:`min-w-0 flex-1 max-[650px]:h-11`,value:s,onChange:e=>c(e.target.value),placeholder:o(`plugins:pluginsPage.searchPackageCatalog`),"aria-label":o(`plugins:pluginsPage.searchPackageCatalog`)}),(0,J.jsxs)(j,{type:`submit`,variant:`secondary`,className:`h-[34px] max-[650px]:h-11`,loading:m,disabled:m,children:[(0,J.jsx)(v,{}),o(`plugins:pluginsPage.search`)]})]}),ee&&(0,J.jsx)(H,{className:`mt-0 mb-3`,children:ee}),S.length>0&&(0,J.jsx)(B,{children:S.slice(0,12).map(e=>{let t=f.some(t=>t.name===e.name||t.source===`npm:${e.name}`);return(0,J.jsx)(z,{icon:(0,J.jsx)(h,{}),name:(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),description:e.description,status:e.published,actions:(0,J.jsx)(j,{type:`button`,variant:`secondary`,size:`sm`,loading:_===e.name,disabled:t||!!_,onClick:()=>void C(e.name),children:o(t?`plugins:pluginsPage.installed`:`plugins:pluginsPage.installExtension`)})},e.name)})})]})]})}function mt({notify:e,onBack:t,requestText:n,requestConfirm:s}){let{t:c}=r(),l=se(`focusSearch`),u=o(e=>e.capabilities),d=a(u,`plugins`),f=d?nt:nt.slice(0,2),[p,m]=(0,q.useState)(``),[h,v]=(0,q.useState)(null),[y,S]=(0,q.useState)([]),[C,w]=(0,q.useState)(``),[T,ne]=(0,q.useState)(`all`),[E,D]=(0,q.useState)({provider:`bing`,language:`auto`,safeSearch:1,maxResults:8}),[O,k]=(0,q.useState)(!1),[re,ie]=(0,q.useState)(!1),[ae,M]=(0,q.useState)(!1),[N,P]=(0,q.useState)(null),[F,I]=(0,q.useState)(!1),[L,R]=(0,q.useState)(``),[ce,H]=(0,q.useState)(!1),U=(0,q.useCallback)(e=>{v(e),S(e.plugins),D(e.webSearch)},[]),W=(0,q.useCallback)(async()=>{R(``);try{U(await i(`/api/plugins`))}catch(e){R(e instanceof Error?e.message:String(e))}},[U]);(0,q.useEffect)(()=>{W()},[W]);let G=(0,q.useMemo)(()=>ot(y),[y]),Y=(0,q.useMemo)(()=>at(y),[y]),X=h?!lt(Y,h.enabledTools)||st(y)!==h.computerUseEnabled||JSON.stringify(ct(y))!==JSON.stringify(h.piExtensions)||JSON.stringify(E)!==JSON.stringify(h.webSearch):!1,Se=(0,q.useCallback)(async()=>{if(!O){if(!h||!X){h&&e(c(`plugins:pluginsPage.noPluginPolicyChanges`));return}k(!0),R(``);try{let t=await i(`/api/plugins`,{method:`PUT`,body:JSON.stringify({enabledTools:Y,webSearch:E,computerUseEnabled:st(y),piExtensions:ct(y)})});U(t),e(c(`plugins:pluginsPage.pluginPolicySavedAgentRuntimeUpdated`))}catch(e){R(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[U,h,X,y,Y,e,O,c,E]),Ce=async()=>{ie(!0),R(``);try{let t=await i(`/api/plugins/web-search/test`,{method:`POST`,body:JSON.stringify(E)});e(c(`plugins:pluginsPage.bingSearchIsAvailableAndReturnedCountResults`,{count:t.count}))}catch(t){let n=t instanceof Error?t.message:String(t);R(n),e(n,`error`)}finally{ie(!1)}},Z=(e,t,n)=>{S(r=>r.map(r=>{if(r.id!==e)return r;let i=r.source===`pi`&&r.managedExternally;return{...r,enabled:n||r.capabilities.some(e=>e.enabled),capabilities:r.capabilities.map(e=>i||e.name===t?{...e,enabled:n}:e)}}))},we=()=>!X||(R(c(`plugins:pluginsPage.saveBeforePluginChanges`)),!1),Te=async()=>{if(!(!N||F)){I(!0),R(``);try{U(await i(`/api/plugins/${encodeURIComponent(N.pluginId)}`,{method:`DELETE`})),e(c(`plugins:pluginsPage.pluginUninstalled`,{name:N.pluginName})),w(``),P(null)}catch(e){R(e instanceof Error?e.message:String(e))}finally{I(!1)}}},Q=c(`navigation:navigation.plugins`),Ee=p.trim().toLowerCase(),$=G.filter(e=>T!==`all`&&e.pluginSource!==T?!1:[ut(e,c),e.name,e.description,dt(e,c),e.pluginId].join(` `).toLowerCase().includes(Ee));return(0,J.jsxs)(fe,{title:Q,description:c(`plugins:pluginsPage.lede`),back:t&&{label:c(`navigation:sidebar.features`),ariaLabel:c(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,J.jsx)(pe,{search:(0,J.jsx)(de,{id:x,value:p,onValueChange:m,placeholder:c(`navigation:pageHeader.searchPage`,{page:Q}),shortcut:l,clearLabel:c(`navigation:more.clearSearch`)}),actions:(0,J.jsxs)(J.Fragment,{children:[d&&(0,J.jsxs)(j,{type:`button`,variant:`secondary`,className:`h-9`,disabled:!h,onClick:()=>we()&&M(!0),children:[(0,J.jsx)(K,{}),c(`plugins:pluginsPage.installPlugin`)]}),(0,J.jsxs)(j,{type:`button`,className:`h-9`,"data-plugins-save":!0,loading:O,disabled:!h||O,onClick:()=>void Se(),children:[(0,J.jsx)(_,{}),c(`plugins:pluginsPage.savePolicy`)]})]}),filters:(0,J.jsx)(me,{options:f.map(e=>it(e,c)),value:it(T,c),onChange:e=>ne(f.find(t=>it(t,c)===e)||`all`)})}),children:[h?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(V,{className:`plugin-catalog`,title:c(`plugins:pluginsPage.toolCatalog`),count:$.length,meta:(0,J.jsxs)(`span`,{className:`plugin-catalog-summary`,children:[G.filter(e=>e.enabled).length,`/`,G.length,` `,c(`plugins:pluginsPage.enabled2`)]}),actions:X&&(0,J.jsxs)(`span`,{"data-plugins-unsaved":!0,className:`flex items-center gap-1.5 text-xs font-medium text-content-secondary`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-content-secondary`}),c(`plugins:pluginsPage.unsaved`)]}),children:$.length?(0,J.jsx)(B,{className:`plugin-tool-grid`,children:$.map(e=>{let t=rt[e.name]||g,n=ut(e,c);return(0,J.jsx)(z,{className:`plugin-tool-card`,"data-plugin-tool":e.name,icon:(0,J.jsx)(t,{}),name:(0,J.jsx)(`span`,{title:n,children:n}),nameMeta:e.name,description:`${dt(e,c)} · ${ye(e.risk,c)}`,status:e.pluginBuiltIn?void 0:c(`plugins:pluginsPage.local`),actions:(0,J.jsx)(ge,{value:e.enabled,onChange:t=>Z(e.pluginId,e.name,t),ariaLabel:n}),expanded:C===e.name,onExpandedChange:t=>w(t?e.name:``),toggleLabel:c(`plugins:pluginsPage.toggleToolDetails`,{name:n}),detail:(0,J.jsxs)(`div`,{className:`plugin-tool-details grid gap-3`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-content-soft`,children:_e({id:e.name,description:e.description},c)}),(0,J.jsxs)(`dl`,{className:`grid grid-cols-[88px_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs [&_dd]:min-w-0 [&_dd]:[overflow-wrap:anywhere] [&_dd]:text-content-soft [&_dt]:text-content-muted [&>div]:contents`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{children:c(`plugins:pluginsPage.source`)}),(0,J.jsxs)(`dd`,{className:`tabular-nums`,children:[dt(e,c),!e.pluginBuiltIn&&` · v${e.pluginVersion}`]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{children:c(`plugins:pluginsPage.riskLevel`)}),(0,J.jsx)(`dd`,{className:A((xe(e.risk)||ve(e.risk))&&`font-medium text-content!`),children:ye(e.risk,c)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{children:c(`plugins:pluginsPage.pathScope`)}),(0,J.jsx)(`dd`,{children:be({id:e.name,scope:e.scope},c)})]}),!e.pluginBuiltIn&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{children:c(`plugins:pluginsPage.executionMode`)}),(0,J.jsx)(`dd`,{children:c(`plugins:pluginsPage.confirmUnlessFullAccess`)})]})]}),!e.pluginBuiltIn&&(0,J.jsxs)(`div`,{className:`plugin-tool-warning flex items-start gap-2 rounded-sm bg-surface-subtle p-2.5 text-xs leading-normal text-content-secondary`,children:[(0,J.jsx)(ee,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:c(`plugins:pluginsPage.localPluginSecurityWarning`)})]}),e.name===`web_search`&&(0,J.jsx)(ft,{value:E,testing:re,onChange:D,onTest:Ce}),!e.pluginBuiltIn&&(0,J.jsxs)(j,{type:`button`,variant:`ghost`,className:`justify-self-end text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,onClick:()=>we()&&P(e),children:[(0,J.jsx)(te,{}),c(`plugins:pluginsPage.uninstallPlugin`)]})]})},e.name)})}):(0,J.jsx)(ue,{compact:!0,title:c(`plugins:pluginsPage.noMatchingTools`)})}),(0,J.jsx)(pt,{query:p,notify:e,requestText:n,requestConfirm:s})]}):L?(0,J.jsx)(le,{kind:`error`,title:c(`plugins:pluginsPage.loadFailed`),description:L,action:(0,J.jsx)(j,{variant:`secondary`,className:`max-[650px]:h-11`,loading:ce,disabled:ce,onClick:()=>{H(!0),W().finally(()=>H(!1))},children:c(`common:pageTemplate.retry`)})}):(0,J.jsx)(le,{kind:`loading`,title:c(`plugins:pluginsPage.loadingToolPlugins`)}),d&&(0,J.jsx)(Qe,{open:ae,onOpenChange:M,onInstalled:W}),(0,J.jsx)(Ve,{open:!!N,onOpenChange:e=>!e&&!F&&P(null),children:(0,J.jsxs)(We,{className:`z-[220]`,children:[(0,J.jsxs)(Ge,{children:[(0,J.jsx)(qe,{children:c(`plugins:pluginsPage.uninstallPlugin`)}),(0,J.jsx)(Je,{children:c(`plugins:pluginsPage.uninstallPluginDescription`,{name:N?.pluginName||``})})]}),(0,J.jsxs)(Ke,{children:[(0,J.jsx)(Xe,{disabled:F,children:c(`common:ui.cancel`)}),(0,J.jsxs)(Ye,{variant:`destructive`,disabled:F,onClick:Te,children:[F&&(0,J.jsx)(oe,{className:`text-current`}),c(`plugins:pluginsPage.uninstallPlugin`)]})]})]})}),L&&h&&(0,J.jsxs)(he,{className:`fixed right-6 bottom-6 z-[21] max-w-[360px] border border-danger-border shadow-float`,children:[(0,J.jsx)(b,{size:13}),L]})]})}export{mt as PluginsPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-CEMK-4P4.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CaxKosZm.js","assets/i18n-Cl3sIF9G.js","assets/vendor-router-CSN_DGvx.js","assets/index-rOrQSojS.js","assets/index-l96Dl6z6.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-oPlZB-qC.js","assets/esm-DCV8yILT.js","assets/TaskTerminalView-CEWghfPZ.js","assets/square-terminal-BVG6cUT1.js","assets/square-bHHVTT3G.js","assets/PageState-Cz6vFMXv.js","assets/AppSelect-DQYKUW5E.js","assets/use-mobile-C2tPBAza.js","assets/select-Bbk9bmXO.js","assets/check-2vYc6QaP.js","assets/chevron-down-CxtxIjiP.js","assets/chevron-up-D_ZcXjqr.js","assets/chevrons-up-down-C2sEPdAh.js","assets/dist-BsRXXcSL.js","assets/dist-BiRPwy4W.js","assets/dist-DzGQ7sLi.js","assets/es2015-DTZdOI9P.js","assets/dist-BRjj4UeB.js","assets/dist-OB2r6Xsr.js","assets/dist-BS3ekNDj.js","assets/terminal-context-aIsIJPn8.js","assets/TaskTerminalView-BrP-ENHg.css","assets/TaskProcessesPane-ML4UTyA9.js","assets/chevron-right-C3t2Rckj.js","assets/checkbox-BrEHgFV0.js","assets/FileAttachmentPreview-DxwMjwfS.js","assets/api-MVoWVwmh.js","assets/abort-signal-f4JsiYKX.js","assets/download-BCfIiuaL.js","assets/file-Bllajneu.js","assets/refresh-cw-TbWxTY4K.js","assets/tabs-DsgBuvJv.js","assets/dist-BaBySQmo.js","assets/format-DMJQzoZ7.js","assets/dialog-9LXtFD-0.js","assets/dist-BHkR6BLP.js","assets/MarkdownMessage-gnw-y810.js","assets/vendor-markdown-plugins-CT5L3KA9.js","assets/vendor-shiki-runtime-DM7fm4Bl.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/vendor-markdown-CT6Z4fh8.js","assets/copy-DHmIFc52.js","assets/route-context-DvWDul4T.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-CaxKosZm.js";import{t as a}from"./useQuery-DdcpUQhO.js";import{t as o}from"./createLucideIcon-Cd-3GVxJ.js";import{t as s}from"./arrow-up-DST6-qVQ.js";import{t as c}from"./check-2vYc6QaP.js";import{t as l}from"./chevron-down-CxtxIjiP.js";import{t as u}from"./chevron-right-C3t2Rckj.js";import{t as d}from"./earth-Ddy13fHh.js";import{t as f}from"./external-link-CEQqPcqc.js";import{i as p}from"./GitDiffViewer-CEMK-4P4.js";import{t as m}from"./file-Bllajneu.js";import{I as h,_ as g,a as _,i as v,o as y,p as b,r as x,v as S}from"./side-chat-context-DhztplBz.js";import{t as C}from"./git-branch-N7LGjtzt.js";import{t as w}from"./image-BY_c3FYU.js";import{t as T}from"./link-2-mgasYn21.js";import{t as E}from"./message-square-SKjZyY3v.js";import{t as D}from"./pause-CYWpPg1R.js";import{t as O}from"./refresh-cw-TbWxTY4K.js";import{t as k}from"./square-bHHVTT3G.js";import"./tooltip-D4MFbqcG.js";import{t as A}from"./utils-C8uzG5AZ.js";import{n as j,t as M}from"./button-CCcCN8tE.js";import{c as ee,r as N}from"./shortcuts-BmJZiLby.js";import{t as P}from"./chat-api-D9RzUTQi.js";import{t as F}from"./input-CPw-zkYh.js";import{n as I}from"./session-change-summary-api-orjhsMHB.js";import{n as L,t as R}from"./PageState-Cz6vFMXv.js";import{t as z}from"./AppSelect-DQYKUW5E.js";import{n as B,r as te,t as V}from"./web-preview-DIo7zGil.js";import"./collapsible-Dcoy-qnz.js";import{o as H}from"./session-tree-summary-BO-Oz0d-.js";var ne=o(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),re=o(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),U=o(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),W=e(n(),1),G=r(),K={completed:`completed`,in_progress:`running`,paused:`pending`,blocked:`blocked`,pending:`pending`};function q(e){let t=new Map(e.map(e=>[String(e.id||``),e])),n=e=>e?.status===`completed`;return e.map(e=>{let r=String(e.id||``),i=(Array.isArray(e.dependsOn)?e.dependsOn:[]).map(e=>t.get(String(e))).filter(e=>!!e&&!n(e)),a=e.status!==`completed`&&(e.status===`blocked`||i.length>0);return{...e,id:r,blocked:a,blockedBy:i}})}function J({status:e,t}){let n=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`paused`?`chat:planBoard.paused`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,G.jsxs)(`span`,{className:`plan-board-status grid size-[18px] flex-none place-items-center rounded-xs text-content-muted [&.completed]:bg-success-soft [&.completed]:text-success [&.running]:text-accent-fg [&.blocked]:bg-danger-soft [&.blocked]:text-danger ${K[String(e)]||`pending`}`,title:n,children:[e===`completed`?(0,G.jsx)(c,{size:12,strokeWidth:2.25}):e===`in_progress`?(0,G.jsx)(j,{className:`size-3.5`}):e===`paused`?(0,G.jsx)(D,{size:11,strokeWidth:2}):e===`blocked`?(0,G.jsx)(U,{size:11,strokeWidth:2}):(0,G.jsx)(ne,{size:11,strokeWidth:2}),(0,G.jsx)(`span`,{className:`sr-only`,children:n})]})}function Y({item:e,current:t,running:n,t:r}){return(0,G.jsxs)(`li`,{className:`plan-board-row flex min-w-0 flex-col gap-[2px] rounded-sm px-[6px] py-[6px] aria-[current=step]:bg-surface-subtle ${e.blocked?`blocked`:``}`,"aria-current":t?`step`:void 0,"data-pisper-plan-current":t?`true`:void 0,"data-pisper-plan-id":e.id,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[10px]`,children:[(0,G.jsx)(J,{status:e.blocked?`blocked`:e.status===`in_progress`&&!n?`paused`:e.status,t:r}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${e.status===`completed`?`text-content-muted`:`text-foreground`}`,title:e.title,children:e.title}),e.assignee?(0,G.jsxs)(`span`,{className:`inline-flex max-w-[40%] flex-none items-center gap-[4px] truncate rounded-xs border border-stroke px-[6px] font-mono text-[12px] leading-[18px] text-content-secondary`,title:r(`chat:planBoard.assignedTo`,{name:e.assignee}),children:[(0,G.jsx)(h,{size:11,className:`flex-none`}),e.assignee]}):e.status!==`completed`&&(0,G.jsx)(`span`,{className:`flex-none text-[12px] text-content-muted`,children:r(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,G.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-[5px] pl-[28px] text-[12px] text-content-muted`,children:[(0,G.jsx)(U,{size:11,className:`flex-none`}),(0,G.jsx)(`span`,{className:`truncate`,children:r(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})})]})]})}function ie({plan:e,running:t,header:n,collapsible:r=!1}){let{t:a}=i(),o=(0,W.useRef)(null),[s,c]=(0,W.useState)(!0),u=e?.items||[],d=q(u),f=d.filter(e=>e.status===`completed`).length,p=d.filter(e=>e.status===`in_progress`&&!e.blocked).length,m=d.filter(e=>e.blocked).length,h=d.find(e=>e.status===`in_progress`&&!e.blocked)?.id??d.find(e=>e.blocked)?.id??d.find(e=>e.status===`pending`)?.id??d.at(-1)?.id;if((0,W.useLayoutEffect)(()=>{if(r&&!s)return;let e=o.current,t=e?.querySelector(`[data-pisper-plan-current="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<n.top?e.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.scrollTop+=i.bottom-n.bottom)},[r,h,s,d.length]),!u.length)return null;let g=d.find(e=>e.id===h),_=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(re,{className:`flex-none text-content-muted`,size:15}),(0,G.jsx)(`strong`,{className:`tabular-nums`,children:a(`chat:planBoard.progress`,{completed:f,total:u.length})}),g?(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-content-secondary`,title:g.title,children:g.title}):null,(0,G.jsxs)(`span`,{className:`plan-board-counts inline-flex flex-none items-center gap-[8px] text-content-muted tabular-nums @max-[470px]:hidden`,children:[p>0&&(0,G.jsx)(`span`,{children:a(t?`chat:planBoard.countInProgress`:`chat:planBoard.countPaused`,{count:p})}),m>0&&(0,G.jsx)(`span`,{className:`blocked text-danger`,children:a(`chat:planBoard.countBlocked`,{count:m})})]}),n,r?(0,G.jsx)(l,{className:`plan-board-chevron flex-none text-content-muted transition-transform duration-(--d-fast) ease-precise [.plan-board-collapsible[open]_&]:rotate-180`,size:15}):null]}),v=(0,G.jsx)(`ul`,{ref:o,className:`plan-board-list [.plan-board-collapsible_>_&]:border-t [.plan-board-collapsible_>_&]:border-stroke-soft [.plan-board-collapsible_>_&]:p-[6px_8px_8px] m-0 flex list-none flex-col gap-[1px] pt-[6px]${d.length>4?` is-scrollable [.session-plan-popover_.plan-board-list&]:[block-size:min(250px,38dvh)] [.plan-board-list&]:[block-size:min(220px,34dvh)] [.plan-board-list&]:overflow-y-auto [.plan-board-list&]:[overscroll-behavior:contain] [.plan-board-list&]:pr-[4px] [.plan-board-list&]:[scrollbar-gutter:stable] [.plan-board-list&:focus-visible]:outline-2 [.plan-board-list&:focus-visible]:outline-focus [.plan-board-list&:focus-visible]:outline-offset-2`:``}`,tabIndex:d.length>4?0:void 0,children:d.map(e=>(0,G.jsx)(Y,{running:t,item:e,current:e.id===h,t:a},e.id))});return r?(0,G.jsxs)(`details`,{className:`plan-board plan-board-collapsible m-[0_auto] flex w-[min(900px,100%)] flex-col overflow-hidden rounded-md border border-stroke bg-panel !p-0 [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent`,open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,G.jsx)(`summary`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,"aria-label":a(`chat:planBoard.toggleAriaLabel`),children:_}),v]}):(0,G.jsxs)(`section`,{className:`plan-board m-[0_auto] flex w-[min(900px,100%)] flex-col rounded-md border border-stroke bg-panel p-[10px_12px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0`,"aria-label":a(`chat:planBoard.ariaLabel`),children:[(0,G.jsx)(`div`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,children:_}),v]})}var ae=(0,W.memo)(ie),oe=(0,W.lazy)(()=>t(()=>import(`./GitDiffViewer-CEMK-4P4.js`).then(e=>e.n).then(e=>({default:e.InlineGitDiff})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])));function X({sessionId:e,path:t,scope:n,revision:r=0,position:o,onReading:s,mode:c,fill:l=!1}){let{t:u}=i(),d=a({queryKey:[`task-file-diff`,e,n,t,r],queryFn:({signal:r})=>n===`project`?P.getFileDiff(e,t,{signal:r}):P.getSessionFileChangeDiff(e,t,{signal:r})});return d.isPending?(0,G.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-3 py-2.5 text-xs text-content-muted`,children:[(0,G.jsx)(j,{className:`size-3.5`}),u(`chat:focusSession.gitLoading`)]}):d.isError?(0,G.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,G.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:d.error.message}),(0,G.jsx)(M,{variant:`ghost`,size:`sm`,onClick:()=>void d.refetch(),children:u(`chat:chatMessage.filePreviewRetry`)})]}):(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(oe,{position:o,onReading:s,diff:d.data.diff,truncated:d.data.diffTruncated,mode:c,fill:l})})}function se({sessionId:e,cwd:t,streaming:n,view:r,onViewChange:o}){let{t:s}=i(),c=a({queryKey:[`task-project-changes`,e,t,n],queryFn:({signal:t})=>P.getVcsChanges(e,{signal:t})}),l=p(r.reading?.list,e=>o({reading:{...r.reading,list:e}})),d=(0,W.useMemo)(()=>g(c.data?.diff||``,c.data?.files.map(e=>e.path)||[],c.data?.diffTruncated),[c.data]),f=r.expandedFiles.filter(e=>c.data&&!c.data.files.some(t=>t.path===e)),m=c.error?.message||c.data?.error,h=c.data?.files||[];return(0,G.jsxs)(`section`,{"aria-label":s(`chat:workbench.projectChanges`),className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,G.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:s(`chat:workbench.projectChanges`)}),c.data?.isRepo&&!m&&(0,G.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`text-success`,children:[`+`,d.added]}),` `,(0,G.jsxs)(`span`,{className:`text-danger`,children:[`−`,d.removed]})]}),(0,G.jsx)(M,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":s(`chat:focusSession.gitRefresh`),disabled:c.isFetching,onClick:()=>void c.refetch(),children:(0,G.jsx)(O,{size:15,className:c.isFetching?`animate-spin`:void 0})})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:s(`chat:workbench.projectScope`)}),(0,G.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,title:t,children:[c.data?.branch&&(0,G.jsxs)(`span`,{className:`inline-flex h-5.5 max-w-[45%] shrink-0 items-center gap-1 rounded-xs border border-stroke px-1.5 font-mono text-content-secondary`,children:[(0,G.jsx)(C,{size:12,className:`shrink-0`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`truncate`,children:c.data.branch})]}),(0,G.jsx)(`span`,{className:`min-w-0 truncate font-mono text-content-muted`,children:t})]}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(M,{variant:`ghost`,size:`sm`,disabled:!h.length||!!m,onClick:()=>o({expandedFiles:h.map(e=>e.path)}),children:s(`chat:workbench.expandAll`)}),(0,G.jsx)(M,{variant:`ghost`,size:`sm`,onClick:()=>o({expandedFiles:[]}),children:s(`chat:workbench.collapseAll`)})]})]}),!c.isFetching&&!m&&f.map(e=>(0,G.jsx)(`p`,{role:`status`,className:`break-all px-3 pt-2 text-xs text-content-muted`,children:s(`chat:workbench.fileNoLongerChanged`,{path:e})},e)),c.isPending?(0,G.jsx)(L,{kind:`loading`,title:s(`chat:focusSession.gitLoading`)}):m?(0,G.jsx)(`p`,{role:`alert`,className:`p-3 text-sm text-danger`,children:m}):c.data?.isRepo?h.length?(0,G.jsx)(`div`,{ref:l.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:h.map(t=>{let n=r.expandedFiles.includes(t.path);return(0,G.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,G.jsxs)(`button`,{"aria-expanded":n,title:t.path,className:`flex min-h-9 w-full min-w-0 items-center gap-2 pr-3 pl-2 text-left text-sm hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${n?`bg-surface-subtle`:``}`,onClick:()=>o({expandedFiles:n?r.expandedFiles.filter(e=>e!==t.path):[...r.expandedFiles,t.path]}),children:[(0,G.jsx)(u,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.path}),(0,G.jsx)(`span`,{className:`min-w-4 shrink-0 text-center font-mono text-xs font-medium text-content-secondary`,children:t.status}),Object.hasOwn(d.files,t.path)&&(0,G.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`text-success`,children:[`+`,d.files[t.path].added]}),` `,(0,G.jsxs)(`span`,{className:`text-danger`,children:[`−`,d.files[t.path].removed]})]})]}),n&&(0,G.jsx)(`p`,{className:`break-all px-3 py-1.5 font-mono text-xs text-content-muted`,children:t.path}),n&&(0,G.jsx)(X,{sessionId:e,path:t.path,scope:`project`,position:r.reading?.[t.path],onReading:e=>o({reading:{...r.reading,[t.path]:e}}),revision:c.dataUpdatedAt})]},t.path)})}):(0,G.jsx)(R,{compact:!0,title:s(`chat:focusSession.fileChangesEmpty`)}):(0,G.jsx)(R,{compact:!0,title:s(`chat:workbench.notRepository`)})]})}function Z(e){return e instanceof Error?e.message:String(e)}function ce({sessionId:e,streaming:t,requestConfirm:n}){let{t:r}=i(),[a,o]=(0,W.useState)(0),[s,c]=(0,W.useState)(0),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(null),[C,w]=(0,W.useState)(null),T=(0,W.useRef)(!1),E=(0,W.useRef)(0),D=(0,W.useRef)(0),O=(0,W.useRef)(!0),k=(0,W.useRef)(!1),A=(0,W.useRef)(t);return(0,W.useLayoutEffect)(()=>{A.current=t},[t]),(0,W.useLayoutEffect)(()=>(T.current=!0,()=>{T.current=!1,E.current+=1,D.current+=1}),[]),(0,W.useEffect)(()=>{let t=++E.current;return D.current+=1,S(null),w(null),O.current=!0,f(!0),m(``),P.getSessionFileChanges(e).then(e=>{T.current&&t===E.current&&(u(e),c(e=>e+1))},e=>{T.current&&t===E.current&&m(Z(e))}).finally(()=>{T.current&&t===E.current&&(O.current=!1,f(!1))}),()=>{E.current+=1}},[a,e,t]),{changes:l,loading:d,error:p,actionError:h,notice:_,running:y,diff:x,setDiff:S,diffLoading:C,snapshotRevision:s,writesDisabled:d||t||!!y||!!p||!l,pendingCount:l?.summary.pending||0,reversibleCount:l?.files.filter(e=>e.canRevert&&!e.reverted).length||0,displayedError:h||p,viewDiff:async t=>{if(k.current||O.current)return;let n=++D.current;w(t),g(``);try{let i=await P.getSessionFileChangeDiff(e,t);if(!T.current||n!==D.current)return;if(!i.diff?.trim()){g(r(`chat:focusSession.fileChangesNoSnapshot`));return}S({diff:i.diff,truncated:!!i.diffTruncated})}catch(e){T.current&&n===D.current&&g(Z(e))}finally{T.current&&n===D.current&&w(null)}},runAction:async t=>{if(!T.current||k.current||O.current||A.current||!l||p||!l.files.filter(e=>t.kind===`approve`?e.pending&&!e.approved&&!e.reverted:e.canRevert&&!e.reverted).some(e=>t.path===void 0||e.path===t.path))return;k.current=!0,b(t),g(``),v(``);let i=++E.current;D.current+=1,S(null),w(null);let a=!1;try{if(t.kind===`revert`&&!await n({title:t.path?r(`chat:focusSession.fileChangesRevertFile`):r(`chat:focusSession.fileChangesRevertAll`),message:t.path?r(`chat:focusSession.fileChangesRevertFileDescription`,{path:t.path}):r(`chat:focusSession.fileChangesRevertAllDescription`),confirmLabel:r(`chat:focusSession.fileChangesConfirmRevert`),tone:`danger`})||!T.current||A.current||O.current||i!==E.current)return;a=!0;let o=t.kind===`approve`?await P.approveSessionFileChanges(e,t.path):await P.revertSessionFileChanges(e,t.path);if(I(e),!T.current||i!==E.current)return;u(o),t.kind===`approve`?v(t.path?r(`chat:focusSession.fileChangesApproved`):r(`chat:focusSession.fileChangesApproveDone`)):o.reverted?t.path===void 0&&o.files.some(e=>e.pending)?v(r(`chat:focusSession.fileChangesRevertPartial`,{count:o.reverted})):v(r(`chat:focusSession.fileChangesRevertDone`)):v(r(`chat:focusSession.fileChangesRevertUnavailable`))}catch(e){T.current&&i===E.current&&g(Z(e))}finally{k.current=!1,T.current&&(b(null),a&&(O.current=!0,f(!0),o(e=>e+1)))}},refresh:()=>{O.current=!0,f(!0),g(``),o(e=>e+1)}}}var Q=(0,W.lazy)(()=>t(()=>import(`./TaskTerminalView-CEWghfPZ.js`).then(e=>({default:e.TaskTerminalView})),__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,19,10,20,14,13,15,12,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]))),le=(0,W.lazy)(()=>t(()=>import(`./TaskProcessesPane-ML4UTyA9.js`).then(e=>({default:e.TaskProcessesPane})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,39,10,19,20,40,25,15,29,34,12,13,14,21,22,23,24,26,27,28,30,31,32,33,35,36]))),ue=(0,W.lazy)(()=>t(()=>import(`./FileAttachmentPreview-DxwMjwfS.js`).then(e=>e.n).then(e=>({default:e.FileAttachmentPreview})),__vite__mapDeps([41,1,2,3,4,5,6,7,8,9,42,43,44,10,45,46,11,47,13,29,15,31,48,12,14,49,50,51,32,52,53,54,55,56,25,57,58])));function de({sources:e,view:t,onViewChange:n}){let{t:r}=i(),a=p(t.reading?.list,e=>n({reading:{...t.reading,list:e}})),o=(0,W.useContext)(S),[s,c]=(0,W.useState)(``),l=(0,W.useRef)(null),d=e.find(e=>e.id===s),f=e.filter(e=>(!t.filter||e.kind===t.filter)&&e.name.toLocaleLowerCase().includes(t.query.toLocaleLowerCase()));return(0,G.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":r(`chat:workbench.sources`),children:[(0,G.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,G.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:[r(`chat:workbench.sources`),(0,G.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.length})]}),(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:r(`chat:workbench.addSource`)}),(0,G.jsx)(`div`,{ref:o?.setSourceActionHost,className:`grid min-h-7 min-w-7 place-items-center`})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:r(`chat:workbench.sourcesScope`)}),(0,G.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,G.jsx)(F,{className:`min-w-0 flex-1`,"aria-label":r(`chat:workbench.searchSources`),placeholder:r(`chat:workbench.searchSources`),value:t.query,onChange:e=>n({query:e.target.value})}),(0,G.jsxs)(z,{"aria-label":r(`chat:workbench.sourceType`),className:`w-auto max-w-[45%] shrink-0`,value:t.filter,onChange:e=>n({filter:e.target.value}),children:[(0,G.jsx)(`option`,{value:``,children:r(`chat:workbench.allTypes`)}),(0,G.jsx)(`option`,{value:`image`,children:r(`chat:workbench.images`)}),(0,G.jsx)(`option`,{value:`text`,children:r(`chat:workbench.text`)}),(0,G.jsx)(`option`,{value:`file`,children:r(`chat:workbench.files`)})]})]})]}),(0,G.jsxs)(`div`,{ref:a.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:[!f.length&&(0,G.jsx)(R,{compact:!0,title:e.length?r(`chat:workbench.noMatches`):r(`chat:workbench.noSources`)}),f.map(e=>{let i=t.selectedSourceId===e.id,a=e.kind===`image`?w:e.method===`path`?T:m;return(0,G.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,G.jsxs)(`button`,{className:`flex min-h-9 w-full min-w-0 items-center gap-2 px-2 text-left hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${i?`bg-surface-subtle`:``}`,"aria-expanded":i,onClick:()=>n({selectedSourceId:i?``:e.id}),children:[(0,G.jsx)(u,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${i?`rotate-90`:``}`}),(0,G.jsx)(a,{className:`size-3.5 shrink-0 text-content-muted`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name||r(`chat:chatMessage.fileAttachment`)})]}),i&&(0,G.jsxs)(`div`,{className:`space-y-1.5 border-t border-stroke-soft bg-code py-2.5 pr-3 pl-8 text-xs text-content-muted`,children:[(0,G.jsx)(`p`,{className:`break-all font-mono text-content-secondary`,children:e.attachment.path||e.attachment.id||r(`chat:workbench.unavailable`)}),(0,G.jsx)(`p`,{className:`font-mono`,children:e.attachment.mimeType||`application/octet-stream`}),(0,G.jsx)(`p`,{children:e.method===`asset`?r(`chat:workbench.registeredAsset`):e.method===`path`?r(`chat:workbench.pathReference`):r(`chat:workbench.invalidReference`)}),(0,G.jsx)(M,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:!e.available,onClick:t=>{l.current=t.currentTarget,c(e.id)},children:r(`chat:chatMessage.fileActionPreview`)})]})]},e.id)})]}),d&&(0,G.jsx)(W.Suspense,{fallback:null,children:(0,G.jsx)(ue,{attachment:d.attachment,onClose:()=>c(``),onRestoreFocus:()=>l.current?.focus(),onDownload:()=>{typeof d.attachment.downloadUrl==`string`&&window.open(d.attachment.downloadUrl,`_blank`,`noopener,noreferrer`)}})})]})}function fe({parentId:e,active:t}){let{t:n}=i(),{entry:r,runtime:a,load:o,setDraft:c}=x(e),l=r.session?.id??``,u=(0,W.useMemo)(()=>e=>a.subscribeSessionState(l,e),[a,l]),d=(0,W.useMemo)(()=>()=>a.getSessionState(l),[a,l]),f=(0,W.useSyncExternalStore)(u,d),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[S,C]=(0,W.useState)(``),w=(0,W.useRef)(!1),T=(0,W.useRef)(!1),D=(0,W.useRef)(r.draft);D.current=r.draft;let O=(0,W.useRef)(null),A=ee(e=>e.bindings),P=v(f,r.session);(0,W.useEffect)(()=>{t&&o(e)},[t,o,e]);let F=async t=>{t.preventDefault();let n=D.current.trim();if(!(!n||w.current||P||r.expired)){w.current=!0,m(!0),C(``);try{let t=await o(e,!r.session);if(!t?.session)return;let i=t.session.id;if(a.getSessionState(i).streaming)return;D.current.trim()===n&&c(e,``),m(!1),await a.send(i,n),await o(e)}catch(e){C(H(e))}finally{w.current=!1,m(!1)}}},I=(0,W.useCallback)(async()=>{if(!(!l||a.getSessionState(l).streaming)){C(``);try{await a.retry(l),await o(e)}catch(e){C(H(e))}}},[o,e,a,l]),L=async()=>{if(!(!l||h)){g(!0);try{C(``),await a.abort(l)}catch(e){C(H(e))}finally{g(!1)}}},R=(0,G.jsxs)(`div`,{className:`grid h-full min-h-36 place-content-center justify-items-center gap-2 px-3 text-center text-xs text-content-muted`,children:[(0,G.jsx)(`span`,{className:`mb-1 grid size-8 place-items-center rounded-md bg-key text-content-secondary shadow-key ring-1 ring-key-border`,children:(0,G.jsx)(E,{className:`size-4`,"aria-hidden":`true`})}),(0,G.jsx)(`p`,{className:`max-w-64 leading-relaxed`,children:r.expired?n(`chat:sideChat.expired`):n(`chat:sideChat.empty`)}),r.expired&&(0,G.jsxs)(M,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:r.loading,onClick:async()=>{(await o(e,!0))?.session&&O.current?.focus()},children:[r.loading&&(0,G.jsx)(j,{className:`size-3.5 text-current`}),n(`chat:sideChat.restart`)]})]}),z=S||r.error||f.error;return(0,G.jsxs)(`section`,{"data-side-chat-parent":e,"aria-label":n(`chat:sideChat.title`),className:`flex h-full min-h-0 min-w-0 flex-1 flex-col [container-type:inline-size]`,children:[(0,G.jsx)(`p`,{className:`shrink-0 border-b border-stroke-soft px-3 py-2 text-xs leading-relaxed text-content-muted`,children:n(`chat:sideChat.retention`)}),l?(0,G.jsx)(y,{sessionId:l,messages:f.messages,transcriptLoadState:f.loaded?`ready`:f.error?`error`:`loading`,emptyState:R,messageStart:f.messageStart,hasOlder:f.hasOlder,loadingOlder:f.loadingOlder,olderError:f.olderError,activityFeed:f.activityFeed,tools:f.tools,thinkingText:f.thinkingText,currentActivity:f.currentActivity,compaction:f.compaction,streaming:P,runStartedAt:f.runStartedAt,lastActivityAt:f.lastActivityAt,runFinishedAt:f.runFinishedAt,runStopped:f.runStopped,runNotice:f.runNotice,error:f.error,cwd:r.session?.cwd,onLoadOlder:()=>a.loadOlderMessages(l),onRetryLastTurn:I}):(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:R}),(0,G.jsxs)(`form`,{className:`flex shrink-0 flex-col gap-2 border-t border-stroke-soft p-3`,onSubmit:F,children:[z&&(0,G.jsx)(b,{error:z,onRetry:r.error||!f.loaded?async()=>{await o(e)}:I}),(0,G.jsx)(_,{approvals:f.approvals,onResolve:async(e,t)=>{try{await a.approve(l,e,t)}catch{}}}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-end gap-2 rounded-[var(--composer-radius,22px)] border border-control bg-panel py-2 pr-2 pl-3 shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) focus-within:border-focus focus-within:ring-3 focus-within:ring-focus-ring`,children:[(0,G.jsx)(`textarea`,{ref:O,rows:2,value:r.draft,"aria-label":n(`chat:sideChat.message`),placeholder:n(`chat:sideChat.placeholder`),className:`max-h-40 min-h-14 min-w-0 flex-1 resize-y border-0 bg-transparent px-1 py-1 text-sm leading-relaxed text-content caret-focus outline-none placeholder:text-content-muted`,onChange:t=>c(e,t.target.value),onCompositionStart:()=>{T.current=!0},onCompositionEnd:()=>{T.current=!1},onKeyDown:e=>{!T.current&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&N(e.nativeEvent,A.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,G.jsx)(M,{type:P?`button`:`submit`,size:`icon`,className:`size-8 shrink-0 rounded-full max-[650px]:size-11 pointer-coarse:size-11`,"aria-label":n(P?`chat:sideChat.stop`:`chat:sideChat.send`),disabled:P?h:p||r.loading||r.expired||!r.draft.trim(),onClick:P?()=>void L():void 0,children:p||h?(0,G.jsx)(j,{className:`size-4 text-current`}):P?(0,G.jsx)(k,{size:13,fill:`currentColor`}):(0,G.jsx)(s,{size:17})})]})]})]})}var $=(0,W.createContext)(null),pe=()=>{let e=(0,W.useContext)($);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},me=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,W.useState)(n),[s,c]=(0,W.useState)(!1),l=(0,W.useCallback)(e=>{o(e),r?.(e)},[r]),u=(0,W.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:l,url:a}),[s,l,a]);return(0,G.jsx)($.Provider,{value:u,children:(0,G.jsx)(`div`,{className:A(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},he=({className:e,loading:t,src:n,...r})=>{let{url:i}=pe();return(0,G.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,G.jsx)(`iframe`,{className:A(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})};function ge({page:e,onChange:t}){let{t:n}=i(),{draft:r,url:a}=e,[o,s]=(0,W.useState)(!1);return(0,G.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-3`,"aria-label":n(`common:webPreview.title`),children:[(0,G.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault();let n=te(r,window.location.href);s(!n),n&&t({url:n})},children:[(0,G.jsx)(F,{"aria-label":n(`common:webPreview.url`),className:`flex-1 font-mono`,value:r,onChange:e=>t({draft:e.target.value}),placeholder:n(`common:webPreview.urlPlaceholder`),maxLength:2048}),(0,G.jsx)(M,{type:`submit`,variant:`secondary`,children:n(`chat:sessionContext.openUrl`)})]}),o&&(0,G.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:n(`chat:sessionContext.invalidUrl`)}),a?(0,G.jsx)(me,{className:`min-h-0 flex-1 overflow-hidden rounded-md border-stroke`,defaultUrl:a,children:(0,G.jsx)(he,{src:a,title:n(`common:webPreview.title`),...B(a)?{sandbox:V}:{}})},a):(0,G.jsx)(R,{icon:d,className:`min-h-0 flex-1`,title:n(`chat:sessionContext.browserEmpty`)}),a&&(0,G.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>window.open(a,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(f,{size:14}),n(`common:webPreview.openExternal`)]}),(0,G.jsx)(`p`,{className:`text-xs text-content-muted`,children:n(`common:webPreview.embedNotice`)})]})}export{Q as a,X as c,le as i,ae as l,fe as n,ce as o,de as r,se as s,ge as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-CEMK-4P4.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-CaxKosZm.js","assets/i18n-Cl3sIF9G.js","assets/vendor-router-CSN_DGvx.js","assets/index-rOrQSojS.js","assets/index-l96Dl6z6.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-oPlZB-qC.js","assets/esm-DCV8yILT.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-CaxKosZm.js";import{i as a}from"./runtime-capabilities-CHYOF_hE.js";import{t as o}from"./runtime-capabilities-store-SnV1V9_K.js";import{a as s}from"./permission-rules-api-M-EIynsN.js";import{t as c}from"./arrow-left-B8oVrQ2S.js";import{t as l}from"./check-2vYc6QaP.js";import{t as u}from"./chevron-right-C3t2Rckj.js";import{a as d,c as f,i as p,l as m,n as h,o as g,r as _,s as v,t as y}from"./SessionBrowserPane-BISoBe8t.js";import{t as b}from"./earth-Ddy13fHh.js";import{i as x,o as S}from"./GitDiffViewer-CEMK-4P4.js";import{b as C,x as w,y as T,z as E}from"./side-chat-context-DhztplBz.js";import{n as D,t as O}from"./undo-2-C-xQ0UVT.js";import{t as k}from"./link-2-mgasYn21.js";import{t as A}from"./message-square-SKjZyY3v.js";import{t as j}from"./plus-fQbSqB1n.js";import{t as M}from"./refresh-cw-TbWxTY4K.js";import{t as N}from"./square-terminal-BVG6cUT1.js";import{t as P}from"./x-07u4-129.js";import{n as F,t as I}from"./button-CCcCN8tE.js";import{s as L}from"./events-oPlZB-qC.js";import{a as ee,n as te,o as ne,t as re}from"./sheet-BTaIEX4w.js";import{t as R}from"./input-CPw-zkYh.js";import{n as z,t as B}from"./PageState-Cz6vFMXv.js";import{r as V}from"./web-preview-DIo7zGil.js";import{n as ie}from"./terminal-context-aIsIJPn8.js";var H=e(n(),1),U=r(),W=(0,H.lazy)(()=>t(()=>import(`./GitDiffViewer-CEMK-4P4.js`).then(e=>e.n).then(e=>({default:e.GitDiffDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))),G=100;function ae({sessionId:e,streaming:t,requestConfirm:n,view:r,onViewChange:a}){let{t:o}=i(),s=x(r?.reading?.list,e=>a?.({reading:{...r?.reading,list:e}})),[c,d]=(0,H.useState)([]),p=r?.expandedFiles||c,m=e=>a?a({expandedFiles:e}):d(e),{changes:h,loading:_,running:v,diff:y,setDiff:b,diffLoading:C,snapshotRevision:w,writesDisabled:T,pendingCount:E,reversibleCount:D,displayedError:k,notice:A,viewDiff:j,runAction:N,refresh:P}=g({sessionId:e,streaming:t,requestConfirm:n}),L=`max-[650px]:size-11 pointer-coarse:size-11`;return(0,U.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":o(`chat:focusSession.fileChanges`),"aria-busy":_||!!v,children:[(0,U.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,U.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:o(`chat:focusSession.fileChanges`)}),h&&(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,h.summary.added]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,h.summary.removed]})]}),(0,U.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,className:L,"aria-label":o(`chat:focusSession.gitRefresh`),title:o(`chat:focusSession.gitRefresh`),disabled:_||!!v,onClick:P,children:(0,U.jsx)(M,{className:_?`animate-spin`:``,size:15})})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[h&&(0,U.jsxs)(`p`,{className:`text-xs text-content-secondary tabular-nums`,children:[o(`chat:focusSession.fileChangesCount`,{count:h.summary.files}),E>0&&` · ${o(`chat:focusSession.fileChangesPending`,{count:E})}`]}),(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:o(`chat:workbench.taskSnapshotScope`)}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex gap-1`,children:[(0,U.jsxs)(I,{type:`button`,variant:`secondary`,size:`sm`,disabled:T||E===0,title:t?o(`chat:focusSession.gitWaitForRunToFinish`):void 0,onClick:()=>void N({kind:`approve`}),children:[v?.kind===`approve`&&!v.path?(0,U.jsx)(M,{className:`animate-spin`,size:14}):(0,U.jsx)(l,{size:14}),o(`chat:focusSession.fileChangesApproveAll`)]}),(0,U.jsxs)(I,{type:`button`,variant:`secondary`,size:`sm`,disabled:T||D===0,title:o(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.fileChangesRevertAllDescription`),onClick:()=>void N({kind:`revert`}),children:[v?.kind===`revert`&&!v.path?(0,U.jsx)(M,{className:`animate-spin`,size:14}):(0,U.jsx)(O,{size:14}),o(`chat:focusSession.fileChangesRevertAll`)]})]}),(0,U.jsxs)(`div`,{className:`flex gap-1`,children:[(0,U.jsx)(I,{variant:`ghost`,size:`sm`,disabled:_||!h?.files.length,onClick:()=>m(h?.files.slice(0,G).map(e=>e.path)||[]),children:o(`chat:workbench.expandAll`)}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>m([]),children:o(`chat:workbench.collapseAll`)})]})]})]}),k&&(0,U.jsx)(`p`,{role:`alert`,className:`px-3 pt-2.5 text-xs text-danger`,children:k}),A&&!k&&(0,U.jsx)(`p`,{role:`status`,className:`px-3 pt-2.5 text-xs text-content-secondary`,children:A}),_&&!h?(0,U.jsx)(z,{kind:`loading`,title:o(`chat:focusSession.gitLoading`)}):h?.files.length?(0,U.jsxs)(`ul`,{ref:s.ref,className:`min-h-0 flex-1 overflow-y-auto`,"aria-label":o(`chat:focusSession.fileChanges`),children:[h.files.slice(0,G).map(t=>{let n=p.includes(t.path);return(0,U.jsxs)(`li`,{className:`min-w-0 border-b border-stroke-soft`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5 pr-1.5 hover:bg-surface-subtle ${n?`bg-surface-subtle`:``}`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`flex min-h-9 min-w-0 flex-1 items-center gap-2 pl-2 text-left text-xs focus-visible:-outline-offset-2 disabled:opacity-60 max-[650px]:min-h-11 pointer-coarse:min-h-11`,title:t.path,disabled:_||!!v,"aria-busy":C===t.path,"aria-expanded":n,onClick:()=>m(n?p.filter(e=>e!==t.path):[...p,t.path]),children:[(0,U.jsx)(u,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),C===t.path?(0,U.jsx)(F,{className:`size-3.5`}):(0,U.jsx)(S,{size:14,className:`flex-none text-content-muted`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:t.path}),(t.reverted||t.approved)&&(0,U.jsx)(`span`,{className:`shrink-0 text-content-muted`,children:t.reverted?o(`chat:focusSession.fileChangesReverted`):o(`chat:focusSession.fileChangesApproved`)}),(0,U.jsxs)(`span`,{className:`shrink-0 font-mono tabular-nums`,children:[(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,t.added]}),` `,(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.removed]})]})]}),(0,U.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,className:L,title:o(`chat:focusSession.fileChangesApproveFile`),"aria-label":`${o(`chat:focusSession.fileChangesApproveFile`)} ${t.path}`,disabled:T||!t.pending||t.approved||t.reverted,onClick:()=>void N({kind:`approve`,path:t.path}),children:(0,U.jsx)(l,{size:14})}),(0,U.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,className:L,title:o(`chat:focusSession.fileChangesRevertFile`),"aria-label":`${o(`chat:focusSession.fileChangesRevertFile`)} ${t.path}`,disabled:T||t.reverted||!t.canRevert,onClick:()=>void N({kind:`revert`,path:t.path}),children:(0,U.jsx)(O,{size:14})})]}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(f,{sessionId:e,path:t.path,scope:`task`,position:r?.reading?.[t.path],onReading:e=>a?.({reading:{...r?.reading,[t.path]:e}}),revision:w}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,className:`m-1.5`,onClick:()=>void j(t.path),children:o(`chat:workbench.fullDiff`)})]})]},t.path)}),h.files.length>G&&(0,U.jsx)(`li`,{className:`px-3 py-2 text-xs text-content-muted tabular-nums`,children:o(`chat:focusSession.gitMoreFiles`,{count:h.files.length-G})})]}):!k&&(0,U.jsx)(B,{compact:!0,title:o(`chat:focusSession.fileChangesEmpty`)}),y&&(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(W,{diff:y.diff,truncated:y.truncated,onClose:()=>b(null)})})]})}function oe({tools:e,onSelect:t,onOpenUrl:n}){let{t:r}=i(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1);return(0,U.jsxs)(`section`,{className:`@container/new-tab flex min-h-0 flex-1 flex-col overflow-y-auto bg-panel p-4`,children:[(0,U.jsx)(`h2`,{className:`mb-3 text-sm font-medium text-content`,children:r(`chat:workbench.newTab`)}),(0,U.jsxs)(`form`,{className:`mb-4 flex gap-2`,onSubmit:e=>{e.preventDefault();let t=V(a,window.location.href);c(!t),t&&n(t)},children:[(0,U.jsx)(R,{className:`font-mono`,"aria-label":r(`common:webPreview.url`),placeholder:r(`common:webPreview.urlPlaceholder`),value:a,maxLength:2048,onChange:e=>o(e.target.value)}),(0,U.jsx)(I,{type:`submit`,variant:`secondary`,children:r(`chat:sessionContext.openUrl`)})]}),s&&(0,U.jsx)(`p`,{role:`alert`,className:`mb-3 text-xs text-danger`,children:r(`chat:sessionContext.invalidUrl`)}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 @min-[420px]/new-tab:grid-cols-2`,children:e.map(({id:e,label:n,icon:r,disabled:i})=>(0,U.jsxs)(I,{disabled:i,variant:`ghost`,className:`h-10 min-w-0 justify-start gap-2.5 border-stroke bg-panel px-3 font-normal text-content max-[650px]:h-11 pointer-coarse:h-11 [&_svg]:text-content-muted`,onClick:()=>t(e),children:[(0,U.jsx)(r,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:n})]},e))})]})}function K({panelId:e,compact:t,embedded:n=!1,active:r=!0,sessionId:l,cwd:u=``,sources:f=[],tab:g,plan:x,streaming:O,plansAvailable:M,requestConfirm:F,onTabChange:R,onClose:z,onBack:V}){let{t:W}=i(),G=ie(),K=o(e=>e.capabilities),q=[{id:`terminal`,icon:N,label:W(`terminal:workspace.terminal`)},{id:`processes`,icon:s,label:W(`terminal:workspace.processes`)},{id:`changes`,icon:S,label:W(`chat:workbench.projectChanges`)},{id:`sources`,icon:k,label:W(`chat:workbench.sources`)},{id:`files`,icon:E,label:W(`chat:workbench.taskSnapshots`)},...M?[{id:`plan`,icon:D,label:W(`chat:sessionContext.plan`)}]:[],{id:`browser`,icon:b,label:W(`common:webPreview.title`)},{id:`side-chat`,icon:A,label:W(`chat:sideChat.title`)}],se=(0,H.useMemo)(()=>C(g),[g]),J=T(e=>Object.prototype.hasOwnProperty.call(e.sessions,l)?e.sessions[l]:void 0)??se,ce=(0,H.useRef)(null),Y=J.pages.find(e=>e.id===J.activeId)??J.pages[0],X=e=>e.kind===`new`?{id:`new`,icon:j,label:W(`chat:workbench.newTab`)}:q.find(t=>t.id===e.kind)??q[0],le=t=>requestAnimationFrame(()=>document.getElementById(`${e}-${t}-tab`)?.focus()),ue=(0,H.useEffectEvent)(()=>{r&&document.getElementById(`${e}-${J.activeId}-tab`)?.focus()});(0,H.useEffect)(()=>{let e=requestAnimationFrame(()=>ue());return()=>cancelAnimationFrame(e)},[e,J.activeId]);let Z=e=>{if(e.type===`view`&&!T.getState().sessions[l])return;[`add`,`open`,`select`,`close`,`kind`].includes(e.type)&&window.dispatchEvent(new Event(L));let t=w(J,e);T.getState().update(l,g,e);let n=t.pages.find(e=>e.id===t.activeId);n&&R(n.kind),(e.type===`add`||e.type===`select`||e.type===`close`)&&le(t.activeId),e.type===`close`&&J.pages.length===1&&z()},Q=W(`chat:sessionContext.addPage`),de=W(`chat:sessionContext.pageLimit`),fe=(0,U.jsx)(I,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,disabled:J.pages.length>=12,"aria-label":Q,title:J.pages.length>=12?de:Q,onClick:()=>Z({type:`add`,kind:`new`}),children:(0,U.jsx)(j,{size:16})}),$=(0,U.jsxs)(`div`,{"data-session-context-panel":!0,className:`flex h-full min-h-0 min-w-0 flex-col bg-panel text-content`,children:[(0,U.jsxs)(`header`,{"data-window-drag-region":!0,className:`auxiliary-page-header flex h-12 shrink-0 items-center gap-1 border-b border-stroke-soft px-2`,children:[V&&(0,U.jsx)(I,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":W(`chat:workbench.backToConversation`),title:W(`chat:workbench.backToConversation`),onClick:V,children:(0,U.jsx)(c,{size:16})}),(0,U.jsx)(`div`,{ref:ce,className:`flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto px-px py-1 [scrollbar-width:none]`,role:`tablist`,"aria-label":W(`chat:sessionContext.title`),onKeyDown:e=>{if(!(e.target instanceof HTMLElement)||e.target.getAttribute(`role`)!==`tab`)return;if(e.key===`Delete`){e.preventDefault(),Z({type:`close`,id:Y.id});return}if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=J.pages.findIndex(e=>e.id===Y.id),n=e.key===`Home`?0:e.key===`End`?J.pages.length-1:(t+(e.key===`ArrowRight`?1:-1)+J.pages.length)%J.pages.length;Z({type:`select`,id:J.pages[n].id})},children:J.pages.map(t=>{let{icon:n,label:r}=X(t);return(0,U.jsxs)(`div`,{className:`relative flex max-w-40 min-w-20 shrink-0 items-center rounded-sm transition-colors duration-(--d-fast) ${t.id===Y.id?`bg-key font-medium text-content shadow-key ring-1 ring-key-border after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-full after:bg-star`:`text-content-muted hover:bg-surface-hover hover:text-content`}`,children:[(0,U.jsxs)(`button`,{id:`${e}-${t.id}-tab`,type:`button`,role:`tab`,"aria-selected":t.id===Y.id,"aria-controls":`${e}-${t.id}-content`,tabIndex:t.id===Y.id?0:-1,className:`flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-sm pl-2 text-sm focus-visible:outline-offset-0 max-[650px]:h-11`,onClick:()=>Z({type:`select`,id:t.id}),children:[(0,U.jsx)(n,{size:14,className:`shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:r})]}),(0,U.jsx)(`button`,{type:`button`,className:`mx-0.5 grid size-5 shrink-0 place-items-center rounded-xs text-content-muted hover:bg-surface-hover hover:text-content focus-visible:outline-offset-0 max-[650px]:size-11`,"aria-label":`${W(`chat:sessionContext.closePage`)} · ${r}`,onClick:()=>Z({type:`close`,id:t.id}),children:(0,U.jsx)(P,{size:12})})]},t.id)})}),fe]}),J.pages.map(t=>{let n=X(t),r=Y.id===t.id;return(0,U.jsx)(`div`,{id:`${e}-${t.id}-content`,role:`tabpanel`,"aria-labelledby":`${e}-${t.id}-tab`,className:r?`flex min-h-0 flex-1 flex-col`:`hidden`,hidden:!r,children:n.id===`new`?r&&(0,U.jsx)(oe,{tools:q.map(e=>({...e,disabled:e.id===`terminal`||e.id===`processes`?!G||!a(K,`terminal`):e.id===`changes`&&!a(K,`vcs`)})),onOpenUrl:e=>{Z({type:`open`,kind:`browser`,replaceId:t.id}),T.getState().update(l,`browser`,{type:`browser`,id:t.id,url:e,draft:e})},onSelect:e=>Z({type:`open`,kind:e,replaceId:t.id})}):n.id===`changes`?r&&(0,U.jsx)(v,{sessionId:l,cwd:u,streaming:O,view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e})}):n.id===`sources`?r&&(0,U.jsx)(_,{sources:f,view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e})}):n.id===`terminal`?r&&(0,U.jsx)(d,{sessionId:l,cwd:u,terminalId:t.resourceId||void 0,onCreated:e=>T.getState().update(l,g,{type:`resource`,id:t.id,resourceId:e})}):n.id===`processes`?r&&(0,U.jsx)(p,{view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e}),sessionId:l,onOpenTerminal:e=>Z({type:`open`,kind:`terminal`,resourceId:e})}):n.id===`side-chat`?(0,U.jsx)(h,{parentId:l,active:r}):n.id===`browser`?(0,U.jsx)(y,{page:t,onChange:e=>Z({type:`browser`,id:t.id,...e})}):r&&(n.id===`files`?(0,U.jsx)(ae,{view:t.view,onViewChange:e=>Z({type:`view`,id:t.id,patch:e}),sessionId:l,streaming:O,requestConfirm:F}):(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:x?.items?.length?(0,U.jsx)(m,{plan:x,running:O}):(0,U.jsx)(B,{compact:!0,title:W(`chat:sessionContext.planEmpty`)})}))},t.id)})]});return t?(0,U.jsx)(re,{open:!0,onOpenChange:e=>!e&&z(),children:(0,U.jsxs)(te,{id:e,side:`right`,showCloseButton:!1,className:`gap-0 overflow-hidden p-0`,style:{top:`var(--pisper-safe-area-top)`,right:`var(--pisper-safe-area-right)`,bottom:`var(--pisper-safe-area-bottom)`,height:`auto`,width:`min(calc(100vw - var(--pisper-safe-area-left) - var(--pisper-safe-area-right)), 420px)`,maxWidth:`none`},children:[(0,U.jsx)(ee,{className:`sr-only`,children:(0,U.jsx)(ne,{children:W(`chat:sessionContext.title`)})}),$]})}):(0,U.jsx)(`aside`,{id:e,tabIndex:n?-1:void 0,className:`h-full min-h-0 w-full overflow-hidden border-l border-stroke bg-panel`,"aria-label":W(`chat:sessionContext.title`),children:$})}export{K as SessionContextPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-CaxKosZm.js";import{t as i}from"./useQuery-DdcpUQhO.js";import{i as a}from"./runtime-capabilities-CHYOF_hE.js";import{t as o}from"./runtime-capabilities-store-SnV1V9_K.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{a as c,i as l}from"./permission-rules-api-M-EIynsN.js";import{t as u}from"./bot-B3TaBp_T.js";import{t as d}from"./check-2vYc6QaP.js";import{a as f,c as p,i as m,l as h,n as g,o as _,r as v,t as ee}from"./SessionBrowserPane-BISoBe8t.js";import{c as y}from"./focus-session-composer-bits-VRvsf-4b.js";import{t as te}from"./earth-Ddy13fHh.js";import{t as b}from"./ellipsis-CfGKfbq6.js";import{o as ne}from"./GitDiffViewer-CEMK-4P4.js";import{_ as x,c as re,l as ie,y as S,z as ae}from"./side-chat-context-DhztplBz.js";import{t as oe}from"./git-branch-N7LGjtzt.js";import{n as se,t as C}from"./undo-2-C-xQ0UVT.js";import{t as ce}from"./message-square-SKjZyY3v.js";import{t as le}from"./plus-fQbSqB1n.js";import{t as w}from"./refresh-cw-TbWxTY4K.js";import{t as ue}from"./square-terminal-BVG6cUT1.js";import{t as de}from"./wrench-6pg6_bqI.js";import{t as fe}from"./x-07u4-129.js";import{c as T,i as E,p as pe,r as me,t as D}from"./dropdown-menu-Ds0gD8S8.js";import{i as he,n as ge,t as _e}from"./popover-DlJP3VbH.js";import{t as O}from"./segmented-control-xkrEOP_d.js";import{t as k}from"./utils-C8uzG5AZ.js";import{t as A}from"./button-CCcCN8tE.js";import{t as ve}from"./chat-api-D9RzUTQi.js";import{a as j,r as M}from"./format-DMJQzoZ7.js";import{t as N}from"./StatusGlyph-1KgitlUg.js";import{s as ye}from"./run-activity-CwfO0cui.js";import{t as be}from"./session-change-summary-api-orjhsMHB.js";import{n as P,t as F}from"./PageState-Cz6vFMXv.js";import{i as xe,n as I,r as Se}from"./MarkdownMessage-gnw-y810.js";import{t as L}from"./route-context-DvWDul4T.js";import"./web-preview-DIo7zGil.js";import{n as Ce,r as R}from"./terminal-context-aIsIJPn8.js";var z=s(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),we=s(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),B=e(t(),1),V=n(),H=new Set([`queued`,`starting`,`running`]),Te=new Set([`starting`,`running`,`stopping`]);function U(e){return typeof e==`string`?e.trim():``}function W(e,t,n){let r=new Map;for(let i of e){if(i?.type!==t)continue;let e=n(i);e&&r.set(String(e.id||r.size),e)}return[...r.values()]}function Ee({startedAt:e}){let[t,n]=(0,B.useState)(()=>Date.now());(0,B.useEffect)(()=>{let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let r=ye(e,null,t);return r?(0,V.jsx)(`span`,{className:`flex-none font-mono text-xs text-content-muted tabular-nums`,children:y(r)}):null}function De(e,t){let n=t?W(e,`tool`,e=>e).filter(e=>e.status===`running`):[],r=W(e,`agent`,e=>e.agent&&typeof e.agent==`object`?e.agent:null).filter(e=>H.has(String(e.status)));return n.length+r.length}function Oe({sessionId:e,streaming:t,activity:n}){let{t:i}=r(),a=R(e),o=[...t?W(n,`tool`,e=>e).filter(e=>e.status===`running`).map(e=>{let t=e.args||{};return{key:`tool:${String(e.id)}`,icon:(0,V.jsx)(de,{size:14,"aria-hidden":`true`}),name:U(e.name)||i(`board:inspector.runningTool`),detail:U(t.command)||U(t.path)||U(t.file_path),startedAt:U(e.startedAt),status:i(`board:inspector.runningStatus`)}}):[],...W(n,`agent`,e=>e.agent&&typeof e.agent==`object`?e.agent:null).filter(e=>H.has(String(e.status))).map(e=>({key:`agent:${String(e.id)}`,icon:(0,V.jsx)(u,{size:14,"aria-hidden":`true`}),name:U(e.title)||U(e.taskName)||i(`board:inspector.runningAgent`),detail:U(e.message),startedAt:U(e.startedAt),status:e.status===`queued`?i(`board:inspector.runningQueued`):i(`board:inspector.runningStatus`)})),...a.filter(e=>Te.has(e.status)).map(e=>({key:`terminal:${e.id}`,icon:(0,V.jsx)(ue,{size:14,"aria-hidden":`true`}),name:e.profileId||i(`board:inspector.terminal`),detail:e.cwd||``,status:e.status===`stopping`?i(`terminal:workspace.stopping`):i(`board:inspector.runningStatus`)}))];return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto p-3`,"data-inspector-running":!0,children:[o.length?(0,V.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-px p-0`,children:o.map(e=>(0,V.jsxs)(`li`,{className:`grid min-w-0 grid-cols-[14px_minmax(0,1fr)_auto] items-start gap-2 py-1.5 text-xs`,"data-running-item":e.key.split(`:`)[0],children:[(0,V.jsx)(`span`,{className:`mt-0.5 text-content-secondary`,children:e.icon}),(0,V.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,V.jsx)(`strong`,{className:`truncate text-[13px] font-medium text-content`,children:e.name}),e.detail&&(0,V.jsx)(`span`,{className:`min-w-0 truncate font-mono text-content-muted`,title:e.detail,children:e.detail})]}),(0,V.jsxs)(`span`,{className:`flex flex-none items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-content-muted`,children:e.status}),(0,V.jsx)(Ee,{startedAt:e.startedAt})]})]},e.key))}):(0,V.jsx)(F,{compact:!0,title:i(`board:inspector.runningEmpty`)}),(0,V.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-content-faint`,children:i(`board:inspector.runningHint`)})]})}var G={running:{kind:`run`,color:`text-st-run`},starting:{kind:`run`,color:`text-st-run`},queued:{kind:`queued`,color:`text-st-queue`},completed:{kind:`done`,color:`text-st-done`},failed:{kind:`failed`,color:`text-st-fail`},interrupted:{kind:`stopped`,color:`text-st-queue`},blocked:{kind:`queued`,color:`text-st-queue`}};function K(e,t){return t(e===`queued`?`chat:agentRunActivity.teamTaskQueued`:e===`starting`?`chat:agentRunActivity.teamTaskStarting`:e===`running`?`chat:agentRunActivity.teamTaskRunning`:e===`completed`?`chat:agentRunActivity.teamTaskCompleted`:e===`failed`?`chat:agentRunActivity.teamTaskFailed`:e===`interrupted`?`chat:agentRunActivity.teamTaskInterrupted`:e===`blocked`?`chat:agentRunActivity.teamTaskBlocked`:`chat:agentRunActivity.teamTaskStatusUpdated`)}function ke(e,t){return e.status===`active`?e.mode===`team`?t(`chat:focusSession.runningAsTeam`):t(`chat:focusSession.runningAutonomously`):e.status===`paused`?t(`chat:focusSession.goalPaused`):e.status===`complete`?t(`chat:focusSession.goalComplete`):e.status===`budget_limited`?t(`chat:focusSession.goalReachedItsBudget`):``}function q({title:e,children:t}){return(0,V.jsxs)(`section`,{className:`grid min-w-0 gap-2`,"aria-label":e,children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-content-secondary`,children:e}),t]})}function J({status:e,name:t,detail:n,t:r}){let i=G[String(e)]??{kind:`queued`,color:`text-st-queue`};return(0,V.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 py-1.5 text-xs`,children:[(0,V.jsx)(N,{status:i.kind,className:`mt-px size-3.5 ${i.color}`}),(0,V.jsxs)(`span`,{className:`grid min-w-0 flex-1 gap-0.5`,children:[(0,V.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`strong`,{className:`min-w-0 truncate font-medium text-content`,children:t}),(0,V.jsx)(`span`,{className:`flex-none text-content-muted`,children:K(e,r)})]}),n&&(0,V.jsx)(`span`,{className:`min-w-0 break-words text-content-muted`,children:n})]})]})}function Ae(e){let t=new Map;for(let n of e){if(n?.type!==`agent`||!n.agent||typeof n.agent!=`object`)continue;let e=n.agent,r=String(e.id||e.taskName||t.size);t.set(r,e)}return[...t.values()]}function je({plan:e,streaming:t,goal:n,team:i,activity:a}){let{t:o}=r(),s=Array.isArray(i?.tasks)?i.tasks:[],c=Ae(a),l=!!(n?.id&&String(n.objective||``).trim()),u=!!e?.items?.length;if(!l&&!u&&!s.length&&!c.length)return(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:(0,V.jsx)(F,{compact:!0,icon:se,title:o(`chat:sessionContext.planEmpty`)})});let d=Number(n?.mode===`team`?n?.teamTokenBudget:n?.tokenBudget)||0;return(0,V.jsxs)(`div`,{className:`grid min-h-0 flex-1 content-start gap-5 overflow-y-auto p-3`,"data-inspector-plan":!0,children:[l&&n&&(0,V.jsx)(q,{title:o(`board:inspector.goal`),children:(0,V.jsxs)(`div`,{className:`grid gap-1.5 rounded-md border border-stroke-soft bg-surface-subtle p-3 text-xs`,children:[(0,V.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-content`,children:String(n.objective)}),(0,V.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-content-muted tabular-nums`,children:[(0,V.jsx)(`span`,{children:ke(n,o)}),(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,V.jsx)(`span`,{children:d>0?o(`chat:focusSession.usedBudgetTokensUsed`,{used:M(n.tokensUsed),budget:M(d)}):o(`chat:focusSession.usedUnlimitedGoalTokens`,{used:M(n.tokensUsed)})})]})]})}),u&&(0,V.jsx)(q,{title:o(`board:inspector.plan`),children:(0,V.jsx)(h,{plan:e,running:t})}),s.length>0&&(0,V.jsx)(q,{title:o(`board:inspector.team`),children:(0,V.jsx)(`ul`,{className:`divide-y divide-stroke-soft`,children:s.map((e,t)=>(0,V.jsx)(J,{status:e.status,name:e.taskName||o(`chat:agentRunActivity.subagent`),detail:e.error||e.output||``,t:o},e.id||`${e.taskName}-${t}`))})}),c.length>0&&(0,V.jsx)(q,{title:o(`board:inspector.subAgents`),children:(0,V.jsx)(`ul`,{className:`divide-y divide-stroke-soft`,children:c.map((e,t)=>(0,V.jsx)(J,{status:e.status,name:String(e.taskName||``).trim()||o(`chat:agentRunActivity.subagent`),detail:String(e.error||e.message||``).trim(),t:o},String(e.id||t)))})})]})}var Y=100;function X(e){let t=e.trim().toUpperCase();return t===`??`||t.includes(`A`)?`created`:t.includes(`D`)?`deleted`:t.includes(`R`)?`renamed`:t.includes(`M`)?`modified`:`other`}var Me={modified:`M`,created:`A`,deleted:`D`,renamed:`R`,other:`·`},Z={modified:`text-content-secondary`,created:`text-st-done`,deleted:`text-st-fail`,renamed:`text-content-secondary`,other:`text-content-muted`};function Ne(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n<0?{directory:``,name:t}:{directory:t.slice(0,n+1),name:t.slice(n+1)}}function Pe(e,t){return/^(?:[a-zA-Z]:[\\/]|\/|\\\\)/.test(t)?t:`${e.replace(/[\\/]+$/,``)}/${t}`}function Q(e,t){window.dispatchEvent(new CustomEvent(L,{detail:{message:e,tone:t}}))}function $({added:e,removed:t}){return e===null||t===null?null:(0,V.jsxs)(`span`,{className:`flex-none font-mono text-xs tabular-nums`,children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}),` `,(0,V.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]})]})}function Fe({status:e,children:t}){let{t:n}=r();return(0,V.jsxs)(`footer`,{className:`mt-auto flex h-10 shrink-0 items-center gap-2 border-t border-stroke-soft pr-1.5 pl-3 text-xs text-content-muted`,"data-changes-footer":!0,children:[(0,V.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 truncate`,children:e}),(0,V.jsxs)(D,{children:[(0,V.jsx)(pe,{asChild:!0,children:(0,V.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`pointer-coarse:size-11`,"aria-label":n(`board:changes.more`),title:n(`board:changes.more`),"data-changes-more":!0,children:(0,V.jsx)(b,{"aria-hidden":`true`})})}),(0,V.jsx)(me,{align:`end`,side:`top`,className:`min-w-48`,children:t})]})]})}function Ie({status:e}){let{t}=r(),n=t(e===`created`?`board:changes.statusCreated`:e===`deleted`?`board:changes.statusDeleted`:e===`renamed`?`board:changes.statusRenamed`:`board:changes.statusModified`);return(0,V.jsxs)(`span`,{className:k(`w-3.5 flex-none text-center font-mono text-xs font-semibold`,Z[e]),title:n,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,children:Me[e]}),(0,V.jsx)(`span`,{className:`sr-only`,children:n})]})}function Le({files:e,selected:t,label:n,onSelect:r}){let i=(0,B.useRef)(null);return(0,V.jsxs)(`ul`,{ref:i,"aria-label":n,className:`max-h-[34%] min-h-11 shrink-0 overflow-y-auto border-b border-stroke-soft py-1`,onKeyDown:e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=[...i.current?.querySelectorAll(`[data-change-file]`)??[]],n=t.findIndex(e=>e===document.activeElement),a=t[e.key===`Home`?0:e.key===`End`?t.length-1:Math.min(t.length-1,Math.max(0,n+(e.key===`ArrowDown`?1:-1)))];a&&(e.preventDefault(),a.focus(),r(a.dataset.changeFile||``))},"data-change-list":!0,children:[e.slice(0,Y).map(e=>{let n=e.path===t,{directory:i,name:a}=Ne(e.path);return(0,V.jsx)(`li`,{className:`px-1`,children:(0,V.jsxs)(`button`,{type:`button`,title:e.path,"aria-label":[e.path,Me[e.status],e.added!==null&&e.removed!==null?`+${e.added} −${e.removed}`:``,e.note||``].filter(Boolean).join(` `),"aria-current":n?`true`:void 0,"data-change-file":e.path,className:k(`flex h-8 w-full min-w-0 items-center gap-2 rounded-sm px-2 text-left text-xs transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus max-[650px]:h-11 pointer-coarse:h-11`,n?`bg-solid shadow-[inset_0_0_0_1px_var(--stroke-strong)]`:`hover:bg-surface-hover`),onClick:()=>r(e.path),children:[(0,V.jsx)(Ie,{status:e.status}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 font-mono`,children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate text-content-muted`,children:i}),(0,V.jsx)(`span`,{className:`flex-none text-content`,children:a})]}),e.note&&(0,V.jsx)(`span`,{className:`flex-none text-content-muted`,children:e.note}),(0,V.jsx)($,{added:e.added,removed:e.removed})]})},e.path)}),e.length>Y&&(0,V.jsx)(`li`,{className:`px-3 py-1.5 text-xs text-content-muted tabular-nums`,children:(0,V.jsx)(Re,{count:e.length-Y})})]})}function Re({count:e}){let{t}=r();return(0,V.jsx)(V.Fragment,{children:t(`chat:focusSession.gitMoreFiles`,{count:e})})}var ze=600;function Be({sessionId:e,file:t,scope:n,revision:i,view:a,onViewChange:o,footer:s}){let{t:c}=r(),u=l(e=>e.diffMode),d=l(e=>e.setDiffMode),f=(0,B.useRef)(null),[m,h]=(0,B.useState)(0);(0,B.useLayoutEffect)(()=>{let e=f.current;if(!e)return;let t=()=>h(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let g=m===0||m>=ze,_=g?u:`unified`,v=g?void 0:c(`board:changes.splitTooNarrow`);return(0,V.jsxs)(`section`,{ref:f,className:`flex min-h-0 flex-1 flex-col`,"aria-label":t.path,"data-change-detail":t.path,children:[(0,V.jsxs)(`header`,{className:`flex min-h-10 shrink-0 items-center gap-2 border-b border-stroke-soft py-1.5 pr-2 pl-3`,children:[(0,V.jsx)(Ie,{status:t.status}),(0,V.jsx)(`strong`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-semibold text-content`,title:t.path,children:t.path}),(0,V.jsx)($,{added:t.added,removed:t.removed}),(0,V.jsx)(O,{size:`sm`,"aria-label":c(`board:changes.diffView`),title:v,"aria-description":v,value:_,onValueChange:d,options:[{value:`unified`,label:c(`board:changes.unified`)},{value:`split`,label:c(`board:changes.split`),disabled:!g}]})]}),(0,V.jsx)(p,{sessionId:e,path:t.path,scope:n,revision:i,mode:_,fill:!0,position:a?.reading?.[t.path],onReading:e=>o?.({reading:{...a?.reading,[t.path]:e}})},`${n}:${t.path}`),(0,V.jsx)(`footer`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-1 border-t border-stroke-soft py-1 pr-1.5 pl-3 text-xs`,children:s})]})}function Ve({cwd:e,path:t}){let{t:n}=r();if(!window.pisperDesktop||!e)return null;let i=Pe(e,t);return(0,V.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,className:`max-[650px]:h-11`,onClick:async()=>{try{await Se(i,xe),Q(n(`common:markdownMessage.revealLocalPathOk`,{path:t}),`info`)}catch(e){Q(e instanceof I&&e.reason===`unavailable`?n(`common:markdownMessage.revealLocalPathUnavailable`):e instanceof I&&e.reason===`timeout`?n(`common:markdownMessage.revealLocalPathTimeout`):n(`common:markdownMessage.revealLocalPathFailed`,{path:t}),`error`)}},children:[(0,V.jsx)(z,{"aria-hidden":`true`}),n(`chat:chatMessage.fileActionReveal`)]})}function He(e){return{path:e.path,status:e.status===`created`?`created`:e.status===`deleted`?`deleted`:`modified`,added:e.added,removed:e.removed}}function Ue(e,t){if(!e)return;let n=[];return e.lineEnding&&n.push(t(`chat:focusSession.fileChangesLineEnding`,{from:e.lineEnding[0].toUpperCase(),to:e.lineEnding[1].toUpperCase()})),e.bom?.[1]?n.push(t(`chat:focusSession.fileChangesBomAdded`)):e.bom&&n.push(t(`chat:focusSession.fileChangesBomRemoved`)),t(`chat:focusSession.fileChangesFormatOnly`,{detail:n.join(` · `)})}function We({sessionId:e,cwd:t,streaming:n,view:i,onViewChange:a,requestConfirm:o}){let{t:s,language:c}=r(),{changes:l,loading:u,running:f,snapshotRevision:p,writesDisabled:m,pendingCount:h,reversibleCount:g,displayedError:v,notice:ee,runAction:y,refresh:te}=_({sessionId:e,streaming:n,requestConfirm:o}),b=l?.files??[],ne=i?.expandedFiles?.[0],x=b.find(e=>e.path===ne)??b[0],re=e=>a?.({expandedFiles:[e]}),ie=(e,t)=>f?.kind===e&&f.path===t,S=n?s(`chat:focusSession.gitWaitForRunToFinish`):void 0;return(0,V.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":s(`chat:focusSession.fileChanges`),"aria-busy":u||!!f,"data-changes-scope":`session`,children:[(0,V.jsx)(`header`,{className:`flex min-h-10 shrink-0 items-center gap-1.5 border-b border-stroke-soft py-1 pr-1.5 pl-3`,children:(0,V.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center gap-2 text-xs text-content-secondary`,children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:s(`board:changes.sessionSummary`,{count:l?.summary.files??0})}),l&&l.summary.files>0&&(0,V.jsx)($,{added:l.summary.added,removed:l.summary.removed})]})}),v&&(0,V.jsx)(`p`,{role:`alert`,className:`shrink-0 px-3 pt-2 text-xs text-st-fail`,children:v}),ee&&!v&&(0,V.jsx)(`p`,{role:`status`,className:`shrink-0 px-3 pt-2 text-xs text-content-secondary`,children:ee}),u&&!l?(0,V.jsx)(P,{kind:`loading`,title:s(`chat:focusSession.gitLoading`)}):b.length?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Le,{files:b.map(e=>({...He(e),note:e.reverted?s(`chat:focusSession.fileChangesReverted`):e.approved?s(`chat:focusSession.fileChangesApproved`):Ue(e.formatChange,s)})),selected:x?.path??``,label:s(`board:changes.files`),onSelect:re}),x&&(0,V.jsx)(Be,{sessionId:e,file:He(x),scope:`task`,revision:p,view:i,onViewChange:a,footer:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:k(`mr-auto flex min-w-0 items-center gap-1.5 truncate`,x.approved?`text-st-done`:`text-content-muted`),"data-change-state":x.reverted?`reverted`:x.approved?`approved`:`pending`,children:[x.approved&&!x.reverted&&(0,V.jsx)(d,{className:`size-3.5 flex-none`,"aria-hidden":`true`}),x.reverted?s(`board:changes.revertedAt`,{time:j(x.changedAt,c)}):x.approved?s(`board:changes.approvedAt`,{time:j(x.changedAt,c)}):s(`board:changes.pendingAt`,{time:j(x.changedAt,c)})]}),x.pending&&!x.approved&&!x.reverted&&(0,V.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,disabled:m,title:S,onClick:()=>void y({kind:`approve`,path:x.path}),children:[ie(`approve`,x.path)?(0,V.jsx)(w,{className:`animate-spin`}):(0,V.jsx)(d,{}),s(`chat:focusSession.fileChangesApproveFile`)]}),(0,V.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,disabled:m||x.reverted||!x.canRevert,title:S,onClick:()=>void y({kind:`revert`,path:x.path}),children:[ie(`revert`,x.path)?(0,V.jsx)(w,{className:`animate-spin`}):(0,V.jsx)(C,{}),s(`board:changes.revertFile`)]}),(0,V.jsx)(Ve,{cwd:t,path:x.path})]})})]}):!v&&(0,V.jsx)(F,{compact:!0,title:s(`chat:focusSession.fileChangesEmpty`)}),(0,V.jsxs)(Fe,{status:f?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(w,{className:`size-3.5 flex-none animate-spin`,"aria-hidden":`true`}),f.kind===`approve`?s(`chat:focusSession.fileChangesApproveAll`):s(`board:changes.revertAll`)]}):h>0?s(`board:changes.pending`,{count:h}):null,children:[h>0&&(0,V.jsxs)(E,{disabled:m,title:S,onSelect:()=>void y({kind:`approve`}),children:[(0,V.jsx)(d,{}),s(`chat:focusSession.fileChangesApproveAll`)]}),(l?.summary.files??0)>0&&(0,V.jsxs)(E,{disabled:m||g===0,title:S??s(`chat:focusSession.fileChangesRevertAllDescription`),onSelect:()=>void y({kind:`revert`}),children:[(0,V.jsx)(C,{}),s(`board:changes.revertAll`)]}),(h>0||(l?.summary.files??0)>0)&&(0,V.jsx)(T,{}),(0,V.jsxs)(E,{disabled:u||!!f,onSelect:te,children:[(0,V.jsx)(w,{}),s(`chat:focusSession.gitRefresh`)]})]})]})}function Ge({sessionId:e,cwd:t,streaming:n,view:a,onViewChange:o}){let{t:s}=r(),c=i({queryKey:[`task-project-changes`,e,t,n],queryFn:({signal:t})=>ve.getVcsChanges(e,{signal:t})}),l=(0,B.useMemo)(()=>x(c.data?.diff||``,c.data?.files.map(e=>e.path)||[],c.data?.diffTruncated),[c.data]),u=c.error?.message||c.data?.error,d=(c.data?.files||[]).map(e=>({path:e.path,status:X(e.status),added:Object.hasOwn(l.files,e.path)?l.files[e.path].added:null,removed:Object.hasOwn(l.files,e.path)?l.files[e.path].removed:null})),f=a?.expandedFiles?.[0],p=d.find(e=>e.path===f)??d[0];return(0,V.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":s(`chat:workbench.projectChanges`),"aria-busy":c.isFetching,"data-changes-scope":`workspace`,children:[(0,V.jsxs)(`header`,{className:`flex min-h-10 shrink-0 items-center gap-1.5 border-b border-stroke-soft py-1 pr-1.5 pl-3`,children:[(0,V.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center gap-2 text-xs text-content-secondary`,children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:s(`board:changes.workspaceSummary`,{count:d.length})}),c.data?.isRepo&&!u&&d.length>0&&(0,V.jsx)($,{added:l.added,removed:l.removed})]}),c.data?.branch&&(0,V.jsxs)(`span`,{className:`inline-flex h-5.5 max-w-[40%] min-w-0 flex-none items-center gap-1 rounded-xs border border-stroke px-1.5 font-mono text-xs text-content-secondary`,title:t,children:[(0,V.jsx)(oe,{size:12,className:`flex-none`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`truncate`,children:c.data.branch})]})]}),c.isPending?(0,V.jsx)(P,{kind:`loading`,title:s(`chat:focusSession.gitLoading`)}):u?(0,V.jsx)(`p`,{role:`alert`,className:`p-3 text-xs text-st-fail`,children:u}):c.data?.isRepo?d.length?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Le,{files:d,selected:p?.path??``,label:s(`board:changes.files`),onSelect:e=>o?.({expandedFiles:[e]})}),p&&(0,V.jsx)(Be,{sessionId:e,file:p,scope:`project`,revision:c.dataUpdatedAt,view:a,onViewChange:o,footer:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-content-muted`,title:t,children:t}),(0,V.jsx)(Ve,{cwd:t,path:p.path})]})})]}):(0,V.jsx)(F,{compact:!0,title:s(`chat:focusSession.fileChangesEmpty`)}):(0,V.jsx)(F,{compact:!0,title:s(`chat:workbench.notRepository`)}),(0,V.jsx)(Fe,{status:c.isFetching?(0,V.jsx)(w,{className:`size-3.5 flex-none animate-spin`,"aria-hidden":`true`}):null,children:(0,V.jsxs)(E,{disabled:c.isFetching,onSelect:()=>void c.refetch(),children:[(0,V.jsx)(w,{}),s(`chat:focusSession.gitRefresh`)]})})]})}function Ke({sessionId:e,cwd:t,streaming:n,scope:i,onScopeChange:a,vcsAvailable:o,view:s,onViewChange:c,requestConfirm:l}){let{t:u}=r();return(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-inspector-changes":i,children:[(0,V.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stroke-soft px-3 py-2`,children:(0,V.jsx)(O,{size:`sm`,"aria-label":u(`board:inspector.changesScope`),value:i,onValueChange:a,options:[{value:`session`,label:u(`board:inspector.scopeSession`)},{value:`workspace`,label:u(`board:inspector.scopeWorkspace`),disabled:!o}]})}),s?i===`workspace`?(0,V.jsx)(Ge,{sessionId:e,cwd:t,streaming:n,view:s,onViewChange:c}):(0,V.jsx)(We,{sessionId:e,cwd:t,streaming:n,view:s,onViewChange:c,requestConfirm:l}):(0,V.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-content-muted`,children:u(`chat:focusSession.gitLoading`)})]})}var qe=[];function Je(e,t,n){return e===`changes`?n===`workspace`?`changes`:`files`:e===`terminal`?t:e===`files`?`sources`:e===`preview`?`browser`:e===`side-chat`?`side-chat`:null}function Ye({panelId:e,sessionId:t,cwd:n,streaming:s,plan:u,goal:d,team:p,activity:h,planTab:_,sources:y,mode:b,requestConfirm:x,onClose:oe,onOpenComponents:C,componentTabs:w,autoFocus:de=!1}){let{t:T}=r(),E=b===`sheet`,pe=Ce(),me=o(e=>e.capabilities),D=!!pe&&a(me,`terminal`),ve=a(me,`vcs`),j=l(e=>e.tab),M=l(e=>e.setTab),N=l(e=>e.terminalView),ye=l(e=>e.setTerminalView),P=l(e=>e.changesView),xe=l(e=>e.setChangesView),I=S(e=>e.sessions[t]?.pages)??qe,Se=I.some(e=>e.kind===`side-chat`),L=j===`side-chat`&&!Se||j===`plan`&&!_?`changes`:j,R=Je(L,N,P),z=R?I.find(e=>e.kind===R):void 0,H=!E&&w?w.tabs(n):[],[Te,U]=(0,B.useState)(null),[W,Ee]=(0,B.useState)(!1),G=H.some(e=>e.id===Te)?Te:null;(0,B.useEffect)(()=>U(null),[j]);let K=(0,B.useRef)(null);(0,B.useEffect)(()=>{K.current?.querySelector(`[role="tab"][aria-selected="true"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[L,G]);let ke=(0,B.useRef)(de);(0,B.useEffect)(()=>{if(!ke.current)return;let e=requestAnimationFrame(()=>K.current?.querySelector(`[role="tab"][aria-selected="true"]`)?.focus({preventScroll:!0}));return()=>cancelAnimationFrame(e)},[]),(0,B.useEffect)(()=>{if(!R||z||(R===`terminal`||R===`processes`)&&!D)return;let e=S.getState(),n=e.sessions[t]?.contentOpen??!1;e.update(t,R,{type:`add`,kind:R}),n||e.update(t,R,{type:`workspace`,contentOpen:!1})},[R,z,t,D]);let q=i({queryKey:[`session-change-summary`,t,s],queryFn:()=>be(t),staleTime:1e4}),J=q.data?.status===`known`?q.data.changedFiles??0:0,Ae=De(h,s),Y=[{id:`changes`,icon:ne,label:J>0?T(`board:inspector.changesCount`,{count:J}):T(`board:inspector.changes`)},{id:`terminal`,icon:ue,label:T(`board:inspector.terminal`)},{id:`running`,icon:c,label:Ae?T(`board:inspector.runningCount`,{count:Ae}):T(`board:inspector.running`)},{id:`files`,icon:ae,label:T(`board:inspector.files`)},{id:`preview`,icon:te,label:T(`board:inspector.preview`)},..._?[{id:`plan`,icon:se,label:T(`board:inspector.plan`)}]:[],...Se?[{id:`side-chat`,icon:ce,label:T(`board:inspector.sideChat`)}]:[]],X=e=>{z&&S.getState().update(t,z.kind,{type:`view`,id:z.id,patch:e})},Me=()=>{let n=I.find(e=>e.kind===`side-chat`);if(n&&S.getState().update(t,`side-chat`,{type:`close`,id:n.id}),M(`changes`),E){oe();return}requestAnimationFrame(()=>document.getElementById(`${e}-changes-tab`)?.focus())},Z=t=>`${e}-component-${t}-tab`,Ne=e=>{U(null),M(e)},Pe=t=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(t.key))return;t.preventDefault();let n=[...Y.map(t=>({fixed:t.id,id:`${e}-${t.id}-tab`})),...H.map(e=>({component:e.id,id:Z(e.id)}))],r=n.findIndex(e=>G?e.component===G:e.fixed===L),i=n[t.key===`Home`?0:t.key===`End`?n.length-1:(r+(t.key===`ArrowRight`?1:-1)+n.length)%n.length];i.component?U(i.component):i.fixed&&Ne(i.fixed),requestAnimationFrame(()=>document.getElementById(i.id)?.focus())},Q=(0,V.jsx)(`p`,{role:`status`,className:`p-4 text-sm text-content-muted`,children:T(`chat:focusSession.gitLoading`)}),$;if(G&&w)$=w.render(G,{sessionId:t,cwd:n});else if(L===`changes`)$=(0,V.jsx)(Ke,{sessionId:t,cwd:n,streaming:s,scope:P,onScopeChange:xe,vcsAvailable:ve,view:z?.view,onViewChange:z?X:void 0,requestConfirm:x});else if(L===`terminal`)$=D?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,V.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-stroke-soft px-3 py-2`,children:(0,V.jsx)(O,{size:`sm`,"aria-label":T(`board:inspector.terminalScope`),value:N,onValueChange:ye,options:[{value:`terminal`,label:T(`board:inspector.terminal`)},{value:`processes`,label:T(`board:inspector.processes`)}]})}),(0,V.jsx)(B.Suspense,{fallback:Q,children:z?N===`processes`?(0,V.jsx)(m,{sessionId:t,view:z.view,onViewChange:X,onOpenTerminal:e=>{let n=S.getState(),r=n.sessions[t]?.pages.find(e=>e.kind===`terminal`);r?n.update(t,`terminal`,{type:`resource`,id:r.id,resourceId:e}):n.update(t,`terminal`,{type:`open`,kind:`terminal`,resourceId:e}),ye(`terminal`)}}):(0,V.jsx)(f,{sessionId:t,cwd:n,terminalId:z.resourceId||void 0,onCreated:e=>S.getState().update(t,`terminal`,{type:`resource`,id:z.id,resourceId:e})},z.id):Q})]}):(0,V.jsx)(F,{compact:!0,icon:ue,title:T(`board:inspector.terminalUnavailable`)});else if(L===`files`)$=z?(0,V.jsx)(v,{sources:y,view:z.view,onViewChange:X}):Q;else if(L===`preview`){let e=s?re([...h]):null;$=z?(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-inspector-preview":!0,children:[e&&(0,V.jsx)(`div`,{className:`max-h-[50%] shrink-0 overflow-y-auto border-b border-stroke-soft p-2`,children:(0,V.jsx)(ie,{target:e,fallbackImage:e.previewImage,streaming:s})}),(0,V.jsx)(ee,{page:z,onChange:e=>S.getState().update(t,`browser`,{type:`browser`,id:z.id,...e})})]}):Q}else $=L===`plan`?(0,V.jsx)(je,{plan:u,streaming:s,goal:d,team:p,activity:h}):L===`running`?(0,V.jsx)(Oe,{sessionId:t,streaming:s,activity:h}):(0,V.jsx)(g,{parentId:t,active:!0});return(0,V.jsxs)(`section`,{id:e,"aria-label":T(`board:inspector.label`),"data-session-inspector":b,"data-inspector-tab":L,"data-inspector-component":G??void 0,className:`flex h-full min-h-0 w-full min-w-0 flex-col bg-panel text-content`,children:[(0,V.jsxs)(`header`,{className:k(`flex shrink-0 items-center gap-1 border-b border-stroke-soft pr-1.5 pl-2`,E?`h-[52px]`:b===`aside`?`h-[52px] [[data-custom-titlebar]_&]:h-11 [[data-custom-titlebar]_&]:pointer-coarse:h-[52px]`:`h-11 pointer-coarse:h-[52px]`),children:[(0,V.jsxs)(`div`,{ref:K,role:`tablist`,"aria-label":T(`board:inspector.tabs`),className:`flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto [scrollbar-width:none]`,onKeyDown:Pe,children:[Y.map(({id:t,icon:n,label:r})=>{let i=!G&&t===L;return(0,V.jsxs)(`button`,{id:`${e}-${t}-tab`,type:`button`,role:`tab`,"aria-selected":i,"aria-controls":`${e}-body`,tabIndex:i?0:-1,"data-inspector-tab-id":t,className:k(`flex flex-none items-center gap-1.5 rounded-sm px-2 text-[13px] whitespace-nowrap transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus`,E?`h-11 min-w-11 justify-center px-2.5`:`h-8 pointer-coarse:h-11 pointer-coarse:min-w-11`,i?`bg-solid font-medium text-content shadow-edge ring-1 ring-stroke-strong ring-inset`:`text-content-secondary hover:bg-surface-hover hover:text-content`),onClick:()=>Ne(t),children:[!E&&(0,V.jsx)(n,{className:`size-3.5`,"aria-hidden":`true`}),r]},t)}),!G&&L===`side-chat`&&(0,V.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,className:k(E&&`size-11`),"aria-label":T(`board:inspector.closeTab`,{tab:T(`board:inspector.sideChat`)}),onClick:Me,children:(0,V.jsx)(fe,{"aria-hidden":`true`})}),!E&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1 h-4 w-px flex-none bg-stroke`}),H.map(({id:t,label:n})=>{let r=t===G;return(0,V.jsx)(`button`,{id:Z(t),type:`button`,role:`tab`,"aria-selected":r,"aria-controls":`${e}-body`,tabIndex:r?0:-1,"data-inspector-component-tab":t,className:k(`flex h-8 max-w-40 flex-none items-center rounded-sm px-2 text-[13px] whitespace-nowrap transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus pointer-coarse:h-11 pointer-coarse:min-w-11`,r?`bg-solid font-medium text-content shadow-edge ring-1 ring-stroke-strong ring-inset`:`text-content-secondary hover:bg-surface-hover hover:text-content`),onClick:()=>U(t),children:(0,V.jsx)(`span`,{className:`truncate`,children:n})},t)})]}),!E&&(0,V.jsxs)(_e,{open:W,onOpenChange:Ee,children:[(0,V.jsx)(he,{asChild:!0,children:(0,V.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`flex-none`,"aria-label":T(`board:inspector.add`),title:T(`board:inspector.add`),"data-inspector-component-add":!0,children:(0,V.jsx)(le,{"aria-hidden":`true`})})}),(0,V.jsxs)(ge,{align:`end`,className:`w-64 text-xs`,children:[w?.addMenu?w.addMenu({cwd:n,onAdded:e=>{U(e),Ee(!1)}}):(0,V.jsx)(`p`,{className:`text-content-secondary`,children:T(`board:inspector.addHint`)}),C&&(0,V.jsx)(A,{type:`button`,variant:`secondary`,size:`sm`,className:`self-start`,onClick:C,children:T(`board:inspector.openComponents`)})]})]}),(0,V.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,className:k(`flex-none`,E&&`size-11`),"aria-label":T(`board:inspector.close`),title:T(`board:inspector.close`),"aria-controls":e,onClick:oe,children:b===`aside`?(0,V.jsx)(we,{"aria-hidden":`true`}):(0,V.jsx)(fe,{"aria-hidden":`true`})})]}),(0,V.jsx)(`div`,{id:`${e}-body`,role:`tabpanel`,"aria-labelledby":G?Z(G):`${e}-${L}-tab`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:$})]})}export{Ye as SessionInspector};
|