@aalis/plugin-webui-client 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +235 -0
- package/README.md +21 -0
- package/dist/assets/AuthorityPage-COZ1GZ_n.js +12 -0
- package/dist/assets/DynamicPage-DJFDEG6E.js +19 -0
- package/dist/assets/FilesPage-CBCBRbIG.js +16 -0
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/LogPage-C_Z3RA5T.js +1 -0
- package/dist/assets/MarketplacePage-HGIvPE-L.js +23 -0
- package/dist/assets/PlatformPage-BU3sDCdV.js +6 -0
- package/dist/assets/PluginConfigPage-B-xh_pwj.js +23 -0
- package/dist/assets/SchemaForm-YVQZ6Keg.js +1 -0
- package/dist/assets/SessionsPage-DOl-b2K7.js +1 -0
- package/dist/assets/arc-B9dZH4Mz.js +1 -0
- package/dist/assets/architectureDiagram-3BPJPVTR-_XZszVRW.js +36 -0
- package/dist/assets/blockDiagram-GPEHLZMM-DjTNIZAV.js +132 -0
- package/dist/assets/c4Diagram-AAUBKEIU-DAcjskYi.js +10 -0
- package/dist/assets/channel-CWs0Ph4z.js +1 -0
- package/dist/assets/chunk-2J33WTMH-CHFaIVIG.js +1 -0
- package/dist/assets/chunk-4BX2VUAB-BLsTiY6G.js +1 -0
- package/dist/assets/chunk-55IACEB6-BUHj8uJ5.js +1 -0
- package/dist/assets/chunk-727SXJPM-BJxPkPIn.js +206 -0
- package/dist/assets/chunk-AQP2D5EJ-D9XSGH7X.js +231 -0
- package/dist/assets/chunk-FMBD7UC4-14mizF84.js +15 -0
- package/dist/assets/chunk-ND2GUHAM-DHAQxCCH.js +1 -0
- package/dist/assets/chunk-QZHKN3VN-BRYJuaKF.js +1 -0
- package/dist/assets/classDiagram-4FO5ZUOK-BGMWGMFm.js +1 -0
- package/dist/assets/classDiagram-v2-Q7XG4LA2-BGMWGMFm.js +1 -0
- package/dist/assets/clock-CuE2gSPG.js +6 -0
- package/dist/assets/cose-bilkent-S5V4N54A---ynUpZp.js +1 -0
- package/dist/assets/cytoscape-fcose-DXAQNCkb.js +1 -0
- package/dist/assets/cytoscape.esm-LDYqcvCF.js +331 -0
- package/dist/assets/dagre-BM42HDAG-B_veAgHZ.js +4 -0
- package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/assets/diagram-2AECGRRQ-2Kvvu1DV.js +43 -0
- package/dist/assets/diagram-5GNKFQAL-BcLJ0vOW.js +10 -0
- package/dist/assets/diagram-KO2AKTUF-DgvS7EhJ.js +3 -0
- package/dist/assets/diagram-LMA3HP47-Dobv6LjS.js +24 -0
- package/dist/assets/diagram-OG6HWLK6-kbRFWXPw.js +24 -0
- package/dist/assets/erDiagram-TEJ5UH35-B6ilVUKl.js +85 -0
- package/dist/assets/flowDiagram-I6XJVG4X-DWyEuHCU.js +162 -0
- package/dist/assets/ganttDiagram-6RSMTGT7-CmgqK4-P.js +292 -0
- package/dist/assets/gitGraphDiagram-PVQCEYII-DuexqjAc.js +106 -0
- package/dist/assets/globe-bFIW3FVE.js +6 -0
- package/dist/assets/graph-CAnANduQ.js +1 -0
- package/dist/assets/highlight-BPWJwfct.css +9 -0
- package/dist/assets/highlight-DJvvuuwd.js +5 -0
- package/dist/assets/index-CaU2rCNv.css +1 -0
- package/dist/assets/index-D4hgfekH.js +207 -0
- package/dist/assets/infoDiagram-5YYISTIA-CzWWvYqm.js +2 -0
- package/dist/assets/init-Gi6I4Gst.js +1 -0
- package/dist/assets/ishikawaDiagram-YF4QCWOH-CwACduTX.js +70 -0
- package/dist/assets/journeyDiagram-JHISSGLW-fT0SRS58.js +139 -0
- package/dist/assets/kanban-definition-UN3LZRKU-DVqDYGqT.js +89 -0
- package/dist/assets/katex-Bq6vt64r.js +265 -0
- package/dist/assets/katex-CIHdCL6t.css +1 -0
- package/dist/assets/layout-DGIYPm2g.js +1 -0
- package/dist/assets/linear-CZgp6Fzk.js +1 -0
- package/dist/assets/markdown-BCywGHw2.js +35 -0
- package/dist/assets/mermaid.core-BbMB3jno.js +309 -0
- package/dist/assets/mindmap-definition-RKZ34NQL-Blj-hhKO.js +96 -0
- package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/assets/pieDiagram-4H26LBE5-C-QBAE8E.js +30 -0
- package/dist/assets/quadrantDiagram-W4KKPZXB-DLNCWkpV.js +7 -0
- package/dist/assets/react-vendor-BPQixOLZ.js +49 -0
- package/dist/assets/requirementDiagram-4Y6WPE33-Db7mnSho.js +84 -0
- package/dist/assets/sankeyDiagram-5OEKKPKP-Dys1xLTB.js +40 -0
- package/dist/assets/sequenceDiagram-3UESZ5HK-BXuxkY9a.js +162 -0
- package/dist/assets/stateDiagram-AJRCARHV-Bf7MYv4Z.js +1 -0
- package/dist/assets/stateDiagram-v2-BHNVJYJU-D-_B0BoL.js +1 -0
- package/dist/assets/timeline-definition-PNZ67QCA-CO_HyU4B.js +120 -0
- package/dist/assets/vennDiagram-CIIHVFJN-BFm2iq_q.js +34 -0
- package/dist/assets/wardley-L42UT6IY-DwPang7i.js +173 -0
- package/dist/assets/wardleyDiagram-YWT4CUSO-B_OPLFkw.js +78 -0
- package/dist/assets/xychartDiagram-2RQKCTM6-I4OX9JOH.js +7 -0
- package/dist/index.html +19 -0
- package/package.json +43 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BbMB3jno.js","assets/react-vendor-BPQixOLZ.js","assets/PluginConfigPage-B-xh_pwj.js","assets/SchemaForm-YVQZ6Keg.js","assets/highlight-DJvvuuwd.js","assets/highlight-BPWJwfct.css","assets/katex-Bq6vt64r.js","assets/katex-CIHdCL6t.css","assets/markdown-BCywGHw2.js","assets/MarketplacePage-HGIvPE-L.js","assets/clock-CuE2gSPG.js","assets/PlatformPage-BU3sDCdV.js","assets/globe-bFIW3FVE.js","assets/AuthorityPage-COZ1GZ_n.js","assets/LogPage-C_Z3RA5T.js","assets/SessionsPage-DOl-b2K7.js","assets/FilesPage-CBCBRbIG.js","assets/DynamicPage-DJFDEG6E.js","assets/cytoscape.esm-LDYqcvCF.js","assets/cytoscape-fcose-DXAQNCkb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as e,r as a,c as qs}from"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import{r as Bs,b as Hs,a as Vs,c as Js,M as _e}from"./markdown-BCywGHw2.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const d of i)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(i){const d={};return i.integrity&&(d.integrity=i.integrity),i.referrerPolicy&&(d.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?d.credentials="include":i.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(i){if(i.ep)return;i.ep=!0;const d=n(i);fetch(i.href,d)}})();const Gs="modulepreload",Ks=function(t){return"/"+t},as={},he=function(s,n,r){let i=Promise.resolve();if(n&&n.length>0){let u=function(l){return Promise.all(l.map(p=>Promise.resolve(p).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),m=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));i=u(n.map(l=>{if(l=Ks(l),l in as)return;as[l]=!0;const p=l.endsWith(".css"),x=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${x}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":Gs,p||(g.as="script"),g.crossOrigin="",g.href=l,m&&g.setAttribute("nonce",m),document.head.appendChild(g),p)return new Promise((w,c)=>{g.addEventListener("load",w),g.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${l}`)))})}))}function d(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return i.then(u=>{for(const h of u||[])h.status==="rejected"&&d(h.reason);return s().catch(d)})},ms="aalis:activeSessionId";function Us(){try{return window.localStorage.getItem(ms)||"__new_chat__"}catch{return"__new_chat__"}}let Ye=Us();const Xe=new Set;function oe(){return Ye}function He(t){if(Ye!==t){Ye=t;try{window.localStorage.setItem(ms,t)}catch{}for(const s of Xe)s(t)}}function Ys(t){return Xe.add(t),()=>Xe.delete(t)}async function te(t,s){return(await fetch(t,{headers:{"Content-Type":"application/json"},...s})).json()}async function de(t,s,n={}){const r=await fetch(`/api/page-action/${encodeURIComponent(t)}/${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),i=await r.json();if(!r.ok)throw new Error(i.error||"请求失败");return i.data}function je(t){return t?t.startsWith("http://")||t.startsWith("https://")?`/api/proxy/image?url=${encodeURIComponent(t)}`:t:""}function Xs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}function Zs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"9",cy:"21",r:"1"}),e.jsx("circle",{cx:"20",cy:"21",r:"1"}),e.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]})}function Qs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function et(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14,2 14,8 20,8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"9"})]})}function st(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function tt(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})})}function nt(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function at(t){const s=a.useRef(t);s.current=t;const n=a.useRef(null),[r,i]=a.useState(!1),d=a.useRef(oe());a.useEffect(()=>{let m,l,p=!1;function x(){if(p)return;const g=location.protocol==="https:"?"wss:":"ws:";m=new WebSocket(`${g}//${location.host}/ws`),n.current=m,m.onopen=()=>{p||(i(!0),m.send(JSON.stringify({type:"subscribe_logs"})),m.send(JSON.stringify({type:"subscribe_session",sessionId:oe()})),d.current=oe())},m.onclose=()=>{p||(i(!1),l=setTimeout(x,3e3))},m.onmessage=w=>{var c,L,I,C,S,K,F,Z,N,W,U,k,D;try{const f=JSON.parse(w.data),v=s.current;f.type==="stream"?(v.onStream(f.contentDelta,f.reasoningDelta,f.done,f.toolLimitReached),f.toolCallProgress&&((c=v.onToolCallProgress)==null||c.call(v,f.toolCallProgress)),f.done&&((L=v.onToolCallProgressClear)==null||L.call(v))):f.type==="message"&&(f.content||(I=f.attachments)!=null&&I.length)?v.onMessage(f.content??"",f.reasoningContent,f.segments,f.attachments,f.modelInfo):f.type==="tool_call"&&f.toolName?v.onToolCall(f.toolName,f.toolArgs??{},f.toolPhase,f.toolResult):f.type==="log"&&f.log?v.onLog(f.log):f.type==="state_changed"?(C=v.onStateChanged)==null||C.call(v):f.type==="restarting"?(S=v.onRestarting)==null||S.call(v):f.type==="reload"?(K=v.onReload)==null||K.call(v):f.type==="sessions_changed"?(F=v.onSessionsChanged)==null||F.call(v):f.type==="todo_updated"&&f.todoItems?(Z=v.onTodoUpdated)==null||Z.call(v,f.todoItems):f.type==="stream_resume"?(N=v.onStreamResume)==null||N.call(v,f.content??"",f.reasoningContent??"",f.segments??[],!!f.done,f.toolCallsProgress):f.type==="confirm"&&f.content?(W=v.onConfirm)==null||W.call(v,f.content):f.type==="token_usage"&&f.tokenUsage?(U=v.onTokenUsage)==null||U.call(v,f.tokenUsage):f.type==="compressing"&&f.sessionId?(k=v.onCompressing)==null||k.call(v,f.sessionId,f.content??"start"):f.type==="history_changed"&&f.sessionId?(D=v.onHistoryChanged)==null||D.call(v,f.sessionId):f.type==="page_refresh"&&window.dispatchEvent(new CustomEvent("aalis:page-refresh",{detail:{pluginName:f.pluginName}}))}catch{}}}return x(),()=>{p=!0,clearTimeout(l),m==null||m.close()}},[]),a.useEffect(()=>Ys(l=>{const p=n.current;(p==null?void 0:p.readyState)===WebSocket.OPEN&&(p.send(JSON.stringify({type:"unsubscribe_session",sessionId:d.current})),p.send(JSON.stringify({type:"subscribe_session",sessionId:l})),d.current=l)}),[]);const u=a.useCallback((m,l)=>{var p;if(((p=n.current)==null?void 0:p.readyState)===WebSocket.OPEN){const x={type:"message",content:m,sessionId:oe()};l&&l.length>0&&(x.attachments=l),n.current.send(JSON.stringify(x))}},[]),h=a.useCallback(m=>{var l;((l=n.current)==null?void 0:l.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(m))},[]);return{send:u,sendRaw:h,connected:r}}function rt(){const t=new Date,s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`会话 ${s}-${n} ${r}:${i}`}function ot(t){const s=[];let n=t.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^)]+\)\]\n--- 文件内容 ---[\s\S]*?--- 文件内容结束 ---/g,(r,i)=>(s.push(i.trim()),""));return n=n.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^,\n)]+[,\n][\s\S]*?\)\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]-]+?) - [^\]]+\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]]+?)\s*(?:\(ID:[^)]+\))?\]/g,(r,i)=>(s.push(i.trim()),"")),{displayContent:n.trim(),fileNames:s}}function it(t){var r,i,d,u;const s=[];let n=0;for(;n<t.length;){const h=t[n];if(h.role==="user"){const m=h.content??"",l=Array.isArray((r=h.metadata)==null?void 0:r.fileNames)?h.metadata.fileNames:null,{displayContent:p,fileNames:x}=ot(m),g=(l??x).filter(Boolean);s.push({role:"user",content:p,fileNames:g.length>0?g:void 0,timestamp:h.timestamp??0}),n++;continue}if(h.role==="system"){h.kind==="event-marker"&&s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="notice"){s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="assistant"){const m=[],l=[];let p=h.timestamp??0,x="",g=!1,w;for(;n<t.length&&(t[n].role==="assistant"||t[n].role==="tool");){const C=t[n];if(C.role==="assistant"){const S=(i=C.metadata)==null?void 0:i.modelInfo;S&&(w=S)}if(C.role==="assistant"&&C.segments&&C.segments.length>0){g=!0,m.length=0,l.length=0;for(const S of C.segments)m.push(S);p=C.timestamp??p,n++;continue}if(C.role==="assistant"&&C.toolCalls&&C.toolCalls.length>0){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&m.push({type:"text",content:C.content});for(const S of C.toolCalls){let K={};try{K=JSON.parse(S.function.arguments)}catch{}m.push({type:"tool_call",name:S.function.name,args:K})}p=C.timestamp??p,n++}else if(C.role==="tool"&&C.toolCallId){for(let S=m.length-1;S>=0;S--){const K=m[S];if(K.type==="tool_call"&&K.result===void 0){K.result=C.content??"";break}}n++}else if(C.role==="assistant"){if(n===t.length-1||((d=t[n+1])==null?void 0:d.role)==="user"||((u=t[n+1])==null?void 0:u.role)==="system"){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),x=C.content??"",p=C.timestamp??p,n++;break}C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&m.push({type:"text",content:C.content}),p=C.timestamp??p,n++}else break}let c;g?c=m:(c=[...l,...m],x&&c.push({type:"text",content:x}));let L="",I="";for(const C of c)C.type==="reasoning_text"?L+=C.content:C.type==="text"&&(I+=C.content);s.push({role:"assistant",content:I||x||h.content||"",segments:c.length>0?c:void 0,reasoningContent:L||void 0,timestamp:p,modelInfo:w});continue}n++}return s}function lt(t){const[s,n]=a.useState([]),[r,i]=a.useState(oe()),[d,u]=a.useState([]),[h,m]=a.useState(!1),l=a.useRef(!1),p=a.useRef(new Map),x=a.useMemo(()=>{const k=t.find(D=>D.key==="sessions");return(k==null?void 0:k.plugin)??null},[t]),g=a.useRef(x);g.current=x;const w=a.useRef(r);w.current=r;const c=a.useRef(d);c.current=d;const L=a.useRef(s);L.current=s;const I=a.useMemo(()=>x?s.length===0||!s.some(k=>k.id===r):!1,[x,s,r]),C=a.useMemo(()=>{const k=s.find(D=>D.id===r);return(k==null?void 0:k.title)||(k==null?void 0:k.displayTitle)||(k==null?void 0:k.name)||""},[s,r]),S=a.useCallback(()=>{const k=g.current;k&&de(k,"listSessions").then(D=>{Array.isArray(D)&&n(D)}).catch(()=>{})},[]),K=a.useCallback(()=>{c.current.length>0&&p.current.set(w.current,c.current);const k="__new_chat__";i(k),He(k),u([]),m(!1),l.current=!1},[]),F=a.useCallback(async k=>{const D=g.current;if(!D)return null;const f=rt();try{const v=await de(D,"createSession",{name:f,...k?{parentId:k}:{}});if(!(v!=null&&v.id))return null;const V=v.id;return n(J=>{if(J.some(_=>_.id===V))return J;const ae={id:V,name:v.name||f,title:v.title,displayTitle:v.title||v.name||f,status:"active",children:[],childCount:0,parentId:k,createdAt:Date.now()};return[...J,ae]}),k&&n(J=>J.map(ae=>ae.id===k?{...ae,children:[...ae.children,V],childCount:ae.childCount+1}:ae)),c.current.length>0&&p.current.set(w.current,c.current),i(V),He(V),u([]),m(!1),l.current=!1,de(D,"listSessions").then(J=>{Array.isArray(J)&&n(J)}).catch(()=>{}),V}catch{return null}},[]),Z=a.useCallback(async()=>!g.current||L.current.some(f=>f.id===w.current)?w.current:await F()||w.current,[F]),N=a.useCallback((k,D)=>{de(D,"getSessionDetail",{id:k}).then(f=>{if(f!=null&&f.messages&&w.current===k){const v=it(f.messages);if(l.current){for(;v.length>0&&v[v.length-1].role==="assistant";)v.pop();const V=c.current,J=V[V.length-1];J&&J.role==="assistant"&&v.push(J)}u(v),p.current.set(k,v)}}).catch(()=>{})},[]),W=a.useCallback(k=>{const D=k===w.current;if(D&&c.current.length>0)return;!D&&c.current.length>0&&p.current.set(w.current,c.current),i(k),He(k),m(!1),l.current=!1;const f=g.current,v=p.current.get(k);u(v??[]),!v&&f&&N(k,f),S()},[N,S]),U=a.useCallback(k=>{if(k!==w.current)return;const D=g.current;D&&(p.current.delete(k),N(k,D))},[N]);return a.useEffect(()=>{x&&de(x,"listSessions").then(k=>{if(!Array.isArray(k))return;n(k);const D=oe();D&&D!=="__new_chat__"&&k.some(f=>f.id===D)&&(i(D),N(D,x))}).catch(()=>{})},[x,N]),{pluginName:x,sessionList:s,activeSessionId:r,activeSessionTitle:C,isNewChat:I,messages:d,setMessages:u,refresh:S,startNewChat:K,createSession:F,ensureSession:Z,switchSession:W,handleHistoryChanged:U,loading:h,setLoading:m,streamingRef:l}}/**
|
|
3
|
+
* @license lucide-react v1.7.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const fs=(...t)=>t.filter((s,n,r)=>!!s&&s.trim()!==""&&r.indexOf(s)===n).join(" ").trim();/**
|
|
8
|
+
* @license lucide-react v1.7.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const ct=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
13
|
+
* @license lucide-react v1.7.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const dt=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
|
|
18
|
+
* @license lucide-react v1.7.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const rs=t=>{const s=dt(t);return s.charAt(0).toUpperCase()+s.slice(1)};/**
|
|
23
|
+
* @license lucide-react v1.7.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/var Ve={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
28
|
+
* @license lucide-react v1.7.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const ut=t=>{for(const s in t)if(s.startsWith("aria-")||s==="role"||s==="title")return!0;return!1},ht=a.createContext({}),mt=()=>a.useContext(ht),ft=a.forwardRef(({color:t,size:s,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:d,iconNode:u,...h},m)=>{const{size:l=24,strokeWidth:p=2,absoluteStrokeWidth:x=!1,color:g="currentColor",className:w=""}=mt()??{},c=r??x?Number(n??p)*24/Number(s??l):n??p;return a.createElement("svg",{ref:m,...Ve,width:s??l??Ve.width,height:s??l??Ve.height,stroke:t??g,strokeWidth:c,className:fs("lucide",w,i),...!d&&!ut(h)&&{"aria-hidden":"true"},...h},[...u.map(([L,I])=>a.createElement(L,I)),...Array.isArray(d)?d:[d]])});/**
|
|
33
|
+
* @license lucide-react v1.7.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const H=(t,s)=>{const n=a.forwardRef(({className:r,...i},d)=>a.createElement(ft,{ref:d,iconNode:s,className:fs(`lucide-${ct(rs(t))}`,`lucide-${t}`,r),...i}));return n.displayName=rs(t),n};/**
|
|
38
|
+
* @license lucide-react v1.7.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const pt=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ps=H("archive",pt);/**
|
|
43
|
+
* @license lucide-react v1.7.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const xt=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],gt=H("bot",xt);/**
|
|
48
|
+
* @license lucide-react v1.7.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const jt=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],os=H("brain-circuit",jt);/**
|
|
53
|
+
* @license lucide-react v1.7.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const vt=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],xs=H("chevron-down",vt);/**
|
|
58
|
+
* @license lucide-react v1.7.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const yt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],gs=H("chevron-right",yt);/**
|
|
63
|
+
* @license lucide-react v1.7.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const Nt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],js=H("circle-check",Nt);/**
|
|
68
|
+
* @license lucide-react v1.7.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const wt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],kt=H("circle",wt);/**
|
|
73
|
+
* @license lucide-react v1.7.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const bt=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],Ct=H("command",bt);/**
|
|
78
|
+
* @license lucide-react v1.7.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const St=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],_t=H("download",St);/**
|
|
83
|
+
* @license lucide-react v1.7.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const $t=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ze=H("file-text",$t);/**
|
|
88
|
+
* @license lucide-react v1.7.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const It=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Mt=H("file",It);/**
|
|
93
|
+
* @license lucide-react v1.7.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const Tt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Et=H("folder-open",Tt);/**
|
|
98
|
+
* @license lucide-react v1.7.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const Lt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Je=H("history",Lt);/**
|
|
103
|
+
* @license lucide-react v1.7.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const Rt=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Dt=H("list-todo",Rt);/**
|
|
108
|
+
* @license lucide-react v1.7.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const Pt=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Qe=H("loader",Pt);/**
|
|
113
|
+
* @license lucide-react v1.7.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const At=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],is=H("message-square",At);/**
|
|
118
|
+
* @license lucide-react v1.7.0 - ISC
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the ISC license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/const zt=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],vs=H("paperclip",zt);/**
|
|
123
|
+
* @license lucide-react v1.7.0 - ISC
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the ISC license.
|
|
126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/const Ot=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ft=H("refresh-cw",Ot);/**
|
|
128
|
+
* @license lucide-react v1.7.0 - ISC
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the ISC license.
|
|
131
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
+
*/const Wt=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],qt=H("sparkles",Wt);/**
|
|
133
|
+
* @license lucide-react v1.7.0 - ISC
|
|
134
|
+
*
|
|
135
|
+
* This source code is licensed under the ISC license.
|
|
136
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
+
*/const Bt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ht=H("square",Bt);/**
|
|
138
|
+
* @license lucide-react v1.7.0 - ISC
|
|
139
|
+
*
|
|
140
|
+
* This source code is licensed under the ISC license.
|
|
141
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
+
*/const Vt=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Jt=H("trash-2",Vt);/**
|
|
143
|
+
* @license lucide-react v1.7.0 - ISC
|
|
144
|
+
*
|
|
145
|
+
* This source code is licensed under the ISC license.
|
|
146
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
+
*/const Gt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],De=H("triangle-alert",Gt);/**
|
|
148
|
+
* @license lucide-react v1.7.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/const Kt=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ss=H("wrench",Kt);/**
|
|
153
|
+
* @license lucide-react v1.7.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/const Ut=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ys=H("x",Ut);/**
|
|
158
|
+
* @license lucide-react v1.7.0 - ISC
|
|
159
|
+
*
|
|
160
|
+
* This source code is licensed under the ISC license.
|
|
161
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
+
*/const Yt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Ns=H("zap",Yt);function Ge({name:t,info:s,onPreferChanged:n}){var g;const[r,i]=a.useState(!1),d=s.providers,u=d.length>0,h=d.length>1,m=s.preferred??((g=d[0])==null?void 0:g.contextId)??"",l=d.find(w=>w.contextId===m),p=async w=>{if(!r){i(!0);try{await te(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"POST",body:JSON.stringify({contextId:w})}),n==null||n()}finally{i(!1)}}},x=async()=>{if(!r){i(!0);try{await te(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"DELETE"}),n==null||n()}finally{i(!1)}}};return e.jsxs("div",{className:"service-slot-card",children:[e.jsxs("div",{className:"service-slot-header",children:[e.jsx("span",{className:"service-slot-name",children:t}),e.jsxs("div",{className:"service-slot-header-badges",children:[s.preferred&&e.jsx("span",{className:"service-winner-badge preferred",children:"偏好"}),e.jsx("span",{className:`badge ${u?"active":"error"}`,children:u?h?`${d.length} 个提供者`:"就绪":"未就绪"})]})]}),u?h?e.jsxs("div",{className:"service-slot-select-row",children:[e.jsx("span",{className:"service-slot-label",children:"活跃提供者"}),e.jsx("select",{className:"service-select",value:m,disabled:r,onChange:w=>p(w.target.value),children:d.map(w=>{const c=w.displayName||w.label||w.contextId,L=c!==w.contextId?`${c} · p${w.priority} (${w.contextId})`:`${w.contextId} · p${w.priority}`;return e.jsx("option",{value:w.contextId,children:L},w.contextId)})}),s.preferred&&e.jsx("button",{type:"button",className:"service-clear-prefer",onClick:x,disabled:r,title:"清除偏好,恢复 priority 默认顺序",children:"恢复默认"})]}):e.jsxs("div",{className:"service-slot-single",children:[e.jsx("span",{className:"service-slot-label",children:"提供者"}),e.jsxs("span",{className:"service-slot-provider-name",children:[(l==null?void 0:l.displayName)||(l==null?void 0:l.label)||(l==null?void 0:l.contextId),((l==null?void 0:l.displayName)||(l==null?void 0:l.label))&&e.jsxs("span",{className:"service-slot-context-id",children:[" ",l==null?void 0:l.contextId]})]})]}):e.jsx("div",{className:"service-slot-single",children:e.jsx("span",{className:"empty-hint",children:"无提供者"})}),l&&l.capabilities.length>0&&e.jsx("div",{className:"service-slot-caps",children:l.capabilities.map(w=>e.jsx("span",{className:"tool-chip",children:w},w))})]})}function Xt({status:t,connected:s,plugins:n,servicesData:r,onRefreshServices:i}){var Z;const d=n.filter(N=>N.state==="active").length,u=n.filter(N=>N.state==="error").length,h=n.length,[m,l]=a.useState(null),[p,x]=a.useState([]),[g,w]=a.useState([]),[c,L]=a.useState([]);a.useEffect(()=>{te("/api/tool-groups").then(N=>x(N.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{te("/api/service-groups").then(N=>w(N.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{te("/api/llm-models").then(N=>L(N.models??[])).catch(()=>{})},[n]);const I=r?Object.entries(r):[],C=g.map(N=>({label:N.label,entries:I.filter(([W])=>N.services.includes(W))})),S=C.some(N=>N.entries.length>0),K=new Set(g.flatMap(N=>N.services)),F=I.filter(([N])=>!K.has(N));return e.jsxs("div",{className:"page-content page-dashboard",children:[m&&e.jsx("div",{className:"toast",children:m}),e.jsx("div",{className:"section-label",children:"概览"}),e.jsxs("div",{className:"overview-grid",children:[e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx("span",{className:`status-dot-lg ${s?"online":"offline"}`})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"连接状态"}),e.jsx("div",{className:"overview-card-value",children:s?"已连接":"离线"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(qt,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"应用名称"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.name)??"-"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(Ns,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"活跃插件"}),e.jsxs("div",{className:"overview-card-value",children:[d," / ",h]})]})]}),u>0&&e.jsxs("div",{className:"overview-card overview-card-error",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(De,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"错误插件"}),e.jsx("div",{className:"overview-card-value",children:u})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(ss,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册工具"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.tools.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(Ct,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册指令"}),e.jsx("div",{className:"overview-card-value",children:((Z=t==null?void 0:t.commands)==null?void 0:Z.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(gt,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"可用模型"}),e.jsx("div",{className:"overview-card-value",children:c.length})]})]})]}),S?e.jsxs(e.Fragment,{children:[C.map(N=>N.entries.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:N.label}),e.jsx("div",{className:"services-grid",children:N.entries.map(([W,U])=>e.jsx(Ge,{name:W,info:U,onPreferChanged:i},W))})]},N.label)),F.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:"其他"}),e.jsx("div",{className:"services-grid",children:F.map(([N,W])=>e.jsx(Ge,{name:N,info:W,onPreferChanged:i},N))})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-label",children:"服务"}),e.jsxs("div",{className:"services-grid",children:[I.length===0&&e.jsx("div",{className:"empty-hint",children:"加载中..."}),I.map(([N,W])=>e.jsx(Ge,{name:N,info:W,onPreferChanged:i},N))]})]}),e.jsx("div",{className:"section-label",children:"工具分组"}),p.length>0?e.jsx("div",{className:"tool-groups-grid",children:p.map(N=>{const W=N.contributingPlugins??[],U=[N.pluginName,...W.filter(k=>k!==N.pluginName)];return e.jsxs("div",{className:"tool-group-card",children:[e.jsxs("div",{className:"tool-group-header",children:[e.jsx("span",{className:"tool-group-name",children:N.label}),e.jsxs("span",{className:"tool-group-count",children:[N.toolCount," 工具"]})]}),N.description&&e.jsx("div",{className:"tool-group-desc",children:N.description}),e.jsxs("div",{className:"tool-group-meta",children:[e.jsx("span",{className:"tool-group-id",children:N.name}),e.jsx("span",{className:"tool-group-plugin",title:U.join(", "),children:U.join(" · ")})]})]},N.name)})}):e.jsx("div",{className:"tools-grid",children:!t||t.tools.length===0?e.jsx("div",{className:"empty-hint",children:"无工具"}):t.tools.map(N=>e.jsx("span",{className:"tool-chip",children:N},N))}),e.jsx("div",{className:"section-label",children:"已注册指令"}),e.jsx("div",{className:"tools-grid",children:!t||!t.commands||t.commands.length===0?e.jsx("div",{className:"empty-hint",children:"无指令"}):t.commands.map(N=>e.jsxs("span",{className:"tool-chip cmd-chip",title:N.description,children:["/",N.name]},N.name))})]})}function ls(t){const n=t.trim().split("|"),r=n[0].trim()===""?1:0,i=n[n.length-1].trim()===""?n.length-1:n.length;return Math.max(0,i-r)}function Zt(t,s){const n=t.trim(),r=n.startsWith("|")?"|":"",i=n.endsWith("|")?"|":"",u=n.slice(r.length,i?n.length-1:void 0).split("|").map(h=>h.trim()).filter(h=>/^:?-+:?$/.test(h));for(;u.length<s;)u.push("---");return u.length=s,r+u.join("|")+i}function Qt(t){return/^\|?[ \t]*:?-+:?[ \t]*(\|[ \t]*:?-+:?[ \t]*)*\|?\s*$/.test(t)}function en(t){return t&&t.split(/(```[\s\S]*?```|`[^`\n]*`)/g).map((n,r)=>{if(r%2===1)return n;const i=n.split(`
|
|
163
|
+
`),d=[];for(let u=0;u<i.length;u++){const h=i[u];if(u>0&&Qt(h)){const m=i[u-1];if(m.includes("|")&&m.trim()){const l=ls(m),p=ls(h);if(l>0&&p>0&&l!==p){d.push(Zt(h,l));continue}}}d.push(h)}return d.join(`
|
|
164
|
+
`)}).join("")}function $e(t){return t=en(t),t.split(/(```[\s\S]*?```|`[^`]*`)/g).map((n,r)=>(r%2===1||(n=n.replace(/\\\[([\s\S]*?)\\\]/g,(d,u)=>`$$${u.replace(/\|/g,"\\vert ")}$$`),n=n.replace(/\\\((.*?)\\\)/g,(d,u)=>`$${u.replace(/\|/g,"\\vert ")}$`),n=n.replace(/\$\$([\s\S]+?)\$\$/g,(d,u)=>u.includes(`
|
|
165
|
+
`)?`
|
|
166
|
+
|
|
167
|
+
$$
|
|
168
|
+
${u.replace(/^[ \t]*\n?/,"").replace(/\n?[ \t]*$/,"")}
|
|
169
|
+
$$
|
|
170
|
+
|
|
171
|
+
`:d),(n.match(/\$\$/g)??[]).length%2===1&&(n=n.replace(/\$\$((?:(?!\$\$)[\s\S])+)$/,(d,u)=>{const h=u.replace(/^[ \t]*\n?/,"").replace(/\n?[ \t]*$/,"");return!h||!u.includes(`
|
|
172
|
+
`)?`$$${u}`:`
|
|
173
|
+
|
|
174
|
+
$$
|
|
175
|
+
${h}
|
|
176
|
+
$$
|
|
177
|
+
|
|
178
|
+
`}))),n)).join("")}function sn(t){if(!t||!Number.isFinite(t))return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=new Date,r=m=>m.toString().padStart(2,"0"),i=`${r(s.getHours())}:${r(s.getMinutes())}`,d=s.getFullYear()===n.getFullYear();if(d&&s.getMonth()===n.getMonth()&&s.getDate()===n.getDate())return i;const h=`${s.getMonth()+1}-${s.getDate()} ${i}`;return d?h:`${s.getFullYear()}-${h}`}let Ke=null;function tn(){return Ke||(Ke=he(()=>import("./mermaid.core-BbMB3jno.js").then(t=>t.bm),__vite__mapDeps([0,1])).then(t=>{var r;const s=t.default,n=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)").matches);return s.initialize({startOnLoad:!1,theme:n?"dark":"default",securityLevel:"loose",fontFamily:"inherit"}),s})),Ke}function cs(t){if(!(typeof document>"u"))for(const s of[`#${t}`,`#d${t}`,`#${t}-temp`])document.querySelectorAll(s).forEach(n=>n.remove())}let nn=0;function an({chart:t}){const[s,n]=a.useState(null),[r,i]=a.useState(null),d=a.useRef(`mermaid-${++nn}`);return a.useEffect(()=>{let u=!1;const h=d.current,m=t.trim();if(!m){n(null),i(null);return}return tn().then(async l=>(await l.parse(m),l.render(h,m))).then(({svg:l})=>{u||(n(l),i(null))}).catch(l=>{if(cs(h),u)return;const p=l instanceof Error?l.message:String(l);i(p),n(null)}),()=>{u=!0,cs(h)}},[t]),r?e.jsxs("div",{className:"mermaid-block mermaid-block-error",children:[e.jsxs("div",{className:"mermaid-error-banner",children:["⚠ Mermaid 渲染失败:",r]}),e.jsx("pre",{children:e.jsx("code",{className:"language-mermaid",children:t})})]}):s?e.jsx("div",{className:"mermaid-block",dangerouslySetInnerHTML:{__html:s}}):e.jsx("pre",{className:"mermaid-block mermaid-block-loading",children:e.jsx("code",{className:"language-mermaid",children:t})})}const rn=a.memo(an),Ie=[Vs,Js],on={strict:"ignore",throwOnError:!1,errorColor:"inherit",output:"htmlAndMathml"},Me=[Bs,[Hs,on]];function ln({className:t,children:s,...n}){const r=/language-(\w+)/.exec(t??"");if((r==null?void 0:r[1])==="mermaid"){const d=Array.isArray(s)?s.join(""):String(s??"");return e.jsx(rn,{chart:d.replace(/\n$/,"")})}return e.jsx("code",{className:t,...n,children:s})}const Te={code:ln};function cn(t){if(t===0)return"—";const s=["B","KB","MB","GB"];let n=0,r=t;for(;r>=1024&&n<s.length-1;)r/=1024,n++;return`${r.toFixed(n===0?0:1)} ${s[n]}`}function dn(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function un({open:t,onClose:s,sessionId:n}){const[r,i]=a.useState([]),[d,u]=a.useState(!1),[h,m]=a.useState(null),[l,p]=a.useState(null),x=a.useCallback(async()=>{if(!n||n==="__new_chat__"){i([]);return}u(!0),m(null);try{const c=await te(`/api/uploaded-files?sessionId=${encodeURIComponent(n)}`);if(c.error)throw new Error(c.error);i(c.files||[])}catch(c){m(c instanceof Error?c.message:String(c)),i([])}finally{u(!1)}},[n]);a.useEffect(()=>{t&&x()},[t,x]);const g=a.useCallback(async c=>{if(window.confirm(`确定删除文件 "${c.name}"?删除后无法恢复。`)){p(c.id);try{const I=await fetch("/api/uploaded-files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:c.sessionId,fileId:c.id})}),C=await I.json();if(!I.ok||C.error)throw new Error(C.error||`HTTP ${I.status}`);await x()}catch(I){window.alert(`删除失败:${I instanceof Error?I.message:String(I)}`)}finally{p(null)}}},[x]),w=a.useCallback(c=>{const L=`/api/uploaded-files/download?sessionId=${encodeURIComponent(c.sessionId)}&fileId=${encodeURIComponent(c.id)}`;window.open(L,"_blank")},[]);return t?e.jsxs("div",{className:"uploaded-files-drawer",children:[e.jsxs("div",{className:"uploaded-files-drawer-header",children:[e.jsx("span",{className:"uploaded-files-drawer-title",children:"已上传的文件"}),e.jsxs("div",{className:"uploaded-files-drawer-actions",children:[e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:x,title:"刷新",disabled:d,children:e.jsx(Ft,{size:14,className:d?"spin":""})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:s,title:"关闭",children:e.jsx(ys,{size:14})})]})]}),e.jsxs("div",{className:"uploaded-files-drawer-body",children:[h&&e.jsxs("div",{className:"uploaded-files-drawer-error",children:["加载失败:",h]}),!h&&r.length===0&&!d&&e.jsx("div",{className:"uploaded-files-drawer-empty",children:"当前会话没有已上传的文件"}),r.map(c=>e.jsxs("div",{className:"uploaded-files-drawer-item",children:[e.jsx(Mt,{size:16,className:"uploaded-files-drawer-icon"}),e.jsxs("div",{className:"uploaded-files-drawer-info",children:[e.jsx("div",{className:"uploaded-files-drawer-name",title:c.name,children:c.name}),e.jsxs("div",{className:"uploaded-files-drawer-meta",children:[cn(c.size)," · ",c.mimeType," · ",dn(c.uploadedAt)]}),e.jsxs("div",{className:"uploaded-files-drawer-id",title:c.id,children:["ID: ",c.id]})]}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:()=>w(c),title:"下载",children:e.jsx(_t,{size:14})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn danger",onClick:()=>g(c),disabled:l===c.id,title:"删除",children:e.jsx(Jt,{size:14})})]},c.id))]})]}):null}function ds(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>s(r.result),r.onerror=n,r.readAsDataURL(t)})}const hn=a.memo(a.forwardRef(function({loading:s,connected:n,canUpload:r,canUploadImage:i,canUploadFile:d,acceptAttr:u,onSend:h,onAbort:m},l){const[p,x]=a.useState(""),[g,w]=a.useState([]),[c,L]=a.useState([]),I=a.useRef([]),C=a.useRef(null),S=a.useRef(null),K=a.useCallback(()=>{const _=C.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]),F=a.useCallback(async _=>{const T=[],A=[],z=[];for(const Y of Array.from(_))if(Y.type.startsWith("image/")&&i){if(Y.size>10*1024*1024)continue;const Q=await ds(Y);T.push(Q),z.push("image")}else if(d){if(Y.size>20*1024*1024)continue;const Q=await ds(Y);A.push({name:Y.name,data:Q,mimeType:Y.type||void 0}),z.push("file")}T.length>0&&w(Y=>[...Y,...T]),A.length>0&&L(Y=>[...Y,...A]),z.length>0&&(I.current=[...I.current,...z])},[i,d]);a.useImperativeHandle(l,()=>({addFiles:F}),[F]);const Z=a.useCallback(async()=>{await h(p,c,g,I.current),x(""),w([]),L([]),I.current=[],C.current&&(C.current.style.height="auto")},[p,c,g,h]),N=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Z())},W=async _=>{_.target.files&&await F(_.target.files),_.target.value=""},U=async _=>{var z;if(!i)return;const T=(z=_.clipboardData)==null?void 0:z.items;if(!T)return;const A=[];for(const Y of Array.from(T)){if(!Y.type.startsWith("image/"))continue;const Q=Y.getAsFile();Q&&A.push(Q)}A.length>0&&await F(A)},k=_=>{w(z=>z.filter((Y,Q)=>Q!==_));const T=[...I.current];let A=0;for(let z=0;z<T.length;z++)if(T[z]==="image"){if(A===_){T.splice(z,1);break}A++}I.current=T},D=_=>{L(z=>z.filter((Y,Q)=>Q!==_));const T=[...I.current];let A=0;for(let z=0;z<T.length;z++)if(T[z]==="file"){if(A===_){T.splice(z,1);break}A++}I.current=T},f=I.current,v=new Array(g.length),V=new Array(c.length);{let _=0,T=0;for(let A=0;A<f.length;A++)f[A]==="image"?(_<v.length&&(v[_]=A+1),_++):f[A]==="file"&&(T<V.length&&(V[T]=A+1),T++)}const J=!!(p.trim()||g.length>0||c.length>0),ae=s&&!J;return e.jsxs(e.Fragment,{children:[g.length>0&&e.jsx("div",{className:"pending-images",children:g.map((_,T)=>e.jsxs("div",{className:"pending-image-item",children:[e.jsx("img",{src:_,alt:`pending-${T}`}),e.jsx("button",{className:"pending-image-remove",onClick:()=>k(T),children:"×"}),v[T]>0&&e.jsxs("span",{className:"pending-order-badge",children:["#",v[T]]})]},T))}),c.length>0&&e.jsx("div",{className:"pending-files",children:c.map((_,T)=>e.jsxs("div",{className:"pending-file-item",children:[V[T]>0&&e.jsxs("span",{className:"pending-file-order",children:["#",V[T]]}),e.jsx("span",{className:"pending-file-icon",children:e.jsx(Ze,{size:14})}),e.jsx("span",{className:"pending-file-name",children:_.name}),e.jsx("button",{className:"pending-file-remove",onClick:()=>D(T),children:"×"})]},T))}),e.jsxs("div",{className:"input-area",children:[e.jsx("input",{ref:S,type:"file",accept:u,multiple:!0,style:{display:"none"},onChange:W}),r&&e.jsx("button",{className:"upload-btn",onClick:()=>{var _;return(_=S.current)==null?void 0:_.click()},disabled:!n,title:i&&d?"上传图片或文件":i?"上传图片":"上传文件",children:e.jsx(vs,{size:18})}),e.jsx("textarea",{ref:C,value:p,onChange:_=>{x(_.target.value),K()},onKeyDown:N,onPaste:U,placeholder:"输入消息... (Enter 发送, Shift+Enter 换行)",disabled:!n,rows:1}),ae?e.jsx("button",{className:"send-btn stop-mode",onClick:m,title:"停止生成",children:e.jsx(Ht,{size:16})}):e.jsx("button",{className:"send-btn",onClick:()=>{Z()},disabled:!n||!J,children:"↑"})]})]})}));function mn({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());if(a.useEffect(()=>{if(s||!t)return;const d=setInterval(()=>r(Date.now()),100);return()=>clearInterval(d)},[t,s]),!t)return null;const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"tool-call-timer",children:[i.toFixed(1),"s"]})}function us({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());a.useEffect(()=>{if(s)return;let d;const u=()=>{r(Date.now()),d=requestAnimationFrame(u)};return d=requestAnimationFrame(u),()=>cancelAnimationFrame(d)},[s]);const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"compress-timer",children:[i.toFixed(1),"s"]})}function fn({seg:t,index:s}){return e.jsxs("details",{className:"tool-call-block",children:[e.jsxs("summary",{className:"tool-call-summary",children:[e.jsx(ss,{size:14})," ",t.name,t.result==null?" …":"",e.jsx(mn,{startTime:t.startTime,endTime:t.endTime})]}),e.jsxs("div",{className:"tool-call-content",children:[e.jsxs("div",{className:"tool-call-args",children:[e.jsx("strong",{children:"参数"}),e.jsx("pre",{children:JSON.stringify(t.args,null,2)})]}),t.result!=null&&e.jsxs("div",{className:"tool-call-result",children:[e.jsx("strong",{children:"结果"}),e.jsx("pre",{children:t.result})]})]})]},s)}const pn=[".txt",".md",".csv",".json",".xml",".html",".htm",".css",".js",".ts",".yaml",".yml",".ini",".cfg",".conf",".log",".sh",".py",".java",".c",".cpp",".h",".rs",".go",".rb",".php",".sql",".pdf",".docx"],xn=pn.join(",")+",text/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document";function gn(t){const s=t.trim();if(!s.startsWith("{"))return null;try{const n=JSON.parse(s);return typeof n!="object"||n===null||Array.isArray(n)?null:n}catch{return null}}function jn(t){const s=t.trim();if(!s.startsWith("{"))return null;const n=[];let r=1;const i=()=>{for(;r<s.length&&/[\s,]/.test(s[r]);)r++};for(;r<s.length&&(i(),!(r>=s.length||s[r]==="}"||s[r]!=='"'));){r++;let d="",u=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length)d+=s[r+1],r+=2;else if(s[r]==='"'){u=!0,r++;break}else d+=s[r],r++;if(!u){n.push({key:d,keyDone:!1,value:"",valueDone:!1,valueType:"unknown"});break}if(i(),r>=s.length||s[r]!==":"){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(r++,i(),r>=s.length){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(s[r]==='"'){r++;let h="",m=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length){const l=s[r+1];h+=l==="n"?`
|
|
179
|
+
`:l==="t"?" ":l==='"'?'"':l==="\\"?"\\":l,r+=2}else if(s[r]==='"'){m=!0,r++;break}else h+=s[r],r++;n.push({key:d,keyDone:!0,value:h,valueDone:m,valueType:"string"})}else if(s[r]==="{"||s[r]==="["){const h=s[r],m=h==="{"?"}":"]";let l=1;const p=r;r++;let x=!1;for(;r<s.length&&l>0;)x?s[r]==="\\"?r++:s[r]==='"'&&(x=!1):s[r]==='"'?x=!0:s[r]===h?l++:s[r]===m&&l--,r++;n.push({key:d,keyDone:!0,value:s.slice(p,r),valueDone:l===0,valueType:h==="{"?"object":"array"})}else{let h="";for(;r<s.length&&!/[,\s}]/.test(s[r]);)h+=s[r],r++;const m=r<s.length&&/[,}]/.test(s[r]),l=/^(true|false)$/.test(h)?"boolean":h==="null"?"null":"number";n.push({key:d,keyDone:!0,value:h,valueDone:m,valueType:l})}}return n.length>0?n:null}const ws={mood:"心情",state:"状态",desire:"发言欲望",current_action:"当前动作",think:"思考",message:"回复",response:"回复",reply:"回复",content:"内容",analysis:"分析",file_analysis:"文件分析",image_analysis:"图片分析"},ks=new Set(["message","response","reply","content","answer","text","msg"]);function vn({label:t,data:s}){const[n,r]=a.useState(!0);return e.jsxs("div",{className:"json-field json-field-group",children:[e.jsxs("div",{className:"json-field-header json-field-toggle",onClick:()=>r(!n),children:[n?e.jsx(xs,{size:14}):e.jsx(gs,{size:14}),e.jsx("span",{className:"json-field-label",children:t})]}),n&&e.jsx("div",{className:"json-field-children",children:Object.entries(s).map(([i,d])=>e.jsx(bs,{fieldKey:i,value:d},i))})]})}function bs({fieldKey:t,value:s}){const n=ws[t]||t;if(s==null||s==="")return null;if(typeof s=="object"&&!Array.isArray(s))return e.jsx(vn,{label:n,data:s});if(Array.isArray(s))return e.jsxs("div",{className:"json-field",children:[e.jsx("span",{className:"json-field-label",children:n}),e.jsx("span",{className:"json-field-value",children:s.map(String).join(", ")})]});const r=String(s),i=ks.has(t);return e.jsxs("div",{className:`json-field${i?" json-field-reply":""}`,children:[e.jsx("span",{className:"json-field-label",children:n}),i?e.jsx("div",{className:"json-field-value json-field-value-md",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(r)})}):e.jsx("span",{className:"json-field-value",children:r})]})}function yn({data:t}){return e.jsx("div",{className:"json-message-view",children:Object.entries(t).map(([s,n])=>e.jsx(bs,{fieldKey:s,value:n},s))})}function Nn({fields:t}){return e.jsx("div",{className:"json-message-view",children:t.map((s,n)=>{const i=n===t.length-1&&(!s.valueDone||!s.keyDone),d=s.keyDone&&ws[s.key]||s.key,u=s.keyDone&&ks.has(s.key);return e.jsxs("div",{className:`json-field${u?" json-field-reply":""}`,children:[e.jsxs("span",{className:`json-field-label${s.keyDone?"":" json-field-partial"}`,children:[d,!s.keyDone&&i&&e.jsx("span",{className:"streaming-cursor"})]}),s.keyDone&&(u&&s.value?e.jsxs("div",{className:"json-field-value json-field-value-md",children:[e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s.value)}),i&&e.jsx("span",{className:"streaming-cursor"})]}):e.jsxs("span",{className:"json-field-value",children:[s.value,i&&e.jsx("span",{className:"streaming-cursor"})]}))]},n)})})}const Ue=a.memo(function({content:s}){const n=gn(s);if(n)return e.jsx(yn,{data:n});if(s.trim().startsWith("{")){const i=jn(s);return i?e.jsx(Nn,{fields:i}):null}return e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s)})});function wn(t){if(!t)return"";const s=[];return t.image&&s.push("image/*"),t.file&&s.push(xn),s.push("audio/*"),s.push("video/*"),s.join(",")}function kn({status:t}){switch(t){case"completed":return e.jsx(js,{size:14,className:"todo-icon todo-icon-done"});case"in-progress":return e.jsx(Qe,{size:14,className:"todo-icon todo-icon-active"});default:return e.jsx(kt,{size:14,className:"todo-icon todo-icon-pending"})}}function bn({items:t,onClear:s,loading:n}){const[r,i]=a.useState(!0),d=t.filter(l=>l.status==="completed").length,u=t.length,h=d===u,m=!h&&n;return e.jsxs("div",{className:`todo-bar ${h?"todo-bar-done":""}`,children:[e.jsxs("div",{className:"todo-bar-header",onClick:()=>i(!r),children:[e.jsx(Dt,{size:15,className:"todo-bar-icon"}),e.jsx("span",{className:"todo-bar-title",children:"任务计划"}),e.jsxs("span",{className:"todo-bar-count",children:[d,"/",u]}),e.jsx("div",{className:"todo-bar-progress",children:e.jsx("div",{className:"todo-bar-progress-fill",style:{width:`${u>0?d/u*100:0}%`}})}),e.jsx("button",{className:"todo-bar-toggle",title:r?"收起":"展开",children:r?e.jsx(xs,{size:14}):e.jsx(gs,{size:14})}),e.jsx("button",{className:"todo-bar-clear",onClick:l=>{l.stopPropagation(),m||s()},disabled:m,title:m?"任务执行中,无法清除":"清除计划",children:e.jsx(ys,{size:14})})]}),r&&e.jsx("div",{className:"todo-bar-list",children:t.map(l=>e.jsxs("div",{className:`todo-item todo-item-${l.status}`,children:[e.jsx(kn,{status:l.status}),e.jsx("span",{className:"todo-item-title",children:l.title})]},l.id))})]})}const es="aalis:open-lightbox";function hs(t){window.dispatchEvent(new CustomEvent(es,{detail:t}))}const Cn=a.memo(function({msg:s,senderName:n,isLast:r,isGenerating:i,onAbort:d,checkpoint:u,rolledBack:h,onRollback:m,onRollbackWithChat:l,toolCallsProgress:p}){return s.role==="system"?e.jsxs("div",{className:"system-event-separator",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(ps,{size:12})," ",s.content]}),e.jsx("span",{className:"system-event-line"})]}):e.jsxs("div",{className:`message-group ${s.role}`,children:[e.jsxs("div",{className:"message-sender",children:[e.jsx("span",{className:"message-sender-name",children:s.role==="user"?"You":n}),s.timestamp?e.jsx("span",{className:"message-time",title:new Date(s.timestamp).toLocaleString(),children:sn(s.timestamp)}):null,s.role==="assistant"&&s.modelInfo&&(s.modelInfo.model||s.modelInfo.completionTokens!=null)?e.jsxs("span",{className:"message-model-badge",title:[s.modelInfo.provider&&s.modelInfo.model?`${s.modelInfo.provider} / ${s.modelInfo.model}`:s.modelInfo.model,s.modelInfo.completionTokens!=null?`本次生成 ${s.modelInfo.completionTokens} tok`:null,s.modelInfo.promptTokens!=null?`上下文 ${s.modelInfo.promptTokens} tok`:null,s.modelInfo.elapsedMs!=null?`耗时 ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:null].filter(Boolean).join(" · "),children:[s.modelInfo.model??"",s.modelInfo.completionTokens!=null?` · ${(s.modelInfo.completionTokens/1e3).toFixed(1)}k`:"",s.modelInfo.elapsedMs!=null?` · ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:""]}):null]}),s.role==="user"&&s.images&&s.images.length>0&&e.jsx("div",{className:"message-images",children:s.images.map((x,g)=>e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(x),alt:`attached-${g}`,className:"message-image",onClick:()=>hs(je(x))})},g))}),s.role==="user"&&s.fileNames&&s.fileNames.length>0&&e.jsx("div",{className:"message-files",children:s.fileNames.map((x,g)=>e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",x]},g))}),s.role==="assistant"&&s.attachments&&s.attachments.length>0&&e.jsx("div",{className:"message-images",children:s.attachments.map((x,g)=>x.kind==="image"?e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:je(x.data),alt:x.name??`attachment-${g}`,className:"message-image",onClick:()=>hs(je(x.data))})},`a-${g}`):x.kind==="video"?e.jsx("video",{controls:!0,src:je(x.data),className:"message-image"},`a-${g}`):x.kind==="audio"?e.jsx("audio",{controls:!0,src:je(x.data)},`a-${g}`):e.jsxs("div",{className:"message-file-item",children:[e.jsx(Ze,{size:14})," ",x.name??"attachment"]},`a-${g}`))}),s.role==="assistant"&&s.segments&&s.segments.length>0?e.jsx("div",{className:"message-bubble",children:(()=>{const x=[];let g=0;for(;g<s.segments.length;){const w=s.segments[g];if(w.type==="reasoning_text"){const c=[];for(;g<s.segments.length&&s.segments[g].type==="reasoning_text";)c.push(s.segments[g]),g++;const L=c.filter(I=>I.type==="reasoning_text").map(I=>I.content).join("");L&&x.push(e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(os,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(L)})})]},`r-${g}`));continue}if(w.type==="text"){w.content&&x.push(e.jsx(Ue,{content:w.content},`t-${g}`)),g++;continue}x.push(e.jsx(fn,{seg:w,index:g},`tc-${g}`)),g++}return x})()}):s.role==="assistant"&&s.reasoningContent?e.jsxs(e.Fragment,{children:[e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(os,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(_e,{remarkPlugins:Ie,rehypePlugins:Me,components:Te,children:$e(s.reasoningContent)})})]}),e.jsx("div",{className:"message-bubble",children:e.jsx(Ue,{content:s.content})})]}):e.jsx("div",{className:"message-bubble",children:s.role==="assistant"?e.jsx(Ue,{content:s.content}):s.content}),s.role==="assistant"&&p&&p.size>0&&e.jsx("div",{className:"tool-call-progress-bubble",children:[...p.entries()].sort((x,g)=>x[0]-g[0]).map(([x,g])=>e.jsx(Cs,{name:g.name,charsAccumulated:g.charsAccumulated,startedAt:g.startedAt},`pending-${x}`))}),r&&i&&s.role==="assistant"&&e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"}),s.role==="assistant"&&u&&!i&&(h?e.jsxs("span",{className:"checkpoint-rolled-back",children:[e.jsx(Je,{size:12})," 此次修改已回滚"]}):e.jsxs("div",{className:"checkpoint-rollback-actions",children:[u.fileCount>0&&e.jsxs("button",{className:"checkpoint-rollback-btn",onClick:()=>m==null?void 0:m(u),title:`仅回滚本回合的 ${u.fileCount} 个文件改动(保留对话)${u.execUsed?`
|
|
180
|
+
注意:本回合调用过 exec/shell,命令副作用无法回滚`:""}`,children:[e.jsx(Je,{size:12})," 回滚文件改动",u.execUsed&&e.jsxs("span",{className:"checkpoint-warn",children:[e.jsx(De,{size:11})," exec"]})]}),e.jsxs("button",{className:"checkpoint-rollback-btn",onClick:()=>l==null?void 0:l(u),title:`回滚本轮对话(含 ${u.fileCount} 处文件改动):删除本轮的用户提问、回复和工具调用记录,并恢复文件${u.execUsed?`
|
|
181
|
+
注意:本回合调用过 exec/shell,命令副作用无法回滚`:""}`,children:[e.jsx(Je,{size:12})," 回滚本轮对话(含文件)",u.execUsed&&e.jsxs("span",{className:"checkpoint-warn",children:[e.jsx(De,{size:11})," exec"]})]})]}))]})});function Cs({name:t,charsAccumulated:s,startedAt:n}){const[r,i]=a.useState(Date.now()-n);a.useEffect(()=>{const u=window.setInterval(()=>i(Date.now()-n),100);return()=>window.clearInterval(u)},[n]);const d=(r/1e3).toFixed(1);return e.jsx("div",{className:"tool-call-block tool-call-block-pending","aria-live":"polite",children:e.jsxs("div",{className:"tool-call-summary",children:[e.jsx("span",{className:"tool-call-progress-icon",children:e.jsx(ss,{size:14})}),e.jsx("span",{children:t||"正在生成…"}),e.jsxs("span",{className:"tool-call-progress-meta",children:[s," 字符 · ",d,"s"]})]})})}function Sn({messages:t,loading:s,connected:n,status:r,onSend:i,onAbort:d,width:u,sessionTitle:h,onNewSession:m,todoItems:l,onClearTodos:p,toolLimitReached:x,onContinueTools:g,toolCallsProgress:w,tokenUsage:c,compressingStatus:L,onCompress:I}){const C=a.useRef(null),S=a.useRef(null),K=a.useRef(null),F=a.useRef(!1),[Z,N]=a.useState([]),[W,U]=a.useState(new Set),k=a.useRef(s);a.useEffect(()=>{let j=!1;async function R(){try{const B=oe();if(!B||B==="__new_chat__"){j||N([]);return}const q=await de("@aalis/plugin-checkpoint","listTurns",{sessionId:B});!j&&Array.isArray(q)&&N(q)}catch{}}return k.current&&!s?R():t.length===0?N([]):R(),k.current=s,()=>{j=!0}},[s,h,t.length]);const D=a.useMemo(()=>j=>{for(const R of Z){const B=R.startedAt-1e3,q=(R.endedAt??R.startedAt+6e4)+5e3;if(j>=B&&j<=q)return R}},[Z]),f=a.useCallback(async j=>{const R=j.filesPreview.slice(0,3).join(`
|
|
182
|
+
`),B=j.fileCount>j.filesPreview.length?`
|
|
183
|
+
... 共 ${j.fileCount} 个文件`:"",q=j.execUsed?`
|
|
184
|
+
|
|
185
|
+
⚠ 本回合调用过 exec/shell,命令的副作用无法回滚!`:"";if(window.confirm(`将回滚此回合的文件改动:
|
|
186
|
+
|
|
187
|
+
${R}${B}${q}
|
|
188
|
+
|
|
189
|
+
确定继续?`))try{const ee=await de("@aalis/plugin-checkpoint","rollback",{sessionId:oe(),turnId:j.turnId}),X=`回滚完成:恢复 ${ee.restored.length} 个,删除 ${ee.deleted.length} 个`;ee.errors.length>0?window.alert(`${X}
|
|
190
|
+
失败 ${ee.errors.length} 个(如有新建文件在不可删除的根下,需手动删除):
|
|
191
|
+
`+ee.errors.map(le=>`${le.uri}: ${le.reason}`).join(`
|
|
192
|
+
`)):window.alert(X),U(le=>new Set([...le,j.turnId]))}catch(ee){window.alert(`回滚失败:${ee.message}`)}},[]),v=a.useCallback(async j=>{const R=j.filesPreview.slice(0,3).join(`
|
|
193
|
+
`),B=j.fileCount>j.filesPreview.length?`
|
|
194
|
+
... 共 ${j.fileCount} 个文件`:"",q=j.execUsed?`
|
|
195
|
+
|
|
196
|
+
⚠ 本回合调用过 exec/shell,命令的副作用无法回滚!`:"",me=j.fileCount>0?`
|
|
197
|
+
|
|
198
|
+
同时恢复以下文件:
|
|
199
|
+
${R}${B}`:"";if(window.confirm(`将回滚本轮对话:
|
|
200
|
+
|
|
201
|
+
· 删除本轮的用户提问、AI 回复和工具调用记录
|
|
202
|
+
· 清除对应的向量记忆条目${me}${q}
|
|
203
|
+
|
|
204
|
+
此操作不可撤销。确定继续?`))try{const X=await de("@aalis/plugin-checkpoint","rollbackWithChat",{sessionId:oe(),turnId:j.turnId}),le=[];X.chatDeleted&&le.push(`删除 ${X.deletedMessages} 条消息`),j.fileCount>0&&le.push(`恢复 ${X.restored.length} 个文件,删除 ${X.deleted.length} 个新建文件`);const Oe=le.length>0?`回滚完成:${le.join(";")}`:"回滚完成";X.errors.length>0&&window.alert(`${Oe}
|
|
205
|
+
失败 ${X.errors.length} 项:
|
|
206
|
+
`+X.errors.map(ge=>`${ge.uri||"(memory)"}: ${ge.reason}`).join(`
|
|
207
|
+
`)),U(ge=>new Set([...ge,j.turnId]))}catch(X){window.alert(`回滚失败:${X.message}`)}},[]),V=a.useRef(null),J=a.useRef(!1),[ae,_]=a.useState(!1),T=a.useRef(0),[A,z]=a.useState(!1),[Y,Q]=a.useState(!1),[xe,ue]=a.useState(null),ve=a.useRef(0),ye=a.useRef(0);a.useEffect(()=>{const j=B=>{const q=B.detail;typeof q=="string"&&ue(q)},R=B=>{B.key==="Escape"&&ue(null)};return window.addEventListener(es,j),window.addEventListener("keydown",R),()=>{window.removeEventListener(es,j),window.removeEventListener("keydown",R)}},[]);const re=r==null?void 0:r.uploadCapabilities,Ne=(re==null?void 0:re.image)??!1,we=(re==null?void 0:re.file)??!1,ke=Ne||we,Pe=wn(re);a.useEffect(()=>{L==="start"?(ve.current=Date.now(),ye.current=0):(L==="done"||L==="error")&&(ye.current=Date.now())},[L]),a.useEffect(()=>{const j=K.current;if(!j)return;const R=()=>{const{scrollTop:B,scrollHeight:q,clientHeight:me}=j;F.current=q-B-me>200,J.current=!0,V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{J.current=!1},300)};return j.addEventListener("scroll",R,{passive:!0}),()=>j.removeEventListener("scroll",R)},[]),a.useEffect(()=>{const j=K.current;if(!j)return;const R=new ResizeObserver(()=>{var B;!F.current&&!J.current&&((B=S.current)==null||B.scrollIntoView({behavior:s?"instant":"smooth"}))});return R.observe(j),()=>R.disconnect()},[t.length]),a.useEffect(()=>{var j;!F.current&&!J.current&&((j=S.current)==null||j.scrollIntoView({behavior:"smooth"}))},[t]);const Ae=a.useCallback((j,R,B,q)=>i(j,R,B,q),[i]),be=j=>{j.preventDefault(),j.stopPropagation(),T.current++,ke&&j.dataTransfer.types.includes("Files")&&_(!0)},Ce=j=>{j.preventDefault(),j.stopPropagation(),T.current--,T.current<=0&&(T.current=0,_(!1))},Ee=j=>{j.preventDefault(),j.stopPropagation()},ze=async j=>{var R;j.preventDefault(),j.stopPropagation(),T.current=0,_(!1),!(!ke||!j.dataTransfer.files.length)&&await((R=C.current)==null?void 0:R.addFiles(j.dataTransfer.files))},ie=t[t.length-1],Le=(ie==null?void 0:ie.role)==="assistant"&&s;return e.jsxs("div",{className:`chat-panel${ae?" drag-over":""}`,style:{width:u},onDragEnter:be,onDragLeave:Ce,onDragOver:Ee,onDrop:ze,children:[ae&&e.jsx("div",{className:"drag-overlay",children:e.jsxs("div",{className:"drag-overlay-content",children:[e.jsx(vs,{size:16})," 松开以上传文件"]})}),e.jsxs("div",{className:"chat-panel-header",children:[e.jsxs("span",{className:"chat-panel-title",children:[e.jsx(is,{size:16})," ",h||(r==null?void 0:r.name)||"Aalis"]}),e.jsxs("div",{className:"chat-panel-header-actions",children:[e.jsxs("div",{className:"token-usage-badge",onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),children:[e.jsx(Ns,{size:12}),e.jsx("span",{className:`token-usage-number${c&&c.usageRatio>.85?" warn":c&&c.usageRatio>.7?" caution":""}`,children:c?c.used.toLocaleString():"--"}),A&&e.jsxs("div",{className:"token-usage-panel",children:[e.jsx("div",{className:"token-panel-title",children:"Token 使用情况"}),c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"token-panel-bar",children:e.jsx("div",{className:`token-panel-bar-fill${c.usageRatio>.85?" warn":c.usageRatio>.7?" caution":""}`,style:{width:`${Math.min(100,c.usageRatio*100)}%`}})}),e.jsxs("div",{className:"token-panel-ratio",children:[(c.usageRatio*100).toFixed(1),"% 已使用"]}),e.jsxs("div",{className:"token-panel-rows",children:[e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"上下文窗口"}),e.jsx("span",{children:c.contextWindow.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-section-header",children:["系统提示词 ",e.jsx("span",{className:"token-panel-section-total",children:c.breakdown.system.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"人设 / Persona"}),e.jsx("span",{children:c.breakdown.persona.toLocaleString()})]}),c.breakdown.memorySummary>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"对话摘要"}),e.jsx("span",{children:c.breakdown.memorySummary.toLocaleString()})]}),c.breakdown.memoryVector>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"向量记忆"}),e.jsx("span",{children:c.breakdown.memoryVector.toLocaleString()})]}),c.breakdown.skills>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"技能描述"}),e.jsx("span",{children:c.breakdown.skills.toLocaleString()})]}),c.breakdown.platform>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"平台提示"}),e.jsx("span",{children:c.breakdown.platform.toLocaleString()})]}),c.breakdown.subtask>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"子任务上下文"}),e.jsx("span",{children:c.breakdown.subtask.toLocaleString()})]}),c.breakdown.systemOther>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"其他系统提示"}),e.jsx("span",{children:c.breakdown.systemOther.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"历史消息"}),e.jsx("span",{children:c.breakdown.history.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具结果"}),e.jsx("span",{children:c.breakdown.toolResults.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具定义"}),e.jsx("span",{children:c.breakdown.toolDefs.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"回复保留量"}),e.jsx("span",{children:c.breakdown.reservedForReply.toLocaleString()})]})]}),I&&e.jsx("button",{className:"token-panel-compress-btn",onClick:j=>{j.stopPropagation(),I()},disabled:L==="start",children:L==="start"?e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:12,className:"compress-spinner"})," 压缩中…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ps,{size:12})," 压缩对话"]})})]}):e.jsx("div",{className:"token-panel-empty",children:"发送消息后将显示 Token 用量统计"})]})]}),m&&e.jsx("button",{className:"chat-panel-new-btn",onClick:m,title:"新对话",children:"+"}),e.jsx("button",{className:"chat-panel-new-btn",onClick:()=>Q(j=>!j),title:"已上传的文件","aria-label":"已上传的文件",children:e.jsx(Et,{size:14})})]})]}),e.jsx(un,{open:Y,onClose:()=>Q(!1),sessionId:oe()}),e.jsxs("div",{className:"messages",ref:K,children:[t.length===0&&e.jsxs("div",{className:"empty",children:[e.jsx("div",{className:"empty-icon",children:e.jsx(is,{size:40})}),"开始和 ",(r==null?void 0:r.name)??"Aalis"," 对话吧"]}),t.map((j,R)=>{const B=R===t.length-1;return e.jsx(Cn,{msg:j,senderName:(r==null?void 0:r.name)??"Aalis",isLast:B,isGenerating:Le,onAbort:d,checkpoint:j.role==="assistant"?D(j.timestamp):void 0,rolledBack:j.role==="assistant"?(()=>{const q=D(j.timestamp);return q?W.has(q.turnId):!1})():!1,onRollback:f,onRollbackWithChat:v,toolCallsProgress:B&&j.role==="assistant"&&Le?w:void 0},R)}),s&&(!ie||ie.role!=="assistant")&&e.jsxs("div",{className:"message-group assistant",children:[e.jsx("div",{className:"message-sender",children:(r==null?void 0:r.name)??"Aalis"}),e.jsx("div",{className:"message-bubble",children:w&&w.size>0?[...w.entries()].sort((j,R)=>j[0]-R[0]).map(([j,R])=>e.jsx(Cs,{name:R.name,charsAccumulated:R.charsAccumulated,startedAt:R.startedAt},`pending-${j}`)):e.jsxs("div",{className:"typing-indicator",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"})]}),x&&!s&&e.jsxs("div",{className:"tool-limit-bar",children:[e.jsx("span",{className:"tool-limit-text",children:"⚠ 工具调用次数已达上限"}),e.jsxs("div",{className:"tool-limit-actions",children:[g&&e.jsx("button",{className:"tool-limit-btn continue",onClick:g,children:"继续迭代"}),e.jsx("span",{className:"tool-limit-hint",children:"或输入新内容引导模型"})]})]}),L==="start"&&e.jsxs("div",{className:"system-event-separator compressing",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(Qe,{size:12,className:"compress-spinner"})," 压缩对话中 ",e.jsx(us,{startTime:ve.current})]}),e.jsx("span",{className:"system-event-line"})]}),L==="done"&&e.jsxs("div",{className:"system-event-separator compress-done",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(js,{size:12})," 已压缩对话 ",e.jsx(us,{startTime:ve.current,endTime:ye.current})]}),e.jsx("span",{className:"system-event-line"})]}),L==="error"&&e.jsxs("div",{className:"system-event-separator compress-error",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(De,{size:12})," 压缩失败"]}),e.jsx("span",{className:"system-event-line"})]}),e.jsx("div",{ref:S})]}),l&&l.length>0&&p&&e.jsx(bn,{items:l,onClear:p,loading:s}),e.jsx(hn,{ref:C,loading:s,connected:n,canUpload:ke,canUploadImage:Ne,canUploadFile:we,acceptAttr:Pe,onSend:Ae,onAbort:d}),xe&&e.jsxs("div",{className:"image-lightbox",onClick:()=>ue(null),children:[e.jsx("img",{src:xe,alt:"预览",className:"image-lightbox-content",onClick:j=>j.stopPropagation()}),e.jsx("button",{type:"button",className:"image-lightbox-close",onClick:()=>ue(null),"aria-label":"关闭",children:"×"})]})]})}const _n=a.lazy(()=>he(()=>import("./PluginConfigPage-B-xh_pwj.js"),__vite__mapDeps([2,1,3,4,5,6,7,8])).then(t=>({default:t.PluginConfigPage}))),$n=a.lazy(()=>he(()=>import("./MarketplacePage-HGIvPE-L.js"),__vite__mapDeps([9,1,10,4,5,6,7,8])).then(t=>({default:t.MarketplacePage}))),In=a.lazy(()=>he(()=>import("./PlatformPage-BU3sDCdV.js"),__vite__mapDeps([11,1,12,4,5,6,7,8])).then(t=>({default:t.PlatformPage}))),Mn=a.lazy(()=>he(()=>import("./AuthorityPage-COZ1GZ_n.js"),__vite__mapDeps([13,1,10,4,5,6,7,8])).then(t=>({default:t.AuthorityPage}))),Tn=a.lazy(()=>he(()=>import("./LogPage-C_Z3RA5T.js"),__vite__mapDeps([14,1])).then(t=>({default:t.LogPage}))),En=a.lazy(()=>he(()=>import("./SessionsPage-DOl-b2K7.js"),__vite__mapDeps([15,1,8,6,7,4,5])).then(t=>({default:t.SessionsPage}))),Ln=a.lazy(()=>he(()=>import("./FilesPage-CBCBRbIG.js"),__vite__mapDeps([16,1,4,5,6,7,8])).then(t=>({default:t.FilesPage}))),Rn=a.lazy(()=>he(()=>import("./DynamicPage-DJFDEG6E.js"),__vite__mapDeps([17,1,3,18,19,12,10,8,6,7,4,5])).then(t=>({default:t.DynamicPage})));function Dn(){var ns;const[t,s]=a.useState(()=>location.hash.replace("#","")||"dashboard"),[n,r]=a.useState(null),[i,d]=a.useState([]);a.useEffect(()=>{location.hash=t},[t]),a.useEffect(()=>{n&&!n.has(t)&&s("dashboard")},[n,t]);const[u,h]=a.useState([]),[m,l]=a.useState(null),[p,x]=a.useState(null),[g,w]=a.useState(null),[c,L]=a.useState([]),[I,C]=a.useState(null),S=lt(i),{messages:K,setMessages:F,loading:Z,setLoading:N,streamingRef:W}=S,U=a.useRef({pending:[],raf:0}),[k,D]=a.useState(0),[f,v]=a.useState([]),[V,J]=a.useState(()=>{if(typeof window>"u")return 420;const o=Number(window.localStorage.getItem("aalis:chatWidth"));return Number.isFinite(o)&&o>=280?o:420});a.useEffect(()=>{try{window.localStorage.setItem("aalis:chatWidth",String(V))}catch{}},[V]),a.useEffect(()=>{const o=document.querySelector(".app-layout");if(!o||typeof ResizeObserver>"u")return;const y=360,b=240,E=()=>{var se;const $=o.clientWidth,O=((se=document.querySelector(".nav-rail"))==null?void 0:se.getBoundingClientRect().width)??56,P=Math.max(b,$-O-y);J(G=>Math.min(Math.max(G,b),P))},M=new ResizeObserver(E);return M.observe(o),()=>M.disconnect()},[]);const[ae,_]=a.useState(!1),[T,A]=a.useState(new Map),[z,Y]=a.useState(!1),[Q,xe]=a.useState(!1),[ue,ve]=a.useState(!1),[ye,re]=a.useState("正在重启…"),[Ne,we]=a.useState(!1),[ke,Pe]=a.useState(null),[Ae,be]=a.useState(null),Ce=(o,y)=>{const b=o?[...o]:[],E=b[b.length-1];return y.type==="text"&&E&&E.type==="text"?b[b.length-1]={type:"text",content:E.content+y.content}:y.type==="reasoning_text"&&E&&E.type==="reasoning_text"?b[b.length-1]={type:"reasoning_text",content:E.content+y.content}:b.push(y),b},Ee=o=>{let y="",b="";for(const E of o??[])E.type==="text"?y+=E.content:E.type==="reasoning_text"&&(b+=E.content);return{content:y,reasoning:b}},ze=a.useCallback((o,y,b,E,M)=>{U.current.raf&&(cancelAnimationFrame(U.current.raf),U.current.raf=0),U.current.pending=[],F($=>{const O=$[$.length-1],P=b&&b.length>0?b:y?[{type:"reasoning_text",content:y},{type:"text",content:o}]:[{type:"text",content:o}];return O&&O.role==="assistant"&&W.current?(W.current=!1,[...$.slice(0,-1),{...O,content:o,reasoningContent:y??O.reasoningContent,segments:P,attachments:E??O.attachments,modelInfo:M??O.modelInfo}]):(W.current=!1,[...$,{role:"assistant",content:o,reasoningContent:y,segments:P,attachments:E,modelInfo:M,timestamp:Date.now()}])}),N(!1)},[]),ie=a.useCallback(()=>{const o=U.current;if(o.raf&&(cancelAnimationFrame(o.raf),o.raf=0),o.pending.length===0)return;const y=o.pending;o.pending=[],F(b=>{const E=b[b.length-1];if(E&&E.role==="assistant"&&W.current){let P=E.segments??[];for(const ne of y)P=Ce(P,{type:ne.kind==="content"?"text":"reasoning_text",content:ne.text});const{content:se,reasoning:G}=Ee(P);return[...b.slice(0,-1),{...E,content:se,reasoningContent:G||void 0,segments:P}]}W.current=!0;let M=[];for(const P of y)M=Ce(M,{type:P.kind==="content"?"text":"reasoning_text",content:P.text});const{content:$,reasoning:O}=Ee(M);return[...b,{role:"assistant",content:$,reasoningContent:O||void 0,segments:M,timestamp:Date.now()}]})},[F,W]),Le=a.useCallback((o,y,b,E)=>{if(b){ie(),N(!1),_(!!E),A(new Map);return}(o||y)&&A($=>$.size===0?$:new Map);const M=U.current;y&&M.pending.push({kind:"reasoning",text:y}),o&&M.pending.push({kind:"content",text:o}),!M.raf&&(M.raf=requestAnimationFrame(ie))},[ie,N]),j=a.useCallback(o=>{h(y=>y.length>0&&y[y.length-1].seq>=o.seq&&y.some(b=>b.seq===o.seq)?y:[...y,o])},[]),R=a.useCallback(async()=>{const o=u[0];if(!o)return 0;try{const y=await te(`/api/logs/range?before=${o.seq}&limit=200`);return!y||y.length===0?0:(h(b=>{const E=new Set(b.map($=>$.seq));return[...y.filter($=>!E.has($.seq)),...b]}),y.length)}catch{return 0}},[u]),B=a.useCallback((o,y,b,E)=>{ie(),b==="start"&&A(M=>M.size===0?M:new Map),F(M=>{const $=M[M.length-1];if(b==="start"){const O=Date.now();if($&&$.role==="assistant"){const P=Ce($.segments,{type:"tool_call",name:o,args:y,startTime:O});return[...M.slice(0,-1),{...$,segments:P}]}return W.current=!0,[...M,{role:"assistant",content:"",segments:[{type:"tool_call",name:o,args:y,startTime:O}],timestamp:Date.now()}]}if($&&$.role==="assistant"&&$.segments){const O=Date.now(),P=[...$.segments];for(let se=P.length-1;se>=0;se--){const G=P[se];if(G.type==="tool_call"&&G.name===o&&G.result==null)return P[se]={...G,result:E,endTime:O},[...M.slice(0,-1),{...$,segments:P}]}}return M})},[ie]),q=a.useCallback(()=>{te("/api/plugins").then(o=>L(o.plugins??[])).catch(()=>{})},[]),me=a.useCallback(()=>{te("/api/config").then(w).catch(()=>{})},[]),ee=a.useCallback(()=>{te("/api/services").then(o=>C(o.services??null)).catch(()=>{})},[]),X=a.useCallback(()=>{te("/api/pages").then(o=>{d(o),r(new Set(o.map(y=>y.key)))}).catch(()=>{})},[]),le=a.useCallback(()=>{q(),ee(),X(),S.refresh(),te("/api/status").then(l).catch(()=>{})},[q,ee,X,S.refresh]),Oe=a.useCallback(()=>{Y(!0),xe(!1),re("正在重启…")},[]),ge=a.useCallback(()=>{ve(!0),re("正在切换前端,即将刷新…")},[]),Ss=a.useCallback(()=>{S.refresh(),D(o=>o+1)},[S.refresh]),_s=a.useCallback(o=>{v(o)},[]),$s=a.useCallback((o,y,b,E,M)=>{F($=>{let O=b&&b.length>0?b:[];O.length===0&&(y&&O.push({type:"reasoning_text",content:y}),o&&O.push({type:"text",content:o}));const P=$[$.length-1];return P&&P.role==="assistant"?[...$.slice(0,-1),{...P,content:o,reasoningContent:y||P.reasoningContent,segments:O}]:[...$,{role:"assistant",content:o,reasoningContent:y||void 0,segments:O,timestamp:Date.now()}]}),E||(W.current=!0,N(!0)),M&&M.length>0?A(new Map(M.map($=>[$.index,{name:$.name,charsAccumulated:$.charsAccumulated,startedAt:$.startedAt}]))):A($=>$.size===0?$:new Map)},[]),Is=a.useCallback(o=>{A(y=>{const b=new Map(y),E=b.get(o.index);return b.set(o.index,{name:o.name,charsAccumulated:o.charsAccumulated,startedAt:(E==null?void 0:E.startedAt)??Date.now()}),b})},[]),Ms=a.useCallback(()=>{A(o=>o.size===0?o:new Map)},[]),Ts=a.useCallback(o=>{we(!0),F(y=>[...y,{role:"assistant",content:o,segments:[{type:"text",content:o}],timestamp:Date.now()}])},[]),Es=a.useCallback(o=>{Pe(o)},[]),Ls=a.useCallback((o,y)=>{o===oe()&&(be(y),y==="done"?(F(b=>[...b,{role:"system",content:"对话已压缩",timestamp:Date.now()}]),setTimeout(()=>be(null),1500)):y==="error"&&setTimeout(()=>be(null),3e3))},[]),{send:Se,sendRaw:Re,connected:fe}=at({onMessage:ze,onStream:Le,onLog:j,onToolCall:B,onStateChanged:le,onRestarting:Oe,onReload:ge,onSessionsChanged:Ss,onTodoUpdated:_s,onStreamResume:$s,onConfirm:Ts,onTokenUsage:Es,onCompressing:Ls,onHistoryChanged:S.handleHistoryChanged,onToolCallProgress:Is,onToolCallProgressClear:Ms}),Rs=a.useCallback(()=>{Re({type:"compress",sessionId:oe()})},[Re]);a.useEffect(()=>{z&&!fe&&(xe(!0),re("等待服务器重启…"))},[z,fe]),a.useEffect(()=>{if(z&&Q&&fe){re("服务器已就绪,即将刷新…");const o=setTimeout(()=>window.location.reload(),800);return()=>clearTimeout(o)}},[z,Q,fe]),a.useEffect(()=>{if(ue){const o=setTimeout(()=>window.location.reload(),1500);return()=>clearTimeout(o)}},[ue]),a.useEffect(()=>{te("/api/status").then(l).catch(()=>{}),te("/api/auth/me").then(x).catch(()=>{}),me(),q(),ee(),X(),S.refresh(),te("/api/logs/tail?limit=200").then(h).catch(()=>{})},[q,me,ee,X,S.refresh]),a.useEffect(()=>{const o=S.activeSessionId;if(!o||o==="__new_chat__"){v([]);return}de("@aalis/plugin-todo-list","getTodos",{sessionId:o}).then(y=>v(y??[])).catch(()=>v([]))},[S.activeSessionId]),a.useEffect(()=>{const o=setInterval(()=>{te("/api/status").then(l).catch(()=>{}),q(),ee(),X(),S.refresh()},3e4);return()=>clearInterval(o)},[q,ee,X,S.refresh]);const Fe=a.useCallback(()=>{Re({type:"abort",sessionId:oe()}),N(!1),_(!1),W.current=!1},[Re]),Ds=a.useCallback(()=>{F(o=>[...o,{role:"user",content:"[请继续执行未完成的工具调用]",timestamp:Date.now()}]),Se("[请继续执行未完成的工具调用]"),_(!1),N(!0)},[Se]),Ps=a.useCallback(()=>{const o=S.activeSessionId;!o||o==="__new_chat__"||(de("@aalis/plugin-todo-list","clearTodos",{sessionId:o}).catch(()=>{}),v([]))},[S.activeSessionId]),As=a.useCallback(async(o,y,b,E)=>{const M=o.trim();if(Ne){if(!M)return;we(!1),F(G=>[...G,{role:"user",content:M,timestamp:Date.now()}]),Se(M);return}if(Z&&Fe(),!M&&b.length===0&&y.length===0)return;await S.ensureSession();const $=b.length>0?[...b]:void 0,O=[];let P=0,se=0;if(E.length>0){for(const G of E)if(G==="image"&&P<b.length)O.push({kind:"image",data:b[P++]});else if(G==="file"&&se<y.length){const ne=y[se++],pe=ne.mimeType??"",Be=pe.startsWith("audio/")?"audio":pe.startsWith("video/")?"video":"file";O.push({kind:Be,data:ne.data,mimeType:pe,name:ne.name})}}for(;P<b.length;)O.push({kind:"image",data:b[P++]});for(;se<y.length;){const G=y[se++],ne=G.mimeType??"",pe=ne.startsWith("audio/")?"audio":ne.startsWith("video/")?"video":"file";O.push({kind:pe,data:G.data,mimeType:ne,name:G.name})}F(G=>[...G,{role:"user",content:M,images:$,fileNames:y.map(ne=>ne.name),timestamp:Date.now()}]),_(!1),N(!0),Se(M,O.length>0?O:void 0)},[Ne,Z,Se,Fe,S]),We={dashboard:e.jsx(Xs,{}),marketplace:e.jsx(Zs,{}),"plugin-config":e.jsx(Qs,{}),platforms:e.jsx(st,{}),authority:e.jsx(tt,{}),files:e.jsx(nt,{}),logs:e.jsx(et,{})},zs=e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18M3 9h18"})]}),Os=(o,y)=>We[o]?We[o]:y&&y.trimStart().startsWith("<svg")?e.jsx("span",{className:"nav-item-svg",dangerouslySetInnerHTML:{__html:y}}):zs,ts=a.useMemo(()=>n?i.filter(o=>n.has(o.key)).map(o=>({key:o.key,label:o.label,pluginDisplayName:o.pluginDisplayName,icon:Os(o.key,o.icon),order:o.order??99})).sort((o,y)=>o.order-y.order):Object.entries(We).map(([o,y],b)=>({key:o,label:o,icon:y,order:(b+1)*10})),[n,i]),Fs=(o,y)=>{switch(o){case"dashboard":return e.jsx(Xt,{status:m,connected:fe,plugins:c,servicesData:I,onRefreshServices:ee});case"marketplace":return e.jsx($n,{plugins:c,onRefresh:q});case"plugin-config":return e.jsx(_n,{plugins:c,config:g,onRefresh:q,onConfigSaved:me,onRestart:()=>{Y(!0),xe(!1),re("正在重启…")}});case"platforms":return e.jsx(In,{});case"authority":return e.jsx(Mn,{});case"logs":return e.jsx(Tn,{logs:u,onLoadOlder:R});case"files":return e.jsx(Ln,{});case"sessions":return e.jsx(En,{pluginName:y,activeSessionId:S.activeSessionId,onSwitchSession:b=>{S.switchSession(b)},onStartNewChat:()=>S.startNewChat(),refreshSignal:k});default:return null}},ce=i.find(o=>o.key===t),qe=ce!=null&&ce.content?ce:void 0;return e.jsxs("div",{className:"app-layout",children:[e.jsxs("nav",{className:"nav-rail",children:[e.jsxs("div",{className:"nav-rail-top",children:[e.jsx("div",{className:"nav-logo",children:"A"}),ts.map(o=>e.jsxs("button",{className:`nav-item ${t===o.key?"active":""}`,onClick:()=>s(o.key),children:[e.jsx("span",{className:"nav-item-icon",children:o.icon}),e.jsx("span",{className:"nav-item-label",children:o.label})]},o.key))]}),e.jsx("div",{className:"nav-rail-bottom",children:e.jsx("div",{className:`nav-status ${fe?"online":"offline"}`,title:fe?"已连接":"离线"})})]}),e.jsxs("main",{className:"content-area",children:[e.jsxs("div",{className:"content-header",children:[e.jsx("span",{className:"content-title",children:(ns=ts.find(o=>o.key===t))==null?void 0:ns.label}),p&&e.jsxs("span",{className:"content-user",title:`${p.identity.platform}:${p.identity.userId}`,children:[p.identity.userId,p.isOwner&&e.jsx("span",{className:"content-user-level",children:"owner"}),e.jsx("button",{className:"btn-sm",onClick:async()=>{await fetch("/api/auth/logout",{method:"POST"}),window.location.reload()},children:"登出"})]})]}),e.jsx("div",{className:"content-body",children:e.jsxs(a.Suspense,{fallback:e.jsx("div",{className:"empty-hint",style:{padding:24},children:"加载中…"}),children:[qe&&e.jsx(Rn,{page:qe}),!qe&&(ce==null?void 0:ce.renderer)&&(Fs(ce.renderer,ce.plugin)||e.jsxs("div",{className:"empty-hint",style:{padding:24},children:["此客户端不支持渲染器「",ce.renderer,"」"]}))]})})]}),e.jsx("div",{className:"resize-handle",onMouseDown:o=>{var pe;o.preventDefault();const y=o.clientX,b=V,E=((pe=document.querySelector(".app-layout"))==null?void 0:pe.clientWidth)??window.innerWidth,M=document.querySelector(".nav-rail"),$=(M==null?void 0:M.getBoundingClientRect().width)??56,O=360,P=280,se=Math.max(P,E-$-O);document.body.classList.add("is-dragging-chat");const G=Be=>{const Ws=b-(Be.clientX-y);J(Math.max(P,Math.min(se,Ws)))},ne=()=>{document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",ne),document.body.style.cursor="",document.body.style.userSelect="",document.body.classList.remove("is-dragging-chat")};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",G),document.addEventListener("mouseup",ne)}}),e.jsx("div",{className:"chat-column",style:{width:V},children:e.jsx(Sn,{messages:K,loading:Z,connected:fe,status:m,onSend:As,onAbort:Fe,width:V,sessionTitle:S.isNewChat?"新对话":S.activeSessionTitle,onNewSession:S.pluginName?()=>S.startNewChat():void 0,todoItems:f,onClearTodos:Ps,toolLimitReached:ae,onContinueTools:Ds,toolCallsProgress:T,tokenUsage:ke,compressingStatus:Ae,onCompress:Rs})}),(z||ue)&&e.jsx("div",{className:"restart-overlay",children:e.jsxs("div",{className:"restart-dialog",children:[e.jsx("div",{className:"restart-spinner"}),e.jsx("h3",{children:ue?"切换前端":"正在重启…"}),e.jsx("p",{className:"restart-desc",children:ye})]})})]})}qs.createRoot(document.getElementById("root")).render(e.jsx(Dn,{}));export{os as B,Ct as C,_t as D,Et as F,Te as M,Me as R,qt as S,De as T,ss as W,ys as X,he as _,te as a,it as b,H as c,Ie as d,$e as e,gs as f,Ft as g,Mt as h,Jt as i,de as p};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as a,l as o,I as i,e as n}from"./mermaid.core-BbMB3jno.js";import{p}from"./wardley-L42UT6IY-DwPang7i.js";import"./index-D4hgfekH.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var g={parse:a(async r=>{const e=await p("info",r);o.debug(e)},"parse")},m={version:"11.15.0"},v=a(()=>m.version,"getVersion"),d={getVersion:v},c=a((r,e,s)=>{o.debug(`rendering info diagram
|
|
2
|
+
`+r);const t=i(e);n(t,100,400,!0),t.append("g").append("text").attr("x",100).attr("y",40).attr("class","version").attr("font-size",32).style("text-anchor","middle").text(`v${s}`)},"draw"),l={draw:c},z={parser:g,db:d,renderer:l};export{z as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(e,a){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(a).domain(e);break}return this}export{t as i};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import{_ as o,c as ot,N as ut,I as dt,ap as yt,z as pt,k as ft,p as it,a as gt,b as kt,g as mt,s as wt,q as _t,e as bt}from"./mermaid.core-BbMB3jno.js";import"./index-D4hgfekH.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-BCywGHw2.js";var tt=(function(){var e=o(function(M,t,s,i){for(s=s||{},i=M.length;i--;s[M[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],p=[1,20],d=[1,18],m=[1,19],c=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],B={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,u,f,n,v){var w=n.length-1;switch(f){case 6:case 7:return u;case 15:u.addNode(n[w-1].length,n[w].trim());break;case 16:u.addNode(0,n[w].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:p,7:d,10:17,11:m},e(c,[2,18],{14:[1,21]}),e(c,[2,16]),e(c,[2,17]),{6:p,7:d,10:22,11:m},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(c,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],u=[],f=[null],n=[],v=this.table,w="",I=0,S=0,L=2,E=1,R=n.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(C.yy[z]=this.yy[z]);b.setInput(t,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var T=b.yylloc;n.push(T);var D=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function F(N){i.length=i.length-2*N,f.length=f.length-N,n.length=n.length-N}o(F,"popStack");function j(){var N;return N=u.pop()||b.lex()||E,typeof N!="number"&&(N instanceof Array&&(u=N,N=u.pop()),N=s.symbols_[N]||N),N}o(j,"lex");for(var A,W,P,K,H={},X,V,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?P=this.defaultActions[W]:((A===null||typeof A>"u")&&(A=j()),P=v[W]&&v[W][A]),typeof P>"u"||!P.length||!P[0]){var Q="";Y=[];for(X in v[W])this.terminals_[X]&&X>L&&Y.push("'"+this.terminals_[X]+"'");b.showPosition?Q="Parse error on line "+(I+1)+`:
|
|
2
|
+
`+b.showPosition()+`
|
|
3
|
+
Expecting `+Y.join(", ")+", got '"+(this.terminals_[A]||A)+"'":Q="Parse error on line "+(I+1)+": Unexpected "+(A==E?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(Q,{text:b.match,token:this.terminals_[A]||A,line:b.yylineno,loc:T,expected:Y})}if(P[0]instanceof Array&&P.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+A);switch(P[0]){case 1:i.push(A),f.push(b.yytext),n.push(b.yylloc),i.push(P[1]),A=null,S=b.yyleng,w=b.yytext,I=b.yylineno,T=b.yylloc;break;case 2:if(V=this.productions_[P[1]][1],H.$=f[f.length-V],H._$={first_line:n[n.length-(V||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(V||1)].first_column,last_column:n[n.length-1].last_column},D&&(H._$.range=[n[n.length-(V||1)].range[0],n[n.length-1].range[1]]),K=this.performAction.apply(H,[w,S,I,C.yy,P[1],f,n].concat(R)),typeof K<"u")return K;V&&(i=i.slice(0,-1*V*2),f=f.slice(0,-1*V),n=n.slice(0,-1*V)),i.push(this.productions_[P[1]][0]),f.push(H.$),n.push(H._$),et=v[i[i.length-2]][i[i.length-1]],i.push(et);break;case 3:return!0}}return!0},"parse")},O=(function(){var M={EOF:1,parseError:o(function(s,i){if(this.yy.parser)this.yy.parser.parseError(s,i);else throw new Error(s)},"parseError"),setInput:o(function(t,s){return this.yy=s||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:o(function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var s=t.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:o(function(t){var s=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var u=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var f=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===u.length?this.yylloc.first_column:0)+u[u.length-i.length].length-i[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[f[0],f[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:o(function(){return this._more=!0,this},"more"),reject:o(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:o(function(t){this.unput(this.match.slice(t))},"less"),pastInput:o(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:o(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:o(function(){var t=this.pastInput(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+`
|
|
5
|
+
`+s+"^"},"showPosition"),test_match:o(function(t,s){var i,u,f;if(this.options.backtrack_lexer&&(f={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(f.yylloc.range=this.yylloc.range.slice(0))),u=t[0].match(/(?:\r\n?|\n).*/g),u&&(this.yylineno+=u.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:u?u[u.length-1].length-u[u.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,s,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var n in f)this[n]=f[n];return!1}return!1},"test_match"),next:o(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,s,i,u;this._more||(this.yytext="",this.match="");for(var f=this._currentRules(),n=0;n<f.length;n++)if(i=this._input.match(this.rules[f[n]]),i&&(!s||i[0].length>s[0].length)){if(s=i,u=n,this.options.backtrack_lexer){if(t=this.test_match(i,f[n]),t!==!1)return t;if(this._backtrack){s=!1;continue}else return!1}else if(!this.options.flex)break}return s?(t=this.test_match(s,f[u]),t!==!1?t:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:o(function(){var s=this.next();return s||this.lex()},"lex"),begin:o(function(s){this.conditionStack.push(s)},"begin"),popState:o(function(){var s=this.conditionStack.length-1;return s>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:o(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:o(function(s){return s=this.conditionStack.length-1-Math.abs(s||0),s>=0?this.conditionStack[s]:"INITIAL"},"topState"),pushState:o(function(s){this.begin(s)},"pushState"),stateStackSize:o(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:o(function(s,i,u,f){switch(u){case 0:return 6;case 1:return 8;case 2:return 8;case 3:return 6;case 4:return 7;case 5:return 13;case 6:return 14;case 7:return 11}},"anonymous"),rules:[/^(?:\s*%%.*)/i,/^(?:ishikawa-beta\b)/i,/^(?:ishikawa\b)/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[\s]+)/i,/^(?:[^\n]+)/i,/^(?:$)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};return M})();B.lexer=O;function $(){this.yy={}}return o($,"Parser"),$.prototype=B,B.Parser=$,new $})();tt.parser=tt;var xt=tt,Z,vt=(Z=class{constructor(){this.stack=[],this.clear=this.clear.bind(this),this.addNode=this.addNode.bind(this),this.getRoot=this.getRoot.bind(this)}clear(){this.root=void 0,this.stack=[],this.baseLevel=void 0,pt()}getRoot(){return this.root}addNode(h,r){const a=ft.sanitizeText(r,ot());if(!this.root){this.root={text:a,children:[]},this.stack=[{level:0,node:this.root}],it(a);return}this.baseLevel??(this.baseLevel=h);let l=h-this.baseLevel+1;for(l<=0&&(l=1);this.stack.length>1&&this.stack[this.stack.length-1].level>=l;)this.stack.pop();const y=this.stack[this.stack.length-1].node,p={text:a,children:[]};y.children.push(p),this.stack.push({level:l,node:p})}getAccTitle(){return gt()}setAccTitle(h){kt(h)}getAccDescription(){return mt()}setAccDescription(h){wt(h)}getDiagramTitle(){return _t()}setDiagramTitle(h){it(h)}},o(Z,"IshikawaDB"),Z),St=14,G=250,$t=30,Et=60,At=5,ht=82*Math.PI/180,st=Math.cos(ht),nt=Math.sin(ht),at=o((e,h,r)=>{const a=e.node().getBBox(),l=a.width+h*2,y=a.height+h*2;bt(e,y,l,r),e.attr("viewBox",`${a.x-h} ${a.y-h} ${l} ${y}`)},"applyPaddedViewBox"),It=o((e,h,r,a)=>{var C,z;const y=a.db.getRoot();if(!y)return;const p=ot(),{look:d,handDrawnSeed:m,themeVariables:c}=p,k=ut(p.fontSize)[0]??St,g=d==="handDrawn",_=y.children??[],x=((C=p.ishikawa)==null?void 0:C.diagramPadding)??20,B=((z=p.ishikawa)==null?void 0:z.useMaxWidth)??!1,O=dt(h),$=O.append("g").attr("class","ishikawa"),M=g?yt.svg(O.node()):void 0,t=M?{roughSvg:M,seed:m??0,lineColor:(c==null?void 0:c.lineColor)??"#333",fillColor:(c==null?void 0:c.mainBkg)??"#fff"}:void 0,s=`ishikawa-arrow-${h}`;g||$.append("defs").append("marker").attr("id",s).attr("viewBox","0 0 10 10").attr("refX",0).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 Z").attr("class","ishikawa-arrow");let i=0,u=G;const f=g?void 0:U($,i,u,i,u,"ishikawa-spine");if(Lt($,i,u,y.text,k,t),!_.length){g&&U($,i,u,i,u,"ishikawa-spine",t),at(O,x,B);return}i-=20;const n=_.filter((T,D)=>D%2===0),v=_.filter((T,D)=>D%2===1),w=rt(n),I=rt(v),S=w.total+I.total;let L=G,E=G;if(S>0){const T=G*2,D=G*.3;L=Math.max(D,T*(w.total/S)),E=Math.max(D,T*(I.total/S))}const R=k*2;L=Math.max(L,w.max*R),E=Math.max(E,I.max*R),u=Math.max(L,G),f&&f.attr("y1",u).attr("y2",u),$.select(".ishikawa-head-group").attr("transform",`translate(0,${u})`);const b=Math.ceil(_.length/2);for(let T=0;T<b;T++){const D=$.append("g").attr("class","ishikawa-pair");for(const[F,j,A]of[[_[T*2],-1,L],[_[T*2+1],1,E]])F&&Nt(D,F,i,u,j,A,k,t);i=D.selectAll("text").nodes().reduce((F,j)=>Math.min(F,j.getBBox().x),1/0)}if(g)U($,i,u,0,u,"ishikawa-spine",t);else{f.attr("x1",i);const T=`url(#${s})`;$.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start",T)}at(O,x,B)},"draw"),rt=o(e=>{const h=o(r=>r.children.reduce((a,l)=>a+1+h(l),0),"countDescendants");return e.reduce((r,a)=>{const l=h(a);return r.total+=l,r.max=Math.max(r.max,l),r},{total:0,max:0})},"sideStats"),Lt=o((e,h,r,a,l,y)=>{const p=Math.max(6,Math.floor(110/(l*.6))),d=e.append("g").attr("class","ishikawa-head-group").attr("transform",`translate(${h},${r})`),m=q(d,ct(a,p),0,0,"ishikawa-head-label","start",l),c=m.node().getBBox(),k=Math.max(60,c.width+6),g=Math.max(40,c.height*2+40),_=`M 0 ${-g/2} L 0 ${g/2} Q ${k*2.4} 0 0 ${-g/2} Z`;if(y){const x=y.roughSvg.path(_,{roughness:1.5,seed:y.seed,fill:y.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:y.lineColor,strokeWidth:2});d.insert(()=>x,":first-child").attr("class","ishikawa-head")}else d.insert("path",":first-child").attr("class","ishikawa-head").attr("d",_);m.attr("transform",`translate(${(k-c.width)/2-c.x+3},${-c.y-c.height/2})`)},"drawHead"),Tt=o((e,h)=>{const r=[],a=[],l=o((y,p,d)=>{const m=h===-1?[...y].reverse():y;for(const c of m){const k=r.length,g=c.children??[];r.push({depth:d,text:ct(c.text,15),parentIndex:p,childCount:g.length}),d%2===0?(a.push(k),g.length&&l(g,k,d+1)):(g.length&&l(g,k,d+1),a.push(k))}},"walk");return l(e,-1,2),{entries:r,yOrder:a}},"flattenTree"),Mt=o((e,h,r,a,l,y,p)=>{const d=e.append("g").attr("class","ishikawa-label-group"),c=q(d,h,r,a+11*l,"ishikawa-label cause","middle",y).node().getBBox();if(p){const k=p.roughSvg.rectangle(c.x-20,c.y-2,c.width+40,c.height+4,{roughness:1.5,seed:p.seed,fill:p.fillColor,fillStyle:"hachure",fillWeight:2.5,hachureGap:5,stroke:p.lineColor,strokeWidth:2});d.insert(()=>k,":first-child").attr("class","ishikawa-label-box")}else d.insert("rect",":first-child").attr("class","ishikawa-label-box").attr("x",c.x-20).attr("y",c.y-2).attr("width",c.width+40).attr("height",c.height+4)},"drawCauseLabel"),J=o((e,h,r,a,l,y)=>{const p=Math.sqrt(a*a+l*l);if(p===0)return;const d=a/p,m=l/p,c=6,k=-m*c,g=d*c,_=h,x=r,B=`M ${_} ${x} L ${_-d*c*2+k} ${x-m*c*2+g} L ${_-d*c*2-k} ${x-m*c*2-g} Z`,O=y.roughSvg.path(B,{roughness:1,seed:y.seed,fill:y.lineColor,fillStyle:"solid",stroke:y.lineColor,strokeWidth:1});e.append(()=>O)},"drawArrowMarker"),Nt=o((e,h,r,a,l,y,p,d)=>{const m=h.children??[],c=y*(m.length?1:.2),k=-st*c,g=nt*c*l,_=r+k,x=a+g;if(U(e,r,a,_,x,"ishikawa-branch",d),d&&J(e,r,a,r-_,a-x,d),Mt(e,h.text,_,x,l,p,d),!m.length)return;const{entries:B,yOrder:O}=Tt(m,l),$=B.length,M=new Array($);for(const[f,n]of O.entries())M[n]=a+g*((f+1)/($+1));const t=new Map;t.set(-1,{x0:r,y0:a,x1:_,y1:x,childCount:m.length,childrenDrawn:0});const s=-st,i=nt*l,u=l<0?"ishikawa-label up":"ishikawa-label down";for(const[f,n]of B.entries()){const v=M[f],w=t.get(n.parentIndex),I=e.append("g").attr("class","ishikawa-sub-group");let S=0,L=0,E=0;if(n.depth%2===0){const R=w.y1-w.y0;S=lt(w.x0,w.x1,R?(v-w.y0)/R:.5),L=v,E=S-(n.childCount>0?Et+n.childCount*At:$t),U(I,S,v,E,v,"ishikawa-sub-branch",d),d&&J(I,S,v,1,0,d),q(I,n.text,E,v,"ishikawa-label align","end",p)}else{const R=w.childrenDrawn++;S=lt(w.x0,w.x1,(w.childCount-R)/(w.childCount+1)),L=w.y0,E=S+s*((v-L)/i),U(I,S,L,E,v,"ishikawa-sub-branch",d),d&&J(I,S,L,S-E,L-v,d),q(I,n.text,E,v,u,"end",p)}n.childCount>0&&t.set(f,{x0:S,y0:L,x1:E,y1:v,childCount:n.childCount,childrenDrawn:0})}},"drawBranch"),Pt=o(e=>e.split(/<br\s*\/?>|\n/),"splitLines"),ct=o((e,h)=>{if(e.length<=h)return e;const r=[];for(const a of e.split(/\s+/)){const l=r.length-1;l>=0&&r[l].length+1+a.length<=h?r[l]+=" "+a:r.push(a)}return r.join(`
|
|
7
|
+
`)},"wrapText"),q=o((e,h,r,a,l,y,p)=>{const d=Pt(h),m=p*1.05,c=e.append("text").attr("class",l).attr("text-anchor",y).attr("x",r).attr("y",a-(d.length-1)*m/2);for(const[k,g]of d.entries())c.append("tspan").attr("x",r).attr("dy",k===0?0:m).text(g);return c},"drawMultilineText"),lt=o((e,h,r)=>e+(h-e)*r,"lerp"),U=o((e,h,r,a,l,y,p)=>{if(p){const d=p.roughSvg.line(h,r,a,l,{roughness:1.5,seed:p.seed,stroke:p.lineColor,strokeWidth:2});e.append(()=>d).attr("class",y);return}return e.append("line").attr("class",y).attr("x1",h).attr("y1",r).attr("x2",a).attr("y2",l)},"drawLine"),Bt={draw:It},Dt=o(e=>`
|
|
8
|
+
.ishikawa .ishikawa-spine,
|
|
9
|
+
.ishikawa .ishikawa-branch,
|
|
10
|
+
.ishikawa .ishikawa-sub-branch {
|
|
11
|
+
stroke: ${e.lineColor};
|
|
12
|
+
stroke-width: 2;
|
|
13
|
+
fill: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ishikawa .ishikawa-sub-branch {
|
|
17
|
+
stroke-width: 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ishikawa .ishikawa-arrow {
|
|
21
|
+
fill: ${e.lineColor};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ishikawa .ishikawa-head {
|
|
25
|
+
fill: ${e.mainBkg};
|
|
26
|
+
stroke: ${e.lineColor};
|
|
27
|
+
stroke-width: 2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.ishikawa .ishikawa-label-box {
|
|
31
|
+
fill: ${e.mainBkg};
|
|
32
|
+
stroke: ${e.lineColor};
|
|
33
|
+
stroke-width: 2;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ishikawa text {
|
|
37
|
+
font-family: ${e.fontFamily};
|
|
38
|
+
font-size: ${e.fontSize};
|
|
39
|
+
fill: ${e.textColor};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ishikawa .ishikawa-head-label {
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
text-anchor: middle;
|
|
45
|
+
dominant-baseline: middle;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ishikawa .ishikawa-label {
|
|
50
|
+
text-anchor: end;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.ishikawa .ishikawa-label.cause {
|
|
54
|
+
text-anchor: middle;
|
|
55
|
+
dominant-baseline: middle;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ishikawa .ishikawa-label.align {
|
|
59
|
+
text-anchor: end;
|
|
60
|
+
dominant-baseline: middle;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ishikawa .ishikawa-label.up {
|
|
64
|
+
dominant-baseline: baseline;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ishikawa .ishikawa-label.down {
|
|
68
|
+
dominant-baseline: hanging;
|
|
69
|
+
}
|
|
70
|
+
`,"getStyles"),Ot=Dt,jt={parser:xt,get db(){return new vt},renderer:Bt,styles:Ot};export{jt as diagram};
|