pisper 0.6.24 → 0.6.25
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 +5 -5
- package/web/.vite/manifest.json +769 -631
- package/web/assets/{AppDialog-BcXOXBcR.js → AppDialog-CuxO26Km.js} +1 -1
- package/web/assets/{AppOverlays-DhOsSE6q.js → AppOverlays-Bt5SL3PY.js} +1 -1
- package/web/assets/{AppSelect-BD6RAaJ5.js → AppSelect-DQYKUW5E.js} +1 -1
- package/web/assets/{AssetsPage-7Fuwati9.js → AssetsPage-BE6AzOGC.js} +1 -1
- package/web/assets/{BoardPage-C81aOK4p.js → BoardPage-DX0fJ_ap.js} +3 -3
- package/web/assets/ChannelsPage-CyT7oDYZ.js +1 -0
- package/web/assets/{ChatAppearancePage-DQr-uhHb.js → ChatAppearancePage-B6Dzj2Bj.js} +1 -1
- package/web/assets/ChatHistoryPage-Cq20l93c.js +1 -0
- package/web/assets/ChatPage-DgiS-Qj_.js +553 -0
- package/web/assets/ConfigPage-CgrWdzb5.js +5 -0
- package/web/assets/{DesktopWindowControls-BWe5YIjj.js → DesktopWindowControls-D8axeuEx.js} +1 -1
- package/web/assets/FeaturePage-BB1TeMlr.js +1 -0
- package/web/assets/{FileAttachmentPreview-IZzA3f8k.js → FileAttachmentPreview-DPjT_iYk.js} +1 -1
- package/web/assets/{FloatingWidgets-DgIJkrEC.js → FloatingWidgets-FI1S4hdn.js} +1 -1
- package/web/assets/FocusRuntimeControls-CvAx-KDV.js +1 -0
- package/web/assets/{GitDiffViewer-CypHOHdP.js → GitDiffViewer-DwFfeFOA.js} +1 -1
- package/web/assets/{ManageProjectsDialog-DxiTEqYf.js → ManageProjectsDialog-BSLNf6qD.js} +1 -1
- package/web/assets/{MarkdownMessage-CuaozZah.js → MarkdownMessage-NK7Ixb4Y.js} +1 -1
- package/web/assets/{McpPage-BbmxMKuy.js → McpPage-Cn-yDgC5.js} +1 -1
- package/web/assets/MemoryEvolution-B8IeSLcd.js +1 -0
- package/web/assets/MemoryPage-ZwoG_oj6.js +2 -0
- package/web/assets/{MobileNavigation-IZrksubf.js → MobileNavigation-DK5a0kZU.js} +1 -1
- package/web/assets/{MorePage-DObfXE0e.js → MorePage-BL8nDnTQ.js} +1 -1
- package/web/assets/{NewFolderDialog-CeRiD1xe.js → NewFolderDialog-COkq83LW.js} +1 -1
- package/web/assets/{PageHeader-D8QTuWd6.js → PageHeader-BBTCMqXc.js} +1 -1
- package/web/assets/{PhoneDrawer-Dfmmixh5.js → PhoneDrawer-BcPKJWl-.js} +1 -1
- package/web/assets/{PhoneMenuButton-Bbna_Bcf.js → PhoneMenuButton-D6vdTZdF.js} +1 -1
- package/web/assets/{PhoneTopBar-Dz94PR8O.js → PhoneTopBar-MqNeI69v.js} +1 -1
- package/web/assets/{PluginsPage-0rmSVMfr.js → PluginsPage-Bp71HpKD.js} +1 -1
- package/web/assets/{SafeModePrompt-CAfT8lBS.js → SafeModePrompt-CpvvU5wL.js} +1 -1
- package/web/assets/SchedulesPage-Drs10rEV.js +1 -0
- package/web/assets/{SessionBrowserPane-DMTNqq-e.js → SessionBrowserPane-DjtB4MCI.js} +2 -2
- package/web/assets/SessionContextPanel-ETfnp4pT.js +2 -0
- package/web/assets/{SessionHome-047YRkeb.js → SessionHome-CHBw3ZvP.js} +1 -1
- package/web/assets/SessionInspector-DVaRflQy.js +1 -0
- package/web/assets/{SessionShell-BqNSjTbQ.js → SessionShell-CwfQAX7i.js} +1 -1
- package/web/assets/{SettingsSidebar-a9IEYCfr.js → SettingsSidebar-FgC-tlY2.js} +1 -1
- package/web/assets/{ShortcutHelpDialog-B1RT_EMe.js → ShortcutHelpDialog-DKbIkUnk.js} +1 -1
- package/web/assets/{ShortcutKeys-DIEI9JQZ.js → ShortcutKeys-BuHXNKVW.js} +1 -1
- package/web/assets/{SidebarUpdateStatus-phIx4K_T.js → SidebarUpdateStatus-LKwNKESF.js} +1 -1
- package/web/assets/{SkillsPage-CZuR-0QX.js → SkillsPage-BbnerW44.js} +1 -1
- package/web/assets/{TaskProcessesPane-x73TNzuV.js → TaskProcessesPane-B2fyZEK9.js} +1 -1
- package/web/assets/{TaskTerminalView-D2UVtmT1.js → TaskTerminalView-CKApgF75.js} +1 -1
- package/web/assets/{TerminalPanel-C0U35k57.js → TerminalPanel-D03WycYm.js} +1 -1
- package/web/assets/{WebDesktopPet-CJtB44aG.js → WebDesktopPet-K2dbcbnQ.js} +1 -1
- package/web/assets/WorkflowsPage-CmzftCtz.js +1 -0
- package/web/assets/{WorkspacePicker-C7hhcfZV.js → WorkspacePicker-DbdbTOV2.js} +1 -1
- package/web/assets/{api-BmSvZCuH.js → api-BW_X0FMZ.js} +1 -1
- package/web/assets/{app-update-DhpOY37a.js → app-update-DYFXTosD.js} +1 -1
- package/web/assets/{approval-confirm-Dc3BZGo4.js → approval-confirm-DQ5N_lJB.js} +1 -1
- package/web/assets/archive-ojKJT7Fp.js +1 -0
- package/web/assets/{board-projects-C7DazgZG.js → board-projects-CrejrMrn.js} +1 -1
- package/web/assets/book-open-BuHHD9os.js +1 -0
- package/web/assets/bots-store-CNXTx3UY.js +1 -0
- package/web/assets/{chat-api-DHqVwcpJ.js → chat-api-Bo6nhq40.js} +1 -1
- package/web/assets/chevrons-up-down-C2sEPdAh.js +1 -0
- package/web/assets/{client-store-Dif482Kx.js → client-store-DzgOPMlh.js} +1 -1
- package/web/assets/{config-search-CKpXm_hp.js → config-search-BiQmWst4.js} +1 -1
- package/web/assets/{dialog-DFcH7POi.js → dialog-DFZX_Dek.js} +1 -1
- package/web/assets/dist-BS3ekNDj.js +1 -0
- package/web/assets/{events-C7sXXop4.js → events-PfANjkHx.js} +1 -1
- package/web/assets/{focus-session-composer-bits-D2XiGLcj.js → focus-session-composer-bits-C_LOpJH_.js} +1 -1
- package/web/assets/{folder-paths-CsQLylLL.js → folder-paths-aRRH_MYq.js} +1 -1
- package/web/assets/{hosts-CwTc21QE.js → hosts-lvoPwC3T.js} +1 -1
- package/web/assets/i18n-EVP8yIdy.js +1 -0
- package/web/assets/index-D_zLThH_.js +2 -0
- package/web/assets/index-l96Dl6z6.css +2 -0
- package/web/assets/memory-api-DkPje--t.js +1 -0
- package/web/assets/message-circle-D-XrK6Ft.js +1 -0
- package/web/assets/{mobile-remote-fallback-C2Q0wAa6.js → mobile-remote-fallback-LLMZWoIu.js} +1 -1
- package/web/assets/mount-app-7pFSwVLO.js +9 -0
- package/web/assets/{permission-rules-api-D1Tbe4E9.js → permission-rules-api-CAJsSBA5.js} +1 -1
- package/web/assets/{pick-system-directory-CQS5pqM-.js → pick-system-directory-yk6L7wR2.js} +1 -1
- package/web/assets/pin-off-BpRu_vrC.js +1 -0
- package/web/assets/placements-CMrgmg3t.js +2 -0
- package/web/assets/{popover-CXB2yzW6.js → popover--q2hs_pT.js} +1 -1
- package/web/assets/{public-D1nVPEiV.js → public-62LVX7HU.js} +1 -1
- package/web/assets/public-DWbrDr0p.js +3 -0
- package/web/assets/{public-BVKkvQiF.js → public-DkqrpWXx.js} +2 -2
- package/web/assets/{public-components-B6uxO_ZB.js → public-components-DHMvCgH2.js} +1 -1
- package/web/assets/public-diff-WjbTu91T.js +1 -0
- package/web/assets/public-events-CTdTIu5Q.js +1 -0
- package/web/assets/{public-flags-KylDNCsK.js → public-flags-D9LdpQwJ.js} +1 -1
- package/web/assets/public-greeting-DEKYruJJ.js +1 -0
- package/web/assets/{public-session-DjI86F5J.js → public-session-B9UHA6rN.js} +1 -1
- package/web/assets/{public-sidebar-PhHPuas_.js → public-sidebar-Lne86i_K.js} +1 -1
- package/web/assets/{runtime-capabilities-store-CTtXyNjK.js → runtime-capabilities-store-BNM5Ug-5.js} +1 -1
- package/web/assets/{safe-mode-instance-_WZgKT1M.js → safe-mode-instance-DnTP7EUr.js} +1 -1
- package/web/assets/safe-mode-sentinel-DOhqH4gj.js +1 -0
- package/web/assets/select-Bbk9bmXO.js +1 -0
- package/web/assets/send-Cj-W03w_.js +1 -0
- package/web/assets/{session-change-summary-api-DENj-A9c.js → session-change-summary-api-DMTwGz7o.js} +1 -1
- package/web/assets/{session-home-D1MkpdBS.js → session-home-DUpZt2dn.js} +1 -1
- package/web/assets/session-list-BRMu9JWa.js +1 -0
- package/web/assets/{session-organization-api-Cm9HoIme.js → session-organization-api-BGyp66Uv.js} +1 -1
- package/web/assets/{session-scope-BnKeB5vZ.js → session-scope-DZITSvZr.js} +1 -1
- package/web/assets/{session-tree-actions-DhF8lJLn.js → session-tree-actions-CRWyFqAD.js} +1 -1
- package/web/assets/{session-tree-summary-DEJ52bdp.js → session-tree-summary-HTmAo_9V.js} +1 -1
- package/web/assets/{shortcuts-DnykOp5e.js → shortcuts-D72gQCwH.js} +1 -1
- package/web/assets/side-chat-context-D1hZOT7g.js +7 -0
- package/web/assets/{sidebar-bemTfe07.js → sidebar-sj8X80Y9.js} +1 -1
- package/web/assets/{sidebar-store-Be8dU3KV.js → sidebar-store-CXZ7QrOr.js} +1 -1
- package/web/assets/slider-De8rWVNs.js +1 -0
- package/web/assets/sliders-horizontal-Dryf1XyC.js +1 -0
- package/web/assets/{speech-session-4UWWW7HR.js → speech-session-D2GQEOAL.js} +1 -1
- package/web/assets/{startup-queries-iq2o5pqJ.js → startup-queries-CuEXV1Zu.js} +1 -1
- package/web/assets/{storage-8QW6lXuT.js → storage-DtvZ_lEu.js} +1 -1
- package/web/assets/tool-labels-Bexnwp5q.js +1 -0
- package/web/assets/undo-2-C-xQ0UVT.js +1 -0
- package/web/assets/{use-i18n-DCxQRXLH.js → use-i18n-_vdxObu5.js} +1 -1
- package/web/assets/{use-open-bot-BTTe7141.js → use-open-bot-BTxzOAbZ.js} +1 -1
- package/web/assets/{use-studio-actions-CvTVL6vy.js → use-studio-actions-CbMHRZpd.js} +1 -1
- package/web/assets/{useCatalogProjects-D0_Xilel.js → useCatalogProjects-BEkCpADy.js} +1 -1
- package/web/assets/{useNewProjectPicker-C3dVgDqI.js → useNewProjectPicker-CUtLjwYE.js} +2 -2
- package/web/assets/{useNow-BrhALV5l.js → useNow-eQeBCqQk.js} +1 -1
- package/web/assets/{usePhoneShell-BleJZMk4.js → usePhoneShell-DZHZWXnN.js} +1 -1
- package/web/assets/{useSessionListQuery-CSTrzBD6.js → useSessionListQuery-BoUzmjZC.js} +1 -1
- package/web/assets/{useSessionRowActions-CBOzJhLW.js → useSessionRowActions-DCqDrGZY.js} +1 -1
- package/web/assets/{useSidebarModel-AYsswvjm.js → useSidebarModel-CZAfH4Fa.js} +1 -1
- package/web/assets/{web-preview-B9ooQu6f.js → web-preview-XrRFo42l.js} +1 -1
- package/web/assets/{web-preview-events-DZb37WWK.js → web-preview-events-Ba6duwGi.js} +1 -1
- package/web/assets/workflow-messages-Cc4pX_oo.js +1 -0
- package/web/assets/{workspace-order-store-CQ4SHO-9.js → workspace-order-store-Ao4OZ13V.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/ChannelsPage-LM4bpKzy.js +0 -1
- package/web/assets/ChatHistoryPage-DcjG1hoQ.js +0 -1
- package/web/assets/ChatPage-HBq1cr2I.js +0 -553
- package/web/assets/ConfigPage-Bcjc5mbO.js +0 -5
- package/web/assets/FeaturePage-DGauTCbU.js +0 -1
- package/web/assets/FocusRuntimeControls-Bgq7LvMl.js +0 -1
- package/web/assets/MemoryPage-BeI2YTUn.js +0 -1
- package/web/assets/SchedulesPage-C3TpSm9t.js +0 -1
- package/web/assets/SessionContextPanel-DoS-Xqny.js +0 -2
- package/web/assets/SessionInspector-GXGZ9n87.js +0 -1
- package/web/assets/WorkflowsPage-o4p12fMI.js +0 -1
- package/web/assets/bots-store-CeTfxdyY.js +0 -1
- package/web/assets/dist-V8chnW6-.js +0 -1
- package/web/assets/i18n-YQ8mc9k7.js +0 -1
- package/web/assets/index-DJA4qaOu.css +0 -2
- package/web/assets/index-DjSjahBi.js +0 -2
- package/web/assets/mount-app-DAxz1ll-.js +0 -9
- package/web/assets/placements-BuU0Zuqy.js +0 -2
- package/web/assets/public-BVuJa7Dh.js +0 -3
- package/web/assets/public-diff-CCVYk91T.js +0 -1
- package/web/assets/public-events-CVn8fEHx.js +0 -1
- package/web/assets/safe-mode-sentinel-CVhmZl77.js +0 -1
- package/web/assets/select-DD_WO-gs.js +0 -1
- package/web/assets/send-QxBfLFo-.js +0 -1
- package/web/assets/session-list-BeyOEzyU.js +0 -1
- package/web/assets/side-chat-context-C2SzUmd5.js +0 -7
- package/web/assets/slider-DTmAZl-R.js +0 -1
- package/web/assets/tool-labels-ghvpPFmc.js +0 -1
- package/web/assets/workflow-messages-Cj35aJZc.js +0 -1
- package/web/memory-galaxy-background.webp +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t}from"./vendor-router-CSN_DGvx.js";import{t as n}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t}from"./vendor-router-CSN_DGvx.js";import{t as n}from"./index-D_zLThH_.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{r as a}from"./routes-DIeaqWVc.js";import{f as o,i as s,n as c,p as l,u}from"./placements-CMrgmg3t.js";import{n as d}from"./safe-mode-sentinel-DOhqH4gj.js";import{t as f}from"./usePhoneShell-DZHZWXnN.js";var p=e(r(),1),m=i(),h=`pisper-floating-widgets`;function g(){(0,p.useEffect)(()=>{try{n.getItem(h)!==null&&n.removeItem(h)}catch{}},[])}function _({activeSessionId:e,notify:n}){let r=f(),i=t().pathname,h=i===a.components||i.startsWith(`${a.components}/`),_=u(`floating`),v=l(),[y]=(0,p.useState)(d),b=o();return g(),(0,m.jsxs)(m.Fragment,{children:[y&&v>0&&(0,m.jsx)(p.Suspense,{fallback:null,children:(0,m.jsx)(s,{notify:n,disableAll:b})}),!r&&_.placed.length>0&&(0,m.jsx)(p.Suspense,{fallback:null,children:(0,m.jsx)(c,{placed:_.placed,hidden:h,activeSessionId:e,notify:n})})]})}export{_ as FloatingWidgets};
|
|
@@ -0,0 +1 @@
|
|
|
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-EVP8yIdy.js";import{t as o}from"./use-i18n-_vdxObu5.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-C_LOpJH_.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--q2hs_pT.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-DFZX_Dek.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,4 +1,4 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{i as n,n as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{i as n,n as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-_vdxObu5.js";import{t as o}from"./createLucideIcon-Cd-3GVxJ.js";import{t as s}from"./x-07u4-129.js";import{t as c}from"./utils-C8uzG5AZ.js";import{t as l}from"./button-CCcCN8tE.js";import{a as u,s as d}from"./events-PfANjkHx.js";import{t as f}from"./esm-DCV8yILT.js";var p=o(`file-diff`,[[`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:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),m=e(n(),1),h=e(r(),1);function g(e){let t=String(e||``).trim().split(` `)[0];if(t.startsWith(`"`)&&t.endsWith(`"`))try{t=JSON.parse(t)}catch{}return t===`/dev/null`?``:t.replace(/^[ab]\//,``)}function _(e){let t=e.match(/^diff --git "a\/(.+)" "b\/(.+)"$/);if(t)return g(`b/${t[2]}`);let n=e.match(/^diff --git a\/(.+) b\/(.+)$/);return n?g(`b/${n[2]}`):``}function v(){return{lineNumber:null,text:``,tone:`empty`}}function y(e){let t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return{oldLine:Number(t?.[1])||0,newLine:Number(t?.[2])||0}}function b(e){let t=String(e||``).replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),n=[],r=null,i=null,a=0,o=0,s=[],c=[],l=()=>{if(!i||!s.length&&!c.length)return;let e=Math.max(s.length,c.length);for(let t=0;t<e;t+=1){let e=s[t],n=c[t];i.rows.push({kind:`pair`,old:e?{lineNumber:e.lineNumber,text:e.text,tone:`deleted`}:v(),next:n?{lineNumber:n.lineNumber,text:n.text,tone:`added`}:v()})}s=[],c=[]},u=()=>{l(),i=null},d=()=>{u(),r&&=(r.path=r.newPath||r.oldPath||r.path,n.push(r),null)};for(let e of t){if(e.startsWith(`diff --git `)){d(),r={oldPath:``,newPath:``,path:_(e),metadata:[],hunks:[]};continue}if(r){if(e.startsWith(`@@ `)){u();let t=y(e);a=t.oldLine,o=t.newLine,i={header:e,rows:[]},r.hunks.push(i);continue}if(i){if(e.startsWith(`-`))s.push({lineNumber:a,text:e.slice(1)}),a+=1;else if(e.startsWith(`+`))c.push({lineNumber:o,text:e.slice(1)}),o+=1;else if(l(),e.startsWith(` `)){let t=e.slice(1);i.rows.push({kind:`pair`,old:{lineNumber:a,text:t,tone:`context`},next:{lineNumber:o,text:t,tone:`context`}}),a+=1,o+=1}else e.startsWith(`\\ `)&&i.rows.push({kind:`meta`,text:e.slice(2)});continue}e.startsWith(`--- `)?r.oldPath=g(e.slice(4)):e.startsWith(`+++ `)?r.newPath=g(e.slice(4)):e.trim()&&r.metadata.push(e)}}return d(),n}var x=/[\p{L}\p{N}_$]/u;function S(e,t){let n=Array.from(e),r=Array.from(t);if(!n.length||!r.length)return null;let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=n.length,o=r.length;for(;a>i&&o>i&&n[a-1]===r[o-1];)--a,--o;if(i===a&&i===o)return null;for(;i>0&&x.test(n[i-1])&&x.test(n[i]??r[i]??``);)--i;for(;a<n.length&&a>0&&x.test(n[a])&&x.test(n[a-1]);)a+=1;for(;o<r.length&&o>0&&x.test(r[o])&&x.test(r[o-1]);)o+=1;return Math.max(a-i,o-i)/Math.max(n.length,r.length)>.7?null:{start:i,oldEnd:a,newEnd:o}}function C(e){let t=[];for(let n of e.hunks){t.push({kind:`header`,text:n.header});let e=0;for(;e<n.rows.length;){let r=n.rows[e];if(r.kind===`meta`){t.push({kind:`meta`,text:r.text}),e+=1;continue}if(r.old.tone===`context`){t.push({kind:`line`,tone:`context`,oldLine:r.old.lineNumber,newLine:r.next.lineNumber,text:r.next.text,mark:null}),e+=1;continue}let i=[];for(;e<n.rows.length;){let t=n.rows[e];if(t.kind!==`pair`||t.old.tone===`context`)break;i.push(t),e+=1}let a=i.map(e=>e.old.tone===`deleted`&&e.next.tone===`added`?S(e.old.text,e.next.text):null);i.forEach((e,n)=>{if(e.old.tone!==`deleted`)return;let r=a[n];t.push({kind:`line`,tone:`deleted`,oldLine:e.old.lineNumber,newLine:null,text:e.old.text,mark:r?[r.start,r.oldEnd]:null})}),i.forEach((e,n)=>{if(e.next.tone!==`added`)return;let r=a[n];t.push({kind:`line`,tone:`added`,oldLine:null,newLine:e.next.lineNumber,text:e.next.text,mark:r?[r.start,r.newEnd]:null})})}}return t}function w(e,t,n=``){let[r,i]=(0,m.useState)(null),a=(0,m.useRef)({identity:n,position:e||{top:0,left:0}});a.current={identity:n,position:e||{top:0,left:0}};let o=(0,m.useRef)(t);return o.current=t,(0,m.useLayoutEffect)(()=>{if(!r)return;let e=a.current.position,t=!0,i=null,s=()=>{a.current.identity===n&&!t&&r.isConnected&&r.clientHeight>0&&o.current({top:r.scrollTop,left:r.scrollLeft})},c=()=>{i=null,t&&(r.scrollTo({top:e.top,left:e.left,behavior:`instant`}),Math.abs(r.scrollTop-e.top)<1&&Math.abs(r.scrollLeft-e.left)<1&&(t=!1))},l=()=>{t&&i===null&&(i=requestAnimationFrame(c))},f=()=>{t=!1,s()};c();let p=new ResizeObserver(l);p.observe(r);for(let e of r.children)p.observe(e);return r.addEventListener(`scroll`,s),r.addEventListener(`wheel`,f,{passive:!0}),r.addEventListener(`pointerdown`,f),r.addEventListener(`keydown`,f),window.addEventListener(u,s),window.addEventListener(d,s),()=>{s(),p.disconnect(),i!==null&&cancelAnimationFrame(i),r.removeEventListener(`scroll`,s),r.removeEventListener(`wheel`,f),r.removeEventListener(`pointerdown`,f),r.removeEventListener(`keydown`,f),window.removeEventListener(u,s),window.removeEventListener(d,s)}},[r,n]),{element:r,ref:i}}var T=t({GitDiffDialog:()=>L,InlineGitDiff:()=>R}),E=i();function D({side:e,cell:t}){let n=t.tone===`deleted`?`−`:t.tone===`added`?`+`:` `;return(0,E.jsxs)(`div`,{className:`git-diff-cell grid min-w-0 min-h-[24px] grid-cols-[44px_20px_minmax(0,1fr)] border-b border-stroke-soft font-mono text-[12px] leading-[1.6] tabular-nums [&.next]:border-l [&.next]:border-l-stroke [&.deleted]:bg-[var(--danger-soft)] [&.added]:bg-[var(--success-soft)] [&.deleted]:shadow-[inset_2px_0_var(--danger)] [&.added]:shadow-[inset_2px_0_var(--success)] [&.empty]:bg-surface-subtle [&.context]:bg-code [&_code]:block [&_code]:min-w-0 [&_code]:p-[3px_8px_3px_2px] [&_code]:text-[var(--text)] [&_code]:font-[inherit] [&_code]:whitespace-pre-wrap [&_code]:[overflow-wrap:anywhere] ${e} ${t.tone}`,children:[(0,E.jsx)(`span`,{className:`block border-r border-stroke-soft p-[3px_8px_3px_4px] text-right text-code-gutter select-none`,children:t.lineNumber??``}),(0,E.jsx)(`span`,{className:`git-diff-line-marker [.git-diff-cell.deleted_&]:text-[var(--danger)] [.git-diff-cell.added_&]:text-[var(--success)] block [padding:3px_4px] text-[var(--text-muted)] text-center select-none`,"aria-hidden":`true`,children:t.tone===`empty`?``:n}),(0,E.jsx)(`code`,{children:t.text||`\xA0`})]})}var O={minWidth:0},k={minWidth:0,gridTemplateColumns:`minmax(0,1fr) minmax(0,1fr)`};function A({file:e,scrollElement:t,compact:n=!1}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(0),o=(0,m.useMemo)(()=>e.hunks.flatMap((e,t)=>[{kind:`header`,hunkIndex:t,header:e.header},...e.rows.map((e,n)=>({kind:`row`,hunkIndex:t,rowIndex:n,row:e}))]),[e.hunks]);(0,m.useLayoutEffect)(()=>{let e=r.current;if(!t||!e)return;let n=()=>{let n=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);a(e=>Math.abs(e-n)<1?e:n)};n();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),i?.observe(e),()=>i?.disconnect()},[t]);let s=f({useFlushSync:!1,count:o.length,getScrollElement:()=>t,estimateSize:()=>25,getItemKey:e=>{let t=o[e];return t.kind===`header`?`hunk-${t.hunkIndex}`:`row-${t.hunkIndex}-${t.rowIndex}`},measureElement:e=>Math.ceil(e.getBoundingClientRect().height),overscan:12,scrollMargin:i}),c=s.getVirtualItems();return(0,E.jsx)(`div`,{className:`relative min-w-[880px] w-full`,"data-pisper-diff-row-count":o.length,"data-diff-mode":n?`split-compact`:`split`,"data-pisper-rendered-count":c.length,ref:r,style:{height:`${s.getTotalSize()}px`,...n?O:{}},children:c.map(e=>{let t=o[e.index];return(0,E.jsx)(`div`,{className:`absolute left-0 w-full`,"data-index":e.index,ref:s.measureElement,style:{top:`${e.start-i}px`},children:t.kind===`header`?(0,E.jsx)(`div`,{className:`git-diff-hunk-header border-b border-stroke-soft bg-surface-subtle p-[4px_10px] font-mono text-[12px] text-content-muted [white-space:pre]`,children:t.header}):t.row.kind===`meta`?(0,E.jsx)(`div`,{className:`git-diff-row-meta border-b border-stroke-soft bg-surface-subtle p-[4px_10px] font-mono text-[12px] text-content-muted [white-space:pre]`,children:t.row.text}):(0,E.jsxs)(`div`,{className:`grid min-w-[880px] grid-cols-[minmax(440px,1fr)_minmax(440px,1fr)]`,style:n?k:void 0,children:[(0,E.jsx)(D,{side:`old`,cell:t.row.old}),(0,E.jsx)(D,{side:`next`,cell:t.row.next})]})},e.key)})})}var j=20;function M(e,t,n){if(!t||t[0]>=t[1])return e||`\xA0`;let r=Array.from(e);return(0,E.jsxs)(E.Fragment,{children:[r.slice(0,t[0]).join(``),(0,E.jsx)(`mark`,{className:c(`rounded-[2px] text-inherit`,n===`added`?`bg-diff-add-mark`:`bg-diff-del-mark`),children:r.slice(t[0],t[1]).join(``)}),r.slice(t[1]).join(``)]})}function N({line:e}){if(e.kind!==`line`)return(0,E.jsx)(`div`,{className:c(`git-diff-hunk-header h-5 bg-surface-subtle px-3 text-content-muted`,e.kind===`meta`&&`italic`),children:e.text});let t=e.tone===`added`?`+`:e.tone===`deleted`?`−`:` `;return(0,E.jsxs)(`div`,{className:c(`git-diff-unified-row grid h-5 grid-cols-[40px_40px_16px_max-content]`,e.tone===`added`&&`bg-diff-add`,e.tone===`deleted`&&`bg-diff-del`),"data-tone":e.tone,children:[(0,E.jsx)(`span`,{className:`pr-2 text-right text-code-gutter select-none`,children:e.oldLine??``}),(0,E.jsx)(`span`,{className:`pr-2 text-right text-code-gutter select-none`,children:e.newLine??``}),(0,E.jsx)(`span`,{"aria-hidden":`true`,className:c(`text-center select-none`,e.tone===`added`&&`text-st-done`,e.tone===`deleted`&&`text-st-fail`),children:t}),(0,E.jsx)(`code`,{className:`pr-4 font-[inherit] text-content`,children:e.tone===`context`?e.text||`\xA0`:M(e.text,e.mark,e.tone)})]})}function P({file:e,scrollElement:t}){let n=(0,m.useRef)(null),[r,i]=(0,m.useState)(0),a=(0,m.useMemo)(()=>C(e),[e]),o=(0,m.useMemo)(()=>a.reduce((e,t)=>Math.max(e,Array.from(t.text.replace(/\t/g,` `)).length),0),[a]);(0,m.useLayoutEffect)(()=>{let e=n.current;if(!t||!e)return;let r=()=>{let n=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);i(e=>Math.abs(e-n)<1?e:n)};r();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return a?.observe(t),a?.observe(e),()=>a?.disconnect()},[t]);let s=f({useFlushSync:!1,count:a.length,getScrollElement:()=>t,estimateSize:()=>j,overscan:24,scrollMargin:r}),c=s.getVirtualItems();return(0,E.jsx)(`div`,{ref:n,className:`relative font-mono text-[12px] leading-5 tabular-nums [tab-size:4] whitespace-pre`,"data-pisper-diff-row-count":a.length,"data-diff-mode":`unified`,style:{height:`${s.getTotalSize()}px`,minWidth:`calc(${o}ch + 112px)`},children:c.map(e=>(0,E.jsx)(`div`,{className:`absolute left-0 w-full`,style:{top:`${e.start-r}px`},children:(0,E.jsx)(N,{line:a[e.index]})},e.key))})}function F(e){let t=e.path.replace(/\\/g,`/`),n=t.split(`/`),r=n.pop()||t,i=0,a=0;for(let t of e.hunks)for(let e of t.rows)e.kind===`pair`&&(e.next.tone===`added`&&(i+=1),e.old.tone===`deleted`&&(a+=1));let o=e.metadata.join(`
|
|
4
4
|
`),s=/(?:^|\n)new file mode /.test(o)||!e.oldPath&&e.newPath?`added`:/(?:^|\n)deleted file mode /.test(o)||!e.newPath&&e.oldPath?`deleted`:/(?:^|\n)rename (?:from|to) /.test(o)||e.oldPath&&e.newPath&&e.oldPath!==e.newPath?`renamed`:`modified`;return{file:e,name:r,directory:n.join(`/`),added:i,deleted:a,status:s}}function I(e){return e===`added`?`A`:e===`deleted`?`D`:e===`renamed`?`R`:`M`}function L({diff:e,truncated:t,onClose:n}){let{t:r}=a(),i=(0,m.useMemo)(()=>b(e),[e]),o=(0,m.useMemo)(()=>i.map(F),[i]),[c,u]=(0,m.useState)(0),[d,f]=(0,m.useState)(null),g=Math.min(c,Math.max(o.length-1,0)),_=o[g];(0,m.useEffect)(()=>{let e=document.body.style.overflow,t=e=>{e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),e.stopPropagation(),n())};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t)}},[n]);let v=e=>{u(e),d?.scrollTo({top:0,left:0})};return(0,h.createPortal)((0,E.jsx)(`div`,{className:`git-diff-dialog-backdrop fixed inset-0 z-[120] grid place-items-center bg-[var(--overlay-scrim)] p-[24px] max-[760px]:p-[10px]`,role:`presentation`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,E.jsxs)(`section`,{className:`git-diff-dialog max-[760px]:w-[calc(100vw_-_20px)] max-[760px]:h-[calc(100vh_-_20px)] flex w-[min(1180px,calc(100vw_-_48px))] h-[min(820px,calc(100vh_-_48px))] min-w-0 min-h-0 flex-col overflow-hidden rounded-xl border border-stroke bg-solid shadow-float`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`chat:focusSession.gitViewDiff`),children:[(0,E.jsxs)(`header`,{className:`git-diff-dialog-head [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_strong]:font-medium [&_small]:text-content-muted [&_small]:text-[12px] [&_small]:tabular-nums grid min-h-[52px] flex-none grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[10px] border-b border-stroke p-[8px_12px]`,children:[(0,E.jsx)(`span`,{className:`grid size-[30px] place-items-center rounded-sm border border-key-border bg-key text-content-secondary shadow-key`,children:(0,E.jsx)(p,{size:16})}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`strong`,{children:r(`chat:focusSession.gitViewDiff`)}),(0,E.jsx)(`small`,{children:r(`chat:focusSession.gitDiffFileCount`,{count:i.length})})]}),(0,E.jsx)(l,{type:`button`,variant:`ghost`,size:`icon`,title:r(`chat:focusSession.gitCloseDiff`),"aria-label":r(`chat:focusSession.gitCloseDiff`),onClick:n,children:(0,E.jsx)(s,{size:17})})]}),o.length?(0,E.jsxs)(`div`,{className:`git-diff-layout max-[760px]:grid-rows-[minmax(112px,26vh)_minmax(0,1fr)] max-[760px]:grid-cols-[minmax(0,1fr)] grid min-w-0 min-h-0 flex-1 grid-cols-[252px_minmax(0,1fr)] overflow-hidden`,children:[(0,E.jsxs)(`nav`,{className:`git-diff-file-nav flex min-h-0 min-w-0 flex-col overflow-hidden border-r border-stroke bg-chrome max-[760px]:border-r-0 max-[760px]:border-b`,"aria-label":r(`chat:focusSession.gitDiffChangedFiles`),children:[(0,E.jsx)(`strong`,{className:`git-diff-file-nav-title flex-none p-[10px_12px_6px] text-[12px] font-medium tracking-[.02em] text-content-muted max-[760px]:[padding-block:7px_5px]`,children:r(`chat:focusSession.gitDiffChangedFiles`)}),(0,E.jsx)(`div`,{className:`git-diff-file-nav-list max-[760px]:pb-[6px] min-h-0 flex-1 overflow-x-hidden overflow-y-auto [padding:0_6px_8px]`,children:o.map((e,t)=>{let n=t===g;return(0,E.jsxs)(`button`,{type:`button`,className:`git-diff-file-nav-item grid min-h-[42px] w-full cursor-pointer grid-cols-[20px_minmax(0,1fr)_auto] items-center gap-[7px] rounded-sm border-0 bg-transparent p-[5px_7px] text-left text-content-secondary transition-colors duration-(--d-fast) hover:bg-surface-hover hover:text-foreground [&.selected]:bg-key [&.selected]:text-foreground [&.selected]:shadow-[inset_3px_0_var(--star),var(--key-shadow)] ${e.status} ${n?`selected`:``}`,title:e.file.path,"aria-current":n?`true`:void 0,onClick:()=>v(t),children:[(0,E.jsx)(`span`,{className:`git-diff-file-status text-center font-mono text-[12px] font-medium [.git-diff-file-nav-item.added_&]:text-[var(--success)] [.git-diff-file-nav-item.deleted_&]:text-[var(--danger)] [.git-diff-file-nav-item.renamed_&]:text-[var(--warning-strong)] [.git-diff-file-nav-item.modified_&]:text-content-secondary`,"aria-hidden":`true`,children:I(e.status)}),(0,E.jsxs)(`span`,{className:`git-diff-file-name [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_strong]:font-medium [&_small]:text-content-muted [&_small]:text-[12px] flex min-w-0 flex-col gap-[1px]`,children:[(0,E.jsx)(`strong`,{children:e.name}),e.directory&&(0,E.jsx)(`small`,{children:e.directory})]}),(0,E.jsxs)(`span`,{className:`git-diff-file-stats inline-flex items-center gap-[4px] font-mono text-[12px] tabular-nums [&_em]:[font-style:normal]`,"aria-hidden":`true`,children:[e.added>0&&(0,E.jsxs)(`em`,{className:`added [.git-diff-file-stats_&]:text-[var(--success)]`,children:[`+`,e.added]}),e.deleted>0&&(0,E.jsxs)(`em`,{className:`deleted [.git-diff-file-stats_&]:text-[var(--danger)]`,children:[`−`,e.deleted]})]})]},`${e.file.path}-${t}`)})})]}),(0,E.jsxs)(`div`,{className:`min-w-0 min-h-0 overflow-auto bg-surface-subtle p-[12px]`,ref:f,children:[t&&(0,E.jsx)(`div`,{className:`mb-[12px] rounded-sm border border-[var(--warning-border)] bg-warning-soft p-[8px_10px] text-[12px] text-warning-strong`,children:r(`chat:focusSession.gitDiffTruncated`)}),_&&(0,E.jsxs)(`section`,{className:`min-w-[880px] [overflow:clip] rounded-md border border-stroke bg-panel`,children:[(0,E.jsxs)(`header`,{className:`git-diff-file-head [&_>_svg]:text-content-muted [&_strong]:overflow-hidden [&_strong]:font-mono [&_strong]:text-[12px] [&_strong]:font-medium [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:max-w-[300px] [&_small]:overflow-hidden [&_small]:text-content-muted [&_small]:text-[12px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap sticky top-0 z-[3] grid min-h-[38px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] border-b border-stroke bg-panel p-[7px_10px]`,children:[(0,E.jsx)(p,{size:14}),(0,E.jsx)(`strong`,{title:_.file.path,children:_.file.path}),_.file.oldPath&&_.file.newPath&&_.file.oldPath!==_.file.newPath&&(0,E.jsx)(`small`,{title:_.file.oldPath,children:_.file.oldPath})]}),_.file.metadata.length>0&&(0,E.jsx)(`div`,{className:`git-diff-file-meta border-b border-stroke-soft bg-surface-subtle p-[5px_10px] font-mono text-[12px] text-content-muted`,children:_.file.metadata.join(` · `)}),_.file.hunks.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`git-diff-column-head [&_span]:p-[5px_10px] [&_span_+_span]:border-l [&_span_+_span]:border-stroke sticky top-[38px] z-[2] grid grid-cols-[1fr_1fr] border-b border-stroke bg-surface-subtle text-[12px] font-medium text-content-muted`,children:[(0,E.jsx)(`span`,{children:r(`chat:focusSession.gitDiffOriginal`)}),(0,E.jsx)(`span`,{children:r(`chat:focusSession.gitDiffModified`)})]}),(0,E.jsx)(A,{file:_.file,scrollElement:d})]}):(0,E.jsx)(`div`,{className:`[padding:28px_16px] text-[var(--text-muted)] text-[12px] text-center`,children:r(`chat:focusSession.gitDiffNoTextChanges`)})]},_.file.path)]})]}):(0,E.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto bg-surface-subtle p-[12px]`,children:(0,E.jsx)(`div`,{className:`rounded-md border border-stroke bg-panel p-[20px] whitespace-pre-wrap text-content-muted`,children:e||r(`chat:focusSession.gitDiffUnavailable`)})})]})}),document.body)}function R({diff:e,truncated:t,position:n,onReading:r=()=>{},mode:i=`split`,fill:o=!1}){let{t:s}=a(),l=(0,m.useMemo)(()=>b(e),[e]),{element:u,ref:d}=w(n,r);return(0,E.jsxs)(`div`,{className:o?`flex min-h-0 flex-1 flex-col`:void 0,children:[t&&(0,E.jsx)(`p`,{className:`px-3 py-2 text-xs text-content-muted`,children:s(`chat:chatMessage.filePreviewTruncated`)}),(0,E.jsx)(`div`,{ref:d,tabIndex:0,"aria-label":s(`chat:focusSession.gitViewDiff`),"data-diff-scroll":!0,className:c(`min-w-0 overflow-auto focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus`,o?`min-h-0 flex-1 bg-panel`:`max-h-80 border-y border-border bg-background`),children:!l.length||l.every(e=>!e.hunks.length)?(0,E.jsx)(`p`,{className:`p-3 text-xs text-content-muted`,children:s(`chat:focusSession.gitDiffNoTextChanges`)}):l.map((e,t)=>i===`unified`?(0,E.jsx)(P,{file:e,scrollElement:u},`${e.path}-${t}`):(0,E.jsx)(A,{file:e,scrollElement:u,compact:o},`${e.path}-${t}`))})]})}export{b as a,w as i,T as n,p as o,R as r,L as t};
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-_vdxObu5.js";import{t as i}from"./arrow-down-CDGua-ue.js";import{t as a}from"./arrow-up-DST6-qVQ.js";import{n as o,t as s}from"./useCatalogProjects-BEkCpADy.js";import{i as c,t as l}from"./workspace-order-store-Ao4OZ13V.js";import{t as u}from"./pencil-U08v_vV9.js";import{t as d}from"./rotate-ccw-C0v8V77_.js";import{t as f}from"./trash-2-CNrPOoPR.js";import{t as p}from"./utils-C8uzG5AZ.js";import{n as m,t as h}from"./button-CCcCN8tE.js";import{t as g}from"./useSessionListQuery-BoUzmjZC.js";import{s as _}from"./card-presentation-1oph2b8P.js";import{a as v,i as y,l as b,n as x,o as S,s as C,t as w}from"./dialog-DFZX_Dek.js";var T=e(t(),1),E=n(),D=`flex-none pointer-coarse:size-11 in-data-[phone-shell]:size-11`;function O({open:e,onOpenChange:t,commands:n}){let{t:O}=r(),k=g(),A=l(e=>e.rememberWorkspaces),j=l(e=>e.moveWorkspace),M=(0,T.useRef)(null),N=(0,T.useRef)(null),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(null),R=s(),z=(0,T.useMemo)(()=>R.map(e=>e.key),[R]);(0,T.useEffect)(()=>{e&&z.length&&A(z)},[z,e,A]),(0,T.useEffect)(()=>{if(!P)return;let e=M.current,t=t=>e?.querySelector(`[data-project-move="${t}"][data-project-key="${CSS.escape(P.key)}"]`),n=t(P.offset);(n&&!n.disabled?n:t(P.offset===-1?1:-1))?.focus(),F(null)},[P,R]),(0,T.useEffect)(()=>{I&&(L(null),!R.some(e=>e.key===I.key)&&((I.next?M.current?.querySelector(`[data-project-remove][data-project-key="${CSS.escape(I.next)}"]`):null)??N.current)?.focus())},[R,I]);let B=(e,t)=>{j(e.key,t,z),F({key:e.key,offset:t})},V=async(e,t)=>{let r=R[t+1]?.key??R[t-1]?.key??``;e.count===0?n.unregister(e):await n.remove(e),L({key:e.key,next:r})},H=!!n.busyKey,U;return U=k.isPending?(0,E.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 py-6 text-sm text-content-muted`,children:[(0,E.jsx)(m,{className:`size-4`}),O(`board:project.loading`)]}):k.error&&!k.data?(0,E.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 py-6 text-sm`,children:[(0,E.jsx)(`p`,{className:`text-content`,children:O(`board:project.error`)}),(0,E.jsx)(h,{variant:`secondary`,size:`sm`,onClick:()=>void k.refetch(),children:O(`board:page.retry`)})]}):R.length===0?(0,E.jsxs)(`div`,{className:`flex flex-col gap-1 py-6 text-sm`,children:[(0,E.jsx)(`p`,{className:`font-medium text-content`,children:O(`board:project.empty`)}),(0,E.jsx)(`p`,{className:`text-content-muted`,children:O(`board:project.emptyHint`)})]}):(0,E.jsx)(`ul`,{ref:M,"aria-label":O(`board:project.listLabel`),className:`flex flex-col divide-y divide-stroke-soft`,"data-manage-projects":!0,children:R.map((e,t)=>{let r=n.busyKey===e.key,s=e.cwd&&e.key!==`\0`,c=e.count===0,l=O(c?`board:project.removeNamed`:`board:project.deleteWithChatsNamed`,{project:e.label});return(0,E.jsxs)(`li`,{"data-project-row":e.key,"data-project-registered-only":c||void 0,"aria-busy":r||void 0,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 py-2`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 flex-none place-items-center rounded-sm border border-stroke-strong bg-solid font-mono text-xs font-semibold text-content uppercase`,children:Array.from(e.label)[0]||`·`}),(0,E.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,E.jsx)(`span`,{className:`truncate font-mono text-sm font-semibold text-content`,children:e.label}),(0,E.jsx)(`span`,{className:`truncate font-mono text-xs text-content-muted`,title:e.cwd||void 0,children:e.custom?`${O(`board:project.folderName`,{name:e.folderLabel})} · ${_(e.cwd)}`:e.cwd?_(e.cwd):``})]}),(0,E.jsx)(`span`,{className:`flex-none text-xs text-content-muted tabular-nums max-[480px]:hidden`,children:r?O(`board:project.deleting`):O(`board:project.sessions`,{count:e.count})}),(0,E.jsxs)(`span`,{className:`flex flex-none items-center max-[480px]:w-full max-[480px]:justify-end`,children:[(0,E.jsx)(h,{variant:`ghost`,size:`icon-sm`,className:D,"data-project-move":`-1`,"data-project-key":e.key,disabled:t===0,"aria-label":O(`board:project.moveUp`,{project:e.label}),title:O(`board:project.moveUp`,{project:e.label}),onClick:()=>B(e,-1),children:(0,E.jsx)(a,{"aria-hidden":`true`})}),(0,E.jsx)(h,{variant:`ghost`,size:`icon-sm`,className:D,"data-project-move":`1`,"data-project-key":e.key,disabled:t===R.length-1,"aria-label":O(`board:project.moveDown`,{project:e.label}),title:O(`board:project.moveDown`,{project:e.label}),onClick:()=>B(e,1),children:(0,E.jsx)(i,{"aria-hidden":`true`})}),s&&(0,E.jsx)(h,{variant:`ghost`,size:`icon-sm`,className:D,"aria-label":O(`board:project.renameNamed`,{project:e.label}),title:O(`board:project.renameNamed`,{project:e.label}),onClick:()=>void n.rename(e),children:(0,E.jsx)(u,{"aria-hidden":`true`})}),s&&e.custom&&(0,E.jsx)(h,{variant:`ghost`,size:`icon-sm`,className:D,"aria-label":O(`board:project.resetNamed`,{project:e.label}),title:O(`board:project.resetNamed`,{project:e.label}),onClick:()=>n.resetName(e),children:(0,E.jsx)(d,{"aria-hidden":`true`})}),(0,E.jsx)(h,{variant:`ghost`,size:`icon-sm`,className:p(D,!c&&`text-danger hover:text-danger`),disabled:H,"data-project-remove":c?`unregister`:`delete`,"data-project-key":e.key,"aria-label":l,title:l,onClick:()=>void V(e,t),children:r?(0,E.jsx)(m,{className:`size-4`}):c?(0,E.jsx)(o,{"aria-hidden":`true`}):(0,E.jsx)(f,{"aria-hidden":`true`})})]})]},e.key)})}),(0,E.jsx)(w,{open:e,onOpenChange:t,children:(0,E.jsxs)(y,{size:`wide`,scrollMode:`body`,"aria-describedby":`board-manage-projects`,onOpenAutoFocus:e=>{e.preventDefault(),N.current?.focus()},children:[(0,E.jsxs)(C,{children:[(0,E.jsx)(b,{children:O(`board:project.manageTitle`)}),(0,E.jsx)(v,{id:`board-manage-projects`,children:O(`board:project.manageDescription`)})]}),(0,E.jsx)(x,{className:`-mx-1 px-1`,children:U}),(0,E.jsxs)(S,{children:[(0,E.jsxs)(h,{variant:`outline`,size:`dialogAction`,disabled:n.picking,onClick:()=>{t(!1),n.newProject()},children:[(0,E.jsx)(c,{"aria-hidden":`true`}),O(`board:project.new`)]}),(0,E.jsx)(h,{ref:N,size:`dialogAction`,onClick:()=>t(!1),children:O(`board:project.done`)})]})]})})}export{O as ManageProjectsDialog};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-markdown-plugins-CT5L3KA9.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-shiki-runtime-DM7fm4Bl.js","assets/vendor-router-CSN_DGvx.js","assets/vendor-react-DwNgTV1j.js","assets/vendor-markdown-plugins-DEcVZfaU.css"])))=>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{n,t as r}from"./vendor-markdown-plugins-CT5L3KA9.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{a as o,i as s,n as c,r as l,t as u}from"./vendor-markdown-CT6Z4fh8.js";import{n as d,r as ee,t as f}from"./vendor-shiki-runtime-DM7fm4Bl.js";import{t as p}from"./use-i18n-DCxQRXLH.js";import{t as te}from"./check-2vYc6QaP.js";import{t as m}from"./copy-DHmIFc52.js";import{t as h}from"./utils-C8uzG5AZ.js";import{t as ne}from"./button-CCcCN8tE.js";import{t as re}from"./route-context-DvWDul4T.js";var g=e(i(),1),_=[`github-dark`,`github-dark`],v=150,y=new Set([`text`,`txt`,`plain`,`plaintext`]),b=new Map;for(let e of d){b.set(e.id,e.id);for(let t of e.aliases??[])b.set(t,e.id)}function x(e){return typeof e==`string`?e:e.name??`custom`}function S(e){let t=String(e||``).trim().toLowerCase();return b.get(t)??`text`}function C(e,t,n){return`${t}:${x(n[0])}:${x(n[1])}:${e.length}:${e.slice(0,64)}:${e.slice(-64)}`}var w=new Map;function ie(e){let t=w.get(e);return t&&(w.delete(e),w.set(e,t)),t}function ae(e,t){for(w.delete(e),w.set(e,t);w.size>v;){let e=w.keys().next().value;if(e===void 0)break;w.delete(e)}}var T=null,E=new Map;function oe(){return T??=ee({themes:[..._],langs:[],engine:f({forgiving:!0})}),T}function se(e,t){if(y.has(t)||e.getLoadedLanguages().includes(t))return Promise.resolve();let n=d.find(e=>e.id===t);if(!n)return Promise.resolve();let r=E.get(t);return r||(r=e.loadLanguage(()=>n.import().then(e=>e.default)).catch(e=>{throw E.delete(t),e}),E.set(t,r)),r}var D=new Map;function ce(){return{name:`shiki`,type:`code-highlighter`,supportsLanguage(e){return b.has(String(e||``).trim().toLowerCase())},getSupportedLanguages(){return d.map(e=>e.id)},getThemes(){return _},highlight({code:e,language:t,themes:n},r){let i=S(t),a=C(e,i,n),o=ie(a);if(o)return o;let s=D.get(a),c=!!s;return s||(s=new Set,D.set(a,s)),r&&s.add(r),c||(async()=>{try{let t=await oe();await se(t,i);let r=t.getLoadedLanguages().includes(i)?i:`text`,o=t.codeToTokens(e,{lang:r,themes:{light:n[0],dark:n[1]}});ae(a,o);let s=D.get(a);if(D.delete(a),s)for(let e of s)e(o)}catch(e){D.delete(a),console.error(`[streamdown] Failed to highlight code:`,e)}})(),null}}}var le=ce(),ue={cjk:n,code:le,math:r};function de(){let e=``,t=[];return n=>{if(n===e)return t;if(t.length>0&&n.startsWith(e)){let r=t[t.length-1],i=e.length-r.length;if(i<0||e.slice(i)!==r)return e=n,t=l(n),t;let a=l(n.slice(i)),o=[...t.slice(0,-1),...a];return e=n,t=o,o}return e=n,t=l(n),t}}var O=100,k=new Map;function A(e){let t=k.get(e);if(t)return k.delete(e),k.set(e,t),t;let n=l(e);if(k.set(e,n),k.size>O){let e=k.keys().next().value;e!==void 0&&k.delete(e)}return n}var j=null;function M(){return j??=t(()=>import(`./vendor-markdown-plugins-CT5L3KA9.js`).then(e=>e.O),__vite__mapDeps([0,1,2,3,4,5])),j}function N(e){return/\$\$|\\\(|\\\[|\$[^\n$]+\$|\\begin\{/.test(e)}var P=160;function F(e,t){let n=String(e||``).match(/language-[\w-]+:(\S+)/)?.[1]||``,r=typeof t==`string`?t:``,i=r.match(/(?:^|\s)(?:title|filename|file)=(?:"([^"]+)"|'([^']+)'|(\S+))/),a=r.split(/\s+/).find(e=>e&&!e.includes(`=`)&&!/^[{[]/.test(e)&&/[/.]/.test(e));return[...(n||i?.[1]||i?.[2]||i?.[3]||a||``).replace(/[\u0000-\u001f\u007f]/g,``).trim()].slice(0,P).join(``)}var I=`https://local-file.pisper.invalid`,L=`/reveal`;function R(e){try{return decodeURIComponent(e)}catch{return e}}function z(e){return[...e].some(e=>{let t=e.codePointAt(0)||0;return t<32||t===127})}function B(e){return/^(?:[A-Za-z]:[\\/]|\/|\\\\)/.test(e)}function V(e){let t=e.match(/:(\d+)(?::(\d+))?$/);if(!t)return{path:e};let n={path:e.slice(0,-t[0].length),line:Number(t[1])};return t[2]&&(n.column=Number(t[2])),n}function H(e){try{let t=new URL(e);if(t.protocol!==`file:`||t.username||t.password||t.port)return null;let n=t.pathname;return t.hostname&&t.hostname!==`localhost`?`//${t.hostname}${n}`:/^\/[A-Za-z]:[\\/]/.test(n)?n.slice(1):n}catch{return null}}function fe(e){return!e||/^[\\/]/.test(e)||/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e)?!1:!e.split(/[\\/]/).includes(`..`)}function pe(e,t){let n=e.replace(/[\\/]+$/,``);if(!n)return e.startsWith(`/`)?`/`+t.replace(/^(?:\.\/)+/,``):``;let r=e.includes(`\\`)?`\\`:`/`,i=t.replace(/^[\\/]+/,``).replace(/^(?:\.[/])+/g,``);return n+r+i}function me(e,t){let n=e.trim();if(!n||z(n))return null;let r=/^file:/i.test(n);if(!r&&/[?#]/.test(n))return null;let i=r?H(n):n;if(!i)return null;let a=V(i),o=R(a.path);if(!o||z(o))return null;let s=/^\/[A-Za-z]:[\\/]/.test(o)?o.slice(1):o;if(B(s))return{...a,path:s};if(/^[A-Za-z][A-Za-z0-9+.-]*:/.test(i)&&!a.path.includes(`.`)||!t)return null;let c=t.trim();if(!B(c)||z(c)||!fe(o))return null;let l=pe(c,o);return B(l)?{...a,path:l}:null}function he(e){let t=new URL(L,I);return t.searchParams.set(`path`,e.path),e.line!==void 0&&t.searchParams.set(`line`,String(e.line)),e.column!==void 0&&t.searchParams.set(`column`,String(e.column)),t.href}function ge(e){try{let t=new URL(e);if(t.origin!==I||t.pathname!==L)return null;let n=t.searchParams.get(`path`)||``;if(!B(n)||z(n))return null;let r=Number(t.searchParams.get(`line`)),i=Number(t.searchParams.get(`column`)),a={path:n};return Number.isSafeInteger(r)&&r>0&&(a.line=r),Number.isSafeInteger(i)&&i>0&&(a.column=i),a}catch{return null}}function _e(e){return t=>{let n=t=>{if(t.type===`link`&&typeof t.url==`string`){let n=me(t.url,e);n&&(t.url=he(n))}for(let e of t.children||[])n(e)};n(t)}}async function U(e){let t=await fetch(`/api/desktop/reveal-path`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e})}),n={};try{n=await t.json()}catch{}if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.revealed===!0}var W=class extends Error{reason;constructor(e){super(`local-reveal:${e}`),this.reason=e,this.name=`LocalPathRevealError`}};async function G(e,t){if(typeof t!=`function`)throw new W(`unavailable`);let n;try{if(await Promise.race([Promise.resolve().then(()=>t(e)),new Promise((e,t)=>{n=setTimeout(()=>t(new W(`timeout`)),8e3)})])!==!0)throw new W(`failed`)}finally{clearTimeout(n)}}var K=a(),ve={a:Se,code:Ee,img:Z,strong:Ce,table:we},ye=!1,be={linkMode:`text-only`};function q(e,t){window.dispatchEvent(new CustomEvent(re,{detail:{message:e,tone:t}}))}function J(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(J).join(``):(0,g.isValidElement)(e)?J(e.props.children):``}function xe(e){return String(e||``).match(/language-([\w-]+)/)?.[1]||`text`}function Y({file:e}){return(0,K.jsx)(`span`,{className:`max-w-[min(360px,45vw)] truncate px-1.5 font-mono text-xs text-content-secondary`,title:e,"data-code-file":!0,children:e})}function X(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);return t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove(),Promise.resolve()}function Se({children:e,node:t,className:n,href:r,...i}){let{t:a}=p(),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(``),u=J(e).trim()?e:r;if(!r)return(0,K.jsx)(`span`,{className:h(`markdown-link`,n),children:u});let d=ge(r);if(d){let e=a(`common:markdownMessage.revealLocalPath`,{path:d.path}),t=async()=>{s(!0),l(``);try{await G(d.path,U),q(a(`common:markdownMessage.revealLocalPathOk`,{path:d.path}),`info`)}catch(e){let t=e instanceof W&&e.reason===`unavailable`?a(`common:markdownMessage.revealLocalPathUnavailable`):e instanceof W&&e.reason===`timeout`?a(`common:markdownMessage.revealLocalPathTimeout`):a(`common:markdownMessage.revealLocalPathFailed`,{path:d.path}),n=e instanceof Error?e.message:String(e);console.error(`[markdown] 无法在文件管理器中显示本地路径。`,e),l(`${t} (${n})`),q(t,`error`)}finally{s(!1)}};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:h(`markdown-link inline cursor-pointer border-0 bg-transparent p-0 [font:inherit]`,n),"data-local-path":d.path,title:e,disabled:o,"aria-busy":o||void 0,onClick:()=>void t(),children:u}),c&&(0,K.jsxs)(`span`,{role:`alert`,className:`ml-2 text-sm text-destructive`,children:[c,` `,(0,K.jsx)(`button`,{type:`button`,className:`cursor-pointer underline underline-offset-2`,onClick:()=>{X(d.path).then(()=>q(a(`common:markdownMessage.copied`),`info`),()=>q(a(`common:markdownMessage.copyPathFailed`),`error`))},children:a(`common:markdownMessage.copyPath`)})]})]})}return(0,K.jsx)(`a`,{...i,className:h(`markdown-link`,n),href:r,target:`_blank`,rel:`noopener noreferrer`,children:u})}function Z({node:e,...t}){return(0,K.jsx)(`img`,{loading:`lazy`,...t})}function Ce({node:e,...t}){return(0,K.jsx)(`strong`,{...t})}function we({node:e,...t}){return(0,K.jsx)(`table`,{...t})}function Q({source:e}){let{t}=p(),[n,r]=(0,g.useState)(!1),i=async()=>{try{await X(e),r(!0),window.setTimeout(()=>r(!1),1800)}catch{r(!1)}},a=t(n?`common:markdownMessage.copied`:`common:markdownMessage.copyCode`);return(0,K.jsx)(ne,{type:`button`,variant:`ghost`,size:`icon-sm`,className:h(`size-[26px] text-[var(--code-toolbar-text)] opacity-0 transition-opacity duration-(--d-fast) hover:bg-surface-hover hover:text-foreground focus-visible:opacity-100 [[data-streamdown=code-block]:hover_&]:opacity-100 [@media(hover:none)]:opacity-100 max-[650px]:size-11 max-[650px]:opacity-100 pointer-coarse:size-11 pointer-coarse:opacity-100`,n&&`opacity-100`),"data-streamdown":`code-block-copy-button`,onClick:i,"aria-label":a,title:a,children:n?(0,K.jsx)(te,{size:14,className:`text-success`}):(0,K.jsx)(m,{size:14})})}function Te({language:e,source:t,file:n}){return(0,K.jsxs)(`div`,{className:`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,"data-incomplete":`true`,"data-language":e,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`},children:[(0,K.jsxs)(`div`,{className:`flex h-8 items-center justify-between text-muted-foreground text-xs`,"data-language":e,"data-streamdown":`code-block-header`,children:[(0,K.jsx)(`span`,{className:`ml-1 font-mono lowercase`,children:e}),(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[n&&(0,K.jsx)(Y,{file:n}),(0,K.jsx)(Q,{source:t})]})]}),(0,K.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`,"data-language":e,"data-streamdown":`code-block-body`,children:(0,K.jsx)(`pre`,{className:`bg-transparent`,children:(0,K.jsx)(`code`,{children:t.split(`
|
|
2
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{n,t as r}from"./vendor-markdown-plugins-CT5L3KA9.js";import{i,r as a}from"./vendor-react-DwNgTV1j.js";import{a as o,i as s,n as c,r as l,t as u}from"./vendor-markdown-CT6Z4fh8.js";import{n as d,r as ee,t as f}from"./vendor-shiki-runtime-DM7fm4Bl.js";import{t as p}from"./use-i18n-_vdxObu5.js";import{t as te}from"./check-2vYc6QaP.js";import{t as m}from"./copy-DHmIFc52.js";import{t as h}from"./utils-C8uzG5AZ.js";import{t as ne}from"./button-CCcCN8tE.js";import{t as re}from"./route-context-DvWDul4T.js";var g=e(i(),1),_=[`github-dark`,`github-dark`],v=150,y=new Set([`text`,`txt`,`plain`,`plaintext`]),b=new Map;for(let e of d){b.set(e.id,e.id);for(let t of e.aliases??[])b.set(t,e.id)}function x(e){return typeof e==`string`?e:e.name??`custom`}function S(e){let t=String(e||``).trim().toLowerCase();return b.get(t)??`text`}function C(e,t,n){return`${t}:${x(n[0])}:${x(n[1])}:${e.length}:${e.slice(0,64)}:${e.slice(-64)}`}var w=new Map;function ie(e){let t=w.get(e);return t&&(w.delete(e),w.set(e,t)),t}function ae(e,t){for(w.delete(e),w.set(e,t);w.size>v;){let e=w.keys().next().value;if(e===void 0)break;w.delete(e)}}var T=null,E=new Map;function oe(){return T??=ee({themes:[..._],langs:[],engine:f({forgiving:!0})}),T}function se(e,t){if(y.has(t)||e.getLoadedLanguages().includes(t))return Promise.resolve();let n=d.find(e=>e.id===t);if(!n)return Promise.resolve();let r=E.get(t);return r||(r=e.loadLanguage(()=>n.import().then(e=>e.default)).catch(e=>{throw E.delete(t),e}),E.set(t,r)),r}var D=new Map;function ce(){return{name:`shiki`,type:`code-highlighter`,supportsLanguage(e){return b.has(String(e||``).trim().toLowerCase())},getSupportedLanguages(){return d.map(e=>e.id)},getThemes(){return _},highlight({code:e,language:t,themes:n},r){let i=S(t),a=C(e,i,n),o=ie(a);if(o)return o;let s=D.get(a),c=!!s;return s||(s=new Set,D.set(a,s)),r&&s.add(r),c||(async()=>{try{let t=await oe();await se(t,i);let r=t.getLoadedLanguages().includes(i)?i:`text`,o=t.codeToTokens(e,{lang:r,themes:{light:n[0],dark:n[1]}});ae(a,o);let s=D.get(a);if(D.delete(a),s)for(let e of s)e(o)}catch(e){D.delete(a),console.error(`[streamdown] Failed to highlight code:`,e)}})(),null}}}var le=ce(),ue={cjk:n,code:le,math:r};function de(){let e=``,t=[];return n=>{if(n===e)return t;if(t.length>0&&n.startsWith(e)){let r=t[t.length-1],i=e.length-r.length;if(i<0||e.slice(i)!==r)return e=n,t=l(n),t;let a=l(n.slice(i)),o=[...t.slice(0,-1),...a];return e=n,t=o,o}return e=n,t=l(n),t}}var O=100,k=new Map;function A(e){let t=k.get(e);if(t)return k.delete(e),k.set(e,t),t;let n=l(e);if(k.set(e,n),k.size>O){let e=k.keys().next().value;e!==void 0&&k.delete(e)}return n}var j=null;function M(){return j??=t(()=>import(`./vendor-markdown-plugins-CT5L3KA9.js`).then(e=>e.O),__vite__mapDeps([0,1,2,3,4,5])),j}function N(e){return/\$\$|\\\(|\\\[|\$[^\n$]+\$|\\begin\{/.test(e)}var P=160;function F(e,t){let n=String(e||``).match(/language-[\w-]+:(\S+)/)?.[1]||``,r=typeof t==`string`?t:``,i=r.match(/(?:^|\s)(?:title|filename|file)=(?:"([^"]+)"|'([^']+)'|(\S+))/),a=r.split(/\s+/).find(e=>e&&!e.includes(`=`)&&!/^[{[]/.test(e)&&/[/.]/.test(e));return[...(n||i?.[1]||i?.[2]||i?.[3]||a||``).replace(/[\u0000-\u001f\u007f]/g,``).trim()].slice(0,P).join(``)}var I=`https://local-file.pisper.invalid`,L=`/reveal`;function R(e){try{return decodeURIComponent(e)}catch{return e}}function z(e){return[...e].some(e=>{let t=e.codePointAt(0)||0;return t<32||t===127})}function B(e){return/^(?:[A-Za-z]:[\\/]|\/|\\\\)/.test(e)}function V(e){let t=e.match(/:(\d+)(?::(\d+))?$/);if(!t)return{path:e};let n={path:e.slice(0,-t[0].length),line:Number(t[1])};return t[2]&&(n.column=Number(t[2])),n}function H(e){try{let t=new URL(e);if(t.protocol!==`file:`||t.username||t.password||t.port)return null;let n=t.pathname;return t.hostname&&t.hostname!==`localhost`?`//${t.hostname}${n}`:/^\/[A-Za-z]:[\\/]/.test(n)?n.slice(1):n}catch{return null}}function fe(e){return!e||/^[\\/]/.test(e)||/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e)?!1:!e.split(/[\\/]/).includes(`..`)}function pe(e,t){let n=e.replace(/[\\/]+$/,``);if(!n)return e.startsWith(`/`)?`/`+t.replace(/^(?:\.\/)+/,``):``;let r=e.includes(`\\`)?`\\`:`/`,i=t.replace(/^[\\/]+/,``).replace(/^(?:\.[/])+/g,``);return n+r+i}function me(e,t){let n=e.trim();if(!n||z(n))return null;let r=/^file:/i.test(n);if(!r&&/[?#]/.test(n))return null;let i=r?H(n):n;if(!i)return null;let a=V(i),o=R(a.path);if(!o||z(o))return null;let s=/^\/[A-Za-z]:[\\/]/.test(o)?o.slice(1):o;if(B(s))return{...a,path:s};if(/^[A-Za-z][A-Za-z0-9+.-]*:/.test(i)&&!a.path.includes(`.`)||!t)return null;let c=t.trim();if(!B(c)||z(c)||!fe(o))return null;let l=pe(c,o);return B(l)?{...a,path:l}:null}function he(e){let t=new URL(L,I);return t.searchParams.set(`path`,e.path),e.line!==void 0&&t.searchParams.set(`line`,String(e.line)),e.column!==void 0&&t.searchParams.set(`column`,String(e.column)),t.href}function ge(e){try{let t=new URL(e);if(t.origin!==I||t.pathname!==L)return null;let n=t.searchParams.get(`path`)||``;if(!B(n)||z(n))return null;let r=Number(t.searchParams.get(`line`)),i=Number(t.searchParams.get(`column`)),a={path:n};return Number.isSafeInteger(r)&&r>0&&(a.line=r),Number.isSafeInteger(i)&&i>0&&(a.column=i),a}catch{return null}}function _e(e){return t=>{let n=t=>{if(t.type===`link`&&typeof t.url==`string`){let n=me(t.url,e);n&&(t.url=he(n))}for(let e of t.children||[])n(e)};n(t)}}async function U(e){let t=await fetch(`/api/desktop/reveal-path`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e})}),n={};try{n=await t.json()}catch{}if(!t.ok)throw Error(n.error||`HTTP ${t.status}`);return n.revealed===!0}var W=class extends Error{reason;constructor(e){super(`local-reveal:${e}`),this.reason=e,this.name=`LocalPathRevealError`}};async function G(e,t){if(typeof t!=`function`)throw new W(`unavailable`);let n;try{if(await Promise.race([Promise.resolve().then(()=>t(e)),new Promise((e,t)=>{n=setTimeout(()=>t(new W(`timeout`)),8e3)})])!==!0)throw new W(`failed`)}finally{clearTimeout(n)}}var K=a(),ve={a:Se,code:Ee,img:Z,strong:Ce,table:we},ye=!1,be={linkMode:`text-only`};function q(e,t){window.dispatchEvent(new CustomEvent(re,{detail:{message:e,tone:t}}))}function J(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(J).join(``):(0,g.isValidElement)(e)?J(e.props.children):``}function xe(e){return String(e||``).match(/language-([\w-]+)/)?.[1]||`text`}function Y({file:e}){return(0,K.jsx)(`span`,{className:`max-w-[min(360px,45vw)] truncate px-1.5 font-mono text-xs text-content-secondary`,title:e,"data-code-file":!0,children:e})}function X(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);return t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove(),Promise.resolve()}function Se({children:e,node:t,className:n,href:r,...i}){let{t:a}=p(),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(``),u=J(e).trim()?e:r;if(!r)return(0,K.jsx)(`span`,{className:h(`markdown-link`,n),children:u});let d=ge(r);if(d){let e=a(`common:markdownMessage.revealLocalPath`,{path:d.path}),t=async()=>{s(!0),l(``);try{await G(d.path,U),q(a(`common:markdownMessage.revealLocalPathOk`,{path:d.path}),`info`)}catch(e){let t=e instanceof W&&e.reason===`unavailable`?a(`common:markdownMessage.revealLocalPathUnavailable`):e instanceof W&&e.reason===`timeout`?a(`common:markdownMessage.revealLocalPathTimeout`):a(`common:markdownMessage.revealLocalPathFailed`,{path:d.path}),n=e instanceof Error?e.message:String(e);console.error(`[markdown] 无法在文件管理器中显示本地路径。`,e),l(`${t} (${n})`),q(t,`error`)}finally{s(!1)}};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:h(`markdown-link inline cursor-pointer border-0 bg-transparent p-0 [font:inherit]`,n),"data-local-path":d.path,title:e,disabled:o,"aria-busy":o||void 0,onClick:()=>void t(),children:u}),c&&(0,K.jsxs)(`span`,{role:`alert`,className:`ml-2 text-sm text-destructive`,children:[c,` `,(0,K.jsx)(`button`,{type:`button`,className:`cursor-pointer underline underline-offset-2`,onClick:()=>{X(d.path).then(()=>q(a(`common:markdownMessage.copied`),`info`),()=>q(a(`common:markdownMessage.copyPathFailed`),`error`))},children:a(`common:markdownMessage.copyPath`)})]})]})}return(0,K.jsx)(`a`,{...i,className:h(`markdown-link`,n),href:r,target:`_blank`,rel:`noopener noreferrer`,children:u})}function Z({node:e,...t}){return(0,K.jsx)(`img`,{loading:`lazy`,...t})}function Ce({node:e,...t}){return(0,K.jsx)(`strong`,{...t})}function we({node:e,...t}){return(0,K.jsx)(`table`,{...t})}function Q({source:e}){let{t}=p(),[n,r]=(0,g.useState)(!1),i=async()=>{try{await X(e),r(!0),window.setTimeout(()=>r(!1),1800)}catch{r(!1)}},a=t(n?`common:markdownMessage.copied`:`common:markdownMessage.copyCode`);return(0,K.jsx)(ne,{type:`button`,variant:`ghost`,size:`icon-sm`,className:h(`size-[26px] text-[var(--code-toolbar-text)] opacity-0 transition-opacity duration-(--d-fast) hover:bg-surface-hover hover:text-foreground focus-visible:opacity-100 [[data-streamdown=code-block]:hover_&]:opacity-100 [@media(hover:none)]:opacity-100 max-[650px]:size-11 max-[650px]:opacity-100 pointer-coarse:size-11 pointer-coarse:opacity-100`,n&&`opacity-100`),"data-streamdown":`code-block-copy-button`,onClick:i,"aria-label":a,title:a,children:n?(0,K.jsx)(te,{size:14,className:`text-success`}):(0,K.jsx)(m,{size:14})})}function Te({language:e,source:t,file:n}){return(0,K.jsxs)(`div`,{className:`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,"data-incomplete":`true`,"data-language":e,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`},children:[(0,K.jsxs)(`div`,{className:`flex h-8 items-center justify-between text-muted-foreground text-xs`,"data-language":e,"data-streamdown":`code-block-header`,children:[(0,K.jsx)(`span`,{className:`ml-1 font-mono lowercase`,children:e}),(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[n&&(0,K.jsx)(Y,{file:n}),(0,K.jsx)(Q,{source:t})]})]}),(0,K.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`,"data-language":e,"data-streamdown":`code-block-body`,children:(0,K.jsx)(`pre`,{className:`bg-transparent`,children:(0,K.jsx)(`code`,{children:t.split(`
|
|
3
3
|
`).map((e,t)=>(0,K.jsx)(`span`,{children:e},t))})})})]})}function Ee({children:e,className:t,node:n,metastring:r,...i}){let a=o();if(!Object.hasOwn(i,`data-block`))return(0,K.jsx)(`code`,{className:t||``,...i,children:e});let c=J(e).replace(/\n$/,``),l=xe(t),u=F(t,r);return a?(0,K.jsx)(Te,{language:l,source:c,file:u}):(0,K.jsxs)(s,{code:c,isIncomplete:a,language:l,lineNumbers:!1,children:[u&&(0,K.jsx)(Y,{file:u}),(0,K.jsx)(Q,{source:c})]})}function De({children:e,className:t,streaming:n=!1,cwd:r}){let i=String(e??``),a=(0,g.useMemo)(()=>[...Object.values(u),[_e,r||void 0]],[r]),o=(0,g.useMemo)(()=>N(i),[i]);(0,g.useEffect)(()=>{o&&M()},[o]);let[s]=(0,g.useState)(()=>de()),l=n?s:A;return(0,K.jsx)(`div`,{className:h(`markdown-body`,n&&`markdown-streaming`,t),"aria-busy":n||void 0,children:(0,K.jsx)(c,{className:`markdown-content space-y-0`,components:ve,controls:ye,isAnimating:n,lineNumbers:!1,mode:`streaming`,parseMarkdownIntoBlocksFn:l,plugins:ue,remarkPlugins:a,remend:be,children:i})})}var $=(0,g.memo)(De);$.displayName=`MarkdownMessage`;export{U as i,W as n,G as r,$ as t};
|
|
@@ -1 +1 @@
|
|
|
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-DCxQRXLH.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-BmSvZCuH.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-DnykOp5e.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-DFcH7POi.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-DGauTCbU.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
|
+
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-_vdxObu5.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-BW_X0FMZ.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-D72gQCwH.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-DFZX_Dek.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-BB1TeMlr.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};
|
|
@@ -0,0 +1 @@
|
|
|
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-_vdxObu5.js";import{t as i}from"./createLucideIcon-Cd-3GVxJ.js";import{t as a}from"./info-DATxy0fb.js";import{t as o}from"./pause-CYWpPg1R.js";import{t as s}from"./play-DNDjDNGn.js";import{t as c}from"./x-07u4-129.js";import{i as l,n as u,t as d}from"./popover--q2hs_pT.js";import{t as f}from"./slider-De8rWVNs.js";import{t as p}from"./segmented-control-xkrEOP_d.js";import{t as m}from"./utils-C8uzG5AZ.js";import{n as h,t as g}from"./button-CCcCN8tE.js";import{n as ee,t as te}from"./PageState-Cz6vFMXv.js";import{t as _}from"./motion-DTR4ZVle.js";import{d as v,l as ne}from"./memory-api-DkPje--t.js";var re=i(`skip-forward`,[[`path`,{d:`M21 4v16`,key:`7j8fe9`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`zs4d6`}]]),y=e(t(),1);function ie(e={}){let{rootMargin:t=`96px 0px`,threshold:n=0}=e,[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(()=>!document.hidden),[s,c]=(0,y.useState)(!0),l=(0,y.useCallback)(e=>{i(e)},[]);return(0,y.useEffect)(()=>{let e=()=>o(!document.hidden);return e(),document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),(0,y.useEffect)(()=>{if(!r||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(([e])=>{e&&c(e.isIntersecting)},{rootMargin:t,threshold:n});return e.observe(r),()=>e.disconnect()},[r,t,n]),{ref:l,playing:a&&s}}var b=864e5,x=Math.PI*2,S=.055,C=.85,w=1e3,T=6e3,E=[`decision`,`preference`,`fact`,`concept`,`risk`,`file`,`task`];function D(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}var ae=e=>D(e)/4294967296,O=e=>Math.min(1,Math.max(0,e));function k(e,t){let n=Date.parse(String(e||``));return Number.isNaN(n)?t:n}function A(e,t){let n=Math.max(1,e.end-e.start);return S+.945*O((t-e.start)/n)**C}function oe(e,t){return t*(1+.046*(.62*Math.sin(3*e+1.1+1.9*t)+.28*Math.sin(5*e+4.2-2.7*t)+.1*Math.sin(11*e+2.3+5.1*t))*Math.min(1,t*2.2))}var se=.042,ce=-.03;function j(e,t){return oe(e,t)*Math.cos(e)+se*(1-t)}function M(e,t){return oe(e,t)*Math.sin(e)+ce*(1-t)}function le(e){let t=(e.end-e.start)/b;return t<=21?`day`:t<=120?`week`:t<=1e3?`month`:t<=3e3?`quarter`:`year`}function ue(e,t){let n=new Date(e);if(t===`day`)return new Date(n.getFullYear(),n.getMonth(),n.getDate()+1);if(t===`week`){let e=(8-n.getDay())%7||7;return new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)}return t===`month`?new Date(n.getFullYear(),n.getMonth()+1,1):t===`quarter`?new Date(n.getFullYear(),Math.floor(n.getMonth()/3)*3+3,1):new Date(n.getFullYear()+1,0,1)}function N(e,t){return t===`day`?new Date(e.getFullYear(),e.getMonth(),e.getDate()+1):t===`week`?new Date(e.getFullYear(),e.getMonth(),e.getDate()+7):t===`month`?new Date(e.getFullYear(),e.getMonth()+1,1):t===`quarter`?new Date(e.getFullYear(),e.getMonth()+3,1):new Date(e.getFullYear()+1,0,1)}function de(e,t){return t===`day`?e.getDay()===1:t===`week`?e.getDate()<=7:t===`month`?e.getMonth()%3==0:t!==`quarter`||e.getMonth()===0}function fe(e,t,n){let r=[],i=ue(e.start,t);for(;i.getTime()<e.end&&r.length<400;)r.push(i),i=N(i,t);let a=Array(r.length).fill(0);for(let e of n){let t=0,n=r.length;for(;t<n;){let i=t+n>>1;r[i].getTime()<e?t=i+1:n=i}t<a.length&&(a[t]+=1)}let o=Math.max(1,...a);return r.map((n,r)=>{let i=n.getTime();return{at:i,rho:A(e,i),major:de(n,t),activity:a[r]/o}})}var pe=new Set([`project`,`projects`,`user`,`users`,`global`,`repo`,`app`,`pisper`,`general`,`misc`,`title`]);function me(e){let t=String(e||``).split(`.`).filter(Boolean);for(;t.length>1&&pe.has(t[0]);)t.shift();return t[0]||``}function he(e,t){let n=k(e.createdAt,t),r=k(e.validFrom,n);return{created:n,valid:r,appear:Math.max(n,r)}}function ge(e,t){if(!e.length)return{start:t-180*b,end:t};let n=1/0,r=t;for(let i of e){let{valid:e,appear:a}=he(i,t);n=Math.min(n,e,a),a<=t&&(r=Math.max(r,a))}let i=Math.max(b,r-n);return{start:Math.min(n-Math.max(i*.02,b/4),r-7*b),end:r}}function _e(e){let t=new Map,n=e.map(e=>me(e.topicKey));e.forEach((e,r)=>{let i=`${e.spaceId}\u0000${n[r]}`,a=t.get(i);a?a.push(r):t.set(i,[r])});let r=Math.max(2,Math.ceil(e.length*.012)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])},o=new Map,s=new Map,c=[...t.entries()].sort((e,t)=>t[1].length-e[1].length||e[0].localeCompare(t[0]));for(let[t,n]of c){let[i,c]=t.split(`\0`),l=s.get(i)||0;if(c&&n.length>=r&&l<16){s.set(i,l+1),a(i,{key:t,label:c,kind:`topic`,spaceId:i,members:n});continue}for(let t of n){let n=`${i}\u0000type:${e[t].type}`,r=o.get(n);r?r.push(t):o.set(n,[t])}}for(let[e,t]of o){let[n,r]=e.split(`\0`);a(n,{key:e,label:r.slice(5),kind:`type`,spaceId:n,members:t})}return i}function ve(e,t,n){let r=_e(e),i=[...r.keys()].sort((e,t)=>e===`global`?-1:t===`global`?1:D(e)-D(t)),a=[],o=new Int16Array(e.length),s=new Float32Array(e.length),c=[],l=i.length>1?.09:0,u=i.reduce((e,t)=>e+(r.get(t)?.length||0),0),d=Math.min(.022,x*.25/Math.max(1,u)),f=e=>(r.get(e)||[]).reduce((e,t)=>e+Math.sqrt(t.members.length)+.6,0),p=i.reduce((e,t)=>e+f(t),0)||1,m=x-l*i.length-d*u,h=-Math.PI/2+l/2;for(let u of i){let i=[...r.get(u)||[]].sort((e,t)=>D(e.key)-D(t.key)),f=h;for(let n of i){let r=m*(Math.sqrt(n.members.length)+.6)/p,i=a.length;a.push({key:n.key.split(`\0`)[1],label:n.label,kind:n.kind,spaceId:u,start:h,end:h+r,count:n.members.length});let c=[...n.members].sort((n,r)=>t[n]-t[r]||e[n].id.localeCompare(e[r].id)),l=ae(n.key);c.forEach((e,t)=>{o[e]=i;let n=(l+t*.61803398875)%1;s[e]=h+r*(.05+.9*n)}),h+=r+d}c.push({spaceId:u,name:n.find(e=>e.id===u)?.name||u,start:f,end:h-d}),h+=l}return{sectors:a,sectorOf:o,theta:s,spaceArcs:i.length>1?c:[]}}function ye(e){return Float64Array.from(e).sort()}function be(e,{histogramBins:t=160}={}){let n=k(e.now,Date.now()),r=[...e.facts].sort((e,t)=>e.id.localeCompare(t.id)),i=r.length,a=ge(r,n),o=a.end-a.start,s=Math.max(b,o*.015),c=new Map(r.map((e,t)=>[e.id,t])),l=new Float64Array(i),u=new Float64Array(i),d=new Float64Array(i).fill(1/0),f=new Float64Array(i).fill(1/0),p=new Int32Array(i).fill(-1),m=new Uint8Array(i),h=new Uint8Array(i),g=new Map;r.forEach((e,t)=>{let{created:r,valid:i,appear:a}=he(e,n);l[t]=i,u[t]=a;let o=E.indexOf(e.type);h[t]=o>=0?o:E.indexOf(`concept`);let d=0;e.pinned&&(d|=1),e.tainted&&(d|=2),e.status===`stale`&&(d|=8),r-i>s&&(d|=4),m[t]=d;let f=e.supersededBy?c.get(e.supersededBy):void 0;if(f!==void 0&&f!==t){p[t]=f;let e=g.get(f);e?e.push(t):g.set(f,[t])}}),r.forEach((e,t)=>{let n=k(e.supersededAt,NaN)||k(e.validTo,NaN)||(e.status===`superseded`?p[t]>=0?u[p[t]]:a.end:NaN);Number.isFinite(n)&&(d[t]=Math.max(n,u[t]));let r=k(e.archivedAt,NaN)||(e.status===`archived`?a.end:NaN);Number.isFinite(r)&&(f[t]=Math.max(r,u[t]))});let{sectors:ee,sectorOf:te,theta:_,spaceArcs:v}=ve(r,u,e.spaces),ne=new Float32Array(i),re=new Float32Array(i),y=new Float32Array(i),ie=new Float32Array(i),S=new Float32Array(i),C=new Float32Array(i),w=new Float32Array(i);r.forEach((e,t)=>{ne[t]=A(a,l[t]),re[t]=j(_[t],ne[t]),y[t]=M(_[t],ne[t]);let n=O(Number(e.importance)||0),r=O((Number(e.authority)||0)/100);S[t]=.16+.84*n**1.5,C[t]=(.4+.22*r+.38*n)*(e.tainted?.6:1),ie[t]=.016+.105*n**1.5+(e.pinned?.03:0),w[t]=ae(e.id)*x});let T=[];r.forEach((e,t)=>{Number.isFinite(d[t])&&T.push({at:d[t],from:t,to:p[t]})}),T.sort((e,t)=>e.at-t.at||e.from-t.from);let D=Math.max(1,t),oe=new Uint16Array(D),se=new Uint16Array(D),ce=e=>Math.min(D-1,Math.floor(O((e-a.start)/o)*D));for(let e=0;e<i;e+=1)u[e]<=a.end&&(oe[ce(u[e])]+=1);for(let e of T)e.at<=a.end&&(se[ce(e.at)]+=1);let ue=[...u],N=[],de=[];for(let e=0;e<i;e+=1){let t=Math.min(d[e],f[e]);Number.isFinite(t)&&N.push(t),Number.isFinite(f[e])&&de.push(f[e])}let pe=e.digests.map(e=>{let t=k(e.windowEnd,a.end),n=k(e.windowStart,t),r=v.find(t=>t.spaceId===e.spaceId),i=r?.start??-Math.PI,o=(r?.end??Math.PI)-i,s=o*(e.level===`month`?.16:e.level===`week`?.085:.045),c=i+ae(e.id)*Math.max(0,o-s);return{id:e.id,level:e.level,at:t,rho:A(a,(n+t)/2),start:c,end:c+s}}),me=le(a);return{facts:r,count:i,indexById:c,domain:a,unit:me,rings:fe(a,me,ue),bornWindow:Math.max(o*.012,1),validAt:l,appearAt:u,replacedAt:d,archivedAt:f,theta:_,rho:ne,x:re,y,lift:ie,size:S,brightness:C,phase:w,typeIndex:h,sector:te,flags:m,successor:p,predecessors:g,replacements:T,sectors:ee,spaceArcs:v,digests:pe,histogram:oe,histogramReplacements:se,truncated:!!e.truncated,sortedAppear:ye(ue),sortedEnded:ye(N),sortedArchived:ye(de)}}function xe(e,t,n){return n<e.appearAt[t]?0:n>=e.archivedAt[t]?3:n>=e.replacedAt[t]?2:1}function Se(e,t,n,r=e.bornWindow){let i=xe(e,t,n);return i===0?`hidden`:i===3?`archived`:i===2?`superseded`:n-e.appearAt[t]<r?`born`:`active`}function P(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<=t?n=i+1:r=i}return n}function Ce(e,t){let n=P(e.sortedAppear,t),r=P(e.sortedEnded,t),i=P(e.sortedArchived,t);return{active:n-r,superseded:r-i,archived:i,known:n}}function we(e,t){let n=new Set([t]),r=[],i=[t];for(;i.length;)for(let t of e.predecessors.get(i.pop())||[])n.has(t)||(n.add(t),r.push(t),i.push(t));let a=[],o=e.successor[t];for(;o>=0&&!n.has(o);)n.add(o),a.push(o),o=e.successor[o];return[...r,t,...a].sort((t,n)=>e.appearAt[t]-e.appearAt[n]||t-n)}function Te(e,t){return e.start+(e.end-e.start)*O(t/w)}function Ee(e,t){let n=Math.max(1,e.end-e.start);return Math.round(O((t-e.start)/n)*w)}function De(e,t=T){let n=O(e/t);return n<.5?4*n*n*n:1-(-2*n+2)**3/2}var F=Math.PI*2,I=144,Oe=72,ke=.2,L=96,Ae=620,R=55e5,je={decision:[255,196,92],preference:[186,164,255],fact:[176,214,255],concept:[104,176,255],risk:[255,104,158],file:[92,226,176],task:[92,222,240]},z=[255,96,44],Me=[96,118,164],Ne=[156,164,178],B=[236,208,164],V=[255,232,192],H=[255,176,104],U=[255,236,204],Pe=[255,206,138],W=[255,222,180],Fe=[176,202,255],G=([e,t,n],r=1)=>`rgba(${e}, ${t}, ${n}, ${r})`;function K(e,t){let n=document.createElement(`canvas`);return n.width=Math.max(1,Math.round(e)),n.height=Math.max(1,Math.round(t)),n}function q([e,t,n]){let r=K(L,L),i=r.getContext(`2d`);if(!i)return r;let a=L/2,o=i.createRadialGradient(a,a,0,a,a,a),s=r=>[255+(e-255)*r,255+(t-255)*r,255+(n-255)*r],c=(e,t)=>{let[n,r,i]=s(e);return`rgba(${n|0}, ${r|0}, ${i|0}, ${t})`};return o.addColorStop(0,c(.12,1)),o.addColorStop(.08,c(.5,.96)),o.addColorStop(.16,c(1,.62)),o.addColorStop(.3,c(1,.22)),o.addColorStop(.56,c(1,.06)),o.addColorStop(1,c(1,0)),i.fillStyle=o,i.fillRect(0,0,L,L),r}function Ie([e,t,n]){let r=K(L,L),i=r.getContext(`2d`);if(!i)return r;let a=L/2,o=i.createRadialGradient(a,a,0,a,a,a);return o.addColorStop(0,`rgba(${e}, ${t}, ${n}, 0.55)`),o.addColorStop(.35,`rgba(${e}, ${t}, ${n}, 0.16)`),o.addColorStop(.7,`rgba(${e}, ${t}, ${n}, 0.035)`),o.addColorStop(1,`rgba(${e}, ${t}, ${n}, 0)`),i.fillStyle=o,i.fillRect(0,0,L,L),r}var Le=class{canvas;ctx;camera={yaw:0,tilt:.92,zoom:1};quality;scene=null;width=1;height=1;dpr=1;maxDpr=2;insets={top:0,right:0,bottom:0,left:0};targetInsets={top:0,right:0,bottom:0,left:0};typeSprites;emberSprite;archiveSprite;untrustedSprite;pulseSprite;coreSprite;discSprite;pinnedHalo;background=null;bloomA=null;bloomB=null;ringPaths=[];grainPaths=[];frontierPath=new Float32Array(288);rimPath=new Float32Array(288);screenX=new Float32Array;screenY=new Float32Array;screenR=new Float32Array;liftNow=new Float32Array;worldX=new Float32Array;worldY=new Float32Array;morphX=null;morphY=null;morphStart=0;slowWindows=0;chainMask=new Uint8Array;ringLabels=[];sectorOrder=[];selected=-1;selectedSector=-1;hovered=-1;ringFormatter=()=>``;dust;rippleQueue=new Int32Array(48);lateQueue=new Int32Array(24);typeCss;ambientPulses=[];nextAmbientPulse=0;frameTimes=0;frameCount=0;px=0;py=0;ps=1;cx=0;cy=0;unit=1;cosYaw=1;sinYaw=0;cosTilt=1;sinTilt=0;constructor(e,{quality:t=3}={}){this.canvas=e;let n=e.getContext(`2d`,{alpha:!1});if(!n)throw Error(`canvas 2d unavailable`);this.ctx=n,this.quality=t,this.typeSprites=E.map(e=>q(je[e])),this.typeCss=E.map(e=>G(je[e])),this.emberSprite=q(z),this.archiveSprite=q(Me),this.untrustedSprite=q(Ne),this.pulseSprite=q(U),this.coreSprite=Ie(Pe),this.discSprite=Ie([206,158,104]),this.pinnedHalo=Ie(V),this.dust=new Float32Array(1e3);let r=20261105,i=()=>(r=Math.imul(r,1664525)+1013904223>>>0,r/4294967296);for(let e=0;e<200;e+=1){let t=i()*F,n=.08+Math.sqrt(i())*1.42;this.dust[e*5]=Math.cos(t)*n,this.dust[e*5+1]=Math.sin(t)*n,this.dust[e*5+2]=(i()-.35)*.42,this.dust[e*5+3]=i()*F,this.dust[e*5+4]=.15+i()*.55}}setRingFormatter(e){this.ringFormatter=e,this.refreshLabels()}setScene(e,{animate:t=!1,now:n=0}={}){let r=this.scene,i=this.worldX,a=this.worldY;if(this.scene=e,this.ambientPulses=[],this.morphX=null,this.morphY=null,!e)return!1;let o=!1;if(t&&r&&r.count&&e.count){let t=Float32Array.from(e.x),s=Float32Array.from(e.y),c=0;e.facts.forEach((e,n)=>{let o=r.indexById.get(e.id);o!==void 0&&(t[n]=i[o],s[n]=a[o],c+=1)}),c>=Math.max(1,e.count*.3)&&(this.morphX=t,this.morphY=s,this.morphStart=n,o=!0)}return this.worldX=Float32Array.from(this.morphX??e.x),this.worldY=Float32Array.from(this.morphY??e.y),this.screenX=new Float32Array(e.count),this.screenY=new Float32Array(e.count),this.screenR=new Float32Array(e.count),this.liftNow=new Float32Array(e.count),this.chainMask=new Uint8Array(e.count),this.ringPaths=e.rings.map(e=>{let t=new Float32Array(288);return this.fillRingPath(t,e.rho),t}),this.fillRingPath(this.rimPath,1),this.grainPaths=this.buildGrain(),this.sectorOrder=e.sectors.map((e,t)=>({sector:e,index:t})).filter(({sector:e})=>e.kind===`topic`).sort((e,t)=>t.sector.count-e.sector.count).slice(0,10).map(e=>e.index),this.refreshLabels(),this.setSelection(this.selected<e.count?this.selected:-1),this.hovered=-1,o}buildGrain(){let e=[],t=7;for(let n=.07;n<1;n+=.0115){t=Math.imul(t,1664525)+1013904223>>>0;let r=((t>>>8)/16777216-.5)*.006,i=new Float32Array(144);for(let e=0;e<Oe;e+=1){let t=e/Oe*F;i[e*2]=j(t,n+r),i[e*2+1]=M(t,n+r)}e.push({rho:n+r,path:i})}return e}refreshLabels(){this.ringLabels=this.scene?this.scene.rings.map(e=>this.ringFormatter(e.at)):[]}setSelection(e){let{scene:t}=this;if(this.selected=e,this.chainMask.fill(0),this.selectedSector=-1,!t||e<0||e>=t.count){this.selected=-1;return}for(let n of we(t,e))this.chainMask[n]=1;this.selectedSector=t.sector[e]}setHover(e){this.hovered=e}resize(e,t,n){let r=Math.max(1,e),i=Math.max(1,t);(r!==this.width||i!==this.height||n!==this.maxDpr)&&(this.width=r,this.height=i,this.maxDpr=n,this.applyResolution())}setInsets(e,{animate:t=!1}={}){this.targetInsets=e,t||(this.insets=e)}get settling(){let{insets:e,targetInsets:t}=this;return e.top!==t.top||e.right!==t.right||e.bottom!==t.bottom||e.left!==t.left}stepInsets(){let e=(e,t)=>Math.abs(t-e)<.5?t:e+(t-e)*.14,{insets:t,targetInsets:n}=this;this.settling&&(this.insets={top:e(t.top,n.top),right:e(t.right,n.right),bottom:e(t.bottom,n.bottom),left:e(t.left,n.left)})}applyResolution(){let e=typeof devicePixelRatio==`number`?devicePixelRatio:1,t=this.quality===1?1:this.maxDpr,n=Math.sqrt(R/(this.width*this.height));this.dpr=Math.max(1,Math.min(e||1,t,n)),this.canvas.width=Math.max(1,Math.round(this.width*this.dpr)),this.canvas.height=Math.max(1,Math.round(this.height*this.dpr)),this.background=this.paintBackground(),this.bloomA=K(this.canvas.width/4,this.canvas.height/4),this.bloomB=K(this.canvas.width/10,this.canvas.height/10)}noteFrameInterval(e){if(this.frameTimes+=e,this.frameCount+=1,this.frameCount<45)return;let t=this.frameTimes/this.frameCount;this.frameTimes=0,this.frameCount=0,this.slowWindows=t>30?this.slowWindows+1:0,this.slowWindows>=2&&this.quality>1&&(this.slowWindows=0,--this.quality,this.applyResolution())}paintBackground(){let e=K(Math.min(1024,this.width),Math.min(1024,this.height)),t=e.getContext(`2d`);if(!t)return e;let{width:n,height:r}=e;t.fillStyle=`#05060a`,t.fillRect(0,0,n,r);let i=this.layoutCenter(),a=t.createRadialGradient(i.x/this.width*n,i.y/this.height*r,0,i.x/this.width*n,i.y/this.height*r,Math.max(n,r)*.72);return a.addColorStop(0,`rgba(30, 27, 32, 0.8)`),a.addColorStop(.42,`rgba(10, 13, 22, 0.7)`),a.addColorStop(1,`rgba(3, 4, 8, 0)`),t.fillStyle=a,t.fillRect(0,0,n,r),e}layoutCenter(){let{top:e,bottom:t,left:n,right:r}=this.insets;return{x:n+(this.width-n-r)/2,y:e+(this.height-e-t)/2}}fillRingPath(e,t){for(let n=0;n<I;n+=1){let r=n/I*F;e[n*2]=j(r,t),e[n*2+1]=M(r,t)}}project(e,t,n){let r=e*this.cosYaw-t*this.sinYaw,i=e*this.sinYaw+t*this.cosYaw,a=1/(1-ke*(i*this.sinTilt+n*this.cosTilt));this.px=this.cx+this.unit*r*a,this.py=this.cy+this.unit*(i*this.cosTilt-n*this.sinTilt)*a,this.ps=a}traceRing(e){let{ctx:t}=this;for(let n=0;n<I;n+=1)this.project(e[n*2],e[n*2+1],0),n===0?t.moveTo(this.px,this.py):t.lineTo(this.px,this.py);t.closePath()}applyCamera(e){let{camera:t}=this;this.stepInsets(),this.cosYaw=Math.cos(t.yaw),this.sinYaw=Math.sin(t.yaw),this.cosTilt=Math.cos(t.tilt),this.sinTilt=Math.sin(t.tilt);let{top:n,bottom:r,left:i,right:a}=this.insets,o=Math.max(40,this.width-i-a),s=Math.max(40,this.height-n-r),c=this.layoutCenter(),l=1+ke*this.sinTilt*.55,u=Math.min(o/(2.08*l),s/(2.08*Math.max(this.cosTilt,.34)*l+.14*this.sinTilt)),d=1+.72*(1-e)**2;this.unit=u*t.zoom*d,this.cx=c.x,this.cy=c.y+this.sinTilt*this.unit*.02}pick(e,t,n,r){let{scene:i}=this;if(!i)return-1;let a=-1,o=n*n;for(let n=0;n<i.count;n+=1){let s=this.screenX[n];if(Number.isNaN(s))continue;let c=s-e,l=this.screenY[n]-t,u=c*c+l*l;(r>=i.replacedAt[n]||r>=i.archivedAt[n])&&(u*=1.8),u<o&&(o=u,a=n)}return a}screenPosition(e){let t=this.screenX[e];return t===void 0||Number.isNaN(t)?null:{x:t,y:this.screenY[e]}}draw(e){let{ctx:t,scene:n,dpr:r}=this;t.setTransform(r,0,0,r,0,0),t.globalCompositeOperation=`source-over`,t.globalAlpha=1,this.background?t.drawImage(this.background,0,0,this.width,this.height):(t.fillStyle=`#05060a`,t.fillRect(0,0,this.width,this.height));let i=n?A(n.domain,e.at):1;this.applyCamera(i),t.globalCompositeOperation=`lighter`,t.lineCap=`round`,t.lineJoin=`round`,this.drawDust(e),n&&(this.stepMorph(n,e),this.drawDiscBody(n,e,i),this.drawDigests(n,e),this.computePositions(n,e),this.drawThreads(n,e),this.drawStems(n,e),this.drawFacts(n,e),this.drawPulses(n,e),this.drawFrontier(e,i)),this.applyBloom(),t.setTransform(r,0,0,r,0,0),t.globalCompositeOperation=`source-over`,t.globalAlpha=1,n&&this.drawLabels(n,e,i),e.fade<1&&(t.globalAlpha=1-e.fade,t.fillStyle=`#05060a`,t.fillRect(0,0,this.width,this.height),t.globalAlpha=1)}stepMorph(e,t){let{morphX:n,morphY:r}=this;if(!n||!r)return;let i=Math.min(1,Math.max(0,(t.wall-this.morphStart)/Ae)),a=i*i*(3-2*i);for(let t=0;t<e.count;t+=1)this.worldX[t]=n[t]+(e.x[t]-n[t])*a,this.worldY[t]=r[t]+(e.y[t]-r[t])*a;i>=1&&(this.morphX=null,this.morphY=null)}get morphing(){return this.morphX!==null}drawDust(e){let{ctx:t,dust:n}=this,r=this.quality===3?200:this.quality===2?110:40,i=e.ambient?e.wall*12e-6:0;for(let a=0;a<r;a+=1){let r=a*5,o=.55+a%7*.05,s=Math.cos(i*o),c=Math.sin(i*o),l=n[r]*s-n[r+1]*c,u=n[r]*c+n[r+1]*s;if(this.project(l,u,n[r+2]),this.px<-4||this.py<-4||this.px>this.width+4||this.py>this.height+4)continue;let d=e.ambient?.55+.45*Math.sin(e.wall*7e-4+n[r+3]):.7,f=(.7+n[r+4]*1.1)*this.ps;t.globalAlpha=n[r+4]*d*.5,t.fillStyle=G(a%3==0?Fe:W),t.fillRect(this.px-f/2,this.py-f/2,f,f)}t.globalAlpha=1}drawDiscBody(e,t,n){let{ctx:r}=this,i=this.selected>=0?.55:1;this.project(j(0,0),M(0,0),0);let a=this.px,o=this.py,s=this.unit*Math.max(n,.1)*1.32;if(r.globalAlpha=.5*i,r.drawImage(this.discSprite,this.cx-s,this.cy-s*this.cosTilt,s*2,s*2*this.cosTilt),n<.995&&(r.beginPath(),this.traceRing(this.rimPath),r.globalAlpha=.06,r.strokeStyle=G(B),r.lineWidth=.8,r.stroke()),this.quality>=2){let e=this.quality===3?1:2;r.strokeStyle=G(B),r.lineWidth=.5,r.globalAlpha=.075*e*i,r.beginPath();for(let t=0;t<this.grainPaths.length;t+=e){let{rho:e,path:i}=this.grainPaths[t];if(e>n)break;for(let e=0;e<Oe;e+=1)this.project(i[e*2],i[e*2+1],0),e===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py);r.closePath()}r.stroke()}let{rings:c}=e,l=-1;for(let e=0;e<c.length&&!(c[e].at>t.at);e+=1)l=e;r.fillStyle=G(B);for(let e=0;e<=l;e+=2){let t=c[e];r.beginPath(),this.traceRing(this.ringPaths[e]),e>0&&this.traceRing(this.ringPaths[e-1]),r.globalAlpha=(.012+.03*t.activity)*i,r.fill(`evenodd`)}r.strokeStyle=G(B);for(let e=0;e<=l;e+=1){let t=c[e];r.beginPath(),this.traceRing(this.ringPaths[e]),r.globalAlpha=(.11+.17*t.activity+(t.major?.13:0))*i,r.lineWidth=t.major?1:.65,r.stroke()}let u=this.knownCount(e,t.at),d=t.ambient?1+.08*Math.sin(t.wall*.0011):1,f=this.unit*(.17+.028*Math.log1p(u))*d;r.globalAlpha=.62*i,r.drawImage(this.coreSprite,a-f,o-f,f*2,f*2),r.globalAlpha=1}knownCount(e,t){let n=0,r=e.sortedAppear.length;for(;n<r;){let i=n+r>>1;e.sortedAppear[i]<=t?n=i+1:r=i}return n}drawDigests(e,t){let{ctx:n}=this;if(e.digests.length){n.strokeStyle=G(V),n.lineWidth=1.25,n.globalAlpha=this.selected>=0?.1:.34,n.beginPath();for(let r of e.digests){if(r.at>t.at)continue;let e=Math.max(4,Math.ceil((r.end-r.start)/F*I));for(let t=0;t<=e;t+=1){let i=r.start+(r.end-r.start)*t/e;this.project(j(i,r.rho),M(i,r.rho),0),t===0?n.moveTo(this.px,this.py):n.lineTo(this.px,this.py)}}n.stroke(),n.globalAlpha=1}}computePositions(e,t){let{at:n,effectWindow:r}=t,{appearAt:i,replacedAt:a,archivedAt:o,lift:s,count:c}=e,{worldX:l,worldY:u}=this;for(let e=0;e<c;e+=1){if(n<i[e]){this.screenX[e]=NaN;continue}let t=s[e],c=Math.min(a[e],o[e]);if(n>=c){let i=Math.min(1,(n-c)/(r*1.6)),a=i*i*(3-2*i);t=n>=o[e]?s[e]*(1-a)-.035*a:s[e]*(1-a)}this.liftNow[e]=t,this.project(l[e],u[e],t),this.screenX[e]=this.px,this.screenY[e]=this.py,this.screenR[e]=this.ps}}threadControl(e,t){let n=this.worldX[e],r=this.worldY[e],i=this.worldX[t],a=this.worldY[t],o=i-n,s=a-r,c=Math.sqrt(o*o+s*s);this.project((n+i)/2,(r+a)/2,(this.liftNow[e]+this.liftNow[t])/2+.018+c*.46)}drawThreads(e,t){let{ctx:n,selected:r,chainMask:i}=this,{at:a}=t;n.strokeStyle=G(H),n.lineWidth=.95,n.globalAlpha=r>=0?.06:.42,n.beginPath();for(let t of e.replacements){if(t.at>a)break;t.to<0||a<e.appearAt[t.to]||r>=0&&i[t.from]&&i[t.to]||(this.threadControl(t.from,t.to),n.moveTo(this.screenX[t.from],this.screenY[t.from]),n.quadraticCurveTo(this.px,this.py,this.screenX[t.to],this.screenY[t.to]))}if(n.stroke(),r>=0){n.strokeStyle=G(V),n.lineWidth=1.5,n.globalAlpha=.8,n.beginPath();for(let t of e.replacements){if(t.at>a)break;t.to<0||a<e.appearAt[t.to]||!i[t.from]||!i[t.to]||(this.threadControl(t.from,t.to),n.moveTo(this.screenX[t.from],this.screenY[t.from]),n.quadraticCurveTo(this.px,this.py,this.screenX[t.to],this.screenY[t.to]))}n.stroke()}n.globalAlpha=1}drawStems(e,t){if(this.sinTilt<.2||this.quality<2||this.quality===2&&e.count>800)return;let{ctx:n,selected:r}=this,{at:i}=t,{appearAt:a,replacedAt:o,archivedAt:s,count:c}=e,{worldX:l,worldY:u}=this;n.strokeStyle=G(B),n.lineWidth=.6,n.globalAlpha=r>=0?.05:.3,n.beginPath();for(let e=0;e<c;e+=1)i<a[e]||i>=o[e]||i>=s[e]||(this.project(l[e],u[e],0),n.moveTo(this.px,this.py),n.lineTo(this.screenX[e],this.screenY[e]));if(n.stroke(),this.quality===3&&c<=1500&&r<0){let t=Math.max(.2,this.cosTilt);for(let r=0;r<c;r+=1){if(i<a[r]||i>=o[r]||i>=s[r])continue;this.project(l[r],u[r],0);let c=12*(.5+e.size[r])*this.ps;n.globalAlpha=.2,n.drawImage(this.typeSprites[e.typeIndex[r]],this.px-c/2,this.py-c*t/2,c,c*t)}}n.globalAlpha=1}drawFacts(e,t){let{ctx:n,selected:r,selectedSector:i,chainMask:a,hovered:o}=this,{at:s,effectWindow:c,wall:l,ambient:u}=t,{appearAt:d,replacedAt:f,archivedAt:p,size:m,brightness:h,phase:g,typeIndex:ee,flags:te,count:_}=e,v=Math.min(1.75,Math.max(.74,(420/Math.max(1,_))**.26)),ne=Math.min(1.35,Math.max(.7,this.unit/330))*v,re=this.quality===3?48:this.quality===2?24:8,y=_>2200||_>800&&this.quality<3?.34:this.quality===1&&_>300?.26:0,ie=0,b=0;for(let v=0;v<_;v+=1){if(s<d[v])continue;let _=this.screenX[v],x=this.screenY[v],S=this.screenR[v],C=1;r>=0&&(C=a[v]?1.3:e.sector[v]===i?.5:.11),v===o&&(C=Math.max(C,1.5)),C*=.62+.42*Math.min(1,Math.max(0,(S-.84)/.3));let w=(6+19*m[v])*ne*S,T=Math.min(f[v],p[v]);if(s>=p[v]){let e=Math.min(1,(s-p[v])/(c*1.6)),t=w*(.62+.25*(1-e));n.globalAlpha=Math.min(1,(.2+.4*(1-e))*C),n.drawImage(this.archiveSprite,_-t/2,x-t/2,t,t);continue}if(s>=T){let e=Math.min(1,(s-T)/c),t=u?.82+.18*Math.sin(l*.0016+g[v]):.9,r=w*(.86+.9*(1-e)*(1-e));if(e<1){n.globalAlpha=Math.min(1,(1-e)*h[v]*C);let t=this.spriteFor(v,ee,te);n.drawImage(t,_-r/2,x-r/2,r,r)}n.globalAlpha=Math.min(1,(.62+.38*(1-e))*t*C),n.drawImage(this.emberSprite,_-r/2,x-r/2,r,r);continue}let E=s-d[v],D=E<c?(1-E/c)*t.effectGain:0;if(m[v]<y&&D===0&&v!==o&&r<0){let e=1.7*S;n.globalAlpha=Math.min(1,h[v]*C),n.fillStyle=this.typeCss[ee[v]],n.fillRect(_-e/2,x-e/2,e,e);continue}let ae=u?.86+.14*Math.sin(l*.0013+g[v]):.95,O=h[v]*ae*C;te[v]&8&&(O*=.72);let k=w*(1+2.4*D*D);n.globalAlpha=Math.min(1,O+D*.5);let A=this.spriteFor(v,ee,te);if(n.drawImage(A,_-k/2,x-k/2,k,k),te[v]&1){let e=w*2.9;n.globalAlpha=Math.min(1,.5*C*ae),n.drawImage(this.pinnedHalo,_-e/2,x-e/2,e,e)}D>0&&(ie<re&&(this.rippleQueue[ie++]=v),te[v]&4&&b<this.lateQueue.length&&(this.lateQueue[b++]=v))}n.globalAlpha=1,this.drawRipples(e,t,ie),this.drawLateBeams(e,t,b),this.drawSelectionMarks(e,t)}spriteFor(e,t,n){return n[e]&2?this.untrustedSprite:this.typeSprites[t[e]]}drawRipples(e,t,n){if(!n)return;let{ctx:r}=this;r.lineWidth=1;for(let i=0;i<n;i+=1){let n=this.rippleQueue[i],a=(t.at-e.appearAt[n])/t.effectWindow;if(a<0||a>=1)continue;this.project(this.worldX[n],this.worldY[n],0);let o=this.unit*(.006+.052*Math.sqrt(a))*this.ps;r.globalAlpha=(1-a)*(1-a)*.42*t.effectGain,r.strokeStyle=G(je[E[e.typeIndex[n]]]),r.beginPath(),r.ellipse(this.px,this.py,o,o*Math.max(.2,this.cosTilt),0,0,F),r.stroke()}r.globalAlpha=1}drawLateBeams(e,t,n){if(!n)return;let{ctx:r}=this,i=A(e.domain,t.at);r.strokeStyle=G(V),r.lineWidth=1.2;for(let a=0;a<n;a+=1){let n=this.lateQueue[a],o=(t.at-e.appearAt[n])/t.effectWindow;if(o<0||o>=1)continue;let s=e.theta[n];this.project(j(s,i),M(s,i),0),r.globalAlpha=(1-o)*.8*t.effectGain,r.beginPath(),r.moveTo(this.px,this.py),r.lineTo(this.screenX[n],this.screenY[n]),r.stroke()}r.globalAlpha=1}drawSelectionMarks(e,t){let{ctx:n,selected:r,hovered:i,chainMask:a}=this,o=(r,i,a)=>{r<0||r>=e.count||t.at<e.appearAt[r]||(n.globalAlpha=a,n.beginPath(),n.arc(this.screenX[r],this.screenY[r],i,0,F),n.stroke())};if(n.strokeStyle=G(V),n.lineWidth=1,r>=0)for(let t=0;t<e.count;t+=1)a[t]&&o(t,t===r?12:7,t===r?.95:.55);i>=0&&i!==r&&o(i,9,.7),n.globalAlpha=1}drawPulseAlong(e,t,n,r){let{ctx:i}=this;this.threadControl(e,t);let a=this.px,o=this.py,s=this.screenX[e],c=this.screenY[e],l=this.screenX[t],u=this.screenY[t],d=e=>{let t=1-e;this.px=t*t*s+2*t*e*a+e*e*l,this.py=t*t*c+2*t*e*o+e*e*u},f=Math.min(1,n*1.3),p=Math.max(0,f-.42),m=r*(n>.75?(1-n)/.25:1);i.strokeStyle=G(U);for(let e=0;e<9;e+=1){let t=p+(f-p)*e/9,n=p+(f-p)*(e+1)/9;d(t);let r=this.px,a=this.py;d(n),i.globalAlpha=Math.min(1,((e+1)/9)**2*m),i.lineWidth=.7+1.5*((e+1)/9),i.beginPath(),i.moveTo(r,a),i.lineTo(this.px,this.py),i.stroke()}d(f);let h=20*Math.min(1.2,this.unit/300);i.globalAlpha=Math.min(1,m),i.drawImage(this.pulseSprite,this.px-h/2,this.py-h/2,h,h)}drawPulses(e,t){let{at:n,effectWindow:r,wall:i,ambient:a}=t,{replacements:o}=e;if(!o.length)return;let s=this.quality===3?36:this.quality===2?18:6,c=0,l=o.length;for(;c<l;){let e=c+l>>1;o[e].at<=n?c=e+1:l=e}let u=c,d=r*1.8,f=0;for(let r=u-1;r>=0&&f<s;--r){let i=o[r],a=(n-i.at)/d;if(a>=1)break;i.to<0||n<e.appearAt[i.to]||(t.effectGain>.02&&this.drawPulseAlong(i.from,i.to,a,t.effectGain),f+=1)}if(!a){this.ctx.globalAlpha=1;return}if(this.selected>=0){let e=0;for(let t of o){if(t.to<0||t.at>n||!this.chainMask[t.from]||!this.chainMask[t.to])continue;let r=((i*45e-5+e*.27)%1+1)%1;this.drawPulseAlong(t.from,t.to,r,.9),e+=1}}else if(u){if(i>=this.nextAmbientPulse&&this.ambientPulses.length<3){this.nextAmbientPulse=i+650+(Math.sin(i)+1)*500;let e=Math.floor(Math.abs(Math.sin(i*12.9898))*u)%u;this.ambientPulses.push({replacement:e,start:i})}for(let t=this.ambientPulses.length-1;t>=0;--t){let r=this.ambientPulses[t],a=(i-r.start)/1900,s=o[r.replacement];if(a>=1||!s||s.at>n){this.ambientPulses.splice(t,1);continue}s.to<0||n<e.appearAt[s.to]||this.drawPulseAlong(s.from,s.to,a,.55)}}this.ctx.globalAlpha=1}drawFrontier(e,t){let{ctx:n}=this,r=this.frontierPath;this.fillRingPath(r,t),n.strokeStyle=G(V);let i=(e.moving?1:.62)*(this.selected>=0?.5:1),a=this.quality===1?1:3;for(let e=0;e<a;e+=1)n.beginPath(),this.traceRing(r),e===a-1?(n.lineWidth=1.1,n.globalAlpha=.72*i):e===0?(n.lineWidth=9,n.globalAlpha=.035*i):(n.lineWidth=3.6,n.globalAlpha=.09*i),n.stroke();if(e.ambient&&this.quality>=2){let r=Math.min(46,this.unit*.11)*(e.moving?1.25:1);for(let a=0;a<3;a+=1){let o=e.wall*17e-5*(a===1?-1:1)+a*2.1;this.project(j(o,t),M(o,t),0),n.globalAlpha=(.32+.3*Math.max(0,Math.sin(e.wall*6e-4+a*2)))*i,n.drawImage(this.pulseSprite,this.px-r/2,this.py-r/2,r,r)}}n.globalAlpha=1}applyBloom(){let{ctx:e,canvas:t}=this;if(this.quality<2||!this.bloomA)return;let n=this.bloomA.getContext(`2d`);if(n){if(n.globalCompositeOperation=`copy`,n.imageSmoothingEnabled=!0,n.drawImage(t,0,0,this.bloomA.width,this.bloomA.height),e.setTransform(1,0,0,1,0,0),e.imageSmoothingEnabled=!0,e.globalCompositeOperation=`lighter`,e.globalAlpha=.34,e.drawImage(this.bloomA,0,0,t.width,t.height),this.quality>=3&&this.bloomB){let n=this.bloomB.getContext(`2d`);n&&(n.globalCompositeOperation=`copy`,n.imageSmoothingEnabled=!0,n.drawImage(this.bloomA,0,0,this.bloomB.width,this.bloomB.height),e.globalAlpha=.3,e.drawImage(this.bloomB,0,0,t.width,t.height))}e.globalAlpha=1}}drawLabels(e,t,n){let{ctx:r}=this;if(this.width<280||!e.count)return;r.textBaseline=`middle`,r.textAlign=`left`,r.font=`10.5px ui-sans-serif, system-ui, sans-serif`;let i=this.selected>=0?.45:1,a=Math.PI*.2-this.camera.yaw,o=1/0,s=1/0;for(let n=e.rings.length-1;n>=0;--n){let c=e.rings[n];if(c.at>t.at||!c.major||(this.project(j(a,c.rho),M(a,c.rho),0),Math.hypot(this.px-o,this.py-s)<34))continue;o=this.px,s=this.py,r.globalAlpha=.62*i,r.fillStyle=G(B);let l=this.ringLabels[n]||``;r.fillText(l,Math.min(this.px+4,this.width-8-r.measureText(l).width),this.py)}let c=Math.min(1.09,n+.07),l=Math.min(1.14,n+.12);if(this.width>=560&&n>.32){r.textAlign=`center`;for(let t of this.sectorOrder){let i=e.sectors[t],a=(i.start+i.end)/2;if(e.spaceArcs.some(e=>e.name.includes(i.label)))continue;this.project(j(a,c),M(a,c),0);let o=(.14+.5*Math.min(1,Math.max(0,(this.ps-.86)/.24)))*Math.min(1,(n-.32)*4);this.selected>=0&&(o=t===this.selectedSector?.95:.1),r.globalAlpha=o,r.fillStyle=G(B),r.fillText(i.label.slice(0,18),this.px,this.py)}}if(e.spaceArcs.length){r.textAlign=`center`;for(let t of e.spaceArcs){let e=Math.max(6,Math.ceil((t.end-t.start)/F*I));r.beginPath();for(let n=0;n<=e;n+=1){let i=t.start+(t.end-t.start)*n/e;this.project(j(i,l),M(i,l),0),n===0?r.moveTo(this.px,this.py):r.lineTo(this.px,this.py)}r.strokeStyle=G(B),r.lineWidth=1,r.globalAlpha=.34*i,r.stroke();let n=(t.start+t.end)/2;this.project(j(n,l+.035),M(n,l+.035),0),r.globalAlpha=.72*i,r.fillStyle=G(V),r.fillText(t.name.slice(0,22),this.px,this.py)}}r.globalAlpha=1}};function Re(e,t,n,r,i){let a=e.getContext(`2d`);if(!a)return;let o=Math.min((typeof devicePixelRatio==`number`?devicePixelRatio:1)||1,2),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o));(e.width!==s||e.height!==c)&&(e.width=s,e.height=c),a.setTransform(o,0,0,o,0,0),a.clearRect(0,0,r,i);let{histogram:l,histogramReplacements:u,domain:d}=t,f=l.length,p=Math.max(1,d.end-d.start),m=Math.min(1,Math.max(0,(n-d.start)/p))*r,h=1;for(let e=0;e<f;e+=1)h=Math.max(h,l[e]);let g=r/f,ee=i-5;for(let e=0;e<f;e+=1){let t=l[e],n=e*g,r=n+g/2<=m;if(t){let e=Math.max(1.5,Math.sqrt(t/h)*ee);a.fillStyle=r?G(B,.78):G(B,.2),a.fillRect(n+.5,i-e,Math.max(1,g-1),e)}if(u[e]){let t=Math.min(ee,3+u[e]*1.5);a.fillStyle=r?G(z,.95):G(z,.34),a.fillRect(n+g/2-.75,0,1.5,t)}}}var J=n(),ze=400,Be=540,Ve=880,He=16,Ue={colorScheme:`dark`,"--text":`rgba(246, 240, 228, 0.96)`,"--foreground":`rgba(246, 240, 228, 0.96)`,"--text-soft":`rgba(246, 240, 228, 0.86)`,"--text-secondary":`rgba(240, 232, 218, 0.74)`,"--text-muted":`rgba(232, 224, 208, 0.58)`,"--text-faint":`rgba(232, 224, 208, 0.38)`,"--surface-hover":`rgba(255, 244, 224, 0.1)`,"--surface-active":`rgba(255, 244, 224, 0.17)`,"--surface-muted":`rgba(255, 244, 224, 0.07)`,"--surface-subtle":`rgba(255, 244, 224, 0.1)`,"--stroke":`rgba(255, 244, 224, 0.13)`,"--stroke-soft":`rgba(255, 244, 224, 0.08)`,"--stroke-strong":`rgba(255, 244, 224, 0.22)`,"--solid":`rgba(255, 244, 224, 0.14)`,"--star":`rgba(255, 232, 192, 0.92)`,"--star-hover":`rgba(255, 240, 214, 1)`,"--key-bg":`rgba(255, 240, 214, 1)`,"--key-border":`rgba(255, 244, 224, 0.2)`,"--key-shadow":`0 0 14px rgba(255, 214, 150, 0.55)`,"--control-border":`rgba(255, 240, 214, 0.9)`,"--focus":`rgba(255, 222, 170, 1)`,"--focus-ring":`rgba(255, 222, 170, 0.32)`,"--danger":`rgba(255, 150, 130, 1)`,"--evo-panel":`rgba(13, 14, 19, 0.74)`,"--evo-line":`rgba(255, 244, 224, 0.13)`,"--evo-scrim":`rgba(5, 6, 10, 0.86)`,"--evo-scrim-clear":`rgba(5, 6, 10, 0)`,"--evo-base":`rgba(5, 6, 10, 1)`,"--evo-active":`rgba(255, 232, 192, 1)`},We=G(z),Ge=G(Me),Ke=24e3,qe=[`0.5`,`1`,`2`],Je=-.38,Ye=.94,Xe=.68,Ze=.24,Qe=26e-6,$e=450,et=2e4,tt=Math.PI*.62,nt=1.1,rt=30,it=7,at=!1;function ot(e){let t=navigator.deviceMemory;return t!==void 0&&t<=2?1:e||t!==void 0&&t<=4?2:3}function st(e){let t=Math.min(1,Math.max(0,e));return t*t*(3-2*t)}var ct=e=>e instanceof Error?e.message:String(e),lt=e=>e instanceof DOMException&&e.name===`AbortError`;function ut({spaceId:e,refreshKey:t=0,selectedId:n=null,onSelect:i}){let{t:b,language:x}=r(),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(!0),[D,ae]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,oe]=(0,y.useState)(0),[se,ce]=(0,y.useState)(0),[j,M]=(0,y.useState)(!1),[le,ue]=(0,y.useState)(`1`),[N,de]=(0,y.useState)(null),[fe,pe]=(0,y.useState)(null),[me,he]=(0,y.useState)(null),[ge,_e]=(0,y.useState)(0),[ve,ye]=(0,y.useState)(0),xe=(0,y.useRef)(null),P=(0,y.useRef)(null),F=(0,y.useRef)(null),I=(0,y.useRef)(null),Oe=(0,y.useRef)(null),ke=(0,y.useRef)(null),L=(0,y.useRef)(null),Ae=(0,y.useRef)(null),R=(0,y.useRef)(null),z=(0,y.useRef)(null),Me=(0,y.useRef)(-1),Ne=(0,y.useRef)(-1),B=(0,y.useRef)(`1`),V=(0,y.useRef)(0),H=(0,y.useRef)(0),U=(0,y.useRef)(`idle`),Pe=(0,y.useRef)(0),W=(0,y.useRef)(1),Fe=(0,y.useRef)(0),K=(0,y.useRef)(!0),q=(0,y.useRef)(0),Ie=(0,y.useRef)(!1),ut=(0,y.useRef)(0),dt=(0,y.useRef)(0),ft=(0,y.useRef)(0),pt=(0,y.useRef)(0),Y=(0,y.useRef)(Je),X=(0,y.useRef)(Ye),mt=(0,y.useRef)(!1),ht=(0,y.useRef)(null),gt=(0,y.useRef)(1),_t=(0,y.useRef)(()=>{}),vt=(0,y.useRef)(null),yt=(0,y.useRef)(!1),{ref:bt,playing:xt}=ie(),St=(0,y.useCallback)(e=>{P.current=e,bt(e)},[bt]),Ct=(0,y.useCallback)((e=!1)=>{if(!z.current)return;let t=performance.now();!e&&t-ft.current<33||(ft.current=t,oe(V.current))},[]),wt=(0,y.useCallback)(e=>{q.current=0;let t=R.current;if(!t)return;let n=z.current,r=yt.current,i=ut.current?Math.min(64,e-ut.current):16;ut.current=e;let a=!1;if(n){let{start:e,end:o}=n.domain,s=Math.max(1,o-e);if(U.current===`opening`){Pe.current+=i;let n=De(Pe.current);V.current=e+s*n,t.camera.tilt=Ze+(X.current-Ze)*st(n*1.15),t.camera.yaw=Y.current-1.3*(1-n)**2,a=!0,Pe.current>=6e3&&(V.current=o,U.current=`idle`,M(!1),Ct(!0))}else U.current===`play`&&(V.current+=i*s*Number(B.current)/Ke,a=!0,V.current>=o&&(V.current=o,U.current=`idle`,M(!1),Ct(!0)));let c=H.current,l=V.current-c;U.current!==`idle`||Math.abs(l)<s*2e-4?H.current=V.current:H.current=c+l*(1-Math.exp(-i/85)),H.current!==c&&(a=!0);let u=Math.abs(H.current-c)/Math.max(1,i),d=Math.min(s*.08,Math.max(s*.002,u*520)),f=d>W.current?90:420;r?W.current=s*.002:(W.current+=(d-W.current)*(1-Math.exp(-i/f)),Math.abs(d-W.current)>s*2e-4&&(a=!0))}let o=!!vt.current?.moved;if(!r&&!o&&U.current!==`opening`&&Ne.current<0&&Me.current<0&&(Y.current+=i*Qe),ht.current!==null&&!o){let e=Math.atan2(Math.sin(ht.current-Y.current),Math.cos(ht.current-Y.current));Math.abs(e)<.002||r?(Y.current=ht.current,ht.current=null):(Y.current+=e*(1-Math.exp(-i/240)),a=!0)}let s=gt.current*(Me.current>=0?nt:1);Math.abs(t.camera.zoom-s)>.001&&!r?(t.camera.zoom+=(s-t.camera.zoom)*(1-Math.exp(-i/240)),a=!0):t.camera.zoom=s,t.settling&&(a=!0),U.current!==`opening`&&(t.camera.yaw=Y.current);let c=Math.min(1,(e-Fe.current)/$e);(a||o)&&(pt.current=e);let l=e-pt.current>et?66:t.quality===3?32:48;(a||K.current||o||c<1||t.morphing||!r&&e-dt.current>=l)&&(t.draw({at:H.current,wall:e,effectWindow:W.current,effectGain:n?Math.min(1,Math.max(0,(W.current/(Math.max(1,n.domain.end-n.domain.start)*.002)-1.05)/1.6)):0,ambient:!r,fade:r?1:c,moving:U.current!==`idle`||o}),dt.current=e,K.current=!1),r||t.noteFrameInterval(i),a&&Ct(),Ie.current&&(!r||a||c<1||K.current||t.morphing)?q.current=requestAnimationFrame(wt):a||Ct(!0)},[Ct]),Z=(0,y.useCallback)(()=>{K.current=!0,Ie.current&&!q.current&&(q.current=requestAnimationFrame(wt))},[wt]),Tt=(0,y.useCallback)(()=>{let e=R.current;U.current===`opening`&&e&&(e.camera.tilt=X.current,e.camera.yaw=Y.current),U.current!==`idle`&&(U.current=`idle`,M(!1))},[]),Et=(0,y.useCallback)(e=>{let t=z.current;t&&(Tt(),V.current=Math.min(t.domain.end,Math.max(t.domain.start,e)),Ct(!0),Z())},[Ct,Tt,Z]),Dt=(0,y.useCallback)(()=>{let e=z.current;if(!e||!e.count)return;if(U.current!==`idle`){Tt(),Ct(!0),Z();return}let{start:t,end:n}=e.domain;V.current>=n-(n-t)*.002&&(V.current=t,H.current=t),U.current=`play`,M(!0),Z()},[Ct,Tt,Z]);(0,y.useLayoutEffect)(()=>{let e=xe.current;if(!e)return;let t=e.closest(`[data-feature-scroller]`);if(!t)return;let n=()=>{let n=t.clientWidth,r=Math.min(n-(n<=650?0:24)*2,1280),i=e.clientWidth;he(r>i?{width:r,offset:(i-r)/2}:{width:i,offset:0});let a=P.current;if(a){let e=a.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop,r=t.clientHeight-e-He;_e(Math.round(Math.min(Ve,Math.max(n<=650?Be:ze,r))))}};n();let r=new ResizeObserver(n);return r.observe(t),r.observe(e),()=>r.disconnect()},[]),(0,y.useLayoutEffect)(()=>{let e=F.current;if(!e)return;let t=matchMedia(`(pointer: coarse)`).matches;yt.current=_();let n;try{n=new Le(e,{quality:ot(t)})}catch{return}n.camera.yaw=Y.current,R.current=n;let r=(e=!1)=>{let r=P.current;if(!r)return;let i=r.clientWidth,a=r.clientHeight,o=i>=720,s=I.current?.offsetHeight??0,c=ke.current?.offsetHeight??0;r.style.setProperty(`--evo-controls`,`${c}px`),mt.current||(X.current=o?Ye:Xe,U.current!==`opening`&&(n.camera.tilt=X.current)),n.resize(i,a,t?1.5:2);let l=o?0:Oe.current?.offsetHeight??0;n.setInsets({top:o?18:s+10,bottom:c+4+(l?l+4:0),left:o?28:6,right:o?28:6},{animate:e&&!yt.current}),K.current=!0,Ie.current&&(q.current&&cancelAnimationFrame(q.current),q.current=0,wt(performance.now()))};r(),_t.current=r;let i=new ResizeObserver(()=>r());return P.current&&i.observe(P.current),I.current&&i.observe(I.current),ke.current&&i.observe(ke.current),()=>{i.disconnect(),R.current=null}},[wt]),(0,y.useEffect)(()=>(Ie.current=xt,xt&&(ut.current=0,Z()),()=>{Ie.current=!1,q.current&&cancelAnimationFrame(q.current),q.current=0}),[xt,Z]),(0,y.useEffect)(()=>{let e=F.current;if(!e)return;let t=e=>{!e.ctrlKey&&!e.metaKey||(e.preventDefault(),R.current&&(gt.current=Math.min(2.6,Math.max(.72,gt.current*Math.exp(-e.deltaY*.0022))),Z()))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[Z]),(0,y.useEffect)(()=>{let t=new AbortController;return T(!0),ae(``),v(e,t.signal).then(e=>{t.signal.aborted||(C(be(e)),T(!1))}).catch(e=>{t.signal.aborted||lt(e)||(ae(ct(e)),T(!1))}),()=>t.abort()},[e,t,O]);let Ot=(0,y.useMemo)(()=>{let e=S?.unit===`day`||S?.unit===`week`?{month:`short`,day:`numeric`}:{year:`numeric`,month:`short`};return new Intl.DateTimeFormat(x,e)},[x,S?.unit]),kt=(0,y.useMemo)(()=>new Intl.DateTimeFormat(x,{year:`numeric`,month:`long`,day:`numeric`}),[x]),At=(0,y.useMemo)(()=>new Intl.DateTimeFormat(x,{year:`numeric`,month:`2-digit`,day:`2-digit`}),[x]);(0,y.useEffect)(()=>{let e=R.current;e&&(e.setRingFormatter(e=>Ot.format(e)),K.current=!0)},[Ot]),(0,y.useEffect)(()=>{if(!S)return;let e=z.current,t=R.current,{start:n,end:r}=S.domain,i=r;if(e){let t=e.domain.end-e.domain.start;V.current>=e.domain.end-t*.002||(i=Math.min(r,Math.max(n,V.current))),U.current!==`idle`&&(U.current=`idle`,M(!1))}else!at&&!yt.current&&S.count>0&&(at=!0,U.current=`opening`,Pe.current=0,i=n,M(!0));z.current=S,V.current=i,H.current=i,W.current=(r-n)*.002;let a=performance.now();t?.setScene(S,{animate:!!e&&!yt.current,now:a})||(Fe.current=a),oe(i),ce(i),de(null),Ne.current=-1,Z()},[S,Z]);let Q=(0,y.useMemo)(()=>!S||!n?-1:S.indexById.get(n)??-1,[S,n]);(0,y.useEffect)(()=>{let e=R.current;Me.current=Q,e?.setSelection(Q);let t=z.current;t&&Q>=0?(ht.current=tt-t.theta[Q],V.current<t.appearAt[Q]&&Et(t.appearAt[Q])):ht.current=null,Z()},[Et,Q,Z]),(0,y.useEffect)(()=>{if(pe(null),!n)return;let e=new AbortController;return ne(n,e.signal).then(t=>{e.signal.aborted||pe(t)}).catch(()=>{}),()=>e.abort()},[n,t]);let jt=(0,y.useMemo)(()=>S&&Q>=0?we(S,Q):[],[S,Q]);(0,y.useLayoutEffect)(()=>{_t.current(!0),Z()},[jt,fe,Z]),(0,y.useEffect)(()=>{if(!n)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[role="dialog"], [data-slot="popover-content"]`)||i(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,n]),(0,y.useEffect)(()=>{if(j)return;let e=window.setTimeout(()=>ce(A),700);return()=>window.clearTimeout(e)},[A,j]),(0,y.useEffect)(()=>{let e=Ae.current;if(!e)return;let t=new ResizeObserver(()=>ye(e.clientWidth));return t.observe(e),ye(e.clientWidth),()=>t.disconnect()},[]),(0,y.useEffect)(()=>{let e=L.current;!e||!S||!ve||Re(e,S,A,ve,rt)},[A,ve,S]);let Mt=(0,y.useMemo)(()=>S?Ce(S,A):{active:0,superseded:0,archived:0,known:0},[A,S]),Nt=(0,y.useMemo)(()=>S?Ce(S,se):Mt,[se,S,Mt]),$=!!S?.count,Pt=!S||A>=S.domain.end-(S.domain.end-S.domain.start)*.002,Ft=S?kt.format(A):``,It=b(`memory:memoryEvolution.stageLabel`,{date:S?kt.format(se):``,active:Nt.active,superseded:Nt.superseded,archived:Nt.archived}),Lt=e=>b(e===`decision`?`memory:memoryEvolution.typeDecision`:e===`preference`?`memory:memoryEvolution.typePreference`:e===`fact`?`memory:memoryEvolution.typeFact`:e===`risk`?`memory:memoryEvolution.typeRisk`:e===`file`?`memory:memoryEvolution.typeFile`:e===`task`?`memory:memoryEvolution.typeTask`:`memory:memoryEvolution.typeConcept`),Rt=e=>b(e===`superseded`?`memory:memoryEvolution.superseded`:e===`archived`?`memory:memoryEvolution.archived`:e===`hidden`?`memory:memoryEvolution.notYet`:`memory:memoryEvolution.active`),zt=e=>{let t=e.target,n=!!t.closest(`[data-slot="segmented-control"], [data-slot="popover-content"]`);if(e.key===` `){if(t.closest(`button, a, [role="radio"]`))return;e.preventDefault(),Dt();return}let r=z.current;if(!r||!r.count||n)return;let i=(r.domain.end-r.domain.start)*(e.shiftKey?.05:.01),a=null;e.key===`ArrowLeft`?a=V.current-i:e.key===`ArrowRight`?a=V.current+i:e.key===`Home`?a=r.domain.start:e.key===`End`&&(a=r.domain.end),a!==null&&(e.preventDefault(),e.stopPropagation(),Et(a))},Bt=e=>{e.button===0&&(vt.current={id:e.pointerId,x:e.clientX,y:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId))},Vt=e=>{let t=R.current;if(!t)return;let n=vt.current;if(n&&n.id===e.pointerId){let r=e.clientX-n.lastX,i=e.clientY-n.lastY;if(!n.moved&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<5)return;n.moved=!0,ht.current=null,n.lastX=e.clientX,n.lastY=e.clientY,Y.current+=r*.0062,e.pointerType===`mouse`&&(mt.current=!0,X.current=Math.min(1.16,Math.max(0,X.current-i*.0042)),t.camera.tilt=X.current),U.current===`opening`&&Tt(),Ne.current=-1,t.setHover(-1),de(null),Z();return}if(e.pointerType!==`mouse`)return;let r=e.currentTarget.getBoundingClientRect(),i=e.clientX-r.left,a=e.clientY-r.top,o=t.pick(i,a,15,H.current);o!==Ne.current&&(Ne.current=o,t.setHover(o),Z()),de(o>=0?{index:o,x:i,y:a}:null)},Ht=e=>{let t=vt.current;vt.current=null;let n=R.current;if(!n||!z.current||!t||t.moved)return;let r=e.currentTarget.getBoundingClientRect(),a=n.pick(e.clientX-r.left,e.clientY-r.top,e.pointerType===`mouse`?16:28,H.current);i(a>=0?z.current.facts[a].id:null)},Ut=()=>{Ne.current>=0&&(Ne.current=-1,R.current?.setHover(-1),Z()),de(null)},Wt=()=>{let e=R.current;e&&(gt.current=1,mt.current=!1,X.current=(P.current?.clientWidth??800)>=720?Ye:Xe,e.camera.tilt=X.current,Z())},Gt=N&&S?S.facts[N.index]:null,Kt=(0,y.useMemo)(()=>{let e=new Map;fe?.item&&e.set(fe.item.id,fe.item.content);for(let t of fe?.history||[])e.set(t.id,t.content);return e},[fe]),qt=e=>(0,J.jsx)(p,{size:`sm`,className:e,"aria-label":b(`memory:memoryEvolution.speed`),value:le,onValueChange:e=>{B.current=e,ue(e)},options:qe.map(e=>({value:e,label:`${e}×`}))}),Jt=me?.width??null,Yt=(()=>{if(!N)return;let e=P.current?.clientWidth??800,t=P.current?.clientHeight??600;return{left:Math.min(e-272,N.x+16),...N.y>t-150?{bottom:t-N.y+16}:{top:N.y+16}}})();return(0,J.jsx)(`div`,{ref:xe,className:`min-w-0`,children:(0,J.jsxs)(`div`,{ref:St,role:`group`,"aria-label":b(`memory:memoryEvolution.regionLabel`),"data-memory-evolution":!0,"data-at":S?new Date(A).toISOString():void 0,"data-active-count":Mt.active,"data-playing":j||void 0,onKeyDownCapture:zt,style:{...Ue,...Jt?{width:Jt,marginLeft:me?.offset??0}:{},...ge?{height:ge}:{}},className:`@container relative isolate h-[clamp(560px,calc(100dvh-196px),880px)] overflow-hidden rounded-xl bg-[var(--evo-base)] text-content select-none max-[650px]:h-[clamp(540px,calc(100dvh-132px),780px)] max-[650px]:rounded-none`,children:[(0,J.jsx)(`canvas`,{ref:F,role:`img`,"aria-label":It,tabIndex:0,onPointerDown:Bt,onPointerMove:Vt,onPointerUp:Ht,onPointerCancel:()=>{vt.current=null},onPointerLeave:Ut,onDoubleClick:Wt,className:`absolute inset-0 size-full cursor-grab touch-pan-y outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset active:cursor-grabbing`}),(0,J.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,role:`status`,children:S&&!j?It:``}),(0,J.jsxs)(`div`,{ref:I,className:`pointer-events-none absolute top-5 left-6 z-10 flex max-w-[min(70%,420px)] flex-col gap-1.5 @max-[719px]:top-3.5 @max-[719px]:right-4 @max-[719px]:left-4 @max-[719px]:max-w-none`,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2.5`,children:[$&&(0,J.jsx)(`span`,{"data-memory-evolution-date":!0,className:`text-[30px] leading-9 font-light tracking-[-0.015em] text-content tabular-nums @max-[719px]:text-2xl @max-[719px]:leading-8`,children:Ft}),$&&Pt&&(0,J.jsx)(`span`,{className:`text-xs text-[var(--evo-active)]`,children:b(`memory:memoryEvolution.now`)})]}),$&&(0,J.jsxs)(`dl`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-content-muted tabular-nums`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-[var(--evo-active)] shadow-[0_0_8px_var(--evo-active)]`}),(0,J.jsx)(`dt`,{children:b(`memory:memoryEvolution.active`)}),(0,J.jsx)(`dd`,{"data-memory-evolution-active":!0,className:`font-medium text-content`,children:Mt.active})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:We,boxShadow:`0 0 8px ${We}`}}),(0,J.jsx)(`dt`,{children:b(`memory:memoryEvolution.superseded`)}),(0,J.jsx)(`dd`,{className:`font-medium text-content`,children:Mt.superseded})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:Ge}}),(0,J.jsx)(`dt`,{children:b(`memory:memoryEvolution.archived`)}),(0,J.jsx)(`dd`,{className:`font-medium text-content`,children:Mt.archived})]})]}),S?.truncated&&(0,J.jsx)(`p`,{className:`m-0 text-xs text-content-faint`,children:b(`memory:memoryEvolution.truncated`,{count:S.count})}),D&&S&&(0,J.jsx)(`p`,{className:`m-0 text-xs text-danger`,children:D})]}),$&&Q<0&&(0,J.jsx)(`ul`,{"aria-label":b(`memory:memoryEvolution.legend`),className:`pointer-events-none absolute top-1/2 right-6 z-10 hidden -translate-y-[62%] list-none flex-col gap-1.5 p-0 text-[11px] text-content-muted @min-[880px]:flex`,children:E.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-end gap-2`,children:[Lt(e),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full`,style:{backgroundColor:G(je[e]),boxShadow:`0 0 7px ${G(je[e])}`}})]},e))}),$&&(0,J.jsx)(`div`,{className:`absolute top-3.5 right-4 z-10 @max-[719px]:top-2.5 @max-[719px]:right-2.5`,children:(0,J.jsxs)(d,{children:[(0,J.jsx)(l,{asChild:!0,children:(0,J.jsx)(g,{variant:`ghost`,size:`icon-sm`,"aria-label":b(`memory:memoryEvolution.howToRead`),title:b(`memory:memoryEvolution.howToRead`),children:(0,J.jsx)(a,{"aria-hidden":`true`})})}),(0,J.jsxs)(u,{align:`end`,className:`w-80 gap-2 text-xs`,children:[(0,J.jsx)(`p`,{className:`m-0 leading-relaxed`,children:b(`memory:memoryEvolution.howToReadBody`)}),(0,J.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-2 gap-x-3 gap-y-1 p-0`,children:E.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-2 text-content-secondary`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full`,style:{backgroundColor:G(je[e])}}),Lt(e)]},e))}),(0,J.jsx)(`p`,{className:`m-0 leading-relaxed text-content-muted`,children:b(`memory:memoryEvolution.gestures`)})]})]})}),Gt&&N&&S&&N.index!==Q&&(0,J.jsxs)(`div`,{role:`tooltip`,"data-memory-evolution-tooltip":!0,style:Yt,className:`pointer-events-none absolute z-20 flex w-max max-w-64 flex-col gap-0.5 rounded-md border border-[var(--evo-line)] bg-[var(--evo-panel)] px-2.5 py-1.5 text-xs backdrop-blur-md`,children:[(0,J.jsx)(`strong`,{className:`line-clamp-2 font-medium text-content`,children:Gt.title}),(0,J.jsxs)(`span`,{className:`text-content-muted tabular-nums`,children:[Lt(Gt.type),` · `,At.format(S.validAt[N.index]),` ·`,` `,Rt(Se(S,N.index,A))]}),!!(S.flags[N.index]&4)&&(0,J.jsx)(`span`,{className:`text-content-muted tabular-nums`,children:b(`memory:memoryEvolution.learnedLate`,{date:At.format(S.appearAt[N.index])})})]}),S&&Q>=0&&(0,J.jsxs)(`section`,{ref:Oe,"data-memory-evolution-card":!0,"aria-label":S.facts[Q].title,className:`absolute top-14 right-4 z-20 flex max-h-[calc(100%-230px)] w-[320px] flex-col gap-2 overflow-y-auto rounded-lg border border-[var(--evo-line)] bg-[var(--evo-panel)] p-3 backdrop-blur-md @max-[719px]:top-auto @max-[719px]:right-2.5 @max-[719px]:bottom-[calc(var(--evo-controls,160px)+4px)] @max-[719px]:left-2.5 @max-[719px]:max-h-[32%] @max-[719px]:w-auto`,children:[(0,J.jsxs)(`header`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,J.jsx)(`h3`,{className:`m-0 min-w-0 text-[13px] leading-5 font-medium break-words text-content`,children:S.facts[Q].title}),(0,J.jsx)(g,{variant:`ghost`,size:`icon-sm`,className:`-mt-1 -mr-1 flex-none`,"aria-label":b(`memory:memoryEvolution.closeCard`),onClick:()=>i(null),children:(0,J.jsx)(c,{"aria-hidden":`true`})})]}),(0,J.jsxs)(`p`,{className:`m-0 flex flex-wrap gap-x-2 text-[11px] text-content-muted`,children:[(0,J.jsx)(`span`,{children:Lt(S.facts[Q].type)}),!!(S.flags[Q]&1)&&(0,J.jsx)(`span`,{children:b(`memory:memoryEvolution.pinned`)}),!!(S.flags[Q]&2)&&(0,J.jsx)(`span`,{children:b(`memory:memoryEvolution.untrusted`)}),!!(S.flags[Q]&8)&&(0,J.jsx)(`span`,{children:b(`memory:memoryEvolution.stale`)})]}),(0,J.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,children:jt.map(e=>{let t=S.facts[e],n=Se(S,e,A),r=Kt.get(t.id);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"aria-current":e===Q||void 0,onClick:()=>{Et(S.appearAt[e]),i(t.id)},className:m(`flex w-full min-w-0 flex-col gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none pointer-coarse:min-h-11`,e===Q&&`bg-surface-muted`),children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-content-muted tabular-nums`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full`,style:{backgroundColor:n===`superseded`?We:n===`archived`?Ge:G(je[t.type]??je.concept)}}),At.format(S.validAt[e]),` · `,Rt(n)]}),(0,J.jsx)(`span`,{className:`line-clamp-3 text-xs leading-[1.45] break-words text-content-soft`,children:r||t.title})]})},t.id)})})]}),S&&!$&&(0,J.jsx)(`div`,{className:`absolute inset-x-0 bottom-5 z-10 flex justify-center px-6`,children:(0,J.jsx)(te,{compact:!0,illustration:(0,J.jsx)(`span`,{}),title:b(`memory:memoryEvolution.emptyTitle`),description:b(`memory:memoryEvolution.emptyDescription`)})}),!S&&w&&(0,J.jsx)(`div`,{role:`status`,className:`absolute inset-0 z-10 grid place-items-center text-xs text-content-muted`,children:(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(h,{className:`size-4`}),b(`memory:memoryEvolution.loading`)]})}),!S&&!w&&D&&(0,J.jsx)(`div`,{className:`absolute inset-0 z-10 grid place-items-center`,children:(0,J.jsx)(ee,{kind:`error`,title:b(`memory:memoryEvolution.loadFailed`),description:D,action:(0,J.jsx)(g,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>k(e=>e+1),children:b(`memory:memoryEvolution.retry`)})})}),(0,J.jsx)(`div`,{ref:ke,className:m(`absolute inset-x-0 bottom-0 z-10 bg-gradient-to-t from-[var(--evo-scrim)] via-[var(--evo-scrim)] via-40% to-[var(--evo-scrim-clear)] px-5 pt-7 pb-3.5 @max-[719px]:px-3 @max-[719px]:pt-5 @max-[719px]:pb-3`,!$&&`invisible`),children:(0,J.jsxs)(`div`,{className:`flex items-end gap-3 @max-[719px]:flex-col @max-[719px]:items-stretch @max-[719px]:gap-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-none items-center gap-1 pb-1 @max-[719px]:order-2 @max-[719px]:justify-between @max-[719px]:pb-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(g,{variant:`ghost`,size:`icon`,"data-memory-evolution-play":!0,className:`max-[650px]:size-11`,"aria-label":b(j?`memory:memoryEvolution.pause`:`memory:memoryEvolution.play`),title:b(j?`memory:memoryEvolution.pause`:`memory:memoryEvolution.play`),disabled:!$,onClick:Dt,children:j?(0,J.jsx)(o,{"aria-hidden":`true`}):(0,J.jsx)(s,{"aria-hidden":`true`})}),(0,J.jsxs)(g,{variant:`ghost`,size:`sm`,"data-memory-evolution-now":!0,className:`aria-disabled:opacity-50 max-[650px]:h-11`,"aria-disabled":!$||Pt&&!j,onClick:()=>{S&&!(Pt&&!j)&&Et(S.domain.end)},children:[(0,J.jsx)(re,{"aria-hidden":`true`}),b(`memory:memoryEvolution.backToNow`)]})]}),qt(`hidden @max-[719px]:inline-flex`)]}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 @max-[719px]:order-1`,children:[(0,J.jsx)(`div`,{ref:Ae,"aria-hidden":`true`,style:{marginLeft:it,marginRight:it,height:rt},children:(0,J.jsx)(`canvas`,{ref:L,className:`block size-full`})}),S&&(0,J.jsx)(f,{"aria-label":b(`memory:memoryEvolution.timelineLabel`),valueText:Ft,min:0,max:1e3,step:1,value:[Ee(S.domain,A)],disabled:!$,className:`h-5 pointer-coarse:h-11 max-[650px]:h-11`,onValueChange:([e])=>Et(Te(S.domain,e))}),S&&(0,J.jsxs)(`div`,{"aria-hidden":`true`,className:`flex justify-between px-[7px] text-[11px] text-content-faint tabular-nums`,children:[(0,J.jsx)(`span`,{children:At.format(S.domain.start)}),(0,J.jsx)(`span`,{children:At.format(S.domain.end)})]})]}),qt(`mb-1 flex-none @max-[719px]:hidden`)]})})]})})}export{ut as MemoryEvolution,ut as default};
|