nextclaw 0.27.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -16
- package/ui-dist/assets/{app-presenter-provider-B1RgR5ug.js → app-presenter-provider-Dp90n1Va.js} +1 -1
- package/ui-dist/assets/{appearance-settings-page-BZSd1SrH.js → appearance-settings-page-Byr55LGb.js} +1 -1
- package/ui-dist/assets/{chat-page-D2xfR6TK.js → chat-page-CEavSS6B.js} +1 -1
- package/ui-dist/assets/{index-B9QEjnoY.js → index-BFIZUZP3.js} +2 -2
- package/ui-dist/assets/remote-_L4pTEaW.js +1 -0
- package/ui-dist/assets/{runtime-config-page-u_fuHxc8.js → runtime-config-page-CIGtssWi.js} +1 -1
- package/ui-dist/index.html +2 -2
- package/ui-dist/assets/remote-2gZkJSX4.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextclaw",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "Powerful AI assistant for coordinating agents, skills, CLI tools, automations, and messaging apps.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"commander": "^12.1.0",
|
|
42
42
|
"jszip": "^3.10.1",
|
|
43
43
|
"yaml": "^2.8.1",
|
|
44
|
-
"@nextclaw/core": "0.15.
|
|
45
|
-
"@nextclaw/
|
|
46
|
-
"@nextclaw/ncp-agent-runtime": "0.4.
|
|
47
|
-
"@nextclaw/ncp
|
|
48
|
-
"@nextclaw/ncp-
|
|
49
|
-
"@nextclaw/
|
|
50
|
-
"@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.3.
|
|
51
|
-
"@nextclaw/
|
|
52
|
-
"@nextclaw/
|
|
53
|
-
"@nextclaw/
|
|
54
|
-
"@nextclaw/
|
|
55
|
-
"@nextclaw/
|
|
56
|
-
"@nextclaw/
|
|
57
|
-
"@nextclaw/
|
|
44
|
+
"@nextclaw/core": "0.15.12",
|
|
45
|
+
"@nextclaw/mcp": "0.3.12",
|
|
46
|
+
"@nextclaw/ncp-agent-runtime": "0.4.10",
|
|
47
|
+
"@nextclaw/ncp": "0.7.10",
|
|
48
|
+
"@nextclaw/ncp-mcp": "0.2.12",
|
|
49
|
+
"@nextclaw/ncp-toolkit": "0.6.11",
|
|
50
|
+
"@nextclaw/nextclaw-ncp-runtime-stdio-client": "0.3.13",
|
|
51
|
+
"@nextclaw/nextclaw-hermes-acp-bridge": "0.3.10",
|
|
52
|
+
"@nextclaw/kernel": "0.6.14",
|
|
53
|
+
"@nextclaw/runtime": "0.4.12",
|
|
54
|
+
"@nextclaw/nextclaw-ncp-runtime-http-client": "0.3.10",
|
|
55
|
+
"@nextclaw/service": "0.3.14",
|
|
56
|
+
"@nextclaw/server": "0.15.14",
|
|
57
|
+
"@nextclaw/remote": "0.3.14"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^20.17.6",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"tsx": "^4.19.2",
|
|
63
63
|
"typescript": "^5.6.3",
|
|
64
64
|
"vitest": "^4.1.2",
|
|
65
|
-
"@nextclaw/ui": "0.15.
|
|
65
|
+
"@nextclaw/ui": "0.15.14"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"dev": "tsx watch --tsconfig ../../scripts/dev/dev-runtime.tsconfig.json src/cli/app/index.ts",
|
package/ui-dist/assets/{app-presenter-provider-B1RgR5ug.js → app-presenter-provider-Dp90n1Va.js}
RENAMED
|
@@ -49,7 +49,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
49
49
|
`)?t.slice(0,-1):t}function fz(e){return(e?lz.exec(e):null)?.[1]?.toLowerCase()||`text`}function pz({className:e,children:t,texts:n}){let r=(0,L.useMemo)(()=>fz(e),[e]),i=(0,L.useMemo)(()=>dz(t),[t]),a=(0,L.useMemo)(()=>cz.highlight(i,r),[i,r]),o=(0,L.useMemo)(()=>{let t=`language-${a.language}`;return B(`hljs`,e,e?.includes(`language-`)?void 0:t)},[e,a.language]),{copied:s,copy:c}=_R({text:i});return(0,R.jsxs)(`div`,{className:`chat-codeblock`,children:[(0,R.jsxs)(`div`,{className:`chat-codeblock-toolbar`,children:[(0,R.jsx)(`span`,{className:`chat-codeblock-language`,children:r}),(0,R.jsxs)(`button`,{type:`button`,className:`chat-codeblock-copy`,onClick:()=>void c(),"aria-label":s?n.copiedCodeLabel:n.copyCodeLabel,children:[s?(0,R.jsx)(cn,{className:`h-3.5 w-3.5`}):(0,R.jsx)(No,{className:`h-3.5 w-3.5`}),(0,R.jsx)(`span`,{children:s?n.copiedCodeLabel:n.copyCodeLabel})]})]}),(0,R.jsx)(`pre`,{children:(0,R.jsx)(`code`,{className:o,"data-highlighted":a.highlighted?`true`:`false`,dangerouslySetInnerHTML:{__html:a.html}})})]})}var mz=`nextclaw-inline`,hz=/language-([a-z0-9-]+)/i,gz=new Set([`auto`,`source`,`rendered`]);function _z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vz(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function yz(e){return Number.isInteger(e)&&Number(e)>0?Number(e):void 0}function bz(e){let t=vz(e);return t&&gz.has(t)?t:void 0}function xz(e){let{payload:t}=e;return _z(t)?t:null}function Sz(e){let t=xz(e);if(!t)return null;let n=vz(t.path);return n?{type:`file`,payload:{path:n,line:yz(t.line),column:yz(t.column),viewer:bz(t.viewer)}}:null}function Cz(e){let t=xz(e);if(!t)return null;let n=vz(t.url);return n?{type:`url`,payload:{url:n}}:null}function wz(e){let t=xz(e);if(!t)return null;let n=vz(t.appId);return n?{type:`panel_app`,payload:{appId:n,path:vz(t.path)}}:null}function Tz(e){let t=xz(e);return!t||!(`value`in t)?null:{type:`json`,payload:{value:t.value}}}function Ez(e){if(!_z(e))return null;let t=vz(e.type);return t===`file`?Sz(e):t===`url`?Cz(e):t===`panel_app`?wz(e):t===`json`?Tz(e):null}function Dz(e){return(e?hz.exec(e):null)?.[1]?.toLowerCase()===mz}function Oz(e){let t=e.endsWith(`
|
|
50
50
|
`)?e.slice(0,-1):e,n;try{n=JSON.parse(t)}catch{return null}if(!_z(n))return null;let r=Ez(n.target);return r?{target:r,title:vz(n.title),description:vz(n.description)}:null}function kz(e){if(e.title)return e.title;if(e.target.type===`file`){let t=e.target.payload.path.split(`/`).filter(Boolean);return t[t.length-1]??e.target.payload.path}return e.target.type===`url`?e.target.payload.url:e.target.type===`panel_app`?e.target.payload.appId:`JSON`}function Az(e){return e.target.type===`file`?e.target.payload.path:e.target.type===`url`?e.target.payload.url:e.target.type===`panel_app`?e.target.payload.appId:JSON.stringify(e.target.payload.value,null,2)}function jz({display:e}){let t=`h-3.5 w-3.5 shrink-0 text-muted-foreground`;return e.target.type===`file`?(0,R.jsx)(hn,{className:t,"aria-hidden":!0}):e.target.type===`url`?(0,R.jsx)(On,{className:t,"aria-hidden":!0}):e.target.type===`panel_app`?(0,R.jsx)(fo,{className:t,"aria-hidden":!0}):(0,R.jsx)(jo,{className:t,"aria-hidden":!0})}function Mz(e){return e.length>1200?`${e.slice(0,1200)}\n...`:e}function Nz({display:e}){let t=kz(e),n=Az(e),r=e.target.type===`json`?Mz(n):n;return(0,R.jsxs)(`section`,{className:B(`my-2 max-w-full border-l-2 border-border bg-muted/30 px-3 py-2`,`text-xs leading-relaxed text-foreground`),"data-nextclaw-inline-display":`true`,"data-nextclaw-inline-display-type":e.target.type,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(jz,{display:e}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]}),e.description?(0,R.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[12px] text-muted-foreground`,children:e.description}):null,(0,R.jsx)(`pre`,{className:B(`mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words`,`font-mono text-[11px] leading-relaxed text-muted-foreground`),children:r})]})}function Pz({display:e,renderInlineDisplay:t}){let n=t?.(e);return n==null?(0,R.jsx)(Nz,{display:e}):(0,R.jsx)(R.Fragment,{children:n})}var Fz=200,Iz=null;function Lz(){return Iz??=h(()=>import(`./mermaid.core-D0Q77r9I.js`).then(e=>e.default),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])),Iz}function Rz(){if(typeof document>`u`)return`default`;let e=document.documentElement;return e.getAttribute(`data-theme-appearance`)===`dark`||e.classList.contains(`dark`)?`dark`:`default`}function zz(){let[e,t]=(0,L.useState)(Rz);return(0,L.useEffect)(()=>{let e=document.documentElement,n=new MutationObserver(()=>t(Rz()));return n.observe(e,{attributes:!0,attributeFilter:[`class`,`data-theme-appearance`]}),()=>n.disconnect()},[]),e}function Bz({isStreaming:e,source:t,texts:n}){let r=(0,L.useId)().replace(/[^a-zA-Z0-9_-]/g,``),i=(0,L.useRef)(0),a=zz(),o=t.trim(),s=`${a}:${o}`,c=(0,L.useRef)({isFinal:!e,key:s,source:o,theme:a}),l=(0,L.useRef)(null),u=(0,L.useRef)(!1),d=(0,L.useRef)(Date.now()),f=(0,L.useRef)(!0),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=n.mermaidDiagramLabel??`Mermaid diagram`,v=n.mermaidLoadingLabel??`Rendering diagram…`,y=n.mermaidRenderErrorLabel??`Diagram could not be rendered`,b=(0,L.useCallback)(e=>{if(!f.current||u.current)return;if(l.current!==null){if(!e)return;window.clearTimeout(l.current),l.current=null}let t=Date.now()-d.current,n=e?0:Math.max(0,Fz-t);l.current=window.setTimeout(()=>{l.current=null,m(c.current)},n)},[]);(0,L.useEffect)(()=>(f.current=!0,()=>{f.current=!1,l.current!==null&&(window.clearTimeout(l.current),l.current=null)}),[]),(0,L.useEffect)(()=>{c.current={isFinal:!e,key:s,source:o,theme:a},b(!e)},[e,o,s,b,a]),(0,L.useEffect)(()=>{if(!p)return;let e=!0;return(async()=>{u.current=!0,d.current=Date.now();try{let t=await Lz();if(!e||!f.current)return;i.current+=1;let n=`nextclaw-mermaid-${r}-${i.current}`;t.initialize({securityLevel:`strict`,startOnLoad:!1,suppressErrorRendering:!0,theme:p.theme});let a=await t.parse(p.source,{suppressErrors:!0});if(!e||!f.current)return;if(!a)throw Error(`Invalid Mermaid diagram`);let{svg:o}=await t.render(n,p.source);e&&f.current&&c.current.theme===p.theme&&g({key:p.key,status:`rendered`,svg:o})}catch{e&&f.current&&p.isFinal&&c.current.key===p.key&&g({key:p.key,status:`error`})}finally{u.current=!1;let t=c.current;e&&f.current&&(t.key!==p.key||t.isFinal!==p.isFinal)&&b(t.isFinal)}})(),()=>{e=!1}},[r,p,b]);let x=h?.key===s?h:null;if(x?.status===`error`)return(0,R.jsxs)(`div`,{"data-chat-mermaid-error":`true`,className:`my-3 overflow-hidden rounded-xl border border-border bg-muted/25`,children:[(0,R.jsx)(`div`,{className:`border-b border-border px-3 py-2 text-xs text-muted-foreground`,children:y}),(0,R.jsx)(pz,{className:`language-mermaid`,texts:n,children:o})]});let S=h?.status===`rendered`?h:null;return(0,R.jsx)(`figure`,{"aria-label":_,"aria-busy":!x,"data-chat-mermaid-diagram":`true`,"data-chat-mermaid-pending":!S||void 0,"data-chat-mermaid-updating":!x||void 0,className:S?`my-3 min-h-24 overflow-auto py-2`:`my-3 flex min-h-14 items-center justify-center rounded-xl bg-muted/20 px-3 py-2`,children:S?(0,R.jsx)(`div`,{className:`min-w-fit [&_svg]:mx-auto [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:{__html:S.svg}}):(0,R.jsxs)(`div`,{role:`status`,className:`inline-flex items-center gap-2 text-xs font-medium text-muted-foreground/80`,children:[(0,R.jsx)(zn,{"aria-hidden":`true`,className:`h-3.5 w-3.5 animate-spin motion-reduce:animate-none`}),(0,R.jsx)(`span`,{children:v})]})})}function Vz({alt:e,closeLabel:t,onClose:n,src:r}){let i=(0,L.useId)();return(0,L.useEffect)(()=>{let e=document.body.style.overflow;document.body.style.overflow=`hidden`;let t=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,t)}},[n]),(0,AD.createPortal)((0,R.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":i,className:`fixed inset-0 z-[var(--z-modal,10050)] flex items-center justify-center bg-black/80 p-4 backdrop-blur-[2px]`,"data-testid":`chat-message-image-lightbox`,onClick:n,children:[(0,R.jsx)(`span`,{id:i,className:`sr-only`,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":t,className:`absolute right-4 top-4 inline-flex h-9 w-9 items-center justify-center rounded-full bg-black/55 text-white transition-colors hover:bg-black/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/70`,onClick:e=>{e.stopPropagation(),n()},children:(0,R.jsx)(Un,{className:`h-4 w-4`,strokeWidth:2})}),(0,R.jsx)(`img`,{src:r,alt:e,className:`max-h-[min(92vh,100%)] max-w-[min(96vw,100%)] object-contain shadow-2xl`,onClick:e=>e.stopPropagation()})]}),document.body)}function Hz({alt:e,expandLabel:t,closeLabel:n,sizeLabel:r,src:i}){let[a,o]=(0,L.useState)(!1),s=()=>o(!0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{"data-chat-message-image-preview":!0,className:`group/image relative block w-fit max-w-[min(100%,32rem)] overflow-hidden rounded-lg`,children:[(0,R.jsx)(`button`,{type:`button`,className:`block w-fit max-w-[min(100%,32rem)] text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,onClick:s,onDoubleClick:e=>{e.preventDefault(),s()},"aria-label":t,children:(0,R.jsx)(`img`,{src:i,alt:e,className:`block h-auto w-auto max-h-[26rem] max-w-full rounded-lg bg-transparent object-contain`})}),(0,R.jsx)(`button`,{type:`button`,"aria-label":t,className:`absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md bg-black/45 text-white opacity-0 transition-opacity duration-150 hover:bg-black/60 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/70 group-hover/image:opacity-100`,onClick:e=>{e.preventDefault(),e.stopPropagation(),s()},children:(0,R.jsx)(Lo,{className:`h-3.5 w-3.5`,strokeWidth:2})}),r?(0,R.jsx)(`span`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex items-end justify-start bg-gradient-to-t from-black/50 via-black/15 to-transparent px-2.5 pb-2 pt-8 opacity-0 transition-opacity duration-150 group-hover/image:opacity-100 group-focus-within/image:opacity-100`,children:(0,R.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-black/40 px-1.5 py-0.5 text-[10px] font-medium text-white/95 backdrop-blur-sm`,children:r})}):null]}),a?(0,R.jsx)(Vz,{alt:e,closeLabel:n,onClose:()=>o(!1),src:i}):null]})}var Uz=new Set([`http:`,`https:`,`mailto:`,`tel:`]),Wz=/^[a-zA-Z][a-zA-Z\d+.-]*:/,Gz=/^[a-z]:[\\/]/i,Kz=/^\/[a-z]:[\\/]/i,qz=`file:`;function Jz(e){return!e.startsWith(`//`)&&!Wz.test(e)}function Yz(e){let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:void 0}function Xz(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==qz||t.hostname&&t.hostname.toLowerCase()!==`localhost`)return null;let n;try{n=decodeURIComponent(t.pathname)}catch{return null}return Kz.test(n)&&(n=n.slice(1)),n?{path:n,query:t.searchParams,fragment:t.hash.slice(1)}:null}function Zz(e){let t=e.indexOf(`#`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``,i=n.indexOf(`?`),a=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i+1):``,s;try{s=decodeURIComponent(a)}catch{return null}return s?{path:s,query:new URLSearchParams(o),fragment:r}:null}function Qz(e){let t=/^L(\d+)(?:C(\d+))?(?:-L\d+(?:C\d+)?)?$/i.exec(e),n=Yz(t?.[1]);return{line:n,column:n?Yz(t?.[2]):void 0}}function $z(e){if(Gz.test(e)||Jz(e))return e;try{let t=new URL(e);return Uz.has(t.protocol)||t.protocol===qz&&Xz(e)?e:``}catch{return``}}function eB(e){return e&&$z(e)||null}function tB(e){return/^https?:\/\//i.test(e)}function nB(e){let t=e.toLowerCase().startsWith(qz)?Xz(e):Zz(e),n=t?.path;if(!n||n.startsWith(`#`)||n.startsWith(`//`)||!Gz.test(n)&&Wz.test(n))return null;let r=t.query.get(`viewer`),i=Qz(t.fragment),a=/^(.*?)(?::(\d+)(?::(\d+))?)$/.exec(n),o=a?.[1]??n,s=i.line??Yz(a?.[2]),c=i.column??(s?Yz(a?.[3]):void 0);return{path:o,label:o.split(/[\\/]/).filter(Boolean).pop()??o,viewMode:`preview`,...r===`source`||r===`rendered`?{previewViewer:r}:{},...typeof s==`number`?{line:s}:{},...typeof c==`number`?{column:c}:{}}}var rB=14e4,iB=`data-chat-inline-token-kind`,aB=`data-chat-inline-token-key`,oB=`data-chat-inline-token-label`,sB=`data-chat-inline-token-raw-text`;function cB(e){return e.length<=rB?e:`${e.slice(0,rB)}\n\n...`}function lB(e){let t=0;for(let n of e?.children??[]){if(n.type===`text`){let e=n.value??``;if(e.trim().length>0||e.includes(`
|
|
51
51
|
`)||e.includes(`\r`))return!1;continue}if(n.tagName!==`img`)return!1;t+=1}return t>=3}function uB(e){if(!e||e.length===0)return[];let t=new Set,n=[];for(let r of e)!r.rawText||t.has(r.rawText)||(t.add(r.rawText),n.push(r));return n.sort((e,t)=>t.rawText.length-e.rawText.length)}function dB(e){return{type:`chatInlineToken`,data:{hName:`span`,hProperties:{[iB]:e.kind,[aB]:e.key,[oB]:e.label,[sB]:e.rawText},hChildren:[{type:`text`,value:e.label}]}}}function fB(e,t,n){let r=null;for(let i of n){let n=e.indexOf(i.rawText,t);n<0||(!r||n<r.index||n===r.index&&i.rawText.length>r.token.rawText.length)&&(r={index:n,token:i})}return r}function pB(e,t){let n=[],r=0;for(;r<e.length;){let i=fB(e,r,t);if(!i){n.push({type:`text`,value:e.slice(r)});break}i.index>r&&n.push({type:`text`,value:e.slice(r,i.index)}),n.push(dB(i.token)),r=i.index+i.token.rawText.length}return n.length>0?n:[{type:`text`,value:e}]}function mB(e,t){return e.type===`code`||e.type===`inlineCode`||!e.children?e:{...e,children:e.children.flatMap(e=>e.type===`text`&&typeof e.value==`string`?pB(e.value,t):[mB(e,t)])}}function hB(e){let t=uB(e);return()=>e=>t.length>0?mB(e,t):e}function gB(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}var _B=(0,L.createContext)(null);function vB(){let e=(0,L.useContext)(_B);if(!e)throw Error(`Chat message Markdown renderer requires its runtime context`);return e}var yB={p:function({node:e,children:t}){let{inline:n}=vB();return n?(0,R.jsx)(R.Fragment,{children:t}):(0,R.jsx)(`p`,{"data-chat-image-row":lB(e)?`three-column`:void 0,children:t})},span:function({node:e,children:t,...n}){let{onInlineTokenClick:r}=vB(),i=n,a=gB(i,iB),o=gB(i,aB),s=gB(i,oB),c=gB(i,sB);return a&&o&&s&&c?(0,R.jsx)(iR,{kind:a,label:s,tooltip:o,onClick:r?()=>r({kind:a,key:o,label:s,rawText:c}):void 0}):(0,R.jsx)(`span`,{...n,children:t})},a:function({node:e,href:t,children:n,...r}){let{onFileOpen:i}=vB(),a=eB(t),o=a?tB(a):!1,s=o?null:a?nB(a):null,c=e=>{if(!a){e.preventDefault();return}!i||!s||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(s))};return(0,R.jsx)(`a`,{...r,className:B(r.className,!a&&`chat-link-invalid`),href:a??`#`,"aria-disabled":!a||void 0,onClick:c,target:o?`_blank`:void 0,rel:o?`noreferrer noopener`:void 0,children:n})},table:function({node:e,children:t,...n}){return(0,R.jsx)(`div`,{className:`chat-table-wrap`,children:(0,R.jsx)(`table`,{...n,children:t})})},input:function({node:e,type:t,checked:n,...r}){return t===`checkbox`?(0,R.jsx)(`input`,{...r,type:`checkbox`,checked:n,readOnly:!0,disabled:!0,className:`chat-task-checkbox`}):(0,R.jsx)(`input`,{...r,type:t})},img:function({node:e,src:t,alt:n}){let{resolveFileContentUrl:r,texts:i}=vB(),a=eB(t);if(!a)return null;let o=nB(a),s=o&&r?r(o):a;return s?(0,R.jsx)(Hz,{alt:n||``,closeLabel:i.attachmentCloseLabel??`Close preview`,expandLabel:i.attachmentExpandLabel??`Expand image`,sizeLabel:null,src:s}):null},code:function({node:e,className:t,children:n,...r}){let{isStreaming:i,renderInlineDisplay:a,texts:o}=vB(),s=String(n??``);if(!t&&!s.includes(`
|
|
52
|
-
`))return(0,R.jsx)(`code`,{...r,className:B(`chat-inline-code`,t),children:n});let c=Dz(t)?Oz(s):null;return c?(0,R.jsx)(Pz,{display:c,renderInlineDisplay:a}):t?.split(` `).includes(`language-mermaid`)?(0,R.jsx)(Bz,{isStreaming:i,source:s,texts:o}):(0,R.jsx)(pz,{className:t,texts:o,children:n})}};function bB({text:e,role:t,texts:n,inline:r=!1,isStreaming:i=!1,inlineTokens:a,onFileOpen:o,onInlineTokenClick:s,resolveFileContentUrl:c,renderInlineDisplay:l}){let u=t===`user`,d=a?.length?[nR,hB(a)]:[nR],f=r?`span`:`div`;return(0,R.jsx)(_B.Provider,{value:{inline:r,isStreaming:i,isUser:u,onFileOpen:o,onInlineTokenClick:s,renderInlineDisplay:l,resolveFileContentUrl:c,texts:n},children:(0,R.jsx)(f,{className:B(`chat-markdown`,u?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,R.jsx)(QP,{skipHtml:!0,remarkPlugins:d,components:yB,urlTransform:$z,children:cB(e)})})})}var xB={archive:`bg-muted text-muted-foreground`,audio:`bg-muted text-muted-foreground`,code:`bg-muted text-muted-foreground`,data:`bg-muted text-muted-foreground`,document:`bg-muted text-muted-foreground`,generic:`bg-muted text-muted-foreground`,image:`bg-muted text-muted-foreground`,pdf:`bg-muted text-muted-foreground`,sheet:`bg-muted text-muted-foreground`,video:`bg-muted text-muted-foreground`},SB=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),CB=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),wB=new Set([`avif`,`bmp`,`gif`,`heic`,`heif`,`ico`,`jpeg`,`jpg`,`png`,`svg`,`tif`,`tiff`,`webp`]),TB=new Set([`aac`,`flac`,`m4a`,`mp3`,`ogg`,`opus`,`wav`,`weba`]),EB=new Set([`avi`,`m4v`,`mov`,`mp4`,`mkv`,`webm`,`wmv`]),DB=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),OB=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),kB=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function AB(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,``)} ${t[r]}`}function jB(e,t){let n=MB(e);if(n)return n.toUpperCase();let r=(t.split(`/`)[1]??``).split(/[+.;-]/)[0]?.trim();return r?r.slice(0,6).toUpperCase():`FILE`}function MB(e){return/\.([a-z0-9]{1,12})$/i.exec(e.trim())?.[1]?.toLowerCase()??``}function NB(e){return typeof e==`string`&&/^data:image\//i.test(e.trim())}function PB(e){return wB.has(e)?e===`jpg`||e===`jpeg`?`image/jpeg`:e===`svg`?`image/svg+xml`:`image/${e}`:TB.has(e)?e===`mp3`?`audio/mpeg`:e===`m4a`?`audio/mp4`:e===`weba`?`audio/webm`:`audio/${e}`:EB.has(e)?e===`mov`?`video/quicktime`:e===`m4v`?`video/mp4`:`video/${e}`:e===`pdf`?`application/pdf`:null}function FB(e){let t=MB(e);return t?PB(t):null}function IB(e){let t=e.mimeType.trim().toLowerCase();return t.length>0&&t!==`application/octet-stream`?t:FB(e.label)}function LB(e){let t=e.mimeType.trim().toLowerCase(),n=MB(e.label);return e.isImage||t.startsWith(`image/`)||wB.has(n)||NB(e.dataUrl)}function RB(e,t){let n=MB(e),r=t.toLowerCase();return r.startsWith(`image/`)||wB.has(n)?`image`:r.startsWith(`audio/`)||TB.has(n)?`audio`:r.startsWith(`video/`)||EB.has(n)?`video`:r.includes(`pdf`)||n===`pdf`?`pdf`:kB.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:OB.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:CB.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:SB.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:DB.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function zB(e){let t=RB(e.label,e.mimeType),n=AB(e.sizeBytes);return{category:t,extension:jB(e.label,e.mimeType),sizeLabel:n}}var BB={archive:`Archive`,audio:`Audio`,code:`Code file`,data:`Data file`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF document`,sheet:`Spreadsheet`,video:`Video`},VB={archive:Ro,audio:zo,code:Bo,data:Ho,document:hn,generic:Go,image:Vo,pdf:hn,sheet:Uo,video:Wo};function HB(e,t){return t?.attachmentCategoryLabels?.[e]??BB[e]}function UB(e,t,n){return(0,R.jsx)(`div`,{className:B(`mt-0.5 text-[11px] leading-4`,n?`text-foreground/55`:`text-muted-foreground`),children:t?`${e} · ${t}`:e})}function WB(e,t,n){return(0,R.jsx)(`span`,{className:B(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-medium`,n?t?`bg-black/5 text-foreground/75`:`bg-muted text-muted-foreground`:t?`bg-black/[0.03] text-foreground/45`:`bg-muted/70 text-muted-foreground/70`),children:e})}function GB(e){let{label:t,href:n,isUser:r,onOpen:i}=e,a=B(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors`,r?`bg-black/5 text-foreground/75 hover:bg-black/10 hover:text-foreground`:`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`);return i?(0,R.jsx)(`button`,{type:`button`,className:a,onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},children:t}):n?(0,R.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:a,children:t}):WB(t,r,!1)}function KB({category:e,isUser:t}){let n=VB[e];return(0,R.jsx)(`div`,{className:B(`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,t?`bg-black/5 text-foreground/70`:xB[e]),children:(0,R.jsx)(n,{className:B(`h-4 w-4`,t?`text-foreground/70`:`text-current`),strokeWidth:2})})}function qB(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:o}=e;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-2`,children:[(0,R.jsx)(KB,{category:t,isUser:a}),(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:n.label}),UB(r,i,a)]}),o]})})]})}function JB(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,shellClasses:o,actionLabel:s,onOpen:c}=e;if(!n.dataUrl||t!==`audio`&&t!==`video`)return null;let l=IB(n);return(0,R.jsxs)(`div`,{className:o,children:[qB({category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:GB({label:s,href:n.dataUrl,isUser:a,onOpen:c?()=>c(n):void 0})}),(0,R.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:t===`audio`?(0,R.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":n.label,className:`block w-full`,children:(0,R.jsx)(`source`,{src:n.dataUrl,...l?{type:l}:{}})}):(0,R.jsx)(`div`,{className:B(`overflow-hidden rounded-lg`,a?`bg-black/10`:`bg-muted ring-1 ring-border/70`),children:(0,R.jsx)(`video`,{controls:!0,preload:`metadata`,playsInline:!0,"aria-label":n.label,className:`block max-h-[28rem] w-full bg-black`,children:(0,R.jsx)(`source`,{src:n.dataUrl,...l?{type:l}:{}})})})})]})}function YB({file:e,isUser:t=!1,texts:n,onOpen:r}){let{category:i,sizeLabel:a}=zB(e),o=LB(e)&&!!e.dataUrl,s=i===`audio`&&!!e.dataUrl,c=i===`video`&&!!e.dataUrl,l=!!e.dataUrl,u=l?n?.attachmentOpenLabel??`Open`:n?.attachmentAttachedLabel??`Attached`,d=n?.attachmentExpandLabel??`Expand image`,f=n?.attachmentCloseLabel??`Close preview`,p=HB(i,n),m=B(`block overflow-hidden rounded-xl border transition-colors`,t?`border-black/8 bg-black/[0.03] text-foreground`:`border-border/70 bg-card text-card-foreground`,l&&(t?`hover:bg-black/[0.05]`:`hover:bg-muted/50`));if(o&&e.dataUrl)return(0,R.jsx)(Hz,{alt:e.label,expandLabel:d,closeLabel:f,sizeLabel:a,src:e.dataUrl});if(s||c)return JB({category:i,file:e,categoryLabel:p,sizeLabel:a,isUser:t,shellClasses:m,actionLabel:u,onOpen:r});let h=qB({category:i,file:e,categoryLabel:p,sizeLabel:a,isUser:t,action:WB(u,t,l)});return!l||!e.dataUrl?(0,R.jsx)(`div`,{className:m,children:h}):r?(0,R.jsx)(`button`,{type:`button`,className:B(m,`group w-full text-left`),onClick:()=>r(e),children:h}):(0,R.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,className:B(m,`group`),children:h})}function XB({group:e,indexOffset:t,isUser:n,texts:r,onOpen:i}){return(0,R.jsx)(`div`,{"data-chat-message-image-row":`three-column`,"data-chat-message-wide-content":`true`,className:`grid w-full grid-cols-3 items-start gap-3`,children:e.items.map(({index:e,part:a})=>(0,R.jsx)(YB,{file:a.file,isUser:n,texts:r,onOpen:i},`file-${t+e}`))})}function ZB(e){return!!(e?.kind===`part`&&e.part.type===`file`&&e.part.file.isImage&&e.part.file.dataUrl)}function QB(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!ZB(r)){r&&t.push(r),n+=1;continue}let i=n,a=[];for(;ZB(e[n]);)a.push(e[n]),n+=1;if(a.length<3){t.push(...a);continue}t.push({kind:`image-group`,key:`image-group-${i}`,items:a})}return t}function $B(e){let{isInProgress:t}=e,[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(t);(0,L.useEffect)(()=>{let e=o.current;!e&&t?(r(!0),a(!1)):e&&!t&&!i&&r(!1),o.current=t},[t,i]);function s(e){e.preventDefault();let i=!n;if(r(i),!i){a(!1);return}t&&a(!0)}return{isOpen:n,onSummaryClick:s}}var eV=10;function tV({contentRef:e,contentVersion:t,hasContent:n,isLoading:r,resetKey:i,scrollRef:a,stickyThresholdPx:o}){let[s,c]=(0,L.useState)(!0),l=(0,L.useRef)(!0),u=(0,L.useRef)(null),d=(0,L.useRef)(!1),f=(0,L.useRef)(null),p=(0,L.useCallback)(e=>{l.current=e,c(e)},[]),m=(0,L.useCallback)(e=>e.scrollHeight-e.scrollTop-e.clientHeight<=(o??eV),[o]),h=(0,L.useCallback)((e=`auto`)=>{a.current&&(f.current!==null&&cancelAnimationFrame(f.current),f.current=requestAnimationFrame(()=>{f.current=null;let t=a.current;t&&(typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)}))},[a]),g=(0,L.useCallback)(()=>{p(!0),h()},[h,p]),_=(0,L.useCallback)(()=>{let e=a.current;e&&p(m(e))},[m,a,p]);return(0,L.useEffect)(()=>{u.current!==i&&(u.current=i,p(!0),d.current=!0)},[i,p]),(0,L.useEffect)(()=>()=>{let e=f.current;e!==null&&(cancelAnimationFrame(e),f.current=null)},[]),(0,L.useEffect)(()=>{let t=e?.current;if(!t||!n||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{l.current&&h()});return r.observe(t),()=>r.disconnect()},[e,n,h,i]),(0,L.useLayoutEffect)(()=>{!d.current||r||!n||a.current&&(d.current=!1,h())},[n,r,h,a]),(0,L.useLayoutEffect)(()=>{!l.current||!n||a.current&&h()},[t,n,h,a]),{isAtBottom:s,onScroll:_,scrollToBottom:g}}var nV=`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-current`,rV=`group/process-row flex w-full min-w-0 items-center gap-1.5 py-0 text-[0.925rem] font-normal leading-[1.72] text-muted-foreground/80`;function iV({children:e,className:t}){return(0,R.jsx)(`span`,{className:B(nV,t),children:e})}function aV({position:e}){return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-tool-workflow-rail":`true`,className:B(`pointer-events-none absolute left-[0.575em] w-px -translate-x-1/2 bg-border/70`,e===`first`?`bottom-0 top-[0.86em]`:e===`last`?`top-0 h-[0.86em]`:`inset-y-0`)})}function oV({children:e,className:t,interactive:n=!1,onClick:r,role:i,tabIndex:a,onKeyDown:o}){return(0,R.jsx)(`div`,{"data-chat-process-meta-row":`true`,className:B(rV,n?`cursor-pointer transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`:null,t),onClick:r,role:i,tabIndex:a,onKeyDown:o,children:e})}function sV({label:e,openGroup:t,open:n=!1,icon:r,className:i,leadingIconClassName:a,labelClassName:o,onClick:s}){return(0,R.jsxs)(`button`,{type:`button`,"data-chat-process-meta-row":`true`,className:B(rV,`m-0 w-full border-0 bg-transparent p-0 text-left shadow-none transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`,i),"aria-expanded":n,onClick:s,children:[r?(0,R.jsx)(iV,{className:B(`relative z-[1] rounded-sm`,a),children:(0,R.jsx)(r,{className:`h-[1.05em] w-[1.05em]`,strokeWidth:2.25})}):null,(0,R.jsx)(`span`,{className:B(`min-w-0 shrink truncate`,o),children:e}),(0,R.jsx)(`span`,{className:B(`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-muted-foreground/80 transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/process-row:opacity-100 focus-visible:opacity-100`),children:(0,R.jsx)(wo,{className:B(`h-[1.05em] w-[1.05em] transition-transform`,n&&`rotate-90`),strokeWidth:2.25})})]})}function cV(e,t,n){let r=Array.from(t).length;return(n??`${e} · {count}`).split(`{count}`).join(String(r))}function lV({label:e,text:t,characterCountTemplates:n,isUser:r,isInProgress:i}){let{isOpen:a,onSummaryClick:o}=$B({isInProgress:i}),s=(0,L.useRef)(null),c=cV(e,t,i?n?.inProgress:n?.completed),{onScroll:l}=tV({scrollRef:s,resetKey:`reasoning`,isLoading:!1,hasContent:t.length>0,contentVersion:t,stickyThresholdPx:20});return(0,R.jsxs)(`div`,{className:`group/reasoning`,children:[(0,R.jsx)(sV,{openGroup:`reasoning`,open:a,icon:yo,leadingIconClassName:r?`bg-primary`:`bg-card`,label:c,labelClassName:r?`text-primary-100`:void 0,onClick:o}),a?(0,R.jsx)(`div`,{ref:s,onScroll:l,"data-reasoning-scroll":`true`,className:B(`mt-1 w-fit max-w-[500px] max-h-56 overflow-y-auto rounded-lg custom-scrollbar`,r?`bg-primary/70`:`bg-muted`),children:(0,R.jsx)(`pre`,{className:`min-w-0 whitespace-pre-wrap break-all p-2 text-[11px]`,children:t})}):null]})}function uV({children:e,className:t}){return(0,R.jsx)(`div`,{className:B(`relative my-0 flex w-full min-w-0 max-w-full flex-col text-[0.925rem] leading-[1.72] text-muted-foreground`,t),children:e})}function dV({children:e,className:t}){return(0,R.jsx)(`div`,{className:B(`mt-0.5 w-full max-w-full min-w-0 overflow-hidden pl-[calc(1.15em+0.375rem)] text-[0.925rem] leading-[1.72] text-muted-foreground`,t),children:e})}function fV({label:e,tone:t,children:n}){let r={input:{dot:`bg-muted-foreground/60`,body:`text-foreground`},output:{dot:`bg-primary/70`,body:`text-foreground`},error:{dot:`bg-rose-500/80`,body:`text-rose-950/85`}}[t];return(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-md border border-border/70 bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-1.5 text-[10px] font-medium tracking-wide text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:B(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,R.jsx)(`span`,{className:`normal-case tracking-normal`,children:e})]}),(0,R.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,R.jsx)(`pre`,{className:B(`w-full max-w-full min-w-0 max-h-64 overflow-x-auto overflow-y-auto px-2.5 py-2 font-mono text-[12px] leading-relaxed whitespace-pre custom-scrollbar`,r.body),children:n})})]})}var pV={running:{text:`text-muted-foreground`,icon:zn,spin:!0},success:{text:`text-muted-foreground/75`,icon:cn,spin:!1},error:{text:`text-destructive`,icon:Ws,spin:!1},cancelled:{text:`text-muted-foreground/70`,icon:ys,spin:!1}};function mV({card:e,iconOnly:t=!1}){let n=pV[e.statusTone]||pV.cancelled,r=n.icon,i=!t&&(e.statusTone===`running`||e.statusTone===`error`);return(0,R.jsxs)(`span`,{className:B(`inline-flex shrink-0 items-center gap-1 text-[0.925rem] font-normal leading-[1.72]`,n.text),"aria-label":t?e.statusLabel:void 0,children:[(0,R.jsx)(r,{"aria-hidden":`true`,className:B(`h-[1.05em] w-[1.05em]`,n.spin&&`animate-spin`),strokeWidth:2.25}),i?e.statusLabel:null]})}function hV(e){return e.kind===`show-content`?{icon:wn,label:e.label,toneClassName:`border-border/70 bg-transparent text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-primary/35`}:{icon:mo,label:e.label??(e.sessionKind===`child`?`Open child session`:`Open session`),toneClassName:`border-border/70 bg-transparent text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-primary/35`}}function gV({action:e,onAction:t}){let{Tooltip:n,TooltipContent:r,TooltipProvider:i,TooltipTrigger:a}=l_,o=hV(e),s=o.icon;return(0,R.jsx)(i,{delayDuration:250,children:(0,R.jsxs)(n,{children:[(0,R.jsx)(a,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:B(`inline-flex h-6 w-6 items-center justify-center rounded-md border transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1`,o.toneClassName),"aria-label":o.label,title:o.label,children:(0,R.jsx)(s,{className:`h-3.5 w-3.5`,strokeWidth:2.25})})}),(0,R.jsx)(r,{side:`top`,className:`text-xs`,children:o.label})]})})}function _V(e){return e.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim()}function vV(e,t){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),t())}function yV({label:e,summary:t}){return(0,R.jsxs)(`span`,{className:`min-w-0 shrink truncate`,children:[e,t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`mx-1.5 select-none text-muted-foreground/45`,children:`·`}),(0,R.jsx)(`span`,{title:t,children:t})]}):null]})}function bV({expanded:e}){return(0,R.jsx)(`span`,{className:B(`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-muted-foreground/80 transition-opacity`,e?`opacity-100`:`opacity-0 group-hover/process-row:opacity-100 group-focus-within/process-row:opacity-100`),children:(0,R.jsx)(wo,{className:B(`h-[1.05em] w-[1.05em] transition-transform`,e&&`rotate-90`),strokeWidth:2.25})})}function xV({additions:e,deletions:t}){if(e===0&&t===0)return null;let n=[e>0?`+${e}`:null,t>0?`-${t}`:null].filter(Boolean).join(` `);return(0,R.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground/75`,"aria-label":n,children:[e>0?(0,R.jsxs)(`span`,{className:`transition-colors group-hover/process-row:text-emerald-600`,children:[`+`,e]}):null,t>0?(0,R.jsxs)(`span`,{className:`transition-colors group-hover/process-row:text-rose-600`,children:[`-`,t]}):null]})}function SV({card:e,toolLabel:t,changeSummary:n,icon:r,expanded:i,canExpand:a,hideSummary:o=!1,actionSlot:s,onToggle:c}){let l=o?``:e.summary?.replace(/^(command|path|args|query|input):\s*/i,``)??``,u=t??_V(e.toolName);return(0,R.jsxs)(oV,{interactive:a,onClick:a?()=>c():void 0,role:a?`button`:void 0,tabIndex:a?0:void 0,onKeyDown:a?e=>vV(e,c):void 0,children:[(0,R.jsx)(iV,{className:`relative z-[1] rounded-sm bg-card`,children:(0,R.jsx)(r,{className:`h-[1.05em] w-[1.05em]`,strokeWidth:2.25})}),(0,R.jsx)(yV,{label:u,summary:l}),n?(0,R.jsx)(xV,{...n}):null,(0,R.jsx)(mV,{card:e,iconOnly:!!t}),a?(0,R.jsx)(bV,{expanded:i}):null,s?(0,R.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/process-row:opacity-100 group-focus-within/process-row:opacity-100`,children:s}):null]})}function CV({action:e,onAction:t}){return(0,R.jsx)(gV,{action:e,onAction:t})}var wV=`font-mono text-[11px] leading-5`,TV=`flex h-5 w-full ${wV}`,EV=`flex h-5 items-center justify-center px-2.5 tabular-nums select-none`;function DV(e){return String(e.newLineNumber??e.oldLineNumber??``)}function OV(e,t){return typeof t==`number`&&(e.newLineNumber??e.oldLineNumber)===t}function kV(e,t,n){return`${e}-${n}-${t.oldLineNumber??`x`}-${t.newLineNumber??`x`}`}function AV(e){return typeof e.newLineNumber==`number`||typeof e.oldLineNumber==`number`}function jV(e){return e.lines.some(AV)}function MV(e){let t=e.lines.reduce((e,t)=>AV(t)?Math.max(e,DV(t).length):e,0);return`${Math.max(6.5,Math.min(8,t+3.5))}ch`}function NV(e){return`calc(${e.lines.reduce((e,t)=>Math.max(e,Math.max(1,t.text.length)),1)}ch + 1.25rem)`}function PV(e){let t=e.split(/[\\/]/).filter(Boolean).pop()??e,n=t.split(/[?#]/)[0]??t,r=n.lastIndexOf(`.`);return r<=0||r===n.length-1?null:n.slice(r+1).toLowerCase()}function FV(e){return e.languageHint?.trim()||PV(e.path)||`text`}function IV(e){let t=e.toLowerCase().replace(/[^a-z0-9-]/g,`-`);return t?`language-${t}`:`language-text`}function LV(e){return e.kind===`remove`?`border-r border-rose-200 bg-rose-50 text-rose-700`:e.kind===`add`?`border-r border-emerald-200 bg-emerald-50 text-emerald-700`:`border-r border-border bg-muted text-muted-foreground`}function RV(e){return e.kind===`remove`?`bg-rose-50 text-rose-950`:e.kind===`add`?`bg-emerald-50 text-emerald-950`:`bg-card text-foreground`}function zV({layout:e,line:t,lineNumberColumnWidth:n,target:r,targetRef:i}){return(0,R.jsx)(`span`,{ref:i,"data-file-line-number-cell":`true`,style:e===`compact`?{width:n,minWidth:n}:void 0,className:B(EV,e===`compact`?`sticky left-0 z-[1]`:`w-full shrink-0`,LV(t),r?`bg-gray-200 font-medium text-gray-950`:null),children:DV(t)})}function BV({language:e,line:t,target:n,targetColumn:r,targetRef:i}){let a=(0,L.useMemo)(()=>cz.highlight(t.text||` `,e),[e,t.text]),o=typeof r==`number`&&Number.isSafeInteger(r)&&r>0?Math.min(r,t.text.length+1):null;return(0,R.jsxs)(`span`,{ref:o?void 0:i,"data-file-code-row":`true`,"data-file-code-language":a.language,"data-highlighted":a.highlighted?`true`:`false`,"data-file-target-column":o??void 0,className:B(`chat-file-code-syntax hljs relative block min-w-0 flex-1 whitespace-pre px-2.5`,IV(a.language),RV(t),n?`bg-gray-100/90`:null),children:[(0,R.jsx)(`span`,{dangerouslySetInnerHTML:{__html:a.html}}),o?(0,R.jsx)(`span`,{ref:i,"aria-hidden":`true`,"data-file-target-caret":`true`,className:`pointer-events-none absolute inset-y-0 w-px bg-primary`,style:{left:`calc(0.625rem + ${o-1}ch)`}}):null]})}function VV({language:e,line:t,showLineNumbers:n,lineNumberColumnWidth:r}){return(0,R.jsxs)(`div`,{"data-file-line-row":`true`,className:TV,children:[n?(0,R.jsx)(zV,{layout:`compact`,line:t,lineNumberColumnWidth:r}):null,(0,R.jsx)(BV,{language:e,line:t})]})}function HV({block:e,targetColumn:t,targetLine:n}){let r=jV(e),i=MV(e),a=NV(e),o=FV(e),s=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{s.current?.scrollIntoView({block:`center`,inline:t?`center`:`nearest`})},[e,t,n]),(0,R.jsxs)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`workspace`,className:`flex h-full min-h-full min-w-full bg-card`,children:[r?(0,R.jsxs)(`div`,{"data-file-code-gutter":`true`,style:{width:i,minWidth:i},className:B(`flex h-full min-h-full shrink-0 flex-col`,wV),children:[e.lines.map((e,r)=>(0,R.jsx)(zV,{layout:`workspace`,line:e,lineNumberColumnWidth:i,target:OV(e,n),targetRef:!t&&OV(e,n)?s:void 0},kV(`gutter`,e,r))),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 border-r border-border bg-muted`})]}):null,(0,R.jsxs)(`div`,{"data-file-code-canvas":`true`,className:`flex h-full min-h-full min-w-0 flex-1 flex-col bg-card`,children:[(0,R.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:a},children:e.lines.map((e,i)=>{let a=OV(e,n);return(0,R.jsx)(`div`,{"data-file-code-canvas-row":`true`,"data-file-target-line":a?`true`:void 0,"aria-current":a?`location`:void 0,className:TV,children:(0,R.jsx)(BV,{language:o,line:e,target:a,targetColumn:a?t:null,targetRef:a&&(t||!r)?s:void 0})},kV(`code`,e,i))})}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 bg-card`})]})]})}function UV({block:e,layout:t=`compact`,targetColumn:n,targetLine:r}){if(t===`workspace`)return(0,R.jsx)(HV,{block:e,targetColumn:n,targetLine:r});let i=jV(e),a=MV(e),o=NV(e),s=i?`calc(${a} + ${o})`:o,c=FV(e);return(0,R.jsx)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`compact`,className:`overflow-x-auto custom-scrollbar bg-card`,children:(0,R.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:s},children:e.lines.map((e,t)=>(0,R.jsx)(VV,{language:c,line:e,showLineNumbers:i,lineNumberColumnWidth:a},kV(`row`,e,t)))})})}function WV({block:e}){return(0,R.jsx)(UV,{block:e,layout:`compact`})}function GV(e){return e.display===`preview`}function KV(e){return e.rawText?e.rawText:e.lines.map(e=>[e.kind,e.oldLineNumber??``,e.newLineNumber??``,e.text].join(`:`)).join(`
|
|
52
|
+
`))return(0,R.jsx)(`code`,{...r,className:B(`chat-inline-code`,t),children:n});let c=Dz(t)?Oz(s):null;return c?(0,R.jsx)(Pz,{display:c,renderInlineDisplay:a}):t?.split(` `).includes(`language-mermaid`)?(0,R.jsx)(Bz,{isStreaming:i,source:s,texts:o}):(0,R.jsx)(pz,{className:t,texts:o,children:n})}};function bB({text:e,role:t,texts:n,inline:r=!1,isStreaming:i=!1,inlineTokens:a,onFileOpen:o,onInlineTokenClick:s,resolveFileContentUrl:c,renderInlineDisplay:l}){let u=t===`user`,d=a?.length?[nR,hB(a)]:[nR],f=r?`span`:`div`;return(0,R.jsx)(_B.Provider,{value:{inline:r,isStreaming:i,isUser:u,onFileOpen:o,onInlineTokenClick:s,renderInlineDisplay:l,resolveFileContentUrl:c,texts:n},children:(0,R.jsx)(f,{className:B(`chat-markdown`,u?`chat-markdown-user`:`chat-markdown-assistant`),children:(0,R.jsx)(QP,{skipHtml:!0,remarkPlugins:d,components:yB,urlTransform:$z,children:cB(e)})})})}var xB={archive:`bg-muted text-muted-foreground`,audio:`bg-muted text-muted-foreground`,code:`bg-muted text-muted-foreground`,data:`bg-muted text-muted-foreground`,document:`bg-muted text-muted-foreground`,generic:`bg-muted text-muted-foreground`,image:`bg-muted text-muted-foreground`,pdf:`bg-muted text-muted-foreground`,sheet:`bg-muted text-muted-foreground`,video:`bg-muted text-muted-foreground`},SB=new Set([`c`,`cpp`,`css`,`go`,`html`,`java`,`js`,`jsx`,`md`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`svg`,`ts`,`tsx`]),CB=new Set([`graphql`,`json`,`toml`,`xml`,`yaml`,`yml`]),wB=new Set([`avif`,`bmp`,`gif`,`heic`,`heif`,`ico`,`jpeg`,`jpg`,`png`,`svg`,`tif`,`tiff`,`webp`]),TB=new Set([`aac`,`flac`,`m4a`,`mp3`,`ogg`,`opus`,`wav`,`weba`]),EB=new Set([`avi`,`m4v`,`mov`,`mp4`,`mkv`,`webm`,`wmv`]),DB=new Set([`doc`,`docx`,`odt`,`pages`,`rtf`,`txt`]),OB=new Set([`csv`,`numbers`,`ods`,`tsv`,`xls`,`xlsx`]),kB=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`zip`]);function AB(e){if(!Number.isFinite(e)||e==null||e<0)return null;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i).replace(/\.0$/,``)} ${t[r]}`}function jB(e,t){let n=MB(e);if(n)return n.toUpperCase();let r=(t.split(`/`)[1]??``).split(/[+.;-]/)[0]?.trim();return r?r.slice(0,6).toUpperCase():`FILE`}function MB(e){return/\.([a-z0-9]{1,12})$/i.exec(e.trim())?.[1]?.toLowerCase()??``}function NB(e){return typeof e==`string`&&/^data:image\//i.test(e.trim())}function PB(e){return wB.has(e)?e===`jpg`||e===`jpeg`?`image/jpeg`:e===`svg`?`image/svg+xml`:`image/${e}`:TB.has(e)?e===`mp3`?`audio/mpeg`:e===`m4a`?`audio/mp4`:e===`weba`?`audio/webm`:`audio/${e}`:EB.has(e)?e===`mov`?`video/quicktime`:e===`m4v`?`video/mp4`:`video/${e}`:e===`pdf`?`application/pdf`:null}function FB(e){let t=MB(e);return t?PB(t):null}function IB(e){let t=e.mimeType.trim().toLowerCase();return t.length>0&&t!==`application/octet-stream`?t:FB(e.label)}function LB(e){let t=e.mimeType.trim().toLowerCase(),n=MB(e.label);return e.isImage||t.startsWith(`image/`)||wB.has(n)||NB(e.dataUrl)}function RB(e,t){let n=MB(e),r=t.toLowerCase();return r.startsWith(`image/`)||wB.has(n)?`image`:r.startsWith(`audio/`)||TB.has(n)?`audio`:r.startsWith(`video/`)||EB.has(n)?`video`:r.includes(`pdf`)||n===`pdf`?`pdf`:kB.has(n)||/(zip|tar|gzip|rar|compressed|archive)/.test(r)?`archive`:OB.has(n)||/(spreadsheet|sheet|excel|csv)/.test(r)?`sheet`:CB.has(n)||/(json|xml|yaml|toml)/.test(r)?`data`:SB.has(n)||/(javascript|typescript|jsx|tsx|css|html)/.test(r)?`code`:DB.has(n)||/(msword|document|opendocument|rtf|text\/)/.test(r)?`document`:`generic`}function zB(e){let t=RB(e.label,e.mimeType),n=AB(e.sizeBytes);return{category:t,extension:jB(e.label,e.mimeType),sizeLabel:n}}var BB={archive:`Archive`,audio:`Audio`,code:`Code file`,data:`Data file`,document:`Document`,generic:`File`,image:`Image`,pdf:`PDF document`,sheet:`Spreadsheet`,video:`Video`},VB={archive:Ro,audio:zo,code:Bo,data:Ho,document:hn,generic:Go,image:Vo,pdf:hn,sheet:Uo,video:Wo};function HB(e,t){return t?.attachmentCategoryLabels?.[e]??BB[e]}function UB(e,t,n){return(0,R.jsx)(`div`,{className:B(`mt-0.5 text-[11px] leading-4`,n?`text-foreground/55`:`text-muted-foreground`),children:t?`${e} · ${t}`:e})}function WB(e,t,n){return(0,R.jsx)(`span`,{className:B(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-medium`,n?t?`bg-black/5 text-foreground/75`:`bg-muted text-muted-foreground`:t?`bg-black/[0.03] text-foreground/45`:`bg-muted/70 text-muted-foreground/70`),children:e})}function GB(e){let{label:t,href:n,isUser:r,onOpen:i}=e,a=B(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors`,r?`bg-black/5 text-foreground/75 hover:bg-black/10 hover:text-foreground`:`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`);return i?(0,R.jsx)(`button`,{type:`button`,className:a,onClick:e=>{e.preventDefault(),e.stopPropagation(),i()},children:t}):n?(0,R.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:a,children:t}):WB(t,r,!1)}function KB({category:e,isUser:t}){let n=VB[e];return(0,R.jsx)(`div`,{className:B(`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg`,t?`bg-black/5 text-foreground/70`:xB[e]),children:(0,R.jsx)(n,{className:B(`h-4 w-4`,t?`text-foreground/70`:`text-current`),strokeWidth:2})})}function qB(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:o}=e;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5 px-2.5 py-2`,children:[(0,R.jsx)(KB,{category:t,isUser:a}),(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-[13px] font-medium leading-5`,children:n.label}),UB(r,i,a)]}),o]})})]})}function JB(e){let{category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,shellClasses:o,actionLabel:s,onOpen:c}=e;if(!n.dataUrl||t!==`audio`&&t!==`video`)return null;let l=IB(n);return(0,R.jsxs)(`div`,{className:o,children:[qB({category:t,file:n,categoryLabel:r,sizeLabel:i,isUser:a,action:GB({label:s,href:n.dataUrl,isUser:a,onOpen:c?()=>c(n):void 0})}),(0,R.jsx)(`div`,{className:`px-2.5 pb-2.5`,children:t===`audio`?(0,R.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":n.label,className:`block w-full`,children:(0,R.jsx)(`source`,{src:n.dataUrl,...l?{type:l}:{}})}):(0,R.jsx)(`div`,{className:B(`overflow-hidden rounded-lg`,a?`bg-black/10`:`bg-muted ring-1 ring-border/70`),children:(0,R.jsx)(`video`,{controls:!0,preload:`metadata`,playsInline:!0,"aria-label":n.label,className:`block max-h-[28rem] w-full bg-black`,children:(0,R.jsx)(`source`,{src:n.dataUrl,...l?{type:l}:{}})})})})]})}function YB({file:e,isUser:t=!1,texts:n,onOpen:r}){let{category:i,sizeLabel:a}=zB(e),o=LB(e)&&!!e.dataUrl,s=i===`audio`&&!!e.dataUrl,c=i===`video`&&!!e.dataUrl,l=!!e.dataUrl,u=l?n?.attachmentOpenLabel??`Open`:n?.attachmentAttachedLabel??`Attached`,d=n?.attachmentExpandLabel??`Expand image`,f=n?.attachmentCloseLabel??`Close preview`,p=HB(i,n),m=B(`block overflow-hidden rounded-xl border transition-colors`,t?`border-black/8 bg-black/[0.03] text-foreground`:`border-border/70 bg-card text-card-foreground`,l&&(t?`hover:bg-black/[0.05]`:`hover:bg-muted/50`));if(o&&e.dataUrl)return(0,R.jsx)(Hz,{alt:e.label,expandLabel:d,closeLabel:f,sizeLabel:a,src:e.dataUrl});if(s||c)return JB({category:i,file:e,categoryLabel:p,sizeLabel:a,isUser:t,shellClasses:m,actionLabel:u,onOpen:r});let h=qB({category:i,file:e,categoryLabel:p,sizeLabel:a,isUser:t,action:WB(u,t,l)});return!l||!e.dataUrl?(0,R.jsx)(`div`,{className:m,children:h}):r?(0,R.jsx)(`button`,{type:`button`,className:B(m,`group w-full text-left`),onClick:()=>r(e),children:h}):(0,R.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,className:B(m,`group`),children:h})}function XB({group:e,indexOffset:t,isUser:n,texts:r,onOpen:i}){return(0,R.jsx)(`div`,{"data-chat-message-image-row":`three-column`,"data-chat-message-wide-content":`true`,className:`grid w-full grid-cols-3 items-start gap-3`,children:e.items.map(({index:e,part:a})=>(0,R.jsx)(YB,{file:a.file,isUser:n,texts:r,onOpen:i},`file-${t+e}`))})}function ZB(e){return!!(e?.kind===`part`&&e.part.type===`file`&&e.part.file.isImage&&e.part.file.dataUrl)}function QB(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(!ZB(r)){r&&t.push(r),n+=1;continue}let i=n,a=[];for(;ZB(e[n]);)a.push(e[n]),n+=1;if(a.length<3){t.push(...a);continue}t.push({kind:`image-group`,key:`image-group-${i}`,items:a})}return t}function $B(e){let{isInProgress:t}=e,[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(t);(0,L.useEffect)(()=>{let e=o.current;!e&&t?(r(!0),a(!1)):e&&!t&&!i&&r(!1),o.current=t},[t,i]);function s(e){e.preventDefault();let i=!n;if(r(i),!i){a(!1);return}t&&a(!0)}return{isOpen:n,onSummaryClick:s}}var eV=10;function tV({contentRef:e,contentVersion:t,hasContent:n,isLoading:r,resetKey:i,scrollRef:a,stickyThresholdPx:o}){let[s,c]=(0,L.useState)(!0),l=(0,L.useRef)(!0),u=(0,L.useRef)(null),d=(0,L.useRef)(!1),f=(0,L.useRef)(null),p=(0,L.useCallback)(e=>{l.current=e,c(e)},[]),m=(0,L.useCallback)(e=>e.scrollHeight-e.scrollTop-e.clientHeight<=(o??eV),[o]),h=(0,L.useCallback)(()=>{let e=f.current;e!==null&&(cancelAnimationFrame(e),f.current=null)},[]),g=(0,L.useCallback)((e=`auto`)=>{a.current&&(h(),f.current=requestAnimationFrame(()=>{f.current=null;let t=a.current;t&&(typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)}))},[h,a]),_=(0,L.useCallback)(()=>{p(!0),g()},[g,p]),v=(0,L.useCallback)(()=>{let e=a.current;if(!e)return;let t=m(e);t||h(),p(t)},[h,m,a,p]);return(0,L.useEffect)(()=>{u.current!==i&&(u.current=i,p(!0),d.current=!0)},[i,p]),(0,L.useEffect)(()=>h,[h]),(0,L.useEffect)(()=>{let t=e?.current;if(!t||!n||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{l.current&&g()});return r.observe(t),()=>r.disconnect()},[e,n,g,i]),(0,L.useLayoutEffect)(()=>{!d.current||r||!n||(d.current=!1,g())},[n,r,g]),(0,L.useLayoutEffect)(()=>{!l.current||!n||g()},[t,n,g]),{isAtBottom:s,onScroll:v,scrollToBottom:_}}var nV=`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-current`,rV=`group/process-row flex w-full min-w-0 items-center gap-1.5 py-0 text-[0.925rem] font-normal leading-[1.72] text-muted-foreground/80`;function iV({children:e,className:t}){return(0,R.jsx)(`span`,{className:B(nV,t),children:e})}function aV({position:e}){return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-tool-workflow-rail":`true`,className:B(`pointer-events-none absolute left-[0.575em] w-px -translate-x-1/2 bg-border/70`,e===`first`?`bottom-0 top-[0.86em]`:e===`last`?`top-0 h-[0.86em]`:`inset-y-0`)})}function oV({children:e,className:t,interactive:n=!1,onClick:r,role:i,tabIndex:a,onKeyDown:o}){return(0,R.jsx)(`div`,{"data-chat-process-meta-row":`true`,className:B(rV,n?`cursor-pointer transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`:null,t),onClick:r,role:i,tabIndex:a,onKeyDown:o,children:e})}function sV({label:e,openGroup:t,open:n=!1,icon:r,className:i,leadingIconClassName:a,labelClassName:o,onClick:s}){return(0,R.jsxs)(`button`,{type:`button`,"data-chat-process-meta-row":`true`,className:B(rV,`m-0 w-full border-0 bg-transparent p-0 text-left shadow-none transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`,i),"aria-expanded":n,onClick:s,children:[r?(0,R.jsx)(iV,{className:B(`relative z-[1] rounded-sm`,a),children:(0,R.jsx)(r,{className:`h-[1.05em] w-[1.05em]`,strokeWidth:2.25})}):null,(0,R.jsx)(`span`,{className:B(`min-w-0 shrink truncate`,o),children:e}),(0,R.jsx)(`span`,{className:B(`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-muted-foreground/80 transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/process-row:opacity-100 focus-visible:opacity-100`),children:(0,R.jsx)(wo,{className:B(`h-[1.05em] w-[1.05em] transition-transform`,n&&`rotate-90`),strokeWidth:2.25})})]})}function cV(e,t,n){let r=Array.from(t).length;return(n??`${e} · {count}`).split(`{count}`).join(String(r))}function lV({label:e,text:t,characterCountTemplates:n,isUser:r,isInProgress:i}){let{isOpen:a,onSummaryClick:o}=$B({isInProgress:i}),s=(0,L.useRef)(null),c=cV(e,t,i?n?.inProgress:n?.completed),{onScroll:l}=tV({scrollRef:s,resetKey:`reasoning`,isLoading:!1,hasContent:t.length>0,contentVersion:t,stickyThresholdPx:20});return(0,R.jsxs)(`div`,{className:`group/reasoning`,children:[(0,R.jsx)(sV,{openGroup:`reasoning`,open:a,icon:yo,leadingIconClassName:r?`bg-primary`:`bg-card`,label:c,labelClassName:r?`text-primary-100`:void 0,onClick:o}),a?(0,R.jsx)(`div`,{ref:s,onScroll:l,"data-reasoning-scroll":`true`,className:B(`mt-1 w-fit max-w-[500px] max-h-56 overflow-y-auto rounded-lg custom-scrollbar`,r?`bg-primary/70`:`bg-muted`),children:(0,R.jsx)(`pre`,{className:`min-w-0 whitespace-pre-wrap break-all p-2 text-[11px]`,children:t})}):null]})}function uV({children:e,className:t}){return(0,R.jsx)(`div`,{className:B(`relative my-0 flex w-full min-w-0 max-w-full flex-col text-[0.925rem] leading-[1.72] text-muted-foreground`,t),children:e})}function dV({children:e,className:t}){return(0,R.jsx)(`div`,{className:B(`mt-0.5 w-full max-w-full min-w-0 overflow-hidden pl-[calc(1.15em+0.375rem)] text-[0.925rem] leading-[1.72] text-muted-foreground`,t),children:e})}function fV({label:e,tone:t,children:n}){let r={input:{dot:`bg-muted-foreground/60`,body:`text-foreground`},output:{dot:`bg-primary/70`,body:`text-foreground`},error:{dot:`bg-rose-500/80`,body:`text-rose-950/85`}}[t];return(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-md border border-border/70 bg-muted/20`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-2.5 py-1.5 text-[10px] font-medium tracking-wide text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:B(`h-1.5 w-1.5 rounded-full`,r.dot)}),(0,R.jsx)(`span`,{className:`normal-case tracking-normal`,children:e})]}),(0,R.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,R.jsx)(`pre`,{className:B(`w-full max-w-full min-w-0 max-h-64 overflow-x-auto overflow-y-auto px-2.5 py-2 font-mono text-[12px] leading-relaxed whitespace-pre custom-scrollbar`,r.body),children:n})})]})}var pV={running:{text:`text-muted-foreground`,icon:zn,spin:!0},success:{text:`text-muted-foreground/75`,icon:cn,spin:!1},error:{text:`text-destructive`,icon:Ws,spin:!1},cancelled:{text:`text-muted-foreground/70`,icon:ys,spin:!1}};function mV({card:e,iconOnly:t=!1}){let n=pV[e.statusTone]||pV.cancelled,r=n.icon,i=!t&&(e.statusTone===`running`||e.statusTone===`error`);return(0,R.jsxs)(`span`,{className:B(`inline-flex shrink-0 items-center gap-1 text-[0.925rem] font-normal leading-[1.72]`,n.text),"aria-label":t?e.statusLabel:void 0,children:[(0,R.jsx)(r,{"aria-hidden":`true`,className:B(`h-[1.05em] w-[1.05em]`,n.spin&&`animate-spin`),strokeWidth:2.25}),i?e.statusLabel:null]})}function hV(e){return e.kind===`show-content`?{icon:wn,label:e.label,toneClassName:`border-border/70 bg-transparent text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-primary/35`}:{icon:mo,label:e.label??(e.sessionKind===`child`?`Open child session`:`Open session`),toneClassName:`border-border/70 bg-transparent text-muted-foreground hover:bg-muted/60 hover:text-foreground focus-visible:ring-primary/35`}}function gV({action:e,onAction:t}){let{Tooltip:n,TooltipContent:r,TooltipProvider:i,TooltipTrigger:a}=l_,o=hV(e),s=o.icon;return(0,R.jsx)(i,{delayDuration:250,children:(0,R.jsxs)(n,{children:[(0,R.jsx)(a,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:B(`inline-flex h-6 w-6 items-center justify-center rounded-md border transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1`,o.toneClassName),"aria-label":o.label,title:o.label,children:(0,R.jsx)(s,{className:`h-3.5 w-3.5`,strokeWidth:2.25})})}),(0,R.jsx)(r,{side:`top`,className:`text-xs`,children:o.label})]})})}function _V(e){return e.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim()}function vV(e,t){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),t())}function yV({label:e,summary:t}){return(0,R.jsxs)(`span`,{className:`min-w-0 shrink truncate`,children:[e,t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`mx-1.5 select-none text-muted-foreground/45`,children:`·`}),(0,R.jsx)(`span`,{title:t,children:t})]}):null]})}function bV({expanded:e}){return(0,R.jsx)(`span`,{className:B(`inline-flex h-[1.15em] w-[1.15em] shrink-0 items-center justify-center text-muted-foreground/80 transition-opacity`,e?`opacity-100`:`opacity-0 group-hover/process-row:opacity-100 group-focus-within/process-row:opacity-100`),children:(0,R.jsx)(wo,{className:B(`h-[1.05em] w-[1.05em] transition-transform`,e&&`rotate-90`),strokeWidth:2.25})})}function xV({additions:e,deletions:t}){if(e===0&&t===0)return null;let n=[e>0?`+${e}`:null,t>0?`-${t}`:null].filter(Boolean).join(` `);return(0,R.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground/75`,"aria-label":n,children:[e>0?(0,R.jsxs)(`span`,{className:`transition-colors group-hover/process-row:text-emerald-600`,children:[`+`,e]}):null,t>0?(0,R.jsxs)(`span`,{className:`transition-colors group-hover/process-row:text-rose-600`,children:[`-`,t]}):null]})}function SV({card:e,toolLabel:t,changeSummary:n,icon:r,expanded:i,canExpand:a,hideSummary:o=!1,actionSlot:s,onToggle:c}){let l=o?``:e.summary?.replace(/^(command|path|args|query|input):\s*/i,``)??``,u=t??_V(e.toolName);return(0,R.jsxs)(oV,{interactive:a,onClick:a?()=>c():void 0,role:a?`button`:void 0,tabIndex:a?0:void 0,onKeyDown:a?e=>vV(e,c):void 0,children:[(0,R.jsx)(iV,{className:`relative z-[1] rounded-sm bg-card`,children:(0,R.jsx)(r,{className:`h-[1.05em] w-[1.05em]`,strokeWidth:2.25})}),(0,R.jsx)(yV,{label:u,summary:l}),n?(0,R.jsx)(xV,{...n}):null,(0,R.jsx)(mV,{card:e,iconOnly:!!t}),a?(0,R.jsx)(bV,{expanded:i}):null,s?(0,R.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/process-row:opacity-100 group-focus-within/process-row:opacity-100`,children:s}):null]})}function CV({action:e,onAction:t}){return(0,R.jsx)(gV,{action:e,onAction:t})}var wV=`font-mono text-[11px] leading-5`,TV=`flex h-5 w-full ${wV}`,EV=`flex h-5 items-center justify-center px-2.5 tabular-nums select-none`;function DV(e){return String(e.newLineNumber??e.oldLineNumber??``)}function OV(e,t){return typeof t==`number`&&(e.newLineNumber??e.oldLineNumber)===t}function kV(e,t,n){return`${e}-${n}-${t.oldLineNumber??`x`}-${t.newLineNumber??`x`}`}function AV(e){return typeof e.newLineNumber==`number`||typeof e.oldLineNumber==`number`}function jV(e){return e.lines.some(AV)}function MV(e){let t=e.lines.reduce((e,t)=>AV(t)?Math.max(e,DV(t).length):e,0);return`${Math.max(6.5,Math.min(8,t+3.5))}ch`}function NV(e){return`calc(${e.lines.reduce((e,t)=>Math.max(e,Math.max(1,t.text.length)),1)}ch + 1.25rem)`}function PV(e){let t=e.split(/[\\/]/).filter(Boolean).pop()??e,n=t.split(/[?#]/)[0]??t,r=n.lastIndexOf(`.`);return r<=0||r===n.length-1?null:n.slice(r+1).toLowerCase()}function FV(e){return e.languageHint?.trim()||PV(e.path)||`text`}function IV(e){let t=e.toLowerCase().replace(/[^a-z0-9-]/g,`-`);return t?`language-${t}`:`language-text`}function LV(e){return e.kind===`remove`?`border-r border-rose-200 bg-rose-50 text-rose-700`:e.kind===`add`?`border-r border-emerald-200 bg-emerald-50 text-emerald-700`:`border-r border-border bg-muted text-muted-foreground`}function RV(e){return e.kind===`remove`?`bg-rose-50 text-rose-950`:e.kind===`add`?`bg-emerald-50 text-emerald-950`:`bg-card text-foreground`}function zV({layout:e,line:t,lineNumberColumnWidth:n,target:r,targetRef:i}){return(0,R.jsx)(`span`,{ref:i,"data-file-line-number-cell":`true`,style:e===`compact`?{width:n,minWidth:n}:void 0,className:B(EV,e===`compact`?`sticky left-0 z-[1]`:`w-full shrink-0`,LV(t),r?`bg-gray-200 font-medium text-gray-950`:null),children:DV(t)})}function BV({language:e,line:t,target:n,targetColumn:r,targetRef:i}){let a=(0,L.useMemo)(()=>cz.highlight(t.text||` `,e),[e,t.text]),o=typeof r==`number`&&Number.isSafeInteger(r)&&r>0?Math.min(r,t.text.length+1):null;return(0,R.jsxs)(`span`,{ref:o?void 0:i,"data-file-code-row":`true`,"data-file-code-language":a.language,"data-highlighted":a.highlighted?`true`:`false`,"data-file-target-column":o??void 0,className:B(`chat-file-code-syntax hljs relative block min-w-0 flex-1 whitespace-pre px-2.5`,IV(a.language),RV(t),n?`bg-gray-100/90`:null),children:[(0,R.jsx)(`span`,{dangerouslySetInnerHTML:{__html:a.html}}),o?(0,R.jsx)(`span`,{ref:i,"aria-hidden":`true`,"data-file-target-caret":`true`,className:`pointer-events-none absolute inset-y-0 w-px bg-primary`,style:{left:`calc(0.625rem + ${o-1}ch)`}}):null]})}function VV({language:e,line:t,showLineNumbers:n,lineNumberColumnWidth:r}){return(0,R.jsxs)(`div`,{"data-file-line-row":`true`,className:TV,children:[n?(0,R.jsx)(zV,{layout:`compact`,line:t,lineNumberColumnWidth:r}):null,(0,R.jsx)(BV,{language:e,line:t})]})}function HV({block:e,targetColumn:t,targetLine:n}){let r=jV(e),i=MV(e),a=NV(e),o=FV(e),s=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{s.current?.scrollIntoView({block:`center`,inline:t?`center`:`nearest`})},[e,t,n]),(0,R.jsxs)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`workspace`,className:`flex h-full min-h-full min-w-full bg-card`,children:[r?(0,R.jsxs)(`div`,{"data-file-code-gutter":`true`,style:{width:i,minWidth:i},className:B(`flex h-full min-h-full shrink-0 flex-col`,wV),children:[e.lines.map((e,r)=>(0,R.jsx)(zV,{layout:`workspace`,line:e,lineNumberColumnWidth:i,target:OV(e,n),targetRef:!t&&OV(e,n)?s:void 0},kV(`gutter`,e,r))),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 border-r border-border bg-muted`})]}):null,(0,R.jsxs)(`div`,{"data-file-code-canvas":`true`,className:`flex h-full min-h-full min-w-0 flex-1 flex-col bg-card`,children:[(0,R.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:a},children:e.lines.map((e,i)=>{let a=OV(e,n);return(0,R.jsx)(`div`,{"data-file-code-canvas-row":`true`,"data-file-target-line":a?`true`:void 0,"aria-current":a?`location`:void 0,className:TV,children:(0,R.jsx)(BV,{language:o,line:e,target:a,targetColumn:a?t:null,targetRef:a&&(t||!r)?s:void 0})},kV(`code`,e,i))})}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 bg-card`})]})]})}function UV({block:e,layout:t=`compact`,targetColumn:n,targetLine:r}){if(t===`workspace`)return(0,R.jsx)(HV,{block:e,targetColumn:n,targetLine:r});let i=jV(e),a=MV(e),o=NV(e),s=i?`calc(${a} + ${o})`:o,c=FV(e);return(0,R.jsx)(`div`,{"data-file-code-surface":`true`,"data-file-code-surface-layout":`compact`,className:`overflow-x-auto custom-scrollbar bg-card`,children:(0,R.jsx)(`div`,{"data-file-code-stack":`true`,className:`min-w-full`,style:{minWidth:s},children:e.lines.map((e,t)=>(0,R.jsx)(VV,{language:c,line:e,showLineNumbers:i,lineNumberColumnWidth:a},kV(`row`,e,t)))})})}function WV({block:e}){return(0,R.jsx)(UV,{block:e,layout:`compact`})}function GV(e){return e.display===`preview`}function KV(e){return e.rawText?e.rawText:e.lines.map(e=>[e.kind,e.oldLineNumber??``,e.newLineNumber??``,e.text].join(`:`)).join(`
|
|
53
53
|
`)}function qV(e){return/^\+\d+$/.test(e)?`text-emerald-700`:/^-\d+$/.test(e)?`text-rose-700`:`text-muted-foreground`}function JV(e){let t=e.split(`·`).map(e=>e.trim()).filter(e=>/^\+\d+$/.test(e)||/^-\d+$/.test(e));return t.length===0?null:(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-x-1 whitespace-nowrap text-[10px] font-medium uppercase tracking-[0.08em]`,children:t.map((e,t)=>(0,R.jsxs)(L.Fragment,{children:[t>0?(0,R.jsx)(`span`,{className:`text-muted-foreground/45`,children:`·`}):null,(0,R.jsx)(`span`,{className:B(qV(e)),children:e})]},`${e}-${t}`))})}function YV(e){return{path:e.path,label:e.path.split(`/`).filter(Boolean).pop()??e.path,viewMode:e.display===`diff`?`diff`:`preview`,...e.rawText?{rawText:e.rawText}:{},...e.beforeText?{beforeText:e.beforeText}:{},...e.afterText?{afterText:e.afterText}:{},...e.patchText?{patchText:e.patchText}:{},...typeof e.oldStartLine==`number`?{oldStartLine:e.oldStartLine}:{},...typeof e.newStartLine==`number`?{newStartLine:e.newStartLine}:{},fullLines:e.fullLines??e.lines}}function XV({children:e,contentVersion:t,resetKey:n,className:r,scrollKind:i}){let a=(0,L.useRef)(null),{onScroll:o}=tV({scrollRef:a,resetKey:n,isLoading:!1,hasContent:!0,contentVersion:t,stickyThresholdPx:20});return(0,R.jsx)(`div`,{ref:a,onScroll:o,"data-file-scroll-kind":i,className:B(`overflow-y-auto bg-card custom-scrollbar`,r),children:e})}function ZV({block:e,showPathRow:t,isFirst:n,onFileOpen:r}){let{Tooltip:i,TooltipContent:a,TooltipProvider:o,TooltipTrigger:s}=l_,c=GV(e),l=t||!!e.caption;return(0,R.jsxs)(`section`,{className:B(`overflow-hidden bg-card`,!n&&`border-t border-border`),children:[l?(0,R.jsxs)(`div`,{className:B(`flex min-h-9 items-center justify-between gap-4 border-b border-border px-3 text-muted-foreground`,t?`py-2`:`py-1.5`),children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,R.jsx)(o,{delayDuration:250,children:(0,R.jsxs)(i,{children:[(0,R.jsx)(s,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,onClick:()=>{r&&r(YV(e))},className:B(`w-full truncate whitespace-nowrap text-left font-mono text-[12px] font-medium leading-5 text-foreground`,r&&`transition-colors hover:text-primary hover:underline`),title:e.path,children:e.path})}),(0,R.jsx)(a,{side:`top`,className:`max-w-[420px] text-xs font-mono break-all`,children:e.path})]})}):null}),e.caption?JV(e.caption):null]}):null,e.lines.length>0?(0,R.jsx)(XV,{resetKey:`block:${e.key}`,contentVersion:KV(e),className:`max-h-72`,scrollKind:`block`,children:(0,R.jsx)(WV,{block:e})}):e.rawText?(0,R.jsx)(XV,{resetKey:`raw:${e.key}`,contentVersion:e.rawText,className:`max-h-72`,scrollKind:`raw`,children:(0,R.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar`,children:(0,R.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-card px-3 py-2 font-mono text-[11px] leading-5 text-foreground`,children:e.rawText})})}):null,e.truncated&&!c?(0,R.jsx)(`div`,{className:`border-t border-border bg-muted px-3 py-2 text-[10px] text-muted-foreground`,children:`Showing a shortened diff preview.`}):null]})}function QV({card:e,className:t,onFileOpen:n,showPathRow:r=!0}){let i=e.fileOperation?.blocks??[],a=e.output?.trim()??``;return i.length===0&&!a?null:(0,R.jsxs)(`div`,{className:B(`overflow-hidden rounded-md border border-border/70 bg-card`,t),children:[i.map((e,t)=>(0,R.jsx)(ZV,{block:e,showPathRow:r,isFirst:t===0,onFileOpen:n},e.key)),a?(0,R.jsx)(XV,{resetKey:`output:${e.toolName}:${e.summary??`none`}`,contentVersion:a,className:B(`max-h-56`,i.length>0&&`border-t border-border`),scrollKind:`output`,children:(0,R.jsx)(`div`,{className:`overflow-x-auto custom-scrollbar`,children:(0,R.jsx)(`pre`,{className:`min-w-max whitespace-pre bg-card px-3 py-2 font-mono text-[11px] leading-5 text-foreground`,children:a})})}):null]})}var $V=`\x1B`,eH=RegExp(`${$V}\\[(.*?)([ -/]*[@-~])`,`g`);function tH(e){return e.includes(`${$V}[`)}function nH(e){return e.replace(RegExp(`${$V}\\[[0-?]*[ -/]*[@-~]`,`g`),``)}function rH(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var iH={bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1},aH={1:{bold:!0},2:{dim:!0},3:{italic:!0},4:{underline:!0},7:{inverse:!0},22:{bold:!1,dim:!1},23:{italic:!1},24:{underline:!1},27:{inverse:!1},39:{fg:void 0},49:{bg:void 0}},oH={30:`black`,31:`red`,32:`green`,33:`yellow`,34:`blue`,35:`magenta`,36:`cyan`,37:`white`,90:`bright-black`,91:`bright-red`,92:`bright-green`,93:`bright-yellow`,94:`bright-blue`,95:`bright-magenta`,96:`bright-cyan`,97:`bright-white`},sH={40:`black`,41:`red`,42:`green`,43:`yellow`,44:`blue`,45:`magenta`,46:`cyan`,47:`white`,100:`bright-black`,101:`bright-red`,102:`bright-green`,103:`bright-yellow`,104:`bright-blue`,105:`bright-magenta`,106:`bright-cyan`,107:`bright-white`};function cH(e,t){let n=e[t+1];return n===5&&typeof e[t+2]==`number`?{color:`ansi-256-${e[t+2]}`,consumed:2}:n===2&&typeof e[t+2]==`number`&&typeof e[t+3]==`number`&&typeof e[t+4]==`number`?{color:`rgb(${e[t+2]},${e[t+3]},${e[t+4]})`,consumed:4}:null}function lH(e,t){let n={...e};for(let e=0;e<t.length;e+=1){let r=t[e];if(r===0)return{...iH};let i=aH[r];if(i){n={...n,...i};continue}if(r===38||r===48){let i=cH(t,e);i&&(n=r===38?{...n,fg:i.color}:{...n,bg:i.color},e+=i.consumed);continue}if(oH[r]){n={...n,fg:oH[r]};continue}sH[r]&&(n={...n,bg:sH[r]})}return n}function uH(e){let t=[`ansi`];return e.bold&&t.push(`ansi-bold`),e.dim&&t.push(`ansi-dim`),e.italic&&t.push(`ansi-italic`),e.underline&&t.push(`ansi-underline`),e.inverse&&t.push(`ansi-inverse`),e.fg&&(e.fg.startsWith(`rgb(`)?t.push(`ansi-fg-custom`):e.fg.startsWith(`ansi-256-`)?(t.push(`ansi-fg-256`),t.push(e.fg)):t.push(`ansi-fg-${e.fg}`)),e.bg&&(e.bg.startsWith(`rgb(`)?t.push(`ansi-bg-custom`):e.bg.startsWith(`ansi-256-`)?(t.push(`ansi-bg-256`),t.push(e.bg)):t.push(`ansi-bg-${e.bg}`)),t.join(` `)}function dH(e){let t=[];return e.fg?.startsWith(`rgb(`)&&t.push(`color:${e.fg}`),e.bg?.startsWith(`rgb(`)&&t.push(`background-color:${e.bg}`),t.length>0?t.join(`;`):void 0}function fH(e){let t=uH(e),n=dH(e);return n?`<span class="${t}" style="${n}">`:`<span class="${t}">`}function pH(e){if(!e)return``;if(!tH(e))return rH(e);let t=``,n=0,r={...iH},i=!1,a=e=>{e&&(i||=(t+=fH(r),!0),t+=rH(e))},o=()=>{i&&=(t+=`</span>`,!1)};return e.replace(eH,(t,i,s,c)=>{if(a(e.slice(n,c)),n=c+t.length,s!==`m`)return t;let l=i.trim().length===0?[0]:i.split(`;`).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e));return o(),r=lH(r,l.length>0?l:[0]),t}),a(e.slice(n)),o(),t}var mH=12e4;function hH(e){return e.length<=mH?e:`${e.slice(0,mH)}\n…`}function gH({code:e,language:t,preferAnsi:n=!1,className:r}){let i=hH(e),a=(0,L.useMemo)(()=>{if(n&&tH(i))return{html:pH(i),language:`ansi`,highlighted:!0};let e=nH(i);return cz.highlight(e,t)},[t,n,i]);return(0,R.jsx)(`code`,{className:B(`hljs chat-terminal-code`,`language-${a.language}`,r),"data-highlighted":a.highlighted?`true`:`false`,dangerouslySetInnerHTML:{__html:a.html}})}function _H({command:e,output:t,emptyLabel:n,isRunning:r,hasOutput:i,isError:a=!1}){return(0,R.jsx)(`div`,{className:B(`chat-terminal-surface`,a?`chat-terminal-surface-error`:void 0),"data-testid":`chat-terminal-surface`,children:(0,R.jsxs)(`div`,{className:`chat-terminal-body custom-scrollbar`,children:[(0,R.jsxs)(`div`,{className:`chat-terminal-line chat-terminal-line-command`,children:[(0,R.jsx)(`span`,{className:`chat-terminal-gutter`,"aria-hidden":`true`,children:`$`}),(0,R.jsx)(`div`,{className:`chat-terminal-line-content`,children:e?(0,R.jsxs)(`pre`,{className:`chat-terminal-pre`,children:[(0,R.jsx)(gH,{code:e,language:`bash`}),r&&!i?(0,R.jsx)(`span`,{className:`chat-terminal-caret`,"aria-hidden":`true`}):null]}):(0,R.jsx)(`div`,{className:`chat-terminal-skeleton`})})]}),(i||!r)&&(0,R.jsx)(`div`,{className:`chat-terminal-output-block`,children:i?(0,R.jsxs)(`pre`,{className:B(`chat-terminal-pre chat-terminal-output`,a?`chat-terminal-pre-error`:void 0),children:[(0,R.jsx)(gH,{code:t,language:a?`text`:`shell`,preferAnsi:!0,className:a?`chat-terminal-code-error`:void 0}),r?(0,R.jsx)(`span`,{className:`chat-terminal-caret`,"aria-hidden":`true`}):null]}):(0,R.jsx)(`div`,{className:`chat-terminal-empty`,children:n})})]})})}var vH=200;function yH(e){return typeof e==`string`&&e.length>0?e:null}function bH(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xH(e){return`command`in e||`workingDir`in e||`exitCode`in e||`durationMs`in e||`stdout`in e||`stderr`in e||`aggregated_output`in e||`combinedOutput`in e}function SH(e){let t=yH(e.aggregated_output)??yH(e.combinedOutput)??yH(e.output);if(t)return t;let n=yH(e.stdout),r=yH(e.stderr);return!n&&!r?null:[n,r].filter(e=>!!e).join(`
|
|
54
54
|
`)}function CH(e,t){if(bH(t)){let e=SH(t);if(e)return e;if(xH(t))return``}if(!e)return``;let n=e.trim();if(!n.startsWith(`{`))return e;try{let t=JSON.parse(n);return bH(t)?SH(t)||(xH(t)?``:e):e}catch{return e}}function wH(e){return e===`write_file`||e===`edit_file`}function TH(e){return e.reduce((e,t)=>({additions:e.additions+t.lines.filter(e=>e.kind===`add`).length,deletions:e.deletions+t.lines.filter(e=>e.kind===`remove`).length}),{additions:0,deletions:0})}function EH({canExpand:e,isRunning:t,autoExpandWhileRunning:n=!0,expandOnError:r=!1,statusTone:i}){let[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(!1),l=(0,L.useRef)(null),u=(0,L.useRef)(t),d=(0,L.useRef)(!0);return(0,L.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),(0,L.useEffect)(()=>{if(r&&i===`error`&&e&&!s){l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(!0),u.current=t,d.current=!1;return}n&&t&&e&&!s&&!a&&(d.current||!u.current)&&(l.current=window.setTimeout(()=>{o(!0),l.current=null},vH)),t||(l.current!==null&&(window.clearTimeout(l.current),l.current=null),u.current&&!s&&o(!1)),u.current=t,d.current=!1},[n,e,r,a,s,t,i]),{expanded:a,onToggle:()=>{e&&(l.current!==null&&(window.clearTimeout(l.current),l.current=null),o(e=>!e),c(!0))}}}function DH(e){return bH(e)?{exitCode:typeof e.exitCode==`number`?e.exitCode:typeof e.exit_code==`number`?e.exit_code:null,workingDir:yH(e.workingDir)??yH(e.cwd)??yH(e.working_directory)}:{}}function OH({card:e,toolLabel:t}){let n=CH(e.output,e.outputData),r=e.statusTone===`running`,i=e.summary?.replace(/^(command|path|args|query|input):\s*/i,``),a=n.trim().length>0,o=r||a||!!i?.trim(),s=DH(e.outputData),{expanded:c,onToggle:l}=EH({canExpand:o,isRunning:r,autoExpandWhileRunning:!1,expandOnError:o,statusTone:e.statusTone});return(0,R.jsxs)(uV,{children:[(0,R.jsx)(SV,{card:e,toolLabel:t,icon:Us,expanded:c,canExpand:o,onToggle:l}),c&&(0,R.jsx)(dV,{className:`bg-transparent py-0`,children:(0,R.jsx)(_H,{command:i,output:n,emptyLabel:e.emptyLabel,isRunning:r,hasOutput:a,isError:e.statusTone===`error`,exitCode:s.exitCode,workingDir:s.workingDir})})]})}function kH({card:e,toolLabel:t,onFileOpen:n}){let r=e.input?.trim()??``,i=e.output?.trim()??``,a=e.statusTone===`running`,o=!!e.fileOperation?.blocks.length,s=!!r&&!o,c=o||!!r||!!i,l=e.fileOperation?.blocks??[],u=l.reduce((e,t)=>e+t.lines.length,0),d=l.reduce((e,t)=>t.rawText?e+t.rawText.length:e+t.lines.reduce((e,t)=>e+t.text.length+1,0),0),f=wH(e.toolName)&&!(a&&e.toolName===`write_file`&&(u>24||d>1200)),{expanded:p,onToggle:m}=EH({canExpand:c||a,isRunning:a,autoExpandWhileRunning:f,expandOnError:c,statusTone:e.statusTone}),h=e.toolName===`edit_file`||e.toolName===`write_file`||e.toolName===`apply_patch`||e.toolName===`file_change`;return(0,R.jsxs)(uV,{children:[(0,R.jsx)(SV,{card:e,toolLabel:t,changeSummary:h?TH(l):void 0,icon:h?jo:hn,expanded:p,canExpand:c||a,hideSummary:!1,onToggle:m}),p&&c?(0,R.jsxs)(dV,{className:`bg-transparent py-0`,children:[s?(0,R.jsx)(fV,{label:e.inputLabel?.trim()||`Input`,tone:`input`,children:r}):null,s&&i?(0,R.jsx)(`div`,{className:`h-2`}):null,o||i?(0,R.jsx)(QV,{card:e,onFileOpen:n,showPathRow:!0}):null]}):null]})}function AH({card:e,toolLabel:t,icon:n=xt}){let r=e.statusTone===`running`,i=e.output?.trim()??``,{expanded:a,onToggle:o}=EH({canExpand:!!i||r,isRunning:r,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,R.jsxs)(uV,{children:[(0,R.jsx)(SV,{card:e,toolLabel:t,icon:n,expanded:a,canExpand:!!i||r,onToggle:o}),a&&i&&(0,R.jsx)(dV,{className:`py-0`,children:(0,R.jsx)(`pre`,{className:`font-mono text-[12px] text-muted-foreground whitespace-pre-wrap break-all w-full max-w-full max-h-64 overflow-y-auto overflow-x-hidden min-w-0 custom-scrollbar leading-relaxed`,children:i})})]})}function jH(e,t,n){let r=e.agentId&&n?n(e.agentId):null,i=e.action&&t?(0,R.jsx)(CV,{action:e.action,onAction:t}):null;return r||i?(0,R.jsxs)(R.Fragment,{children:[r,i]}):void 0}function MH({card:e,toolLabel:t,icon:n=Ys,onToolAction:r,renderToolAgent:i}){let a=e.input?.trim()??``,o=e.output?.trim()??``,s=e.statusTone===`running`,c=a.length>0,l=o.length>0,u=c||l,d=jH(e,r,i),{expanded:f,onToggle:p}=EH({canExpand:u||s,isRunning:s,autoExpandWhileRunning:!1,statusTone:e.statusTone});return(0,R.jsxs)(uV,{children:[(0,R.jsx)(SV,{card:e,toolLabel:t,icon:n,expanded:f,canExpand:u||s,actionSlot:d,onToggle:p}),f&&u?(0,R.jsxs)(dV,{className:`bg-transparent py-0`,children:[c?(0,R.jsx)(fV,{label:e.inputLabel?.trim()||`Input`,tone:`input`,children:a}):null,c&&l?(0,R.jsx)(`div`,{className:`h-2`}):null,l?(0,R.jsx)(fV,{label:e.outputLabel?.trim()||`Output`,tone:e.statusTone===`error`?`error`:`output`,children:o}):null]}):null]})}function NH({card:e,onToolAction:t,renderPanelAppCard:n}){let{panelApp:r}=e;return r&&n?n(r):(0,R.jsx)(MH,{card:e,onToolAction:t})}function PH(e){let t=e.toLowerCase();return t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t.includes(`run_`)}function FH(e){let t=e.toLowerCase();return t===`read_file`||t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function IH(e){let t=e.toLowerCase();return t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`}function LH(e){let t=e.toLowerCase();return t===`grep_search`||t===`find_files`||t.includes(`search`)}var RH={list_dir:{statusKind:`directory`,icon:Xo},web_fetch:{statusKind:`web`,icon:Io},message:{statusKind:`message`,icon:Ns},sessions_list:{statusKind:`session`,icon:Nn},sessions_history:{statusKind:`session`,icon:Nn},sessions_request:{statusKind:`session`,icon:Nn},spawn:{statusKind:`agent`,icon:go},sessions_spawn:{statusKind:`agent`,icon:go},subagents:{statusKind:`agent`,icon:go},memory_search:{statusKind:`memory`,icon:yo},memory_get:{statusKind:`memory`,icon:yo},cron:{statusKind:`schedule`,icon:bo},gateway:{statusKind:`system`,icon:jn},view_image:{statusKind:`image`,icon:os},show_file:{statusKind:`display`,icon:wn},show_url:{statusKind:`display`,icon:wn},show_panel_app:{statusKind:`display`,icon:wn},show_content:{statusKind:`display`,icon:wn}};function zH(e){return RH[e.toLowerCase()]??null}function BH({card:e,toolStatusLabels:t,onToolAction:n,onFileOpen:r,renderToolAgent:i,renderPanelAppCard:a}){if(e.panelApp)return(0,R.jsx)(NH,{card:e,onToolAction:n,renderPanelAppCard:a});let o=zH(e.toolName),s=o?t?.builtIn?.[o.statusKind]?.[e.statusTone]:void 0;return PH(e.toolName)?(0,R.jsx)(OH,{card:e,toolLabel:t?.terminal[e.statusTone]}):FH(e.toolName)?(0,R.jsx)(kH,{card:e,toolLabel:IH(e.toolName)?t?.fileEdit[e.statusTone]:t?.fileRead[e.statusTone],onFileOpen:r}):LH(e.toolName)?(0,R.jsx)(AH,{card:e,toolLabel:s??t?.search[e.statusTone],icon:o?.icon}):(0,R.jsx)(MH,{card:e,toolLabel:s,icon:o?.icon,onToolAction:n,renderToolAgent:i})}function VH({group:e,open:t,isUser:n,reasoningCharacterCountTemplates:r,toolStatusLabels:i,onToolAction:a,onFileOpen:o,renderToolAgent:s,renderPanelAppCard:c,onOpenChange:l}){let u=e.parts.filter(e=>e.type===`tool-card`).length,d=t&&u>1;return(0,R.jsxs)(`div`,{className:`group/tool-activity`,children:[(0,R.jsx)(sV,{openGroup:`tool-activity`,open:t,icon:Js,leadingIconClassName:`bg-card`,label:e.label,onClick:()=>l(!t)}),t?(0,R.jsx)(`div`,{className:`text-[0.925rem] leading-[1.72]`,children:e.parts.map((t,l)=>{let u=l===e.parts.length-1;return(0,R.jsxs)(`div`,{className:`relative min-w-0`,children:[d?(0,R.jsx)(aV,{position:l===0?`first`:u?`last`:`middle`}):null,t.type===`tool-card`?(0,R.jsx)(BH,{card:t.card,toolStatusLabels:i,onToolAction:a,onFileOpen:o,renderToolAgent:s,renderPanelAppCard:c}):(0,R.jsx)(lV,{label:t.label,text:t.text,characterCountTemplates:r,isUser:n,isInProgress:!1})]},`tool-group-item-${e.startIndex+l}`)})}):null]})}var HH=3;function UH(e){return e.type===`tool-card`}function WH(e){return e?.type===`reasoning`||e?.type===`tool-card`&&!e.card.panelApp}function GH(e){let t=e.toLowerCase();return t===`list_dir`?`directory`:t.includes(`show_content`)||t.includes(`panel_app`)||t.includes(`panel`)?`panel`:t===`spawn`||t.includes(`subagent`)||t.includes(`session_request`)||t.includes(`agent`)&&!t.includes(`read`)?`agent`:t.includes(`web_`)||t.includes(`_web`)||t.includes(`url`)||t.includes(`fetch`)||t.includes(`http`)?`web`:t===`grep_search`||t===`find_files`||t===`search_files`||t.includes(`search`)||t.includes(`grep`)?`search`:t===`exec`||t===`exec_command`||t===`execute_command`||t===`command_execution`||t===`bash`||t===`shell`||t===`terminal`||t.includes(`run_`)?`bash`:t===`write_file`||t===`edit_file`||t===`apply_patch`||t===`file_change`||t===`multi_replace`||t.includes(`write_file`)||t.includes(`edit_file`)||t.includes(`apply_patch`)?`edit`:t===`read_file`||t===`read`||t===`view_file`||t.includes(`read_file`)||t.startsWith(`read_`)?`read`:`other`}function KH(e){return e===`error`?0:e===`cancelled`?1:e===`running`?2:3}function qH(e,t,n){if(t!==`read`&&t!==`edit`&&t!==`directory`)return[`call:${n}`];let r=e.fileOperation?.blocks.map(({path:e})=>e.trim()).filter(Boolean),i=e.summary?.replace(/^(path|file):\s*/i,``).trim();return r?.length?r:[i||`call:${n}`]}function JH(e,t){let n=t.segmentTemplates[e.family],r=e.count===1?n.one:n.other.split(`{count}`).join(String(e.count));return e.tone===`error`?`${r} ${t.failedLabel}`:e.tone===`cancelled`?`${r} ${t.cancelledLabel}`:r}function YH(e){let t=[],n=new Map;for(let[r,i]of e.entries()){let e=GH(i.toolName),a=qH(i,e,r),o=n.get(e);if(!o){t.push(e),n.set(e,{units:new Set(a),tone:i.statusTone});continue}a.forEach(e=>o.units.add(e)),KH(i.statusTone)<KH(o.tone)&&(o.tone=i.statusTone)}let r=t.map(e=>{let t=n.get(e);return{family:e,count:t.units.size,tone:t.tone}});return r.sort((e,n)=>{let r=KH(e.tone)-KH(n.tone);return r===0?t.indexOf(e.family)-t.indexOf(n.family):r}),r}function XH(e){let{labels:t,segments:n}=e;if(n.length===0)return``;let r=n.slice(0,HH),i=n.length-r.length,a=r.map(e=>JH(e,t));return i>0&&a.push(`+${i}`),a.join(` · `)}function ZH(e,t){let n=[],r=t,i=-1;for(;;){let t=e[r];if(!WH(t))break;n.push(t),t.type===`tool-card`&&(i=n.length-1),r+=1}return{candidateParts:n,lastToolOffset:i}}function QH(e,t){let n=[],r=0;for(;r<e.length;){let i=e[r];if(i.type!==`tool-card`||i.card.panelApp){n.push({kind:`part`,key:`part-${r}`,index:r,part:i}),r+=1;continue}let a=r,{candidateParts:o,lastToolOffset:s}=ZH(e,a),c=o.filter(UH);if(c.length===1){n.push({kind:`part`,key:`part-${a}`,index:a,part:i}),r=a+1;continue}let l=o.slice(0,s+1);r=a+l.length;let u=YH(c.map(e=>e.card)),d=XH({segments:u,labels:t});n.push({kind:`tool-group`,key:`tool-group-${a}`,group:{key:`tool-group-${a}`,startIndex:a,endIndex:r-1,parts:l,segments:u,label:d}})}return n}var $H={segmentTemplates:{read:{one:`Read 1 file`,other:`Read {count} files`},edit:{one:`Edit 1 file`,other:`Edit {count} files`},directory:{one:`View 1 directory`,other:`View {count} directories`},search:{one:`Search 1 time`,other:`Search {count} times`},bash:{one:`Run 1 command`,other:`Run {count} commands`},web:{one:`Open 1 page`,other:`Open {count} pages`},agent:{one:`Start 1 subtask`,other:`Start {count} subtasks`},panel:{one:`Show 1 result`,other:`Show {count} results`},other:{one:`Use 1 tool`,other:`Use {count} tools`}},failedLabel:`failed`,cancelledLabel:`cancelled`};function eU(e){return{segmentTemplates:{...$H.segmentTemplates,...e.toolActivitySegmentTemplates??{}},failedLabel:e.toolActivityFailedLabel??$H.failedLabel,cancelledLabel:e.toolActivityCancelledLabel??$H.cancelledLabel}}function tU(e){return e===`pending`||e===`streaming`}function nU(e){return e.type===`reasoning`||e.type===`tool-card`}function rU(e){if(e.role!==`assistant`||!e.processSummary||tU(e.status))return null;let t=-1;for(let n=e.parts.length-1;n>=0;--n)if(nU(e.parts[n])){t=n;break}return t<0||t>=e.parts.length-1?null:{processParts:e.parts.slice(0,t+1),finalParts:e.parts.slice(t+1)}}function iU({index:e,isInProgress:t,isLastPart:n,isUser:r,onAttachmentOpen:i,onFileOpen:a,onInlineTokenClick:o,onToolAction:s,part:c,renderInlineDisplay:l,renderPanelAppCard:u,renderToolAgent:d,resolveFileContentUrl:f,role:p,texts:m}){let{type:h}=c;if(h===`markdown`){let{inlineTokens:r,text:i}=c;return(0,R.jsx)(bB,{text:i,role:p,texts:m,isStreaming:t&&n,inlineTokens:r,onFileOpen:a,onInlineTokenClick:o,resolveFileContentUrl:f,renderInlineDisplay:l},`markdown-${e}`)}if(h===`reasoning`){let{label:i,text:a}=c;return(0,R.jsx)(lV,{label:i,text:a,characterCountTemplates:m.reasoningCharacterCountTemplates,isUser:r,isInProgress:t&&n},`reasoning-${e}`)}if(h===`tool-card`){let{card:t}=c;return(0,R.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,R.jsx)(aV,{position:`single`}),(0,R.jsx)(BH,{card:t,toolStatusLabels:m.toolStatusLabels,onToolAction:s,onFileOpen:a,renderToolAgent:d,renderPanelAppCard:u})]},`tool-${e}`)}if(h===`file`){let{file:t}=c;return(0,R.jsx)(YB,{file:t,isUser:r,texts:m,onOpen:i},`file-${e}`)}if(h===`unknown`){let{label:t,rawType:n,text:r}=c;return(0,R.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/60 px-2.5 py-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`div`,{className:`font-semibold text-foreground`,children:[t,`: `,n]}),r?(0,R.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground`,children:r}):null]},`unknown-${e}`)}return null}function aU(e){let{isInProgress:t,isUser:n,onAttachmentOpen:r,onFileOpen:i,onInlineTokenClick:a,onToolActivityOpenChange:o,onToolAction:s,openToolGroupKeys:c,parts:l,renderInlineDisplay:u,renderPanelAppCard:d,renderToolAgent:f,resolveFileContentUrl:p,role:m,texts:h,indexOffset:g=0}=e;return QB(QH(l,eU(h))).map(e=>e.kind===`image-group`?(0,R.jsx)(XB,{group:e,indexOffset:g,isUser:n,texts:h,onOpen:r},`${e.key}-${g}`):e.kind===`tool-group`?(0,R.jsx)(VH,{group:e.group,open:c.has(e.group.key),isUser:n,reasoningCharacterCountTemplates:h.reasoningCharacterCountTemplates,toolStatusLabels:h.toolStatusLabels,onToolAction:s,onFileOpen:i,renderToolAgent:f,renderPanelAppCard:d,onOpenChange:t=>o(e.group.key,t)},e.key):iU({part:e.part,index:g+e.index,role:m,isUser:n,isInProgress:t,isLastPart:g+e.index===g+l.length-1,texts:h,onToolAction:s,onFileOpen:i,onAttachmentOpen:r,onInlineTokenClick:a,resolveFileContentUrl:p,renderInlineDisplay:u,renderToolAgent:f,renderPanelAppCard:d}))}var oU=(0,L.memo)(function({layout:e,message:t,texts:n,onToolAction:r,onFileOpen:i,onAttachmentOpen:a,onInlineTokenClick:o,renderInlineDisplay:s,renderToolAgent:c,renderPanelAppCard:l,resolveFileContentUrl:u}){let{role:d}=t,f=d===`user`,p=e===`flat`&&!f,m=tU(t.status),h=rU(t),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(()=>new Set),b=(e,t)=>{y(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),t&&_(!0)};return(0,R.jsx)(`div`,{"data-chat-message-surface":p?`flat`:`card`,className:B(`max-w-full has-[[data-chat-message-wide-content=true]]:w-full`,p?`block w-full text-foreground`:`inline-block w-fit rounded-2xl border px-4 shadow-sm`,!p&&(f?`nextclaw-chat-message-user rounded-[1.45rem] border-primary bg-primary py-2.5 text-primary-foreground shadow-none`:d===`assistant`?`border-border bg-card pb-3 pt-4 text-card-foreground`:`border-border bg-muted/45 py-3 text-foreground`)),children:(0,R.jsx)(`div`,{className:`space-y-0`,children:h?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`group/process`,children:[(0,R.jsx)(`div`,{className:`mb-2 border-b border-border/60 pb-2`,children:(0,R.jsx)(sV,{openGroup:`process`,open:g,icon:ds,leadingIconClassName:`bg-card`,label:t.processSummary?.label,onClick:()=>_(e=>!e)})}),g?(0,R.jsx)(`div`,{className:`space-y-0`,children:aU({parts:h.processParts,role:d,isUser:f,isInProgress:m,texts:n,onToolAction:r,onFileOpen:i,onAttachmentOpen:a,onInlineTokenClick:o,resolveFileContentUrl:u,openToolGroupKeys:v,onToolActivityOpenChange:b,renderInlineDisplay:s,renderToolAgent:c,renderPanelAppCard:l})}):null]}),aU({parts:h.finalParts,role:d,isUser:f,isInProgress:m,texts:n,onToolAction:r,onFileOpen:i,onAttachmentOpen:a,onInlineTokenClick:o,resolveFileContentUrl:u,openToolGroupKeys:v,onToolActivityOpenChange:b,renderInlineDisplay:s,renderToolAgent:c,renderPanelAppCard:l,indexOffset:h.processParts.length})]}):aU({parts:t.parts,role:d,isUser:f,isInProgress:m,texts:n,onToolAction:r,onFileOpen:i,onAttachmentOpen:a,onInlineTokenClick:o,resolveFileContentUrl:u,openToolGroupKeys:v,onToolActivityOpenChange:b,renderInlineDisplay:s,renderToolAgent:c,renderPanelAppCard:l})})})});function sU({messageText:e,texts:t}){let{copied:n,copy:r}=_R({text:e}),i=n?t.copiedMessageLabel:t.copyMessageLabel,{Tooltip:a,TooltipContent:o,TooltipProvider:s,TooltipTrigger:c}=l_;return e?(0,R.jsx)(s,{delayDuration:250,children:(0,R.jsxs)(a,{children:[(0,R.jsx)(c,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void r(),className:`flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`,"aria-label":i,children:n?(0,R.jsx)(cn,{className:`h-3.5 w-3.5`}):(0,R.jsx)(No,{className:`h-3.5 w-3.5`})})}),(0,R.jsx)(o,{side:`top`,className:`text-xs`,children:i})]})}):null}function cU({action:e,open:t,onOpenChange:n,restoreFocusRef:r}){let{Dialog:i,DialogContent:a,DialogDescription:o,DialogHeader:s,DialogTitle:c}=l_;return(0,R.jsx)(i,{open:t,onOpenChange:n,children:(0,R.jsxs)(a,{className:`sm:max-w-xl`,closeLabel:e.dialog.closeLabel,onCloseAutoFocus:e=>{e.preventDefault(),r.current?.focus()},children:[(0,R.jsxs)(s,{className:`space-y-1 pr-8 text-left`,children:[(0,R.jsx)(c,{className:`text-lg font-semibold leading-tight text-foreground`,children:e.dialog.title}),e.dialog.description?(0,R.jsx)(o,{className:`text-sm leading-relaxed text-muted-foreground`,children:e.dialog.description}):null]}),(0,R.jsx)(`dl`,{className:`divide-y divide-border/70 rounded-xl border border-border/80 bg-muted/20 px-4`,children:e.dialog.rows.map(e=>(0,R.jsxs)(`div`,{className:`grid gap-1 py-3 sm:grid-cols-[11rem_minmax(0,1fr)] sm:gap-4`,children:[(0,R.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-xs leading-5 text-foreground`,children:e.value})]},e.label))})]})})}function lU({message:e}){let[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(null),s=(0,L.useRef)(null),{moreActions:c}=e,{Popover:l,PopoverContent:u,PopoverTrigger:d,Tooltip:f,TooltipContent:p,TooltipProvider:m,TooltipTrigger:h}=l_;return c?.items.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(l,{open:t,onOpenChange:n,children:[(0,R.jsx)(m,{delayDuration:250,children:(0,R.jsxs)(f,{children:[(0,R.jsx)(h,{asChild:!0,children:(0,R.jsx)(d,{asChild:!0,children:(0,R.jsx)(`button`,{ref:s,type:`button`,"aria-label":c.triggerLabel,className:`flex items-center justify-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/35`,children:(0,R.jsx)(Cn,{className:`h-3.5 w-3.5`})})})}),(0,R.jsx)(p,{side:`top`,className:`text-xs`,children:c.triggerLabel})]})}),(0,R.jsx)(u,{align:`end`,className:`w-52 p-1`,role:`menu`,children:c.items.map(e=>(0,R.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex w-full items-center rounded-lg px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent focus-visible:bg-accent focus-visible:outline-none`,onClick:()=>{n(!1),o(e),i(!0)},children:e.label},e.key))})]}),a?(0,R.jsx)(cU,{action:a,open:r,onOpenChange:i,restoreFocusRef:s}):null]}):null}function uU({message:e,texts:t}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,R.jsx)(sU,{messageText:(0,L.useMemo)(()=>e.parts.map(e=>e.type===`markdown`||e.type===`unknown`?e.text:``).filter(e=>!!e?.trim()).join(`
|
|
55
55
|
|
package/ui-dist/assets/{appearance-settings-page-BZSd1SrH.js → appearance-settings-page-Byr55LGb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{h as t,i as n,p as r,r as i,u as a}from"./react-B0LbRnAE.js";import{S as o,T as s,a as c,v as l}from"./app-presenter-provider-
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{h as t,i as n,p as r,r as i,u as a}from"./react-B0LbRnAE.js";import{S as o,T as s,a as c,v as l}from"./app-presenter-provider-Dp90n1Va.js";import{Qt as u,Xt as d,Yt as f,Zt as p,wt as m}from"./api-DGG69ZcJ.js";import{a as h,i as g,n as _,r as v,t as y,w as b}from"./select-CYHT8P5S.js";import{r as x}from"./use-confirm-dialog-WZ94CehU.js";var S=e(t(),1);function C(){let{language:e,setLanguage:t}=x();return{currentLanguage:e,currentLanguageLabel:n.find(t=>t.value===e)?.label??e,languageOptions:n,selectLanguage:(0,S.useCallback)(n=>{e!==n&&(t(n),window.location.reload())},[e,t])}}var w=r(),T=[{value:`card`,labelKey:`chatMessageLayoutCard`,descriptionKey:`chatMessageLayoutCardDescription`},{value:`flat`,labelKey:`chatMessageLayoutFlat`,descriptionKey:`chatMessageLayoutFlatDescription`}];function E(){let{theme:e,setTheme:t}=l(),{currentLanguage:n,languageOptions:r,selectLanguage:x}=C(),S=s(e=>e.layout),E=s(e=>e.setLayout),D=c(e=>e.isVisible),O=c(e=>e.setVisible);return(0,w.jsx)(u,{title:i(`appearance`),children:(0,w.jsx)(p,{children:(0,w.jsxs)(d,{children:[(0,w.jsx)(f,{title:i(`theme`),control:(0,w.jsxs)(y,{value:e,onValueChange:e=>t(e),children:[(0,w.jsx)(g,{"aria-label":i(`theme`),className:`w-36 sm:w-44`,children:(0,w.jsx)(h,{})}),(0,w.jsx)(_,{children:o.map(e=>(0,w.jsx)(v,{value:e.value,children:i(e.labelKey)},e.value))})]})}),(0,w.jsx)(f,{title:i(`language`),control:(0,w.jsxs)(y,{value:n,onValueChange:e=>x(e),children:[(0,w.jsx)(g,{"aria-label":i(`language`),className:`w-36 sm:w-44`,children:(0,w.jsx)(h,{})}),(0,w.jsx)(_,{children:r.map(e=>(0,w.jsx)(v,{value:e.value,children:e.label},e.value))})]})}),(0,w.jsx)(f,{title:i(`chatMessageLayoutTitle`),description:i(`chatMessageLayoutDescription`),layout:`stacked`,children:(0,w.jsx)(`div`,{role:`radiogroup`,"aria-label":i(`chatMessageLayoutTitle`),className:`grid gap-1 rounded-xl bg-background/65 p-1 sm:grid-cols-2`,children:T.map(e=>{let t=e.value===S;return(0,w.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>E(e.value),className:a(`flex min-w-0 items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,t?`bg-card text-foreground shadow-sm`:`text-muted-foreground hover:bg-card/60 hover:text-foreground`),children:[(0,w.jsx)(`span`,{className:a(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full ring-1`,t?`bg-primary text-primary-foreground ring-primary`:`bg-background ring-border`),children:t?(0,w.jsx)(b,{className:`h-2.5 w-2.5`,strokeWidth:3}):null}),(0,w.jsxs)(`span`,{className:`min-w-0`,children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium`,children:i(e.labelKey)}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-muted-foreground`,children:i(e.descriptionKey)})]})]},e.value)})})}),(0,w.jsx)(f,{title:i(`sideDockVisibilityTitle`),description:i(`sideDockVisibilityDescription`),control:(0,w.jsx)(m,{id:`appearance-side-dock-visible`,"aria-label":i(`sideDockVisibilityTitle`),checked:D,onCheckedChange:O})})]})})})}export{E as AppearanceSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{h as t,p as n,r,u as i}from"./react-B0LbRnAE.js";import{A as a,C as o,F as s,I as c,L as l,M as u,N as d,O as f,P as p,R as m,_t as h,c as g,ct as _,d as v,et as y,gt as b,ht as x,it as S,j as C,k as ee,l as te,lt as ne,n as re,nt as w,o as T,rt as E,s as D,w as O,z as k}from"./app-presenter-provider-B1RgR5ug.js";import{$t as ie,Jt as ae,nn as A,on as oe,tn as j,vt as se}from"./api-DGG69ZcJ.js";import{c as ce}from"./dist-C87P4QWA.js";import{i as M,r as le,t as ue}from"./popover-Txwrum65.js";import{a as N,i as P,n as F,o as I,r as L,s as R}from"./confirm-dialog-o_VPKvVD.js";import{C as de,a as fe,i as pe,n as me,r as he,t as ge}from"./select-CYHT8P5S.js";import{t as _e}from"./provider-scoped-model-input-B7rQM4b6.js";import{a as ve,o as z,t as ye}from"./use-confirm-dialog-WZ94CehU.js";import{n as B,t as V}from"./card-Bcr5YM8F.js";import{n as be,t as xe}from"./eye-DL9QkrKg.js";import{t as Se}from"./use-viewport-layout-CZ-3pMne.js";import{t as H}from"./plus-DjdTWPjQ.js";import{t as Ce}from"./settings-2-DGh4bGSi.js";import{t as we}from"./trash-2-Bo3DWiju.js";import{n as Te}from"./provider-models-CXUgDxGR.js";import{t as Ee}from"./tag-chip-De0iz4o2.js";import{t as De}from"./index-B9QEjnoY.js";import{l as U,t as W,u as G}from"./use-config-DCzwgChy.js";var Oe=ce(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),K=e(t(),1),q=n(),J=new Intl.NumberFormat;function ke({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:i,defaultRuntimeLabel:a,onOpenChange:o,onEdit:s}){if(!e)return null;let c=Y(e.model,t?.model),l=Ae({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:i,defaultRuntimeLabel:a}),u=X(e.contextTokens,t?.contextTokens??2e5),d=X(e.reservedContextTokens,t?.reservedContextTokens),f=X(e.maxToolIterations,t?.maxToolIterations??1e3),p=Y(e.thinkingDefault,t?.thinkingDefault??`off`),m=Me(e.runtimeConfig??e.engineConfig,t?.engineConfig),h=Me(e.models,t?.models);return(0,q.jsx)(F,{open:e!==null,onOpenChange:o,children:(0,q.jsxs)(L,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-white p-0 sm:max-h-[720px] sm:max-w-2xl`,children:[(0,q.jsx)(`div`,{className:`shrink-0 px-5 pb-3 pt-5`,children:(0,q.jsx)(I,{className:`text-left`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,q.jsx)(C,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-10 w-10 shrink-0`}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(R,{className:`truncate text-base`,children:e.displayName?.trim()||e.id}),(0,q.jsxs)(P,{className:`truncate text-xs`,children:[`@`,e.id]})]})]})})}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-5 py-3`,children:[(0,q.jsxs)(Z,{icon:ne,title:r(`agentsDetailsIdentitySection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldDisplayName`),value:e.displayName?.trim()||e.id}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldId`),value:e.id,mono:!0}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldDescription`),value:e.description?.trim()||r(`agentsDetailsEmptyValue`),wide:!0}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldWorkspace`),value:e.workspace??r(`agentsDetailsUnsetValue`),mono:!0,wide:!0})]}),(0,q.jsxs)(Z,{icon:z,title:r(`agentsDetailsRuntimeSection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldModel`),value:c.value,source:c.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldRuntime`),value:l.value,source:l.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldRuntimeConfig`),value:m.value,source:m.source,mono:!0,prewrap:!0})]}),(0,q.jsxs)(Z,{icon:Oe,title:r(`agentsDetailsContextSection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldContextTokens`),value:u.value,source:u.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldReservedContextTokens`),value:d.value,source:d.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldMaxToolIterations`),value:f.value,source:f.source})]}),(0,q.jsxs)(Z,{icon:_,title:r(`agentsDetailsBehaviorSection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldThinkingDefault`),value:p.value,source:p.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldModelOverrides`),value:h.value,source:h.source,mono:!0,prewrap:!0}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldAvatar`),value:e.avatar??r(`agentsDetailsUnsetValue`),mono:!0})]})]}),(0,q.jsxs)(N,{className:`shrink-0 px-5 pb-4 pt-2`,children:[(0,q.jsx)(A,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:r(`cancel`)}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`px-4`,onClick:()=>s(e),children:[(0,q.jsx)(w,{className:`mr-2 h-4 w-4`}),r(`agentsDetailsEditAction`)]})]})]})})}function Y(e,t){let n=e?.trim();return n?{value:n,source:`override`}:{value:t?.trim()||r(`agentsDetailsUnsetValue`),source:`default`}}function X(e,t){return typeof e==`number`?{value:J.format(e),source:`override`}:{value:typeof t==`number`?J.format(t):r(`agentsDetailsUnsetValue`),source:`default`}}function Ae(e){let{agent:t,defaults:n,runtimeOptions:r,defaultRuntime:i,defaultRuntimeLabel:a}=e,o=t.runtime?.trim()||t.engine?.trim();if(o)return{value:je(o,r,a),source:`override`};let s=n?.engine?.trim()||i;return{value:s?je(s,r,a):a,source:`default`}}function je(e,t,n){let r=d(e);return r?t.find(e=>e.value===r)?.label??s(r):n}function Me(e,t){return Ne(e)?{value:JSON.stringify(e,null,2),source:`override`}:{value:Ne(t)?JSON.stringify(t,null,2):r(`agentsDetailsUnsetValue`),source:`default`}}function Ne(e){return!!(e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0)}function Z(e){let{icon:t,title:n,children:r}=e;return(0,q.jsxs)(`section`,{className:`space-y-2 border-t border-gray-100 pt-3 first:border-t-0 first:pt-0`,children:[(0,q.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold leading-5 text-gray-900`,children:[(0,q.jsx)(t,{className:`h-3.5 w-3.5 text-gray-400`}),n]}),(0,q.jsx)(`dl`,{className:`grid min-w-0 gap-x-6 gap-y-2.5 pl-5 sm:grid-cols-2`,children:r})]})}function Q(e){let{label:t,value:n,source:r,mono:a=!1,prewrap:o=!1,wide:s=!1}=e,c=o&&n.trim().startsWith(`{`),l=a&&(!o||c);return(0,q.jsxs)(`div`,{className:i(`grid min-w-0 grid-cols-[10rem_minmax(0,1fr)] items-baseline gap-x-2`,(s||c)&&`sm:col-span-2`),children:[(0,q.jsx)(`dt`,{className:`flex min-w-0 items-baseline leading-5`,children:(0,q.jsx)(`span`,{className:`whitespace-nowrap text-xs font-medium text-gray-500`,children:t})}),(0,q.jsxs)(`dd`,{className:i(`min-w-0 break-words text-xs leading-5 text-gray-900`,c?`max-h-28 overflow-auto whitespace-pre-wrap rounded bg-gray-50/70 px-2 py-1.5 text-left`:``),children:[(0,q.jsx)(`span`,{className:l?`font-mono`:void 0,children:n}),r?(0,q.jsx)(Pe,{source:r}):null]})]})}function Pe({source:e}){return(0,q.jsxs)(`span`,{className:i(`ml-1 whitespace-nowrap text-xs font-normal leading-5`,e===`override`?`text-blue-500`:`text-gray-400`),children:[`(`,r(e===`override`?`agentsDetailsAgentOverride`:`agentsDetailsInheritedDefault`),`)`]})}function Fe({form:e,disabled:t=!1,onChange:n}){return(0,q.jsxs)(`details`,{className:`group rounded-2xl border border-gray-200 bg-white`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-gray-800 [&::-webkit-details-marker]:hidden`,children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(Ce,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,q.jsx)(`span`,{className:`truncate`,children:r(`agentsAdvancedConfigToggle`)})]}),(0,q.jsx)(de,{className:`h-4 w-4 shrink-0 text-gray-400 transition-transform group-open:rotate-180`})]}),(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-gray-100 px-4 py-4`,children:[(0,q.jsx)(`p`,{className:`text-xs leading-5 text-gray-500`,children:r(`agentsAdvancedConfigDescription`)}),(0,q.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:(0,q.jsx)(Ie,{label:r(`agentsAdvancedContextTokensLabel`),value:e.contextTokens,min:1e3,step:1e3,disabled:t,onChange:e=>n({contextTokens:e})})})]})]})}function Ie(e){let{label:t,value:n,min:i,step:a,disabled:o,onChange:s}=e;return(0,q.jsxs)(`label`,{className:`space-y-2 text-sm font-medium text-gray-700`,children:[(0,q.jsx)(`span`,{children:t}),(0,q.jsx)(j,{type:`number`,min:i,step:a,value:n,disabled:o,placeholder:r(`agentsAdvancedInheritPlaceholder`),"aria-label":t,onChange:e=>s(e.target.value)})]})}function Le(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:Re(e.contextTokens)}}function Re(e){return typeof e==`number`?String(e):``}var ze=K.forwardRef(({className:e,...t},n)=>(0,q.jsx)(`textarea`,{className:i(`flex min-h-28 w-full rounded-xl border border-border/75 bg-card px-3.5 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/55 placeholder:font-normal transition-colors focus:outline-none focus:ring-0 focus:border-border disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));ze.displayName=`Textarea`;function Be(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=d(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:s(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function Ve({value:e,disabled:t=!1,runtimeOptions:n,defaultRuntime:i,onChange:a}){let o=e.trim()?d(e):``,s=Be({runtimeOptions:n,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?r(`agentsRuntimeUnavailableHelp`):``);return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(ge,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:t,children:[(0,q.jsx)(pe,{"aria-label":r(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,q.jsx)(fe,{placeholder:r(`agentsRuntimeSelectPlaceholder`)})}),(0,q.jsx)(me,{className:`rounded-xl`,children:s.map(e=>(0,q.jsx)(he,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,q.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function He({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,q.jsx)(F,{open:e!==null,onOpenChange:a,children:e?(0,q.jsx)(Ue,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function Ue(e){let{agent:t,pending:n,providerCatalog:i,runtimeOptions:a,defaultRuntime:o,onOpenChange:s,onSubmit:c}=e,[l,u]=(0,K.useState)(Le(t));return(0,q.jsxs)(L,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,q.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,q.jsxs)(I,{className:`text-left`,children:[(0,q.jsx)(R,{children:r(`agentsEditDialogTitle`)}),(0,q.jsx)(P,{children:r(`agentsEditDialogDescription`)})]})}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(ve,{tone:`warning`,title:r(`agentsEditHomeReadonly`),description:r(`agentsEditHomeReadonlyHint`),children:(0,q.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,q.jsx)(j,{value:l.displayName,onChange:e=>u(t=>({...t,displayName:e.target.value})),placeholder:r(`agentsFormNamePlaceholder`)}),(0,q.jsx)(ze,{value:l.description,onChange:e=>u(t=>({...t,description:e.target.value})),placeholder:r(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,q.jsx)(j,{value:l.avatar,onChange:e=>u(t=>({...t,avatar:e.target.value})),placeholder:r(`agentsFormAvatarPlaceholder`)}),(0,q.jsx)(_e,{value:l.model,onChange:e=>u(t=>({...t,model:e})),providerCatalog:i,disabled:n,className:`md:col-span-2`}),(0,q.jsx)(Ve,{value:l.runtime,onChange:e=>u(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:n})]}),(0,q.jsx)(Fe,{form:l,disabled:n,onChange:e=>u(t=>({...t,...e}))})]})}),(0,q.jsxs)(N,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,q.jsx)(A,{type:`button`,variant:`ghost`,onClick:()=>s(!1),disabled:n,children:r(`cancel`)}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>c(t.id,l),disabled:n,children:[(0,q.jsx)(w,{className:`mr-2 h-4 w-4`}),r(`agentsEditSaveAction`)]})]})]})}var We=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function Ge(e,t){let n=e.trim();if(!n)return null;let i=Number(n);if(!Number.isFinite(i))throw Error(r(`agentsAdvancedInvalidNumberError`));return Math.max(t,Math.trunc(i))}function Ke(e){return{displayName:e.displayName,description:e.description,avatar:e.avatar,model:e.model,...e.runtime.trim()?{runtime:e.runtime.trim()}:{runtime:``},contextTokens:Ge(e.contextTokens,1e3)}}function qe(e){let{agentCount:t,onCreate:n}=e;return(0,q.jsxs)(`section`,{className:`flex flex-col gap-3 border-b border-gray-200 pb-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold text-gray-950`,children:r(`agentsHeroEyebrow`)}),(0,q.jsx)(`span`,{className:`rounded-full border border-gray-200 bg-white px-2 py-0.5 text-xs font-medium text-gray-500`,children:t})]}),(0,q.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-gray-500`,children:r(`agentsHeroDescription`)})]}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:n,children:[(0,q.jsx)(H,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}function $(e){let{icon:t,label:n,disabled:r=!1,destructive:a=!1,onClick:o}=e;return(0,q.jsxs)(`button`,{type:`button`,className:i(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:o,disabled:r,children:[(0,q.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,q.jsx)(`span`,{children:n})]})}function Je(e){let{agent:t,runtimeOptions:n,defaultRuntimeLabel:i,updatePending:a,deletePending:o,onStartChat:c,onView:l,onEdit:u,onDelete:f}=e,p=t.runtime?.trim()||t.engine?.trim()||``,m=p?n.find(e=>e.value===d(p))?.label??s(p):i;return(0,q.jsx)(V,{className:`group overflow-hidden border border-gray-200 bg-white shadow-none transition-colors duration-200 hover:border-gray-300`,children:(0,q.jsxs)(B,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,q.jsx)(C,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-950`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,q.jsxs)(Ee,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,q.jsx)(y,{className:`h-3 w-3`}),r(`agentsCardBuiltInTag`)]}):null]}),(0,q.jsxs)(`div`,{className:`truncate text-xs text-gray-400`,children:[`@`,t.id]})]})]}),(0,q.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 flex items-center gap-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,children:[(0,q.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`agentsCardStartChat`),title:r(`agentsCardStartChat`),onClick:c,children:(0,q.jsx)(E,{className:`h-4 w-4`})}),(0,q.jsxs)(ue,{children:[(0,q.jsx)(M,{asChild:!0,children:(0,q.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`chatSessionMoreActions`),title:r(`chatSessionMoreActions`),children:(0,q.jsx)(be,{className:`h-4 w-4`})})}),(0,q.jsxs)(le,{align:`end`,className:`w-44 p-1.5`,children:[(0,q.jsx)($,{icon:xe,label:r(`agentsViewDetailsAction`),onClick:l}),(0,q.jsx)($,{icon:w,label:r(`agentsEditAction`),onClick:u,disabled:a}),t.builtIn?null:(0,q.jsx)($,{icon:we,label:r(`agentsRemoveAction`),onClick:f,disabled:o,destructive:!0})]})]})]}),(0,q.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-gray-600`,children:t.description?.trim()||(t.builtIn?r(`agentsCardBuiltInSummary`):r(`agentsCardCustomSummary`))}),(0,q.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-gray-100 pt-2 text-xs text-gray-500`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(z,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,q.jsx)(`span`,{className:`truncate`,children:m})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,q.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function Ye(){let e=k(),t=re(),n=b(),i=f(),o=W(),c=G(),l=U(),m=T(),h=a(),g=ee(),[_,v]=(0,K.useState)(null),[y,x]=(0,K.useState)(null),S=(0,K.useMemo)(()=>i.data?.agents??[],[i.data?.agents]),C=(0,K.useMemo)(()=>[...S].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[S]),te=(0,K.useMemo)(()=>Te({config:o.data,providersView:c.data,templatesView:l.data,onlyConfigured:!0}),[o.data,c.data,l.data]),w=(0,K.useMemo)(()=>u(m.data?.options??[]),[m.data?.options]),E=(0,K.useMemo)(()=>d(m.data?.defaultType??`native`),[m.data?.defaultType]),D=(0,K.useMemo)(()=>w.find(e=>e.value===E)?.label??s(E),[E,w]),O=o.data?.agents.defaults,ae=e=>{v(e)},j=e=>{x(e)},se=async(e,t)=>{let n;try{n=Ke(t)}catch(e){oe.error(e instanceof Error?e.message:r(`agentsAdvancedParseFailed`));return}await h.mutateAsync({agentId:e,data:n}),x(null)},ce=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,p(t,E))},M=()=>{n(`/chat`),t.chatDraftIntentManager.requestDraft(We)};return(0,q.jsxs)(ie,{className:`space-y-5`,children:[(0,q.jsx)(qe,{agentCount:S.length,onCreate:M}),(0,q.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:i.isLoading?(0,q.jsx)(V,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,q.jsx)(B,{className:`py-14 text-center text-sm text-gray-500`,children:r(`agentsLoading`)})}):C.length===0?(0,q.jsx)(V,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-[#d9dce3] bg-[linear-gradient(135deg,#fff7ea_0%,#f4fbff_100%)]`,children:(0,q.jsxs)(B,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,q.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,q.jsx)(ne,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,q.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:r(`agentsEmpty`)}),(0,q.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:r(`agentsEmptyDescription`)}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:M,children:[(0,q.jsx)(H,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}):C.map(e=>(0,q.jsx)(Je,{agent:e,runtimeOptions:w,defaultRuntimeLabel:D,updatePending:h.isPending,deletePending:g.isPending,onStartChat:()=>ce(e),onView:()=>ae(e),onEdit:()=>j(e),onDelete:()=>g.mutate({agentId:e.id})},e.id))}),(0,q.jsx)(ke,{agent:_,defaults:O,runtimeOptions:w,defaultRuntime:E,defaultRuntimeLabel:D,onOpenChange:e=>{e||v(null)},onEdit:e=>{v(null),x(e)}}),(0,q.jsx)(He,{agent:y,pending:h.isPending,providerCatalog:te,runtimeOptions:w,defaultRuntime:E,onOpenChange:e=>{!e&&!h.isPending&&x(null)},onSubmit:se})]})}function Xe(e){let{view:t,routeSessionKey:n,syncRouteSessionSelection:r}=e;(0,K.useLayoutEffect)(()=>{r({isChatView:t===`chat`,routeSessionKey:n})},[n,r,t])}function Ze({view:e,confirmDialog:t}){let{isMobile:n}=Se();return(0,q.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,q.jsx)(te,{}),e===`chat`?n?(0,q.jsx)(v,{}):(0,q.jsx)(o,{}):(0,q.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:e===`cron`?(0,q.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,q.jsx)(O,{})})}):e===`agents`?(0,q.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,q.jsx)(Ye,{})})}):(0,q.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,q.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-4 py-4 sm:px-6 sm:py-5`,children:(0,q.jsx)(De,{forcedType:`skills`})})})}),t]})}function Qe(e){let t=k(),n=W(),r=G(),i=U(),a=l({limit:200}),o=T(),s=e.sessionKey?.trim()||`draft-session`,u=c({sessionId:s});(0,K.useEffect)(()=>{t.chatQueryManager.syncSnapshot({configQuery:n,providersQuery:r,providerTemplatesQuery:i,sessionsQuery:a,sessionTypesQuery:o,sessionSkillsSessionId:s,sessionSkillsQuery:u})},[n,t.chatQueryManager,r,s,u,a,o,i])}function $e(){let e=k();(0,K.useEffect)(()=>se.eventBus.on(ae.uiShowContent,t=>{e.chatThreadManager.handleUiShowContentEvent(t)}),[e])}function et(){let{sessionId:e}=h(),t=(0,K.useMemo)(()=>g(e),[e]);return{routeSessionKey:t,sessionKey:t??void 0}}function tt(){let e=k(),{confirm:t,ConfirmDialog:n}=ye(),r=x(),i=b();return(0,K.useEffect)(()=>{e.chatUiManager.syncState({pathname:r.pathname}),e.chatUiManager.bindActions({navigate:i,confirm:t})},[t,r.pathname,i,e]),(0,q.jsx)(n,{})}function nt({view:e}){let t=re();return(0,q.jsx)(m,{presenter:(0,K.useMemo)(()=>new D(t),[t]),children:(0,q.jsx)(rt,{view:e})})}function rt({view:e}){let t=k(),n=tt(),{routeSessionKey:r,sessionKey:i}=et();return Qe({sessionKey:i??null}),Xe({view:e,routeSessionKey:r,syncRouteSessionSelection:t.chatSessionListManager.syncRouteSessionSelection}),$e(),(0,q.jsx)(Ze,{view:e,confirmDialog:n})}function it({view:e}){return(0,q.jsx)(nt,{view:e})}export{it as ChatPage};
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{h as t,p as n,r,u as i}from"./react-B0LbRnAE.js";import{A as a,C as o,F as s,I as c,L as l,M as u,N as d,O as f,P as p,R as m,_t as h,c as g,ct as _,d as v,et as y,gt as b,ht as x,it as S,j as C,k as ee,l as te,lt as ne,n as re,nt as w,o as T,rt as E,s as D,w as O,z as k}from"./app-presenter-provider-Dp90n1Va.js";import{$t as ie,Jt as ae,nn as A,on as oe,tn as j,vt as se}from"./api-DGG69ZcJ.js";import{c as ce}from"./dist-C87P4QWA.js";import{i as M,r as le,t as ue}from"./popover-Txwrum65.js";import{a as N,i as P,n as F,o as I,r as L,s as R}from"./confirm-dialog-o_VPKvVD.js";import{C as de,a as fe,i as pe,n as me,r as he,t as ge}from"./select-CYHT8P5S.js";import{t as _e}from"./provider-scoped-model-input-B7rQM4b6.js";import{a as ve,o as z,t as ye}from"./use-confirm-dialog-WZ94CehU.js";import{n as B,t as V}from"./card-Bcr5YM8F.js";import{n as be,t as xe}from"./eye-DL9QkrKg.js";import{t as Se}from"./use-viewport-layout-CZ-3pMne.js";import{t as H}from"./plus-DjdTWPjQ.js";import{t as Ce}from"./settings-2-DGh4bGSi.js";import{t as we}from"./trash-2-Bo3DWiju.js";import{n as Te}from"./provider-models-CXUgDxGR.js";import{t as Ee}from"./tag-chip-De0iz4o2.js";import{t as De}from"./index-BFIZUZP3.js";import{l as U,t as W,u as G}from"./use-config-DCzwgChy.js";var Oe=ce(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),K=e(t(),1),q=n(),J=new Intl.NumberFormat;function ke({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:i,defaultRuntimeLabel:a,onOpenChange:o,onEdit:s}){if(!e)return null;let c=Y(e.model,t?.model),l=Ae({agent:e,defaults:t,runtimeOptions:n,defaultRuntime:i,defaultRuntimeLabel:a}),u=X(e.contextTokens,t?.contextTokens??2e5),d=X(e.reservedContextTokens,t?.reservedContextTokens),f=X(e.maxToolIterations,t?.maxToolIterations??1e3),p=Y(e.thinkingDefault,t?.thinkingDefault??`off`),m=Me(e.runtimeConfig??e.engineConfig,t?.engineConfig),h=Me(e.models,t?.models);return(0,q.jsx)(F,{open:e!==null,onOpenChange:o,children:(0,q.jsxs)(L,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-white p-0 sm:max-h-[720px] sm:max-w-2xl`,children:[(0,q.jsx)(`div`,{className:`shrink-0 px-5 pb-3 pt-5`,children:(0,q.jsx)(I,{className:`text-left`,children:(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,q.jsx)(C,{agentId:e.id,displayName:e.displayName,avatarUrl:e.avatarUrl,className:`h-10 w-10 shrink-0`}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(R,{className:`truncate text-base`,children:e.displayName?.trim()||e.id}),(0,q.jsxs)(P,{className:`truncate text-xs`,children:[`@`,e.id]})]})]})})}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-5 py-3`,children:[(0,q.jsxs)(Z,{icon:ne,title:r(`agentsDetailsIdentitySection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldDisplayName`),value:e.displayName?.trim()||e.id}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldId`),value:e.id,mono:!0}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldDescription`),value:e.description?.trim()||r(`agentsDetailsEmptyValue`),wide:!0}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldWorkspace`),value:e.workspace??r(`agentsDetailsUnsetValue`),mono:!0,wide:!0})]}),(0,q.jsxs)(Z,{icon:z,title:r(`agentsDetailsRuntimeSection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldModel`),value:c.value,source:c.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldRuntime`),value:l.value,source:l.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldRuntimeConfig`),value:m.value,source:m.source,mono:!0,prewrap:!0})]}),(0,q.jsxs)(Z,{icon:Oe,title:r(`agentsDetailsContextSection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldContextTokens`),value:u.value,source:u.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldReservedContextTokens`),value:d.value,source:d.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldMaxToolIterations`),value:f.value,source:f.source})]}),(0,q.jsxs)(Z,{icon:_,title:r(`agentsDetailsBehaviorSection`),children:[(0,q.jsx)(Q,{label:r(`agentsDetailsFieldThinkingDefault`),value:p.value,source:p.source}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldModelOverrides`),value:h.value,source:h.source,mono:!0,prewrap:!0}),(0,q.jsx)(Q,{label:r(`agentsDetailsFieldAvatar`),value:e.avatar??r(`agentsDetailsUnsetValue`),mono:!0})]})]}),(0,q.jsxs)(N,{className:`shrink-0 px-5 pb-4 pt-2`,children:[(0,q.jsx)(A,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:r(`cancel`)}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`px-4`,onClick:()=>s(e),children:[(0,q.jsx)(w,{className:`mr-2 h-4 w-4`}),r(`agentsDetailsEditAction`)]})]})]})})}function Y(e,t){let n=e?.trim();return n?{value:n,source:`override`}:{value:t?.trim()||r(`agentsDetailsUnsetValue`),source:`default`}}function X(e,t){return typeof e==`number`?{value:J.format(e),source:`override`}:{value:typeof t==`number`?J.format(t):r(`agentsDetailsUnsetValue`),source:`default`}}function Ae(e){let{agent:t,defaults:n,runtimeOptions:r,defaultRuntime:i,defaultRuntimeLabel:a}=e,o=t.runtime?.trim()||t.engine?.trim();if(o)return{value:je(o,r,a),source:`override`};let s=n?.engine?.trim()||i;return{value:s?je(s,r,a):a,source:`default`}}function je(e,t,n){let r=d(e);return r?t.find(e=>e.value===r)?.label??s(r):n}function Me(e,t){return Ne(e)?{value:JSON.stringify(e,null,2),source:`override`}:{value:Ne(t)?JSON.stringify(t,null,2):r(`agentsDetailsUnsetValue`),source:`default`}}function Ne(e){return!!(e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0)}function Z(e){let{icon:t,title:n,children:r}=e;return(0,q.jsxs)(`section`,{className:`space-y-2 border-t border-gray-100 pt-3 first:border-t-0 first:pt-0`,children:[(0,q.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold leading-5 text-gray-900`,children:[(0,q.jsx)(t,{className:`h-3.5 w-3.5 text-gray-400`}),n]}),(0,q.jsx)(`dl`,{className:`grid min-w-0 gap-x-6 gap-y-2.5 pl-5 sm:grid-cols-2`,children:r})]})}function Q(e){let{label:t,value:n,source:r,mono:a=!1,prewrap:o=!1,wide:s=!1}=e,c=o&&n.trim().startsWith(`{`),l=a&&(!o||c);return(0,q.jsxs)(`div`,{className:i(`grid min-w-0 grid-cols-[10rem_minmax(0,1fr)] items-baseline gap-x-2`,(s||c)&&`sm:col-span-2`),children:[(0,q.jsx)(`dt`,{className:`flex min-w-0 items-baseline leading-5`,children:(0,q.jsx)(`span`,{className:`whitespace-nowrap text-xs font-medium text-gray-500`,children:t})}),(0,q.jsxs)(`dd`,{className:i(`min-w-0 break-words text-xs leading-5 text-gray-900`,c?`max-h-28 overflow-auto whitespace-pre-wrap rounded bg-gray-50/70 px-2 py-1.5 text-left`:``),children:[(0,q.jsx)(`span`,{className:l?`font-mono`:void 0,children:n}),r?(0,q.jsx)(Pe,{source:r}):null]})]})}function Pe({source:e}){return(0,q.jsxs)(`span`,{className:i(`ml-1 whitespace-nowrap text-xs font-normal leading-5`,e===`override`?`text-blue-500`:`text-gray-400`),children:[`(`,r(e===`override`?`agentsDetailsAgentOverride`:`agentsDetailsInheritedDefault`),`)`]})}function Fe({form:e,disabled:t=!1,onChange:n}){return(0,q.jsxs)(`details`,{className:`group rounded-2xl border border-gray-200 bg-white`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-gray-800 [&::-webkit-details-marker]:hidden`,children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(Ce,{className:`h-4 w-4 shrink-0 text-gray-400`}),(0,q.jsx)(`span`,{className:`truncate`,children:r(`agentsAdvancedConfigToggle`)})]}),(0,q.jsx)(de,{className:`h-4 w-4 shrink-0 text-gray-400 transition-transform group-open:rotate-180`})]}),(0,q.jsxs)(`div`,{className:`space-y-4 border-t border-gray-100 px-4 py-4`,children:[(0,q.jsx)(`p`,{className:`text-xs leading-5 text-gray-500`,children:r(`agentsAdvancedConfigDescription`)}),(0,q.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:(0,q.jsx)(Ie,{label:r(`agentsAdvancedContextTokensLabel`),value:e.contextTokens,min:1e3,step:1e3,disabled:t,onChange:e=>n({contextTokens:e})})})]})]})}function Ie(e){let{label:t,value:n,min:i,step:a,disabled:o,onChange:s}=e;return(0,q.jsxs)(`label`,{className:`space-y-2 text-sm font-medium text-gray-700`,children:[(0,q.jsx)(`span`,{children:t}),(0,q.jsx)(j,{type:`number`,min:i,step:a,value:n,disabled:o,placeholder:r(`agentsAdvancedInheritPlaceholder`),"aria-label":t,onChange:e=>s(e.target.value)})]})}function Le(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:Re(e.contextTokens)}}function Re(e){return typeof e==`number`?String(e):``}var ze=K.forwardRef(({className:e,...t},n)=>(0,q.jsx)(`textarea`,{className:i(`flex min-h-28 w-full rounded-xl border border-border/75 bg-card px-3.5 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/55 placeholder:font-normal transition-colors focus:outline-none focus:ring-0 focus:border-border disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));ze.displayName=`Textarea`;function Be(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=d(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:s(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function Ve({value:e,disabled:t=!1,runtimeOptions:n,defaultRuntime:i,onChange:a}){let o=e.trim()?d(e):``,s=Be({runtimeOptions:n,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?r(`agentsRuntimeUnavailableHelp`):``);return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(ge,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:t,children:[(0,q.jsx)(pe,{"aria-label":r(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,q.jsx)(fe,{placeholder:r(`agentsRuntimeSelectPlaceholder`)})}),(0,q.jsx)(me,{className:`rounded-xl`,children:s.map(e=>(0,q.jsx)(he,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,q.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function He({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,q.jsx)(F,{open:e!==null,onOpenChange:a,children:e?(0,q.jsx)(Ue,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function Ue(e){let{agent:t,pending:n,providerCatalog:i,runtimeOptions:a,defaultRuntime:o,onOpenChange:s,onSubmit:c}=e,[l,u]=(0,K.useState)(Le(t));return(0,q.jsxs)(L,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,q.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,q.jsxs)(I,{className:`text-left`,children:[(0,q.jsx)(R,{children:r(`agentsEditDialogTitle`)}),(0,q.jsx)(P,{children:r(`agentsEditDialogDescription`)})]})}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(ve,{tone:`warning`,title:r(`agentsEditHomeReadonly`),description:r(`agentsEditHomeReadonlyHint`),children:(0,q.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:t.workspace??`-`})}),(0,q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,q.jsx)(j,{value:l.displayName,onChange:e=>u(t=>({...t,displayName:e.target.value})),placeholder:r(`agentsFormNamePlaceholder`)}),(0,q.jsx)(ze,{value:l.description,onChange:e=>u(t=>({...t,description:e.target.value})),placeholder:r(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,q.jsx)(j,{value:l.avatar,onChange:e=>u(t=>({...t,avatar:e.target.value})),placeholder:r(`agentsFormAvatarPlaceholder`)}),(0,q.jsx)(_e,{value:l.model,onChange:e=>u(t=>({...t,model:e})),providerCatalog:i,disabled:n,className:`md:col-span-2`}),(0,q.jsx)(Ve,{value:l.runtime,onChange:e=>u(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:n})]}),(0,q.jsx)(Fe,{form:l,disabled:n,onChange:e=>u(t=>({...t,...e}))})]})}),(0,q.jsxs)(N,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,q.jsx)(A,{type:`button`,variant:`ghost`,onClick:()=>s(!1),disabled:n,children:r(`cancel`)}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>c(t.id,l),disabled:n,children:[(0,q.jsx)(w,{className:`mr-2 h-4 w-4`}),r(`agentsEditSaveAction`)]})]})]})}var We=`请直接创建一个默认示例 Agent,不要问我问题。创建完成后,简单告诉我它能做什么。`;function Ge(e,t){let n=e.trim();if(!n)return null;let i=Number(n);if(!Number.isFinite(i))throw Error(r(`agentsAdvancedInvalidNumberError`));return Math.max(t,Math.trunc(i))}function Ke(e){return{displayName:e.displayName,description:e.description,avatar:e.avatar,model:e.model,...e.runtime.trim()?{runtime:e.runtime.trim()}:{runtime:``},contextTokens:Ge(e.contextTokens,1e3)}}function qe(e){let{agentCount:t,onCreate:n}=e;return(0,q.jsxs)(`section`,{className:`flex flex-col gap-3 border-b border-gray-200 pb-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h1`,{className:`text-xl font-semibold text-gray-950`,children:r(`agentsHeroEyebrow`)}),(0,q.jsx)(`span`,{className:`rounded-full border border-gray-200 bg-white px-2 py-0.5 text-xs font-medium text-gray-500`,children:t})]}),(0,q.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-gray-500`,children:r(`agentsHeroDescription`)})]}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`h-9 shrink-0 rounded-xl px-4 text-sm font-semibold`,onClick:n,children:[(0,q.jsx)(H,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}function $(e){let{icon:t,label:n,disabled:r=!1,destructive:a=!1,onClick:o}=e;return(0,q.jsxs)(`button`,{type:`button`,className:i(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50`,a?`text-destructive hover:bg-destructive/10`:`text-gray-700 hover:bg-gray-100`),onClick:o,disabled:r,children:[(0,q.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,q.jsx)(`span`,{children:n})]})}function Je(e){let{agent:t,runtimeOptions:n,defaultRuntimeLabel:i,updatePending:a,deletePending:o,onStartChat:c,onView:l,onEdit:u,onDelete:f}=e,p=t.runtime?.trim()||t.engine?.trim()||``,m=p?n.find(e=>e.value===d(p))?.label??s(p):i;return(0,q.jsx)(V,{className:`group overflow-hidden border border-gray-200 bg-white shadow-none transition-colors duration-200 hover:border-gray-300`,children:(0,q.jsxs)(B,{className:`relative flex h-full flex-col gap-3 px-3.5 py-3.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5 pr-16`,children:[(0,q.jsx)(C,{agentId:t.id,displayName:t.displayName,avatarUrl:t.avatarUrl,className:`h-9 w-9 shrink-0`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-semibold text-gray-950`,children:t.displayName?.trim()||t.id}),t.builtIn?(0,q.jsxs)(Ee,{tone:`warning`,className:`h-5 gap-1 border-amber-200 bg-amber-50 px-1.5 text-[10px] text-amber-700`,children:[(0,q.jsx)(y,{className:`h-3 w-3`}),r(`agentsCardBuiltInTag`)]}):null]}),(0,q.jsxs)(`div`,{className:`truncate text-xs text-gray-400`,children:[`@`,t.id]})]})]}),(0,q.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 flex items-center gap-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,children:[(0,q.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`agentsCardStartChat`),title:r(`agentsCardStartChat`),onClick:c,children:(0,q.jsx)(E,{className:`h-4 w-4`})}),(0,q.jsxs)(ue,{children:[(0,q.jsx)(M,{asChild:!0,children:(0,q.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-gray-400 hover:text-gray-800`,"aria-label":r(`chatSessionMoreActions`),title:r(`chatSessionMoreActions`),children:(0,q.jsx)(be,{className:`h-4 w-4`})})}),(0,q.jsxs)(le,{align:`end`,className:`w-44 p-1.5`,children:[(0,q.jsx)($,{icon:xe,label:r(`agentsViewDetailsAction`),onClick:l}),(0,q.jsx)($,{icon:w,label:r(`agentsEditAction`),onClick:u,disabled:a}),t.builtIn?null:(0,q.jsx)($,{icon:we,label:r(`agentsRemoveAction`),onClick:f,disabled:o,destructive:!0})]})]})]}),(0,q.jsx)(`p`,{className:`line-clamp-2 min-h-10 text-sm leading-5 text-gray-600`,children:t.description?.trim()||(t.builtIn?r(`agentsCardBuiltInSummary`):r(`agentsCardCustomSummary`))}),(0,q.jsxs)(`div`,{className:`mt-auto grid gap-2 border-t border-gray-100 pt-2 text-xs text-gray-500`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(z,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,q.jsx)(`span`,{className:`truncate`,children:m})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 text-gray-300`}),(0,q.jsx)(`span`,{className:`truncate`,children:t.workspace??`-`})]})]})]})})}function Ye(){let e=k(),t=re(),n=b(),i=f(),o=W(),c=G(),l=U(),m=T(),h=a(),g=ee(),[_,v]=(0,K.useState)(null),[y,x]=(0,K.useState)(null),S=(0,K.useMemo)(()=>i.data?.agents??[],[i.data?.agents]),C=(0,K.useMemo)(()=>[...S].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[S]),te=(0,K.useMemo)(()=>Te({config:o.data,providersView:c.data,templatesView:l.data,onlyConfigured:!0}),[o.data,c.data,l.data]),w=(0,K.useMemo)(()=>u(m.data?.options??[]),[m.data?.options]),E=(0,K.useMemo)(()=>d(m.data?.defaultType??`native`),[m.data?.defaultType]),D=(0,K.useMemo)(()=>w.find(e=>e.value===E)?.label??s(E),[E,w]),O=o.data?.agents.defaults,ae=e=>{v(e)},j=e=>{x(e)},se=async(e,t)=>{let n;try{n=Ke(t)}catch(e){oe.error(e instanceof Error?e.message:r(`agentsAdvancedParseFailed`));return}await h.mutateAsync({agentId:e,data:n}),x(null)},ce=t=>{e.chatSessionListManager.startAgentDraftChat(t.id,p(t,E))},M=()=>{n(`/chat`),t.chatDraftIntentManager.requestDraft(We)};return(0,q.jsxs)(ie,{className:`space-y-5`,children:[(0,q.jsx)(qe,{agentCount:S.length,onCreate:M}),(0,q.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:i.isLoading?(0,q.jsx)(V,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,q.jsx)(B,{className:`py-14 text-center text-sm text-gray-500`,children:r(`agentsLoading`)})}):C.length===0?(0,q.jsx)(V,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-[#d9dce3] bg-[linear-gradient(135deg,#fff7ea_0%,#f4fbff_100%)]`,children:(0,q.jsxs)(B,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,q.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,q.jsx)(ne,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,q.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:r(`agentsEmpty`)}),(0,q.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:r(`agentsEmptyDescription`)}),(0,q.jsxs)(A,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:M,children:[(0,q.jsx)(H,{className:`mr-2 h-4 w-4`}),r(`agentsCreateButton`)]})]})}):C.map(e=>(0,q.jsx)(Je,{agent:e,runtimeOptions:w,defaultRuntimeLabel:D,updatePending:h.isPending,deletePending:g.isPending,onStartChat:()=>ce(e),onView:()=>ae(e),onEdit:()=>j(e),onDelete:()=>g.mutate({agentId:e.id})},e.id))}),(0,q.jsx)(ke,{agent:_,defaults:O,runtimeOptions:w,defaultRuntime:E,defaultRuntimeLabel:D,onOpenChange:e=>{e||v(null)},onEdit:e=>{v(null),x(e)}}),(0,q.jsx)(He,{agent:y,pending:h.isPending,providerCatalog:te,runtimeOptions:w,defaultRuntime:E,onOpenChange:e=>{!e&&!h.isPending&&x(null)},onSubmit:se})]})}function Xe(e){let{view:t,routeSessionKey:n,syncRouteSessionSelection:r}=e;(0,K.useLayoutEffect)(()=>{r({isChatView:t===`chat`,routeSessionKey:n})},[n,r,t])}function Ze({view:e,confirmDialog:t}){let{isMobile:n}=Se();return(0,q.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,q.jsx)(te,{}),e===`chat`?n?(0,q.jsx)(v,{}):(0,q.jsx)(o,{}):(0,q.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:e===`cron`?(0,q.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,q.jsx)(O,{})})}):e===`agents`?(0,q.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,q.jsx)(Ye,{})})}):(0,q.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,q.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-4 py-4 sm:px-6 sm:py-5`,children:(0,q.jsx)(De,{forcedType:`skills`})})})}),t]})}function Qe(e){let t=k(),n=W(),r=G(),i=U(),a=l({limit:200}),o=T(),s=e.sessionKey?.trim()||`draft-session`,u=c({sessionId:s});(0,K.useEffect)(()=>{t.chatQueryManager.syncSnapshot({configQuery:n,providersQuery:r,providerTemplatesQuery:i,sessionsQuery:a,sessionTypesQuery:o,sessionSkillsSessionId:s,sessionSkillsQuery:u})},[n,t.chatQueryManager,r,s,u,a,o,i])}function $e(){let e=k();(0,K.useEffect)(()=>se.eventBus.on(ae.uiShowContent,t=>{e.chatThreadManager.handleUiShowContentEvent(t)}),[e])}function et(){let{sessionId:e}=h(),t=(0,K.useMemo)(()=>g(e),[e]);return{routeSessionKey:t,sessionKey:t??void 0}}function tt(){let e=k(),{confirm:t,ConfirmDialog:n}=ye(),r=x(),i=b();return(0,K.useEffect)(()=>{e.chatUiManager.syncState({pathname:r.pathname}),e.chatUiManager.bindActions({navigate:i,confirm:t})},[t,r.pathname,i,e]),(0,q.jsx)(n,{})}function nt({view:e}){let t=re();return(0,q.jsx)(m,{presenter:(0,K.useMemo)(()=>new D(t),[t]),children:(0,q.jsx)(rt,{view:e})})}function rt({view:e}){let t=k(),n=tt(),{routeSessionKey:r,sessionKey:i}=et();return Qe({sessionKey:i??null}),Xe({view:e,routeSessionKey:r,syncRouteSessionSelection:t.chatSessionListManager.syncRouteSessionSelection}),$e(),(0,q.jsx)(Ze,{view:e,confirmDialog:n})}function it({view:e}){return(0,q.jsx)(nt,{view:e})}export{it as ChatPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/model-config-page-oNqnMXNY.js","assets/chunk-DseTPa7n.js","assets/api-DGG69ZcJ.js","assets/react-B0LbRnAE.js","assets/book-open-BhaS5BJv.js","assets/dist-C87P4QWA.js","assets/provider-scoped-model-input-B7rQM4b6.js","assets/select-CYHT8P5S.js","assets/popover-Txwrum65.js","assets/provider-models-CXUgDxGR.js","assets/navigation-link-Dk6VdDkc.js","assets/host-capabilities-B-TtABsP.js","assets/loader-circle-CAnHHSrY.js","assets/doc-browser-context-tE0--wSa.js","assets/middleware-Df-a4x-q.js","assets/form-actions-J0tIaUdK.js","assets/skeleton-BQuylYFO.js","assets/use-config-DCzwgChy.js","assets/config-hints-S3g-UVZb.js","assets/appearance-settings-page-
|
|
2
|
-
import{i as e,t}from"./chunk-DseTPa7n.js";import{h as n,m as r,p as i,r as a,u as o}from"./react-B0LbRnAE.js";import{t as s}from"./preload-helper-D4M6sveU.js";import{B as c,D as l,E as u,V as d,_ as f,_t as p,a as m,at as h,b as g,dt as _,f as v,ft as y,gt as b,ht as x,i as S,m as C,mt as w,ot as T,p as ee,pt as E,r as te,st as D,t as O,u as ne,ut as re,y as ie}from"./app-presenter-provider-B1RgR5ug.js";import{$t as ae,At as k,B as oe,Cn as se,Dn as ce,En as le,Ft as ue,I as de,It as A,Jt as j,L as M,On as fe,R as pe,St as me,Tn as he,V as ge,_n as _e,an as ve,cn as ye,dn as be,fn as xe,gn as Se,hn as Ce,in as we,m as N,mn as Te,on as P,pn as Ee,sn as De,un as Oe,vn as ke,vt as F,wn as I,xt as Ae,yn as L,z as je}from"./api-DGG69ZcJ.js";import{a as R,c as Me,d as Ne,f as Pe,i as Fe,l as Ie,n as Le,o as z,r as Re,s as B,u as V}from"./mcp-marketplace-page-COWlzeP1.js";import{c as H}from"./dist-C87P4QWA.js";import{n as ze}from"./search-UKxiouNi.js";import{a as U,c as W,o as G,s as Be}from"./doc-browser-DQ75iUkA.js";import{i as Ve,n as He,o as Ue,r as K,t as We}from"./use-confirm-dialog-WZ94CehU.js";import{o as Ge}from"./card-Bcr5YM8F.js";import{t as Ke}from"./navigation-link-Dk6VdDkc.js";import{i as qe,r as Je,t as Ye}from"./tabs-BCihm1zK.js";import{t as Xe}from"./use-viewport-layout-CZ-3pMne.js";import{t as Ze}from"./refresh-cw-C84mMku5.js";import{t as Qe}from"./trash-2-Bo3DWiju.js";import{n as $e,t as et}from"./doc-browser-context-tE0--wSa.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var tt=t((e=>{var t=r();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}));function nt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function rt(e,t,n){let r=e.slice(0);return r[t]=n,r}var it=class extends fe{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,I.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ce(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(nt(e,n).forEach(e=>{e.destroy()}),nt(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=le(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new se(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=rt(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&I.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},q=e(n(),1);function at({queries:e,...t},n){let r=L(n),i=_e(),a=Se(),o=q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Oe(e),Ee(e,a,r.getQueryCache().get(e.queryHash))}),Ce(a);let[s]=q.useState(()=>new it(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;q.useSyncExternalStore(q.useCallback(e=>d?s.subscribe(I.batchCalls(e)):he,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),q.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>xe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&xe(n,e)?be(n,new se(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Te({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var ot=H(`BriefcaseBusiness`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),st=H(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),ct=H(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),lt=H(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),ut=H(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),dt=H(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),ft=tt();function J(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function pt(e){let{request:t,result:n}=e,r=new Date().toISOString();return n.type===`skill`?{type:`skill`,spec:n.spec,id:t.skill??n.spec,label:t.skill??n.name??n.spec,source:`workspace`,installPath:t.installPath,installedAt:r}:{type:n.type,spec:n.spec,id:n.name??n.spec,label:n.name??n.spec,source:`marketplace`,origin:`marketplace`,enabled:t.enabled??!0,runtimeStatus:t.enabled===!1?`disabled`:`ready`,installedAt:r}}function mt(e,t){let{id:n,spec:r}=t;return!!(r&&e.spec===r||n&&e.id===n)}function ht(e,t){return t??{type:e,total:0,specs:[],records:[]}}function gt(e){let{result:t,view:n}=e,r=ht(t.type,n),i=pt(e),a=r.records.findIndex(e=>mt(e,{id:i.id,spec:i.spec})),o=[...r.records];return a>=0?o[a]={...o[a],...i}:o.unshift(i),{...r,type:t.type,records:o,specs:J(o),total:o.length}}function _t(e){let{request:t,result:n,view:r}=e,i=ht(n.type,r);if(n.action===`uninstall`||n.action===`remove`){let e=i.records.filter(e=>!mt(e,{id:n.id,spec:t.spec}));return{...i,records:e,specs:J(e),total:e.length}}let a=i.records.map(e=>mt(e,{id:n.id,spec:t.spec})?n.action===`disable`?{...e,enabled:!1,runtimeStatus:`disabled`}:n.action===`update`?{...e,installedAt:new Date().toISOString(),origin:e.origin??`marketplace`}:{...e,enabled:!0,runtimeStatus:`ready`}:e);return{...i,records:a,specs:J(a),total:a.length}}var vt=3e4;function yt(e){let t=Pe({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>M({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type&&xt(r,e)?t:void 0},staleTime:15e3,refetchInterval:e.q?!1:vt,refetchOnMount:`always`,refetchOnReconnect:`always`,refetchOnWindowFocus:`always`}),n=(0,q.useMemo)(()=>Ne(t.data),[t.data]);return{...t,data:n}}function bt(e,t=!0){return ye({queryKey:[`marketplace-recent-items`,e],queryFn:()=>M({type:e,sort:`updated`,page:1,pageSize:6}),enabled:t,staleTime:15e3,refetchInterval:vt,refetchOnMount:`always`,refetchOnReconnect:`always`,refetchOnWindowFocus:`always`})}function xt(e,t){return e.tag===t.tag&&e.scene===t.scene&&e.pageSize===t.pageSize}function St(e=!0){return ye({queryKey:[`marketplace-skill-scenes`],queryFn:je,enabled:e,staleTime:6e4})}function Ct(e,t=!0){let n=at({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>M({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,q.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{let i=typeof e.count==`number`?e.count:n[r]?.data?.total;typeof i==`number`&&t.set(e.scene,i)}),t},[n,e])}function wt(e){return ye({queryKey:[`marketplace-installed`,e],queryFn:()=>de(e),staleTime:1e4})}function Tt(){let e=L();return De({mutationFn:e=>oe(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>gt({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),P.success(t.message||a(`marketplaceInstallSuccessSkill`))},onError:e=>{P.error(e.message||a(`marketplaceInstallFailed`))}})}function Et(){let e=L();return De({mutationFn:e=>ge(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>_t({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`});let r=t.action===`enable`?a(`marketplaceEnableSuccess`):t.action===`disable`?a(`marketplaceDisableSuccess`):t.action===`update`?a(`marketplaceUpdateSuccess`):a(`marketplaceUninstallSuccess`);P.success(t.message||r)},onError:e=>{P.error(e.message||a(`marketplaceOperationFailed`))}})}var Y=i(),Dt=[`bg-amber-600`,`bg-orange-500`,`bg-yellow-600`,`bg-emerald-600`,`bg-teal-600`,`bg-cyan-600`,`bg-stone-600`,`bg-rose-500`,`bg-violet-500`];function Ot(e){let{name:t,fallback:n,className:r}=e,i=t||n,a=i.substring(0,2).toUpperCase();return(0,Y.jsx)(`div`,{className:o(`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-sm font-semibold text-white`,kt(i),r),children:a})}function kt(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Dt[Math.abs(t)%Dt.length]}function At({title:e,spec:t}){return(0,Y.jsxs)(Be,{delayDuration:400,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`div`,{className:`truncate text-[14px] font-semibold leading-tight text-gray-950`,children:e})}),(0,Y.jsx)(G,{className:`max-w-[300px] text-xs`,children:e})]}),(0,Y.jsx)(`div`,{className:`mb-2 mt-1 flex min-w-0 items-center gap-1.5`,children:t?(0,Y.jsxs)(U,{children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`span`,{className:`max-w-full truncate text-[11px] font-mono leading-tight text-gray-400`,children:t})}),(0,Y.jsx)(G,{className:`max-w-[300px] break-all font-mono text-xs`,children:t})]}):null})]})}function jt(e){let{item:t,record:n,state:r,onInstall:i,onManage:s}=e,{isInstalling:c,canUpdate:l,canUninstall:u,busyAction:d}=r,f=!!d;return t&&!n||n&&(l||u)?(0,Y.jsxs)(`div`,{className:o(`flex shrink-0 items-center justify-end gap-1.5 opacity-100 transition-opacity duration-150`,`md:pointer-events-none md:opacity-0`,`md:group-hover:pointer-events-auto md:group-hover:opacity-100`,`md:group-focus-within:pointer-events-auto md:group-focus-within:opacity-100`),children:[t&&!n&&(0,Y.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),i(t)},disabled:c,className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md bg-primary px-2 text-[11px] font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3`}),a(c?`marketplaceInstalling`:`marketplaceInstall`)]}),n&&l&&(0,Y.jsxs)(`button`,{disabled:f,onClick:e=>{e.stopPropagation(),s(`update`,n)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-blue-200/80 bg-white px-2 text-[11px] font-medium text-blue-600 transition-colors hover:border-blue-300 hover:bg-blue-50 disabled:opacity-50`,children:[(0,Y.jsx)(Ze,{className:`h-3 w-3`}),a(d===`update`?`marketplaceUpdating`:`marketplaceUpdate`)]}),n&&u&&(0,Y.jsxs)(`button`,{disabled:f,onClick:e=>{e.stopPropagation(),s(`uninstall`,n)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-gray-200/80 bg-white px-2 text-[11px] font-medium text-gray-500 transition-colors hover:border-rose-200 hover:bg-rose-50 hover:text-rose-600 disabled:opacity-50`,children:[(0,Y.jsx)(Qe,{className:`h-3 w-3`}),a(d===`uninstall`?`marketplaceRemoving`:`marketplaceUninstall`)]})]}):null}function Mt(e){let{record:t,disabled:n}=e;return t?(0,Y.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-end`,children:(0,Y.jsx)(Nt,{disabled:n})}):null}function Nt(e){let{disabled:t}=e,n=a(t?`marketplaceDisabledStatus`:`marketplaceInstalledStatus`);return(0,Y.jsx)(Be,{delayDuration:300,children:(0,Y.jsxs)(U,{children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`span`,{"aria-label":n,className:o(`inline-flex h-5 w-5 items-center justify-center`,t?`text-gray-400`:`text-emerald-700`),children:t?(0,Y.jsx)(D,{className:`h-4 w-4 opacity-40`}):(0,Y.jsx)(D,{className:`h-4 w-4`})})}),(0,Y.jsx)(G,{className:`text-xs`,children:n})]})})}function Pt(e){let{item:t,record:n,installState:r,manageState:i,onOpen:o,onInstall:s,onManage:c}=e,{language:l}=K(),u=z(l),d=t?.name??n?.label??n?.id??n?.spec??a(`marketplaceUnknownItem`),f=B(t?.summaryI18n,t?.summary,u)||(n?a(`marketplaceInstalledLocalSummary`):``),p=t?.install.spec??n?.spec??``,m=t?.tags??[],h=n?.id||n?.spec,g=h?i.actionsByTarget.get(h):void 0,_=n?.type===`skill`&&n.source===`workspace`,v=n?.type===`skill`&&n.origin===`marketplace`,y=n?n.enabled===!1||n.runtimeStatus===`disabled`:!1,b=t?.install.spec,x=typeof b==`string`&&r.installingSpecs.has(b);return(0,Y.jsxs)(`article`,{onClick:o,className:`group flex h-full min-h-[156px] cursor-pointer flex-col rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(Ot,{name:d,fallback:p||a(`marketplaceTypeSkill`),className:`h-9 w-9 rounded-lg text-xs`}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,Y.jsx)(At,{title:d,spec:p})}),(0,Y.jsx)(Mt,{record:n,disabled:y})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`p`,{className:`line-clamp-2 text-left text-[12px] leading-relaxed text-gray-500`,children:f}),(0,Y.jsxs)(`div`,{className:`mt-auto flex min-w-0 items-end justify-between gap-2 pt-2`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(Ft,{tags:m})}),(0,Y.jsx)(jt,{item:t,record:n,state:{isInstalling:x,canUpdate:v,canUninstall:_,busyAction:g},onInstall:s,onManage:c})]})]})]})}function Ft({tags:e}){let t=e.filter(It).slice(0,3);return t.length===0?null:(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5 overflow-hidden`,children:t.map(e=>(0,Y.jsx)(`span`,{className:`max-w-[104px] truncate rounded-md bg-gray-100 px-2 py-0.5 text-[11px] font-medium leading-5 text-gray-500`,children:e},e))})}function It(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function Lt({model:e,showTitle:t,operationState:n,scroll:r,actions:i}){let{scope:a,entries:s,header:c,status:l,emptyLabel:u,errorLabel:d}=e,{showSkeleton:f,isRefreshing:p,error:m}=l,{hasMore:h,loadingMore:g,sentinelRef:_}=r,{installState:v,manageState:y}=n,{onOpen:b,onInstall:x,onManage:S}=i;return(0,Y.jsxs)(`section`,{className:o(`flex min-h-full flex-col`,t&&`gap-3`),children:[t&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-950`,children:c.title}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-gray-500`,children:[p&&(0,Y.jsx)(`span`,{className:`font-medium text-primary`,children:c.refreshingLabel}),(0,Y.jsx)(`span`,{children:c.summary})]})]}),m&&(0,Y.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[d,`: `,m.message]}),p&&(0,Y.jsx)(`div`,{"data-testid":`marketplace-list-refreshing`,className:`h-0.5 overflow-hidden rounded-full bg-primary/10`,children:(0,Y.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-primary`})}),(0,Y.jsxs)(`div`,{"data-testid":f?`marketplace-list-skeleton`:void 0,className:o(`grid grid-cols-1 gap-2.5 md:grid-cols-2 xl:grid-cols-3`,f&&`min-h-0 flex-1 auto-rows-[156px] content-start`),children:[f&&(0,Y.jsx)(V,{count:36}),!f&&!m&&s.map(e=>(0,Y.jsx)(Pt,{item:e.item,record:e.record,installState:v,manageState:y,onOpen:()=>b(e.item,e.record),onInstall:x,onManage:S},e.key))]}),!f&&!m&&s.length===0&&(0,Y.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:u}),a===`all`&&!f&&!m&&(0,Y.jsx)(Ie,{hasMore:h,loading:g,sentinelRef:_})]})}function Rt(e){let{entry:t,language:n,localeFallbacks:r,installState:i,layout:s=`rail`,onOpen:c,onInstall:l}=e,{item:u,record:d}=t,f=B(u.summaryI18n,u.summary,r),p=u.install.spec,m=i.installingSpecs.has(p),h=!!d;return(0,Y.jsxs)(`article`,{onClick:()=>c(t),className:o(`group flex min-h-[166px] cursor-pointer flex-col justify-between rounded-xl border border-gray-200/70 bg-white p-3 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,s===`rail`?`w-[260px] shrink-0`:`w-full min-w-0`),children:[(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(Ot,{name:u.name,fallback:u.install.spec}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,Y.jsx)(`div`,{className:`truncate text-[13px] font-semibold leading-tight text-gray-950`,children:u.name}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] font-mono leading-tight text-gray-400`,children:zt(u)})]})]}),(0,Y.jsx)(`p`,{className:`line-clamp-2 text-[12px] leading-relaxed text-gray-500`,children:f}),(0,Y.jsx)(Bt,{tags:u.tags})]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-gray-400`,children:Ht(u.updatedAt)}),h?(0,Y.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 text-[11px] font-semibold text-emerald-700`,children:[(0,Y.jsx)(D,{className:`h-3.5 w-3.5`}),Ut({zh:`已安装`,en:`Installed`},n)]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:m,onClick:e=>{e.stopPropagation(),l(u)},className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-gray-200 bg-white px-2 text-[11px] font-semibold text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 disabled:opacity-50`,children:[(0,Y.jsx)(Ge,{className:`h-3.5 w-3.5`}),a(m?`marketplaceInstalling`:`marketplaceInstall`)]})]})]})}function zt(e){return e.slug||e.install.spec}function Bt({tags:e}){let t=e.filter(Vt).slice(0,2);return t.length===0?null:(0,Y.jsx)(`div`,{className:`mt-auto truncate pt-2 text-[11px] font-medium text-gray-400`,children:t.join(` / `)})}function Vt(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function Ht(e){return e.slice(0,10)||e}function Ut(e,t){return t.startsWith(`zh`)?e.zh:e.en}var Wt=[{scene:`development-debugging`,title:{zh:`开发与调试`,en:`Development`},summary:{zh:`代码审查、错误定位、架构分析与交付验证。`,en:`Review, debug, analyze, and verify delivery work.`},icon:dt,tone:`dark`,span:`md:col-span-2`},{scene:`office-collaboration`,title:{zh:`办公协作`,en:`Office Work`},summary:{zh:`连接文档、日历、会议、邮件和团队通信。`,en:`Connect docs, calendars, meetings, mail, and teams.`},icon:ot,tone:`green`,span:`md:col-span-2`},{scene:`writing-content`,title:{zh:`写作与内容`,en:`Writing`},summary:{zh:`把调研、写作、润色和发布组织成连续工作流。`,en:`Turn research, writing, polishing, and publishing into one flow.`},icon:ut,tone:`amber`,span:`md:col-span-2`},{scene:`browser-automation`,title:{zh:`浏览器自动化`,en:`Browser`},summary:{zh:`操作网页、捕获动态内容并验证真实用户路径。`,en:`Operate pages, capture dynamic content, and verify user paths.`},icon:h,tone:`blue`,span:`md:col-span-2`},{scene:`local-environment`,title:{zh:`本地环境`,en:`Local`},summary:{zh:`管理终端、文件、运行时和本地服务。`,en:`Manage shells, files, runtimes, and local services.`},icon:T,tone:`violet`,span:`md:col-span-1`},{scene:`social-platforms`,title:{zh:`社交平台`,en:`Social`},summary:{zh:`处理发布、互动、检索和内容分发。`,en:`Handle posting, interaction, search, and distribution.`},icon:lt,tone:`sky`,span:`md:col-span-1`},{scene:`nextclaw-official`,title:{zh:`NextClaw 官方`,en:`NextClaw Official`},summary:{zh:`优先查看由 NextClaw 维护的原生能力。`,en:`Browse native capabilities maintained by NextClaw.`},icon:Ue,tone:`teal`,span:`md:col-span-2`}],Gt={icon:Ue,tone:`dark`,span:`md:col-span-2`},Kt={dark:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-stone-600 bg-stone-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},blue:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-cyan-600 bg-cyan-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},green:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-emerald-600 bg-emerald-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},amber:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-amber-600 bg-amber-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},violet:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-violet-500 bg-violet-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},sky:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-sky-500 bg-sky-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},teal:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-teal-600 bg-teal-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`}},qt=`grid grid-cols-[repeat(auto-fill,minmax(240px,320px))] justify-start gap-3`;function Jt(e){let{recentEntries:t,scenes:n,isScenesLoading:r,isItemsLoading:i,language:a,installState:o,onOpen:s,onInstall:c,onOpenScene:l}=e,u=z(a);return(0,Y.jsxs)(`div`,{className:`mb-4 space-y-5`,children:[(0,Y.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,Y.jsx)(Qt,{icon:ct,title:X({zh:`场景`,en:`Scenes`},a),description:X({zh:`按使用场景浏览适合的技能组合。`,en:`Browse skills by how you plan to use them.`},a)}),r?(0,Y.jsx)(`div`,{"data-testid":`marketplace-scenes-skeleton`,className:`grid auto-rows-[104px] grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:(0,Y.jsx)(V,{count:Wt.length})}):(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:n.map(e=>(0,Y.jsx)(Yt,{scene:e,language:a,onSelect:l},e.scene))})]}),(i||t.length>0)&&(0,Y.jsx)(Zt,{icon:st,title:X({zh:`最近更新`,en:`Recently updated`},a),description:X({zh:`看看生态最近在补齐哪些能力。`,en:`See what the ecosystem has been improving lately.`},a),entries:t,language:a,localeFallbacks:u,isLoading:i,installState:o,onOpen:s,onInstall:c})]})}function Yt(e){let{scene:t,language:n,onSelect:r}=e,i=$t(t.scene),a=i.icon,s=Kt[i.tone];return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(t.scene),className:o(`group flex min-h-[74px] flex-col justify-center rounded-lg border px-3 py-2.5 text-left shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/70`,s.card),children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:o(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,s.icon),children:(0,Y.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold text-gray-950`,children:en(t,i,n)}),typeof t.count==`number`&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:nn(t.count,n)})]}),(0,Y.jsx)(`p`,{className:o(`mt-1 line-clamp-1 text-[11px] leading-relaxed`,s.text),children:tn(t,i,n)})]})})}function Xt(e){let{scene:t,entries:n,isLoading:r,language:i,localeFallbacks:a,installState:s,onBack:c,onOpen:l,onInstall:u}=e,d=$t(t.scene),f=d.icon,p=Kt[d.tone];return(0,Y.jsxs)(`section`,{className:`flex min-h-full flex-col`,children:[(0,Y.jsxs)(`div`,{className:`mb-4 flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":X({zh:`返回`,en:`Back`},i),children:(0,Y.jsx)(ze,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:o(`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border`,p.icon),children:(0,Y.jsx)(f,{className:`h-4 w-4`})}),(0,Y.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-gray-950`,children:en(t,d,i)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:X(r?{zh:`加载中`,en:`Loading`}:{zh:`${n.length} 个技能`,en:`${n.length} skills`},i)})]}),(0,Y.jsx)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-2`,children:(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[12px] leading-relaxed text-gray-500`,children:tn(t,d,i)})})]})]}),r?(0,Y.jsx)(`div`,{"data-testid":`marketplace-scene-skeleton`,className:o(qt,`min-h-0 flex-1 auto-rows-[166px] content-start`),children:(0,Y.jsx)(V,{count:24})}):n.length>0?(0,Y.jsx)(`div`,{className:qt,children:n.map(e=>(0,Y.jsx)(Rt,{entry:e,language:i,localeFallbacks:a,installState:s,layout:`grid`,onOpen:l,onInstall:u},e.item.id))}):(0,Y.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-200 py-8 text-center text-[12px] text-gray-500`,children:X({zh:`这个模块暂无技能。`,en:`No skills in this module yet.`},i)})]})}function Zt(e){let{icon:t,title:n,description:r,entries:i,language:a,localeFallbacks:o,isLoading:s,installState:c,onOpen:l,onInstall:u}=e;return(0,Y.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,Y.jsx)(Qt,{icon:t,title:n,description:r}),s?(0,Y.jsx)(`div`,{"data-testid":`marketplace-recent-skeleton`,className:`-mx-1 grid auto-rows-[166px] grid-cols-[repeat(4,260px)] gap-2.5 overflow-hidden px-1 pb-1.5`,children:(0,Y.jsx)(V,{count:4})}):(0,Y.jsx)(`div`,{className:`-mx-1 flex gap-2.5 overflow-x-auto px-1 pb-1.5 custom-scrollbar`,children:i.map(e=>(0,Y.jsx)(Rt,{entry:e,language:a,localeFallbacks:o,installState:c,onOpen:l,onInstall:u},e.item.id))})]})}function Qt({icon:e,title:t,description:n}){return(0,Y.jsx)(`div`,{className:`flex items-end justify-between gap-4`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-2 text-[14px] font-semibold text-gray-950`,children:[(0,Y.jsx)(e,{className:`h-4 w-4 text-primary`}),t]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[12px] leading-relaxed text-gray-500`,children:n})]})})}function X(e,t){return t.startsWith(`zh`)?e.zh:e.en}function $t(e){return Wt.find(t=>t.scene===e)??{scene:e,...Gt}}function en(e,t,n){return t.title?X(t.title,n):e.title}function tn(e,t,n){return t.summary?X(t.summary,n):e.description??e.scene}function nn(e,t){return t.startsWith(`zh`)?`${e} 个技能`:`${e} skills`}var rn=`https://skillhub.cn/`;function an(){return(0,Y.jsx)(Ke,{href:rn,external:!0,className:`h-7 shrink-0 px-1.5 text-[13px]`,children:a(`marketplaceExternalSkillSourceTitle`)})}function on(e){return(e??``).trim().toLowerCase()}function Z(e,t){let n=on(t);return n.length>0?`${e}:${n}`:``}function sn(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function cn(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function ln(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=Z(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function un(e,t){return t.get(Z(e.type,e.spec))||t.get(Z(e.type,e.id))||t.get(Z(e.type,e.label))}function dn(e,t,n,r){let i=on(n);if(!i)return!0;let a=B(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>on(e)).filter(Boolean).some(e=>e.includes(i))}function fn(e){let{items:t,recentItems:n,installedRecordLookup:r,scene:i,forcedType:a,typeFilter:o,scope:s,searchText:c,query:l,showListSkeleton:u,hasCatalogError:d}=e,f=St(o===`skill`),p=(0,q.useMemo)(()=>f.data?.scenes??[],[f.data?.scenes]),m=Ct(p,o===`skill`),h=(0,q.useMemo)(()=>p.map(e=>({...e,count:typeof e.count==`number`?e.count:m.get(e.scene)})),[m,p]),g=(0,q.useMemo)(()=>t.map(e=>({item:e,record:ln(e,r)})),[t,r]),_=(0,q.useMemo)(()=>n.map(e=>({item:e,record:ln(e,r)})),[r,n]),v=(0,q.useMemo)(()=>{let e=i?.trim();if(e)return h.find(t=>t.scene===e)??{scene:e,title:e}},[i,h]),y=o===`skill`&&!!i?.trim(),b=o===`skill`&&s===`all`&&!c.trim()&&!l&&!y,x=u||t.length>=4,S=b&&!d&&x&&h.length===0&&f.isLoading;return{entries:g,recentEntries:_,scenes:h,selectedScene:v,sceneEntries:g,isSceneRoute:y,isScenesLoading:S,showShelves:b&&!d&&x&&(u||h.length>0||S),backPath:a?`/skills`:`/marketplace/skills`,pathPrefix:a?`/skills/scenes`:`/marketplace/skills/scenes`}}function pn(){let e=Tt(),t=Et(),{confirm:n,ConfirmDialog:r}=We(),[i,o]=(0,q.useState)(new Set),[s,c]=(0,q.useState)(new Map);return{installState:{installingSpecs:i},manageState:{actionsByTarget:s},handleInstall:async t=>{let n=t.install.spec;if(!i.has(n)){o(e=>new Set(e).add(n));try{await e.mutateAsync({type:t.type,spec:n,kind:t.install.kind,skill:t.slug,installPath:`skills/${t.slug}`})}catch{}finally{o(e=>{let t=new Set(e);return t.delete(n),t})}}},handleManage:async(e,r)=>{let i=e===`update`?r.catalogSlug||r.id||r.spec:r.id||r.spec;if(!(!i||s.has(i))&&!(e===`uninstall`&&!await n({title:`${a(`marketplaceUninstallTitle`)} ${i}?`,description:a(`marketplaceUninstallDescription`),confirmLabel:a(`marketplaceUninstall`),variant:`destructive`}))){c(t=>new Map(t).set(i,e));try{await t.mutateAsync({type:r.type,action:e,id:i,spec:r.spec})}finally{c(e=>{let t=new Map(e);return t.delete(i),t})}}},ConfirmDialog:r}}function mn(e){let t=$e(),n=(0,q.useRef)({byKey:new Map,seq:0});return{openItemDetail:async(r,i)=>{let o=r?.name??i?.label??i?.id??i?.spec??a(`marketplaceUnknownItem`),s=Fe(r?`skill`:`skill-local`,r?.slug??i?.id??i?.spec??o),c=r?`marketplace:${r.type}:${r.slug}`:`marketplace:${i?.type??`unknown`}:${i?.id??i?.spec??o}`,l=a(`marketplaceTypeSkill`);if(!r){R(t,{id:s,title:o,typeLabel:l,spec:i?.spec??`-`,status:`ready`,summary:a(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify(i??{},null,2),contentRaw:`-`});return}let u=n.current.seq+1;n.current.seq=u,n.current.byKey.set(c,u);let d=B(r.summaryI18n,r.summary,e);R(t,{id:s,title:o,typeLabel:l,spec:r.install.spec,status:`loading`,summary:d,tags:r.tags,author:r.author});try{let e=await pe(r.slug);if(n.current.byKey.get(c)!==u)return;R(t,{id:s,title:o,typeLabel:l,spec:r.install.spec,status:`ready`,summary:d,metadataRaw:e.metadataRaw,contentRaw:e.bodyRaw||e.raw,sourceUrl:e.sourceUrl,sourceLabel:`Source (${e.source})`,tags:r.tags,author:r.author},{activate:!1})}catch(e){if(n.current.byKey.get(c)!==u)return;R(t,{id:s,title:o,typeLabel:l,spec:r.install.spec,status:`error`,summary:d,metadataRaw:JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),contentRaw:a(`marketplaceOperationFailed`)},{activate:!1})}}}}function hn(e){let{scope:t,typeFilter:n,query:r,localeFallbacks:i,catalogView:o,installedView:s,isCatalogLoading:c,isCatalogFetching:l,isCatalogFetchingNextPage:u,catalogError:d,isInstalledLoading:f,installedError:p}=e,m=(0,q.useMemo)(()=>s?.records??[],[s?.records]),h=(0,q.useMemo)(()=>o?.items??[],[o?.items]),g=(0,q.useMemo)(()=>sn(h),[h]),_=(0,q.useMemo)(()=>cn(m),[m]),v=(0,q.useMemo)(()=>m.filter(e=>e.type===n).map(e=>({key:`${e.type}:${e.spec}:${e.id??``}`,record:e,item:un(e,g)})).filter(e=>dn(e.record,e.item,r,i)).sort((e,t)=>gn(e.record,t.record)),[m,n,g,r,i]),y=(0,q.useMemo)(()=>t===`installed`?v:h.map(e=>({key:e.id,item:e,record:ln(e,_)})),[h,v,_,t]),b=t===`all`&&c&&!o||t===`installed`&&f&&!s,x=t===`all`&&!b&&!!o&&l&&!u,S=t===`installed`?f&&!s?a(`loading`):`${v.length} ${a(`marketplaceInstalledSkillsCountSuffix`)}`:o?`${o.total} ${a(`marketplaceSkillsCountSuffix`)}`:a(`loading`),C=t===`all`&&d?d:t===`installed`&&p?p:void 0,w={scope:t,entries:y,header:{title:a(t===`installed`?`marketplaceSectionInstalledSkills`:`marketplaceAllSkills`),summary:S,refreshingLabel:a(`marketplaceRefreshingResults`)},status:{showSkeleton:b,isRefreshing:x,error:C},emptyLabel:a(t===`installed`?`marketplaceNoInstalledSkills`:`marketplaceNoSkills`),errorLabel:a(t===`installed`?`marketplaceErrorLoadingInstalledSkills`:`marketplaceErrorLoadingSkillsData`)};return{allItems:h,installedRecordLookup:_,installedTotal:s?.total??0,itemListView:w,showListSkeleton:b,isRefreshingList:x}}function gn(e,t){let n=Date.parse(e.installedAt??``),r=Date.parse(t.installedAt??``);return Number.isNaN(n)||Number.isNaN(r)||n===r?e.spec.localeCompare(t.spec):r-n}var _n=20;function vn({forcedType:e}={}){let t=b(),n=p(),{language:r}=K(),i=`skill`,o=(0,q.useMemo)(()=>z(r),[r]),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(`all`),[m,h]=(0,q.useState)(`relevance`),{installState:g,manageState:_,handleInstall:v,handleManage:y,ConfirmDialog:x}=pn(),{openItemDetail:S}=mn(o);(0,q.useEffect)(()=>{let e=setTimeout(()=>{u(s.trim())},250);return()=>clearTimeout(e)},[s]);let C=wt(i),w=i===`skill`?n.scene?.trim():void 0,T=yt({q:w?void 0:l||void 0,scene:w,type:i,sort:m,pageSize:_n}),ee=bt(i,d===`all`&&!s.trim()&&!l&&!w),{containerRef:E,sentinelRef:te}=Le({disabled:d!==`all`||T.isError||!T.hasNextPage||T.isFetchingNextPage,onLoadMore:()=>T.fetchNextPage(),watchValue:`${i}:${d}:${l}:${w??``}:${m}:${T.data?.loadedItems??0}:${T.data?.loadedPages??0}`});(0,q.useEffect)(()=>{let e=E.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[E,l,w,d,m,i]);let D=hn({scope:d,typeFilter:i,query:l,localeFallbacks:o,catalogView:T.data,installedView:C.data,isCatalogLoading:T.isLoading,isCatalogFetching:T.isFetching,isCatalogFetchingNextPage:T.isFetchingNextPage,catalogError:T.isError?T.error:void 0,isInstalledLoading:C.isLoading,installedError:C.isError?C.error:void 0}),O=fn({items:D.allItems,recentItems:ee.data?.items??[],installedRecordLookup:D.installedRecordLookup,scene:w,forcedType:e,typeFilter:i,scope:d,searchText:s,query:l,showListSkeleton:D.showListSkeleton,hasCatalogError:T.isError});return(0,Y.jsxs)(ae,{className:`flex h-full min-h-0 flex-col pb-0`,children:[!O.isSceneRoute&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3 border-b border-gray-200/60`,children:[(0,Y.jsx)(Ye,{value:d,onValueChange:e=>f(e),children:(0,Y.jsxs)(Je,{className:`mb-0 h-auto flex-1 justify-start gap-6 rounded-none border-b-0 bg-transparent p-0 text-gray-500`,children:[(0,Y.jsx)(qe,{value:`all`,className:`rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:a(`marketplaceTabMarketplaceSkills`)}),(0,Y.jsxs)(qe,{value:`installed`,className:`gap-1.5 rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:[a(`marketplaceTabInstalledSkills`),(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:D.installedTotal})]})]})}),(0,Y.jsx)(an,{})]}),(0,Y.jsx)(Me,{scope:d,searchText:s,isRefreshing:D.isRefreshingList,searchPlaceholder:a(`marketplaceSearchPlaceholderSkills`),sort:m,onSearchTextChange:c,onSortChange:h})]}),(0,Y.jsx)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Y.jsxs)(`div`,{ref:E,className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1`,"aria-busy":D.showListSkeleton||T.isFetchingNextPage,children:[O.isSceneRoute&&O.selectedScene&&(0,Y.jsx)(Xt,{scene:O.selectedScene,entries:O.sceneEntries,isLoading:D.showListSkeleton,language:r,localeFallbacks:o,installState:g,onBack:()=>t(O.backPath),onOpen:e=>void S(e.item,e.record),onInstall:v}),O.isSceneRoute&&!D.showListSkeleton&&(0,Y.jsx)(Ie,{hasMore:!!T.hasNextPage,loading:T.isFetchingNextPage,sentinelRef:te}),O.showShelves&&(0,Y.jsx)(Jt,{recentEntries:O.recentEntries,scenes:O.scenes,isScenesLoading:O.isScenesLoading,isItemsLoading:D.showListSkeleton||ee.isLoading,language:r,installState:g,onOpen:e=>void S(e.item,e.record),onInstall:v,onOpenScene:e=>t(`${O.pathPrefix}/${e}`)}),!O.isSceneRoute&&(0,Y.jsx)(Lt,{model:D.itemListView,showTitle:O.showShelves||!D.showListSkeleton,operationState:{installState:g,manageState:_},scroll:{hasMore:!!T.hasNextPage,loadingMore:T.isFetchingNextPage,sentinelRef:te},actions:{onOpen:(e,t)=>void S(e,t),onInstall:v,onManage:y}})]})}),(0,Y.jsx)(x,{})]})}var yn=`NextClaw`,bn=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function xn(e,t){return e===t||e.startsWith(`${t}/`)}function Sn(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of bn)if(xn(t,e))return a(n);return a(`settings`)}function Cn(e){let t=e.toLowerCase();return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||t===`[::1]`||t.startsWith(`127.`)}function wn(e){let t=e?.host.trim(),n=e?.hostname.trim(),r=e?.port.trim();return!t||!n?null:Cn(n)?r||null:t}function Tn(e,t){let n=wn(t);return`${yn}${n?` ${n}`:``} - ${Sn(e)}`}var En={...u,...Re};function Dn({children:e,sideDockManager:t}){let{isOpen:n,mode:r}=$e();Ve();let{pathname:i}=x(),{language:a}=K(),{isMobile:o}=Xe(),s=C(),c=m(e=>e.isVisible);m(e=>e.pinnedItems);let l={getDockState:t.getDockState,pinTab:t.pinTab,unpinTab:t.unpinTab};return(0,q.useEffect)(()=>{document.title=Tn(i,window.location)},[i,a]),o&&s!==`win32`?(0,Y.jsx)(ee,{pathname:i,isDocBrowserOpen:n,docBrowserDockControls:l,docBrowserRenderers:En,topbarLeadingInset:s===`darwin`?`4.75rem`:void 0,children:e}):(0,Y.jsx)(ne,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:l,docBrowserRenderers:En,sideDock:c?(0,Y.jsx)(S,{manager:t}):null,children:e})}function On({children:e}){let t=te();return(0,Y.jsx)(et,{manager:t.docBrowserManager,children:(0,Y.jsx)(Dn,{sideDockManager:t.sideDockManager,children:e})})}function kn(){let{isMobile:e}=Xe();return e?(0,Y.jsx)(v,{}):(0,Y.jsx)(y,{to:`/model`,replace:!0})}function An(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function jn(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function Mn(e,t){e&&An(t)&&e.invalidateQueries({queryKey:[`config`]}),jn(e,t)}function Nn(e){let t=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let n=F.eventBus.on(j.connectionOpen,()=>{A.handleConnectionRestored(),k.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=F.eventBus.on(j.connectionClose,()=>{A.handleConnectionInterrupted(null),t.current=!0}),i=F.eventBus.on(j.connectionError,e=>{A.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=F.eventBus.on(j.configUpdated,({path:t})=>{Mn(e,t)}),o=F.eventBus.on(j.runtimeUpdateSnapshot,e=>{k.reportSnapshot(e)}),s=F.eventBus.on(j.sessionRunStatus,t=>{N(e,{type:`session.run-status`,payload:t})}),c=F.eventBus.on(j.sessionSummaryUpsert,t=>{N(e,{type:`session.summary.upsert`,payload:t})}),l=F.eventBus.on(j.sessionSummaryDelete,t=>{N(e,{type:`session.summary.delete`,payload:t})}),u=F.eventBus.on(j.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var Pn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ModelConfigPage:e}=await import(`./model-config-page-oNqnMXNY.js`);return{ModelConfigPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))).ModelConfigPage})),Fn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{AppearanceSettingsPage:e}=await import(`./appearance-settings-page-BZSd1SrH.js`);return{AppearanceSettingsPage:e}},__vite__mapDeps([19,1,20,21,5,3,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35]))).AppearanceSettingsPage})),Q=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ChatPage:e}=await import(`./chat-page-D2xfR6TK.js`);return{ChatPage:e}},__vite__mapDeps([36,1,5,3,20,21,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35,6,37,38,17]))).ChatPage})),In=(0,q.lazy)(async()=>({default:(await s(async()=>{let{SearchConfigPage:e}=await import(`./search-config-page-DzkpSGFH.js`);return{SearchConfigPage:e}},__vite__mapDeps([39,1,7,5,3,2,25,10,11,32,14,40,15,17]))).SearchConfigPage})),Ln=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ProvidersConfigPage:e}=await import(`./providers-config-page-CP-OnvLK.js`);return{ProvidersConfigPage:e}},__vite__mapDeps([41,1,5,3,7,22,8,2,23,25,30,32,14,26,37,33,34,40,15,17,18,11,9]))).ProvidersConfigPage})),Rn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-C_x83ZCT.js`);return{ChannelsList:e}},__vite__mapDeps([42,1,5,3,7,2,25,4,10,11,31,32,14,12,23,34,40,38,15,17,18]))).ChannelsList})),zn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-u_fuHxc8.js`);return{RuntimeConfig:e}},__vite__mapDeps([43,1,20,21,5,3,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35,44,45,15,17]))).RuntimeConfig})),Bn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-DEOMOsDN.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([46,7,1,5,3,2,29,10,11,27,44]))).DesktopUpdateConfig})),Vn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{SecurityConfig:e}=await import(`./security-config-yraYoy9s.js`);return{SecurityConfig:e}},__vite__mapDeps([47,2,1,3]))).SecurityConfig})),Hn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{SecretsConfigPage:e}=await import(`./secrets-config-page-DhoLYm7Z.js`);return{SecretsConfigPage:e}},__vite__mapDeps([48,1,7,5,3,2,26,45,33,15,17]))).SecretsConfigPage})),Un=(0,q.lazy)(async()=>({default:(await s(async()=>{let{RemoteAccessPage:e}=await import(`./remote-2gZkJSX4.js`);return{RemoteAccessPage:e}},__vite__mapDeps([49,20,1,21,5,3,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35]))).RemoteAccessPage})),Wn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-CaUFv37E.js`);return{McpMarketplacePage:e}},__vite__mapDeps([50,51,1,5,3,7,22,8,2,23,28,24,25,10,11,26,27,13,14,12,38,16]))).McpMarketplacePage}));function Gn(){return(0,Y.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function Kn({children:e}){return(0,Y.jsx)(q.Suspense,{fallback:(0,Y.jsx)(Gn,{}),children:e})}function $(e){return(0,Y.jsx)(Kn,{children:e})}var qn=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:$((0,Y.jsx)(Q,{view:`chat`}))},{path:`/agents`,element:$((0,Y.jsx)(Q,{view:`agents`}))},{path:`/skills`,element:$((0,Y.jsx)(Q,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:$((0,Y.jsx)(Q,{view:`skills`}))},{path:`/cron`,element:$((0,Y.jsx)(Q,{view:`cron`}))},{path:`/appearance`,element:$((0,Y.jsx)(Fn,{}))},{path:`/model`,element:$((0,Y.jsx)(Pn,{}))},{path:`/search`,element:$((0,Y.jsx)(In,{}))},{path:`/providers`,element:$((0,Y.jsx)(Ln,{}))},{path:`/channels`,element:$((0,Y.jsx)(Rn,{}))},{path:`/runtime`,element:$((0,Y.jsx)(zn,{}))},{path:`/updates`,element:$((0,Y.jsx)(Bn,{}))},{path:`/remote`,element:$((0,Y.jsx)(Un,{}))},{path:`/security`,element:$((0,Y.jsx)(Vn,{}))},{path:`/secrets`,element:$((0,Y.jsx)(Hn,{}))},{path:`/settings`,element:(0,Y.jsx)(kn,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:$((0,Y.jsx)(Wn,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function Jn(e){return`redirectTo`in e?(0,Y.jsx)(E,{path:e.path,element:(0,Y.jsx)(y,{to:e.redirectTo,replace:!0})},e.path):(0,Y.jsx)(E,{path:e.path,element:e.element},e.path)}function Yn(){return(0,Y.jsx)(w,{children:qn.map(Jn)})}function Xn(){return Nn(we),ue(),(0,q.useEffect)(()=>(k.start(),()=>{k.stop()}),[]),(0,Y.jsxs)(O,{children:[(0,Y.jsx)(On,{children:(0,Y.jsx)(Yn,{})}),(0,Y.jsx)(d,{}),(0,Y.jsx)(l,{})]})}function Zn(){let e=me(),t=e.isError&&Ae(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,Y.jsx)(Xn,{}):e.data?.enabled&&!e.data.authenticated?(0,Y.jsx)(c,{username:e.data.username}):(0,Y.jsx)(Xn,{})}function Qn(){return(0,q.useEffect)(()=>{ie()},[]),(0,Y.jsxs)(ke,{client:we,children:[(0,Y.jsx)(Zn,{}),(0,Y.jsx)(g,{}),(0,Y.jsx)(ve,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var $n=window.nextclawDesktop?.platform===`win32`?_:re;(0,ft.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(q.StrictMode,{children:(0,Y.jsx)(f,{children:(0,Y.jsx)(He,{children:(0,Y.jsx)($n,{children:(0,Y.jsx)(Qn,{})})})})}));export{vn as t};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/model-config-page-oNqnMXNY.js","assets/chunk-DseTPa7n.js","assets/api-DGG69ZcJ.js","assets/react-B0LbRnAE.js","assets/book-open-BhaS5BJv.js","assets/dist-C87P4QWA.js","assets/provider-scoped-model-input-B7rQM4b6.js","assets/select-CYHT8P5S.js","assets/popover-Txwrum65.js","assets/provider-models-CXUgDxGR.js","assets/navigation-link-Dk6VdDkc.js","assets/host-capabilities-B-TtABsP.js","assets/loader-circle-CAnHHSrY.js","assets/doc-browser-context-tE0--wSa.js","assets/middleware-Df-a4x-q.js","assets/form-actions-J0tIaUdK.js","assets/skeleton-BQuylYFO.js","assets/use-config-DCzwgChy.js","assets/config-hints-S3g-UVZb.js","assets/appearance-settings-page-Byr55LGb.js","assets/app-presenter-provider-Dp90n1Va.js","assets/preload-helper-D4M6sveU.js","assets/confirm-dialog-o_VPKvVD.js","assets/x-NZxXyqW1.js","assets/doc-browser-DQ75iUkA.js","assets/search-UKxiouNi.js","assets/plus-DjdTWPjQ.js","assets/refresh-cw-C84mMku5.js","assets/use-confirm-dialog-WZ94CehU.js","assets/card-Bcr5YM8F.js","assets/eye-DL9QkrKg.js","assets/tabs-BCihm1zK.js","assets/use-viewport-layout-CZ-3pMne.js","assets/trash-2-Bo3DWiju.js","assets/logo-badge-BYTbZbOF.js","assets/app-presenter-provider-D3BuuOyZ.css","assets/chat-page-CEavSS6B.js","assets/settings-2-DGh4bGSi.js","assets/tag-chip-De0iz4o2.js","assets/search-config-page-DzkpSGFH.js","assets/config-split-page-RXAoLeNv.js","assets/providers-config-page-CP-OnvLK.js","assets/channels-list-page-C_x83ZCT.js","assets/runtime-config-page-CIGtssWi.js","assets/rotate-cw-DQJhDnjg.js","assets/save-R_qyrHpa.js","assets/desktop-update-config-DEOMOsDN.js","assets/security-config-yraYoy9s.js","assets/secrets-config-page-DhoLYm7Z.js","assets/remote-_L4pTEaW.js","assets/mcp-marketplace-page-CaUFv37E.js","assets/mcp-marketplace-page-COWlzeP1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,t}from"./chunk-DseTPa7n.js";import{h as n,m as r,p as i,r as a,u as o}from"./react-B0LbRnAE.js";import{t as s}from"./preload-helper-D4M6sveU.js";import{B as c,D as l,E as u,V as d,_ as f,_t as p,a as m,at as h,b as g,dt as _,f as v,ft as y,gt as b,ht as x,i as S,m as C,mt as w,ot as T,p as ee,pt as E,r as te,st as D,t as O,u as ne,ut as re,y as ie}from"./app-presenter-provider-Dp90n1Va.js";import{$t as ae,At as k,B as oe,Cn as se,Dn as ce,En as le,Ft as ue,I as de,It as A,Jt as j,L as M,On as fe,R as pe,St as me,Tn as he,V as ge,_n as _e,an as ve,cn as ye,dn as be,fn as xe,gn as Se,hn as Ce,in as we,m as N,mn as Te,on as P,pn as Ee,sn as De,un as Oe,vn as ke,vt as F,wn as I,xt as Ae,yn as L,z as je}from"./api-DGG69ZcJ.js";import{a as R,c as Me,d as Ne,f as Pe,i as Fe,l as Ie,n as Le,o as z,r as Re,s as B,u as V}from"./mcp-marketplace-page-COWlzeP1.js";import{c as H}from"./dist-C87P4QWA.js";import{n as ze}from"./search-UKxiouNi.js";import{a as U,c as W,o as G,s as Be}from"./doc-browser-DQ75iUkA.js";import{i as Ve,n as He,o as Ue,r as K,t as We}from"./use-confirm-dialog-WZ94CehU.js";import{o as Ge}from"./card-Bcr5YM8F.js";import{t as Ke}from"./navigation-link-Dk6VdDkc.js";import{i as qe,r as Je,t as Ye}from"./tabs-BCihm1zK.js";import{t as Xe}from"./use-viewport-layout-CZ-3pMne.js";import{t as Ze}from"./refresh-cw-C84mMku5.js";import{t as Qe}from"./trash-2-Bo3DWiju.js";import{n as $e,t as et}from"./doc-browser-context-tE0--wSa.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var tt=t((e=>{var t=r();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}));function nt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function rt(e,t,n){let r=e.slice(0);return r[t]=n,r}var it=class extends fe{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,I.batch(()=>{let e=this.#i,t=this.#f(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!ce(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(nt(e,n).forEach(e=>{e.destroy()}),nt(n,e).forEach(e=>{e.subscribe(t=>{this.#p(e,t)})})),this.#m()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#f(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=le(this.#a,t(e))),this.#a}return e}#f(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new se(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#p(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=rt(this.#t,n,t),this.#m())}#m(){if(this.hasListeners()){let e=this.#a,t=this.#u(this.#t,this.#l);e!==this.#d(t,this.#r?.combine)&&I.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},q=e(n(),1);function at({queries:e,...t},n){let r=L(n),i=_e(),a=Se(),o=q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Oe(e),Ee(e,a,r.getQueryCache().get(e.queryHash))}),Ce(a);let[s]=q.useState(()=>new it(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;q.useSyncExternalStore(q.useCallback(e=>d?s.subscribe(I.batchCalls(e)):he,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),q.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>xe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&xe(n,e)?be(n,new se(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Te({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var ot=H(`BriefcaseBusiness`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),st=H(`Clock3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16.5 12`,key:`1aq6pp`}]]),ct=H(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),lt=H(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z`,key:`p1xzt8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),ut=H(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),dt=H(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),ft=tt();function J(e){return Array.from(new Set(e.map(e=>e.spec).filter(Boolean)))}function pt(e){let{request:t,result:n}=e,r=new Date().toISOString();return n.type===`skill`?{type:`skill`,spec:n.spec,id:t.skill??n.spec,label:t.skill??n.name??n.spec,source:`workspace`,installPath:t.installPath,installedAt:r}:{type:n.type,spec:n.spec,id:n.name??n.spec,label:n.name??n.spec,source:`marketplace`,origin:`marketplace`,enabled:t.enabled??!0,runtimeStatus:t.enabled===!1?`disabled`:`ready`,installedAt:r}}function mt(e,t){let{id:n,spec:r}=t;return!!(r&&e.spec===r||n&&e.id===n)}function ht(e,t){return t??{type:e,total:0,specs:[],records:[]}}function gt(e){let{result:t,view:n}=e,r=ht(t.type,n),i=pt(e),a=r.records.findIndex(e=>mt(e,{id:i.id,spec:i.spec})),o=[...r.records];return a>=0?o[a]={...o[a],...i}:o.unshift(i),{...r,type:t.type,records:o,specs:J(o),total:o.length}}function _t(e){let{request:t,result:n,view:r}=e,i=ht(n.type,r);if(n.action===`uninstall`||n.action===`remove`){let e=i.records.filter(e=>!mt(e,{id:n.id,spec:t.spec}));return{...i,records:e,specs:J(e),total:e.length}}let a=i.records.map(e=>mt(e,{id:n.id,spec:t.spec})?n.action===`disable`?{...e,enabled:!1,runtimeStatus:`disabled`}:n.action===`update`?{...e,installedAt:new Date().toISOString(),origin:e.origin??`marketplace`}:{...e,enabled:!0,runtimeStatus:`ready`}:e);return{...i,records:a,specs:J(a),total:a.length}}var vt=3e4;function yt(e){let t=Pe({queryKey:[`marketplace-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>M({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,placeholderData:(t,n)=>{let r=n?.queryKey?.[1];if(!(!r||typeof r!=`object`||!r))return(`type`in r?r.type:void 0)===e.type&&xt(r,e)?t:void 0},staleTime:15e3,refetchInterval:e.q?!1:vt,refetchOnMount:`always`,refetchOnReconnect:`always`,refetchOnWindowFocus:`always`}),n=(0,q.useMemo)(()=>Ne(t.data),[t.data]);return{...t,data:n}}function bt(e,t=!0){return ye({queryKey:[`marketplace-recent-items`,e],queryFn:()=>M({type:e,sort:`updated`,page:1,pageSize:6}),enabled:t,staleTime:15e3,refetchInterval:vt,refetchOnMount:`always`,refetchOnReconnect:`always`,refetchOnWindowFocus:`always`})}function xt(e,t){return e.tag===t.tag&&e.scene===t.scene&&e.pageSize===t.pageSize}function St(e=!0){return ye({queryKey:[`marketplace-skill-scenes`],queryFn:je,enabled:e,staleTime:6e4})}function Ct(e,t=!0){let n=at({queries:e.map(e=>({queryKey:[`marketplace-skill-scene-count`,e.scene],queryFn:()=>M({type:`skill`,scene:e.scene,pageSize:1}),enabled:t&&typeof e.count!=`number`,staleTime:6e4}))});return(0,q.useMemo)(()=>{let t=new Map;return e.forEach((e,r)=>{let i=typeof e.count==`number`?e.count:n[r]?.data?.total;typeof i==`number`&&t.set(e.scene,i)}),t},[n,e])}function wt(e){return ye({queryKey:[`marketplace-installed`,e],queryFn:()=>de(e),staleTime:1e4})}function Tt(){let e=L();return De({mutationFn:e=>oe(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>gt({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`}),P.success(t.message||a(`marketplaceInstallSuccessSkill`))},onError:e=>{P.error(e.message||a(`marketplaceInstallFailed`))}})}function Et(){let e=L();return De({mutationFn:e=>ge(e),onSuccess:(t,n)=>{e.setQueryData([`marketplace-installed`,t.type],e=>_t({view:e,request:n,result:t})),e.invalidateQueries({queryKey:[`marketplace-installed`,t.type],refetchType:`inactive`});let r=t.action===`enable`?a(`marketplaceEnableSuccess`):t.action===`disable`?a(`marketplaceDisableSuccess`):t.action===`update`?a(`marketplaceUpdateSuccess`):a(`marketplaceUninstallSuccess`);P.success(t.message||r)},onError:e=>{P.error(e.message||a(`marketplaceOperationFailed`))}})}var Y=i(),Dt=[`bg-amber-600`,`bg-orange-500`,`bg-yellow-600`,`bg-emerald-600`,`bg-teal-600`,`bg-cyan-600`,`bg-stone-600`,`bg-rose-500`,`bg-violet-500`];function Ot(e){let{name:t,fallback:n,className:r}=e,i=t||n,a=i.substring(0,2).toUpperCase();return(0,Y.jsx)(`div`,{className:o(`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-sm font-semibold text-white`,kt(i),r),children:a})}function kt(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Dt[Math.abs(t)%Dt.length]}function At({title:e,spec:t}){return(0,Y.jsxs)(Be,{delayDuration:400,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`div`,{className:`truncate text-[14px] font-semibold leading-tight text-gray-950`,children:e})}),(0,Y.jsx)(G,{className:`max-w-[300px] text-xs`,children:e})]}),(0,Y.jsx)(`div`,{className:`mb-2 mt-1 flex min-w-0 items-center gap-1.5`,children:t?(0,Y.jsxs)(U,{children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`span`,{className:`max-w-full truncate text-[11px] font-mono leading-tight text-gray-400`,children:t})}),(0,Y.jsx)(G,{className:`max-w-[300px] break-all font-mono text-xs`,children:t})]}):null})]})}function jt(e){let{item:t,record:n,state:r,onInstall:i,onManage:s}=e,{isInstalling:c,canUpdate:l,canUninstall:u,busyAction:d}=r,f=!!d;return t&&!n||n&&(l||u)?(0,Y.jsxs)(`div`,{className:o(`flex shrink-0 items-center justify-end gap-1.5 opacity-100 transition-opacity duration-150`,`md:pointer-events-none md:opacity-0`,`md:group-hover:pointer-events-auto md:group-hover:opacity-100`,`md:group-focus-within:pointer-events-auto md:group-focus-within:opacity-100`),children:[t&&!n&&(0,Y.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),i(t)},disabled:c,className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md bg-primary px-2 text-[11px] font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50`,children:[(0,Y.jsx)(Ge,{className:`h-3 w-3`}),a(c?`marketplaceInstalling`:`marketplaceInstall`)]}),n&&l&&(0,Y.jsxs)(`button`,{disabled:f,onClick:e=>{e.stopPropagation(),s(`update`,n)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-blue-200/80 bg-white px-2 text-[11px] font-medium text-blue-600 transition-colors hover:border-blue-300 hover:bg-blue-50 disabled:opacity-50`,children:[(0,Y.jsx)(Ze,{className:`h-3 w-3`}),a(d===`update`?`marketplaceUpdating`:`marketplaceUpdate`)]}),n&&u&&(0,Y.jsxs)(`button`,{disabled:f,onClick:e=>{e.stopPropagation(),s(`uninstall`,n)},className:`inline-flex h-6 items-center gap-1 whitespace-nowrap rounded-md border border-gray-200/80 bg-white px-2 text-[11px] font-medium text-gray-500 transition-colors hover:border-rose-200 hover:bg-rose-50 hover:text-rose-600 disabled:opacity-50`,children:[(0,Y.jsx)(Qe,{className:`h-3 w-3`}),a(d===`uninstall`?`marketplaceRemoving`:`marketplaceUninstall`)]})]}):null}function Mt(e){let{record:t,disabled:n}=e;return t?(0,Y.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-end`,children:(0,Y.jsx)(Nt,{disabled:n})}):null}function Nt(e){let{disabled:t}=e,n=a(t?`marketplaceDisabledStatus`:`marketplaceInstalledStatus`);return(0,Y.jsx)(Be,{delayDuration:300,children:(0,Y.jsxs)(U,{children:[(0,Y.jsx)(W,{asChild:!0,children:(0,Y.jsx)(`span`,{"aria-label":n,className:o(`inline-flex h-5 w-5 items-center justify-center`,t?`text-gray-400`:`text-emerald-700`),children:t?(0,Y.jsx)(D,{className:`h-4 w-4 opacity-40`}):(0,Y.jsx)(D,{className:`h-4 w-4`})})}),(0,Y.jsx)(G,{className:`text-xs`,children:n})]})})}function Pt(e){let{item:t,record:n,installState:r,manageState:i,onOpen:o,onInstall:s,onManage:c}=e,{language:l}=K(),u=z(l),d=t?.name??n?.label??n?.id??n?.spec??a(`marketplaceUnknownItem`),f=B(t?.summaryI18n,t?.summary,u)||(n?a(`marketplaceInstalledLocalSummary`):``),p=t?.install.spec??n?.spec??``,m=t?.tags??[],h=n?.id||n?.spec,g=h?i.actionsByTarget.get(h):void 0,_=n?.type===`skill`&&n.source===`workspace`,v=n?.type===`skill`&&n.origin===`marketplace`,y=n?n.enabled===!1||n.runtimeStatus===`disabled`:!1,b=t?.install.spec,x=typeof b==`string`&&r.installingSpecs.has(b);return(0,Y.jsxs)(`article`,{onClick:o,className:`group flex h-full min-h-[156px] cursor-pointer flex-col rounded-xl border border-gray-200/60 bg-white p-3.5 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(Ot,{name:d,fallback:p||a(`marketplaceTypeSkill`),className:`h-9 w-9 rounded-lg text-xs`}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,Y.jsx)(At,{title:d,spec:p})}),(0,Y.jsx)(Mt,{record:n,disabled:y})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`p`,{className:`line-clamp-2 text-left text-[12px] leading-relaxed text-gray-500`,children:f}),(0,Y.jsxs)(`div`,{className:`mt-auto flex min-w-0 items-end justify-between gap-2 pt-2`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(Ft,{tags:m})}),(0,Y.jsx)(jt,{item:t,record:n,state:{isInstalling:x,canUpdate:v,canUninstall:_,busyAction:g},onInstall:s,onManage:c})]})]})]})}function Ft({tags:e}){let t=e.filter(It).slice(0,3);return t.length===0?null:(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5 overflow-hidden`,children:t.map(e=>(0,Y.jsx)(`span`,{className:`max-w-[104px] truncate rounded-md bg-gray-100 px-2 py-0.5 text-[11px] font-medium leading-5 text-gray-500`,children:e},e))})}function It(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function Lt({model:e,showTitle:t,operationState:n,scroll:r,actions:i}){let{scope:a,entries:s,header:c,status:l,emptyLabel:u,errorLabel:d}=e,{showSkeleton:f,isRefreshing:p,error:m}=l,{hasMore:h,loadingMore:g,sentinelRef:_}=r,{installState:v,manageState:y}=n,{onOpen:b,onInstall:x,onManage:S}=i;return(0,Y.jsxs)(`section`,{className:o(`flex min-h-full flex-col`,t&&`gap-3`),children:[t&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`h3`,{className:`text-[14px] font-semibold text-gray-950`,children:c.title}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] text-gray-500`,children:[p&&(0,Y.jsx)(`span`,{className:`font-medium text-primary`,children:c.refreshingLabel}),(0,Y.jsx)(`span`,{children:c.summary})]})]}),m&&(0,Y.jsxs)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700`,children:[d,`: `,m.message]}),p&&(0,Y.jsx)(`div`,{"data-testid":`marketplace-list-refreshing`,className:`h-0.5 overflow-hidden rounded-full bg-primary/10`,children:(0,Y.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-primary`})}),(0,Y.jsxs)(`div`,{"data-testid":f?`marketplace-list-skeleton`:void 0,className:o(`grid grid-cols-1 gap-2.5 md:grid-cols-2 xl:grid-cols-3`,f&&`min-h-0 flex-1 auto-rows-[156px] content-start`),children:[f&&(0,Y.jsx)(V,{count:36}),!f&&!m&&s.map(e=>(0,Y.jsx)(Pt,{item:e.item,record:e.record,installState:v,manageState:y,onOpen:()=>b(e.item,e.record),onInstall:x,onManage:S},e.key))]}),!f&&!m&&s.length===0&&(0,Y.jsx)(`div`,{className:`py-8 text-center text-[13px] text-gray-500`,children:u}),a===`all`&&!f&&!m&&(0,Y.jsx)(Ie,{hasMore:h,loading:g,sentinelRef:_})]})}function Rt(e){let{entry:t,language:n,localeFallbacks:r,installState:i,layout:s=`rail`,onOpen:c,onInstall:l}=e,{item:u,record:d}=t,f=B(u.summaryI18n,u.summary,r),p=u.install.spec,m=i.installingSpecs.has(p),h=!!d;return(0,Y.jsxs)(`article`,{onClick:()=>c(t),className:o(`group flex min-h-[166px] cursor-pointer flex-col justify-between rounded-xl border border-gray-200/70 bg-white p-3 shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/60`,s===`rail`?`w-[260px] shrink-0`:`w-full min-w-0`),children:[(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`mb-2.5 flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(Ot,{name:u.name,fallback:u.install.spec}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,Y.jsx)(`div`,{className:`truncate text-[13px] font-semibold leading-tight text-gray-950`,children:u.name}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] font-mono leading-tight text-gray-400`,children:zt(u)})]})]}),(0,Y.jsx)(`p`,{className:`line-clamp-2 text-[12px] leading-relaxed text-gray-500`,children:f}),(0,Y.jsx)(Bt,{tags:u.tags})]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-gray-100 pt-2.5`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-gray-400`,children:Ht(u.updatedAt)}),h?(0,Y.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1.5 text-[11px] font-semibold text-emerald-700`,children:[(0,Y.jsx)(D,{className:`h-3.5 w-3.5`}),Ut({zh:`已安装`,en:`Installed`},n)]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:m,onClick:e=>{e.stopPropagation(),l(u)},className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-gray-200 bg-white px-2 text-[11px] font-semibold text-gray-700 transition-colors hover:border-gray-300 hover:bg-gray-50 disabled:opacity-50`,children:[(0,Y.jsx)(Ge,{className:`h-3.5 w-3.5`}),a(m?`marketplaceInstalling`:`marketplaceInstall`)]})]})]})}function zt(e){return e.slug||e.install.spec}function Bt({tags:e}){let t=e.filter(Vt).slice(0,2);return t.length===0?null:(0,Y.jsx)(`div`,{className:`mt-auto truncate pt-2 text-[11px] font-medium text-gray-400`,children:t.join(` / `)})}function Vt(e){let t=e.trim().toLowerCase();return t.length>0&&t!==`skill`}function Ht(e){return e.slice(0,10)||e}function Ut(e,t){return t.startsWith(`zh`)?e.zh:e.en}var Wt=[{scene:`development-debugging`,title:{zh:`开发与调试`,en:`Development`},summary:{zh:`代码审查、错误定位、架构分析与交付验证。`,en:`Review, debug, analyze, and verify delivery work.`},icon:dt,tone:`dark`,span:`md:col-span-2`},{scene:`office-collaboration`,title:{zh:`办公协作`,en:`Office Work`},summary:{zh:`连接文档、日历、会议、邮件和团队通信。`,en:`Connect docs, calendars, meetings, mail, and teams.`},icon:ot,tone:`green`,span:`md:col-span-2`},{scene:`writing-content`,title:{zh:`写作与内容`,en:`Writing`},summary:{zh:`把调研、写作、润色和发布组织成连续工作流。`,en:`Turn research, writing, polishing, and publishing into one flow.`},icon:ut,tone:`amber`,span:`md:col-span-2`},{scene:`browser-automation`,title:{zh:`浏览器自动化`,en:`Browser`},summary:{zh:`操作网页、捕获动态内容并验证真实用户路径。`,en:`Operate pages, capture dynamic content, and verify user paths.`},icon:h,tone:`blue`,span:`md:col-span-2`},{scene:`local-environment`,title:{zh:`本地环境`,en:`Local`},summary:{zh:`管理终端、文件、运行时和本地服务。`,en:`Manage shells, files, runtimes, and local services.`},icon:T,tone:`violet`,span:`md:col-span-1`},{scene:`social-platforms`,title:{zh:`社交平台`,en:`Social`},summary:{zh:`处理发布、互动、检索和内容分发。`,en:`Handle posting, interaction, search, and distribution.`},icon:lt,tone:`sky`,span:`md:col-span-1`},{scene:`nextclaw-official`,title:{zh:`NextClaw 官方`,en:`NextClaw Official`},summary:{zh:`优先查看由 NextClaw 维护的原生能力。`,en:`Browse native capabilities maintained by NextClaw.`},icon:Ue,tone:`teal`,span:`md:col-span-2`}],Gt={icon:Ue,tone:`dark`,span:`md:col-span-2`},Kt={dark:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-stone-600 bg-stone-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},blue:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-cyan-600 bg-cyan-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},green:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-emerald-600 bg-emerald-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},amber:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-amber-600 bg-amber-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},violet:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-violet-500 bg-violet-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},sky:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-sky-500 bg-sky-500 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`},teal:{card:`border-gray-200/80 bg-white text-gray-950`,icon:`border-teal-600 bg-teal-600 text-white`,title:`text-gray-950`,text:`text-gray-500`,meta:`text-gray-400`}},qt=`grid grid-cols-[repeat(auto-fill,minmax(240px,320px))] justify-start gap-3`;function Jt(e){let{recentEntries:t,scenes:n,isScenesLoading:r,isItemsLoading:i,language:a,installState:o,onOpen:s,onInstall:c,onOpenScene:l}=e,u=z(a);return(0,Y.jsxs)(`div`,{className:`mb-4 space-y-5`,children:[(0,Y.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,Y.jsx)(Qt,{icon:ct,title:X({zh:`场景`,en:`Scenes`},a),description:X({zh:`按使用场景浏览适合的技能组合。`,en:`Browse skills by how you plan to use them.`},a)}),r?(0,Y.jsx)(`div`,{"data-testid":`marketplace-scenes-skeleton`,className:`grid auto-rows-[104px] grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:(0,Y.jsx)(V,{count:Wt.length})}):(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5`,children:n.map(e=>(0,Y.jsx)(Yt,{scene:e,language:a,onSelect:l},e.scene))})]}),(i||t.length>0)&&(0,Y.jsx)(Zt,{icon:st,title:X({zh:`最近更新`,en:`Recently updated`},a),description:X({zh:`看看生态最近在补齐哪些能力。`,en:`See what the ecosystem has been improving lately.`},a),entries:t,language:a,localeFallbacks:u,isLoading:i,installState:o,onOpen:s,onInstall:c})]})}function Yt(e){let{scene:t,language:n,onSelect:r}=e,i=$t(t.scene),a=i.icon,s=Kt[i.tone];return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(t.scene),className:o(`group flex min-h-[74px] flex-col justify-center rounded-lg border px-3 py-2.5 text-left shadow-sm transition-colors hover:border-gray-300 hover:bg-gray-50/70`,s.card),children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:o(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,s.icon),children:(0,Y.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold text-gray-950`,children:en(t,i,n)}),typeof t.count==`number`&&(0,Y.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:nn(t.count,n)})]}),(0,Y.jsx)(`p`,{className:o(`mt-1 line-clamp-1 text-[11px] leading-relaxed`,s.text),children:tn(t,i,n)})]})})}function Xt(e){let{scene:t,entries:n,isLoading:r,language:i,localeFallbacks:a,installState:s,onBack:c,onOpen:l,onInstall:u}=e,d=$t(t.scene),f=d.icon,p=Kt[d.tone];return(0,Y.jsxs)(`section`,{className:`flex min-h-full flex-col`,children:[(0,Y.jsxs)(`div`,{className:`mb-4 flex min-w-0 items-start gap-2.5`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900`,"aria-label":X({zh:`返回`,en:`Back`},i),children:(0,Y.jsx)(ze,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:o(`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border`,p.icon),children:(0,Y.jsx)(f,{className:`h-4 w-4`})}),(0,Y.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] font-semibold text-gray-950`,children:en(t,d,i)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[11px] font-medium text-gray-400`,children:X(r?{zh:`加载中`,en:`Loading`}:{zh:`${n.length} 个技能`,en:`${n.length} skills`},i)})]}),(0,Y.jsx)(`div`,{className:`mt-1.5 flex min-w-0 items-center gap-2`,children:(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-[12px] leading-relaxed text-gray-500`,children:tn(t,d,i)})})]})]}),r?(0,Y.jsx)(`div`,{"data-testid":`marketplace-scene-skeleton`,className:o(qt,`min-h-0 flex-1 auto-rows-[166px] content-start`),children:(0,Y.jsx)(V,{count:24})}):n.length>0?(0,Y.jsx)(`div`,{className:qt,children:n.map(e=>(0,Y.jsx)(Rt,{entry:e,language:i,localeFallbacks:a,installState:s,layout:`grid`,onOpen:l,onInstall:u},e.item.id))}):(0,Y.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-200 py-8 text-center text-[12px] text-gray-500`,children:X({zh:`这个模块暂无技能。`,en:`No skills in this module yet.`},i)})]})}function Zt(e){let{icon:t,title:n,description:r,entries:i,language:a,localeFallbacks:o,isLoading:s,installState:c,onOpen:l,onInstall:u}=e;return(0,Y.jsxs)(`section`,{className:`space-y-2.5`,children:[(0,Y.jsx)(Qt,{icon:t,title:n,description:r}),s?(0,Y.jsx)(`div`,{"data-testid":`marketplace-recent-skeleton`,className:`-mx-1 grid auto-rows-[166px] grid-cols-[repeat(4,260px)] gap-2.5 overflow-hidden px-1 pb-1.5`,children:(0,Y.jsx)(V,{count:4})}):(0,Y.jsx)(`div`,{className:`-mx-1 flex gap-2.5 overflow-x-auto px-1 pb-1.5 custom-scrollbar`,children:i.map(e=>(0,Y.jsx)(Rt,{entry:e,language:a,localeFallbacks:o,installState:c,onOpen:l,onInstall:u},e.item.id))})]})}function Qt({icon:e,title:t,description:n}){return(0,Y.jsx)(`div`,{className:`flex items-end justify-between gap-4`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h3`,{className:`flex items-center gap-2 text-[14px] font-semibold text-gray-950`,children:[(0,Y.jsx)(e,{className:`h-4 w-4 text-primary`}),t]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[12px] leading-relaxed text-gray-500`,children:n})]})})}function X(e,t){return t.startsWith(`zh`)?e.zh:e.en}function $t(e){return Wt.find(t=>t.scene===e)??{scene:e,...Gt}}function en(e,t,n){return t.title?X(t.title,n):e.title}function tn(e,t,n){return t.summary?X(t.summary,n):e.description??e.scene}function nn(e,t){return t.startsWith(`zh`)?`${e} 个技能`:`${e} skills`}var rn=`https://skillhub.cn/`;function an(){return(0,Y.jsx)(Ke,{href:rn,external:!0,className:`h-7 shrink-0 px-1.5 text-[13px]`,children:a(`marketplaceExternalSkillSourceTitle`)})}function on(e){return(e??``).trim().toLowerCase()}function Z(e,t){let n=on(t);return n.length>0?`${e}:${n}`:``}function sn(e){let t=new Map;for(let n of e){let e=[n.install.spec,n.slug,n.id];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function cn(e){let t=new Map;for(let n of e){let e=[n.spec,n.id,n.label];for(let r of e){let e=Z(n.type,r);!e||t.has(e)||t.set(e,n)}}return t}function ln(e,t){let n=[e.install.spec,e.slug,e.id];for(let r of n){let n=Z(e.type,r);if(!n)continue;let i=t.get(n);if(i)return i}}function un(e,t){return t.get(Z(e.type,e.spec))||t.get(Z(e.type,e.id))||t.get(Z(e.type,e.label))}function dn(e,t,n,r){let i=on(n);if(!i)return!0;let a=B(t?.summaryI18n,t?.summary,r);return[e.id,e.spec,e.label,t?.name,t?.slug,t?.summary,a,...t?.tags??[]].map(e=>on(e)).filter(Boolean).some(e=>e.includes(i))}function fn(e){let{items:t,recentItems:n,installedRecordLookup:r,scene:i,forcedType:a,typeFilter:o,scope:s,searchText:c,query:l,showListSkeleton:u,hasCatalogError:d}=e,f=St(o===`skill`),p=(0,q.useMemo)(()=>f.data?.scenes??[],[f.data?.scenes]),m=Ct(p,o===`skill`),h=(0,q.useMemo)(()=>p.map(e=>({...e,count:typeof e.count==`number`?e.count:m.get(e.scene)})),[m,p]),g=(0,q.useMemo)(()=>t.map(e=>({item:e,record:ln(e,r)})),[t,r]),_=(0,q.useMemo)(()=>n.map(e=>({item:e,record:ln(e,r)})),[r,n]),v=(0,q.useMemo)(()=>{let e=i?.trim();if(e)return h.find(t=>t.scene===e)??{scene:e,title:e}},[i,h]),y=o===`skill`&&!!i?.trim(),b=o===`skill`&&s===`all`&&!c.trim()&&!l&&!y,x=u||t.length>=4,S=b&&!d&&x&&h.length===0&&f.isLoading;return{entries:g,recentEntries:_,scenes:h,selectedScene:v,sceneEntries:g,isSceneRoute:y,isScenesLoading:S,showShelves:b&&!d&&x&&(u||h.length>0||S),backPath:a?`/skills`:`/marketplace/skills`,pathPrefix:a?`/skills/scenes`:`/marketplace/skills/scenes`}}function pn(){let e=Tt(),t=Et(),{confirm:n,ConfirmDialog:r}=We(),[i,o]=(0,q.useState)(new Set),[s,c]=(0,q.useState)(new Map);return{installState:{installingSpecs:i},manageState:{actionsByTarget:s},handleInstall:async t=>{let n=t.install.spec;if(!i.has(n)){o(e=>new Set(e).add(n));try{await e.mutateAsync({type:t.type,spec:n,kind:t.install.kind,skill:t.slug,installPath:`skills/${t.slug}`})}catch{}finally{o(e=>{let t=new Set(e);return t.delete(n),t})}}},handleManage:async(e,r)=>{let i=e===`update`?r.catalogSlug||r.id||r.spec:r.id||r.spec;if(!(!i||s.has(i))&&!(e===`uninstall`&&!await n({title:`${a(`marketplaceUninstallTitle`)} ${i}?`,description:a(`marketplaceUninstallDescription`),confirmLabel:a(`marketplaceUninstall`),variant:`destructive`}))){c(t=>new Map(t).set(i,e));try{await t.mutateAsync({type:r.type,action:e,id:i,spec:r.spec})}finally{c(e=>{let t=new Map(e);return t.delete(i),t})}}},ConfirmDialog:r}}function mn(e){let t=$e(),n=(0,q.useRef)({byKey:new Map,seq:0});return{openItemDetail:async(r,i)=>{let o=r?.name??i?.label??i?.id??i?.spec??a(`marketplaceUnknownItem`),s=Fe(r?`skill`:`skill-local`,r?.slug??i?.id??i?.spec??o),c=r?`marketplace:${r.type}:${r.slug}`:`marketplace:${i?.type??`unknown`}:${i?.id??i?.spec??o}`,l=a(`marketplaceTypeSkill`);if(!r){R(t,{id:s,title:o,typeLabel:l,spec:i?.spec??`-`,status:`ready`,summary:a(`marketplaceInstalledLocalSummary`),metadataRaw:JSON.stringify(i??{},null,2),contentRaw:`-`});return}let u=n.current.seq+1;n.current.seq=u,n.current.byKey.set(c,u);let d=B(r.summaryI18n,r.summary,e);R(t,{id:s,title:o,typeLabel:l,spec:r.install.spec,status:`loading`,summary:d,tags:r.tags,author:r.author});try{let e=await pe(r.slug);if(n.current.byKey.get(c)!==u)return;R(t,{id:s,title:o,typeLabel:l,spec:r.install.spec,status:`ready`,summary:d,metadataRaw:e.metadataRaw,contentRaw:e.bodyRaw||e.raw,sourceUrl:e.sourceUrl,sourceLabel:`Source (${e.source})`,tags:r.tags,author:r.author},{activate:!1})}catch(e){if(n.current.byKey.get(c)!==u)return;R(t,{id:s,title:o,typeLabel:l,spec:r.install.spec,status:`error`,summary:d,metadataRaw:JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),contentRaw:a(`marketplaceOperationFailed`)},{activate:!1})}}}}function hn(e){let{scope:t,typeFilter:n,query:r,localeFallbacks:i,catalogView:o,installedView:s,isCatalogLoading:c,isCatalogFetching:l,isCatalogFetchingNextPage:u,catalogError:d,isInstalledLoading:f,installedError:p}=e,m=(0,q.useMemo)(()=>s?.records??[],[s?.records]),h=(0,q.useMemo)(()=>o?.items??[],[o?.items]),g=(0,q.useMemo)(()=>sn(h),[h]),_=(0,q.useMemo)(()=>cn(m),[m]),v=(0,q.useMemo)(()=>m.filter(e=>e.type===n).map(e=>({key:`${e.type}:${e.spec}:${e.id??``}`,record:e,item:un(e,g)})).filter(e=>dn(e.record,e.item,r,i)).sort((e,t)=>gn(e.record,t.record)),[m,n,g,r,i]),y=(0,q.useMemo)(()=>t===`installed`?v:h.map(e=>({key:e.id,item:e,record:ln(e,_)})),[h,v,_,t]),b=t===`all`&&c&&!o||t===`installed`&&f&&!s,x=t===`all`&&!b&&!!o&&l&&!u,S=t===`installed`?f&&!s?a(`loading`):`${v.length} ${a(`marketplaceInstalledSkillsCountSuffix`)}`:o?`${o.total} ${a(`marketplaceSkillsCountSuffix`)}`:a(`loading`),C=t===`all`&&d?d:t===`installed`&&p?p:void 0,w={scope:t,entries:y,header:{title:a(t===`installed`?`marketplaceSectionInstalledSkills`:`marketplaceAllSkills`),summary:S,refreshingLabel:a(`marketplaceRefreshingResults`)},status:{showSkeleton:b,isRefreshing:x,error:C},emptyLabel:a(t===`installed`?`marketplaceNoInstalledSkills`:`marketplaceNoSkills`),errorLabel:a(t===`installed`?`marketplaceErrorLoadingInstalledSkills`:`marketplaceErrorLoadingSkillsData`)};return{allItems:h,installedRecordLookup:_,installedTotal:s?.total??0,itemListView:w,showListSkeleton:b,isRefreshingList:x}}function gn(e,t){let n=Date.parse(e.installedAt??``),r=Date.parse(t.installedAt??``);return Number.isNaN(n)||Number.isNaN(r)||n===r?e.spec.localeCompare(t.spec):r-n}var _n=20;function vn({forcedType:e}={}){let t=b(),n=p(),{language:r}=K(),i=`skill`,o=(0,q.useMemo)(()=>z(r),[r]),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(`all`),[m,h]=(0,q.useState)(`relevance`),{installState:g,manageState:_,handleInstall:v,handleManage:y,ConfirmDialog:x}=pn(),{openItemDetail:S}=mn(o);(0,q.useEffect)(()=>{let e=setTimeout(()=>{u(s.trim())},250);return()=>clearTimeout(e)},[s]);let C=wt(i),w=i===`skill`?n.scene?.trim():void 0,T=yt({q:w?void 0:l||void 0,scene:w,type:i,sort:m,pageSize:_n}),ee=bt(i,d===`all`&&!s.trim()&&!l&&!w),{containerRef:E,sentinelRef:te}=Le({disabled:d!==`all`||T.isError||!T.hasNextPage||T.isFetchingNextPage,onLoadMore:()=>T.fetchNextPage(),watchValue:`${i}:${d}:${l}:${w??``}:${m}:${T.data?.loadedItems??0}:${T.data?.loadedPages??0}`});(0,q.useEffect)(()=>{let e=E.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[E,l,w,d,m,i]);let D=hn({scope:d,typeFilter:i,query:l,localeFallbacks:o,catalogView:T.data,installedView:C.data,isCatalogLoading:T.isLoading,isCatalogFetching:T.isFetching,isCatalogFetchingNextPage:T.isFetchingNextPage,catalogError:T.isError?T.error:void 0,isInstalledLoading:C.isLoading,installedError:C.isError?C.error:void 0}),O=fn({items:D.allItems,recentItems:ee.data?.items??[],installedRecordLookup:D.installedRecordLookup,scene:w,forcedType:e,typeFilter:i,scope:d,searchText:s,query:l,showListSkeleton:D.showListSkeleton,hasCatalogError:T.isError});return(0,Y.jsxs)(ae,{className:`flex h-full min-h-0 flex-col pb-0`,children:[!O.isSceneRoute&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3 border-b border-gray-200/60`,children:[(0,Y.jsx)(Ye,{value:d,onValueChange:e=>f(e),children:(0,Y.jsxs)(Je,{className:`mb-0 h-auto flex-1 justify-start gap-6 rounded-none border-b-0 bg-transparent p-0 text-gray-500`,children:[(0,Y.jsx)(qe,{value:`all`,className:`rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:a(`marketplaceTabMarketplaceSkills`)}),(0,Y.jsxs)(qe,{value:`installed`,className:`gap-1.5 rounded-none border-b-2 border-transparent bg-transparent px-0 pb-3 pt-0 shadow-none hover:bg-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:text-gray-950 data-[state=active]:shadow-none`,children:[a(`marketplaceTabInstalledSkills`),(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-gray-500`,children:D.installedTotal})]})]})}),(0,Y.jsx)(an,{})]}),(0,Y.jsx)(Me,{scope:d,searchText:s,isRefreshing:D.isRefreshingList,searchPlaceholder:a(`marketplaceSearchPlaceholderSkills`),sort:m,onSearchTextChange:c,onSortChange:h})]}),(0,Y.jsx)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Y.jsxs)(`div`,{ref:E,className:`min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1`,"aria-busy":D.showListSkeleton||T.isFetchingNextPage,children:[O.isSceneRoute&&O.selectedScene&&(0,Y.jsx)(Xt,{scene:O.selectedScene,entries:O.sceneEntries,isLoading:D.showListSkeleton,language:r,localeFallbacks:o,installState:g,onBack:()=>t(O.backPath),onOpen:e=>void S(e.item,e.record),onInstall:v}),O.isSceneRoute&&!D.showListSkeleton&&(0,Y.jsx)(Ie,{hasMore:!!T.hasNextPage,loading:T.isFetchingNextPage,sentinelRef:te}),O.showShelves&&(0,Y.jsx)(Jt,{recentEntries:O.recentEntries,scenes:O.scenes,isScenesLoading:O.isScenesLoading,isItemsLoading:D.showListSkeleton||ee.isLoading,language:r,installState:g,onOpen:e=>void S(e.item,e.record),onInstall:v,onOpenScene:e=>t(`${O.pathPrefix}/${e}`)}),!O.isSceneRoute&&(0,Y.jsx)(Lt,{model:D.itemListView,showTitle:O.showShelves||!D.showListSkeleton,operationState:{installState:g,manageState:_},scroll:{hasMore:!!T.hasNextPage,loadingMore:T.isFetchingNextPage,sentinelRef:te},actions:{onOpen:(e,t)=>void S(e,t),onInstall:v,onManage:y}})]})}),(0,Y.jsx)(x,{})]})}var yn=`NextClaw`,bn=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function xn(e,t){return e===t||e.startsWith(`${t}/`)}function Sn(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of bn)if(xn(t,e))return a(n);return a(`settings`)}function Cn(e){let t=e.toLowerCase();return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||t===`[::1]`||t.startsWith(`127.`)}function wn(e){let t=e?.host.trim(),n=e?.hostname.trim(),r=e?.port.trim();return!t||!n?null:Cn(n)?r||null:t}function Tn(e,t){let n=wn(t);return`${yn}${n?` ${n}`:``} - ${Sn(e)}`}var En={...u,...Re};function Dn({children:e,sideDockManager:t}){let{isOpen:n,mode:r}=$e();Ve();let{pathname:i}=x(),{language:a}=K(),{isMobile:o}=Xe(),s=C(),c=m(e=>e.isVisible);m(e=>e.pinnedItems);let l={getDockState:t.getDockState,pinTab:t.pinTab,unpinTab:t.unpinTab};return(0,q.useEffect)(()=>{document.title=Tn(i,window.location)},[i,a]),o&&s!==`win32`?(0,Y.jsx)(ee,{pathname:i,isDocBrowserOpen:n,docBrowserDockControls:l,docBrowserRenderers:En,topbarLeadingInset:s===`darwin`?`4.75rem`:void 0,children:e}):(0,Y.jsx)(ne,{pathname:i,isMobileLayout:o,isDocBrowserOpen:n,docBrowserMode:r,docBrowserDockControls:l,docBrowserRenderers:En,sideDock:c?(0,Y.jsx)(S,{manager:t}):null,children:e})}function On({children:e}){let t=te();return(0,Y.jsx)(et,{manager:t.docBrowserManager,children:(0,Y.jsx)(Dn,{sideDockManager:t.sideDockManager,children:e})})}function kn(){let{isMobile:e}=Xe();return e?(0,Y.jsx)(v,{}):(0,Y.jsx)(y,{to:`/model`,replace:!0})}function An(e){let t=e.trim().toLowerCase();return t?!t.startsWith(`skills`):!0}function jn(e,t){t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function Mn(e,t){e&&An(t)&&e.invalidateQueries({queryKey:[`config`]}),jn(e,t)}function Nn(e){let t=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let n=F.eventBus.on(j.connectionOpen,()=>{A.handleConnectionRestored(),k.refreshAfterRealtimeReconnect(),t.current&&(t.current=!1,e?.invalidateQueries({queryKey:[`ncp-sessions`]}))}),r=F.eventBus.on(j.connectionClose,()=>{A.handleConnectionInterrupted(null),t.current=!0}),i=F.eventBus.on(j.connectionError,e=>{A.handleConnectionInterrupted(e?.message??null),t.current=!0}),a=F.eventBus.on(j.configUpdated,({path:t})=>{Mn(e,t)}),o=F.eventBus.on(j.runtimeUpdateSnapshot,e=>{k.reportSnapshot(e)}),s=F.eventBus.on(j.sessionRunStatus,t=>{N(e,{type:`session.run-status`,payload:t})}),c=F.eventBus.on(j.sessionSummaryUpsert,t=>{N(e,{type:`session.summary.upsert`,payload:t})}),l=F.eventBus.on(j.sessionSummaryDelete,t=>{N(e,{type:`session.summary.delete`,payload:t})}),u=F.eventBus.on(j.error,e=>{console.error(`Realtime transport error:`,e.message)});return()=>{n(),r(),i(),a(),o(),s(),c(),l(),u()}},[e])}var Pn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ModelConfigPage:e}=await import(`./model-config-page-oNqnMXNY.js`);return{ModelConfigPage:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]))).ModelConfigPage})),Fn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{AppearanceSettingsPage:e}=await import(`./appearance-settings-page-Byr55LGb.js`);return{AppearanceSettingsPage:e}},__vite__mapDeps([19,1,20,21,5,3,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35]))).AppearanceSettingsPage})),Q=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ChatPage:e}=await import(`./chat-page-CEavSS6B.js`);return{ChatPage:e}},__vite__mapDeps([36,1,5,3,20,21,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35,6,37,38,17]))).ChatPage})),In=(0,q.lazy)(async()=>({default:(await s(async()=>{let{SearchConfigPage:e}=await import(`./search-config-page-DzkpSGFH.js`);return{SearchConfigPage:e}},__vite__mapDeps([39,1,7,5,3,2,25,10,11,32,14,40,15,17]))).SearchConfigPage})),Ln=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ProvidersConfigPage:e}=await import(`./providers-config-page-CP-OnvLK.js`);return{ProvidersConfigPage:e}},__vite__mapDeps([41,1,5,3,7,22,8,2,23,25,30,32,14,26,37,33,34,40,15,17,18,11,9]))).ProvidersConfigPage})),Rn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-C_x83ZCT.js`);return{ChannelsList:e}},__vite__mapDeps([42,1,5,3,7,2,25,4,10,11,31,32,14,12,23,34,40,38,15,17,18]))).ChannelsList})),zn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-CIGtssWi.js`);return{RuntimeConfig:e}},__vite__mapDeps([43,1,20,21,5,3,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35,44,45,15,17]))).RuntimeConfig})),Bn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-DEOMOsDN.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([46,7,1,5,3,2,29,10,11,27,44]))).DesktopUpdateConfig})),Vn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{SecurityConfig:e}=await import(`./security-config-yraYoy9s.js`);return{SecurityConfig:e}},__vite__mapDeps([47,2,1,3]))).SecurityConfig})),Hn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{SecretsConfigPage:e}=await import(`./secrets-config-page-DhoLYm7Z.js`);return{SecretsConfigPage:e}},__vite__mapDeps([48,1,7,5,3,2,26,45,33,15,17]))).SecretsConfigPage})),Un=(0,q.lazy)(async()=>({default:(await s(async()=>{let{RemoteAccessPage:e}=await import(`./remote-_L4pTEaW.js`);return{RemoteAccessPage:e}},__vite__mapDeps([49,20,1,21,5,3,7,22,8,2,23,24,25,10,11,26,27,13,14,4,28,29,30,31,32,12,33,34,9,35]))).RemoteAccessPage})),Wn=(0,q.lazy)(async()=>({default:(await s(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-CaUFv37E.js`);return{McpMarketplacePage:e}},__vite__mapDeps([50,51,1,5,3,7,22,8,2,23,28,24,25,10,11,26,27,13,14,12,38,16]))).McpMarketplacePage}));function Gn(){return(0,Y.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function Kn({children:e}){return(0,Y.jsx)(q.Suspense,{fallback:(0,Y.jsx)(Gn,{}),children:e})}function $(e){return(0,Y.jsx)(Kn,{children:e})}var qn=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:$((0,Y.jsx)(Q,{view:`chat`}))},{path:`/agents`,element:$((0,Y.jsx)(Q,{view:`agents`}))},{path:`/skills`,element:$((0,Y.jsx)(Q,{view:`skills`}))},{path:`/skills/scenes/:scene`,element:$((0,Y.jsx)(Q,{view:`skills`}))},{path:`/cron`,element:$((0,Y.jsx)(Q,{view:`cron`}))},{path:`/appearance`,element:$((0,Y.jsx)(Fn,{}))},{path:`/model`,element:$((0,Y.jsx)(Pn,{}))},{path:`/search`,element:$((0,Y.jsx)(In,{}))},{path:`/providers`,element:$((0,Y.jsx)(Ln,{}))},{path:`/channels`,element:$((0,Y.jsx)(Rn,{}))},{path:`/runtime`,element:$((0,Y.jsx)(zn,{}))},{path:`/updates`,element:$((0,Y.jsx)(Bn,{}))},{path:`/remote`,element:$((0,Y.jsx)(Un,{}))},{path:`/security`,element:$((0,Y.jsx)(Vn,{}))},{path:`/secrets`,element:$((0,Y.jsx)(Hn,{}))},{path:`/settings`,element:(0,Y.jsx)(kn,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/skills`},{path:`/marketplace/mcp`,element:$((0,Y.jsx)(Wn,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function Jn(e){return`redirectTo`in e?(0,Y.jsx)(E,{path:e.path,element:(0,Y.jsx)(y,{to:e.redirectTo,replace:!0})},e.path):(0,Y.jsx)(E,{path:e.path,element:e.element},e.path)}function Yn(){return(0,Y.jsx)(w,{children:qn.map(Jn)})}function Xn(){return Nn(we),ue(),(0,q.useEffect)(()=>(k.start(),()=>{k.stop()}),[]),(0,Y.jsxs)(O,{children:[(0,Y.jsx)(On,{children:(0,Y.jsx)(Yn,{})}),(0,Y.jsx)(d,{}),(0,Y.jsx)(l,{})]})}function Zn(){let e=me(),t=e.isError&&Ae(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,Y.jsx)(Xn,{}):e.data?.enabled&&!e.data.authenticated?(0,Y.jsx)(c,{username:e.data.username}):(0,Y.jsx)(Xn,{})}function Qn(){return(0,q.useEffect)(()=>{ie()},[]),(0,Y.jsxs)(ke,{client:we,children:[(0,Y.jsx)(Zn,{}),(0,Y.jsx)(g,{}),(0,Y.jsx)(ve,{position:`top-right`,richColors:!0,offset:window.nextclawDesktop?.platform===`win32`?56:void 0,mobileOffset:window.nextclawDesktop?.platform===`win32`?56:void 0})]})}var $n=window.nextclawDesktop?.platform===`win32`?_:re;(0,ft.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(q.StrictMode,{children:(0,Y.jsx)(f,{children:(0,Y.jsx)(He,{children:(0,Y.jsx)($n,{children:(0,Y.jsx)(Qn,{})})})})}));export{vn as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Z as e}from"./app-presenter-provider-Dp90n1Va.js";export{e as RemoteAccessPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DseTPa7n.js";import{h as t,p as n,r}from"./react-B0LbRnAE.js";import{$ as i,g as a,h as o,tt as s,x as c}from"./app-presenter-provider-B1RgR5ug.js";import{It as l,Lt as u,Mt as d,Pt as f,Qt as p,Xt as m,Yt as h,Zt as g,nn as _,on as v,tn as y,wt as b}from"./api-DGG69ZcJ.js";import{a as x,i as S,n as C,r as w,t as T}from"./select-CYHT8P5S.js";import{a as E}from"./use-confirm-dialog-WZ94CehU.js";import{t as D}from"./loader-circle-CAnHHSrY.js";import{t as O}from"./plus-DjdTWPjQ.js";import{t as ee}from"./rotate-cw-DQJhDnjg.js";import{t as k}from"./save-R_qyrHpa.js";import{t as A}from"./trash-2-Bo3DWiju.js";import{t as j}from"./form-actions-J0tIaUdK.js";import{g as M,t as te}from"./use-config-DCzwgChy.js";var N=e(t(),1),P=n(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return r(F[e]??`runtimeControlUnavailable`)}function z(e){return r(I[e]??`runtimeControlServiceUnknown`)}function B(e){return r(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:r(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:r(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:r(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:r(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(D,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(s,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(i,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(ee,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:a,visibleLifecycle:o,visibleMessage:s,visibleServiceState:c}=d(),f=H(n??void 0),p=async e=>{let t=V(n,e);if(!t?.available){v.error(u(t?.reasonIfUnavailable)??r(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(r(`runtimeControlStopServiceConfirm`))))try{let t=await l.runRuntimeControlAction(e);v.success(u(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);v.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}},h=async()=>{if(!n?.canRestartApp.available){v.error(u(n?.canRestartApp.reasonIfUnavailable)??r(`runtimeRestartAppUnavailable`));return}if(window.confirm(r(`runtimeControlRestartAppConfirm`)))try{let e=await l.runRuntimeControlAction(`restart-app`);v.success(u(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);v.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(g,{title:r(`runtimeControlTitle`),description:r(`runtimeControlDescription`),children:(0,P.jsxs)(m,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(c)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):r(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(o)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(n.managementHint)}):null,i&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),a?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:r(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:r(`runtimeControlPendingRestartDescription`)}),a.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:r(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:f.map(n=>(0,P.jsxs)(_,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){h();return}p(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),f.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(E,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(g,{title:r(`runtimePresenceTitle`),description:r(`runtimePresenceDescription`),children:(0,P.jsx)(m,{children:t})})}function q(){let e=f().runtimeControlView?.environment,t=a(e=>e.supported),n=a(e=>e.initialized),i=a(e=>e.busyAction),s=a(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){o.start();return}o.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(E,{tone:`neutral`,title:r(`runtimePresenceBehaviorLabel`),description:s?.closeToBackground?r(`runtimePresenceBehaviorBackground`):r(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!s?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)}):null,s?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(h,{title:r(`runtimePresenceCloseToBackground`),description:r(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(b,{id:`runtime-presence-close-background`,"aria-label":r(`runtimePresenceCloseToBackground`),checked:s.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{o.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(h,{title:r(`runtimePresenceLaunchAtLogin`),description:s.supportsLaunchAtLogin?r(`runtimePresenceLaunchAtLoginHelp`):s.launchAtLoginReason??r(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(b,{id:`runtime-presence-launch-login`,"aria-label":r(`runtimePresenceLaunchAtLogin`),checked:s.launchAtLogin,disabled:!s.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{o.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceManagedLocalTitle`),description:r(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSelfHostedTitle`),description:r(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSharedTitle`),description:r(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)})})}function J(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(q,{}),(0,P.jsx)(c,{})]})}var Y={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function X(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function Z(){return{agentId:``,match:{channel:``,accountId:``}}}function ne(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Y,configText:JSON.stringify(Y,null,2)}}function re(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ie(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function Q(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(re),bindings:(e.bindings??[]).map(ie),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(r(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${r(`duplicateAgentId`)}: ${n[0]}`);let i=e.bindings.map((t,n)=>{let i=t.agentId.trim(),a=t.match.channel.trim(),o=t.match.accountId?.trim()??``,s=t.match.peer?.kind,c=t.match.peer?.id?.trim()??``;if(!i)throw Error(r(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(i))throw Error(`${r(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${i}`);if(!a)throw Error(r(`bindingChannelRequired`).replace(`{index}`,String(n)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(r(`bindingPeerIdRequired`).replace(`{index}`,String(n)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,n)=>{let i=t.id.trim(),a=t.type.trim();if(!i)throw Error(r(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!a)throw Error(r(`runtimeEntryTypeRequired`).replace(`{id}`,i));if(e[i])throw Error(`${r(`runtimeEntryDuplicate`)}: ${i}`);let o=t.configText.trim()?JSON.parse(t.configText):{};if(o&&(typeof o!=`object`||Array.isArray(o)))throw Error(r(`runtimeEntryConfigObjectRequired`).replace(`{id}`,i));return e[i]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:a,config:o??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:n,onSetDefaultAgent:i,onUpdateAgent:a}){return(0,P.jsx)(g,{title:r(`agentList`),description:r(`agentListHelp`),actions:(0,P.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addAgent`)]}),children:(0,P.jsx)(m,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(y,{value:e.id,onChange:e=>a(t,{id:e.target.value}),placeholder:r(`agentIdPlaceholder`)}),(0,P.jsx)(y,{value:e.workspace??``,onChange:e=>a(t,{workspace:e.target.value}),placeholder:r(`workspaceOverridePlaceholder`)}),(0,P.jsx)(y,{value:e.model??``,onChange:e=>a(t,{model:e.target.value}),placeholder:r(`modelOverridePlaceholder`)}),(0,P.jsx)(y,{value:e.runtime??e.engine??``,onChange:e=>a(t,{runtime:e.target.value}),placeholder:r(`engineOverridePlaceholder`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,P.jsx)(y,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>a(t,{contextTokens:Q(e.target.value)}),placeholder:r(`contextTokensPlaceholder`)}),(0,P.jsx)(y,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>a(t,{maxToolIterations:Q(e.target.value)}),placeholder:r(`maxToolsPlaceholder`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(b,{checked:!!e.default,onCheckedChange:e=>i(t,e)}),(0,P.jsx)(`span`,{children:r(`defaultAgent`)})]}),(0,P.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(A,{className:`h-4 w-4 mr-1`}),r(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:n,onUpdateBinding:i}){return(0,P.jsx)(g,{title:r(`bindings`),description:r(`bindingsHelp`),actions:(0,P.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addBinding`)]}),children:(0,P.jsx)(m,{children:e.map((e,t)=>{let a=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(y,{value:e.agentId,onChange:n=>i(t,{...e,agentId:n.target.value}),placeholder:r(`targetAgentIdPlaceholder`)}),(0,P.jsx)(y,{value:e.match.channel,onChange:n=>i(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:r(`channelPlaceholder`)}),(0,P.jsx)(y,{value:e.match.accountId??``,onChange:n=>i(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:r(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(T,{value:a||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;i(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(S,{children:(0,P.jsx)(x,{})}),(0,P.jsxs)(C,{children:[(0,P.jsx)(w,{value:`__none__`,children:r(`peerKindOptional`)}),(0,P.jsx)(w,{value:`direct`,children:r(`peerKindDirect`)}),(0,P.jsx)(w,{value:`group`,children:r(`peerKindGroup`)}),(0,P.jsx)(w,{value:`channel`,children:r(`peerKindChannel`)})]})]}),(0,P.jsx)(y,{value:e.match.peer?.id??``,onChange:n=>i(t,{...e,match:{...e.match,peer:a?{kind:a,id:n.target.value}:void 0}}),placeholder:r(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(A,{className:`h-4 w-4 mr-1`}),r(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:n,onUpdateEntry:i}){return(0,P.jsx)(g,{title:r(`runtimeEntries`),description:r(`runtimeEntriesHelp`),actions:(0,P.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addRuntimeEntry`)]}),children:(0,P.jsx)(m,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(y,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:r(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(y,{value:e.label??``,onChange:e=>i(t,{label:e.target.value}),placeholder:r(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(y,{value:e.type,onChange:e=>i(t,{type:e.target.value}),placeholder:r(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:r(`enabled`)}),(0,P.jsx)(b,{checked:e.enabled!==!1,onCheckedChange:e=>i(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:r(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>i(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(_,{type:`button`,variant:`outline`,onClick:()=>n(t),children:[(0,P.jsx)(A,{className:`mr-2 h-4 w-4`}),r(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:n,dmScope:i,onCompanionEnabledChange:a,onDefaultContextTokensChange:o,onDefaultEngineChange:s,onDmScopeChange:c}){return(0,P.jsx)(g,{title:r(`dmScope`),description:r(`dmScopeHelp`),children:(0,P.jsxs)(m,{children:[(0,P.jsx)(h,{title:r(`runtimeCompanionEnabled`),description:r(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(b,{checked:e,onCheckedChange:a})}),(0,P.jsx)(h,{title:r(`defaultContextTokens`),description:r(`defaultContextTokensHelp`),control:(0,P.jsx)(y,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>o(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(h,{title:r(`defaultEngine`),description:r(`defaultEngineHelp`),control:(0,P.jsx)(y,{value:n,onChange:e=>s(e.target.value),placeholder:r(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(h,{title:r(`dmScope`),control:(0,P.jsxs)(T,{value:i,onValueChange:e=>c(e),children:[(0,P.jsx)(S,{className:`w-56`,children:(0,P.jsx)(x,{})}),(0,P.jsx)(C,{children:ue.map(e=>(0,P.jsx)(w,{value:e.value,children:r(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[i,a]=(0,N.useState)(n.agents),[o,s]=(0,N.useState)(n.bindings),[c,l]=(0,N.useState)(n.runtimeEntries),[u,d]=(0,N.useState)(n.dmScope),[f,m]=(0,N.useState)(n.companionEnabled),[h,g]=(0,N.useState)(n.defaultContextTokens),[y,b]=(0,N.useState)(n.defaultEngine),x=(0,N.useMemo)(()=>{let e=new Set([`main`]);return i.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[i]);return(0,P.jsxs)(p,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:[(0,P.jsx)(J,{}),(0,P.jsx)(de,{companionEnabled:f,dmScope:u,defaultContextTokens:h,defaultEngine:y,onCompanionEnabledChange:m,onDmScopeChange:d,onDefaultContextTokensChange:g,onDefaultEngineChange:b}),(0,P.jsx)(le,{entries:c,onUpdateEntry:(e,t)=>l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>l(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>l(e=>[...e,ne()])}),(0,P.jsx)(se,{agents:i,onUpdateAgent:(e,t)=>{a(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>a(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>a(e=>[...e,X()]),onSetDefaultAgent:(e,t)=>a(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:o,onUpdateBinding:(e,t)=>{s(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>s(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>s(e=>[...e,Z()])}),(0,P.jsx)(j,{children:(0,P.jsxs)(_,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:f,agents:i,bindings:o,runtimeEntries:c,dmScope:u,defaultContextTokens:h,defaultEngine:y,knownAgentIds:x});t.mutate({data:e})}catch(e){v.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(k,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?r(`saving`):r(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=te(),n=M();return t||!e?(0,P.jsx)(p,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
|
|
1
|
+
import{i as e}from"./chunk-DseTPa7n.js";import{h as t,p as n,r}from"./react-B0LbRnAE.js";import{$ as i,g as a,h as o,tt as s,x as c}from"./app-presenter-provider-Dp90n1Va.js";import{It as l,Lt as u,Mt as d,Pt as f,Qt as p,Xt as m,Yt as h,Zt as g,nn as _,on as v,tn as y,wt as b}from"./api-DGG69ZcJ.js";import{a as x,i as S,n as C,r as w,t as T}from"./select-CYHT8P5S.js";import{a as E}from"./use-confirm-dialog-WZ94CehU.js";import{t as D}from"./loader-circle-CAnHHSrY.js";import{t as O}from"./plus-DjdTWPjQ.js";import{t as ee}from"./rotate-cw-DQJhDnjg.js";import{t as k}from"./save-R_qyrHpa.js";import{t as A}from"./trash-2-Bo3DWiju.js";import{t as j}from"./form-actions-J0tIaUdK.js";import{g as M,t as te}from"./use-config-DCzwgChy.js";var N=e(t(),1),P=n(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return r(F[e]??`runtimeControlUnavailable`)}function z(e){return r(I[e]??`runtimeControlServiceUnknown`)}function B(e){return r(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:r(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:r(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:r(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:r(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(D,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(s,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(i,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(ee,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:a,visibleLifecycle:o,visibleMessage:s,visibleServiceState:c}=d(),f=H(n??void 0),p=async e=>{let t=V(n,e);if(!t?.available){v.error(u(t?.reasonIfUnavailable)??r(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(r(`runtimeControlStopServiceConfirm`))))try{let t=await l.runRuntimeControlAction(e);v.success(u(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);v.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}},h=async()=>{if(!n?.canRestartApp.available){v.error(u(n?.canRestartApp.reasonIfUnavailable)??r(`runtimeRestartAppUnavailable`));return}if(window.confirm(r(`runtimeControlRestartAppConfirm`)))try{let e=await l.runRuntimeControlAction(`restart-app`);v.success(u(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:r(`runtimeControlActionFailed`);v.error(`${r(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(g,{title:r(`runtimeControlTitle`),description:r(`runtimeControlDescription`),children:(0,P.jsxs)(m,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(c)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):r(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(o)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(n.managementHint)}):null,i&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),a?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:r(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:r(`runtimeControlPendingRestartDescription`)}),a.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:r(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:f.map(n=>(0,P.jsxs)(_,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){h();return}p(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),f.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(E,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(g,{title:r(`runtimePresenceTitle`),description:r(`runtimePresenceDescription`),children:(0,P.jsx)(m,{children:t})})}function q(){let e=f().runtimeControlView?.environment,t=a(e=>e.supported),n=a(e=>e.initialized),i=a(e=>e.busyAction),s=a(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){o.start();return}o.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(E,{tone:`neutral`,title:r(`runtimePresenceBehaviorLabel`),description:s?.closeToBackground?r(`runtimePresenceBehaviorBackground`):r(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!s?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)}):null,s?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(h,{title:r(`runtimePresenceCloseToBackground`),description:r(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(b,{id:`runtime-presence-close-background`,"aria-label":r(`runtimePresenceCloseToBackground`),checked:s.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{o.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(h,{title:r(`runtimePresenceLaunchAtLogin`),description:s.supportsLaunchAtLogin?r(`runtimePresenceLaunchAtLoginHelp`):s.launchAtLoginReason??r(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(b,{id:`runtime-presence-launch-login`,"aria-label":r(`runtimePresenceLaunchAtLogin`),checked:s.launchAtLogin,disabled:!s.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{o.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceManagedLocalTitle`),description:r(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSelfHostedTitle`),description:r(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:r(`runtimePresenceSharedTitle`),description:r(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:r(`runtimePresenceLoading`)})})}function J(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(q,{}),(0,P.jsx)(c,{})]})}var Y={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function X(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function Z(){return{agentId:``,match:{channel:``,accountId:``}}}function ne(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Y,configText:JSON.stringify(Y,null,2)}}function re(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens,maxToolIterations:e.maxToolIterations}}function ie(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function Q(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(re),bindings:(e.bindings??[]).map(ie),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(r(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${r(`duplicateAgentId`)}: ${n[0]}`);let i=e.bindings.map((t,n)=>{let i=t.agentId.trim(),a=t.match.channel.trim(),o=t.match.accountId?.trim()??``,s=t.match.peer?.kind,c=t.match.peer?.id?.trim()??``;if(!i)throw Error(r(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(i))throw Error(`${r(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${i}`);if(!a)throw Error(r(`bindingChannelRequired`).replace(`{index}`,String(n)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(r(`bindingPeerIdRequired`).replace(`{index}`,String(n)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,n)=>{let i=t.id.trim(),a=t.type.trim();if(!i)throw Error(r(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!a)throw Error(r(`runtimeEntryTypeRequired`).replace(`{id}`,i));if(e[i])throw Error(`${r(`runtimeEntryDuplicate`)}: ${i}`);let o=t.configText.trim()?JSON.parse(t.configText):{};if(o&&(typeof o!=`object`||Array.isArray(o)))throw Error(r(`runtimeEntryConfigObjectRequired`).replace(`{id}`,i));return e[i]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:a,config:o??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:n,onSetDefaultAgent:i,onUpdateAgent:a}){return(0,P.jsx)(g,{title:r(`agentList`),description:r(`agentListHelp`),actions:(0,P.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addAgent`)]}),children:(0,P.jsx)(m,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(y,{value:e.id,onChange:e=>a(t,{id:e.target.value}),placeholder:r(`agentIdPlaceholder`)}),(0,P.jsx)(y,{value:e.workspace??``,onChange:e=>a(t,{workspace:e.target.value}),placeholder:r(`workspaceOverridePlaceholder`)}),(0,P.jsx)(y,{value:e.model??``,onChange:e=>a(t,{model:e.target.value}),placeholder:r(`modelOverridePlaceholder`)}),(0,P.jsx)(y,{value:e.runtime??e.engine??``,onChange:e=>a(t,{runtime:e.target.value}),placeholder:r(`engineOverridePlaceholder`)}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,P.jsx)(y,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>a(t,{contextTokens:Q(e.target.value)}),placeholder:r(`contextTokensPlaceholder`)}),(0,P.jsx)(y,{type:`number`,min:1,value:e.maxToolIterations??``,onChange:e=>a(t,{maxToolIterations:Q(e.target.value)}),placeholder:r(`maxToolsPlaceholder`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(b,{checked:!!e.default,onCheckedChange:e=>i(t,e)}),(0,P.jsx)(`span`,{children:r(`defaultAgent`)})]}),(0,P.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(A,{className:`h-4 w-4 mr-1`}),r(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:n,onUpdateBinding:i}){return(0,P.jsx)(g,{title:r(`bindings`),description:r(`bindingsHelp`),actions:(0,P.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addBinding`)]}),children:(0,P.jsx)(m,{children:e.map((e,t)=>{let a=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(y,{value:e.agentId,onChange:n=>i(t,{...e,agentId:n.target.value}),placeholder:r(`targetAgentIdPlaceholder`)}),(0,P.jsx)(y,{value:e.match.channel,onChange:n=>i(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:r(`channelPlaceholder`)}),(0,P.jsx)(y,{value:e.match.accountId??``,onChange:n=>i(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:r(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(T,{value:a||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;i(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(S,{children:(0,P.jsx)(x,{})}),(0,P.jsxs)(C,{children:[(0,P.jsx)(w,{value:`__none__`,children:r(`peerKindOptional`)}),(0,P.jsx)(w,{value:`direct`,children:r(`peerKindDirect`)}),(0,P.jsx)(w,{value:`group`,children:r(`peerKindGroup`)}),(0,P.jsx)(w,{value:`channel`,children:r(`peerKindChannel`)})]})]}),(0,P.jsx)(y,{value:e.match.peer?.id??``,onChange:n=>i(t,{...e,match:{...e.match,peer:a?{kind:a,id:n.target.value}:void 0}}),placeholder:r(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(t),children:[(0,P.jsx)(A,{className:`h-4 w-4 mr-1`}),r(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:n,onUpdateEntry:i}){return(0,P.jsx)(g,{title:r(`runtimeEntries`),description:r(`runtimeEntriesHelp`),actions:(0,P.jsxs)(_,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(O,{className:`mr-2 h-4 w-4`}),r(`addRuntimeEntry`)]}),children:(0,P.jsx)(m,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(y,{value:e.id,onChange:e=>i(t,{id:e.target.value}),placeholder:r(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(y,{value:e.label??``,onChange:e=>i(t,{label:e.target.value}),placeholder:r(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(y,{value:e.type,onChange:e=>i(t,{type:e.target.value}),placeholder:r(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:r(`enabled`)}),(0,P.jsx)(b,{checked:e.enabled!==!1,onCheckedChange:e=>i(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:r(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>i(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(_,{type:`button`,variant:`outline`,onClick:()=>n(t),children:[(0,P.jsx)(A,{className:`mr-2 h-4 w-4`}),r(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:n,dmScope:i,onCompanionEnabledChange:a,onDefaultContextTokensChange:o,onDefaultEngineChange:s,onDmScopeChange:c}){return(0,P.jsx)(g,{title:r(`dmScope`),description:r(`dmScopeHelp`),children:(0,P.jsxs)(m,{children:[(0,P.jsx)(h,{title:r(`runtimeCompanionEnabled`),description:r(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(b,{checked:e,onCheckedChange:a})}),(0,P.jsx)(h,{title:r(`defaultContextTokens`),description:r(`defaultContextTokensHelp`),control:(0,P.jsx)(y,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>o(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(h,{title:r(`defaultEngine`),description:r(`defaultEngineHelp`),control:(0,P.jsx)(y,{value:n,onChange:e=>s(e.target.value),placeholder:r(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(h,{title:r(`dmScope`),control:(0,P.jsxs)(T,{value:i,onValueChange:e=>c(e),children:[(0,P.jsx)(S,{className:`w-56`,children:(0,P.jsx)(x,{})}),(0,P.jsx)(C,{children:ue.map(e=>(0,P.jsx)(w,{value:e.value,children:r(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[i,a]=(0,N.useState)(n.agents),[o,s]=(0,N.useState)(n.bindings),[c,l]=(0,N.useState)(n.runtimeEntries),[u,d]=(0,N.useState)(n.dmScope),[f,m]=(0,N.useState)(n.companionEnabled),[h,g]=(0,N.useState)(n.defaultContextTokens),[y,b]=(0,N.useState)(n.defaultEngine),x=(0,N.useMemo)(()=>{let e=new Set([`main`]);return i.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[i]);return(0,P.jsxs)(p,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:[(0,P.jsx)(J,{}),(0,P.jsx)(de,{companionEnabled:f,dmScope:u,defaultContextTokens:h,defaultEngine:y,onCompanionEnabledChange:m,onDmScopeChange:d,onDefaultContextTokensChange:g,onDefaultEngineChange:b}),(0,P.jsx)(le,{entries:c,onUpdateEntry:(e,t)=>l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>l(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>l(e=>[...e,ne()])}),(0,P.jsx)(se,{agents:i,onUpdateAgent:(e,t)=>{a(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>a(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>a(e=>[...e,X()]),onSetDefaultAgent:(e,t)=>a(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:o,onUpdateBinding:(e,t)=>{s(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>s(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>s(e=>[...e,Z()])}),(0,P.jsx)(j,{children:(0,P.jsxs)(_,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:f,agents:i,bindings:o,runtimeEntries:c,dmScope:u,defaultContextTokens:h,defaultEngine:y,knownAgentIds:x});t.mutate({data:e})}catch(e){v.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(k,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?r(`saving`):r(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=te(),n=M();return t||!e?(0,P.jsx)(p,{title:r(`runtimePageTitle`),description:r(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
|
package/ui-dist/index.html
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
})();
|
|
187
187
|
</script>
|
|
188
188
|
<title>NextClaw</title>
|
|
189
|
-
<script type="module" crossorigin src="/assets/index-
|
|
189
|
+
<script type="module" crossorigin src="/assets/index-BFIZUZP3.js"></script>
|
|
190
190
|
<link rel="modulepreload" crossorigin href="/assets/chunk-DseTPa7n.js">
|
|
191
191
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-D4M6sveU.js">
|
|
192
192
|
<link rel="modulepreload" crossorigin href="/assets/react-B0LbRnAE.js">
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
<link rel="modulepreload" crossorigin href="/assets/trash-2-Bo3DWiju.js">
|
|
215
215
|
<link rel="modulepreload" crossorigin href="/assets/logo-badge-BYTbZbOF.js">
|
|
216
216
|
<link rel="modulepreload" crossorigin href="/assets/provider-models-CXUgDxGR.js">
|
|
217
|
-
<link rel="modulepreload" crossorigin href="/assets/app-presenter-provider-
|
|
217
|
+
<link rel="modulepreload" crossorigin href="/assets/app-presenter-provider-Dp90n1Va.js">
|
|
218
218
|
<link rel="modulepreload" crossorigin href="/assets/tag-chip-De0iz4o2.js">
|
|
219
219
|
<link rel="modulepreload" crossorigin href="/assets/skeleton-BQuylYFO.js">
|
|
220
220
|
<link rel="modulepreload" crossorigin href="/assets/mcp-marketplace-page-COWlzeP1.js">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Z as e}from"./app-presenter-provider-B1RgR5ug.js";export{e as RemoteAccessPage};
|