@opencue/cli 0.0.0-stage → 1.0.41
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/LICENSE.md +12 -0
- package/README.md +1208 -2
- package/bin/dscode.exe +12 -0
- package/bin/stt/requirements.txt +20 -0
- package/bin/stt/stt_server.py +544 -0
- package/bin/tts/requirements.txt +21 -0
- package/bin/tts/tts_server.py +404 -0
- package/cli-wrapper.cjs +109 -0
- package/install.cjs +331 -0
- package/llms.txt +115 -0
- package/package.json +56 -4
- package/scripts/figure/compose.py +363 -0
- package/scripts/figure/replay-shots.mjs +205 -0
- package/web/dist/assets/AssistantsView-dhdYVIy0.js +1 -0
- package/web/dist/assets/AutomationView-D1dU5ZV7.js +1 -0
- package/web/dist/assets/ChannelConfigView-CEPVZntU.js +8 -0
- package/web/dist/assets/ChartsView-DdN-beHW.js +1 -0
- package/web/dist/assets/ConnectorsView-CseCss9C.js +1 -0
- package/web/dist/assets/FileTreeView-Dnc3-gRF.js +1 -0
- package/web/dist/assets/HookConfigView-DA2h4HdJ.js +1 -0
- package/web/dist/assets/InputArea-DAgOOjOc.js +14 -0
- package/web/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/web/dist/assets/MemoryView-D6OUBi4-.js +1 -0
- package/web/dist/assets/MessageBubble-CCTRbIMZ.css +1 -0
- package/web/dist/assets/MessageBubble-CV16DZMG.js +453 -0
- package/web/dist/assets/ModelsView-BuqD9vWl.js +1 -0
- package/web/dist/assets/PluginsView-CIziDHFJ.js +2 -0
- package/web/dist/assets/ProjectsView-c6faWy32.js +1 -0
- package/web/dist/assets/SessionGrid-BZJHcklh.js +4 -0
- package/web/dist/assets/SessionGrid-Bk5CAXEn.css +1 -0
- package/web/dist/assets/SettingsModal-BqdGEGW-.js +4 -0
- package/web/dist/assets/SkillsView-CB6CKkmb.js +1 -0
- package/web/dist/assets/TemplatesTab-B8efVwVZ.js +1 -0
- package/web/dist/assets/ThreadsView-CDoM0aNb.js +2 -0
- package/web/dist/assets/ToolsView-BG-xsWsO.js +1 -0
- package/web/dist/assets/abnfDiagram-WEYOIA3C-DGUPHfRO.js +1 -0
- package/web/dist/assets/agentIconSet-Btsb_SC4.js +1 -0
- package/web/dist/assets/api-CCt9DRQm.js +1 -0
- package/web/dist/assets/arc-Y1ARJVZ4.js +1 -0
- package/web/dist/assets/architecture-WOLXFQ4H-BUERx_-B.js +1 -0
- package/web/dist/assets/architectureDiagram-ZHVYKT53-BPsQL7O5.js +36 -0
- package/web/dist/assets/array-BifhSqXX.js +1 -0
- package/web/dist/assets/blockDiagram-RJAE7QA3-pB7EXp6p.js +140 -0
- package/web/dist/assets/c4Diagram-XDPPPE54-BnPeCq_L.js +38 -0
- package/web/dist/assets/channel-CSrLW66f.js +1 -0
- package/web/dist/assets/channelMeta-BGQXQxgj.js +1 -0
- package/web/dist/assets/chunk-2E7WHVMD-xX282MrC.js +88 -0
- package/web/dist/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/web/dist/assets/chunk-4EMNKR2T-BAQDLVqt.js +1 -0
- package/web/dist/assets/chunk-55XCU76K-BwAE3Eqq.js +1 -0
- package/web/dist/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/web/dist/assets/chunk-7S6XSTFO-DwwaClMo.js +2 -0
- package/web/dist/assets/chunk-AQDTSKZB-DHG5Km_p.js +72 -0
- package/web/dist/assets/chunk-DSNLSHJZ-a6-B52h-.js +129 -0
- package/web/dist/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
- package/web/dist/assets/chunk-HAGFOTED-DZMcAj3o.js +62 -0
- package/web/dist/assets/chunk-HNE4Q36P-gl_4xI6B.js +1 -0
- package/web/dist/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
- package/web/dist/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/web/dist/assets/chunk-NGNAAXSQ-Bw6tHVuc.js +136 -0
- package/web/dist/assets/chunk-NQOKRVIF-B8Q-YmhL.js +213 -0
- package/web/dist/assets/chunk-UHW7PFBP-isP5lYMB.js +1 -0
- package/web/dist/assets/chunk-VQ5W62QI-Bn68syIc.js +1 -0
- package/web/dist/assets/chunk-WQQL4CDK-CdZpmEYA.js +10 -0
- package/web/dist/assets/chunk-XXDRQBXY-CnbRkih_.js +1 -0
- package/web/dist/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/web/dist/assets/chunk-YZO67HFG-DX9GhJkR.js +1 -0
- package/web/dist/assets/chunk-ZAUX2LTX-Ki22UlYp.js +1 -0
- package/web/dist/assets/chunk-ZCHMQSOR-BVj0Zx6L.js +2 -0
- package/web/dist/assets/classDiagram-v2-4MYWR3UA-C7PV1veb.js +217 -0
- package/web/dist/assets/cn-rx4uumOJ.js +1 -0
- package/web/dist/assets/common-BHXgEvgk.js +192 -0
- package/web/dist/assets/cose-bilkent-JH36ORCC-DHFtpmij.js +1 -0
- package/web/dist/assets/cynefin-EF2NZ3EQ-1rI2T0cc.js +1 -0
- package/web/dist/assets/cynefinDiagram-WF24UDRP-C8O_v8xU.js +62 -0
- package/web/dist/assets/cytoscape.esm-BY277UBX.js +321 -0
- package/web/dist/assets/dagre-NK4GIZVX-BWGoHIUd.js +4 -0
- package/web/dist/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/web/dist/assets/diagram-CBK3MWTC-kf9v35RN.js +24 -0
- package/web/dist/assets/diagram-I5XIIV2D-Ro-ig56_.js +24 -0
- package/web/dist/assets/diagram-ODIL2UCW-CtGga01G.js +30 -0
- package/web/dist/assets/diagram-PFBEJUXE-C14lcR-6.js +3 -0
- package/web/dist/assets/diagram-RJA3I4VV-BBbqaSKU.js +41 -0
- package/web/dist/assets/diagram-TYUNFSNR-BynvjQsr.js +200 -0
- package/web/dist/assets/dist-CumnGVmJ.js +1 -0
- package/web/dist/assets/ebnfDiagram-V4P3TTPT-BdqUCZnk.js +1 -0
- package/web/dist/assets/elk-QONTBCTQ-CYCP_9Jy.js +27 -0
- package/web/dist/assets/erDiagram-KYQIGQAA-C3L55l_F.js +99 -0
- package/web/dist/assets/eventmodeling-K75KTNOO-CTQdA_1v.js +1 -0
- package/web/dist/assets/flowDiagram-IUGLLWBU-COLKOzBg.js +1 -0
- package/web/dist/assets/ganttDiagram-R7GPNTJY-Be4Qk8Hx.js +292 -0
- package/web/dist/assets/gitGraph-VSP46ZUC-B59HXvj1.js +1 -0
- package/web/dist/assets/gitGraphDiagram-PDYL7XHY-C2A0VA6q.js +106 -0
- package/web/dist/assets/graphlib-DS17s2tU.js +1 -0
- package/web/dist/assets/icons-BvYhTENi.js +1 -0
- package/web/dist/assets/index-BNI6CNsY.css +1 -0
- package/web/dist/assets/index-BX-d2OBW.js +130 -0
- package/web/dist/assets/info-OHQRW6UA-DWlkKvmi.js +1 -0
- package/web/dist/assets/infoDiagram-MVDRKAX5-B8e6dTjN.js +2 -0
- package/web/dist/assets/init-C-OQMol4.js +1 -0
- package/web/dist/assets/ishikawaDiagram-HPEHV2GE-udXPYi9H.js +70 -0
- package/web/dist/assets/journeyDiagram-BOSHW7O7-DTyDkf5d.js +139 -0
- package/web/dist/assets/kanban-definition-FNSA4HC5-BXgV20qe.js +89 -0
- package/web/dist/assets/katex-B940_AAO.js +257 -0
- package/web/dist/assets/line-DVabuQAu.js +1 -0
- package/web/dist/assets/linear-gLkGxN9m.js +1 -0
- package/web/dist/assets/markdown-DAQZeY5V.js +14 -0
- package/web/dist/assets/mermaid-parser.core-BrXnuEs7.js +7 -0
- package/web/dist/assets/mermaid.core-BGbz3k1k.js +44 -0
- package/web/dist/assets/mindmap-definition-6OY57UG3-DbtP-bmk.js +98 -0
- package/web/dist/assets/ordinal-BDEzSJ7C.js +1 -0
- package/web/dist/assets/packet-JDAUHWVQ-iW8w3JF5.js +1 -0
- package/web/dist/assets/panels-DYiQiVWh.js +1 -0
- package/web/dist/assets/path-fybaL0A-.js +1 -0
- package/web/dist/assets/pegDiagram-ECIUJNBX-rBWJbaq4.js +1 -0
- package/web/dist/assets/pie-XZMESJXO-KHXEq-Yx.js +1 -0
- package/web/dist/assets/pieDiagram-GNMPY74T-DsW7yHm0.js +39 -0
- package/web/dist/assets/preload-helper-BLdHbfdN.js +1 -0
- package/web/dist/assets/profileChange-xrd7jkii.js +1 -0
- package/web/dist/assets/quadrantDiagram-D57K4MC3-DF_pwNhM.js +7 -0
- package/web/dist/assets/radar-ABXABTNO-BkAUJ_Zd.js +1 -0
- package/web/dist/assets/railroad-I3PHUGI6-BdnWRdGt.js +1 -0
- package/web/dist/assets/railroad-abnf-LNEFI6M7-C8K36-8b.js +1 -0
- package/web/dist/assets/railroad-ebnf-DWYD2UWJ-BlS25T3f.js +1 -0
- package/web/dist/assets/railroad-peg-JR7BVNR7-CBKGDi75.js +1 -0
- package/web/dist/assets/railroadDiagram-Y72NRBL7-DmrlMIvv.js +1 -0
- package/web/dist/assets/react-vendor-BlngCquv.js +19 -0
- package/web/dist/assets/requirementDiagram-EQYSW5RA-cvUq9H3I.js +84 -0
- package/web/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
- package/web/dist/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/web/dist/assets/sankeyDiagram-SY24JHO5-BdxXAbER.js +40 -0
- package/web/dist/assets/sequenceDiagram-BLEHNHQU-Druumi0k.js +169 -0
- package/web/dist/assets/settingsStore-RLUAWgIk.js +1 -0
- package/web/dist/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
- package/web/dist/assets/src-49LUQhkG.js +1 -0
- package/web/dist/assets/src-BWF7jMDv.js +1 -0
- package/web/dist/assets/state-_ZfNVAsd.js +1 -0
- package/web/dist/assets/stateDiagram-v2-A6IESKWZ-Jgh6qlrr.js +291 -0
- package/web/dist/assets/sttLanguages-aqoVC79g.js +2 -0
- package/web/dist/assets/swimlanes-B3ENRKFQ-4xKumvXQ.js +1 -0
- package/web/dist/assets/swimlanesDiagram-AYQRV4AK-bHcLKL3d.js +8 -0
- package/web/dist/assets/timeline-definition-JXYKGLGB-BYKhga9x.js +120 -0
- package/web/dist/assets/treeView-D4JQ5SDB-6-eTVUuH.js +1 -0
- package/web/dist/assets/treemap-SAJKECNS-Dxl8yCLE.js +1 -0
- package/web/dist/assets/ttsSettings-DHo3OsOq.js +15 -0
- package/web/dist/assets/types-JssxRFJn.js +1 -0
- package/web/dist/assets/useTranslation-BGmCDuQI.js +1 -0
- package/web/dist/assets/usecaseDiagram-WPOLBNNX-BaQ8nAv9.js +328 -0
- package/web/dist/assets/vennDiagram-Q3Y3IDCW-DkPvfmfT.js +34 -0
- package/web/dist/assets/wardley-7MLQ67FV-CZtI22aa.js +1 -0
- package/web/dist/assets/wardleyDiagram-IVAIDKWA-Dgi2OWQ4.js +78 -0
- package/web/dist/assets/websocket-C9e3h7VU.js +1 -0
- package/web/dist/assets/whatsNewStore-Bf_7lW8o.js +1 -0
- package/web/dist/assets/workspaceSemantics-RaIRer76.js +3 -0
- package/web/dist/assets/xychartDiagram-4URNHDU4-Ch96dep-.js +7 -0
- package/web/dist/favicon.svg +19 -0
- package/web/dist/fonts/OFL-Inter.txt +93 -0
- package/web/dist/fonts/inter-latin-400-normal.woff2 +0 -0
- package/web/dist/fonts/inter-latin-600-normal.woff2 +0 -0
- package/web/dist/icons/icon-1024.png +0 -0
- package/web/dist/icons/icon-180.png +0 -0
- package/web/dist/icons/icon-192.png +0 -0
- package/web/dist/icons/icon-512.png +0 -0
- package/web/dist/icons/icon-maskable-512.png +0 -0
- package/web/dist/index.html +90 -0
- package/web/dist/logo.svg +26 -0
- package/web/dist/manifest.webmanifest +16 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,C as n,J as r,Ur as i,Vn as a,_ as o,g as s,ln as c,m as l,n as u,ot as d,p as f,t as p,v as m,vr as h,wn as g,x as _,xr as v,yr as ee}from"./icons-BvYhTENi.js";import{t as y}from"./useTranslation-BGmCDuQI.js";import{t as b}from"./cn-rx4uumOJ.js";import{t as x}from"./api-CCt9DRQm.js";import{I as S}from"./markdown-DAQZeY5V.js";import{A as C,a as w,c as T,f as te,h as ne,m as re,o as E,s as ie}from"./common-BHXgEvgk.js";var D=e(i(),1),O=S();function ae(){let{t:e}=y(),[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)(!0),[o,s]=(0,D.useState)(null),[f,p]=(0,D.useState)(null),[m,h]=(0,D.useState)(!1),[g,_]=(0,D.useState)({skillName:``,description:``,trigger:``,content:``}),[ee,b]=(0,D.useState)(!1),[S,w]=(0,D.useState)(null),T=(0,D.useCallback)(async()=>{a(!0);try{let e=await x.skills.workshop.list();r(e.data??[]),s(null)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,D.useEffect)(()=>{T()},[T]);let te=async e=>{p(e);try{await x.skills.workshop.apply(e),await T()}catch(e){s(e instanceof Error?e.message:String(e))}finally{p(null)}},ne=async e=>{p(e);try{await x.skills.workshop.reject(e),await T()}catch(e){s(e instanceof Error?e.message:String(e))}finally{p(null)}};return(0,O.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar pe-1 space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-dark-muted`,children:e(`skills.workshopHint`)||`技能提案:从会话/手动生成,审核后一键应用为技能`}),(0,O.jsx)(C,{variant:`accent`,leftIcon:(0,O.jsx)(d,{size:14}),onClick:()=>{h(e=>!e),w(null)},children:e(`skills.workshopPropose`)||`新建提案`})]}),m&&(0,O.jsxs)(`div`,{className:`rounded-xl border border-dark-border bg-dark-surface p-3 space-y-2`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,O.jsx)(`input`,{value:g.skillName,onChange:e=>_(t=>({...t,skillName:e.target.value})),placeholder:e(`skills.workshopName`)||`技能名 (skill-name) 如 format-json`,className:`px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue text-sm`}),(0,O.jsx)(`input`,{value:g.trigger,onChange:e=>_(t=>({...t,trigger:e.target.value})),placeholder:e(`skills.workshopTrigger`)||`触发关键词(可选)`,className:`px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue text-sm`})]}),(0,O.jsx)(`input`,{value:g.description,onChange:e=>_(t=>({...t,description:e.target.value})),placeholder:e(`skills.workshopDescription`)||`一句话描述`,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue text-sm`}),(0,O.jsx)(`textarea`,{value:g.content,onChange:e=>_(t=>({...t,content:e.target.value})),placeholder:e(`skills.workshopContent`)||`技能正文(系统提示 / 工作流指令)`,rows:5,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue text-sm resize-y`}),S&&(0,O.jsx)(`div`,{className:`text-xs text-accent-red`,children:S}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,O.jsx)(`button`,{onClick:()=>h(!1),className:`px-3 py-1.5 rounded-lg text-sm border border-dark-border hover:bg-dark-hover`,children:e(`common.cancel`)||`取消`}),(0,O.jsx)(C,{variant:`accent`,leftIcon:(0,O.jsx)(v,{size:14}),loading:ee,onClick:async()=>{if(!g.skillName.trim()||!g.content.trim())w(e(`skills.workshopFormRequired`)||`skillName and content are required`);else{b(!0),w(null);try{await x.skills.workshop.propose({skillName:g.skillName.trim(),description:g.description.trim(),trigger:g.trigger.trim(),content:g.content.trim(),reason:`manual proposal`}),_({skillName:``,description:``,trigger:``,content:``}),h(!1),await T()}catch(e){w(e instanceof Error?e.message:String(e))}finally{b(!1)}}},children:e(`skills.workshopSubmit`)||`提交提案`})]})]}),o&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-accent-red/10 text-accent-red text-sm`,children:[(0,O.jsx)(l,{size:14,className:`shrink-0`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1`,children:o}),(0,O.jsx)(`button`,{onClick:()=>s(null),className:`shrink-0 p-0.5 rounded hover:bg-dark-hover`,children:(0,O.jsx)(u,{size:14})})]}),i?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,O.jsx)(t,{size:24,className:`animate-spin text-accent-blue`})}):n.length===0?(0,O.jsx)(`div`,{className:`text-sm text-dark-muted py-10 text-center`,children:e(`skills.workshopEmpty`)||`暂无技能提案`}):n.map(t=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-dark-border bg-dark-surface p-3 space-y-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(c,{size:14,className:`text-accent-blue shrink-0`}),(0,O.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.skillName}),(0,O.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full shrink-0 ${t.status===`applied`?`bg-accent-green/15 text-accent-green`:t.status===`rejected`?`bg-dark-hover text-dark-muted`:`bg-accent-yellow/15 text-accent-yellow`}`,children:t.status})]}),(0,O.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:t.status===`pending`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`button`,{onClick:()=>te(t.id),disabled:f===t.id,className:`px-2 py-1 bg-accent-green text-accent-fg rounded text-xs flex items-center gap-1 disabled:opacity-50`,children:[(0,O.jsx)(v,{size:12}),e(`skills.workshopApply`)||`应用`]}),(0,O.jsx)(`button`,{onClick:()=>ne(t.id),disabled:f===t.id,className:`px-2 py-1 rounded text-xs border border-dark-border hover:bg-dark-hover disabled:opacity-50`,children:(0,O.jsx)(u,{size:12})})]})})]}),t.description&&(0,O.jsx)(`div`,{className:`text-xs text-dark-muted truncate`,children:t.description}),t.trigger&&(0,O.jsxs)(`div`,{className:`text-xs text-accent-blue`,children:[`trigger: `,t.trigger]}),(0,O.jsx)(`div`,{className:`text-xs text-dark-muted line-clamp-3 whitespace-pre-wrap`,children:t.content}),(0,O.jsxs)(`div`,{className:`text-meta text-dark-muted/70 flex items-center justify-between`,children:[(0,O.jsx)(`span`,{children:t.reason}),(0,O.jsx)(`span`,{children:new Date(t.createdAt).toLocaleString()})]})]},t.id))]})}var oe=/^(https?:|data:)/i;function k({icon:e,className:t=`w-4 h-4 rounded object-cover shrink-0`}){return e&&oe.test(e)?(0,O.jsx)(`img`,{src:e,alt:``,loading:`lazy`,className:t}):(0,O.jsx)(`span`,{children:e||`⭐`})}function se({marketplaces:e,value:t,onChange:n}){let{t:r}=y(),i=Array.from(new Map(e.filter(e=>e.domain).map(e=>[e.domain,e.domainIcon||`📁`])).entries());return i.length===0?null:(0,O.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[{id:``,icon:`🗂️`},...i.map(([e,t])=>({id:e,icon:t}))].map(e=>(0,O.jsxs)(`button`,{onClick:()=>n(e.id),className:`flex items-center gap-1 px-2.5 py-1 rounded-full border text-xs transition-colors ${t===e.id?`border-accent-blue bg-accent-blue/15 text-accent-blue`:`border-dark-border bg-dark-surface text-dark-muted hover:bg-dark-hover`}`,children:[(0,O.jsx)(k,{icon:e.icon,className:`w-3.5 h-3.5 rounded-sm object-cover shrink-0`}),(0,O.jsx)(`span`,{children:e.id||r(`skills.marketDomainAll`)})]},e.id||`__all__`))})}function ce({id:e,installed:t=!0,className:n}){let{t:r}=y(),{configured:i,settingFor:a,effectiveFor:o}=E(`skills`);if(!i)return null;let s=a(e),c=o(e),l=s===`inherit`&&!c,u=r(s===`inherit`?l?`settings.kindCapability.excluded`:`settings.kindCapability.inherit`:`settings.kindCapability.${s}`);return(0,O.jsxs)(`span`,{title:r(`settings.kindCapability.hint`),className:b(`inline-flex w-fit items-center gap-1 rounded-full border px-2 py-0.5 text-xs`,s===`allow`&&`border-accent-green/40 bg-accent-green/15 text-accent-green`,s===`deny`&&`border-accent-red/40 bg-accent-red/15 text-accent-red`,s===`inherit`&&!l&&`border-dark-border text-dark-muted`,l&&`border-dark-border text-dark-tertiary line-through`,n),children:[(0,O.jsx)(`span`,{children:u}),!t&&(0,O.jsx)(`span`,{className:`text-dark-tertiary no-underline`,children:r(`skills.kindTagUninstalled`)})]})}function le({ids:e,className:t}){let{t:n}=y(),r=T(e=>e.kinds),i=T(e=>e.activeKind),{configured:a,effectiveFor:o}=E(`skills`);if(e.length===0)return null;let s=r.find(e=>e.id===i),c=s?s.labelKey?n(s.labelKey):s.id:i||`—`,l=e.filter(e=>o(e)).length;return(0,O.jsxs)(`p`,{className:b(`text-xs`,a?`text-dark-muted`:`text-dark-tertiary`,t),children:[a?n(`skills.kindAvailabilityNarrowed`,{kind:c,available:l,total:e.length}):n(`skills.kindAvailabilityInherit`,{kind:c,total:e.length}),(0,O.jsx)(`span`,{className:`ms-1 text-dark-tertiary`,children:n(`skills.kindAvailabilityHint`)})]})}function ue({index:e,children:t}){let n=T(e=>e.activeKind),r=Math.min(e,10)*70;return(0,O.jsx)(`div`,{className:`animate-fade-in h-full [&>*]:h-full`,style:{animationDelay:`${r}ms`},children:t},n)}var A={id:``,name:``,description:``,category:``,trigger:``,systemPrompt:``,injection:`lazy`,tags:``,requiredTools:``},j=8;function de({onUseSkill:e}){let{t:i}=y(),[b,S]=(0,D.useState)(`marketplace`),[T,E]=(0,D.useState)([]),[oe,de]=(0,D.useState)(!0),[pe,N]=(0,D.useState)(null),[P,me]=(0,D.useState)(``),[he,F]=(0,D.useState)(!1),[I,ge]=(0,D.useState)(null),[_e,ve]=(0,D.useState)(!1),[ye,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(A),[be,xe]=(0,D.useState)(!1),[Se,Ce]=(0,D.useState)(!1),[we,B]=(0,D.useState)(null),V=(0,D.useRef)(null),[H,U]=(0,D.useState)([]),[Te,W]=(0,D.useState)([]),[Ee,G]=(0,D.useState)({}),[De,K]=(0,D.useState)(!1),[Oe,q]=(0,D.useState)(null),[ke,Ae]=(0,D.useState)(null),[je,Me]=(0,D.useState)({}),[Ne,Pe]=(0,D.useState)({}),[Fe,Ie]=(0,D.useState)({}),[J,Le]=(0,D.useState)(``),[Y,Re]=(0,D.useState)(``),[ze,Be]=(0,D.useState)(``),[Ve,He]=(0,D.useState)(!1),[X,Ue]=(0,D.useState)(null),Z=(0,D.useMemo)(()=>T.filter(e=>e.source===`marketplace`||e.provenance===`marketplace`),[T]),We=(0,D.useMemo)(()=>T.filter(e=>e.source!==`marketplace`&&e.provenance!==`marketplace`),[T]),Ge=e=>{let t=Ee[e]?.skills||[];return Math.max(1,Math.ceil(t.length/j))},Ke=(e,t)=>{Me(n=>({...n,[e]:Math.max(0,Math.min(Ge(e)-1,t))}))},qe=async()=>{K(!0),q(null);let e=await x.skills.marketplaces.list();e.success?(U(e.data?.marketplaces||[]),W(e.data?.installed||[]),G(e.data?.indexes||{}),K(!1)):(q(e.error||i(`skills.loadMarketplaceFail`)),K(!1))},Je=async()=>{let e=Y.trim();if(!e)return;He(!0),q(null);let t=await x.skills.marketplaces.add({url:e,name:ze.trim()||void 0});if(t.success&&t.data){Re(``),Be(``);let e=t.data.marketplace;U(t=>[...t.filter(t=>t.id!==e.id),e]),G(n=>({...n,[e.id]:t.data.index}))}else q(t.error||i(`skills.addFail`));He(!1)},Ye=async e=>{q(null);let t=await x.skills.marketplaces.refresh(e);t.success&&t.data?G(n=>({...n,[e]:t.data.index})):q(t.error||i(`skills.loadMarketplaceFail`))},Xe=async e=>{await x.skills.marketplaces.remove(e),U(t=>t.filter(t=>t.id!==e)),G(t=>{let n={...t};return delete n[e],n})},Ze=async(e,t)=>{Ae(t),q(null);let n=await x.skills.marketplaces.install(e,t);n.success&&n.data?(W(e=>[...e.filter(e=>e!==n.data.id),n.data.id]),await Q()):q(n.error||i(`skills.installFail`)),Ae(null)},Qe=async e=>{q(null);let t=await x.skills.delete(e);t.success?(W(t=>t.filter(t=>t!==e)),await Q()):q(t.error||i(`skills.uninstallFail`)),Ue(null)},Q=async()=>{de(!0),N(null);let e=await x.skills.list();if(e.success){let t=Array.isArray(e.data)?e.data:[];E(t),e.data!==null&&e.data!==void 0&&!Array.isArray(e.data)&&N(`服务端返回的技能数据格式异常`)}else N(e.error||i(`skills.loadFailedFallback`));de(!1)};(0,D.useEffect)(()=>{Q(),qe()},[]);let $e=(0,D.useMemo)(()=>{let e=P.trim().toLowerCase();return e?We.filter(t=>[t.id,t.name,t.description,t.category,...t.tags||[]].join(` `).toLowerCase().includes(e)):We},[We,P]),et=()=>{ge(null),z(A),L(null),F(!0)},tt=e=>{ge(e.id),z({id:e.id,name:e.name,description:e.description,category:e.category,trigger:e.trigger||``,systemPrompt:e.systemPrompt||``,injection:e.injection||`lazy`,tags:(e.tags||[]).join(`, `),requiredTools:(e.requiredTools||[]).join(`, `)}),L(null),F(!0)},nt=async()=>{let e=R.id.trim();if(!e){L(i(`skills.fieldId`)+` is required`);return}ve(!0),L(null);let t={id:e,name:R.name.trim(),description:R.description.trim(),category:R.category.trim(),trigger:R.trigger.trim(),systemPrompt:R.systemPrompt,injection:R.injection.trim(),tags:fe(R.tags),requiredTools:fe(R.requiredTools)},n=I?await x.skills.update(I,t):await x.skills.create(t);n.success?(F(!1),ge(null),z(A),await Q()):L(n.error||i(`skills.save`)),ve(!1)},rt=async e=>{(await x.skills.toggle(e.id,!e.enabled)).success&&E(t=>t.map(t=>t.id===e.id?{...t,enabled:!t.enabled}:t))},it=async e=>{Ce(!0),B(null);try{let t=await e.text(),n=await x.skills.import({fileName:e.name,content:t});n.success?(xe(!1),await Q()):B(n.error||i(`skills.import`))}catch(e){B(e instanceof Error?e.message:i(`skills.import`))}finally{Ce(!1),V.current&&(V.current.value=``)}};if(oe)return(0,O.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,role:`status`,children:(0,O.jsx)(te,{count:5})});if(pe)return(0,O.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,O.jsxs)(`div`,{className:`text-center`,children:[(0,O.jsx)(l,{size:32,className:`mx-auto mb-2 text-accent-red`}),(0,O.jsx)(`p`,{className:`text-accent-red mb-4`,children:pe}),(0,O.jsx)(C,{variant:`accent`,onClick:Q,children:i(`skills.retry`)})]})});let $=e=>`flex items-center gap-2 px-4 py-1.5 rounded-lg text-sm font-medium transition-colors ${e?`bg-accent-blue/20 text-accent-blue`:`text-dark-muted hover:bg-dark-hover`}`;return(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden p-4 gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2 shrink-0`,children:[(0,O.jsx)(_,{size:20}),i(`skills.title`),(0,O.jsxs)(`span`,{className:`text-sm font-normal text-dark-muted`,children:[`(`,T.length,`)`]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-1 bg-dark-surface border border-dark-border rounded-xl p-1`,children:[(0,O.jsxs)(`button`,{onClick:()=>S(`marketplace`),className:$(b===`marketplace`),children:[(0,O.jsx)(n,{size:14}),i(`skills.marketplaceTab`)]}),(0,O.jsxs)(`button`,{onClick:()=>S(`mine`),className:$(b===`mine`),children:[(0,O.jsx)(_,{size:14}),i(`skills.mineTab`)]}),(0,O.jsxs)(`button`,{onClick:()=>S(`installed`),className:$(b===`installed`),children:[(0,O.jsx)(v,{size:14}),i(`skills.installedTab`),(0,O.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full bg-dark-bg border border-dark-border`,children:Z.length})]}),(0,O.jsxs)(`button`,{onClick:()=>S(`workshop`),className:$(b===`workshop`),children:[(0,O.jsx)(c,{size:14}),i(`skills.workshopTab`)]})]})]}),(0,O.jsx)(ie,{slot:i(`nav.skills`)}),Oe&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-accent-red/10 text-accent-red text-sm`,children:[(0,O.jsx)(l,{size:14,className:`shrink-0`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1`,children:Oe}),(0,O.jsx)(`button`,{onClick:()=>q(null),className:`shrink-0 p-0.5 rounded hover:bg-dark-hover`,children:(0,O.jsx)(u,{size:14})})]}),b===`marketplace`&&(0,O.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar pe-1 space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{value:Y,onChange:e=>Re(e.target.value),placeholder:i(`skills.marketplaceUrlPlaceholder`),className:`flex-1 px-3 py-2 rounded-lg bg-dark-surface border border-dark-border outline-none focus:border-accent-blue text-sm`}),(0,O.jsx)(`input`,{value:ze,onChange:e=>Be(e.target.value),placeholder:i(`skills.marketplaceName`),className:`w-40 px-3 py-2 rounded-lg bg-dark-surface border border-dark-border outline-none focus:border-accent-blue text-sm`}),(0,O.jsx)(C,{variant:`accent`,onClick:Je,disabled:!Y.trim(),loading:Ve,leftIcon:(0,O.jsx)(d,{size:14}),children:i(Ve?`skills.adding`:`skills.addMarketplace`)})]}),(0,O.jsx)(`div`,{className:`text-xs text-dark-muted`,children:i(`skills.marketplaceHint`)}),(0,O.jsx)(se,{marketplaces:H,value:J,onChange:Le}),De?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,O.jsx)(t,{size:24,className:`animate-spin text-accent-blue`})}):(0,O.jsxs)(O.Fragment,{children:[H.length===0&&(0,O.jsx)(`div`,{className:`text-sm text-dark-muted py-10 text-center`,children:i(`skills.noMarketplaces`)}),H.filter(e=>!J||e.domain===J).map(e=>{let n=Ee[e.id],r=n?.skills||[],o=(Ne[e.id]||``).trim().toLowerCase(),s=Fe[e.id]||``,c=Array.from(new Set(r.map(e=>e.category).filter(Boolean))).sort(),l=r.filter(e=>(!o||[e.name,e.id,e.description,...e.tags||[]].join(` `).toLowerCase().includes(o))&&(!s||e.category===s)),d=Math.max(1,Math.ceil(l.length/j)),f=Math.min(je[e.id]||0,d-1),p=l.slice(f*j,(f+1)*j),m=o||s?`${l.length}/${r.length}`:String(r.length);return(0,O.jsxs)(`div`,{className:`border border-dark-border rounded-lg overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`px-3 py-2 border-b border-dark-border bg-dark-surface flex items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`font-medium flex items-center gap-2`,children:[e.builtin&&(0,O.jsx)(`span`,{className:`text-badge px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue`,children:i(`skills.presets`)}),(0,O.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,O.jsx)(`div`,{className:`text-xs text-dark-muted truncate`,children:e.url})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,O.jsx)(`span`,{className:`text-xs text-dark-muted whitespace-nowrap`,children:i(`skills.skillCount`,{count:m})}),(0,O.jsx)(`button`,{onClick:()=>Ye(e.id),className:`p-1.5 rounded hover:bg-dark-hover`,title:i(`skills.refreshMarketplace`),children:(0,O.jsx)(t,{size:14})}),!e.builtin&&(0,O.jsx)(`button`,{onClick:()=>Xe(e.id),className:`p-1.5 rounded hover:bg-dark-hover text-accent-red`,title:i(`skills.removeMarketplace`),children:(0,O.jsx)(u,{size:14})})]})]}),n?.error?(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 bg-accent-red/10 text-accent-red text-xs`,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate`,title:n.error,children:i(`skills.marketplaceError`,{error:n.error})}),(0,O.jsxs)(`button`,{onClick:()=>Ye(e.id),className:`flex items-center gap-1 px-2 py-1 rounded bg-dark-surface border border-dark-border whitespace-nowrap shrink-0`,children:[(0,O.jsx)(t,{size:12}),i(`skills.retryMarket`)]})]}):r.length===0?(0,O.jsx)(`div`,{className:`text-xs text-dark-muted py-4 text-center`,children:i(`skills.noSkillsInMarket`)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-dark-border/60 bg-dark-surface/40`,children:[(0,O.jsx)(`input`,{value:Ne[e.id]||``,onChange:t=>Pe(n=>({...n,[e.id]:t.target.value})),placeholder:i(`skills.marketFilterPlaceholder`),className:`flex-1 px-2.5 py-1.5 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue text-xs`}),c.length>1&&(0,O.jsxs)(`select`,{value:Fe[e.id]||``,onChange:t=>Ie(n=>({...n,[e.id]:t.target.value})),className:`px-2.5 py-1.5 rounded-lg bg-dark-bg border border-dark-border outline-none text-xs`,children:[(0,O.jsx)(`option`,{value:``,children:i(`skills.marketCategoryAll`)}),c.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))]})]}),(0,O.jsx)(le,{ids:l.map(e=>e.id),className:`px-3 pt-2`}),l.length===0?(0,O.jsx)(`div`,{className:`text-xs text-dark-muted py-4 text-center`,children:i(`skills.noSkillsInMarket`)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2 p-3`,children:p.map((n,r)=>{let o=Te.includes(n.id),s=ke===n.id;return(0,O.jsx)(ue,{index:r,children:(0,O.jsxs)(`div`,{className:`border border-dark-border rounded-lg p-3 flex flex-col gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,O.jsxs)(`span`,{className:`font-medium text-sm truncate`,children:[(0,O.jsx)(k,{icon:n.icon}),` `,n.name]}),n.risk===`critical`&&(0,O.jsx)(`span`,{className:`text-badge px-1.5 py-0.5 rounded bg-accent-red/20 text-accent-red shrink-0`,children:i(`skills.riskCritical`)})]}),(0,O.jsxs)(`div`,{className:`text-xs text-dark-muted truncate`,children:[n.category,n.author?` · ${n.author}`:``,n.version?` · v${n.version}`:``]})]}),(0,O.jsxs)(`button`,{disabled:o||s,onClick:()=>Ze(e.id,n.id),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium whitespace-nowrap shrink-0 disabled:opacity-60 ${o?`bg-accent-green/20 text-accent-green`:`bg-accent-blue text-accent-fg hover:bg-accent-blue/80`}`,children:[o?(0,O.jsx)(v,{size:12}):s?(0,O.jsx)(t,{size:12,className:`animate-spin`}):(0,O.jsx)(a,{size:12}),i(o?`skills.installed`:s?`skills.installing`:`skills.installSkill`)]})]}),n.description&&(0,O.jsx)(`p`,{className:`text-xs text-dark-muted line-clamp-2`,children:n.description}),(0,O.jsx)(ce,{id:n.id,installed:o,className:`mt-auto`})]})},n.id)})}),d>1&&(0,O.jsxs)(`div`,{className:`flex items-center justify-center gap-3 pb-3 text-xs text-dark-muted`,children:[(0,O.jsxs)(`button`,{disabled:f<=0,onClick:()=>Ke(e.id,f-1),className:`flex items-center gap-1 px-2 py-1 rounded border border-dark-border hover:bg-dark-hover disabled:opacity-40`,children:[(0,O.jsx)(ee,{size:14}),i(`skills.pagePrev`)]}),(0,O.jsx)(`span`,{className:`whitespace-nowrap`,children:i(`skills.pageOf`,{page:f+1,total:d})}),(0,O.jsxs)(`button`,{disabled:f>=d-1,onClick:()=>Ke(e.id,f+1),className:`flex items-center gap-1 px-2 py-1 rounded border border-dark-border hover:bg-dark-hover disabled:opacity-40`,children:[i(`skills.pageNext`),(0,O.jsx)(h,{size:14})]})]})]})]})]},e.id)})]})]}),b===`installed`&&(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar pe-1`,children:Z.length===0?(0,O.jsxs)(`div`,{className:`text-center py-16 text-dark-muted`,children:[(0,O.jsx)(`p`,{className:`mb-1`,children:i(`skills.emptyInstalled`)}),(0,O.jsx)(`p`,{className:`text-xs mb-4`,children:i(`skills.emptyInstalledHint`)}),(0,O.jsx)(C,{variant:`accent`,leftIcon:(0,O.jsx)(n,{size:14}),onClick:()=>S(`marketplace`),children:i(`skills.browseMarket`)})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(le,{ids:Z.map(e=>e.id),className:`px-1 pb-2`}),(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:Z.map((t,n)=>(0,O.jsx)(ue,{index:n,children:(0,O.jsxs)(`div`,{className:`border border-dark-border rounded-lg p-3 flex flex-col gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`font-medium text-sm truncate`,children:[(0,O.jsx)(k,{icon:t.icon}),` `,t.name]}),(0,O.jsxs)(`div`,{className:`text-xs text-dark-muted truncate`,children:[t.id,` · `,t.category]})]}),(0,O.jsxs)(`button`,{onClick:()=>rt(t),className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shrink-0 transition-colors ${t.enabled?`bg-accent-green/20 text-accent-green hover:bg-accent-green/30`:`bg-accent-red/20 text-accent-red hover:bg-accent-red/30`}`,title:t.enabled?i(`skills.disable`):i(`skills.enable`),children:[t.enabled?(0,O.jsx)(o,{size:14}):(0,O.jsx)(m,{size:14}),t.enabled?i(`skills.enabled`):i(`skills.disabled`)]})]}),t.description&&(0,O.jsx)(`p`,{className:`text-xs text-dark-muted line-clamp-2`,children:t.description}),(0,O.jsx)(ce,{id:t.id}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-auto`,children:[(0,O.jsx)(`span`,{className:`text-badge px-1.5 py-0.5 rounded bg-dark-bg border border-dark-border text-dark-muted truncate`,children:t.marketplace||t.source||i(`skills.marketplace`)}),(0,O.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[e&&(0,O.jsxs)(`button`,{onClick:()=>e(t),className:`flex items-center gap-1 px-2 py-1 rounded bg-accent-blue/15 text-accent-blue text-xs hover:bg-accent-blue/25 transition-colors`,title:i(`skills.useHint`),children:[(0,O.jsx)(p,{size:12}),i(`skills.use`)]}),(0,O.jsxs)(`button`,{onClick:()=>tt(t),className:`flex items-center gap-1 px-2 py-1 rounded border border-dark-border text-xs hover:bg-dark-hover`,children:[(0,O.jsx)(r,{size:12}),i(`skills.edit`)]}),(0,O.jsxs)(`button`,{onClick:()=>Ue(t.id),className:`flex items-center gap-1 px-2 py-1 rounded border border-dark-border text-accent-red text-xs hover:bg-accent-red/10`,children:[(0,O.jsx)(s,{size:12}),i(`skills.uninstall`)]})]})]})]})},t.id))})]})}),b===`workshop`&&(0,O.jsx)(ae,{}),b===`mine`&&(0,O.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,O.jsx)(`input`,{value:P,onChange:e=>me(e.target.value),placeholder:`Search skills`,className:`w-56 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg text-sm outline-none focus:border-accent-blue`}),(0,O.jsx)(`span`,{className:`text-sm text-dark-muted shrink-0`,children:$e.length})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,O.jsx)(C,{variant:`accent`,leftIcon:(0,O.jsx)(d,{size:14}),onClick:et,children:i(`skills.new`)}),(0,O.jsxs)(`button`,{onClick:()=>xe(!0),className:`flex items-center gap-2 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg`,children:[(0,O.jsx)(f,{size:14}),i(`skills.import`)]}),(0,O.jsxs)(`button`,{onClick:Q,className:`flex items-center gap-2 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg`,children:[(0,O.jsx)(t,{size:14}),i(`skills.refresh`)]})]})]}),$e.length===0?(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-dark-muted gap-3`,children:[(0,O.jsx)(`p`,{children:i(`skills.noSkills`)}),(0,O.jsx)(C,{variant:`accent`,leftIcon:(0,O.jsx)(d,{size:14}),onClick:et,children:i(`skills.new`)})]}):(0,O.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar pe-1`,children:(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-3`,children:$e.map((t,n)=>(0,O.jsx)(ue,{index:n,children:(0,O.jsxs)(`div`,{className:`border border-dark-border rounded-lg p-3 flex flex-col gap-2 bg-dark-surface`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`font-medium text-sm truncate`,children:[(0,O.jsx)(k,{icon:t.icon}),` `,t.name]}),(0,O.jsx)(`div`,{className:`text-xs text-dark-muted truncate`,children:t.id})]}),(0,O.jsxs)(`button`,{onClick:()=>rt(t),className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shrink-0 transition-colors ${t.enabled?`bg-accent-green/20 text-accent-green hover:bg-accent-green/30`:`bg-accent-red/20 text-accent-red hover:bg-accent-red/30`}`,title:t.enabled?i(`skills.disable`):i(`skills.enable`),children:[t.enabled?(0,O.jsx)(o,{size:14}):(0,O.jsx)(m,{size:14}),t.enabled?i(`skills.enabled`):i(`skills.disabled`)]})]}),t.description&&(0,O.jsx)(`p`,{className:`text-xs text-dark-muted line-clamp-2`,children:t.description}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-auto`,children:[(0,O.jsx)(`span`,{className:`text-badge px-1.5 py-0.5 rounded bg-dark-bg border border-dark-border text-dark-muted truncate`,children:t.category}),(0,O.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,O.jsx)(w,{slot:`skills`,id:t.id}),e&&(0,O.jsxs)(`button`,{onClick:()=>e(t),className:`flex items-center gap-1 px-2 py-1 rounded bg-accent-blue/15 text-accent-blue text-xs hover:bg-accent-blue/25 transition-colors`,title:i(`skills.useHint`),children:[(0,O.jsx)(p,{size:12}),i(`skills.use`)]}),(0,O.jsxs)(`button`,{onClick:()=>tt(t),className:`flex items-center gap-1 px-2 py-1 rounded border border-dark-border text-xs hover:bg-dark-hover shrink-0`,children:[(0,O.jsx)(r,{size:12}),i(`skills.edit`)]})]})]})]})},t.id))})})]}),(0,O.jsx)(ne,{isOpen:he,onClose:()=>F(!1),title:i(I?`skills.edit`:`skills.new`),size:`xl`,children:(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsx)(M,{label:i(`skills.fieldId`),value:R.id,onChange:e=>z(t=>({...t,id:e}))}),(0,O.jsx)(M,{label:i(`skills.fieldName`),value:R.name,onChange:e=>z(t=>({...t,name:e}))}),(0,O.jsx)(M,{label:i(`skills.fieldCategory`),value:R.category,onChange:e=>z(t=>({...t,category:e}))}),(0,O.jsx)(M,{label:i(`skills.fieldTrigger`),value:R.trigger,onChange:e=>z(t=>({...t,trigger:e}))}),(0,O.jsx)(M,{label:i(`skills.tags`),value:R.tags,onChange:e=>z(t=>({...t,tags:e}))}),(0,O.jsx)(M,{label:i(`skills.fieldTools`),value:R.requiredTools,onChange:e=>z(t=>({...t,requiredTools:e}))}),(0,O.jsxs)(`div`,{className:`col-span-2`,children:[(0,O.jsx)(`label`,{className:`block text-sm mb-1 text-dark-muted`,children:i(`skills.description`)}),(0,O.jsx)(`textarea`,{value:R.description,onChange:e=>z(t=>({...t,description:e.target.value})),className:`w-full h-20 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none resize-none`})]}),(0,O.jsxs)(`div`,{className:`col-span-2`,children:[(0,O.jsx)(`label`,{className:`block text-sm mb-1 text-dark-muted`,children:i(`skills.systemPrompt`)}),(0,O.jsx)(`textarea`,{value:R.systemPrompt,onChange:e=>z(t=>({...t,systemPrompt:e.target.value})),className:`w-full h-40 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none resize-none font-mono text-sm`})]}),ye&&(0,O.jsx)(`div`,{className:`col-span-2 text-sm text-accent-red`,children:ye}),(0,O.jsxs)(`div`,{className:`col-span-2 flex justify-end gap-2`,children:[(0,O.jsx)(C,{variant:`secondary`,onClick:()=>F(!1),children:i(`skills.cancel`)}),(0,O.jsx)(C,{variant:`accent`,leftIcon:(0,O.jsx)(r,{size:14}),loading:_e,onClick:nt,children:i(`skills.save`)})]})]})}),(0,O.jsx)(ne,{isOpen:be,onClose:()=>xe(!1),title:i(`skills.importTitle`),size:`md`,children:(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsx)(`input`,{ref:V,type:`file`,accept:`.md,.skill.md,.txt`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&it(t)}}),(0,O.jsxs)(`button`,{onClick:()=>V.current?.click(),disabled:Se,className:`w-full py-6 border border-dashed border-dark-border rounded-lg flex items-center justify-center gap-2`,children:[(0,O.jsx)(g,{size:16}),i(`skills.chooseFile`)]}),we&&(0,O.jsx)(`div`,{className:`text-sm text-accent-red`,children:we}),(0,O.jsx)(`div`,{className:`text-xs text-dark-muted`,children:i(`skills.importHint`)})]})}),(0,O.jsx)(re,{isOpen:X!==null,onClose:()=>Ue(null),onConfirm:()=>{X&&Qe(X)},title:i(`skills.uninstall`),message:i(`skills.uninstallConfirm`,{name:Z.find(e=>e.id===X)?.name||X||``}),confirmText:i(`skills.uninstall`),cancelText:i(`skills.cancel`),variant:`danger`})]})}function fe(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function M({label:e,value:t,onChange:n}){return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`label`,{className:`block text-sm mb-1 text-dark-muted`,children:e}),(0,O.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue`})]})}export{de as SkillsView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,$n as n,Bn as r,Bt as i,In as a,J as o,O as s,Q as c,R as l,Rr as u,Ur as d,Vn as f,W as ee,Xt as te,Yn as ne,cr as p,ct as re,er as ie,fn as ae,g as oe,m,mt as h,n as g,ot as _,xr as se,z as ce}from"./icons-BvYhTENi.js";import{t as v}from"./useTranslation-BGmCDuQI.js";import{t as y}from"./cn-rx4uumOJ.js";import{t as b}from"./api-CCt9DRQm.js";import{I as le}from"./markdown-DAQZeY5V.js";import{A as x,h as ue,l as S,m as de,u as fe}from"./common-BHXgEvgk.js";import{D as pe,E as me,O as he,k as ge}from"./index-BX-d2OBW.js";var C=e(d(),1),w=new Set([`read_file`,`grep`,`glob`,`list_dir`,`web_fetch`,`web_search`,`git_status`,`git_diff`,`git_log`,`code_intel_lookup`,`lsp_diagnostics`,`artifact_query`,`artifact_read`]),T=new Set([`write_file`,`edit_file`,`file_delete`,`apply_patch`,`bash`,`git_commit`,`git_apply_patch`,`notebook_edit`,`git_branch`,`git_pr`]);function E(e){let t=(e.metadata??{}).primitive?.options;return Array.isArray(t?.tools)?t.tools.map(String):null}var D=new Set([`explore`,`plan`,`verify`]);function O(e){let t=E(e);if(t!==null)return t;let n=e.metadata??{},r=typeof n.role==`string`?n.role:e.type;return D.has(r)?[]:null}function _e(e){if(ye(e))return!1;let t=O(e);return t===null||t.length!==0&&t.some(e=>T.has(e))}var ve=new Set([`parallel`,`pipeline`,`phase`,`condition`,`loop`,`synthesize`,`checkpoint`,`retry`]);function ye(e){let t=(e.metadata??{}).primitive,n=typeof t?.kind==`string`?t.kind:void 0;return n===void 0?ve.has(e.type):n!==`agent`&&n!==`tool`}function k(e){let t=[];for(let n of e)t.push(n),Array.isArray(n.children)&&n.children.length&&t.push(...k(n.children));return t}function be(e){let t=new Map(e.map(e=>[e.id,e])),n=new Set,r=[],i=[...e];for(;i.length>0;){let e=i.filter(e=>(e.dependencies??[]).every(e=>n.has(e)||!t.has(e)));if(e.length===0){r.push(i);break}r.push(e);for(let t of e)n.add(t.id);i=i.filter(e=>!n.has(e.id))}return r}function xe(e){return be(e).reduce((e,t)=>Math.max(e,t.length),1)}function Se(e){let t=e.children??[];if(t.length===0)return 1;let n=Math.max(...t.map(e=>Se(e)));return e.type===`parallel`?Math.max(t.length,n):Math.max(1,n)}function Ce(e){let t=xe(e),n=e.reduce((e,t)=>Math.max(e,Se(t)),1);return Math.max(t,n)}function we(e,t=0){if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return{readonly:!0,risk:`low`,maxParallel:0,nodeCount:0,inputCount:t||0,roles:[]};let n=k(e.nodes),r=[],i=!0;for(let e of n){let t=typeof(e.metadata??{}).role==`string`?String(e.metadata.role):e.type;r.includes(t)||r.push(t),_e(e)&&(i=!1)}return{readonly:i,risk:i?`low`:`medium`,maxParallel:Ce(e.nodes),nodeCount:n.length,inputCount:t||0,roles:r}}var Te={parallel:`templates.nodeParallel`,pipeline:`templates.nodePipeline`,phase:`templates.nodePhase`,synthesize:`templates.nodeSynthesize`,condition:`templates.nodeCondition`,loop:`templates.nodeLoop`,checkpoint:`templates.nodeCheckpoint`},Ee={retry:`templates.nodeRetry`};function De(e){let t=e.metadata?.primitive,n=typeof t?.kind==`string`?t.kind:void 0;return n&&Ee[n]?Ee[n]:Te[e.type]}var A=le(),j={explore:`info`,plan:`default`,execute:`success`,verify:`warning`,summarize:`info`,generic:`default`},Oe={explore:`templates.roleExplore`,plan:`templates.rolePlan`,execute:`templates.roleExecute`,verify:`templates.roleVerify`,summarize:`templates.roleSummarize`,generic:`templates.roleGeneric`},M={explore:`text-accent-blue`,plan:`text-dark-muted`,execute:`text-accent-green`,verify:`text-accent-yellow`,summarize:`text-dark-muted`};function ke(e){let t=e.metadata?.role;return typeof t==`string`?t:e.type}function Ae({definition:e}){let{t}=v(),n=(0,C.useMemo)(()=>k(e.nodes||[]),[e.nodes]),r=(0,C.useMemo)(()=>be(n),[n]),i=(0,C.useMemo)(()=>new Map(n.map(e=>[e.id,e])),[n]);return r.length===0?(0,A.jsx)(`p`,{className:`text-xs text-dark-muted`,children:t(`templates.noNodes`)}):(0,A.jsxs)(`div`,{className:`space-y-0`,children:[r.map((e,n)=>(0,A.jsxs)(`div`,{className:`flex`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center shrink-0 w-6 me-2`,children:[n>0&&(0,A.jsx)(`span`,{className:`w-px h-3 bg-dark-border/60`}),e.length>1&&(0,A.jsx)(`span`,{className:`inline-flex items-center gap-0.5 mt-0.5 mb-0.5`,children:e.map((e,t)=>(0,A.jsx)(`span`,{className:`w-[2px] h-2 rounded bg-accent-blue/40`},t))}),n<r.length-1&&(0,A.jsx)(`span`,{className:`w-px flex-1 bg-dark-border/60 my-0.5`})]}),(0,A.jsx)(`div`,{className:y(`flex-1 min-w-0`,e.length>1?`grid grid-cols-2 gap-2 py-1`:`py-0.5`),children:e.map(e=>{let n=ke(e),r=M[n]||`text-dark-muted`,a=(e.dependencies??[]).map(e=>i.get(e)?.title||e),o=De(e);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border bg-dark-bg/60 overflow-hidden`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[(0,A.jsx)(p,{size:12,className:y(`shrink-0`,r)}),(0,A.jsx)(`span`,{className:`text-xs font-medium text-dark-text truncate flex-1`,title:e.title,children:e.title}),(0,A.jsx)(S,{size:`sm`,variant:j[n]||`default`,children:t(o||Oe[n]||`templates.roleGeneric`)})]}),e.description&&(0,A.jsx)(`p`,{className:`px-2.5 pb-1.5 text-meta text-dark-muted leading-relaxed`,children:e.description}),a.length>0&&(0,A.jsx)(`div`,{className:`px-2.5 pb-1.5 flex items-center flex-wrap gap-1`,children:a.map(e=>(0,A.jsxs)(`span`,{className:`text-badge px-1.5 py-0.5 rounded bg-dark-hover text-dark-muted truncate max-w-[14rem]`,children:[`← `,e]},e))})]},e.id)})})]},n)),(0,A.jsxs)(`div`,{className:`flex items-center gap-3 mt-3 pt-2 border-t border-dark-border text-badge text-dark-muted`,children:[(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,A.jsx)(l,{size:11,className:`text-accent-yellow`}),` `,t(`templates.roleVerify`)]}),(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,A.jsx)(p,{size:11,className:`text-accent-blue`}),` `,t(`templates.roleExplore`)]})]})]})}function N(e){let t=e.metadata?.role;return typeof t==`string`?t:e.type}function P({definition:e}){let{t}=v(),n=(0,C.useMemo)(()=>k(e.nodes||[]),[e.nodes]),{readonly:r,allowList:i,toolSet:a}=(0,C.useMemo)(()=>{let e=new Set,t=!1;for(let r of n){let n=E(r);if(n!==null){for(let t of n)e.add(t);n.some(e=>T.has(e))&&(t=!0)}else N(r)!==`explore`&&N(r)!==`plan`&&N(r)!==`verify`&&(t=!0)}let r=[...e].filter(e=>w.has(e));return{readonly:!t,allowList:r,toolSet:e}},[n]),o=(0,C.useMemo)(()=>[...T].filter(e=>!a.has(e)),[a]);return(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?(0,A.jsx)(l,{size:16,className:`text-accent-green`}):(0,A.jsx)(ce,{size:16,className:`text-accent-yellow`}),(0,A.jsx)(`span`,{className:`text-sm text-dark-text`,children:t(r?`templates.readonly`:`templates.writable`)}),(0,A.jsx)(S,{size:`sm`,variant:r?`success`:`warning`,children:t(r?`templates.riskLow`:`templates.riskMedium`)})]}),(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border p-3`,children:[(0,A.jsx)(`div`,{className:`text-meta uppercase tracking-wider text-dark-muted/70 mb-2`,children:t(`templates.allowDuringReplay`)}),i.length>0?(0,A.jsx)(`ul`,{className:`space-y-1`,children:i.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-1.5 text-xs text-dark-muted`,children:[(0,A.jsx)(se,{size:12,className:`text-accent-green shrink-0`}),` `,e]},e))}):(0,A.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:t(`templates.noToolsRestriction`)})]}),(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border p-3`,children:[(0,A.jsx)(`div`,{className:`text-meta uppercase tracking-wider text-dark-muted/70 mb-2`,children:t(`templates.denyDuringReplay`)}),r?(0,A.jsx)(`ul`,{className:`space-y-1`,children:o.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-1.5 text-xs text-dark-muted`,children:[(0,A.jsx)(g,{size:12,className:`text-accent-red shrink-0`}),` `,e]},e))}):(0,A.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:`—`})]})]}),a.size>0&&(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border p-3`,children:[(0,A.jsx)(`div`,{className:`text-meta uppercase tracking-wider text-dark-muted/70 mb-1.5`,children:t(`templates.toolWhitelist`)}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[...a].map(e=>(0,A.jsx)(`span`,{className:`text-badge px-1.5 py-0.5 rounded bg-dark-hover text-dark-muted`,children:e},e))})]})]})}function je(e){let{t:i,detail:o,sourceLabelKey:s,detailTab:d,onTabChange:ee,onReplay:p,onPreflight:ie,onEdit:m,onDelete:g,onExport:_,onCopyId:se,onToggleAdvanced:v,onToggleVersions:b,onReRecord:le,versions:ue,historyView:de,onLoadVersion:fe,onClearHistory:pe,onRefresh:me,menuOpen:he,setMenuOpen:ge,saveMsg:w}=e,T=(0,C.useMemo)(()=>we(o.definition,o.inputs?.length??0),[o.definition,o.inputs]),E=s?i(s):o.source.type,D=T.inputCount,O=[{id:`overview`,label:i(`templates.overviewTab`)},{id:`flow`,label:i(`templates.flowTab`)},{id:`permissions`,label:i(`templates.permissionsTab`)},{id:`history`,label:i(`templates.historyTab`)}];return(0,A.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-y-auto custom-scrollbar`,children:(0,A.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3 flex-wrap`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,A.jsx)(`h2`,{className:`text-lg font-semibold text-dark-text truncate`,children:o.name}),(0,A.jsxs)(S,{variant:`info`,children:[`v`,o.version]}),o.status===`degraded`&&(0,A.jsxs)(S,{variant:`warning`,children:[`⚠ `,i(`templates.degradedBadge`)]}),(0,A.jsx)(S,{variant:o.source.type===`saved`?`success`:`default`,children:E})]}),o.description&&(0,A.jsx)(`p`,{className:`text-sm text-dark-muted mt-1`,children:o.description})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,A.jsx)(x,{variant:`accent`,leftIcon:(0,A.jsx)(re,{className:`w-4 h-4`}),onClick:p,children:i(`templates.replay`)}),(0,A.jsx)(x,{variant:`secondary`,leftIcon:(0,A.jsx)(a,{className:`w-4 h-4`}),onClick:ie,children:i(`templates.preflight`)}),(0,A.jsxs)(`button`,{onClick:m,className:`px-3 py-2 rounded-lg border border-dark-border text-dark-text hover:bg-dark-hover transition-colors inline-flex items-center gap-1.5`,children:[(0,A.jsx)(h,{className:`w-4 h-4`}),` `,i(`templates.edit`)]}),(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`button`,{onClick:()=>ge(!he),className:`p-2 rounded-lg text-dark-muted hover:bg-dark-hover transition-colors`,"aria-label":i(`templates.more`),children:(0,A.jsx)(r,{className:`w-4 h-4`})}),he&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>ge(!1)}),(0,A.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 w-52 rounded-lg border border-dark-border bg-dark-overlay ui-surface-overlay shadow-pop p-1.5 space-y-0.5 text-compact`,children:[(0,A.jsx)(F,{icon:(0,A.jsx)(f,{size:13}),label:i(`templates.exportJson`),onClick:_}),(0,A.jsx)(F,{icon:(0,A.jsx)(ne,{size:13}),label:i(`templates.copyId`),onClick:se}),(0,A.jsx)(F,{icon:(0,A.jsx)(c,{size:13}),label:i(`templates.versionHistory`),onClick:b}),(0,A.jsx)(F,{icon:(0,A.jsx)(n,{size:13}),label:i(`templates.advancedJson`),onClick:v}),(0,A.jsx)(`div`,{className:`border-t border-dark-border my-1`}),(0,A.jsx)(F,{icon:(0,A.jsx)(oe,{size:13}),label:i(`templates.deleteTemplate`),onClick:g,danger:!0})]})]})]})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o.category&&(0,A.jsxs)(S,{size:`sm`,variant:`info`,className:`gap-1`,children:[(0,A.jsx)(te,{size:11}),o.category]}),(0,A.jsxs)(S,{size:`sm`,variant:T.readonly?`success`:`warning`,className:`gap-1`,children:[T.readonly?(0,A.jsx)(l,{size:11}):(0,A.jsx)(ce,{size:11}),T.readonly?`${i(`templates.readonly`)} · ${i(`templates.riskLow`)}`:`${i(`templates.writable`)} · ${i(`templates.riskMedium`)}`]}),(0,A.jsxs)(S,{size:`sm`,variant:`default`,className:`gap-1`,children:[(0,A.jsx)(ae,{size:11}),T.maxParallel>1?i(`templates.parallelCount`,{n:T.nodeCount,p:T.maxParallel}):i(`templates.stepCount`,{n:T.nodeCount})]}),(0,A.jsxs)(S,{size:`sm`,variant:`default`,className:`gap-1`,children:[(0,A.jsx)(u,{size:11}),D>0?i(`templates.confirmCount`,{n:D}):i(`templates.confirmCountNone`)]}),w&&(0,A.jsx)(`span`,{className:`text-xs text-dark-muted`,children:w})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-dark-border pb-1.5`,children:[O.map(e=>(0,A.jsx)(`button`,{onClick:()=>ee(e.id),className:y(`px-3 py-1.5 rounded-md text-xs transition-colors`,d===e.id?`bg-accent-blue/10 text-accent-blue font-medium`:`text-dark-muted hover:text-dark-text hover:bg-dark-hover`),children:e.label},e.id)),(0,A.jsx)(`div`,{className:`ms-auto flex items-center gap-1`,children:(0,A.jsx)(`button`,{onClick:me,className:`p-1.5 rounded-md text-dark-muted hover:text-dark-text hover:bg-dark-hover`,title:i(`templates.refresh`),children:(0,A.jsx)(t,{className:`w-3.5 h-3.5`})})})]}),(0,A.jsxs)(`div`,{children:[d===`overview`&&(0,A.jsx)(I,{t:i,detail:o,meta:T,inputCount:D}),d===`flow`&&(0,A.jsx)(Ae,{definition:o.definition}),d===`permissions`&&(0,A.jsx)(P,{definition:o.definition}),d===`history`&&(0,A.jsx)(L,{t:i,versions:ue,currentVersion:o.version,historyView:de,onLoadVersion:fe,onClearHistory:pe,onReRecord:le})]})]})})}function F({icon:e,label:t,onClick:n,danger:r}){return(0,A.jsxs)(`button`,{onClick:n,className:y(`w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-dark-hover text-start transition-colors`,r?`text-accent-red hover:text-accent-red`:`text-dark-muted hover:text-dark-text`),children:[e,` `,t]})}function I({t:e,detail:t,meta:n,inputCount:r}){let i=t.inputs??[],a=t.outputs??[];return(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border p-3`,children:[(0,A.jsx)(`div`,{className:`text-meta uppercase tracking-wider text-dark-muted/70 mb-2`,children:e(`templates.inputsNeeded`)}),r>0?(0,A.jsx)(`ul`,{className:`space-y-1.5`,children:i.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-dark-text truncate`,children:e.label||e.name}),e.required&&(0,A.jsx)(`span`,{className:`text-accent-red shrink-0`,children:`*`})]},e.name))}):(0,A.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:e(`templates.confirmCountNone`)})]}),(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border p-3`,children:[(0,A.jsx)(`div`,{className:`text-meta uppercase tracking-wider text-dark-muted/70 mb-2`,children:e(`templates.outputsProduced`)}),a.length>0?(0,A.jsx)(`ul`,{className:`space-y-1.5`,children:a.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,A.jsx)(`span`,{className:`text-dark-text truncate`,children:e.label||e.name}),e.kind&&(0,A.jsx)(S,{size:`sm`,children:e.kind})]},e.name))}):(0,A.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:e(`templates.noOutputsDeclared`)})]}),(0,A.jsxs)(`div`,{className:`col-span-2 text-meta text-dark-muted/70`,children:[e(`templates.replayNewSession`),` · `,n.readonly?e(`templates.readonlyHint`):e(`templates.writable`)]})]})}function L({t:e,versions:n,currentVersion:r,historyView:i,onLoadVersion:a,onClearHistory:o,onReRecord:s}){return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[n.length===0&&(0,A.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:e(`templates.noVersions`)}),[...n].reverse().map(n=>(0,A.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-dark-border px-3 py-2`,children:[(0,A.jsxs)(S,{variant:n===r?`success`:`default`,children:[`v`,n]}),n===r&&(0,A.jsx)(`span`,{className:`text-meta text-accent-green`,children:e(`templates.statusReady`)}),(0,A.jsx)(`span`,{className:`text-meta text-dark-muted/60`,children:n===r?e(`templates.reRecordHint`,{v:n}):``}),(0,A.jsxs)(`div`,{className:`ms-auto flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{onClick:()=>a(n),className:`text-meta px-2 py-1 rounded border border-dark-border hover:border-accent-blue/50 transition-colors`,children:e(`templates.compare`)}),n!==r&&(0,A.jsxs)(`button`,{onClick:()=>s(n),className:`text-meta px-2 py-1 rounded border border-accent-blue/40 text-accent-blue hover:bg-accent-blue/10 transition-colors inline-flex items-center gap-1`,children:[(0,A.jsx)(t,{className:`w-3 h-3`}),` `,e(`templates.reRecordAsNew`)]})]})]},n)),i&&(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-dark-muted`,children:[e(`templates.viewingVersion`),` v`,i.version]}),(0,A.jsx)(`button`,{onClick:o,className:`text-meta text-dark-muted hover:text-dark-text`,children:e(`templates.cancel`)})]}),(0,A.jsx)(`pre`,{className:`p-3 rounded-lg bg-dark-bg text-badge font-mono text-dark-muted max-h-60 overflow-y-auto custom-scrollbar`,children:JSON.stringify({version:i.version,inputs:i.inputs,definition:i.definition},null,2)})]})]})}var R={explore:`info`,plan:`default`,execute:`success`,verify:`warning`,summarize:`info`,generic:`default`},z={explore:`templates.roleExplore`,plan:`templates.rolePlan`,execute:`templates.roleExecute`,verify:`templates.roleVerify`,summarize:`templates.roleSummarize`,generic:`templates.roleGeneric`};function B(e){let t=e.metadata?.role;return typeof t==`string`?t:e.type}function Me(e){let t=new Map(e.map(e=>[e.id,e])),n=new Set,r=[],i=[...e];for(;i.length>0;){let e=i.filter(e=>(e.dependencies??[]).every(e=>n.has(e)||!t.has(e)));if(e.length===0){r.push(...i);break}for(let t of e)r.push(t),n.add(t.id);i=i.filter(e=>!n.has(e.id))}return r}function V(e){let t=[];for(let n of e)t.push(n),Array.isArray(n.children)&&n.children.length&&t.push(...V(n.children));return t}function Ne(e,t){for(let n of e)t.set(n.id,t.size+1),Array.isArray(n.children)&&n.children.length&&Ne(n.children,t)}function Pe({nodes:e,allById:t,indexById:n}){let{t:r}=v();return(0,A.jsx)(A.Fragment,{children:e.map((i,a)=>{let o=B(i),s=R[o]||`default`,c=De(i),l=z[o],u=c?r(c):l?r(l):o,d=(i.dependencies??[]).map(e=>t.get(e)?.title||e).filter((e,t,n)=>n.indexOf(e)===t);return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex gap-2.5`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center shrink-0`,children:[(0,A.jsx)(`span`,{className:`w-6 h-6 rounded-full grid place-items-center bg-dark-border/60 text-dark-muted text-badge font-semibold shrink-0`,children:n.get(i.id)??a+1}),a<e.length-1&&(0,A.jsx)(`span`,{className:`w-px flex-1 bg-dark-border/70 my-0.5`})]}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0 mb-1.5 rounded-lg border border-dark-border bg-dark-bg/60 overflow-hidden`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[(0,A.jsx)(p,{size:12,className:y(`shrink-0`,o===`verify`?`text-accent-yellow`:o===`explore`?`text-accent-blue`:`text-dark-muted`)}),(0,A.jsx)(`span`,{className:`text-xs font-medium text-dark-text truncate flex-1`,children:i.title}),(0,A.jsx)(S,{size:`sm`,variant:s,children:u})]}),i.description&&(0,A.jsx)(`p`,{className:`px-2.5 pb-1.5 text-meta text-dark-muted leading-relaxed`,children:i.description}),d.length>0&&(0,A.jsxs)(`div`,{className:`px-2.5 pb-2 flex items-center flex-wrap gap-1`,children:[(0,A.jsx)(ae,{size:11,className:`text-dark-muted/60 shrink-0`}),d.map(e=>(0,A.jsx)(`span`,{className:`text-badge px-1.5 py-0.5 rounded bg-dark-hover text-dark-muted truncate max-w-[16rem]`,children:e},e))]})]})]}),Array.isArray(i.children)&&i.children.length>0&&(0,A.jsx)(`div`,{className:`ms-3 ps-3 border-s-2 border-dark-border/60`,children:(0,A.jsx)(Pe,{nodes:i.children,allById:t,indexById:n})})]},i.id)})})}function Fe({definition:e}){let{t}=v(),n=(0,C.useMemo)(()=>Me(e.nodes||[]),[e.nodes]),r=(0,C.useMemo)(()=>new Map(V(e.nodes||[]).map(e=>[e.id,e])),[e.nodes]),i=(0,C.useMemo)(()=>{let t=new Map;return Ne(e.nodes||[],t),t},[e.nodes]);return n.length===0?(0,A.jsx)(`p`,{className:`text-xs text-dark-muted`,children:t(`templates.noNodes`)}):(0,A.jsx)(`div`,{className:`space-y-0`,children:(0,A.jsx)(Pe,{nodes:n,allById:r,indexById:i})})}function H(e){let t=[];for(let n of e)t.push(n),Array.isArray(n.children)&&n.children.length&&t.push(...H(n.children));return t}function Ie(e,t){let n=new Set,r=(e,i)=>{for(let a of e){let e=i||a.id===t;e&&n.add(a.id),Array.isArray(a.children)&&a.children.length&&r(a.children,e)}};return r(e,!1),n}function Le(e){let t=new Set(H(e).map(e=>e.id)),n=1;for(;t.has(`task-${n}`);)n++;return`task-${n}`}function U(e,t,n){return e.map(e=>e.id===t?{...e,...n}:Array.isArray(e.children)&&e.children.length?{...e,children:U(e.children,t,n)}:e)}function Re(e,t){let n=e=>e.filter(e=>e.id!==t).map(e=>({...e,dependencies:(e.dependencies??[]).filter(e=>e!==t),children:Array.isArray(e.children)&&e.children.length?n(e.children):e.children}));return n(e)}function W(e,t,n){let r=new Date().toISOString(),i={id:Le(e),title:n?.title??``,description:n?.description??``,type:n?.type??`task`,status:`pending`,dependencies:[],priority:5,createdAt:r,updatedAt:r};if(!t)return[...e,i];let a=e=>e.map(e=>e.id===t?{...e,children:[...Array.isArray(e.children)?e.children:[],i]}:Array.isArray(e.children)&&e.children.length?{...e,children:a(e.children)}:e);return a(e)}var ze=[`task`,`agent`,`parallel`,`pipeline`,`phase`,`condition`,`loop`,`checkpoint`],G=new Set([`parallel`,`pipeline`,`phase`,`condition`,`loop`,`checkpoint`]),Be=[`string`,`number`,`select`,`boolean`,`folder`,`connector`];function K(e){return Te[e]??(e===`agent`?`templates.editorTypeAgent`:`templates.editorTypeTask`)}function Ve(e,t){return G.has(t)?e(Te[t]??t):e(K(t))}function q(e){let{t}=v(),{node:n,index:r,depth:i,depOptions:a,definition:o,onChange:s,onRemove:c,onAddChild:l,onDepAdd:u,onDepRemove:d}=e,f=n.dependencies??[],ee=Array.isArray(n.children)&&n.children.length>0,te=G.has(n.type);return(0,A.jsxs)(`div`,{className:He(i)+` rounded-lg border border-dark-border bg-dark-bg/60`,"data-node-id":n.id,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5`,children:[(0,A.jsx)(`span`,{className:`text-badge text-dark-muted/70 shrink-0 w-4 text-end`,children:r}),(0,A.jsx)(`input`,{value:n.title,onChange:e=>s({title:e.target.value}),placeholder:t(`templates.editorNodeTitlePlaceholder`),"aria-label":t(`templates.editorNodeTitlePlaceholder`),className:`flex-1 min-w-[120px] px-2 py-1 rounded-md bg-dark-surface border border-dark-border text-xs text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`}),(0,A.jsx)(`span`,{className:`text-badge font-mono text-dark-muted/50 shrink-0 hidden xl:inline`,title:n.id,children:n.id}),(0,A.jsx)(`select`,{value:n.type,onChange:e=>s({type:e.target.value}),"aria-label":t(`templates.editorInputType`),className:`shrink-0 px-1.5 py-1 rounded-md bg-dark-surface border border-dark-border text-meta text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`,children:ze.map(e=>(0,A.jsx)(`option`,{value:e,children:Ve(t,e)},e))}),(0,A.jsx)(`button`,{onClick:c,className:`p-1 rounded-md text-dark-muted hover:text-accent-red hover:bg-dark-hover transition-colors shrink-0`,title:t(`templates.editorDeleteNode`),"aria-label":`${t(`templates.editorDeleteNode`)} ${n.title||n.id}`,children:(0,A.jsx)(oe,{size:12})})]}),(0,A.jsxs)(`div`,{className:`px-2.5 pb-2 space-y-1.5`,children:[(0,A.jsx)(`textarea`,{value:n.description,onChange:e=>s({description:e.target.value}),rows:2,placeholder:t(`templates.editorNodeDescPlaceholder`),"aria-label":`${t(`templates.editorNodeDescPlaceholder`)} ${n.id}`,className:`w-full px-2 py-1 rounded-md bg-dark-surface border border-dark-border text-meta text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue placeholder:text-dark-muted/40`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,A.jsx)(ae,{size:11,className:`text-dark-muted/60 shrink-0`}),(0,A.jsx)(`span`,{className:`text-meta text-dark-muted shrink-0`,children:t(`templates.editorDepsLabel`)}),f.length===0&&(0,A.jsx)(`span`,{className:`text-meta text-dark-muted/50`,children:t(`templates.editorDepsNone`)}),f.map(e=>{let n=V(o.nodes??[]).find(t=>t.id===e);return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-meta px-1.5 py-0.5 rounded bg-accent-blue/10 text-accent-blue`,children:[n?.title||e,(0,A.jsx)(`button`,{onClick:()=>d(e),className:`hover:text-accent-red`,"aria-label":`${t(`templates.editorDepsRemove`)} ${n?.title||e}`,children:`✕`})]},e)}),(0,A.jsxs)(`select`,{value:``,onChange:e=>{e.target.value&&u(e.target.value)},"aria-label":t(`templates.editorDepsAdd`),className:`ms-auto px-1.5 py-0.5 rounded-md bg-dark-surface border border-dark-border text-meta text-dark-muted focus:outline-none focus:ring-1 focus:ring-accent-blue`,children:[(0,A.jsx)(`option`,{value:``,children:t(`templates.editorDepsAdd`)}),a.filter(e=>!f.includes(e.id)).map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.title||e.id},e.id))]}),(0,A.jsxs)(`label`,{className:`ms-auto inline-flex items-center gap-1 text-meta text-dark-muted`,children:[t(`templates.editorPriority`),(0,A.jsx)(`input`,{type:`number`,value:n.priority,onChange:e=>s({priority:Number(e.target.value)||0}),className:`w-14 px-1.5 py-0.5 rounded-md bg-dark-surface border border-dark-border text-meta text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]})]})]}),(te||ee)&&(0,A.jsxs)(`div`,{className:`ms-3 ps-3 pb-2 border-s-2 border-dark-border/60`,children:[ee&&(0,A.jsx)(J,{nodes:n.children,depth:i+1,definition:o,onChangeNodes:e=>s({children:e})}),(0,A.jsxs)(`button`,{onClick:l,className:`mt-1 inline-flex items-center gap-1 text-meta text-dark-muted hover:text-accent-blue transition-colors`,children:[(0,A.jsx)(_,{size:11}),` `,t(`templates.editorAddChild`)]})]})]})}function He(e){return e>0?`ms-3`:``}function J({nodes:e,depth:t,definition:n,onChangeNodes:r}){let{t:i}=v(),a=(0,C.useMemo)(()=>V(n.nodes??[]),[n.nodes]);return(0,A.jsxs)(`div`,{className:`space-y-2`,children:[e.map((i,o)=>{let s=Ie(n.nodes??[],i.id),c=a.filter(e=>!s.has(e.id));return(0,A.jsx)(`div`,{children:(0,A.jsx)(q,{node:i,index:o+1,depth:t,depOptions:c,definition:n,onChange:t=>r(U(e,i.id,t)),onRemove:()=>r(Re(e,i.id)),onAddChild:()=>r(W(e,i.id)),onDepAdd:t=>r(U(e,i.id,{dependencies:[...i.dependencies??[],t]})),onDepRemove:t=>r(U(e,i.id,{dependencies:(i.dependencies??[]).filter(e=>e!==t)}))})},i.id)}),e.length===0&&(0,A.jsx)(`p`,{className:`text-meta text-dark-muted/50`,children:i(`templates.editorEmptyLevel`)})]})}function Ue({inputs:e,onChange:t}){let{t:n}=v(),r=(n,r)=>{t(e.map((e,t)=>t===n?{...e,...r}:e))},i=()=>{let n=new Set(e.map(e=>e.name)),r=1;for(;n.has(`input_${r}`);)r++;t([...e,{name:`input_${r}`,label:``,type:`string`}])},a=n=>t(e.filter((e,t)=>t!==n));return(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg overflow-hidden`,children:[(0,A.jsxs)(`div`,{className:`px-3 py-2 bg-dark-surface border-b border-dark-border flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`text-xs font-semibold text-dark-text`,children:n(`templates.editorInputsTitle`)}),(0,A.jsx)(`span`,{className:`ms-auto text-badge text-dark-muted`,children:n(`templates.confirmCount`,{n:e.length})})]}),(0,A.jsxs)(`div`,{className:`p-2.5 space-y-1.5`,children:[e.length===0&&(0,A.jsx)(`p`,{className:`text-meta text-dark-muted/50`,children:n(`templates.editorInputsEmpty`)}),e.map((e,t)=>(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,A.jsx)(`input`,{value:e.name,onChange:e=>r(t,{name:e.target.value}),placeholder:n(`templates.editorInputName`),"aria-label":`${n(`templates.editorInputName`)} ${t+1}`,className:`w-28 px-2 py-1 rounded-md bg-dark-surface border border-dark-border text-meta font-mono text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`}),(0,A.jsx)(`input`,{value:e.label,onChange:e=>r(t,{label:e.target.value}),placeholder:n(`templates.editorInputLabel`),"aria-label":`${n(`templates.editorInputLabel`)} ${t+1}`,className:`flex-1 min-w-[80px] px-2 py-1 rounded-md bg-dark-surface border border-dark-border text-meta text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`}),(0,A.jsx)(`select`,{value:e.type,onChange:e=>r(t,{type:e.target.value}),"aria-label":`${n(`templates.editorInputType`)} ${t+1}`,className:`px-1.5 py-1 rounded-md bg-dark-surface border border-dark-border text-meta text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`,children:Be.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))}),(0,A.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-meta text-dark-muted shrink-0`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:!!e.required,onChange:e=>r(t,{required:e.target.checked}),"aria-label":`${n(`templates.editorInputRequired`)} ${t+1}`}),n(`templates.editorInputRequired`)]}),(0,A.jsx)(`input`,{value:e.default===void 0||e.default===null?``:String(e.default),onChange:n=>{let i=n.target.value;i===``?r(t,{default:void 0}):e.type===`number`&&Number.isFinite(Number(i))?r(t,{default:Number(i)}):e.type===`boolean`?r(t,{default:i===`true`}):r(t,{default:i})},placeholder:n(`templates.editorInputDefault`),"aria-label":`${n(`templates.editorInputDefault`)} ${t+1}`,className:`w-24 px-2 py-1 rounded-md bg-dark-surface border border-dark-border text-meta text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`}),(0,A.jsx)(`button`,{onClick:()=>a(t),className:`p-1 rounded-md text-dark-muted hover:text-accent-red hover:bg-dark-hover transition-colors`,title:n(`templates.editorInputRemove`),"aria-label":`${n(`templates.editorInputRemove`)} ${e.name||t+1}`,children:(0,A.jsx)(oe,{size:12})})]},t)),(0,A.jsxs)(`button`,{onClick:i,className:`inline-flex items-center gap-1 text-meta text-dark-muted hover:text-accent-blue transition-colors`,children:[(0,A.jsx)(_,{size:11}),` `,n(`templates.editorInputsAdd`)]})]})]})}function We({definition:e,inputs:t,issues:n,onDefinitionChange:r,onInputsChange:i}){let{t:a}=v(),o=e.nodes??[],s=(0,C.useMemo)(()=>V(o),[o]),c=t=>{r({...e,nodes:t,updatedAt:new Date().toISOString()})};return(0,A.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[3fr_2fr] gap-4 items-start`,children:[(0,A.jsxs)(`section`,{className:`border border-dark-border rounded-lg overflow-hidden`,children:[(0,A.jsxs)(`div`,{className:`px-3 py-2 bg-dark-surface border-b border-dark-border flex items-center gap-2`,children:[(0,A.jsx)(te,{size:13,className:`text-accent-blue shrink-0`}),(0,A.jsx)(`span`,{className:`text-xs font-semibold text-dark-text`,children:a(`templates.editorNodesTitle`)}),(0,A.jsx)(`span`,{className:`text-badge text-dark-muted`,children:a(`templates.editorNodeCount`,{n:s.length})}),(0,A.jsxs)(`button`,{onClick:()=>c(W(o)),className:`ms-auto inline-flex items-center gap-1 text-meta px-2 py-1 rounded-md border border-dark-border text-dark-muted hover:text-accent-blue hover:border-accent-blue/40 transition-colors`,children:[(0,A.jsx)(_,{size:11}),` `,a(`templates.editorAddNode`)]})]}),(0,A.jsxs)(`div`,{className:`p-2.5 space-y-2`,children:[(0,A.jsx)(J,{nodes:o,depth:0,definition:e,onChangeNodes:c}),o.length===0&&(0,A.jsxs)(`button`,{onClick:()=>c(W(o)),className:`w-full border border-dashed border-dark-border rounded-lg py-3 text-xs text-dark-muted hover:text-accent-blue hover:border-accent-blue/40 transition-colors`,children:[(0,A.jsx)(_,{size:12,className:`inline me-1`}),` `,a(`templates.editorAddNode`)]})]})]}),(0,A.jsxs)(`section`,{className:`space-y-3 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg overflow-hidden`,children:[(0,A.jsx)(`div`,{className:`px-3 py-2 bg-dark-surface border-b border-dark-border`,children:(0,A.jsx)(`span`,{className:`text-xs font-semibold text-dark-text`,children:a(`templates.editorPreviewTitle`)})}),(0,A.jsx)(`div`,{className:`p-2.5`,children:(0,A.jsx)(Fe,{definition:e})})]}),n.length>0&&(0,A.jsxs)(`div`,{className:`rounded-lg border border-accent-yellow/40 bg-accent-yellow/5 px-3 py-2 space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-accent-yellow font-medium`,children:[(0,A.jsx)(m,{size:13}),` `,a(`templates.editorValidationIssues`)]}),n.map((e,t)=>(0,A.jsx)(`div`,{className:`text-meta text-dark-muted`,children:a(e.key,e.params)},t))]}),n.length===0&&s.length>0&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(S,{size:`sm`,variant:`success`,children:a(`templates.editorValidationOk`)}),(0,A.jsx)(`span`,{className:`text-meta text-dark-muted/60`,children:a(`templates.editorAdvancedSyncHint`)})]}),(0,A.jsx)(Ue,{inputs:t,onChange:i})]})]})}var Ge=/<<input:([A-Za-z][A-Za-z0-9_]*)>>/g;function Ke(e){let t=[];for(let n of e)n&&typeof n==`object`&&(t.push(n),Array.isArray(n.children)&&n.children.length&&t.push(...Ke(n.children)));return t}function qe(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map(e.map(e=>[e.id,0]));for(let r of e)for(let e of r.dependencies||[])t.has(e)&&n.set(r.id,(n.get(r.id)??0)+1);let r=e.filter(e=>(n.get(e.id)??0)===0).map(e=>e.id),i=0;for(;r.length;){let t=r.pop();i++;for(let i of e)if((i.dependencies||[]).includes(t)){let e=(n.get(i.id)??0)-1;n.set(i.id,e),e===0&&r.push(i.id)}}return i<e.length}function Je(e,t){let n=[];if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return n.push({key:`templates.validateNoNodes`}),n;let r=Ke(e.nodes);if(r.length===0)return n.push({key:`templates.validateNoNodes`}),n;let i=new Set;for(let e of r)typeof e.id!=`string`||e.id===``?n.push({key:`templates.validateNodeNoId`}):(i.has(e.id)&&n.push({key:`templates.validateDupNodeId`,params:{id:e.id}}),i.add(e.id));let a=new Map(r.map(e=>[e.id,e]));for(let e of r)for(let t of e.dependencies||[])a.has(t)||n.push({key:`templates.validateDanglingDep`,params:{node:e.id,dep:t}});qe(r)&&n.push({key:`templates.validateCycle`});let o=new Set((t??[]).map(e=>e?.name).filter(e=>typeof e==`string`)),s=new Set;for(let e of r)for(let t of[e.title,e.description])if(typeof t==`string`)for(let e of t.matchAll(Ge)){let t=e[1];t&&!o.has(t)&&s.add(t)}for(let e of s)n.push({key:`templates.validateUndeclaredInput`,params:{name:e}});return n}function Ye(e,t,n){let r=new Date().toISOString();return{id:`wf_${Date.now()}`,title:e,description:``,nodes:[{id:`task-1`,title:t,description:n,type:`task`,status:`pending`,dependencies:[],priority:5,createdAt:r,updatedAt:r}],createdAt:r,updatedAt:r}}function Y(e){let t=(e.nodes??[]).map(e=>({...e,dependencies:Array.isArray(e.dependencies)?e.dependencies:[]}));return{...e,nodes:t}}var X=`__all__`;function Xe(e,t){if(!t)return;let n={};for(let r of e.inputs??[])r.type===`folder`&&r.default===void 0&&t&&(n[r.name]={value:t,label:t});return Object.keys(n).length>0?n:void 0}function Ze({t:e,detail:t,workspaceDir:n}){let r=(0,C.useMemo)(()=>we(t.definition,t.inputs?.length??0),[t.definition,t.inputs]);return r.nodeCount===0?null:(0,A.jsxs)(`div`,{className:`rounded-lg border border-dark-border bg-dark-bg/50 px-3 py-2.5 space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap text-xs`,children:[(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-medium text-dark-text`,children:[(0,A.jsx)(l,{size:13,className:r.readonly?`text-accent-green`:`text-accent-yellow`}),r.readonly?e(`templates.readonly`):e(`templates.writable`),` · `,r.readonly?e(`templates.riskLow`):e(`templates.riskMedium`)]}),(0,A.jsx)(`span`,{className:`text-dark-muted`,children:r.maxParallel>1?e(`templates.parallelCount`,{n:r.nodeCount,p:r.maxParallel}):e(`templates.stepCount`,{n:r.nodeCount})}),(0,A.jsx)(`span`,{className:`text-dark-muted`,children:r.inputCount>0?e(`templates.confirmCount`,{n:r.inputCount}):e(`templates.confirmCountNone`)})]}),n&&!r.readonly&&(0,A.jsxs)(`div`,{className:`text-meta text-dark-muted/70 truncate`,title:n,children:[e(`templates.writable`),`: `,n]})]})}var Qe={saved:`templates.sourceSaved`,script:`templates.sourceScript`,handwritten:`templates.sourceHandwritten`};function $e({onLaunch:e,workspaceDir:r}){let{t:d}=v(),[f,ne]=(0,C.useState)([]),[p,m]=(0,C.useState)(null),[h,g]=(0,C.useState)(null),[se,le]=(0,C.useState)(!1),[w,T]=(0,C.useState)(``),[E,D]=(0,C.useState)(``),[O,_e]=(0,C.useState)(X),[ve,ye]=(0,C.useState)(``),[k,be]=(0,C.useState)(``),[xe,Se]=(0,C.useState)(``),[Ce,we]=(0,C.useState)(``),[Te,Ee]=(0,C.useState)(``),[De,j]=(0,C.useState)(!1),[Oe,M]=(0,C.useState)(``),[ke,Ae]=(0,C.useState)(!1),[N,P]=(0,C.useState)([]),[F,I]=(0,C.useState)(!1),[L,R]=(0,C.useState)(null),[z,B]=(0,C.useState)(null),[Me,V]=(0,C.useState)(null),[Ne,Pe]=(0,C.useState)(!1),[Fe,H]=(0,C.useState)(!1),[Ie,Le]=(0,C.useState)(null),[U,Re]=(0,C.useState)(!1),W=(0,C.useRef)(p);W.current=p;let[ze,G]=(0,C.useState)(!0),[Be,K]=(0,C.useState)(`overview`),[Ve,q]=(0,C.useState)(!1),[He,J]=(0,C.useState)([]),[Ue,Ge]=(0,C.useState)(null),Ke=()=>{h&&(J(h.inputs??[]),Ge(Y(h.definition))),G(!1)},qe=e=>{Ge(e),Ee(JSON.stringify(e,null,2)),j(!0),M(``)},$e=e=>{J(e),we(JSON.stringify(e,null,2)),j(!0),M(``)},et=e=>{try{let t=JSON.parse(e);t&&typeof t==`object`&&Array.isArray(t.nodes)&&Ge(Y(t))}catch{}},tt=e=>{try{let t=JSON.parse(e);Array.isArray(t)&&J(t)}catch{}},nt=(0,C.useMemo)(()=>Je(Ue??void 0,He),[Ue,He]),[rt,it]=(0,C.useState)(!1),[at,ot]=(0,C.useState)(``),[st,ct]=(0,C.useState)(``),[lt,ut]=(0,C.useState)(`general`),[dt,ft]=(0,C.useState)(`[]`),[pt,mt]=(0,C.useState)(()=>JSON.stringify(Ye(d(`templates.starterTitle`),d(`templates.starterNodeTitle`),d(`templates.starterNodeDesc`)),null,2)),[ht,Z]=(0,C.useState)(``),[gt,_t]=(0,C.useState)([]),[vt,yt]=(0,C.useState)(null),[bt,xt]=(0,C.useState)(!1),[St,Ct]=(0,C.useState)(!1),[wt,Tt]=(0,C.useState)(``),[Et,Dt]=(0,C.useState)(!1),[Ot,Q]=(0,C.useState)(``),kt=()=>{let e=Ye(d(`templates.starterTitle`),d(`templates.starterNodeTitle`),d(`templates.starterNodeDesc`));ot(``),ct(``),ut(`general`),ft(`[]`),mt(JSON.stringify(e,null,2)),yt(e),_t([]),xt(!1),Z(``),Ct(!1),Tt(``),Dt(!1),Q(``),it(!0)},At=async()=>{if(!wt.trim())Q(d(`templates.aiPromptRequired`));else{Dt(!0),Q(``);try{let e=await b.workflows.synthesize(wt.trim());if(e.success&&e.data){let t=Y(e.data);ot(e.data.title||``),ct(e.data.description||``),yt(t),_t([]),ft(`[]`),mt(JSON.stringify(t,null,2)),xt(!1),Ct(!1),Z(``)}else Q(e.error||d(`templates.aiDraftFailed`))}catch(e){Q(e instanceof Error?e.message:String(e))}finally{Dt(!1)}}},jt=e=>{yt(e),mt(JSON.stringify(e,null,2)),Z(``)},Mt=e=>{_t(e),ft(JSON.stringify(e,null,2))},Nt=e=>{try{let t=JSON.parse(e);t&&typeof t==`object`&&Array.isArray(t.nodes)&&yt(Y(t))}catch{}},Pt=e=>{try{let t=JSON.parse(e);Array.isArray(t)&&_t(t)}catch{}},Ft=(0,C.useMemo)(()=>Je(vt??void 0,gt),[vt,gt]),It=async()=>{if(!at.trim()){Z(d(`templates.nameRequired`));return}let e,t;try{e=JSON.parse(dt),t=JSON.parse(pt)}catch(e){Z(d(`templates.jsonParseFailed`,{error:e instanceof Error?e.message:String(e)}));return}if(!t||typeof t!=`object`||!Array.isArray(t.nodes)){Z(d(`templates.invalidDefinition`));return}let n=Je(t,Array.isArray(e)?e:[]);if(n.length>0){Z(n.map(e=>d(e.key,e.params)).join(`;`));return}Z(``);let r=await b.templates.create({name:at.trim(),description:st.trim(),category:lt.trim()||`general`,inputs:Array.isArray(e)?e:[],definition:Y(t),source:{type:`handwritten`}});r.success&&r.data?(it(!1),m(r.data.id),$()):Z(r.error||d(`templates.createFailed`))},$=(0,C.useCallback)(async()=>{let e=await b.templates.list();e.success&&e.data&&(ne(e.data),p&&!e.data.some(e=>e.id===p)&&(m(null),g(null)))},[p]);(0,C.useEffect)(()=>{$()},[]),(0,C.useEffect)(()=>{if(!p){g(null);return}let e=!1;return le(!0),b.templates.get(p).then(t=>{e||(t.success&&t.data?(g(t.data),ye(t.data.name),be(t.data.description),Se(t.data.category),we(JSON.stringify(t.data.inputs,null,2)),Ee(JSON.stringify(t.data.definition,null,2)),J(t.data.inputs??[]),Ge(Y(t.data.definition)),j(!1),M(``),I(!1),R(null),b.templates.versions(p).then(t=>{!e&&t.success&&t.data&&P(t.data)})):T(t.error||d(`templates.loadFailed`)))}).catch(()=>T(d(`templates.loadFailed`))).finally(()=>le(!1)),()=>{e=!0}},[p]);let Lt=(0,C.useCallback)((e,t)=>d(e,{defaultValue:t}),[d]),Rt=(0,C.useMemo)(()=>f.map(e=>he(e,Lt)),[f,Lt]),zt=(0,C.useMemo)(()=>{let e=new Set;for(let t of Rt)t.builtin||e.add(t.category||d(`templates.uncategorized`));return[X,...[...e].sort()]},[Rt,d]),Bt=(0,C.useMemo)(()=>{let e=E.trim().toLowerCase();return Rt.filter(t=>O!==X&&pe(t,Lt)!==O?!1:!e||`${t.name} ${t.description} ${t.category}`.toLowerCase().includes(e))},[Rt,E,O,Lt]),Vt=(0,C.useMemo)(()=>zt.filter(e=>e!==X),[zt]),Ht=(0,C.useMemo)(()=>{let{userGroups:e,builtin:t}=ge(Bt,e=>d(e));return t.length===0?e:[...e,[d(`templates.builtinGroup`),t]]},[Bt,d]),Ut=e=>{m(e),G(!0),Ae(!1),I(!1),R(null),V(null),B(null),q(!1),j(!1),M(``),K(`overview`)},Wt=e=>{e!==p&&(!ze&&De?Le(e):Ut(e))},Gt=e=>t=>{e(t),j(!0),M(``)},Kt=async()=>{if(!p||!h||U)return;let e=p,t,n;try{t=JSON.parse(Ce),n=JSON.parse(Te)}catch(e){M(d(`templates.jsonParseFailed`,{error:e instanceof Error?e.message:String(e)}));return}let r=Je(n,Array.isArray(t)?t:[]);if(r.length>0)M(r.map(e=>d(e.key,e.params)).join(`;`));else{M(``),Re(!0);try{let r=await b.templates.update(e,{name:ve,description:k,category:xe,inputs:Array.isArray(t)?t:[],definition:Y(n)});if(W.current!==e)return;r.success&&r.data?(g(r.data),j(!1),M(d(`templates.savedVersion`,{version:r.data.version})),$(),b.templates.versions(e).then(t=>{W.current===e&&t.success&&t.data&&P(t.data)})):M(r.error||d(`templates.saveFailed`))}finally{Re(!1)}}},qt=async e=>{if(!p)return;let t=p;Pe(!0);try{let n=await b.templates.render(t,e);if(W.current!==t)return;V({ok:n.success,json:n.success?JSON.stringify(n.data,null,2):void 0,error:n.success?void 0:n.error||d(`templates.renderFailed`)})}catch(e){V({ok:!1,error:e instanceof Error?e.message:d(`templates.renderFailed`)})}finally{Pe(!1)}},Jt=t=>{h&&(e(h,t),B(null))},Yt=e=>{h&&(V(null),B({mode:e}))},Xt=async e=>{if(!p)return;let t=await b.templates.getVersion(p,e);t.success&&t.data&&R(t.data)};return(0,A.jsxs)(`div`,{className:`flex flex-1 min-h-0 bg-dark-bg`,children:[(0,A.jsxs)(`div`,{className:`w-80 shrink-0 border-e border-dark-border overflow-y-auto custom-scrollbar p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-2 px-1`,children:[(0,A.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-dark-muted font-medium`,children:d(`templates.workflowLibraryTitle`)}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsxs)(`button`,{onClick:kt,className:`p-1.5 rounded-lg text-accent-blue hover:bg-accent-blue/10 transition-colors inline-flex items-center gap-1 text-xs`,title:d(`templates.manualCreateTitle`),children:[(0,A.jsx)(_,{className:`w-4 h-4`}),(0,A.jsx)(`span`,{className:`hidden xl:inline`,children:d(`templates.manualCreate`)})]}),(0,A.jsx)(`button`,{onClick:()=>{T(``),$()},className:`p-1.5 rounded-lg text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,title:d(`templates.refresh`),children:(0,A.jsx)(t,{className:`w-4 h-4`})})]})]}),(0,A.jsxs)(`div`,{className:`relative mb-2`,children:[(0,A.jsx)(ee,{size:13,className:`absolute start-2.5 top-1/2 -translate-y-1/2 text-dark-muted/60`}),(0,A.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:d(`templates.searchPlaceholder`),className:`w-full ps-8 pe-3 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-xs text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue placeholder:text-dark-muted/50`})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1.5 mb-3 flex-wrap`,children:zt.map(e=>(0,A.jsx)(`button`,{onClick:()=>_e(e),className:y(`text-meta px-2 py-0.5 rounded-full border transition-colors`,O===e?`border-accent-blue text-accent-blue bg-accent-blue/10`:`border-dark-border text-dark-muted hover:border-dark-muted/50 hover:text-dark-text`),children:e===X?d(`templates.filterAll`):e},e))}),w&&(0,A.jsx)(`div`,{className:`text-xs text-accent-red mb-2`,children:w}),Ht.length===0&&!w&&(0,A.jsx)(`div`,{className:`text-xs text-dark-muted px-1 py-4 text-center`,children:d(E||O!==X?`templates.noMatchTemplates`:`templates.emptyTemplates`)}),Ht.map(([e,t])=>(0,A.jsxs)(`div`,{className:`mb-4`,children:[(0,A.jsx)(`div`,{className:`px-1 mb-1.5 text-badge uppercase tracking-wider text-dark-muted/70`,children:e}),(0,A.jsx)(`div`,{className:`space-y-1.5`,children:t.map(e=>{let t=p===e.id,n=e.status&&e.status!==`ready`?e.status:null,r=n===`degraded`?`templates.degradedBadge`:n===`draft`?`templates.statusDraft`:n===`deprecated`?`templates.statusDeprecated`:n===`archived`?`templates.statusArchived`:null;return(0,A.jsxs)(`button`,{onClick:()=>Wt(e.id),className:y(`w-full text-start px-3 py-2.5 rounded-lg border transition-colors`,t?`bg-accent-blue/10 border-accent-blue/30 text-dark-text`:`border-transparent hover:bg-dark-hover text-dark-muted`),children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.name}),(0,A.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[r&&(0,A.jsx)(S,{size:`sm`,variant:n===`degraded`?`warning`:`default`,children:d(r)}),(0,A.jsxs)(S,{size:`sm`,variant:`info`,children:[`v`,e.version]})]})]}),e.description&&(0,A.jsx)(`div`,{className:`text-meta text-dark-muted/70 truncate mt-0.5`,children:e.description}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-2 flex-wrap`,children:[e.summary&&(0,A.jsxs)(S,{size:`sm`,variant:e.summary.readonly?`success`:`warning`,className:`gap-1`,children:[e.summary.readonly?(0,A.jsx)(l,{size:10}):(0,A.jsx)(ce,{size:10}),e.summary.readonly?`${d(`templates.readonly`)} · ${d(`templates.riskLow`)}`:`${d(`templates.writable`)} · ${d(`templates.riskMedium`)}`]}),(0,A.jsx)(S,{size:`sm`,variant:`default`,children:e.inputs.length>0?d(`templates.confirmCount`,{n:e.inputs.length}):d(`templates.confirmCountNone`)}),(0,A.jsxs)(`span`,{className:`ms-auto inline-flex items-center gap-0.5 text-badge text-accent-blue`,children:[d(t?`templates.viewing`:`templates.view`),!t&&(0,A.jsx)(u,{size:10})]})]})]},e.id)})})]},e))]}),(()=>{if(!p)return(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-dark-muted`,children:(0,A.jsxs)(`div`,{className:`text-center px-8`,children:[(0,A.jsx)(te,{size:36,className:`mx-auto mb-2 opacity-30 text-dark-muted`}),(0,A.jsx)(`p`,{children:d(`templates.selectTemplateHint`)}),(0,A.jsx)(`p`,{className:`text-xs text-dark-muted/60 mt-1`,children:d(`templates.workflowLibraryHint`)})]})});if(se||!h)return(0,A.jsxs)(`div`,{className:`flex-1 flex items-center justify-center text-dark-muted`,children:[(0,A.jsx)(i,{className:`w-4 h-4 animate-spin me-2`}),` `,d(`templates.loading`)]});let e=h.definition?.nodes?.length??0,r=h.inputs?.length??0,s=Qe[h.source.type];return ze?(0,A.jsx)(je,{t:d,detail:he(h,Lt),nodeCount:e,inputCount:r,sourceLabelKey:s,detailTab:Be,onTabChange:K,onReplay:()=>{B({mode:`launch`}),q(!1)},onPreflight:()=>{B({mode:`preview`}),q(!1)},onEdit:()=>{Ke(),q(!1)},onDelete:()=>H(!0),onExport:()=>{let e=new Blob([JSON.stringify(h,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${h.id}.template.json`,n.click(),URL.revokeObjectURL(t)},onCopyId:async()=>{try{await navigator.clipboard.writeText(h.id),M(d(`templates.copied`))}catch{}},onToggleAdvanced:()=>{Ke(),Ae(!0),q(!1)},onToggleVersions:()=>{K(`history`),q(!1),I(!1)},onReRecord:async e=>{let t=await b.templates.getVersion(p,e);if(t.success&&t.data){let e=t.data,n=await b.templates.update(p,{name:e.name,description:e.description,category:e.category,inputs:e.inputs,definition:e.definition});n.success&&n.data&&(g(n.data),K(`history`),$(),b.templates.versions(p).then(e=>{e.success&&e.data&&P(e.data)}))}},versions:N,historyView:L,onLoadVersion:Xt,onClearHistory:()=>R(null),onRefresh:$,menuOpen:Ve,setMenuOpen:q,saveMsg:Oe}):(0,A.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col overflow-y-auto custom-scrollbar`,children:(0,A.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,A.jsxs)(`button`,{onClick:()=>{G(!0),j(!1),Ae(!1),I(!1)},className:`inline-flex items-center gap-1 text-xs text-dark-muted hover:text-dark-text transition-colors shrink-0`,children:[`← `,d(`templates.backToView`)]}),(0,A.jsx)(`input`,{value:ve,onChange:e=>Gt(ye)(e.target.value),className:`flex-1 min-w-[200px] px-3 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-sm text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`}),(0,A.jsxs)(S,{variant:`info`,children:[`v`,h.version]}),(0,A.jsx)(S,{variant:h.source.type===`saved`?`success`:`default`,children:s?d(s):h.source.type}),(0,A.jsx)(`button`,{onClick:()=>H(!0),className:`p-2 rounded-lg text-dark-muted hover:text-accent-red hover:bg-dark-hover transition-colors`,title:d(`templates.deleteTemplate`),children:(0,A.jsx)(oe,{className:`w-4 h-4`})})]}),(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:[d(`templates.categoryLabel`),(0,A.jsx)(`span`,{className:`text-badge text-dark-muted/60 ms-1.5`,children:d(`templates.categoryCreateHint`)})]}),(0,A.jsx)(`input`,{value:xe,onChange:e=>Gt(Se)(e.target.value),list:`template-category-suggestions`,className:`w-full px-3 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-sm text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`}),(0,A.jsx)(`datalist`,{id:`template-category-suggestions`,children:Vt.map(e=>(0,A.jsx)(`option`,{value:e},e))})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.descriptionLabel`)}),(0,A.jsx)(`input`,{value:k,onChange:e=>Gt(be)(e.target.value),className:`w-full px-3 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-sm text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap text-xs text-dark-muted`,children:[(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,A.jsx)(ae,{size:13,className:`text-accent-blue`}),d(`templates.nodeCount`,{n:e})]}),(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,A.jsx)(u,{size:13,className:`text-accent-green`}),d(`templates.topologyHint`)]}),r>0&&(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,A.jsx)(n,{size:13,className:`text-accent-yellow`}),d(`templates.inputCount`,{n:r})]}),(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,A.jsx)(ie,{size:13,className:`text-dark-muted/60`}),new Date(h.updatedAt).toLocaleString()]})]}),Ue&&(0,A.jsx)(We,{definition:Ue,inputs:He,issues:nt,onDefinitionChange:qe,onInputsChange:$e}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,A.jsx)(x,{variant:`accent`,leftIcon:(0,A.jsx)(re,{className:`w-4 h-4`}),onClick:()=>Yt(`launch`),children:d(`templates.launchWithTemplate`)}),(0,A.jsxs)(`button`,{onClick:()=>Yt(`preview`),className:`px-4 py-2 rounded-lg border border-dark-border text-dark-text hover:bg-dark-hover transition-colors inline-flex items-center gap-1.5`,children:[(0,A.jsx)(a,{className:`w-4 h-4`}),` `,d(`templates.testRun`)]}),(0,A.jsxs)(`button`,{onClick:()=>I(e=>!e),className:`px-4 py-2 rounded-lg border border-dark-border text-dark-text hover:bg-dark-hover transition-colors inline-flex items-center gap-1.5`,children:[(0,A.jsx)(c,{className:`w-4 h-4`}),` `,d(`templates.versionHistory`)]}),(0,A.jsx)(x,{variant:`accent`,leftIcon:(0,A.jsx)(o,{className:`w-4 h-4`}),onClick:Kt,loading:U,disabled:!De||nt.length>0,title:nt.length>0?d(`templates.editorValidationIssues`):void 0,children:d(`templates.saveChanges`)}),(0,A.jsxs)(`button`,{onClick:()=>Ae(e=>!e),className:`px-4 py-2 rounded-lg border border-dark-border text-dark-text hover:bg-dark-hover transition-colors inline-flex items-center gap-1.5`,children:[(0,A.jsx)(n,{className:`w-4 h-4`}),` `,d(`templates.advancedJson`)]}),(0,A.jsx)(`button`,{onClick:$,className:`p-2 rounded-lg text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,title:d(`templates.refresh`),children:(0,A.jsx)(t,{className:`w-4 h-4`})}),Oe&&(0,A.jsx)(`span`,{className:`text-xs text-dark-muted`,children:Oe})]}),ke&&(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg p-3 space-y-3`,children:[(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.inputsSchemaLabel`)}),(0,A.jsx)(`textarea`,{value:Ce,onChange:e=>{Gt(we)(e.target.value),tt(e.target.value)},rows:5,spellCheck:!1,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-xs font-mono text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.definitionLabel`)}),(0,A.jsx)(`textarea`,{value:Te,onChange:e=>{Gt(Ee)(e.target.value),et(e.target.value)},rows:10,spellCheck:!1,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-xs font-mono text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]}),(0,A.jsx)(`p`,{className:`text-meta text-dark-muted/60`,children:d(`templates.editorAdvancedSyncHint`)})]}),F&&(0,A.jsxs)(`div`,{className:`border border-dark-border rounded-lg p-3 space-y-1.5`,children:[(0,A.jsx)(`div`,{className:`text-xs text-dark-muted mb-1`,children:d(`templates.versionSnapshotLabel`)}),N.length===0&&(0,A.jsx)(`div`,{className:`text-xs text-dark-muted/60`,children:d(`templates.noVersions`)}),N.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsxs)(`button`,{onClick:()=>Xt(e),className:`text-xs px-2 py-1 rounded border border-dark-border hover:border-accent-blue/50 transition-colors`,children:[`v`,e]}),L&&L.version===e&&(0,A.jsx)(`span`,{className:`text-xs text-dark-muted/60`,children:d(`templates.viewingVersion`)})]},e)),L&&(0,A.jsx)(`pre`,{className:`mt-2 p-3 rounded-lg bg-dark-bg text-badge font-mono text-dark-muted max-h-60 overflow-y-auto custom-scrollbar`,children:JSON.stringify({version:L.version,inputs:L.inputs,definition:L.definition},null,2)})]})]})})})(),z&&h&&(0,A.jsxs)(fe,{isOpen:!0,onClose:()=>B(null),title:z.mode===`launch`?d(`templates.replayDrawerTitle`,{name:h.name}):d(`templates.previewModalTitle`,{name:h.name}),size:`md`,children:[(0,A.jsx)(me,{template:h,onCancel:()=>B(null),onSubmit:z.mode===`launch`?Jt:qt,submitLabel:z.mode===`launch`?d(`templates.replayStart`):d(`templates.renderPreview`),submitIcon:z.mode===`launch`?(0,A.jsx)(u,{className:`w-3.5 h-3.5`}):void 0,busy:Ne,autoValues:Xe(h,r),preflightSummary:(0,A.jsx)(Ze,{t:d,detail:h,workspaceDir:r})}),z.mode===`preview`&&Me&&(0,A.jsx)(`div`,{className:`mt-4`,children:Me.ok?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`text-xs text-accent-green mb-1.5`,children:d(`templates.renderSuccess`)}),(0,A.jsx)(`pre`,{className:`p-3 rounded-lg bg-dark-bg text-badge font-mono text-dark-muted max-h-72 overflow-y-auto custom-scrollbar`,children:Me.json})]}):(0,A.jsx)(`div`,{className:`text-xs text-accent-red`,children:Me.error})})]}),(0,A.jsx)(ue,{isOpen:rt,onClose:()=>it(!1),title:d(`templates.newTemplate`),size:`lg`,children:(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.nameLabel`)}),(0,A.jsx)(`input`,{value:at,onChange:e=>ot(e.target.value),placeholder:d(`templates.namePlaceholder`),className:`w-full px-3 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-sm text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.categoryField`)}),(0,A.jsx)(`input`,{value:lt,onChange:e=>ut(e.target.value),className:`w-full px-3 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-sm text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.descriptionField`)}),(0,A.jsx)(`input`,{value:st,onChange:e=>ct(e.target.value),className:`w-full px-3 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-sm text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsxs)(`button`,{type:`button`,onClick:()=>{Ct(!0),Q(``)},className:y(`px-3 py-1.5 rounded-lg border text-xs transition-colors inline-flex items-center gap-1.5`,St?`border-accent-blue text-accent-blue bg-accent-blue/10`:`border-dark-border text-dark-muted hover:border-dark-muted/50 hover:text-dark-text`),children:[(0,A.jsx)(s,{size:12}),` `,d(`templates.aiDraftTab`)]}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>Ct(!1),className:y(`px-3 py-1.5 rounded-lg border text-xs transition-colors inline-flex items-center gap-1.5`,St?`border-dark-border text-dark-muted hover:border-dark-muted/50 hover:text-dark-text`:`border-accent-blue text-accent-blue bg-accent-blue/10`),children:[(0,A.jsx)(n,{size:12}),` `,d(`templates.editorManualTab`)]})]}),St?(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.aiPromptLabel`)}),(0,A.jsx)(`textarea`,{value:wt,onChange:e=>Tt(e.target.value),rows:4,spellCheck:!1,placeholder:d(`templates.aiPromptPlaceholder`),className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-xs text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]}),(0,A.jsx)(x,{variant:`accent`,onClick:()=>void At(),loading:Et,leftIcon:Et?void 0:(0,A.jsx)(s,{className:`w-4 h-4`}),children:d(Et?`templates.aiWorking`:`templates.generateWorkflow`)}),Et&&(0,A.jsx)(`div`,{className:`text-xs text-dark-muted`,children:d(`templates.aiTimeHint`)}),Ot&&(0,A.jsx)(`div`,{className:`text-xs text-accent-red`,children:Ot})]}):(0,A.jsxs)(A.Fragment,{children:[vt&&(0,A.jsx)(We,{definition:vt,inputs:gt,issues:Ft,onDefinitionChange:jt,onInputsChange:Mt}),(0,A.jsx)(`div`,{children:(0,A.jsxs)(`button`,{type:`button`,onClick:()=>xt(e=>!e),className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-dark-border text-xs text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors`,children:[(0,A.jsx)(n,{size:12}),` `,d(`templates.advancedJson`)]})}),bt&&(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.inputsSchemaLabel`)}),(0,A.jsx)(`textarea`,{value:dt,onChange:e=>{ft(e.target.value),Pt(e.target.value)},rows:4,spellCheck:!1,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-xs font-mono text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]}),(0,A.jsxs)(`label`,{className:`block`,children:[(0,A.jsx)(`span`,{className:`text-xs text-dark-muted mb-1 block`,children:d(`templates.definitionLabel`)}),(0,A.jsx)(`textarea`,{value:pt,onChange:e=>{mt(e.target.value),Nt(e.target.value)},rows:10,spellCheck:!1,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-xs font-mono text-dark-text focus:outline-none focus:ring-1 focus:ring-accent-blue`})]}),(0,A.jsx)(`p`,{className:`text-meta text-dark-muted/60`,children:d(`templates.editorAdvancedSyncHint`)})]})]}),ht&&(0,A.jsx)(`div`,{className:`text-xs text-accent-red`,children:ht}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,A.jsx)(`button`,{onClick:()=>it(!1),className:`px-4 py-2 rounded-lg border border-dark-border text-dark-text hover:bg-dark-hover transition-colors`,children:d(`templates.cancel`)}),(0,A.jsx)(x,{variant:`accent`,onClick:()=>void It(),children:d(`templates.create`)})]})]})}),(0,A.jsx)(de,{isOpen:Fe,onClose:()=>H(!1),onConfirm:async()=>{if(!p)return;let e=p;(await b.templates.remove(e)).success&&W.current===e&&(P([]),I(!1),R(null),V(null),B(null),K(`overview`),G(!0),M(``),j(!1),m(null),H(!1),$())},title:d(`templates.deleteTemplate`),message:d(`templates.deleteConfirm`,{name:h?.name||p||``}),confirmText:d(`templates.delete`),variant:`danger`}),(0,A.jsx)(de,{isOpen:Ie!==null,onClose:()=>Le(null),onConfirm:()=>{let e=Ie;Le(null),e&&Ut(e)},title:d(`templates.discardEditsTitle`),message:d(`templates.discardEditsMessage`,{name:h?.name||p||``}),confirmText:d(`templates.discardEditsConfirm`),variant:`danger`})]})}export{$e as TemplatesTab};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,Fn as n,H as r,Ht as i,Rn as a,T as o,Ur as s,W as c,a as l,at as u,br as d,ct as f,gn as p,ht as m,m as h,n as g,nn as _,vr as v,x as y,xr as b,zr as x}from"./icons-BvYhTENi.js";import{t as S}from"./useTranslation-BGmCDuQI.js";import{n as C}from"./state-_ZfNVAsd.js";import{t as w}from"./cn-rx4uumOJ.js";import{C as T,T as E,g as D,r as O,v as k,w as A,y as j}from"./src-49LUQhkG.js";import{$ as M,_ as N,ht as P,mt as ee,t as F}from"./MessageBubble-CV16DZMG.js";import{r as I}from"./api-CCt9DRQm.js";import{I as te}from"./markdown-DAQZeY5V.js";import{n as ne}from"./websocket-C9e3h7VU.js";import{m as L}from"./common-BHXgEvgk.js";var R=400,z=`sessions-changed`;function re(){window.dispatchEvent(new CustomEvent(z))}function ie(e,t={}){let n=t.runChanges??!0,r=-1/0,i=null,a=()=>{let t=Date.now(),n=R-(t-r);n<=0?(r=t,e()):i||=setTimeout(()=>{i=null,r=Date.now(),e()},n)},o=()=>{document.visibilityState===`visible`&&a()};n&&window.addEventListener(z,a),window.addEventListener(`focus`,a),document.addEventListener(`visibilitychange`,o);let s=ne.onOpen(a);return()=>{i&&clearTimeout(i),i=null,n&&window.removeEventListener(z,a),window.removeEventListener(`focus`,a),document.removeEventListener(`visibilitychange`,o),s()}}var B=e(s(),1),V=te(),H=16,ae=2,U=7,oe=2*Math.PI*U,se=(0,B.memo)(function({round:e,maxRounds:t,className:n}){let r=Math.max(0,Math.min(1,t>0?e/t:0));return(0,V.jsxs)(`span`,{className:w(`inline-flex items-center gap-1 shrink-0`,n),children:[(0,V.jsxs)(`svg`,{width:H,height:H,viewBox:`0 0 ${H} ${H}`,"aria-hidden":`true`,className:`shrink-0`,children:[(0,V.jsx)(`circle`,{cx:H/2,cy:H/2,r:U,fill:`none`,strokeWidth:ae,className:`stroke-dark-border`}),(0,V.jsx)(`circle`,{cx:H/2,cy:H/2,r:U,fill:`none`,strokeWidth:ae,strokeLinecap:`round`,strokeDasharray:oe,strokeDashoffset:oe*(1-r),transform:`rotate(-90 ${H/2} ${H/2})`,className:`stroke-accent-blue transition-[stroke-dashoffset] duration-500`})]}),(0,V.jsxs)(`span`,{className:`font-mono text-meta tabular-nums text-dark-muted`,children:[e,`/`,t]})]})}),ce={waiting:`bg-accent-yellow`,review:`bg-accent-blue`,working:`bg-accent-blue`,paused:`bg-accent-yellow`,done:`bg-dark-muted`};function le(e,t){return e===`done`?t===`FAILED`?`bg-accent-red`:t===`CANCELLED`?`bg-dark-muted`:`bg-accent-green`:ce[e]??`bg-dark-muted`}function ue(e,t){return e===`done`?t===`FAILED`?`failed`:t===`CANCELLED`?`erased`:`committed`:`draft`}var de={blocked:`text-accent-yellow`,review:`text-dark-muted`,working:`text-dark-muted`,coordinating:`text-dark-muted`,"claim-blocked":`text-dark-muted`,paused:`text-accent-yellow`,interrupted:`text-accent-yellow`,failed:`text-accent-red`,cancelled:`text-dark-muted`,completed:`text-dark-muted`};function fe(e){return`threads.group.${e}`}function pe(e){return`threads.verb.${e}`}function me(e){return`threads.detail.${e}`}function he(e){return e===`done`}function W(e){return e.slice(0,7)}function ge(e){return/\/(?:pull|pulls)\/(\d+)(?:$|[/?#])/.exec(e??``)?.[1]}function _e(e){if(!e)return[];let t=[];e.branch&&e.commit?t.push(`${e.branch}@${W(e.commit)}`):e.branch?t.push(e.branch):e.commit&&t.push(W(e.commit));let n=ge(e.prUrl);return n?t.push(`PR #${n}`):e.prUrl&&t.push(`PR`),t}function ve(e){return e===`review`||e===`done`}function ye(e,t,n,r){return e===`waiting`||t===`WAITING_COORDINATOR`||t===`BLOCKED_CLAIM`?!1:typeof n==`number`&&typeof r==`number`&&r>0}function be(e,t){if(e!==`done`)return t;let n=t.filter(e=>e.status===`FAILED`);return n.length===0?t:[...n,...t.filter(e=>e.status!==`FAILED`)]}function xe(e){return e.workspaceId?.trim()||`\0unknown-project`}function Se(e){let t=e=>{let t=D.indexOf(e.group);return t===-1?D.length:t};return[...e].sort((e,n)=>t(e)-t(n)||(e.createdAt<n.createdAt?1:e.createdAt>n.createdAt?-1:0))}function Ce(e){let t=new Map;for(let n of e){let e=xe(n),r=t.get(e);r?r.rows.push(n):t.set(e,{key:e,...n.workspaceId?{workspaceId:n.workspaceId}:{},rows:[n]})}let n=e=>e.rows.reduce((e,t)=>{let n=D.indexOf(t.group);return Math.min(e,n===-1?D.length:n)},D.length);for(let e of t.values())e.rows=Se(e.rows);return[...t.values()].sort((e,t)=>n(e)-n(t)||(e.key<t.key?-1:+(e.key>t.key)))}function we(e){return E(e)}var Te=(0,B.memo)(function({thread:e,summary:t,onOpen:n,now:r}){let{t:i}=S(),a=A(e),o=T(e),s=o?i(me(o)):e.group===`working`&&t?.trim()||void 0,c=k(e.createdAt,r),l=ve(e.group)?_e(e.delivery):[],u=ye(e.group,e.status,e.progress?.round,e.progress?.maxRounds),d=ue(e.group,e.status),f=e.title?.trim()||e.alias,p=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:w(`mt-[5px] h-1.5 w-1.5 shrink-0 rounded-full`,le(e.group,e.status)),"aria-hidden":`true`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`span`,{className:`block truncate text-xs text-dark-text`,children:f}),a&&(0,V.jsx)(`span`,{className:`ui-fold`,"data-collapsed":d===`erased`||void 0,children:(0,V.jsxs)(`span`,{className:`block truncate text-meta`,children:[(0,V.jsx)(`span`,{className:w(`font-medium`,de[a]),children:i(pe(a))}),s&&(0,V.jsx)(`span`,{className:`text-dark-muted`,children:` · ${s}`}),l.map(e=>(0,V.jsx)(`span`,{className:`text-dark-muted`,children:` · ${e}`},e))]})})]}),(0,V.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[u&&e.progress&&(0,V.jsx)(se,{round:e.progress.round??0,maxRounds:e.progress.maxRounds??0}),c&&(0,V.jsx)(`span`,{className:`font-mono text-meta tabular-nums text-dark-muted`,children:c})]})]});return n?(0,V.jsx)(`button`,{type:`button`,onClick:()=>n(e.threadId),"aria-label":i(`threads.openThread`,{alias:e.alias}),title:e.title?.trim()||e.alias,className:w(`ui-gram ui-gram--wash flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-start transition-colors hover:bg-dark-hover`,N[d]),"data-testid":`thread-row`,children:p}):(0,V.jsx)(`div`,{className:w(`ui-gram ui-gram--wash flex items-start gap-2 rounded-lg px-2 py-1.5`,N[d]),"data-testid":`thread-row`,children:p})}),Ee=6e4;function De(e={}){let t=e.enabled!==!1,n=P(e=>e.rows),r=P(e=>e.stats),i=P(e=>e.progressSummaries),a=P(e=>e.stale),o=P(e=>e.live),s=P(e=>e.loading),c=P(e=>e.lastError),l=P(e=>e.query),u=P(e=>e.setQuery),d=P(e=>e.disabled),f=P(e=>e.refresh);(0,B.useEffect)(()=>{if(!t)return;let e=P.getState();(e.stale||e.lastFetchedAt===0)&&e.refresh()},[t]),(0,B.useEffect)(()=>{t&&a&&P.getState().scheduleRefresh()},[t,a]),(0,B.useEffect)(()=>{if(!t||typeof document>`u`)return;let e=()=>{document.visibilityState===`visible`&&P.getState().refresh()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t]);let p=Object.values(n).some(e=>e.group!==`done`);return(0,B.useEffect)(()=>{if(!t||!p)return;let e=setInterval(()=>{(typeof document>`u`||document.visibilityState===`visible`)&&P.getState().refresh()},Ee);return()=>clearInterval(e)},[t,p]),{groups:ee(n),order:D,rows:Object.values(n),stats:r,progressSummaries:i,stale:a,live:o,loading:s,lastError:c,query:l,setQuery:u,disabled:d,refresh:()=>void f()}}var Oe=(0,B.memo)(function({label:e,title:t,rows:n,defaultCollapsed:r=!1,testId:i,progressSummaries:a,now:o,onOpen:s}){let{t:c}=S(),[l,u]=(0,B.useState)(r);if(n.length===0)return null;let f=n.filter(e=>e.status===`FAILED`).length;return(0,V.jsxs)(`section`,{className:`select-none`,"data-testid":i,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),"aria-expanded":!l,title:t??c(l?`threads.expandGroup`:`threads.collapseGroup`,{group:e}),className:`flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-start transition-colors hover:bg-dark-hover`,children:[(0,V.jsx)(d,{size:13,className:w(`shrink-0 text-dark-muted transition-transform`,l&&`-rotate-90`),"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`truncate text-xs font-medium text-dark-text`,children:e}),(0,V.jsx)(`span`,{className:`font-mono text-meta tabular-nums text-dark-muted`,children:n.length}),f>0&&(0,V.jsx)(`span`,{className:`font-mono text-meta tabular-nums text-accent-red`,children:f})]}),!l&&(0,V.jsx)(`div`,{className:`space-y-0.5 ps-1`,children:n.map(e=>(0,V.jsx)(Te,{thread:e,summary:a[e.threadId],onOpen:s,now:o},e.threadId))})]})}),ke={open:[],recent:[],loading:!1,stale:!0,live:!1,lastError:null,lastFetchedAt:0,disabled:!1,resolving:{},resolveErrors:{}},Ae=400,G=null;function je(){G!==null&&(clearTimeout(G),G=null)}var K=C()((e,t)=>({...ke,refresh:async()=>{if(!t().loading){e({loading:!0});try{let t=await I.get(`/api/threads/escalations`);if(!t?.success){if(t?.code===`THREADS_DISABLED`){e({disabled:!0,open:[],recent:[],loading:!1,stale:!1,lastError:null,lastFetchedAt:Date.now()});return}throw Error(t?.error||`Escalations query failed`)}e({open:t.data?.open??[],recent:t.data?.recent??[],stale:!1,loading:!1,lastError:null,lastFetchedAt:Date.now(),disabled:!1})}catch(t){e({loading:!1,stale:!0,lastError:t instanceof Error?t.message:String(t),lastFetchedAt:Date.now()})}}},scheduleRefresh:()=>{G===null&&(G=setTimeout(()=>{G=null,t().refresh()},Ae))},resolve:async(n,r,i)=>{if(t().resolving[n])return{ok:!1,error:`already-submitting`};if(!i.trim())return{ok:!1,error:`instruction-required`};e(e=>({resolving:{...e.resolving,[n]:!0}}));try{let a=await I.post(`/api/threads/escalations/${encodeURIComponent(n)}/resolve`,{action:r,instruction:i.trim(),decidedBy:`web-ui`});if(!a?.success){let t=a?.error||`Resolve failed`;return e(e=>({resolving:q(e.resolving,n),resolveErrors:{...e.resolveErrors,[n]:t}})),{ok:!1,error:t}}return e(e=>({resolving:q(e.resolving,n),resolveErrors:q(e.resolveErrors,n)})),t().refresh(),P.getState().scheduleRefresh(),{ok:!0}}finally{t().resolving[n]&&e(e=>({resolving:q(e.resolving,n)}))}},setLive:t=>{e(t?{live:!0}:{live:!1,stale:!0})},reset:()=>{je(),e({...ke})}}));function q(e,t){let n={};for(let[r,i]of Object.entries(e))r!==t&&(n[r]=i);return n}function Me(e={}){let t=e.enabled!==!1,n=K(e=>e.open),r=K(e=>e.recent),i=K(e=>e.loading),a=K(e=>e.lastError),o=K(e=>e.resolving),s=K(e=>e.resolveErrors),c=K(e=>e.disabled),l=K(e=>e.refresh),u=K(e=>e.resolve),d=P(e=>e.stale);return(0,B.useEffect)(()=>{if(!t)return;let e=K.getState();(e.stale||e.lastFetchedAt===0)&&e.refresh()},[t]),(0,B.useEffect)(()=>{t&&d&&K.getState().scheduleRefresh()},[t,d]),(0,B.useEffect)(()=>{if(!t||typeof document>`u`)return;let e=()=>{document.visibilityState===`visible`&&K.getState().refresh()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t]),{open:n,recent:r,loading:i,lastError:a,resolving:o,resolveErrors:s,disabled:c,resolve:u,refresh:()=>void l()}}var Ne=(0,B.memo)(function({onOpenThread:e,className:n}){let{t:r}=S(),{open:i,recent:a,loading:o,lastError:s,resolving:c,resolveErrors:l,resolve:u,refresh:f}=Me(),[p,m]=(0,B.useState)(null),[g,y]=(0,B.useState)(!1),b=(e,t)=>{m({escalationId:e,action:t,instruction:``})},x=async()=>{p&&p.instruction.trim()&&(await u(p.escalationId,p.action,p.instruction)).ok&&m(null)};return(0,V.jsxs)(`section`,{className:w(`shrink-0 rounded-2xl border border-dark-border/60 bg-dark-surface`,`transition-all duration-200 hover:border-accent-blue/40 hover:bg-dark-raised`,n),"data-testid":`escalation-inbox`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,V.jsx)(_,{size:13,className:`text-dark-muted`}),(0,V.jsx)(`span`,{className:`text-xs font-medium text-dark-text`,children:r(`threads.escalation.title`)}),i.length>0&&(0,V.jsx)(`span`,{className:`rounded-full bg-accent-blue px-1.5 py-0.5 font-mono text-badge tabular-nums text-accent-fg`,"data-testid":`escalation-inbox-badge`,children:i.length}),(0,V.jsx)(`div`,{className:`ms-auto`,children:(0,V.jsx)(`button`,{type:`button`,onClick:f,disabled:o,className:`rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text disabled:opacity-50`,title:r(`common.refresh`),"aria-label":r(`common.refresh`),"data-testid":`escalation-inbox-refresh`,children:(0,V.jsx)(t,{size:12,className:w(o&&`animate-spin`)})})})]}),s&&(0,V.jsx)(`div`,{className:`px-3 pb-2`,"data-testid":`escalation-inbox-error`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md bg-dark-hover/60 px-2 py-1.5 text-meta text-dark-muted`,children:[(0,V.jsx)(h,{size:12,className:`shrink-0 text-accent-red`}),(0,V.jsx)(`span`,{className:`truncate`,children:r(`threads.escalation.error`,{message:s})})]})}),i.length===0?(0,V.jsx)(`p`,{className:`px-3 pb-3 text-meta text-dark-muted`,"data-testid":`escalation-inbox-empty`,children:r(`threads.escalation.empty`)}):(0,V.jsx)(`ul`,{className:`px-3 pb-2`,children:i.map(t=>(0,V.jsx)(Pe,{entry:t,draft:p?.escalationId===t.request.escalationId?p:null,resolving:!!c[t.request.escalationId],resolveError:l[t.request.escalationId],onBeginDecide:b,onDraftChange:e=>m(t=>t&&{...t,instruction:e}),onSubmitDraft:x,onCancelDraft:()=>m(null),onOpenThread:e},t.request.escalationId))}),(0,V.jsxs)(`div`,{className:`border-t border-dark-border px-3 py-1.5`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),"aria-expanded":g,className:`flex w-full items-center gap-1 text-meta text-dark-muted transition-colors hover:text-dark-text`,"data-testid":`escalation-recent-toggle`,children:[g?(0,V.jsx)(d,{size:11}):(0,V.jsx)(v,{size:11}),r(`threads.escalation.recent`),a.length>0&&(0,V.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`(`,a.length,`)`]})]}),g&&(0,V.jsx)(Fe,{recent:a,onOpenThread:e})]})]})}),Pe=(0,B.memo)(function({entry:e,draft:t,resolving:n,resolveError:r,onBeginDecide:i,onDraftChange:a,onSubmitDraft:o,onCancelDraft:s,onOpenThread:c}){let{t:l}=S(),u=e.request.escalationId,d=t!==null;return(0,V.jsxs)(`li`,{className:`rounded-md bg-dark-hover/40 px-2.5 py-2`,"data-testid":`escalation-item-${u}`,children:[(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-dark-text`,children:e.request.question}),(0,V.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-meta text-dark-muted`,children:[c?(0,V.jsx)(`button`,{type:`button`,onClick:()=>c(e.request.threadId),className:`font-mono underline-offset-2 hover:text-dark-text hover:underline`,"data-testid":`escalation-thread-${u}`,children:e.request.threadId}):(0,V.jsx)(`span`,{className:`font-mono`,"data-testid":`escalation-thread-${u}`,children:e.request.threadId}),(0,V.jsx)(`span`,{children:`·`}),(0,V.jsx)(`span`,{children:l(`threads.escalation.since`,{time:Ie(e.request.createdAt)})})]}),e.request.context&&(0,V.jsx)(`p`,{className:`mt-1 border-s border-dark-border ps-2 text-meta leading-relaxed text-dark-muted`,children:e.request.context}),r&&(0,V.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1 text-meta text-accent-red`,"data-testid":`escalation-error-${u}`,children:[(0,V.jsx)(h,{size:11,className:`shrink-0`}),l(`threads.escalation.resolveFailed`,{message:r})]}),d&&t?(0,V.jsxs)(`div`,{className:`mt-2`,"data-testid":`escalation-form-${u}`,children:[(0,V.jsx)(`textarea`,{value:t.instruction,onChange:e=>a(e.target.value),placeholder:l(`threads.escalation.instructionPlaceholder`),rows:2,autoFocus:!0,disabled:n,className:`w-full resize-none rounded-md bg-dark-hover/60 px-2 py-1.5 text-meta text-dark-text placeholder:text-dark-muted focus:outline-none focus:ring-1 focus:ring-accent-blue`,"data-testid":`escalation-instruction-${u}`}),(0,V.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:o,disabled:n||!t.instruction.trim(),className:w(`flex items-center gap-1 rounded px-2 py-0.5 text-meta text-accent-fg transition-colors disabled:opacity-50`,t.action===`proceed`?`bg-accent-green`:`bg-accent-red`),"data-testid":`escalation-confirm-${u}`,children:[t.action===`proceed`?(0,V.jsx)(b,{size:10}):(0,V.jsx)(g,{size:10}),n?l(`threads.escalation.deciding`):t.action===`proceed`?l(`threads.escalation.confirmProceed`):l(`threads.escalation.confirmAbort`)]}),(0,V.jsx)(`button`,{type:`button`,onClick:s,disabled:n,className:`rounded px-2 py-0.5 text-meta text-dark-muted transition-colors hover:text-dark-text disabled:opacity-50`,"data-testid":`escalation-cancel-${u}`,children:l(`threads.escalation.cancel`)})]})]}):(0,V.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(u,`proceed`),disabled:n,className:`flex items-center gap-1 rounded bg-accent-green px-2 py-0.5 text-meta text-accent-fg transition-colors hover:opacity-90 disabled:opacity-50`,"data-testid":`escalation-proceed-${u}`,children:[(0,V.jsx)(b,{size:10}),l(`threads.escalation.proceed`)]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(u,`abort`),disabled:n,className:`flex items-center gap-1 rounded bg-accent-red px-2 py-0.5 text-meta text-accent-fg transition-colors hover:opacity-90 disabled:opacity-50`,"data-testid":`escalation-abort-${u}`,children:[(0,V.jsx)(g,{size:10}),l(`threads.escalation.abort`)]})]})]})}),Fe=(0,B.memo)(function({recent:e,onOpenThread:t}){let{t:n}=S();return e.length===0?(0,V.jsx)(`p`,{className:`py-1.5 text-meta text-dark-muted`,"data-testid":`escalation-recent-empty`,children:n(`threads.escalation.recentEmpty`)}):(0,V.jsx)(`ul`,{className:`py-1.5`,children:e.map(e=>{let r=e.request.escalationId,i=e.status===`cancelled`?`resolvedCancelled`:e.outcome?.action===`proceed`?`resolvedProceed`:`resolvedAbort`,a=e.status===`cancelled`?`text-dark-muted`:e.outcome?.action===`proceed`?`text-accent-green`:`text-accent-red`;return(0,V.jsxs)(`li`,{className:`py-1`,"data-testid":`escalation-recent-${r}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-meta`,children:[(0,V.jsx)(`span`,{className:w(`shrink-0 font-medium`,a),children:n(`threads.escalation.${i}`)}),(0,V.jsx)(`span`,{className:`truncate text-dark-muted`,children:e.request.question})]}),(0,V.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-badge text-dark-muted`,children:[e.outcome&&(0,V.jsx)(`span`,{children:n(`threads.escalation.decidedBy`,{by:e.outcome.decidedBy})}),(0,V.jsx)(`span`,{className:`font-mono`,children:t?(0,V.jsx)(`button`,{type:`button`,onClick:()=>t(e.request.threadId),className:`underline-offset-2 hover:text-dark-text hover:underline`,children:e.request.threadId}):e.request.threadId})]})]},r)})})});function Ie(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}var Le={items:[],loading:!1,stale:!0,live:!1,lastError:null,lastFetchedAt:0,disabled:!1,deciding:{},decideErrors:{}},Re=400,J=null;function ze(){J!==null&&(clearTimeout(J),J=null)}function Y(e,t){let n={};for(let r of Object.keys(e))r!==t&&(n[r]=e[r]);return n}var X=C()((e,t)=>({...Le,refresh:async()=>{if(!t().loading){e({loading:!0});try{let t=await I.get(`/api/threads/reviews`);if(!t?.success){if(t?.code===`THREADS_DISABLED`){e({disabled:!0,items:[],loading:!1,stale:!1,lastError:null,lastFetchedAt:Date.now()});return}throw Error(t?.error||`Reviews query failed`)}e({items:t.data?.reviews??[],stale:!1,loading:!1,lastError:null,lastFetchedAt:Date.now(),disabled:!1})}catch(t){e({loading:!1,stale:!0,lastError:t instanceof Error?t.message:String(t),lastFetchedAt:Date.now()})}}},scheduleRefresh:()=>{J===null&&(J=setTimeout(()=>{J=null,t().refresh()},Re))},decide:async(n,r)=>{if(t().deciding[n])return{ok:!1,error:`already-submitting`};e(e=>({deciding:{...e.deciding,[n]:!0}}));try{let i=await I.post(`/api/threads/reviews/${encodeURIComponent(n)}/${r}`,{});if(!i?.success){let t=i?.error||`Decision failed`;return e(e=>({deciding:Y(e.deciding,n),decideErrors:{...e.decideErrors,[n]:t}})),{ok:!1,error:t}}return e(e=>({deciding:Y(e.deciding,n),decideErrors:Y(e.decideErrors,n)})),t().refresh(),P.getState().scheduleRefresh(),{ok:!0}}finally{t().deciding[n]&&e(e=>({deciding:Y(e.deciding,n)}))}},setLive:t=>{e(t?{live:!0}:{live:!1,stale:!0})},reset:()=>{ze(),e({...Le})}}));function Be(e={}){let t=e.enabled!==!1,n=X(e=>e.items),r=X(e=>e.loading),i=X(e=>e.lastError),a=X(e=>e.deciding),o=X(e=>e.decideErrors),s=X(e=>e.disabled),c=X(e=>e.refresh),l=X(e=>e.decide),u=P(e=>e.stale);return(0,B.useEffect)(()=>{if(!t)return;let e=X.getState();(e.stale||e.lastFetchedAt===0)&&e.refresh()},[t]),(0,B.useEffect)(()=>{t&&u&&X.getState().scheduleRefresh()},[t,u]),(0,B.useEffect)(()=>{if(!t||typeof document>`u`)return;let e=()=>{document.visibilityState===`visible`&&X.getState().refresh()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t]),{items:n,loading:r,lastError:i,deciding:a,decideErrors:o,disabled:s,decide:l,refresh:()=>void c()}}var Ve=(0,B.memo)(function({onOpenThread:e,className:r}){let{t:i}=S(),{items:a,loading:o,lastError:s,deciding:c,decideErrors:l,decide:u,refresh:d}=Be();return(0,V.jsxs)(`section`,{className:w(`shrink-0 rounded-2xl border border-dark-border/60 bg-dark-surface`,`transition-all duration-200 hover:border-accent-blue/40 hover:bg-dark-raised`,r),"data-testid":`review-inbox`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,V.jsx)(n,{size:13,className:`text-dark-muted`}),(0,V.jsx)(`span`,{className:`text-xs font-medium text-dark-text`,children:i(`threads.reviewQueue.title`)}),a.length>0&&(0,V.jsx)(`span`,{className:`rounded-full bg-accent-blue px-1.5 py-0.5 font-mono text-badge tabular-nums text-accent-fg`,"data-testid":`review-inbox-badge`,children:a.length}),(0,V.jsx)(`div`,{className:`ms-auto`,children:(0,V.jsx)(`button`,{type:`button`,onClick:d,disabled:o,className:`rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text disabled:opacity-50`,title:i(`common.refresh`),"aria-label":i(`common.refresh`),"data-testid":`review-inbox-refresh`,children:(0,V.jsx)(t,{size:12,className:w(o&&`animate-spin`)})})})]}),s&&(0,V.jsx)(`div`,{className:`px-3 pb-2`,"data-testid":`review-inbox-error`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md bg-dark-hover/60 px-2 py-1.5 text-meta text-dark-muted`,children:[(0,V.jsx)(h,{size:12,className:`shrink-0 text-accent-red`}),(0,V.jsx)(`span`,{className:`truncate`,children:i(`threads.reviewQueue.error`,{message:s})})]})}),a.length===0?(0,V.jsx)(`p`,{className:`px-3 pb-3 text-meta text-dark-muted`,"data-testid":`review-inbox-empty`,children:i(`threads.reviewQueue.empty`)}):(0,V.jsx)(`ul`,{className:`px-3 pb-2`,children:a.map(t=>(0,V.jsx)(He,{item:t,deciding:!!c[t.artifactId],decideError:l[t.artifactId],onDecide:u,onOpenThread:e},t.artifactId))})]})}),He=(0,B.memo)(function({item:e,deciding:t,decideError:n,onDecide:r,onOpenThread:i}){let{t:a}=S(),o=e.artifactId;return(0,V.jsxs)(`li`,{className:`rounded-md bg-dark-hover/40 px-2.5 py-2`,"data-testid":`review-item-${o}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`font-mono text-xs text-dark-text`,"data-testid":`review-logical-${o}`,children:[e.logicalId,`#`,e.version]}),(0,V.jsx)(`span`,{className:w(`rounded px-1 py-0.5 font-mono text-badge`,e.type===`patch`?`bg-accent-amber/15 text-accent-amber`:`bg-dark-hover text-dark-muted`),"data-testid":`review-type-${o}`,children:e.type})]}),(0,V.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-meta text-dark-muted`,children:[i?(0,V.jsx)(`button`,{type:`button`,onClick:()=>i(e.producerThreadId),className:`font-mono underline-offset-2 hover:text-dark-text hover:underline`,"data-testid":`review-thread-${o}`,children:e.producerThreadId}):(0,V.jsx)(`span`,{className:`font-mono`,"data-testid":`review-thread-${o}`,children:e.producerThreadId}),e.createdAt&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{children:`·`}),(0,V.jsx)(`span`,{children:a(`threads.reviewQueue.registered`,{time:Ue(e.createdAt)})})]})]}),n&&(0,V.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1 text-meta text-accent-red`,"data-testid":`review-error-${o}`,children:[(0,V.jsx)(h,{size:11,className:`shrink-0`}),a(`threads.reviewQueue.decideFailed`,{message:n})]}),(0,V.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void r(o,`approve`),disabled:t,className:`flex items-center gap-1 rounded bg-accent-green px-2 py-0.5 text-meta text-accent-fg transition-colors hover:opacity-90 disabled:opacity-50`,"data-testid":`review-approve-${o}`,children:[(0,V.jsx)(b,{size:10}),a(t?`threads.reviewQueue.deciding`:`threads.reviewQueue.approve`)]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>void r(o,`reject`),disabled:t,className:`flex items-center gap-1 rounded bg-accent-red px-2 py-0.5 text-meta text-accent-fg transition-colors hover:opacity-90 disabled:opacity-50`,"data-testid":`review-reject-${o}`,children:[(0,V.jsx)(g,{size:10}),a(`threads.reviewQueue.reject`)]})]})]})});function Ue(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}var We=3e4,Ge=250,Ke=(0,B.memo)(function({onClose:e,onOpenThread:n,workspaceId:r,className:a}){let{t:o}=S(),s=De(),{order:d,stats:f,progressSummaries:m,live:_,loading:v,lastError:y,query:b,setQuery:x,disabled:C,refresh:T}=s,E=(0,B.useMemo)(()=>r?s.rows.filter(e=>e.workspaceId===r):s.rows,[s.rows,r]),D=(0,B.useMemo)(()=>{if(!r)return s.groups;let e={};for(let t of E)e[t.threadId]=t;return ee(e)},[s.groups,E,r]),[O,k]=(0,B.useState)(`status`),[A,j]=(0,B.useState)(b),M=(0,B.useRef)(null);(0,B.useEffect)(()=>{j(b)},[b]),(0,B.useEffect)(()=>()=>{M.current&&clearTimeout(M.current)},[]);let N=e=>{j(e),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>x(e),Ge)},P=(0,B.useMemo)(()=>d.some(e=>e!==`done`&&(D[e]?.length??0)>0),[D,d]),[F,I]=(0,B.useState)(()=>Date.now());(0,B.useEffect)(()=>{if(!P)return;let e=setInterval(()=>I(Date.now()),We);return()=>clearInterval(e)},[P]);let te=(0,B.useMemo)(()=>O===`project`?Ce(E):[],[O,E]),ne=Object.values(D).reduce((e,t)=>e+t.length,0),L=D.waiting.length,R=f&&typeof f.inflight?.threads==`number`&&typeof f.limits?.maxThreads==`number`?o(`threads.running`,{inflight:f.inflight.threads,max:f.limits.maxThreads}):void 0,z=typeof f?.queued?.threads==`number`?f.queued.threads:0;return(0,V.jsxs)(`div`,{className:w(`flex h-full min-h-0 flex-col`,a),children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-3 py-2.5`,children:[L>0&&(0,V.jsx)(`span`,{className:`rounded-full bg-accent-blue px-1.5 py-0.5 font-mono text-badge tabular-nums text-accent-fg`,"data-testid":`threads-waiting-badge`,children:L}),(0,V.jsxs)(`div`,{className:`ms-auto flex items-center gap-0.5`,children:[!r&&(0,V.jsxs)(`div`,{className:`me-0.5 flex items-center rounded-md bg-dark-hover/60 p-0.5`,role:`group`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>k(`status`),"aria-pressed":O===`status`,className:w(`shrink-0 rounded p-1 transition-colors`,O===`status`?`bg-dark-surface text-dark-text`:`text-dark-muted hover:text-dark-text`),title:o(`threads.groupByStatus`),"aria-label":o(`threads.groupByStatus`),"data-testid":`threads-groupby-status`,children:(0,V.jsx)(i,{size:13})}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>k(`project`),"aria-pressed":O===`project`,className:w(`shrink-0 rounded p-1 transition-colors`,O===`project`?`bg-dark-surface text-dark-text`:`text-dark-muted hover:text-dark-text`),title:o(`threads.groupByProject`),"aria-label":o(`threads.groupByProject`),"data-testid":`threads-groupby-project`,children:(0,V.jsx)(p,{size:13})})]}),(0,V.jsx)(`button`,{type:`button`,onClick:T,disabled:v,className:`shrink-0 rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text disabled:opacity-50`,title:o(`common.refresh`),"aria-label":o(`common.refresh`),"data-testid":`threads-refresh`,children:(0,V.jsx)(t,{size:14,className:w(v&&`animate-spin`)})}),e&&(0,V.jsx)(`button`,{type:`button`,onClick:e,className:`shrink-0 rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,title:o(`common.close`),"aria-label":o(`common.close`),children:(0,V.jsx)(g,{size:14})})]})]}),C&&(0,V.jsx)(`div`,{className:`shrink-0 px-3 pb-3`,"data-testid":`threads-disabled`,children:(0,V.jsx)(Z,{tone:`info`,icon:(0,V.jsx)(u,{size:12}),text:o(`threads.disabled`)})}),!C&&(0,V.jsxs)(`div`,{className:`shrink-0 px-3 pb-2`,children:[!r&&(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(c,{size:13,className:`pointer-events-none absolute start-2 top-1/2 -translate-y-1/2 text-dark-muted`}),(0,V.jsx)(`input`,{type:`text`,value:A,onChange:e=>N(e.target.value),placeholder:o(`threads.searchPlaceholder`),"aria-label":o(`threads.searchPlaceholder`),"data-testid":`threads-search`,className:`w-full rounded-md bg-dark-hover/60 py-1 ps-7 pe-7 text-xs text-dark-text placeholder:text-dark-muted focus:outline-none focus:ring-1 focus:ring-accent-blue`}),A&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>N(``),title:o(`threads.searchClear`),"aria-label":o(`threads.searchClear`),"data-testid":`threads-search-clear`,className:`absolute end-1.5 top-1/2 -translate-y-1/2 rounded p-0.5 text-dark-muted transition-colors hover:text-dark-text`,children:(0,V.jsx)(g,{size:12})})]}),b.trim()&&(0,V.jsx)(`p`,{className:`mt-1 text-badge text-dark-muted`,"data-testid":`threads-search-note`,children:o(`threads.searchActive`,{q:b.trim()})})]}),!C&&(0,V.jsxs)(`div`,{className:`shrink-0 px-3 pb-2 pt-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-dark-text`,children:o(`threads.greeting`)}),(0,V.jsx)(`p`,{className:`mt-0.5 text-xs text-dark-muted`,"data-testid":`threads-waiting-line`,children:L>0?o(`threads.waitingOnYou`,{count:L}):o(`threads.nothingWaiting`)}),R&&(0,V.jsxs)(`p`,{className:`mt-1.5 font-mono text-meta tabular-nums text-dark-muted`,children:[R,z>0&&` · ${o(`threads.queued`,{count:z})}`]})]}),!C&&(0,V.jsx)(Ne,{onOpenThread:n,className:`mx-3 mb-4`}),!C&&(0,V.jsx)(Ve,{onOpenThread:n,className:`mx-3 mb-4`}),!C&&(!_||y)&&(0,V.jsx)(`div`,{className:`shrink-0 px-3 pb-2`,"data-testid":`threads-status-banner`,children:_?(0,V.jsx)(Z,{tone:`error`,icon:(0,V.jsx)(h,{size:12}),text:o(`threads.refreshFailed`,{message:y??``}),action:(0,V.jsx)(`button`,{type:`button`,onClick:T,className:`underline hover:no-underline`,children:o(`threads.retry`)})}):(0,V.jsx)(Z,{tone:`warn`,icon:(0,V.jsx)(l,{size:12}),text:o(`threads.offline`)})}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-2 pb-3 custom-scrollbar`,children:ne===0?C?null:(0,V.jsxs)(`div`,{className:`px-3 py-8 text-center`,"data-testid":`threads-empty`,children:[(0,V.jsx)(`p`,{className:`text-xs text-dark-text`,children:o(`threads.empty`)}),(0,V.jsx)(`p`,{className:`mt-1 text-meta leading-relaxed text-dark-muted`,children:o(`threads.emptyHint`)})]}):O===`status`?d.map(e=>(0,V.jsx)(Oe,{label:o(fe(e)),rows:be(e,D[e]??[]),defaultCollapsed:he(e),testId:`threads-section-${e}`,progressSummaries:m,now:F,onOpen:n},e)):te.map(e=>{let t=we(e.workspaceId);return(0,V.jsx)(Oe,{label:t??o(`threads.noWorkspace`),title:e.workspaceId??o(`threads.noWorkspace`),rows:e.rows,testId:`threads-project-${e.key}`,progressSummaries:m,now:F,onOpen:n},e.key)})})]})});function Z({tone:e,icon:t,text:n,action:r}){return(0,V.jsxs)(`div`,{className:w(`flex items-start gap-1.5 rounded-lg border px-2 py-1.5 text-meta leading-relaxed`,e===`error`?`border-accent-red/40 bg-accent-red/10 text-accent-red`:e===`info`?`border-dark-border bg-dark-hover/50 text-dark-muted`:`border-accent-yellow/40 bg-accent-yellow/10 text-accent-yellow`),children:[(0,V.jsx)(`span`,{className:`mt-[1px] shrink-0`,children:t}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1`,children:n}),r&&(0,V.jsx)(`span`,{className:`shrink-0`,children:r})]})}function qe(){return{activities:{},order:[],taskTitles:{},artifacts:[]}}var Je=C()(e=>({bySession:{},applyEvent:(t,n)=>e(e=>{let r=e.bySession[t]??qe();switch(n.type){case`activity_started`:return r.activities[n.activity.id]?e:{...e,bySession:{...e.bySession,[t]:{...r,activities:{...r.activities,[n.activity.id]:n.activity},order:[...r.order,n.activity.id]}}};case`activity_updated`:{let i=r.activities[n.activityId];return i?{...e,bySession:{...e.bySession,[t]:{...r,activities:{...r.activities,[n.activityId]:{...i,...n.patch}}}}}:e}case`activity_finalized`:{let i=r.activities[n.activityId];return i?{...e,bySession:{...e.bySession,[t]:{...r,activities:{...r.activities,[n.activityId]:{...i,status:n.status,endedAt:n.endedAt}}}}}:e}case`artifact_produced`:return r.artifacts.some(e=>e.id===n.artifact.id)?e:{...e,bySession:{...e.bySession,[t]:{...r,artifacts:[...r.artifacts,n.artifact]}}};case`task_title_set`:return{...e,bySession:{...e.bySession,[t]:{...r,taskTitles:{...r.taskTitles,[n.messageId]:n.title}}}};case`next_action_set`:return{...e,bySession:{...e.bySession,[t]:{...r,nextAction:n.text??void 0}}};default:return e}}),resetSession:t=>e(e=>{if(!e.bySession[t])return e;let n={...e.bySession};return delete n[t],{bySession:n}}),finalizeSession:(t,n)=>e(e=>{let r=e.bySession[t];if(!r)return e;let i=Date.now(),a=[`pending`,`running`,`paused`,`waiting_user`],o=!1,s={};for(let[e,t]of Object.entries(r.activities))a.includes(t.status)?(s[e]={...t,status:n,endedAt:i},o=!0):s[e]=t;return o?{...e,bySession:{...e.bySession,[t]:{...r,activities:s}}}:e}),markStatus:(t,n,r)=>e(e=>{let i=e.bySession[t];if(!i)return e;let a=!1,o={};for(let[e,t]of Object.entries(i.activities))n.includes(t.status)?(o[e]={...t,status:r},a=!0):o[e]=t;return a?{...e,bySession:{...e.bySession,[t]:{...i,activities:o}}}:e})}));function Ye(e,t){if(!t)return;let n=e.bySession[t];if(n)for(let e=n.order.length-1;e>=0;e--){let t=n.order[e];if(!t)continue;let r=n.activities[t];if(r&&(r.status===`running`||r.status===`waiting_user`||r.status===`paused`||r.status===`blocked`))return r}}function Xe(e){return e===`running`||e===`waiting`}function Ze({sessionId:e,status:t,fallback:n}){let r=Je(t=>{let n=t.bySession[e];if(n)for(let e=n.order.length-1;e>=0;e--){let t=n.order[e],r=t?n.activities[t]:void 0;if(r)return r.title}});return Xe(t)&&r?(0,V.jsx)(`span`,{"data-session-activity":`live`,className:`line-clamp-2 min-w-0 flex-1 text-dark-muted/70`,title:r,children:r}):n?(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}):null}var Qe=[`pause`,`resume`,`cancel`];function $e(e){return Qe.includes(e)}function et(e){return Qe.filter(t=>e.allowedActions.includes(t))}var tt=(0,B.memo)(function({thread:e,onControlled:t,className:n}){let{t:r}=S(),[i,a]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>{a(null),c(null),u(!1)},[e.threadId]);let d=(0,B.useCallback)(async n=>{if(i)return;a(n),c(null);let o=await I.post(`/api/threads/${encodeURIComponent(e.threadId)}/${n}`,{expectedStatus:e.status});a(null),t(),o?.success||c(o?.error||r(`threads.controlFailed`))},[i,e.threadId,e.status,t,r]),p=et(e),h=e.allowedActions.filter(e=>!$e(e));if(p.length===0&&h.length===0)return(0,V.jsx)(`p`,{className:w(`text-meta text-dark-muted`,n),children:r(`threads.factNoActions`)});let g={pause:m,resume:f,cancel:o},_={pause:r(`threads.action.pause`),resume:r(`threads.action.resume`),cancel:r(`threads.action.cancel`)};return(0,V.jsxs)(`div`,{className:w(`space-y-1.5`,n),children:[p.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:p.map(e=>{let t=g[e],n=e===`cancel`;return(0,V.jsxs)(`button`,{type:`button`,"data-testid":`thread-action-${e}`,disabled:i!==null,onClick:()=>n?u(!0):void d(e),className:w(`inline-flex items-center gap-1 rounded border px-2 py-1 text-meta transition-colors`,`disabled:cursor-not-allowed disabled:opacity-50`,n?`border-accent-red/40 text-accent-red hover:bg-accent-red/10`:`border-dark-border text-dark-text hover:bg-dark-hover`),children:[(0,V.jsx)(t,{size:11}),_[e]]},e)})}),h.length>0&&(0,V.jsx)(`p`,{className:`text-badge text-dark-muted`,"data-testid":`thread-actions-elsewhere`,children:r(`threads.actionsElsewhere`,{actions:h.join(` · `)})}),s&&(0,V.jsx)(`p`,{className:`text-meta text-accent-red`,role:`alert`,"data-testid":`thread-control-error`,children:s}),(0,V.jsx)(L,{isOpen:l,onClose:()=>u(!1),onConfirm:()=>void d(`cancel`),title:r(`threads.cancelConfirmTitle`),message:r(`threads.cancelConfirm`),confirmText:r(`threads.cancelConfirmAction`),variant:`danger`})]})}),nt={claim:`threads.goal.blockerClaim`,escalation:`threads.goal.blockerEscalation`,approval:`threads.goal.blockerApproval`},rt=(0,B.memo)(function({snapshot:e,className:t}){let{t:n}=S(),r=new Map(e.nodes.map(e=>[e.id,e.title])),i=e=>r.get(e)??e;return(0,V.jsxs)(`section`,{"data-testid":`thread-goal-snapshot`,className:w(`rounded-lg border border-dark-border px-2 py-2`,t),children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(y,{size:13,className:`shrink-0 text-dark-muted`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`truncate text-xs font-medium text-dark-text`,children:e.goal}),(0,V.jsx)(`span`,{className:`ms-auto shrink-0 font-mono text-meta tabular-nums text-dark-muted`,"data-testid":`thread-goal-revision`,title:n(`threads.goal.revisionTitle`),children:n(`threads.goal.revision`,{n:e.revision})})]}),(0,V.jsx)(`ul`,{className:`mt-1.5 space-y-1 ps-4`,children:e.nodes.map(e=>{let t=e.parentIds??[];return(0,V.jsxs)(`li`,{"data-testid":`thread-goal-node`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,V.jsx)(`span`,{className:`truncate text-dark-text`,children:e.title}),(0,V.jsx)(`span`,{className:`shrink-0 font-mono text-meta tabular-nums text-dark-muted`,children:e.status}),(0,V.jsx)(`span`,{className:`ms-auto flex shrink-0 items-center gap-1`,children:e.threadIds.map(e=>(0,V.jsx)(M,{threadId:e},e))})]}),t.length>0&&(0,V.jsx)(`div`,{className:`mt-0.5 truncate text-meta text-dark-muted`,"data-testid":`thread-goal-node-deps`,title:t.map(i).join(`, `),children:n(`threads.goal.dependsOn`,{names:t.map(i).join(`, `)})})]},e.id)})}),(0,V.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-meta text-dark-muted`,children:[(0,V.jsx)(`span`,{"data-testid":`thread-goal-active`,children:n(`threads.goal.activeThreads`,{n:e.activeThreads.length})}),(0,V.jsx)(`span`,{"data-testid":`thread-goal-blockers`,children:n(`threads.goal.blockers`,{n:e.blockers.length})}),e.openEscalations>0&&(0,V.jsx)(`span`,{className:`text-accent-red`,"data-testid":`thread-goal-escalations`,children:n(`threads.goal.openEscalations`,{n:e.openEscalations})})]}),e.blockers.length>0&&(0,V.jsx)(`ul`,{className:`mt-1 space-y-0.5 ps-4`,children:e.blockers.map(e=>(0,V.jsx)(`li`,{className:`text-meta text-dark-muted`,children:n(nt[e.kind]??`threads.goal.blockerUnknown`,{ref:e.ref})},`${e.kind}:${e.ref}:${e.threadId}`))})]})});function it({tail:e,path:t}){let{t:n}=S();return e?e.missing||e.lines.length===0?(0,V.jsxs)(`div`,{className:`mt-0.5 ps-4 text-meta text-dark-muted`,"data-testid":`thread-worktree-service-log`,children:[(0,V.jsx)(`div`,{children:n(`threads.services.logMissing`)}),(0,V.jsx)(`div`,{className:`truncate font-mono`,title:t,children:t})]}):(0,V.jsxs)(`div`,{className:`mt-0.5 ps-4`,"data-testid":`thread-worktree-service-log`,children:[(0,V.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-all rounded bg-dark-surface p-1 font-mono text-meta leading-snug text-dark-muted`,children:e.lines.join(`
|
|
2
|
+
`)}),e.truncated&&(0,V.jsx)(`div`,{className:`mt-0.5 text-meta text-dark-muted`,children:n(`threads.services.logTruncated`)})]}):(0,V.jsx)(`div`,{className:`mt-0.5 ps-4 text-meta text-dark-muted`,children:n(`threads.services.logLoading`)})}var at={running:`bg-accent-green`,exited:`bg-accent-yellow`,stopped:`bg-dark-muted`},ot=(0,B.memo)(function({ownerKey:e,services:t,className:n}){let{t:i}=S(),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)({}),l=t=>{a===t.name?o(null):(o(t.name),!s[t.name]&&I.get(`/api/worktree-services/log?sessionId=${encodeURIComponent(e)}&name=${encodeURIComponent(t.name)}&tail=200`).then(e=>{c(n=>({...n,[t.name]:e?.success&&e.data?e.data:{lines:[],truncated:!1,missing:!0}}))}))};return(0,V.jsxs)(`section`,{"data-testid":`thread-worktree-services`,className:w(`rounded-lg border border-dark-border px-2 py-2`,n),children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(r,{size:13,className:`shrink-0 text-dark-muted`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`truncate text-xs font-medium text-dark-text`,children:i(`threads.services.title`)}),(0,V.jsx)(`span`,{className:`ms-auto shrink-0 font-mono text-meta tabular-nums text-dark-muted`,children:t.length})]}),(0,V.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:t.map(e=>{let t=a===e.name;return(0,V.jsxs)(`li`,{"data-testid":`thread-worktree-service`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,V.jsx)(`span`,{className:w(`h-1.5 w-1.5 shrink-0 rounded-full`,at[e.status]??`bg-dark-muted`),"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`truncate text-dark-text`,children:e.name}),(0,V.jsx)(`span`,{className:`shrink-0 font-mono text-meta text-dark-muted`,"data-testid":`thread-worktree-service-status`,children:e.status}),(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`ms-auto shrink-0 truncate font-mono text-meta text-accent-blue hover:underline`,"data-testid":`thread-worktree-service-url`,children:e.url}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>l(e),"aria-expanded":t,"aria-label":i(`threads.services.toggleLog`),title:i(`threads.services.toggleLog`),className:`shrink-0 rounded p-0.5 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,"data-testid":`thread-worktree-service-log-toggle`,children:t?(0,V.jsx)(d,{size:12}):(0,V.jsx)(v,{size:12})})]}),t&&(0,V.jsx)(it,{tail:s[e.name],path:e.resultPath})]},e.name)})})]})});function st(e){let t=[];return e.forEach((e,n)=>{if(O(e.kind))return;let r=e.type===`user`?`user`:e.type===`assistant`?`assistant`:null;if(!r)return;let i=typeof e.content==`string`?e.content:``,a=typeof e.thinking==`string`&&e.thinking?e.thinking:void 0;(i.trim()||a)&&t.push({id:e.id||`thread-msg-${n}`,type:r,content:i,timestamp:typeof e.timestamp==`number`?e.timestamp:0,thinking:a})}),t}var ct=(0,B.memo)(function({sessionId:e,reloadKey:t=0,className:n}){let{t:r}=S(),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!e){a(null);return}let t=!1;return s(!0),(async()=>{let n=await I.get(`/api/sessions/${encodeURIComponent(e)}/messages`);t||(n?.success?(a(Array.isArray(n.data)?n.data:[]),l(null)):(l(n?.error||`request failed`),a(null)),s(!1))})(),()=>{t=!0}},[e,t]);let u=(0,B.useMemo)(()=>i?st(i):[],[i]);return e?c?(0,V.jsx)(`p`,{className:w(`mt-3 text-meta text-accent-red`,n),"data-testid":`thread-conversation-error`,children:r(`threads.conversationFailed`,{message:c})}):i===null?(0,V.jsx)(`p`,{className:w(`mt-3 text-meta text-dark-muted`,n),"data-testid":`thread-conversation-loading`,children:o?r(`threads.conversationLoading`):null}):u.length===0?(0,V.jsx)(`p`,{className:w(`mt-3 text-meta text-dark-muted`,n),"data-testid":`thread-conversation-empty`,children:r(`threads.conversationEmpty`)}):(0,V.jsx)(`div`,{className:w(`mt-3 min-w-0`,n),"data-testid":`thread-conversation`,children:u.map(t=>(0,V.jsx)(F,{message:t,sessionId:e},t.id))}):null});function lt({detail:e,className:t}){let{t:n}=S(),r=e.thread;return(0,V.jsxs)(`div`,{className:w(`min-w-0`,t),children:[(0,V.jsxs)(`dl`,{className:`mt-3 space-y-1.5 text-meta`,"data-testid":`thread-detail-facts`,children:[(0,V.jsx)(Q,{label:n(`threads.factWorkspace`),value:r.workspaceId,mono:!0}),(0,V.jsx)(Q,{label:n(`threads.factIsolation`),value:r.isolation.mode===`shared`?n(`threads.isolationShared`):r.isolation.branch?n(`threads.isolationBranch`,{branch:r.isolation.branch}):n(`threads.isolationIsolated`)}),r.model&&(0,V.jsx)(Q,{label:n(`threads.factModel`),value:r.model,mono:!0}),r.delivery?.branch&&(0,V.jsx)(Q,{label:n(`threads.factBranch`),value:r.delivery.branch,mono:!0}),r.delivery?.commit&&(0,V.jsx)(Q,{label:n(`threads.factCommit`),value:W(r.delivery.commit),mono:!0}),r.delivery?.prUrl&&(0,V.jsx)(ut,{label:n(`threads.factPr`),url:r.delivery.prUrl}),r.parentThreadId&&(0,V.jsx)(Q,{label:n(`threads.factParent`),value:r.parentThreadId,mono:!0}),r.detached&&(0,V.jsx)(Q,{label:n(`threads.factDetached`),value:n(`threads.detachedValue`)}),(0,V.jsx)(Q,{label:n(`threads.factCreated`),value:k(r.createdAt)??r.createdAt})]}),(0,V.jsxs)($,{title:n(`threads.sectionBudget`),testId:`thread-detail-budget`,children:[r.progress?.maxRounds==null?(0,V.jsx)(`p`,{className:`text-meta text-dark-muted`,children:n(`threads.noBudget`)}):(0,V.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,V.jsx)(se,{round:r.progress.round??0,maxRounds:r.progress.maxRounds})}),e.usage?(0,V.jsxs)(`p`,{className:`mt-1 font-mono text-meta text-dark-muted`,children:[n(`threads.usageTokens`,{in:e.usage.tokensIn,out:e.usage.tokensOut}),e.budgetVerdict&&(0,V.jsxs)(`span`,{className:w(`ms-2`,e.budgetVerdict.level===`exceeded`?`text-accent-red`:e.budgetVerdict.level===`warn`?`text-accent-yellow`:`text-dark-muted`),children:[n(`threads.usageUtilization`,{percent:Math.round(e.budgetVerdict.utilization*100)}),e.budgetVerdict.reason?` (${e.budgetVerdict.reason})`:``]})]}):(0,V.jsx)(`p`,{className:`mt-1 text-meta text-dark-muted`,children:n(`threads.noActiveRun`)})]}),(0,V.jsx)($,{title:n(`threads.sectionArtifacts`),testId:`thread-detail-artifacts`,children:(0,V.jsx)(dt,{artifacts:e.artifacts})})]})}function Q({label:e,value:t,mono:n}){return t?(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(`dt`,{className:`w-[74px] shrink-0 text-dark-muted`,children:e}),(0,V.jsx)(`dd`,{className:w(`min-w-0 flex-1 break-words text-dark-text`,n&&`font-mono text-meta`),children:t})]}):null}function ut({label:e,url:t}){return(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(`dt`,{className:`w-[74px] shrink-0 text-dark-muted`,children:e}),(0,V.jsx)(`dd`,{className:`min-w-0 flex-1 break-words`,children:(0,V.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer noopener`,className:`font-mono text-meta text-accent-blue underline-offset-2 hover:underline`,children:t})})]})}function $({title:e,testId:t,children:n}){return(0,V.jsxs)(`section`,{className:`mt-4`,"data-testid":t,children:[(0,V.jsx)(`h3`,{className:`mb-1.5 text-meta font-medium text-dark-text`,children:e}),n]})}function dt({artifacts:e}){let{t}=S();return e.length===0?(0,V.jsx)(`p`,{className:`text-meta text-dark-muted`,children:t(`threads.noArtifacts`)}):(0,V.jsx)(`ul`,{className:`space-y-1`,children:j(e).map(e=>{let n=e[0];return(0,V.jsxs)(`li`,{className:`rounded-lg border border-dark-border px-2 py-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-meta text-dark-text`,children:n.logicalId}),(0,V.jsxs)(`span`,{className:`shrink-0 font-mono text-meta text-dark-muted`,children:[`v`,n.version]})]}),(0,V.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 text-meta text-dark-muted`,children:[(0,V.jsx)(`span`,{children:n.type}),(0,V.jsx)(`span`,{children:n.status}),n.reviewRequired&&(0,V.jsxs)(`span`,{children:[`review: `,n.reviewState]}),e.length>1&&(0,V.jsx)(`span`,{children:t(`threads.artifactVersions`,{count:e.length})})]})]},n.logicalId)})})}var ft=(0,B.memo)(function({threadId:e,onBack:n,onOpenSession:r,className:i}){let{t:o}=S(),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)([]),[p,m]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null),v=(0,B.useCallback)(async()=>{m(!0);try{let[t,n,r]=await Promise.all([I.get(`/api/threads/${encodeURIComponent(e)}`),I.get(`/api/threads/goal-snapshot?thread=${encodeURIComponent(e)}`),I.get(`/api/worktree-services?sessionId=${encodeURIComponent(e)}`)]);if(u(n?.success&&n.data&&Array.isArray(n.data.nodes)?n.data:null),f(r?.success&&r.data&&Array.isArray(r.data.services)?r.data.services:[]),!t?.success||!t.data)throw Error(t?.error||`not found`);c(t.data),_(null);let i=P.getState().rows[t.data.thread.threadId];i&&i.status!==t.data.thread.status&&P.getState().refresh()}catch(e){c(null),_(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e]);(0,B.useEffect)(()=>{v()},[v]),(0,B.useEffect)(()=>{let e=()=>void v();return window.addEventListener(`worktree-services-changed`,e),()=>window.removeEventListener(`worktree-services-changed`,e)},[v]);let y=(0,B.useCallback)(()=>{v(),P.getState().refresh()},[v]),b=s?.thread,C=b?A(b):void 0;return(0,V.jsxs)(`div`,{className:w(`flex h-full min-h-0 flex-col`,i),children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 border-b border-dark-border px-2 py-2.5`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:n,className:`shrink-0 rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,title:o(`common.back`),"aria-label":o(`common.back`),"data-testid":`thread-detail-back`,children:(0,V.jsx)(x,{size:14})}),(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-dark-muted`,children:o(`threads.title`)}),(0,V.jsx)(`span`,{className:`shrink-0 text-xs text-dark-muted`,"aria-hidden":`true`,children:`›`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-dark-text`,title:b?.title,"data-testid":`thread-detail-title`,children:b?.title?.trim()||b?.alias||e}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:p,className:`shrink-0 rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text disabled:opacity-50`,title:o(`common.refresh`),"aria-label":o(`common.refresh`),"data-testid":`thread-detail-refresh`,children:(0,V.jsx)(t,{size:13,className:w(p&&`animate-spin`)})})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3 custom-scrollbar`,children:[g&&(0,V.jsxs)(`div`,{className:`flex items-start gap-1.5 rounded-lg border border-accent-red/40 bg-accent-red/10 px-2 py-1.5 text-meta leading-relaxed text-accent-red`,"data-testid":`thread-detail-error`,children:[(0,V.jsx)(h,{size:12,className:`mt-[1px] shrink-0`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1`,children:o(`threads.detailLoadFailed`,{message:g})})]}),!s&&p&&!g&&(0,V.jsx)(`p`,{className:`text-meta text-dark-muted`,"data-testid":`thread-detail-loading`,children:o(`common.loading`)}),b&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(`span`,{className:w(`mt-[5px] h-1.5 w-1.5 shrink-0 rounded-full`,le(b.group,b.status)),"aria-hidden":`true`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C&&(0,V.jsx)(`p`,{className:w(`text-xs font-medium`,de[C]),children:o(pe(C))}),(0,V.jsx)(`p`,{className:`mt-0.5 font-mono text-meta text-dark-muted`,children:b.status})]}),(0,V.jsx)(`span`,{className:`shrink-0 font-mono text-meta text-dark-muted`,children:b.alias})]}),r&&b.sessionId&&(0,V.jsxs)(`button`,{type:`button`,onClick:()=>r(b),className:`mt-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-accent-blue/40 bg-accent-blue/10 px-2 py-1.5 text-meta text-accent-blue transition-colors hover:bg-accent-blue/15`,"data-testid":`thread-detail-open-session`,children:[(0,V.jsx)(a,{size:12,"aria-hidden":`true`}),o(`threads.openSession`)]}),(0,V.jsx)($,{title:o(`threads.sectionConversation`),testId:`thread-detail-conversation`,children:(0,V.jsx)(ct,{sessionId:b.sessionId})}),l&&(0,V.jsx)(rt,{snapshot:l,className:`mt-3`}),d.length>0&&(0,V.jsx)(ot,{ownerKey:e,services:d,className:`mt-3`}),(0,V.jsx)(lt,{detail:s}),(0,V.jsx)($,{title:o(`threads.sectionControl`),testId:`thread-detail-control`,children:(0,V.jsx)(tt,{thread:b,onControlled:y})})]})]}),b&&pt(b.group)&&(0,V.jsx)(`div`,{className:`shrink-0 px-3 pt-1 text-meta`,children:(0,V.jsx)(Ze,{sessionId:b.sessionId,status:mt(b.group)})})]})});function pt(e){return e===`working`||e===`waiting`||e===`review`}function mt(e){return e===`working`?`running`:e===`waiting`||e===`review`?`waiting`:`done`}var ht=(0,B.memo)(function({onOpenSession:e,focusThread:t,className:n}){let[r,i]=(0,B.useState)(null),a=(0,B.useCallback)(t=>{i(t);let n=P.getState().rows[t];n&&e?.(n)},[e]);return(0,B.useEffect)(()=>{t?.id&&i(t.id)},[t]),r?(0,V.jsx)(ft,{threadId:r,onBack:()=>i(null),onOpenSession:e,className:n}):(0,V.jsx)(Ke,{onOpenThread:a,className:n})});export{Ye as a,De as c,fe as d,re as f,Xe as i,Te as l,ft as n,Je as o,ie as p,Ze as r,Ke as s,ht as t,_e as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,Rr as n,Ur as r,Vn as i,W as a,Xt as o,Z as s,_ as ee,br as c,ft as l,m as te,n as ne,p as re,r as u,v as d,vr as f,xr as p,z as m}from"./icons-BvYhTENi.js";import{t as ie}from"./useTranslation-BGmCDuQI.js";import{n as h}from"./cn-rx4uumOJ.js";import{t as g}from"./api-CCt9DRQm.js";import{I as _}from"./markdown-DAQZeY5V.js";import{A as v,a as y,f as b,h as ae,s as x}from"./common-BHXgEvgk.js";var S=e(r(),1),C=_(),w={critical:0,high:1,medium:2,low:3},T={critical:`bg-accent-red/20 text-accent-red`,high:`bg-accent-red/15 text-accent-red`,medium:`bg-accent-yellow/20 text-accent-yellow`,low:`bg-accent-green/20 text-accent-green`};function E(e,t){let n=`tools.cat.${e}`,r=t(n);if(r&&r!==n)return r;let i=e.replace(/_/g,` `).trim();return i?i.charAt(0).toUpperCase()+i.slice(1):t(`tools.groupUncategorized`)}function D(e,t){switch(e){case`critical`:return t(`tools.riskCritical`);case`high`:return t(`tools.riskHigh`);case`medium`:return t(`tools.riskMedium`);case`low`:return t(`tools.riskLow`);default:return t(`tools.riskUnknown`)}}function oe(e,t,n){let r=new Map;for(let i of e){let e,a,o=0;t===`risk`?(e=i.risk??`unknown`,a=D(i.risk,n),o=w[e]??99):t===`state`?(e=i.enabled?`on`:`off`,a=i.enabled?n(`tools.enabled`):n(`tools.disabled`),o=+!i.enabled):(e=i.category||`__none__`,a=i.category?E(i.category,n):n(`tools.groupUncategorized`));let s=r.get(e);s||(s={key:e,label:a,tools:[],order:o},r.set(e,s)),s.tools.push(i)}for(let e of r.values())e.tools.sort((e,t)=>e.enabled===t.enabled?e.id.localeCompare(t.id):e.enabled?-1:1);return[...r.values()].sort((e,n)=>t===`category`?n.tools.length-e.tools.length||e.label.localeCompare(n.label):e.order-n.order||e.label.localeCompare(n.label))}function se(e,t){try{if(typeof URL.createObjectURL!=`function`)return!1;let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);return i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r),!0}catch{return!1}}function O(){let{t:e}=ie(),[r,_]=(0,S.useState)([]),[w,E]=(0,S.useState)(!0),[O,k]=(0,S.useState)(null),[A,ce]=(0,S.useState)(``),[j,le]=(0,S.useState)(`category`),[M,N]=(0,S.useState)(new Set),[ue,P]=(0,S.useState)(null),[de,F]=(0,S.useState)(null),[I,L]=(0,S.useState)({name:``,description:``,category:``,enabled:!0}),[R,z]=(0,S.useState)(null),[B,V]=(0,S.useState)(null),[H,fe]=(0,S.useState)(0),[pe,me]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),G=(0,S.useRef)(null),K=(0,S.useCallback)(async()=>{E(!0),k(null);let[t,n]=await Promise.all([g.tools.list(),g.tools.exportConfig()]);t.success&&Array.isArray(t.data)?_(t.data):t.success&&t.data&&!Array.isArray(t.data)?k(e(`tools.invalidData`)):k(t.error||e(`tools.loadFailed`)),n.success&&n.data&&(V(n.data.path??null),fe(Object.keys(n.data.tools??{}).length),me(n.data.profile??null)),E(!1)},[e]);(0,S.useEffect)(()=>{K()},[K]);let he=(0,S.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`switch-tab`,{detail:`connectors`}))},[]),q=(0,S.useMemo)(()=>{let e=A.trim().toLowerCase();return e?r.filter(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.category.toLowerCase().includes(e)):r},[r,A]),J=(0,S.useMemo)(()=>oe(q,j,e),[q,j,e]),Y=(0,S.useMemo)(()=>r.filter(e=>e.enabled).length,[r]),X=(0,S.useCallback)((e,t,n)=>{_(r=>r.map(r=>r.id===t?{...r,...n,...e??{}}:r))},[]),ge=(0,S.useCallback)(async t=>{z(t.id);let n=await g.tools.toggle(t.id,!t.enabled);if(z(null),!n.success){h.error(n.error||e(`tools.toggleFailed`));return}let r=n.data?.enabled??!t.enabled;X(void 0,t.id,{enabled:r,overridden:!0})},[X,e]),_e=(0,S.useCallback)(e=>{F(e.id),P(e.id),L({name:e.name,description:e.description,category:e.category,enabled:e.enabled})},[]),ve=(0,S.useCallback)(async t=>{z(t.id);let n=await g.tools.update(t.id,{name:I.name,description:I.description,category:I.category,enabled:I.enabled});z(null),!n.success||!n.data?h.error(n.error||e(`tools.saveFailed`)):(X(n.data,t.id,{}),F(null),h.success(e(`tools.saved`)))},[I,X,e]),ye=(0,S.useCallback)(async t=>{z(t.id);let n=await g.tools.reset(t.id);z(null),!n.success||!n.data?h.error(n.error||e(`tools.resetFailed`)):(X(n.data,t.id,{}),F(e=>e===t.id?null:e),h.success(e(`tools.resetDone`)))},[X,e]),Z=(0,S.useCallback)(async(t,n)=>{let r=t.tools.filter(e=>e.enabled!==n);if(r.length===0)return;let i=(await Promise.all(r.map(e=>g.tools.toggle(e.id,n)))).filter(e=>!e.success).length;i>0&&h.warning(e(`tools.groupPartial`,{failed:i,total:r.length})),await K()},[K,e]),be=(0,S.useCallback)(async()=>{let t=await g.tools.exportConfig();if(!t.success||!t.data){h.error(t.error||e(`tools.loadFailed`));return}let n=Object.keys(t.data.tools??{}).length;n===0?h.info(e(`tools.exportEmpty`)):se(`deepseekcode-tools.json`,t.data)?h.success(e(`tools.exportDone`,{count:n})):h.error(e(`tools.exportFailed`))},[e]),xe=(0,S.useCallback)(async t=>{let n;try{n=JSON.parse(await t.text())}catch{h.error(e(`tools.importInvalid`));return}let r=n&&typeof n==`object`&&`tools`in n?n.tools:n,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.keys(r).length:0;i===0?h.error(e(`tools.importEmpty`)):W({payload:n,count:i})},[e]),Q=(0,S.useCallback)(async t=>{let n=U;if(W(null),!n)return;let r=await g.tools.importConfig(n.payload,t);!r.success||!r.data?h.error(e(`tools.importFailed`,{error:r.error??``})):(r.data.unknown.length>0&&h.warning(e(`tools.importUnknown`,{count:r.data.unknown.length})),h.success(e(`tools.importDone`,{count:r.data.applied.length})),await K())},[K,U,e]),Se=(0,S.useCallback)(e=>{N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),$=J.length>0&&J.every(e=>M.has(e.key));return w?(0,C.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,role:`status`,"aria-label":e(`tools.loading`),children:(0,C.jsx)(b,{count:5})}):O?(0,C.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(te,{size:32,className:`mx-auto mb-2 text-accent-red`}),(0,C.jsx)(`p`,{className:`text-accent-red mb-4`,children:O}),(0,C.jsx)(v,{variant:`accent`,onClick:()=>void K(),children:e(`tools.retry`)})]})}):(0,C.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden p-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between mb-3 gap-3`,children:[(0,C.jsxs)(`h2`,{className:`text-lg font-semibold flex items-center gap-2 min-w-0`,children:[(0,C.jsx)(u,{size:20,className:`shrink-0`}),(0,C.jsx)(`span`,{className:`truncate`,children:e(`tools.title`)}),(0,C.jsxs)(`span`,{className:`text-sm font-normal text-dark-muted whitespace-nowrap`,children:[e(`tools.totalTools`,{count:r.length}),` · `,e(`tools.enabledCount`,{count:Y})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,C.jsxs)(`button`,{onClick:()=>void be(),title:B?e(`tools.importPath`,{path:B}):void 0,className:`flex items-center gap-1.5 px-3 py-1.5 bg-dark-surface border border-dark-border rounded hover:bg-dark-hover transition-colors`,children:[(0,C.jsx)(i,{size:14}),e(`tools.exportConfig`),H>0&&(0,C.jsxs)(`span`,{className:`text-xs text-accent-blue`,children:[`(`,H,`)`]})]}),(0,C.jsxs)(`button`,{onClick:()=>G.current?.click(),className:`flex items-center gap-1.5 px-3 py-1.5 bg-dark-surface border border-dark-border rounded hover:bg-dark-hover transition-colors`,children:[(0,C.jsx)(re,{size:14}),e(`tools.importConfig`)]}),(0,C.jsx)(`input`,{ref:G,type:`file`,accept:`application/json,.json`,className:`hidden`,"data-testid":`tools-import-input`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&xe(t)}}),(0,C.jsxs)(`button`,{onClick:()=>void K(),className:`flex items-center gap-1.5 px-3 py-1.5 bg-dark-surface border border-dark-border rounded hover:bg-dark-hover transition-colors`,children:[(0,C.jsx)(t,{size:14}),e(`tools.refresh`)]})]})]}),(0,C.jsx)(x,{slot:e(`nav.tools`),className:`mb-3`}),(0,C.jsxs)(`div`,{className:`mb-3 px-3 py-2 rounded-lg bg-accent-blue/10 border border-accent-blue/20 text-xs text-dark-muted space-y-1`,children:[pe===`minimal`&&(0,C.jsx)(`div`,{children:e(`tools.profileMinimalHint`,{off:r.length-Y})}),(0,C.jsxs)(`div`,{className:`flex items-center gap-x-2 gap-y-1 flex-wrap`,children:[(0,C.jsx)(`span`,{children:e(`tools.scopeHint`)}),(0,C.jsxs)(`button`,{type:`button`,onClick:he,className:`inline-flex items-center gap-1 text-accent-blue hover:underline`,children:[e(`tools.scopeHintConnectorsLink`),(0,C.jsx)(n,{size:11})]})]})]}),(0,C.jsxs)(`div`,{className:`flex gap-3 mb-3 items-center flex-wrap`,children:[(0,C.jsxs)(`div`,{className:`flex-1 min-w-[200px] relative`,children:[(0,C.jsx)(a,{size:16,className:`absolute start-3 top-1/2 -translate-y-1/2 text-dark-muted`}),(0,C.jsx)(`input`,{type:`text`,value:A,onChange:e=>ce(e.target.value),placeholder:e(`tools.searchTools`),className:`w-full ps-10 pe-4 py-2 bg-dark-surface border border-dark-border rounded-lg text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,C.jsx)(o,{size:14,className:`text-dark-muted`}),(0,C.jsx)(`span`,{className:`text-dark-muted me-1`,children:e(`tools.groupBy`)}),[`category`,`risk`,`state`].map(t=>(0,C.jsx)(`button`,{onClick:()=>le(t),className:`px-3 py-1.5 rounded-lg transition-colors ${j===t?`bg-accent-blue text-accent-fg`:`bg-dark-surface border border-dark-border hover:bg-dark-hover`}`,children:e(t===`category`?`tools.groupByCategory`:t===`risk`?`tools.groupByRisk`:`tools.groupByState`)},t)),(0,C.jsx)(`button`,{onClick:()=>N($?new Set:new Set(J.map(e=>e.key))),className:`px-3 py-1.5 rounded-lg bg-dark-surface border border-dark-border hover:bg-dark-hover transition-colors`,children:e($?`tools.expandAll`:`tools.collapseAll`)})]})]}),(0,C.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar`,children:(0,C.jsxs)(`div`,{className:`space-y-3`,children:[J.map(t=>{let n=M.has(t.key),r=t.tools.filter(e=>e.enabled).length;return(0,C.jsxs)(`div`,{className:`bg-dark-surface border border-dark-border rounded-lg overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-dark-hover/40`,children:[(0,C.jsxs)(`button`,{onClick:()=>Se(t.key),className:`flex items-center gap-2 min-w-0 flex-1 text-start`,children:[n?(0,C.jsx)(f,{size:16,className:`shrink-0 text-dark-muted`}):(0,C.jsx)(c,{size:16,className:`shrink-0 text-dark-muted`}),(0,C.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,C.jsx)(`span`,{className:`text-xs text-dark-muted whitespace-nowrap`,children:e(`tools.groupEnabled`,{on:r,total:t.tools.length})})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,C.jsx)(`button`,{onClick:()=>void Z(t,!0),disabled:r===t.tools.length,className:`text-xs px-2 py-1 rounded border border-dark-border hover:bg-dark-hover disabled:opacity-40 disabled:cursor-not-allowed`,children:e(`tools.enableGroup`)}),(0,C.jsx)(`button`,{onClick:()=>void Z(t,!1),disabled:r===0,className:`text-xs px-2 py-1 rounded border border-dark-border hover:bg-dark-hover disabled:opacity-40 disabled:cursor-not-allowed`,children:e(`tools.disableGroup`)})]})]}),!n&&(0,C.jsx)(`div`,{className:`divide-y divide-dark-border`,children:t.tools.map(t=>{let n=de===t.id,r=ue===t.id||n;return(0,C.jsxs)(`div`,{className:t.enabled?``:`opacity-60`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 gap-3`,children:[(0,C.jsxs)(`button`,{className:`flex items-center gap-2 flex-1 min-w-0 text-start`,onClick:()=>P(r&&!n?null:t.id),children:[r?(0,C.jsx)(c,{size:14,className:`shrink-0 text-dark-muted`}):(0,C.jsx)(f,{size:14,className:`shrink-0 text-dark-muted`}),(0,C.jsx)(`span`,{className:`font-medium truncate`,children:t.name}),(0,C.jsx)(`code`,{className:`text-xs text-dark-muted truncate`,children:t.id}),t.risk&&(0,C.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-badge whitespace-nowrap ${T[t.risk]??`bg-dark-hover text-dark-muted`}`,children:[t.risk===`high`||t.risk===`critical`?(0,C.jsx)(m,{size:10,className:`inline -mt-px me-0.5`}):null,D(t.risk,e)]}),t.overridden&&(0,C.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-badge bg-accent-purple/20 text-accent-purple whitespace-nowrap`,children:e(`tools.overridden`)}),!t.enabled&&!t.overridden&&(0,C.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-badge bg-dark-hover text-dark-muted whitespace-nowrap`,children:t.defaultEnabled===!1?e(`tools.defaultOff`):e(`tools.disabled`)}),t.userInstalled&&(0,C.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-badge bg-accent-blue/20 text-accent-blue whitespace-nowrap`,title:e(`tools.userInstalledHint`),children:e(`tools.userInstalled`)})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,C.jsx)(y,{slot:`tools`,id:t.id}),(0,C.jsx)(`button`,{onClick:()=>_e(t),title:e(`tools.edit`),className:`p-1.5 rounded text-dark-muted hover:bg-dark-hover hover:text-dark-text transition-colors`,children:(0,C.jsx)(l,{size:14})}),t.overridden&&(0,C.jsx)(`button`,{onClick:()=>void ye(t),disabled:R===t.id,title:e(`tools.reset`),className:`p-1.5 rounded text-dark-muted hover:bg-dark-hover hover:text-dark-text transition-colors disabled:opacity-40`,children:(0,C.jsx)(s,{size:14})}),(0,C.jsx)(`button`,{onClick:()=>void ge(t),disabled:R===t.id,title:t.enabled?e(`tools.disabled`):e(`tools.enabled`),className:`p-1.5 rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${t.enabled?`text-accent-green hover:bg-accent-green/10`:`text-dark-muted hover:bg-dark-hover`}`,children:t.enabled?(0,C.jsx)(ee,{size:24}):(0,C.jsx)(d,{size:24})})]})]}),r&&(0,C.jsx)(`div`,{className:`px-3 pb-3 border-t border-dark-border`,children:n?(0,C.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,C.jsxs)(`label`,{className:`block`,children:[(0,C.jsx)(`span`,{className:`text-xs text-dark-muted`,children:e(`tools.fieldName`)}),(0,C.jsx)(`input`,{value:I.name,onChange:e=>L(t=>({...t,name:e.target.value})),placeholder:e(`tools.namePlaceholder`),className:`w-full mt-1 px-2 py-1.5 bg-dark-bg border border-dark-border rounded text-sm focus:border-accent-blue focus:outline-none`})]}),(0,C.jsxs)(`label`,{className:`block`,children:[(0,C.jsx)(`span`,{className:`text-xs text-dark-muted`,children:e(`tools.fieldCategory`)}),(0,C.jsx)(`input`,{value:I.category,onChange:e=>L(t=>({...t,category:e.target.value})),placeholder:e(`tools.categoryPlaceholder`),className:`w-full mt-1 px-2 py-1.5 bg-dark-bg border border-dark-border rounded text-sm focus:border-accent-blue focus:outline-none`})]}),(0,C.jsxs)(`label`,{className:`block`,children:[(0,C.jsx)(`span`,{className:`text-xs text-dark-muted`,children:e(`tools.fieldDescription`)}),(0,C.jsx)(`textarea`,{value:I.description,onChange:e=>L(t=>({...t,description:e.target.value})),placeholder:e(`tools.descriptionPlaceholder`),rows:3,className:`w-full mt-1 px-2 py-1.5 bg-dark-bg border border-dark-border rounded text-sm focus:border-accent-blue focus:outline-none resize-y`})]}),(0,C.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:I.enabled,onChange:e=>L(t=>({...t,enabled:e.target.checked}))}),e(`tools.fieldEnabled`)]}),(0,C.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`tools.descriptionHint`)}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,C.jsx)(v,{variant:`accent`,size:`sm`,leftIcon:(0,C.jsx)(p,{size:14}),loading:R===t.id,onClick:()=>void ve(t),children:e(`tools.save`)}),(0,C.jsxs)(`button`,{onClick:()=>F(null),className:`flex items-center gap-1.5 px-3 py-1.5 border border-dark-border rounded text-sm hover:bg-dark-hover`,children:[(0,C.jsx)(ne,{size:14}),e(`tools.cancel`)]})]})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{className:`text-sm text-dark-muted mt-3 mb-3 whitespace-pre-wrap`,children:t.description}),t.usage&&(0,C.jsxs)(`div`,{className:`mb-3`,children:[(0,C.jsx)(`div`,{className:`text-xs text-dark-muted mb-1`,children:e(`tools.usageHint`)}),(0,C.jsx)(`p`,{className:`text-sm text-dark-muted whitespace-pre-wrap`,children:t.usage})]}),t.params&&t.params.length>0&&(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xs text-dark-muted mb-2`,children:e(`tools.params`)}),(0,C.jsx)(`div`,{className:`space-y-1`,children:t.params.map(e=>(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-sm flex-wrap`,children:[(0,C.jsxs)(`code`,{className:`px-1.5 py-0.5 bg-dark-bg rounded text-accent-blue`,children:[e.name,e.required&&(0,C.jsx)(`span`,{className:`text-accent-red`,children:`*`})]}),(0,C.jsxs)(`span`,{className:`text-dark-muted text-xs`,children:[`(`,e.type,`)`]}),(0,C.jsx)(`span`,{className:`text-dark-muted text-xs`,children:e.description})]},e.name))})]})]})})]},t.id)})})]},t.key)}),q.length===0&&(0,C.jsxs)(`div`,{className:`text-center text-dark-muted py-8`,children:[(0,C.jsx)(u,{size:48,className:`mx-auto mb-2 opacity-50`}),(0,C.jsx)(`p`,{children:e(A?`tools.noMatch`:`tools.noTools`)})]})]})}),(0,C.jsxs)(ae,{isOpen:U!==null,onClose:()=>W(null),title:e(`tools.importTitle`),size:`sm`,children:[(0,C.jsx)(`p`,{className:`text-sm text-dark-muted mb-4`,children:e(`tools.importDesc`,{count:U?.count??0})}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`button`,{onClick:()=>void Q(`merge`),className:`w-full text-start px-3 py-2 border border-dark-border rounded hover:bg-dark-hover transition-colors`,children:[(0,C.jsx)(`div`,{className:`font-medium text-sm`,children:e(`tools.importMerge`)}),(0,C.jsx)(`div`,{className:`text-xs text-dark-muted`,children:e(`tools.importMergeHint`)})]}),(0,C.jsxs)(`button`,{onClick:()=>void Q(`replace`),className:`w-full text-start px-3 py-2 border border-dark-border rounded hover:bg-dark-hover transition-colors`,children:[(0,C.jsx)(`div`,{className:`font-medium text-sm`,children:e(`tools.importReplace`)}),(0,C.jsx)(`div`,{className:`text-xs text-dark-muted`,children:e(`tools.importReplaceHint`)})]}),(0,C.jsx)(`button`,{onClick:()=>W(null),className:`w-full px-3 py-2 text-sm text-dark-muted hover:text-dark-text transition-colors`,children:e(`tools.cancel`)})]})]})]})}export{O as ToolsView,O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as e,t}from"./mermaid-parser.core-BrXnuEs7.js";import{n}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as r}from"./src-BWF7jMDv.js";import"./chunk-DSNLSHJZ-a6-B52h-.js";import{n as i,r as a,t as o}from"./chunk-2E7WHVMD-xX282MrC.js";import{t as s}from"./chunk-JWPE2WC7-DVXcaiue.js";import"./mermaid.core-BGbz3k1k.js";var c=e().RailroadAbnf.parser.LangiumParser,l=n(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=n(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=n(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=n(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=n(e=>{switch(e.$type){case`AbnfStringLiteral`:return{type:`terminal`,value:e.value};case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=n(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=n(e=>{s(e,o),e.title&&o.setTitle(e.title),e.rules.map(e=>o.addRule(m(e)))},`populateDb`),g={parser:{parse:n(e=>{o.clear(),r.debug(`[ABNF Parser] Starting Langium parse`);let n=c.parse(e);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new t(n);let i=n.value;r.debug(`[ABNF Parser] Parsed rules:`,i.rules.length),h(i),r.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:o}},db:o,renderer:a,styles:i};export{g as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as e}from"./markdown-DAQZeY5V.js";var t=e(),n=[{id:`normal`,label:`灵动`,emoji:`👀`},{id:`sleepy`,label:`困困`,emoji:`😴`},{id:`surprised`,label:`惊讶`,emoji:`😳`},{id:`happy`,label:`开心`,emoji:`😊`},{id:`kiss`,label:`飞吻`,emoji:`😘`},{id:`love`,label:`爱心眼`,emoji:`😍`},{id:`angry`,label:`认真`,emoji:`😠`}],r=[{id:`midnight`,name:`午夜小团子`,cat:`经典`,desc:`安静 · 专注`,colors:[`#111722`,`#4a5262`,`#03060b`],acc:`🪽`},{id:`berry`,name:`莓果甜心`,cat:`可爱`,desc:`甜甜 · 俏皮`,colors:[`#ff78ad`,`#ffb7d2`,`#8d2d61`],acc:`🎀`},{id:`jade`,name:`翡翠王子`,cat:`奇幻`,desc:`优雅 · 沉稳`,colors:[`#075c47`,`#4ba58a`,`#021d1a`],acc:`👑`},{id:`blaze`,name:`烈焰明星`,cat:`潮流`,desc:`热烈 · 自信`,colors:[`#ff171d`,`#ff8a80`,`#8a0010`],acc:`🪶`},{id:`blues`,name:`蓝调玩家`,cat:`潮流`,desc:`酷感 · 松弛`,colors:[`#164eaa`,`#4f91f8`,`#06142f`],acc:`🕶️`},{id:`bride`,name:`白纱新娘`,cat:`可爱`,desc:`温柔 · 梦幻`,colors:[`#fff3d9`,`#ffffff`,`#d4c5b2`],acc:`👰`},{id:`galaxy`,name:`银河幽灵`,cat:`奇幻`,desc:`神秘 · 漂浮`,colors:[`#8e7bff`,`#c4baff`,`#382a81`],acc:`✨`},{id:`lemon`,name:`柠檬汽水`,cat:`自然`,desc:`清爽 · 元气`,colors:[`#b5d92e`,`#f0ff9c`,`#4e6411`],acc:`🍋`},{id:`cream`,name:`奶油云朵`,cat:`可爱`,desc:`软糯 · 治愈`,colors:[`#f2e9dd`,`#ffffff`,`#c7b7a8`],acc:`☁️`},{id:`sakura`,name:`樱花武士`,cat:`奇幻`,desc:`勇敢 · 温柔`,colors:[`#e45f91`,`#ffb5cf`,`#7e244c`],acc:`🎎`},{id:`cyber`,name:`赛博像素`,cat:`潮流`,desc:`未来 · 高能`,colors:[`#18d8d0`,`#a1fff7`,`#075a70`],acc:`🤖`},{id:`pumpkin`,name:`南瓜精灵`,cat:`节日`,desc:`古灵精怪`,colors:[`#ff7b25`,`#ffc078`,`#8b3000`],acc:`🎃`},{id:`snow`,name:`雪夜旅人`,cat:`自然`,desc:`冷静 · 清透`,colors:[`#8fc9e8`,`#e0f8ff`,`#326b91`],acc:`❄️`},{id:`devil`,name:`小恶魔`,cat:`奇幻`,desc:`调皮 · 狡黠`,colors:[`#a83254`,`#f56e83`,`#4a0b23`],acc:`😈`},{id:`mushroom`,name:`森林蘑菇`,cat:`自然`,desc:`自然 · 慢活`,colors:[`#6b8f52`,`#c6d9a2`,`#2a4525`],acc:`🍄`},{id:`gold`,name:`黄金会员`,cat:`奢华`,desc:`闪耀 · 稀有`,colors:[`#d69c27`,`#ffe6a0`,`#71440c`],acc:`👑`},{id:`astro`,name:`宇航员`,cat:`奇幻`,desc:`探索 · 好奇`,colors:[`#64758c`,`#e2ecff`,`#263348`],acc:`🚀`},{id:`catcap`,name:`猫耳队长`,cat:`可爱`,desc:`敏捷 · 机灵`,colors:[`#6b6de2`,`#b7b8ff`,`#2d2b7a`],acc:`🐱`},{id:`mintbot`,name:`薄荷机器人`,cat:`科技`,desc:`理性 · 可靠`,colors:[`#3cbda2`,`#b1f5e4`,`#126858`],acc:`🤖`},{id:`vinyl`,name:`复古唱片`,cat:`潮流`,desc:`复古 · 慵懒`,colors:[`#9c6d51`,`#e7b99a`,`#4d2e23`],acc:`🎧`},{id:`seal`,name:`海盐海豹`,cat:`自然`,desc:`软萌 · 平和`,colors:[`#729fb9`,`#cce9f7`,`#31526d`],acc:`🐚`},{id:`rainbow`,name:`彩虹糖豆`,cat:`可爱`,desc:`快乐 · 多彩`,colors:[`#df66d4`,`#ffc5f5`,`#792c7d`],acc:`🌈`},{id:`count`,name:`暗夜伯爵`,cat:`奢华`,desc:`神秘 · 高贵`,colors:[`#28213f`,`#71658e`,`#0b0914`],acc:`🎩`},{id:`birthday`,name:`生日派对`,cat:`节日`,desc:`庆祝 · 欢腾`,colors:[`#ff9b58`,`#ffe4a8`,`#b44b7a`],acc:`🎉`},{id:`wizard`,name:`代码巫师`,cat:`科技`,desc:`聪明 · 专注`,colors:[`#3867db`,`#92b5ff`,`#172d72`],acc:`🪄`},{id:`desert`,name:`沙漠旅者`,cat:`自然`,desc:`自由 · 坚韧`,colors:[`#c58b5a`,`#f2d0a5`,`#754629`],acc:`🧢`},{id:`bubble`,name:`泡泡糖`,cat:`可爱`,desc:`活泼 · 甜酷`,colors:[`#fa8bc8`,`#ffd3e9`,`#a52e73`],acc:`🫧`},{id:`bolt`,name:`雷电侠`,cat:`潮流`,desc:`速度 · 能量`,colors:[`#f1c928`,`#fff1a3`,`#8d6800`],acc:`⚡`},{id:`deepsea`,name:`深海潜行者`,cat:`自然`,desc:`沉静 · 深邃`,colors:[`#126b83`,`#61d0df`,`#04303e`],acc:`🐠`},{id:`gelato`,name:`冰淇淋骑士`,cat:`可爱`,desc:`甜品 · 勇气`,colors:[`#e6a6cb`,`#ffe3f3`,`#a45a89`],acc:`🍦`},{id:`halloween`,name:`万圣夜`,cat:`节日`,desc:`怪趣 · 暗黑`,colors:[`#5e347e`,`#bd81e9`,`#251038`],acc:`🦇`},{id:`angel`,name:`晨光天使`,cat:`奇幻`,desc:`希望 · 温暖`,colors:[`#f5d9a4`,`#fff8dc`,`#b99858`],acc:`😇`},{id:`rocker`,name:`摇滚主唱`,cat:`潮流`,desc:`自由 · 不羁`,colors:[`#4b4b58`,`#a8a8bd`,`#181820`],acc:`🎸`},{id:`gardener`,name:`小小园丁`,cat:`自然`,desc:`生长 · 友善`,colors:[`#70aa65`,`#c9e8b9`,`#2d6031`],acc:`🌱`},{id:`pearl`,name:`珍珠公主`,cat:`奢华`,desc:`优雅 · 闪亮`,colors:[`#d6c9ec`,`#fff6ff`,`#8e7da8`],acc:`💎`},{id:`xmas`,name:`圣诞精灵`,cat:`节日`,desc:`温暖 · 欢乐`,colors:[`#247d58`,`#a3e0b8`,`#10412d`],acc:`🎄`},{id:`mars`,name:`火星来客`,cat:`科技`,desc:`奇妙 · 外星`,colors:[`#db6b52`,`#ffc1a9`,`#843523`],acc:`👽`},{id:`tea`,name:`茶茶大师`,cat:`自然`,desc:`松弛 · 清醒`,colors:[`#94734d`,`#d9bd92`,`#503c26`],acc:`🍵`},{id:`koi`,name:`幸运锦鲤`,cat:`奇幻`,desc:`好运 · 闪耀`,colors:[`#ef8159`,`#ffd2a3`,`#9e3c2d`],acc:`🍀`},{id:`ghost`,name:`像素幽灵`,cat:`科技`,desc:`轻巧 · 数字`,colors:[`#8ca2a9`,`#e4f3f6`,`#3c535a`],acc:`👾`}],i=[[`#111722`,`#4a5262`,`#03060b`],[`#ff78ad`,`#ffb7d2`,`#8d2d61`],[`#075c47`,`#4ba58a`,`#021d1a`],[`#164eaa`,`#4f91f8`,`#06142f`],[`#8e7bff`,`#c4baff`,`#382a81`],[`#ff7b25`,`#ffc078`,`#8b3000`],[`#f2e9dd`,`#ffffff`,`#c7b7a8`],[`#18d8d0`,`#a1fff7`,`#075a70`],[`#d69c27`,`#ffe6a0`,`#71440c`],[`#df66d4`,`#ffc5f5`,`#792c7d`]],a=[{id:`none`,label:`无配件`},{id:`bow`,label:`蝴蝶结`},{id:`crown`,label:`王冠`},{id:`glasses`,label:`太阳镜`,layer:`front`},{id:`wings`,label:`天使翅膀`},{id:`feather`,label:`羽毛围脖`},{id:`ears`,label:`猫耳`},{id:`horns`,label:`恶魔角`},{id:`halo`,label:`光环`},{id:`headphones`,label:`耳机`},{id:`hat`,label:`魔法帽`},{id:`star`,label:`星星`},{id:`gem`,label:`皇冠宝石`},{id:`party`,label:`派对帽`},{id:`scarf`,label:`围巾`},{id:`sprout`,label:`小芽`},{id:`flower`,label:`花朵`},{id:`flame`,label:`小火焰`},{id:`snow`,label:`雪花`},{id:`fish`,label:`小鱼`},{id:`coffee`,label:`咖啡杯`},{id:`rocket`,label:`火箭`},{id:`mask`,label:`面具`,layer:`front`},{id:`ghost`,label:`小幽灵`}],o={"🎀":`bow`,"👑":`crown`,"🕶️":`glasses`,"🤓":`glasses`,"🪽":`wings`,"🪶":`feather`,"🐱":`ears`,"🐰":`ears`,"😈":`horns`,"🦇":`horns`,"😇":`halo`,"🎧":`headphones`,"🎸":`headphones`,"🧙":`hat`,"🪄":`hat`,"🎩":`hat`,"⭐":`star`,"✨":`star`,"⚡":`star`,"🚀":`star`,"🌈":`star`,"🫧":`star`,"💎":`gem`,"🐚":`gem`,"🐠":`gem`,"🥳":`party`,"🎉":`party`,"🍦":`party`,"🧣":`scarf`,"🍃":`sprout`,"🌱":`sprout`,"🍀":`sprout`,"🎄":`sprout`,"🍄":`sprout`,"🍋":`sprout`,"☁️":`wings`,"👰":`bow`,"🎎":`bow`,"🎃":`horns`,"👽":`ears`,"👾":`glasses`,"🍵":`sprout`,"🧢":`feather`},s={经典:`feather`,可爱:`bow`,奇幻:`star`,潮流:`glasses`,自然:`sprout`,科技:`headphones`,奢华:`gem`,节日:`party`};function c(e){return o[e.acc]??s[e.cat]}var l=`M40 11C25 11 17 22 19 35C7 43 7 59 14 71C21 84 30 88 40 88C54 88 66 78 68 62C71 49 65 39 61 34C63 20 53 11 40 11Z`,u=`M40 12C27 12 21 23 22 34C15 42 13 54 18 65C21 73 28 79 35 80C25 65 26 52 31 43C35 34 46 28 55 31C56 19 49 12 40 12Z`;function d(e){return e<=26?`small`:`large`}function f(e){return Math.min(7.5,Math.max(1.8,116/e))}var p=1.35,m=1.16,h=`#3f3646`;function g(e){let t=Number.parseInt(e.replace(`#`,``),16),n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*n(t>>16&255)+.7152*n(t>>8&255)+.0722*n(t&255)}function _(e,t){let n=g(e),r=g(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function v(e,t){let n=Number.parseInt(e.replace(`#`,``),16),r=e=>Math.round(e+(255-e)*t).toString(16).padStart(2,`0`);return`#${r(n>>16&255)}${r(n>>8&255)}${r(n&255)}`}function y(e){let[t,n]=e,r=v(n,.22);return _(r,t)>=_(h,t)?r:h}function b(e,n){switch(e){case`happy`:return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(`path`,{d:`M22 39Q29 30 36 39`,fill:`none`,stroke:n,strokeWidth:3.5,strokeLinecap:`round`}),(0,t.jsx)(`path`,{d:`M44 39Q51 30 58 39`,fill:`none`,stroke:n,strokeWidth:3.5,strokeLinecap:`round`})]});case`love`:return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(`path`,{d:`M29 44C14 34 22 25 29 33C36 25 44 34 29 44Z`,fill:`#ff7eaa`}),(0,t.jsx)(`path`,{d:`M51 44C36 34 44 25 51 33C58 25 66 34 51 44Z`,fill:`#ff7eaa`})]});case`angry`:return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(`path`,{d:`M22 35L35 39`,stroke:n,strokeWidth:4,strokeLinecap:`round`}),(0,t.jsx)(`path`,{d:`M45 39L58 35`,stroke:n,strokeWidth:4,strokeLinecap:`round`})]});case`surprised`:return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(`ellipse`,{cx:29,cy:37,rx:6.5,ry:8,fill:n}),(0,t.jsx)(`ellipse`,{cx:51,cy:37,rx:6.5,ry:8,fill:n})]});default:return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(`ellipse`,{cx:29,cy:38,rx:6.5,ry:7.5,fill:n}),(0,t.jsx)(`ellipse`,{cx:51,cy:38,rx:6.5,ry:7.5,fill:n})]})}}function x(e,n){switch(e){case`sleepy`:return(0,t.jsx)(`path`,{d:`M37 51Q40 48 43 51`,fill:`none`,stroke:n,strokeWidth:2.4,strokeLinecap:`round`});case`surprised`:return(0,t.jsx)(`ellipse`,{cx:40,cy:51,rx:3.2,ry:4.2,fill:n});case`happy`:return(0,t.jsx)(`path`,{d:`M33 48Q40 57 47 48`,fill:`none`,stroke:n,strokeWidth:2.5,strokeLinecap:`round`});case`love`:return(0,t.jsx)(`path`,{d:`M35 49Q40 54 45 49`,fill:`none`,stroke:n,strokeWidth:2.4,strokeLinecap:`round`});case`angry`:return(0,t.jsx)(`path`,{d:`M34 52H46`,stroke:n,strokeWidth:2.5,strokeLinecap:`round`});case`kiss`:return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(`path`,{d:`M38 49Q40 46 43 49Q40 54 38 49Z`,fill:`#ff8caf`,stroke:n,strokeWidth:1}),(0,t.jsx)(`path`,{d:`M60 34C54 27 64 23 67 30C70 23 80 27 73 34L67 40Z`,fill:`#ff5f9a`}),(0,t.jsx)(`path`,{d:`M63 48C58 43 65 39 68 44C71 39 78 43 72 48L68 52Z`,fill:`#ff8caf`})]});default:return(0,t.jsx)(`path`,{d:`M39 49Q43 52 47 49`,fill:`none`,stroke:n,strokeWidth:2.4,strokeLinecap:`round`})}}function S(e){return a.find(t=>t.id===e)?.layer===`front`?`front`:`behind`}function C(e,n,r){switch(e){case`bow`:return(0,t.jsxs)(`g`,{transform:`translate(60 13)`,children:[(0,t.jsx)(`path`,{d:`M0 0Q-18 -13 -16 1Q-11 10 0 3Q12 12 17 1Q17 -12 0 0`,fill:`#ff86b8`,stroke:`#f7d5e5`,strokeWidth:r*.5}),(0,t.jsx)(`circle`,{r:4,fill:`#ffc6df`})]});case`crown`:return(0,t.jsxs)(`g`,{transform:`translate(39 11)`,stroke:`#e8b847`,strokeWidth:r*.7,strokeLinejoin:`round`,children:[(0,t.jsx)(`path`,{d:`M-15 5L-19 -8 -7 0 0 -13 7 0 19 -8 15 5Z`,fill:`#f7d778`}),(0,t.jsx)(`path`,{d:`M-15 5H15V10H-15Z`,fill:`#dba72f`}),(0,t.jsx)(`circle`,{cx:0,cy:-13,r:2,fill:`#fff1b5`})]});case`glasses`:return(0,t.jsxs)(`g`,{transform:`translate(39 38)`,stroke:`#e9eef7`,strokeWidth:r*.7,children:[(0,t.jsx)(`path`,{d:`M-27 -4Q-12 -10 -3 -3L-5 7Q-14 13 -23 6Z`,fill:`#172335`,fillOpacity:.92}),(0,t.jsx)(`path`,{d:`M3 -3Q14 -10 27 -4L23 6Q14 13 5 7Z`,fill:`#172335`,fillOpacity:.92}),(0,t.jsx)(`path`,{d:`M-4 0H4`,strokeWidth:r})]});case`wings`:return(0,t.jsxs)(`g`,{fill:`#fff`,fillOpacity:.78,stroke:`#d7d5e4`,strokeWidth:r*.25,children:[(0,t.jsx)(`path`,{d:`M16 31Q-4 9 0 23Q-4 14 8 39L19 49Z`}),(0,t.jsx)(`path`,{d:`M62 31Q82 9 78 23Q82 14 70 39L59 49Z`})]});case`feather`:return(0,t.jsxs)(`g`,{fill:`#fff5f7`,stroke:`#e8dce1`,strokeWidth:r*.28,children:[(0,t.jsx)(`path`,{d:`M16 54Q-1 45 7 57L16 64 10 65 20 68 25 63Z`}),(0,t.jsx)(`path`,{d:`M62 54Q79 45 71 57L62 64 68 65 58 68 53 63Z`})]});case`ears`:return(0,t.jsxs)(`g`,{fill:n[0],stroke:n[1],strokeWidth:r*.7,children:[(0,t.jsx)(`path`,{d:`M19 25L16 5Q29 12 32 22Z`}),(0,t.jsx)(`path`,{d:`M59 22Q62 12 75 5L72 25Z`})]});case`horns`:return(0,t.jsxs)(`g`,{fill:`#c73b5d`,stroke:`#ffb3bd`,strokeWidth:r*.35,children:[(0,t.jsx)(`path`,{d:`M19 25Q8 3 18 9L31 22Z`}),(0,t.jsx)(`path`,{d:`M59 22L72 9Q82 3 71 25Z`})]});case`halo`:return(0,t.jsx)(`ellipse`,{cx:39,cy:7,rx:18,ry:5,fill:`none`,stroke:`#f3d578`,strokeWidth:r});case`headphones`:return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(`path`,{d:`M13 40V33Q13 8 39 8Q65 8 65 33V40`,fill:`none`,stroke:`#b5a5ff`,strokeWidth:r*1.7}),(0,t.jsx)(`rect`,{x:10,y:34,width:9,height:17,rx:4,fill:`#9e8aff`}),(0,t.jsx)(`rect`,{x:59,y:34,width:9,height:17,rx:4,fill:`#9e8aff`})]});case`hat`:return(0,t.jsxs)(`g`,{children:[(0,t.jsx)(`path`,{d:`M19 23L32 -5Q36 -12 41 -4L61 23Z`,fill:`#4b327e`,stroke:`#bca4ff`,strokeWidth:r*.5}),(0,t.jsx)(`ellipse`,{cx:40,cy:23,rx:23,ry:5,fill:`#7456ad`}),(0,t.jsx)(`path`,{d:`M31 8L37 4 42 10 48 5`,fill:`none`,stroke:`#ffe68c`,strokeWidth:r*.7})]});case`star`:return(0,t.jsx)(`g`,{fill:`#ffe27d`,stroke:`#fff4c4`,strokeWidth:r*.35,children:(0,t.jsx)(`path`,{d:`M63 15L66 22 74 23 68 28 70 36 63 31 56 36 58 28 52 23 60 22Z`})});case`gem`:return(0,t.jsx)(`path`,{d:`M27 13L34 7H44L51 13 39 25Z`,fill:`#a4eaff`,stroke:`#eaffff`,strokeWidth:r*.5});case`party`:return(0,t.jsxs)(`g`,{children:[(0,t.jsx)(`path`,{d:`M20 22L30 0 41 18 51 -2 61 22Z`,fill:`#ffce5b`}),(0,t.jsx)(`circle`,{cx:30,cy:0,r:2,fill:`#ff7ca8`}),(0,t.jsx)(`circle`,{cx:51,cy:-2,r:2,fill:`#8d80ff`})]});case`scarf`:return(0,t.jsx)(`path`,{d:`M19 58Q39 66 60 57L65 66Q40 77 17 67Z`,fill:`#dc4d63`,stroke:`#ffb2bd`,strokeWidth:r*.35});case`sprout`:return(0,t.jsx)(`path`,{d:`M60 23Q58 4 75 7Q76 23 60 23M60 23Q44 8 42 20Q48 29 60 23`,fill:`#83c77d`,stroke:`#d4f2bc`,strokeWidth:r*.5});case`flower`:return(0,t.jsxs)(`g`,{transform:`translate(64 16)`,children:[[0,72,144,216,288].map(e=>(0,t.jsx)(`ellipse`,{cx:0,cy:-6,rx:4.2,ry:5,fill:`#ffb3d1`,stroke:`#fff0f6`,strokeWidth:r*.25,transform:`rotate(${e})`},e)),(0,t.jsx)(`circle`,{r:3,fill:`#ffd166`})]});case`flame`:return(0,t.jsxs)(`g`,{transform:`translate(63 8)`,children:[(0,t.jsx)(`path`,{d:`M0 6C-7 0 -4 -8 0 -14C4 -8 7 0 0 6Z`,fill:`#ff7a3d`,stroke:`#ffd7a8`,strokeWidth:r*.3}),(0,t.jsx)(`path`,{d:`M0 4C-3.4 1 -2 -4 0 -7C2 -4 3.4 1 0 4Z`,fill:`#ffd166`})]});case`snow`:return(0,t.jsx)(`g`,{transform:`translate(64 15)`,stroke:`#bce7ff`,strokeWidth:r*.45,strokeLinecap:`round`,children:[0,60,120].map(e=>(0,t.jsx)(`path`,{d:`M0 -8V8`,transform:`rotate(${e})`},e))});case`fish`:return(0,t.jsxs)(`g`,{transform:`translate(65 52)`,children:[(0,t.jsx)(`path`,{d:`M-6 0Q0 -6 6 0Q0 6 -6 0Z`,fill:`#7fd8ea`,stroke:`#d7f6ff`,strokeWidth:r*.3}),(0,t.jsx)(`path`,{d:`M6 0L11 -4V4Z`,fill:`#7fd8ea`})]});case`coffee`:return(0,t.jsxs)(`g`,{transform:`translate(65 70)`,children:[(0,t.jsx)(`path`,{d:`M-7 -5H5V6Q-1 10 -7 6Z`,fill:`#f0e3d2`,stroke:`#c9b79f`,strokeWidth:r*.3}),(0,t.jsx)(`path`,{d:`M5 -3Q10 -1 5 3`,fill:`none`,stroke:`#c9b79f`,strokeWidth:r*.5})]});case`rocket`:return(0,t.jsxs)(`g`,{transform:`translate(65 18) rotate(28)`,children:[(0,t.jsx)(`path`,{d:`M0 -12C6 -6 6 4 0 8C-6 4 -6 -6 0 -12Z`,fill:`#eef2f8`,stroke:`#c3ccd9`,strokeWidth:r*.3}),(0,t.jsx)(`circle`,{cy:-2,r:2.4,fill:`#7cc7ff`}),(0,t.jsx)(`path`,{d:`M0 8L-3.4 12H3.4Z`,fill:`#ff8a80`})]});case`mask`:return(0,t.jsxs)(`g`,{transform:`translate(62 46)`,children:[(0,t.jsx)(`path`,{d:`M-8 -6Q0 -10 8 -6Q7 6 0 9Q-7 6 -8 -6Z`,fill:`#f6f1ff`,stroke:`#c9bce6`,strokeWidth:r*.35}),(0,t.jsx)(`circle`,{cx:-3,cy:-2,r:1.6,fill:`#3f3646`}),(0,t.jsx)(`circle`,{cx:3,cy:-2,r:1.6,fill:`#3f3646`}),(0,t.jsx)(`path`,{d:`M-3 3Q0 5 3 3`,fill:`none`,stroke:`#3f3646`,strokeWidth:r*.35,strokeLinecap:`round`})]});case`ghost`:return(0,t.jsx)(`g`,{transform:`translate(64 24)`,children:(0,t.jsx)(`path`,{d:`M-6 -2Q-6 -10 0 -10Q6 -10 6 -2V6L3 3.6 0 6 -3 3.6 -6 6Z`,fill:`#f2f4ff`,fillOpacity:.92,stroke:`#cfd6ee`,strokeWidth:r*.3})});default:return null}}function w({colors:e,expression:n=`normal`,accessory:r=`none`,tier:i=`large`,uid:a,size:o}){let s=e,c=i===`small`?`translate(40 46) scale(${i===`small`?p:1}) translate(-40 -46)`:void 0,d=i===`small`?`translate(40 44) scale(${i===`small`?m:1}) translate(-40 -44)`:void 0,h=f(o),g=i===`large`,_=`bg${a}`,v=y(s),w=S(r)===`front`;return(0,t.jsxs)(`svg`,{viewBox:`0 0 80 94`,width:o,height:o,"aria-hidden":`true`,style:{overflow:`visible`},children:[(0,t.jsxs)(`defs`,{children:[(0,t.jsxs)(`radialGradient`,{id:`${_}a`,cx:`30%`,cy:`22%`,r:`78%`,children:[(0,t.jsx)(`stop`,{stopColor:s[1]}),(0,t.jsx)(`stop`,{offset:.36,stopColor:s[0]}),(0,t.jsx)(`stop`,{offset:1,stopColor:s[2]})]}),g&&(0,t.jsxs)(`linearGradient`,{id:`${_}b`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,t.jsx)(`stop`,{stopColor:`#fff`,stopOpacity:.6}),(0,t.jsx)(`stop`,{offset:.5,stopColor:`#fff`,stopOpacity:0}),(0,t.jsx)(`stop`,{offset:1,stopColor:`#fff`,stopOpacity:.05})]})]}),!w&&(0,t.jsx)(`g`,{className:`ag-deco`,transform:c,children:C(r,s,h)}),(0,t.jsx)(`path`,{d:l,fill:`url(#${_}a)`,stroke:v,strokeOpacity:.26,strokeWidth:g?1.2:h*.45}),g&&(0,t.jsx)(`path`,{d:u,fill:`url(#${_}b)`}),w&&(0,t.jsx)(`g`,{className:`ag-deco`,transform:c,children:C(r,s,h)}),(0,t.jsx)(`g`,{className:`ag-eye`,transform:d,children:b(n,v)}),x(n,v),g&&(0,t.jsx)(`ellipse`,{cx:40,cy:88,rx:23,ry:3,fill:s[2],opacity:.12})]})}var T=r.map(e=>({id:e.id,cat:e.cat,name:e.name,desc:e.desc,colors:e.colors,accessory:c(e)}));T.map(e=>e.id);function E(e){let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t%2147483647+2147483647)%2147483647}function D(e){return e?T[E(`${e}:icon`)%T.length]:T[0]}function O(e){return T.find(t=>t.id===e)??T[0]}var k={running:`normal`,waiting:`surprised`,done:`happy`,failed:`angry`};function A(e){return e?k[e]:`normal`}export{a,i as c,y as d,d as f,D as i,r as l,O as n,l as o,A as r,n as s,T as t,w as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-COiEfhsA.js";var t=``;function n(e){t=typeof e==`string`?e.trim():``}function r(){return t}function i(e){return`${e}`}function a(){return r()}function o(){let e=a();return e?`&sessionId=${encodeURIComponent(e)}`:``}var s=new class{baseUrl;constructor(e){this.baseUrl=e}async request(e,t={}){try{let n=sessionStorage.getItem(`auth_token`)??localStorage.getItem(`auth_token`),r={"Content-Type":`application/json`,...t.headers};n&&(r.Authorization=`Bearer ${n}`);let i=a();i&&!r[`X-Session-Id`]&&(r[`X-Session-Id`]=i);let o=await fetch(`${this.baseUrl}${e}`,{headers:r,...t}),s=await o.json();return o.ok?s&&typeof s.success==`boolean`?{success:s.success,data:s.data,error:s.error,...typeof s.code==`string`?{code:s.code}:{}}:{success:!0,data:s}:{success:!1,error:s.error||`HTTP ${o.status}`,...typeof s.code==`string`?{code:s.code}:{},data:s.data}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Network error`}}}get(e){return this.request(e,{method:`GET`})}post(e,t){return this.request(e,{method:`POST`,body:t?JSON.stringify(t):void 0})}put(e,t){return this.request(e,{method:`PUT`,body:t?JSON.stringify(t):void 0})}delete(e,t){return this.request(e,{method:`DELETE`,body:t?JSON.stringify(t):void 0})}patch(e,t){return this.request(e,{method:`PATCH`,body:t?JSON.stringify(t):void 0})}}(``),c={get:()=>s.get(`/api/config/sandbox`),save:e=>s.post(`/api/config/sandbox`,e)},l=e({api:()=>u,apiClient:()=>s,default:()=>u}),u={providers:{presets:()=>s.get(`/api/providers/presets`),refresh:()=>s.post(`/api/providers/refresh`),testConnection:(e,t,n)=>s.post(`/api/providers/test-connection`,{baseUrl:e,apiKey:t,model:n})},models:{list:async()=>{let e=await s.get(`/api/models`);return e.success&&e.data?.models&&(e.data.models=e.data.models.map(e=>({...e,isGlobalDefault:e.isDefault===!0}))),e},get:e=>s.get(`/api/models/${e}`),create:e=>s.post(`/api/models`,e),update:(e,t,n)=>s.post(`/api/models/update`,{provider:e,modelId:t,...n}),delete:(e,t)=>s.post(`/api/models/delete`,{provider:e,modelId:t}),test:e=>s.post(`/api/models/${e}/test`),fetch:(e,t,n,r)=>s.post(`/api/models/fetch`,{baseUrl:e,apiKey:t,fullPath:n,preset:r}),byProvider:(e,t)=>{let n=new URLSearchParams({provider:e});return t&&n.set(`q`,t),s.get(`/api/models/by-provider?${n.toString()}`)},catalogSearch:e=>{let t=new URLSearchParams;e.q&&t.set(`q`,e.q),e.toolCall&&t.set(`toolCall`,`1`),e.reasoning&&t.set(`reasoning`,`1`),e.minContext&&t.set(`minContext`,String(e.minContext)),e.limit&&t.set(`limit`,String(e.limit));let n=t.toString();return s.get(`/api/models/catalog${n?`?${n}`:``}`)},toggle:(e,t)=>s.post(`/api/models/toggle`,{provider:e,modelId:t}),setDefaults:e=>s.post(`/api/models/defaults`,e),getSessionModel:e=>s.get(`/api/sessions/${encodeURIComponent(e)}/model`),setSessionModel:(e,t,n)=>s.put(`/api/sessions/${encodeURIComponent(e)}/model`,{provider:t,model:n}),clearSessionModel:e=>s.delete(`/api/sessions/${encodeURIComponent(e)}/model`)},tools:{list:()=>s.get(`/api/tools`),get:e=>s.get(`/api/tools/${e}`),update:(e,t)=>s.put(`/api/tools/${encodeURIComponent(e)}`,t),toggle:(e,t)=>s.post(`/api/tools/${encodeURIComponent(e)}/toggle`,{enabled:t}),reset:e=>s.post(`/api/tools/${encodeURIComponent(e)}/reset`,{}),exportConfig:()=>s.get(`/api/tools/config`),importConfig:(e,t=`merge`)=>s.put(`/api/tools/config`,{config:e,mode:t})},connectors:{list:()=>s.get(`/api/connectors`),get:e=>s.get(`/api/connectors/${encodeURIComponent(e)}`),toggle:(e,t,n)=>s.post(`/api/connectors/${encodeURIComponent(e)}/toggle`,{enabled:t,env:n}),connect:(e,t)=>s.post(`/api/connectors/${encodeURIComponent(e)}/connect`,{env:t}),accounts:e=>s.get(`/api/connectors/${encodeURIComponent(e)}/accounts`),addAccount:(e,t)=>s.post(`/api/connectors/${encodeURIComponent(e)}/accounts`,t),updateAccount:(e,t,n)=>s.patch(`/api/connectors/${encodeURIComponent(e)}/accounts/${encodeURIComponent(t)}`,n),removeAccount:(e,t)=>s.delete(`/api/connectors/${encodeURIComponent(e)}/accounts/${encodeURIComponent(t)}`),addCustom:e=>s.post(`/api/connectors/custom`,e),removeCustom:e=>s.delete(`/api/connectors/custom/${encodeURIComponent(e)}`),authorize:e=>s.post(`/api/connectors/${encodeURIComponent(e)}/authorize`,{})},device:{androidStatus:()=>s.get(`/api/device/android`)},skills:{list:()=>s.get(`/api/skills`),get:e=>s.get(`/api/skills/${e}`),create:e=>s.post(`/api/skills`,e),update:(e,t)=>s.put(`/api/skills/${e}`,t),toggle:(e,t)=>s.post(`/api/skills/${e}/toggle`,{enabled:t}),delete:e=>s.delete(`/api/skills/${e}`),import:e=>s.post(`/api/skills/import`,e),marketplaces:{list:()=>s.get(`/api/skills/marketplaces`),add:e=>s.post(`/api/skills/marketplaces`,e),remove:e=>s.delete(`/api/skills/marketplaces/${e}`),get:e=>s.get(`/api/skills/marketplaces/${e}`),refresh:e=>s.post(`/api/skills/marketplaces/${e}/refresh`,{}),install:(e,t)=>s.post(`/api/skills/marketplaces/${e}/install`,{skillId:t})},workshop:{list:e=>s.get(`/api/skills/workshop${e?`?status=${e}`:``}`),propose:e=>s.post(`/api/skills/workshop`,e),apply:e=>s.post(`/api/skills/workshop/${e}/apply`,{}),reject:e=>s.post(`/api/skills/workshop/${e}/reject`,{})},config:{get:e=>s.get(`/api/skills/${e}/config`),update:(e,t)=>s.put(`/api/skills/${e}/config`,t)}},shell:{exec:(e,t,n)=>s.post(`/api/shell/exec`,{command:e,workspaceDir:t,timeoutMs:n})},terminalFigure:{generate:e=>s.post(`/api/terminal-figure`,e)},visualArtifacts:{list:(e={})=>{let t=Object.entries(e).filter(([,e])=>typeof e==`string`&&e!==``).map(([e,t])=>`${e}=${encodeURIComponent(String(t))}`).join(`&`);return s.get(`/api/visual-artifacts${t?`?${t}`:``}`)},remove:e=>s.delete(`/api/visual-artifacts/${encodeURIComponent(e)}`)},pendingArtifacts:{list:e=>s.get(`/api/pending-artifacts${e?`?status=${e}`:``}`),approve:(e,t)=>s.post(`/api/pending-artifacts/${e}/approve`,{note:t}),reject:(e,t)=>s.post(`/api/pending-artifacts/${e}/reject`,{note:t})},files:{list:(e,t)=>s.get(`/api/files${e?`?path=${encodeURIComponent(e)}${t?.optional?`&optional=1`:``}`:``}`),search:e=>s.get(`/api/files/search?query=${encodeURIComponent(e)}`),read:e=>s.get(`/api/files/read?path=${encodeURIComponent(e)}`),previewDocx:e=>s.get(`/api/files/preview-docx?path=${encodeURIComponent(e)}`),previewXlsx:e=>s.get(`/api/files/preview-xlsx?path=${encodeURIComponent(e)}`),previewTicket:(e,t)=>s.post(`/api/files/preview-ticket`,{path:e,endpoint:t}),create:(e,t)=>s.post(`/api/files`,{path:e,content:t}),update:(e,t)=>s.put(`/api/files/write`,{path:e,content:t}),delete:e=>s.delete(`/api/files?path=${encodeURIComponent(e)}`),download:async e=>{try{let t={},n=sessionStorage.getItem(`auth_token`)??localStorage.getItem(`auth_token`);n&&(t.Authorization=`Bearer ${n}`);let r=await fetch(i(`/api/files/download?path=${encodeURIComponent(e)}${o()}`),{headers:t});if(!r.ok){let e=`HTTP ${r.status}`;try{let t=await r.json();t?.error&&(e=t.error)}catch{}return{success:!1,error:e}}let a=await r.blob(),s=URL.createObjectURL(a),c=document.createElement(`a`);return c.href=s,c.download=e.split(/[\\/]/).pop()||`download`,c.click(),URL.revokeObjectURL(s),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Download failed`}}},upload:async(e,t)=>{try{let n=await d(e);return s.post(`/api/files/upload`,{path:t,content:n,base64:!0})}catch(e){return{success:!1,error:e instanceof Error?e.message:`Upload failed`}}}},dirs:{list:e=>s.get(`/api/dirs${e?`?path=${encodeURIComponent(e)}`:``}`)},fs:{open:(e,t)=>s.post(`/api/fs/open`,{path:e,mode:t}),openFolder:e=>s.post(`/api/fs/open-folder`,{dir:e})},sessions:{list:()=>s.get(`/api/sessions`),get:e=>s.get(`/api/sessions/${e}`),create:(e,t,n)=>s.post(`/api/sessions`,{...e?{title:e}:{},...t?{workspaceDir:t}:{},...n?{sessionId:n}:{}}),delete:e=>s.delete(`/api/sessions/${e}`),resume:e=>s.get(`/api/sessions/${encodeURIComponent(e)}/resume`),fork:(e,t)=>s.post(`/api/sessions/${encodeURIComponent(e)}/fork`,t?{title:t}:{}),rename:(e,t)=>s.patch(`/api/sessions/${encodeURIComponent(e)}`,{title:t})},agentRuns:{list:e=>s.get(e?`/api/agent-runs?sessionId=${encodeURIComponent(e)}`:`/api/agent-runs`),get:e=>s.get(`/api/agent-runs/${encodeURIComponent(e)}`),stop:e=>s.post(`/api/agent-runs/${encodeURIComponent(e)}/stop`),kill:e=>s.post(`/api/agent-runs/${encodeURIComponent(e)}/kill`),pause:e=>s.post(`/api/agent-runs/${encodeURIComponent(e)}/pause`),resume:e=>s.post(`/api/agent-runs/${encodeURIComponent(e)}/resume`)},config:{provider:{get:()=>s.get(`/api/config/provider`),save:e=>s.post(`/api/config/provider`,e),delete:e=>s.post(`/api/config/provider/remove`,{provider:e}),setDefault:e=>s.post(`/api/config/provider`,{provider:e,setDefault:!0})},files:{list:()=>s.get(`/api/config/files`),read:e=>s.get(`/api/config/files/read?file=${encodeURIComponent(e)}`),write:(e,t)=>s.put(`/api/config/files/write`,{file:e,content:t})},desktop:()=>s.get(`/api/config/desktop`),setDesktop:e=>s.post(`/api/config/desktop`,e),context:{get:()=>s.get(`/api/config/context`),save:e=>s.post(`/api/config/context`,e)},sandbox:c,language:{get:()=>s.get(`/api/config/language`),set:e=>s.post(`/api/config/language`,{language:e})},profile:{get:()=>s.get(`/api/config/profile`),set:e=>s.post(`/api/config/profile`,e)}},profile:{get:()=>s.get(`/api/profile`),raw:()=>s.get(`/api/profile/raw`),set:e=>s.put(`/api/profile`,e),clear:()=>s.delete(`/api/profile`)},git:{status:()=>s.get(`/api/git/status`),diff:(e,t)=>{let n=new URLSearchParams({path:e});return t?.mode&&n.set(`mode`,t.mode),t?.context!=null&&n.set(`context`,String(t.context)),s.get(`/api/git/diff?${n.toString()}`)}},fileJob:{parse:e=>s.post(`/api/filejob/parse`,{files:e}),parsePaths:e=>s.post(`/api/filejob/parse`,{paths:e}),importPaths:e=>s.post(`/api/filejob/import`,{paths:e}),render:e=>s.post(`/api/filejob/render`,e)},system:{status:()=>s.get(`/api/system/status`),metrics:()=>s.get(`/api/metrics`),restart:()=>s.post(`/api/system/restart`),shutdown:()=>s.post(`/api/system/shutdown`),network:()=>s.get(`/api/system/network`),setNetwork:e=>s.put(`/api/system/network`,{allowLanAccess:e}),setTailscale:e=>s.post(`/api/system/tailscale`,{enabled:e}),daemon:()=>s.get(`/api/system/daemon`),setDaemon:e=>s.put(`/api/system/daemon`,{daemonEnabled:e}),desktopDownload:()=>s.get(`/api/system/desktop-download`)},observability:{summary:()=>s.get(`/api/observability/summary`),contextAdvice:e=>s.get(`/api/context/advice?sessionId=${encodeURIComponent(e)}`),costs:e=>s.get(`/api/observability/costs${e?`?sessionId=${encodeURIComponent(e)}`:``}`)},templates:{list:()=>s.get(`/api/templates`),get:e=>s.get(`/api/templates/${encodeURIComponent(e)}`),create:e=>s.post(`/api/templates`,e),update:(e,t)=>s.put(`/api/templates/${encodeURIComponent(e)}`,t),remove:e=>s.delete(`/api/templates/${encodeURIComponent(e)}`),versions:e=>s.get(`/api/templates/${encodeURIComponent(e)}/versions`),getVersion:(e,t)=>s.get(`/api/templates/${encodeURIComponent(e)}/versions/${t}`),render:(e,t)=>s.post(`/api/templates/${encodeURIComponent(e)}/render`,{inputs:t}),createFromRun:(e,t)=>s.post(`/api/templates`,{sourceRunId:e,generalize:t?.generalize===!0,name:t?.name,message:t?.message})},workflows:{list:()=>s.get(`/api/workflows`),start:e=>s.post(`/api/workflows`,e),get:e=>s.get(`/api/workflows/${encodeURIComponent(e)}`),events:e=>s.get(`/api/workflows/${encodeURIComponent(e)}/events`),synthesize:e=>s.post(`/api/workflows/synthesize`,{message:e})},plans:{list:()=>s.get(`/api/plans`),read:e=>s.get(`/api/plans/${encodeURIComponent(e)}`),delete:e=>s.delete(`/api/plans/${encodeURIComponent(e)}`)},logs:{list:()=>s.get(`/api/logs`),read:(e,t)=>s.get(`/api/logs/read?file=${encodeURIComponent(e)}${t?`&maxLines=${t}`:``}`),downloadUrl:e=>`/api/logs/download?file=${encodeURIComponent(e)}`,querySessions:e=>{let t=new URLSearchParams;e.sessionIds?.length&&t.set(`sessionIds`,e.sessionIds.join(`,`)),e.levels?.length&&t.set(`levels`,e.levels.join(`,`)),e.from!==void 0&&t.set(`from`,String(e.from)),e.to!==void 0&&t.set(`to`,String(e.to)),e.q&&t.set(`q`,e.q),e.limit!==void 0&&t.set(`limit`,String(e.limit));let n=t.toString();return s.get(`/api/logs/session${n?`?${n}`:``}`)},sessionIndex:()=>s.get(`/api/logs/sessions`)},stt:{status:()=>s.get(`/api/stt/status`),transcribe:(e,t,n=`wav`)=>s.post(`/api/stt/transcribe`,{language:e,audio:t,format:n}),install:()=>s.post(`/api/stt/install`),installStatus:()=>s.get(`/api/stt/install/status`),cancelInstall:()=>s.post(`/api/stt/install/cancel`),getConfig:()=>s.get(`/api/stt/config`),setConfig:e=>s.put(`/api/stt/config`,e)},tts:{status:()=>s.get(`/api/tts/status`),synthesize:e=>s.post(`/api/tts/synthesize`,e),install:()=>s.post(`/api/tts/install`),installStatus:()=>s.get(`/api/tts/install/status`),cancelInstall:()=>s.post(`/api/tts/install/cancel`)},hooks:{list:()=>s.get(`/api/hooks/rules`),get:e=>s.get(`/api/hooks/rules/${encodeURIComponent(e)}`),create:e=>s.post(`/api/hooks/rules`,e),update:(e,t)=>s.put(`/api/hooks/rules/${encodeURIComponent(e)}`,t),delete:e=>s.delete(`/api/hooks/rules/${encodeURIComponent(e)}`),batchDelete:e=>s.post(`/api/hooks/rules/batch-delete`,{names:e}),toggle:(e,t)=>s.patch(`/api/hooks/rules/${encodeURIComponent(e)}/toggle`,{enabled:t}),batchToggle:(e,t)=>s.post(`/api/hooks/rules/batch-toggle`,{names:e,enabled:t}),dryRun:e=>s.post(`/api/hooks/dry-run`,e),stats:()=>s.get(`/api/hooks/stats`),events:()=>s.get(`/api/hooks/events`),agents:()=>s.get(`/api/hooks/agents`),templates:()=>s.get(`/api/hooks/templates`),export:()=>s.get(`/api/hooks/export`),import:e=>s.post(`/api/hooks/import`,e)},assistants:{list:()=>s.get(`/api/assistants`),get:e=>s.get(`/api/assistants/${encodeURIComponent(e)}`),create:(e={})=>s.post(`/api/assistants`,e),rename:(e,t)=>s.patch(`/api/assistants/${encodeURIComponent(e)}`,{title:t}),update:(e,t)=>s.patch(`/api/assistants/${encodeURIComponent(e)}`,t),remove:e=>s.delete(`/api/assistants/${encodeURIComponent(e)}`)},channels:{list:()=>s.get(`/api/channels`),types:()=>s.get(`/api/channels/types`),catalog:()=>s.get(`/api/channels/catalog`),create:e=>s.post(`/api/channels`,e),update:(e,t)=>s.put(`/api/channels/${encodeURIComponent(e)}`,t),delete:e=>s.delete(`/api/channels/${encodeURIComponent(e)}`),toggle:(e,t)=>s.patch(`/api/channels/${encodeURIComponent(e)}/toggle`,{enabled:t}),test:e=>s.post(`/api/channels/${encodeURIComponent(e)}/test`),wechat:{qrcode:(e,t)=>s.get(`/api/channels/${encodeURIComponent(e)}/wechat/qrcode?token=${encodeURIComponent(t)}`),qrcodeStatus:(e,t,n)=>s.get(`/api/channels/${encodeURIComponent(e)}/wechat/qrcode/status?token=${encodeURIComponent(t)}&qrcode=${encodeURIComponent(n)}`)},weixin:{bind:()=>s.get(`/api/weixin/bind`),bindStatus:e=>s.get(`/api/weixin/bind/status?qrcode=${encodeURIComponent(e)}`)}},automations:{list:()=>s.get(`/api/automations`),create:e=>s.post(`/api/automations`,e),update:(e,t)=>s.put(`/api/automations/${encodeURIComponent(e)}`,t),remove:e=>s.delete(`/api/automations/${encodeURIComponent(e)}`),toggle:(e,t)=>s.post(`/api/automations/${encodeURIComponent(e)}/toggle`,{enabled:t}),run:e=>s.post(`/api/automations/${encodeURIComponent(e)}/run`),runs:e=>s.get(`/api/automations/${encodeURIComponent(e)}/runs`),addPermission:(e,t,n)=>s.post(`/api/automations/${encodeURIComponent(e)}/permissions`,{tool:t,target:n}),revokePermission:(e,t)=>s.delete(`/api/automations/${encodeURIComponent(e)}/permissions`,{entry:t})}};function d(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result,n=e.indexOf(`,`);t(n>=0?e.slice(n+1):e)},r.onerror=()=>n(r.error||Error(`Failed to read file`)),r.readAsDataURL(e)})}export{o as a,i,l as n,n as o,s as r,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./path-fybaL0A-.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-CumnGVmJ.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i){if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-NGNAAXSQ-Bw6tHVuc.js";export{M as createArchitectureServices}from"./mermaid-parser.core-BrXnuEs7.js";
|