@youweichen/pi-harness 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/server/agent-service.js +87 -7
- package/dist/server/control-socket.js +1 -0
- package/dist/server/extensions-worker.js +3 -2
- package/dist/server/files-service.js +8 -16
- package/dist/server/index.js +7 -3
- package/dist/server/node-agent.js +262 -0
- package/dist/server/node-workbench.js +62 -1
- package/dist/server/plan/extension.js +4 -4
- package/dist/server/plan/state.js +11 -1
- package/dist/server/slash-commands.js +6 -0
- package/dist/server/wiki-routes.js +8 -1
- package/dist/server/wiki-service.js +13 -0
- package/package.json +1 -1
- package/web/dist/assets/NodeWorkbench-BiP2ktQP.js +3 -0
- package/web/dist/assets/{TerminalPanel-CWh6vw_N.js → TerminalPanel-CKaSUsN-.js} +1 -1
- package/web/dist/assets/{abnfDiagram-VCTEODGH-D5Ti0Kpa.js → abnfDiagram-VCTEODGH-CnwRJDRL.js} +1 -1
- package/web/dist/assets/{arc-DKJilLd6.js → arc-CG4Q7-W_.js} +1 -1
- package/web/dist/assets/{architectureDiagram-5GKGNRK7-Cf0w38g-.js → architectureDiagram-5GKGNRK7-BrGqX_Rg.js} +1 -1
- package/web/dist/assets/{blockDiagram-I7D4REHJ-BOTLWLIL.js → blockDiagram-I7D4REHJ-C2t0PjZT.js} +1 -1
- package/web/dist/assets/{c4Diagram-7LVT6UL2-CLCCoJs3.js → c4Diagram-7LVT6UL2-CadrcgGL.js} +1 -1
- package/web/dist/assets/channel-C27Jizb6.js +1 -0
- package/web/dist/assets/{chunk-2Q5K7J3B-BHjga2Ge.js → chunk-2Q5K7J3B-CC3V2ITZ.js} +1 -1
- package/web/dist/assets/{chunk-5VM5RSS4-CQJ5VfDZ.js → chunk-5VM5RSS4-DqKSbGmE.js} +1 -1
- package/web/dist/assets/{chunk-F27PBJKO-C67qoPJH.js → chunk-F27PBJKO-_CDr3JbY.js} +1 -1
- package/web/dist/assets/{chunk-IMKFNOWR-CgXXGwI8.js → chunk-IMKFNOWR-BIR4H4fX.js} +1 -1
- package/web/dist/assets/{chunk-JWPE2WC7-D0RPyByP.js → chunk-JWPE2WC7-CrsdBGXT.js} +1 -1
- package/web/dist/assets/{chunk-POPQ4Y6H-BeYC9s9x.js → chunk-POPQ4Y6H-C6q9kQmf.js} +1 -1
- package/web/dist/assets/{chunk-SVP7TREG-eQPl4UBQ.js → chunk-SVP7TREG-l2XXTr2v.js} +1 -1
- package/web/dist/assets/{chunk-TICWLB2K-DT73arPU.js → chunk-TICWLB2K-29I_mZgB.js} +1 -1
- package/web/dist/assets/{chunk-XXDRQBXY-B4FwQcP-.js → chunk-XXDRQBXY-htV9FBqi.js} +1 -1
- package/web/dist/assets/classDiagram-ZZMXUADV-DYTBrAEP.js +1 -0
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-DYTBrAEP.js +1 -0
- package/web/dist/assets/{cose-bilkent-JH36ORCC-Bnn5nlQN.js → cose-bilkent-JH36ORCC-Cop-ihyx.js} +1 -1
- package/web/dist/assets/{cynefin-OW5HDTMX-CStWX9kE.js → cynefin-OW5HDTMX-IEk8qBRq.js} +1 -1
- package/web/dist/assets/{cynefinDiagram-5FMLGOSQ-BMVHC03f.js → cynefinDiagram-5FMLGOSQ-Bmzt6Qb5.js} +1 -1
- package/web/dist/assets/{dagre-GXQ25YYZ-ClSaO4ml.js → dagre-GXQ25YYZ-DiXTJYYU.js} +1 -1
- package/web/dist/assets/{diagram-S7CK7UJ4-C43LL08C.js → diagram-S7CK7UJ4-BT7CLuNk.js} +1 -1
- package/web/dist/assets/{diagram-UQ7AKVKN-BPVn_ySW.js → diagram-UQ7AKVKN-BZZ3nTCO.js} +1 -1
- package/web/dist/assets/{diagram-VSXAHHWV-C34FFhRi.js → diagram-VSXAHHWV-Dal8LeZh.js} +1 -1
- package/web/dist/assets/{diagram-VX7I27RA-BRk4bncf.js → diagram-VX7I27RA-D6V9FfNA.js} +1 -1
- package/web/dist/assets/{diagram-Z3DM3KII-O5hYPLEd.js → diagram-Z3DM3KII-KUAIcFiD.js} +1 -1
- package/web/dist/assets/{ebnfDiagram-PWID7BFC-DVGEBm99.js → ebnfDiagram-PWID7BFC-s0FEPZrV.js} +1 -1
- package/web/dist/assets/{erDiagram-RLTQ6QDP-M-BLpTEV.js → erDiagram-RLTQ6QDP-CiIQPFCD.js} +1 -1
- package/web/dist/assets/{flowDiagram-HODETNUW-BwdLopEx.js → flowDiagram-HODETNUW-CvG4MYWn.js} +1 -1
- package/web/dist/assets/{ganttDiagram-EL5Y4UJY-DYxx2ppA.js → ganttDiagram-EL5Y4UJY-CUf115ii.js} +1 -1
- package/web/dist/assets/{gitGraphDiagram-WWUBYQGX-DUU0wMYB.js → gitGraphDiagram-WWUBYQGX-o3K1r6fL.js} +1 -1
- package/web/dist/assets/index-C3vDFSEV.css +10 -0
- package/web/dist/assets/index-C5or_GAq.js +276 -0
- package/web/dist/assets/{infoDiagram-27XIBGKW-CFaW5C0C.js → infoDiagram-27XIBGKW-BxiBeQ8E.js} +1 -1
- package/web/dist/assets/{ishikawaDiagram-5VMMS53U--ENP1MTB.js → ishikawaDiagram-5VMMS53U-B1ONuCkH.js} +1 -1
- package/web/dist/assets/{journeyDiagram-3NMN7TZE-DgnAzSTj.js → journeyDiagram-3NMN7TZE-DwmuoXcX.js} +1 -1
- package/web/dist/assets/{kanban-definition-UXKFOSKX-_STZN1vU.js → kanban-definition-UXKFOSKX-pMKHubxH.js} +1 -1
- package/web/dist/assets/{layout-CkUClkXt.js → layout-CEwfjQR0.js} +1 -1
- package/web/dist/assets/{linear-sYHiUOxa.js → linear-D22Gdbt1.js} +1 -1
- package/web/dist/assets/{markdown-vNTCZJ6d.js → markdown-BhJ_LInD.js} +1 -1
- package/web/dist/assets/{mermaid.core-B8fKGWsc.js → mermaid.core-CO2nrD04.js} +5 -5
- package/web/dist/assets/{mindmap-definition-YA3MSWOX-DP0BYOEx.js → mindmap-definition-YA3MSWOX-9MQn9ZAp.js} +1 -1
- package/web/dist/assets/{pegDiagram-XKGWAZYB-DkWTmZre.js → pegDiagram-XKGWAZYB-Dy6fLjM-.js} +1 -1
- package/web/dist/assets/{pieDiagram-E7YTZNPT-DfZgMV4u.js → pieDiagram-E7YTZNPT-EDLez6nA.js} +1 -1
- package/web/dist/assets/{quadrantDiagram-AXDQQJYC-Djl4TT7q.js → quadrantDiagram-AXDQQJYC-Cgcd9mvy.js} +1 -1
- package/web/dist/assets/{railroadDiagram-O6MQD6OU-DbKF6zXn.js → railroadDiagram-O6MQD6OU-B4Td0tjj.js} +1 -1
- package/web/dist/assets/{react-BNj3n7jX.js → react-BddUxV-9.js} +1 -1
- package/web/dist/assets/{requirementDiagram-BXWQKSXE-idola5qb.js → requirementDiagram-BXWQKSXE-aF2QNZ78.js} +1 -1
- package/web/dist/assets/{sankeyDiagram-P5KCCOFB-KA0hQOle.js → sankeyDiagram-P5KCCOFB-DgTYwYMa.js} +1 -1
- package/web/dist/assets/{sequenceDiagram-WJ2MYXX4-BXSKvxzP.js → sequenceDiagram-WJ2MYXX4-EUcddWUc.js} +1 -1
- package/web/dist/assets/{sizeCapture-INFHLROL-C_Ewv3S5.js → sizeCapture-INFHLROL-CXHOv9Sx.js} +1 -1
- package/web/dist/assets/{stateDiagram-D77RDMKH-DIf5X8oo.js → stateDiagram-D77RDMKH-B-xlgfaK.js} +1 -1
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-kwAwAlWX.js +1 -0
- package/web/dist/assets/{swimlanes-42K2YHIH-Cx_Rc8M2.js → swimlanes-42K2YHIH-BtFBOCDh.js} +1 -1
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N-D5j5Cj3S.js +8 -0
- package/web/dist/assets/{timeline-definition-24CTP7MA-BRrDhWVz.js → timeline-definition-24CTP7MA-CZlQY6pb.js} +1 -1
- package/web/dist/assets/{vennDiagram-4TSXK5OY-Ad6G0YwD.js → vennDiagram-4TSXK5OY-Cn61dJvL.js} +1 -1
- package/web/dist/assets/{wardleyDiagram-VM6X3IG4-X6-ENpSi.js → wardleyDiagram-VM6X3IG4-fiMNrWpr.js} +1 -1
- package/web/dist/assets/{xychartDiagram-S5SC5T6Z-DhegNS6d.js → xychartDiagram-S5SC5T6Z-CuzM_sof.js} +1 -1
- package/web/dist/index.html +4 -4
- package/web/dist/assets/NodeWorkbench-C4U1PldE.js +0 -3
- package/web/dist/assets/channel-D8Hd7T4P.js +0 -1
- package/web/dist/assets/classDiagram-ZZMXUADV-B_btgYRB.js +0 -1
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-B_btgYRB.js +0 -1
- package/web/dist/assets/index-CI2KfVSr.css +0 -10
- package/web/dist/assets/index-DQcpggFU.js +0 -275
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-DYwe_2mB.js +0 -1
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N-52Y8tgRV.js +0 -8
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B8fKGWsc.js","assets/markdown-vNTCZJ6d.js","assets/TerminalPanel-CWh6vw_N.js","assets/xterm-D1D2FVe3.js","assets/react-BNj3n7jX.js","assets/xterm-6GBZ9nXN.css","assets/NodeWorkbench-C4U1PldE.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Bl=Object.defineProperty;var Ul=(t,n,s)=>n in t?Bl(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var Lr=(t,n,s)=>Ul(t,typeof n!="symbol"?n+"":n,s);import{a as d,j as e,R as fs,u as wr,b as br,c as vi,M as jr,d as ro,H as Pt,e as Wl,f as ql,h as zl,i as Vl,k as Kl,l as Gl,m as Jl,n as Ql,o as Yl,p as Xl,q as Zl,s as ec,t as tc,v as nc,w as sc,x as rc,y as ic,z as ac,A as oc,B as lc,C as cc,D as dc,E as uc,F as pc,G as hc,I as mc,J as fc,r as io}from"./markdown-vNTCZJ6d.js";import{r as ao}from"./react-BNj3n7jX.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function s(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=s(i);fetch(i.href,a)}})();const gc="pi-harness:theme-change";function wf(){const t=getComputedStyle(document.documentElement),n=s=>t.getPropertyValue(s).trim();return{background:n("--term-bg"),foreground:n("--term-fg"),cursor:n("--term-cursor"),cursorAccent:n("--term-cursor-accent"),selectionBackground:n("--term-selection"),black:n("--term-black"),red:n("--term-red"),green:n("--term-green"),yellow:n("--term-yellow"),blue:n("--term-blue"),magenta:n("--term-magenta"),cyan:n("--term-cyan"),white:n("--term-white"),brightBlack:n("--term-bright-black"),brightRed:n("--term-bright-red"),brightGreen:n("--term-bright-green"),brightYellow:n("--term-bright-yellow"),brightBlue:n("--term-bright-blue"),brightMagenta:n("--term-bright-magenta"),brightCyan:n("--term-bright-cyan"),brightWhite:n("--term-bright-white")}}const oo="pi-harness:appearance";function lo(){try{const t=localStorage.getItem(oo);return t==="dark"||t==="system"?t:"light"}catch{return"light"}}function Mr(t=lo()){document.documentElement.dataset.appearance=t==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,window.dispatchEvent(new Event(gc))}function xc(){Mr(),matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{lo()==="system"&&Mr()}),window.addEventListener("storage",t=>{(t.key===oo||t.key===null)&&Mr()})}var er={},Gi;function vc(){if(Gi)return er;Gi=1;var t=ao();return er.createRoot=t.createRoot,er.hydrateRoot=t.hydrateRoot,er}var kc=vc();const yc="modulepreload",wc=function(t){return"/"+t},Ji={},Cr=function(n,s,r){let i=Promise.resolve();if(s&&s.length>0){let o=function(p){return Promise.all(p.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),l=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=o(s.map(p=>{if(p=wc(p),p in Ji)return;Ji[p]=!0;const u=p.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${f}`))return;const k=document.createElement("link");if(k.rel=u?"stylesheet":yc,u||(k.as="script"),k.crossOrigin="",k.href=p,l&&k.setAttribute("nonce",l),document.head.appendChild(k),u)return new Promise((j,I)=>{k.addEventListener("load",j),k.addEventListener("error",()=>I(new Error(`Unable to preload CSS for ${p}`)))})}))}function a(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return i.then(o=>{for(const c of o||[])c.status==="rejected"&&a(c.reason);return n().catch(a)})},co=d.createContext(null),Sr=()=>d.useContext(co),uo=d.createContext(!1),po=d.createContext(null),bc=()=>d.useContext(uo),jc=()=>d.useContext(po);function Cc({conversationId:t,files:n,active:s,onOpenChange:r,children:i}){const a=`pi-harness:changes:${t}`,o=()=>{try{const L=JSON.parse(sessionStorage.getItem(a)??"null");if(L)return{open:L.open===!0,list:L.list===!0,scope:["branch","work"].includes(L.scope)?L.scope:"turn",selected:"",base:""}}catch{}return{open:!1,list:!1,scope:"turn",selected:"",base:""}},[c,l]=d.useState(a),[p,u]=d.useState(o),[f,k]=d.useState(null),[j,I]=d.useState(0);c!==a&&(l(a),u(o()),k(null),I(0)),d.useEffect(()=>{try{sessionStorage.setItem(a,JSON.stringify(p))}catch{}},[a,p]),d.useEffect(()=>(r(s&&p.open),()=>r(!1)),[s,p.open,r,t]),d.useEffect(()=>{const L=b=>{!s||!(b.metaKey||b.ctrlKey)||b.key.toLowerCase()!=="d"||(b.preventDefault(),u(F=>({...F,open:!F.open})))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[s]);const E=d.useCallback(L=>{L.scope==="turn"&&k(null),u(b=>({...b,...L}))},[]),$=d.useCallback((L,b)=>{k(L.length===n.length&&L.every((F,B)=>{var ie,Q;return F.path===n[B].path&&((ie=F.toolIds)==null?void 0:ie.join())===((Q=n[B].toolIds)==null?void 0:Q.join())})?null:L),u(F=>({...F,open:!0,scope:"turn",selected:b??""})),I(F=>F+1)},[n]),N=f??n,R=d.useMemo(()=>({...p,files:N,focusRequest:j,set:E,show:$}),[p,N,j,E,$]),y=d.useMemo(()=>({files:N,show:$}),[N,$]);return e.jsx(uo.Provider,{value:!0,children:e.jsx(po.Provider,{value:y,children:e.jsx(co.Provider,{value:R,children:i})})})}const Sc=/^\s*(?:(?:async\s+)?def\s+\w+|(?:export\s+)?(?:async\s+)?function\s+\w+|(?:public|private|protected)\s+\w+\s*\(|(?:async\s+)?\w+\s*\([^)]*\)\s*[:{])/;function Nc(t,n=2){var i;const s=[[]];let r=0;for(const a of t.replace(/\r\n/g,`
|
|
3
|
-
`).split(`
|
|
4
|
-
`)){if(/^\s*\.\.\.\s*$/.test(a)){(i=s.at(-1))!=null&&i.length&&s.push([]);continue}const o=/^([+\- ])\s*(\d+) (.*)$/.exec(a);if(!o)continue;const c=o[1],l=Number(o[2]),p=o[3];c==="+"?(s.at(-1).push({marker:c,newLine:l,text:p}),r++):c==="-"?(s.at(-1).push({marker:c,oldLine:l,text:p}),r--):s.at(-1).push({marker:c,oldLine:l,newLine:l+r,text:p})}return s.flatMap(a=>{const o=a.flatMap((l,p)=>l.marker===" "?[]:[p]);if(!o.length)return[];const c=[];for(const l of o){const p=c.at(-1);p&&l-p.last<=n*2+1?p.last=l:c.push({first:l,last:l})}return c.map(({first:l,last:p})=>{var k;const u=a.slice(Math.max(0,l-n),Math.min(a.length,p+n+1)),f=(k=[...a.slice(0,l)].reverse().find(j=>Sc.test(j.text)))==null?void 0:k.text.trim();return{line:a[l].newLine??a[l].oldLine??1,...f?{functionName:f}:{},lines:u}})})}function Rs(t,n,s=2){var k;if(t.name!=="edit"&&t.name!=="write")return null;let r={};try{r=JSON.parse(t.argumentsText??"{}")}catch{}const i=typeof r.path=="string"?r.path:"",a=(n==null?void 0:n.content.filter(j=>j.type==="text").map(j=>j.text).join(`
|
|
5
|
-
`))??"",o=!!(n!=null&&n.isError);if(t.name==="write"){const j=typeof r.content=="string"?r.content:"",I=j?j.replace(/\r\n/g,`
|
|
6
|
-
`).replace(/\n$/,"").split(`
|
|
7
|
-
`):[];return{path:i,kind:"write",added:o?0:I.length,removed:0,firstChangedLine:1,hunks:I.length?[{line:1,lines:I.map((E,$)=>({marker:"+",newLine:$+1,text:E}))}]:[],error:o,errorText:o?a:"",output:a,empty:!I.length}}const c=n==null?void 0:n.details,l=!o&&typeof(c==null?void 0:c.diff)=="string"?c.diff:"";let p=Nc(l,s),u=!1;!o&&n&&p.length===0&&(p=(Array.isArray(r.edits)?r.edits:[r]).flatMap(I=>{if(!I||typeof I!="object")return[];const{oldText:E,newText:$}=I;if(typeof E!="string"||typeof $!="string"||E===$)return[];const N=E?E.replace(/\r\n/g,`
|
|
8
|
-
`).replace(/\n$/,"").split(`
|
|
9
|
-
`):[],R=$?$.replace(/\r\n/g,`
|
|
10
|
-
`).replace(/\n$/,"").split(`
|
|
11
|
-
`):[];let y=0;for(;y<N.length&&y<R.length&&N[y]===R[y];)y++;let L=0;for(;L<N.length-y&&L<R.length-y&&N[N.length-L-1]===R[R.length-L-1];)L++;const b=N.slice(Math.max(0,y-s),y).map(B=>({marker:" ",text:B})),F=N.slice(N.length-L,Math.min(N.length,N.length-L+s)).map(B=>({marker:" ",text:B}));return[{line:1,lines:[...b,...N.slice(y,N.length-L).map(B=>({marker:"-",text:B})),...R.slice(y,R.length-L).map(B=>({marker:"+",text:B})),...F]}]}),u=p.length>0);const f=p.flatMap(j=>j.lines);if(o){const E=(Array.isArray(r.edits)?r.edits:[r]).map($=>typeof $=="object"&&$&&"oldText"in $&&typeof $.oldText=="string"?$.oldText:"").filter(Boolean).join(`
|
|
12
|
-
|
|
13
|
-
`);return{path:i,kind:"edit",added:0,removed:0,firstChangedLine:1,hunks:E?[{line:1,lines:E.replace(/\n$/,"").split(`
|
|
14
|
-
`).map($=>({marker:" ",text:$}))}]:[],error:o,errorText:a,output:a,empty:!E}}return{path:i,kind:"edit",added:f.filter(j=>j.marker==="+").length,removed:f.filter(j=>j.marker==="-").length,firstChangedLine:typeof(c==null?void 0:c.firstChangedLine)=="number"?c.firstChangedLine:((k=p[0])==null?void 0:k.line)??1,hunks:p,error:o,errorText:"",output:a,empty:!p.length,fromArguments:u,diffTruncated:(c==null?void 0:c.diffTruncated)===!0}}function Ec(t,n){var i;const s=new Map,r=new Set;for(const a of t)if(a.role==="assistant")for(const o of a.content){if(o.type!=="toolCall"||o.name!=="edit")continue;const c=o,l=n.get(c.id);if(!l)continue;const p=(i=Rs(c,l))==null?void 0:i.path;if(p)if(l.isError)s.set(p,[...s.get(p)??[],c.id]);else{for(const u of s.get(p)??[])r.add(u);s.delete(p)}}return r}function ho(t,n){const s=a=>{const o=[];for(const c of a.replace(/\\/g,"/").split("/"))c!=="."&&(c===".."&&o.length&&o.at(-1)!==".."&&o.at(-1)!==""?o.pop():o.push(c));return o.join("/")},r=s(n).replace(/\/$/,""),i=s(t);return i.startsWith(`${r}/`)?i.slice(r.length+1):i}function mo(t,n,s){const r=new Map;if(!t)return[];const i=new Map(n.filter(c=>c.role==="toolResult").map(c=>[c.toolCallId,c])),a=new Map;for(const c of n)if(c.role==="assistant")for(const l of c.content)l.type==="toolCall"&&typeof l.id=="string"&&a.set(l.id,l);const o=new Set;for(const c of t.steps)for(const l of c.artifacts){if(o.has(l.toolCallId))continue;o.add(l.toolCallId);const p=i.get(l.toolCallId),u=a.get(l.toolCallId);if(!l.path||!["write","edit"].includes(l.kind)||!p||p.isError)continue;const f=ho(l.path,s),k=r.get(f)??{path:f,added:0,removed:0,counted:!1},j=u&&Rs(u,p);(j==null?void 0:j.kind)==="edit"&&!j.error&&!j.diffTruncated&&!j.empty&&(k.added+=j.added,k.removed+=j.removed,k.counted=!0),r.set(f,k)}return[...r.values()]}function fo(t,n,s){const r=mo(t,n,s).map(c=>({...c,lines:[],toolIds:[],unlocated:!1,truncated:!1})),i=new Map(r.map(c=>[c.path,c])),a=new Set((t==null?void 0:t.steps.flatMap(c=>c.artifacts.map(l=>l.toolCallId)))??[]),o=new Map(n.filter(c=>c.role==="toolResult").map(c=>[c.toolCallId,c]));for(const c of n)if(c.role==="assistant")for(const l of c.content){if(l.type!=="toolCall"||!a.delete(String(l.id)))continue;const p=l,u=o.get(p.id);if(!u||u.isError)continue;const f=Rs(p,u,3);if(!f)continue;const k=i.get(ho(f.path,s));k&&(k.lines.push(...f.hunks.flatMap(j=>j.lines)),k.toolIds.push(p.id),k.unlocated||(k.unlocated=!!f.fromArguments),k.truncated||(k.truncated=!!f.diffTruncated))}return r}function xs(t,n=!0){let s=t.replace(/\t.*$/,"");if(s.startsWith('"'))try{s=JSON.parse(s)}catch{}return n?s.replace(/^[ab]\//,""):s}function Tc(t){const n=[];let s,r=0,i=0,a=0,o=0;for(const c of t.split(`
|
|
15
|
-
`)){if(c.startsWith("diff --git ")){s={path:"",added:0,removed:0,counted:!0,lines:[]},n.push(s),a=o=0;const p=/^diff --git ("(?:[^"\\]|\\.)*"|a\/.*?) ("(?:[^"\\]|\\.)*"|b\/.*)$/.exec(c);p&&(s.oldPath=xs(p[1]),s.path=xs(p[2]));continue}if(!s)continue;const l=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(c);if(l){r=+l[1],a=l[2]===void 0?1:+l[2],i=+l[3],o=l[4]===void 0?1:+l[4];continue}if(a||o){c.startsWith("+")?(s.lines.push({marker:"+",newLine:i++,text:c.slice(1)}),o--,s.added++):c.startsWith("-")?(s.lines.push({marker:"-",oldLine:r++,text:c.slice(1)}),a--,s.removed++):c.startsWith(" ")&&(s.lines.push({marker:" ",oldLine:r++,newLine:i++,text:c.slice(1)}),a--,o--);continue}c.startsWith("+++ ")&&c!=="+++ /dev/null"?s.path=xs(c.slice(4)):c.startsWith("--- ")&&c!=="--- /dev/null"?s.oldPath=xs(c.slice(4)):c.startsWith("rename from ")?s.oldPath=xs(c.slice(12),!1):c.startsWith("rename to ")?s.path=xs(c.slice(10),!1):c.startsWith("Binary files ")||c==="GIT binary patch"?s.binary=!0:c==="\\ Preview truncated"&&(s.truncated=!0)}return n.filter(c=>c.path)}function Rc(t,n){const s=t.match(/\s+|[\p{L}\p{N}_]+|[^\s\p{L}\p{N}_]/gu)??[],r=n.match(/\s+|[\p{L}\p{N}_]+|[^\s\p{L}\p{N}_]/gu)??[],i=new Set;if(s.length*r.length<=25e4){const o=r.length+1,c=new Uint32Array((s.length+1)*o);for(let l=s.length-1;l>=0;l--)for(let p=r.length-1;p>=0;p--)c[l*o+p]=s[l]===r[p]?c[(l+1)*o+p+1]+1:Math.max(c[(l+1)*o+p],c[l*o+p+1]);for(let l=0,p=0;l<s.length&&p<r.length;)s[l]===r[p]?(i.add(l++),p++):c[(l+1)*o+p]>=c[l*o+p+1]?l++:p++}else{let o=0,c=0;for(;o<s.length&&o<r.length&&s[o]===r[o];)i.add(o++);for(;c<s.length-o&&c<r.length-o&&s.at(-c-1)===r.at(-c-1);)i.add(s.length-c-1),c++}const a=[];return s.forEach((o,c)=>{const l=!i.has(c),p=a.at(-1);(p==null?void 0:p.changed)===l?p.text+=o:a.push({text:o,changed:l})}),a}function Ic(t){const n=[];for(let s=0;s<t.length;){if(t[s].marker!==" "){n.push({kind:"line",index:s++});continue}let r=s;for(;r<t.length&&t[r].marker===" ";)r++;const i=s===0?s:Math.min(s+3,r),a=r===t.length?r:Math.max(i,r-3);if(a-i>4){for(let o=s;o<i;o++)n.push({kind:"line",index:o});n.push({kind:"gap",start:i,end:a});for(let o=a;o<r;o++)n.push({kind:"line",index:o})}else for(let o=s;o<r;o++)n.push({kind:"line",index:o});s=r}return n}function Lc(t,n,s,r){const i=new Map,a=t.flatMap((o,c)=>o.role==="user"&&o.origin!=="auto-reminder"?[c]:[]);for(let o=0;o<a.length;o++){if(r&&o===a.length-1)continue;const c=t.slice(a[o],a[o+1]??t.length),l=c.findLast(f=>f.role==="assistant");if(!l)continue;const p=(n==null?void 0:n.sourceMessageId)===c[0].id?n:{id:c[0].id,sourceMessageId:c[0].id,steps:c.filter(f=>f.role==="assistant").map(f=>({id:f.id,messageId:f.id,title:"",status:"done",startedAt:0,artifacts:f.content.flatMap(k=>{if(k.type!=="toolCall")return[];const j=k,I=Rs(j);return I?[{toolCallId:j.id,kind:I.kind,path:I.path,label:I.path}]:[]})}))},u=fo(p,n===p?t:c,s);u.length&&i.set(l.id,u)}return i}var go={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qi=fs.createContext&&fs.createContext(go),Mc=["attr","size","title"];function Pc(t,n){if(t==null)return{};var s,r,i=Ac(t,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)s=a[r],n.indexOf(s)===-1&&{}.propertyIsEnumerable.call(t,s)&&(i[s]=t[s])}return i}function Ac(t,n){if(t==null)return{};var s={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(n.indexOf(r)!==-1)continue;s[r]=t[r]}return s}function ar(){return ar=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},ar.apply(null,arguments)}function Yi(t,n){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),s.push.apply(s,r)}return s}function or(t){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Yi(Object(s),!0).forEach(function(r){Dc(t,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Yi(Object(s)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(s,r))})}return t}function Dc(t,n,s){return(n=$c(n))in t?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s,t}function $c(t){var n=Fc(t,"string");return typeof n=="symbol"?n:n+""}function Fc(t,n){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var r=s.call(t,n);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function xo(t){return t&&t.map((n,s)=>fs.createElement(n.tag,or({key:s},n.attr),xo(n.child)))}function ot(t){return n=>fs.createElement(Oc,ar({attr:or({},t.attr)},n),xo(t.child))}function Oc(t){var n=s=>{var r=t.attr,i=t.size,a=t.title,o=Pc(t,Mc),c=i||s.size||"1em",l;return s.className&&(l=s.className),t.className&&(l=(l?l+" ":"")+t.className),fs.createElement("svg",ar({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,r,o,{className:l,style:or(or({color:t.color||s.color},s.style),t.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),a&&fs.createElement("title",null,a),t.children)};return Qi!==void 0?fs.createElement(Qi.Consumer,null,s=>n(s)):n(go)}function _c(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(t)}function Hc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"11",y1:"8",x2:"11",y2:"14"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(t)}function Bc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"},child:[]}]})(t)}function qt(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"18",y1:"6",x2:"6",y2:"18"},child:[]},{tag:"line",attr:{x1:"6",y1:"6",x2:"18",y2:"18"},child:[]}]})(t)}function Xi(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"},child:[]},{tag:"path",attr:{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"},child:[]}]})(t)}function As(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"4 7 4 4 20 4 20 7"},child:[]},{tag:"line",attr:{x1:"9",y1:"20",x2:"15",y2:"20"},child:[]},{tag:"line",attr:{x1:"12",y1:"4",x2:"12",y2:"20"},child:[]}]})(t)}function Pr(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"3 6 5 6 21 6"},child:[]},{tag:"path",attr:{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",y1:"11",x2:"10",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",y1:"11",x2:"14",y2:"17"},child:[]}]})(t)}function ki(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"4 17 10 11 4 5"},child:[]},{tag:"line",attr:{x1:"12",y1:"19",x2:"20",y2:"19"},child:[]}]})(t)}function Zi(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"},child:[]},{tag:"line",attr:{x1:"7",y1:"7",x2:"7.01",y2:"7"},child:[]}]})(t)}function ls(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]}]})(t)}function ea(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]},{tag:"line",attr:{x1:"9",y1:"3",x2:"9",y2:"21"},child:[]}]})(t)}function _s(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(t)}function ts(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]}]})(t)}function Uc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"},child:[]},{tag:"polyline",attr:{points:"17 21 17 13 7 13 7 21"},child:[]},{tag:"polyline",attr:{points:"7 3 7 8 15 8"},child:[]}]})(t)}function Wc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"23 4 23 10 17 10"},child:[]},{tag:"path",attr:{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"},child:[]}]})(t)}function qc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"1 4 1 10 7 10"},child:[]},{tag:"path",attr:{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"},child:[]}]})(t)}function Is(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"23 4 23 10 17 10"},child:[]},{tag:"polyline",attr:{points:"1 20 1 14 7 14"},child:[]},{tag:"path",attr:{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"},child:[]}]})(t)}function gs(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]}]})(t)}function bf(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"5 3 19 12 5 21 5 3"},child:[]}]})(t)}function ta(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"},child:[]}]})(t)}function zc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"16.5",y1:"9.4",x2:"7.5",y2:"4.21"},child:[]},{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(t)}function Ss(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"19",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"5",cy:"12",r:"1"},child:[]}]})(t)}function Qr(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]}]})(t)}function vo(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},child:[]}]})(t)}function ko(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"3",y1:"12",x2:"21",y2:"12"},child:[]},{tag:"line",attr:{x1:"3",y1:"6",x2:"21",y2:"6"},child:[]},{tag:"line",attr:{x1:"3",y1:"18",x2:"21",y2:"18"},child:[]}]})(t)}function Vc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"15 3 21 3 21 9"},child:[]},{tag:"polyline",attr:{points:"9 21 3 21 3 15"},child:[]},{tag:"line",attr:{x1:"21",y1:"3",x2:"14",y2:"10"},child:[]},{tag:"line",attr:{x1:"3",y1:"21",x2:"10",y2:"14"},child:[]}]})(t)}function Kc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M7 11V7a5 5 0 0 1 10 0v4"},child:[]}]})(t)}function Gc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"2",x2:"12",y2:"6"},child:[]},{tag:"line",attr:{x1:"12",y1:"18",x2:"12",y2:"22"},child:[]},{tag:"line",attr:{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"},child:[]},{tag:"line",attr:{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"},child:[]},{tag:"line",attr:{x1:"2",y1:"12",x2:"6",y2:"12"},child:[]},{tag:"line",attr:{x1:"18",y1:"12",x2:"22",y2:"12"},child:[]},{tag:"line",attr:{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"},child:[]},{tag:"line",attr:{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"},child:[]}]})(t)}function ir(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"8",y1:"6",x2:"21",y2:"6"},child:[]},{tag:"line",attr:{x1:"8",y1:"12",x2:"21",y2:"12"},child:[]},{tag:"line",attr:{x1:"8",y1:"18",x2:"21",y2:"18"},child:[]},{tag:"line",attr:{x1:"3",y1:"6",x2:"3.01",y2:"6"},child:[]},{tag:"line",attr:{x1:"3",y1:"12",x2:"3.01",y2:"12"},child:[]},{tag:"line",attr:{x1:"3",y1:"18",x2:"3.01",y2:"18"},child:[]}]})(t)}function lr(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"},child:[]},{tag:"path",attr:{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},child:[]}]})(t)}function ys(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"12 2 2 7 12 12 22 7 12 2"},child:[]},{tag:"polyline",attr:{points:"2 17 12 22 22 17"},child:[]},{tag:"polyline",attr:{points:"2 12 12 17 22 12"},child:[]}]})(t)}function Jc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"},child:[]}]})(t)}function na(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"19",y1:"4",x2:"10",y2:"4"},child:[]},{tag:"line",attr:{x1:"14",y1:"20",x2:"5",y2:"20"},child:[]},{tag:"line",attr:{x1:"15",y1:"4",x2:"9",y2:"20"},child:[]}]})(t)}function Qc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(t)}function yo(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]},{tag:"circle",attr:{cx:"8.5",cy:"8.5",r:"1.5"},child:[]},{tag:"polyline",attr:{points:"21 15 16 10 5 21"},child:[]}]})(t)}function Yc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"},child:[]},{tag:"polyline",attr:{points:"9 22 9 12 15 12 15 22"},child:[]}]})(t)}function Xc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"22",y1:"12",x2:"2",y2:"12"},child:[]},{tag:"path",attr:{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"},child:[]},{tag:"line",attr:{x1:"6",y1:"16",x2:"6.01",y2:"16"},child:[]},{tag:"line",attr:{x1:"10",y1:"16",x2:"10.01",y2:"16"},child:[]}]})(t)}function sa(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"2",y1:"12",x2:"22",y2:"12"},child:[]},{tag:"path",attr:{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"},child:[]}]})(t)}function os(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"6",y1:"3",x2:"6",y2:"15"},child:[]},{tag:"circle",attr:{cx:"18",cy:"6",r:"3"},child:[]},{tag:"circle",attr:{cx:"6",cy:"18",r:"3"},child:[]},{tag:"path",attr:{d:"M18 9a9 9 0 0 1-9 9"},child:[]}]})(t)}function Us(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"},child:[]}]})(t)}function Ws(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"},child:[]},{tag:"polyline",attr:{points:"13 2 13 9 20 9"},child:[]}]})(t)}function Zc(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},child:[]},{tag:"polyline",attr:{points:"14 2 14 8 20 8"},child:[]},{tag:"line",attr:{x1:"16",y1:"13",x2:"8",y2:"13"},child:[]},{tag:"line",attr:{x1:"16",y1:"17",x2:"8",y2:"17"},child:[]},{tag:"polyline",attr:{points:"10 9 9 9 8 9"},child:[]}]})(t)}function wo(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},child:[]},{tag:"polyline",attr:{points:"15 3 21 3 21 9"},child:[]},{tag:"line",attr:{x1:"10",y1:"14",x2:"21",y2:"3"},child:[]}]})(t)}function ra(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 20h9"},child:[]},{tag:"path",attr:{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"},child:[]}]})(t)}function ia(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"},child:[]}]})(t)}function yi(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"7 10 12 15 17 10"},child:[]},{tag:"line",attr:{x1:"12",y1:"15",x2:"12",y2:"3"},child:[]}]})(t)}function wi(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"4",y:"4",width:"16",height:"16",rx:"2",ry:"2"},child:[]},{tag:"rect",attr:{x:"9",y:"9",width:"6",height:"6"},child:[]},{tag:"line",attr:{x1:"9",y1:"1",x2:"9",y2:"4"},child:[]},{tag:"line",attr:{x1:"15",y1:"1",x2:"15",y2:"4"},child:[]},{tag:"line",attr:{x1:"9",y1:"20",x2:"9",y2:"23"},child:[]},{tag:"line",attr:{x1:"15",y1:"20",x2:"15",y2:"23"},child:[]},{tag:"line",attr:{x1:"20",y1:"9",x2:"23",y2:"9"},child:[]},{tag:"line",attr:{x1:"20",y1:"14",x2:"23",y2:"14"},child:[]},{tag:"line",attr:{x1:"1",y1:"9",x2:"4",y2:"9"},child:[]},{tag:"line",attr:{x1:"1",y1:"14",x2:"4",y2:"14"},child:[]}]})(t)}function ed(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"15 14 20 9 15 4"},child:[]},{tag:"path",attr:{d:"M4 20v-7a4 4 0 0 1 4-4h12"},child:[]}]})(t)}function bo(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 14 4 9 9 4"},child:[]},{tag:"path",attr:{d:"M20 20v-7a4 4 0 0 0-4-4H4"},child:[]}]})(t)}function td(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"14 9 9 4 4 9"},child:[]},{tag:"path",attr:{d:"M20 20h-7a4 4 0 0 1-4-4V4"},child:[]}]})(t)}function Ls(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},child:[]}]})(t)}function jo(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"16 18 22 12 16 6"},child:[]},{tag:"polyline",attr:{points:"8 6 2 12 8 18"},child:[]}]})(t)}function aa(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(t)}function nd(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"7 13 12 18 17 13"},child:[]},{tag:"polyline",attr:{points:"7 6 12 11 17 6"},child:[]}]})(t)}function Co(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"18 15 12 9 6 15"},child:[]}]})(t)}function _t(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 18 15 12 9 6"},child:[]}]})(t)}function nn(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"6 9 12 15 18 9"},child:[]}]})(t)}function ss(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"20 6 9 17 4 12"},child:[]}]})(t)}function sd(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 11 12 14 22 4"},child:[]},{tag:"path",attr:{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"},child:[]}]})(t)}function So(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"},child:[]},{tag:"line",attr:{x1:"16",y1:"2",x2:"16",y2:"6"},child:[]},{tag:"line",attr:{x1:"8",y1:"2",x2:"8",y2:"6"},child:[]},{tag:"line",attr:{x1:"3",y1:"10",x2:"21",y2:"10"},child:[]}]})(t)}function rd(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(t)}function id(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"},child:[]},{tag:"path",attr:{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"},child:[]}]})(t)}function oa(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"},child:[]},{tag:"path",attr:{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"},child:[]}]})(t)}function cr(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"19",x2:"12",y2:"5"},child:[]},{tag:"polyline",attr:{points:"5 12 12 5 19 12"},child:[]}]})(t)}function No(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"polyline",attr:{points:"19 12 12 19 5 12"},child:[]}]})(t)}function la(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"21 8 21 21 3 21 3 8"},child:[]},{tag:"rect",attr:{x:"1",y:"3",width:"22",height:"5"},child:[]},{tag:"line",attr:{x1:"10",y1:"12",x2:"14",y2:"12"},child:[]}]})(t)}function Eo(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"},child:[]},{tag:"line",attr:{x1:"12",y1:"9",x2:"12",y2:"13"},child:[]},{tag:"line",attr:{x1:"12",y1:"17",x2:"12.01",y2:"17"},child:[]}]})(t)}function ad(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12.01",y2:"16"},child:[]}]})(t)}const To="pi-harness:lang",od={changesTitle:"改动",changesRegenerate:"重新生成",changesTurn:"本轮",changesBranch:"整个分支",changesWork:"未提交",changesSummary:"改了 {n} 个文件",changesViewAll:"全部查看",changesMore:"还有 {n} 个文件",changesFiles:"{n} 个文件",changesList:"文件列表",changesBase:"基准分支",changesSearch:"在改动里搜索",changesExpand:"全部展开或收起",changesEmpty:"此范围没有改动",changesBinary:"二进制文件,无法显示差异",changesUnavailable:"没有可显示的文本差异",changesUnlocated:"行号不可用",changesLarge:"大文件 · 点击展开",changesUnchanged:"⇕ {n} 行未改动",changesTrailing:"显示后面 {n} 行",changesRecent:"刚刚改动",changesTruncated:"差异已截断",changesLoading:"正在读取改动…",changesReducedContext:"改动较大,只显示改动附近的上下文。",changesOmittedUntracked:"另有 {n} 个未跟踪文件未显示,可将它们加入 .gitignore。",changesCommands:"{n} 条命令",bashDurationUnknown:"耗时未记录",bashGroupCount:"运行了 {n} 条命令",bashGroupRunning:"正在运行 {n} 条命令",bashGroupFailed:"· {n} 条失败",bashGroupCwd:"在 {path}",bashGroupEarlier:"前面还有 {n} 条 · 展开全部",bashExtraLines:"+{n} 行",bashExitCode:"退出码 {n}",bashUnfinished:"未完成",bashRemainingLines:"展开其余 {n} 行",bashCopyCommand:"复制命令",bashCopyOutput:"复制输出",bashOpenTerminal:"在终端中打开",bashOpenTerminalHint:"在可见终端重新运行完整命令",bashCommandCount:"{n} 条命令",editBusy:"编辑重问暂不可用,请等待当前回复、压缩或切换完成。",editFailed:"编辑重问已取消或失败。",treeTitle:"会话树",treeFork:"派生新会话",treeForkAt:"从这里派生",treeFilter:"过滤节点",treeSearch:"搜索会话树",treeExternal:"会话文件已被外部修改,重新打开后才能继续写入。",treeReopen:"重新打开",treeTruncated:"结果超过 5000 个节点,请缩小过滤范围或搜索。",treeEmpty:"没有匹配的节点",treeFold:"折叠或展开分支",treeNavigate:"切换到这里",treeLabel:"设置书签",treeNodes:"个节点",treeClone:"复制当前分支",treePreviewCount:"将总结 {n} 条记录",treeSummary_none:"不生成摘要",treeSummary_default:"生成摘要",treeSummary_custom:"按自定义指令生成摘要",treeInstructions:"摘要指令",treeStopConfirm:"停止当前回复并切换,将排队消息放回输入框",treeLabelClear:"留空可清除书签",treeContent:"节点内容",treeDisconnected:"连接已断开,请重连后重试",treeBusy:"等待当前回复、压缩或切换完成",treeCancelled:"扩展取消了切换",treeAborted:"已取消分支摘要,保留原位置",treeFailed:"会话树操作失败",treeDraftConflict:"切换返回了文本,当前输入框已有草稿。请选择如何保留。",treeReturnedText:"查看返回的文本",treeReplaceDraft:"替换草稿",treeAppendDraft:"追加到草稿",treeKeepDraft:"保留当前草稿",treeEditOptions:"重问选项",treePrevious:"上一个分支",treeNext:"下一个分支",treeSummarizing:"正在总结离开的分支",treeEditNewSession:"编辑重问时新建会话",treeBranches:"{n} 个分叉点",treeDerived:"派生自 {name}",treeFilter_default:"默认","treeFilter_no-tools":"隐藏工具","treeFilter_user-only":"仅用户","treeFilter_labeled-only":"仅书签",treeFilter_all:"全部(CLI 规则)",treeKind_user:"用户",treeKind_assistant:"助手",treeKind_tool:"工具",treeKind_compaction:"压缩",treeKind_branchSummary:"分支摘要",treeKind_custom:"自定义",treeKind_model:"模型",treeKind_thinking:"思考档位",treeKind_info:"会话信息",treeKind_contextEdit:"上下文编辑",treeKind_label:"书签变更",wikiSaving:"保存中",wikiSaved:"已保存",wikiSaveFailedRetry:"保存失败 · 重试",wikiExternalChanged:"文件已在外部修改",wikiKeepMine:"保留我的版本",wikiMessageActions:"消息操作",wikiFullRequest:"查看完整发送内容",wikiResend:"重新发送",wikiReplyChanged:"修改了 {file}",wikiViewChange:"查看",richImage:"图片",richWikiLink:"文档链接",wikiLinkAddress:"输入链接,或 [[ 搜索文档",wikiInsertLinkAction:"插入链接",wikiInvalidLink:"请输入 http、https、mailto 或相对链接",wikiInsertParagraph:"普通正文段落",wikiInsertH1:"一级标题",wikiInsertH2:"二级标题",wikiInsertH3:"三级标题",wikiInsertList:"无序的项目列表",wikiInsertOrdered:"按顺序排列的列表",wikiInsertTask:"可勾选的待办事项",wikiInsertQuote:"引用一段文字",wikiInsertCode:"带语法高亮的代码",wikiInsertCallout:"强调提示或注意事项",wikiInsertTable:"插入 3 × 3 表格",wikiInsertDivider:"分隔不同内容",wikiInsertImage:"上传或粘贴图片",wikiInsertLink:"搜索并链接到文档",wikiNoInsertResults:"没有匹配项 · 按 Esc 关闭",wikiInsertKeys:"↑ ↓ 选择 ↵ 插入 Esc 关闭",v2PromptHint:"每次对话开头发给模型",v2IdentityHint:"告诉模型它是 Pi,该怎么工作",v2ToolsHint:"模型能调用的能力,随启用的工具和扩展变化",v2RulesHint:"工具的用法说明,由 Pi 自动去重",v2DocsHint:"只在你问到 Pi 本身时才读取",v2AppendHint:"写在默认内容之后的个人要求,例如回复语言",v2ContextHint:"当前目录和上级目录中的上下文,自动读取",v2CreateAgents:"新建 AGENTS.md",v2PiHint:"Desktop 内置的智能体引擎,随应用升级",v2ExtensionsIntro:"扩展为 Pi 增加工具和命令;扩展包还可以包含技能、提示词和主题。",v2ExtensionCount:"共 {n} 项",v2LastChecked:"上次检查 {time}",v2PackagesHint:"可检查更新",v2NoPackages:"还没有可管理的扩展包。浏览 pi.dev,找到需要的工具或技能。",v2FilesHint:"修改文件后重新加载生效",v2UpdatePolicy:"更新方式",v2AutoCheckHint:"打开管理页时检查,此后服务运行期间每 6 小时检查扩展包",v2InstallPolicy:"安装扩展更新",v2InstallHint:"由你确认更新;完成后重新加载或新建会话生效",v2ManualInstall:"手动安装",v2SkillsIntro:"技能是按需读取的操作指南。启用后仅名称和描述进入提示词,需要时才读取正文;关闭后不会被发现。",v2SkillCount:"共 {n} 项 · 已启用 {enabled} 项 · 约 {tokens} tokens",v2SkillSearch:"搜索技能名称或描述",v2SkillPackage:"扩展包",v2SkillAll:"全部",v2SkillsPaths:"技能目录",v2CopyPaths:"复制目录路径",v2OpenSkills:"打开技能目录",v2SkillsChanged:"已保存原生技能配置。重新加载或新建会话后生效。",v2ServersHint:"连接外部服务,让模型使用更多工具",v2ScopeHint:"全局对所有项目生效;项目只影响当前工作目录",v2CodemodeHint:"让模型写小段脚本批量调用工具,减少往返和上下文占用",v2ModeHint:"on:保留直接调用;only:工具通过脚本调用",v2BudgetHint:"直接放入上下文的工具声明预算;0 表示全部按需查找",v2AutoHint:"有 MCP 服务时自动启用 Codemode",v2EditMcp:"编辑 mcp.json",v2NoServersHint:"还没有配置服务。导入已有配置,或新建一个连接。",promptSavedShadowed:"已保存;当前会话仍使用优先级更高的同名文件。",promptDiscard:"放弃未保存的改动?",promptRestoreConfirm:"删除 {path}?Pi 将按原生优先级使用下一份 SYSTEM.md;没有其他文件时恢复默认提示词。",promptCopyFailed:"复制失败,请从原始文本中手动复制。",promptReplaceWarning:"SYSTEM.md 会替换默认身份、工具说明、规则和 Pi 文档段落。追加提示词、项目上下文、技能及工作目录仍由 Pi 管理。建议只需要补充指令时使用追加提示词。",promptContinueReplace:"继续替换",promptScope:"保存范围",promptUser:"个人 · 所有项目",promptProject:"当前项目",promptUntrusted:"未信任",promptContextHint:"编辑实际加载的上下文文件;上级目录或个人文件的修改也会影响使用它的其他项目。",promptEditor:"提示词文件内容",promptNativeSave:"保存到原生文件",promptReloadFile:"重新读取文件",promptSaving:"保存中…",promptSave:"保存",promptTokenHint:"粗略估算,包含技能和工作目录;实际 token 数取决于模型。",promptTokens:"约 {n} tokens",promptViewSections:"分段视图",promptViewRaw:"原始文本",promptCopied:"已复制",promptCopy:"复制全文",promptSavedPending:"文件已保存,等待会话空闲后重新加载。",promptSavedNext:"已重新加载;Pi 会在下一次请求中应用变化。",promptReloadFailed:"原生重新加载失败,文件已保存。",promptRetry:"重试加载",promptForced:"当前扩展强制设置了完整提示词,无法可靠拆分来源。仅显示原始文本,编辑已禁用。",promptOpaque:"当前提示词无法与 Pi 原生结构匹配,仅显示原始文本,编辑已禁用。",settingsLoaded:"已加载",settingsNoSkills:"暂无技能",settingsNoServers:"暂无服务器",settingsImportSave:"导入并保存",settingsRetrySave:"重试保存",settingsToolPresentation:"工具呈现",settingsDeclarationBudget:"声明预算",settingsAutoCodemode:"连接 MCP 时自动启用",settingsPackages:"包",settingsUpdates:"更新",settingsAutoCheck:"自动检查更新",settingsCheckNow:"立即检查",settingsBundled:"随应用更新",promptDefault:"身份",promptReplaced:"已由 SYSTEM.md 或运行时设置替换",promptBuiltinIdentity:"pi 默认",promptEdit:"编辑",promptRestore:"移除此替换",promptReplace:"替换",promptTools:"工具",promptInactive:"未包含说明",promptAutomatic:"自动生成",promptRules:"规则",promptRuleSummary:"{builtin} 条内置 · {tools} 条工具 · {extensions} 条扩展 / 运行时",promptCollapse:"收起",promptExpand:"展开",promptBuiltin:"内置",promptExtension:"扩展",promptRuntime:"运行时",promptDocs:"Pi 文档",promptDocsSummary:"按需阅读",promptAppend:"追加提示词",promptNotSet:"未设置",promptAdd:"添加",promptContext:"项目上下文",promptNoContext:"没有加载上下文文件",promptRuntimeSection:"原生运行时提供的额外段落",promptPriority:"受信任项目的 .pi 文件优先于个人目录同名文件;每类仅加载一份。技能和工作目录包含在全文中。",promptProjectNotTrusted:"当前项目尚未获得 Pi 信任,项目级替换与追加文件不可编辑。",promptDiskChanged:"磁盘内容与当前加载版本不同",connectionDisconnected:"连接已断开",downloadImage:"下载",extNew:"刚安装",extRetry:"重试",extEditFile:"编辑文件",extEditHint:"保存前请检查代码。变更将在重载后生效。",extDiscard:"放弃未保存的改动?",extSaveFile:"保存文件",extReleaseNotes:"版本说明",extNoNotes:"暂无可读取的版本说明。",extViewNotes:"查看完整版本说明",extSubtitle:"管理 Pi 原生扩展包与单文件扩展",extDetails:"查看详情",extPersonal:"个人",extProject:"项目",extUntrusted:"未信任 · 未加载",extPinned:"已锁定",extUpdate:"更新",extEnable:"启用",extOpen:"在文件管理器中显示",extCopyPath:"复制路径",extUnpin:"解除版本锁定",extMoveProject:"仅用于此项目",extMovePersonal:"移到个人范围",extRemoveReference:"移除引用",extUninstall:"卸载",extResources:"包含的资源",extResourceConfig:"资源单项开关由 pi config 管理,整包开关保留原有过滤规则。",extInstalled:"已安装",extBrowse:"浏览 pi.dev",extRefresh:"刷新",extRunning:"正在处理扩展包…",extDone:"操作完成",extFailed:"操作失败",extLog:"查看完整日志",extReloadHint:"变更在新会话生效;也可重载当前会话。",extReload:"重载当前会话",extLastChecked:"上次检查",extNotChecked:"尚未检查更新",extChecking:"检查中…",extCheck:"检查更新",extUpdatesAvailable:"个包可更新",extUpdateAll:"全部更新",extFilter:"筛选已安装扩展…",extScope:"安装范围",extInstallProject:"仅本项目",extAllScopes:"所有范围",extEmpty:"没有匹配的扩展包,浏览目录或从来源安装。",extSingleFiles:"单文件扩展 · 不检测版本更新",extAutoCheck:"打开页面时及每 6 小时自动检查更新",extTypeExtension:"扩展",extTypeSkill:"技能",extTypePrompt:"提示词",extTypeTheme:"主题",extLicenseUnknown:"未提供许可证",extCatalogPage:"pi.dev 页面",extCatalogOrigin:"来自 pi.dev · 带 pi-package 关键字的 npm 包 · 共 {count} 个",extCatalogOriginPage:"来自 pi.dev · 本页 {count} 个包",extInstallSource:"从 npm / git 安装",extUntrustedNotLoaded:"未信任,未加载",extWillLoad:"将加载的资源",extProjectUntrusted:"本项目尚未信任,暂不能安装到项目。",extNoneDeclared:"无",extInstalling:"安装中…",extSearch:"搜索 pi.dev 扩展包…",extSort:"排序",extPopular:"最多下载",extRecent:"最近更新",extAllTypes:"全部",extDownloads:"下载 / 月",extInstall:"安装",extNoResults:"没有找到匹配的扩展包。",extPrevious:"上一页",extNext:"下一页",extConfirm:"确认操作",extSource:"包来源",extReview:"查看安装信息",extResourcesUnknown:"该来源未声明资源清单;请先查看源代码。Git 来源在确认安装后才拉取。",extPinVersion:"锁定此版本",extSecurity:"扩展会在本机运行代码,技能可能让模型执行命令。不确定的话先看一下源码。",extViewSource:"查看源代码",extCancel:"取消",extRemoveHint:"移除这个包的配置及托管安装。对于本地路径,只移除引用,保留文件。",extMoveHint:"安装到目标范围,成功后移除原范围的声明,保留资源过滤规则。",extUnpinHint:"解除固定版本或 Git ref,下次检查可获取更新。",extUpdateHint:"更新可升级的包;锁定版本及本地路径保持不变。",cmCalls:"调用",cmScript:"脚本",cmWaitingCalls:"等待脚本调用…",cmNoCalls:"没有嵌套调用",cmMoreCalls:"前面还有 {n} 次调用 · 展开全部",cmCollapseCalls:"只显示最后 8 次调用",cmCancelled:"已取消",cmUnfinished:"未完成",cmLimitedCalls:"另有 {n} 次调用未在此显示",cmTruncated:"此预览已截断。",cmWaitingOutput:"输出将在脚本返回时显示。",cmNoOutput:"脚本没有文本输出。",cmFullOutput:"完整输出文件",cmFailureNote:"脚本失败前的工具调用已实际执行,不会自动撤销。错误及相似工具名建议见「输出」。",cmSaveImage:"保存到当前目录",cmAttachImage:"附加到下一条消息",cmAttached:"图片已添加到输入框",cmSaved:"已保存:{path}",cmModelCost:"模型调用费用",mcpDesignIntro:"管理原生 MCP 连接与 Codemode;设置直接保存到 pi 配置。",mcpServersTitle:"服务器",mcpAttentionFirst:"需要处理的连接优先显示,后台连接不会阻塞聊天输入。",mcpImport:"从其他客户端导入",mcpImportHelp:"粘贴 Claude、Cursor、VS Code 或 OpenCode 的 JSON 配置。重名服务器不会被覆盖;Codex TOML 请先转换为 mcpServers JSON。",mcpImportDraft:"导入到草稿",mcpEditorHelp:'填写原生服务器 JSON:本地使用 command / args / env,远程使用 url / headers / oauth。支持 clientRegistration: "cimd"。',mcpInvalidServer:"服务器配置必须是 JSON 对象",mcpDiscard:"放弃未保存的配置更改?",mcpNeedsAuth:"需要登录",mcpConnected:"已连接",mcpConnecting:"连接中",mcpDisabled:"已停用",mcpDisconnected:"已断开",mcpNotLoaded:"未加载",mcpFailed:"连接失败",mcpRuntime:"其他配置来源",mcpAuthHelp:"使用 pi 原生 OAuth 登录。服务器要求额外权限时,重新登录会保留已授予的权限。",mcpRemoteLogin:"浏览器在另一台机器上?登录后将跳转地址粘贴到原生登录输入框。",mcpAnnotations:"提示",mcpActualExposure:"实际暴露方式",mcpDestructive:"破坏性",mcpReadOnly:"只读",mcpInherit:"继承",mcpNoTools:"当前连接没有可展示的工具。",mcpExposureDraftHint:"* 为单工具覆盖。左侧是 SDK 实际暴露状态,codemode 在 SDK 中映射为 deferred;右侧修改配置草稿,保存后应用。",mcpEnableServer:"启用",mcpDisableServer:"停用",mcpEnableProject:"在本项目启用",mcpDisableProject:"在本项目停用",mcpRemoveConfirm:"从配置草稿中移除 {name}?保存后生效。",mcpUnsaved:"有未保存的更改",mcpSavedConfig:"配置已保存",mcpSaveApply:"保存并应用",mcpExposureGuide:"工具暴露方式说明",mcpExposure_codemode:"通过脚本或工具搜索按需发现,不直接声明。",mcpExposure_deferred:"tool_search 找到后加载,也可从脚本调用。",mcpExposure_direct:"直接声明给模型,同时支持脚本调用。",mcpExposure_hidden:"保留注册,但不可调用。",mcpEmpty:"尚未配置服务器。添加一个本地或远程 MCP 服务。",mcpCodemodeHelp:"只将脚本输出传给模型。工具调用遵循 pi 原生权限与生命周期。",mcpModeHelp:"on 保留直接工具;only 让模型统一通过脚本调用工具。",mcpBudgetHelp:"工具声明的估算 token 预算,默认 3000。0 仅列命名空间。",mcpBudgetSlider:"调整工具声明预算",mcpEffective:"当前会话生效值",mcpSaveCodemode:"保存 Codemode 设置",mcpAutoHelp:"codemode 暴露的 MCP 服务连接时自动启用。此项随 MCP 配置保存,不会关闭已启用的 codemode。",mcpAdvanced:"高级:原生 JSON 配置",wikiLoadMore:"加载更多文件",wikiOpenDefault:"用默认应用打开",wikiHiddenFolders:"隐藏文件夹 · {count}",wikiProperties:"文档属性",wikiIndexSkipped:"跳过 {count}",wikiIndexCounting:"统计中",wikiIndexStatus:"已索引 {indexed} / {total}",wikiIndexIssueCount:"{count} 项受限:{reason}",wikiIndexMultipleReasons:"{count} 种原因,点击查看",wikiIndexFileSize:"单个文件超过 2 MB",wikiIndexBudget:"总读取量超过 64 MB",wikiIndexEntries:"超过 20,000 项",wikiIndexDepth:"目录深度超过 32 层",wikiIndexUnreadable:"文件无法读取或路径不可访问",wikiIndexSubtree:"该目录还有未扫描内容",wikiIndexPartial:"扫描未覆盖整个工作区,仍有未统计的文件。下方按原因列出受限文件或未扫描目录。",wikiIndexHint:"部分内容未纳入索引。达到大小或预算限制的文件仍可按路径查找;无法访问的路径需要先解决访问问题。",wikiIndexComplete:"索引已完成,没有受限文件。",wikiUpdatedToday:"今天 {time} 更新",wikiUpdatedDate:"{date}更新",wikiReadingTime:"约 {minutes} 分钟读完",wikiCitations:"{count} 篇引用本文",wikiOnThisPage:"本页",wikiExpandComposer:"展开提问框",wikiCompactPlaceholder:"问 pi 关于这篇文档…",wikiCollapseComposer:"Esc 收起",wikiDocumentsOnly:"只改文档",wikiMayEditCode:"可改代码",wikiReferenceHint:"@ 引用",wikiSessionPreparing:"会话准备中",wikiRetrySession:"重试创建会话",wikiReferencesLoading:"引用加载中",wikiMode:"Wiki 模式",wikiRecent:"最近改动",wikiPreview:"渲染预览",wikiSource:"编辑源码",wikiSearchAll:"搜索全部文件",wikiFiles:"目录",wikiClear:"清除",wikiRefresh:"刷新文件",wikiUnread:"pi 修改后未查看",wikiNoFiles:"没有匹配的文件",wikiReload:"重新加载",wikiLimits:"部分文件未建立全文索引:单文件上限 2 MB,总量 64 MB,最多 20,000 项。目录仍可查看。",wikiBacklinks:"反向链接",wikiUnsaved:"有未保存修改",wikiCodeReadOnly:"代码只读 · 点击「编辑源码」可手动编辑",wikiEditingSource:"源码编辑 · ⌘/Ctrl S 保存",wikiPiAdded:"pi 新增",wikiDownloadOpen:"下载并用默认应用打开",wikiNoBacklinks:"还没有文档引用此文件",wikiWelcome:"和 pi 一起整理知识",wikiWelcomeHint:"从左侧打开文件,或搜索整个工作区。",wikiChangedFiles:"pi 修改了 {count} 个文件",wikiRedo:"重做",wikiUndo:"撤销",wikiChatPanel:"Wiki 对话面板",wikiFocus:"专注阅读",wikiTableSize:"表格尺寸",wikiTableDimensions:"{columns} 列 × {rows} 行",wikiTableHeader:"带表头",wikiSearchLanguage:"搜索语言…",wikiCodeAutomatic:"自动识别",wikiCodeAutomaticHint:"默认",wikiCodeShell:"命令行",wikiCodePython:"脚本",wikiCodeTypescript:"类型脚本",wikiCodeData:"结构化数据",wikiCodeConfig:"配置",wikiCodeQuery:"数据库查询",wikiCodeDiagram:"图表与源码",wikiMoreInsert:"更多插入",wikiMoreInsertHint:"更多插入 · 也可以输入 /",wikiStandardWidth:"标准宽度",wikiWideWidth:"宽版(隐藏两侧)",wikiMentionDate:"提及日期",wikiInsertDate:"插入今天的日期",wikiEmptyParagraph:"输入 / 插入内容,或直接写",wikiExitFocus:"退出专注阅读",wikiChatTitle:"对话",wikiCloseChat:"收起对话面板",wikiChatContext:"上下文 {percent}%",wikiNoModel:"未选择模型",wikiEarlierMessages:"查看更早的消息",wikiQuickSummary:"总结这篇文档",wikiQuickLinks:"找出失效链接",wikiQuickSections:"补全空的小节",wikiChatEmpty:"问 pi 关于这篇文档,或选中文字后提问。",wikiJumpSection:"跳到 §{section}",wikiToolInterrupted:"已中断",wikiWorking:"正在处理…",wikiLastAnswer:"最近一轮回复",wikiSelected:"选中内容",wikiAsk:"问 pi",wikiAskCode:"问 pi 关于 {file},比如「和文档一致吗」",wikiAskPlaceholder:"问 pi 关于这篇文档…",wikiScope:"范围",wikiCurrentScope:"范围 · 当前文档",wikiWholeScope:"范围 · 整个工作区",wikiReferencedScope:"范围 · 引用文件",wikiAllowCode:"允许修改代码",wikiPromptPreview:"查看发送内容",wikiStop:"停止",wikiSend:"发送",wikiRelatedChanges:"相关文档改动",wikiMe:"我",wikiFileCount:"{count} 个文件",wikiUndoAll:"全部撤销",wikiRedoAll:"全部重做",wikiViewDiff:"查看前后版本",wikiBinaryChange:"二进制文件改动,可恢复原始文件",wikiNewFile:"(新建文件)",wikiDeletedFile:"(已删除)",wikiUntracked:"以下文件未纳入撤销记录",wikiNoChanges:"Wiki 中的编辑和 pi 改动会显示在这里",wikiAskPi:"问 pi",wikiRewrite:"改写",wikiExplain:"解释",wikiAddLink:"加双链",wikiSearchHint:"搜索文档、代码和 PDF 内容…",wikiDocuments:"文档",wikiPdf:"PDF",wikiCode:"代码",wikiPage:"第 {page} 页",wikiNoResults:"没有找到结果",wikiSearchLimited:"结果有截断或部分文件无法搜索;PDF 最多搜索 8 个、每个 200 页。",wikiSearchKeys:"↑↓ 选择 ↵ 打开 ⌘/Ctrl ↵ 交给 pi Esc 关闭",wikiUnsavedHint:"先保存当前文件,再继续操作?",wikiDiscard:"放弃修改",wikiSaveContinue:"保存后继续",wikiSaveFirst:"请先保存或放弃当前草稿,再撤销文件改动。",wikiMissingLink:"找不到唯一对应文件:{path}",wikiDocumentsOnlyPrompt:"仅在用户明确要求修改时,将修改限制在此范围内的文档。代码文件默认只读,除非本条请求明确要求修改代码。",wikiSkipPrompt:"以上范围、引用与选区仅作为上下文,不代表用户要求分析或修改文档。请按用户本条消息的实际意图回复;问候或闲聊直接回应,不要因此读取、诊断或修改文件。只有用户明确要求修改时才编辑并保存,随后说明实际改动。",wikiRewritePrompt:"请改写选中内容,保持原意并保存。",wikiExplainPrompt:"请解释选中内容,不修改文件。",wikiLinkPrompt:"请为选中内容添加指向工作区已有文档的 [[双链]] 并保存,不要编造目标文件。",mcpArgs:"参数(JSON 数组)",mcpEnv:"环境变量(JSON 对象)",mcpHeaders:"HTTP headers(JSON 对象)",mcpProvider:"凭据服务商(仅全局)",mcpOauth:"OAuth 参数(JSON 对象,含 authServerMetadataUrl)",mcpEnabled:"启用",mcpExposure:"工具 exposure",mcpUpdateDraft:"更新配置草稿",mcpNew:"新建服务",mcpEdit:"编辑",nativeMcp:"MCP 与 Codemode",mcpScope:"配置范围",mcpGlobal:"全局",mcpProject:"当前项目",mcpExplanation:"原生 MCP 使用 Pi 配置与凭据。旧界面 MCP 桥仍使用应用 data-dir/mcp.json。",mcpUntrusted:"项目尚未信任,保存不会自动加载此配置。",mcpTrust:"信任当前项目",mcpPending:"等待当前任务结束后应用",mcpName:"服务名称",mcpCommand:"命令",mcpAdd:"加入配置草稿",mcpConfig:"MCP 配置 JSON",mcpJsonHelp:"JSON 可编辑 args、env、headers、auth.provider、oauth(含 authServerMetadataUrl)、enabled、exposure 及高级字段。•••••••• 保留原敏感值,替换为新值或删除字段以清除。删除 mcpServers 中的条目可移除服务。",mcpNameConflict:"名称为空或已存在",mcpRefresh:"刷新配置",mcpStatus:"官方连接状态",mcp_login:"登录",mcp_logout:"退出",mcp_reconnect:"重连",mcpTools:"可用工具",mcpConfigureRadius:"配置 Radius MCP",nonChatModelsPreserved:"此处仅编辑聊天模型。另有 {n} 个图片或分类模型,其配置会保留。",providerAuthChoose:"请选择",providerLogout:"退出账号",providerLogin:"登录账号",providerChatGPTLogin:"使用 ChatGPT 登录",providerAuthPending:"正在等待授权,请在浏览器中完成登录。",providerAuthSuccess:"登录成功,模型列表已更新。",providerAuthCancelled:"登录已取消。",providerAuthError:"登录失败。",providerAuthOpenBrowser:"打开授权页面",providerAuthDeviceCode:"授权码:",nodeConnectionTiming:"握手 {ms} ms · 已连接 {duration}",nodeRevealSource:"在本机定位配置",nodeSources:"节点来源",nodeSourceIntro:"连接已有的会话配置。在原工具中新增、修改节点,这里自动更新。",nodeDetect:"检测本机来源",nodeSyncKeep:"同步并保持更新",nodeImportOnce:"只导入一次",nodeChangePath:"选择其他路径",nodeSourcePath:"运行服务的机器上的配置路径",nodeSyncNow:"立即同步",nodeSyncPause:"暂停同步",nodeSyncResume:"恢复同步",nodeSyncInfo:"{n} 个节点 · {g} 个分组",nodeSyncTime:"上次同步:{time}",nodeSyncFields:"名称、分组、地址、端口、用户名及私钥路径",nodeSyncPassword:"暂不支持导入保存的密码,首次连接时补填",nodeSyncUnsupported:"跳板机、代理及其他不支持的选项会标记并阻止连接",nodeSearch:"搜索名称、地址",nodeMissingSecret:"缺密码",nodeSourceMissing:"来源已移除",nodeUnsupported:"暂不支持此配置",nodeFillSecret:"认证设置",nodeLocalAuthHint:"可切换密码或公钥认证。测试通过后保存在本机,不修改 Xshell 原配置,正常同步不会覆盖;来源的主机、用户或认证资料变化时重置。",nodeCredentialHint:"凭据单独保存,配置同步不会覆盖。Xshell 中修改密码后需在这里更新。",nodePersistSecret:"加密保存在运行服务的机器上",nodeGroupSecret:"同组且认证方式相同的节点使用此凭据",nodeGroupHint:"仅测试当前节点;同组其他节点在连接时验证。",nodeTestSave:"测试并保存",nodeTesting:"正在验证…",nodeCredentialsSaved:"凭据已验证,已应用到 {n} 个节点",nodeSourceReadonly:"来源字段只读,请在原工具中编辑",nodeSourceLocation:"来源文件",nodeLastConnected:"上次连接",nodeNever:"从未",nodeOpenTerminal:"打开终端",nodeBackList:"‹ 节点",nodeDetails:"节点详情",nodePolicy:"Agent 执行权限",nodePolicyReadonly:"只读自动 · 其余确认",nodePolicyConfirm:"每次执行需确认",nodePolicyAuto:"允许自动执行",nodePolicyOff:"停用 Agent",nodePolicyHint:"已识别的只读命令自动执行;写入、重启及无法确定的命令需确认。",nodeApproval:"需要确认",nodeAllow:"允许执行",nodeDeny:"不执行",nodeEditCommand:"改命令",nodeLocate:"定位 ↗",nodeRunOutput:"命令输出",nodeSendSelection:"发给 pi · {n} 行",nodeSelection:"终端选中 · {n} 行",nodeTerminalHint:"紫色标记为 pi 命令 · 选中输出可发给 pi",nodeCopy:"复制",nodeCopied:"已复制",nodeModel:"节点模型",nodeNoModel:"请先配置模型",nodeShowFiles:"文件",nodeCloseTab:"关闭终端",nodeAddSource:"添加来源",nodeNoSources:"未检测到默认来源,可手动指定 Xshell 会话目录或 SSH config 文件。",nodeWorkingHere:"在 {name} 上",nodeRunFailed:"执行失败",nodeSourceOpenHint:"复制路径,在 Xshell 或文本编辑器中打开原配置。",nodeQuoteRemove:"移除引用",currentFileLabel:"当前文件",currentFileUnsaved:"未保存",currentFileDraft:"当前文件 · 未保存草稿",currentFileUnavailable:"当前文件尚未就绪,请重新打开或移除标签",currentFileTooLarge:"当前文件快照超过 512 KiB,请缩减内容或移除标签",currentFileSaving:"当前文件正在保存,请稍候再发送",switchingProject:"正在同步项目…",retryProjectSwitch:"重试切换项目",cancel:"取消",ok:"确定",save:"保存",close:"关闭",widgetExpand:"点击放大查看完整输出",dragToResize:"拖拽调整宽度 · 双击复位",loading:"加载中…",connected:"已连接",connecting:"连接中…",reconnecting:"重连中…",language:"语言",langZh:"中文",langEn:"English",githubRepo:"GitHub 仓库(youweichen0208/pi-harness)",copy:"复制",viewSwitch:"视图切换",desktopWorkspace:"工作区",windowControls:"窗口操作",minimizeWindow:"最小化窗口",maximizeWindow:"最大化窗口",restoreWindow:"还原窗口",closeWindow:"关闭窗口(隐藏到托盘)",chat:"对话",terminal:"终端",nodes:"节点",nodeWorkbench:"SSH 节点",nodeAdd:"添加节点",nodeEdit:"编辑节点",nodeGroup:"分组",nodeName:"名称",nodeAddress:"地址",nodePort:"端口",nodeUsername:"用户名",nodeDefaultDir:"默认目录",nodeAuth:"认证方式",nodePassword:"密码",nodeKey:"公钥登录(私钥认证)",expandProjects:"展开项目栏",collapseProjects:"收起项目栏",nodePrivateKeyHint:"请选择运行 pi 的电脑上的 OpenSSH 私钥文件,不是 .pub 公钥。Xshell 密钥名称不能作为路径;可在 Xshell 用户密钥管理器中导出 OpenSSH 私钥。私钥口令可留空。",nodeAgentAuth:"SSH Agent",nodeKeyPath:"本机私钥路径",nodePassphrase:"私钥口令",nodeKeepSecret:"留空保留已存凭据",nodeImportLegacy:"导入 Remote-SSH 配置",nodeImportJson:"导入节点 JSON",nodeExport:"导出非机密资料",nodeEmpty:"选择或添加 SSH 节点",nodeAddHint:"添加节点,或导入已有 Remote-SSH 主机。",nodeConnected:"已连接",nodeDisconnected:"未连接",nodeConnect:"连接",nodeDisconnect:"断开",nodeTab:"终端 {n}",nodeTabClosed:"断开",nodeTabBusy:"Agent 执行中",nodeOpenHint:"连接后打开终端。Agent 将使用当前选中的终端。",nodeBrowse:"浏览文件",nodeChat:"节点 Agent",nodeChatPlaceholder:"向当前节点的 Agent 提问…",nodeSelectTerminal:"请先打开终端",nodeInterrupt:"中断终端",nodeStopAgent:"停止 Agent",nodeSend:"发送",nodeAgentWaiting:"pi 正在思考,等待响应…",nodeAgentExecuting:"pi 正在执行命令…",nodeAgentApproval:"等待你确认操作…",nodeDelete:"删除",nodeForgetHostKey:"清除主机密钥信任",nodeForgetHostKeyConfirm:"确认已核实 {name} 的新主机密钥?清除后下次连接会重新显示指纹。",nodeTrust:`首次连接 {name} ({host})
|
|
16
|
-
主机密钥指纹:{fingerprint}
|
|
17
|
-
确认信任?`,nodeDeleteConfirm:"删除 {name}?",nodeImported:"已导入 {n} 台节点(凭据请手动设置)",nodeInvalidJson:"节点 JSON 无效",selectModel:"选择模型",availableModels:"可用模型",noModels:"暂无可用模型(请先配置 API 密钥)",reasoning:"推理",vision:"识图",refreshModels:"刷新模型列表(保留手填,合并新增)",manageModels:"⚙ 管理模型(新增 / 修改)",manageModelsTitle:"管理模型",thinkingLevel:"思考强度",steerSend:"插话发送",activityReply:"正在生成回复…",activityTool:"正在运行 {name}…",activityReading:"正在读取 {name}…",waitingCommand:"等待命令完成…",onlyChanged:"只看改动",changedCount:"改动 {n}",yesterday:"昨天",noChangedFiles:"没有改动文件",goalEventSet:"目标已设定:{text}",cwdSwitchEvent:"工作目录切换到 {path}",goalEventComplete:"目标已完成:{text}",goalReviewDetails:"查看审查详情",thinkingDuration:"{n} 秒",thinkingUnrecorded:"耗时未记录",thinking:"思考",thinkingChip:"思考:{level}",sound:"声音",theme:"主题",themeDefault:"深色(默认)",newChat:"新对话",more:"更多",newChatTip:"新建对话(每个浏览器独立保存会话)","thinking.off":"关闭","thinking.minimal":"极简","thinking.low":"低","thinking.medium":"中","thinking.high":"高","thinking.xhigh":"极高","thinking.max":"最大",thinkingUnsupported:"当前模型不支持该级别,已按模型能力就近生效",context:"上下文",contextUsage:"上下文用量",usageContextTitle:"上下文窗口",usageCacheTitle:"缓存命中",usageCacheShort:"缓存",taskCurrentRound:"本轮",cumulativeCost:"累计成本",sessionMessages:"会话消息数",messages:"消息",pluginStatus:"插件状态",working:"工作中",queued:"排队",enterPath:"输入路径,Enter 切换",cwdTip:"工作目录:{path}(点击切换)",folderRef:"文件夹引用:{path}",refOnly:"仅引用:{path}",attachContent:"附加内容:{path}",attachLines:"附加选中行:{path}(第 {start}-{end} 行)",attachImage:"图片:{name}",attachFile:"文件:{name}",removeAttachment:"移除附件",attachHint:"将随下一条消息发送",uploadFile:"添加文件(图片/文本/任意文件,也可直接拖入或粘贴截图)",dropHereToAttach:"松开以添加文件",imageNotSupported:"当前模型不支持识图:图片将交给视觉桥转写(若未配置视觉模型则可能被忽略)",imageLoadFailed:"图片读取失败:{name}",fileLoadFailed:"文件读取失败:{name}",fileTooLarge:"文件过大已跳过(>{size}MB):{name}",foldersNotSupported:"不支持直接拖入文件夹,请展开后选择文件",placeholderStreaming:"继续输入,当前步骤结束后发送",stopTask:"停止任务",taskCommitting:"提交中",taskCompletionCriteria:"完成标准",taskOutlineChanged:"计划有变",taskOutlineAdded:"新增第 {n} 步「{title}」",taskOutlineRemoved:"移除「{title}」",taskOutlineUpdated:"调整第 {n} 步「{title}」",taskNoStepDetails:"尚无执行记录",otherDirectories:"其余 {n} 个目录",bashStatusFiles:"{n} 个文件",bashStatusAdded:"{n} 新增",bashStatusModified:"{n} 修改",bashStatusDeleted:"{n} 删除",bashStatusConflicts:"{n} 冲突",placeholderIdle:"给 pi 发送消息 — Enter 发送,/ 查看命令",placeholderConnecting:"正在连接服务器…",stopAgent:"停止智能体",stopQueuedAfterReconnect:"连接已中断;重连后将尝试停止当前对话。",stopUnavailable:"当前无法发送停止请求,请等待重新连接。",workDisconnected:"连接已中断,正在重连;运行状态待确认。",stop:"停止",bgTasks:"后台任务",bgTasksTip:"AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留",bgTasksEmpty:"暂无后台任务",bgTasksDesc:"AI 运行中启动并仍在监听的进程(按监听端口检测)",bgTaskPort:"端口",bgTaskPid:"PID",bgTaskSince:"启动",bgTaskStop:"停止",bgTaskStopAll:"全部关闭",bgTaskRefresh:"刷新",bgTaskJustNow:"刚刚",bgTaskMinutes:"{n} 分钟前",bgTaskHours:"{n} 小时前",bgTaskDays:"{n} 天前",stopBash:"停止",stopBashTip:"停止正在运行的 bash 命令(对话继续)",supplement:"排队",supplementTip:"加入队列:AI 回答完全结束后才发送(不打断)",commandAttempts:"试了 {n} 次",queueSteerTag:"插话",pendingMessages:"{n} 条待发",recallQueueEdit:"全部撤回编辑",deliverySteerHint:"当前这一步结束后发送",deliveryFollowHint:"本轮结束后发送",placeholderStreamingModes:"继续输入,↵ {primary} · ⌥↵ {alternate}",queueFollowTag:"排队",sendTip:"发送(Enter)",slashCommands:"命令",slashMenuHint:"↑↓ 选择 · Enter/Tab 补全",slashHelpTitle:"pi 命令",slashHelpHint:"输入 / 随时打开命令列表",slashLoading:"命令列表加载中…(连接服务器后可用)",slashBuiltin:"内置",slashExtension:"扩展",slashPrompt:"模板",slashSkill:"技能",slashPlugin:"插件",slashCopied:"已复制上一条助手回复",slashCopyFailed:"复制失败,请手动复制",slashCopyEmpty:"还没有可复制的助手回复",mermaidRendering:"正在渲染图表…",mermaidRenderFailed:"图表渲染失败,已显示原始代码",recentProjects:"最近项目",workspaceFiles:"文件",showHiddenFiles:"显示隐藏项",taskProgress:"任务进度",taskProgressHeading:"进度",taskOutputsHeading:"输出",taskProgressEmpty:"较长任务的进度会显示在此处。",taskOutputsEmpty:"查看并打开在此任务期间创建或修改的文件。",taskPaused:"已暂停 · 等待继续",taskFailed:"任务失败",taskCompletedCount:"已完成 {n}",taskRunningCount:"进行中 {n}",taskSteps:"步",taskCompletedHidden:"已完成 {n} 步 · 展开",taskJumpToChat:"在对话中定位",builtinTaskList:"任务清单",componentUpdates:"更新",componentNewVersion:"有新版本",componentCurrent:"已是最新稳定版",componentPinned:"版本已固定,请手动调整安装来源",componentManual:"请按安装来源手动维护",componentUnknown:"无法确定已安装版本",componentCheckFailed:"检查失败,可重试",componentApp:"pi-harness 应用",componentDesktopUnsupported:"开发运行不支持自动安装,请使用已安装的桌面版。",componentAppHint:"检查并下载新版本,完成后可重启安装。",componentWebUpdateHint:"在终端更新全局 npm 包;完成后运行 pi-harness server restart 重启服务。",componentDownloading:"正在下载:{n}%",componentRestartInstall:"重启并安装",componentAutoUpdate:"自动更新",componentLocal:"本地文件扩展,请修改源文件后重新加载。",componentChecking:"正在检查…",componentCheck:"检查更新",componentUpdateIntro:"查看运行中的 pi Agent 与扩展安装版本。检查不会自动安装;用户扩展更新后需重启应用。",componentOffline:"连接恢复后可检查更新。",componentInstalling:"正在更新扩展,请等待完成…",componentRestart:"更新已安装,请重启应用以加载新版本。",componentBundled:"内置",componentBundledHint:"随应用版本升级,上游新版本不一定已被当前应用采用。",componentProject:"当前项目",componentUser:"用户安装",componentInstalled:"已安装",componentInstall:"更新扩展",taskTodoUpdate:"任务清单更新",planUnassignedRecords:"本轮执行记录 · 未归入计划",planEnabled:"原生计划工具(服务全局)",planEnabledHint:"默认开启,保留已保存的选择;所有客户端共用。运行中的会话在任务结束后应用。",planPending:"等待会话空闲或恢复可写后应用",planConflict:"当前会话存在第三方同名工具,开关不会修改它。",planMissing:"当前会话未加载原生计划扩展",planReplaced:"计划 {id}(版本 {revision})已被新计划替换并取消",planStatusChanged:"计划状态:{status}",planRecorded:"计划已记录",planActive:"未结束",planPrevious:"此前未完成计划 · 等待确认",todoCounts:"{total} 项 · 已完成 {completed}",todoCreated:"已建立",todoPending:"待执行",todoRemoved:"已移除",todoView:"查看",todoChanges:"清单更新:{changes}",todoChangeSeparator:";",todoCleared:"任务清单已清空",todoItemAdded:"新增第 {n} 项",todoItemUpdated:"第 {n} 项已修改",todoItemPending:"第 {n} 项待执行",todoItemStarted:"第 {n} 项开始",todoItemCompleted:"第 {n} 项完成",todoItemDeleted:"第 {n} 项已移除",taskWaitingContinue:"等待继续",taskPlanSource:"任务清单",taskPlanSourceHint:"按 agent 创建的清单跟踪步骤",taskObservedSource:"执行记录 · 未创建计划",taskObservedSourceHint:"由实际工具调用归纳,不代表 agent 已创建任务清单",taskBlockedBy:"等待步骤 {steps} 完成",taskCancelled:"已停止",taskLongTool:"命令运行中",taskStepSilent:"暂时没有新数据,查看输入框上方的操作",taskPhases:"个阶段",taskDuration:"用时",taskResult:"结果",taskCommit:"提交",taskTests:"测试",taskChanges:"改动",taskPassed:"通过",taskFiles:"个文件",taskViewChanges:"查看改动",taskFinalReply:"定位到最终回复",taskProcess:"过程",taskOnlyResult:"只看结果",taskShowProcess:"展开过程",taskRawSteps:"原始 {n} 段",taskShowRaw:"查看原始 {n} 段",taskHideRaw:"收起原始段落",taskCopyMarkdown:"复制为 Markdown",taskArtifactRead:"读取",taskArtifactWrite:"写入",taskArtifactEdit:"修改",taskArtifactRun:"运行",taskLines:"行",taskExplicitPlan:"pi 计划",taskPlanSteps:"步",taskPlanPosition:"第 {current} / {total} 步",taskPlanChanged:"计划已调整",taskPlanAdded:"新增",taskPlanCard:"计划",taskUnderSecond:"<1 秒",taskReadCount:"读取 {n}",taskWriteCount:"写入 {n}",taskEditCount:"修改 {n}",taskCommandCount:"{n} 条命令",changeEdit:"编辑",changeWrite:"写入",changeOpen:"打开",changeRawArgs:"原始参数",changeRawOutput:"原始输出",changeAtLine:"第 {n} 行",changeWrittenLines:"写入 {n} 行",changeOriginal:"想替换的原文",changeAttemptedWrite:"尝试写入的内容",changeFailed:"修改失败",changeNoOriginal:"没有可显示的原文",changeNoDiff:"没有可显示的差异",changeReplacement:"替换内容(未返回文件差异)",changeRetried:"已重试",modelSilent:"{duration} 未收到模型响应",modelSilentShort:"模型未响应",toolSilentShort:"工具运行中 · 暂无新输出",placeholderModelSilent:"模型暂时没有响应,可停止、重试或继续等待…",placeholderToolSilent:"命令或工具仍在运行,输入的消息会排队…",toolSilent:"命令或工具已运行 {duration},暂时没有新输出",retrySilentUnavailable:"本轮已执行工具或包含附件,为避免重复执行,请停止后检查并手动重试",continueWaiting:"继续等待",actions:"操作",retry:"重试",writeVerb:"写入",expandRemainingLines:"展开其余 {n} 行",lines:"行",fileUsed:"涉及",thinkingDepthTip:"思考深度:越深越慢、越耗 token",readFiles:"读取 {n} 个文件",readVerb:"读取",modelReadOnly:"文件内容 · 仅供模型读取",readRaw:"原文",skillLabel:"技能",bashSteps:"步骤",bashRaw:"原始",bashRunning:"运行中",bashPartial:"部分失败 · {ok}/{total} 步成功",bashFailed:"失败",bashErrorCount:"{n} 个错误",bashExpandCommand:"展开完整命令 · {n} 步",bashExpandFullCommand:"展开完整命令",bashLikelyErrorLines:"疑似错误 {n} 行",bashHiddenLines:"省略 {n} 行",bashNoMatch:"无匹配",bashSkipped:"未执行",bashShowRaw:"查看原始输出",grepSearch:"搜索",grepInPath:"在 {path}",grepMatches:"{n} 处匹配",allDone:"全部完成",expandAllLines:"展开全部 · {n} 行",timeGapAt:"时间间隔,{time}",notGitRepoShort:"非 Git 仓库",toolWrap:"换行",copied:"已复制",toolLineCount:"{n} 行",toolRelativeTo:"相对于 {path}",toolMoreLines:"展开其余 {n} 行",workspaceBranch:"分支",workspacePath:"路径",workspaceProjects:"项目",composerPlaceholder:"给 pi 发送消息…",thinkingStandard:"标准",thinkingDeep:"深度",thinkingMinimalDescription:"几乎不思考,最快",thinkingStandardDescription:"速度和质量平衡",thinkingDeepDescription:"充分思考,适合复杂任务",workspaceModified:"有未提交改动",workspaceChanges:"{n} 项最近改动",runningConversations:"运行的对话",historySessions:"历史对话",openHistory:"历史对话",openFiles:"文件列表",streaming:"进行中…",noHistory:"还没有历史对话",current:"当前",messageCount:"{n} 条消息",tuiTip:"pi 终端(TUI)中的对话",deleteProject:"从最近项目移出",deleteProjectConfirm:"确认移出",deleteSession:"删除该对话记录(不可恢复)",deleteSessionConfirm:"确认删除",confirm:"确认",expandCode:"展开完整内容",collapseCode:"收起",zoomCode:"放大查看",closeZoom:"关闭",renameSession:"重命名该对话",renameSessionPlaceholder:"对话名称(留空则显示首条提问)",openFolder:"打开文件夹…",openFolderPlaceholder:"或直接粘贴绝对路径",openThisFolder:"打开当前文件夹",openTypedPath:"打开输入的路径",parentFolder:"上一级",home:"主目录",noSubfolders:"这里没有子文件夹",listTruncated:"目录过多,列表已截断",emptyChat:"空对话",editReask:"编辑重问",editReaskTip:"修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)",reaskFromHere:"从此处重新提问",editPlaceholder:"修改问题内容…",editHint:"⌘/Ctrl+Enter 提交 · Esc 取消",editAttachmentHint:"原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消",expandMsg:"展开",collapseMsg:"收起",toolCalls:"工具调用",bashRuns:"终端运行",images:"图片",update:"更新",updateTip:"检查并更新 pi-harness",currentVersion:"当前版本",latestVersion:"最新版本",checkingUpdate:"检查中…",checkUpdate:"检查更新",upToDate:"已是最新版本",updateAvailable:"发现新版本 v{version}",updateJustPublished:"v{version} 刚刚发布,npm 缓存可能尚未同步——若未检测到新版本,请稍后重新检查",updateNow:"在终端中更新",updateTabTitle:"更新 pi-harness",updateTerminalHint:"点击后会在可见终端中运行 npm i -g @youweichen/pi-harness@latest;完成后重启服务生效(pi-harness server restart)。",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",richSourceBlock:"此段保留原文,可切换源码编辑",richFormatting:"文档格式",richEditMarkdown:"编辑 Markdown 文档",reloadRunning:"正在重新加载…",reloadDone:"已重新加载",reloadPartial:"已重新加载,{count} 项加载出错",reloadCounts:"扩展 {extensions} · 技能 {skills} · 提示模板 {prompts}",reloadDetails:"查看错误详情",reloadGeneralError:"重新加载",reloadExtensionList:"扩展:{names}",reloadSkillList:"技能:{names}",reloadPromptList:"提示模板:{names}",richFormatToolbar:"文档格式",richBold:"粗体",richItalic:"斜体",richHeading:"标题",richParagraph:"正文",richList:"列表",richOrderedList:"编号",richQuote:"引用",richUndo:"撤销",richRedo:"重做",richTable:"插入表格",dbViewer:"数据库预览",dbReadOnly:"只读",dbRefresh:"刷新",dbTable:"表 / 视图",dbView:"视图",dbRows:"表数据",dbNoTables:"数据库中没有可查看的表。",dbNoRows:"这张表暂无数据。",dbPrevious:"上一页",dbNext:"下一页",dbRowRange:"第 {start}–{end} 行",dbSchema:"查看表结构",dbCellLimit:"每页最多 50 行;长文本显示前 256 个字符,BLOB 显示字节数。",dbStructureLimited:"仅展示前 500 张表及每表前 64 个字段。",dbLoadFailed:"无法读取 SQLite 数据库:",dbUnavailable:"连接或工作区暂不可用。",richColumn:"列",richTableTools:"表格操作",richAddRow:"下方加行",richAddColumn:"右侧加列",richRemoveRow:"删除当前行",richRemoveColumn:"删除当前列",fileMoreActions:"更多文件操作",richCodeBlock:"代码块",richHighlightBlock:"高亮块",richTextHighlight:"背景标记",richHighlight_yellow:"黄色背景",richHighlight_green:"绿色背景",richHighlight_blue:"蓝色背景",richHighlight_pink:"粉色背景",richHighlight_purple:"紫色背景",richHighlightClear:"清除背景标记",richCodeLanguage:"代码语言",richPlainText:"纯文本",richImageUploading:"正在插入图片…",richImageFailed:"图片插入失败,请确认连接和文件状态后重新粘贴。",richImageTooLarge:"图片不能超过 5 MB。",richDivider:"分隔线",richTaskList:"任务列表",richInsertMenu:"插入元素",richTextGroup:"文字格式",richBlocksGroup:"基础元素",richNoElements:"没有匹配的元素",backToFiles:"返回文件列表",fileUnsaved:"未保存",fileSaving:"保存中",fileSaved:"已保存",fileViewMode:"文件视图",fileViewPreview:"预览",fileViewSource:"源码",fileViewChanges:"查看改动",fileChangesCount:"改动 {n}",fileEditMode:"编辑模式",fileReadOnly:"只读",fileEditShort:"编辑",fileReference:"引用",fileExternalChanged:"pi 修改了此文件",fileCompare:"对比",fileNoChanges:"没有可显示的改动",fileLocalDraft:"未保存草稿",fileDiskVersion:"磁盘最新版本",quoteSelection:"引用选中内容 @{name}:{start}-{end}",fileSaveFailed:"保存失败",fileOffline:"连接中断或请求超时,草稿已保留。请重试。",fileReload:"重新加载",fileOverwrite:"覆盖磁盘文件",fileOverwriteConfirm:"磁盘文件已改变,确定用当前草稿覆盖?",fileLeavePrompt:"当前文件有未保存的修改。",fileSaveContinue:"保存后继续",fileDiscard:"放弃修改",previewFile:"预览",downloadFile:"下载文件",downloadFailed:"下载失败:{error}",protocolMismatch:"页面版本与服务器不一致(应用刚更新过),请刷新页面以恢复全部功能。",selectLinesHint:"点击选择行;拖拽或 Shift+点击选择范围",enableWrap:"开启自动换行",disableWrap:"关闭自动换行",selectedRange:"已选 {n} 行(第 {start}-{end} 行)",fileLines:"{n} 行",selectAll:"全选",clearSelection:"清除",addToChat:"添加到对话",addedToChat:"已添加",previewTruncated:"⚠ 文件过大,仅预览前 512KB",previewLinesTruncated:"… 文件行数过多,仅显示前 {n} 行",binaryFile:"🔣 二进制文件,已显示前 4KB 十六进制",binaryHexTruncated:"(文件更大,可下载完整文件)",previewNotSupported:"该类型文件不支持预览(仅图片 / 视频 / 文本)",emptyFile:"(空文件)",editFile:"编辑文件",exitEditFile:"退出编辑",saveFile:"保存文件",discardFileChanges:"放弃未保存的修改?",fileEditTruncated:"文件过大,预览不完整,无法编辑",showMarkdownSource:"显示 Markdown 原文",showMarkdownPreview:"显示 Markdown 预览",fullscreen:"全屏",exitFullscreen:"退出全屏",zoomIn:"放大字号",zoomOut:"缩小字号",resetZoom:"重置缩放",pluginRequest:"插件请求",noOptions:"(无选项)",inputPlaceholder:"输入内容",soundHeader:"声音提示",enableSound:"启用声音",preview:"试听",volume:"音量","sound.question":"问卷弹出","sound.question.desc":"ask_user_question 出现时","sound.done":"回复结束","sound.done.desc":"智能体完成一轮回答时","sound.start":"回复开始","sound.start.desc":"智能体开始新一轮时","sound.error":"出错","sound.error.desc":"出现错误提示时",setupTitle:"未检测到 pi agent 配置",setupDesc:"pi-harness 需要 pi 的配置目录(~/.pi/agent)和至少一个 API 密钥才能运行智能体。pi 内置了 openai、anthropic、deepseek 等服务商——选一个填密钥即可,全程无需打开终端。",installFailed:"✖ pi agent 安装失败:",retryInstall:"重试安装",skip:"跳过",installDone:"✅ pi agent CLI 已安装。选择服务商并填入 API 密钥即可开始对话:",cliReadyHint:"✅ 本地已检测到 pi agent,选择服务商并填入 API 密钥即可开始对话:",provider:"服务商",configured:"已配置",providerKeyReady:"该服务商已配置密钥,可直接使用或更换新密钥。",apiKey:"API 密钥",saving:"保存中…",saveAndStart:"保存并开始使用",recheck:"重新检测",installing:"正在安装 pi agent CLI…",autoInstall:"自动安装 pi agent",attachment:"附件",plugin:"插件",unknown:"未知",thinkingWait:"正在思考",exitCode:"退出码 {code}",cancelled:"已取消",truncated:"… 内容过长,当前视图已截断",outputTruncated:"… 输出过长,当前视图已截断",refOnlyShort:"仅引用",folderRefShort:"文件夹 · 仅引用",inlineLines:"内联 · {n} 行",inlineLinesRange:"行 {start}-{end}",image:"🖼 图片",bridgedVision:"👁 已转写",bridgedVisionDetail:"图片已由视觉桥转写(当前模型不支持识图)",folderNotExpanded:"文件夹,未展开内容 —— 智能体会按需浏览目录",fileNotExpanded:"文件较大({size}),未展开内容 —— 智能体会按需读取","role.user":"你","role.assistant":"pi","role.tool":"工具","role.bash":"终端","role.branch":"分支摘要","role.compaction":"上下文已压缩",welcomeTitle:"pi 编码智能体",welcomeSub:"检查、编辑、运行 —— 随时待命",directory:"目录",clickToFill:"点击填入输入框",sending:"发送中",backToBottom:"回到底部",questionNavTitle:"问题列表",questionMarkerGroup:"附近 {n} 条消息",searchPlaceholder:"在对话中搜索…",searchNoResults:"无结果",searchModels:"搜索模型…",noModelMatches:"无匹配模型",searchGlobal:"搜索",searchGlobalTip:"全局搜索:对话 / 项目 / 文件(Ctrl+K)",gsPlaceholder:"搜索项目、历史对话、工作区文件…",gsHint:"输入关键词:同时搜索历史对话、最近项目与当前项目的文件名",gsSessions:"对话",gsProjects:"项目",gsFiles:"文件",gsNoResults:"无匹配结果",gsSearching:"正在搜索文件…",gsTruncated:"匹配过多,仅显示部分结果",gsCurrentProject:"当前",gsOpenPreview:"打开文件预览",gsNavigate:"选择",gsOpen:"打开",gsCloseHint:"关闭",bgTaskCommand:"命令行",searchPrev:"上一个(Shift+Enter)",searchNext:"下一个(Enter)",searchClose:"关闭(Esc)",questionNavTip:"本对话的全部问题,悬浮展开,点击跳转","ex.understand":"了解这个项目","ex.understand.prompt":"介绍一下这个项目:整体结构、主要模块和如何运行?","ex.debug":"排查一个问题","ex.debug.prompt":"帮我排查一个 bug,请先说明问题现象,我会补充细节。","ex.test":"编写测试","ex.test.prompt":"为项目的核心模块编写单元测试。","ex.review":"代码审查","ex.review.prompt":"审查最近改动的代码,指出潜在问题和改进建议。",error:"出错",done:"完成",running:"执行中…",toolQueued:"排队中",copyArgs:"复制参数",errorOutput:"错误输出",nestedToolCalls:"内部工具调用 · {n}",nestedToolCallsIncomplete:"部分调用记录或参数未完整保存。",recoveryCompacting:"正在压缩",recallQueue:"撤回全部待发消息",recallQueueShort:"撤回全部待发",treeVerifying:"正在校验会话文件…",compactionCompleted:"压缩完成",compactionAborted:"压缩已取消",compactionFailed:"压缩失败",compactionManual:"手动压缩",compactionThreshold:"上下文接近上限",compactionOverflow:"上下文超限",recoveryWaiting:"等待原生重试",recoveryRunning:"正在原生重试",recoverySummaryWaiting:"等待摘要重试",recoverySummaryRunning:"正在重试摘要",conversationRunSettings:"当前对话运行设置",conversationAutoCompaction:"自动压缩",conversationAutoRetry:"SDK 自动重试",commandAttachmentsRetained:"命令已执行,附件未发送,已保留在输入框。",toolOutputAuth:"下载认证失败,请重新连接。",toolOutputDenied:"无权访问此输出。",toolOutputError:"下载失败,请稍后重试。",toolOutputText:"完整文本",toolOutputDownload:"下载完整输出",toolOutputUnavailable:"完整输出不可用,文件可能已清理",toolResultImage:"工具返回的图片",output:"输出",waitingOutput:"等待输出…",toolDoneWaitingModel:"完成",waitUnderstanding:"Understanding your question",waitResults:"Reading command results",waitFile:"Reading files",waitThinking:"Thinking",waitTests:"Waiting for test results",waitBuild:"Waiting for build results",waitSteer:"Processing your direction",waitSeconds:"{n} sec",waitMinutes:"{m} min {s} sec",waitStop:"Stop",thinkingNow:"思考中",thinkingPreview:"思考:{preview}",leakedThinking:"模型附加内容",toolUnexecutedTitle:"工具调用未执行",toolUnexecutedAttempts:"自动提醒 {n} 次后停止",toolUnexecutedHint:"{model} 把工具指令写成了正文,自动提醒后仍没有调用工具,任务停在这里。前面的结果都已保留。",toolUnexecutedInline:"工具指令写成了正文,没有执行",toolAutoReminded:"已自动提醒",toolReminderEvent:"已自动提醒 pi 用工具调用重新发起",toolRecoverySwitch:"换个模型",toolRecoveryRaw:"查看原始输出",toolRecoveryRawHide:"收起原始输出",toolRecoveryFirst:"第 1 次",toolRecoveryAfterReminder:"自动提醒后",toolRecoveryNoCall:"没有工具调用",taskInterruptedHint:"工具调用未执行。在对话里点「重新发送」继续。",taskInterruptedTitle:"已中断",unexecutedToolHint:"{model} 将工具指令作为正文返回,未形成原生工具调用。前面的结果已保留。",unexecutedToolOriginal:"查看原始输出",toolStoppedTitle:"模型没有执行工具就结束了",toolStoppedHint:"已自动提醒 {model} 用工具调用继续,但它仍未调用任何工具,任务停在这里。可以重新发送,或换个模型继续。",toolRecoveryResend:"重新发送",toolRecoveryFailed:"未能确认重发请求,请检查连接与当前模型后重试。",toolRecoveryInterrupted:"中断",leakedThinkingHint:"正文中检测到思考标记,相关内容已折叠;不代表应用报错或数据泄露。点击查看原文。",commands:"命令",newCommand:"新建命令",newTerminal:"新建终端",name:"名称",command:"命令",cwdHint:"(${pwd} = 当前工作目录)",noCommands:"还没有命令,点 + 添加一个",clickToRun:"点击运行",edit:"编辑",delete:"删除",confirmQ:"确认?",builtinTerminal:"内置终端",termEmptySub:"点击左侧命令运行,或点右侧 + 新建终端",noTerminal:"暂无终端",exited:"(已退出{code})",closeTerminal:"关闭终端",rerun:"重新读取 .pi/commands.json",terminalTitle:"终端 {n}",exampleName:"例如:启动开发服务器",exampleCommand:"例如:npm run dev",scmTab:"Git",scmTitle:"源代码管理",scmRefreshTip:"重新查询 Git 状态与差异",scmCurrentBranch:"当前分支",scmUpstreamGone:"上游已删除",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"分离 HEAD",scmSelectBranch:"选择分支…",scmRemoteBranches:"远程分支",scmStageTip:"暂存 {path}",scmUnstageTip:"取消暂存 {path}",scmSwitch:"切换",scmSwitchBranch:"切换分支",scmSwitchBranchTip:"在终端中执行 git checkout {branch}",scmPush:"推送",scmPushTip:"在终端中执行 git push",scmPull:"拉取",scmPullTip:"在终端中执行 git pull",scmCommit:"提交",scmCommitTip:'在终端中执行 git add -A && git commit -m "…"(提交全部更改,含未跟踪)',scmCommitPlaceholder:"输入提交信息…",scmChanges:"更改",scmHistory:"提交树",scmCommitDetail:"提交详情",scmSelectCommitHint:"点击左侧提交查看详情",scmNoHistory:"暂无提交记录",scmNoChanges:"工作区干净,没有更改",scmNotGitRepo:"当前目录不是 Git 仓库",scmLoading:"查询中…",scmConnecting:"等待连接…",scmDiff:"差异",scmSelectFileHint:"点击左侧文件查看差异",scmNoDiff:"(无差异)",scmStaged:"已暂存",scmUnstaged:"未暂存",scmStagedUnstaged:"已暂存 + 未暂存",scmUntracked:"未跟踪",scmUntrackedBadge:"u",scmUntrackedBinary:"二进制文件无法在此预览",scmUntrackedDirectory:"目录无法在此预览,请选择其中的文件",scmEmptyFile:"空文件",scmPreviewTruncated:"仅显示前 512 KB",scmQueryFailed:"Git 查询失败:{error}",scmTooManyFailures:"Git 查询连续失败,请点击刷新重试",scmRunsInTerminal:"提交 / 切换分支 / 推送 / 拉取在终端中执行",scmViewTerminal:"去终端",editProvider:"编辑服务商",builtinProviders:"内置服务商",hintKeyOnly:"配置 API 密钥或登录支持的账号",configuredBadge:"✓ 已配置",keyReady:"密钥已就绪",replaceKey:"更换密钥",replaceKeyTitle:"替换已保存的密钥",clearKey:"清空",clearKeyTitle:"清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)",clearKeyConfirm:"清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。",cloneProvider:"复制为自定义",cloning:"复制中",cloneProviderTitle:"复制该内置供应商(baseUrl + 模型列表)为自定义供应商,填入另一个 API 密钥即可双 key 并存",pasteKey:"粘贴 API 密钥…",savingKey:"保存中",saveKey:"保存密钥",customProviders:"自定义服务商",customDesc:"用于 Ollama / vLLM / 兼容 OpenAI 的代理等,写入 pi 的 models.json,保存后热重载、立即生效。",noCustomProviders:"还没有自定义服务商",modelsCount:"{n} 个模型",addProvider:"新增服务商",providerId:"服务商 ID",providerIdHint:"(必填,如 ollama / my-proxy)",displayName:"显示名",displayNamePh:"我的代理",apiType:"API 类型",baseUrlHint:"(OpenAI 兼容端点)",apiKeyHint:"sk-…(留空保留已有密钥)",authHeader:"自动添加 Authorization 请求头",modelsTitle:"模型",modelIdReq:"模型 ID(必填)",text:"文本",textImage:"文本+图片",contextWindow:"上下文",maxOutput:"最大输出",removeModel:"移除模型",addModel:"添加模型",deleteProviderConfirm:"删除服务商 {id} 及其 {n} 个模型?",fetchModels:"自动获取模型列表",fetchModelsHint:"从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)",fetchingModels:"获取中…",fetchModelsOk:"已获取 {n} 个模型",fetchModelsEmpty:"接口未返回任何模型",fetchModelsErr:"获取失败:{msg}",fetchModelsNeedBaseUrl:"请先填写 baseUrl 再获取",goalBarTitle:"目标",goalWizardCard:"目标调研",settings:"设置",nativeContextOnly:"使用 pi 原生上下文,WebUI 不追加提示词或注册自定义代理工具。",nativeResourcesManaged:"技能和扩展由 pi 原生配置管理,这里仅展示已加载的资源。",settingsTitle:"设置",allSettings:"所有设置",quickActions:"快捷操作",settingsAppearance:"外观",settingsCodeTheme:"代码文件配色",codeThemeLight:"浅色",codeThemeDark:"深色",codeThemeSystem:"跟随系统",settingsDesc:"修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。",settingsSystemPrompt:"系统提示词",promptModeAppend:"追加",promptModeReplace:"替换",promptAppendHint:"追加模式:自定义内容拼接到默认系统提示词末尾(推荐,保留默认行为约束)。",promptReplaceHint:"替换模式:完全用自定义内容替换系统提示词(项目上下文与技能段仍会自动附加)。切换后输入框会显示原本的默认提示词,可直接修改;不改动失焦则仍使用默认。",promptPlaceholder:"输入自定义系统提示词…(失焦后自动应用)",settingsViewPrompt:"查看当前完整提示词",settingsViewPromptHint:"当前会话实际生效的完整系统提示词(含自定义追加/替换内容、项目上下文、技能说明与工具引导),只读。",settingsViewPromptEmpty:"会话尚未就绪,暂无系统提示词。",settingsSkills:"技能",settingsReview:"目标审查",settingsReviewDesc:"为独立的目标审查会话配置额外提示词和技能;不会改变主会话设置。",settingsReviewSkills:"审查可用技能",reviewPromptPlaceholder:"输入审查自定义提示词…(失焦后自动应用)",reviewPromptHint:"这些内容会追加到审查任务中;审查仍会强制要求输出 pass/fail JSON。技能开关仅对审查生效。",settingsVisionBridge:"视觉桥",settingsVisionBridgeDesc:"当前模型不支持识图时,把图片交给已配置的视觉模型转写为文字证据,再让模型回答",settingsTerminalTools:"终端工具",settingsTerminalToolsDesc:"让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具",settingsMessageDisplay:"消息显示",thinkingWrap:"完整显示思考",thinkingWrapDesc:"开启:思考内容始终完整展开并自动换行(流式推理过程也实时可见);关闭:折叠成一行摘要,流式中一行实时显示最新文本",toolsWrap:"完整显示工具",toolsWrapDesc:"开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开",uninstallExt:"卸载",uninstallConfirm:"确认卸载?",uninstallConfirmHint:"再次点击确认,将在终端执行 pi remove",uninstallHint:"通过可见终端执行 pi remove 卸载此包,完成后自动刷新列表",uninstallTitle:"卸载",pluginUpdate:"更新",pluginUpdateHint:"从安装来源重新拉取并覆盖安装(保留 config.json 配置),完成后自动重载插件列表",pluginUninstallHint:"在可见终端执行 pi-harness uninstall 卸载此插件(再次点击确认),完成后自动刷新列表",settingsExtensions:"Extensions",settingsUiPlugins:"界面插件",noUiPlugins:"未安装界面组件(<dataDir>/plugins/)",uiPluginNoSource:"手工安装,无来源信息,无法在线更新",uiPluginPerms:"能力声明",pluginSettingsSave:"保存插件设置",pluginSettingsSaving:"保存中…",pluginSettingsReset:"恢复默认",settingsEnabled:"已启用",settingsDisabled:"已禁用",saveAsPreset:"保存为预设",applyPreset:"应用",deletePreset:"删除预设",noSkills:"暂无技能",noExtensions:"暂无插件",noPresets:"暂无预设(先调整上面的设置,再保存为预设组合)",loadingSession:"正在加载会话…",connectingServer:"正在连接 pi-harness 服务器…"},ld={changesTitle:"Changes",changesRegenerate:"Regenerate",changesTurn:"This turn",changesBranch:"Branch",changesWork:"Uncommitted",changesSummary:"Changed {n} files",changesViewAll:"View all",changesMore:"{n} more files",changesFiles:"{n} files",changesList:"File list",changesBase:"Base branch",changesSearch:"Search changes",changesExpand:"Expand or collapse all",changesEmpty:"No changes in this scope",changesBinary:"Binary file; diff unavailable",changesUnavailable:"No text diff available",changesUnlocated:"Line numbers unavailable",changesLarge:"Large file · click to expand",changesUnchanged:"⇕ {n} unchanged lines",changesTrailing:"Show remaining {n} lines",changesRecent:"Just changed",changesTruncated:"Diff truncated",changesLoading:"Loading changes…",changesReducedContext:"Large diff: showing only the lines around each change.",changesOmittedUntracked:"{n} more untracked files are not shown; consider adding them to .gitignore.",changesCommands:"{n} commands",bashDurationUnknown:"Time unavailable",bashGroupCount:"Ran {n} commands",bashGroupRunning:"Running {n} commands",bashGroupFailed:"· {n} failed",bashGroupCwd:"In {path}",bashGroupEarlier:"{n} earlier commands · Show all",bashExtraLines:"+{n} lines",bashExitCode:"Exit code {n}",bashUnfinished:"Unfinished",bashRemainingLines:"Show remaining {n} lines",bashCopyCommand:"Copy command",bashCopyOutput:"Copy output",bashOpenTerminal:"Open in terminal",bashOpenTerminalHint:"Run the full command again in a visible terminal",bashCommandCount:"{n} commands",editBusy:"Wait for the current response, compaction or branch switch before editing.",editFailed:"Editing was cancelled or failed.",treeTitle:"Session tree",treeFork:"Fork session",treeForkAt:"Fork from here",treeFilter:"Filter nodes",treeSearch:"Search session tree",treeExternal:"This session changed externally. Reopen it before making changes.",treeReopen:"Reopen",treeTruncated:"More than 5,000 nodes. Narrow the filter or search.",treeEmpty:"No matching nodes",treeFold:"Collapse or expand branch",treeNavigate:"Switch here",treeLabel:"Set label",treeNodes:"nodes",treeClone:"Clone branch",treePreviewCount:"Summarize {n} entries",treeSummary_none:"Without summary",treeSummary_default:"Generate summary",treeSummary_custom:"Summarize with instructions",treeInstructions:"Summary instructions",treeStopConfirm:"Stop this response and switch; restore queued messages",treeLabelClear:"Leave blank to clear the label",treeContent:"Entry content",treeDisconnected:"Disconnected. Reconnect and retry.",treeBusy:"Wait for the current response, compaction or navigation",treeCancelled:"An extension cancelled navigation",treeAborted:"Branch summary cancelled; original position retained",treeFailed:"Session tree operation failed",treeDraftConflict:"Navigation returned text and the editor already contains a draft. Choose how to keep it.",treeReturnedText:"View returned text",treeReplaceDraft:"Replace draft",treeAppendDraft:"Append to draft",treeKeepDraft:"Keep current draft",treeEditOptions:"Resend options",treePrevious:"Previous branch",treeNext:"Next branch",treeSummarizing:"Summarizing the branch being left",treeEditNewSession:"Create a new session when editing and resending",treeBranches:"{n} branch points",treeDerived:"Forked from {name}",treeFilter_default:"Default","treeFilter_no-tools":"No tools","treeFilter_user-only":"Users only","treeFilter_labeled-only":"Labeled only",treeFilter_all:"All (CLI rules)",treeKind_user:"User",treeKind_assistant:"Assistant",treeKind_tool:"Tool",treeKind_compaction:"Compaction",treeKind_branchSummary:"Branch summary",treeKind_custom:"Custom",treeKind_model:"Model",treeKind_thinking:"Thinking",treeKind_info:"Session info",treeKind_contextEdit:"Context edit",treeKind_label:"Label change",wikiSaving:"Saving",wikiSaved:"Saved",wikiSaveFailedRetry:"Save failed · Retry",wikiExternalChanged:"File changed outside the editor",wikiKeepMine:"Keep my version",wikiMessageActions:"Message actions",wikiFullRequest:"View full sent message",wikiResend:"Resend",wikiReplyChanged:"Modified {file}",wikiViewChange:"View",richImage:"Image",richWikiLink:"Document link",wikiLinkAddress:"Enter a URL, or [[ to find a document",wikiInsertLinkAction:"Insert link",wikiInvalidLink:"Enter an http, https, mailto or relative URL",wikiInsertParagraph:"Plain text paragraph",wikiInsertH1:"Top-level heading",wikiInsertH2:"Section heading",wikiInsertH3:"Subsection heading",wikiInsertList:"Bulleted list",wikiInsertOrdered:"Numbered list",wikiInsertTask:"Checkable tasks",wikiInsertQuote:"Quote a passage",wikiInsertCode:"Code with syntax highlighting",wikiInsertCallout:"Highlight a note",wikiInsertTable:"Insert a 3 × 3 table",wikiInsertDivider:"Separate sections",wikiInsertImage:"Upload or paste an image",wikiInsertLink:"Find and link a document",wikiNoInsertResults:"No matches · Esc to close",wikiInsertKeys:"↑ ↓ Select ↵ Insert Esc Close",v2PromptHint:"Sent to the model at the start of each conversation",v2IdentityHint:"Tells the model it is Pi and how to work",v2ToolsHint:"Available capabilities, based on enabled tools and extensions",v2RulesHint:"Tool usage instructions, deduplicated by Pi",v2DocsHint:"Read only when you ask about Pi itself",v2AppendHint:"Extra instructions after the defaults, such as response language",v2ContextHint:"Context from this directory and its parents, loaded automatically",v2CreateAgents:"Create AGENTS.md",v2PiHint:"Built-in agent engine, updated with Desktop",v2ExtensionsIntro:"Extensions add tools and commands to Pi. Packages can also include skills, prompts, and themes.",v2ExtensionCount:"{n} installed",v2LastChecked:"Last checked {time}",v2PackagesHint:"Updates available through the package manager",v2NoPackages:"No managed packages yet. Browse pi.dev to find tools and skills.",v2FilesHint:"Reload after editing a file",v2UpdatePolicy:"Update policy",v2AutoCheckHint:"Check packages on opening management, then every 6 hours while the service runs",v2InstallPolicy:"Install package updates",v2InstallHint:"Update when you choose, then reload or start a new conversation",v2ManualInstall:"Manual",v2SkillsIntro:"Skills are instructions read on demand. Only enabled names and descriptions enter the prompt; full instructions are read when needed. Disabled skills are excluded.",v2SkillCount:"{n} skills · {enabled} enabled · about {tokens} tokens",v2SkillSearch:"Search skill names or descriptions",v2SkillPackage:"Package",v2SkillAll:"All",v2SkillsPaths:"Skill directories",v2CopyPaths:"Copy directory paths",v2OpenSkills:"Open skills directory",v2SkillsChanged:"Native skill settings saved. Reload or start a new conversation to apply.",v2ServersHint:"Connect external services to make more tools available",v2ScopeHint:"Global applies to all projects; project applies to this workspace",v2CodemodeHint:"Let the model batch tool calls in short scripts to reduce round trips and context use",v2ModeHint:"on: allow direct calls; only: call tools through scripts",v2BudgetHint:"Budget for inline tool declarations; 0 means discover all on demand",v2AutoHint:"Automatically enable Codemode when MCP servers are configured",v2EditMcp:"Edit mcp.json",v2NoServersHint:"No servers configured. Import an existing configuration or add a connection.",promptSavedShadowed:"Saved. This session still uses a higher-priority file of the same name.",promptDiscard:"Discard unsaved changes?",promptRestoreConfirm:"Delete {path}? Pi will use the next SYSTEM.md in native priority order, or its default prompt if none remains.",promptCopyFailed:"Copy failed. Copy manually from the raw text.",promptReplaceWarning:"SYSTEM.md replaces the default identity, tool descriptions, rules and Pi documentation. Pi still manages appended instructions, project context, skills and working directory. Use appended instructions for additions.",promptContinueReplace:"Continue with replacement",promptScope:"Save to",promptUser:"User · all projects",promptProject:"Current project",promptUntrusted:"Not trusted",promptContextHint:"Edits the loaded context file. Changes to a parent or user file also affect other projects that use it.",promptEditor:"Prompt file content",promptNativeSave:"Save to native file",promptReloadFile:"Reload file",promptSaving:"Saving…",promptSave:"Save",promptTokenHint:"Approximate count including skills and working directory; actual tokens depend on the model.",promptTokens:"~{n} tokens",promptViewSections:"Sections",promptViewRaw:"Raw text",promptCopied:"Copied",promptCopy:"Copy all",promptSavedPending:"File saved. Reload will run when the session is idle.",promptSavedNext:"Reloaded. Pi will apply the changes on the next request.",promptReloadFailed:"Native reload failed. The file was saved.",promptRetry:"Retry reload",promptForced:"An extension forced the entire prompt for this run. Its sources cannot be reliably separated. Raw text is read-only.",promptOpaque:"The current prompt cannot be matched to native Pi sections. Raw text is read-only.",settingsLoaded:"Loaded",settingsNoSkills:"No skills loaded",settingsNoServers:"No servers",settingsImportSave:"Import and save",settingsRetrySave:"Retry save",settingsToolPresentation:"Tool presentation",settingsDeclarationBudget:"Declaration budget",settingsAutoCodemode:"Enable when connecting MCP",settingsPackages:"Packages",settingsUpdates:"Updates",settingsAutoCheck:"Automatically check for updates",settingsCheckNow:"Check now",settingsBundled:"Updated with app",promptDefault:"Identity",promptReplaced:"Replaced by SYSTEM.md or runtime configuration",promptBuiltinIdentity:"Pi default",promptEdit:"Edit",promptRestore:"Remove replacement",promptReplace:"Replace",promptTools:"Tools",promptInactive:"Descriptions omitted",promptAutomatic:"Automatic",promptRules:"Rules",promptRuleSummary:"{builtin} built-in · {tools} tool · {extensions} extension / runtime",promptCollapse:"Collapse",promptExpand:"Expand",promptBuiltin:"Built-in",promptExtension:"Extension",promptRuntime:"Runtime",promptDocs:"Pi docs",promptDocsSummary:"Read on demand",promptAppend:"Append",promptNotSet:"Not set",promptAdd:"Add",promptContext:"Context",promptNoContext:"No context files loaded",promptRuntimeSection:"Additional native runtime section",promptPriority:"Trusted project .pi files take priority over user files of the same name; one file per type is loaded. Skills and working directory are included in the full text.",promptProjectNotTrusted:"Pi has not trusted this project. Project replacement and append files are read-only.",promptDiskChanged:"Disk content differs from the loaded version",connectionDisconnected:"Disconnected",downloadImage:"Download",extNew:"Just installed",extRetry:"Retry",extEditFile:"Edit file",extEditHint:"Review the code before saving. Changes take effect after reload.",extDiscard:"Discard unsaved changes?",extSaveFile:"Save file",extReleaseNotes:"Release notes",extNoNotes:"No release notes available.",extViewNotes:"View full release notes",extSubtitle:"Manage native Pi packages and standalone extensions",extDetails:"View details",extPersonal:"Personal",extProject:"Project",extUntrusted:"Untrusted · not loaded",extPinned:"Pinned",extUpdate:"Update",extEnable:"Enable",extOpen:"Show in file manager",extCopyPath:"Copy path",extUnpin:"Unpin version",extMoveProject:"Move to this project",extMovePersonal:"Move to personal scope",extRemoveReference:"Remove reference",extUninstall:"Uninstall",extResources:"Included resources",extResourceConfig:"Use pi config for individual resources. Package toggles preserve existing filters.",extInstalled:"Installed",extBrowse:"Browse pi.dev",extRefresh:"Refresh",extRunning:"Package operation in progress…",extDone:"Operation complete",extFailed:"Operation failed",extLog:"View full log",extReloadHint:"Changes apply to new sessions. You can also reload the current session.",extReload:"Reload current session",extLastChecked:"Last checked",extNotChecked:"Updates not checked yet",extChecking:"Checking…",extCheck:"Check updates",extUpdatesAvailable:"package updates available",extUpdateAll:"Update all",extFilter:"Filter installed packages…",extScope:"Install scope",extInstallProject:"This project only",extAllScopes:"All scopes",extEmpty:"No matching packages. Browse the catalog or install from a source.",extSingleFiles:"Standalone extensions · no version checks",extAutoCheck:"Check on opening and every 6 hours",extTypeExtension:"Extensions",extTypeSkill:"Skills",extTypePrompt:"Prompts",extTypeTheme:"Themes",extLicenseUnknown:"License not provided",extCatalogPage:"View on pi.dev",extCatalogOrigin:"From pi.dev · npm packages tagged pi-package · {count} total",extCatalogOriginPage:"From pi.dev · {count} packages on this page",extInstallSource:"Install from npm / git",extUntrustedNotLoaded:"Untrusted, not loaded",extWillLoad:"Resources to load",extProjectUntrusted:"This project is not trusted; project installation is unavailable.",extNoneDeclared:"None",extInstalling:"Installing…",extSearch:"Search pi.dev packages…",extSort:"Sort order",extPopular:"Most downloaded",extRecent:"Recently updated",extAllTypes:"All types",extDownloads:"downloads / month",extInstall:"Install",extNoResults:"No matching packages found.",extPrevious:"Previous",extNext:"Next",extConfirm:"Confirm action",extSource:"Package source",extReview:"Review installation",extResourcesUnknown:"No resource manifest available. Review the source first. Git sources are fetched only after confirmation.",extPinVersion:"Pin this version",extSecurity:"Extensions execute local code, and skills may instruct the model to run programs. Review the source before installing.",extViewSource:"View source",extCancel:"Cancel",extRemoveHint:"Remove this declaration and managed installation. Local paths are only unreferenced; their files remain.",extMoveHint:"Install in the destination scope, then remove the original declaration and preserve resource filters.",extUnpinHint:"Remove the fixed version or Git ref to allow future updates.",extUpdateHint:"Update eligible packages. Pinned versions and local paths stay unchanged.",cmCalls:"Calls",cmScript:"Script",cmWaitingCalls:"Waiting for script calls…",cmNoCalls:"No nested calls",cmMoreCalls:"{n} earlier calls · Show all",cmCollapseCalls:"Show last 8 calls",cmCancelled:"Cancelled",cmUnfinished:"Unfinished",cmLimitedCalls:"{n} additional calls omitted here",cmTruncated:"This preview has been truncated.",cmWaitingOutput:"Output appears when the script returns.",cmNoOutput:"The script returned no text.",cmFullOutput:"Full output file",cmFailureNote:"Calls made before the failure have already run and are not undone. See Output for the error and any similar tool names.",cmSaveImage:"Save to workspace",cmAttachImage:"Attach to next message",cmAttached:"Image added to composer",cmSaved:"Saved: {path}",cmModelCost:"Model call cost",mcpDesignIntro:"Manage native MCP connections and Codemode. Changes are saved to Pi configuration.",mcpServersTitle:"Servers",mcpAttentionFirst:"Connections needing attention appear first. Background connections do not block the composer.",mcpImport:"Import from another client",mcpImportHelp:"Paste Claude, Cursor, VS Code, or OpenCode JSON. Existing server names are preserved. Convert Codex TOML to mcpServers JSON first.",mcpImportDraft:"Import into draft",mcpEditorHelp:'Enter native server JSON: command / args / env for local servers; url / headers / oauth for remote servers. Supports clientRegistration: "cimd".',mcpInvalidServer:"Server configuration must be a JSON object",mcpDiscard:"Discard unsaved configuration changes?",mcpNeedsAuth:"Sign-in required",mcpConnected:"Connected",mcpConnecting:"Connecting",mcpDisabled:"Disabled",mcpDisconnected:"Disconnected",mcpNotLoaded:"Not loaded",mcpFailed:"Connection failed",mcpRuntime:"Another configuration source",mcpAuthHelp:"Sign in with Pi OAuth. When a server requests additional scopes, signing in again retains previously granted scopes.",mcpRemoteLogin:"Browser on another machine? Paste the redirected URL into the native sign-in dialog.",mcpAnnotations:"Hints",mcpActualExposure:"Actual exposure",mcpDestructive:"Destructive",mcpReadOnly:"Read-only",mcpInherit:"Inherited",mcpNoTools:"No tools available from this connection.",mcpExposureDraftHint:"* Per-tool override. Left: actual SDK exposure (codemode maps to deferred). Right: configuration draft. Save to apply.",mcpEnableServer:"Enable",mcpDisableServer:"Disable",mcpEnableProject:"Enable for this project",mcpDisableProject:"Disable for this project",mcpRemoveConfirm:"Remove {name} from the configuration draft? Save to apply.",mcpUnsaved:"Unsaved changes",mcpSavedConfig:"Configuration saved",mcpSaveApply:"Save and apply",mcpExposureGuide:"About tool exposure",mcpExposure_codemode:"Discovered through scripts or tool search; not declared directly.",mcpExposure_deferred:"Loaded by tool_search; also callable from scripts.",mcpExposure_direct:"Declared to the model and callable from scripts.",mcpExposure_hidden:"Registered but unreachable.",mcpEmpty:"No servers configured. Add a local or remote MCP server.",mcpCodemodeHelp:"Only script output reaches the model. Calls follow native Pi permissions and lifecycle.",mcpModeHelp:"on keeps direct tools; only routes tools through scripts.",mcpBudgetHelp:"Estimated token budget for tool declarations; default 3000. Zero lists only namespaces.",mcpBudgetSlider:"Adjust tool declaration budget",mcpEffective:"Current session values",mcpSaveCodemode:"Save Codemode settings",mcpAutoHelp:"Auto-enable when a codemode MCP server connects. Saved with MCP configuration; does not deactivate an already active codemode tool.",mcpAdvanced:"Advanced: native JSON configuration",wikiLoadMore:"Load more files",wikiOpenDefault:"Open in default app",wikiHiddenFolders:"Hidden folders · {count}",wikiProperties:"Document properties",wikiIndexSkipped:"Skipped {count}",wikiIndexCounting:"Counting",wikiIndexStatus:"Indexed {indexed} / {total}",wikiIndexIssueCount:"{count} limited: {reason}",wikiIndexMultipleReasons:"{count} reasons; click for details",wikiIndexFileSize:"File exceeds 2 MB",wikiIndexBudget:"Total read budget exceeds 64 MB",wikiIndexEntries:"More than 20,000 entries",wikiIndexDepth:"Directory depth exceeds 32",wikiIndexUnreadable:"File or path cannot be read",wikiIndexSubtree:"This directory contains unscanned content",wikiIndexPartial:"The scan did not cover the entire workspace. More files remain uncounted. Limited files and unscanned directories are listed below by reason.",wikiIndexHint:"Some content is not indexed. Files exceeding size or budget limits remain searchable by path; inaccessible paths require their access issue to be resolved first.",wikiIndexComplete:"Indexing is complete, with no limited files.",wikiUpdatedToday:"Updated today at {time}",wikiUpdatedDate:"Updated {date}",wikiReadingTime:"About {minutes} min read",wikiCitations:"{count} pages link here",wikiOnThisPage:"On this page",wikiExpandComposer:"Expand question composer",wikiCompactPlaceholder:"Ask pi about this document…",wikiCollapseComposer:"Esc Collapse",wikiDocumentsOnly:"Documents only",wikiMayEditCode:"Code edits allowed",wikiReferenceHint:"@ Reference",wikiSessionPreparing:"Preparing conversation",wikiRetrySession:"Retry conversation",wikiReferencesLoading:"Loading references",wikiMode:"Wiki mode",wikiRecent:"Recent changes",wikiPreview:"Preview",wikiSource:"Edit source",wikiSearchAll:"Search all files",wikiFiles:"Files",wikiClear:"Clear",wikiRefresh:"Refresh files",wikiUnread:"Unseen pi changes",wikiNoFiles:"No matching files",wikiReload:"Reload",wikiLimits:"Some files are not indexed: 2 MB per file, 64 MB total, 20,000 entries. Files remain browsable.",wikiBacklinks:"Backlinks",wikiUnsaved:"Unsaved changes",wikiCodeReadOnly:"Read-only code · Choose Edit source to edit manually",wikiEditingSource:"Source editor · ⌘/Ctrl S to save",wikiPiAdded:"Added by pi",wikiDownloadOpen:"Download and open in default app",wikiNoBacklinks:"No documents link to this file yet",wikiWelcome:"Explore your knowledge with pi",wikiWelcomeHint:"Open a file from the sidebar, or search your workspace.",wikiChangedFiles:"pi changed {count} files",wikiRedo:"Redo",wikiUndo:"Undo",wikiChatPanel:"Wiki conversation panel",wikiFocus:"Focus on document",wikiTableSize:"Table size",wikiTableDimensions:"{columns} columns × {rows} rows",wikiTableHeader:"With header",wikiSearchLanguage:"Search languages…",wikiCodeAutomatic:"Auto detect",wikiCodeAutomaticHint:"Default",wikiCodeShell:"Shell",wikiCodePython:"Script",wikiCodeTypescript:"Typed script",wikiCodeData:"Structured data",wikiCodeConfig:"Configuration",wikiCodeQuery:"Database query",wikiCodeDiagram:"Diagram and source",wikiMoreInsert:"More insertions",wikiMoreInsertHint:"More insertions · or type /",wikiStandardWidth:"Standard width",wikiWideWidth:"Wide document (hide both sides)",wikiMentionDate:"Mention date",wikiInsertDate:"Insert today’s date",wikiEmptyParagraph:"Type / to insert, or start writing",wikiExitFocus:"Exit focus mode",wikiChatTitle:"Chat",wikiCloseChat:"Close conversation panel",wikiChatContext:"Context {percent}%",wikiNoModel:"No model selected",wikiEarlierMessages:"Show earlier messages",wikiQuickSummary:"Summarize this document",wikiQuickLinks:"Find broken links",wikiQuickSections:"Fill empty sections",wikiChatEmpty:"Ask pi about this document, or select text to ask a question.",wikiJumpSection:"Jump to §{section}",wikiToolInterrupted:"Interrupted",wikiWorking:"Working…",wikiLastAnswer:"Latest reply",wikiSelected:"Selection",wikiAsk:"Ask pi",wikiAskCode:"Ask pi about {file}, e.g. “Does it match the docs?”",wikiAskPlaceholder:"Ask pi about this document…",wikiScope:"Scope",wikiCurrentScope:"Scope · Current document",wikiWholeScope:"Scope · Entire workspace",wikiReferencedScope:"Scope · Referenced files",wikiAllowCode:"Allow code changes",wikiPromptPreview:"Preview request",wikiStop:"Stop",wikiSend:"Send",wikiRelatedChanges:"Related changes",wikiMe:"Me",wikiFileCount:"{count} files",wikiUndoAll:"Undo all",wikiRedoAll:"Redo all",wikiViewDiff:"View before and after",wikiBinaryChange:"Binary change; original bytes can be restored",wikiNewFile:"(New file)",wikiDeletedFile:"(Deleted)",wikiUntracked:"Files excluded from undo history",wikiNoChanges:"Edits and pi changes made in Wiki appear here",wikiAskPi:"Ask pi",wikiRewrite:"Rewrite",wikiExplain:"Explain",wikiAddLink:"Add links",wikiSearchHint:"Search documents, code and PDFs…",wikiDocuments:"Documents",wikiPdf:"PDF",wikiCode:"Code",wikiPage:"Page {page}",wikiNoResults:"No results found",wikiSearchLimited:"Results are limited or some files could not be searched; up to 8 PDFs, 200 pages each.",wikiSearchKeys:"↑↓ Select ↵ Open ⌘/Ctrl ↵ Ask pi Esc Close",wikiUnsavedHint:"Save this file before continuing?",wikiDiscard:"Discard",wikiSaveContinue:"Save and continue",wikiSaveFirst:"Save or discard your draft before restoring files.",wikiMissingLink:"No unique matching file: {path}",wikiDocumentsOnlyPrompt:"Only when the user explicitly requests edits, limit changes to documents in this scope. Code files are read-only unless this request explicitly asks to change code.",wikiSkipPrompt:"The scope, references and selection are context only, not a request to analyze or edit documents. Respond to the actual intent of the user message; answer greetings or casual conversation directly without reading, diagnosing or modifying files on that basis. Only edit and save when the user explicitly requests changes, then describe the actual changes.",wikiRewritePrompt:"Rewrite the selection, preserve its meaning, and save.",wikiExplainPrompt:"Explain the selection without changing files.",wikiLinkPrompt:"Add [[wiki links]] to existing workspace documents in the selection and save. Do not invent target files.",mcpArgs:"Arguments (JSON array)",mcpEnv:"Environment (JSON object)",mcpHeaders:"HTTP headers (JSON object)",mcpProvider:"Credential provider (global only)",mcpOauth:"OAuth parameters (JSON object, including authServerMetadataUrl)",mcpEnabled:"Enabled",mcpExposure:"Tool exposure",mcpUpdateDraft:"Update draft",mcpNew:"New server",mcpEdit:"Edit",nativeMcp:"MCP & Codemode",mcpScope:"Configuration scope",mcpGlobal:"Global",mcpProject:"Current project",mcpExplanation:"Native MCP uses Pi configuration and credentials. The legacy UI bridge uses app data-dir/mcp.json.",mcpUntrusted:"Project is untrusted. Saving does not load this configuration.",mcpTrust:"Trust current project",mcpPending:"Applies after the current task settles",mcpName:"Server name",mcpCommand:"Command",mcpAdd:"Add to draft",mcpConfig:"MCP configuration JSON",mcpJsonHelp:"Edit args, env, headers, auth.provider, oauth (including authServerMetadataUrl), enabled, exposure and advanced fields. Keep •••••••• to preserve secrets; replace it or remove the field to clear. Remove an mcpServers entry to delete a server.",mcpNameConflict:"Name is empty or already exists",mcpRefresh:"Refresh configuration",mcpStatus:"Official connection status",mcp_login:"Sign in",mcp_logout:"Sign out",mcp_reconnect:"Reconnect",mcpTools:"Available tools",mcpConfigureRadius:"Configure Radius MCP",nonChatModelsPreserved:"This form edits chat models. Configuration for {n} image or classifier models is preserved.",providerAuthChoose:"Choose an option",providerLogout:"Sign out",providerLogin:"Sign in",providerChatGPTLogin:"Sign in with ChatGPT",providerAuthPending:"Waiting for authorization. Complete sign-in in your browser.",providerAuthSuccess:"Signed in. The model list has been updated.",providerAuthCancelled:"Sign-in cancelled.",providerAuthError:"Sign-in failed.",providerAuthOpenBrowser:"Open authorization page",providerAuthDeviceCode:"Authorization code:",nodeConnectionTiming:"Handshake {ms} ms · Connected {duration}",nodeRevealSource:"Reveal local configuration",nodeSources:"Node sources",nodeSourceIntro:"Connect existing sessions. Changes in the source update here automatically.",nodeDetect:"Detect local sources",nodeSyncKeep:"Sync and keep updated",nodeImportOnce:"Import once",nodeChangePath:"Use another path",nodeSourcePath:"Configuration path on the server machine",nodeSyncNow:"Sync now",nodeSyncPause:"Pause sync",nodeSyncResume:"Resume sync",nodeSyncInfo:"{n} nodes · {g} groups",nodeSyncTime:"Last synced: {time}",nodeSyncFields:"Names, groups, addresses, ports, usernames and key paths",nodeSyncPassword:"Saved passwords are not imported. Enter credentials before connecting.",nodeSyncUnsupported:"Jump hosts, proxies and unsupported options are flagged and blocked.",nodeSearch:"Search name or address",nodeMissingSecret:"Needs password",nodeSourceMissing:"Source removed",nodeUnsupported:"Unsupported configuration",nodeFillSecret:"Authentication settings",nodeLocalAuthHint:"Choose password or public-key authentication. Saved locally after a successful test; source files are unchanged. Normal sync preserves this choice; host, user or source authentication changes reset it.",nodeCredentialHint:"Credentials are stored separately. After changing a password in Xshell, update it here too.",nodePersistSecret:"Save encrypted on the server machine",nodeGroupSecret:"Apply to this group’s nodes using the same authentication method",nodeGroupHint:"Only this node is tested; other nodes are verified when connected.",nodeTestSave:"Test and save",nodeTesting:"Verifying…",nodeCredentialsSaved:"Credentials verified and applied to {n} nodes",nodeSourceReadonly:"Source fields are read-only. Edit them in the original tool.",nodeSourceLocation:"Source file",nodeLastConnected:"Last connected",nodeNever:"Never",nodeOpenTerminal:"Open terminal",nodeBackList:"‹ Nodes",nodeDetails:"Node details",nodePolicy:"Agent permissions",nodePolicyReadonly:"Read-only auto · confirm others",nodePolicyConfirm:"Confirm every command",nodePolicyAuto:"Allow automatic execution",nodePolicyOff:"Disable agent",nodePolicyHint:"Recognized read-only commands run automatically. Writes, restarts and unknown commands require confirmation.",nodeApproval:"Approval required",nodeAllow:"Allow",nodeDeny:"Deny",nodeEditCommand:"Edit command",nodeLocate:"Locate ↗",nodeRunOutput:"Command output",nodeSendSelection:"Send to pi · {n} lines",nodeSelection:"Terminal selection · {n} lines",nodeTerminalHint:"Purple marks pi commands · select output to send to pi",nodeCopy:"Copy",nodeCopied:"Copied",nodeModel:"Node model",nodeNoModel:"Configure a model first",nodeShowFiles:"Files",nodeCloseTab:"Close terminal",nodeAddSource:"Add source",nodeNoSources:"No default source found. Specify an Xshell sessions folder or SSH config file.",nodeWorkingHere:"On {name}",nodeRunFailed:"Failed",nodeSourceOpenHint:"Copy the path and open the original configuration in Xshell or a text editor.",nodeQuoteRemove:"Remove quote",currentFileLabel:"Current file",currentFileUnsaved:"Unsaved",currentFileDraft:"Current file · Unsaved draft",currentFileUnavailable:"Current file is unavailable. Reopen it or remove the tag.",currentFileTooLarge:"Current file exceeds 512 KiB. Reduce its content or remove the tag.",currentFileSaving:"Current file is still saving — send again in a moment.",switchingProject:"Syncing project…",retryProjectSwitch:"Retry project switch",cancel:"Cancel",ok:"OK",save:"Save",close:"Close",widgetExpand:"Click to view full output",dragToResize:"Drag to resize · double-click to reset",loading:"Loading…",connected:"Connected",connecting:"Connecting…",reconnecting:"Reconnecting…",language:"Language",langZh:"中文",langEn:"English",githubRepo:"GitHub repository (youweichen0208/pi-harness)",copy:"Copy",viewSwitch:"Switch view",desktopWorkspace:"Workspace",windowControls:"Window controls",minimizeWindow:"Minimize window",maximizeWindow:"Maximize window",restoreWindow:"Restore window",closeWindow:"Close window (hide to tray)",chat:"Chat",terminal:"Terminal",nodes:"Nodes",nodeWorkbench:"SSH nodes",nodeAdd:"Add node",nodeEdit:"Edit node",nodeGroup:"Group",nodeName:"Name",nodeAddress:"Address",nodePort:"Port",nodeUsername:"Username",nodeDefaultDir:"Default directory",nodeAuth:"Authentication",nodePassword:"Password",nodeKey:"Public key (private key authentication)",expandProjects:"Expand projects",collapseProjects:"Collapse projects",nodePrivateKeyHint:"Enter the OpenSSH private key path on the computer running pi, not a .pub file. Xshell key names are not file paths; export an OpenSSH private key from its user key manager. Leave the passphrase empty for an unencrypted key.",nodeAgentAuth:"SSH Agent",nodeKeyPath:"Local private key path",nodePassphrase:"Key passphrase",nodeKeepSecret:"Leave blank to keep saved secret",nodeImportLegacy:"Import Remote-SSH hosts",nodeImportJson:"Import nodes JSON",nodeExport:"Export non-secret details",nodeEmpty:"Select or add an SSH node",nodeAddHint:"Add a node or import existing Remote-SSH hosts.",nodeConnected:"Connected",nodeDisconnected:"Disconnected",nodeConnect:"Connect",nodeDisconnect:"Disconnect",nodeTab:"Terminal {n}",nodeTabClosed:"disconnected",nodeTabBusy:"Agent running",nodeOpenHint:"Connect and open a terminal. The Agent uses the selected terminal.",nodeBrowse:"Browse files",nodeChat:"Node Agent",nodeChatPlaceholder:"Ask this node's Agent…",nodeSelectTerminal:"Open a terminal first",nodeInterrupt:"Interrupt terminal",nodeStopAgent:"Stop Agent",nodeSend:"Send",nodeAgentWaiting:"pi is thinking, waiting for a response…",nodeAgentExecuting:"pi is running a command…",nodeAgentApproval:"Waiting for your approval…",nodeDelete:"Delete",nodeForgetHostKey:"Forget trusted host key",nodeForgetHostKeyConfirm:"Have you verified the new host key for {name}? The fingerprint will appear again on the next connection.",nodeTrust:`First connection to {name} ({host})
|
|
18
|
-
Host key fingerprint: {fingerprint}
|
|
19
|
-
Trust this host?`,nodeDeleteConfirm:"Delete {name}?",nodeImported:"Imported {n} nodes (set credentials manually)",nodeInvalidJson:"Invalid nodes JSON",selectModel:"Select model",availableModels:"Available models",noModels:"No models available (configure an API key first)",reasoning:"reasoning",vision:"vision",refreshModels:"Refresh model list (keeps manual rows, merges new ones)",manageModels:"⚙ Manage models (add / edit)",manageModelsTitle:"Manage models",thinkingLevel:"Thinking level",steerSend:"Send now",activityReply:"Writing the reply…",activityTool:"Running {name}…",activityReading:"Reading {name}…",waitingCommand:"Waiting for command to finish…",onlyChanged:"Changed only",changedCount:"Changes {n}",yesterday:"Yesterday",noChangedFiles:"No changed files",goalEventSet:"Goal set: {text}",cwdSwitchEvent:"Workspace changed to {path}",goalEventComplete:"Goal completed: {text}",goalReviewDetails:"Review details",thinkingDuration:"{n}s",thinkingUnrecorded:"duration unavailable",thinking:"Thinking",thinkingChip:"Thinking: {level}",sound:"Sound",theme:"Theme",themeDefault:"Dark (default)",newChat:"New chat",more:"More",newChatTip:"New chat (sessions are saved per browser)","thinking.off":"Off","thinking.minimal":"Minimal","thinking.low":"Low","thinking.medium":"Medium","thinking.high":"High","thinking.xhigh":"Extra high","thinking.max":"Max",thinkingUnsupported:"Not supported by this model — snapped to the nearest supported level",context:"Context",contextUsage:"Context usage",usageContextTitle:"Context window",usageCacheTitle:"Cache hits",usageCacheShort:"Cache",taskCurrentRound:"This turn",cumulativeCost:"Cumulative cost",sessionMessages:"Session messages",messages:"messages",pluginStatus:"Plugin status",working:"Working",queued:"queued",enterPath:"Type a path, Enter to switch",cwdTip:"Working directory: {path} (click to switch)",folderRef:"Folder reference: {path}",refOnly:"Reference only: {path}",attachContent:"Attached content: {path}",attachLines:"Attached selected lines: {path} (lines {start}-{end})",attachImage:"Image: {name}",attachFile:"File: {name}",removeAttachment:"Remove attachment",attachHint:"Will be sent with the next message",uploadFile:"Add files (images / text / any file — or drag in / paste a screenshot)",dropHereToAttach:"Release to attach file",imageNotSupported:"The current model doesn't support vision — images will be transcribed by the vision bridge (may be ignored if no vision model is configured)",imageLoadFailed:"Couldn't read image: {name}",fileLoadFailed:"Couldn't read file: {name}",fileTooLarge:"File too large, skipped (> {size}MB): {name}",foldersNotSupported:"Folders can't be dropped directly — expand and pick files instead",placeholderStreaming:"Keep typing; send after the current step",stopTask:"Stop task",taskCommitting:"Committing",taskCompletionCriteria:"Done when",taskOutlineChanged:"Plan changed",taskOutlineAdded:"Added step {n}: {title}",taskOutlineRemoved:"Removed: {title}",taskOutlineUpdated:"Updated step {n}: {title}",taskNoStepDetails:"No execution records yet",otherDirectories:"{n} other folders",bashStatusFiles:"{n} files",bashStatusAdded:"{n} added",bashStatusModified:"{n} modified",bashStatusDeleted:"{n} deleted",bashStatusConflicts:"{n} conflicts",placeholderIdle:"Message pi — Enter to send, / for commands",placeholderConnecting:"Connecting to server…",stopAgent:"Stop agent",stopQueuedAfterReconnect:"Connection lost. The current conversation will be stopped after reconnecting.",stopUnavailable:"Cannot send a stop request yet. Wait for the connection to return.",workDisconnected:"Connection lost. Reconnecting; run status is unconfirmed.",stop:"Stop",bgTasks:"Background tasks",bgTasksTip:"Servers the AI started in the background (npm run dev & etc.) — stop them individually or all at once; they survive the conversation",bgTasksEmpty:"No background tasks",bgTasksDesc:"Processes the AI started that are still listening (detected by port)",bgTaskPort:"Port",bgTaskPid:"PID",bgTaskSince:"Started",bgTaskStop:"Stop",bgTaskStopAll:"Stop all",bgTaskRefresh:"Refresh",bgTaskJustNow:"just now",bgTaskMinutes:"{n} min ago",bgTaskHours:"{n} hr ago",bgTaskDays:"{n} days ago",stopBash:"Stop",stopBashTip:"Stop the running bash command (conversation continues)",supplement:"Queue",supplementTip:"Add to queue: sent only after the whole run finishes (no interruption)",commandAttempts:"{n} attempts",queueSteerTag:"Steer",pendingMessages:"{n} pending",recallQueueEdit:"Recall all to edit",deliverySteerHint:"Send after the current step",deliveryFollowHint:"Send after this turn",placeholderStreamingModes:"Keep typing, ↵ {primary} · Alt+↵ {alternate}",queueFollowTag:"Queued",sendTip:"Send (Enter)",slashCommands:"Commands",slashMenuHint:"↑↓ select · Enter/Tab complete",slashHelpTitle:"pi commands",slashHelpHint:"Type / anytime to open the command list",slashLoading:"Loading commands… (available once connected)",slashBuiltin:"Builtin",slashExtension:"Extension",slashPrompt:"Template",slashSkill:"Skill",slashPlugin:"Plugin",slashCopied:"Copied the last assistant reply",slashCopyFailed:"Copy failed — please copy manually",slashCopyEmpty:"No assistant reply to copy yet",mermaidRendering:"Rendering diagram…",mermaidRenderFailed:"Diagram failed to render — showing raw source",recentProjects:"Recent projects",workspaceFiles:"Files",showHiddenFiles:"Show hidden",taskProgress:"Task progress",taskProgressHeading:"Progress",taskOutputsHeading:"Outputs",taskProgressEmpty:"Progress for longer tasks will appear here.",taskOutputsEmpty:"View and open files created or modified during this task.",taskPaused:"Paused · waiting to continue",taskFailed:"Task failed",taskCompletedCount:"{n} completed",taskRunningCount:"{n} running",taskSteps:"steps",taskCompletedHidden:"{n} completed steps · Show",taskJumpToChat:"Find in chat",builtinTaskList:"Task list",componentUpdates:"Updates",componentNewVersion:"Update available",componentCurrent:"Latest stable version installed",componentPinned:"Pinned version; change the installation source manually",componentManual:"Maintain manually at the installation source",componentUnknown:"Installed version unknown",componentCheckFailed:"Check failed; retry available",componentApp:"pi-harness application",componentDesktopUnsupported:"Automatic installation is available in the installed desktop app, not development mode.",componentAppHint:"Check and download a new version, then restart to install.",componentWebUpdateHint:"Update the global npm package in the terminal, then run pi-harness server restart.",componentDownloading:"Downloading: {n}%",componentRestartInstall:"Restart and install",componentAutoUpdate:"Update automatically",componentLocal:"Local file extension; edit its source and reload.",componentChecking:"Checking…",componentCheck:"Check for updates",componentUpdateIntro:"Running pi Agent and installed extension versions. Checks never install updates. Restart the app after updating user extensions.",componentOffline:"Reconnect to check for updates.",componentInstalling:"Updating extension. Please wait…",componentRestart:"Update installed. Restart the app to load the new version.",componentBundled:"Bundled",componentBundledHint:"Updated with the app. An upstream release may not yet be included in this app.",componentProject:"Project",componentUser:"User-installed",componentInstalled:"Installed",componentInstall:"Update extension",taskTodoUpdate:"Task list update",planUnassignedRecords:"This turn’s execution records · outside the plan",planEnabled:"Native plan tool (whole service)",planEnabledHint:"On by default; saved preferences are preserved. Shared by all clients; running sessions apply changes after settling.",planPending:"Applies when the session is idle and writable",planConflict:"A third-party plan tool is present. This switch does not change it.",planMissing:"The native plan extension is unavailable in this session",planReplaced:"Plan {id} (revision {revision}) was replaced and cancelled",planStatusChanged:"Plan status: {status}",planRecorded:"Plan recorded",planActive:"Active",planPrevious:"Previous unfinished plan · awaiting confirmation",todoCounts:"{total} items · {completed} completed",todoCreated:"Created",todoPending:"Pending",todoRemoved:"Removed",todoView:"View",todoChanges:"Checklist update: {changes}",todoChangeSeparator:"; ",todoCleared:"Task checklist cleared",todoItemAdded:"Item {n} added",todoItemUpdated:"Item {n} updated",todoItemPending:"Item {n} pending",todoItemStarted:"Item {n} started",todoItemCompleted:"Item {n} completed",todoItemDeleted:"Item {n} removed",taskWaitingContinue:"Waiting to continue",taskPlanSource:"Task checklist",taskPlanSourceHint:"Steps tracked from the checklist created by the agent",taskObservedSource:"Activity · No plan created",taskObservedSourceHint:"Summarized from tool calls; the agent has not created a task checklist",taskBlockedBy:"Waiting for steps {steps}",taskCancelled:"Stopped",taskLongTool:"Command running",taskStepSilent:"No new data; see actions above the composer",taskPhases:"phases",taskDuration:"Duration",taskResult:"Result",taskCommit:"Commit",taskTests:"Tests",taskChanges:"Changes",taskPassed:"passed",taskFiles:"files",taskViewChanges:"View changes",taskFinalReply:"Go to final reply",taskProcess:"Process",taskOnlyResult:"Only result",taskShowProcess:"Expand process",taskRawSteps:"{n} original steps",taskShowRaw:"Show {n} original steps",taskHideRaw:"Hide original steps",taskCopyMarkdown:"Copy as Markdown",taskArtifactRead:"Read",taskArtifactWrite:"Write",taskArtifactEdit:"Edit",taskArtifactRun:"Run",taskLines:"lines",taskExplicitPlan:"Pi plan",taskPlanSteps:"steps",taskPlanPosition:"Step {current} / {total}",taskPlanChanged:"Plan updated",taskPlanAdded:"Added",taskPlanCard:"Plan",taskUnderSecond:"<1s",taskReadCount:"{n} reads",taskWriteCount:"{n} writes",taskEditCount:"{n} edits",taskCommandCount:"{n} commands",changeEdit:"Edit",changeWrite:"Write",changeOpen:"Open",changeRawArgs:"Raw arguments",changeRawOutput:"Raw output",changeAtLine:"Line {n}",changeWrittenLines:"Wrote {n} lines",changeOriginal:"Original text sought",changeAttemptedWrite:"Content attempted",changeFailed:"Edit failed",changeNoOriginal:"No original text available",changeNoDiff:"No diff available",changeReplacement:"Replacement text (file diff unavailable)",changeRetried:"Retried",modelSilent:"No model response for {duration}",modelSilentShort:"Model unresponsive",toolSilentShort:"Tool running · no new output",placeholderModelSilent:"The model is quiet. Stop, retry, or keep waiting…",placeholderToolSilent:"A command or tool is still running. New messages will queue…",toolSilent:"Command or tool running for {duration} without new output",retrySilentUnavailable:"This turn used tools or attachments. Stop and review before retrying to avoid duplicate effects.",continueWaiting:"Keep waiting",actions:"Actions",retry:"Retry",writeVerb:"Write",expandRemainingLines:"Show {n} more lines",lines:"lines",fileUsed:"Used",thinkingDepthTip:"Thinking depth: deeper takes longer and uses more tokens",readFiles:"Read {n} files",readVerb:"Read",modelReadOnly:"File content · read by model only",readRaw:"Source",skillLabel:"Skill",bashSteps:"Steps",bashRaw:"Raw",bashRunning:"Running",bashPartial:"Partly failed · {ok}/{total} steps passed",bashFailed:"Failed",bashErrorCount:"{n} errors",bashExpandCommand:"Show full command · {n} steps",bashExpandFullCommand:"Show full command",bashLikelyErrorLines:"{n} likely error lines",bashHiddenLines:"{n} lines hidden",bashNoMatch:"No matches",bashSkipped:"Not run",bashShowRaw:"Show raw output",grepSearch:"Search",grepInPath:"in {path}",grepMatches:"{n} matches",allDone:"All done",expandAllLines:"Show all · {n} lines",timeGapAt:"Time gap, {time}",notGitRepoShort:"Not a Git repo",toolWrap:"Wrap",copied:"Copied",toolLineCount:"{n} lines",toolRelativeTo:"Relative to {path}",toolMoreLines:"Show remaining {n} lines",workspaceBranch:"Branch",workspacePath:"Path",workspaceProjects:"Projects",composerPlaceholder:"Message pi…",thinkingStandard:"Standard",thinkingDeep:"Deep",thinkingMinimalDescription:"Minimal reasoning, fastest",thinkingStandardDescription:"Balanced speed and quality",thinkingDeepDescription:"More reasoning for complex tasks",workspaceModified:"Uncommitted changes",workspaceChanges:"{n} recent changes",runningConversations:"Running chats",historySessions:"History",openHistory:"History",openFiles:"Files",streaming:"Streaming…",noHistory:"No previous chats",current:"Current",messageCount:"{n} messages",tuiTip:"Chat in the pi terminal (TUI)",deleteProject:"Remove from recent projects",deleteProjectConfirm:"Confirm remove",deleteSession:"Delete this chat transcript permanently",deleteSessionConfirm:"Confirm delete",confirm:"Confirm",expandCode:"Expand full content",collapseCode:"Collapse",zoomCode:"Open in a larger view",closeZoom:"Close",renameSession:"Rename this chat",renameSessionPlaceholder:"Chat name (empty falls back to first message)",openFolder:"Open folder…",openFolderPlaceholder:"Or paste an absolute path",openThisFolder:"Open this folder",openTypedPath:"Open typed path",parentFolder:"Parent folder",home:"Home",noSubfolders:"No subfolders here",listTruncated:"Too many folders — list truncated",emptyChat:"Empty chat",editReask:"Edit & re-ask",editReaskTip:"Edit this question and re-ask from here (forks a new conversation; the original is kept)",reaskFromHere:"Re-ask from here",editPlaceholder:"Edit the question…",editHint:"⌘/Ctrl+Enter to submit · Esc to cancel",editAttachmentHint:"Original attachments kept — paste/drop images or files · ⌘/Ctrl+Enter to submit · Esc to cancel",expandMsg:"Expand",collapseMsg:"Collapse",toolCalls:"tool calls",bashRuns:"bash runs",images:"images",update:"Update",updateTip:"Check & update pi-harness",currentVersion:"Current version",latestVersion:"Latest version",checkingUpdate:"Checking…",checkUpdate:"Check for updates",upToDate:"You're up to date",updateAvailable:"New version v{version} available",updateJustPublished:"v{version} was just published — npm cache may lag; if the new version isn't detected yet, re-check in a moment",updateNow:"Update in terminal",updateTabTitle:"Update pi-harness",updateTerminalHint:"Clicking runs npm i -g @youweichen/pi-harness@latest in a visible terminal; restart the service afterwards to take effect (pi-harness server restart).",rootDir:"Root",noFiles:"No files",filesTruncated:"Directory too large — list truncated (first 2000 shown)",linkFolderTip:"Link folder path to chat",attachInlineTip:"Attach content to chat",referenceTip:"Reference path only (AI reads on demand)",richSourceBlock:"Source preserved; switch to source to edit",richFormatting:"Document formatting",richEditMarkdown:"Edit Markdown document",reloadRunning:"Reloading…",reloadDone:"Reloaded",reloadPartial:"Reloaded with {count} loading error(s)",reloadCounts:"Extensions {extensions} · Skills {skills} · Prompts {prompts}",reloadDetails:"Show error details",reloadGeneralError:"Reload",reloadExtensionList:"Extensions: {names}",reloadSkillList:"Skills: {names}",reloadPromptList:"Prompts: {names}",richFormatToolbar:"Document formatting",richBold:"Bold",richItalic:"Italic",richHeading:"Heading",richParagraph:"Paragraph",richList:"List",richOrderedList:"Numbered list",richQuote:"Quote",richUndo:"Undo",richRedo:"Redo",richTable:"Insert table",dbViewer:"Database preview",dbReadOnly:"Read only",dbRefresh:"Refresh",dbTable:"Table / view",dbView:"View",dbRows:"Table data",dbNoTables:"This database has no tables to display.",dbNoRows:"This table has no rows.",dbPrevious:"Previous",dbNext:"Next",dbRowRange:"Rows {start}–{end}",dbSchema:"Show schema",dbCellLimit:"Up to 50 rows per page; text previews show 256 characters and BLOBs show byte counts.",dbStructureLimited:"Showing up to 500 tables and 64 columns per table.",dbLoadFailed:"Unable to read SQLite database:",dbUnavailable:"Connection or workspace is unavailable.",richColumn:"Column",richTableTools:"Table actions",richAddRow:"Add row below",richAddColumn:"Add column right",richRemoveRow:"Delete current row",richRemoveColumn:"Delete current column",fileMoreActions:"More file actions",richCodeBlock:"Code block",richHighlightBlock:"Highlight block",richTextHighlight:"Highlight",richHighlight_yellow:"Yellow highlight",richHighlight_green:"Green highlight",richHighlight_blue:"Blue highlight",richHighlight_pink:"Pink highlight",richHighlight_purple:"Purple highlight",richHighlightClear:"Clear highlight",richCodeLanguage:"Code language",richPlainText:"Plain text",richImageUploading:"Inserting image…",richImageFailed:"Image insertion failed. Check the connection and file state, then paste again.",richImageTooLarge:"Images must be at most 5 MB.",richDivider:"Divider",richTaskList:"Task list",richInsertMenu:"Insert element",richTextGroup:"Text formatting",richBlocksGroup:"Basic elements",richNoElements:"No matching elements",backToFiles:"Back to files",fileUnsaved:"Unsaved",fileSaving:"Saving",fileSaved:"Saved",fileViewMode:"File view",fileViewPreview:"Preview",fileViewSource:"Source",fileViewChanges:"View changes",fileChangesCount:"Changes {n}",fileEditMode:"Editing mode",fileReadOnly:"Read only",fileEditShort:"Edit",fileReference:"Reference",fileExternalChanged:"pi changed this file",fileCompare:"Compare",fileNoChanges:"No changes to show",fileLocalDraft:"Unsaved draft",fileDiskVersion:"Latest disk version",quoteSelection:"Quote selection @{name}:{start}-{end}",fileSaveFailed:"Save failed",fileOffline:"Disconnected or timed out. Your draft is retained. Please retry.",fileReload:"Reload",fileOverwrite:"Overwrite disk file",fileOverwriteConfirm:"The disk file has changed. Overwrite it with this draft?",fileLeavePrompt:"This file has unsaved changes.",fileSaveContinue:"Save and continue",fileDiscard:"Discard changes",previewFile:"Preview",downloadFile:"Download file",downloadFailed:"Download failed: {error}",protocolMismatch:"Page version differs from the server (the app was just updated). Refresh the page to restore full functionality.",selectLinesHint:"Click a line to select; drag or Shift+click for a range",enableWrap:"Enable line wrap",disableWrap:"Disable line wrap",selectedRange:"Selected {n} lines (lines {start}-{end})",fileLines:"{n} lines",selectAll:"Select all",clearSelection:"Clear",addToChat:"Add to chat",addedToChat:"Added",previewTruncated:"⚠ File too large — previewing the first 512KB",previewLinesTruncated:"… too many lines — showing the first {n}",binaryFile:"🔣 Binary file — first 4KB shown as hex",binaryHexTruncated:" (file larger — download for the full file)",previewNotSupported:"This file type can't be previewed (only images / videos / text)",emptyFile:"(empty file)",editFile:"Edit file",exitEditFile:"Exit editing",saveFile:"Save file",discardFileChanges:"Discard unsaved changes?",fileEditTruncated:"The preview is incomplete, so this file can't be edited",showMarkdownSource:"Show Markdown source",showMarkdownPreview:"Show Markdown preview",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",zoomIn:"Increase font size",zoomOut:"Decrease font size",resetZoom:"Reset zoom",pluginRequest:"Plugin request",noOptions:"(no options)",inputPlaceholder:"Enter content",soundHeader:"Sound notifications",enableSound:"Enable sound",preview:"Preview",volume:"Volume","sound.question":"Question popup","sound.question.desc":"When ask_user_question appears","sound.done":"Reply finished","sound.done.desc":"When the agent finishes a turn","sound.start":"Reply started","sound.start.desc":"When the agent starts a new turn","sound.error":"Error","sound.error.desc":"When an error notice appears",setupTitle:"pi agent config not detected",setupDesc:"pi-harness needs pi's config directory (~/.pi/agent) and at least one API key to run the agent. pi has built-in providers such as openai, anthropic, and deepseek — just pick one and enter a key, no terminal needed.",installFailed:"✖ pi agent installation failed:",retryInstall:"Retry install",skip:"Skip",installDone:"✅ pi agent CLI installed. Pick a provider and enter an API key to start chatting:",cliReadyHint:"✅ pi agent CLI already installed locally. Pick a provider and enter an API key to start chatting:",provider:"Provider",configured:"configured",providerKeyReady:"This provider already has a key — use it or replace it.",apiKey:"API key",saving:"Saving…",saveAndStart:"Save and start using",recheck:"Recheck",installing:"Installing pi agent CLI…",autoInstall:"Auto-install pi agent",attachment:"Attachment",plugin:"plugin",unknown:"unknown",thinkingWait:"Thinking",exitCode:"Exit code {code}",cancelled:"Cancelled",truncated:"… content too long, truncated in this view",outputTruncated:"… output too long, truncated in this view",refOnlyShort:"Reference only",folderRefShort:"Folder · reference only",inlineLines:"Inline · {n} lines",inlineLinesRange:"Lines {start}-{end}",image:"🖼 Image",bridgedVision:"👁 Transcribed",bridgedVisionDetail:"Image transcribed by the vision bridge (current model can't see images)",folderNotExpanded:"Folder — content not expanded, the agent will browse it as needed",fileNotExpanded:"Large file ({size}) — content not expanded, the agent will read it as needed","role.user":"You","role.assistant":"pi","role.tool":"Tool","role.bash":"Terminal","role.branch":"Branch summary","role.compaction":"Context compacted",welcomeTitle:"pi coding agent",welcomeSub:"Inspect, edit, run — always ready",directory:"Directory",clickToFill:"Click to fill input",sending:"Sending",backToBottom:"Back to bottom",questionNavTitle:"Questions",questionMarkerGroup:"{n} nearby questions",searchPlaceholder:"Search in conversation…",searchNoResults:"No results",searchModels:"Filter models…",noModelMatches:"No matching models",searchGlobal:"Search",searchGlobalTip:"Global search: sessions / projects / files (Ctrl+K)",gsPlaceholder:"Search projects, past conversations, workspace files…",gsHint:"Type to search session history, recent projects and file names in the current workspace at once",gsSessions:"Conversations",gsProjects:"Projects",gsFiles:"Files",gsNoResults:"No matches",gsSearching:"Searching files…",gsTruncated:"Too many matches — showing a subset",gsCurrentProject:"current",gsOpenPreview:"Open file preview",gsNavigate:"select",gsOpen:"open",gsCloseHint:"close",bgTaskCommand:"Command",searchPrev:"Previous (Shift+Enter)",searchNext:"Next (Enter)",searchClose:"Close (Esc)",questionNavTip:"All questions in this conversation — hover to expand, click to jump","ex.understand":"Understand this project","ex.understand.prompt":"Introduce this project: overall structure, main modules, and how to run it?","ex.debug":"Debug an issue","ex.debug.prompt":"Help me debug a bug — describe the symptom first, and I'll add details.","ex.test":"Write tests","ex.test.prompt":"Write unit tests for the core modules.","ex.review":"Code review","ex.review.prompt":"Review the recently changed code and point out potential issues and improvements.",error:"Error",done:"Done",running:"Running…",toolQueued:"Queued",copyArgs:"Copy args",errorOutput:"Error output",nestedToolCalls:"Nested tool calls · {n}",nestedToolCallsIncomplete:"Some call records or arguments were not fully retained.",recoveryCompacting:"Compacting",recallQueue:"Recall all queued messages",recallQueueShort:"Recall queued messages",treeVerifying:"Verifying session file…",compactionCompleted:"Compaction completed",compactionAborted:"Compaction cancelled",compactionFailed:"Compaction failed",compactionManual:"Manual",compactionThreshold:"Context near limit",compactionOverflow:"Context overflow",recoveryWaiting:"Waiting for native retry",recoveryRunning:"Retrying",recoverySummaryWaiting:"Waiting to retry summary",recoverySummaryRunning:"Retrying summary",conversationRunSettings:"Conversation run settings",conversationAutoCompaction:"Auto compaction",conversationAutoRetry:"SDK auto retry",commandAttachmentsRetained:"Command executed. Unsent attachments remain in the composer.",toolOutputAuth:"Download authentication failed. Please reconnect.",toolOutputDenied:"Access to this output was denied.",toolOutputError:"Download failed. Please try again.",toolOutputText:"Full text",toolOutputDownload:"Download full output",toolOutputUnavailable:"Full output unavailable or already cleaned up",toolResultImage:"Image returned by a tool",output:"Output",waitingOutput:"Waiting for output…",toolDoneWaitingModel:"Done",waitUnderstanding:"Understanding your question",waitResults:"Reading command results",waitFile:"Reading files",waitThinking:"Thinking",waitTests:"Waiting for test results",waitBuild:"Waiting for build results",waitSteer:"Processing your direction",waitSeconds:"{n} sec",waitMinutes:"{m} min {s} sec",waitStop:"Stop",thinkingNow:"Thinking",thinkingPreview:"Thinking: {preview}",leakedThinking:"Additional model content",toolUnexecutedTitle:"Tool call not executed",toolUnexecutedAttempts:"Stopped after {n} automatic reminder(s)",toolUnexecutedHint:"{model} wrote the tool instruction as text and still made no tool call after a reminder. Earlier results are preserved.",toolUnexecutedInline:"Tool instruction was written as text and not executed",toolAutoReminded:"Reminder sent",toolReminderEvent:"Asked pi to retry with a real tool call",toolRecoverySwitch:"Switch model",toolRecoveryRaw:"View original output",toolRecoveryRawHide:"Hide original output",toolRecoveryFirst:"First attempt",toolRecoveryAfterReminder:"After reminder",toolRecoveryNoCall:"No tool call",taskInterruptedHint:"Tool call not executed. Use Resend in the conversation to continue.",taskInterruptedTitle:"Interrupted",unexecutedToolHint:"{model} returned a tool instruction as text instead of a native tool call. Earlier results have been preserved.",unexecutedToolOriginal:"View original output",toolStoppedTitle:"The model stopped without running a tool",toolStoppedHint:"{model} was reminded to continue with a tool call but still did not call any tool, so the task stopped here. Resend, or continue with another model.",toolRecoveryResend:"Resend",toolRecoveryFailed:"Could not confirm the resend request. Check the connection and selected model before retrying.",toolRecoveryInterrupted:"Interrupted",leakedThinkingHint:"Reasoning markers were detected in the reply, so this content was collapsed. This does not indicate an application error or data disclosure. Click to view the original.",commands:"Commands",newCommand:"New command",newTerminal:"New terminal",name:"Name",command:"Command",cwdHint:"(${pwd} = current working directory)",noCommands:"No commands yet — click + to add one",clickToRun:"Click to run",edit:"Edit",delete:"Delete",confirmQ:"Confirm?",builtinTerminal:"Built-in terminal",termEmptySub:"Click a command on the left to run it, or + on the right for a new terminal",noTerminal:"No terminals",exited:"(exited{code})",closeTerminal:"Close terminal",rerun:"Reload .pi/commands.json",terminalTitle:"Terminal {n}",exampleName:"e.g. start dev server",exampleCommand:"e.g. npm run dev",scmTab:"Git",scmTitle:"Source Control",scmRefreshTip:"Re-query git status & diff",scmCurrentBranch:"Current branch",scmUpstreamGone:"Upstream deleted",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"Detached HEAD",scmSelectBranch:"Select branch…",scmRemoteBranches:"Remote branches",scmStageTip:"Stage {path}",scmUnstageTip:"Unstage {path}",scmSwitch:"Switch",scmSwitchBranch:"Switch branch",scmSwitchBranchTip:"Runs git checkout {branch} in the terminal",scmPush:"Push",scmPushTip:"Runs git push in the terminal",scmPull:"Pull",scmPullTip:"Runs git pull in the terminal",scmCommit:"Commit",scmCommitTip:'Runs git add -A && git commit -m "…" in the terminal (commits all changes incl. untracked)',scmCommitPlaceholder:"Type a commit message…",scmChanges:"Changes",scmHistory:"Commit tree",scmCommitDetail:"Commit details",scmSelectCommitHint:"Click a commit on the left to view its details",scmNoHistory:"No commits yet",scmNoChanges:"Working tree clean — no changes",scmNotGitRepo:"Current directory is not a Git repository",scmLoading:"Querying…",scmConnecting:"Waiting for connection…",scmDiff:"Diff",scmSelectFileHint:"Click a file on the left to view its diff",scmNoDiff:"(no diff)",scmStaged:"Staged",scmUnstaged:"Unstaged",scmStagedUnstaged:"Staged + unstaged",scmUntracked:"Untracked",scmUntrackedBadge:"u",scmUntrackedBinary:"Binary file cannot be previewed here",scmUntrackedDirectory:"Directory cannot be previewed here; select a file inside it",scmEmptyFile:"Empty file",scmPreviewTruncated:"Showing only the first 512 KB",scmQueryFailed:"Git query failed: {error}",scmTooManyFailures:"Git queries keep failing — click refresh to retry",scmRunsInTerminal:"Commit / branch switch / push / pull run in the terminal",scmViewTerminal:"Open terminal",editProvider:"Edit provider",builtinProviders:"Built-in providers",hintKeyOnly:"Configure an API key or sign in to a supported account",configuredBadge:"✓ Configured",keyReady:"Key ready",replaceKey:"Replace key",replaceKeyTitle:"Replace the saved key",clearKey:"Clear",clearKeyTitle:"Remove this provider's key stored in auth.json; it returns to unconfigured (env-var sourced keys can't be cleared here)",clearKeyConfirm:"Clear the stored key for {id}? Its models will leave the list until you configure it again.",cloneProvider:"Clone as custom",cloning:"Cloning",cloneProviderTitle:"Copy this built-in provider (baseUrl + model catalog) into a custom provider — paste another API key to run both keys side by side",pasteKey:"Paste API key…",savingKey:"Saving",saveKey:"Save key",customProviders:"Custom providers",customDesc:"For Ollama / vLLM / OpenAI-compatible proxies, etc. Written to pi's models.json — hot-reloaded immediately.",noCustomProviders:"No custom providers yet",modelsCount:"{n} models",addProvider:"Add provider",providerId:"Provider ID",providerIdHint:"(required, e.g. ollama / my-proxy)",displayName:"Display name",displayNamePh:"My proxy",apiType:"API type",baseUrlHint:"(OpenAI-compatible endpoint)",apiKeyHint:"sk-… (leave blank to keep the existing key)",authHeader:"Auto-add Authorization header",modelsTitle:"Models",modelIdReq:"Model ID (required)",text:"Text",textImage:"Text+image",contextWindow:"Context",maxOutput:"Max output",removeModel:"Remove model",addModel:"Add model",deleteProviderConfirm:"Delete provider {id} and its {n} models?",fetchModels:"Fetch model list",fetchModelsHint:"Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)",fetchingModels:"Fetching…",fetchModelsOk:"Fetched {n} models",fetchModelsEmpty:"The endpoint returned no models",fetchModelsErr:"Fetch failed: {msg}",fetchModelsNeedBaseUrl:"Enter a baseUrl first",goalBarTitle:"Goal",goalWizardCard:"Goal survey",settings:"Settings",nativeContextOnly:"Uses the native pi context. WebUI does not append prompts or register custom agent tools.",nativeResourcesManaged:"Skills and extensions are managed by native pi configuration. Loaded resources are shown here.",settingsTitle:"Settings",allSettings:"All settings",quickActions:"Quick actions",settingsAppearance:"Appearance",settingsCodeTheme:"Code file colors",codeThemeLight:"Light",codeThemeDark:"Dark",codeThemeSystem:"Follow system",settingsDesc:"Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).",settingsSystemPrompt:"System prompt",promptModeAppend:"Append",promptModeReplace:"Replace",promptAppendHint:"Append mode: your text is appended to the end of the default system prompt (recommended — keeps the default behavior constraints).",promptReplaceHint:"Replace mode: your text fully replaces the system prompt (project context and skills are still appended automatically). After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.",promptPlaceholder:"Type a custom system prompt… (applied on blur)",settingsViewPrompt:"View the current full prompt",settingsViewPromptHint:"The full system prompt actually in effect for this conversation (custom append/replace text, project context, skills and tool guidance). Read-only.",settingsViewPromptEmpty:"Session not ready yet — no system prompt available.",settingsSkills:"Skills",settingsReview:"Goal review",settingsReviewDesc:"Configure extra instructions and skills for the isolated goal-review session; the main session is unaffected.",settingsReviewSkills:"Skills available to review",reviewPromptPlaceholder:"Type custom review instructions… (applied on blur)",reviewPromptHint:"These instructions are added to the review task; pass/fail JSON output is still enforced. Skill toggles apply only to review.",settingsVisionBridge:"Vision bridge",settingsVisionBridgeDesc:"When the current model can't see images, send them to a configured vision model and transcribe into text evidence first",settingsTerminalTools:"Terminal tools",settingsTerminalToolsDesc:"Let the AI use the built-in terminal for interactive programs (REPLs/vim), long-running servers, continuous output watching, or when you ask it to work in the visible terminal; ordinary commands still go through the one-shot bash tool",settingsMessageDisplay:"Message display",thinkingWrap:"Show full thinking",thinkingWrapDesc:"On: thinking always expands fully and wraps (live reasoning visible while streaming); Off: collapses to a one-line summary with the latest text shown live while streaming",toolsWrap:"Show full tools",toolsWrapDesc:"On: tool calls always expand fully showing arguments and output; Off: collapsed by default, click to expand",uninstallExt:"Uninstall",uninstallConfirm:"Confirm?",uninstallConfirmHint:"Click again to confirm — runs pi remove in the terminal",uninstallHint:"Runs pi remove in a visible terminal, then refreshes the list automatically",uninstallTitle:"Uninstall",pluginUpdate:"Update",pluginUpdateHint:"Re-installs from the recorded source (--force, keeps config.json), then refreshes the plugin list automatically",pluginUninstallHint:"Runs pi-harness uninstall in a visible terminal (click again to confirm), then refreshes the list automatically",settingsExtensions:"Extensions",settingsUiPlugins:"UI plugins",noUiPlugins:"No UI plugins installed (<dataDir>/plugins/)",uiPluginNoSource:"Installed manually — no recorded source, online update unavailable",uiPluginPerms:"Permissions",pluginSettingsSave:"Save plugin settings",pluginSettingsSaving:"Saving…",pluginSettingsReset:"Reset defaults",settingsEnabled:"Enabled",settingsDisabled:"Disabled",saveAsPreset:"Save as preset",applyPreset:"Apply",deletePreset:"Delete preset",noSkills:"No skills",noExtensions:"No extensions",noPresets:"No presets yet (tune the settings above, then save them as a preset)",loadingSession:"Loading session…",connectingServer:"Connecting to pi-harness server…"},Ro=d.createContext(null);function cd(){try{const t=localStorage.getItem(To);if(t==="zh"||t==="en")return t}catch{}return"zh"}function dd({children:t}){const[n,s]=d.useState(cd),r=d.useCallback(o=>{s(o);try{localStorage.setItem(To,o)}catch{}},[]),i=d.useCallback((o,c)=>{let l=ld[o];if(n==="zh"&&(l=od[o]),c)for(const[p,u]of Object.entries(c))l=l.replaceAll(`{${p}}`,String(u));return l},[n]);d.useEffect(()=>{document.documentElement.lang=n==="zh"?"zh-CN":"en"},[n]);const a=d.useMemo(()=>({locale:n,setLocale:r,t:i}),[n,r,i]);return e.jsx(Ro.Provider,{value:a,children:t})}function Qn(){const t=d.useContext(Ro);if(!t)throw new Error("useI18n must be used within LanguageProvider");return t}function nt(){return Qn().t}function Ns({files:t}){if(!t.some(r=>r.counted))return null;const n=t.reduce((r,i)=>r+i.added,0),s=t.reduce((r,i)=>r+i.removed,0);return e.jsxs("span",{className:"change-counts",children:[e.jsxs("span",{className:"add",children:["+",n]}),e.jsxs("span",{className:"del",children:["−",s]})]})}function ca({files:t}){const n=nt(),s=Sr(),[r,i]=d.useState(!1);return!t.length||!s?null:e.jsxs("section",{className:"change-summary",children:[e.jsxs("header",{children:[e.jsx("strong",{children:n("changesSummary",{n:t.length})}),e.jsx(Ns,{files:t}),e.jsx("button",{onClick:()=>s.show(t),children:n("changesViewAll")})]}),(r?t:t.slice(0,6)).map(a=>e.jsxs("button",{className:`change-summary-file ${s.open&&s.selected===a.path?"selected":""}`,onClick:()=>s.show(t,a.path),children:[e.jsx(Ws,{}),e.jsx("code",{children:a.path.split("/").at(-1)}),e.jsx("span",{className:"change-directory",children:a.path.split("/").slice(0,-1).join("/")}),e.jsx(Ns,{files:[a]}),e.jsx(_t,{})]},a.path)),!r&&t.length>6&&e.jsx("button",{className:"changes-more",onClick:()=>i(!0),children:n("changesMore",{n:t.length-6})})]})}let ud=-1e6;function pd({cwd:t,data:n,send:s,notRepo:r,branch:i,branches:a,defaultBase:o,dirty:c,ready:l}){const p=Sr(),u=nt(),[f,k]=d.useState(),[j,I]=d.useState(!1),[E,$]=d.useState(""),[N,R]=d.useState({}),[y,L]=d.useState(new Set),b=d.useRef(0),F=d.useRef(null),B=d.useRef(null),ie=r?"turn":p.scope,Q=`${t}\0${ie}\0${p.base}`;d.useEffect(()=>{if(!p.open||ie==="turn"||!l)return;const M=()=>{const ve=--ud;s({type:"scm_diff",reqId:ve,scope:ie,base:p.base||void 0})&&(b.current=ve)};M();const V=setInterval(M,3e4);return()=>{clearInterval(V),b.current=0}},[p.open,ie,p.base,t,c,l,s]),d.useEffect(()=>{(n==null?void 0:n.type)!=="scm_data"||n.kind!=="diff"||n.reqId!==b.current||n.cwd!==t||k({key:Q,files:n.ok?Tc(n.text??""):[],error:n.error,base:n.base,omittedUntracked:n.omittedUntracked,reducedContext:n.reducedContext})},[n,Q,t]);const q=ie==="turn"?p.files:(f==null?void 0:f.key)===Q?f.files:[],ke=ie!=="turn"&&(f==null?void 0:f.key)!==Q,Re=d.useMemo(()=>E.trim()?q.filter(M=>M.path.toLowerCase().includes(E.toLowerCase())||M.lines.some(V=>V.text.toLowerCase().includes(E.toLowerCase()))):q,[q,E]),O=M=>N[M.path]??M.lines.filter(V=>V.marker!==" ").length>400,_e=M=>{p.set({selected:M}),R(V=>({...V,[M]:!1})),requestAnimationFrame(()=>{var V,ve;return(ve=Array.from(((V=F.current)==null?void 0:V.querySelectorAll("[data-change-file]"))??[]).find(ye=>ye.dataset.changeFile===M))==null?void 0:ve.scrollIntoView({block:"start"})})};return d.useEffect(()=>{p.open&&($(""),p.selected?_e(p.selected):p.focusRequest>0&&(R(Object.fromEntries(q.map(M=>[M.path,!1]))),q[0]&&_e(q[0].path)))},[p.focusRequest,p.open]),d.useEffect(()=>{var M;j&&((M=B.current)==null||M.focus())},[j]),p.open?e.jsxs("aside",{className:"changes-panel","aria-label":u("changesTitle"),tabIndex:0,onKeyDown:M=>{var ve,ye,oe;const V=M.target;if((M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="f")M.preventDefault(),M.stopPropagation(),I(!0);else if(M.key==="Escape")M.preventDefault(),M.stopPropagation(),j?(I(!1),$(""),M.currentTarget.focus()):(ve=document.querySelector(".inputbox textarea"))==null||ve.focus();else if(!V.closest("input,textarea,select")&&!M.metaKey&&!M.ctrlKey&&["j","k"].includes(M.key.toLowerCase())){M.preventDefault();const Fe=Array.from(((ye=F.current)==null?void 0:ye.querySelectorAll("[data-change-hunk]"))??[]),U=((oe=F.current)==null?void 0:oe.getBoundingClientRect().top)??0,ce=(M.key.toLowerCase()==="j"?Fe:Fe.slice().reverse()).find(ae=>M.key.toLowerCase()==="j"?ae.getBoundingClientRect().top>U+45:ae.getBoundingClientRect().top<U+35);ce==null||ce.scrollIntoView({block:"start"})}},children:[e.jsxs("header",{className:"changes-toolbar",children:[e.jsx("button",{title:u("changesList"),"aria-label":u("changesList"),"aria-pressed":p.list,onClick:()=>p.set({list:!p.list}),children:e.jsx(ir,{})}),!r&&e.jsxs("label",{className:"changes-branch",children:[e.jsxs("select",{"aria-label":u("changesBase"),value:p.base||(f==null?void 0:f.base)||o||"",onChange:M=>p.set({base:M.target.value}),children:[e.jsx("option",{value:"",children:u("changesBase")}),[...new Set([...a.map(M=>M.name),...f!=null&&f.base?[f.base]:[]])].map(M=>e.jsx("option",{children:M},M))]}),e.jsx("span",{children:"→"}),e.jsx("code",{title:i,children:i})]}),!r&&e.jsx("div",{className:"changes-scopes",children:["turn","branch","work"].map(M=>e.jsx("button",{"aria-pressed":ie===M,onClick:()=>{p.set({scope:M}),R({}),L(new Set)},children:u(M==="turn"?"changesTurn":M==="branch"?"changesBranch":"changesWork")},M))}),e.jsx("button",{title:u("changesSearch"),"aria-label":u("changesSearch"),onClick:()=>I(!j),children:e.jsx(ts,{})}),e.jsx("button",{title:u("changesExpand"),"aria-label":u("changesExpand"),onClick:()=>{const M=q.some(V=>!O(V));R(Object.fromEntries(q.map(V=>[V.path,M])))},children:e.jsx(nd,{})}),e.jsx("button",{title:`${u("close")} (⌘D)`,"aria-label":u("close"),onClick:()=>p.set({open:!1}),children:e.jsx(qt,{})})]}),j&&e.jsxs("div",{className:"changes-search",children:[e.jsx(ts,{}),e.jsx("input",{ref:B,value:E,placeholder:u("changesSearch"),"aria-label":u("changesSearch"),onChange:M=>$(M.target.value)}),e.jsxs("span",{children:[Re.length," / ",q.length]})]}),e.jsxs("div",{className:"changes-content",children:[p.list&&e.jsxs("nav",{className:"changes-files","aria-label":u("changesList"),children:[e.jsxs("header",{children:[u("changesFiles",{n:q.length}),e.jsx(Ns,{files:q})]}),Re.map(M=>e.jsxs("button",{className:p.selected===M.path?"selected":"",onClick:()=>_e(M.path),children:[e.jsx("code",{children:M.path.split("/").at(-1)}),e.jsxs("span",{children:[e.jsx("span",{className:"change-directory",children:M.path.split("/").slice(0,-1).join("/")||"."}),e.jsx(Ns,{files:[M]})]})]},M.path))]}),e.jsxs("div",{className:"changes-diffs",ref:F,onScroll:()=>{var ye;const M=F.current.getBoundingClientRect().top,ve=(ye=Array.from(F.current.querySelectorAll("[data-change-file]")).find(oe=>oe.getBoundingClientRect().bottom>M+40))==null?void 0:ye.dataset.changeFile;ve&&ve!==p.selected&&p.set({selected:ve})},children:[!ke&&(f==null?void 0:f.key)===Q&&ie!=="turn"&&(f.reducedContext||f.omittedUntracked)?e.jsx("p",{className:"changes-note",role:"status",children:[f.reducedContext?u("changesReducedContext"):"",f.omittedUntracked?u("changesOmittedUntracked",{n:f.omittedUntracked}):""].filter(Boolean).join(" ")}):null,ke?e.jsx("p",{className:"changes-empty",children:u("changesLoading")}):(f==null?void 0:f.key)===Q&&f.error&&ie!=="turn"?e.jsx("p",{className:"changes-empty",role:"alert",children:f.error}):!Re.length&&e.jsx("p",{className:"changes-empty",children:u("changesEmpty")}),Re.map(M=>e.jsx(hd,{file:M,selected:p.selected===M.path,collapsed:O(M),toggle:()=>{p.set({selected:M.path}),R(V=>({...V,[M.path]:!O(M)}))},gaps:y,expandGap:V=>L(ve=>new Set([...ve,V])),query:E},M.path))]})]})]}):null}function hd({file:t,selected:n,collapsed:s,toggle:r,gaps:i,expandGap:a,query:o}){var N,R;const c=nt(),l=Sr(),p=()=>l==null?void 0:l.set({open:!1}),[u,f]=d.useState(!!((N=t.toolIds)!=null&&N.length));d.useEffect(()=>{const y=setTimeout(()=>f(!1),3e3);return()=>clearTimeout(y)},[]);const k=((R=t.toolIds)==null?void 0:R.join(","))??"",j=d.useRef(k);d.useEffect(()=>{if(j.current===k)return;j.current=k,f(!0);const y=setTimeout(()=>f(!1),3e3);return()=>clearTimeout(y)},[k]);const I=d.useMemo(()=>{var L,b;const y=new Map;for(let F=0;F<t.lines.length;){if(t.lines[F].marker!=="-"){F++;continue}const B=F;for(;((L=t.lines[F])==null?void 0:L.marker)==="-";)F++;const ie=F;for(;((b=t.lines[F])==null?void 0:b.marker)==="+";)F++;for(let Q=0;Q<Math.min(ie-B,F-ie);Q++)y.set(B+Q,t.lines[ie+Q].text),y.set(ie+Q,t.lines[B+Q].text)}return y},[t.lines]),E=y=>{const L=t.lines[y],b=L.marker==="+"?"add":L.marker==="-"?"del":"context",F=I.get(y),B=F===void 0?[{text:L.text,changed:!1}]:Rc(L.text,F);return e.jsxs("div",{className:`changes-line ${b}${o&&L.text.toLowerCase().includes(o.toLowerCase())?" search-match":""}`,"data-change-hunk":L.marker!==" "&&(y===0||t.lines[y-1].marker===" ")?"":void 0,children:[e.jsx("span",{className:"changes-line-number",children:L.newLine??L.oldLine}),e.jsx("span",{className:"changes-line-sign",children:L.marker}),e.jsx("code",{className:/^#{1,6} /.test(L.text)?"markdown-heading":"",children:B.map((ie,Q)=>ie.changed?e.jsx("mark",{children:ie.text},Q):ie.text)})]},y)},$=t.lines.find(y=>y.marker!==" ");return e.jsxs("section",{className:`changes-file ${n?"selected":""}`,"data-change-file":t.path,children:[e.jsxs("header",{className:"changes-file-head",children:[e.jsxs("button",{"aria-expanded":!s,onClick:r,children:[s?e.jsx(_t,{}):e.jsx(nn,{}),e.jsx("code",{title:t.path,children:t.oldPath&&t.oldPath!==t.path?`${t.oldPath} → ${t.path}`:t.path.split("/").at(-1)}),e.jsx("span",{className:"change-directory",children:t.path.split("/").slice(0,-1).join("/")}),e.jsx(Ns,{files:[t]}),u&&e.jsx("span",{className:"changes-recent",title:c("changesRecent"),children:"●"})]}),e.jsxs("button",{className:"changes-open-file",title:c("changeOpen"),onClick:()=>{p(),window.dispatchEvent(new CustomEvent("pi-harness:open-tool-file",{detail:{path:t.path,line:($==null?void 0:$.newLine)??($==null?void 0:$.oldLine)??1}}))},children:[c("changeOpen")," ",e.jsx(wo,{})]})]}),s&&t.lines.filter(y=>y.marker!==" ").length>400&&e.jsx("button",{className:"changes-gap",onClick:r,children:c("changesLarge")}),!s&&(t.binary?e.jsx("p",{className:"changes-empty",children:c("changesBinary")}):e.jsxs("div",{className:"changes-file-lines",children:[!t.lines.length&&e.jsx("p",{className:"changes-meta",children:c("changesUnavailable")}),t.unlocated&&e.jsx("p",{className:"changes-meta",children:c("changesUnlocated")}),Ic(t.lines).map(y=>y.kind==="line"?E(y.index):i.has(`${t.path}:${y.start}`)||o?Array.from({length:y.end-y.start},(L,b)=>E(y.start+b)):e.jsx("button",{className:"changes-gap",onClick:()=>a(`${t.path}:${y.start}`),children:c(y.end===t.lines.length?"changesTrailing":"changesUnchanged",{n:y.end-y.start})},`gap:${y.start}`)),t.truncated&&e.jsx("p",{className:"changes-meta",children:c("changesTruncated")})]}))]})}const md="你上一条回复里的工具调用是以普通文本输出的,没有被执行。请通过工具调用(不要写成文本)重新发起它,然后继续完成任务。";function Yr(t){let n;return t.split(`
|
|
20
|
-
`).map(r=>{const i=/^ {0,3}(`{3,}|~{3,})(.*)$/.exec(r),a=!!n||!!i;return i&&(n?i[1][0]===n.marker&&i[1].length>=n.length&&!i[2].trim()&&(n=void 0):n={marker:i[1][0],length:i[1].length}),a?r.replace(/</g,"\0"):r}).join(`
|
|
21
|
-
`).replace(/(`+)([\s\S]*?)\1(?!`)/g,r=>r.replace(/</g,"\0"))}const Jn="(?:[||]DSML[||])?",fd=new RegExp(`<${Jn}invoke\\s+name=["']([\\w.-]+)["']\\s*>`,"g"),Io=`<${Jn}parameter\\s+name=["'][\\w.-]+["'][^>]*>[\\s\\S]*?<\\/${Jn}parameter>`,Lo=`(?:<\\/${Jn}(?:tool_calls|function_calls)>\\s*)?`,gd=new RegExp(`(?:${Io}\\s*)+<\\/${Jn}invoke>\\s*${Lo}$`),xd=new RegExp(`(?:<${Jn}(?:tool_calls|function_calls)>\\s*)?<${Jn}invoke\\s+name=["'][\\w.-]+["']\\s*>`);function bi(t){var c;const n=Yr(t),s=xd.exec(n);if(s){const l=n.slice(s.index),p=new RegExp(`<\\/${Jn}invoke>\\s*${Lo}$`).test(l),u=[...l.matchAll(new RegExp(`<${Jn}invoke\\s+name=["']([\\w.-]+)["']\\s*>([\\s\\S]*?)<\\/${Jn}invoke>`,"g"))];if(p&&u.length&&u.every(f=>new RegExp(Io).test(f[2])))return{before:t.slice(0,s.index).trimEnd(),raw:t.slice(s.index).trim(),tools:[...new Set(u.map(f=>f[1]))]}}const r=gd.exec(t);if(!r)return null;const i=[...t.matchAll(fd)],a=((c=i.find(l=>l.index!==void 0&&l.index<r.index))==null?void 0:c.index)??r.index,o=Math.min(a,r.index);return{before:t.slice(0,o).trimEnd(),raw:t.slice(o).trim(),tools:[...new Set(i.map(l=>l[1]))]}}function vd(t,n){const s=t[n],r=t[n-1];if((s==null?void 0:s.role)!=="user"||s.content.length!==1||s.content[0].type!=="text"||s.content[0].text!==md||(r==null?void 0:r.role)!=="assistant"||r.stopReason==="aborted"||r.stopReason==="error"||r.content.some(a=>a.type==="toolCall"))return!1;const i=r.content.map(a=>a.type==="text"?a.text:"").join(`
|
|
22
|
-
`);return!!bi(i)}const da=new WeakMap;function kd(t){const n=da.get(t);if(n)return n;const s=t.content.map(i=>i.type==="text"?i.text:"").join(`
|
|
23
|
-
`),r={text:s,leak:bi(s)};return da.set(t,r),r}function Ms(t,n=!1){const s=[];let r,i,a=!1;for(const[o,c]of t.entries()){if(c.role==="user"){i&&vd(t,o)?(i.reminders.push(c),i.state="reminding",a=!1):(r=c,i=void 0,a=!1);continue}if(c.role!=="assistant"||!r)continue;if(c.content.some(k=>k.type==="toolCall")){i&&(i.state="recovered"),a=!0;continue}const{text:p,leak:u}=kd(c),f=c.stopReason==="aborted"||c.stopReason==="error";u&&!f&&!i&&(i={incidentId:`tool-text:${r.entryId??r.id}:${c.entryId??c.id}`,user:r,first:c,last:c,reminders:[],leaks:[],outputs:[],state:"stopped"},s.push(i)),i&&(!u&&!i.reminders.length&&(i.state="recovered"),u&&i.leaks.push(c),(u||i.reminders.length&&!a)&&(i.last=c,i.outputs.push({message:c,raw:i.reminders.length?p:(u==null?void 0:u.raw)??p,attempt:i.reminders.length}),i.state=f?"recovered":"stopped"))}return i&&i.state!=="recovered"&&(i.state=n?"reminding":"stopped"),{incidents:s,current:i}}const ua=new WeakMap;function yd(t){const n=new Map;for(const s of Ms(t).incidents){for(const r of s.outputs)n.set(r.message.id,{toolText:{incidentId:s.incidentId,attempt:r.attempt}});s.reminders.forEach((r,i)=>n.set(r.id,{origin:"auto-reminder",toolText:{incidentId:s.incidentId,attempt:i+1}}))}return t.map(s=>{const r=n.get(s.id);if(!r)return s;const i=JSON.stringify(r),a=ua.get(s);if((a==null?void 0:a.key)===i)return a.message;const o={...s,...r};return ua.set(s,{key:i,message:o}),o})}function wd(t,n=!1){const{current:s}=Ms(t,n);return!n&&(s==null?void 0:s.state)==="stopped"?{message:s.last,user:s.user}:null}function pa(t,n,s){let r=!1;for(const i of n){const a=i;if(a.type!=="image"||typeof a.dataUrl!="string"||!a.dataUrl.startsWith("data:"))continue;const o=a.dataUrl.match(/^data:([^;]*);base64,(.+)$/);o&&(r=!0,t.push({path:"",imageData:o[2],mimeType:o[1]||"image/png",name:s??`image.${(o[1]||"image/png").split("/")[1]??"png"}`}))}return r}function Mo(t){var s;const n=new Map;for(let r=0;r<t.length;r++){const i=t[r];if(i.role!=="user"||!i.id)continue;const a=(i.userAttachments??[]).map(o=>({path:o.path,mode:o.mode,nativeRef:o.nativeRef}));pa(a,i.content);for(let o=r+1;o<t.length&&t[o].role==="custom"&&t[o].customType==="file";o++){if((s=t[o].userAttachments)!=null&&s.length){a.push(...t[o].userAttachments.map(l=>({path:l.path,mode:l.mode,nativeRef:l.nativeRef})));continue}const c=t[o].details??{};if(!pa(a,t[o].content,c.name)){if(c.upload&&c.path){a.push({path:"",uploadPath:c.path,name:c.name??c.path,size:c.size});continue}if(c.path&&c.mode){const l=c.mode==="inline"||c.mode==="lines"?c.mode:"reference",p={path:c.path,mode:l,...c.editorSnapshot?{editorSnapshot:c.editorSnapshot}:{}};c.mode==="lines"&&typeof c.startLine=="number"&&typeof c.endLine=="number"&&(p.lines={start:c.startLine,end:c.endLine}),a.push(p)}}}a.length>0&&n.set(i.id,a)}return n}const bd=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Es(t){var s;const n=t.match(bd);return n?{name:n[1],location:n[2],content:n[3],userMessage:((s=n[4])==null?void 0:s.trim())||void 0}:null}function cs(t){const n=Es(t);return n?`skill:${n.name}`+(n.userMessage?` · ${n.userMessage.replace(/\s+/g," ").trim()}`:""):t.replace(/\s+/g," ").trim()}function tr(t){if(Es(t))return cs(t);const n=/^<skill name="([^"]+)" location="[^"]+">\r?\n/.exec(t);return n&&!t.includes("</skill>")?`skill:${n[1]}`:t}function Qt(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let s=0;s<16;s++)t[s]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const n=[...t].map(s=>s.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function jd(t,n,s){var f,k,j,I;const r=((f=t.state)==null?void 0:f.conversationId)===t.activeConversationId?t.state:null,i=r&&wd(r.messages,r.isStreaming),a=d.useRef(null),[o,c]=d.useState(!1),l=!!r&&t.ready&&!r.isStreaming&&!((k=r.tree)!=null&&k.busy)&&!((j=r.tree)!=null&&j.verifying)&&!((I=r.tree)!=null&&I.externallyModified)&&!Object.values(r.recovery??{}).some(Boolean),p=d.useRef({state:r,failure:i,writable:l,send:n,onError:s});p.current={state:r,failure:i,writable:l,send:n,onError:s};const u=()=>{a.current=null,c(!1)};return d.useEffect(()=>{var $,N,R;const E=a.current;if(E){if(!t.ready||(r==null?void 0:r.conversationId)!==E.conversation||(r==null?void 0:r.sessionFile)!==E.session){u();return}if((($=t.promptResult)==null?void 0:$.requestId)===E.requestId){u();return}if(!E.sent){if(!l||(i==null?void 0:i.user.id)!==E.source){u();return}E.modelId&&`${(N=r.model)==null?void 0:N.provider}/${(R=r.model)==null?void 0:R.id}`!==E.modelId||(E.sent=!0,n({type:"prompt",text:E.text,attachments:E.attachments,requestId:E.requestId})||(u(),s()))}}},[r,t.ready,t.promptResult,l,i,n,s]),d.useEffect(()=>{if(!o)return;const E=window.setTimeout(()=>{a.current&&(a.current=null,c(!1),p.current.onError())},3e4);return()=>window.clearTimeout(E)},[o]),{messageId:i==null?void 0:i.message.id,currentModelId:r!=null&&r.model?`${r.model.provider}/${r.model.id}`:void 0,disabled:!l||o,retry:E=>{var B,ie;const{state:$,failure:N,writable:R,send:y}=p.current;if(!$||!N||!R||a.current)return;const L=N.user.questionText??N.user.content.map(Q=>Q.type==="text"&&typeof Q.text=="string"?Q.text:"").join(`
|
|
24
|
-
`),b=Es(L),F=b?`/skill:${b.name}${b.userMessage?` ${b.userMessage}`:""}`:L;F.trim()&&(a.current={conversation:$.conversationId,session:$.sessionFile,source:N.user.id,modelId:E,text:F,attachments:Mo($.messages).get(N.user.id)??[],requestId:Qt(),sent:!1},c(!0),E&&`${(B=$.model)==null?void 0:B.provider}/${(ie=$.model)==null?void 0:ie.id}`!==E&&!y({type:"set_model",modelId:E})&&(u(),p.current.onError()))}}}const Po="pi-harness:token";function Cd(){try{const t=new URL(window.location.href),n=t.searchParams.get("token");n&&(localStorage.setItem(Po,n.trim()),t.searchParams.delete("token"),window.history.replaceState(null,"",t.toString()))}catch{}}function Sd(){try{return localStorage.getItem(Po)??""}catch{return""}}function Sn(t){const n=Sd();return n?`${t}${t.includes("?")?"&":"?"}token=${encodeURIComponent(n)}`:t}function Nr({url:t}){const n=nt(),[s,r]=d.useState(!1),[i,a]=d.useState(),[o,c]=d.useState();d.useEffect(()=>{c(void 0),a(void 0)},[t]);const l=f=>{a(f)},p=async(f,k="tool-output.txt")=>{r(!0),a(void 0);try{const j=await fetch(Sn(t+(f?`&outputId=${encodeURIComponent(f)}`:"")));if(!j.ok){l(j.status);return}const I=j.headers.get("content-disposition")??"",E=I.match(/filename\*=UTF-8''([^;]+)/i),$=I.match(/filename="([^"]+)"/),N=E?decodeURIComponent(E[1]):($==null?void 0:$[1])??k,R=URL.createObjectURL(await j.blob()),y=document.createElement("a");y.href=R,y.download=N,y.click(),setTimeout(()=>URL.revokeObjectURL(R),1e3)}catch{l(500)}finally{r(!1)}},u=async()=>{r(!0),a(void 0);try{const f=await fetch(Sn(t.replace("/api/tool-output?","/api/tool-output-list?")));if(!f.ok){l(f.status);return}const k=await f.json();k.length?k.length===1&&k[0].default?await p(k[0].id,k[0].name):c(k):await p()}catch{l(500)}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",disabled:s,onClick:()=>void u(),children:n("toolOutputDownload")}),o&&e.jsxs("span",{className:"tool-output-files",children:[e.jsx("button",{disabled:s,onClick:()=>void p(),children:n("toolOutputText")}),o.map(f=>e.jsx("button",{disabled:s,onClick:()=>void p(f.id,f.name),children:f.name},f.id))]}),i&&e.jsx("span",{role:"alert",children:n(i===404?"toolOutputUnavailable":i===401?"toolOutputAuth":i===403?"toolOutputDenied":"toolOutputError")})]})}function ha(t,n=performance.now()){return t&&{...t,retry:t.retry?{...t.retry,deadline:n+Math.max(0,t.retry.remainingMs??0)}:void 0,summary:t.summary?{...t.summary,deadline:n+Math.max(0,t.summary.remainingMs??0)}:void 0}}function Nd(t){window.dispatchEvent(new CustomEvent("pi-tree-response",{detail:t}))}function ma(){window.dispatchEvent(new Event("pi-tree-open"))}function fa(t,n){window.dispatchEvent(new CustomEvent("pi-tree-navigate",{detail:{conversationId:t,targetId:n}}))}const qs=new Map,Ds=new Set;function ga(t){var s;if(!t.text&&!((s=t.images)!=null&&s.length)||Ds.has(t.id))return;Ds.add(t.id),Ds.size>256&&Ds.delete(Ds.values().next().value);const n=qs.get(t.conversationId)??[];n.some(r=>r.id===t.id)||n.push(t),qs.set(t.conversationId,n),window.dispatchEvent(new Event("pi-tree-draft"))}function Ed(t){var n;return(n=qs.get(t))==null?void 0:n[0]}function xa(t,n){var r;const s=qs.get(t);((r=s==null?void 0:s[0])==null?void 0:r.id)===n&&s.shift(),s!=null&&s.length||qs.delete(t),window.dispatchEvent(new Event("pi-tree-draft"))}const dr=new Map,va=new Set;function Td(t){dr.delete(t)}function Rd(t){va.has(t.id)||(va.add(t.id),dr.set(t.conversationId,t),window.dispatchEvent(new Event("pi-extension-editor")))}function Ao(t,n,s){d.useEffect(()=>{if(!n)return;const r=()=>{const i=dr.get(t);i&&(dr.delete(t),s(i.text))};return r(),window.addEventListener("pi-extension-editor",r),()=>window.removeEventListener("pi-extension-editor",r)},[t,n,s])}const Ar=2e5;function Id(t,n){const s=n.replace?n.delta:t+n.delta;return s.length>Ar?`…[前 ${s.length-Ar} 字符已省略]…
|
|
25
|
-
${s.slice(-Ar)}`:s}class Ld{constructor(n=3,s=32*1024*1024){Lr(this,"entries",new Map);Lr(this,"bytes",0);this.limit=n,this.budget=s}get(n){const s=this.entries.get(n);if(s)return this.entries.delete(n),this.entries.set(n,s),s.value}set(n,s){this.delete(n);const r=JSON.stringify(s).length*2;if(!(r>this.budget))for(this.entries.set(n,{value:s,bytes:r}),this.bytes+=r;this.entries.size>this.limit||this.bytes>this.budget;)this.delete(this.entries.keys().next().value)}delete(n){var s;this.bytes-=((s=this.entries.get(n))==null?void 0:s.bytes)??0,this.entries.delete(n)}}const xt=window.electronAPI,Xr=new Set;function Md(t){return Xr.add(t),()=>{Xr.delete(t)}}async function Pd(){return(await Promise.allSettled([...Xr].map(n=>n()))).every(n=>n.status==="fulfilled"&&n.value)}function Ad(t,n){const s=n.assistantMessageEvent,r=t.stats.tokens,i=n.usage!==null?{...r,...n.usage}:r,a=i===r?t.stats:{...t.stats,tokens:i};if(s.type!=="text_delta"&&s.type!=="thinking_delta")return a===t.stats?t:{...t,stats:a};const o=s.delta??"";if(!o)return a===t.stats?t:{...t,stats:a};const c=t.streamingMessage??null,l=c&&c.id===n.messageId?c:{id:n.messageId,content:[]},p=[...l.content],u=s.type==="thinking_delta"?"thinking":"text",f=s.contentIndex??p.length-1;return f>=0&&f<p.length&&p[f].type===u?p[f]=u==="thinking"?{...p[f],type:"thinking",thinking:(p[f].thinking??"")+o}:{type:"text",text:(p[f].text??"")+o}:p.push(u==="thinking"?{type:"thinking",thinking:o}:{type:"text",text:o}),{...t,stats:a,streamingMessage:{...l,id:n.messageId,content:p}}}const Zr="pi-harness:plugin-data";function Dd(t,n){window.dispatchEvent(new CustomEvent(Zr,{detail:{pluginId:t,payload:n}}))}function $d(t){const n=s=>{const r=s.detail;t(r.pluginId,r.payload)};return window.addEventListener(Zr,n),()=>window.removeEventListener(Zr,n)}const ks=new Map,ei=new Set,vs=new Set;let ka=-1;function Do(){return[...ks.values()]}function Fd(){const t=Do();for(const n of ei)n(t)}function Od(t){return ei.add(t),t(Do()),()=>ei.delete(t)}async function _d(t,n){n!==ka&&(ka=n,ks.clear(),vs.clear());const s=new Set(t.map(r=>r.id));for(const r of[...ks.keys()])s.has(r)||ks.delete(r);for(const r of[...vs])s.has(r)||vs.delete(r);await Promise.all(t.filter(r=>r.hasClient&&!r.error&&!ks.has(r.id)&&!vs.has(r.id)).map(async r=>{try{const a=(await Cr(()=>import(`/plugins/${encodeURIComponent(r.id)}/client/entry.mjs?e=${n}`),[])).default;a&&typeof a.mount=="function"?ks.set(r.id,{info:r,module:a}):(vs.add(r.id),console.error(`[plugin:${r.id}] entry.mjs 缺少 default.mount`))}catch(i){vs.add(r.id),console.error(`[plugin:${r.id}] 客户端加载失败:`,i)}})),Fd()}function Hd(t,n){return{pluginId:t,send:s=>n({type:"plugin_message",pluginId:t,payload:s}),onData:s=>$d((r,i)=>{r===t&&s(i)})}}const Bd=41,$o="pi-harness:reload-events";function Ud(){try{const t=JSON.parse(sessionStorage.getItem($o)??"[]");return Array.isArray(t)?t.filter(n=>n&&typeof n=="object"&&n.type==="reload_status"&&typeof n.conversationId=="string"&&typeof n.requestId=="string"&&(n.phase==="running"||n.phase==="done")&&typeof n.timestamp=="number").slice(-40):[]}catch{return[]}}const Wd=2e5;function qd(){const t=new Map,n=new Map,s=(r,i)=>`${r}:${i}`;return{write(r,i,a){const o=s(r,i),c=t.get(o);if(c&&c.size>0){for(const u of c)try{u.write(a)}catch{}return}const l=n.get(o)??"",p=l.length+a.length>Wd?a:l+a;n.set(o,p)},register(r,i,a){const o=s(r,i);let c=t.get(o);c||(c=new Set,t.set(o,c)),c.add(a);const l=n.get(o);if(l){try{a.write(l)}catch{}n.delete(o)}return()=>{const p=t.get(o);p&&(p.delete(a),p.size===0&&t.delete(o)),n.delete(o)}},clear(){t.clear(),n.clear()}}}function ya(t,n){const s=new Set;for(const i of n.messages)i.role==="toolResult"&&i.toolCallId&&s.add(i.toolCallId),i.role==="bashExecution"&&s.add(`bash-${i.id}`);let r=!1;for(const i of t.keys())s.has(i)&&(t.delete(i),r=!0);return r?new Map(t):t}function wa(t,n){var a;if(t.size===0)return t;const s=new Set;for(const o of n.messages)o.role==="toolResult"&&o.toolCallId&&s.add(o.toolCallId);const r=new Set(n.messages.flatMap(o=>o.content.flatMap(c=>c.type==="toolCall"&&typeof c.id=="string"?[c.id]:[])));for(const o of((a=n.streamingMessage)==null?void 0:a.content)??[])o.type==="toolCall"&&typeof o.id=="string"&&r.add(o.id);const i=new Map([...t].filter(([o,c])=>c.conversationId!==n.conversationId||c.parentToolCallId&&s.has(c.parentToolCallId)?!1:c.toolName==="bash"&&c.durationMs!==void 0?r.has(o):!s.has(o)));return i.size===t.size?t:i}function zd(t,n){var s,r,i,a,o,c,l,p;switch(n.type){case"status":return{...t,status:n.status,pendingDialogs:n.status==="closed"?[]:t.pendingDialogs,extensionUi:n.status==="closed"?{}:t.extensionUi,ready:n.status==="open"?t.ready:!1,agentSilence:n.status==="closed"?null:t.agentSilence,agentSilenceByConversation:n.status==="closed"?{}:t.agentSilenceByConversation,terminals:n.status==="closed"?[]:t.terminals};case"ready":return{...t,serverVersion:n.serverVersion,ready:!0,protocolMismatch:n.protocolVersion!==void 0&&n.protocolVersion!==Bd};case"snapshot":return{...t,ready:!0,state:n.state,...((s=t.state)==null?void 0:s.cwd)!==n.state.cwd?{sessions:[],files:null,conversationFilesChecked:null,fileContent:null,scmData:null,scmDiffData:null}:{},activeConversationId:n.state.conversationId,agentSilence:n.state.isStreaming?t.agentSilenceByConversation[n.state.conversationId]??null:null,liveOutputs:ya(t.liveOutputs,n.state),toolStatuses:wa(t.toolStatuses,n.state),pendingEcho:null};case"snapshot_delta":{const u=t.state,f=n.msg;if(!u||u.conversationId!==f.conversationId||u.rev!==f.baseRev)return t;const k={...u,...f.state,messages:f.appended.length>0?[...u.messages,...f.appended]:u.messages};return{...t,ready:!0,state:k,agentSilence:k.isStreaming?t.agentSilenceByConversation[k.conversationId]??null:null,activeConversationId:k.conversationId,liveOutputs:ya(t.liveOutputs,k),toolStatuses:wa(t.toolStatuses,k),pendingEcho:f.appended.length>0?null:t.pendingEcho}}case"tool_delta":{const u=t.liveOutputs.get(n.toolCallId),f=Id((u==null?void 0:u.text)??"",n),k=new Map(t.liveOutputs);return k.set(n.toolCallId,{toolName:n.toolName,text:f,codemode:n.codemode??(u==null?void 0:u.codemode)}),{...t,liveOutputs:k}}case"message_delta":{const u=t.state;return!u||u.conversationId!==n.msg.conversationId?t:{...t,state:Ad(u,n.msg)}}case"tool_status":return n.status.conversationId&&((r=t.state)==null?void 0:r.conversationId)!==n.status.conversationId?t:{...t,toolStatuses:new Map(t.toolStatuses).set(n.status.toolCallId,{...t.toolStatuses.get(n.status.toolCallId),...n.status})};case"notice":return{...t,notices:[...t.notices,n.notice].slice(-6)};case"agent_silence":{const u={...t.agentSilenceByConversation};return n.event.phase==="active"?delete u[n.event.conversationId]:u[n.event.conversationId]=n.event,{...t,agentSilenceByConversation:u,agentSilence:u[t.activeConversationId]??null}}case"reload_status":{const u=t.reloadEvents.findIndex(k=>k.requestId===n.event.requestId&&k.conversationId===n.event.conversationId),f=u<0?[...t.reloadEvents,n.event].slice(-40):t.reloadEvents.map((k,j)=>j===u?n.event:k);return{...t,reloadEvents:f}}case"dismiss_notice":return{...t,notices:t.notices.filter(u=>u.id!==n.id)};case"set_pending_echo":return{...t,pendingEcho:n.echo};case"clear_pending_echo":return{...t,pendingEcho:null};case"sessions":return{...t,sessions:n.sessions};case"conversations":return{...t,conversations:n.conversations,activeConversationId:n.activeId};case"projects":return{...t,projects:n.projects};case"dir_browse":return{...t,dirBrowse:n.dirBrowse};case"git_branch":return{...t,gitBranch:n.data};case"files":return{...t,files:n.files};case"conversation_files_checked":return{...t,conversationFilesChecked:n.result};case"file_changed":return{...t,fileChanged:{path:n.path}};case"prompt_result":return{...t,promptResult:n.result};case"file_result":return{...t,fileResult:n.result};case"file_content":return{...t,fileContent:n.content};case"models":return{...t,models:n.models,modelsLoading:n.loading};case"models_config":return{...t,modelsConfig:n.providers};case"provider_auth":return{...t,providerAuth:n.state};case"providers_status":return{...t,providers:n.providers};case"fetch_models_result":return{...t,fetchModelsResult:n.result};case"refresh_provider_result":return{...t,refreshProviderResult:n.result};case"clone_provider_result":return{...t,cloneProviderResult:n.result};case"install_result":return{...t,installResult:n.result};case"scm_data":return{...t,scmData:n.data,...n.data.type==="scm_data"&&n.data.kind==="diff"?{scmDiffData:n.data}:{}};case"file_search_result":return{...t,fileSearch:n.result};case"scm_changed":return{...t,scmDirty:t.scmDirty+1};case"path_completions":return{...t,pathCompletions:n.completions};case"component_updates_start":return{...t,componentUpdates:{type:"component_updates",requestId:n.requestId,cwd:n.cwd,phase:n.updating?"updating":"checking",items:n.updating&&((i=t.componentUpdates)==null?void 0:i.cwd)===n.cwd?t.componentUpdates.items:[]}};case"component_updates":return((a=t.componentUpdates)==null?void 0:a.requestId)!==n.result.requestId?t:{...t,componentUpdates:{...n.result,items:n.result.items.length?n.result.items:t.componentUpdates.items}};case"update_status":return{...t,update:n.status};case"extension_ui":{const u=n.message;return u.type==="dialog"?{...t,pendingDialogs:[...t.pendingDialogs.filter(f=>f.id!==u.id),u]}:u.type==="dialog_closed"?{...t,pendingDialogs:t.pendingDialogs.filter(f=>f.id!==u.id||f.conversationId!==u.conversationId)}:{...t,extensionUi:{...t.extensionUi,[u.conversationId]:{...t.extensionUi[u.conversationId],...u.type==="widgets"?{widgets:u.widgets}:u.type==="statuses"?{statuses:u.statuses}:{title:u.title}}}}}case"commands":return{...t,commands:n.commands,commandsPath:n.path};case"slash_commands":return{...t,slashCommands:n.commands};case"settings":return{...t,settings:n.settings};case"bg_servers":return{...t,bgServers:n.servers};case"plugins":return{...t,plugins:n.plugins,pluginsEpoch:n.epoch};case"terminal_add":return{...t,terminals:[...t.terminals,n.meta]};case"terminal_remove":return{...t,terminals:t.terminals.filter(u=>u.id!==n.id)};case"terminal_exit":return n.conversationId&&(t.activeConversationId||(o=t.state)!=null&&o.conversationId)&&n.conversationId!==(t.activeConversationId||((c=t.state)==null?void 0:c.conversationId))?t:{...t,terminals:t.terminals.map(u=>u.id===n.terminalId?{...u,running:!1,exitCode:n.exitCode}:u)};case"terminal_restart":return{...t,terminals:t.terminals.map(u=>u.id===n.terminalId?{...u,running:!0,exitCode:null}:u)};case"terminal_list":return n.conversationId&&(t.activeConversationId||(l=t.state)!=null&&l.conversationId)&&n.conversationId!==(t.activeConversationId||((p=t.state)==null?void 0:p.conversationId))?t:{...t,terminals:n.terminals.map(u=>{var f;return{...u,conversationId:n.conversationId??((f=t.state)==null?void 0:f.conversationId)??""}})};default:return t}}const Dr="pi-web-client-id";let $r=null;function fn(){if($r)return $r;let t=(xt==null?void 0:xt.clientId)??null;try{t&&sessionStorage.setItem(Dr,t),t=t??sessionStorage.getItem(Dr),t||(t=Qt(),sessionStorage.setItem(Dr,t))}catch{t=t??Qt()}return $r=t,t}function Vd(){const t=location.protocol==="https:"?"wss:":"ws:";return Sn(`${t}//${location.host}/ws`)}function Kd(){var Z,W,ge,Ie,Ae,re,we;const t=nt(),n=d.useRef(t);n.current=t;const[s,r]=d.useReducer(zd,{status:"connecting",ready:!1,state:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],agentSilence:null,agentSilenceByConversation:{},sessions:[],conversations:[],activeConversationId:"",projects:[],dirBrowse:null,files:null,conversationFilesChecked:null,gitBranch:null,fileChanged:null,fileContent:null,promptResult:null,fileResult:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],installResult:null,pathCompletions:[],update:null,componentUpdates:null,providerAuth:null,extensionUi:{},pendingDialogs:[],widgets:[],statuses:[],dialog:null,commands:[],commandsPath:"",slashCommands:[],terminals:[],bgServers:[],settings:null,fetchModelsResult:null,refreshProviderResult:null,cloneProviderResult:null,scmData:null,scmDiffData:null,fileSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,protocolMismatch:!1,pendingEcho:null,reloadEvents:Ud()});d.useEffect(()=>{try{sessionStorage.setItem($o,JSON.stringify(s.reloadEvents))}catch{}},[s.reloadEvents]);const i=d.useRef(s);i.current=s;const a=d.useRef(new Ld),[o,c]=d.useState(null),l=d.useRef(o),p=d.useRef(""),u=d.useRef(!1),[f,k]=d.useState(!1),j=d.useRef(null),[I,E]=d.useState(null);d.useEffect(()=>{var A;o&&j.current===o.id&&((A=s.state)==null?void 0:A.cwd)===p.current&&(l.current=null,c(null))},[s.state,o]),d.useEffect(()=>{if(!(o!=null&&o.display))return;const A=requestAnimationFrame(()=>{performance.clearMeasures("project-switch:cached-content"),performance.measure("project-switch:cached-content","project-switch:click")});return()=>cancelAnimationFrame(A)},[o]);const $=d.useRef(null),N=d.useRef(qd()),R=d.useRef(0),y=d.useRef(null),L=d.useRef(!0),b=d.useRef(0),F=d.useRef(0),B=d.useRef(null),ie=d.useRef(new Map),Q=d.useRef(null),q=()=>{Q.current||(Q.current=setTimeout(()=>{Q.current=null;const A=$.current;A&&A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"get_state"}))},300))},ke=(A,xe)=>{var J;const _=ie.current,Se=_.get(A);if(Se!==void 0&&xe!==Se+1){const De=i.current,G=De.activeConversationId||((J=De.state)==null?void 0:J.conversationId);A===G&&q()}_.set(A,xe)},Re=d.useCallback((A,xe)=>{const _=++F.current;r({type:"notice",notice:{id:_,level:A,text:xe}})},[]),O=d.useCallback(A=>{var _,Se;const xe=$.current;if(A.type==="abort"&&(!xe||xe.readyState!==WebSocket.OPEN||!u.current)){const J=(_=i.current.state)==null?void 0:_.conversationId;return J?(B.current=J,!0):!1}if(xe&&xe.readyState===WebSocket.OPEN){if(!u.current&&A.type!=="get_state")return!1;if((A.type==="check_component_updates"||A.type==="update_component")&&r({type:"component_updates_start",requestId:A.requestId,cwd:((Se=i.current.state)==null?void 0:Se.cwd)??"",updating:A.type==="update_component"}),A.type==="set_cwd"){const J=i.current,De=a.current.get(A.path);!l.current&&J.state&&a.current.set(J.state.cwd,{state:J.state,sessions:J.sessions,files:J.files}),E(null);const G=Qt(),Oe={id:G,path:A.path,display:De};l.current=Oe,c(Oe),performance.clearMarks("project-switch:click"),performance.mark("project-switch:click"),A={...A,requestId:G}}else if(l.current&&A.type!=="get_state")return!1;return xe.send(JSON.stringify(A)),!0}return!1},[]),_e=d.useCallback(()=>{if(!L.current)return;r({type:"status",status:"connecting"});const A=new WebSocket(Vd());$.current=A,A.onopen=()=>{$.current===A&&(r({type:"status",status:"open"}),R.current=0,b.current=Date.now(),A.send(JSON.stringify({type:"hello",clientId:fn()})))},A.onmessage=xe=>{var Se,J,De,G,Oe,Ne;if($.current!==A)return;b.current=Date.now();let _;try{_=JSON.parse(xe.data)}catch{return}switch(_.type){case"node_event":window.dispatchEvent(new CustomEvent("pi-node-event",{detail:_}));break;case"ready":r({type:"ready",serverVersion:_.serverVersion,protocolVersion:_.protocolVersion}),A.send(JSON.stringify({type:"get_state"})),A.send(JSON.stringify({type:"list_models"})),A.send(JSON.stringify({type:"list_commands"})),A.send(JSON.stringify({type:"get_commands"})),A.send(JSON.stringify({type:"check_update"}));break;case"cwd_result":_.requestId===((Se=l.current)==null?void 0:Se.id)&&(p.current=_.cwd,j.current=_.requestId,_.ok||E(l.current.path),!_.ok||((J=i.current.state)==null?void 0:J.cwd)===_.cwd?(l.current=null,c(null)):A.send(JSON.stringify({type:"get_state"})));break;case"snapshot":if(u.current=!0,k(!0),l.current||(p.current=_.state.cwd),l.current&&j.current===l.current.id&&p.current===_.state.cwd&&(l.current=null,c(null)),ie.current=new Map,r({type:"snapshot",state:{..._.state,recovery:ha(_.state.recovery)}}),B.current){const Ee=B.current===_.state.conversationId&&_.state.isStreaming;B.current=null,Ee&&A.send(JSON.stringify({type:"abort"}))}break;case"snapshot_delta":{const Ee=i.current.state;(!Ee||Ee.conversationId!==_.conversationId||Ee.rev!==_.baseRev)&&q(),r({type:"snapshot_delta",msg:{..._,state:{..._.state,recovery:ha(_.state.recovery)}}});break}case"tool_delta":ke(_.conversationId,_.seq),r({type:"tool_delta",toolCallId:_.toolCallId,toolName:_.toolName,delta:_.delta,replace:_.replace,codemode:_.codemode});break;case"tool_status":r({type:"tool_status",status:_});break;case"message_delta":{ke(_.conversationId,_.seq),r({type:"message_delta",msg:_});break}case"notice":{(!_.conversationId||_.conversationId===i.current.activeConversationId)&&/MCP|mcp/i.test(_.text)&&window.dispatchEvent(new CustomEvent("pi-mcp-notice",{detail:_.text}));const Ee=++F.current;r({type:"notice",notice:{id:Ee,conversationId:_.conversationId,level:_.level,text:_.text}});break}case"agent_silence":r({type:"agent_silence",event:_});break;case"reload_status":r({type:"reload_status",event:_});break;case"sessions":if(_.cwd!==p.current)break;r({type:"sessions",sessions:_.sessions});break;case"conversations":((De=i.current.state)==null?void 0:De.conversationId)!==_.activeId&&q(),r({type:"conversations",conversations:_.conversations,activeId:_.activeId});break;case"projects":r({type:"projects",projects:_.projects});break;case"dir_browse":r({type:"dir_browse",dirBrowse:{path:_.path,parent:_.parent,dirs:_.dirs,truncated:_.truncated}});break;case"git_branch":if(_.cwd!==p.current||l.current)break;r({type:"git_branch",data:_});break;case"files":if(_.cwd!==p.current)break;r({type:"files",files:_});break;case"conversation_files_checked":if(_.cwd!==p.current)break;r({type:"conversation_files_checked",result:_});break;case"file_changed":r({type:"file_changed",path:_.path});break;case"prompt_result":r({type:"prompt_result",result:_});break;case"file_result":r({type:"file_result",result:_});break;case"file_content":if(_.cwd!==p.current||l.current)break;r({type:"file_content",content:_});break;case"models":r({type:"models",models:_.models,loading:!1});break;case"models_config":r({type:"models_config",providers:_.providers});break;case"native_mcp_result":window.dispatchEvent(new CustomEvent("pi-native-mcp-event",{detail:_}));break;case"provider_auth":r({type:"provider_auth",state:_.state});break;case"providers_status":r({type:"providers_status",providers:_.providers});break;case"fetch_models_result":r({type:"fetch_models_result",result:{reqId:_.reqId,ok:_.ok,models:_.models,error:_.error}});break;case"refresh_provider_result":r({type:"refresh_provider_result",result:{reqId:_.reqId,ok:_.ok,added:_.added,total:_.total,error:_.error}});break;case"clone_provider_result":r({type:"clone_provider_result",result:{reqId:_.reqId,ok:_.ok,config:_.config,error:_.error}});break;case"scm_data":if(_.cwd!==p.current||l.current)break;r({type:"scm_data",data:_});break;case"search_files_result":if(_.cwd!==p.current||l.current)break;r({type:"file_search_result",result:{reqId:_.reqId,ok:_.ok,results:_.results,truncated:_.truncated}});break;case"scm_changed":r({type:"scm_changed"});break;case"install_result":r({type:"install_result",result:_});break;case"path_completions":r({type:"path_completions",completions:_.completions});break;case"component_updates":r({type:"component_updates",result:_});break;case"update_status":r({type:"update_status",status:_});break;case"widgets":case"statuses":case"dialog":case"dialog_closed":case"extension_title":r({type:"extension_ui",message:_});break;case"extension_ui_reset":Td(_.conversationId);break;case"tree":case"tree_changed":case"tree_open":case"tree_content_result":case"tree_preview_result":case"tree_navigate_result":if(_.type==="tree_navigate_result"){_.reqId.startsWith("edit-")&&_.status!=="ok"&&r({type:"notice",notice:{id:++F.current,conversationId:_.conversationId,level:"warning",text:_.error??n.current(_.status==="busy"?"editBusy":"editFailed")}});const Ee=[...((G=_.restoredQueue)==null?void 0:G.steering)??[],...((Oe=_.restoredQueue)==null?void 0:Oe.followUp)??[]];_.editorText&&!_.reqId.startsWith("edit-")&&Ee.push(_.editorText),ga({id:_.reqId,conversationId:_.conversationId,text:Ee.join(`
|
|
26
|
-
|
|
27
|
-
`),images:(Ne=_.restoredQueue)==null?void 0:Ne.images})}Nd(_);break;case"queue_recalled":ga({id:_.requestId,conversationId:_.conversationId,text:_.text,images:_.images}),A.send(JSON.stringify({type:"queue_recall_ack",conversationId:_.conversationId,requestId:_.requestId}));break;case"extension_editor":Rd(_);break;case"terminal_output":N.current.write(_.conversationId??i.current.activeConversationId,_.terminalId,_.data);break;case"terminal_exit":r({type:"terminal_exit",conversationId:_.conversationId,terminalId:_.terminalId,exitCode:_.exitCode});break;case"terminal_list":r({type:"terminal_list",conversationId:_.conversationId,terminals:_.terminals});break;case"commands":if(_.cwd!==p.current||l.current)break;r({type:"commands",commands:_.commands,path:_.path});break;case"slash_commands":r({type:"slash_commands",commands:_.commands});break;case"settings_state":r({type:"settings",settings:_.settings});break;case"bg_servers":r({type:"bg_servers",servers:_.servers});break;case"plugins":r({type:"plugins",plugins:_.plugins,epoch:_.epoch});break;case"plugin_data":Dd(_.pluginId,_.payload);break}},A.onclose=()=>{if($.current===A&&($.current=null),N.current.clear(),!L.current||$.current&&$.current!==A)return;l.current=null,c(null),u.current=!1,k(!1),r({type:"status",status:"closed"});const xe=Math.min(1e3*2**R.current,1e4);R.current+=1,y.current=setTimeout(()=>{y.current=null,_e()},xe)},A.onerror=()=>{}},[]);d.useEffect(()=>{L.current=!0,_e();const A=setInterval(()=>{if(!L.current)return;const xe=$.current;xe&&xe.readyState===WebSocket.OPEN&&Date.now()-b.current>3e4&&xe.close()},5e3);return()=>{var xe;L.current=!1,clearInterval(A),Q.current&&(clearTimeout(Q.current),Q.current=null),y.current&&(clearTimeout(y.current),y.current=null),(xe=$.current)==null||xe.close(),$.current=null}},[_e]);const M=d.useCallback(A=>r({type:"dismiss_notice",id:A}),[]),V=d.useCallback((A,xe)=>r({type:"set_pending_echo",echo:{conversationId:A,text:xe,ts:Date.now()}}),[]),ve=d.useCallback(A=>r({type:"terminal_add",meta:A}),[]),ye=d.useCallback(A=>r({type:"terminal_remove",id:A}),[]),oe=d.useCallback(A=>r({type:"terminal_restart",terminalId:A}),[]),Fe=d.useCallback((A,xe,_)=>N.current.register(A,xe,_),[]),U=d.useMemo(()=>({create:ve,close:ye,register:Fe,restart:oe}),[ve,ye,Fe,oe]),fe=d.useRef({chat:s,send:O,pushNotice:Re,dismissNotice:M,setPendingEcho:V,terminal:U});fe.current={chat:s,send:O,pushNotice:Re,dismissNotice:M,setPendingEcho:V,terminal:U};const ce=s.extensionUi[s.activeConversationId];d.useEffect(()=>{document.title=(ce==null?void 0:ce.title)||"pi-harness"},[ce==null?void 0:ce.title]);const ae={...s,notices:s.notices.filter(A=>!A.conversationId||A.conversationId===s.activeConversationId),widgets:(ce==null?void 0:ce.widgets)??[],statuses:(ce==null?void 0:ce.statuses)??[],dialog:s.pendingDialogs.find(A=>A.conversationId===s.activeConversationId)??null},z=o?{...s,state:((Z=o.display)==null?void 0:Z.state)??null,sessions:((W=o.display)==null?void 0:W.sessions)??[],files:((ge=o.display)==null?void 0:ge.files)??null,activeConversationId:((Ae=(Ie=o.display)==null?void 0:Ie.state)==null?void 0:Ae.conversationId)??`pending:${o.path}`,ready:!1,liveOutputs:new Map,toolStatuses:new Map,dialog:null}:{...ae,ready:s.ready&&f,files:s.files??((we=a.current.get(((re=s.state)==null?void 0:re.cwd)??""))==null?void 0:we.files)??null};return{...fe.current,chat:z,switching:(o==null?void 0:o.path)??null,switchError:I}}function Gd({state:t,connected:n,send:s}){var re,we,A,xe,_,Se,J,De;const r=nt(),[i,a]=d.useState(!1),[o,c]=d.useState("tree"),[l,p]=d.useState("default"),[u,f]=d.useState(""),[k,j]=d.useState([]),[I,E]=d.useState(!1),[$,N]=d.useState(new Set),[R,y]=d.useState(),[L,b]=d.useState(),[F,B]=d.useState(),[ie,Q]=d.useState(),[q,ke]=d.useState(),[Re,O]=d.useState(""),[_e,M]=d.useState(!1),[V,ve]=d.useState(!1),ye=d.useRef(t);ye.current=t;const oe=d.useRef(new Map),Fe=d.useRef(""),U=d.useRef(""),fe=d.useRef(""),ce=d.useCallback((G,Oe=!1)=>{["tree_get","tree_preview","tree_content"].includes(G.type)||(fe.current=G.reqId),oe.current.set(G.reqId,{type:G.type,targetId:"targetId"in G?G.targetId:"entryId"in G?G.entryId:void 0,copy:Oe}),s(G)||(oe.current.delete(G.reqId),O(r("treeDisconnected")),M(!1),ve(!1))},[s,r]),ae=d.useCallback(()=>{if(!(t!=null&&t.conversationId)||!n||!i)return;const G=Qt();Fe.current=G,ve(!0),ce({type:"tree_get",conversationId:t.conversationId,reqId:G,filter:o==="fork"?"user-only":l,query:u})},[t==null?void 0:t.conversationId,n,i,l,u,o,ce]);d.useEffect(()=>{const G=setTimeout(ae,120);return()=>clearTimeout(G)},[ae,(re=t==null?void 0:t.tree)==null?void 0:re.revision]),d.useEffect(()=>{var G,Oe;oe.current.clear(),j([]),y(void 0),b(void 0),Q(void 0),ke(void 0),O(""),M(!1),N(new Set),p(((Oe=(G=ye.current)==null?void 0:G.tree)==null?void 0:Oe.filterMode)??"default")},[t==null?void 0:t.conversationId]),d.useEffect(()=>{n||(oe.current.clear(),M(!1),ve(!1))},[n]);const z=d.useCallback(G=>{const Oe=ye.current;Oe&&(M(!0),O(""),ce({type:"tree_navigate",conversationId:Oe.conversationId,reqId:Qt(),...G}))},[ce]),Z=d.useCallback((G,Oe=!1)=>{var Ce,be,ze;const Ne=ye.current;if(!Ne||(Ce=Ne.tree)!=null&&Ce.verifying||(be=Ne.tree)!=null&&be.externallyModified)return;const Ee={targetId:G,summary:"none",customInstructions:"",abortRunning:!1};if((Oe||(ze=Ne.tree)!=null&&ze.skipSummaryPrompt)&&!Ne.isStreaming){z(Ee);return}b(Ee),B(void 0),O("");const et=Qt();U.current=et,ce({type:"tree_preview",conversationId:Ne.conversationId,reqId:et,targetId:G})},[ce,z]);d.useEffect(()=>{const G=()=>{c("tree"),a(Ee=>!Ee)},Oe=Ee=>{(Ee.ctrlKey||Ee.metaKey)&&Ee.shiftKey&&Ee.key.toLowerCase()==="t"&&(Ee.preventDefault(),G())},Ne=Ee=>{var Ce;const et=Ee.detail;((Ce=ye.current)==null?void 0:Ce.conversationId)===et.conversationId&&Z(et.targetId,!0)};return window.addEventListener("pi-tree-open",G),window.addEventListener("keydown",Oe),window.addEventListener("pi-tree-navigate",Ne),()=>{window.removeEventListener("pi-tree-open",G),window.removeEventListener("keydown",Oe),window.removeEventListener("pi-tree-navigate",Ne)}},[Z]),d.useEffect(()=>{const G=Oe=>{var et;const Ne=Oe.detail;if(Ne.conversationId!==((et=ye.current)==null?void 0:et.conversationId))return;if(Ne.type==="tree_open"){c(Ne.mode),a(!0);return}if(Ne.type==="tree_changed"){ae();return}const Ee=oe.current.get(Ne.reqId);oe.current.delete(Ne.reqId),!((Ee==null?void 0:Ee.type)==="tree_get"&&Ne.reqId!==Fe.current)&&((Ee==null?void 0:Ee.type)==="tree_preview"&&Ne.reqId!==U.current||!Ee&&!Ne.reqId.startsWith("command-")||(Ne.type==="tree"&&Ne.reqId===Fe.current&&(j(Ne.nodes),E(Ne.truncated),ve(!1)),Ne.type==="tree_preview_result"&&Ne.reqId===U.current&&B(Ne.entryCount),Ne.type==="tree_content_result"&&(Ee!=null&&Ee.copy?navigator.clipboard.writeText(Ne.content).catch(()=>ke({id:Ne.entryId,text:Ne.content,toolCallId:Ne.toolCallId})):ke({id:Ne.entryId,text:Ne.content,toolCallId:Ne.toolCallId})),Ne.type==="tree_navigate_result"&&(Ne.reqId===fe.current&&M(!1),Ne.reqId===Fe.current&&ve(!1),Ne.status==="ok"?((Ee==null?void 0:Ee.type)==="tree_navigate"&&(y(Ee.targetId),b(void 0)),(Ee==null?void 0:Ee.type)==="tree_label"&&Q(void 0),ae()):O(Ne.error??r(Ne.status==="busy"?"treeBusy":Ne.status==="cancelled"?"treeCancelled":Ne.status==="aborted"?"treeAborted":"treeFailed")))))};return window.addEventListener("pi-tree-response",G),()=>window.removeEventListener("pi-tree-response",G)},[ae,r]);const W=d.useMemo(()=>{const G=new Set;return k.filter(Oe=>Oe.visibleParentId&&($.has(Oe.visibleParentId)||G.has(Oe.visibleParentId))?(G.add(Oe.id),!1):!0)},[k,$]),ge=G=>{M(!0),O(""),ce(G)},Ie=!n||_e||((we=t==null?void 0:t.tree)==null?void 0:we.busy)||((A=t==null?void 0:t.tree)==null?void 0:A.verifying)||((xe=t==null?void 0:t.tree)==null?void 0:xe.externallyModified),Ae=()=>({conversationId:(t==null?void 0:t.conversationId)??"",reqId:Qt()});return e.jsxs(e.Fragment,{children:[i&&e.jsxs("aside",{className:"session-tree-panel","aria-label":r("treeTitle"),children:[e.jsxs("header",{children:[e.jsx(os,{}),e.jsx("h2",{children:r(o==="fork"?"treeFork":"treeTitle")}),e.jsx("button",{onClick:()=>a(!1),"aria-label":r("close"),children:e.jsx(qt,{})})]}),e.jsxs("div",{className:"session-tree-controls",children:[e.jsx("select",{"aria-label":r("treeFilter"),value:o==="fork"?"user-only":l,disabled:o==="fork",onChange:G=>p(G.target.value),children:["default","no-tools","user-only","labeled-only","all"].map(G=>e.jsx("option",{value:G,children:r(`treeFilter_${G}`)},G))}),e.jsx("input",{"aria-label":r("treeSearch"),placeholder:r("treeSearch"),value:u,onChange:G=>f(G.target.value)})]}),((_=t==null?void 0:t.tree)==null?void 0:_.verifying)&&e.jsx("div",{role:"status",children:r("treeVerifying")}),((Se=t==null?void 0:t.tree)==null?void 0:Se.externallyModified)&&e.jsxs("div",{className:"tree-warning",role:"alert",children:[e.jsx("p",{children:r("treeExternal")}),e.jsx("button",{disabled:!n||_e||t.isStreaming,onClick:()=>ge({type:"session_reopen",...Ae()}),children:r("treeReopen")})]}),Re&&e.jsx("p",{role:"alert",className:"tree-warning",children:Re}),I&&e.jsx("p",{className:"tree-warning",children:r("treeTruncated")}),e.jsxs("div",{className:"session-tree-list","aria-busy":V,children:[!k.length&&e.jsx("p",{className:"tree-empty",children:r(V?"loadingSession":"treeEmpty")}),W.map((G,Oe)=>e.jsxs("section",{className:`tree-node${G.onActivePath?" active-path":""}${G.id===R?" selected":""}${Oe===0||W[Oe-1].rootId!==G.rootId?" root-start":""}`,style:{paddingLeft:`${12+Math.min(G.depth,18)*12}px`},"data-entry-id":G.id,children:[e.jsx("span",{className:"tree-connector","aria-hidden":"true",style:{width:`${Math.min(G.depth,18)*12}px`}}),e.jsxs("div",{className:"tree-node-heading",children:[e.jsx("button",{className:"tree-fold",disabled:!G.childCount,"aria-expanded":!$.has(G.id),"aria-label":r("treeFold"),onClick:()=>N(Ne=>{const Ee=new Set(Ne);return Ee.has(G.id)?Ee.delete(G.id):Ee.add(G.id),Ee}),children:G.childCount?$.has(G.id)?e.jsx(_t,{}):e.jsx(nn,{}):e.jsx("span",{children:G.isLeaf?"●":"·"})}),e.jsxs("button",{className:"tree-node-preview",onClick:()=>ce({type:"tree_content",...Ae(),entryId:G.id}),children:[e.jsxs("small",{children:[G.kind==="compaction"?e.jsx(la,{}):G.kind==="branchSummary"?e.jsx(os,{}):null,G.isLeaf?"● ":"",r(`treeKind_${G.kind}`),G.childCount>1?` · ${G.childCount}`:""]}),e.jsx("span",{children:G.preview||"…"})]}),G.label&&e.jsxs("span",{className:"tree-label",children:[e.jsx(Zi,{}),G.label]})]}),e.jsxs("div",{className:"tree-node-actions",children:[e.jsx("button",{disabled:Ie,onClick:()=>o==="fork"?ge({type:"session_fork",...Ae(),entryId:G.id,position:"before"}):Z(G.id),children:r(o==="fork"?"treeFork":"treeNavigate")}),e.jsxs("button",{disabled:Ie||(t==null?void 0:t.isStreaming),onClick:()=>ge({type:"session_fork",...Ae(),entryId:G.id,position:"at"}),children:[e.jsx(os,{}),r("treeForkAt")]}),e.jsxs("button",{disabled:Ie,onClick:()=>Q({id:G.id,value:G.label??""}),children:[e.jsx(Zi,{}),r("treeLabel")]}),e.jsx("button",{disabled:!n,onClick:()=>ce({type:"tree_content",...Ae(),entryId:G.id},!0),"aria-label":r("copy"),children:e.jsx(Ls,{})})]})]},G.id))]}),e.jsxs("footer",{children:[e.jsxs("span",{children:[k.length," · ",r("treeNodes")]}),e.jsxs("button",{disabled:Ie||(t==null?void 0:t.isStreaming),onClick:()=>ge({type:"session_clone",...Ae()}),children:[e.jsx(la,{}),r("treeClone")]})]})]}),!i&&Re&&e.jsxs("div",{className:"tree-floating-error",role:"alert",children:[Re,e.jsx("button",{onClick:()=>O(""),"aria-label":r("close"),children:e.jsx(qt,{})})]}),L&&!_e&&e.jsx("div",{className:"tree-modal-backdrop",children:e.jsxs("section",{className:"tree-dialog",role:"dialog","aria-modal":"true","aria-label":r("treeNavigate"),children:[e.jsx("h3",{children:r("treeNavigate")}),F!==void 0&&e.jsx("p",{children:r("treePreviewCount",{n:F})}),["none","default","custom"].map(G=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"tree-summary",value:G,checked:L.summary===G,disabled:_e,onChange:()=>b({...L,summary:G})}),r(`treeSummary_${G}`)]},G)),L.summary==="custom"&&e.jsx("textarea",{"aria-label":r("treeInstructions"),placeholder:r("treeInstructions"),value:L.customInstructions,onChange:G=>b({...L,customInstructions:G.target.value})}),(t==null?void 0:t.isStreaming)&&e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:L.abortRunning,onChange:G=>b({...L,abortRunning:G.target.checked})}),r("treeStopConfirm")]}),Re&&e.jsx("p",{role:"alert",children:Re}),e.jsxs("div",{className:"tree-dialog-actions",children:[e.jsx("button",{disabled:_e,onClick:()=>b(void 0),children:r("cancel")}),e.jsx("button",{className:"primary",disabled:Ie||!!(t!=null&&t.isStreaming)&&!L.abortRunning,onClick:()=>z(L),children:r("treeNavigate")})]})]})}),ie&&e.jsx("div",{className:"tree-modal-backdrop",children:e.jsxs("form",{className:"tree-dialog",role:"dialog","aria-modal":"true","aria-label":r("treeLabel"),onSubmit:G=>{G.preventDefault(),ge({type:"tree_label",...Ae(),entryId:ie.id,label:ie.value.trim()||null})},children:[e.jsx("h3",{children:r("treeLabel")}),e.jsx("input",{autoFocus:!0,maxLength:200,"aria-label":r("treeLabel"),value:ie.value,onChange:G=>Q({...ie,value:G.target.value})}),e.jsx("p",{children:r("treeLabelClear")}),Re&&e.jsx("p",{role:"alert",children:Re}),e.jsxs("div",{className:"tree-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>Q(void 0),children:r("cancel")}),e.jsx("button",{className:"primary",disabled:_e||!n||((J=t==null?void 0:t.tree)==null?void 0:J.verifying)||((De=t==null?void 0:t.tree)==null?void 0:De.externallyModified),children:r("save")})]})]})}),q&&e.jsx("div",{className:"tree-modal-backdrop",children:e.jsxs("section",{className:"tree-dialog tree-content-dialog",role:"dialog","aria-modal":"true","aria-label":r("treeContent"),children:[e.jsx("h3",{children:r("treeContent")}),e.jsx("pre",{children:q.text}),q.toolCallId&&t&&e.jsx(Nr,{url:`/api/tool-output?${new URLSearchParams({clientId:fn(),conversationId:t.conversationId,toolCallId:q.toolCallId})}`}),e.jsx("button",{onClick:()=>ke(void 0),children:r("close")})]})})]})}function Jd({state:t,send:n,connected:s}){var $,N,R,y,L,b,F;const r=nt(),[,i]=d.useState(0),[a,o]=d.useState(),c=performance.now(),l=t==null?void 0:t.recovery,p=(l==null?void 0:l.summary)??(l==null?void 0:l.retry)??(l==null?void 0:l.compaction)??(l==null?void 0:l.branch);if(d.useEffect(()=>{if(!p)return;const B=setInterval(()=>i(ie=>ie+1),250);return()=>clearInterval(B)},[p]),!t)return null;if(($=t.tree)!=null&&$.verifying)return e.jsx("div",{className:"agent-silence",role:"status",children:r("treeVerifying")});const u=(l==null?void 0:l.compaction)??(p||l==null?void 0:l.lastCompaction);if(!p&&!u)return null;const f=p||l==null?void 0:l.lastCompaction;if(f&&f.id===a)return null;const k=((N=l==null?void 0:l.summary)==null?void 0:N.deadline)??((R=l==null?void 0:l.retry)==null?void 0:R.deadline),j=((y=l==null?void 0:l.summary)==null?void 0:y.attempt)??((L=l==null?void 0:l.retry)==null?void 0:L.attempt),I=((b=l==null?void 0:l.summary)==null?void 0:b.maxAttempts)??((F=l==null?void 0:l.retry)==null?void 0:F.maxAttempts),E=l!=null&&l.summary?l.summary.phase==="waiting"?"recoverySummaryWaiting":"recoverySummaryRunning":l!=null&&l.retry?l.retry.phase==="running"||c>=(l.retry.deadline??1/0)?"recoveryRunning":"recoveryWaiting":l!=null&&l.branch?"treeSummarizing":"recoveryCompacting";return e.jsxs("div",{className:"agent-silence",role:"status",children:[e.jsxs("span",{children:[r(f?f.status==="completed"?"compactionCompleted":f.status==="aborted"?"compactionAborted":"compactionFailed":E),u&&` · ${r(u.reason==="manual"?"compactionManual":u.reason==="threshold"?"compactionThreshold":"compactionOverflow")}`,(u==null?void 0:u.tokensBefore)!==void 0&&` · ${u.tokensBefore.toLocaleString()} tokens`,(f==null?void 0:f.tokensAfter)!==void 0&&` → ≈${f.tokensAfter.toLocaleString()} tokens`,(f==null?void 0:f.error)&&` · ${f.error}`,s&&k!==void 0&&k>c&&` · ${Math.max(0,Math.ceil((k-c)/1e3))}s`,j!==void 0&&` · ${j}/${I}`]}),p&&e.jsx("button",{disabled:!s,onClick:()=>n({type:"cancel_recovery",conversationId:t.conversationId,operationId:p.id}),children:r("cancel")}),f&&e.jsx("button",{onClick:()=>o(f.id),children:r("close")})]})}function Fo({text:t}){return e.jsx(e.Fragment,{children:t.split(/(https?:\/\/[^\s<>]+)/g).map((n,s)=>{try{const r=new URL(n);if(r.protocol==="https:"||r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname))return e.jsx("a",{href:n,target:"_blank",rel:"noreferrer",children:n},s)}catch{}return n})})}class Oo extends Error{constructor(n){super(n.error),this.detail=n}}async function Pn(t,n,s={},r){const i=await fetch(Sn("/api/wiki"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,clientId:fn(),cwd:t,action:n}),signal:r}),a=await i.json();if(!i.ok)throw new Oo({...a,error:a.error||i.statusText});return a}function Fr(t,n,s=!1){return Sn("/api/wiki-media?"+new URLSearchParams({clientId:fn(),cwd:t,path:n,...s?{download:"1"}:{}}))}const _o=/^(?:\*\*([\p{L}\p{N}_ -]{1,40})[::]\*\*|(?:\*\*)?([\p{L}\p{N}_ -]{1,40})(?:\*\*)?[::])\s*(.+)$/u,Ho=t=>t.replace(/(?:\\| {2,})$/,"").trim();function Qd(t,n){var a;let s=!1,r=!1;const i=/[^\n]*(?:\n|$)/g;i.lastIndex=n;for(let o=i.exec(t);o&&o[0];o=i.exec(t)){const c=Ho(o[0]);if(c){if(!r&&!s&&/^# /.test(c)){s=!0;continue}if(r=!0,!_o.test(c)){const l=o.index+o[0].length,p=((a=t.slice(l).match(/^ {0,3}(?:=+|-+)[ \t]*(?:\r?\n|$)/))==null?void 0:a[0])??"",u=o[0].replace(/^[ \t]{4,}/," ");return t.slice(0,o.index)+u.slice(0,256).trimEnd()+`
|
|
28
|
-
`+p}}}return t}function Bo(t){var o,c;const n=((o=t.match(/^---\r?\n[\s\S]*?\r?\n(?:---|\.\.\.)(?:\r?\n|$)/))==null?void 0:o[0].length)??0,s=Qd(t,n),r=wr().use(br).parse(s).children.filter(l=>{var p;return(((p=l.position)==null?void 0:p.start.offset)??0)>=n});((c=r[0])==null?void 0:c.type)==="heading"&&r[0].depth===1&&r.shift();const i=[],a=[];for(const l of r){if(l.type!=="paragraph")break;const p=l.position.start.offset,u=l.position.end.offset,f=t.slice(p,u).split(/\r?\n/).map(k=>_o.exec(Ho(k)));if(f.some(k=>!k))break;for(const k of f)i.push({key:(k[1]??k[2]).trim(),value:k[3]});a.push({start:p,end:u})}return i.length>=2?{rows:i,ranges:a}:{rows:[],ranges:[]}}var mn=ao();const Yd=wr().use(br);function ti(t){var n;return["code","html","definition"].includes(t.type)?"":t.value??((n=t.children)==null?void 0:n.map(ti).join(""))??""}function Uo(t,n){var s;n(t),["code","inlineCode","html","definition"].includes(t.type)||(s=t.children)==null||s.forEach(r=>Uo(r,n))}function ba(t){const n=t.trim();if(n.startsWith('"')&&n.endsWith('"'))try{return JSON.parse(n)}catch{}return n.replace(/^(['"])([\s\S]*)\1$/,"$2").replaceAll("''","'")}function Wo(t){var E;const n=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(t),s=n?t.slice(n[0].length):t,r=(n==null?void 0:n[1])??"",i=new Set,a=$=>{const N=ba($).replace(/^#/,"").trim();N&&!/^(?:[a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(N)&&i.add(N)},o=/^tags?:[ \t]*(.*)$/m.exec(r);if(o!=null&&o[1].trim())for(const $ of o[1].replace(/^\[|\]$/g,"").split(/[,\s]+/))a($);if(o&&!o[1].trim())for(const $ of r.slice(o.index+o[0].length).split(/\r?\n/)){if(!$.trim())continue;const N=/^\s*-\s+(.+)$/.exec($);if(!N)break;a(N[1])}const c=Yd.parse(s);let l;Uo(c,$=>{var N;if(!l&&$.type==="heading"&&$.depth===1&&(l=$),$.type==="text"&&((N=$.position)==null?void 0:N.start.offset)!==void 0&&$.position.end.offset!==void 0){const R=$.position.start.offset,y=s.slice(R,$.position.end.offset);for(const L of y.matchAll(/(?:^|\s)#([\p{L}\p{N}_/-]+)/gu))L.index===0&&y.startsWith("#")&&R>0&&!/\s/.test(s[R-1])||a(L[1])}});const p=l?ti(l).trim():void 0,u=ba(((E=/^title:[ \t]*(.*)$/m.exec(r))==null?void 0:E[1])??"")||p;let f=s;if(u&&p===u.trim()&&(l!=null&&l.position)){const{start:$,end:N}=l.position;$.offset!==void 0&&N.offset!==void 0&&(f=s.slice(0,$.offset)+s.slice(N.offset))}const k=c.children.map($=>ti($)).join(" "),j=(k.match(new RegExp("\\p{Script=Han}","gu"))??[]).length,I=(k.replace(new RegExp("\\p{Script=Han}","gu")," ").match(/[\p{L}\p{N}]+(?:['’-][\p{L}\p{N}]+)*/gu)??[]).length;return{tags:[...i].slice(0,100),title:u,body:s,readingBody:f,minutes:Math.max(1,Math.ceil(j/400+I/200))}}const Xd=t=>(t.split("/").at(-1)??"").replace(/\.(md|txt)$/i,"");function Zd(t){const n=new Map;for(const s of t){const r=Xd(s),i=n.get(r);i?i.push(s):n.set(r,[s])}return{paths:new Set(t),byName:n}}function ja(t,n,s){let r;try{r=decodeURIComponent(n.split("|")[0].split("#")[0]).replaceAll("\\","/")}catch{return}if(!r||/^(?:[a-z]+:|\/)/i.test(r))return;const i=l=>{const p=[];for(const u of l.split("/"))if(u===".."){if(!p.length)return"";p.pop()}else u&&u!=="."&&p.push(u);return p.join("/")},a=t.includes("/")?t.slice(0,t.lastIndexOf("/")+1):"",o=Array.isArray(s)?Zd(s):s;for(const l of[i(a+r),i(r)])for(const p of[l,l+".md",l+".txt"])if(o.paths.has(p))return p;const c=o.byName.get(r.replace(/\.(md|txt)$/i,""))??[];return c.length===1?c[0]:void 0}function eu(t){let n="";return t.split(`
|
|
29
|
-
`).map(s=>{const r=/^\s*(`{3,}|~{3,})/.exec(s);return r?(n?r[1][0]===n[0]&&r[1].length>=n.length&&(n=""):n=r[1],s):n?s:s.split(/(`+[^`]*`+)/g).map(i=>i.startsWith("`")?i:i.replace(/\[\[([^\]]+)\]\]/g,(a,o)=>`[${(o.split("|")[1]||o.split("|")[0]).replace(/[\[\]]/g,"")}](#wiki=${encodeURIComponent(o.split("|")[0])})`)).join("")}).join(`
|
|
30
|
-
`)}function Ca(t,n,s,r,i,a,o,c,l){const p=[...new Set([...n&&!i?[n]:[],...r,...a.filter(u=>i).map(u=>u.path)])];return`${t.trim()}
|
|
31
|
-
|
|
32
|
-
${l.scope}: ${o?".":p.map(u=>JSON.stringify(u)).join(", ")}
|
|
33
|
-
${c?"":l.documentsOnly+`
|
|
34
|
-
`}${l.skip}${s?`
|
|
35
|
-
|
|
36
|
-
${l.selection} (${JSON.stringify(n)}):
|
|
37
|
-
${s}`:""}`}const ji=wr().use(br),Ci=t=>"value"in t?t.value:"children"in t?t.children.map(Ci).join(""):"";function tu(t){var r,i;const n=[];let s=0;for(const a of ji.parse(t).children){if(a.type!=="list"||!a.children.every(l=>{var p,u;return((p=l.children[0])==null?void 0:p.type)==="paragraph"&&((u=l.children[0].children[0])==null?void 0:u.type)==="strong"}))continue;const o=(r=a.position)==null?void 0:r.start.offset,c=(i=a.position)==null?void 0:i.end.offset;if(!(o===void 0||c===void 0)){o>s&&n.push({kind:"text",text:t.slice(s,o)});for(const l of a.children){const p=l.children[0];if(p.type!=="paragraph")continue;const u=p.children[0];if(u.type!=="strong")continue;const f=u.children.map(Ci).join(""),k=t.slice(u.position.end.offset,l.position.end.offset).trim().replace(/^[::—–]\s*/,""),j=/(?:§\s*(\d+)|第\s*(\d+)\s*节|\bsection\s+(\d+)\b)/i.exec(`${f}
|
|
38
|
-
${k}`);n.push({kind:"card",title:f,text:k,section:j?Number(j[1]??j[2]??j[3]):null})}s=c}}return s<t.length&&n.push({kind:"text",text:t.slice(s)}),n}function Sa(t,n){const s=t.map(r=>{var i;return(i=/^\s*(?:第\s*)?(\d+)\s*(?:[.、.))]|节|\s)/.exec(r))==null?void 0:i[1]});return s.some(Boolean)?s.findIndex(r=>Number(r)===n):n>=1&&n<=t.length?n-1:-1}function nu(t){return ji.parse(t).children.flatMap(n=>n.type==="heading"&&n.depth===2?[n.children.map(Ci).join("")]:[])}function su(t){const n=t.replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/,""),s=ji.parse(n).children;return s.some((r,i)=>{const a=s[i+1];return r.type==="heading"&&(!a||a.type==="heading"&&a.depth<=r.depth)})}function qo({thinking:t,durationMs:n,streaming:s,wrap:r=!0}){const i=nt(),[a,o]=d.useState(null),c=a??r;return s?t.trim()?c?e.jsx("div",{className:"thinking open live",children:e.jsx("div",{className:"thinking-body",children:t})}):e.jsx("div",{className:"thinking live",children:e.jsxs("button",{type:"button",className:"thinking-toggle",onClick:()=>o(!0),children:[e.jsx(_t,{}),e.jsx("span",{className:"thinking-label",children:i("thinking")}),e.jsx("span",{className:"thinking-live-label",children:t.trim().split(`
|
|
39
|
-
`).at(-1)})]})}):null:e.jsxs("div",{className:`thinking ${c?"open":""}`,children:[e.jsxs("button",{type:"button",className:"thinking-toggle",onClick:()=>o(!c),children:[c?e.jsx(nn,{}):e.jsx(_t,{}),e.jsx("span",{className:"thinking-label",children:i("thinking")}),e.jsxs("span",{className:"thinking-duration",children:["· ",n!==void 0?i("thinkingDuration",{n:Math.max(1,Math.round(n/1e3))}):i("thinkingUnrecorded")]})]}),c&&e.jsx("div",{className:"thinking-body",children:t})]})}function zs(t){try{const n=JSON.parse(t??"");return n&&typeof n=="object"&&"command"in n&&typeof n.command=="string"?n.command:null}catch{return null}}function zo(t){const n=[];let s=0,r="",i=null,a=!1,o=0;for(let c=0;c<t.length;c++){const l=t[c];if(a){a=!1;continue}if(l==="\\"&&i!=="'"){a=!0;continue}if(i){l===i&&(i=null);continue}if(l==="'"||l==='"'){i=l;continue}if(l==="("||l==="{"){o++;continue}if(l===")"||l==="}"){o=Math.max(0,o-1);continue}o===0&&(l===";"||l==="&"&&t[c+1]==="&")&&(n.push({text:t.slice(s,c).trim(),separator:r}),r=l===";"?";":"&&",s=c+r.length,c=s-1)}return n.push({text:t.slice(s).trim(),separator:r}),n.filter(c=>c.text)}function Si(t){return zo(t).map(n=>n.text)}function ru(t){var s;const n=/^echo\s+(["']?)===\s*(.+?)\s*===\1\s*$/.exec(t);return((s=n==null?void 0:n[2])==null?void 0:s.trim())??null}function Vo(t){return t.replace(/\x1b\[[0-9;]*m/g,"").replace(/\r\n/g,`
|
|
40
|
-
`)}function iu(t){return t.split(`
|
|
41
|
-
`).filter(n=>n.trim().length>0).length}function au(t,n,s,r,i){var N,R,y,L,b;const a=zs(t);if(!a)return null;const o=zo(a),c=[];let l=null;for(const F of o){const B=ru(F.text);B?(l&&c.push({label:l.label,command:l.commands.map((ie,Q)=>`${Q?` ${ie.separator} `:""}${ie.text}`).join("")}),l={label:B,commands:[]}):l&&l.commands.push(F)}if(l&&c.push({label:l.label,command:l.commands.map((F,B)=>`${B?` ${F.separator} `:""}${F.text}`).join("")}),c.length<2||c.some(F=>!F.command)||new Set(c.map(F=>F.label)).size!==c.length)return null;const p=new Map;let u=null;for(const F of Vo(n).split(`
|
|
42
|
-
`)){const B=(R=(N=/^===\s*(.+?)\s*===\s*$/.exec(F))==null?void 0:N[1])==null?void 0:R.trim();if(B&&c.some(ie=>ie.label===B)){if(p.has(B))return null;const ie=(y=c[p.size])==null?void 0:y.label;if(B!==ie)return null;u=B,p.set(B,[])}else if(u)(L=p.get(u))==null||L.push(F);else if(F.trim())return null}if(p.size===0)return null;const f=p.size-1,k=i??Number(((b=/(?:exited with code\s*|exit(?:ed)?\s+)(\d+)/i.exec(n))==null?void 0:b[1])??NaN),j=c.map((F,B)=>{const ie=(p.get(F.label)??[]).join(`
|
|
43
|
-
`).trimEnd();let Q="skipped";return B<f?Q="done":B===f&&(s?r?/^(?:grep|rg)\b/.test(F.command)&&k===1&&(!ie.replace(/(?:^|\n)Command exited with code 1\s*$/i,"").trim()||/^0\s*(?:\n|$)/.test(ie))?Q="no-match":Q="failed":Q="done":Q="running"),{label:F.label,command:F.command,output:ie,state:Q,lineCount:iu(ie)}}),I=j.filter(F=>F.state==="done").length,E=j.filter(F=>F.state==="failed").length,$=j.filter(F=>F.state==="no-match").length;return{command:a,steps:j,completed:I,failed:E,noMatch:$,exitCode:Number.isFinite(k)?k:void 0,status:s?E?I||$?"partial":"failed":$?"no-match":r?"failed":"done":"running"}}function ou(t){const n=[];for(const s of Vo(t).split(`
|
|
44
|
-
`)){const r=s.trim(),i=/^(.+?\.(?:tsx?|jsx?|mjs|cjs|json|css|html|py|go|rs))(?::(\d+)(?::(\d+))?|\((\d+),(\d+)\)):\s*(?:error\s*(?:TS\d+)?\s*:?\s*)?(.+)$/i.exec(r);if(!i)continue;const a=Number(i[2]??i[4]);!Number.isInteger(a)||a<1||n.push({path:i[1],line:a,column:i[3]||i[5]?Number(i[3]??i[5]):void 0,message:i[6]})}return n.slice(0,20)}function lu(t){const n=new Map;let s;for(const r of t)if(r.role!=="toolResult"){if(r.role!=="assistant"){s=void 0;continue}s&&s.model===r.model&&n.set(r.id,s.id),s=r}return n}function cu(t,n){const s=new Set(t.filter(r=>r.role==="toolResult").map(r=>r.toolCallId));for(let r=t.length-1;r>=0;r--){const i=t[r];if(i.role==="user")break;for(const a of[...i.content].reverse())if(a.type==="toolCall"&&typeof a.id=="string"&&typeof a.name=="string"&&!s.has(a.id)&&!n.has(a.id))return a;if(i.role==="assistant"&&i.content.some(a=>a.type==="toolCall"))return}}function Ko(t,n,s){const r=t.findLastIndex(c=>c.role==="user"),i=t.slice(r+1),a=cu(t,n);if(a){let c="";try{c=JSON.parse(a.argumentsText??"{}").command??""}catch{}if(a.name!=="bash"||typeof c!="string")return null;const l=Si(c),p=l.some(f=>/^(?:(?:npm|pnpm|yarn|bun) (?:run )?test(?:[:\s]|$)|(?:npx )?(?:vitest|pytest|jest)(?:\s|$)|python\d? -m pytest(?:\s|$))/.test(f)),u=l.some(f=>/^(?:(?:npm|pnpm|yarn|bun) (?:run )?build(?:[:\s]|$)|(?:npx )?(?:tsc|vite build|make|cargo build)(?:\s|$))/.test(f));return p||u?{key:a.id,label:p?"waitTests":"waitBuild",delay:4e3}:null}for(let c=i.length-1;c>=0;c--){const l=i[c];if(l.role==="toolResult")return{key:l.toolCallId??l.id,label:l.toolName==="read"?"waitFile":"waitResults",delay:300};if(l.role==="assistant")for(const p of[...l.content].reverse()){if(p.type==="toolCall"&&typeof p.id=="string")return n.has(p.id)?{key:p.id,label:p.name==="read"?"waitFile":"waitResults",delay:300}:null;if(p.type==="text"&&(typeof p.text=="string"&&p.text.trim()||p.truncated))return null;if(p.type==="thinking")return typeof p.thinking=="string"&&p.thinking.trim()||l.content.some(u=>u.type==="text"&&(typeof u.text=="string"&&u.text.trim()||u.truncated)||u.type==="thinking"&&typeof u.thinking=="string"&&u.thinking.trim())?null:{key:l.id,label:"waitThinking",delay:300}}}const o=t[r];return o?{key:o.id,label:o.id===s?"waitSteer":"waitUnderstanding",delay:300}:null}function du({stage:t,onStop:n}){const s=nt(),r=d.useRef(Date.now()),[i,a]=d.useState(0);if(d.useEffect(()=>{const c=()=>a(Date.now()-r.current),l=window.setTimeout(c,t.delay),p=window.setInterval(c,250);return()=>{window.clearTimeout(l),window.clearInterval(p)}},[t.delay]),i<t.delay)return null;const o=Math.floor(i/1e3);return e.jsxs("div",{className:"waiting-indicator",role:"status",children:[e.jsxs("span",{className:"waiting-brand","aria-hidden":"true",children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),e.jsx("span",{className:"waiting-label",children:s(t.label)}),o>=4&&e.jsx("span",{className:"waiting-duration","aria-live":"off",children:o<60?s("waitSeconds",{n:o}):s("waitMinutes",{m:Math.floor(o/60),s:String(o%60).padStart(2,"0")})}),o>=60&&n&&e.jsxs("button",{className:"waiting-stop",onClick:n,children:["· ",s("waitStop")]})]})}function Go({state:t,connected:n,silenceNotified:s,toolStatuses:r,onStop:i}){const a=nt(),o=t.messages.findLast(j=>j.role==="user"),c=d.useRef({conversation:t.conversationId,user:o==null?void 0:o.id,steering:[]}),[l,p]=d.useState();d.useEffect(()=>{var I;const j=c.current;if(j.conversation!==t.conversationId||!t.isStreaming)p(void 0);else if(o&&j.user!==o.id){const E=cs(o.questionText??o.content.filter(N=>N.type==="text").map(N=>N.type==="text"?N.text:"").join(`
|
|
45
|
-
`)),$=E.length>2e3?E.slice(0,2e3)+"…":E;p(j.steering.some(N=>cs(N)===$)?o.id:void 0)}c.current={conversation:t.conversationId,user:o==null?void 0:o.id,steering:((I=t.queue)==null?void 0:I.steering)??[]}},[t.conversationId,t.isStreaming,t.queue,o]);const u=new Map([...r].filter(([,j])=>!j.running&&(!j.conversationId||j.conversationId===t.conversationId))),f=t.streamingMessage?[...t.messages.filter(j=>{var I;return j.id!==((I=t.streamingMessage)==null?void 0:I.id)}),{...t.streamingMessage,role:"assistant"}]:t.messages,k=Ko(f,u,l);return!t.isStreaming||s||t.recovery&&Object.values(t.recovery).some(Boolean)?null:n?k&&e.jsx(du,{stage:k,onStop:i},`${t.conversationId}:${k.key}:${k.label}`):e.jsx("div",{className:"agent-working disconnected",role:"status",children:a("workDisconnected")})}function uu(t){const n=new Map;for(const s of t)n.set(s.reason,(n.get(s.reason)??0)+1);return[...n].map(([s,r])=>({reason:s,count:r})).sort((s,r)=>r.count-s.count)}function Ni({title:t,onClose:n,children:s}){const r=nt(),i=d.useRef(null);return d.useEffect(()=>{var o,c,l;const a=document.activeElement;return(l=((o=i.current)==null?void 0:o.querySelector("input"))??((c=i.current)==null?void 0:c.querySelector("button")))==null||l.focus(),()=>{a!=null&&a.isConnected&&a.focus()}},[]),mn.createPortal(e.jsx("div",{className:"wiki-modal-backdrop",onMouseDown:a=>{a.target===a.currentTarget&&n()},children:e.jsxs("section",{ref:i,className:"wiki-reading-dialog",role:"dialog","aria-modal":"true","aria-label":t,onKeyDown:a=>{var c,l,p;if(a.key==="Escape"&&(a.stopPropagation(),n()),a.key!=="Tab")return;const o=[...((c=i.current)==null?void 0:c.querySelectorAll("button, input, [tabindex='0']"))??[]];a.shiftKey&&document.activeElement===o[0]?(a.preventDefault(),(l=o.at(-1))==null||l.focus()):!a.shiftKey&&document.activeElement===o.at(-1)&&(a.preventDefault(),(p=o[0])==null||p.focus())},children:[e.jsxs("header",{children:[e.jsx("h2",{children:t}),e.jsx("button",{"aria-label":r("close"),onClick:n,children:e.jsx(qt,{})})]}),s]})}),document.body)}function pu({status:t}){const n=nt(),{locale:s}=Qn(),[r,i]=d.useState(!1),a={"file-size":"wikiIndexFileSize","byte-budget":"wikiIndexBudget","entry-limit":"wikiIndexEntries","depth-limit":"wikiIndexDepth",unreadable:"wikiIndexUnreadable"},o=u=>u.toLocaleString(s==="zh"?"zh-CN":"en-US"),c=t.issues.length,l=uu(t.issues),p=n("wikiIndexStatus",{indexed:o(t.indexed),total:t.totalIsLowerBound?n("wikiIndexCounting"):o(t.total)});return!r&&!c&&!t.totalIsLowerBound&&t.indexed===t.total?null:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`wiki-index-status ${c?"limited":""}`,onClick:()=>i(!0),title:[p,...l.map(u=>n("wikiIndexIssueCount",{count:o(u.count),reason:n(a[u.reason])}))].join(`
|
|
46
|
-
`),children:[c>0&&e.jsx("i",{}),e.jsx("span",{children:p}),c>0&&e.jsxs("span",{className:"wiki-index-reason",children:[" · ",n("wikiIndexSkipped",{count:o(c)})]})]}),r&&e.jsxs(Ni,{title:p,onClose:()=>i(!1),children:[e.jsx("p",{children:n(t.totalIsLowerBound?"wikiIndexPartial":c?"wikiIndexHint":"wikiIndexComplete")}),e.jsx("ul",{className:"wiki-index-summary",children:l.map(u=>e.jsx("li",{children:n("wikiIndexIssueCount",{count:o(u.count),reason:n(a[u.reason])})},u.reason))}),e.jsx("div",{className:"wiki-index-issues",children:t.issues.map((u,f)=>e.jsxs("div",{children:[e.jsx("code",{children:u.path}),e.jsx("span",{children:u.size===void 0?"—":`${(u.size/1024/1024).toFixed(2)} MB`}),e.jsxs("small",{children:[n(a[u.reason]),u.subtree?` · ${n("wikiIndexSubtree")}`:""]})]},`${u.path}:${f}`))})]})]})}function hu(t){const n=[...new Set(t)].filter(Boolean).sort((s,r)=>r.length-s.length);return()=>s=>{const r=i=>{!i.children||["link","code","inlineCode"].includes(i.type)||(i.children=i.children.flatMap(a=>{if((a.type==="text"||a.type==="inlineCode")&&a.value){const o=a.value,c=[];let l=0;for(;l<o.length;){let p=-1,u="";for(const f of n){const k=o.indexOf(f,l);k<0||p>=0&&k>=p||k>0&&/[\w/.-]/.test(o[k-1])||/[\w/.-]/.test(o[k+f.length]??"")&&o[k+f.length]!=="."||(p=k,u=f)}if(p<0){c.push({...a,value:o.slice(l)});break}p>l&&c.push({...a,value:o.slice(l,p)}),c.push({type:"link",url:`#pi-change=${encodeURIComponent(u)}`,children:[{...a,value:u}]}),l=p+u.length}return c}return r(a),[a]}))};r(s)}}const ni=[{name:"yellow",hex:"#fff3a3",rgb:"rgb(255, 243, 163)"},{name:"green",hex:"#ccebc5",rgb:"rgb(204, 235, 197)"},{name:"blue",hex:"#c8e4ff",rgb:"rgb(200, 228, 255)"},{name:"pink",hex:"#ffd5e5",rgb:"rgb(255, 213, 229)"},{name:"purple",hex:"#e5d5ff",rgb:"rgb(229, 213, 255)"}];function si(t){return ni.find(n=>n.hex===t.toLowerCase()||n.rgb===t.toLowerCase())}function Jo(){return t=>{const n=s=>{for(let r=0;r<s.children.length;r++){const i=s.children[r];if(i.type==="html"){const o=/^<mark style="background-color: (#[0-9a-f]{6})">$/i.exec(i.value),c=o&&si(o[1]);if(!c)continue;let l=r+1;for(;l<s.children.length;){const u=s.children[l];if(u.type==="html"&&u.value==="</mark>")break;if(u.type==="html"){l=s.children.length;break}l++}if(l===s.children.length)continue;const p=s.children.slice(r+1,l);s.children.splice(r,l-r+1,{type:"emphasis",children:p,data:{hName:"span",hProperties:{style:`background-color: ${c.hex}`}}})}const a=s.children[r];"children"in a&&n(a)}};n(t)}}function Qo(){return t=>{const n=s=>{if(s.type==="blockquote"){const r=s.children[0],i=(r==null?void 0:r.type)==="paragraph"?r.children[0]:void 0;(i==null?void 0:i.type)==="text"&&/^\[!NOTE\](?:\r?\n|$)/.test(i.value)&&(i.value=i.value.replace(/^\[!NOTE\](?:\r?\n)?/,""),s.data={...s.data,hProperties:{className:["rich-highlight"],"data-rich-highlight":"note"}})}"children"in s&&s.children.forEach(r=>n(r))};n(t)}}const mu=/[ -〿-]/;function Yo(t){const n=t.children;if(n)for(let s=0;s<n.length;s++){const r=n[s];if(Yo(r),r.type!=="link"||typeof r.url!="string")continue;const i=mu.exec(r.url);if(!i||i.index===0)continue;const a=r.children&&r.children.length===1?r.children[0]:null;if(!a||a.type!=="text"||typeof a.value!="string")continue;const o=r.url.length-a.value.length;if(o<0||r.url.slice(o)!==a.value)continue;const c=i.index-o;if(c<=0)continue;const l=a.value.slice(c);a.value=a.value.slice(0,c),r.url=r.url.slice(0,i.index),n.splice(s+1,0,{type:"text",value:l}),s++}}function fu(){return t=>{Yo(t)}}const ur=d.memo(function({text:n,label:s=!1}){const r=nt(),[i,a]=d.useState(!1);return n?e.jsxs("button",{type:"button",className:"copy-btn",title:r("copy"),onClick:()=>{navigator.clipboard.writeText(n).then(()=>{a(!0),setTimeout(()=>a(!1),1200)})},children:[i?e.jsx(ss,{}):e.jsx(Ls,{}),s&&e.jsx("span",{children:r("copy")})]}):null});let Or=null;function gu(){return Or||(Or=Cr(()=>import("./mermaid.core-B8fKGWsc.js").then(t=>t.cb),__vite__mapDeps([0,1])).then(t=>t.default)),Or}let xu=0,Na=Promise.resolve();function vu(t,n){const s=Na.then(async()=>{const r=await gu(),i=getComputedStyle(document.documentElement),a=document.createElement("canvas");a.width=a.height=1;const o=a.getContext("2d"),c=l=>{o.clearRect(0,0,1,1),o.fillStyle=i.getPropertyValue(l).trim(),o.fillRect(0,0,1,1);const[p,u,f]=o.getImageData(0,0,1,1).data;return`rgb(${p}, ${u}, ${f})`};return r.initialize({startOnLoad:!1,securityLevel:"strict",theme:"base",themeVariables:{background:c("--bg-elev"),primaryColor:c("--accent-soft"),primaryBorderColor:c("--accent"),primaryTextColor:c("--text"),textColor:c("--text"),lineColor:c("--text-dim"),secondaryColor:c("--bg-elev2"),tertiaryColor:c("--bg"),fontFamily:i.getPropertyValue("--mono").trim()}}),r.render(t,n)});return Na=s.catch(()=>{}),s}function Xo({code:t}){const n=nt(),s=d.useId().replace(/[^a-zA-Z0-9]/g,""),[r,i]=d.useState(null),[a,o]=d.useState(null),c=d.useRef(null),[l,p]=d.useState(document.documentElement.dataset.appearance);return d.useEffect(()=>{const u=new MutationObserver(()=>p(document.documentElement.dataset.appearance));return u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-appearance"]}),()=>u.disconnect()},[]),d.useEffect(()=>{let u=!1;i(null),o(null);const f=`mermaid-${s}-${++xu}`;return vu(f,t).then(({svg:k})=>{u||i(k)}).catch(k=>{var j;u||o(k instanceof Error?k.message:String(k)),(j=document.getElementById(f))==null||j.remove()}),()=>{u=!0}},[t,s,l]),a?e.jsxs("div",{className:"mermaid-block mermaid-block-error",children:[e.jsx("div",{className:"mermaid-error-note",children:n("mermaidRenderFailed")}),e.jsxs("div",{className:"codeblock",children:[e.jsx(ur,{text:t}),e.jsx("pre",{children:e.jsx("code",{children:t})})]})]}):r?e.jsxs("div",{className:"mermaid-block",children:[e.jsx(ur,{text:t}),e.jsx("div",{ref:c,className:"mermaid-svg",dangerouslySetInnerHTML:{__html:r}})]}):e.jsx("div",{className:"mermaid-block mermaid-block-loading",children:e.jsx("div",{className:"mermaid-loading-note",children:n("mermaidRendering")})})}const ri=[vi,fu,Qo,Jo],Zo=[[ro,{detect:!0,ignoreMissing:!0}]],ku={p:({node:t,...n})=>{var s,r;return e.jsx("p",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})},li:({node:t,...n})=>{var s,r;return e.jsx("li",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})},h1:({node:t,...n})=>{var s,r;return e.jsx("h1",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})},h2:({node:t,...n})=>{var s,r;return e.jsx("h2",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})},h3:({node:t,...n})=>{var s,r;return e.jsx("h3",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})},h4:({node:t,...n})=>{var s,r;return e.jsx("h4",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})},h5:({node:t,...n})=>{var s,r;return e.jsx("h5",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})},h6:({node:t,...n})=>{var s,r;return e.jsx("h6",{...n,"data-source-start":(s=t==null?void 0:t.position)==null?void 0:s.start.line,"data-source-end":(r=t==null?void 0:t.position)==null?void 0:r.end.line})}};function el({text:t,imageSrc:n,sourceLines:s,fileLinks:r}){const i=jc(),a=i&&!s?[...ri,hu(i.files.map(o=>o.path))]:ri;return e.jsx(jr,{remarkPlugins:a,rehypePlugins:Zo,components:{pre:({children:o,...c})=>e.jsx(tl,{...c,fileLinks:r,children:o}),a:({node:o,href:c,children:l,...p})=>{const u=/^https?:\/\/github\.com\/[^/]+\/[^/]+\/pull\/(\d+)(?:[?#].*)?$/.exec(c??"");return e.jsx("a",{...p,href:c,className:u?"pr-reference":void 0,onClick:f=>{if(c!=null&&c.startsWith("#pi-change=")){f.preventDefault();const k=decodeURIComponent(c.slice(11));i==null||i.show(i.files,k)}else if(r&&(c!=null&&c.startsWith("#pi-file=")))f.preventDefault(),nl(c.slice(9));else if(i&&c&&!/^(?:[a-z]+:|#|\/\/)/i.test(c)&&/\.[a-z0-9]+(?:#L\d+)?$/i.test(c)){f.preventDefault();const[k,j]=c.split("#L"),I=i.files.find(E=>E.path===k);I?i.show(i.files,I.path):window.dispatchEvent(new CustomEvent("pi-harness:open-tool-file",{detail:{path:decodeURIComponent(k),line:Number(j)||1}}))}},children:u?`#${u[1]}`:l})},...s?ku:{},...n?{img:({node:o,src:c,...l})=>e.jsx("img",{...l,src:n(c??"")})}:{}},children:t})}const Fn=d.memo(function({text:n,imageSrc:s,sourceLines:r,fileLinks:i}){return e.jsx("div",{className:"md",children:e.jsx(el,{text:n,imageSrc:s,sourceLines:r,fileLinks:i})})});function tl({children:t,fileLinks:n,showLanguage:s,...r}){var l;if(bu(t))return e.jsx(Xo,{code:pr(t)});const i=n&&yu(t),a=pr(t),o=Array.isArray(t)?t[0]:t,c=o&&typeof o=="object"&&"props"in o?(l=/language-([\w+-]+)/.exec(String(o.props.className??"")))==null?void 0:l[1]:void 0;return e.jsxs("div",{className:`codeblock${i?" ascii-table":""}`,children:[s?e.jsxs("div",{className:"codeblock-heading",children:[e.jsx("span",{children:c}),e.jsx(ur,{text:a,label:!0})]}):e.jsx(ur,{text:a}),e.jsx("pre",{...r,children:i?e.jsx("code",{children:wu(a)}):t})]})}function yu(t){var s;const n=Array.isArray(t)?t[0]:t;return!!n&&typeof n=="object"&&"props"in n&&/(^|\s)language-ascii-table(\s|$)/.test(String(((s=n.props)==null?void 0:s.className)??""))}function nl(t){const n=/^(.+):([1-9]\d*)$/.exec(t);if(n)try{window.dispatchEvent(new CustomEvent("pi-harness:open-tool-file",{detail:{path:decodeURIComponent(n[1]),line:Number(n[2])}}))}catch{}}function wu(t){const n=/((?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]+):([1-9]\d*)/g,s=[];let r=0;for(const i of t.matchAll(n)){const a=i.index;a>r&&s.push(t.slice(r,a));const o=`${i[1]}:${i[2]}`;s.push(e.jsx("a",{href:`#pi-file=${encodeURIComponent(i[1])}:${i[2]}`,onClick:c=>{c.preventDefault(),nl(`${encodeURIComponent(i[1])}:${i[2]}`)},children:o},a)),r=a+i[0].length}return r<t.length&&s.push(t.slice(r)),s}function bu(t){var r;const n=Array.isArray(t)?t[0]:t;if(!n||typeof n!="object"||!("props"in n))return!1;const s=(r=n.props)==null?void 0:r.className;return typeof s=="string"&&/(^|\s)language-mermaid(\s|$)/.test(s)}function pr(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(pr).join("");if(t&&typeof t=="object"&&"props"in t){const n=t.props;return pr(n==null?void 0:n.children)}return""}function ju({messages:t,live:n,streaming:s,toolStatuses:r,model:i,contextPercent:a,disabled:o,onNew:c,onClose:l,canJump:p,jump:u,composer:f,quickQuestions:k,onQuickQuestion:j,revisions:I,onViewChange:E,onUndo:$,onResend:N,error:R,conversationId:y,thinkingWrap:L,connected:b,silenceNotified:F,recovery:B,onStop:ie}){const Q=nt(),q=d.useRef(null),ke=d.useRef(!0),[Re,O]=d.useState(null),[_e,M]=d.useState(""),[V,ve]=d.useState(60),ye=d.useMemo(()=>s&&n&&!t.some(ae=>ae.id===n.id)?[...t,{...n,role:"assistant"}]:t,[t,n,s]),oe=d.useMemo(()=>new Map(t.filter(ae=>ae.role==="toolResult"&&ae.toolCallId).map(ae=>[ae.toolCallId,ae])),[t]);d.useEffect(()=>{ke.current&&q.current&&(q.current.scrollTop=q.current.scrollHeight)},[t,n,s]);const Fe=d.useMemo(()=>{const ae=ye.map(z=>z.role).lastIndexOf("user");return new Set(s?ye.slice(Math.max(0,ae)).flatMap(z=>z.content.filter(Z=>Z.type==="toolCall").map(Z=>Z.type==="toolCall"?Z.id:"")):[])},[ye,s]),[U,fe]=d.useState(()=>window.matchMedia("(max-width: 1099px)").matches);d.useEffect(()=>{const ae=window.matchMedia("(max-width: 1099px)"),z=()=>fe(ae.matches);return ae.addEventListener("change",z),()=>ae.removeEventListener("change",z)},[]);const ce=ae=>{const z=oe.get(ae.id),Z=r.get(ae.id),W=(z==null?void 0:z.isError)||(Z==null?void 0:Z.isError),ge=Fe.has(ae.id),Ie=!!z||!!Z&&!Z.running;let Ae="";try{const we=JSON.parse(ae.argumentsText??"{}");Ae=String(we.path??we.file_path??we.command??"").split(`
|
|
47
|
-
`)[0]}catch{}const re=z==null?void 0:z.content.filter(we=>we.type==="text").map(we=>we.type==="text"?String(we.text??""):"").join(`
|
|
48
|
-
`);return e.jsxs("details",{className:`wiki-chat-tool ${W?"error":Ie?"done":"pending"}`,children:[e.jsxs("summary",{children:[e.jsx("span",{children:W?e.jsx(qt,{}):Ie?e.jsx(ss,{}):ge?e.jsx(Gc,{}):"−"}),e.jsxs("code",{children:[ae.name," ",Ae]}),e.jsxs("small",{children:[Q(W?"error":Ie?"done":ge?"running":"wikiToolInterrupted"),(Z==null?void 0:Z.durationMs)!==void 0?` · ${(Z.durationMs/1e3).toFixed(1)}s`:""]})]}),e.jsx("pre",{children:re||ae.argumentsText||ae.name})]},ae.id)};return e.jsxs("aside",{className:"wiki-chat-panel","aria-label":Q("wikiChatPanel"),role:U?"dialog":void 0,"aria-modal":U||void 0,onKeyDown:ae=>{var Z,W;if(!U||ae.key!=="Tab")return;const z=[...ae.currentTarget.querySelectorAll("button:not(:disabled), textarea, summary, a[href]")].filter(ge=>ge.getClientRects().length);ae.shiftKey&&document.activeElement===z[0]?(ae.preventDefault(),(Z=z.at(-1))==null||Z.focus()):!ae.shiftKey&&document.activeElement===z.at(-1)&&(ae.preventDefault(),(W=z[0])==null||W.focus())},children:[e.jsxs("header",{children:[e.jsx("img",{className:"wiki-chat-brand",src:"/icon/1a-mark.svg",alt:""}),e.jsx("strong",{children:Q("wikiChatTitle")}),e.jsxs("span",{className:"wiki-chat-model",title:i==null?void 0:i.id,children:[(i==null?void 0:i.name)||(i==null?void 0:i.id)||Q("wikiNoModel"),a!=null&&a>0?` · ${Q("wikiChatContext",{percent:Math.round(a)})}`:""]}),e.jsx("button",{disabled:o,onClick:c,children:Q("newChat")}),e.jsx("button",{"aria-label":Q("wikiCloseChat"),onClick:l,children:e.jsx(qt,{})})]}),R,e.jsxs("div",{className:`wiki-chat-messages${ye.length?"":" empty"}`,ref:q,onScroll:ae=>{const z=ae.currentTarget;ke.current=z.scrollHeight-z.scrollTop-z.clientHeight<80},children:[ye.length>V&&e.jsx("button",{className:"wiki-chat-earlier",onClick:()=>{ke.current=!1,ve(ae=>ae+60)},children:Q("wikiEarlierMessages")}),!ye.length&&e.jsxs("div",{className:"wiki-chat-empty",children:[e.jsx("p",{children:Q("wikiChatEmpty")}),e.jsx("div",{className:"wiki-quick-questions",children:k.map(ae=>e.jsx("button",{disabled:o||!b||s,onClick:()=>j(ae),children:ae},ae))})]}),ye.slice(-V).map(ae=>{if(!["user","assistant"].includes(ae.role))return null;const z=ae.content.filter(Z=>Z.type==="text").map(Z=>"text"in Z?Z.text:"").join(`
|
|
49
|
-
`);return e.jsxs("div",{className:`wiki-chat-message ${ae.role}`,children:[ae.content.map((Z,W)=>{if(Z.type==="thinking"){const ge=Z;return e.jsx(qo,{thinking:ge.thinking,durationMs:ge.durationMs,streaming:s&&ae.id===(n==null?void 0:n.id)&&W===ae.content.length-1,wrap:L},W)}if(Z.type==="toolCall")return ce(Z);if(Z.type==="image"&&typeof Z.dataUrl=="string")return e.jsx("img",{src:Z.dataUrl,alt:Q("attachment")},W);if(Z.type!=="text"||typeof Z.text!="string"||!Z.text.trim())return null;if(ae.role==="user"){const ge=/\n\n(?:范围|Scope): /.exec(Z.text);return e.jsx("div",{children:e.jsx(Fn,{text:ge?Z.text.slice(0,ge.index):Z.text})},W)}return e.jsx("div",{className:"wiki-chat-answer",children:tu(Z.text).map((ge,Ie)=>ge.kind==="text"?e.jsx(Fn,{text:ge.text},Ie):e.jsxs("section",{className:"wiki-suggestion",children:[e.jsxs("header",{children:[e.jsx("strong",{children:ge.title}),ge.section!==null&&p(ge.section)&&e.jsx("button",{onClick:()=>u(ge.section),children:Q("wikiJumpSection",{section:ge.section})})]}),ge.text&&e.jsx(Fn,{text:ge.text})]},Ie))},W)}),ae.role==="user"&&e.jsxs("details",{className:"wiki-message-actions",children:[e.jsx("summary",{"aria-label":Q("wikiMessageActions"),children:e.jsx(Ss,{})}),e.jsxs("div",{role:"menu",children:[e.jsx("button",{role:"menuitem",onClick:Z=>{var W;(W=Z.currentTarget.closest("details"))==null||W.removeAttribute("open"),O(z)},children:Q("wikiFullRequest")}),e.jsx("button",{role:"menuitem",onClick:Z=>{var W;(W=Z.currentTarget.closest("details"))==null||W.removeAttribute("open"),navigator.clipboard.writeText(z).catch(ge=>M(ge.message))},children:Q("copy")}),e.jsx("button",{role:"menuitem",disabled:o||s,onClick:Z=>{var W;(W=Z.currentTarget.closest("details"))==null||W.removeAttribute("open"),N(z)},children:Q("wikiResend")})]})]}),ae.role==="assistant"&&I.filter(Z=>Z.author==="pi"&&Z.conversationId===y&&Z.assistantTimestamp!==void 0&&Z.assistantTimestamp===ae.timestamp&&Z.changes.length>0).map(Z=>e.jsxs("div",{className:"wiki-reply-change",children:[e.jsx(ss,{}),e.jsxs("span",{children:[Q("wikiReplyChanged",{file:Z.changes.length===1?Z.changes[0].path.split("/").at(-1):Q("wikiFileCount",{count:Z.changes.length})})," · ",e.jsxs("em",{children:["+",Z.changes.reduce((W,ge)=>W+ge.additions,0)]})," ",e.jsxs("b",{children:["−",Z.changes.reduce((W,ge)=>W+ge.deletions,0)]})]}),e.jsx("button",{onClick:()=>E(Z),children:Q("wikiViewChange")}),e.jsx("button",{disabled:o||s,onClick:()=>$(Z),children:Q(Z.changes.every(W=>W.undone)?"wikiRedo":"wikiUndo")})]},Z.id)),ae.errorMessage&&e.jsx("p",{role:"alert",className:"wiki-chat-error",children:ae.errorMessage})]},ae.id)}),s&&e.jsx(Go,{onStop:ie,state:{recovery:B,messages:t,streamingMessage:n,isStreaming:s,conversationId:y,model:i??null},connected:b,silenceNotified:F,toolStatuses:r})]}),_e&&e.jsx("p",{role:"alert",children:_e}),e.jsx("footer",{children:f}),Re!==null&&e.jsx(Ni,{title:Q("wikiFullRequest"),onClose:()=>O(null),children:e.jsx("pre",{className:"wiki-full-request",children:Re})})]})}function Cu(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),e.jsx("path",{d:"M3 9h18M3 14h18M9 9v11M15 9v11"})]})}function Su(){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M4 4v16M9 6h12M9 12h12M9 18h8"})})}function Nu(){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M3 12h18M7 8l-4 4 4 4M17 8l4 4-4 4"})})}function Eu(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 12h8"},child:[]},{tag:"path",attr:{d:"M4 18V6"},child:[]},{tag:"path",attr:{d:"M12 18V6"},child:[]},{tag:"path",attr:{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"},child:[]},{tag:"path",attr:{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"},child:[]}]})(t)}function Tu(t){return ot({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 12h8"},child:[]},{tag:"path",attr:{d:"M4 18V6"},child:[]},{tag:"path",attr:{d:"M12 18V6"},child:[]},{tag:"path",attr:{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"},child:[]}]})(t)}function Ru({popup:t,onClose:n,children:s}){const r=d.useRef(null);return d.useLayoutEffect(()=>{var a;const i=r.current;i&&(i.style.left=`${Math.max(8,Math.min(t.x,innerWidth-i.offsetWidth-8))}px`,i.style.top=`${Math.max(8,Math.min(t.y,innerHeight-i.offsetHeight-8))}px`,(a=i.querySelector('input, [tabindex="0"], button'))==null||a.focus())},[t]),d.useEffect(()=>{const i=a=>{var o;(o=r.current)!=null&&o.contains(a.target)||n()};return window.addEventListener("pointerdown",i),window.addEventListener("resize",n),()=>{window.removeEventListener("pointerdown",i),window.removeEventListener("resize",n)}},[n]),mn.createPortal(e.jsx("div",{ref:r,className:`wiki-insert-popover wiki-${t.kind}-popover`,role:"dialog",onKeyDown:i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),n())},style:{left:t.x,top:t.y},children:s}),document.body)}function Iu({readOnly:t,focused:n,onWidth:s,items:r,popup:i,onPrepare:a,onSelect:o,onPopup:c}){const l=nt(),p=[r.slice(0,3),r.slice(3,9),r.slice(9)],u=(f,k)=>{const j=k.getBoundingClientRect();c({kind:f,x:j.left,y:j.bottom+6})};return e.jsxs("div",{className:"wiki-insert-toolbar",role:"toolbar","aria-label":l("richInsertMenu"),children:[p.map((f,k)=>e.jsx("div",{className:"wiki-tool-group",children:f.map(j=>{const{id:I}=j,E=I==="bt2"?e.jsx(Tu,{}):I==="bt3"?e.jsx(Eu,{}):j.icon,$=I==="bg"?"table":I==="dmk"?"code":void 0;return e.jsx("button",{type:"button",disabled:t,title:`${j.label} · ${j.help}${j.hint?` · ${j.hint}`:""}`,"aria-label":j.label,"aria-expanded":$?(i==null?void 0:i.kind)===$:void 0,onMouseDown:N=>{N.preventDefault(),a()},onClick:N=>$?u($,N.currentTarget):o(I),children:E},I)})},k)),e.jsx("button",{type:"button",className:"wiki-width-toggle",title:l(n?"wikiStandardWidth":"wikiWideWidth"),"aria-label":l(n?"wikiStandardWidth":"wikiWideWidth"),"aria-pressed":n,onMouseDown:f=>f.preventDefault(),onClick:s,children:e.jsx(Nu,{})})]})}function Lu({onInsert:t}){const n=nt(),[s,r]=d.useState({columns:3,rows:3});return e.jsxs("div",{className:"wiki-table-picker",tabIndex:0,role:"group","aria-label":n("wikiTableSize"),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),t(s.columns,s.rows)),i.key.startsWith("Arrow")&&(i.preventDefault(),r(a=>({columns:Math.max(1,Math.min(8,a.columns+(i.key==="ArrowRight"?1:i.key==="ArrowLeft"?-1:0))),rows:Math.max(1,Math.min(6,a.rows+(i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:0)))})))},children:[e.jsx("div",{className:"wiki-table-grid",children:Array.from({length:48},(i,a)=>{const o=a%8+1,c=Math.floor(a/8)+1;return e.jsx("button",{type:"button",tabIndex:-1,"aria-label":n("wikiTableDimensions",{columns:o,rows:c}),className:o<=s.columns&&c<=s.rows?"selected":"",onMouseEnter:()=>r({columns:o,rows:c}),onClick:()=>t(o,c)},a)})}),e.jsxs("footer",{children:[e.jsx("span",{"aria-live":"polite",children:n("wikiTableDimensions",s)}),e.jsx("small",{children:n("wikiTableHeader")})]})]})}const Ea=["","bash","python","ts","json","yaml","sql","mermaid"];function Mu({onInsert:t}){const n=nt(),[s,r]=d.useState(""),[i,a]=d.useState(-1),o=Ea.filter(l=>(l||n("wikiCodeAutomatic")).toLowerCase().includes(s.toLowerCase())),c=["wikiCodeAutomaticHint","wikiCodeShell","wikiCodePython","wikiCodeTypescript","wikiCodeData","wikiCodeConfig","wikiCodeQuery","wikiCodeDiagram"];return e.jsxs("div",{className:"wiki-language-picker",onKeyDown:l=>{(l.key==="ArrowDown"||l.key==="ArrowUp")&&(l.preventDefault(),a(p=>o.length?(p+(l.key==="ArrowDown"?1:-1)+o.length)%o.length:-1)),l.key==="Enter"&&(l.preventDefault(),t(o[i]??""))},children:[e.jsx("input",{autoFocus:!0,placeholder:n("wikiSearchLanguage"),"aria-label":n("wikiSearchLanguage"),value:s,onChange:l=>{r(l.target.value),a(-1)},role:"combobox","aria-expanded":"true","aria-controls":"wiki-code-languages","aria-activedescendant":i>=0?`wiki-code-language-${i}`:void 0}),e.jsx("div",{id:"wiki-code-languages",role:"listbox",children:o.map((l,p)=>e.jsxs("button",{type:"button",role:"option","aria-selected":p===i,id:`wiki-code-language-${p}`,onMouseEnter:()=>a(p),onClick:()=>t(l),children:[e.jsx("code",{children:l||n("wikiCodeAutomatic")}),e.jsx("small",{children:n(c[Ea.indexOf(l)])})]},l))})]})}function sl(t,n){if(!t||/^(?:[a-z]+:|\/\/|#)/i.test(t))return t;try{const s=n.path.replace(/\\/g,"/").split("/").slice(0,-1).map(encodeURIComponent).join("/"),r=decodeURIComponent(new URL(t,`https://workspace.invalid/${s?s+"/":""}`).pathname).slice(1);return Sn(`/api/file?clientId=${encodeURIComponent(fn())}&cwd=${encodeURIComponent(n.cwd)}&path=${encodeURIComponent(r)}`)}catch{return t}}function Hs(t){const n=t.cloneNode(!0);return n.querySelectorAll("br").forEach(s=>s.replaceWith(`
|
|
50
|
-
`)),n.textContent??""}Pt.registerLanguage("bash",Wl);Pt.registerLanguage("c",ql);Pt.registerLanguage("cpp",zl);Pt.registerLanguage("csharp",Vl);Pt.registerLanguage("css",Kl);Pt.registerLanguage("diff",Gl);Pt.registerLanguage("go",Jl);Pt.registerLanguage("graphql",Ql);Pt.registerLanguage("ini",Yl);Pt.registerLanguage("java",Xl);Pt.registerLanguage("javascript",Zl);Pt.registerLanguage("json",ec);Pt.registerLanguage("kotlin",tc);Pt.registerLanguage("less",nc);Pt.registerLanguage("lua",sc);Pt.registerLanguage("makefile",rc);Pt.registerLanguage("php",ic);Pt.registerLanguage("python",ac);Pt.registerLanguage("r",oc);Pt.registerLanguage("ruby",lc);Pt.registerLanguage("rust",cc);Pt.registerLanguage("scss",dc);Pt.registerLanguage("sql",uc);Pt.registerLanguage("swift",pc);Pt.registerLanguage("typescript",hc);Pt.registerLanguage("xml",mc);Pt.registerLanguage("yaml",fc);function bs(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ks(t,n){if(!n||!Pt.getLanguage(n))return bs(t);try{return Pt.highlight(t,{language:n,ignoreIllegals:!0}).value}catch{return bs(t)}}function Pu(t,n){if(n&&n!=="plaintext")return Ks(t,n);try{return Pt.highlightAuto(t,["bash","python","typescript","json","yaml","sql"]).value}catch{return bs(t)}}const Au={json:"json",jsonc:"json",ts:"typescript",mts:"typescript",cts:"typescript",tsx:"typescript",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"javascript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",kts:"kotlin",swift:"swift",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",cs:"csharp",php:"php",sql:"sql",css:"css",scss:"scss",less:"less",html:"xml",htm:"xml",xml:"xml",svg:"xml",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",zsh:"bash",toml:"ini",ini:"ini",graphql:"graphql",gql:"graphql",lua:"lua",r:"r",makefile:"makefile",diff:"diff",patch:"diff"};function Ps(t){var s,r;const n=(r=(s=t.split(/[\\/]/).pop())==null?void 0:s.split(".").pop())==null?void 0:r.toLowerCase();return n&&Au[n]||null}function rl(t,n){const s=t.split(`
|
|
51
|
-
`);if(!n||!Pt.getLanguage(n))return s.map(bs);let r;try{r=Pt.highlight(t,{language:n,ignoreIllegals:!0}).value}catch{return s.map(bs)}const i=[],a=[];let o="",c=0;for(;c<r.length;){if(r[c]==="<"){const f=r.indexOf(">",c);if(f===-1){o+=r.slice(c);break}const k=r.slice(c,f+1);k.startsWith("</")?a.pop():k.endsWith("/>")||a.push(k),o+=k,c=f+1;continue}const l=r.indexOf(`
|
|
52
|
-
`,c),p=r.indexOf("<",c),u=Math.min(l===-1?Number.POSITIVE_INFINITY:l,p===-1?Number.POSITIVE_INFINITY:p);if(u===Number.POSITIVE_INFINITY){o+=r.slice(c);break}o+=r.slice(c,u),u===l?(i.push(o+"</span>".repeat(a.length)),o=a.join(""),c=u+1):c=u}return i.push(o+"</span>".repeat(a.length)),i.length===s.length?i:s.map(bs)}const Du=t=>{if(["hljs-keyword","hljs-type","hljs-literal","hljs-selector-tag"].some(n=>t.contains(n)))return"keyword";if(["hljs-string","hljs-regexp","hljs-addition"].some(n=>t.contains(n)))return"string";if(["hljs-number","hljs-attr","hljs-symbol","hljs-bullet"].some(n=>t.contains(n)))return"number";if(["hljs-title","hljs-built_in","hljs-section"].some(n=>t.contains(n)))return"title";if(["hljs-comment","hljs-quote","hljs-meta","hljs-deletion"].some(n=>t.contains(n)))return"comment"};function $u(t=!1){const n=CSS.highlights,s=window.Highlight,r=new Map,i=a=>{for(const{group:o,range:c}of r.get(a)??[]){const l=`rich-code-${o}`,p=n==null?void 0:n.get(l);p==null||p.delete(c),(p==null?void 0:p.size)===0&&(n==null||n.delete(l))}r.delete(a)};return{update(a){var N,R,y,L;if(!n||!s)return;for(const b of r.keys())b.isConnected||i(b);i(a);const o=Hs(a);if(!o)return;const c=((N=a.className.match(/language-([^\s]+)/))==null?void 0:N[1])??"",l=document.createElement("template");l.innerHTML=(t?Pu:Ks)(o,c==="toml"?"ini":c);const p=[],u=document.createTreeWalker(a,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT);let f,k=0;for(;f=u.nextNode();){if(f.nodeName==="BR"){k++;continue}f.nodeType===Node.TEXT_NODE&&(p.push({node:f,start:k,end:k+(((R=f.textContent)==null?void 0:R.length)??0)}),k+=((y=f.textContent)==null?void 0:y.length)??0)}const j=[],I=(b,F,B)=>{if(F===B)return;const ie=p.find(O=>O.end>F),Q=[...p].reverse().find(O=>O.start<B);if(!ie||!Q)return;const q=document.createRange();q.setStart(ie.node,Math.max(0,F-ie.start)),q.setEnd(Q.node,Math.min(Q.node.length,B-Q.start));const ke=`rich-code-${b}`;let Re=n.get(ke);Re||(Re=new s,Re.priority=b==="plain"?0:1,n.set(ke,Re)),Re.add(q),j.push({group:b,range:q})};I("plain",0,((L=p.at(-1))==null?void 0:L.end)??0);let E=0;const $=(b,F)=>{var ie;if(b.nodeType===Node.TEXT_NODE){const Q=E+(((ie=b.textContent)==null?void 0:ie.length)??0);F&&I(F,E,Q),E=Q;return}const B=b instanceof Element?Du(b.classList)??F:F;b.childNodes.forEach(Q=>$(Q,B))};$(l.content),r.set(a,j)},dispose(){for(const a of r.keys())i(a)}}}var is={},ms={};/**
|
|
53
|
-
* @license React
|
|
54
|
-
* react-dom-server-legacy.browser.production.min.js
|
|
55
|
-
*
|
|
56
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
57
|
-
*
|
|
58
|
-
* This source code is licensed under the MIT license found in the
|
|
59
|
-
* LICENSE file in the root directory of this source tree.
|
|
60
|
-
*/var Ta;function Fu(){if(Ta)return ms;Ta=1;var t=io();function n(h){for(var v="https://reactjs.org/docs/error-decoder.html?invariant="+h,S=1;S<arguments.length;S++)v+="&args[]="+encodeURIComponent(arguments[S]);return"Minified React error #"+h+"; visit "+v+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=Object.prototype.hasOwnProperty,r=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,i={},a={};function o(h){return s.call(a,h)?!0:s.call(i,h)?!1:r.test(h)?a[h]=!0:(i[h]=!0,!1)}function c(h,v,S,P,de,le,je){this.acceptsBooleans=v===2||v===3||v===4,this.attributeName=P,this.attributeNamespace=de,this.mustUseProperty=S,this.propertyName=h,this.type=v,this.sanitizeURL=le,this.removeEmptyString=je}var l={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(h){l[h]=new c(h,0,!1,h,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(h){var v=h[0];l[v]=new c(v,1,!1,h[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(h){l[h]=new c(h,2,!1,h.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(h){l[h]=new c(h,2,!1,h,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(h){l[h]=new c(h,3,!1,h.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(h){l[h]=new c(h,3,!0,h,null,!1,!1)}),["capture","download"].forEach(function(h){l[h]=new c(h,4,!1,h,null,!1,!1)}),["cols","rows","size","span"].forEach(function(h){l[h]=new c(h,6,!1,h,null,!1,!1)}),["rowSpan","start"].forEach(function(h){l[h]=new c(h,5,!1,h.toLowerCase(),null,!1,!1)});var p=/[\-:]([a-z])/g;function u(h){return h[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(h){var v=h.replace(p,u);l[v]=new c(v,1,!1,h,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(h){var v=h.replace(p,u);l[v]=new c(v,1,!1,h,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(h){var v=h.replace(p,u);l[v]=new c(v,1,!1,h,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(h){l[h]=new c(h,1,!1,h.toLowerCase(),null,!1,!1)}),l.xlinkHref=new c("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(h){l[h]=new c(h,1,!1,h.toLowerCase(),null,!0,!0)});var f={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},k=["Webkit","ms","Moz","O"];Object.keys(f).forEach(function(h){k.forEach(function(v){v=v+h.charAt(0).toUpperCase()+h.substring(1),f[v]=f[h]})});var j=/["'&<>]/;function I(h){if(typeof h=="boolean"||typeof h=="number")return""+h;h=""+h;var v=j.exec(h);if(v){var S="",P,de=0;for(P=v.index;P<h.length;P++){switch(h.charCodeAt(P)){case 34:v=""";break;case 38:v="&";break;case 39:v="'";break;case 60:v="<";break;case 62:v=">";break;default:continue}de!==P&&(S+=h.substring(de,P)),de=P+1,S+=v}h=de!==P?S+h.substring(de,P):S}return h}var E=/([A-Z])/g,$=/^ms-/,N=Array.isArray;function R(h,v){return{insertionMode:h,selectedValue:v}}function y(h,v,S){switch(v){case"select":return R(1,S.value!=null?S.value:S.defaultValue);case"svg":return R(2,null);case"math":return R(3,null);case"foreignObject":return R(1,null);case"table":return R(4,null);case"thead":case"tbody":case"tfoot":return R(5,null);case"colgroup":return R(7,null);case"tr":return R(6,null)}return 4<=h.insertionMode||h.insertionMode===0?R(1,null):h}var L=new Map;function b(h,v,S){if(typeof S!="object")throw Error(n(62));v=!0;for(var P in S)if(s.call(S,P)){var de=S[P];if(de!=null&&typeof de!="boolean"&&de!==""){if(P.indexOf("--")===0){var le=I(P);de=I((""+de).trim())}else{le=P;var je=L.get(le);je!==void 0||(je=I(le.replace(E,"-$1").toLowerCase().replace($,"-ms-")),L.set(le,je)),le=je,de=typeof de=="number"?de===0||s.call(f,P)?""+de:de+"px":I((""+de).trim())}v?(v=!1,h.push(' style="',le,":",de)):h.push(";",le,":",de)}}v||h.push('"')}function F(h,v,S,P){switch(S){case"style":b(h,v,P);return;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<S.length)||S[0]!=="o"&&S[0]!=="O"||S[1]!=="n"&&S[1]!=="N"){if(v=l.hasOwnProperty(S)?l[S]:null,v!==null){switch(typeof P){case"function":case"symbol":return;case"boolean":if(!v.acceptsBooleans)return}switch(S=v.attributeName,v.type){case 3:P&&h.push(" ",S,'=""');break;case 4:P===!0?h.push(" ",S,'=""'):P!==!1&&h.push(" ",S,'="',I(P),'"');break;case 5:isNaN(P)||h.push(" ",S,'="',I(P),'"');break;case 6:!isNaN(P)&&1<=P&&h.push(" ",S,'="',I(P),'"');break;default:v.sanitizeURL&&(P=""+P),h.push(" ",S,'="',I(P),'"')}}else if(o(S)){switch(typeof P){case"function":case"symbol":return;case"boolean":if(v=S.toLowerCase().slice(0,5),v!=="data-"&&v!=="aria-")return}h.push(" ",S,'="',I(P),'"')}}}function B(h,v,S){if(v!=null){if(S!=null)throw Error(n(60));if(typeof v!="object"||!("__html"in v))throw Error(n(61));v=v.__html,v!=null&&h.push(""+v)}}function ie(h){var v="";return t.Children.forEach(h,function(S){S!=null&&(v+=S)}),v}function Q(h,v,S,P){h.push(Re(S));var de=S=null,le;for(le in v)if(s.call(v,le)){var je=v[le];if(je!=null)switch(le){case"children":S=je;break;case"dangerouslySetInnerHTML":de=je;break;default:F(h,P,le,je)}}return h.push(">"),B(h,de,S),typeof S=="string"?(h.push(I(S)),null):S}var q=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,ke=new Map;function Re(h){var v=ke.get(h);if(v===void 0){if(!q.test(h))throw Error(n(65,h));v="<"+h,ke.set(h,v)}return v}function O(h,v,S,P,de){switch(v){case"select":h.push(Re("select"));var le=null,je=null;for(gt in S)if(s.call(S,gt)){var Ge=S[gt];if(Ge!=null)switch(gt){case"children":le=Ge;break;case"dangerouslySetInnerHTML":je=Ge;break;case"defaultValue":case"value":break;default:F(h,P,gt,Ge)}}return h.push(">"),B(h,je,le),le;case"option":je=de.selectedValue,h.push(Re("option"));var dt=Ge=null,ut=null,gt=null;for(le in S)if(s.call(S,le)){var It=S[le];if(It!=null)switch(le){case"children":Ge=It;break;case"selected":ut=It;break;case"dangerouslySetInnerHTML":gt=It;break;case"value":dt=It;default:F(h,P,le,It)}}if(je!=null)if(S=dt!==null?""+dt:ie(Ge),N(je)){for(P=0;P<je.length;P++)if(""+je[P]===S){h.push(' selected=""');break}}else""+je===S&&h.push(' selected=""');else ut&&h.push(' selected=""');return h.push(">"),B(h,gt,Ge),Ge;case"textarea":h.push(Re("textarea")),gt=je=le=null;for(Ge in S)if(s.call(S,Ge)&&(dt=S[Ge],dt!=null))switch(Ge){case"children":gt=dt;break;case"value":le=dt;break;case"defaultValue":je=dt;break;case"dangerouslySetInnerHTML":throw Error(n(91));default:F(h,P,Ge,dt)}if(le===null&&je!==null&&(le=je),h.push(">"),gt!=null){if(le!=null)throw Error(n(92));if(N(gt)&&1<gt.length)throw Error(n(93));le=""+gt}return typeof le=="string"&&le[0]===`
|
|
61
|
-
`&&h.push(`
|
|
62
|
-
`),le!==null&&h.push(I(""+le)),null;case"input":h.push(Re("input")),dt=gt=Ge=le=null;for(je in S)if(s.call(S,je)&&(ut=S[je],ut!=null))switch(je){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,"input"));case"defaultChecked":dt=ut;break;case"defaultValue":Ge=ut;break;case"checked":gt=ut;break;case"value":le=ut;break;default:F(h,P,je,ut)}return gt!==null?F(h,P,"checked",gt):dt!==null&&F(h,P,"checked",dt),le!==null?F(h,P,"value",le):Ge!==null&&F(h,P,"value",Ge),h.push("/>"),null;case"menuitem":h.push(Re("menuitem"));for(var Gt in S)if(s.call(S,Gt)&&(le=S[Gt],le!=null))switch(Gt){case"children":case"dangerouslySetInnerHTML":throw Error(n(400));default:F(h,P,Gt,le)}return h.push(">"),null;case"title":h.push(Re("title")),le=null;for(It in S)if(s.call(S,It)&&(je=S[It],je!=null))switch(It){case"children":le=je;break;case"dangerouslySetInnerHTML":throw Error(n(434));default:F(h,P,It,je)}return h.push(">"),le;case"listing":case"pre":h.push(Re(v)),je=le=null;for(dt in S)if(s.call(S,dt)&&(Ge=S[dt],Ge!=null))switch(dt){case"children":le=Ge;break;case"dangerouslySetInnerHTML":je=Ge;break;default:F(h,P,dt,Ge)}if(h.push(">"),je!=null){if(le!=null)throw Error(n(60));if(typeof je!="object"||!("__html"in je))throw Error(n(61));S=je.__html,S!=null&&(typeof S=="string"&&0<S.length&&S[0]===`
|
|
63
|
-
`?h.push(`
|
|
64
|
-
`,S):h.push(""+S))}return typeof le=="string"&&le[0]===`
|
|
65
|
-
`&&h.push(`
|
|
66
|
-
`),le;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":h.push(Re(v));for(var dn in S)if(s.call(S,dn)&&(le=S[dn],le!=null))switch(dn){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,v));default:F(h,P,dn,le)}return h.push("/>"),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return Q(h,S,v,P);case"html":return de.insertionMode===0&&h.push("<!DOCTYPE html>"),Q(h,S,v,P);default:if(v.indexOf("-")===-1&&typeof S.is!="string")return Q(h,S,v,P);h.push(Re(v)),je=le=null;for(ut in S)if(s.call(S,ut)&&(Ge=S[ut],Ge!=null))switch(ut){case"children":le=Ge;break;case"dangerouslySetInnerHTML":je=Ge;break;case"style":b(h,P,Ge);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:o(ut)&&typeof Ge!="function"&&typeof Ge!="symbol"&&h.push(" ",ut,'="',I(Ge),'"')}return h.push(">"),B(h,je,le),le}}function _e(h,v,S){if(h.push('<!--$?--><template id="'),S===null)throw Error(n(395));return h.push(S),h.push('"></template>')}function M(h,v,S,P){switch(S.insertionMode){case 0:case 1:return h.push('<div hidden id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 2:return h.push('<svg aria-hidden="true" style="display:none" id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 3:return h.push('<math aria-hidden="true" style="display:none" id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 4:return h.push('<table hidden id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 5:return h.push('<table hidden><tbody id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 6:return h.push('<table hidden><tr id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');case 7:return h.push('<table hidden><colgroup id="'),h.push(v.segmentPrefix),v=P.toString(16),h.push(v),h.push('">');default:throw Error(n(397))}}function V(h,v){switch(v.insertionMode){case 0:case 1:return h.push("</div>");case 2:return h.push("</svg>");case 3:return h.push("</math>");case 4:return h.push("</table>");case 5:return h.push("</tbody></table>");case 6:return h.push("</tr></table>");case 7:return h.push("</colgroup></table>");default:throw Error(n(397))}}var ve=/[<\u2028\u2029]/g;function ye(h){return JSON.stringify(h).replace(ve,function(v){switch(v){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}function oe(h,v){return v=v===void 0?"":v,{bootstrapChunks:[],startInlineScript:"<script>",placeholderPrefix:v+"P:",segmentPrefix:v+"S:",boundaryPrefix:v+"B:",idPrefix:v,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1,generateStaticMarkup:h}}function Fe(h,v,S,P){return S.generateStaticMarkup?(h.push(I(v)),!1):(v===""?h=P:(P&&h.push("<!-- -->"),h.push(I(v)),h=!0),h)}var U=Object.assign,fe=Symbol.for("react.element"),ce=Symbol.for("react.portal"),ae=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),Z=Symbol.for("react.profiler"),W=Symbol.for("react.provider"),ge=Symbol.for("react.context"),Ie=Symbol.for("react.forward_ref"),Ae=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),we=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),xe=Symbol.for("react.scope"),_=Symbol.for("react.debug_trace_mode"),Se=Symbol.for("react.legacy_hidden"),J=Symbol.for("react.default_value"),De=Symbol.iterator;function G(h){if(h==null)return null;if(typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case ae:return"Fragment";case ce:return"Portal";case Z:return"Profiler";case z:return"StrictMode";case Ae:return"Suspense";case re:return"SuspenseList"}if(typeof h=="object")switch(h.$$typeof){case ge:return(h.displayName||"Context")+".Consumer";case W:return(h._context.displayName||"Context")+".Provider";case Ie:var v=h.render;return h=h.displayName,h||(h=v.displayName||v.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case we:return v=h.displayName||null,v!==null?v:G(h.type)||"Memo";case A:v=h._payload,h=h._init;try{return G(h(v))}catch{}}return null}var Oe={};function Ne(h,v){if(h=h.contextTypes,!h)return Oe;var S={},P;for(P in h)S[P]=v[P];return S}var Ee=null;function et(h,v){if(h!==v){h.context._currentValue2=h.parentValue,h=h.parent;var S=v.parent;if(h===null){if(S!==null)throw Error(n(401))}else{if(S===null)throw Error(n(401));et(h,S)}v.context._currentValue2=v.value}}function Ce(h){h.context._currentValue2=h.parentValue,h=h.parent,h!==null&&Ce(h)}function be(h){var v=h.parent;v!==null&&be(v),h.context._currentValue2=h.value}function ze(h,v){if(h.context._currentValue2=h.parentValue,h=h.parent,h===null)throw Error(n(402));h.depth===v.depth?et(h,v):ze(h,v)}function tt(h,v){var S=v.parent;if(S===null)throw Error(n(402));h.depth===S.depth?et(h,S):tt(h,S),v.context._currentValue2=v.value}function Ye(h){var v=Ee;v!==h&&(v===null?be(h):h===null?Ce(v):v.depth===h.depth?et(v,h):v.depth>h.depth?ze(v,h):tt(v,h),Ee=h)}var Le={isMounted:function(){return!1},enqueueSetState:function(h,v){h=h._reactInternals,h.queue!==null&&h.queue.push(v)},enqueueReplaceState:function(h,v){h=h._reactInternals,h.replace=!0,h.queue=[v]},enqueueForceUpdate:function(){}};function Xe(h,v,S,P){var de=h.state!==void 0?h.state:null;h.updater=Le,h.props=S,h.state=de;var le={queue:[],replace:!1};h._reactInternals=le;var je=v.contextType;if(h.context=typeof je=="object"&&je!==null?je._currentValue2:P,je=v.getDerivedStateFromProps,typeof je=="function"&&(je=je(S,de),de=je==null?de:U({},de,je),h.state=de),typeof v.getDerivedStateFromProps!="function"&&typeof h.getSnapshotBeforeUpdate!="function"&&(typeof h.UNSAFE_componentWillMount=="function"||typeof h.componentWillMount=="function"))if(v=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),v!==h.state&&Le.enqueueReplaceState(h,h.state,null),le.queue!==null&&0<le.queue.length)if(v=le.queue,je=le.replace,le.queue=null,le.replace=!1,je&&v.length===1)h.state=v[0];else{for(le=je?v[0]:h.state,de=!0,je=je?1:0;je<v.length;je++){var Ge=v[je];Ge=typeof Ge=="function"?Ge.call(h,le,S,P):Ge,Ge!=null&&(de?(de=!1,le=U({},le,Ge)):U(le,Ge))}h.state=le}else le.queue=null}var vt={id:1,overflow:""};function se(h,v,S){var P=h.id;h=h.overflow;var de=32-Ue(P)-1;P&=~(1<<de),S+=1;var le=32-Ue(v)+de;if(30<le){var je=de-de%5;return le=(P&(1<<je)-1).toString(32),P>>=je,de-=je,{id:1<<32-Ue(v)+de|S<<de|P,overflow:le+h}}return{id:1<<le|S<<de|P,overflow:h}}var Ue=Math.clz32?Math.clz32:X,w=Math.log,H=Math.LN2;function X(h){return h>>>=0,h===0?32:31-(w(h)/H|0)|0}function me(h,v){return h===v&&(h!==0||1/h===1/v)||h!==h&&v!==v}var $e=typeof Object.is=="function"?Object.is:me,Pe=null,st=null,lt=null,g=null,ne=!1,We=!1,He=0,ct=null,ft=0;function Mt(){if(Pe===null)throw Error(n(321));return Pe}function Dt(){if(0<ft)throw Error(n(312));return{memoizedState:null,queue:null,next:null}}function $t(){return g===null?lt===null?(ne=!1,lt=g=Dt()):(ne=!0,g=lt):g.next===null?(ne=!1,g=g.next=Dt()):(ne=!0,g=g.next),g}function Ft(){st=Pe=null,We=!1,lt=null,ft=0,g=ct=null}function Yt(h,v){return typeof v=="function"?v(h):v}function Ut(h,v,S){if(Pe=Mt(),g=$t(),ne){var P=g.queue;if(v=P.dispatch,ct!==null&&(S=ct.get(P),S!==void 0)){ct.delete(P),P=g.memoizedState;do P=h(P,S.action),S=S.next;while(S!==null);return g.memoizedState=P,[P,v]}return[g.memoizedState,v]}return h=h===Yt?typeof v=="function"?v():v:S!==void 0?S(v):v,g.memoizedState=h,h=g.queue={last:null,dispatch:null},h=h.dispatch=Rt.bind(null,Pe,h),[g.memoizedState,h]}function it(h,v){if(Pe=Mt(),g=$t(),v=v===void 0?null:v,g!==null){var S=g.memoizedState;if(S!==null&&v!==null){var P=S[1];e:if(P===null)P=!1;else{for(var de=0;de<P.length&&de<v.length;de++)if(!$e(v[de],P[de])){P=!1;break e}P=!0}if(P)return S[0]}}return h=h(),g.memoizedState=[h,v],h}function Rt(h,v,S){if(25<=ft)throw Error(n(301));if(h===Pe)if(We=!0,h={action:S,next:null},ct===null&&(ct=new Map),S=ct.get(v),S===void 0)ct.set(v,h);else{for(v=S;v.next!==null;)v=v.next;v.next=h}}function zt(){throw Error(n(394))}function Ot(){}var Vt={readContext:function(h){return h._currentValue2},useContext:function(h){return Mt(),h._currentValue2},useMemo:it,useReducer:Ut,useRef:function(h){Pe=Mt(),g=$t();var v=g.memoizedState;return v===null?(h={current:h},g.memoizedState=h):v},useState:function(h){return Ut(Yt,h)},useInsertionEffect:Ot,useLayoutEffect:function(){},useCallback:function(h,v){return it(function(){return h},v)},useImperativeHandle:Ot,useEffect:Ot,useDebugValue:Ot,useDeferredValue:function(h){return Mt(),h},useTransition:function(){return Mt(),[!1,zt]},useId:function(){var h=st.treeContext,v=h.overflow;h=h.id,h=(h&~(1<<32-Ue(h)-1)).toString(32)+v;var S=jt;if(S===null)throw Error(n(404));return v=He++,h=":"+S.idPrefix+"R"+h,0<v&&(h+="H"+v.toString(32)),h+":"},useMutableSource:function(h,v){return Mt(),v(h._source)},useSyncExternalStore:function(h,v,S){if(S===void 0)throw Error(n(407));return S()}},jt=null,Xt=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function K(h){return console.error(h),null}function ee(){}function Ke(h,v,S,P,de,le,je,Ge,dt){var ut=[],gt=new Set;return v={destination:null,responseState:v,progressiveChunkSize:P===void 0?12800:P,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:gt,pingedTasks:ut,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:de===void 0?K:de,onAllReady:ee,onShellReady:je===void 0?ee:je,onShellError:ee,onFatalError:ee},S=te(v,0,null,S,!1,!1),S.parentFlushed=!0,h=Be(v,h,null,S,gt,Oe,null,vt),ut.push(h),v}function Be(h,v,S,P,de,le,je,Ge){h.allPendingTasks++,S===null?h.pendingRootTasks++:S.pendingTasks++;var dt={node:v,ping:function(){var ut=h.pingedTasks;ut.push(dt),ut.length===1&&en(h)},blockedBoundary:S,blockedSegment:P,abortSet:de,legacyContext:le,context:je,treeContext:Ge};return de.add(dt),dt}function te(h,v,S,P,de,le){return{status:0,id:-1,index:v,parentFlushed:!1,chunks:[],children:[],formatContext:P,boundary:S,lastPushedText:de,textEmbedded:le}}function Je(h,v){if(h=h.onError(v),h!=null&&typeof h!="string")throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "'+typeof h+'" instead');return h}function qe(h,v){var S=h.onShellError;S(v),S=h.onFatalError,S(v),h.destination!==null?(h.status=2,h.destination.destroy(v)):(h.status=1,h.fatalError=v)}function yt(h,v,S,P,de){for(Pe={},st=v,He=0,h=S(P,de);We;)We=!1,He=0,ft+=1,g=null,h=S(P,de);return Ft(),h}function Kt(h,v,S,P){var de=S.render(),le=P.childContextTypes;if(le!=null){var je=v.legacyContext;if(typeof S.getChildContext!="function")P=je;else{S=S.getChildContext();for(var Ge in S)if(!(Ge in le))throw Error(n(108,G(P)||"Unknown",Ge));P=U({},je,S)}v.legacyContext=P,Ct(h,v,de),v.legacyContext=je}else Ct(h,v,de)}function an(h,v){if(h&&h.defaultProps){v=U({},v),h=h.defaultProps;for(var S in h)v[S]===void 0&&(v[S]=h[S]);return v}return v}function Zt(h,v,S,P,de){if(typeof S=="function")if(S.prototype&&S.prototype.isReactComponent){de=Ne(S,v.legacyContext);var le=S.contextType;le=new S(P,typeof le=="object"&&le!==null?le._currentValue2:de),Xe(le,S,P,de),Kt(h,v,le,S)}else{le=Ne(S,v.legacyContext),de=yt(h,v,S,P,le);var je=He!==0;if(typeof de=="object"&&de!==null&&typeof de.render=="function"&&de.$$typeof===void 0)Xe(de,S,P,le),Kt(h,v,de,S);else if(je){P=v.treeContext,v.treeContext=se(P,1,0);try{Ct(h,v,de)}finally{v.treeContext=P}}else Ct(h,v,de)}else if(typeof S=="string"){switch(de=v.blockedSegment,le=O(de.chunks,S,P,h.responseState,de.formatContext),de.lastPushedText=!1,je=de.formatContext,de.formatContext=y(je,S,P),ht(h,v,le),de.formatContext=je,S){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":break;default:de.chunks.push("</",S,">")}de.lastPushedText=!1}else{switch(S){case Se:case _:case z:case Z:case ae:Ct(h,v,P.children);return;case re:Ct(h,v,P.children);return;case xe:throw Error(n(343));case Ae:e:{S=v.blockedBoundary,de=v.blockedSegment,le=P.fallback,P=P.children,je=new Set;var Ge={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:je,errorDigest:null},dt=te(h,de.chunks.length,Ge,de.formatContext,!1,!1);de.children.push(dt),de.lastPushedText=!1;var ut=te(h,0,null,de.formatContext,!1,!1);ut.parentFlushed=!0,v.blockedBoundary=Ge,v.blockedSegment=ut;try{if(ht(h,v,P),h.responseState.generateStaticMarkup||ut.lastPushedText&&ut.textEmbedded&&ut.chunks.push("<!-- -->"),ut.status=1,Bt(Ge,ut),Ge.pendingTasks===0)break e}catch(gt){ut.status=4,Ge.forceClientRender=!0,Ge.errorDigest=Je(h,gt)}finally{v.blockedBoundary=S,v.blockedSegment=de}v=Be(h,le,S,dt,je,v.legacyContext,v.context,v.treeContext),h.pingedTasks.push(v)}return}if(typeof S=="object"&&S!==null)switch(S.$$typeof){case Ie:if(P=yt(h,v,S.render,P,de),He!==0){S=v.treeContext,v.treeContext=se(S,1,0);try{Ct(h,v,P)}finally{v.treeContext=S}}else Ct(h,v,P);return;case we:S=S.type,P=an(S,P),Zt(h,v,S,P,de);return;case W:if(de=P.children,S=S._context,P=P.value,le=S._currentValue2,S._currentValue2=P,je=Ee,Ee=P={parent:je,depth:je===null?0:je.depth+1,context:S,parentValue:le,value:P},v.context=P,Ct(h,v,de),h=Ee,h===null)throw Error(n(403));P=h.parentValue,h.context._currentValue2=P===J?h.context._defaultValue:P,h=Ee=h.parent,v.context=h;return;case ge:P=P.children,P=P(S._currentValue2),Ct(h,v,P);return;case A:de=S._init,S=de(S._payload),P=an(S,P),Zt(h,v,S,P,void 0);return}throw Error(n(130,S==null?S:typeof S,""))}}function Ct(h,v,S){if(v.node=S,typeof S=="object"&&S!==null){switch(S.$$typeof){case fe:Zt(h,v,S.type,S.props,S.ref);return;case ce:throw Error(n(257));case A:var P=S._init;S=P(S._payload),Ct(h,v,S);return}if(N(S)){cn(h,v,S);return}if(S===null||typeof S!="object"?P=null:(P=De&&S[De]||S["@@iterator"],P=typeof P=="function"?P:null),P&&(P=P.call(S))){if(S=P.next(),!S.done){var de=[];do de.push(S.value),S=P.next();while(!S.done);cn(h,v,de)}return}throw h=Object.prototype.toString.call(S),Error(n(31,h==="[object Object]"?"object with keys {"+Object.keys(S).join(", ")+"}":h))}typeof S=="string"?(P=v.blockedSegment,P.lastPushedText=Fe(v.blockedSegment.chunks,S,h.responseState,P.lastPushedText)):typeof S=="number"&&(P=v.blockedSegment,P.lastPushedText=Fe(v.blockedSegment.chunks,""+S,h.responseState,P.lastPushedText))}function cn(h,v,S){for(var P=S.length,de=0;de<P;de++){var le=v.treeContext;v.treeContext=se(le,P,de);try{ht(h,v,S[de])}finally{v.treeContext=le}}}function ht(h,v,S){var P=v.blockedSegment.formatContext,de=v.legacyContext,le=v.context;try{return Ct(h,v,S)}catch(dt){if(Ft(),typeof dt=="object"&&dt!==null&&typeof dt.then=="function"){S=dt;var je=v.blockedSegment,Ge=te(h,je.chunks.length,null,je.formatContext,je.lastPushedText,!0);je.children.push(Ge),je.lastPushedText=!1,h=Be(h,v.node,v.blockedBoundary,Ge,v.abortSet,v.legacyContext,v.context,v.treeContext).ping,S.then(h,h),v.blockedSegment.formatContext=P,v.legacyContext=de,v.context=le,Ye(le)}else throw v.blockedSegment.formatContext=P,v.legacyContext=de,v.context=le,Ye(le),dt}}function Et(h){var v=h.blockedBoundary;h=h.blockedSegment,h.status=3,St(this,v,h)}function Ht(h,v,S){var P=h.blockedBoundary;h.blockedSegment.status=3,P===null?(v.allPendingTasks--,v.status!==2&&(v.status=2,v.destination!==null&&v.destination.push(null))):(P.pendingTasks--,P.forceClientRender||(P.forceClientRender=!0,h=S===void 0?Error(n(432)):S,P.errorDigest=v.onError(h),P.parentFlushed&&v.clientRenderedBoundaries.push(P)),P.fallbackAbortableTasks.forEach(function(de){return Ht(de,v,S)}),P.fallbackAbortableTasks.clear(),v.allPendingTasks--,v.allPendingTasks===0&&(P=v.onAllReady,P()))}function Bt(h,v){if(v.chunks.length===0&&v.children.length===1&&v.children[0].boundary===null){var S=v.children[0];S.id=v.id,S.parentFlushed=!0,S.status===1&&Bt(h,S)}else h.completedSegments.push(v)}function St(h,v,S){if(v===null){if(S.parentFlushed){if(h.completedRootSegment!==null)throw Error(n(389));h.completedRootSegment=S}h.pendingRootTasks--,h.pendingRootTasks===0&&(h.onShellError=ee,v=h.onShellReady,v())}else v.pendingTasks--,v.forceClientRender||(v.pendingTasks===0?(S.parentFlushed&&S.status===1&&Bt(v,S),v.parentFlushed&&h.completedBoundaries.push(v),v.fallbackAbortableTasks.forEach(Et,h),v.fallbackAbortableTasks.clear()):S.parentFlushed&&S.status===1&&(Bt(v,S),v.completedSegments.length===1&&v.parentFlushed&&h.partialBoundaries.push(v)));h.allPendingTasks--,h.allPendingTasks===0&&(h=h.onAllReady,h())}function en(h){if(h.status!==2){var v=Ee,S=Xt.current;Xt.current=Vt;var P=jt;jt=h.responseState;try{var de=h.pingedTasks,le;for(le=0;le<de.length;le++){var je=de[le],Ge=h,dt=je.blockedSegment;if(dt.status===0){Ye(je.context);try{Ct(Ge,je,je.node),Ge.responseState.generateStaticMarkup||dt.lastPushedText&&dt.textEmbedded&&dt.chunks.push("<!-- -->"),je.abortSet.delete(je),dt.status=1,St(Ge,je.blockedBoundary,dt)}catch(on){if(Ft(),typeof on=="object"&&on!==null&&typeof on.then=="function"){var ut=je.ping;on.then(ut,ut)}else{je.abortSet.delete(je),dt.status=4;var gt=je.blockedBoundary,It=on,Gt=Je(Ge,It);if(gt===null?qe(Ge,It):(gt.pendingTasks--,gt.forceClientRender||(gt.forceClientRender=!0,gt.errorDigest=Gt,gt.parentFlushed&&Ge.clientRenderedBoundaries.push(gt))),Ge.allPendingTasks--,Ge.allPendingTasks===0){var dn=Ge.onAllReady;dn()}}}finally{}}}de.splice(0,le),h.destination!==null&&wn(h,h.destination)}catch(on){Je(h,on),qe(h,on)}finally{jt=P,Xt.current=S,S===Vt&&Ye(v)}}}function yn(h,v,S){switch(S.parentFlushed=!0,S.status){case 0:var P=S.id=h.nextSegmentId++;return S.lastPushedText=!1,S.textEmbedded=!1,h=h.responseState,v.push('<template id="'),v.push(h.placeholderPrefix),h=P.toString(16),v.push(h),v.push('"></template>');case 1:S.status=2;var de=!0;P=S.chunks;var le=0;S=S.children;for(var je=0;je<S.length;je++){for(de=S[je];le<de.index;le++)v.push(P[le]);de=xn(h,v,de)}for(;le<P.length-1;le++)v.push(P[le]);return le<P.length&&(de=v.push(P[le])),de;default:throw Error(n(390))}}function xn(h,v,S){var P=S.boundary;if(P===null)return yn(h,v,S);if(P.parentFlushed=!0,P.forceClientRender)return h.responseState.generateStaticMarkup||(P=P.errorDigest,v.push("<!--$!-->"),v.push("<template"),P&&(v.push(' data-dgst="'),P=I(P),v.push(P),v.push('"')),v.push("></template>")),yn(h,v,S),h=h.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),h;if(0<P.pendingTasks){P.rootSegmentID=h.nextSegmentId++,0<P.completedSegments.length&&h.partialBoundaries.push(P);var de=h.responseState,le=de.nextSuspenseID++;return de=de.boundaryPrefix+le.toString(16),P=P.id=de,_e(v,h.responseState,P),yn(h,v,S),v.push("<!--/$-->")}if(P.byteSize>h.progressiveChunkSize)return P.rootSegmentID=h.nextSegmentId++,h.completedBoundaries.push(P),_e(v,h.responseState,P.id),yn(h,v,S),v.push("<!--/$-->");if(h.responseState.generateStaticMarkup||v.push("<!--$-->"),S=P.completedSegments,S.length!==1)throw Error(n(391));return xn(h,v,S[0]),h=h.responseState.generateStaticMarkup?!0:v.push("<!--/$-->"),h}function Un(h,v,S){return M(v,h.responseState,S.formatContext,S.id),xn(h,v,S),V(v,S.formatContext)}function Wn(h,v,S){for(var P=S.completedSegments,de=0;de<P.length;de++)On(h,v,S,P[de]);if(P.length=0,h=h.responseState,P=S.id,S=S.rootSegmentID,v.push(h.startInlineScript),h.sentCompleteBoundaryFunction?v.push('$RC("'):(h.sentCompleteBoundaryFunction=!0,v.push('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("')),P===null)throw Error(n(395));return S=S.toString(16),v.push(P),v.push('","'),v.push(h.segmentPrefix),v.push(S),v.push('")<\/script>')}function On(h,v,S,P){if(P.status===2)return!0;var de=P.id;if(de===-1){if((P.id=S.rootSegmentID)===-1)throw Error(n(392));return Un(h,v,P)}return Un(h,v,P),h=h.responseState,v.push(h.startInlineScript),h.sentCompleteSegmentFunction?v.push('$RS("'):(h.sentCompleteSegmentFunction=!0,v.push('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("')),v.push(h.segmentPrefix),de=de.toString(16),v.push(de),v.push('","'),v.push(h.placeholderPrefix),v.push(de),v.push('")<\/script>')}function wn(h,v){try{var S=h.completedRootSegment;if(S!==null&&h.pendingRootTasks===0){xn(h,v,S),h.completedRootSegment=null;var P=h.responseState.bootstrapChunks;for(S=0;S<P.length-1;S++)v.push(P[S]);S<P.length&&v.push(P[S])}var de=h.clientRenderedBoundaries,le;for(le=0;le<de.length;le++){var je=de[le];P=v;var Ge=h.responseState,dt=je.id,ut=je.errorDigest,gt=je.errorMessage,It=je.errorComponentStack;if(P.push(Ge.startInlineScript),Ge.sentClientRenderFunction?P.push('$RX("'):(Ge.sentClientRenderFunction=!0,P.push('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("')),dt===null)throw Error(n(395));if(P.push(dt),P.push('"'),ut||gt||It){P.push(",");var Gt=ye(ut||"");P.push(Gt)}if(gt||It){P.push(",");var dn=ye(gt||"");P.push(dn)}if(It){P.push(",");var on=ye(It);P.push(on)}if(!P.push(")<\/script>")){h.destination=null,le++,de.splice(0,le);return}}de.splice(0,le);var Nn=h.completedBoundaries;for(le=0;le<Nn.length;le++)if(!Wn(h,v,Nn[le])){h.destination=null,le++,Nn.splice(0,le);return}Nn.splice(0,le);var un=h.partialBoundaries;for(le=0;le<un.length;le++){var kn=un[le];e:{de=h,je=v;var tn=kn.completedSegments;for(Ge=0;Ge<tn.length;Ge++)if(!On(de,je,kn,tn[Ge])){Ge++,tn.splice(0,Ge);var ln=!1;break e}tn.splice(0,Ge),ln=!0}if(!ln){h.destination=null,le++,un.splice(0,le);return}}un.splice(0,le);var Jt=h.completedBoundaries;for(le=0;le<Jt.length;le++)if(!Wn(h,v,Jt[le])){h.destination=null,le++,Jt.splice(0,le);return}Jt.splice(0,le)}finally{h.allPendingTasks===0&&h.pingedTasks.length===0&&h.clientRenderedBoundaries.length===0&&h.completedBoundaries.length===0&&v.push(null)}}function rn(h,v){try{var S=h.abortableTasks;S.forEach(function(P){return Ht(P,h,v)}),S.clear(),h.destination!==null&&wn(h,h.destination)}catch(P){Je(h,P),qe(h,P)}}function bn(){}function vn(h,v,S,P){var de=!1,le=null,je="",Ge={push:function(ut){return ut!==null&&(je+=ut),!0},destroy:function(ut){de=!0,le=ut}},dt=!1;if(h=Ke(h,oe(S,v?v.identifierPrefix:void 0),{insertionMode:1,selectedValue:null},1/0,bn,void 0,function(){dt=!0}),en(h),rn(h,P),h.status===1)h.status=2,Ge.destroy(h.fatalError);else if(h.status!==2&&h.destination===null){h.destination=Ge;try{wn(h,Ge)}catch(ut){Je(h,ut),qe(h,ut)}}if(de)throw le;if(!dt)throw Error(n(426));return je}return ms.renderToNodeStream=function(){throw Error(n(207))},ms.renderToStaticMarkup=function(h,v){return vn(h,v,!0,'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server')},ms.renderToStaticNodeStream=function(){throw Error(n(208))},ms.renderToString=function(h,v){return vn(h,v,!1,'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server')},ms.version="18.3.1",ms}var nr={};/**
|
|
67
|
-
* @license React
|
|
68
|
-
* react-dom-server.browser.production.min.js
|
|
69
|
-
*
|
|
70
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
71
|
-
*
|
|
72
|
-
* This source code is licensed under the MIT license found in the
|
|
73
|
-
* LICENSE file in the root directory of this source tree.
|
|
74
|
-
*/var Ra;function Ou(){if(Ra)return nr;Ra=1;var t=io();function n(m){for(var x="https://reactjs.org/docs/error-decoder.html?invariant="+m,C=1;C<arguments.length;C++)x+="&args[]="+encodeURIComponent(arguments[C]);return"Minified React error #"+m+"; visit "+x+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=null,r=0;function i(m,x){if(x.length!==0)if(512<x.length)0<r&&(m.enqueue(new Uint8Array(s.buffer,0,r)),s=new Uint8Array(512),r=0),m.enqueue(x);else{var C=s.length-r;C<x.length&&(C===0?m.enqueue(s):(s.set(x.subarray(0,C),r),m.enqueue(s),x=x.subarray(C)),s=new Uint8Array(512),r=0),s.set(x,r),r+=x.length}}function a(m,x){return i(m,x),!0}function o(m){s&&0<r&&(m.enqueue(new Uint8Array(s.buffer,0,r)),s=null,r=0)}var c=new TextEncoder;function l(m){return c.encode(m)}function p(m){return c.encode(m)}function u(m,x){typeof m.error=="function"?m.error(x):m.close()}var f=Object.prototype.hasOwnProperty,k=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,j={},I={};function E(m){return f.call(I,m)?!0:f.call(j,m)?!1:k.test(m)?I[m]=!0:(j[m]=!0,!1)}function $(m,x,C,D,he,ue,Me){this.acceptsBooleans=x===2||x===3||x===4,this.attributeName=D,this.attributeNamespace=he,this.mustUseProperty=C,this.propertyName=m,this.type=x,this.sanitizeURL=ue,this.removeEmptyString=Me}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(m){N[m]=new $(m,0,!1,m,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(m){var x=m[0];N[x]=new $(x,1,!1,m[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(m){N[m]=new $(m,2,!1,m.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(m){N[m]=new $(m,2,!1,m,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(m){N[m]=new $(m,3,!1,m.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(m){N[m]=new $(m,3,!0,m,null,!1,!1)}),["capture","download"].forEach(function(m){N[m]=new $(m,4,!1,m,null,!1,!1)}),["cols","rows","size","span"].forEach(function(m){N[m]=new $(m,6,!1,m,null,!1,!1)}),["rowSpan","start"].forEach(function(m){N[m]=new $(m,5,!1,m.toLowerCase(),null,!1,!1)});var R=/[\-:]([a-z])/g;function y(m){return m[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(m){var x=m.replace(R,y);N[x]=new $(x,1,!1,m,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(m){var x=m.replace(R,y);N[x]=new $(x,1,!1,m,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(m){var x=m.replace(R,y);N[x]=new $(x,1,!1,m,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(m){N[m]=new $(m,1,!1,m.toLowerCase(),null,!1,!1)}),N.xlinkHref=new $("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(m){N[m]=new $(m,1,!1,m.toLowerCase(),null,!0,!0)});var L={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},b=["Webkit","ms","Moz","O"];Object.keys(L).forEach(function(m){b.forEach(function(x){x=x+m.charAt(0).toUpperCase()+m.substring(1),L[x]=L[m]})});var F=/["'&<>]/;function B(m){if(typeof m=="boolean"||typeof m=="number")return""+m;m=""+m;var x=F.exec(m);if(x){var C="",D,he=0;for(D=x.index;D<m.length;D++){switch(m.charCodeAt(D)){case 34:x=""";break;case 38:x="&";break;case 39:x="'";break;case 60:x="<";break;case 62:x=">";break;default:continue}he!==D&&(C+=m.substring(he,D)),he=D+1,C+=x}m=he!==D?C+m.substring(he,D):C}return m}var ie=/([A-Z])/g,Q=/^ms-/,q=Array.isArray,ke=p("<script>"),Re=p("<\/script>"),O=p('<script src="'),_e=p('<script type="module" src="'),M=p('" async=""><\/script>'),V=/(<\/|<)(s)(cript)/gi;function ve(m,x,C,D){return""+x+(C==="s"?"\\u0073":"\\u0053")+D}function ye(m,x,C,D,he){m=m===void 0?"":m,x=x===void 0?ke:p('<script nonce="'+B(x)+'">');var ue=[];if(C!==void 0&&ue.push(x,l((""+C).replace(V,ve)),Re),D!==void 0)for(C=0;C<D.length;C++)ue.push(O,l(B(D[C])),M);if(he!==void 0)for(D=0;D<he.length;D++)ue.push(_e,l(B(he[D])),M);return{bootstrapChunks:ue,startInlineScript:x,placeholderPrefix:p(m+"P:"),segmentPrefix:p(m+"S:"),boundaryPrefix:m+"B:",idPrefix:m,nextSuspenseID:0,sentCompleteSegmentFunction:!1,sentCompleteBoundaryFunction:!1,sentClientRenderFunction:!1}}function oe(m,x){return{insertionMode:m,selectedValue:x}}function Fe(m){return oe(m==="http://www.w3.org/2000/svg"?2:m==="http://www.w3.org/1998/Math/MathML"?3:0,null)}function U(m,x,C){switch(x){case"select":return oe(1,C.value!=null?C.value:C.defaultValue);case"svg":return oe(2,null);case"math":return oe(3,null);case"foreignObject":return oe(1,null);case"table":return oe(4,null);case"thead":case"tbody":case"tfoot":return oe(5,null);case"colgroup":return oe(7,null);case"tr":return oe(6,null)}return 4<=m.insertionMode||m.insertionMode===0?oe(1,null):m}var fe=p("<!-- -->");function ce(m,x,C,D){return x===""?D:(D&&m.push(fe),m.push(l(B(x))),!0)}var ae=new Map,z=p(' style="'),Z=p(":"),W=p(";");function ge(m,x,C){if(typeof C!="object")throw Error(n(62));x=!0;for(var D in C)if(f.call(C,D)){var he=C[D];if(he!=null&&typeof he!="boolean"&&he!==""){if(D.indexOf("--")===0){var ue=l(B(D));he=l(B((""+he).trim()))}else{ue=D;var Me=ae.get(ue);Me!==void 0||(Me=p(B(ue.replace(ie,"-$1").toLowerCase().replace(Q,"-ms-"))),ae.set(ue,Me)),ue=Me,he=typeof he=="number"?he===0||f.call(L,D)?l(""+he):l(he+"px"):l(B((""+he).trim()))}x?(x=!1,m.push(z,ue,Z,he)):m.push(W,ue,Z,he)}}x||m.push(re)}var Ie=p(" "),Ae=p('="'),re=p('"'),we=p('=""');function A(m,x,C,D){switch(C){case"style":ge(m,x,D);return;case"defaultValue":case"defaultChecked":case"innerHTML":case"suppressContentEditableWarning":case"suppressHydrationWarning":return}if(!(2<C.length)||C[0]!=="o"&&C[0]!=="O"||C[1]!=="n"&&C[1]!=="N"){if(x=N.hasOwnProperty(C)?N[C]:null,x!==null){switch(typeof D){case"function":case"symbol":return;case"boolean":if(!x.acceptsBooleans)return}switch(C=l(x.attributeName),x.type){case 3:D&&m.push(Ie,C,we);break;case 4:D===!0?m.push(Ie,C,we):D!==!1&&m.push(Ie,C,Ae,l(B(D)),re);break;case 5:isNaN(D)||m.push(Ie,C,Ae,l(B(D)),re);break;case 6:!isNaN(D)&&1<=D&&m.push(Ie,C,Ae,l(B(D)),re);break;default:x.sanitizeURL&&(D=""+D),m.push(Ie,C,Ae,l(B(D)),re)}}else if(E(C)){switch(typeof D){case"function":case"symbol":return;case"boolean":if(x=C.toLowerCase().slice(0,5),x!=="data-"&&x!=="aria-")return}m.push(Ie,l(C),Ae,l(B(D)),re)}}}var xe=p(">"),_=p("/>");function Se(m,x,C){if(x!=null){if(C!=null)throw Error(n(60));if(typeof x!="object"||!("__html"in x))throw Error(n(61));x=x.__html,x!=null&&m.push(l(""+x))}}function J(m){var x="";return t.Children.forEach(m,function(C){C!=null&&(x+=C)}),x}var De=p(' selected=""');function G(m,x,C,D){m.push(et(C));var he=C=null,ue;for(ue in x)if(f.call(x,ue)){var Me=x[ue];if(Me!=null)switch(ue){case"children":C=Me;break;case"dangerouslySetInnerHTML":he=Me;break;default:A(m,D,ue,Me)}}return m.push(xe),Se(m,he,C),typeof C=="string"?(m.push(l(B(C))),null):C}var Oe=p(`
|
|
75
|
-
`),Ne=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Ee=new Map;function et(m){var x=Ee.get(m);if(x===void 0){if(!Ne.test(m))throw Error(n(65,m));x=p("<"+m),Ee.set(m,x)}return x}var Ce=p("<!DOCTYPE html>");function be(m,x,C,D,he){switch(x){case"select":m.push(et("select"));var ue=null,Me=null;for(wt in C)if(f.call(C,wt)){var Ve=C[wt];if(Ve!=null)switch(wt){case"children":ue=Ve;break;case"dangerouslySetInnerHTML":Me=Ve;break;case"defaultValue":case"value":break;default:A(m,D,wt,Ve)}}return m.push(xe),Se(m,Me,ue),ue;case"option":Me=he.selectedValue,m.push(et("option"));var mt=Ve=null,bt=null,wt=null;for(ue in C)if(f.call(C,ue)){var Wt=C[ue];if(Wt!=null)switch(ue){case"children":Ve=Wt;break;case"selected":bt=Wt;break;case"dangerouslySetInnerHTML":wt=Wt;break;case"value":mt=Wt;default:A(m,D,ue,Wt)}}if(Me!=null)if(C=mt!==null?""+mt:J(Ve),q(Me)){for(D=0;D<Me.length;D++)if(""+Me[D]===C){m.push(De);break}}else""+Me===C&&m.push(De);else bt&&m.push(De);return m.push(xe),Se(m,wt,Ve),Ve;case"textarea":m.push(et("textarea")),wt=Me=ue=null;for(Ve in C)if(f.call(C,Ve)&&(mt=C[Ve],mt!=null))switch(Ve){case"children":wt=mt;break;case"value":ue=mt;break;case"defaultValue":Me=mt;break;case"dangerouslySetInnerHTML":throw Error(n(91));default:A(m,D,Ve,mt)}if(ue===null&&Me!==null&&(ue=Me),m.push(xe),wt!=null){if(ue!=null)throw Error(n(92));if(q(wt)&&1<wt.length)throw Error(n(93));ue=""+wt}return typeof ue=="string"&&ue[0]===`
|
|
76
|
-
`&&m.push(Oe),ue!==null&&m.push(l(B(""+ue))),null;case"input":m.push(et("input")),mt=wt=Ve=ue=null;for(Me in C)if(f.call(C,Me)&&(bt=C[Me],bt!=null))switch(Me){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,"input"));case"defaultChecked":mt=bt;break;case"defaultValue":Ve=bt;break;case"checked":wt=bt;break;case"value":ue=bt;break;default:A(m,D,Me,bt)}return wt!==null?A(m,D,"checked",wt):mt!==null&&A(m,D,"checked",mt),ue!==null?A(m,D,"value",ue):Ve!==null&&A(m,D,"value",Ve),m.push(_),null;case"menuitem":m.push(et("menuitem"));for(var Ln in C)if(f.call(C,Ln)&&(ue=C[Ln],ue!=null))switch(Ln){case"children":case"dangerouslySetInnerHTML":throw Error(n(400));default:A(m,D,Ln,ue)}return m.push(xe),null;case"title":m.push(et("title")),ue=null;for(Wt in C)if(f.call(C,Wt)&&(Me=C[Wt],Me!=null))switch(Wt){case"children":ue=Me;break;case"dangerouslySetInnerHTML":throw Error(n(434));default:A(m,D,Wt,Me)}return m.push(xe),ue;case"listing":case"pre":m.push(et(x)),Me=ue=null;for(mt in C)if(f.call(C,mt)&&(Ve=C[mt],Ve!=null))switch(mt){case"children":ue=Ve;break;case"dangerouslySetInnerHTML":Me=Ve;break;default:A(m,D,mt,Ve)}if(m.push(xe),Me!=null){if(ue!=null)throw Error(n(60));if(typeof Me!="object"||!("__html"in Me))throw Error(n(61));C=Me.__html,C!=null&&(typeof C=="string"&&0<C.length&&C[0]===`
|
|
77
|
-
`?m.push(Oe,l(C)):m.push(l(""+C)))}return typeof ue=="string"&&ue[0]===`
|
|
78
|
-
`&&m.push(Oe),ue;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":m.push(et(x));for(var _n in C)if(f.call(C,_n)&&(ue=C[_n],ue!=null))switch(_n){case"children":case"dangerouslySetInnerHTML":throw Error(n(399,x));default:A(m,D,_n,ue)}return m.push(_),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return G(m,C,x,D);case"html":return he.insertionMode===0&&m.push(Ce),G(m,C,x,D);default:if(x.indexOf("-")===-1&&typeof C.is!="string")return G(m,C,x,D);m.push(et(x)),Me=ue=null;for(bt in C)if(f.call(C,bt)&&(Ve=C[bt],Ve!=null))switch(bt){case"children":ue=Ve;break;case"dangerouslySetInnerHTML":Me=Ve;break;case"style":ge(m,D,Ve);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:E(bt)&&typeof Ve!="function"&&typeof Ve!="symbol"&&m.push(Ie,l(bt),Ae,l(B(Ve)),re)}return m.push(xe),Se(m,Me,ue),ue}}var ze=p("</"),tt=p(">"),Ye=p('<template id="'),Le=p('"></template>'),Xe=p("<!--$-->"),vt=p('<!--$?--><template id="'),se=p('"></template>'),Ue=p("<!--$!-->"),w=p("<!--/$-->"),H=p("<template"),X=p('"'),me=p(' data-dgst="');p(' data-msg="'),p(' data-stck="');var $e=p("></template>");function Pe(m,x,C){if(i(m,vt),C===null)throw Error(n(395));return i(m,C),a(m,se)}var st=p('<div hidden id="'),lt=p('">'),g=p("</div>"),ne=p('<svg aria-hidden="true" style="display:none" id="'),We=p('">'),He=p("</svg>"),ct=p('<math aria-hidden="true" style="display:none" id="'),ft=p('">'),Mt=p("</math>"),Dt=p('<table hidden id="'),$t=p('">'),Ft=p("</table>"),Yt=p('<table hidden><tbody id="'),Ut=p('">'),it=p("</tbody></table>"),Rt=p('<table hidden><tr id="'),zt=p('">'),Ot=p("</tr></table>"),Vt=p('<table hidden><colgroup id="'),jt=p('">'),Xt=p("</colgroup></table>");function K(m,x,C,D){switch(C.insertionMode){case 0:case 1:return i(m,st),i(m,x.segmentPrefix),i(m,l(D.toString(16))),a(m,lt);case 2:return i(m,ne),i(m,x.segmentPrefix),i(m,l(D.toString(16))),a(m,We);case 3:return i(m,ct),i(m,x.segmentPrefix),i(m,l(D.toString(16))),a(m,ft);case 4:return i(m,Dt),i(m,x.segmentPrefix),i(m,l(D.toString(16))),a(m,$t);case 5:return i(m,Yt),i(m,x.segmentPrefix),i(m,l(D.toString(16))),a(m,Ut);case 6:return i(m,Rt),i(m,x.segmentPrefix),i(m,l(D.toString(16))),a(m,zt);case 7:return i(m,Vt),i(m,x.segmentPrefix),i(m,l(D.toString(16))),a(m,jt);default:throw Error(n(397))}}function ee(m,x){switch(x.insertionMode){case 0:case 1:return a(m,g);case 2:return a(m,He);case 3:return a(m,Mt);case 4:return a(m,Ft);case 5:return a(m,it);case 6:return a(m,Ot);case 7:return a(m,Xt);default:throw Error(n(397))}}var Ke=p('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),Be=p('$RS("'),te=p('","'),Je=p('")<\/script>'),qe=p('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'),yt=p('$RC("'),Kt=p('","'),an=p('")<\/script>'),Zt=p('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'),Ct=p('$RX("'),cn=p('"'),ht=p(")<\/script>"),Et=p(","),Ht=/[<\u2028\u2029]/g;function Bt(m){return JSON.stringify(m).replace(Ht,function(x){switch(x){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}var St=Object.assign,en=Symbol.for("react.element"),yn=Symbol.for("react.portal"),xn=Symbol.for("react.fragment"),Un=Symbol.for("react.strict_mode"),Wn=Symbol.for("react.profiler"),On=Symbol.for("react.provider"),wn=Symbol.for("react.context"),rn=Symbol.for("react.forward_ref"),bn=Symbol.for("react.suspense"),vn=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.for("react.scope"),P=Symbol.for("react.debug_trace_mode"),de=Symbol.for("react.legacy_hidden"),le=Symbol.for("react.default_value"),je=Symbol.iterator;function Ge(m){if(m==null)return null;if(typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case xn:return"Fragment";case yn:return"Portal";case Wn:return"Profiler";case Un:return"StrictMode";case bn:return"Suspense";case vn:return"SuspenseList"}if(typeof m=="object")switch(m.$$typeof){case wn:return(m.displayName||"Context")+".Consumer";case On:return(m._context.displayName||"Context")+".Provider";case rn:var x=m.render;return m=m.displayName,m||(m=x.displayName||x.name||"",m=m!==""?"ForwardRef("+m+")":"ForwardRef"),m;case h:return x=m.displayName||null,x!==null?x:Ge(m.type)||"Memo";case v:x=m._payload,m=m._init;try{return Ge(m(x))}catch{}}return null}var dt={};function ut(m,x){if(m=m.contextTypes,!m)return dt;var C={},D;for(D in m)C[D]=x[D];return C}var gt=null;function It(m,x){if(m!==x){m.context._currentValue=m.parentValue,m=m.parent;var C=x.parent;if(m===null){if(C!==null)throw Error(n(401))}else{if(C===null)throw Error(n(401));It(m,C)}x.context._currentValue=x.value}}function Gt(m){m.context._currentValue=m.parentValue,m=m.parent,m!==null&&Gt(m)}function dn(m){var x=m.parent;x!==null&&dn(x),m.context._currentValue=m.value}function on(m,x){if(m.context._currentValue=m.parentValue,m=m.parent,m===null)throw Error(n(402));m.depth===x.depth?It(m,x):on(m,x)}function Nn(m,x){var C=x.parent;if(C===null)throw Error(n(402));m.depth===C.depth?It(m,C):Nn(m,C),x.context._currentValue=x.value}function un(m){var x=gt;x!==m&&(x===null?dn(m):m===null?Gt(x):x.depth===m.depth?It(x,m):x.depth>m.depth?on(x,m):Nn(x,m),gt=m)}var kn={isMounted:function(){return!1},enqueueSetState:function(m,x){m=m._reactInternals,m.queue!==null&&m.queue.push(x)},enqueueReplaceState:function(m,x){m=m._reactInternals,m.replace=!0,m.queue=[x]},enqueueForceUpdate:function(){}};function tn(m,x,C,D){var he=m.state!==void 0?m.state:null;m.updater=kn,m.props=C,m.state=he;var ue={queue:[],replace:!1};m._reactInternals=ue;var Me=x.contextType;if(m.context=typeof Me=="object"&&Me!==null?Me._currentValue:D,Me=x.getDerivedStateFromProps,typeof Me=="function"&&(Me=Me(C,he),he=Me==null?he:St({},he,Me),m.state=he),typeof x.getDerivedStateFromProps!="function"&&typeof m.getSnapshotBeforeUpdate!="function"&&(typeof m.UNSAFE_componentWillMount=="function"||typeof m.componentWillMount=="function"))if(x=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),x!==m.state&&kn.enqueueReplaceState(m,m.state,null),ue.queue!==null&&0<ue.queue.length)if(x=ue.queue,Me=ue.replace,ue.queue=null,ue.replace=!1,Me&&x.length===1)m.state=x[0];else{for(ue=Me?x[0]:m.state,he=!0,Me=Me?1:0;Me<x.length;Me++){var Ve=x[Me];Ve=typeof Ve=="function"?Ve.call(m,ue,C,D):Ve,Ve!=null&&(he?(he=!1,ue=St({},ue,Ve)):St(ue,Ve))}m.state=ue}else ue.queue=null}var ln={id:1,overflow:""};function Jt(m,x,C){var D=m.id;m=m.overflow;var he=32-An(D)-1;D&=~(1<<he),C+=1;var ue=32-An(x)+he;if(30<ue){var Me=he-he%5;return ue=(D&(1<<Me)-1).toString(32),D>>=Me,he-=Me,{id:1<<32-An(x)+he|C<<he|D,overflow:ue+m}}return{id:1<<ue|C<<he|D,overflow:m}}var An=Math.clz32?Math.clz32:qn,En=Math.log,ds=Math.LN2;function qn(m){return m>>>=0,m===0?32:31-(En(m)/ds|0)|0}function Dn(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var Yn=typeof Object.is=="function"?Object.is:Dn,pn=null,Xn=null,zn=null,At=null,Vn=!1,Kn=!1,Tn=0,jn=null,$n=0;function Rn(){if(pn===null)throw Error(n(321));return pn}function us(){if(0<$n)throw Error(n(312));return{memoizedState:null,queue:null,next:null}}function Zn(){return At===null?zn===null?(Vn=!1,zn=At=us()):(Vn=!0,At=zn):At.next===null?(Vn=!1,At=At.next=us()):(Vn=!0,At=At.next),At}function rs(){Xn=pn=null,Kn=!1,zn=null,$n=0,At=jn=null}function ps(m,x){return typeof x=="function"?x(m):x}function hs(m,x,C){if(pn=Rn(),At=Zn(),Vn){var D=At.queue;if(x=D.dispatch,jn!==null&&(C=jn.get(D),C!==void 0)){jn.delete(D),D=At.memoizedState;do D=m(D,C.action),C=C.next;while(C!==null);return At.memoizedState=D,[D,x]}return[At.memoizedState,x]}return m=m===ps?typeof x=="function"?x():x:C!==void 0?C(x):x,At.memoizedState=m,m=At.queue={last:null,dispatch:null},m=m.dispatch=Te.bind(null,pn,m),[At.memoizedState,m]}function Y(m,x){if(pn=Rn(),At=Zn(),x=x===void 0?null:x,At!==null){var C=At.memoizedState;if(C!==null&&x!==null){var D=C[1];e:if(D===null)D=!1;else{for(var he=0;he<D.length&&he<x.length;he++)if(!Yn(x[he],D[he])){D=!1;break e}D=!0}if(D)return C[0]}}return m=m(),At.memoizedState=[m,x],m}function Te(m,x,C){if(25<=$n)throw Error(n(301));if(m===pn)if(Kn=!0,m={action:C,next:null},jn===null&&(jn=new Map),C=jn.get(x),C===void 0)jn.set(x,m);else{for(x=C;x.next!==null;)x=x.next;x.next=m}}function Ze(){throw Error(n(394))}function pt(){}var kt={readContext:function(m){return m._currentValue},useContext:function(m){return Rn(),m._currentValue},useMemo:Y,useReducer:hs,useRef:function(m){pn=Rn(),At=Zn();var x=At.memoizedState;return x===null?(m={current:m},At.memoizedState=m):x},useState:function(m){return hs(ps,m)},useInsertionEffect:pt,useLayoutEffect:function(){},useCallback:function(m,x){return Y(function(){return m},x)},useImperativeHandle:pt,useEffect:pt,useDebugValue:pt,useDeferredValue:function(m){return Rn(),m},useTransition:function(){return Rn(),[!1,Ze]},useId:function(){var m=Xn.treeContext,x=m.overflow;m=m.id,m=(m&~(1<<32-An(m)-1)).toString(32)+x;var C=Nt;if(C===null)throw Error(n(404));return x=Tn++,m=":"+C.idPrefix+"R"+m,0<x&&(m+="H"+x.toString(32)),m+":"},useMutableSource:function(m,x){return Rn(),x(m._source)},useSyncExternalStore:function(m,x,C){if(C===void 0)throw Error(n(407));return C()}},Nt=null,Lt=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function T(m){return console.error(m),null}function pe(){}function Qe(m,x,C,D,he,ue,Me,Ve,mt){var bt=[],wt=new Set;return x={destination:null,responseState:x,progressiveChunkSize:D===void 0?12800:D,status:0,fatalError:null,nextSegmentId:0,allPendingTasks:0,pendingRootTasks:0,completedRootSegment:null,abortableTasks:wt,pingedTasks:bt,clientRenderedBoundaries:[],completedBoundaries:[],partialBoundaries:[],onError:he===void 0?T:he,onAllReady:ue===void 0?pe:ue,onShellReady:Me===void 0?pe:Me,onShellError:Ve===void 0?pe:Ve,onFatalError:mt===void 0?pe:mt},C=at(x,0,null,C,!1,!1),C.parentFlushed=!0,m=rt(x,m,null,C,wt,dt,null,ln),bt.push(m),x}function rt(m,x,C,D,he,ue,Me,Ve){m.allPendingTasks++,C===null?m.pendingRootTasks++:C.pendingTasks++;var mt={node:x,ping:function(){var bt=m.pingedTasks;bt.push(mt),bt.length===1&&Ui(m)},blockedBoundary:C,blockedSegment:D,abortSet:he,legacyContext:ue,context:Me,treeContext:Ve};return he.add(mt),mt}function at(m,x,C,D,he,ue){return{status:0,id:-1,index:x,parentFlushed:!1,chunks:[],children:[],formatContext:D,boundary:C,lastPushedText:he,textEmbedded:ue}}function Tt(m,x){if(m=m.onError(x),m!=null&&typeof m!="string")throw Error('onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "'+typeof m+'" instead');return m}function sn(m,x){var C=m.onShellError;C(x),C=m.onFatalError,C(x),m.destination!==null?(m.status=2,u(m.destination,x)):(m.status=1,m.fatalError=x)}function Cn(m,x,C,D,he){for(pn={},Xn=x,Tn=0,m=C(D,he);Kn;)Kn=!1,Tn=0,$n+=1,At=null,m=C(D,he);return rs(),m}function hn(m,x,C,D){var he=C.render(),ue=D.childContextTypes;if(ue!=null){var Me=x.legacyContext;if(typeof C.getChildContext!="function")D=Me;else{C=C.getChildContext();for(var Ve in C)if(!(Ve in ue))throw Error(n(108,Ge(D)||"Unknown",Ve));D=St({},Me,C)}x.legacyContext=D,In(m,x,he),x.legacyContext=Me}else In(m,x,he)}function Js(m,x){if(m&&m.defaultProps){x=St({},x),m=m.defaultProps;for(var C in m)x[C]===void 0&&(x[C]=m[C]);return x}return x}function Er(m,x,C,D,he){if(typeof C=="function")if(C.prototype&&C.prototype.isReactComponent){he=ut(C,x.legacyContext);var ue=C.contextType;ue=new C(D,typeof ue=="object"&&ue!==null?ue._currentValue:he),tn(ue,C,D,he),hn(m,x,ue,C)}else{ue=ut(C,x.legacyContext),he=Cn(m,x,C,D,ue);var Me=Tn!==0;if(typeof he=="object"&&he!==null&&typeof he.render=="function"&&he.$$typeof===void 0)tn(he,C,D,ue),hn(m,x,he,C);else if(Me){D=x.treeContext,x.treeContext=Jt(D,1,0);try{In(m,x,he)}finally{x.treeContext=D}}else In(m,x,he)}else if(typeof C=="string"){switch(he=x.blockedSegment,ue=be(he.chunks,C,D,m.responseState,he.formatContext),he.lastPushedText=!1,Me=he.formatContext,he.formatContext=U(Me,C,D),Tr(m,x,ue),he.formatContext=Me,C){case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"input":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":break;default:he.chunks.push(ze,l(C),tt)}he.lastPushedText=!1}else{switch(C){case de:case P:case Un:case Wn:case xn:In(m,x,D.children);return;case vn:In(m,x,D.children);return;case S:throw Error(n(343));case bn:e:{C=x.blockedBoundary,he=x.blockedSegment,ue=D.fallback,D=D.children,Me=new Set;var Ve={id:null,rootSegmentID:-1,parentFlushed:!1,pendingTasks:0,forceClientRender:!1,completedSegments:[],byteSize:0,fallbackAbortableTasks:Me,errorDigest:null},mt=at(m,he.chunks.length,Ve,he.formatContext,!1,!1);he.children.push(mt),he.lastPushedText=!1;var bt=at(m,0,null,he.formatContext,!1,!1);bt.parentFlushed=!0,x.blockedBoundary=Ve,x.blockedSegment=bt;try{if(Tr(m,x,D),bt.lastPushedText&&bt.textEmbedded&&bt.chunks.push(fe),bt.status=1,Qs(Ve,bt),Ve.pendingTasks===0)break e}catch(wt){bt.status=4,Ve.forceClientRender=!0,Ve.errorDigest=Tt(m,wt)}finally{x.blockedBoundary=C,x.blockedSegment=he}x=rt(m,ue,C,mt,Me,x.legacyContext,x.context,x.treeContext),m.pingedTasks.push(x)}return}if(typeof C=="object"&&C!==null)switch(C.$$typeof){case rn:if(D=Cn(m,x,C.render,D,he),Tn!==0){C=x.treeContext,x.treeContext=Jt(C,1,0);try{In(m,x,D)}finally{x.treeContext=C}}else In(m,x,D);return;case h:C=C.type,D=Js(C,D),Er(m,x,C,D,he);return;case On:if(he=D.children,C=C._context,D=D.value,ue=C._currentValue,C._currentValue=D,Me=gt,gt=D={parent:Me,depth:Me===null?0:Me.depth+1,context:C,parentValue:ue,value:D},x.context=D,In(m,x,he),m=gt,m===null)throw Error(n(403));D=m.parentValue,m.context._currentValue=D===le?m.context._defaultValue:D,m=gt=m.parent,x.context=m;return;case wn:D=D.children,D=D(C._currentValue),In(m,x,D);return;case v:he=C._init,C=he(C._payload),D=Js(C,D),Er(m,x,C,D,void 0);return}throw Error(n(130,C==null?C:typeof C,""))}}function In(m,x,C){if(x.node=C,typeof C=="object"&&C!==null){switch(C.$$typeof){case en:Er(m,x,C.type,C.props,C.ref);return;case yn:throw Error(n(257));case v:var D=C._init;C=D(C._payload),In(m,x,C);return}if(q(C)){_i(m,x,C);return}if(C===null||typeof C!="object"?D=null:(D=je&&C[je]||C["@@iterator"],D=typeof D=="function"?D:null),D&&(D=D.call(C))){if(C=D.next(),!C.done){var he=[];do he.push(C.value),C=D.next();while(!C.done);_i(m,x,he)}return}throw m=Object.prototype.toString.call(C),Error(n(31,m==="[object Object]"?"object with keys {"+Object.keys(C).join(", ")+"}":m))}typeof C=="string"?(D=x.blockedSegment,D.lastPushedText=ce(x.blockedSegment.chunks,C,m.responseState,D.lastPushedText)):typeof C=="number"&&(D=x.blockedSegment,D.lastPushedText=ce(x.blockedSegment.chunks,""+C,m.responseState,D.lastPushedText))}function _i(m,x,C){for(var D=C.length,he=0;he<D;he++){var ue=x.treeContext;x.treeContext=Jt(ue,D,he);try{Tr(m,x,C[he])}finally{x.treeContext=ue}}}function Tr(m,x,C){var D=x.blockedSegment.formatContext,he=x.legacyContext,ue=x.context;try{return In(m,x,C)}catch(mt){if(rs(),typeof mt=="object"&&mt!==null&&typeof mt.then=="function"){C=mt;var Me=x.blockedSegment,Ve=at(m,Me.chunks.length,null,Me.formatContext,Me.lastPushedText,!0);Me.children.push(Ve),Me.lastPushedText=!1,m=rt(m,x.node,x.blockedBoundary,Ve,x.abortSet,x.legacyContext,x.context,x.treeContext).ping,C.then(m,m),x.blockedSegment.formatContext=D,x.legacyContext=he,x.context=ue,un(ue)}else throw x.blockedSegment.formatContext=D,x.legacyContext=he,x.context=ue,un(ue),mt}}function Hl(m){var x=m.blockedBoundary;m=m.blockedSegment,m.status=3,Bi(this,x,m)}function Hi(m,x,C){var D=m.blockedBoundary;m.blockedSegment.status=3,D===null?(x.allPendingTasks--,x.status!==2&&(x.status=2,x.destination!==null&&x.destination.close())):(D.pendingTasks--,D.forceClientRender||(D.forceClientRender=!0,m=C===void 0?Error(n(432)):C,D.errorDigest=x.onError(m),D.parentFlushed&&x.clientRenderedBoundaries.push(D)),D.fallbackAbortableTasks.forEach(function(he){return Hi(he,x,C)}),D.fallbackAbortableTasks.clear(),x.allPendingTasks--,x.allPendingTasks===0&&(D=x.onAllReady,D()))}function Qs(m,x){if(x.chunks.length===0&&x.children.length===1&&x.children[0].boundary===null){var C=x.children[0];C.id=x.id,C.parentFlushed=!0,C.status===1&&Qs(m,C)}else m.completedSegments.push(x)}function Bi(m,x,C){if(x===null){if(C.parentFlushed){if(m.completedRootSegment!==null)throw Error(n(389));m.completedRootSegment=C}m.pendingRootTasks--,m.pendingRootTasks===0&&(m.onShellError=pe,x=m.onShellReady,x())}else x.pendingTasks--,x.forceClientRender||(x.pendingTasks===0?(C.parentFlushed&&C.status===1&&Qs(x,C),x.parentFlushed&&m.completedBoundaries.push(x),x.fallbackAbortableTasks.forEach(Hl,m),x.fallbackAbortableTasks.clear()):C.parentFlushed&&C.status===1&&(Qs(x,C),x.completedSegments.length===1&&x.parentFlushed&&m.partialBoundaries.push(x)));m.allPendingTasks--,m.allPendingTasks===0&&(m=m.onAllReady,m())}function Ui(m){if(m.status!==2){var x=gt,C=Lt.current;Lt.current=kt;var D=Nt;Nt=m.responseState;try{var he=m.pingedTasks,ue;for(ue=0;ue<he.length;ue++){var Me=he[ue],Ve=m,mt=Me.blockedSegment;if(mt.status===0){un(Me.context);try{In(Ve,Me,Me.node),mt.lastPushedText&&mt.textEmbedded&&mt.chunks.push(fe),Me.abortSet.delete(Me),mt.status=1,Bi(Ve,Me.blockedBoundary,mt)}catch(Hn){if(rs(),typeof Hn=="object"&&Hn!==null&&typeof Hn.then=="function"){var bt=Me.ping;Hn.then(bt,bt)}else{Me.abortSet.delete(Me),mt.status=4;var wt=Me.blockedBoundary,Wt=Hn,Ln=Tt(Ve,Wt);if(wt===null?sn(Ve,Wt):(wt.pendingTasks--,wt.forceClientRender||(wt.forceClientRender=!0,wt.errorDigest=Ln,wt.parentFlushed&&Ve.clientRenderedBoundaries.push(wt))),Ve.allPendingTasks--,Ve.allPendingTasks===0){var _n=Ve.onAllReady;_n()}}}finally{}}}he.splice(0,ue),m.destination!==null&&Rr(m,m.destination)}catch(Hn){Tt(m,Hn),sn(m,Hn)}finally{Nt=D,Lt.current=C,C===kt&&un(x)}}}function Ys(m,x,C){switch(C.parentFlushed=!0,C.status){case 0:var D=C.id=m.nextSegmentId++;return C.lastPushedText=!1,C.textEmbedded=!1,m=m.responseState,i(x,Ye),i(x,m.placeholderPrefix),m=l(D.toString(16)),i(x,m),a(x,Le);case 1:C.status=2;var he=!0;D=C.chunks;var ue=0;C=C.children;for(var Me=0;Me<C.length;Me++){for(he=C[Me];ue<he.index;ue++)i(x,D[ue]);he=Xs(m,x,he)}for(;ue<D.length-1;ue++)i(x,D[ue]);return ue<D.length&&(he=a(x,D[ue])),he;default:throw Error(n(390))}}function Xs(m,x,C){var D=C.boundary;if(D===null)return Ys(m,x,C);if(D.parentFlushed=!0,D.forceClientRender)D=D.errorDigest,a(x,Ue),i(x,H),D&&(i(x,me),i(x,l(B(D))),i(x,X)),a(x,$e),Ys(m,x,C);else if(0<D.pendingTasks){D.rootSegmentID=m.nextSegmentId++,0<D.completedSegments.length&&m.partialBoundaries.push(D);var he=m.responseState,ue=he.nextSuspenseID++;he=p(he.boundaryPrefix+ue.toString(16)),D=D.id=he,Pe(x,m.responseState,D),Ys(m,x,C)}else if(D.byteSize>m.progressiveChunkSize)D.rootSegmentID=m.nextSegmentId++,m.completedBoundaries.push(D),Pe(x,m.responseState,D.id),Ys(m,x,C);else{if(a(x,Xe),C=D.completedSegments,C.length!==1)throw Error(n(391));Xs(m,x,C[0])}return a(x,w)}function Wi(m,x,C){return K(x,m.responseState,C.formatContext,C.id),Xs(m,x,C),ee(x,C.formatContext)}function qi(m,x,C){for(var D=C.completedSegments,he=0;he<D.length;he++)zi(m,x,C,D[he]);if(D.length=0,m=m.responseState,D=C.id,C=C.rootSegmentID,i(x,m.startInlineScript),m.sentCompleteBoundaryFunction?i(x,yt):(m.sentCompleteBoundaryFunction=!0,i(x,qe)),D===null)throw Error(n(395));return C=l(C.toString(16)),i(x,D),i(x,Kt),i(x,m.segmentPrefix),i(x,C),a(x,an)}function zi(m,x,C,D){if(D.status===2)return!0;var he=D.id;if(he===-1){if((D.id=C.rootSegmentID)===-1)throw Error(n(392));return Wi(m,x,D)}return Wi(m,x,D),m=m.responseState,i(x,m.startInlineScript),m.sentCompleteSegmentFunction?i(x,Be):(m.sentCompleteSegmentFunction=!0,i(x,Ke)),i(x,m.segmentPrefix),he=l(he.toString(16)),i(x,he),i(x,te),i(x,m.placeholderPrefix),i(x,he),a(x,Je)}function Rr(m,x){s=new Uint8Array(512),r=0;try{var C=m.completedRootSegment;if(C!==null&&m.pendingRootTasks===0){Xs(m,x,C),m.completedRootSegment=null;var D=m.responseState.bootstrapChunks;for(C=0;C<D.length-1;C++)i(x,D[C]);C<D.length&&a(x,D[C])}var he=m.clientRenderedBoundaries,ue;for(ue=0;ue<he.length;ue++){var Me=he[ue];D=x;var Ve=m.responseState,mt=Me.id,bt=Me.errorDigest,wt=Me.errorMessage,Wt=Me.errorComponentStack;if(i(D,Ve.startInlineScript),Ve.sentClientRenderFunction?i(D,Ct):(Ve.sentClientRenderFunction=!0,i(D,Zt)),mt===null)throw Error(n(395));i(D,mt),i(D,cn),(bt||wt||Wt)&&(i(D,Et),i(D,l(Bt(bt||"")))),(wt||Wt)&&(i(D,Et),i(D,l(Bt(wt||"")))),Wt&&(i(D,Et),i(D,l(Bt(Wt)))),a(D,ht)}he.splice(0,ue);var Ln=m.completedBoundaries;for(ue=0;ue<Ln.length;ue++)qi(m,x,Ln[ue]);Ln.splice(0,ue),o(x),s=new Uint8Array(512),r=0;var _n=m.partialBoundaries;for(ue=0;ue<_n.length;ue++){var Hn=_n[ue];e:{he=m,Me=x;var Zs=Hn.completedSegments;for(Ve=0;Ve<Zs.length;Ve++)if(!zi(he,Me,Hn,Zs[Ve])){Ve++,Zs.splice(0,Ve);var Ki=!1;break e}Zs.splice(0,Ve),Ki=!0}if(!Ki){m.destination=null,ue++,_n.splice(0,ue);return}}_n.splice(0,ue);var Ir=m.completedBoundaries;for(ue=0;ue<Ir.length;ue++)qi(m,x,Ir[ue]);Ir.splice(0,ue)}finally{o(x),m.allPendingTasks===0&&m.pingedTasks.length===0&&m.clientRenderedBoundaries.length===0&&m.completedBoundaries.length===0&&x.close()}}function Vi(m,x){try{var C=m.abortableTasks;C.forEach(function(D){return Hi(D,m,x)}),C.clear(),m.destination!==null&&Rr(m,m.destination)}catch(D){Tt(m,D),sn(m,D)}}return nr.renderToReadableStream=function(m,x){return new Promise(function(C,D){var he,ue,Me=new Promise(function(wt,Wt){ue=wt,he=Wt}),Ve=Qe(m,ye(x?x.identifierPrefix:void 0,x?x.nonce:void 0,x?x.bootstrapScriptContent:void 0,x?x.bootstrapScripts:void 0,x?x.bootstrapModules:void 0),Fe(x?x.namespaceURI:void 0),x?x.progressiveChunkSize:void 0,x?x.onError:void 0,ue,function(){var wt=new ReadableStream({type:"bytes",pull:function(Wt){if(Ve.status===1)Ve.status=2,u(Wt,Ve.fatalError);else if(Ve.status!==2&&Ve.destination===null){Ve.destination=Wt;try{Rr(Ve,Wt)}catch(Ln){Tt(Ve,Ln),sn(Ve,Ln)}}},cancel:function(){Vi(Ve)}},{highWaterMark:0});wt.allReady=Me,C(wt)},function(wt){Me.catch(function(){}),D(wt)},he);if(x&&x.signal){var mt=x.signal,bt=function(){Vi(Ve,mt.reason),mt.removeEventListener("abort",bt)};mt.addEventListener("abort",bt)}Ui(Ve)})},nr.version="18.3.1",nr}var Ia;function _u(){if(Ia)return is;Ia=1;var t,n;return t=Fu(),n=Ou(),is.version=t.version,is.renderToString=t.renderToString,is.renderToStaticMarkup=t.renderToStaticMarkup,is.renderToNodeStream=t.renderToNodeStream,is.renderToStaticNodeStream=t.renderToStaticNodeStream,is.renderToReadableStream=n.renderToReadableStream,is}var Hu=_u();function Bu(t){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}function ii(t,n){return Array(n+1).join(t)}function il(t){return t.replace(/^\n*/,"")}function al(t){for(var n=t.length;n>0&&t[n-1]===`
|
|
79
|
-
`;)n--;return t.substring(0,n)}function ol(t){return al(il(t))}var Uu=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function Ei(t){return Ti(t,Uu)}var ll=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function cl(t){return Ti(t,ll)}function Wu(t){return ul(t,ll)}var dl=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function qu(t){return Ti(t,dl)}function zu(t){return ul(t,dl)}function Ti(t,n){return n.indexOf(t.nodeName)>=0}function ul(t,n){return t.getElementsByTagName&&n.some(function(s){return t.getElementsByTagName(s).length})}var Vu=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function pl(t){return Vu.reduce(function(n,s){return n.replace(s[0],s[1])},t)}var gn={};gn.paragraph={filter:"p",replacement:function(t){return`
|
|
80
|
-
|
|
81
|
-
`+t+`
|
|
82
|
-
|
|
83
|
-
`}};gn.lineBreak={filter:"br",replacement:function(t,n,s){return s.br+`
|
|
84
|
-
`}};gn.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(t,n,s){var r=Number(n.nodeName.charAt(1));if(s.headingStyle==="setext"&&r<3){var i=ii(r===1?"=":"-",t.length);return`
|
|
85
|
-
|
|
86
|
-
`+t+`
|
|
87
|
-
`+i+`
|
|
88
|
-
|
|
89
|
-
`}else return`
|
|
90
|
-
|
|
91
|
-
`+ii("#",r)+" "+t+`
|
|
92
|
-
|
|
93
|
-
`}};gn.blockquote={filter:"blockquote",replacement:function(t){return t=ol(t).replace(/^/gm,"> "),`
|
|
94
|
-
|
|
95
|
-
`+t+`
|
|
96
|
-
|
|
97
|
-
`}};gn.list={filter:["ul","ol"],replacement:function(t,n){var s=n.parentNode;return s.nodeName==="LI"&&s.lastElementChild===n?`
|
|
98
|
-
`+t:`
|
|
99
|
-
|
|
100
|
-
`+t+`
|
|
101
|
-
|
|
102
|
-
`}};gn.listItem={filter:"li",replacement:function(t,n,s){var r=s.bulletListMarker+" ",i=n.parentNode;if(i.nodeName==="OL"){var a=i.getAttribute("start"),o=Array.prototype.indexOf.call(i.children,n);r=(a?Number(a)+o:o+1)+". "}var c=/\n$/.test(t);return t=ol(t)+(c?`
|
|
103
|
-
`:""),t=t.replace(/\n/gm,`
|
|
104
|
-
`+" ".repeat(r.length)),r+t+(n.nextSibling?`
|
|
105
|
-
`:"")}};gn.indentedCodeBlock={filter:function(t,n){return n.codeBlockStyle==="indented"&&t.nodeName==="PRE"&&t.firstChild&&t.firstChild.nodeName==="CODE"},replacement:function(t,n,s){return`
|
|
106
|
-
|
|
107
|
-
`+n.firstChild.textContent.replace(/\n/g,`
|
|
108
|
-
`)+`
|
|
109
|
-
|
|
110
|
-
`}};gn.fencedCodeBlock={filter:function(t,n){return n.codeBlockStyle==="fenced"&&t.nodeName==="PRE"&&t.firstChild&&t.firstChild.nodeName==="CODE"},replacement:function(t,n,s){for(var r=n.firstChild.getAttribute("class")||"",i=(r.match(/language-(\S+)/)||[null,""])[1],a=n.firstChild.textContent,o=s.fence.charAt(0),c=3,l=new RegExp("^"+o+"{3,}","gm"),p;p=l.exec(a);)p[0].length>=c&&(c=p[0].length+1);var u=ii(o,c);return`
|
|
111
|
-
|
|
112
|
-
`+u+i+`
|
|
113
|
-
`+a.replace(/\n$/,"")+`
|
|
114
|
-
`+u+`
|
|
115
|
-
|
|
116
|
-
`}};gn.horizontalRule={filter:"hr",replacement:function(t,n,s){return`
|
|
117
|
-
|
|
118
|
-
`+s.hr+`
|
|
119
|
-
|
|
120
|
-
`}};gn.inlineLink={filter:function(t,n){return n.linkStyle==="inlined"&&t.nodeName==="A"&&t.getAttribute("href")},replacement:function(t,n){var s=Ri(n.getAttribute("href")),r=Ii(hr(n.getAttribute("title"))),i=r?' "'+r+'"':"";return"["+t+"]("+s+i+")"}};gn.referenceLink={filter:function(t,n){return n.linkStyle==="referenced"&&t.nodeName==="A"&&t.getAttribute("href")},replacement:function(t,n,s){var r=Ri(n.getAttribute("href")),i=hr(n.getAttribute("title"));i&&(i=' "'+Ii(i)+'"');var a,o;switch(s.linkReferenceStyle){case"collapsed":a="["+t+"][]",o="["+t+"]: "+r+i;break;case"shortcut":a="["+t+"]",o="["+t+"]: "+r+i;break;default:var c=this.references.length+1;a="["+t+"]["+c+"]",o="["+c+"]: "+r+i}return this.references.push(o),a},references:[],append:function(t){var n="";return this.references.length&&(n=`
|
|
121
|
-
|
|
122
|
-
`+this.references.join(`
|
|
123
|
-
`)+`
|
|
124
|
-
|
|
125
|
-
`,this.references=[]),n}};gn.emphasis={filter:["em","i"],replacement:function(t,n,s){return t.trim()?s.emDelimiter+t+s.emDelimiter:""}};gn.strong={filter:["strong","b"],replacement:function(t,n,s){return t.trim()?s.strongDelimiter+t+s.strongDelimiter:""}};gn.code={filter:function(t){var n=t.previousSibling||t.nextSibling,s=t.parentNode.nodeName==="PRE"&&!n;return t.nodeName==="CODE"&&!s},replacement:function(t){if(!t)return"";t=t.replace(/\r?\n|\r/g," ");for(var n=/^`|^ .*?[^ ].* $|`$/.test(t)?" ":"",s="`",r=t.match(/`+/gm)||[];r.indexOf(s)!==-1;)s=s+"`";return s+n+t+n+s}};gn.image={filter:"img",replacement:function(t,n){var s=pl(hr(n.getAttribute("alt"))),r=Ri(n.getAttribute("src")||""),i=hr(n.getAttribute("title")),a=i?' "'+Ii(i)+'"':"";return r?"":""}};function hr(t){return t?t.replace(/(\n+\s*)+/g,`
|
|
126
|
-
`):""}function Ri(t){var n=t.replace(/([<>()])/g,"\\$1");return n.indexOf(" ")>=0?"<"+n+">":n}function Ii(t){return t.replace(/"/g,'\\"')}function hl(t){this.options=t,this._keep=[],this._remove=[],this.blankRule={replacement:t.blankReplacement},this.keepReplacement=t.keepReplacement,this.defaultRule={replacement:t.defaultReplacement},this.array=[];for(var n in t.rules)this.array.push(t.rules[n])}hl.prototype={add:function(t,n){this.array.unshift(n)},keep:function(t){this._keep.unshift({filter:t,replacement:this.keepReplacement})},remove:function(t){this._remove.unshift({filter:t,replacement:function(){return""}})},forNode:function(t){if(t.isBlank)return this.blankRule;var n;return(n=_r(this.array,t,this.options))||(n=_r(this._keep,t,this.options))||(n=_r(this._remove,t,this.options))?n:this.defaultRule},forEach:function(t){for(var n=0;n<this.array.length;n++)t(this.array[n],n)}};function _r(t,n,s){for(var r=0;r<t.length;r++){var i=t[r];if(Ku(i,n,s))return i}}function Ku(t,n,s){var r=t.filter;if(typeof r=="string"){if(r===n.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(n.nodeName.toLowerCase())>-1)return!0}else if(typeof r=="function"){if(r.call(t,n,s))return!0}else throw new TypeError("`filter` needs to be a string, array, or function")}function Gu(t){var n=t.element,s=t.isBlock,r=t.isVoid,i=t.isPre||function(f){return f.nodeName==="PRE"};if(!(!n.firstChild||i(n))){for(var a=null,o=!1,c=null,l=La(c,n,i);l!==n;){if(l.nodeType===3||l.nodeType===4){var p=l.data.replace(/[ \r\n\t]+/g," ");if((!a||/ $/.test(a.data))&&!o&&p[0]===" "&&(p=p.substr(1)),!p){l=Hr(l);continue}l.data=p,a=l}else if(l.nodeType===1)s(l)||l.nodeName==="BR"?(a&&(a.data=a.data.replace(/ $/,"")),a=null,o=!1):r(l)||i(l)?(a=null,o=!0):a&&(o=!1);else{l=Hr(l);continue}var u=La(c,l,i);c=l,l=u}a&&(a.data=a.data.replace(/ $/,""),a.data||Hr(a))}}function Hr(t){var n=t.nextSibling||t.parentNode;return t.parentNode.removeChild(t),n}function La(t,n,s){return t&&t.parentNode===n||s(n)?n.nextSibling||n.parentNode:n.firstChild||n.nextSibling||n.parentNode}var Li=typeof window<"u"?window:{};function Ju(){var t=Li.DOMParser,n=!1;try{new t().parseFromString("","text/html")&&(n=!0)}catch{}return n}function Qu(){var t=function(){};return Yu()?t.prototype.parseFromString=function(n){var s=new window.ActiveXObject("htmlfile");return s.designMode="on",s.open(),s.write(n),s.close(),s}:t.prototype.parseFromString=function(n){var s=document.implementation.createHTMLDocument("");return s.open(),s.write(n),s.close(),s},t}function Yu(){var t=!1;try{document.implementation.createHTMLDocument("").open()}catch{Li.ActiveXObject&&(t=!0)}return t}var Xu=Ju()?Li.DOMParser:Qu();function Zu(t,n){var s;if(typeof t=="string"){var r=ep().parseFromString('<x-turndown id="turndown-root">'+t+"</x-turndown>","text/html");s=r.getElementById("turndown-root")}else s=t.cloneNode(!0);return Gu({element:s,isBlock:Ei,isVoid:cl,isPre:n.preformattedCode?tp:null}),s}var Br;function ep(){return Br=Br||new Xu,Br}function tp(t){return t.nodeName==="PRE"||t.nodeName==="CODE"}function np(t,n){return t.isBlock=Ei(t),t.isCode=t.nodeName==="CODE"||t.parentNode.isCode,t.isBlank=sp(t),t.flankingWhitespace=rp(t,n),t}function sp(t){return!cl(t)&&!qu(t)&&/^\s*$/i.test(t.textContent)&&!Wu(t)&&!zu(t)}function rp(t,n){if(t.isBlock||n.preformattedCode&&t.isCode)return{leading:"",trailing:""};var s=ip(t.textContent);return s.leadingAscii&&Ma("left",t,n)&&(s.leading=s.leadingNonAscii),s.trailingAscii&&Ma("right",t,n)&&(s.trailing=s.trailingNonAscii),{leading:s.leading,trailing:s.trailing}}function ip(t){var n=t.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:n[1],leadingAscii:n[2],leadingNonAscii:n[3],trailing:n[4],trailingNonAscii:n[5],trailingAscii:n[6]}}function Ma(t,n,s){var r,i,a;return t==="left"?(r=n.previousSibling,i=/ $/):(r=n.nextSibling,i=/^ /),r&&(r.nodeType===3?a=i.test(r.nodeValue):s.preformattedCode&&r.nodeName==="CODE"?a=!1:r.nodeType===1&&!Ei(r)&&(a=i.test(r.textContent))),a}var ap=Array.prototype.reduce;function mr(t){if(!(this instanceof mr))return new mr(t);var n={rules:gn,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(s,r){return r.isBlock?`
|
|
127
|
-
|
|
128
|
-
`:""},keepReplacement:function(s,r){return r.isBlock?`
|
|
129
|
-
|
|
130
|
-
`+r.outerHTML+`
|
|
131
|
-
|
|
132
|
-
`:r.outerHTML},defaultReplacement:function(s,r){return r.isBlock?`
|
|
133
|
-
|
|
134
|
-
`+s+`
|
|
135
|
-
|
|
136
|
-
`:s}};this.options=Bu({},n,t),this.rules=new hl(this.options)}mr.prototype={turndown:function(t){if(!cp(t))throw new TypeError(t+" is not a string, or an element/document/fragment node.");if(t==="")return"";var n=ml.call(this,new Zu(t,this.options));return op.call(this,n)},use:function(t){if(Array.isArray(t))for(var n=0;n<t.length;n++)this.use(t[n]);else if(typeof t=="function")t(this);else throw new TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(t,n){return this.rules.add(t,n),this},keep:function(t){return this.rules.keep(t),this},remove:function(t){return this.rules.remove(t),this},escape:function(t){return pl(t)}};function ml(t){var n=this;return ap.call(t.childNodes,function(s,r){r=new np(r,n.options);var i="";return r.nodeType===3?i=r.isCode?r.nodeValue:n.escape(r.nodeValue):r.nodeType===1&&(i=lp.call(n,r)),fl(s,i)},"")}function op(t){var n=this;return this.rules.forEach(function(s){typeof s.append=="function"&&(t=fl(t,s.append(n.options)))}),t.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function lp(t){var n=this.rules.forNode(t),s=ml.call(this,t),r=t.flankingWhitespace;return(r.leading||r.trailing)&&(s=s.trim()),r.leading+n.replacement(s,t,this.options)+r.trailing}function fl(t,n){var s=al(t),r=il(n),i=Math.max(t.length-s.length,n.length-r.length),a=`
|
|
137
|
-
|
|
138
|
-
`.substring(0,i);return s+a+r}function cp(t){return t!=null&&(typeof t=="string"||t.nodeType&&(t.nodeType===1||t.nodeType===9||t.nodeType===11))}var Pa=/highlight-(?:text|source)-([a-z0-9]+)/;function dp(t){t.addRule("highlightedCodeBlock",{filter:function(n){var s=n.firstChild;return n.nodeName==="DIV"&&Pa.test(n.className)&&s&&s.nodeName==="PRE"},replacement:function(n,s,r){var i=s.className||"",a=(i.match(Pa)||[null,""])[1];return`
|
|
139
|
-
|
|
140
|
-
`+r.fence+a+`
|
|
141
|
-
`+s.firstChild.textContent+`
|
|
142
|
-
`+r.fence+`
|
|
143
|
-
|
|
144
|
-
`}})}function up(t){t.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(n){return"~"+n+"~"}})}var pp=Array.prototype.indexOf,hp=Array.prototype.every,Ts={};Ts.tableCell={filter:["th","td"],replacement:function(t,n){return gl(t,n)}};Ts.tableRow={filter:"tr",replacement:function(t,n){var s="",r={left:":--",right:"--:",center:":-:"};if(Mi(n))for(var i=0;i<n.childNodes.length;i++){var a="---",o=(n.childNodes[i].getAttribute("align")||"").toLowerCase();o&&(a=r[o]||a),s+=gl(a,n.childNodes[i])}return`
|
|
145
|
-
`+t+(s?`
|
|
146
|
-
`+s:"")}};Ts.table={filter:function(t){return t.nodeName==="TABLE"&&Mi(t.rows[0])},replacement:function(t){return t=t.replace(`
|
|
147
|
-
|
|
148
|
-
`,`
|
|
149
|
-
`),`
|
|
150
|
-
|
|
151
|
-
`+t+`
|
|
152
|
-
|
|
153
|
-
`}};Ts.tableSection={filter:["thead","tbody","tfoot"],replacement:function(t){return t}};function Mi(t){var n=t.parentNode;return n.nodeName==="THEAD"||n.firstChild===t&&(n.nodeName==="TABLE"||mp(n))&&hp.call(t.childNodes,function(s){return s.nodeName==="TH"})}function mp(t){var n=t.previousSibling;return t.nodeName==="TBODY"&&(!n||n.nodeName==="THEAD"&&/^\s*$/i.test(n.textContent))}function gl(t,n){var s=pp.call(n.parentNode.childNodes,n),r=" ";return s===0&&(r="| "),r+t+" |"}function fp(t){t.keep(function(s){return s.nodeName==="TABLE"&&!Mi(s.rows[0])});for(var n in Ts)t.addRule(n,Ts[n])}function gp(t){t.addRule("taskListItems",{filter:function(n){return n.type==="checkbox"&&n.parentNode.nodeName==="LI"},replacement:function(n,s){return(s.checked?"[x]":"[ ]")+" "}})}function xp(t){t.use([dp,up,fp,gp])}const vp=wr().use(br).use(vi);function ai(t){var o;const n=t.querySelector("code"),s=Hs(n??t),r=((o=n==null?void 0:n.className.match(/language-([^\s]+)/))==null?void 0:o[1])??"",i=r==="plaintext"?"":r,a="`".repeat(Math.max(3,...Array.from(s.matchAll(/`+/g),c=>c[0].length+1)));return`
|
|
154
|
-
|
|
155
|
-
${a}${i}
|
|
156
|
-
${s.replace(/\n$/,"")}
|
|
157
|
-
${a}
|
|
158
|
-
|
|
159
|
-
`}const Bn=new mr({headingStyle:"atx",codeBlockStyle:"fenced",bulletListMarker:"-",blankReplacement:(t,n)=>{if(n.nodeName==="BLOCKQUOTE"&&n.hasAttribute("data-rich-highlight"))return`
|
|
160
|
-
|
|
161
|
-
> [!NOTE]
|
|
162
|
-
>
|
|
163
|
-
|
|
164
|
-
`;if(n.nodeName==="PRE")return ai(n);const s=Array.from(n.querySelectorAll("pre"));return s.length?s.map(ai).join(`
|
|
165
|
-
|
|
166
|
-
`):"isBlock"in n&&n.isBlock?`
|
|
167
|
-
|
|
168
|
-
`:""}});Bn.use(xp);Bn.addRule("textHighlight",{filter:t=>t.nodeName==="SPAN"&&!!si(t.style.backgroundColor),replacement:(t,n)=>`<mark style="background-color: ${si(n.style.backgroundColor).hex}">${t}</mark>`});Bn.addRule("highlightBlock",{filter:t=>t.nodeName==="BLOCKQUOTE"&&t.hasAttribute("data-rich-highlight"),replacement:t=>`
|
|
169
|
-
|
|
170
|
-
> [!NOTE]
|
|
171
|
-
`+t.trim().split(`
|
|
172
|
-
`).map(n=>"> "+n).join(`
|
|
173
|
-
`)+`
|
|
174
|
-
|
|
175
|
-
`});Bn.addRule("taskCheckbox",{filter:t=>t.nodeName==="INPUT"&&t.getAttribute("type")==="checkbox",replacement:(t,n)=>n.checked?"[x] ":"[ ] "});Bn.addRule("preservedSource",{filter:t=>t.hasAttribute("data-rich-source"),replacement:(t,n)=>`
|
|
176
|
-
|
|
177
|
-
`+n.getAttribute("data-rich-source")+`
|
|
178
|
-
|
|
179
|
-
`});Bn.addRule("preservedInlineSource",{filter:t=>t.hasAttribute("data-rich-inline"),replacement:(t,n)=>n.getAttribute("data-rich-inline")??""});Bn.addRule("wikiLink",{filter:t=>t.nodeName==="A"&&(t.getAttribute("href")??"").startsWith("#wiki="),replacement:(t,n)=>{let s;try{s=decodeURIComponent(n.getAttribute("href").slice(6))}catch{return t}return`[[${s}${t===s?"":"|"+t}]]`}});Bn.addRule("codeFence",{filter:"pre",replacement:(t,n)=>ai(n)});Bn.addRule("tableBreak",{filter:"br",replacement:(t,n)=>n.closest("td, th")?"<br>":`
|
|
180
|
-
`});Bn.addRule("tableCell",{filter:["th","td"],replacement:(t,n)=>{var r;return(Array.from(((r=n.parentNode)==null?void 0:r.childNodes)??[]).indexOf(n)===0?"| ":" ")+t.trim().replace(/\|/g,"\\|").replace(/\n/g,"<br>")+" |"}});function xl(t,n=!1){return t.type==="html"?!n:["definition","footnoteDefinition","footnoteReference"].includes(t.type)?!0:"children"in t&&t.children.some(s=>xl(s,!0))}function kp(){return t=>{const n=s=>{if("children"in s)for(let r=0;r<s.children.length;r++){const i=s.children[r];i.type==="html"&&s.type!=="root"?/^<br\s*\/?>(?:\r?\n)?$/i.test(i.value)?s.children[r]={type:"break"}:s.children[r]={type:"text",value:i.value,data:{hName:"span",hProperties:{"data-rich-inline":i.value,contentEditable:"false"},hChildren:[{type:"text",value:i.value}]}}:n(i)}};n(t)}}function yp(t,n=!1){var u,f,k;const s=[],r=vp.parse(t).children,i=r.filter(j=>j.type==="definition").map(j=>{var I,E;return t.slice((I=j.position)==null?void 0:I.start.offset,(E=j.position)==null?void 0:E.end.offset)}).join(`
|
|
181
|
-
`),a=(u=t.match(/^---\r?\n[\s\S]*?\r?\n(?:---|\.\.\.)(?:\r?\n|$)/))==null?void 0:u[0],o=n?Wo(t):null,c=n?Bo(t).ranges:[];let l=!0,p=0;a&&(s.push({raw:a.trimEnd(),prefix:"",html:"",protected:!0,hidden:n}),p=a.trimEnd().length);for(const j of r){const I=(f=j.position)==null?void 0:f.start.offset,E=(k=j.position)==null?void 0:k.end.offset;if(I===void 0||E===void 0||I<p)continue;const $=t.slice(I,E),N=xl(j),R=c.some(y=>y.start===I&&y.end===E)||!!o&&l&&j.type==="heading"&&j.depth===1&&o.readingBody!==o.body;j.type==="heading"&&j.depth===1&&(l=!1),s.push({raw:$,prefix:t.slice(p,I),protected:N,hidden:R,html:N?"":Hu.renderToStaticMarkup(e.jsx(jr,{remarkPlugins:[vi,Jo,kp,Qo],rehypePlugins:[ro],children:(n?eu($):$)+`
|
|
182
|
-
|
|
183
|
-
`+i}))}),p=E}return{source:t,blocks:s,suffix:t.slice(p)}}function wp(t,n,s){t.replaceChildren();let r=0;n.blocks.forEach((i,a)=>{r+=i.prefix.length;const o=n.source.slice(0,r).split(`
|
|
184
|
-
`).length,c=t.ownerDocument.createElement("div");if(c.dataset.richBlock=String(a),c.dataset.sourceStart=String(o),c.dataset.sourceEnd=String(o+i.raw.split(`
|
|
185
|
-
`).length-1),c.className="rich-block",c.hidden=!!i.hidden,i.protected){c.contentEditable="false",c.dataset.richSource=i.raw,c.classList.add("rich-source-block");const l=t.ownerDocument.createElement("small");l.textContent=s;const p=t.ownerDocument.createElement("pre");p.textContent=i.raw,c.append(l,p)}else c.innerHTML=i.html;c.querySelectorAll('input[type="checkbox"]').forEach(l=>{l.disabled=!1}),t.append(c),r+=i.raw.length,i.html=c.innerHTML}),n.blocks.length||(t.innerHTML="<p><br></p>")}function Aa(t,n){const s=n.ownerDocument.createElement("div");return s.append(t.cloneNode(!0)),s.querySelectorAll("th, td").forEach(r=>{const i=r.style.textAlign;["left","center","right"].includes(i)&&r.setAttribute("align",i)}),Bn.turndown(s)}function bp(t,n){t=t.cloneNode(!0),t.querySelectorAll("[data-wiki-placeholder]").forEach(i=>i.removeAttribute("data-wiki-placeholder")),t.querySelectorAll("[data-rich-ui]").forEach(i=>i.remove()),t.querySelectorAll("img[data-rich-image-src]").forEach(i=>{i.setAttribute("src",i.dataset.richImageSrc),i.removeAttribute("data-rich-image-src")});for(let i=n.blocks.length-1;i>=0;i--){const a=n.blocks[i];if(!a.hidden||t.querySelector(`[data-rich-block="${i}"]`))continue;const o=t.ownerDocument.createElement("div");o.dataset.richBlock=String(i),o.innerHTML=a.html;const c=[...t.children].find(l=>Number(l.dataset.richBlock)>i);c?t.insertBefore(o,c):t.prepend(o)}const s=new Set,r=[];for(const i of Array.from(t.childNodes)){const a=i instanceof HTMLElement?i.dataset.richBlock:void 0,o=a===void 0?-1:Number(a),c=n.blocks[o];if(c&&!s.has(o)){s.add(o);const p=i instanceof HTMLElement&&i.tagName==="DIV"&&i.innerHTML===c.html||c.protected?c.raw:Aa(i,t);r.push((r.length?c.prefix||`
|
|
186
|
-
|
|
187
|
-
`:c.prefix)+p)}else{const l=Aa(i,t);l&&r.push((r.length?`
|
|
188
|
-
|
|
189
|
-
`:"")+l)}}return r.join("")+(r.length?n.suffix:"")}const jp=["javascript","typescript","python","bash","json","yaml","html","css","sql","go","rust","java","c","cpp","csharp","ruby","php","swift","kotlin","markdown","xml","toml","diff","mermaid"],vl=d.memo(function({value:n,readOnly:s,onChange:r,file:i,wiki:a}){const o=nt(),[c,l]=d.useState(null),p=d.useRef(null),[u,f]=d.useState([]),k=d.useRef(!1),[j,I]=d.useState(!1),[E,$]=d.useState(""),N=d.useRef(null),R=d.useRef(s);R.current=s,d.useEffect(()=>()=>{var w;(w=N.current)==null||w.abort()},[]);const y=d.useRef(null),L=d.useRef(null);d.useEffect(()=>()=>{var w;(w=L.current)==null||w.dispose(),L.current=null},[]);const b=w=>{L.current??(L.current=$u(!!a)),L.current.update(w)},F=()=>{var $e;const w=window.getSelection(),H=w==null?void 0:w.anchorNode,X=H instanceof Element?H:H==null?void 0:H.parentElement,me=X==null?void 0:X.closest("pre > code");return me&&(($e=y.current)!=null&&$e.contains(me))&&(w!=null&&w.focusNode)&&me.contains(w.focusNode)?me:null},[B,ie]=d.useState(null),[Q,q]=d.useState(null),ke=d.useRef(null),Re=d.useRef(null),O=d.useRef(null),_e=d.useRef(null),M=d.useRef(null),[V,ve]=d.useState(!1),ye=()=>{var X;const w=window.getSelection();if(!(w!=null&&w.rangeCount)||w.isCollapsed||!((X=y.current)!=null&&X.contains(w.anchorNode))||!y.current.contains(w.focusNode))return null;const H=w.getRangeAt(0);return[...y.current.querySelectorAll("pre, code, [contenteditable=false]")].some(me=>H.intersectsNode(me))?null:H};d.useEffect(()=>{const w=()=>{var st,lt,g,ne,We;const H=window.getSelection();H!=null&&H.rangeCount&&((st=y.current)!=null&&st.contains(H.anchorNode))&&y.current.contains(H.focusNode)&&(p.current=H.getRangeAt(0).cloneRange()),(lt=y.current)==null||lt.querySelectorAll("[data-wiki-placeholder]").forEach(He=>He.removeAttribute("data-wiki-placeholder"));const X=H==null?void 0:H.anchorNode,me=(g=X instanceof Element?X:X==null?void 0:X.parentElement)==null?void 0:g.closest("p, div");a&&me&&me!==y.current&&((ne=y.current)!=null&&ne.contains(me))&&!((We=me.textContent)!=null&&We.trim())&&!me.querySelector("img, code")&&me.setAttribute("data-wiki-placeholder",o("wikiEmptyParagraph"));const $e=ye();if(ve(!!$e),!$e){ie(null);return}const Pe=$e.getBoundingClientRect();if(Pe.bottom<0||Pe.top>window.innerHeight){ie(null);return}ie({x:Math.max(8,Math.min(Pe.left+Pe.width/2-160,window.innerWidth-328)),y:Pe.top>=50?Pe.top-46:Math.min(Pe.bottom+8,window.innerHeight-46)})};return document.addEventListener("selectionchange",w),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{document.removeEventListener("selectionchange",w),window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[]),d.useLayoutEffect(()=>{const w=M.current,H=ye();if(!w||!H)return;const X=H.getBoundingClientRect();w.style.left=`${Math.max(8,Math.min(X.left+X.width/2-w.offsetWidth/2,window.innerWidth-w.offsetWidth-8))}px`,w.style.top=`${Math.max(8,X.top>=w.offsetHeight+8?X.top-w.offsetHeight-8:Math.min(X.bottom+8,window.innerHeight-w.offsetHeight-8))}px`},[B]);const oe=d.useRef(null),[Fe,U]=d.useState(null),[fe,ce]=d.useState(0),[ae,z]=d.useState(null),Z=d.useRef(null),W=()=>{Z.current=null,U(null)},ge=d.useRef(null);d.useLayoutEffect(()=>{if(!y.current||n===ge.current)return;W(),z(null);const w=yp(n,!!a);wp(y.current,w,o("richSourceBlock")),a&&(y.current.querySelectorAll("pre:has(> code)").forEach(H=>H.classList.add("codeblock")),y.current.querySelectorAll("h2").forEach((H,X)=>{H.id=`wiki-heading-${X}`}),y.current.querySelectorAll("p").forEach(H=>{[...a.added].some(X=>{var me;return X.trim()&&((me=H.textContent)==null?void 0:me.includes(X))})&&H.classList.add("wiki-added")}),y.current.querySelectorAll("code").forEach(H=>{if(H.closest("pre")||!a.resolveCode(H.textContent??""))return;const X=document.createElement("a");X.href=`#wiki=${encodeURIComponent(H.textContent??"")}`,X.textContent=H.textContent,H.replaceChildren(X)}),y.current.querySelectorAll("[data-rich-block]").forEach(H=>{w.blocks[Number(H.dataset.richBlock)].html=H.innerHTML})),oe.current=w,ge.current=n},[n,o]),d.useLayoutEffect(()=>{!a||!y.current||y.current.querySelectorAll("p").forEach(w=>w.classList.toggle("wiki-added",[...a.added].some(H=>{var X;return H.trim()&&((X=w.textContent)==null?void 0:X.includes(H))})))},[a==null?void 0:a.added,n]),d.useLayoutEffect(()=>{var w;s&&W(),(w=y.current)==null||w.querySelectorAll('input[type="checkbox"]').forEach(H=>{H.disabled=s})},[s,n]),d.useLayoutEffect(()=>{var w;(w=y.current)==null||w.querySelectorAll("pre > code").forEach(H=>{var st;const X=H.parentElement;a&&X.classList.add("codeblock");let me=X.querySelector("select[data-code-language]");if(!me){const lt=document.createElement("span");if(lt.dataset.richUi="",lt.contentEditable="false",lt.className="fp-code-language",me=document.createElement("select"),me.dataset.codeLanguage="",lt.append(me),a){const g=document.createElement("button");g.type="button",g.textContent=o("copy"),g.onmousedown=ne=>ne.preventDefault(),g.onclick=()=>{navigator.clipboard.writeText(Hs(H))},lt.append(g)}X.prepend(lt)}const $e=((st=H.className.match(/language-([^\s]+)/))==null?void 0:st[1])??"",Pe=$e==="plaintext"?"":$e;me.replaceChildren();for(const lt of["",...new Set([...jp,...Pe?[Pe]:[]])])me.add(new Option(lt||o(a?"wikiCodeAutomatic":"richPlainText"),lt));me.value=Pe,me.disabled=s,me.setAttribute("aria-label",o("richCodeLanguage")),b(H)})},[n,s,o]),d.useLayoutEffect(()=>{var w;(w=y.current)==null||w.querySelectorAll("img").forEach(H=>{const X=H.dataset.richImageSrc??H.getAttribute("src")??"";!X||/^(?:[a-z]+:|\/\/|#)/i.test(X)||(H.dataset.richImageSrc=X,H.src=sl(X,i))})},[n,i.cwd,i.path]),d.useEffect(()=>{var H,X;if(!a||s||k.current||!y.current)return;k.current=!0,y.current.focus({preventScroll:!0});const w=document.createRange();w.selectNodeContents(y.current),w.collapse(!1),(H=window.getSelection())==null||H.removeAllRanges(),(X=window.getSelection())==null||X.addRange(w),p.current=w.cloneRange()},[s]),d.useLayoutEffect(()=>{if(!a||!y.current)return;const w=[];y.current.querySelectorAll("pre > code.language-mermaid").forEach(H=>{const X=H.parentElement;let me=X.querySelector(".wiki-mermaid-preview");me||(me=document.createElement("div"),me.dataset.richUi="",me.contentEditable="false",me.className="wiki-mermaid-preview",X.prepend(me)),w.push({host:me,code:Hs(H)})}),y.current.querySelectorAll(".wiki-mermaid-preview").forEach(H=>{w.some(X=>X.host===H)||H.remove()}),f(w)},[n]);const Ie=()=>{var me,$e;const w=(me=window.getSelection())==null?void 0:me.anchorNode,H=w instanceof Element?w:w==null?void 0:w.parentElement,X=(H==null?void 0:H.closest("th, td"))??null;return X&&(($e=y.current)!=null&&$e.contains(X))?X:null},Ae=w=>{var me;(me=y.current)==null||me.focus();const H=document.createRange();H.selectNodeContents(w),H.collapse(!0);const X=window.getSelection();X==null||X.removeAllRanges(),X==null||X.addRange(H),z(w)},re=(w,H=ae)=>{var st,lt;if(s||!H||!((st=y.current)!=null&&st.contains(H)))return;const X=H.closest("table"),me=H.parentElement,$e=H.cellIndex;let Pe=H;if(w==="row"){const g=document.createElement("tr");for(const ne of Array.from(X.rows[0].cells)){const We=g.insertCell();We.style.textAlign=ne.style.textAlign,We.append(document.createElement("br"))}((lt=me.parentElement)==null?void 0:lt.tagName)==="THEAD"?(X.tBodies[0]??X.createTBody()).prepend(g):me.after(g),Pe=g.cells[0]}else if(w==="column")for(const g of Array.from(X.rows)){const ne=document.createElement(g.cells[0].tagName==="TH"?"th":"td");ne.style.textAlign=g.cells[$e].style.textAlign,ne.tagName==="TH"?ne.textContent=o("richColumn"):ne.append(document.createElement("br")),g.cells[$e].after(ne),g===me&&(Pe=ne)}else if(w==="removeRow"){if(me.rowIndex===0||X.rows.length<=2)return;Pe=X.rows[me.rowIndex-1].cells[$e],me.remove()}else{if(me.cells.length<=1)return;Pe=me.cells[$e>0?$e-1:1];for(const g of Array.from(X.rows))g.deleteCell($e)}Ae(Pe),xe()},we=async w=>{var $e;if(R.current||N.current||!y.current)return;const H=window.getSelection();if(!(H!=null&&H.rangeCount)||!y.current.contains(H.anchorNode))return;const X=H.getRangeAt(0).cloneRange(),me=new AbortController;N.current=me,I(!0),$("");try{if(w.size>5*1024*1024)throw new Error(o("richImageTooLarge"));const Pe=await new Promise((ne,We)=>{const He=new FileReader;He.onload=()=>ne(String(He.result).split(",")[1]),He.onerror=()=>We(new Error(o("richImageFailed"))),He.readAsDataURL(w)});if(me.signal.aborted)return;const st=await fetch(Sn("/api/markdown-image"),{method:"POST",headers:{"Content-Type":"application/json"},signal:me.signal,body:JSON.stringify({clientId:fn(),cwd:i.cwd,path:i.path,data:Pe})});if(!st.ok)throw new Error(o("richImageFailed"));const lt=await st.json();if(typeof lt.path!="string")throw new Error(o("richImageFailed"));if(me.signal.aborted)return;if(R.current||!(($e=y.current)!=null&&$e.contains(X.startContainer)))throw new Error(o("richImageFailed"));y.current.focus(),H.removeAllRanges(),H.addRange(X);const g=document.createElement("img");g.setAttribute("src",lt.path),g.setAttribute("alt",w.name||"screenshot"),document.execCommand("insertHTML",!1,g.outerHTML),xe()}catch(Pe){me.signal.aborted||$(Pe.message)}finally{me.signal.aborted||I(!1),N.current===me&&(N.current=null)}},A=w=>{var st;const H=w.closest("pre"),X=H==null?void 0:H.querySelector("code");if(s||!H||!X||!((st=y.current)!=null&&st.contains(H)))return;const me=w.value;X.className=`hljs language-${me||"plaintext"}`,X.innerHTML=Ks(Hs(X),me==="toml"?"ini":me),X.textContent||X.append(document.createElement("br")),y.current.focus();const $e=document.createRange();$e.selectNodeContents(X),$e.collapse(!1);const Pe=window.getSelection();Pe==null||Pe.removeAllRanges(),Pe==null||Pe.addRange($e),xe()},xe=()=>{if(s||!y.current||!oe.current)return;const w=bp(y.current,oe.current);ge.current=w,r(w)},_=(w,H)=>{if(s||!y.current)return;const X=window.getSelection();(!(X!=null&&X.anchorNode)||!y.current.contains(X.anchorNode))&&y.current.focus(),document.execCommand(w,!1,H),xe()},Se=[...(a?[1,2,3]:[1,2,3,4,5,6]).map(w=>({label:"richHeading",keywords:`heading header title h${w} bt${w} biaoti${w} 标题${w}`,alias:`bt${w}`,action:"formatBlock",argument:`h${w}`})),{label:"richParagraph",alias:"zw",keywords:"paragraph text zw zhengwen 正文",action:"formatBlock",argument:"p"},{label:"richCodeBlock",alias:"dmk",keywords:"code fence dmk daimakuai 代码 代码块",action:"insertHTML",argument:"<pre><code data-slash-insert><br></code></pre><p><br></p>"},{label:"richHighlightBlock",alias:"glk",keywords:"highlight note callout glk gaoliangkuai ts tishi 高亮 提示",action:"insertHTML",argument:'<blockquote class="rich-highlight" data-rich-highlight="note"><p data-slash-insert><br></p></blockquote><p><br></p>'},{label:"richTable",alias:"bg",keywords:"table bg biaoge 表格",action:"insertHTML",argument:`<table><thead><tr><th data-slash-insert>${o("richColumn")} 1</th><th>${o("richColumn")} 2</th></tr></thead><tbody><tr><td>…</td><td>…</td></tr></tbody></table><p><br></p>`},{label:"richList",alias:"lb",keywords:"bullet list lb liebiao wxlb wuxuliebiao 列表 无序列表",action:"insertUnorderedList"},{label:"richOrderedList",alias:"bh",keywords:"number ordered bh bianhao yxlb youxuliebiao 编号 有序列表",action:"insertOrderedList"},{label:"richTaskList",alias:"rw",keywords:"task todo checkbox rw rwlb renwu renwuliebiao 任务",action:"insertHTML",argument:'<ul><li><input type="checkbox"><span data-slash-insert> </span></li></ul><p><br></p>'},{label:"richQuote",alias:"yy",keywords:"quote yy yinyong 引用",action:"formatBlock",argument:"blockquote"},{label:"richDivider",alias:"fgx",keywords:"divider horizontal rule fgx fengexian 分隔线",action:"insertHTML",argument:"<hr><p><br></p>"},{label:"richImage",alias:"tp",keywords:"image photo upload tp tupian 图片",action:"image"},{label:"richWikiLink",alias:"sl",keywords:"wiki link document sl shuanglian 链接 双链 文档",action:"wikiLink"},{label:"wikiMentionDate",alias:"date",keywords:"date mention riqi 日期",action:"insertText",get argument(){return new Date().toLocaleDateString("sv-SE")}}],J=["zw","bt2","bt3","lb","bg","tp","rw","yy","dmk","sl","date"],De=a?Se.filter(w=>J.includes(w.alias)).sort((w,H)=>J.indexOf(w.alias)-J.indexOf(H.alias)):Se.filter(w=>w.alias!=="date"),G={wikiMentionDate:e.jsx(So,{}),richImage:e.jsx(yo,{}),richWikiLink:e.jsx(lr,{}),richHighlightBlock:e.jsx(ls,{}),richHeading:e.jsx(As,{}),richParagraph:e.jsx(As,{}),richCodeBlock:e.jsx(jo,{}),richTable:e.jsx(Cu,{}),richList:e.jsx(ir,{}),richOrderedList:e.jsx(ir,{}),richTaskList:e.jsx(sd,{}),richQuote:e.jsx(Su,{}),richDivider:e.jsx(Qr,{})},Oe=w=>w.label==="richHeading"?`${o(w.label)} ${"argument"in w?w.argument.slice(1):""}`:o(w.label),Ne=w=>w.action==="insertHTML",Ee={date:"@",zw:"",bt1:"#",bt2:"##",bt3:"###",lb:"-",bh:"1.",rw:"[]",yy:">",dmk:"```",glk:":::",bg:"3 × 3",fgx:"---",tp:"![]",sl:"[["},et={date:"wikiInsertDate",zw:"wikiInsertParagraph",bt1:"wikiInsertH1",bt2:"wikiInsertH2",bt3:"wikiInsertH3",lb:"wikiInsertList",bh:"wikiInsertOrdered",rw:"wikiInsertTask",yy:"wikiInsertQuote",dmk:"wikiInsertCode",glk:"wikiInsertCallout",bg:"wikiInsertTable",fgx:"wikiInsertDivider",tp:"wikiInsertImage",sl:"wikiInsertLink"},Ce=De.filter(w=>a||!["image","wikiLink"].includes(w.action)).filter(w=>`${Oe(w)} ${w.keywords}`.toLowerCase().includes((Fe==null?void 0:Fe.query.toLowerCase())??"")).sort((w,H)=>a?J.indexOf(w.alias)-J.indexOf(H.alias):Number(Ne(w))-Number(Ne(H))),be=()=>{var H;const w=window.getSelection();w!=null&&w.rangeCount&&((H=y.current)!=null&&H.contains(w.anchorNode))&&(p.current=w.getRangeAt(0).cloneRange())},ze=()=>{if(!y.current||s)return!1;y.current.focus({preventScroll:!0});const w=p.current&&y.current.contains(p.current.startContainer)?p.current:document.createRange();(!p.current||!y.current.contains(w.startContainer))&&(w.selectNodeContents(y.current),w.collapse(!1));const H=window.getSelection();return H==null||H.removeAllRanges(),H==null||H.addRange(w),!0},tt=(w,H,X,me)=>{var We,He,ct,ft,Mt,Dt,$t,Ft,Yt,Ut;if(!ze())return;const $e=(We=window.getSelection())==null?void 0:We.anchorNode,Pe=(He=$e instanceof Element?$e:$e==null?void 0:$e.parentElement)==null?void 0:He.closest("p,h1,h2,h3,h4,h5,h6"),st=Pe==null?void 0:Pe.parentElement,lt=!((ct=Pe==null?void 0:Pe.textContent)!=null&&ct.trim());let g;if(w==="bg"&&!H||w==="dmk"&&X===void 0){const it=me??((ft=p.current)==null?void 0:ft.getBoundingClientRect());l({kind:w==="bg"?"table":"code",x:(c==null?void 0:c.x)??(it==null?void 0:it.left)??16,y:(c==null?void 0:c.y)??((it==null?void 0:it.bottom)??80)+6});return}if(l(null),w==="bg"&&H)_("insertHTML",`<table><thead><tr>${Array.from({length:H.columns},(it,Rt)=>`<th ${Rt===0?"data-slash-insert":""}>${o("richColumn")} ${Rt+1}</th>`).join("")}</tr></thead><tbody>${Array.from({length:H.rows-1},()=>`<tr>${"<td><br></td>".repeat(H.columns)}</tr>`).join("")}</tbody></table><p><br></p>`);else if(w==="dmk")_("insertHTML",`<pre><code data-slash-insert class="language-${X||"plaintext"}">${X==="mermaid"?`flowchart LR
|
|
190
|
-
A --> B`:"<br>"}</code></pre><p><br></p>`);else{const it=De.find(Rt=>Rt.alias===w);if(!it)return;if(it.action==="image"){Re.current=((Mt=window.getSelection())==null?void 0:Mt.getRangeAt(0).cloneRange())??null,(Dt=O.current)==null||Dt.click();return}if(it.action==="wikiLink"){_("insertText","[[");const Rt=($t=window.getSelection())==null?void 0:$t.getRangeAt(0).cloneRange();Rt&&Rt.startOffset>=2&&Rt.setStart(Rt.startContainer,Rt.startOffset-2),ke.current=Rt??null,q("[[");return}it.action==="formatBlock"&&(g=it.argument),_(it.action,"argument"in it?it.argument:void 0)}const ne=((Ft=y.current)==null?void 0:Ft.querySelector("[data-slash-insert]"))??(lt&&g?st==null?void 0:st.querySelector(g):null);if(ne){ne.removeAttribute("data-slash-insert");const it=document.createRange();it.selectNodeContents(ne),it.collapse(!0),(Yt=window.getSelection())==null||Yt.removeAllRanges(),(Ut=window.getSelection())==null||Ut.addRange(it),xe()}be()},Ye=(w=!0)=>{var We,He,ct,ft;if(s)return W();const H=window.getSelection();if(!(H!=null&&H.isCollapsed)||!H.anchorNode||!((We=y.current)!=null&&We.contains(H.anchorNode)))return W();const X=H.anchorNode;if(X.nodeType!==Node.TEXT_NODE||(He=X.parentElement)!=null&&He.closest("pre, code, a, li, [contenteditable=false]"))return W();const me=((ct=X.textContent)==null?void 0:ct.slice(0,H.anchorOffset))??"",$e=(a?/\/([\p{L}\p{N}]{0,32})$/u:/\/([^\s/]{0,32})$/).exec(me);if(!$e)return W();const Pe=H.getRangeAt(0).cloneRange();Pe.setStart(X,H.anchorOffset-$e[1].length-1);const st=(ft=X.parentElement)==null?void 0:ft.closest("p, h1, h2, h3, h4, h5, h6, li, td, th, div");if(!st||!y.current.contains(st))return W();const lt=document.createRange();lt.selectNodeContents(st),lt.setEnd(Pe.startContainer,Pe.startOffset);const g=lt.cloneContents();if((a?g.textContent&&!/\s$/.test(g.textContent):g.textContent)||g.querySelector("br, img, input, hr, video, audio"))return W();Z.current=Pe;const ne=Pe.getBoundingClientRect();U({query:$e[1],x:Math.max(8,Math.min(ne.left,window.innerWidth-(a?308:328))),y:ne.bottom+6}),w&&ce(0)};d.useEffect(()=>{if(!Fe)return;const w=H=>{var me;if(H.target instanceof Element&&H.target.closest(".fp-slash-menu"))return;const X=(me=Z.current)==null?void 0:me.getBoundingClientRect();a&&X&&X.bottom>=0&&X.top<=window.innerHeight?Ye(!1):W()};return window.addEventListener("scroll",w,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",W)}},[!!Fe]),d.useLayoutEffect(()=>{if(!Fe||!_e.current||!Z.current)return;const w=Z.current.getBoundingClientRect(),H=_e.current.offsetHeight;_e.current.style.top=`${Math.max(8,w.bottom+6+H<=window.innerHeight-8?w.bottom+6:w.top-H-6)}px`},[Fe]),d.useLayoutEffect(()=>{const w=document.getElementById(`fp-slash-option-${fe}`),H=a?w==null?void 0:w.parentElement:w==null?void 0:w.closest(".fp-slash-menu");w&&H&&(w.offsetTop<H.scrollTop?H.scrollTop=w.offsetTop:w.offsetTop+w.offsetHeight>H.scrollTop+H.clientHeight&&(H.scrollTop=w.offsetTop+w.offsetHeight-H.clientHeight))},[fe,Fe==null?void 0:Fe.query]);const Le=w=>{var lt,g,ne,We;const H=Z.current,X=Ce[w];if(s||!X||!H||!((lt=y.current)!=null&<.contains(H.startContainer)))return W();const me=(ne=(g=H.startContainer.parentElement)==null?void 0:g.closest("p, h1, h2, h3, h4, h5, h6, td, th"))==null?void 0:ne.parentElement;y.current.focus();const $e=window.getSelection();$e==null||$e.removeAllRanges(),$e==null||$e.addRange(H);const Pe=H.getBoundingClientRect();if(W(),document.execCommand("delete"),a){be(),tt(X.alias,void 0,void 0,Pe);return}if(X.action==="image"){Re.current=($e==null?void 0:$e.getRangeAt(0).cloneRange())??null,(We=O.current)==null||We.click(),xe();return}if(X.action==="wikiLink"){ke.current=($e==null?void 0:$e.getRangeAt(0).cloneRange())??null,q("[["),xe();return}a&&X.alias==="bg"?_("insertHTML",`<table><thead><tr>${[1,2,3].map(He=>`<th ${He===1?"data-slash-insert":""}>${o("richColumn")} ${He}</th>`).join("")}</tr></thead><tbody>${[1,2].map(()=>"<tr><td>…</td><td>…</td><td>…</td></tr>").join("")}</tbody></table><p><br></p>`):_(X.action,"argument"in X?X.argument:void 0);const st=y.current.querySelector("[data-slash-insert]")??(X.action==="formatBlock"?me==null?void 0:me.querySelector(X.argument):null);if(st){st.removeAttribute("data-slash-insert");const He=document.createRange();He.selectNodeContents(st),He.collapse(!0),$e==null||$e.removeAllRanges(),$e==null||$e.addRange(He),xe()}},Xe=w=>{const H=ye();if(!H||!y.current)return;const X=document.createTreeWalker(y.current,NodeFilter.SHOW_TEXT),me=[];let $e;for(;$e=X.nextNode();){if(!$e.textContent||!H.intersectsNode($e)||H.endContainer===$e&&H.endOffset===0||H.startContainer===$e&&H.startOffset===$e.textContent.length)continue;let Pe=$e.parentElement,st="";for(;Pe&&Pe!==y.current;){if(Pe.style.backgroundColor&&Pe.style.backgroundColor!=="transparent"){st=Pe.style.backgroundColor;break}Pe=Pe.parentElement}me.push(st)}_("hiliteColor",me.length&&me.every(Pe=>Pe===w.rgb||Pe===w.hex)?"transparent":w.hex)},vt=(w,H=!1)=>{var Pe;const X=ke.current;if(s||!X||!((Pe=y.current)!=null&&Pe.contains(X.startContainer)))return;if(!H&&!/^(https?:\/\/|mailto:|#|\.?\.?\/)/i.test(w)){$(o("wikiInvalidLink"));return}const me=document.createElement("a");me.setAttribute("href",H?`#wiki=${encodeURIComponent(w)}`:w),me.textContent=X.toString()&&X.toString()!=="[["?X.toString():w,y.current.focus();const $e=window.getSelection();$e==null||$e.removeAllRanges(),$e==null||$e.addRange(X),_("insertHTML",me.outerHTML),q(null)},se=()=>{var g,ne,We;if(!a||s)return!1;const w=window.getSelection(),H=w==null?void 0:w.anchorNode;if(!(w!=null&&w.isCollapsed)||!H||!((g=y.current)!=null&&g.contains(H))||(ne=H.parentElement)!=null&&ne.closest("pre, code, a, [contenteditable=false]"))return!1;const X=(We=H.parentElement)==null?void 0:We.closest("p, div");if(!X||X===y.current)return!1;const me=w.getRangeAt(0).cloneRange();me.setStart(X,0);const $e=me.toString(),Pe=/^(#{1,6})$/.exec($e),st=Se.find(He=>He.alias==={"-":"lb","*":"lb","1.":"bh","[]":"rw","[ ]":"rw",">":"yy","```":"dmk","---":"fgx",":::":"glk"}[$e]);if(!Pe&&!st)return!1;if(w.removeAllRanges(),w.addRange(me),document.execCommand("delete"),Pe){const He=X.parentElement,ct=`h${Pe[1].length}`;_("formatBlock",ct);const ft=He==null?void 0:He.querySelector(ct);ft&&!ft.textContent&&(me.selectNodeContents(ft),me.collapse(!0),w.removeAllRanges(),w.addRange(me))}else st&&_(st.action,"argument"in st?st.argument:void 0);const lt=y.current.querySelector("[data-slash-insert]");return lt&&(lt.removeAttribute("data-slash-insert"),me.selectNodeContents(lt),me.collapse(!0),w.removeAllRanges(),w.addRange(me)),W(),xe(),!0},Ue=[{label:o("richUndo"),icon:e.jsx(qc,{}),action:"undo"},{label:o("richRedo"),icon:e.jsx(Wc,{}),action:"redo"},{label:o("richParagraph"),icon:e.jsx(As,{}),action:"formatBlock",argument:"p",separator:!0},{label:`${o("richHeading")} 1`,icon:e.jsx("span",{children:"H₁"}),action:"formatBlock",argument:"h1"},{label:`${o("richHeading")} 2`,icon:e.jsx("span",{children:"H₂"}),action:"formatBlock",argument:"h2"},{label:o("richBold"),icon:e.jsx(oa,{}),action:"bold",separator:!0},{label:o("richItalic"),icon:e.jsx(na,{}),action:"italic"},{label:o("richList"),icon:e.jsx(ir,{}),action:"insertUnorderedList",separator:!0},{label:o("richOrderedList"),icon:e.jsx("span",{children:"1."}),action:"insertOrderedList"}];return e.jsxs("div",{className:"fp-rich-editor",onScrollCapture:w=>{w.target.closest(".fp-slash-menu")||Fe&&Ye(!1)},children:[(a==null?void 0:a.toolbarHost)&&mn.createPortal(e.jsx(Iu,{readOnly:s,focused:!!a.focused,onWidth:a.onWidth??(()=>{}),items:De.map(w=>({id:w.alias,label:Oe(w),hint:Ee[w.alias]??"",help:o(et[w.alias]),icon:G[w.label]})),popup:c,onPrepare:be,onSelect:w=>tt(w),onPopup:l}),a.toolbarHost),u.map(({host:w,code:H},X)=>mn.createPortal(e.jsx(Xo,{code:H}),w,String(X))),c&&!s&&e.jsx(Ru,{popup:c,onClose:()=>{l(null),ze()},children:c.kind==="table"?e.jsx(Lu,{onInsert:(w,H)=>tt("bg",{columns:w,rows:H})}):e.jsx(Mu,{onInsert:w=>tt("dmk",void 0,w)})}),!a&&e.jsxs("div",{className:"fp-rich-toolbar",role:"toolbar","aria-label":o("richFormatToolbar"),children:[Ue.map(w=>e.jsxs(d.Fragment,{children:[w.separator&&e.jsx("span",{className:"fp-rich-toolbar-separator","aria-hidden":"true"}),e.jsx("button",{type:"button",title:w.label,"aria-label":w.label,disabled:s,onMouseDown:H=>H.preventDefault(),onClick:()=>_(w.action,w.argument),children:w.icon})]},w.label)),e.jsx("span",{className:"fp-rich-toolbar-separator","aria-hidden":"true"}),e.jsx("span",{className:"fp-highlight-label",children:o("richTextHighlight")}),ni.map(w=>e.jsx("button",{type:"button",className:`fp-highlight-swatch fp-highlight-${w.name}`,title:o(`richHighlight_${w.name}`),"aria-label":o(`richHighlight_${w.name}`),disabled:s||!V,onMouseDown:H=>H.preventDefault(),onClick:()=>{ye()&&_("hiliteColor",w.hex)},children:e.jsx("span",{})},w.name)),e.jsx("button",{type:"button",title:o("richHighlightClear"),"aria-label":o("richHighlightClear"),disabled:s||!V,onMouseDown:w=>w.preventDefault(),onClick:()=>{ye()&&_("hiliteColor","transparent")},children:e.jsx(Qr,{})})]}),(ae==null?void 0:ae.isConnected)&&!s&&e.jsxs("div",{className:"fp-table-tools",role:"toolbar","aria-label":o("richTableTools"),children:[e.jsx("button",{type:"button",onMouseDown:w=>w.preventDefault(),onClick:()=>re("row"),children:o("richAddRow")}),e.jsx("button",{type:"button",onMouseDown:w=>w.preventDefault(),onClick:()=>re("column"),children:o("richAddColumn")}),e.jsx("button",{type:"button",disabled:ae.parentElement.rowIndex===0||ae.closest("table").rows.length<=2,onMouseDown:w=>w.preventDefault(),onClick:()=>re("removeRow"),children:o("richRemoveRow")}),e.jsx("button",{type:"button",disabled:ae.parentElement.cells.length<=1,onMouseDown:w=>w.preventDefault(),onClick:()=>re("removeColumn"),children:o("richRemoveColumn")})]}),j&&e.jsx("div",{className:"fp-notice",role:"status",children:o("richImageUploading")}),E&&e.jsx("div",{className:"fp-notice",role:"alert",children:E}),a&&B&&Q===null&&mn.createPortal(e.jsxs("div",{ref:M,className:"wiki-format-popover",role:"toolbar","aria-label":o("richFormatToolbar"),style:{left:B.x,top:B.y},onMouseDown:w=>w.preventDefault(),children:[[{label:o("richBold"),action:"bold",icon:e.jsx(oa,{})},{label:o("richItalic"),action:"italic",icon:e.jsx(na,{})},{label:`${o("richHeading")} 2`,action:"formatBlock",argument:"h2",icon:e.jsx(As,{})},{label:`${o("richHeading")} 3`,action:"formatBlock",argument:"h3",icon:e.jsx(As,{})}].map(w=>e.jsx("button",{"aria-label":w.label,title:w.label,disabled:s,onClick:()=>_(w.action,w.argument),children:w.icon},w.label)),e.jsx("button",{"aria-label":o("wikiAddLink"),title:o("wikiAddLink"),disabled:s,onClick:()=>{var w;ke.current=((w=ye())==null?void 0:w.cloneRange())??null,q("")},children:e.jsx(lr,{})}),e.jsx("i",{}),ni.slice(0,2).map(w=>e.jsx("button",{className:`fp-highlight-swatch fp-highlight-${w.name}`,"aria-label":o(`richHighlight_${w.name}`),title:o(`richHighlight_${w.name}`),disabled:s,onClick:()=>Xe(w),children:e.jsx("span",{})},w.name)),e.jsx("i",{}),e.jsx("button",{className:"wiki-ask-selection",onClick:()=>{var w;a.ask(((w=window.getSelection())==null?void 0:w.toString())??""),ie(null)},children:o("wikiAskPi")})]}),document.body),e.jsx("input",{ref:O,type:"file",accept:"image/*",hidden:!0,onChange:w=>{var me,$e;const H=(me=w.target.files)==null?void 0:me[0],X=Re.current;if(H&&X&&(($e=y.current)!=null&&$e.contains(X.startContainer))){y.current.focus();const Pe=window.getSelection();Pe==null||Pe.removeAllRanges(),Pe==null||Pe.addRange(X),we(H)}w.target.value=""}}),Q!==null&&e.jsxs(Ni,{title:o("wikiAddLink"),onClose:()=>q(null),children:[e.jsxs("form",{className:"wiki-link-form",onSubmit:w=>{w.preventDefault(),vt(Q)},children:[e.jsx("input",{"aria-label":o("wikiLinkAddress"),placeholder:o("wikiLinkAddress"),value:Q,onChange:w=>q(w.target.value)}),e.jsx("button",{type:"submit",disabled:!Q.trim()||Q.startsWith("[["),children:o("wikiInsertLinkAction")})]}),Q.startsWith("[[")&&e.jsx("div",{className:"wiki-link-results",children:a==null?void 0:a.paths.filter(w=>/\.(md|markdown|mdown)$/i.test(w)&&w.toLowerCase().includes(Q.slice(2).toLowerCase())).slice(0,30).map(w=>e.jsx("button",{onClick:()=>vt(w,!0),children:w},w))})]}),Fe&&!s&&mn.createPortal(e.jsxs("div",{ref:_e,className:`fp-slash-menu ${a?"wiki-slash-menu":""}`,style:{left:Fe.x,top:Fe.y},children:[e.jsx("div",{className:"fp-slash-options",role:"listbox","aria-label":o("richInsertMenu"),children:Ce.length?Ce.map((w,H)=>e.jsxs(d.Fragment,{children:[!a&&(H===0||Ne(w)!==Ne(Ce[H-1]))&&e.jsx("div",{className:"fp-slash-group",role:"presentation",children:o(Ne(w)?"richBlocksGroup":"richTextGroup")}),e.jsxs("button",{type:"button",role:"option","aria-label":Oe(w),"aria-selected":H===fe,id:`fp-slash-option-${H}`,onMouseDown:X=>X.preventDefault(),onMouseEnter:()=>ce(H),onClick:()=>Le(H),children:[e.jsx("span",{className:"fp-slash-icon","aria-hidden":"true",children:G[w.label]}),e.jsxs("span",{className:"fp-slash-label",children:[Oe(w),a&&e.jsx("small",{children:o(et[w.alias])})]}),e.jsx("kbd",{"aria-hidden":"true",children:a?Ee[w.alias]:`/${w.alias}`})]})]},w.alias)):e.jsx("span",{className:"wiki-slash-empty",children:o(a?"wikiNoInsertResults":"richNoElements")})}),a&&e.jsx("footer",{children:o("wikiInsertKeys")})]}),document.body),e.jsx("div",{className:"fp-markdown msg-text",children:e.jsx("div",{className:"fp-markdown-zoom",children:e.jsx("div",{ref:y,className:"md fp-rich-document",role:"textbox","aria-label":o("richEditMarkdown"),"aria-multiline":"true",contentEditable:!s,suppressContentEditableWarning:!0,spellCheck:!1,"aria-expanded":!!Fe,"aria-autocomplete":"list","aria-activedescendant":Fe&&Ce.length?`fp-slash-option-${fe}`:void 0,onBlur:W,onCompositionStart:W,onCompositionEnd:()=>{const w=F();w&&b(w),xe(),Ye()},onKeyUp:()=>z(Ie()),onKeyDown:w=>{if(w.key===" "&&!w.nativeEvent.isComposing&&se()){w.preventDefault();return}if(w.key==="Enter"&&!s&&!w.nativeEvent.isComposing&&F()){w.preventDefault(),_("insertLineBreak");return}if(w.key==="Tab"&&!s&&!w.nativeEvent.isComposing){const H=Ie();if(H){const X=Array.from(H.closest("table").querySelectorAll("th, td")),me=X.indexOf(H);if(!w.shiftKey||me>0){w.preventDefault(),!w.shiftKey&&me===X.length-1?re("row",H):Ae(X[me+(w.shiftKey?-1:1)]);return}}}!Fe||w.nativeEvent.isComposing||(w.key==="Escape"?(w.preventDefault(),w.stopPropagation(),W()):w.key==="ArrowDown"||w.key==="ArrowUp"?(w.preventDefault(),ce(H=>Ce.length?(H+(w.key==="ArrowDown"?1:-1)+Ce.length)%Ce.length:0)):w.key==="Enter"&&Ce.length?(w.preventDefault(),Le(fe)):(w.key==="ArrowLeft"||w.key==="ArrowRight"||w.key==="Home"||w.key==="End")&&W())},onInput:w=>{var X,me;if(w.target instanceof HTMLSelectElement&&w.target.hasAttribute("data-code-language")){A(w.target);return}const H=w.target;if(H.type==="checkbox"&&H.toggleAttribute("checked",H.checked),xe(),!w.nativeEvent.isComposing){Ye();const $e=window.getSelection(),Pe=$e==null?void 0:$e.anchorNode;if(a&&($e!=null&&$e.isCollapsed)&&(Pe==null?void 0:Pe.nodeType)===Node.TEXT_NODE&&!((X=Pe.parentElement)!=null&&X.closest("pre, code, a"))&&((me=Pe.textContent)!=null&&me.slice(0,$e.anchorOffset).endsWith("[["))){const st=$e.getRangeAt(0).cloneRange();st.setStart(Pe,$e.anchorOffset-2),ke.current=st,q("[[")}}},onClick:w=>{z(Ie()),W();const H=w.target.closest("a");if(H){w.preventDefault();const X=H.getAttribute("href");a&&X&&(/^(https?:|mailto:)/i.test(X)?window.open(X,"_blank","noopener,noreferrer"):a.followLink(X))}},onChange:w=>{const H=w.target;H.type==="checkbox"&&(H.toggleAttribute("checked",H.checked),xe())},onPaste:w=>{w.preventDefault();const H=Array.from(w.clipboardData.files).find(X=>X.type.startsWith("image/"));if(H){we(H);return}s||_("insertText",w.clipboardData.getData("text/plain"))},onDrop:w=>{w.preventDefault(),w.stopPropagation()}})})})]})}),kl=d.memo(function({value:n,name:s,readOnly:r,wrap:i,markers:a,onChange:o,onSelectLines:c}){const l=nt(),p=d.useRef(null),[u,f]=d.useState(0),k=d.useMemo(()=>rl(n,Ps(s)),[n,s]);return e.jsxs("div",{className:`fp-code-editor ${i?"":"no-wrap"}`,children:[e.jsx("div",{className:"fp-code-paint",ref:p,"aria-hidden":"true",children:e.jsx("div",{className:"fp-code-ink hljs",children:k.map((j,I)=>e.jsxs("div",{className:`fp-edit-line ${I+1===u?"current":""}`,"data-line":I+1,children:[e.jsx("span",{className:`fp-edit-marker ${(a==null?void 0:a.get(I+1))??""}`}),e.jsx("span",{className:"fp-edit-number",children:I+1}),e.jsx("span",{className:"fp-edit-text",dangerouslySetInnerHTML:{__html:j||""}})]},I))})}),e.jsx("textarea",{className:"fp-editor","aria-label":l("editFile"),value:n,readOnly:r,onChange:j=>o(j.target.value),onClick:j=>f(n.slice(0,j.currentTarget.selectionStart).split(`
|
|
191
|
-
`).length),onKeyUp:j=>f(n.slice(0,j.currentTarget.selectionStart).split(`
|
|
192
|
-
`).length),onSelect:j=>{const I=j.currentTarget;if(I.selectionStart===I.selectionEnd)return;const E=n.slice(0,I.selectionStart).split(`
|
|
193
|
-
`).length,$=n.slice(0,Math.max(I.selectionStart,I.selectionEnd-1)).split(`
|
|
194
|
-
`).length;c==null||c(E,$)},onScroll:j=>{p.current&&(p.current.scrollTop=j.currentTarget.scrollTop,p.current.scrollLeft=j.currentTarget.scrollLeft)},onKeyDown:j=>{j.key!=="Tab"||r||j.nativeEvent.isComposing||(j.preventDefault(),document.execCommand("insertText",!1," "))},wrap:i?"soft":"off",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})});function Cp(t,n,s,r,i,a){const o=d.useRef({doc:n,draft:s,blocked:r,accept:i,refreshed:a});o.current={doc:n,draft:s,blocked:r,accept:i,refreshed:a};const c=d.useRef(!0),l=d.useRef(null),[p,u]=d.useState(!1),[f,k]=d.useState(""),[j,I]=d.useState(!1),E=d.useRef(!1);d.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]),d.useEffect(()=>{k(""),I(!1),E.current=!1},[n==null?void 0:n.entry.path]);const $=d.useCallback(()=>{if(l.current)return l.current;const L=o.current.doc;if(!(L!=null&&L.editable)||L.text===void 0||L.text===o.current.draft)return Promise.resolve(!0);if(E.current||o.current.blocked)return Promise.resolve(!1);u(!0),k("");const b=async()=>{var B,ie,Q;let F=L;try{for(;c.current&&((B=o.current.doc)==null?void 0:B.entry.path)===L.entry.path;){const q=o.current.draft;if(q===F.text)return!0;if(o.current.blocked)return!1;const ke=await Pn(t,"write",{path:L.entry.path,text:q,version:F.version});if(!c.current||((ie=o.current.doc)==null?void 0:ie.entry.path)!==L.entry.path)return!1;F={...ke,backlinks:o.current.doc.backlinks},o.current.doc=F,o.current.accept(F),o.current.refreshed()}return!1}catch(q){return c.current&&((Q=o.current.doc)==null?void 0:Q.entry.path)===L.entry.path&&(k(q.message),q instanceof Oo&&q.detail.code==="version_conflict"&&(E.current=!0,I(!0))),!1}};return l.current=b().finally(()=>{l.current=null,c.current&&u(!1)}),l.current},[t]);d.useEffect(()=>{(n==null?void 0:n.text)===s&&(k(""),I(!1),E.current=!1)},[n==null?void 0:n.version,s]);const N=!!(n!=null&&n.editable)&&n.text!==void 0&&n.text!==s;d.useEffect(()=>{if(!N||r||j||f)return;const L=setTimeout(()=>void $(),800);return()=>clearTimeout(L)},[s,N,r,j,f,$]);const R=async()=>{var b;const L=o.current.doc;if(!L||o.current.blocked)return!1;try{const F=await Pn(t,"document-content",{path:L.entry.path});if(!c.current||((b=o.current.doc)==null?void 0:b.entry.path)!==L.entry.path||o.current.doc.version!==L.version)return!1;const B={...F,backlinks:L.backlinks};return o.current.doc=B,o.current.accept(B),E.current=!1,I(!1),k(""),await $()}catch(F){return c.current&&k(F.message),!1}},y=d.useCallback(()=>{E.current=!0,I(!0),k("File changed on disk; reload before saving")},[]);return{save:$,saving:p,failure:f,conflict:j,keepMine:R,noteExternalChange:y}}const Sp={entries:[],tags:[],revisions:[],running:!1,limited:!1};function Np({cwd:t,conversationId:n,messages:s,streaming:r,live:i,model:a,contextPercent:o,toolStatuses:c,active:l,ready:p,send:u,guard:f,fileRequest:k,openDocument:j,thinkingWrap:I,connected:E,silenceNotified:$,sessionError:N,writingBlocked:R,onContentRequested:y,recovery:L}){const b=nt(),{locale:F}=Qn(),[B,ie]=d.useState(Sp),[Q,q]=d.useState({}),[ke,Re]=d.useState({}),[O,_e]=d.useState(()=>(k==null?void 0:k.path)??localStorage.getItem(`pi-wiki-file:${t}`)??""),[M,V]=d.useState(!1),[ve,ye]=d.useState(100),[oe,Fe]=d.useState(null),[U,fe]=d.useState(""),[ce,ae]=d.useState(!1),[z,Z]=d.useState(!1),[W,ge]=d.useState(!1),[Ie,Ae]=d.useState(""),[re,we]=d.useState(null),[A,xe]=d.useState(()=>new Set),[_,Se]=d.useState(()=>localStorage.getItem(`pi-wiki-hidden:${t}`)==="true"),[J,De]=d.useState(!0),[G,Oe]=d.useState(!1),[Ne,Ee]=d.useState(null);d.useEffect(()=>Oe(!1),[O]);const et=T=>{De(T),tt(!1),T&&($e(null),Oe(!1))},[Ce,be]=d.useState(!1),[ze,tt]=d.useState(!1),[Ye,Le]=d.useState(null),Xe=d.useRef(null),vt=d.useRef(null),[se,Ue]=d.useState(0),w=()=>{be(!0)};d.useEffect(()=>{var T;(Ce||J)&&((T=Et.current)==null||T.focus())},[Ce,J]),d.useEffect(()=>{const T=vt.current;if(!T)return;const pe=new ResizeObserver(()=>Ue(T.getBoundingClientRect().height));return pe.observe(T),()=>pe.disconnect()},[J]);const[H,X]=d.useState(!1),[me,$e]=d.useState(null),[Pe,st]=d.useState(!1),[lt,g]=d.useState(""),[ne,We]=d.useState([]),[He,ct]=d.useState(!1),[ft,Mt]=d.useState(!1),[Dt,$t]=d.useState(0),[Ft,Yt]=d.useState(0),[Ut,it]=d.useState(""),[Rt,zt]=d.useState([]),[Ot,Vt]=d.useState("");Ao(n,l&&p,it);const[jt,Xt]=d.useState(null),[K,ee]=d.useState(!1),[Ke,Be]=d.useState(!1),[te,Je]=d.useState(!1),[qe,yt]=d.useState(!1),[Kt,an]=d.useState(()=>{try{return JSON.parse(localStorage.getItem(`pi-wiki-viewed:${t}`)??"{}")}catch{return{}}}),[Zt,Ct]=d.useState(Date.now()),[cn,ht]=d.useState(null),Et=d.useRef(null),Ht=d.useRef(null),Bt=d.useRef(k);Bt.current=k;const St=d.useRef(!0),en=d.useRef(0),yn=d.useRef(0),xn=d.useRef(0),Un=d.useRef(B.entries),Wn=d.useRef(B.revisions),On=d.useRef(void 0);Wn.current=B.revisions;const wn=d.useRef(oe),rn=!!(oe!=null&&oe.editable)&&oe.text!==void 0&&U!==oe.text;wn.current=oe;const bn=te||W||z||B.running||R||!!oe&&oe.entry.path!==O,vn=bn||!p,[h,v]=d.useState(null),S=new Set(B.revisions.filter(T=>T.author==="pi").flatMap(T=>T.changes.filter(pe=>!pe.undone&&(Kt[pe.path]??0)<T.at).map(pe=>pe.path))),P=d.useMemo(()=>{const T=new Map(B.entries.map(pe=>[pe.path,pe]));for(const pe of Object.values(Q)){const Qe=!B.entries.length||B.limited||B.entries.some(rt=>rt.symlink&&pe.path.startsWith(rt.path));for(const rt of pe.entries)!T.has(rt.path)&&Qe&&T.set(rt.path,rt)}return[...T.values()].sort((pe,Qe)=>{const rt=pe.path.split("/"),at=Qe.path.split("/");for(let Tt=0;Tt<Math.min(rt.length,at.length);Tt++){if(rt[Tt]===at[Tt])continue;const sn=Tt<rt.length-1||pe.kind==="directory",Cn=Tt<at.length-1||Qe.kind==="directory";return Number(Cn)-Number(sn)||rt[Tt].localeCompare(at[Tt])}return rt.length-at.length})},[B.entries,B.limited,Q]),de=d.useMemo(()=>P.filter(T=>T.kind!=="directory").map(T=>T.path),[P]),le=d.useMemo(()=>new Set(P.filter(T=>T.kind==="directory"&&!T.path.includes("/")&&T.name.startsWith(".")).map(T=>T.path)),[P]),je=d.useMemo(()=>P.filter(T=>(_||!le.has(T.path.split("/")[0]))&&T.path.split("/").slice(0,-1).every((pe,Qe,rt)=>A.has(rt.slice(0,Qe+1).join("/")))),[P,A,_,le]),[Ge,dt]=d.useState(0),ut=Math.max(0,Math.floor(Ge/30)-10),gt=ut+70,It=/(?:^|\s)(@)([^\s]*)$/.exec(Ut),Gt=It?de.filter(T=>T.toLocaleLowerCase().includes(It[2].toLocaleLowerCase())).slice(0,8):[],dn=T=>{var pe;It&&(zt(Qe=>[...new Set([...Qe,T])]),it(Ut.slice(0,It.index).trimEnd()+" "),Yt(0),(pe=Et.current)==null||pe.focus())},on=d.useMemo(()=>(oe==null?void 0:oe.entry.kind)==="document"&&oe.text!==void 0?[b("wikiQuickSummary"),b("wikiQuickLinks"),...su(U)?[b("wikiQuickSections")]:[]]:[],[oe==null?void 0:oe.entry.kind,oe==null?void 0:oe.text,U,b]),Nn=Ca(Ut,O,Ot,Rt,"",P,K,Ke,{scope:b("wikiScope"),selection:b("wikiSelected"),documentsOnly:b("wikiDocumentsOnlyPrompt"),skip:b("wikiSkipPrompt")});d.useEffect(()=>(St.current=!0,()=>{St.current=!1,en.current++,yn.current++}),[]),d.useEffect(()=>{ht(document.getElementById("wiki-toolbar-slot")),Le(document.getElementById("wiki-status-slot"))},[l]);const un=d.useCallback(async(T,pe=0)=>{try{const Qe=await Pn(t,"directory",{path:T,offset:pe});St.current&&q(rt=>{var at;return{...rt,[T]:{...Qe,entries:pe?[...((at=rt[T])==null?void 0:at.entries)??[],...Qe.entries]:Qe.entries}}})}catch(Qe){St.current&&Ae(Qe.message)}},[t]);d.useEffect(()=>{var T;k&&(((T=wn.current)==null?void 0:T.entry.path)===k.path&&y(k.token),Oe(!1),De(!0),$e(null),_e(k.path),ae(!1),st(!1),X(!1),Vt(""),Xt(null))},[k,y,oe==null?void 0:oe.entry.path]),d.useEffect(()=>{l&&un("")},[l,un]),d.useEffect(()=>{l&&O&&!k&&j(O)},[l,O,k,j]);const kn=d.useCallback(async(T=!1)=>{const pe=++yn.current;try{const Qe=await Pn(t,T?"refresh":"state");St.current&&pe===yn.current&&ie(Qe)}catch(Qe){St.current&&pe===yn.current&&Ae(Qe.message)}},[t]),tn=Cp(t,oe,U,z||W||B.running||R||(oe==null?void 0:oe.entry.path)!==O,Fe,()=>void kn(!0)),{save:ln,saving:Jt}=tn;d.useEffect(()=>Md(async()=>{const T=await ln();return T||et(!1),T}),[ln]),d.useEffect(()=>{if(!l)return;kn();const T=setInterval(()=>{Ct(Date.now()),kn()},r||B.running?1e3:3e4);return()=>clearInterval(T)},[l,r,B.running,kn]),d.useEffect(()=>{O&&xe(T=>{const pe=new Set(T),Qe=O.split("/");for(let rt=1;rt<Qe.length;rt++)pe.add(Qe.slice(0,rt).join("/"));return pe})},[O]),d.useEffect(()=>{if(O||!B.entries.length)return;const T=B.entries.find(pe=>/^(readme|index)\.md$/i.test(pe.path))??B.entries.find(pe=>pe.kind==="document");T&&_e(T.path)},[B.entries,O]);const An=d.useCallback(async(T,pe)=>{const Qe=++xn.current;try{const rt=await Pn(t,"document-references",{path:T});if(!St.current||pe!==en.current||Qe!==xn.current)return;Fe(at=>(at==null?void 0:at.entry.path)===T?{...at,...rt}:at),V(!0)}catch(rt){St.current&&pe===en.current&&Qe===xn.current&&Ae(rt.message)}},[t]),En=d.useCallback(async(T,pe=!1)=>{var rt;const Qe=++en.current;Z(!0),V(!1),ye(100),Ae("");try{const at=Pn(t,"document-content",{path:T}),Tt=Bt.current;(Tt==null?void 0:Tt.path)===T&&y(Tt.token);const sn=await at;if(!St.current||Qe!==en.current)return;On.current=(rt=Wn.current.find(Cn=>Cn.author==="pi"&&Cn.changes.some(hn=>hn.path===T)))==null?void 0:rt.id,Fe({...sn,backlinks:[]}),fe(sn.text??""),Vt(""),Xt(null),An(T,Qe),localStorage.setItem(`pi-wiki-file:${t}`,T),pe&&an(Cn=>{const hn={...Cn,[T]:Date.now()};return localStorage.setItem(`pi-wiki-viewed:${t}`,JSON.stringify(hn)),hn})}catch(at){St.current&&Qe===en.current&&(Fe(null),Ae(at.message))}finally{St.current&&Qe===en.current&&Z(!1)}},[t,y,An]);d.useEffect(()=>{var T;return O&&l&&((T=wn.current)==null?void 0:T.entry.path)!==O&&En(O,!0),()=>{en.current++}},[O,l,En]),d.useEffect(()=>{var T;l&&((T=wn.current)==null?void 0:T.entry.path)===O&&B.entries.length&&An(O,en.current)},[B.entries,l,O,An]),d.useEffect(()=>{if(!oe||rn||Jt||z||r||B.running||!l||Un.current===B.entries)return;Un.current=B.entries;const T=B.entries.find(at=>at.path===O),pe=B.revisions.find(at=>at.author==="pi"&&at.changes.some(Tt=>Tt.path===O));if(!T||T.modified===oe.entry.modified){On.current=pe==null?void 0:pe.id;return}if(!oe.editable||(pe==null?void 0:pe.id)!==On.current){En(O);return}const Qe=oe,rt=en.current;Pn(t,"document-content",{path:O}).then(at=>{var Tt;!St.current||rt!==en.current||((Tt=wn.current)==null?void 0:Tt.version)!==Qe.version||(at.version!==Qe.version?tn.noteExternalChange():Fe(sn=>sn&&{...sn,entry:at.entry}))}).catch(at=>{St.current&&rt===en.current&&Ae(at.message)})},[B.entries,oe,rn,Jt,z,l,O,En,t,B.revisions,B.running,r,tn.noteExternalChange]);const ds=d.useRef(0),qn=d.useCallback(T=>{const pe=++ds.current;rn||Jt?ln().then(Qe=>{!St.current||pe!==ds.current||(Qe?T():we(()=>T))}):T()},[rn,Jt,ln]);d.useEffect(()=>(f.current=rn||Jt?qn:null,()=>{f.current=null}),[f,qn,rn,Jt]),d.useEffect(()=>{const T=pe=>{rn&&(ln(),pe.preventDefault(),pe.returnValue="")};return window.addEventListener("beforeunload",T),()=>window.removeEventListener("beforeunload",T)},[rn,ln]);const Dn=T=>qn(()=>{if(T!==O){j(T);return}et(!0),_e(T),ae(!1),st(!1),X(!1),Xt(null),xe(pe=>{const Qe=new Set(pe),rt=T.split("/");for(let at=1;at<rt.length;at++)Qe.add(rt.slice(0,at).join("/"));return Qe}),T===O&&En(T,!0)});d.useEffect(()=>{if(!l)return;const T=pe=>{var Qe;if(pe.key==="/"&&!pe.metaKey&&!pe.ctrlKey&&!pe.altKey&&!pe.isComposing&&!(pe.target instanceof HTMLElement&&pe.target.closest("input,textarea,select,[contenteditable=true],[role=dialog]"))&&(pe.preventDefault(),w()),pe.key==="Tab"&&(Pe||re)){const rt=[...document.querySelectorAll(".wiki-modal-backdrop [role=dialog]")].at(-1),at=[...(rt==null?void 0:rt.querySelectorAll("button:not(:disabled), input, textarea, select, [tabindex='0']"))??[]];at.length&&pe.shiftKey&&document.activeElement===at[0]?(pe.preventDefault(),(Qe=at.at(-1))==null||Qe.focus()):at.length&&!pe.shiftKey&&document.activeElement===at.at(-1)&&(pe.preventDefault(),at[0].focus())}(pe.metaKey||pe.ctrlKey)&&pe.key.toLowerCase()==="j"&&!pe.isComposing&&!Pe&&!re&&(pe.preventDefault(),et(!J)),(pe.metaKey||pe.ctrlKey)&&pe.key.toLowerCase()==="k"&&(pe.preventDefault(),st(rt=>!rt)),(pe.metaKey||pe.ctrlKey)&&pe.key.toLowerCase()==="s"&&(pe.preventDefault(),bn||ln()),pe.key==="Escape"&&(!Pe&&!re&&!me&&!jt&&!ze&&et(!1),be(!1),tt(!1),yt(!1),we(null),st(!1),Xt(null),$e(null),X(!1))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)}),d.useEffect(()=>{if(!Pe||!lt.trim()){We([]),ct(!1);return}const T=new AbortController;ct(!0),We([]),Mt(!1),$t(0);const pe=setTimeout(()=>{Pn(t,"search",{query:lt},T.signal).then(Qe=>{T.signal.aborted||(We(Qe.results.sort((rt,at)=>["document","code","pdf","image","other"].indexOf(rt.kind)-["document","code","pdf","image","other"].indexOf(at.kind))),Mt(Qe.limited))}).catch(Qe=>{T.signal.aborted||Ae(Qe.message)}).finally(()=>{T.signal.aborted||ct(!1)})},250);return()=>{clearTimeout(pe),T.abort()}},[t,lt,Pe]),d.useEffect(()=>{var T;Pe&&((T=document.querySelector(".wiki-search-results button.selected"))==null||T.scrollIntoView({block:"nearest"}))},[Pe,Dt]);const Yn=async(T,pe,Qe)=>{if(rn){Ae(b("wikiSaveFirst"));return}ge(!0),Ae("");try{const rt=await Pn(t,"restore",{id:T.id,undo:pe,path:Qe});St.current&&(ie(rt),O&&await En(O))}catch(rt){St.current&&Ae(rt.message)}finally{St.current&&ge(!1)}},pn=async T=>{if(!(!(T??Ut).trim()||vn||!O&&!K&&!Rt.length)){Je(!0),Ae("");try{if(rn&&!await ln())return;await Pn(t,"prompt",{text:T??Nn,requestId:Qt(),conversationId:n}),St.current&&(T||(it(""),Vt(""),zt([])),yt(!1),tt(!1),be(!1),et(!0),kn())}catch(pe){St.current&&Ae(pe.message)}finally{St.current&&Je(!1)}}},Xn=T=>{var pe;zt(Qe=>[...new Set([...Qe,T.path])]),st(!1),w(),(pe=Et.current)==null||pe.focus()},zn=()=>{var rt,at;const T=window.getSelection();if(!T||T.isCollapsed||!((rt=Ht.current)!=null&&rt.contains(T.anchorNode))||!((at=Ht.current)!=null&&at.contains(T.focusNode))){Xt(null);return}const pe=T.toString().trim().slice(0,12e3),Qe=T.getRangeAt(0).getBoundingClientRect();pe&&Xt({text:pe,x:Math.max(8,Math.min(Qe.left,window.innerWidth-300)),y:Math.min(Qe.bottom+8,window.innerHeight-50)})},At=T=>{var pe;jt&&(Vt(jt.text),Xt(null),et(!0),T!=="ask"&&it(b(T==="rewrite"?"wikiRewritePrompt":T==="explain"?"wikiExplainPrompt":"wikiLinkPrompt")),w(),(pe=Et.current)==null||pe.focus())},Vn=T=>{let pe=T;try{T.startsWith("#wiki=")&&(pe=decodeURIComponent(T.slice(6)))}catch{return}const Qe=ja(O,pe,de);Qe?Dn(Qe):Ae(b("wikiMissingLink",{path:pe}))},Kn=d.useMemo(()=>Bo(U).rows,[U]),Tn=d.useMemo(()=>Wo(U),[U]),jn=Tn.readingBody,$n=new Date((oe==null?void 0:oe.entry.modified)??0),Rn=new Date(Zt),us=$n.toDateString()===Rn.toDateString()?b("wikiUpdatedToday",{time:$n.toLocaleTimeString(F==="zh"?"zh-CN":"en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}):b("wikiUpdatedDate",{date:$n.toLocaleDateString(F==="zh"?"zh-CN":"en-US",{month:"long",day:"numeric",...$n.getFullYear()!==Rn.getFullYear()?{year:"numeric"}:{}})}),Zn=new Set(oe==null?void 0:oe.backlinks.map(T=>T.path)).size,rs=d.useMemo(()=>h&&h.path===O&&!h.undone?new Set((h.after??"").split(`
|
|
195
|
-
`).filter(T=>!(h.before??"").split(`
|
|
196
|
-
`).includes(T))):new Set,[h,O]),ps=async T=>{const pe=en.current,Qe=T.changes.find(rt=>rt.path===O)??T.changes[0];if(Qe)try{const rt=await Pn(t,"change",{id:T.id,path:Qe.path});if(!St.current||pe!==en.current)return;v(rt),Qe.path!==O?Dn(Qe.path):requestAnimationFrame(()=>{var at,Tt;return(Tt=(at=Ht.current)==null?void 0:at.querySelector(".wiki-added"))==null?void 0:Tt.scrollIntoView({block:"center",behavior:"smooth"})})}catch(rt){Ae(rt.message)}},hs=d.useMemo(()=>nu(jn),[jn]),Y=T=>{var Qe;const pe=[...((Qe=Ht.current)==null?void 0:Qe.querySelectorAll(".wiki-prose h2"))??[]];return pe[Sa(pe.map(rt=>rt.textContent??""),T)]},Te=T=>{const pe=Y(T);pe&&(window.matchMedia("(max-width: 1099px)").matches&&et(!1),pe.scrollIntoView({behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",block:"start"}),pe.animate([{backgroundColor:"transparent"},{backgroundColor:getComputedStyle(pe).getPropertyValue("--accent-soft").trim(),offset:.15},{backgroundColor:"transparent"}],{duration:1500}))},Ze=(Ie||N)&&e.jsxs("div",{className:"wiki-error",role:"alert",children:[e.jsx("span",{children:Ie||N}),N&&e.jsx("button",{onClick:()=>void j(O),children:b("wikiRetrySession")}),e.jsx("button",{onClick:()=>Ae(""),"aria-label":b("close"),children:e.jsx(qt,{})}),oe&&e.jsx("button",{onClick:()=>qn(()=>void En(O)),children:b("wikiReload")})]}),pt=e.jsxs("div",{ref:vt,className:`wiki-composer-area ${Ce||J?"expanded":"compact"}`,children:[!J&&!Ce&&e.jsxs("div",{className:"wiki-composer-pill",children:[e.jsxs("button",{className:"wiki-expand-composer",onClick:w,"aria-label":b("wikiExpandComposer"),children:[e.jsx("span",{className:"wiki-pill-file",children:O.split("/").at(-1)||b("wikiMode")}),e.jsx("span",{children:Ut.trim()||b("wikiCompactPlaceholder")}),e.jsx("kbd",{children:"/"})]}),r?e.jsx("button",{className:"wiki-pill-send stop","aria-label":b("wikiStop"),onClick:()=>u({type:"abort"}),children:e.jsx(ls,{})}):e.jsx("button",{className:"wiki-pill-send","aria-label":b("wikiSend"),disabled:!0,children:e.jsx(cr,{})})]}),e.jsxs("div",{className:`wiki-composer${Ut.trim()?" has-draft":""}`,hidden:!Ce&&!J,children:[(Ot||Rt.length>0)&&e.jsxs("div",{className:"wiki-context-chips",children:[Ot&&e.jsxs("button",{className:"wiki-quoted-selection",onClick:()=>Vt(""),title:b("wikiSelected"),children:[e.jsx("b",{children:b("wikiSelected")}),e.jsx("span",{children:Ot}),e.jsx(qt,{})]}),Rt.map(T=>e.jsxs("button",{onClick:()=>zt(pe=>pe.filter(Qe=>Qe!==T)),children:["@",T,e.jsx(qt,{})]},T))]}),Gt.length>0&&e.jsx("div",{className:"wiki-mentions",children:Gt.map(T=>e.jsxs("button",{className:Gt[Ft]===T?"selected":"",onClick:()=>dn(T),children:[It[1],T]},T))}),e.jsx("textarea",{ref:Et,"aria-label":b("wikiAsk"),placeholder:(oe==null?void 0:oe.entry.kind)==="code"?b("wikiAskCode",{file:oe.entry.name}):b("wikiAskPlaceholder"),value:Ut,onChange:T=>{it(T.target.value),Yt(0)},onKeyDown:T=>{if(Gt.length&&!T.nativeEvent.isComposing){if(T.key==="ArrowDown"||T.key==="ArrowUp"){T.preventDefault(),Yt(pe=>(pe+(T.key==="ArrowDown"?1:Gt.length-1))%Gt.length);return}if(T.key==="Enter"||T.key==="Tab"){T.preventDefault(),dn(Gt[Ft]??Gt[0]);return}}T.key==="Enter"&&!T.shiftKey&&!T.nativeEvent.isComposing&&(T.preventDefault(),pn())}}),e.jsxs("div",{className:"wiki-composer-controls",children:[e.jsxs("div",{className:"wiki-scope-control",children:[e.jsxs("button",{"aria-label":b("wikiScope"),"aria-expanded":ze,onClick:()=>tt(T=>!T),children:[K?b("wikiWholeScope"):Rt.length?b("wikiReferencedScope"):(oe==null?void 0:oe.entry.name)||b("wikiCurrentScope")," ",e.jsx(nn,{})]}),ze&&e.jsxs("div",{className:"wiki-scope-menu",children:[e.jsx("button",{"aria-pressed":!K,onClick:()=>{ee(!1),tt(!1)},children:b("wikiCurrentScope")}),e.jsx("button",{"aria-pressed":K,onClick:()=>{ee(!0),tt(!1)},children:b("wikiWholeScope")}),e.jsx("button",{onClick:()=>{yt(T=>!T),tt(!1)},children:b("wikiPromptPreview")})]})]}),e.jsx("button",{"aria-pressed":Ke,onClick:()=>Be(T=>!T),children:b(Ke?"wikiMayEditCode":"wikiDocumentsOnly")}),e.jsx("span",{className:"wiki-mention-hints",children:e.jsx("button",{onClick:()=>{var T;it(pe=>pe+" @"),(T=Et.current)==null||T.focus()},children:b("wikiReferenceHint")})}),!J&&e.jsx("button",{className:"wiki-collapse-composer",onClick:()=>{be(!1),tt(!1)},children:b("wikiCollapseComposer")}),r?e.jsx("button",{className:"wiki-send stopping","aria-label":b("wikiStop"),onClick:()=>u({type:"abort"}),children:e.jsx(ls,{})}):e.jsxs("button",{className:"wiki-send","aria-label":b(p?te?"sending":"wikiSend":"wikiSessionPreparing"),title:b(p?te?"sending":"wikiSend":"wikiSessionPreparing"),disabled:vn||!Ut.trim()||!O&&!K&&!Rt.length,onClick:()=>void pn(),children:[(!p||te)&&e.jsx("span",{children:b(p?"sending":"wikiSessionPreparing")}),e.jsx(cr,{})]})]}),qe&&e.jsx("pre",{className:"wiki-prompt-preview",children:Nn})]})]}),kt=(oe==null?void 0:oe.editable)&&e.jsxs("button",{className:`wiki-save-status ${tn.failure?"failed":Jt||rn?"saving":"saved"}`,onClick:()=>void ln(),title:tn.failure||void 0,disabled:!tn.failure||tn.conflict,"aria-live":"polite",children:[e.jsx("i",{}),b(tn.failure?"wikiSaveFailedRetry":Jt||rn?"wikiSaving":"wikiSaved")]}),Nt=e.jsxs("button",{disabled:!(oe!=null&&oe.editable)||z||oe.entry.path!==O,"aria-pressed":ce,onClick:()=>ae(T=>!T),children:[e.jsx(jo,{}),b(ce?"wikiPreview":"wikiSource")]}),Lt=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"wiki-breadcrumb",title:`${t}/${O}`,children:[e.jsx("span",{className:"wiki-path-parent",children:O.includes("/")&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"wiki-path-segment",children:O.split("/").slice(0,-2).map(T=>`${T} / `).join("")}),e.jsxs("span",{className:"wiki-path-tail",children:[O.split("/").at(-2)," / "]})]})}),e.jsx("b",{children:O.split("/").at(-1)||b("wikiMode")}),kt]}),e.jsxs("div",{className:"wiki-toolbar-actions",children:[e.jsxs("button",{onClick:()=>{Oe(!1),et(!1),$e(me==="recent"?null:"recent")},className:me==="recent"?"active":"",children:[e.jsx(aa,{}),b("wikiRecent")]}),e.jsxs("button",{className:`wiki-chat-toggle ${J?"active":""}`,"aria-label":b("wikiChatPanel"),"aria-expanded":J,onClick:()=>et(!J),children:[e.jsx("span",{children:"π"}),b("wikiChatTitle"),e.jsx("kbd",{children:navigator.platform.includes("Mac")?"⌘J":"Ctrl+J"})]})]})]});return e.jsxs("section",{className:`wiki-workbench ${G?"is-focused":""} ${me?"with-drawer":""} ${J?"with-chat":""}`,"aria-label":b("wikiMode"),children:[l&&cn&&mn.createPortal(Lt,cn),l&&Ye&&B.index&&mn.createPortal(e.jsx(pu,{status:B.index}),Ye),e.jsxs("aside",{className:`wiki-sidebar ${H?"open":""}`,children:[e.jsxs("button",{className:"wiki-search-trigger",onClick:()=>st(!0),children:[e.jsx(ts,{}),e.jsx("span",{children:b("wikiSearchAll")}),e.jsx("kbd",{children:"⌘K"})]}),e.jsxs("div",{className:"wiki-tree-label",children:[e.jsx("span",{children:b("wikiFiles")}),e.jsx("button",{"aria-label":b("wikiRefresh"),onClick:()=>void kn(!0),children:e.jsx(Is,{})})]}),e.jsxs("div",{className:"wiki-tree",role:"tree","aria-label":b("wikiFiles"),onScroll:T=>dt(T.currentTarget.scrollTop),children:[le.size>0&&e.jsxs("button",{className:"wiki-tree-row wiki-hidden-folders",role:"treeitem","aria-expanded":_,onClick:()=>{const T=!_;Se(T),localStorage.setItem(`pi-wiki-hidden:${t}`,String(T)),dt(0)},children:[_?e.jsx(nn,{}):e.jsx(_t,{}),e.jsx("span",{children:b("wikiHiddenFolders",{count:le.size})})]}),e.jsx("div",{style:{height:ut*30}}),je.slice(ut,gt).map(T=>e.jsxs("button",{role:"treeitem","aria-selected":T.path===O,"aria-expanded":T.kind==="directory"?A.has(T.path):void 0,className:`wiki-tree-row ${T.path===O?"selected":""}`,style:{paddingLeft:12+(T.path.split("/").length-1)*16},title:T.path,onClick:()=>T.kind==="directory"?xe(pe=>{const Qe=new Set(pe);return Qe.has(T.path)?Qe.delete(T.path):(Qe.add(T.path),un(T.path)),Qe}):Dn(T.path),children:[T.kind==="directory"?A.has(T.path)?e.jsx(nn,{}):e.jsx(_t,{}):e.jsx("i",{className:"wiki-tree-spacer"}),e.jsx("span",{children:T.name}),S.has(T.path)&&e.jsx("i",{className:"wiki-unread","aria-label":b("wikiUnread")})]},T.path)),e.jsx("div",{style:{height:Math.max(0,je.length-gt)*30}}),Object.values(Q).filter(T=>T.nextOffset!==void 0&&(B.limited||P.some(pe=>pe.symlink&&T.path.startsWith(pe.path)))&&(!T.path||A.has(T.path))).map(T=>e.jsxs("button",{className:"wiki-load-more",onClick:()=>void un(T.path,T.nextOffset),children:[b("wikiLoadMore")," · ",T.path||"/"]},T.path)),!je.length&&e.jsx("p",{className:"wiki-muted",children:b("wikiNoFiles")})]})]}),H&&e.jsx("button",{className:"wiki-sidebar-scrim","aria-label":b("close"),onClick:()=>X(!1)}),e.jsxs("div",{className:"wiki-main",children:[e.jsxs("div",{className:"wiki-document-toolbar",children:[e.jsxs("div",{className:"wiki-mobile-tools",children:[e.jsx("button",{"aria-label":b("wikiFiles"),onClick:()=>{Oe(!1),X(T=>!T)},children:e.jsx(ko,{})}),e.jsx("button",{"aria-label":b("wikiSearchAll"),onClick:()=>st(!0),children:e.jsx(ts,{})})]}),e.jsx("div",{className:"wiki-editor-toolbar-slot",ref:Ee}),(oe==null?void 0:oe.entry.kind)==="code"&&e.jsx("div",{className:"wiki-toolbar-actions",children:Nt})]}),!J&&Ze,tn.conflict&&e.jsxs("div",{className:"wiki-conflict",role:"alert",children:[e.jsx("span",{children:b("wikiExternalChanged")}),e.jsx("button",{disabled:bn,onClick:()=>void En(O),children:b("wikiReload")}),e.jsx("button",{disabled:bn||Jt,onClick:()=>void tn.keepMine(),children:b("wikiKeepMine")})]}),e.jsx("div",{className:"wiki-scroll",ref:Xe,style:{paddingBottom:J?0:Math.max(0,se-120)},onScroll:()=>Xt(null),children:z?e.jsx("div",{className:"wiki-empty",children:b("loading")}):oe?e.jsxs("article",{className:`wiki-document ${ce||oe.entry.kind==="code"?"is-source":""}`,ref:Ht,onMouseUp:ce?zn:void 0,onKeyUp:ce?zn:void 0,children:[e.jsxs("header",{className:"wiki-document-heading",children:[e.jsx("h1",{children:Tn.title||oe.entry.name.replace(/\.(md|txt)$/i,"")}),e.jsxs("div",{className:"wiki-document-meta",children:[e.jsxs("span",{className:"wiki-meta-chip",children:[e.jsx(So,{}),us]}),oe.text!==void 0&&e.jsxs("span",{className:"wiki-meta-chip",children:[e.jsx(aa,{}),b("wikiReadingTime",{minutes:Tn.minutes})]}),Tn.tags.map(T=>e.jsxs("span",{className:"wiki-meta-chip wiki-meta-tag",children:["#",T]},T)),(!M||Zn>0)&&e.jsx("button",{onClick:()=>{var T,pe;return(pe=(T=Ht.current)==null?void 0:T.querySelector(".wiki-backlinks"))==null?void 0:pe.scrollIntoView({behavior:"smooth"})},children:M?b("wikiCitations",{count:Zn}):b("wikiReferencesLoading")})]}),(oe==null?void 0:oe.entry.kind)==="document"&&Kn.length>0&&e.jsxs("details",{className:"wiki-properties",open:!0,children:[e.jsx("summary",{children:b("wikiProperties")}),e.jsx("dl",{children:Kn.map((T,pe)=>e.jsxs("div",{children:[e.jsx("dt",{children:T.key}),e.jsx("dd",{children:e.jsx(jr,{children:T.value})})]},pe))})]})]}),oe.text!==void 0?ce||oe.entry.kind==="code"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"wiki-code-hint",children:oe.entry.kind==="code"&&!ce?b("wikiCodeReadOnly"):b("wikiEditingSource")}),e.jsx(kl,{value:U,name:O,readOnly:bn||!oe.editable||!ce&&oe.entry.kind==="code",wrap:!1,onChange:fe,onSelectLines:(T,pe)=>Vt(U.split(`
|
|
197
|
-
`).slice(T-1,pe).join(`
|
|
198
|
-
`))})]}):e.jsx("div",{className:"wiki-prose md",children:e.jsx(vl,{file:{cwd:t,path:O},value:U,readOnly:bn||!oe.editable,onChange:fe,wiki:{toolbarHost:Ne,focused:G,onWidth:()=>{Oe(!G),et(!1),be(!1),$e(null),X(!1)},paths:de,ask:T=>{var pe;Vt(T.slice(0,12e3)),et(!0),w(),(pe=Et.current)==null||pe.focus()},followLink:Vn,resolveCode:T=>ja(O,T,de),added:rs}},`${t}:${O}`)}):oe.entry.kind==="image"?e.jsx("img",{className:"wiki-image",src:Fr(t,O),alt:oe.entry.name}):oe.entry.kind==="pdf"?e.jsx("iframe",{className:"wiki-pdf",title:oe.entry.name,src:Fr(t,O)}):e.jsxs("div",{className:"wiki-empty",children:[e.jsx(Ws,{}),e.jsxs("p",{children:[oe.entry.name," · ",Math.ceil(oe.entry.size/1024)," KB"]}),xt!=null&&xt.openWikiFile?e.jsx("button",{onClick:()=>void xt.openWikiFile({clientId:fn(),cwd:t,path:O}).catch(T=>Ae(T.message)),children:b("wikiOpenDefault")}):e.jsx("a",{href:Fr(t,O,!0),download:!0,children:b("wikiDownloadOpen")})]}),(!M||oe.backlinks.length>0)&&e.jsxs("section",{className:"wiki-backlinks",children:[e.jsxs("h2",{children:[e.jsx(lr,{}),b("wikiBacklinks")," ",e.jsx("span",{children:M?oe.backlinks.length:b("loading")})]}),oe.backlinks.slice(0,ve).map((T,pe)=>e.jsxs("button",{onClick:()=>Dn(T.path),children:[e.jsx("strong",{children:T.path}),e.jsx("span",{children:T.snippet})]},`${T.path}:${pe}`)),oe.backlinks.length>ve&&e.jsx("button",{onClick:()=>ye(T=>T+100),children:b("wikiLoadMore")}),!M&&e.jsx("p",{children:b("wikiReferencesLoading")}),M&&!oe.backlinks.length&&e.jsx("p",{children:b("wikiNoBacklinks")})]})]}):e.jsxs("div",{className:"wiki-empty",children:[e.jsx(id,{}),e.jsx("h1",{children:b("wikiWelcome")}),e.jsx("p",{children:b("wikiWelcomeHint")}),e.jsx("button",{onClick:()=>st(!0),children:b("wikiSearchAll")})]})}),!J&&pt]}),J&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"wiki-chat-scrim","aria-label":b("wikiCloseChat"),onClick:()=>et(!1)}),e.jsx(ju,{onStop:()=>u({type:"abort"}),recovery:L,conversationId:n,thinkingWrap:I,connected:E,silenceNotified:$,messages:s,live:i,streaming:r,toolStatuses:c,model:a??void 0,contextPercent:o,disabled:vn,onNew:()=>qn(()=>void j(O)),onClose:()=>et(!1),canJump:T=>!ce&&Sa(hs,T)>=0,jump:Te,composer:pt,quickQuestions:on,onQuickQuestion:T=>void pn(Ca(T,O,"",[],"",[],!1,!1,{scope:b("wikiScope"),selection:b("wikiSelected"),documentsOnly:b("wikiDocumentsOnlyPrompt"),skip:b("wikiSkipPrompt")})),revisions:B.revisions,onViewChange:T=>void ps(T),onUndo:T=>void Yn(T,!T.changes.every(pe=>pe.undone)),onResend:T=>void pn(T),error:Ze})]}),me&&e.jsxs("aside",{className:"wiki-changes",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("h2",{children:b(me==="recent"?"wikiRecent":"wikiRelatedChanges")}),e.jsx("span",{children:t.split(/[\\/]/).at(-1)})]}),e.jsx("button",{"aria-label":b("close"),onClick:()=>$e(null),children:e.jsx(qt,{})})]}),e.jsxs("div",{className:"wiki-changes-scroll",children:[B.revisions.filter(T=>me==="recent"||T.id===me).map((T,pe,Qe)=>e.jsxs("div",{className:"wiki-revision",children:[(pe===0||new Date(Qe[pe-1].at).toDateString()!==new Date(T.at).toDateString())&&e.jsx("time",{children:new Date(T.at).toLocaleDateString(F==="zh"?"zh-CN":"en-US")}),e.jsxs("div",{className:"wiki-revision-title",children:[e.jsx("span",{className:`wiki-avatar ${T.author}`,children:T.author==="pi"?e.jsx("img",{src:"/icon/1a-mark.svg",alt:"pi"}):b("wikiMe")}),e.jsxs("div",{children:[e.jsx("strong",{children:T.title.split(`
|
|
199
|
-
`)[0]}),e.jsxs("small",{children:[new Date(T.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," · ",b("wikiFileCount",{count:T.changes.length})]})]})]}),e.jsxs("div",{className:"wiki-revision-actions",children:[e.jsxs("button",{disabled:vn||T.changes.every(rt=>rt.undone),onClick:()=>void Yn(T,!0),children:[e.jsx(bo,{}),b("wikiUndoAll")]}),e.jsxs("button",{disabled:vn||T.changes.every(rt=>!rt.undone),onClick:()=>void Yn(T,!1),children:[e.jsx(ed,{}),b("wikiRedoAll")]})]}),T.changes.map(rt=>{const at={...rt,...ke[`${T.id}:${rt.path}`]??{},undone:rt.undone};return e.jsxs("div",{className:`wiki-file-change ${at.undone?"undone":""}`,children:[e.jsxs("div",{children:[e.jsx("button",{title:at.path,onClick:()=>Dn(at.path),children:at.path}),e.jsx("button",{disabled:vn,onClick:()=>void Yn(T,!at.undone,at.path),children:b(at.undone?"wikiRedo":"wikiUndo")})]}),e.jsxs("small",{children:[e.jsxs("em",{children:["+",at.additions]})," ",e.jsxs("b",{children:["−",at.deletions]})]}),e.jsxs("details",{onToggle:Tt=>{Tt.currentTarget.open&&at.truncated&&Pn(t,"change",{id:T.id,path:at.path}).then(sn=>{St.current&&Re(Cn=>({...Cn,[`${T.id}:${at.path}`]:sn}))}).catch(sn=>Ae(sn.message))},children:[e.jsx("summary",{children:b("wikiViewDiff")}),at.binary?e.jsx("p",{children:b("wikiBinaryChange")}):e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"wiki-diff-before",children:at.before??b("wikiNewFile")}),e.jsx("pre",{className:"wiki-diff-after",children:at.after??b("wikiDeletedFile")})]})]})]},at.path)}),T.skipped.length>0&&e.jsxs("p",{className:"wiki-skipped",children:[b("wikiUntracked"),": ",T.skipped.join(", ")]})]},T.id)),!B.revisions.length&&e.jsx("p",{className:"wiki-muted",children:b("wikiNoChanges")})]})]}),jt&&mn.createPortal(e.jsx("div",{className:"wiki-selection-menu",style:{left:jt.x,top:jt.y},onMouseDown:T=>T.preventDefault(),children:["ask","rewrite","explain","link"].map(T=>e.jsx("button",{onClick:()=>At(T),children:b(T==="ask"?"wikiAskPi":T==="rewrite"?"wikiRewrite":T==="explain"?"wikiExplain":"wikiAddLink")},T))}),document.body),Pe&&e.jsx("div",{className:"wiki-modal-backdrop",onMouseDown:T=>{T.target===T.currentTarget&&st(!1)},children:e.jsxs("section",{className:"wiki-search-modal",role:"dialog","aria-modal":"true","aria-label":b("wikiSearchAll"),children:[e.jsxs("div",{children:[e.jsx(ts,{}),e.jsx("input",{autoFocus:!0,"aria-label":b("wikiSearchAll"),placeholder:b("wikiSearchHint"),value:lt,onChange:T=>g(T.target.value),onKeyDown:T=>{(T.key==="ArrowDown"||T.key==="ArrowUp")&&(T.preventDefault(),$t(pe=>Math.max(0,Math.min(ne.length-1,pe+(T.key==="ArrowDown"?1:-1))))),T.key==="Enter"&&ne[Dt]&&(T.preventDefault(),T.metaKey||T.ctrlKey?Xn(ne[Dt]):Dn(ne[Dt].path))}}),e.jsx("button",{"aria-label":b("close"),onClick:()=>st(!1),children:e.jsx(qt,{})})]}),e.jsxs("div",{className:"wiki-search-results",children:[He&&e.jsx("p",{role:"status",children:b("loading")}),ne.map((T,pe)=>e.jsxs("div",{children:[(pe===0||ne[pe-1].kind!==T.kind)&&e.jsx("h3",{children:b(T.kind==="document"?"wikiDocuments":T.kind==="pdf"?"wikiPdf":T.kind==="code"?"wikiCode":"wikiFiles")}),e.jsxs("button",{className:Dt===pe?"selected":"",onMouseEnter:()=>$t(pe),onClick:Qe=>Qe.metaKey||Qe.ctrlKey?Xn(T):Dn(T.path),children:[e.jsxs("strong",{children:[T.path,T.page?` · ${b("wikiPage",{page:T.page})}`:""]}),e.jsx("span",{children:T.snippet})]})]},`${T.path}:${T.line}:${pe}`)),lt&&!He&&!ne.length&&e.jsx("p",{children:b("wikiNoResults")}),ft&&e.jsx("p",{children:b("wikiSearchLimited")})]}),e.jsx("footer",{children:b("wikiSearchKeys")})]})}),re&&e.jsx("div",{className:"wiki-modal-backdrop",children:e.jsxs("section",{className:"wiki-confirm",role:"dialog","aria-modal":"true","aria-label":b("wikiUnsaved"),children:[e.jsx("h2",{children:b("wikiUnsaved")}),e.jsx("p",{children:b("wikiUnsavedHint")}),e.jsxs("div",{children:[e.jsx("button",{disabled:Jt,onClick:()=>we(null),children:b("cancel")}),e.jsx("button",{disabled:Jt,onClick:()=>{const T=re;fe((oe==null?void 0:oe.text)??""),we(null),T()},children:b("wikiDiscard")}),e.jsx("button",{disabled:vn,onClick:()=>void(async()=>{if(await ln()){const T=re;we(null),T()}})(),children:b("wikiSaveContinue")})]})]})})]})}function Ep({state:t,send:n}){var p,u;const s=nt(),[r,i]=d.useState(""),[a,o]=d.useState(null);if(d.useEffect(()=>{i("")},[t==null?void 0:t.requestId,(p=t==null?void 0:t.prompt)==null?void 0:p.id]),d.useEffect(()=>{if(!t||a===t.requestId)return;const f=k=>{k.key==="Escape"&&(k.preventDefault(),t.phase==="pending"&&n({type:"cancel_provider_login",requestId:t.requestId}),o(t.requestId))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[t,a,n]),!t||a===t.requestId)return null;let c;try{const f=new URL(t.url??"");(f.protocol==="https:"||f.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(f.hostname))&&(c=f.href)}catch{}const l=()=>{t.phase==="pending"&&n({type:"cancel_provider_login",requestId:t.requestId}),o(t.requestId)};return e.jsx("div",{className:"modal-backdrop provider-auth-backdrop",children:e.jsxs("section",{className:"modal provider-auth-modal",role:"dialog","aria-modal":"true","aria-labelledby":"provider-auth-title",children:[e.jsxs("div",{className:"modal-head",children:[e.jsxs("h2",{id:"provider-auth-title",children:[s("providerLogin")," · ",t.provider]}),e.jsx("button",{className:"iconbtn",onClick:l,"aria-label":s("close"),children:"×"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("p",{children:s(t.phase==="pending"?"providerAuthPending":t.phase==="success"?"providerAuthSuccess":t.phase==="cancelled"?"providerAuthCancelled":"providerAuthError")}),t.message&&e.jsx("p",{className:"provider-auth-message",children:t.message}),c&&e.jsx("a",{className:"btn",href:c,target:"_blank",rel:"noreferrer",children:s("providerAuthOpenBrowser")}),t.phase==="success"&&t.provider==="radius"&&e.jsx("button",{className:"btn",onClick:()=>window.dispatchEvent(new Event("pi-configure-radius")),children:s("mcpConfigureRadius")}),t.code&&e.jsxs("p",{children:[s("providerAuthDeviceCode")," ",e.jsx("code",{children:t.code})]}),t.prompt&&e.jsxs("form",{onSubmit:f=>{f.preventDefault(),t.prompt&&n({type:"provider_auth_response",requestId:t.requestId,promptId:t.prompt.id,value:r}),i("")},children:[e.jsxs("label",{children:[t.prompt.message,t.prompt.kind==="select"?e.jsxs("select",{value:r,onChange:f=>i(f.target.value),children:[e.jsx("option",{value:"",children:s("providerAuthChoose")}),(u=t.prompt.options)==null?void 0:u.map(f=>e.jsx("option",{value:f.id,children:f.label},f.id))]}):e.jsx("input",{autoFocus:!0,type:t.prompt.kind==="secret"?"password":"text",value:r,onChange:f=>i(f.target.value),placeholder:t.prompt.placeholder,autoComplete:"off"})]}),e.jsx("button",{type:"submit",className:"btn",disabled:!r,children:s("confirm")})]},t.prompt.id)]}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:l,children:s(t.phase==="pending"?"cancel":"close")})})]})})}const Gs=d.createContext("");let Tp=-100;const Rp=[];function Ip(t,n,s,r,i){const a=d.useRef(0),[o,c]=d.useState(null);return d.useEffect(()=>{if(!n||!t)return;const l=()=>{document.visibilityState!=="hidden"&&(a.current=--Tp,i({type:"scm_status",reqId:a.current}))};return l(),window.addEventListener("focus",l),document.addEventListener("visibilitychange",l),()=>{a.current=0,window.removeEventListener("focus",l),document.removeEventListener("visibilitychange",l)}},[t,n,s,i]),d.useEffect(()=>{(r==null?void 0:r.type)!=="scm_data"||r.kind!=="status"||r.reqId!==a.current||r.cwd!==t||c({cwd:t,files:r.ok?(r.files??[]).map(l=>({...l,path:l.path.replaceAll("\\","/")})):[],base:r.base??"",branch:r.branch??"",branches:r.branches??[],notRepo:!!r.notRepo})},[r,t]),(o==null?void 0:o.cwd)===t?o:{cwd:t,files:Rp,notRepo:!1,base:"",branch:"",branches:[]}}function js({trigger:t,open:n,onOpenChange:s,children:r,align:i="right",fit:a=!1,direction:o="down",menuClassName:c}){const l=d.useRef(null);return d.useEffect(()=>{if(!n)return;const p=f=>{l.current&&!l.current.contains(f.target)&&s(!1)},u=f=>{f.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",u)}},[n,s]),e.jsxs("div",{className:`dropdown ${i} ${a?"fit":""} ${o==="up"?"dd-up":""}`,ref:l,children:[e.jsxs("button",{type:"button",className:"chip",onClick:()=>s(!n),"aria-expanded":n,children:[t,e.jsx(nn,{className:`dd-caret ${n?"up":""}`})]}),n&&e.jsx("div",{className:`dd-menu ${c??""}`,children:r})]})}function Gn({active:t,disabled:n=!1,title:s,onClick:r,children:i}){return e.jsx("button",{type:"button",className:`dd-item ${t?"active":""}`,disabled:n,title:s,onClick:r,children:i})}const Lp=["off","minimal","low","medium","high","xhigh","max"],yl=d.memo(function({state:n,models:s,modelsLoading:r,send:i,onManageModels:a,compact:o=!1,segmented:c=!1}){const l=nt(),p=n==null?void 0:n.model,u=p?`${p.provider}/${p.id}`:null,[f,k]=d.useState(!1),[j,I]=d.useState(!1),[E,$]=d.useState("");d.useEffect(()=>{f||$("")},[f]);const N=d.useMemo(()=>{const q=E.trim().toLowerCase();return q?s.filter(ke=>ke.name.toLowerCase().includes(q)||ke.provider.toLowerCase().includes(q)||ke.id.toLowerCase().includes(q)):s},[s,E]),[R,y]=d.useState(!1),L=n!=null&&n.availableThinkingLevels&&n.availableThinkingLevels.length>0?new Set(n.availableThinkingLevels):null,b=Lp.map(q=>({value:q,label:l(`thinking.${q}`),supported:L?L.has(q):!0})),F=[{label:l("thinking.minimal"),description:l("thinkingMinimalDescription"),values:["minimal","low","off"]},{label:l("thinkingStandard"),description:l("thinkingStandardDescription"),values:["medium"]},{label:l("thinkingDeep"),description:l("thinkingDeepDescription"),values:["high","xhigh","max"]}],B=F.find(q=>q.values.includes((n==null?void 0:n.thinkingLevel)??"off"))??F[0],ie=q=>{var ke;return((ke=b.find(Re=>Re.value===q))==null?void 0:ke.label)??q},Q=(n==null?void 0:n.runSettings)&&e.jsx("div",{className:"thinking-run-settings",children:["autoCompaction","autoRetry"].map(q=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:n.runSettings[q],onChange:ke=>i({type:"set_run_settings",conversationId:n.conversationId,[q]:ke.target.checked})}),l(q==="autoCompaction"?"conversationAutoCompaction":"conversationAutoRetry")]},q))});return d.useEffect(()=>{f&&s.length===0&&!R&&!r&&(y(!0),i({type:"list_models"}))},[f,s.length,R,r,i]),d.useEffect(()=>{s.length>0&&y(!1)},[s.length]),e.jsxs(e.Fragment,{children:[e.jsxs(js,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(wi,{}),e.jsxs("span",{className:"chip-model",children:[p?p.name:l("selectModel"),(n==null?void 0:n.routedModel)&&e.jsxs("span",{className:"chip-routed-model",title:`${n.routedModel.provider}/${n.routedModel.id}${n.routedModel.thinkingLevel?` · ${n.routedModel.thinkingLevel}`:""}`,children:[" → ",n.routedModel.name]})]}),!o&&(p==null?void 0:p.vision)&&e.jsx("span",{className:"chip-vision",title:l("vision"),children:"🖼"}),!o&&p&&e.jsx("span",{className:"chip-sub",children:p.provider})]}),open:f,onOpenChange:k,menuClassName:"dd-menu-model",children:[e.jsx("div",{className:"dd-header",children:l("availableModels")}),e.jsxs("div",{className:"dd-search-row",children:[e.jsx(ts,{}),e.jsx("input",{className:"dd-search",type:"text",placeholder:l("searchModels"),value:E,onChange:q=>$(q.target.value)})]}),e.jsxs("div",{className:"dd-model-scroll",children:[(R||r)&&e.jsx("div",{className:"dd-loading",children:l("loading")}),s.length===0&&!R&&!r&&e.jsx("div",{className:"dd-loading",children:l("noModels")}),N.length===0&&s.length>0&&e.jsx("div",{className:"dd-loading",children:l("noModelMatches")}),N.map(q=>e.jsx(Gn,{active:u===q.id,onClick:()=>{u!==q.id&&i({type:"set_model",modelId:q.id}),k(!1)},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:q.name}),e.jsxs("span",{className:"dd-model-meta",children:[e.jsx("span",{className:"dd-model-provider",children:q.provider}),(q.reasoning||q.vision)&&e.jsxs("span",{className:"dd-model-badges",children:[q.reasoning&&e.jsx("span",{className:"dd-model-badge",children:l("reasoning")}),q.vision&&e.jsx("span",{className:"dd-model-badge",children:l("vision")})]})]})]})},q.id))]}),c&&e.jsxs("div",{className:"dd-thinking-levels",children:[e.jsx("span",{children:l("thinkingLevel")}),b.filter(q=>q.supported).map(q=>e.jsx("button",{type:"button","aria-pressed":(n==null?void 0:n.thinkingLevel)===q.value,onClick:()=>i({type:"set_thinking",level:q.value}),children:q.label},q.value))]}),e.jsxs("div",{className:"dd-footer",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>i({type:"list_models"}),children:l("refreshModels")}),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{k(!1),a()},children:l("manageModels")})]})]}),c?e.jsx("div",{className:"thinking-control",children:e.jsxs(js,{trigger:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"thinking-trigger-prefix",children:[l("thinking")," · "]}),e.jsx("span",{children:B.label})]}),open:j,onOpenChange:I,align:"left",menuClassName:"dd-menu-thinking",children:[e.jsx("div",{className:"dd-header",children:l("thinkingLevel")}),F.map(q=>{const ke=q.values.find(Re=>!L||L.has(Re));return e.jsx(Gn,{active:q===B,disabled:!ke,title:ke?void 0:l("thinkingUnsupported"),onClick:()=>{ke&&(n==null?void 0:n.thinkingLevel)!==ke&&i({type:"set_thinking",level:ke}),I(!1)},children:e.jsxs("span",{className:"thinking-mode-option",children:[e.jsx("strong",{children:q.label}),e.jsx("small",{children:q.description})]})},q.label)}),Q]})}):e.jsxs(js,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Bc,{}),e.jsx("span",{className:"chip-sub",children:l("thinkingChip",{level:n?ie(n.thinkingLevel):"—"})})]}),open:j,onOpenChange:I,children:[e.jsx("div",{className:"dd-header",children:l("thinkingLevel")}),b.map(q=>e.jsx(Gn,{active:(n==null?void 0:n.thinkingLevel)===q.value,disabled:!q.supported,title:q.supported?void 0:l("thinkingUnsupported"),onClick:()=>{(n==null?void 0:n.thinkingLevel)!==q.value&&i({type:"set_thinking",level:q.value}),I(!1)},children:q.label},q.value)),Q]})]})}),Mp=[{kind:"question",labelKey:"sound.question",descKey:"sound.question.desc"},{kind:"done",labelKey:"sound.done",descKey:"sound.done.desc"},{kind:"start",labelKey:"sound.start",descKey:"sound.start.desc"},{kind:"error",labelKey:"sound.error",descKey:"sound.error.desc"}];function Pp({settings:t,onChange:n,onPreview:s}){const r=nt(),i=a=>n({...t,...a});return e.jsxs("details",{className:"sound-menu",children:[e.jsxs("summary",{className:"sound-menu-summary",children:[e.jsx(Xi,{"aria-hidden":"true"}),e.jsx("span",{children:r("soundHeader")}),e.jsx(nn,{className:"sound-menu-caret","aria-hidden":"true"})]}),e.jsxs("div",{className:"sound-menu-options",children:[e.jsxs("label",{className:"sound-row sound-master",children:[e.jsxs("span",{className:"sound-label",children:[e.jsx(Xi,{className:"sound-icon"}),e.jsx("span",{children:r("enableSound")})]}),e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:a=>i({enabled:a.target.checked})})]}),Mp.map(({kind:a,labelKey:o,descKey:c})=>e.jsxs("label",{className:`sound-row ${t.enabled?"":"disabled"}`,children:[e.jsxs("span",{className:"sound-label",children:[e.jsx("span",{className:"sound-name",children:r(o)}),e.jsx("span",{className:"sound-desc",children:r(c)})]}),e.jsxs("span",{className:"sound-right",children:[e.jsx("button",{type:"button",className:"sound-preview",title:r("preview"),disabled:!t.enabled,onClick:l=>{l.preventDefault(),s(a)},children:r("preview")}),e.jsx("input",{type:"checkbox",checked:t[a],disabled:!t.enabled,onChange:l=>i({[a]:l.target.checked})})]})]},a)),e.jsxs("div",{className:`sound-volume ${t.enabled?"":"disabled"}`,children:[e.jsx("span",{className:"sound-name",children:r("volume")}),e.jsx("input",{type:"range",min:0,max:100,step:5,value:t.volume,disabled:!t.enabled,onChange:a=>i({volume:Number(a.target.value)})}),e.jsxs("span",{className:"sound-vol-num",children:[t.volume,"%"]})]})]})]})}function fr(t,n,s,r,i,a){if(s!=null&&s.trim())return s;const o=(n||t).trim();if(r>1&&/^(?:hi|hello|hey|你好|您好|嗨|哈喽)[\s!!??.。~~]*$/iu.test(o)){const c=a==null?void 0:a.filter(l=>l.role==="user").map(l=>l.content.filter(p=>p.type==="text").map(p=>p.type==="text"?p.text:"").join(" ").trim()).find(l=>l&&!/^(?:hi|hello|hey|你好|您好|嗨|哈喽)[\s!!??.。~~]*$/iu.test(l)&&!l.startsWith("【目标已设定】")&&!l.startsWith("✅ 目标已达成"));if(c)return Array.from(c).slice(0,24).join("")+(Array.from(c).length>24?"…":"");if(i==="zh")return"打招呼"}return t}function Ap({leftCollapsed:t=!1,gitChangeCount:n,onOpenTask:s,chat:r,send:i,terminal:a,view:o,plugins:c,onViewChange:l,onOpenPanel:p,onManageModels:u,onOpenSettings:f,onOpenBgTasks:k,onOpenGlobalSearch:j,sound:I,onSoundChange:E,onSoundPreview:$}){var ge,Ie,Ae,re,we,A,xe,_,Se,J,De,G,Oe,Ne,Ee,et;const{locale:N,setLocale:R,t:y}=Qn(),L=Sr(),[b,F]=d.useState(!1),[B,ie]=d.useState(!1),[Q,q]=d.useState(null);d.useEffect(()=>{q(t?null:document.getElementById("sidebar-settings-slot")),o==="nodes"&&ie(!1)},[o,t]);const[ke,Re]=d.useState({maximized:!1,fullscreen:!1});d.useEffect(()=>xt==null?void 0:xt.onWindowState(Re),[]);const O=(Ie=(ge=r.state)==null?void 0:ge.cwd)==null?void 0:Ie.split(/[\\/]/).filter(Boolean).at(-1),_e=((Ae=r.gitBranch)==null?void 0:Ae.cwd)===((re=r.state)==null?void 0:re.cwd)&&!!((we=r.gitBranch)!=null&&we.notRepo),M=((A=r.state)==null?void 0:A.conversationId)===r.activeConversationId?Ms(r.state.streamingMessage?[...r.state.messages,r.state.streamingMessage]:r.state.messages,r.state.isStreaming).current:void 0,V=(M==null?void 0:M.state)==="stopped",ve=(M==null?void 0:M.state)==="reminding",ye=((xe=r.state)==null?void 0:xe.conversationId)===r.activeConversationId?(_=r.state)==null?void 0:_.taskProgress:null,oe=(ye==null?void 0:ye.status)==="running"||(ye==null?void 0:ye.status)==="waiting"?((Se=ye.plan)==null?void 0:Se.items.filter(Ce=>Ce.status!=="removed"))??[]:[],Fe=oe.findIndex(Ce=>Ce.status==="running"),U=r.sessions.find(Ce=>{var be;return Ce.path===((be=r.state)==null?void 0:be.sessionFile)}),fe=r.conversations.find(Ce=>Ce.id===r.activeConversationId),ce=fr((fe==null?void 0:fe.title)||cs((U==null?void 0:U.firstMessage)??"")||y("newChat"),U==null?void 0:U.firstMessage,U==null?void 0:U.name,Math.max((U==null?void 0:U.messageCount)??0,(fe==null?void 0:fe.messageCount)??0,((J=r.state)==null?void 0:J.messages.length)??0),N,(De=r.state)==null?void 0:De.messages),ae=[{value:"zh",label:y("langZh")},{value:"en",label:y("langEn")}],z=r.ready?y("connected"):r.status==="closed"?y("reconnecting"):y("connecting"),Z=r.ready?"ok":"busy",W=e.jsx("div",{className:"topbar-more",children:e.jsxs(js,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(_s,{"aria-hidden":"true"}),e.jsx("span",{className:"chip-sub",children:y("settings")})]}),open:B,onOpenChange:ie,menuClassName:"workspace-settings-menu",children:[e.jsxs(Gn,{onClick:()=>{ie(!1),f()},children:[e.jsx(_s,{"aria-hidden":"true"}),e.jsx("span",{className:"workspace-menu-label",children:y("allSettings")})]}),e.jsx("div",{className:"dd-header workspace-menu-section",children:y("quickActions")}),e.jsxs(Gn,{onClick:()=>{ie(!1),ma()},children:[e.jsx(os,{"aria-hidden":"true"}),e.jsx("span",{className:"workspace-menu-label",children:y("treeTitle")})]}),e.jsxs(Gn,{onClick:()=>{ie(!1),j()},children:[e.jsx(ts,{"aria-hidden":"true"}),e.jsx("span",{className:"workspace-menu-label",children:y("searchGlobal")})]}),e.jsxs(Gn,{onClick:()=>{ie(!1),k()},children:[e.jsx(ys,{"aria-hidden":"true"}),e.jsx("span",{className:"workspace-menu-label",children:y("bgTasks")}),r.bgServers.length>0&&e.jsx("em",{className:"bg-task-badge",children:r.bgServers.length})]}),e.jsx(Pp,{settings:I,onChange:E,onPreview:$}),e.jsx("div",{className:"dd-header",children:y("language")}),ae.map(Ce=>e.jsx(Gn,{active:N===Ce.value,onClick:()=>R(Ce.value),children:Ce.label},Ce.value))]})});return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"brand",children:[e.jsx("button",{type:"button",className:"panel-toggle",title:y("openHistory"),onClick:()=>p("left"),children:e.jsx(ko,{})}),e.jsx("img",{className:"brand-logo",src:"/icon/1a-mark.svg",alt:""}),e.jsx("span",{className:"brand-name",children:"pi-harness"}),xt&&e.jsxs("span",{className:"desktop-window-title",title:((G=r.state)==null?void 0:G.cwd)??"",children:["pi-harness ",e.jsx("span",{className:"desktop-title-separator",children:"/"})," ",O||y("desktopWorkspace")]}),e.jsx("span",{className:`conn-dot ${Z}`,title:z}),e.jsx("span",{className:"conn-label",children:z})]}),o!=="nodes"&&e.jsx("button",{type:"button",className:"project-panel-toggle",title:y(t?"expandProjects":"collapseProjects"),"aria-label":y(t?"expandProjects":"collapseProjects"),"aria-expanded":!t,onClick:()=>p("left"),children:e.jsx(ea,{})}),e.jsx("div",{id:"wiki-toolbar-slot"}),e.jsxs("div",{className:"header-location",children:[e.jsx("span",{title:(Oe=r.state)==null?void 0:Oe.cwd,children:O||y("desktopWorkspace")}),e.jsx("i",{children:"/"}),e.jsxs("button",{className:"conversation-title-button",title:y("treeTitle"),onClick:()=>ma(),children:[e.jsx("strong",{title:ce,children:ce}),e.jsx("span",{"aria-hidden":"true",children:"⌄"})]}),o==="chat"&&((Ne=r.gitBranch)==null?void 0:Ne.branch)&&e.jsx("code",{className:"changes-current-branch",children:r.gitBranch.branch}),(V||ve||Fe>=0||!!((Ee=ye==null?void 0:ye.plan)!=null&&Ee.awaitingConfirmation))&&e.jsxs("button",{type:"button",className:`header-task-progress${V?" interrupted":ve?" reminding":""}`,title:y("taskProgress"),onClick:s,children:[e.jsx("span",{"aria-hidden":"true",children:"●"}),V?y("toolRecoveryInterrupted"):ve?y("working"):(et=ye==null?void 0:ye.plan)!=null&&et.awaitingConfirmation?y("taskProgress"):y("taskPlanPosition",{current:Fe+1,total:oe.length})]})]}),e.jsxs("div",{className:"topbar-actions",children:[o==="chat"&&L&&(L.files.length>0||n>0||L.open)&&e.jsxs("button",{className:"changes-toggle","aria-pressed":L.open,title:"⌘D",onClick:()=>L.set({open:!L.open}),children:[e.jsx(ys,{"aria-hidden":"true"}),y("changesTitle")," ",e.jsx(Ns,{files:L.files})]}),e.jsxs("div",{className:"view-switch",role:"tablist","aria-label":y("viewSwitch"),children:[e.jsxs("button",{type:"button",role:"tab","aria-label":y("chat"),title:y("chat"),"aria-selected":o==="chat",className:o==="chat"?"active":"",onClick:()=>l("chat"),children:[e.jsx(vo,{}),e.jsx("span",{children:y("chat")})]}),o==="wiki"&&e.jsx("button",{type:"button",role:"tab","aria-selected":"true",className:"active wiki-view-tab",children:e.jsx("span",{children:"Wiki"})}),e.jsxs("button",{type:"button",role:"tab","aria-label":y("terminal"),title:y("terminal"),"aria-selected":o==="terminal",className:o==="terminal"?"active":"",onClick:()=>l("terminal"),children:[e.jsx(ki,{}),e.jsx("span",{children:y("terminal")})]}),e.jsxs("button",{type:"button",role:"tab","aria-label":y("nodes"),title:y("nodes"),"aria-selected":o==="nodes",className:o==="nodes"?"active":"",onClick:()=>l("nodes"),children:[e.jsx(sa,{}),e.jsx("span",{children:y("nodes")})]}),e.jsxs("button",{type:"button",role:"tab","aria-label":y("scmTab"),title:y(_e?"notGitRepoShort":"scmTab"),"aria-disabled":_e,className:o==="git"?"active":void 0,"aria-selected":o==="git",onClick:()=>{_e||l("git")},children:[e.jsx(os,{}),e.jsx("span",{children:y("scmTab")}),!_e&&n>0&&e.jsx("em",{className:"tab-change-count",children:n})]}),e.jsxs("button",{type:"button",className:"workspace-jobs",onClick:k,title:y("bgTasksTip"),children:[e.jsx(ys,{}),e.jsx("span",{children:y("bgTasks")}),r.bgServers.length>0&&e.jsx("em",{className:"bg-task-badge",children:r.bgServers.length})]}),c.map(Ce=>{const be=Ce.error?`${Ce.name}: ${Ce.error}`:Ce.description?`${Ce.name} — ${Ce.description}`:Ce.name;return e.jsxs("button",{type:"button",role:"tab","aria-selected":o===`plugin:${Ce.id}`,className:`plugin-tab${o===`plugin:${Ce.id}`?" active":""}${Ce.error?" broken":""}`,title:be,onClick:()=>l(`plugin:${Ce.id}`),children:[Ce.icon?e.jsx("span",{"aria-hidden":!0,children:Ce.icon}):null,e.jsx("span",{children:Ce.name})]},Ce.id)})]}),e.jsxs("div",{className:"topbar-desktop",children:[e.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":y("bgTasksTip"),onClick:k,children:[e.jsx(ys,{}),e.jsx("span",{className:"chip-sub",children:y("bgTasks")}),r.bgServers.length>0&&e.jsx("span",{className:"bg-task-badge",children:r.bgServers.length})]}),e.jsx(yl,{state:r.state?{conversationId:r.state.conversationId,runSettings:r.state.runSettings,model:r.state.model,routedModel:r.state.routedModel,thinkingLevel:r.state.thinkingLevel,availableThinkingLevels:r.state.availableThinkingLevels}:null,models:r.models,modelsLoading:r.modelsLoading,send:i,onManageModels:u}),e.jsxs("button",{type:"button",className:"chip",title:y("settingsTitle"),onClick:f,children:[e.jsx(_s,{}),e.jsx("span",{className:"chip-sub",children:y("settings")})]}),e.jsxs(js,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(sa,{}),e.jsx("span",{className:"chip-sub",children:N==="zh"?y("langZh"):"EN"})]}),open:b,onOpenChange:F,children:[e.jsx("div",{className:"dd-header",children:y("language")}),ae.map(Ce=>e.jsx(Gn,{active:N===Ce.value,onClick:()=>{R(Ce.value),F(!1)},children:Ce.label},Ce.value))]})]}),e.jsxs("button",{type:"button",className:"chip newchat","data-tip":y("newChatTip"),onClick:()=>i({type:"new_chat"}),children:[e.jsx(gs,{}),e.jsx("span",{children:y("newChat")})]}),o!=="nodes"&&(Q?mn.createPortal(W,Q):W),e.jsx("button",{type:"button",className:"panel-toggle",title:y("openFiles"),onClick:()=>p("right"),children:e.jsx(ea,{})})]}),xt&&xt.platform!=="darwin"&&e.jsxs("div",{className:"desktop-window-controls","aria-label":y("windowControls"),children:[e.jsx("button",{type:"button",title:y("minimizeWindow"),"aria-label":y("minimizeWindow"),onClick:()=>xt==null?void 0:xt.windowAction("minimize"),children:e.jsx(Qr,{})}),e.jsx("button",{type:"button",title:ke.maximized||ke.fullscreen?y("restoreWindow"):y("maximizeWindow"),"aria-label":ke.maximized||ke.fullscreen?y("restoreWindow"):y("maximizeWindow"),onClick:()=>xt==null?void 0:xt.windowAction("toggle-maximize"),children:ke.maximized||ke.fullscreen?e.jsx(Ls,{}):e.jsx(ls,{})}),e.jsx("button",{type:"button",className:"desktop-window-close",title:y("closeWindow"),"aria-label":y("closeWindow"),onClick:()=>xt==null?void 0:xt.windowAction("close"),children:e.jsx(qt,{})})]})]})}function Dp({dirBrowse:t,onBrowse:n,onPick:s,onClose:r}){const i=nt(),[a,o]=d.useState("");d.useEffect(()=>{n(void 0)},[]),d.useEffect(()=>{const f=k=>{k.key==="Escape"&&r()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r]);const c=(t==null?void 0:t.path)??"",l=c.includes("\\")&&!c.includes("/")?"\\":"/",p=f=>c.endsWith(l)?`${c}${f}`:`${c}${l}${f}`,u=(t==null?void 0:t.drives)??[];return e.jsx("div",{className:"modal-backdrop",onClick:r,children:e.jsxs("div",{className:"fpk-modal",role:"dialog","aria-modal":"true",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"fpk-modal-head",children:[e.jsx(Us,{className:"modal-head-icon"}),e.jsx("h2",{children:i("openFolder")}),e.jsx("span",{className:"toolcall-spacer"}),e.jsx("button",{type:"button",className:"toolcall-zoom-close",title:i("cancel"),onClick:r,children:e.jsx(qt,{})})]}),e.jsxs("div",{className:"fpk-modal-bar",children:[e.jsx("button",{type:"button",className:"fpk-nav-btn",title:i("home"),onClick:()=>n(void 0),children:e.jsx(Yc,{})}),e.jsx("button",{type:"button",className:"fpk-nav-btn",title:i("parentFolder"),disabled:!(t!=null&&t.parent),onClick:()=>(t==null?void 0:t.parent)&&n(t.parent),children:e.jsx(td,{})}),e.jsx("code",{className:"fpk-path",title:c,children:c||"…"})]}),u.length>0&&e.jsx("div",{className:"fpk-drives",children:u.map(f=>e.jsxs("button",{type:"button",className:`fpk-drive ${c.toUpperCase().startsWith(f.toUpperCase())?"active":""}`,onClick:()=>n(f),children:[e.jsx(Xc,{}),e.jsx("span",{children:f.replace(/\\$/,"")})]},f))}),e.jsxs("div",{className:"fpk-list",children:[t&&t.dirs.length===0&&e.jsx("div",{className:"panel-empty",children:i("noSubfolders")}),t==null?void 0:t.dirs.map(f=>e.jsxs("button",{type:"button",className:"fpk-item",onClick:()=>n(p(f)),children:[e.jsx(Us,{className:"fpk-item-icon"}),e.jsx("span",{className:"fpk-item-name",children:f}),e.jsx(_t,{className:"fpk-item-go"})]},f)),(t==null?void 0:t.truncated)&&e.jsx("div",{className:"panel-empty",children:i("listTruncated")})]}),e.jsxs("form",{className:"fpk-modal-foot",onSubmit:f=>{f.preventDefault();const k=a.trim()||c;k&&s(k)},children:[e.jsx("input",{className:"lp-inline-input",placeholder:i("openFolderPlaceholder"),value:a,onChange:f=>o(f.target.value)}),e.jsxs("button",{type:"submit",className:"fpk-open-btn",disabled:!c&&!a.trim(),children:[e.jsx(ss,{}),e.jsx("span",{children:a.trim()?i("openTypedPath"):i("openThisFolder")})]})]})]})})}function Ur(t,n){const s=new Date(t),r=new Date;if(s.toDateString()===r.toDateString())return`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`;const a=new Date(r.getFullYear(),r.getMonth(),r.getDate()-1);return s.toDateString()===a.toDateString()?n:`${s.getMonth()+1}/${s.getDate()}`}const $p=d.memo(function({incidentState:n,onOpenSettings:s,onNewChat:r,ready:i,status:a,cwd:o,sessionFile:c,conversations:l,sessions:p,projects:u,dirBrowse:f,activeConversationId:k,send:j,active:I}){const{t:E,locale:$}=Qn(),N=c,R=o,[y,L]=d.useState(null),[b,F]=d.useState(null),[B,ie]=d.useState(""),[Q,q]=d.useState(null),[ke,Re]=d.useState(!1);d.useEffect(()=>Re(!1),[o]),d.useEffect(()=>{if(!Q)return;const z=W=>{const ge=W.target instanceof Element?W.target.closest(".lp-menu-zone"):null;(ge==null?void 0:ge.dataset.menuKey)!==Q&&q(null)},Z=W=>{W.key==="Escape"&&q(null)};return document.addEventListener("pointerdown",z),document.addEventListener("keydown",Z),()=>{document.removeEventListener("pointerdown",z),document.removeEventListener("keydown",Z)}},[Q]);const[O,_e]=d.useState(!1),[M,V]=d.useState(null);d.useEffect(()=>{M&&o===M&&V(null)},[o,M]),d.useEffect(()=>{if(!M)return;const z=setTimeout(()=>V(null),15e3);return()=>clearTimeout(z)},[M]),d.useEffect(()=>{!I||!i||a!=="open"||o&&(j({type:"list_sessions"}),j({type:"list_projects"}))},[I,i,a,o,j]);const ve=z=>{var W;const Z=z.name||((W=ye.get(z.path))==null?void 0:W.title)||cs(z.firstMessage);return fr(Z.length>0?Z:E("emptyChat"),z.firstMessage,z.name,z.messageCount,$)},ye=new Map;for(const z of l)z.sessionFile&&ye.set(z.sessionFile,z);const oe=new Set(p.map(z=>z.path)),Fe=l.filter(z=>!z.sessionFile||!oe.has(z.sessionFile)),U=z=>{const Z=z.replace(/\\/g,"/").replace(/\/$/,"")||"/";return Z==="/"||/^[A-Za-z]:$/.test(Z)?E("rootDir"):/^(?:\/Users\/[^/]+|\/home\/[^/]+|[A-Za-z]:\/Users\/[^/]+)$/.test(Z)?"~":Z.split("/").at(-1)||Z},fe=z=>Math.max(z.lastUsed,z.lastConversationAt??0,z.path===R&&p.length?Math.max(...p.map(Z=>Z.modified)):0),ce=[...u].sort((z,Z)=>+(Z.path===R)-+(z.path===R)||fe(Z)-fe(z)||z.path.localeCompare(Z.path)),ae=e.jsxs("div",{className:"panel-sessions",children:[e.jsx("div",{className:"panel-section-title",children:E("historySessions")}),e.jsxs("div",{className:"sessions-scroll",children:[p.length===0&&Fe.length===0&&e.jsx("div",{className:"panel-empty",children:E("noHistory")}),Fe.map(z=>{var W;const Z=k===z.id;return e.jsxs("button",{type:"button",className:`session-item ${Z?"active":""}`,title:`${z.title}
|
|
200
|
-
${Z?E("current"):E("messageCount",{n:z.messageCount})}`,onClick:()=>{Z||j({type:"switch_conversation",id:z.id})},children:[e.jsx("span",{className:`session-dot${z.id===k&&n==="stopped"?" interrupted":z.id===k&&n==="reminding"||z.isStreaming?" streaming":""}`,title:z.isStreaming?E("streaming"):void 0}),e.jsxs("span",{className:"session-info",children:[e.jsx("span",{className:"session-title",children:fr(z.title,void 0,void 0,z.messageCount,$)}),!!z.branchPoints&&e.jsx("small",{children:E("treeBranches",{n:z.branchPoints})}),z.parentSessionPath&&e.jsx("small",{title:z.parentSessionPath,children:E("treeDerived",{name:((W=p.find(ge=>ge.path===z.parentSessionPath))==null?void 0:W.name)||z.parentSessionPath.split(/[\\/]/).pop()||""})})]}),e.jsx("span",{className:"session-time",children:Ur(z.createdAt??Date.now(),E("yesterday"))})]},z.id)}),p.map(z=>{var ge;const Z=ye.get(z.path),W=Z?k===Z.id:N===z.path;return b===z.path?e.jsxs("form",{className:"lp-inline-form",onSubmit:Ie=>{Ie.preventDefault(),j({type:"rename_session",path:z.path,name:B.trim()}),F(null)},children:[e.jsx("input",{autoFocus:!0,className:"lp-inline-input",placeholder:E("renameSessionPlaceholder"),value:B,onChange:Ie=>ie(Ie.target.value),onKeyDown:Ie=>{Ie.key==="Escape"&&F(null)}}),e.jsx("button",{type:"submit",className:"lp-inline-ok",title:E("confirm"),children:e.jsx(ss,{})}),e.jsx("button",{type:"button",className:"lp-inline-cancel",title:E("cancel"),onClick:()=>F(null),children:e.jsx(qt,{})})]},z.path):e.jsxs("div",{className:"lp-row",onMouseLeave:()=>L(Ie=>Ie===`sess:${z.path}`?null:Ie),children:[e.jsxs("button",{type:"button",className:`session-item ${W?"active":""}`,title:`${z.path}
|
|
201
|
-
${W?E("current"):E("messageCount",{n:z.messageCount})}`,onClick:()=>{W||j(Z?{type:"switch_conversation",id:Z.id}:{type:"switch_session",path:z.path})},children:[e.jsx("span",{className:`session-dot${(Z==null?void 0:Z.id)===k&&n==="stopped"?" interrupted":(Z==null?void 0:Z.id)===k&&n==="reminding"||Z!=null&&Z.isStreaming?" streaming":""}`,title:Z!=null&&Z.isStreaming?E("streaming"):void 0}),e.jsxs("span",{className:"session-info",children:[e.jsx("span",{className:"session-title",children:ve(z)}),!!((Z==null?void 0:Z.branchPoints)??z.branchPoints)&&e.jsx("small",{children:E("treeBranches",{n:(Z==null?void 0:Z.branchPoints)??z.branchPoints??0})}),z.parentSessionPath&&e.jsx("small",{title:z.parentSessionPath,children:E("treeDerived",{name:((ge=p.find(Ie=>Ie.path===z.parentSessionPath))==null?void 0:ge.name)||z.parentSessionPath.split(/[\\/]/).pop()||""})})]}),z.source==="tui"&&e.jsx("span",{className:"session-src",title:E("tuiTip"),children:"TUI"}),e.jsx("span",{className:"session-time",children:Ur(z.modified,E("yesterday"))})]}),e.jsxs("div",{className:`lp-menu-zone${Q===`sess:${z.path}`?" is-open":""}`,"data-menu-key":`sess:${z.path}`,children:[e.jsx("button",{type:"button",className:"lp-menu-trigger","aria-label":`${ve(z)} · ${E("more")}`,"aria-haspopup":"menu","aria-expanded":Q===`sess:${z.path}`,onClick:()=>q(Ie=>Ie===`sess:${z.path}`?null:`sess:${z.path}`),children:e.jsx(Ss,{})}),Q===`sess:${z.path}`&&e.jsxs("div",{className:"lp-menu-popover",role:"menu",children:[e.jsx("button",{type:"button",role:"menuitem",onClick:()=>{ie(z.name??ve(z)),F(z.path),q(null)},children:E("renameSession")}),e.jsx("button",{type:"button",role:"menuitem",className:y===`sess:${z.path}`?"danger":"",onClick:()=>{y===`sess:${z.path}`?(j({type:"delete_session",path:z.path}),L(null),q(null)):L(`sess:${z.path}`)},children:y===`sess:${z.path}`?E("deleteSessionConfirm"):E("deleteSession")})]})]})]},z.path)})]})]});return e.jsxs("aside",{className:"panel panel-left",children:[e.jsxs("div",{className:"sidebar-brand",children:[e.jsx("span",{className:"sidebar-logo",children:e.jsx("img",{src:"/icon/1a-mark.svg",alt:""})}),e.jsx("strong",{children:"pi-harness"})]}),e.jsx("div",{className:"sidebar-new",children:e.jsxs("button",{type:"button",onClick:r,children:[e.jsxs("span",{children:[e.jsx(gs,{}),E("newChat")]}),e.jsxs("kbd",{children:[navigator.platform.includes("Mac")?"⌘":"Ctrl+","N"]})]})}),e.jsxs("div",{className:"panel-projects",children:[e.jsxs("div",{className:"panel-section-title",children:[e.jsx("span",{children:E("workspaceProjects")}),e.jsx("button",{type:"button",className:"lp-add-project",title:E("openFolder"),"aria-label":E("openFolder"),onClick:()=>_e(!0),children:e.jsx(gs,{})})]}),e.jsx("div",{className:"projects-scroll",children:ce.map(z=>{const Z=R===z.path,W=!Z&&M===z.path,ge=Z&&!ke,Ie=Z?Math.max(z.conversationCount??0,p.length+Fe.length):z.conversationCount??0;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>L(Ae=>Ae===`proj:${z.path}`?null:Ae),children:[e.jsxs("button",{type:"button",className:`project-item ${Z?"active":""} ${W?"pending":""}`,title:z.path,onClick:()=>{Z?Re(Ae=>!Ae):(Re(!1),V(z.path),j({type:"set_cwd",path:z.path,source:"ui"}))},children:[ge?e.jsx(nn,{className:"project-chevron"}):e.jsx(_t,{className:"project-chevron"}),e.jsxs("span",{className:"project-info",children:[e.jsx("span",{className:"project-name",children:U(z.path)}),e.jsxs("span",{className:"project-count",children:["· ",Ie]})]}),W?e.jsx("span",{className:"thinking-spinner project-spinner","aria-hidden":"true"}):e.jsx("span",{className:"project-time",children:Ur(fe(z),E("yesterday"))})]}),e.jsxs("div",{className:`lp-menu-zone${Q===`proj:${z.path}`?" is-open":""}`,"data-menu-key":`proj:${z.path}`,children:[e.jsx("button",{type:"button",className:"lp-menu-trigger","aria-label":`${U(z.path)} · ${E("more")}`,"aria-haspopup":"menu","aria-expanded":Q===`proj:${z.path}`,onClick:()=>q(Ae=>Ae===`proj:${z.path}`?null:`proj:${z.path}`),children:e.jsx(Ss,{})}),Q===`proj:${z.path}`&&e.jsx("div",{className:"lp-menu-popover",role:"menu",children:e.jsx("button",{type:"button",role:"menuitem",className:y===`proj:${z.path}`?"danger":"",onClick:()=>{y===`proj:${z.path}`?(j({type:"remove_project",path:z.path}),L(null),q(null)):L(`proj:${z.path}`)},children:y===`proj:${z.path}`?E("deleteProjectConfirm"):E("deleteProject")})})]}),ge&&ae]},z.path)})})]}),!u.some(z=>z.path===R)&&ae,e.jsxs("div",{className:"sidebar-footer",children:[e.jsxs("span",{className:"sidebar-connection",children:[e.jsx("i",{className:i?"ok":"busy"}),E(i?"connected":"connecting")]}),e.jsx("span",{id:"sidebar-settings-slot",children:e.jsxs("button",{type:"button",onClick:s,children:[e.jsx(_s,{"aria-hidden":"true"})," ",E("settings")]})})]}),O&&e.jsx(Dp,{dirBrowse:f,onBrowse:z=>j({type:"browse_dirs",path:z}),onPick:z=>{V(z),j({type:"set_cwd",path:z,source:"ui"}),_e(!1)},onClose:()=>_e(!1)})]})}),Fp=200*1024*1024,Op=/windows/i.test(navigator.userAgent),_p=/[<>:"/\\|?*\u0000-\u001f]/g,Hp=/[. ]+$/,Bp=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Up(t){const n=t.replace(_p,"_").replace(Hp,"");return n?Bp.test(n)?`_${n}`:n:"_"}function Da(t,n=!0){const s=new URLSearchParams({clientId:fn(),path:t,...n?{download:"1"}:{}});return Sn(`/api/file?${s}`)}async function wl(t,n){const s=Op?Up(n):n;try{const r=await fetch(Da(t));if(!r.ok)return{ok:!1,cancelled:!1,error:await r.text().catch(()=>"")||(r.status===404?"文件不存在":`HTTP ${r.status}`)};if(Number(r.headers.get("content-length")??"0")>Fp)return window.location.assign(Da(t)),{ok:!0};const a=await r.blob();return window.showSaveFilePicker&&window.isSecureContext?Wp(a,s):oi(a,s)}catch(r){return{ok:!1,cancelled:!1,error:r instanceof Error?r.message:String(r)}}}async function Wp(t,n){let s;const r=window.showSaveFilePicker;if(!r)return oi(t,n);try{s=await r({suggestedName:n})}catch(i){return i instanceof DOMException&&i.name==="AbortError"?{ok:!1,cancelled:!0}:oi(t,n)}try{const i=await s.createWritable();return await i.write(t),await i.close(),{ok:!0}}catch(i){return{ok:!1,cancelled:!1,error:i instanceof Error?i.message:String(i)}}}function oi(t,n){const s=URL.createObjectURL(t),r=document.createElement("a");return r.href=s,r.download=n,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e4),{ok:!0}}function qp(t){const n=new Set;for(const s of t)for(const r of s.content){if(r.type!=="toolCall"||r.name!=="bash"||typeof r.argumentsText!="string")continue;let i;try{i=JSON.parse(r.argumentsText??"{}").command??""}catch{continue}for(const a of i.matchAll(/(?:^|[\s'"=/])(\.[A-Za-z][\w.-]*)(?=\/|[\s'";&|]|$)/g))n.add(a[1])}return n}function zp(t,n){var i;const s=n.toolCallIds?new Set(n.toolCallIds):null,r=(i=t.plan)==null?void 0:i.items.filter(a=>a.startedAt&&a.startedAt>(n.startedAt??1/0)).map(a=>a.startedAt).sort((a,o)=>a-o)[0];return t.steps.flatMap(a=>a.artifacts.filter(o=>s?s.has(o.toolCallId):!!n.startedAt&&a.startedAt>=n.startedAt&&a.startedAt<(n.endedAt??r??1/0)).map(o=>({messageId:a.messageId,artifact:o})))}function Vp({task:t,silence:n,cwd:s,messages:r,onPreview:i,streaming:a,live:o}){var Re,O,_e;const c=nt(),l=Ms(o?[...r,o]:r,a??(t==null?void 0:t.status)==="running").current,p=(l==null?void 0:l.state)==="stopped",u=(l==null?void 0:l.state)==="reminding",[f,k]=d.useState(0);d.useEffect(()=>{var ye;if(!u)return;const M=((ye=l==null?void 0:l.reminders.at(-1))==null?void 0:ye.timestamp)??Date.now(),V=()=>k(Math.max(0,Math.floor((Date.now()-M)/1e3)));V();const ve=window.setInterval(V,1e3);return()=>window.clearInterval(ve)},[u,l==null?void 0:l.incidentId]);const j=Ko(r,new Map),[I,E]=d.useState(!0),[$,N]=d.useState(!0),[R,y]=d.useState(null),L=d.useRef(null),b=((Re=t==null?void 0:t.plan)==null?void 0:Re.items.filter(M=>M.status!=="removed"))??[],F=(O=b.find(M=>M.status==="running"))==null?void 0:O.id;d.useEffect(()=>{if(!I||!F)return;const M=L.current,V=M==null?void 0:M.querySelector(".task-plan-step.running");if(!M||!V)return;const ve=V.getBoundingClientRect().top-M.getBoundingClientRect().top+M.scrollTop;M.scrollTop=Math.max(0,ve-M.clientHeight/3)},[F,t==null?void 0:t.id,I]);const B=M=>{const V=M.startsWith(`${s}/`)?M.slice(s.length+1):M;i(V,V.replace(/\\/g,"/").split("/").at(-1)??V)},ie=mo(t,r,s),Q=r.find(M=>{var V,ve;return M.role==="toolResult"&&((V=M.planSnapshot)==null?void 0:V.planId)===((ve=t==null?void 0:t.plan)==null?void 0:ve.origin)}),q=Q&&r.find(M=>M.role==="assistant"&&M.content.some(V=>V.type==="toolCall"&&V.id===Q.toolCallId)),ke=p?c("toolRecoveryInterrupted"):u?`${c("working")} · ${c("waitSeconds",{n:f})}`:(t==null?void 0:t.status)==="failed"?c("taskFailed"):(t==null?void 0:t.status)==="cancelled"?c("taskCancelled"):(_e=t==null?void 0:t.plan)!=null&&_e.awaitingConfirmation?c("planPrevious"):(t==null?void 0:t.status)==="waiting"?c("taskPaused"):n&&t&&n.conversationId===t.conversationId?c((j==null?void 0:j.label)??"working"):"";return e.jsx("div",{className:`task-progress task-sections ${p?"interrupted":u?"reminding":(t==null?void 0:t.status)??"empty"}`,tabIndex:-1,"aria-label":c("taskProgress"),children:e.jsxs("div",{className:"task-sections-scroll",ref:L,children:[e.jsxs("section",{className:"task-section",children:[e.jsxs("button",{type:"button",className:"task-section-heading","aria-expanded":I,onClick:()=>E(M=>!M),children:[e.jsx(_t,{className:I?"open":""}),c("taskProgressHeading")]}),I&&e.jsxs("div",{className:"task-section-content",children:[ke&&(!p||!!(t!=null&&t.plan))&&e.jsxs("p",{className:`task-progress-status task-progress-source ${p?"interrupted":u?"reminding":t==null?void 0:t.status}`,role:"status",children:[u&&e.jsx("i",{"aria-hidden":"true"}),ke]}),t!=null&&t.plan&&b.length?e.jsxs(e.Fragment,{children:[t.plan.completionCriteria&&e.jsxs("p",{className:"task-outline-criteria",children:[c("taskCompletionCriteria"),":",t.plan.completionCriteria]}),e.jsx("div",{className:"task-plan-list",children:b.map(M=>{var V;return e.jsxs("div",{className:`task-plan-step ${p&&M.status==="running"?"interrupted":M.status}${R===M.id?" expanded":""}`,children:[e.jsxs("button",{type:"button",className:"task-plan-step-head","aria-expanded":R===M.id,onClick:()=>y(ve=>ve===M.id?null:M.id),children:[e.jsx("span",{className:"task-plan-mark","aria-hidden":"true",children:p&&M.status==="running"?"×":M.status==="done"?"✓":M.status==="running"?"●":""}),e.jsx("span",{className:"task-plan-step-title",children:M.title}),e.jsx(_t,{className:R===M.id?"open":""})]}),R===M.id&&e.jsxs("div",{className:"task-plan-step-detail",children:[M.detail&&e.jsx("p",{children:M.detail}),!!((V=M.blockedBy)!=null&&V.length)&&e.jsx("p",{children:c("taskBlockedBy",{steps:M.blockedBy.join(", ")})}),zp(t,M).map(({artifact:ve,messageId:ye})=>e.jsxs("div",{className:"task-artifact-row",children:[ve.path&&e.jsx("button",{type:"button",title:ve.path,onClick:()=>B(ve.path),children:ve.path}),e.jsx("button",{type:"button",title:c("taskJumpToChat"),onClick:()=>window.dispatchEvent(new CustomEvent("pi:jump-tool",{detail:{messageId:ye,toolCallId:ve.toolCallId}})),children:ve.path?"↗":ve.label})]},ve.toolCallId)),e.jsxs("button",{type:"button",className:"task-step-jump",onClick:()=>window.dispatchEvent(new CustomEvent("pi:jump-message",{detail:{messageId:(q==null?void 0:q.id)??t.sourceMessageId}})),children:[c("taskJumpToChat")," →"]})]})]},M.id)})})]}):p?e.jsxs("div",{className:"task-interrupted-hint",children:[e.jsxs("strong",{children:["● ",c("taskInterruptedTitle")]}),e.jsx("p",{children:c("taskInterruptedHint")})]}):u?null:e.jsxs("div",{className:"task-section-empty",children:[e.jsxs("div",{className:"task-empty-circles","aria-hidden":"true",children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),e.jsx("p",{children:c("taskProgressEmpty")})]})]})]}),e.jsxs("section",{className:"task-section",children:[e.jsxs("button",{type:"button",className:"task-section-heading","aria-expanded":$,onClick:()=>N(M=>!M),children:[e.jsx(_t,{className:$?"open":""}),c("taskOutputsHeading")]}),$&&e.jsx("div",{className:"task-section-content",children:ie.length?e.jsx("div",{className:"task-file-results",children:ie.map(M=>e.jsxs("div",{className:"task-file-result",children:[e.jsx(Ws,{"aria-hidden":"true"}),e.jsxs("button",{type:"button",title:M.path,onClick:()=>B(M.path),children:[e.jsx("span",{children:M.path.split("/").at(-1)}),M.path.includes("/")&&e.jsx("small",{children:M.path})]}),M.counted&&e.jsxs("span",{className:"task-file-counts",children:[e.jsxs("span",{children:["+",M.added]})," ",e.jsxs("span",{children:["−",M.removed]})]})]},M.path))}):e.jsxs("div",{className:"task-section-empty",children:[e.jsx(Ws,{className:"task-empty-file","aria-hidden":"true"}),e.jsx("p",{children:c("taskOutputsEmpty")})]})})]})]})})}const Kp=d.memo(function({active:n,files:s,fileChanged:r,changed:i,notRepo:a,widgets:o,messages:c,streamingMessage:l,isStreaming:p,taskProgress:u,conversationId:f,agentSilence:k,cwd:j,send:I,onAttach:E,onPreview:$,onNotice:N}){const R=nt(),[y,L]=d.useState(null),[b,F]=d.useState({}),[B,ie]=d.useState(new Set),[Q,q]=d.useState(!1),[ke,Re]=d.useState(!1);d.useEffect(()=>Re(!1),[j,u==null?void 0:u.id]);const O=(u==null?void 0:u.status)==="running"&&!a&&i.length>0&&!ke,[_e,M]=d.useState(!0),[V,ve]=d.useState(!1),ye=d.useRef(null);d.useEffect(()=>{if(!V)return;const A=_=>{var Se;(Se=ye.current)!=null&&Se.contains(_.target)||ve(!1)},xe=_=>{_.key==="Escape"&&ve(!1)};return document.addEventListener("pointerdown",A,!0),document.addEventListener("keydown",xe),()=>{document.removeEventListener("pointerdown",A,!0),document.removeEventListener("keydown",xe)}},[V]);const oe=l?[...c,l]:c,Fe=qp(oe),U=d.useRef(j),fe=d.useRef(null),ce=d.useRef([]),ae=d.useRef(null),z=d.useRef(B);z.current=B;const Z=d.useCallback(()=>{if(!n||ae.current!==null)return;const A=ce.current.shift();A!==void 0&&(ae.current=A,I({type:"list_files",path:A||void 0})||(ae.current=null))},[n,I]),W=d.useCallback(A=>{ae.current!==A&&!ce.current.includes(A)&&ce.current.push(A),Z()},[Z]);d.useEffect(()=>{if(U.current!==j&&(U.current=j,fe.current=s,ce.current=[],ae.current=null,F({}),ie(new Set),q(!1)),!n||!j)return;W("");const A=setInterval(()=>{if(document.visibilityState!=="hidden"){ae.current=null,W("");for(const xe of z.current)W(xe)}},1e4);return()=>clearInterval(A)},[n,j,W]),d.useEffect(()=>{!s||s===fe.current||U.current!==j||(fe.current=s,F(A=>({...A,[s.path]:s})),ae.current===s.path&&(ae.current=null),Z())},[s,j,Z]),d.useEffect(()=>{n&&r&&W(r.path)},[n,r,W]),d.useEffect(()=>{(a||!i.length)&&q(!1)},[a,i]);const ge=A=>{ie(xe=>{const _=new Set(xe);return _.has(A)?_.delete(A):_.add(A),_}),B.has(A)||W(A)},Ie=A=>{var Se;const xe=(((Se=b[A])==null?void 0:Se.entries)??[]).map(J=>({entry:J,virtual:!1})),_=new Set(xe.map(({entry:J})=>J.name));for(const J of i){if(J.x!=="D"&&J.y!=="D")continue;const De=A?J.path.startsWith(`${A}/`)?J.path.slice(A.length+1):"":J.path;if(!De)continue;const G=De.split("/")[0];_.has(G)||(_.add(G),xe.push({entry:{name:G,path:A?`${A}/${G}`:G,type:De.includes("/")?"dir":"file"},virtual:!0}))}return xe.sort((J,De)=>J.entry.type===De.entry.type?J.entry.name.localeCompare(De.entry.name):J.entry.type==="dir"?-1:1)},Ae=(A,xe,_)=>{const Se=A.type==="dir",J=B.has(A.path),De=i.filter(Ee=>Ee.path===A.path||Se&&Ee.path.startsWith(`${A.path}/`)).length,G=Se?void 0:i.find(Ee=>Ee.path===A.path),Oe=G?G.x==="D"||G.y==="D"?"D":G.x==="A"||G.y==="A"||G.x==="?"?"A":"M":null;if(O&&xe===0&&Se&&De===0)return null;const Ne=Se&&A.name.startsWith(".")&&Fe.has(A.name);return(!_e&&A.name.startsWith(".")||Q&&!De)&&!Ne?null:e.jsxs("div",{role:"treeitem","aria-expanded":Se?J:void 0,children:[e.jsxs("div",{className:`file-item ${Se?"dir":"file"}`,style:{paddingLeft:6+xe*16},children:[e.jsxs("button",{type:"button","data-tree-node":A.path,className:Se?"file-dir-main":"file-name",title:A.path,disabled:_&&!Se,onClick:()=>Se?_?ie(Ee=>{const et=new Set(Ee);return et.has(A.path)?et.delete(A.path):et.add(A.path),et}):ge(A.path):$(A.path,A.name),children:[e.jsx("span",{className:`tree-caret ${J?"open":""}`,children:Se&&e.jsx(_t,{})}),e.jsx("span",{className:Se?"file-name":"file-name-text",children:A.name})]}),Se&&De>0&&e.jsx("span",{className:"tree-modified-count",title:R("workspaceChanges",{n:De}),children:De}),Oe&&e.jsx("span",{className:`tree-change-badge ${Oe.toLowerCase()}`,title:Oe==="A"?"Added":Oe==="D"?"Deleted":"Modified",children:Oe}),!Se&&!_&&e.jsx("button",{type:"button",className:"file-attach download",title:R("downloadFile"),onClick:()=>void wl(A.path,A.name).then(Ee=>{!Ee.ok&&!Ee.cancelled&&N("error",R("downloadFailed",{error:Ee.error}))}),children:e.jsx(yi,{})}),!Se&&!_&&e.jsx("button",{type:"button",className:"file-attach inline",title:R("attachInlineTip"),onClick:()=>E(A.path,A.name,"inline"),children:e.jsx(gs,{})}),!_&&e.jsx("button",{type:"button",className:"file-attach ref",title:R(Se?"linkFolderTip":"referenceTip"),onClick:()=>E(A.path,A.name,"reference",Se),children:e.jsx(lr,{})})]}),Se&&J&&e.jsx("div",{role:"group",children:b[A.path]||_?re(A.path,xe+1):e.jsx("div",{className:"tree-loading",children:R("loading")})})]},A.path)},re=(A,xe)=>{var _;return e.jsxs(e.Fragment,{children:[Ie(A).map(({entry:Se,virtual:J})=>Ae(Se,xe,J)),((_=b[A])==null?void 0:_.truncated)&&e.jsx("div",{className:"panel-empty files-truncated",children:R("filesTruncated")})]})},we=Ie("").filter(({entry:A})=>A.type==="dir"&&!i.some(xe=>xe.path===A.path||xe.path.startsWith(`${A.path}/`))&&(_e||!A.name.startsWith("."))).length;return e.jsxs("aside",{className:"panel panel-right has-task-progress",children:[e.jsxs("div",{className:"panel-title",children:[e.jsx("span",{children:R("workspaceFiles")}),!a&&i.length>0&&e.jsx("button",{type:"button",className:"tree-filter","aria-pressed":Q,onClick:()=>q(A=>!A),children:R("changedCount",{n:i.length})}),e.jsxs("div",{className:"tree-controls",ref:ye,children:[e.jsx("button",{type:"button",className:"tree-menu-trigger","aria-label":R("more"),"aria-expanded":V,onClick:()=>ve(A=>!A),children:e.jsx(Ss,{})}),V&&e.jsx("div",{className:"tree-controls-menu",children:e.jsxs("button",{type:"button",className:"tree-hidden-toggle",role:"switch","aria-checked":_e,onClick:()=>M(A=>!A),children:[e.jsx("span",{children:R("showHiddenFiles")}),e.jsx("span",{className:"tree-switch-track"})]})})]})]}),e.jsxs("div",{className:"panel-body",role:"tree","aria-label":R("workspaceFiles"),onKeyDown:A=>{var J,De;const xe=A.target.closest("button[data-tree-node]");if(!xe)return;const _=xe.dataset.treeNode,Se=xe.classList.contains("file-dir-main");if(A.key==="ArrowRight"&&Se&&!B.has(_)&&(A.preventDefault(),ge(_)),A.key==="ArrowLeft")if(A.preventDefault(),Se&&B.has(_))ge(_);else{const G=_.slice(0,_.lastIndexOf("/"));(J=Array.from(A.currentTarget.querySelectorAll("button[data-tree-node]")).find(Oe=>Oe.dataset.treeNode===G))==null||J.focus()}if(A.key==="ArrowDown"||A.key==="ArrowUp"){A.preventDefault();const G=Array.from(A.currentTarget.querySelectorAll("button[data-tree-node]"));(De=G[G.indexOf(xe)+(A.key==="ArrowDown"?1:-1)])==null||De.focus()}},children:[Q&&i.length===0?e.jsx("div",{className:"panel-empty",children:R("noChangedFiles")}):b[""]?re("",0):e.jsx("div",{className:"panel-empty",children:R("loading")}),O&&!Q&&we>0&&e.jsx("button",{type:"button",className:"tree-other-directories",onClick:()=>Re(!0),children:R("otherDirectories",{n:we})})]}),e.jsx("div",{className:"panel-lower",children:e.jsx(Vp,{task:u,streaming:p,live:l,silence:k??null,cwd:j,messages:c,onPreview:$},f)}),o.filter(A=>A.lines.length>0).length>0&&e.jsx("div",{className:"panel-widgets",children:o.filter(A=>A.lines.length>0).map(A=>e.jsxs("div",{className:"widget",children:[e.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:R("widgetExpand"),onClick:()=>L(A.key),children:[e.jsx("span",{children:A.key}),e.jsx(Vc,{})]}),e.jsx("pre",{className:"widget-lines",children:A.lines.join(`
|
|
202
|
-
`)})]},A.key))}),y&&(()=>{const A=o.find(xe=>xe.key===y);return A?e.jsx("div",{className:"modal-backdrop",onClick:()=>L(null),children:e.jsxs("div",{className:"widget-expand",onClick:xe=>xe.stopPropagation(),children:[e.jsxs("div",{className:"widget-expand-head",children:[e.jsx("span",{className:"widget-expand-title",children:A.key}),e.jsx("button",{type:"button",className:"btn",title:R("close"),onClick:()=>L(null),children:e.jsx(qt,{})})]}),e.jsx("pre",{className:"widget-expand-lines",children:A.lines.join(`
|
|
203
|
-
`)})]})}):null})()]})});function Gp(t,n,s=!1){const r=s==="mixed"?/^([^:\s]+):(\d+):\s*(.*)$/.exec(t):s?/^(?:([^:\s]+):)?(\d+):\s*(.*)$/.exec(t):null;return r?{number:r[2],text:r[1]?`${r[1]}: ${r[3]}`:r[3]}:{number:String(n+1),text:t}}function Vs(t){return/^(?:stderr\b|fatal:|error:|[^:\n]+:\s.*(?:No such file or directory|Permission denied|command not found|not found|cannot access|failed|error))/i.test(t.trim())}function Jp(t,n){if(n||t.length<=8)return t.map((r,i)=>i);const s=new Set;for(let r=0;r<Math.min(5,t.length);r++)s.add(r);for(let r=Math.max(0,t.length-3);r<t.length;r++)s.add(r);for(let r=0;r<t.length;r++)Vs(t[r])&&s.add(r);return[...s].sort((r,i)=>r-i)}function Bs(t,n){var r;const s=(r=/^\/(?:Users|home)\/[^/]+/.exec(n))==null?void 0:r[0];return s?t.replaceAll(s,"~"):t}function Qp(t){try{const n=JSON.parse(t??"{}").command;return typeof n!="string"||!/(?:^|[;&|(\s])(?:grep|rg)\s+(?:-[\w-]*n[\w-]*\s+|--line-number\s+)/.test(n)?"none":/^\s*(?:grep|rg)\b/.test(n)&&!/[;&|]/.test(n)?"standalone":"mixed"}catch{return"none"}}function li(t,n){var s,r;try{const i=JSON.parse(t??"{}"),a=typeof i.cwd=="string"?i.cwd:typeof i.command=="string"?(s=/^\s*cd\s+(?:"([^"$`]+)"|'([^']+)'|([^\s;&|$`]+))\s*&&/.exec(i.command))==null?void 0:s.slice(1).find(Boolean):void 0;if(!a||/[$`*?]/.test(a))return null;const o=(r=/^(\/(?:Users|home)\/[^/]+)/.exec(n))==null?void 0:r[1],c=a.startsWith("~/")&&o?o+a.slice(1):a.startsWith("/")?a:`${n}/${a}`,l=[];for(const u of c.split("/"))u===".."?l.pop():u&&u!=="."&&l.push(u);const p="/"+l.join("/");return p===n.replace(/\/$/,"")?null:o&&(p===o||p.startsWith(o+"/"))?"~"+p.slice(o.length):p}catch{return null}}function gr(t,n){const s=/^\s*cd\s+(?:"([^"$`\\]+)"|'([^']+)'|([^\s;&|$`\\*?(){}<>]+))\s*&&\s*/.exec(t);if(!s||!n.startsWith("/"))return{command:Bs(t,n),directory:null};const r=s.slice(1).find(Boolean);return/[$`*?\\]/.test(r)||(s[1]||s[2])&&r.startsWith("~")||r==="-"||r.startsWith("~")&&!r.startsWith("~/")?{command:Bs(t,n),directory:null}:{command:Bs(t.slice(s[0].length),n),directory:li(JSON.stringify({command:t}),n)}}function bl(t){const n=/^([ MADRCUT?!]{2}) (.+)$/.exec(t);if(!n||!n[1].trim())return null;const s=n[1].trim(),r=s.includes("U")||s==="AA"||s==="DD"?"conflict":s==="??"?"untracked":s.includes("D")?"deleted":s.includes("A")?"added":"modified";return{status:s,path:n[2],kind:r}}function Yp(t,n){if(!Si(t).some(r=>/^git\s+status\b/.test(r))||!n.length)return null;const s=n.map(bl);return s.some(r=>!r)?null:{files:s.length,added:s.filter(r=>r.kind==="added"||r.kind==="untracked").length,modified:s.filter(r=>r.kind==="modified").length,deleted:s.filter(r=>r.kind==="deleted").length,conflicts:s.filter(r=>r.kind==="conflict").length}}function Xp(t){const n=t.split(/\r?\n/,1)[0],s=/\s+2>\s*\/dev\/null\s*$/.exec(n);if(!s)return n;const r=n.slice(0,s.index);return/['"`\\;&|<>$]/.test(r)?n:r}function ci(t){const n=Xp(t).replace(/(?:[~.]?\/|[A-Za-z]:\\)(?:[\w.@-]+[\/\\]){2,}([\w.@-]+)/g,(s,r,i,a)=>`${s.startsWith("/")&&i>0&&/[\w.@-]/.test(a[i-1])?"/":""}…/${r}`);return n.length>80?`${n.slice(0,28)}…${n.slice(-48)}`:n}function Zp(t){return t<100?"<0.1s":`${(t/1e3).toFixed(1)}s`}function di(t,n=!1){const s=/^\s*echo\s+(["'])===\s*(.+?)\s*===\1\s*&&\s*([\s\S]+)$/.exec(t),r=s?s[3]:t,i=Si(r)[0]??r,a=/^sed\s+-n\s+['"]?(\d+),(\d+)p['"]?\s+(['"]?)([^\s'";&|<>$`]+)\3(?:\s+2>\s*\/dev\/null)?\s*$/.exec(i),o=/^(?:cat|head|tail)\s+(?:-n\s+\d+\s+)?(['"]?)([^\s'";&|<>$`]+)\1(?:\s+2>\s*\/dev\/null)?\s*$/.exec(i),c=/^git\s+show\s+[^\s:'"`;$&|<>]+:([^\s'"`;$&|<>]+)(?:\s+2>\s*\/dev\/null)?\s*$/.exec(i),l=(a==null?void 0:a[4])??(o==null?void 0:o[2])??(c==null?void 0:c[1]),p=l==null?void 0:l.split(/[\\/]/).at(-1);return{title:(s==null?void 0:s[2].trim())||(a?`${p} ${a[1]}–${a[2]}${n?" lines":" 行"}`:p)||ci(t),command:r,path:l}}function eh(t,n){const s=[];for(const r of t){const i=s.at(-1);i&&n(i[0])===n(r)?i.push(r):s.push([r])}return s}function jl(t){const n=t.trim();return[...n].length<40&&!/[\n#*]|(?:完成|通过|失败|结论|发现|结果|问题是|已修复)/.test(n)&&/^(?:(?:我|我们)(?:会|将|要)?|接下来|下一步|然后|现在|先|再|继续|让我|I'll|I will|Next,?\s|Let me)/i.test(n)&&/(?:检查|查看|读取|确认|验证|修改|修复|测试|实现|更新|定位|对照|check|read|inspect|test|update|verify)/i.test(n)}function th({message:t,last:n,regenerate:s}){const r=nt(),[i,a]=d.useState(!1),o=t.content.map(c=>c.type==="text"?c.text:"").join(`
|
|
204
|
-
`);return!o.trim()||t.content.some(c=>c.type==="toolCall")||!n&&jl(o)?null:e.jsxs("div",{className:`reply-actions ${n?"last":""}`,children:[e.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(o).then(()=>a(!0)).catch(()=>a(!1))},children:[e.jsx(Ls,{}),r(i?"copied":"copy")]}),s&&e.jsxs("button",{onClick:s,children:[e.jsx(Is,{}),r("changesRegenerate")]}),t.timestamp&&e.jsx("time",{dateTime:new Date(t.timestamp).toISOString(),children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})}function nh(t,n=0,s=new Set){const r=new Map,i=new Map,a=new Map;let o;for(let c=n;c<t.length;c++){const l=t[c];for(const f of l.content)f.type==="toolCall"&&typeof f.id=="string"&&a.set(f.id,l.id);if(s.has(c)&&(o=void 0),l.role==="toolResult")continue;if(!(l.role==="assistant"&&l.content.length>0&&l.content.every(f=>f.type==="toolCall"&&f.name==="bash"))){const f=l.content.at(-1);o=l.role==="assistant"&&(f==null?void 0:f.type)==="toolCall"&&f.name==="bash"?l:void 0;continue}if(!o){o=l;continue}const u=r.get(o.id)??o;r.set(o.id,{...u,content:[...u.content,...l.content]}),i.set(l.id,o.id)}return{projected:r,owners:i,sources:a}}function Pi(t){var s;if(t.role!=="user"||t.content.some(r=>r.type!=="text"))return null;const n=t.content.map(r=>r.type==="text"?r.text:"").join(`
|
|
205
|
-
`);return((s=/^【目标已设定】\n\n([\s\S]+)\n\n请现在开始实现这个目标。$/.exec(n))==null?void 0:s[1].trim())||null}function Ai(t){var s;if(t.role!=="user"||t.content.some(r=>r.type!=="text"))return null;const n=t.content.map(r=>r.type==="text"?r.text:"").join(`
|
|
206
|
-
`);return((s=/^✅ 目标已达成并通过审查(第 \d+ 轮)。\n\n目标:(.+)\n\n[\s\S]+\n\n(目标模式已解除,接下来按你的普通指令响应。)$/.exec(n))==null?void 0:s[1].trim())||null}function sh(t){const n=new Map,s=new Set;let r;for(const i of t){const a=Pi(i),o=a??Ai(i);if(!o){r=void 0;continue}const c=a?"set":"complete";c==="set"&&(r==null?void 0:r.text)===o&&r.kind===c?(r.ids.push(i.id),s.add(i.id)):(r={text:o,kind:c,ids:[i.id]},n.set(i.id,r))}return{groups:n,absorbed:s}}function rh({recovery:t}){const n=nt(),[s,r]=d.useState(!1),[i,a]=d.useState({left:0,top:0,maxHeight:300}),o=d.useRef(null),c=d.useRef(null),l=()=>{var p;r(!1),(p=o.current)==null||p.focus()};return d.useEffect(()=>{t.disabled&&r(!1)},[t.disabled]),d.useLayoutEffect(()=>{if(!s)return;const p=()=>{var k,j;const u=(k=o.current)==null?void 0:k.getBoundingClientRect();if(!u)return;const f=Math.min(300,window.innerHeight-24,((j=c.current)==null?void 0:j.scrollHeight)||100);a({left:Math.max(12,Math.min(u.left,window.innerWidth-272)),top:u.bottom+f+8<=window.innerHeight?u.bottom+6:Math.max(12,u.top-f-6),maxHeight:f})};return p(),window.addEventListener("resize",p),window.addEventListener("scroll",p,!0),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0)}},[s,t.models]),d.useEffect(()=>{var u,f;if(!s)return;(f=((u=c.current)==null?void 0:u.querySelector('[aria-checked="true"], button'))??c.current)==null||f.focus();const p=k=>{var j,I;!((j=c.current)!=null&&j.contains(k.target))&&!((I=o.current)!=null&&I.contains(k.target))&&r(!1)};return document.addEventListener("pointerdown",p),()=>document.removeEventListener("pointerdown",p)},[s,t.models]),e.jsxs(e.Fragment,{children:[e.jsxs("button",{ref:o,type:"button",disabled:t.disabled,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>{s||t.onLoadModels(),r(!s)},onKeyDown:p=>{(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),t.onLoadModels(),r(!0))},children:[n("toolRecoverySwitch")," ",e.jsx(nn,{className:s?"up":""})]}),s&&mn.createPortal(e.jsx("div",{ref:c,className:"tool-model-menu dd-menu",role:"menu","aria-label":n("toolRecoverySwitch"),tabIndex:-1,style:i,onKeyDown:p=>{var u,f;if(p.key==="Escape"&&(p.preventDefault(),l()),p.key==="Tab"&&r(!1),["ArrowDown","ArrowUp","Home","End"].includes(p.key)){p.preventDefault();const k=Array.from(((u=c.current)==null?void 0:u.querySelectorAll("button"))??[]),j=k.indexOf(document.activeElement),I=p.key==="Home"?0:p.key==="End"?k.length-1:(j+(p.key==="ArrowDown"?1:-1)+k.length)%k.length;(f=k[I])==null||f.focus()}},children:t.models.length?t.models.map(p=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":p.id===t.currentModelId,className:`dd-item ${p.id===t.currentModelId?"active":""}`,onClick:()=>{l(),t.retry(p.id)},children:[e.jsx("span",{className:"dd-model-name",children:p.name}),e.jsx("span",{className:"dd-model-provider",children:p.provider})]},p.id)):e.jsx("span",{className:"tool-model-empty",children:n("loading")})}),document.body)]})}function ih({incident:t,model:n,recovery:s}){const r=nt(),[i,a]=d.useState(!1);return e.jsxs("div",{className:"unexecuted-tool",role:"status","data-incident-id":t.incidentId,children:[e.jsxs("header",{children:[e.jsxs("strong",{children:["✗ ",r("toolUnexecutedTitle")]}),e.jsx("span",{children:r("toolUnexecutedAttempts",{n:t.reminders.length})})]}),e.jsxs("div",{className:"tool-recovery-body",children:[e.jsx("p",{children:r(t.reminders.length?"toolUnexecutedHint":"unexecutedToolHint",{model:n})}),e.jsxs("div",{className:"tool-recovery-actions",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"tool-recovery-primary",disabled:s.disabled,onClick:()=>s.retry(),children:r("toolRecoveryResend")}),e.jsx(rh,{recovery:s})]}),e.jsx("button",{type:"button",className:"tool-recovery-raw","aria-expanded":i,onClick:()=>a(o=>!o),children:r(i?"toolRecoveryRawHide":"toolRecoveryRaw")})]}),i&&e.jsx("div",{className:"tool-recovery-outputs",children:t.outputs.map(({message:o,raw:c,attempt:l})=>e.jsxs("section",{children:[e.jsxs("div",{children:[r(l?"toolRecoveryAfterReminder":"toolRecoveryFirst"),o.timestamp?` · ${new Date(o.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:"",l>0&&` · ${r("toolRecoveryNoCall")}`]}),e.jsx("pre",{children:c})]},o.id))})]})]})}function ah({text:t}){const n=nt(),[s,r]=d.useState(!1);return e.jsxs("div",{className:`thinking leaked ${s?"open":""}`,children:[e.jsxs("button",{type:"button",className:"thinking-toggle","aria-expanded":s,title:n("leakedThinkingHint"),onClick:()=>r(!s),children:[s?e.jsx(nn,{}):e.jsx(_t,{}),e.jsx(Eo,{className:"thinking-icon"}),e.jsx("span",{className:"thinking-label",children:n("leakedThinking")})]}),s&&e.jsx("div",{className:"thinking-body",children:t})]})}const oh=/^\s{0,3}(`{3,}|~{3,})/,lh=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Wr(t){return t.trim()===""}function $a(t){const n=oh.exec(t);return n?n[1]:null}function ch(t){const n=t.split(`
|
|
207
|
-
`),s=[];let r=[],i=null;for(let a=0;a<n.length;a++){const o=n[a];if(i!==null){const l=$a(o);l&&l[0]===i[0]&&l.length>=i.length&&(i=null),r.push(o);continue}const c=$a(o);if(c&&!Wr(o)){i=c,r.push(o);continue}if(Wr(o)){let l=a;for(;l<n.length&&Wr(n[l]);)l++;if(!(l<n.length&&lh.test(n[l]))&&r.length>0){s.push(r.join(`
|
|
208
|
-
`)),r=[];continue}r.push(o);continue}r.push(o)}return{frozen:s,active:r.join(`
|
|
209
|
-
`),inFence:i!==null}}const dh=d.memo(function({text:n}){return e.jsx(jr,{remarkPlugins:ri,rehypePlugins:Zo,components:{pre:tl},children:n})}),Fa=200;function uh({text:t,inFence:n}){const[s,r]=d.useState(t),i=d.useRef(0),a=d.useRef(null);return d.useEffect(()=>{if(n)return;const o=Date.now()-i.current,c=()=>{i.current=Date.now(),r(t)};if(o>=Fa){c();return}return a.current=setTimeout(c,Fa-o),()=>{a.current&&clearTimeout(a.current)}},[t,n]),n?e.jsx("div",{className:"codeblock",children:e.jsx("pre",{children:e.jsx("code",{children:t})})}):e.jsx(el,{text:s})}const ph=d.memo(function({text:n}){const{frozen:s,active:r,inFence:i}=d.useMemo(()=>ch(n),[n]);return e.jsxs("div",{className:"md",children:[s.map((a,o)=>e.jsx(dh,{text:a},o)),r.length>0&&e.jsx(uh,{text:r,inFence:i},s.length)]})});function hh(t){if(!t)return"";try{const n=JSON.parse(t);if(typeof n=="string")return n;if(typeof(n==null?void 0:n.code)=="string")return n.code}catch{}return t}function mh(t){const n=/^\s*\/\/\s*@options:\s*(\{[^\n]*\})/.exec(t);if(!n)return{};try{const s=JSON.parse(n[1]);return Object.fromEntries(["max_output_tokens","timeout_ms"].filter(r=>typeof s[r]=="number"&&Number.isFinite(s[r])&&s[r]>=0).map(r=>[r,s[r]]))}catch{return{}}}function fh({block:t,view:n,wrap:s=!0}){var V,ve,ye,oe,Fe,U,fe,ce,ae,z,Z;const r=nt(),i=d.useContext(Gs),[a,o]=d.useState(s),[c,l]=d.useState("calls"),[p,u]=d.useState(!1),[f,k]=d.useState(""),[j,I]=d.useState(!1),E=((V=n.result)==null?void 0:V.codemode)??n.codemode,$=(E==null?void 0:E.calls)??((ye=((ve=n.result)==null?void 0:ve.nestedCalls)??n.nestedCalls)==null?void 0:ye.calls.map(W=>({...W,args:W.argumentsText??"",status:W.status==="unfinished"?"running":W.status,cost:void 0})))??[],N=(E==null?void 0:E.totalCalls)??$.length,R=!!n.result||!!n.status&&!n.status.running,y=!R&&n.streaming,L=((oe=n.result)==null?void 0:oe.isError)??((Fe=n.status)==null?void 0:Fe.isError),b=L?"error":R?"done":y?"running":"toolQueued",F=((U=n.result)==null?void 0:U.content.map(W=>W.type==="text"?W.text:"").join(`
|
|
210
|
-
`))??n.liveOutput??"",B=hh(t.argumentsText),ie=mh(B),Q=((fe=n.result)==null?void 0:fe.content.flatMap(W=>W.type==="image"&&typeof W.dataUrl=="string"&&/^data:image\/(png|jpeg|gif|webp);base64,/.test(W.dataUrl)?[W.dataUrl]:[]))??[],q=new Map;for(const W of $)q.set(W.name,(q.get(W.name)??0)+1);const ke=$.filter(W=>W.cost!==void 0),Re=ke.reduce((W,ge)=>W+(ge.cost??0),0),O=((ce=n.status)==null?void 0:ce.durationMs)!==void 0?`${(n.status.durationMs/1e3).toFixed(1)}s`:(ae=/Wall time:?\s*([^\n]+)/i.exec(F))==null?void 0:ae[1],_e=async W=>{try{await navigator.clipboard.writeText(W),k(r("copied"))}catch(ge){k(String(ge))}},M=async(W,ge,Ie)=>{I(!0),k("");try{if(ge){const Ae=await(await fetch(W)).blob();if(!await new Promise(we=>window.dispatchEvent(new CustomEvent("pi-codemode-attach",{detail:{cwd:i,complete:we,file:new File([Ae],`codemode-${Ie}.${Ae.type.split("/")[1]}`,{type:Ae.type})}}))))throw new Error(r("imageLoadFailed",{name:`codemode-${Ie}`}));k(r("cmAttached"))}else{const Ae=await fetch(Sn("/api/codemode-image"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:fn(),cwd:i,dataUrl:W})}),re=await Ae.json();if(!Ae.ok)throw new Error(re.error??`HTTP ${Ae.status}`);k(r("cmSaved",{path:re.path}))}}catch(Ae){k(Ae.message)}finally{I(!1)}};return e.jsxs("section",{className:`codemode-card ${L?"err":y?"run":""}`,"data-tool-call-id":t.id,children:[e.jsxs("button",{className:"codemode-head","aria-expanded":a,onClick:()=>o(!a),children:[e.jsx("span",{"aria-hidden":"true",children:a?"⌄":"›"}),e.jsx("span",{className:"codemode-mark",children:"{ }"}),e.jsx("strong",{children:"codemode"}),e.jsx("span",{className:"codemode-state",children:r(b)}),O&&e.jsx("small",{children:O}),ke.length>0&&e.jsxs("small",{children:["$",Re.toFixed(4)]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"codemode-summary",children:[[...q].map(([W,ge])=>e.jsxs("span",{children:[e.jsx("code",{children:W})," × ",ge]},W)),!$.length&&e.jsx("span",{children:r(y?"cmWaitingCalls":"cmNoCalls")})]}),e.jsxs("div",{className:"codemode-tabs",role:"tablist","aria-label":"Codemode",children:[["calls","script","output"].map(W=>e.jsxs("button",{id:`${t.id}-${W}`,role:"tab","aria-selected":c===W,"aria-controls":`${t.id}-panel`,tabIndex:c===W?0:-1,onKeyDown:ge=>{var Ie;if(ge.key==="ArrowRight"||ge.key==="ArrowLeft"){ge.preventDefault();const Ae=["calls","script","output"],re=Ae[(Ae.indexOf(W)+(ge.key==="ArrowRight"?1:2))%3];l(re),(Ie=document.getElementById(`${t.id}-${re}`))==null||Ie.focus()}},onClick:()=>l(W),children:[r(W==="calls"?"cmCalls":W==="script"?"cmScript":"output"),W==="calls"&&` · ${N}`]},W)),e.jsx("span",{}),c!=="calls"&&e.jsx("button",{className:"codemode-copy",onClick:()=>void _e(c==="script"?B:F),children:r("copy")})]}),e.jsxs("div",{className:"codemode-body",id:`${t.id}-panel`,role:"tabpanel","aria-labelledby":`${t.id}-${c}`,children:[c==="calls"&&e.jsxs(e.Fragment,{children:[$.length>8&&e.jsx("button",{className:"codemode-expand",onClick:()=>u(!p),children:r(p?"cmCollapseCalls":"cmMoreCalls",{n:$.length-8})}),(p?$:$.slice(-8)).map(W=>e.jsxs("details",{className:`codemode-call ${W.status}`,children:[e.jsxs("summary",{children:[e.jsx("span",{className:"codemode-call-dot","aria-label":r(W.status==="ok"?"done":W.status==="cancelled"?"cmCancelled":W.status==="running"?R?"cmUnfinished":"running":"error"),children:W.status==="ok"?"✓":W.status==="error"?"×":W.status==="cancelled"||R&&W.status==="running"?"−":"•"}),e.jsx("code",{children:W.name}),e.jsx("span",{className:"codemode-args",children:W.args}),W.cost!==void 0&&e.jsxs("small",{children:["$",W.cost.toFixed(4)]}),W.durationMs!==void 0&&e.jsx("small",{children:W.durationMs<1e3?`${Math.round(W.durationMs)}ms`:`${(W.durationMs/1e3).toFixed(1)}s`})]}),e.jsx("pre",{children:W.args}),W.error&&e.jsx("pre",{className:"err",children:W.error})]},W.id)),N>$.length&&e.jsx("p",{children:r("cmLimitedCalls",{n:N-$.length})}),!$.length&&e.jsx("p",{className:"codemode-empty",children:r("cmNoCalls")})]}),c==="script"&&e.jsxs(e.Fragment,{children:[e.jsx(Fn,{text:`\`\`\`\`javascript
|
|
211
|
-
${B}
|
|
212
|
-
\`\`\`\``}),t.argumentsTruncated&&e.jsx("p",{children:r("cmTruncated")})]}),c==="output"&&e.jsxs(e.Fragment,{children:[((z=n.result)==null?void 0:z.toolOutputUrl)&&e.jsx(Nr,{url:n.result.toolOutputUrl}),e.jsx("pre",{children:F||r(y?"cmWaitingOutput":"cmNoOutput")}),((Z=n.result)==null?void 0:Z.content.some(W=>W.type==="text"&&W.truncated))&&e.jsx("p",{children:r("cmTruncated")}),(E==null?void 0:E.fullOutputPath)&&e.jsxs("div",{className:"codemode-full-output",children:[r("cmFullOutput")," ",e.jsx("code",{children:E.fullOutputPath}),e.jsx("button",{onClick:()=>void _e(E.fullOutputPath),children:r("copy")})]})]})]}),L&&e.jsx("p",{className:"codemode-error-note",children:r("cmFailureNote")}),Q.length>0&&e.jsx("div",{className:"codemode-images",children:Q.map((W,ge)=>e.jsxs("figure",{children:[e.jsx("a",{href:W,target:"_blank",rel:"noreferrer",children:e.jsx("img",{src:W,alt:r("toolResultImage"),loading:"lazy"})}),e.jsxs("figcaption",{children:[e.jsx("button",{disabled:j,onClick:()=>void M(W,!1,ge),children:r("cmSaveImage")}),e.jsx("button",{disabled:j,onClick:()=>void M(W,!0,ge),children:r("cmAttachImage")})]})]},ge))}),e.jsxs("footer",{className:"codemode-footer",children:[e.jsxs("span",{children:["max_output_tokens ",ie.max_output_tokens??1e4]}),ie.timeout_ms!==void 0&&e.jsxs("span",{children:["timeout ",ie.timeout_ms/1e3,"s"]}),e.jsx("span",{children:"QuickJS · 256 MB"}),ke.length>0&&e.jsxs("span",{children:[r("cmModelCost"),": $",Re.toFixed(4)]})]}),f&&e.jsx("p",{className:"codemode-feedback",role:"status",children:f})]})]})}function Di(t){if(!t)return null;try{const n=JSON.parse(t);return!n||typeof n!="object"||!("path"in n)?null:typeof n.path=="string"?n.path:null}catch{return null}}function $i(t){var s;const n=(s=t.match(/^\/(?:Users|home)\/[^/]+(?=\/|$)/))==null?void 0:s[0];return n?`~${t.slice(n.length)}`:t}function Cl(t){var i;const n=t.replace(/\r\n/g,`
|
|
213
|
-
`).split(`
|
|
214
|
-
`);if(((i=n[0])==null?void 0:i.trim())!=="---")return{fields:[],body:t};const s=n.findIndex((a,o)=>o>0&&o<50&&a.trim()==="---");if(s<0)return{fields:[],body:t};const r=[];for(const a of n.slice(1,s)){const o=/^([\w-]+):\s*(.*)$/.exec(a);o?r.push({name:o[1],value:o[2].replace(/^['"]|['"]$/g,"")}):/^\s+\S/.test(a)&&r.length&&(r[r.length-1].value+=` ${a.trim()}`)}return{fields:r,body:n.slice(s+1).join(`
|
|
215
|
-
`).trimStart()}}function Sl(t,n){const s=[...n.values()].filter(r=>r.parentToolCallId===t).slice(0,256).map(r=>({id:r.toolCallId,name:r.toolName,argumentsText:r.argumentsText,status:r.running?"unfinished":r.isError?"error":"ok",durationMs:r.durationMs}));return s.length?{calls:s,complete:!1}:void 0}function xr(t){window.dispatchEvent(new CustomEvent("pi:tool-hover",{detail:{toolCallId:t}}))}function gh({items:t,wrap:n}){const s=nt(),[r,i]=d.useState(!1),a=t.map(({block:u})=>Di(u.argumentsText)??u.name),o=t.some(({view:u})=>u.streaming&&!u.result&&!u.status),c=t.every(({view:u})=>u.result||u.status),l=t.some(({view:u})=>{var f,k;return((f=u.result)==null?void 0:f.isError)||((k=u.status)==null?void 0:k.isError)}),p=t.reduce((u,{view:f})=>{var k;return u+(((k=f.status)==null?void 0:k.durationMs)??0)},0);return e.jsxs("div",{className:`read-group ${l?"err":o?"run":c?"ok":"idle"}`,children:[e.jsxs("button",{type:"button",className:"read-group-head","aria-expanded":r,onClick:()=>i(u=>!u),children:[e.jsx("span",{"aria-hidden":"true",children:r?"⌄":"›"}),e.jsx("span",{"aria-hidden":"true",children:"📄"}),e.jsx("strong",{children:s("readFiles",{n:t.length})}),e.jsx("span",{className:"read-group-paths",title:a.join(`
|
|
216
|
-
`),children:a.map(u=>u.split("/").slice(-2).join("/")).join(", ")}),e.jsx("span",{className:"read-group-status",children:l?s("error"):o?s("running"):c?`${s("done")}${p?` · ${vr(p)}`:""}`:s("toolQueued")})]}),r&&e.jsx("div",{className:"read-group-items",children:t.map(({block:u,view:f})=>e.jsx(xh,{block:u,view:f,wrap:n},u.id))})]})}function xh({block:t,view:n,wrap:s}){var p,u,f;const r=nt(),[i,a]=d.useState(!1),o=Di(t.argumentsText)??t.name,c=((p=n.result)==null?void 0:p.content.map(k=>k.type==="text"&&typeof k.text=="string"?k.text:"").join(""))??n.liveOutput??"",l=c?c.replace(/\r\n/g,`
|
|
217
|
-
`).replace(/\n$/,"").split(`
|
|
218
|
-
`).length:0;return e.jsxs("div",{className:"read-file-row",onMouseEnter:()=>xr(t.id),onMouseLeave:()=>xr(null),children:[e.jsxs("button",{type:"button",className:"read-file-head",title:o,"aria-expanded":i,onClick:()=>a(k=>!k),children:[e.jsx(_t,{className:i?"open":""}),e.jsx("span",{children:r("readVerb")}),e.jsx("code",{children:$i(o)}),l>0&&e.jsx("span",{children:r("toolLineCount",{n:l})}),e.jsx("i",{className:(u=n.result)!=null&&u.isError||(f=n.status)!=null&&f.isError?"error":n.result||n.status?"done":"pending"})]}),i&&e.jsx(Fi,{block:t,view:n,wrap:s})]})}function vh({block:t,view:n,wrap:s}){var k,j;const r=nt(),[i,a]=d.useState(!1);let o="",c="";try{const I=JSON.parse(t.argumentsText??"{}");typeof I.pattern=="string"&&(o=I.pattern),typeof I.path=="string"?c=I.path:typeof I.glob=="string"&&(c=I.glob)}catch{}const l=((k=n.result)==null?void 0:k.content.map(I=>I.type==="text"&&typeof I.text=="string"?I.text:"").join(""))??n.liveOutput??"",p=/^\s*(?:No matches|没有匹配)/i.test(l),u=l.split(`
|
|
219
|
-
`).filter(I=>/^\S+?:\d+[:-]/.test(I)).length,f=((j=n.status)==null?void 0:j.durationMs)!==void 0?vr(n.status.durationMs):"";return e.jsxs("div",{className:"grep-summary",children:[e.jsxs("button",{type:"button",className:"grep-summary-head","aria-expanded":i,onClick:()=>a(I=>!I),children:[e.jsx(_t,{className:i?"open":""}),e.jsx("strong",{children:r("grepSearch")}),e.jsx("code",{title:o,children:o||t.name}),c&&e.jsx("span",{title:c,children:r("grepInPath",{path:$i(c)})}),n.result&&!n.result.isError&&e.jsx("span",{children:u||p?r("grepMatches",{n:u}):r("toolLineCount",{n:l.split(`
|
|
220
|
-
`).filter(Boolean).length})}),f&&e.jsx("span",{className:"grep-summary-time",children:f})]}),i&&e.jsx("div",{className:"grep-summary-body",children:e.jsx(Fi,{block:t,view:n,wrap:s})})]})}const kh={bash:"$",read:"📄",write:"W",edit:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function Oa(t){return kh[t]??"🛠"}function yh(t){if(t.name!=="read"||!t.argumentsText)return!1;try{const n=JSON.parse(t.argumentsText);return typeof n.path=="string"&&/\.(md|markdown)$/i.test(n.path)}catch{return!1}}function wh(t){if(t.name!=="read"||!t.argumentsText)return null;try{const n=JSON.parse(t.argumentsText);return typeof n.path=="string"?Ps(n.path):null}catch{return null}}function bh(t){if(t.name!=="write"||!t.argumentsText)return null;try{const n=JSON.parse(t.argumentsText);return typeof n.content!="string"?null:{lang:typeof n.path=="string"?Ps(n.path):null,content:n.content}}catch{return null}}function jh(t){if(t.name!=="edit"||!t.argumentsText)return null;try{const n=JSON.parse(t.argumentsText);return typeof n.path=="string"?Ps(n.path):null}catch{return null}}function Ch(t,n){if(t.name!=="edit"||!n.result||n.result.isError)return null;const s=n.result.details;return typeof(s==null?void 0:s.diff)=="string"?s.diff:null}const Sh=/^([+\- ])(\s*\d+) (.*)$/;function Nh(t){return t.split(`
|
|
221
|
-
`).map(n=>{const s=Sh.exec(n);return s?{marker:s[1],lineNum:s[2],code:s[3]}:{marker:" ",lineNum:"",code:n}})}function Eh({diff:t,lang:n,path:s}){const r=Nh(t),i=r.filter(o=>o.marker==="+").length,a=r.filter(o=>o.marker==="-").length;return e.jsxs("div",{className:"toolcall-diff",children:[e.jsxs("div",{className:"toolcall-diff-header",children:[e.jsx("span",{title:s,children:s}),e.jsxs("span",{children:["+",i," −",a]})]}),e.jsx("div",{className:"toolcall-diff-lines",children:r.map((o,c)=>e.jsxs("div",{className:`toolcall-diff-line ${o.marker==="+"?"add":o.marker==="-"?"del":"ctx"}`,children:[e.jsxs("span",{className:"toolcall-diff-gutter",children:[o.marker,o.lineNum]}),e.jsx("code",{className:"toolcall-diff-code hljs",dangerouslySetInnerHTML:{__html:Ks(o.code,n)||""}})]},c))})]})}function _a(t,n){var a;const s=((a=t.match(/`+/g))==null?void 0:a.map(o=>o.length))??[],r=s.length?Math.max(...s):0,i="`".repeat(Math.max(3,r+1));return`${i}${n}
|
|
222
|
-
${t.replace(/\n$/,"")}
|
|
223
|
-
${i}`}const Fi=d.memo(function(n){return n.block.name==="codemode"?e.jsx(fh,{...n}):n.block.name==="task_plan"?e.jsx(Th,{block:n.block,view:n.view}):e.jsx(Ih,{...n})});function Th({block:t,view:n}){var l,p,u,f,k;const s=nt();let r=[];try{const j=JSON.parse(t.argumentsText??"{}");Array.isArray(j.steps)&&(r=j.steps.filter(I=>typeof I=="object"&&I!==null&&typeof I.title=="string"))}catch{}const[i,a]=d.useState(!n.result);d.useEffect(()=>{n.result&&a(!1)},[n.result]);const o=((l=n.result)==null?void 0:l.content.filter(j=>j.type==="text").map(j=>j.text).join(" "))??"",c=Number(((p=/Plan revision (\d+)/.exec(o))==null?void 0:p[1])??0)>1;return e.jsxs("div",{className:`task-plan-card${(u=n.result)!=null&&u.isError?" err":""}`,children:[e.jsxs("button",{type:"button",className:"task-plan-card-head","aria-expanded":i,onClick:()=>a(j=>!j),children:[e.jsx(_t,{className:i?"open":""}),e.jsxs("span",{children:[s(c?"taskPlanChanged":"taskPlanCard")," · ",r.length," ",s("taskPlanSteps")]}),e.jsx("span",{className:"task-plan-card-state",children:(f=n.result)!=null&&f.isError?s("error"):n.result?s("done"):s("running")})]}),i&&e.jsx("ol",{children:r.map(j=>e.jsx("li",{children:j.title},j.id))}),((k=n.result)==null?void 0:k.isError)&&e.jsx("div",{className:"task-plan-card-error",children:o})]})}function Rh({command:t,original:n,directory:s,running:r,elapsed:i,status:a,full:o,onFull:c,onKill:l,children:p}){const u=nt(),f=/^git\s+commit\s+(?:-q\s+)?-m\s+(?:"([^"$`]+)"|'([^']+)')\s*$/.exec(t),k=d.useRef(null),[j,I]=d.useState(!1);return d.useEffect(()=>{const E=k.current;if(!E)return;const $=()=>I(E.scrollWidth>E.clientWidth+1||t.includes(`
|
|
224
|
-
`)),N=new ResizeObserver($);return N.observe(E),$(),()=>N.disconnect()},[t]),e.jsxs("div",{className:"toolcall-head bash-command-head",children:[r&&e.jsx("span",{className:"bash-running-dot","aria-label":u("running")}),e.jsxs("button",{type:"button",className:"bash-head-command",title:n,disabled:!j&&!o,"aria-expanded":o,"aria-label":o?u("collapseCode"):j?u("bashExpandFullCommand"):t,onClick:c,children:[e.jsx("span",{className:"bash-prompt",children:"$"}),f&&e.jsx("span",{className:"bash-command-verb",children:"git commit"}),e.jsx("span",{ref:k,className:`bash-command-text${f?" bash-commit-subject":""}`,children:f?f[1]??f[2]:t}),(j||o)&&e.jsx(nn,{className:o?"open":""})]}),s&&e.jsx("span",{className:"bash-directory",title:s,children:s}),e.jsx("span",{className:"toolcall-status",children:r?`${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`:a}),r&&l&&e.jsx("button",{type:"button",className:"toolcall-kill",title:u("stopBashTip"),onClick:l,children:u("stopBash")}),e.jsxs("details",{className:"bash-card-more",children:[e.jsx("summary",{"aria-label":u("more"),children:"⋯"}),e.jsx("div",{children:p})]})]})}function Ih({block:t,view:n,onKillBash:s,wrap:r=!0}){var G,Oe,Ne,Ee,et,Ce,be,ze,tt,Ye;const i=((G=n.result)==null?void 0:G.nestedCalls)??n.nestedCalls,a=nt(),[o,c]=d.useState(r),[l,p]=d.useState(!1),[u,f]=d.useState(!1),[k,j]=d.useState("steps"),[I,E]=d.useState(!1),[$,N]=d.useState(0),R=d.useContext(Gs),[y,L]=d.useState(!0),[b,F]=d.useState(!1),[B,ie]=d.useState(!1);d.useEffect(()=>{if(!B)return;const Le=Xe=>{Xe.key==="Escape"&&ie(!1)};return window.addEventListener("keydown",Le),()=>window.removeEventListener("keydown",Le)},[B]);const Q=!n.result&&n.streaming&&!n.status;d.useEffect(()=>{if(!Q)return;const Le=Date.now(),Xe=window.setInterval(()=>N(Math.floor((Date.now()-Le)/1e3)),1e3);return()=>window.clearInterval(Xe)},[Q]);const q=t.name==="bash"&&Q,ke=n.result!==void 0,Re=!n.result&&!!n.status,O=((Oe=n.result)==null?void 0:Oe.isError)??((Ne=n.status)==null?void 0:Ne.isError)??!1,_e=yh(t),M=!_e&&!O?wh(t):null,V=bh(t),ve=Ch(t,n),ye=ve?jh(t):null;let oe="";if(ve)try{oe=JSON.parse(t.argumentsText??"").path??""}catch{}const Fe=n.result?n.result.content.map(Le=>Le.type==="text"?Le.text:"").join(""):n.liveOutput??"",U=((et=(Ee=n.result)==null?void 0:Ee.details)==null?void 0:et.exitCode)??((Ce=n.status)==null?void 0:Ce.exitCode),fe=t.name==="bash"?au(t.argumentsText,Fe,ke||Re,O,U):null,ce=t.name==="bash"&&O&&!fe?ou(Fe):[],ae=U??Number(((be=/(?:exited with code\s*|exit(?:ed)?\s+)(\d+)/i.exec(Fe))==null?void 0:be[1])??NaN),z=Fe.replace(/\r\n/g,`
|
|
225
|
-
`).split(`
|
|
226
|
-
`);z.at(-1)===""&&z.pop();const Z=t.name==="bash"?zs(t.argumentsText):null,W=!!Z,ge=Z?gr(Z,R):null,Ae=t.name!=="bash"&&z.length>10&&!b&&!B?z.slice(0,10).join(`
|
|
227
|
-
`):Fe,re=_e&&y&&!O?Cl(Ae):null,we=t.name==="read"?Di(t.argumentsText):null,A=(fe==null?void 0:fe.status)==="partial"?"partial":(fe==null?void 0:fe.status)==="no-match"?"idle":O?"err":ke||Re?"ok":Q?"run":"idle";let xe=a(O?"error":ke?"done":Q?"running":Re?"done":"toolQueued");const _=((ze=n.status)==null?void 0:ze.durationMs)!==void 0?vr(n.status.durationMs):"";_&&(xe=`${xe} · ${_}`),fe?xe=fe.status==="partial"?a("bashPartial",{ok:fe.completed,total:fe.steps.length}):fe.status==="failed"?a("bashFailed"):fe.status==="no-match"?a("bashNoMatch"):fe.status==="running"?`${a("bashRunning")}${$?` · ${$}s`:""}`:`${a("done")}${_?` · ${_}`:""}`:t.name==="bash"&&O&&(xe=`${a("bashFailed")}${Number.isFinite(ae)?` · exit ${ae}`:""}${ce.length?` · ${a("bashErrorCount",{n:ce.length})}`:""}`);const Se=U!==void 0?`exit ${U}`:"",J=()=>{if(t.argumentsText){let Le=t.argumentsText;try{t.name==="bash"&&(Le=JSON.parse(Le).command??Le)}catch{}navigator.clipboard.writeText(Le),p(!0),setTimeout(()=>p(!1),1200)}},De=e.jsxs(e.Fragment,{children:[t.argumentsText&&(!W||I||B)&&e.jsx("div",{className:"toolcall-args",children:we?e.jsx("button",{type:"button",className:"toolcall-read-path",title:we,onClick:()=>ie(!0),children:$i(we)}):t.name==="bash"&&t.argumentsText.startsWith("{")?e.jsx("div",{className:"bash-command-preview",children:e.jsx(Lh,{args:t.argumentsText,cwd:R})}):V?V.lang?e.jsx("div",{className:"toolcall-code",children:e.jsx(Fn,{text:_a(V.content,V.lang)})}):e.jsx("pre",{children:V.content}):e.jsx("pre",{children:t.argumentsText})}),i&&e.jsxs("details",{className:"tool-nested-calls",open:!0,children:[e.jsx("summary",{children:a("nestedToolCalls",{n:i.calls.length})}),i.calls.map(Le=>e.jsxs("details",{className:"tool-nested-call",children:[e.jsxs("summary",{children:[e.jsx("code",{children:Le.name}),e.jsxs("span",{className:Le.status==="error"?"err":"",children:[a(Le.status==="ok"?"done":Le.status==="error"?"error":"running"),Le.durationMs!==void 0?` · ${vr(Le.durationMs)}`:""]})]}),Le.argumentsText&&e.jsx("pre",{children:Le.argumentsText}),Le.error&&e.jsx("pre",{className:"err",children:Le.error})]},Le.id)),n.result&&!i.complete&&e.jsx("p",{children:a("nestedToolCallsIncomplete")})]}),((tt=n.result)==null?void 0:tt.toolOutputUrl)&&e.jsx(Nr,{url:n.result.toolOutputUrl}),(Ye=n.result)==null?void 0:Ye.content.flatMap(Le=>Le.type==="image"&&"dataUrl"in Le&&typeof Le.dataUrl=="string"?[Le.dataUrl]:[]).map((Le,Xe)=>e.jsxs("div",{children:[e.jsx("a",{href:Le,target:"_blank",rel:"noreferrer",className:"tool-result-image",children:e.jsx("img",{src:Le,alt:a("toolResultImage"),loading:"lazy"})}),e.jsx("a",{href:Le,download:`generated-${Xe}.png`,children:a("downloadImage")})]},Xe)),Fe.length>0&&(t.name==="bash"?fe&&k==="steps"?e.jsx(Mh,{run:fe,wrap:u}):ce.length>0?e.jsx(Ph,{diagnostics:ce,output:Fe,wrap:u}):e.jsx(Ah,{output:Fe,wrap:u,cwd:li(t.argumentsText,R)??"",searchOutput:Qp(t.argumentsText),command:(ge==null?void 0:ge.command)??""}):e.jsxs("div",{className:"toolcall-output",children:[e.jsxs("div",{className:"toolcall-output-label",children:[O?a("errorOutput"):t.name==="read"?a("modelReadOnly"):a("output"),Q&&e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),e.jsx("span",{className:"toolcall-output-spacer"}),_e&&!O&&e.jsx("button",{type:"button",className:"toolcall-md-toggle",title:a(y?"showMarkdownSource":"showMarkdownPreview"),onClick:()=>L(Le=>!Le),children:a(y?"readRaw":"showMarkdownPreview")})]}),ve?e.jsx(Eh,{diff:ve,lang:ye,path:oe}):_e&&y&&!O?e.jsxs("div",{className:"toolcall-markdown",children:[re&&re.fields.length>0&&e.jsx("dl",{className:"toolcall-frontmatter",children:re.fields.map(({name:Le,value:Xe})=>e.jsxs("div",{children:[e.jsx("dt",{children:Le}),e.jsx("dd",{children:Xe})]},Le))}),e.jsx(Fn,{text:(re==null?void 0:re.body)??Ae})]}):M?e.jsx("div",{className:"toolcall-code",children:e.jsx(Fn,{text:_a(Ae,M)})}):e.jsx("pre",{children:Ae}),t.name!=="bash"&&z.length>10&&e.jsx("button",{type:"button",className:"toolcall-output-more",onClick:()=>F(Le=>!Le),children:b||B?a("collapseCode"):a("expandAllLines",{n:z.length})})]}))]});return e.jsxs("div",{className:`toolcall ${A} ${t.name==="bash"?"toolcall-bash":""} ${fe?"toolcall-steps":""} ${ce.length?"toolcall-diagnostics":""}`,onMouseEnter:()=>xr(t.id),onMouseLeave:()=>xr(null),children:[ge?e.jsxs(Rh,{command:ge.command,original:Z,directory:ge.directory??li(t.argumentsText,R),running:q,elapsed:$,status:xe,full:I,onFull:()=>{E(Le=>!Le),c(!0)},onKill:s,children:[fe&&e.jsxs("span",{className:"bash-view-switch",children:[e.jsx("button",{type:"button",className:k==="steps"?"active":"",onClick:()=>j("steps"),children:a("bashSteps")}),e.jsx("button",{type:"button",className:k==="raw"?"active":"",onClick:()=>j("raw"),children:a("bashRaw")})]}),e.jsx("button",{type:"button",className:"toolcall-wrap","aria-pressed":u,onClick:()=>f(Le=>!Le),children:a("toolWrap")}),e.jsx("button",{type:"button",className:"toolcall-expand",onClick:()=>F(Le=>!Le),children:a(b?"collapseCode":"expandCode")}),e.jsx("button",{type:"button",className:"toolcall-expand",onClick:()=>ie(!0),children:a("zoomCode")}),e.jsx("button",{type:"button",className:"toolcall-copy",onClick:J,children:a(l?"copied":"copy")}),e.jsx("button",{type:"button",className:"toolcall-toggle",onClick:()=>c(Le=>!Le),children:a(o?"collapseCode":"expandCode")})]}):e.jsxs("div",{className:"toolcall-head",children:[e.jsx("span",{className:"toolcall-icon",children:Oa(t.name)}),W?e.jsxs("code",{className:"bash-head-command",title:Z??"",children:["$ ",Bs(Z,R)]}):e.jsx("span",{className:"toolcall-name",children:t.name}),W&&Fe&&e.jsx("span",{className:"bash-head-count",children:a("toolLineCount",{n:z.length})}),e.jsxs("span",{className:"toolcall-status",children:[xe,Q&&t.name==="bash"&&e.jsxs("span",{className:"working-dots","aria-hidden":"true",children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),Se&&e.jsx("em",{className:"toolcall-exit",children:Se})]}),e.jsx("span",{className:"toolcall-spacer"}),fe&&e.jsxs("span",{className:"bash-view-switch",children:[e.jsx("button",{type:"button",className:k==="steps"?"active":"",onClick:()=>j("steps"),children:a("bashSteps")}),e.jsx("button",{type:"button",className:k==="raw"?"active":"",onClick:()=>j("raw"),children:a("bashRaw")})]}),t.name==="bash"&&!fe&&!ce.length&&e.jsx("button",{type:"button",className:"toolcall-wrap","aria-pressed":u,onClick:()=>f(Le=>!Le),children:a("toolWrap")}),q&&s&&e.jsxs("button",{type:"button",className:"toolcall-kill",title:a("stopBashTip"),onClick:s,children:[e.jsx(ls,{}),e.jsx("span",{children:a("stopBash")})]}),t.name!=="read"&&!fe&&!ce.length&&e.jsx("button",{type:"button",disabled:!o,className:"toolcall-expand",title:a(b?"collapseCode":"expandCode"),onClick:()=>F(Le=>!Le),children:a(b?"collapseCode":"expandCode")}),!fe&&!ce.length&&e.jsx("button",{type:"button",className:"toolcall-expand",title:a("zoomCode"),onClick:()=>ie(!0),children:a("zoomCode")}),e.jsx("button",{type:"button",className:"toolcall-copy",title:a("copyArgs"),onClick:J,children:a(l?"copied":"copy")}),(fe||ce.length>0)&&e.jsxs("details",{className:"bash-card-more",children:[e.jsx("summary",{"aria-label":a("more"),children:"⋯"}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>f(Le=>!Le),children:a("toolWrap")}),e.jsx("button",{type:"button",onClick:()=>ie(!0),children:a("zoomCode")}),e.jsx("button",{type:"button",onClick:()=>c(Le=>!Le),children:a(o?"collapseCode":"expandCode")})]})]}),!fe&&!ce.length&&e.jsx("button",{type:"button",className:"toolcall-toggle","aria-label":a(o?"collapseCode":"expandCode"),onClick:()=>c(Le=>!Le),children:o?e.jsx(nn,{}):e.jsx(_t,{})})]}),o&&e.jsx("div",{className:`toolcall-body ${b?"expanded":""}`,children:De}),B&&e.jsx("div",{className:"modal-backdrop",onClick:()=>ie(!1),children:e.jsxs("div",{className:"toolcall-zoom",role:"dialog","aria-modal":"true",onClick:Le=>Le.stopPropagation(),children:[e.jsxs("div",{className:"toolcall-zoom-head",children:[e.jsx("span",{className:"toolcall-icon",children:Oa(t.name)}),e.jsx("span",{className:"toolcall-name",children:t.name}),e.jsx("span",{className:"toolcall-spacer"}),e.jsx("button",{type:"button",className:"toolcall-zoom-close",title:a("closeZoom"),onClick:()=>ie(!1),children:e.jsx(qt,{})})]}),e.jsx("div",{className:"toolcall-body toolcall-zoom-body",children:De})]})})]})}function Lh({args:t,cwd:n}){let s=null;try{s=JSON.parse(t)}catch{return e.jsx("pre",{children:t})}return typeof s.command!="string"?e.jsx("pre",{children:t}):e.jsxs("div",{className:"termline",children:[e.jsx("span",{className:"termline-icon",children:"$"}),e.jsx("code",{title:s.command,children:Bs(s.command,n)}),typeof s.timeout=="number"&&e.jsxs("span",{className:"termline-timeout",children:["⏱ ",s.timeout,"s"]})]})}function vr(t){if(t===void 0)return"";const n=t/1e3;if(n<.1)return"<0.1s";if(n<60)return`${n.toFixed(1)}s`;const s=Math.floor(n/60),r=Math.round(n%60);return`${s}m ${String(r).padStart(2,"0")}s`}function Mh({run:t,wrap:n}){const s=nt(),[r,i]=d.useState(()=>t.steps.findIndex(a=>a.state==="failed"));return e.jsx("div",{className:"bash-steps",children:t.steps.map((a,o)=>{const c=r===o,l=a.state==="done"?"✓":a.state==="failed"?"×":a.state==="running"?"⋯":"–";return e.jsxs("div",{className:`bash-step ${a.state}`,children:[e.jsxs("button",{type:"button",className:"bash-step-head","aria-expanded":c,onClick:()=>i(c?null:o),children:[e.jsx("span",{className:"bash-step-index",children:o+1}),e.jsx("span",{className:"bash-step-icon",children:l}),e.jsx("strong",{children:a.label}),e.jsx("code",{title:a.command,children:a.command}),e.jsx("span",{className:"bash-step-count",children:a.state==="no-match"?s("bashNoMatch"):a.state==="skipped"?s("bashSkipped"):a.state==="failed"?t.exitCode!==void 0?`exit ${t.exitCode}`:s("bashFailed"):a.state==="running"?s("running"):s("toolLineCount",{n:a.lineCount})}),e.jsx(_t,{className:c?"open":""})]}),c&&e.jsxs("div",{className:`bash-step-detail ${n?"wrap":""}`,children:[e.jsxs("div",{className:"bash-step-command",children:["$ ",a.command]}),e.jsx("pre",{children:a.output?a.output.split(`
|
|
228
|
-
`).map((p,u,f)=>e.jsxs("span",{className:Vs(p)?"error":"",children:[p,u<f.length-1?`
|
|
229
|
-
`:""]},u)):s(a.state==="no-match"?"bashNoMatch":"waitingOutput")})]})]},`${a.label}-${o}`)})})}function Ph({diagnostics:t,output:n,wrap:s}){const r=nt(),[i,a]=d.useState(!1);return e.jsxs("div",{className:"bash-failure",children:[e.jsx("div",{className:"bash-failure-list",children:t.map((o,c)=>e.jsxs("div",{className:"bash-failure-line",children:[e.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("pi-harness:open-tool-file",{detail:o})),children:[o.path,":",o.line,o.column?`:${o.column}`:""]}),e.jsx("span",{children:o.message})]},`${o.path}:${o.line}:${c}`))}),e.jsx("button",{type:"button",className:"bash-failure-toggle",onClick:()=>a(o=>!o),children:r(i?"collapseCode":"bashShowRaw")}),i&&e.jsx("pre",{className:s?"wrap":"",children:n})]})}function Ah({output:t,wrap:n,cwd:s,searchOutput:r,compact:i=!1,command:a=""}){const o=nt(),[c,l]=d.useState(!1),p=d.useRef(null),[u,f]=d.useState(!1);d.useEffect(()=>{const N=p.current;if(!N)return;const R=()=>f(!n&&N.scrollWidth-N.clientWidth-N.scrollLeft>1),y=new ResizeObserver(R);return y.observe(N),N.addEventListener("scroll",R),R(),()=>{y.disconnect(),N.removeEventListener("scroll",R)}},[t,c,n]);const k=t.replace(/\r\n/g,`
|
|
230
|
-
`).split(`
|
|
231
|
-
`);k.at(-1)===""&&k.pop();const j=Yp(a,k),I=j&&!c&&k.length>6?[0,1,2,k.length-3,k.length-2,k.length-1]:Jp(k,c),E=k.filter(Vs).length,$=I.some((N,R)=>R>0&&N>I[R-1]+1);return e.jsxs("div",{className:"bash-output",children:[j?e.jsxs("div",{className:"bash-output-label bash-git-summary",children:[e.jsxs("span",{children:["git status · ",o("bashStatusFiles",{n:j.files})]}),j.added>0&&e.jsxs("span",{className:"git-added",children:["· ",o("bashStatusAdded",{n:j.added})]}),j.modified>0&&e.jsxs("span",{className:"git-modified",children:["· ",o("bashStatusModified",{n:j.modified})]}),j.deleted>0&&e.jsxs("span",{className:"git-deleted",children:["· ",o("bashStatusDeleted",{n:j.deleted})]}),j.conflicts>0&&e.jsxs("span",{className:"git-deleted",children:["· ",o("bashStatusConflicts",{n:j.conflicts})]})]}):!i&&e.jsxs("div",{className:"bash-output-label",children:[e.jsxs("span",{children:[o("output")," · ",o("toolLineCount",{n:k.length}),E>0?` · ${o("bashLikelyErrorLines",{n:E})}`:""]}),s&&e.jsx("span",{title:s,children:o("toolRelativeTo",{path:s})})]}),e.jsx("div",{ref:p,className:`bash-output-lines ${n?"wrap":""} ${u?"has-overflow":""}`,children:I.map((N,R)=>{const y=k[N],{number:L,text:b}=Gp(y,N,r==="mixed"?"mixed":r==="standalone"),F=/^(?:[.~/\w-]+\/)*[.\w-]+(?:\.[\w-]+)$/.test(b),B=F?b.lastIndexOf("/")+1:0,ie=j?bl(b):null;return e.jsxs(d.Fragment,{children:[R>0&&N>I[R-1]+1&&e.jsxs("button",{type:"button",className:"bash-output-gap bash-output-gap-button",onClick:()=>l(!0),children:["⋯ ",o("toolMoreLines",{n:N-I[R-1]-1})]}),e.jsxs("div",{className:`bash-output-line${ie?" git-row":""}${Vs(y)?" error":""}`,children:[e.jsx("span",{className:"bash-line-number",children:L}),ie?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`bash-git-status git-${ie.kind}`,children:ie.status}),e.jsx("span",{className:"bash-line-text",children:ie.path})]}):e.jsx("span",{className:"bash-line-text",children:F?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bash-path-dir",children:b.slice(0,B)}),e.jsx("span",{className:B?"bash-path-file":"bash-root-file",children:b.slice(B)})]}):b||" "})]})]},N)})}),k.length>(j?6:8)&&(c||!$)&&e.jsx("button",{type:"button",className:"bash-output-more",onClick:()=>l(N=>!N),children:c?o("collapseCode"):o("toolMoreLines",{n:k.length-I.length})})]})}function ui(t){var s,r;return((s=t.view.result)==null?void 0:s.isError)||((r=t.view.status)==null?void 0:r.isError)?"err":t.view.result||t.view.status?"done":t.view.streaming?"running":"pending"}function Dh({lines:t,path:n}){const s=Ps(n);return e.jsx("div",{className:"change-lines",children:t.map((r,i)=>e.jsxs("div",{className:`change-line ${r.marker==="+"?"add":r.marker==="-"?"del":"context"}`,children:[e.jsx("span",{className:"change-old",children:r.oldLine??""}),e.jsx("span",{className:"change-new",children:r.newLine??""}),e.jsx("span",{className:"change-marker",children:r.marker==="-"?"−":r.marker}),e.jsx("code",{className:"hljs",dangerouslySetInnerHTML:{__html:Ks(r.text,s)||"​"}})]},i))})}function $h({change:t}){const n=nt(),[s,r]=d.useState(!1),i=t.hunks.reduce((o,c)=>o+c.lines.length,0);let a=s?1/0:12;return e.jsxs("div",{className:"change-card-body",children:[t.error&&e.jsx("div",{className:"change-error",children:t.errorText.split(`
|
|
232
|
-
`).find(o=>o.trim())||n("changeFailed")}),t.empty?e.jsx("div",{className:"change-empty",children:t.error?n("changeNoOriginal"):t.kind==="write"?`${n("emptyFile")} (${t.path.split("/").at(-1)})`:n("changeNoDiff")}):t.hunks.map((o,c)=>{if(a<=0)return null;const l=o.lines.slice(0,a);return a-=l.length,e.jsxs("div",{className:"change-hunk",children:[e.jsxs("div",{className:"change-hunk-head",children:[t.error?t.kind==="write"?n("changeAttemptedWrite"):n("changeOriginal"):t.kind==="write"?n("changeWrittenLines",{n:t.added}):t.fromArguments?n("changeReplacement"):n("changeAtLine",{n:o.line}),o.functionName&&e.jsxs("span",{children:[" · ",o.functionName]})]}),e.jsx(Dh,{lines:l,path:t.path})]},c)}),t.diffTruncated&&e.jsx("div",{className:"change-empty",children:n("truncated")}),i>12&&e.jsx("button",{type:"button",className:"change-more",onClick:()=>r(o=>!o),children:s?n("collapseCode"):n("expandRemainingLines",{n:i-12})})]})}function Nl({item:t,compact:n=!1,retried:s=!1}){const r=nt(),i=d.useMemo(()=>Rs(t.block,t.view.result),[t.block,t.view.result]),[a,o]=d.useState(!n&&!s);if(d.useEffect(()=>{s&&o(!1)},[s]),d.useEffect(()=>{(i==null?void 0:i.kind)==="edit"&&i.empty&&!i.error&&t.view.result&&o(!1)},[i,t.view.result]),d.useEffect(()=>{const f=k=>{var j;((j=k.detail)==null?void 0:j.toolCallId)===t.block.id&&o(!0)};return window.addEventListener("pi:jump-tool",f),()=>window.removeEventListener("pi:jump-tool",f)},[t.block.id]),!i)return null;const c=s?"retried":ui(t),l=i.kind==="edit"&&i.empty&&!i.error&&c==="done",p=i.path||t.block.name,u=()=>window.dispatchEvent(new CustomEvent("pi-harness:open-tool-file",{detail:{path:i.path,...i.fromArguments?{}:{line:i.firstChangedLine}}}));return e.jsxs("div",{className:`change-card ${c}`,"data-tool-call-id":t.block.id,onMouseEnter:()=>window.dispatchEvent(new CustomEvent("pi:tool-hover",{detail:{toolCallId:t.block.id}})),onMouseLeave:()=>window.dispatchEvent(new CustomEvent("pi:tool-hover",{detail:{toolCallId:null}})),children:[e.jsxs("div",{className:"change-card-head",children:[e.jsxs("button",{type:"button",className:"change-card-toggle","aria-expanded":a&&!l,disabled:l,onClick:()=>o(f=>!f),children:[!l&&e.jsx(_t,{className:a?"open":""}),e.jsx("span",{className:"change-verb",children:t.block.name==="edit"?r("changeEdit"):r("changeWrite")}),e.jsx("code",{title:p,children:p})]}),e.jsx("span",{className:"change-counts",children:!i.error&&e.jsxs(e.Fragment,{children:[i.added>0&&e.jsxs("span",{className:"add",children:["+",i.added]}),i.removed>0&&e.jsxs("span",{className:"del",children:["−",i.removed]})]})}),e.jsxs("span",{className:`change-state ${c}`,children:[e.jsx("i",{}),r(s?"changeRetried":c==="err"?"error":c==="done"?"done":c==="running"?"running":"toolQueued")]}),i.path&&e.jsx("button",{type:"button",className:"change-open",onClick:u,children:r("changeOpen")}),e.jsxs("details",{className:"change-raw",children:[e.jsx("summary",{"aria-label":r("more"),children:e.jsx(Ss,{})}),e.jsxs("div",{children:[e.jsx("strong",{children:r("changeRawArgs")}),e.jsx("pre",{children:t.block.argumentsText}),i.output&&e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:r("changeRawOutput")}),e.jsx("pre",{children:i.output})]})]})]})]}),a&&!l&&e.jsx($h,{change:i})]})}function Fh({items:t,retriedIds:n}){const s=nt(),[r,i]=d.useState(!0);d.useEffect(()=>{const f=k=>{var I;const j=(I=k.detail)==null?void 0:I.toolCallId;j&&t.some(E=>E.block.id===j)&&i(!0)};return window.addEventListener("pi:jump-tool",f),()=>window.removeEventListener("pi:jump-tool",f)},[t]);const a=t.map(({block:f,view:k})=>Rs(f,k.result)),o=a.reduce((f,k)=>f+((k==null?void 0:k.added)??0),0),c=a.reduce((f,k)=>f+((k==null?void 0:k.removed)??0),0),l=t.some(f=>ui(f)==="err"&&!(n!=null&&n.has(f.block.id))),p=t.every(f=>["done","err"].includes(ui(f))),u=t.every(f=>f.block.name==="edit")?s("changeEdit"):t.every(f=>f.block.name==="write")?s("changeWrite"):s("taskChanges");return e.jsxs("div",{className:`change-group ${l?"err":p?"done":"running"}`,children:[e.jsxs("button",{type:"button",className:"change-group-head","aria-expanded":r,onClick:()=>i(f=>!f),children:[e.jsx(_t,{className:r?"open":""}),e.jsxs("strong",{children:[u," ",t.length," ",s("taskFiles")]}),e.jsxs("span",{className:"change-counts",children:[o>0&&e.jsxs("span",{className:"add",children:["+",o]}),c>0&&e.jsxs("span",{className:"del",children:["−",c]})]}),e.jsx("span",{className:"change-state",children:s(l?"error":p?"done":"running")})]}),r&&e.jsx("div",{className:"change-group-items",children:t.map(f=>e.jsx(Nl,{item:f,compact:!0,retried:n==null?void 0:n.has(f.block.id)},f.block.id))})]})}const Oh=/<\/(?:ant)?think(?:ing)?>/gi,_h=/(?:\s*<\/?(?:ant)?think(?:ing)?>\s*)+$/i;function Ha(t){let n=-1;for(const s of t.matchAll(Oh))n=s.index+s[0].length;return n}const Hh=/(?:\s*<\/(?:[||]DSML[||])?(?:parameter|invoke|tool_calls)>)+\s*$/i,Bh=/<\/?(?:ant)?think(?:ing)?>/gi;function El(t){let n=Yr(t);const s=n.match(Hh),r=!!s&&/[||]DSML[||]/i.test(s[0]);r&&(t=t.slice(0,s.index).trimEnd(),n=n.slice(0,s.index).trimEnd());const i=n.match(_h),a=i!=null&&Ha(n.slice(0,i.index))!==-1,o=a?t.slice(i.index).trim():"",c=a?t.slice(0,i.index):t,l=Ha(a?n.slice(0,i.index):n);if(l===-1)return r?{leaked:"",visible:t.trim()}:null;const p=[c.slice(0,l).trim(),o].filter(Boolean).join(`
|
|
233
|
-
`);return{leaked:Yr(p).replace(Bh,"").trim().length>0?p:"",visible:c.slice(l).trim()}}const Uh="#ffffff",Wh=1568,qh=2*1024*1024;function ns(t){return t.startsWith("image/")&&t!=="image/svg+xml"&&t!=="image/svg"}async function pi(t){if(!t.type.startsWith("image/"))return null;let n;try{n=await createImageBitmap(t,{imageOrientation:"from-image"})}catch{return null}try{const s=Math.min(1,Wh/Math.max(n.width,n.height)),r=Math.max(1,Math.round(n.width*s)),i=Math.max(1,Math.round(n.height*s)),a=t.type==="image/jpeg"||t.type==="image/jpg"?[["image/jpeg",.85],["image/jpeg",.6],["image/webp",.8]]:[["image/png",1],["image/jpeg",.85],["image/jpeg",.6]];let o=null;for(const[c,l]of a){const p=document.createElement("canvas");p.width=r,p.height=i;const u=p.getContext("2d");if(!u)continue;c!=="image/png"&&(u.fillStyle=Uh,u.fillRect(0,0,r,i)),u.drawImage(n,0,0,r,i);const f=p.toDataURL(c,l),k=f.match(/^data:([^;]+);base64,/),j=k?k[1]:c,I=f.replace(/^data:[^;]*;base64,/,""),E=Math.floor(I.length*3/4);if(o={data:I,mimeType:j,name:t.name,size:E},E<=qh)return o}return o}finally{n.close()}}function Tl(t){return t.trim().replace(/^\d+[.)、.]\s*/,"").replace(/\s+/g," ")}function zh(t,n,s=32){const r=[];for(const i of[...t].sort((a,o)=>a.position-o.position)){const a=r.at(-1);a&&(i.position-a.positions.at(-1))*n<s?(a.ids.push(i.id),a.positions.push(i.position)):r.push({ids:[i.id],positions:[i.position]})}return r.map(({ids:i,positions:a})=>({ids:i,position:a.reduce((o,c)=>o+c,0)/a.length}))}function kr(t){const n=t.split(`
|
|
234
|
-
`),s=[];let r=!1;for(let i=0;i<n.length;){const a=n[i];if(/^\s*(```|~~~)/.test(a)){r=!r,s.push(a),i++;continue}if(!r&&Vh(n,i)){for(s.push("```ascii-table");i<n.length&&n[i].trim();)s.push(n[i++]);s.push("```");continue}if(!r&&/^\s*[│ ]*[├└]─{1,2}/.test(a)){const o=s.at(-1),c=o&&o.trim()&&o.length<100&&!/^\s*(?:[-*#>]|\d+[.)])\s/.test(o)?s.pop():void 0;for(s.push("```text"),c!==void 0&&s.push(c);i<n.length&&/^\s*[│ ]*[├└]─{1,2}/.test(n[i]);)s.push(n[i++]);s.push("```");continue}s.push(r?a:Kh(a)),i++}return s.join(`
|
|
235
|
-
`)}function Vh(t,n){var r;if(!((r=t[n])!=null&&r.trim())||!Ba(t[n+1]??""))return!1;let s=0;for(let i=n+1;i<t.length&&i<n+20&&t[i].trim();i++)Ba(t[i])&&s++;return s>=2}function Ba(t){var s;const n=t.replace(/\s/g,"");return n.length>=20&&/[─━═╌┄┈┉]/.test(n)&&(((s=n.match(/[─━═╌┄┈┉│┃┌┐└┘├┤┼┬┴╭╮╰╯]/g))==null?void 0:s.length)??0)/n.length>=.7}function Kh(t){return t.includes("](")?t:t.split(/(`[^`]*`)/g).map(n=>n.startsWith("`")?n:n.replace(/(^|[\s(])((?:[\w.-]+\/)+[\w.-]+\.[A-Za-z0-9]+):([1-9]\d*)/g,(s,r,i,a)=>`${r}[${i}:${a}](#pi-file=${encodeURIComponent(i)}:${a})`)).join("")}const yr=t=>t<1e3?"":Zp(t);function hi(t){return t.result?t.result.isError?"err":"ok":t.status&&!t.status.running?t.status.isError?"err":"ok":t.streaming?"run":"err"}function Gh({items:t,onKill:n,active:s=!1,title:r}){const i=nt(),a=d.useContext(Gs),o=eh(t,y=>di(gr(zs(y.block.argumentsText)??"",a).command).title),[c,l]=d.useState(s);d.useEffect(()=>l(s),[s]);const[p,u]=d.useState(!1),[f,k]=d.useState(),j=o.map(y=>y[y.length-1]),I=j.filter(({view:y})=>hi(y)==="err").length,E=j.some(({view:y})=>hi(y)==="run"),$=I?"err":E?"run":"ok",N=t.map(({view:y})=>{var L;return(L=y.status)==null?void 0:L.durationMs}),R=N.every(y=>y!==void 0);return d.useEffect(()=>{const y=L=>{var F;const b=(F=L.detail)==null?void 0:F.toolCallId;t.some(({block:B})=>B.id===b)&&(l(!0),u(!0),k(b))};return window.addEventListener("pi:reveal-tool",y),()=>window.removeEventListener("pi:reveal-tool",y)},[t]),e.jsxs("section",{className:`bash-group ${$} ${c?"":"historical-step"}`,children:[(!s||t.length>1)&&e.jsxs("button",{type:"button",className:"bash-group-head","aria-expanded":c,onClick:()=>l(!c),children:[e.jsx("span",{className:`bash-state ${$}`,"aria-label":i(I?"error":E?"running":"done"),children:I?"✗":E?"●":"✓"}),e.jsx("strong",{children:c?i(E?"bashGroupRunning":"bashGroupCount",{n:t.length}):r||di(gr(zs(t[0].block.argumentsText)??"",a).command).title}),!c&&e.jsxs("span",{children:[" · ",i("changesCommands",{n:t.length})]}),I>0&&e.jsx("span",{className:"bash-state err",children:i("bashGroupFailed",{n:I})}),R&&yr(N.reduce((y,L)=>y+(L??0),0))&&e.jsx("span",{className:"bash-group-duration",children:yr(N.reduce((y,L)=>y+(L??0),0))}),c?e.jsx(nn,{}):e.jsx(_t,{})]}),(c||s&&t.length===1)&&e.jsxs("div",{className:"bash-group-items",children:[!p&&o.length>8&&e.jsx("button",{type:"button",className:"bash-group-more",onClick:()=>u(!0),children:i("bashGroupEarlier",{n:o.length-8})}),(p?o:o.slice(-8)).map(y=>y.length===1?e.jsx(qr,{...y[0],onKill:n,revealed:f===y[0].block.id},y[0].block.id):e.jsx(qr,{...y[y.length-1],onKill:n,revealed:y.some(L=>L.block.id===f),attempts:y.length,history:e.jsx("div",{className:"bash-attempt-history",children:y.slice(0,-1).map(L=>e.jsx(qr,{...L,revealed:L.block.id===f,historical:!0},L.block.id))})},y[0].block.id))]})]})}function qr({block:t,view:n,onKill:s,revealed:r,messageId:i,attempts:a,historical:o,history:c}){var O,_e,M,V,ve,ye,oe,Fe;const l=nt(),p=d.useContext(Gs),u=o&&!n.result?"empty":hi(n),{locale:f}=Qn(),[k,j]=d.useState(u==="err"),[I,E]=d.useState(!1),[$,N]=d.useState(null),R=d.useRef();d.useEffect(()=>()=>clearTimeout(R.current),[]),d.useEffect(()=>{(u==="err"||r)&&j(!0)},[u,r]),d.useEffect(()=>{const U=fe=>{var ce,ae;((ce=fe.detail)==null?void 0:ce.toolCallId)===t.id&&(j(!0),(ae=fe.detail)!=null&&ae.search&&E(!0))};return window.addEventListener("pi:reveal-tool",U),()=>window.removeEventListener("pi:reveal-tool",U)},[t.id]);const y=zs(t.argumentsText)??t.argumentsText??"bash",L=gr(y,p),b=di(L.command,f==="en"),F=L.command.trimEnd().split(/\r?\n/),B=((O=n.result)==null?void 0:O.content.map(U=>U.type==="text"&&typeof U.text=="string"?U.text:"").join(""))??n.liveOutput??"",ie=B?B.replace(/\r\n/g,`
|
|
236
|
-
`).replace(/\n$/,"").split(`
|
|
237
|
-
`):[],Q=(_e=n.result)==null?void 0:_e.details,q=(Q==null?void 0:Q.exitCode)??((M=n.status)==null?void 0:M.exitCode),ke=(Q==null?void 0:Q.fullOutputPath)||((V=Q==null?void 0:Q.truncation)==null?void 0:V.truncated)||((ve=n.result)==null?void 0:ve.content.some(U=>U.type==="text"&&U.truncated)),Re=async U=>{try{await navigator.clipboard.writeText(U==="command"?y:B),N(U),clearTimeout(R.current),R.current=setTimeout(()=>N(null),1500)}catch{N(null)}};return e.jsxs("div",{className:`bash-row ${u}`,"data-tool-call-id":t.id,"data-msg-id":i,onMouseEnter:()=>window.dispatchEvent(new CustomEvent("pi:tool-hover",{detail:{toolCallId:t.id}})),onMouseLeave:()=>window.dispatchEvent(new CustomEvent("pi:tool-hover",{detail:{toolCallId:null}})),children:[e.jsxs("button",{type:"button",className:"bash-row-head",title:y,"aria-expanded":k,onClick:()=>j(!k),children:[e.jsx("span",{className:`bash-state ${u}`,"aria-label":l(u==="run"?"running":u==="err"?"error":"done"),children:u==="run"?"●":u==="err"?"✗":u==="empty"?"−":"✓"}),e.jsx("span",{className:"bash-readable-title",children:b.title}),a&&e.jsx("span",{className:"bash-attempt-count",children:l("commandAttempts",{n:a})}),b.title!==ci(b.command)&&e.jsx("code",{className:"bash-command-secondary",children:b.command}),F.length>1&&e.jsx("span",{className:"bash-extra-lines",children:l("bashExtraLines",{n:F.length-1})}),e.jsxs("span",{className:"bash-row-stats",children:[u==="run"?l("running"):q!==void 0&&u==="err"?l("bashExitCode",{n:q}):l("toolLineCount",{n:ie.length}),((ye=n.status)==null?void 0:ye.durationMs)!==void 0&&yr(n.status.durationMs)?` · ${yr(n.status.durationMs)}`:""]}),k?e.jsx(nn,{}):e.jsx(_t,{})]}),k&&e.jsxs("div",{className:"bash-row-body",children:[L.directory&&e.jsx("div",{className:"bash-row-directory",children:l("bashGroupCwd",{path:L.directory})}),e.jsx("pre",{className:"bash-full-command",children:y}),ie.length>0&&e.jsx("div",{className:"bash-numbered-output","data-msg-id":(oe=n.result)==null?void 0:oe.id,children:(I?ie:ie.slice(0,6)).map((U,fe)=>e.jsxs("div",{className:`bash-numbered-line${Vs(U)?" error":/(?:\bPASS\b|\bpassed\b|\bsummary\b)/i.test(U)?" important":""}`,children:[e.jsx("span",{"aria-hidden":"true",children:fe+1}),e.jsx("code",{children:U||" "})]},fe))}),ie.length>6&&e.jsx("button",{type:"button",className:"bash-group-more",onClick:()=>E(!I),children:I?l("collapseCode"):l("bashRemainingLines",{n:ie.length-6})}),e.jsxs("div",{className:"bash-row-actions",children:[e.jsx("button",{type:"button",onClick:()=>void Re("command"),children:l($==="command"?"copied":"bashCopyCommand")}),e.jsx("button",{type:"button",disabled:!B,onClick:()=>void Re("output"),children:l($==="output"?"copied":"bashCopyOutput")}),ke&&((Fe=n.result)==null?void 0:Fe.toolOutputUrl)&&e.jsx(Nr,{url:n.result.toolOutputUrl}),e.jsx("button",{type:"button",title:l("bashOpenTerminalHint"),onClick:()=>window.dispatchEvent(new CustomEvent("pi-harness:plugin-run-command",{detail:{title:ci(F[0]),command:y}})),children:l("bashOpenTerminal")}),u==="run"&&s&&e.jsx("button",{type:"button",onClick:s,children:l("stopBash")})]}),c]})]})}function Jh(t,n){if(t.kind==="replaced")return n("planReplaced",{id:t.planId,revision:t.revision});if(t.kind==="status")return n("planStatusChanged",{status:n(t.status==="active"?"running":t.status==="completed"?"done":t.status==="failed"?"error":"cancelled")});const s={added:"todoItemAdded",updated:"todoItemUpdated",pending:"todoItemPending",started:"todoItemStarted",completed:"todoItemCompleted",removed:"todoItemDeleted"};return t.position?n(s[t.kind],{n:t.position}):`${n("todoRemoved")}: ${t.title}`}function Qh({view:t,toolCallId:n}){const s=nt(),r=t.changes.map(a=>Jh(a,s)).join(s("todoChangeSeparator"));if(t.kind==="update")return e.jsxs("div",{className:"todo-update","data-tool-call-id":n,children:[e.jsx("span",{className:"todo-update-dot","aria-hidden":"true"}),e.jsx("span",{children:r||s("planRecorded")}),e.jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("pi:jump-tool",{detail:{...t.target,todoItemIds:t.changes.flatMap(a=>"stepId"in a?[a.stepId]:[])}})),children:s("todoView")})]});const i=t.snapshot;return e.jsxs("section",{className:"todo-checklist","data-tool-call-id":n,"aria-label":s("taskPlanSource"),children:[e.jsxs("header",{className:"todo-checklist-head",children:[e.jsx("strong",{children:i.title}),e.jsx("span",{children:s("todoCounts",{total:i.steps.length,completed:i.completedStepIds.length})}),e.jsx("span",{className:"todo-checklist-state",children:s(i.status==="active"?"planActive":i.status==="completed"?"done":i.status==="failed"?"error":"cancelled")})]}),e.jsx("ol",{className:"todo-checklist-items",children:i.steps.map(a=>{const o=i.completedStepIds.includes(a.id)?"completed":i.currentStepId===a.id?"in_progress":"pending";return e.jsxs("li",{className:`todo-checklist-item ${o}`,"data-todo-item-id":a.id,tabIndex:-1,children:[e.jsx("span",{className:"todo-checklist-mark","aria-hidden":"true",children:o==="completed"?"✓":""}),e.jsx("div",{children:a.detail?e.jsxs("details",{children:[e.jsx("summary",{children:a.title}),e.jsx("p",{children:a.detail})]}):a.title})]},a.id)})}),e.jsxs("p",{className:"task-outline-criteria",children:[s("taskCompletionCriteria"),":",i.completionCriteria]}),r&&e.jsx("p",{className:"todo-update",children:r})]})}const Yh=20*1024*1024;function Cs(t){return t.type==="text"&&typeof t.text=="string"?t:null}function Rl(t){return t.type==="thinking"&&typeof t.thinking=="string"?t:null}function ws(t){return t.type==="toolCall"&&typeof t.id=="string"&&typeof t.name=="string"?t:null}function Il(t){return t.type==="image"&&typeof t.dataUrl=="string"?t:null}function Ll(t){return t.type==="bash"&&typeof t.command=="string"?t:null}function Xh(t){return t.imageData?"image":t.uploadPath?"upload":t.fileData?"file":"path"}function Zh(t,n){if(t.editorSnapshot)return`${t.path} · ${n(t.editorSnapshot.dirty?"currentFileDraft":"currentFileLabel")}`;if(t.imageData)return n("attachImage",{name:t.name??"image"});if(t.uploadPath)return n("attachFile",{name:t.name??t.uploadPath});if(t.fileData)return n("attachFile",{name:t.name??"file"});const s=t.path.split("/").pop()??t.path;return t.mode==="lines"&&t.lines?n("attachLines",{path:s,start:t.lines.start,end:t.lines.end}):t.mode==="reference"?n("refOnly",{path:s}):n("attachContent",{path:s})}const zr=d.memo(function({incident:n,recovery:s,toolsRunning:r,bashActive:i,bashTitle:a,toolMessageIds:o,planViews:c,continuation:l,conversationId:p,message:u,toolResults:f,retriedEditIds:k,liveOutputs:j,toolStatuses:I,streaming:E,isLast:$,onEdit:N,onKillBash:R,onCollapse:y,questionAttachments:L,qnIndex:b,qnActive:F,onJump:B,thinkingWrap:ie,toolsWrap:Q}){var Ce;const q=nt(),ke=bc(),[Re,O]=d.useState(!1),[_e,M]=d.useState(""),[V,ve]=d.useState([]),[ye,oe]=d.useState(!1),[Fe,U]=d.useState(null),fe=u.role==="user"&&u.content.length>0&&u.content.every(be=>be.type==="text"),ce=d.useRef(null),[ae,z]=d.useState(!1),[Z,W]=d.useState(!1),[ge,Ie]=d.useState(0);d.useLayoutEffect(()=>{if(!fe||Re||ae)return;const be=ce.current;if(!be)return;const ze=()=>{W(be.scrollHeight>be.clientHeight+2);const Le=u.content.map(vt=>{var se;return((se=Cs(vt))==null?void 0:se.text)??""}).filter(Boolean).join(`
|
|
238
|
-
`).split(/\r?\n/).length,Xe=parseFloat(getComputedStyle(be).lineHeight)||22;Ie(Math.max(Le,Math.ceil(be.scrollHeight/Xe)))},tt=new ResizeObserver(ze);return tt.observe(be),ze(),()=>tt.disconnect()},[fe,u.content,Re,ae]);const Ae=be=>{U(be),window.setTimeout(()=>U(ze=>ze===be?null:ze),4e3)};if(u.role==="toolResult")return null;if(u.origin==="auto-reminder")return e.jsx("div",{className:"tool-reminder-event","data-msg-id":u.id,title:u.content.map(be=>be.type==="text"?be.text:"").join(`
|
|
239
|
-
`),children:e.jsxs("span",{children:["↻ ",q("toolReminderEvent"),u.timestamp?` · ${qa(u.timestamp)}`:""]})});if(u.role==="system"&&!u.content.some(be=>be.type==="text"?typeof be.text=="string"&&be.text.trim():be.type!=="thinking"))return null;const re=u.role==="custom"&&u.customType==="file",we=u.questionText??u.content.map(be=>{var ze;return((ze=Cs(be))==null?void 0:ze.text)??""}).filter(Boolean).join(`
|
|
240
|
-
`),A=u.role==="user"?Es(we):null,xe=Tl(A?A.userMessage??`skill:${A.name}`:we),_=u.role==="user"&&!E&&!!N,Se=async be=>{const ze=[];for(const tt of be){if(!ns(tt.type))continue;const Ye=await pi(tt);Ye&&ze.push({path:"",imageData:Ye.data,mimeType:Ye.mimeType,name:Ye.name})}ze.length>0&&ve(tt=>[...tt,...ze])},J=async be=>{if(be.size>Yh){Ae(q("fileTooLarge",{name:be.name,size:20}));return}let ze;try{ze=(await new Promise((Ye,Le)=>{const Xe=new FileReader;Xe.onload=()=>Ye(Xe.result),Xe.onerror=()=>Le(Xe.error??new Error("read failed")),Xe.readAsDataURL(be)})).replace(/^data:[^;]*;base64,/,"")}catch{Ae(q("fileLoadFailed",{name:be.name}));return}ve(tt=>[...tt,{path:"",fileData:ze,name:be.name,size:be.size,mimeType:be.type||void 0}])},De=async be=>{const ze=[];for(const tt of be)ns(tt.type)?ze.push(tt):J(tt);ze.length>0&&await Se(ze)},G=()=>{M(A?`/skill:${A.name}${A.userMessage?` ${A.userMessage}`:""}`:u.questionText??u.content.map(be=>{var ze;return((ze=Cs(be))==null?void 0:ze.text)??""}).filter(Boolean).join(`
|
|
241
|
-
`)),ve(L??[]),O(!0)},Oe=be=>{const ze=_e.trim();ze&&(N==null||N(u.id,ze,V.length>0?V:void 0,{entryId:u.entryId,newSession:be}),O(!1))},Ne=u.role==="custom"&&(u.customType==="goal-review"||u.customType==="goal-wizard"),Ee=u.role==="custom"&&u.customType==="goal-wizard",et=be=>{const ze=[],tt=Ye=>{var Le,Xe;return{result:f.get(Ye.id),nestedCalls:Sl(Ye.id,I),liveOutput:(Le=j.get(Ye.id))==null?void 0:Le.text,codemode:(Xe=j.get(Ye.id))==null?void 0:Xe.codemode,status:I.get(Ye.id),streaming:E}};for(let Ye=0;Ye<u.content.length;Ye++){const Le=u.content[Ye];if(be&&Le.type==="text")continue;const Xe=ws(Le),vt=Xe&&(c==null?void 0:c.get(Xe.id));if(Xe&&vt){ze.push(e.jsx(Qh,{toolCallId:Xe.id,view:vt},Xe.id));continue}if((Xe==null?void 0:Xe.name)==="write"||(Xe==null?void 0:Xe.name)==="edit"){const se=[Xe];for(;Ye+1<u.content.length;){const w=ws(u.content[Ye+1]);if((w==null?void 0:w.name)!=="write"&&(w==null?void 0:w.name)!=="edit")break;se.push(w),Ye++}const Ue=ke?se.filter(w=>{var H;return!f.get(w.id)||((H=f.get(w.id))==null?void 0:H.isError)}):se;Ue.length>=3?ze.push(e.jsx(Fh,{items:Ue.map(w=>({block:w,view:tt(w)})),retriedIds:k},`${u.id}-${Xe.id}`)):ze.push(...Ue.map(w=>e.jsx(Nl,{item:{block:w,view:tt(w)},retried:k==null?void 0:k.has(w.id)},`${u.id}-${w.id}`)));continue}if((Xe==null?void 0:Xe.name)==="bash"){const se=[Xe];for(;Ye+1<u.content.length;){const Ue=ws(u.content[Ye+1]);if((Ue==null?void 0:Ue.name)!=="bash")break;se.push(Ue),Ye++}ze.push(e.jsx(Gh,{active:i??r??E,title:a,items:se.map(Ue=>({block:Ue,view:{...tt(Ue),streaming:r??E},messageId:(o==null?void 0:o.get(Ue.id))??u.id})),onKill:R},Xe.id));continue}if((Xe==null?void 0:Xe.name)==="read"){const se=[Xe];for(;Ye+1<u.content.length;){const Ue=ws(u.content[Ye+1]);if((Ue==null?void 0:Ue.name)!=="read")break;se.push(Ue),Ye++}ze.push(e.jsx(gh,{items:se.map(Ue=>({block:Ue,view:tt(Ue)})),wrap:Q},`${u.id}-${Xe.id}`));continue}if((Xe==null?void 0:Xe.name)==="grep"){ze.push(e.jsx(vh,{block:Xe,view:tt(Xe),wrap:Q},`${u.id}-${Xe.id}`));continue}ze.push(e.jsx(Wa,{suppressLeak:!!n,block:Le,user:u.role==="user",toolResults:f,liveOutputs:j,toolStatuses:I,streaming:E,isLast:$&&Ye===u.content.length-1,onKillBash:R,toolsWrap:Q,thinkingWrap:ie},`${u.id}-${Ye}`))}return ze};return e.jsxs("div",{className:`msg msg-${u.role}${Ne?" msg-goal-review":""}${l?" msg-continuation":""}`,"data-role":u.role,"data-msg-id":u.id,children:[e.jsxs("div",{className:"msg-meta",children:[e.jsx("span",{className:"msg-role",children:u.role==="custom"?Ee?q("goalWizardCard"):Ne?q("goalBarTitle"):u.customType==="file"?q("attachment"):`${q("plugin")} · ${u.customType??q("unknown")}`:Ml(u.role,q)}),u.model&&e.jsx("span",{className:"msg-model",children:u.model}),u.timestamp&&e.jsx("span",{className:"msg-time",title:new Date(u.timestamp).toLocaleString(),children:qa(u.timestamp)}),y&&e.jsxs("button",{type:"button",className:"msg-collapse-btn",title:q("collapseMsg"),onClick:()=>y(u.id),children:[e.jsx(nn,{})," ",q("collapseMsg")]}),b!==void 0&&B&&e.jsxs("button",{type:"button",className:`qn-tag ${F?"active":""}`,title:`${b+1}. ${xe}`,"aria-label":`${b+1}. ${xe}`,onClick:()=>B(u.id),children:[e.jsx("span",{className:"qn-tag-bar"}),e.jsx("span",{className:"qn-tag-idx",children:b+1})]})]}),(u.label||u.siblings)&&e.jsxs("div",{className:"message-tree-controls",children:[u.label&&e.jsx("span",{className:"tree-label",children:u.label}),u.siblings&&p&&e.jsxs("span",{className:"tree-siblings",children:[e.jsx("button",{"aria-label":q("treePrevious"),disabled:!u.siblings.prevTarget||E,onClick:()=>fa(p,u.siblings.prevTarget),children:"‹"}),e.jsxs("span",{children:[u.siblings.index," / ",u.siblings.count]}),e.jsx("button",{"aria-label":q("treeNext"),disabled:!u.siblings.nextTarget||E,onClick:()=>fa(p,u.siblings.nextTarget),children:"›"})]})]}),e.jsx("div",{className:"msg-body",children:Re?e.jsxs("div",{className:`msg-editor${ye?" drag-over":""}`,onDragOver:be=>{be.preventDefault(),be.stopPropagation(),oe(!0)},onDragLeave:be=>{be.currentTarget.contains(be.relatedTarget)||oe(!1)},onDrop:be=>{var ze;be.preventDefault(),be.stopPropagation(),oe(!1),De(Array.from(((ze=be.dataTransfer)==null?void 0:ze.files)??[]))},children:[V.length>0&&e.jsx("div",{className:"msg-editor-images",children:V.map((be,ze)=>{var Ye;const tt=Xh(be);return e.jsxs("span",{className:`msg-editor-img ${tt==="image"?"":"file-chip"}`,title:Zh(be,q),children:[tt==="image"?e.jsx("img",{src:`data:${be.mimeType??"image/png"};base64,${be.imageData}`,alt:be.name}):e.jsxs("span",{className:"msg-editor-file",children:[e.jsx("span",{className:"msg-editor-file-icon",children:tt==="path"?be.mode==="reference"?"🔗":"📎":"📄"}),e.jsx("span",{className:"msg-editor-file-name",children:be.name??((Ye=be.path)==null?void 0:Ye.split("/").pop())})]}),e.jsx("button",{type:"button",className:"msg-editor-img-remove",title:q("removeAttachment"),onClick:()=>ve(Le=>Le.filter((Xe,vt)=>vt!==ze)),children:e.jsx(qt,{})})]},`${be.name??be.path??"att"}-${ze}`)})}),Fe&&e.jsx("div",{className:"msg-editor-notice",children:Fe}),e.jsx("textarea",{className:"msg-editor-input",value:_e,autoFocus:!0,placeholder:q("editPlaceholder"),rows:Math.max(2,Math.min(10,_e.split(`
|
|
242
|
-
`).length+1)),onChange:be=>M(be.target.value),onPaste:be=>{var tt;const ze=[];for(const Ye of((tt=be.clipboardData)==null?void 0:tt.items)??[])if(Ye.kind==="file"&&ns(Ye.type)){const Le=Ye.getAsFile();Le&&ze.push(Le)}ze.length!==0&&(be.preventDefault(),Se(ze))},onKeyDown:be=>{be.key==="Enter"&&(be.metaKey||be.ctrlKey)?(be.preventDefault(),Oe()):be.key==="Escape"&&O(!1)}}),e.jsxs("div",{className:"msg-editor-actions",children:[e.jsxs("details",{className:"tree-edit-menu",children:[e.jsx("summary",{children:q("treeEditOptions")}),e.jsx("button",{disabled:!_e.trim(),onClick:()=>Oe(!0),children:q("treeFork")})]}),e.jsxs("span",{className:"msg-editor-hint",children:[e.jsx(yo,{})," ",q("editAttachmentHint")]}),e.jsx("button",{type:"button",className:"chip",onClick:()=>O(!1),children:q("cancel")}),e.jsxs("button",{type:"button",className:"chip primary",disabled:!_e.trim(),title:q("reaskFromHere"),onClick:()=>Oe(),children:[e.jsx(ra,{})," ",q("reaskFromHere")]})]})]}):e.jsxs(e.Fragment,{children:[u.errorMessage&&e.jsx("div",{className:"msg-error",children:u.errorMessage}),re?e.jsx(em,{message:u}):A?e.jsxs(e.Fragment,{children:[e.jsx(nm,{block:A}),A.userMessage&&e.jsx("div",{className:"msg-text",children:e.jsx(Fn,{text:kr(A.userMessage),fileLinks:!0})}),et(!0)]}):u.role==="user"?e.jsx("div",{ref:ce,className:`user-message-content${fe&&!ae?" collapsed":""}`,children:u.questionText!==void 0?e.jsxs(e.Fragment,{children:[e.jsx(Fn,{text:kr(u.questionText),fileLinks:!0}),u.content.filter(be=>be.type==="image").map((be,ze)=>e.jsx(Wa,{block:be,user:!0,toolResults:f,liveOutputs:j,toolStatuses:I,streaming:E,isLast:!1},ze))]}):et(!1)}):et(!1),n&&n.last.id===u.id&&n.state==="stopped"?e.jsx(ih,{incident:n,model:u.model||n.first.model||q("unknown"),recovery:(s==null?void 0:s.messageId)===u.id?s:void 0}):(n==null?void 0:n.leaks.some(be=>be.id===u.id))&&e.jsxs("div",{className:"tool-unexecuted-inline",children:[e.jsx("span",{children:"✗"})," ",q("toolUnexecutedInline"),n.reminders.length>0&&e.jsxs("small",{children:[" · ",q("toolAutoReminded")]})]}),u.role==="user"&&((Ce=u.userAttachments)==null?void 0:Ce.map((be,ze)=>e.jsxs("details",{className:"user-attachment-card",children:[e.jsx("summary",{children:be.path}),e.jsx("pre",{children:be.preview})]},ze))),fe&&Z&&!Re&&!A&&e.jsx("button",{type:"button",className:"user-message-expand",onClick:()=>z(be=>!be),children:ae?q("collapseCode"):q("expandAllLines",{n:ge})})]})}),_&&!Re&&e.jsx("div",{className:"msg-actions",children:e.jsxs("button",{type:"button",className:"msg-action",title:q("editReaskTip"),onClick:G,children:[e.jsx(ra,{})," ",q("editReask")]})})]})});function em({message:t}){var j;const n=nt(),[s,r]=d.useState(!1),i=t.details??{},a=i.name??i.path??n("attachment"),o=i.type==="folder",c=i.mode==="reference",l=i.mode==="bridged",p=t.content.filter(I=>I.type==="text").map(I=>I.text).join(`
|
|
243
|
-
`),u=((j=i.editorSnapshot)==null?void 0:j.text)??tm(p),f=t.content.find(I=>I.type==="image"),k=u.split(`
|
|
244
|
-
`).length;return e.jsxs("div",{className:`attachcard ${c?"reference":""}`,children:[e.jsxs("button",{type:"button",className:"attachcard-head",onClick:()=>r(I=>!I),children:[e.jsx("span",{className:"attachcard-icon",children:o?"📁":"📎"}),e.jsx("span",{className:"attachcard-name",children:a}),i.editorSnapshot&&e.jsx("span",{className:"attachcard-mode",children:n(i.editorSnapshot.dirty?"currentFileDraft":"currentFileLabel")}),i.path&&e.jsx("span",{className:"attachcard-path",children:i.path}),e.jsx("span",{className:`attachcard-mode ${i.mode==="lines"?"lines":c?"ref":l?"bridged":"inline"}`,children:c?o?n("folderRefShort"):`${n("refOnlyShort")} · ${Ua(i.size)}`:l?n("bridgedVision"):f?n("image"):i.mode==="lines"?n("inlineLinesRange",{start:i.startLine??1,end:i.endLine??i.lines??1}):n("inlineLines",{n:i.lines??k})}),!c&&(s?e.jsx(nn,{}):e.jsx(_t,{}))]}),!c&&s&&(l?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"attachcard-bridgenote",children:n("bridgedVisionDetail")}),(f==null?void 0:f.dataUrl)&&e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:f.dataUrl,alt:a})}),u&&e.jsx("pre",{className:"attachcard-content",children:u})]}):f!=null&&f.dataUrl?e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:f.dataUrl,alt:a})}):e.jsx("pre",{className:"attachcard-content",children:u})),c&&e.jsx("div",{className:"attachcard-refnote",children:o?n("folderNotExpanded"):n("fileNotExpanded",{size:Ua(i.size)})})]})}function Ua(t){return t===void 0?"":t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}function tm(t){const n=t.match(/^\s*<file path="[^"]*"(?:\s+lines="[^"]*")?>\s*```\s*\n?([\s\S]*?)\n?```\s*<\/file>\s*$/);if(n)return n[1].trim();const s=t.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return s?s[1].trim():t.trim()}function nm({block:t}){const n=nt(),[s,r]=d.useState(!1),i=Cl(t.content);return e.jsxs("div",{className:`skillcard${s?" expanded":""}`,children:[e.jsxs("button",{type:"button",className:"skillcard-head",onClick:()=>r(a=>!a),title:t.location,children:[e.jsx("span",{className:"skillcard-icon","aria-hidden":"true",children:"◆"}),e.jsxs("span",{className:"skillcard-name",children:[n("skillLabel")," · ",t.name]}),s&&e.jsx("span",{className:"skillcard-path",children:t.location}),e.jsxs("span",{className:"skillcard-action",children:[s?e.jsx(Co,{}):e.jsx(nn,{}),n(s?"collapseMsg":"expandMsg")]})]}),s&&e.jsxs("div",{className:"skillcard-body",children:[i.fields.length>0&&e.jsx("dl",{className:"toolcall-frontmatter",children:i.fields.map(({name:a,value:o})=>e.jsxs("div",{children:[e.jsx("dt",{children:a}),e.jsx("dd",{children:o})]},a))}),e.jsx(Fn,{text:i.body})]})]})}function Wa({suppressLeak:t,block:n,user:s,toolResults:r,liveOutputs:i,toolStatuses:a,streaming:o,isLast:c,onKillBash:l,thinkingWrap:p,toolsWrap:u}){const f=nt(),k=Cs(n);if(k){const N=o&&c,R=!s&&(!o||t)?bi(k.text):null,y=R?R.before:k.text,L=s?null:El(y),b=L?L.visible:y;return!b.trim()&&!(L!=null&&L.leaked.trim())&&!R&&!k.truncated?null:e.jsxs("div",{className:`msg-text${!s&&!c&&jl(b)?" process-narration":""}`,children:[(L==null?void 0:L.leaked)&&!t&&e.jsx(ah,{text:L.leaked}),b&&(N?e.jsx(ph,{text:s?kr(b):b}):e.jsx(Fn,{text:s?kr(b):b,fileLinks:s})),k.truncated&&e.jsx("div",{className:"trunc-note",children:f("truncated")})]})}const j=Rl(n);if(j)return j.thinking.trim()?e.jsx(qo,{thinking:j.thinking,durationMs:j.durationMs,streaming:o&&c,wrap:p}):null;const I=ws(n);if(I){const N=r.get(I.id),R=i.get(I.id),y={nestedCalls:Sl(I.id,a),result:N,liveOutput:R==null?void 0:R.text,codemode:R==null?void 0:R.codemode,streaming:o,status:a.get(I.id)};return e.jsx(Fi,{block:I,view:y,onKillBash:l,wrap:u})}const E=Il(n);if(E&&E.dataUrl)return e.jsx("div",{className:"msg-image",children:e.jsx("img",{src:E.dataUrl,alt:"attachment"})});const $=Ll(n);return $?e.jsxs("div",{className:"bashblock",children:[e.jsxs("div",{className:"bashblock-command",children:[e.jsx("span",{className:"bashblock-prompt",children:"$"}),e.jsx("code",{children:$.command}),$.exitCode!==void 0&&e.jsx("span",{className:`bashblock-exit ${$.exitCode===0?"ok":"err"}`,children:f("exitCode",{code:$.exitCode})}),$.cancelled&&e.jsx("span",{className:"bashblock-exit err",children:f("cancelled")})]}),$.output&&e.jsx("pre",{className:"bashblock-output",children:$.output}),$.truncated&&e.jsx("div",{className:"trunc-note",children:f("outputTruncated")})]}):null}function Ml(t,n){switch(t){case"user":return n("role.user");case"assistant":return n("role.assistant");case"toolResult":return n("role.tool");case"bashExecution":return n("role.bash");case"branchSummary":return n("role.branch");case"compactionSummary":return n("role.compaction");default:return t}}function qa(t){const n=new Date(t),s=String(n.getHours()).padStart(2,"0"),r=String(n.getMinutes()).padStart(2,"0");return`${s}:${r}`}function sm(t,n,s){const r=new Map,i=new Map;for(const a of t)if(a.role==="assistant")for(const o of a.content){if(o.type!=="toolCall"||o.name!=="plan"||typeof o.id!="string")continue;const c=n.get(o.id),l=c==null?void 0:c.planSnapshot;if(!l||c!=null&&c.isError)continue;for(const u of l.changes)if(u.kind==="replaced"){const f=i.get(`${s}:${u.planId}`);f&&(f.snapshot={...f.snapshot,status:"cancelled",currentStepId:null})}let p=i.get(`${s}:${l.planId}`);p?(p.snapshot=l,r.set(o.id,{kind:"update",target:p.target,changes:l.changes})):(p={kind:"card",target:{messageId:a.id,toolCallId:o.id},snapshot:l,changes:l.changes.filter(u=>u.kind==="replaced")},i.set(`${s}:${l.planId}`,p),r.set(o.id,p))}return r}function rm(t,n=!0){var r;const s=n?((r=El(t))==null?void 0:r.visible)??t:t;return cs(s).replace(/`+([^`]+)`+/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*|__([^_]+)__/g,(i,a,o)=>a??o).replace(/\*([^*]+)\*/g,"$1").replace(/^#{1,6}\s+/,"")}function im(t,n,s,r=new Set,i=new Set){const a=new Map,o=new Set;let c=-1,l=[];const p=()=>{c>=0&&l.length>0&&a.set(c,l),c=-1,l=[]},u=Math.min(n,t.length);for(let f=0;f<u;f++){const k=t[f];if(k.role==="toolResult"||k.origin==="auto-reminder"||i.has(k.id)){o.add(f);continue}if(r.has(f)&&p(),s.has(k.id)||Pi(k)||Ai(k)){p();continue}c>=0&&l[0].role===k.role?(l.push(k),o.add(f)):(p(),c=f,l=[k])}return p(),{groupAt:a,absorbed:o}}const am=1800*1e3;function om(t){const n=new Map;let s;for(let r=0;r<t.length;r++){const i=t[r];if(i.role==="toolResult"||!i.timestamp)continue;const a=i.timestamp;if(s!==void 0&&a-s>am){const o=new Date(a);n.set(r,`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`)}s=a}return n}const Vr=4,lm=d.memo(function({messages:n,onExpand:s}){const r=nt(),i=n[0];let a="";e:for(const I of n)for(const E of I.content){const $=Cs(E);if($&&$.text.trim()&&(a=rm($.text,I.role==="assistant"),a))break e}if(!a&&i.role==="custom"&&i.customType==="file"){const I=i.details??{};a=I.name??I.path??""}a.length>90&&(a=`${a.slice(0,90)}…`);const o=new Map;let c=0,l=0,p=0;for(const I of n)for(const E of I.content){const $=ws(E);if($){o.set($.name,(o.get($.name)??0)+1);continue}Rl(E)?c++:Ll(E)?l++:Il(E)&&p++}const u=[...o.entries()].sort((I,E)=>E[1]-I[1]||I[0].localeCompare(E[0])),f=[];for(const[I,E]of u.slice(0,Vr))f.push({key:`t:${I}`,label:sr(I,E),kind:"tool"});u.length>Vr&&f.push({key:"t:more",label:`+${u.length-Vr}`,kind:"tool"}),c&&f.push({key:"thinking",label:sr(r("thinking"),c),kind:"meta"}),l&&f.push({key:"bash",label:sr(r("bashRuns"),l),kind:"meta"}),p&&f.push({key:"images",label:sr(r("images"),p),kind:"meta"});const k=i.role==="custom"&&i.customType==="file"?r("attachment"):Ml(i.role,r),j=n.map(I=>I.id);return e.jsxs("button",{type:"button",className:"msg-collapsed","data-msg-id":i.id,title:`${r("expandMsg")} · ${a||f.map(I=>I.label).join(" · ")||i.role}`,onClick:()=>s(j),children:[e.jsx("span",{className:`msg-collapsed-role role-${i.role}`,children:k}),e.jsxs("span",{className:"msg-collapsed-body",children:[a&&e.jsx("span",{className:"msg-collapsed-preview",children:a}),f.length>0&&e.jsx("span",{className:"msg-collapsed-chips",children:f.map(I=>e.jsx("span",{className:`msg-collapsed-chip is-${I.kind}`,children:I.label},I.key))})]}),i.timestamp?e.jsx("span",{className:"msg-collapsed-time",children:cm(i.timestamp)}):null,e.jsx("span",{className:"msg-collapsed-action","aria-hidden":"true",children:e.jsx(_t,{})})]})});function sr(t,n){return n>1?`${t} ×${n}`:t}function cm(t){const n=new Date(t),s=String(n.getHours()).padStart(2,"0"),r=String(n.getMinutes()).padStart(2,"0");return`${s}:${r}`}const za=d.memo(function({id:n,show:s,height:r,containerRef:i,onMeasured:a,lazyRef:o,children:c}){const l=d.useRef(null),p=d.useRef(null);return d.useLayoutEffect(()=>{const u=p.current;if(p.current=s,!s||u!==!1)return;const f=l.current,k=i.current;if(!f||!k)return;const j=f.offsetHeight;a==null||a(n,j);const I=j-r;if(I!==0){const E=f.parentElement;E&&E.getBoundingClientRect().bottom<=k.getBoundingClientRect().top&&(k.scrollTop+=I)}},[s]),s?e.jsx("div",{ref:o,"data-lazy-id":n,children:e.jsx("div",{ref:l,children:c})}):e.jsx("div",{ref:o,className:"msg-lazy-ph","data-msg-id":n,"data-lazy-id":n,style:{height:r},"aria-hidden":"true"})});function dm(t,n,s,r){const i=[],a=[];let o=0;for(const c of t){if(s.has(c.id))continue;c.top<n.bottom&&c.bottom>n.top?r.has(c.id)&&i.push(c.id):r.has(c.id)||(a.push(c.id),c.bottom<=n.top&&(o+=c.bottom-c.top))}return{show:i,hide:a,shrinkAbove:o}}function um(t,n){if(n.show.length===0&&n.hide.length===0)return t;const s=new Set(t);for(const r of n.show)s.delete(r);for(const r of n.hide)s.add(r);return s}function pm(t,n,s){const r=new Set;let i=0;for(let a=t.length-1;a>=0&&!(a<t.length-1&&i>=s);a--){const o=t[a];r.add(o.id),i+=n.get(o.id)??Pl(o.role,o.customType)}return r}function Pl(t,n){switch(t){case"user":return 72;case"assistant":return 280;case"toolResult":return 8;case"custom":return n==="file"?96:72;default:return 60}}function hm(t){if(t.role==="toolResult")return"";const n=[];for(const s of t.content)mm(s,n);return t.errorMessage&&n.push(t.errorMessage),n.join(`
|
|
245
|
-
`)}function mm(t,n){if(typeof t.text=="string"){n.push(t.text);return}switch(t.type){case"thinking":typeof t.thinking=="string"&&n.push(t.thinking);break;case"toolCall":{typeof t.name=="string"&&n.push(t.name),typeof t.argumentsText=="string"&&n.push(t.argumentsText);break}case"bash":typeof t.command=="string"&&n.push(t.command),typeof t.output=="string"&&n.push(t.output);break}}function fm(t,n){const s=n.trim().toLowerCase();if(!s)return 0;const r=t.toLowerCase();let i=0,a=r.indexOf(s);for(;a!==-1;)i++,a=r.indexOf(s,a+s.length);return i}function gm(t,n){const s=n.trim().toLowerCase();if(!s)return[];const r=[];for(const i of t){const a=hm(i);if(!a)continue;const o=fm(a,s);for(let c=0;c<o;c++)r.push({messageId:i.id,occurrence:c})}return r}function xm(t,n){var o;const s=new Map,r=[],i=n.toLowerCase();if(!i)return{byMsg:s,all:r};const a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(c){const l=c.parentElement;return!l||l.closest(".search-bar")?NodeFilter.FILTER_REJECT:(c.textContent??"").toLowerCase().includes(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let c=a.nextNode();c;c=a.nextNode()){const l=(c.textContent??"").toLowerCase(),p=(o=c.parentElement)==null?void 0:o.closest("[data-msg-id]");if(!p)continue;const u=p.getAttribute("data-msg-id")??"";let f=l.indexOf(i);for(;f!==-1;){const k=document.createRange();k.setStart(c,f),k.setEnd(c,f+i.length),r.push(k);const j=s.get(u);j?j.push(k):s.set(u,[k]),f=l.indexOf(i,f+i.length)}}return{byMsg:s,all:r}}function as(t,n){const s=CSS;if(!s.highlights)return;if(n.length===0){s.highlights.delete(t);return}const r=window.Highlight;r&&s.highlights.set(t,new r(...n))}function vm({containerRef:t,messages:n,open:s,onClose:r,onEnsureExpanded:i}){const a=nt(),o=d.useRef(null),[c,l]=d.useState(""),[p,u]=d.useState(0),f=d.useDeferredValue(c),k=s?f.trim():"",j=d.useMemo(()=>s?gm(n,k):[],[n,k,s]),I=d.useRef(j);I.current=j;const E=d.useRef(p);E.current=p,d.useEffect(()=>{s&&(u(0),requestAnimationFrame(()=>{var y;return(y=o.current)==null?void 0:y.select()}))},[s]),d.useEffect(()=>{if(!s)return;const y=L=>{L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),r())};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[s,r]),d.useEffect(()=>(s||(as("msg-search",[]),as("msg-search-active",[])),()=>{as("msg-search",[]),as("msg-search-active",[])}),[s]);const $=d.useCallback(y=>{const L=t.current;if(!L)return;const b=L.querySelector(`[data-msg-id="${y}"]`);b&&(b.classList.remove("msg-flash"),b.offsetWidth,b.classList.add("msg-flash"))},[t]);d.useLayoutEffect(()=>{if(!s||!k)return;const y=t.current;if(!y)return;let L=!1,b=0;return b=requestAnimationFrame(()=>{var ke;if(L)return;const F=I.current,B=F[Math.min(E.current,F.length-1)];if(!B){as("msg-search",[]),as("msg-search-active",[]);return}i(B.messageId);const{byMsg:ie,all:Q}=xm(y,k);as("msg-search",Q);const q=(ke=ie.get(B.messageId))==null?void 0:ke[B.occurrence];if(q){as("msg-search-active",[q]);const Re=q.startContainer.parentElement??y.querySelector(`[data-msg-id="${B.messageId}"]`);Re==null||Re.scrollIntoView({block:"center"})}else $(B.messageId)}),()=>{L=!0,cancelAnimationFrame(b)}},[s,k,j,t,$,i]);const N=d.useCallback(y=>{const L=I.current;if(L.length===0)return;const b=(E.current+y+L.length)%L.length;u(b),i(L[b].messageId)},[i]);if(!s)return null;const R=j.length;return e.jsxs("div",{className:"search-bar",role:"search",children:[e.jsx("input",{ref:o,className:"search-input",type:"text",value:c,placeholder:a("searchPlaceholder"),onChange:y=>{l(y.target.value),u(0)},onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),N(y.shiftKey?-1:1))}}),e.jsx("span",{className:`search-count ${R===0?"empty":""}`,children:R===0?a("searchNoResults"):`${Math.min(p+1,R)}/${R}`}),e.jsx("button",{type:"button",className:"search-btn",title:a("searchPrev"),disabled:R===0,onClick:()=>N(-1),children:e.jsx(Co,{})}),e.jsx("button",{type:"button",className:"search-btn",title:a("searchNext"),disabled:R===0,onClick:()=>N(1),children:e.jsx(nn,{})}),e.jsx("button",{type:"button",className:"search-btn",title:a("searchClose"),onClick:r,children:e.jsx(qt,{})})]})}const Kr=new Map,km=15,Va=30,Ka=1200,ym=1600;function Ga(t){return t.content.some(n=>n.type==="toolCall")}const wm=[{key:"ex.understand",icon:"🔍"},{key:"ex.debug",icon:"🐛"},{key:"ex.test",icon:"🧪"},{key:"ex.review",icon:"🧹"}];function bm(t){return wm.map(({key:n,icon:s})=>({icon:s,text:t(n),prompt:t(`${n}.prompt`)}))}const es=new Map;function jm({event:t}){const n=nt(),s=t.errors??[],r=t.phase==="done"&&s.length>0,i=t.phase==="running"?n("reloadRunning"):r?n("reloadPartial",{count:s.length}):n("reloadDone"),a=t.extensions===void 0?"":n("reloadCounts",{extensions:t.extensions,skills:t.skills??0,prompts:t.prompts??0}),o=t.durationMs===void 0?"":` · ${(t.durationMs/1e3).toFixed(1)}s`,c=p=>p.length>8?`${p.slice(0,8).join(", ")} +${p.length-8}`:p.join(", "),l=t.resources?[n("reloadExtensionList",{names:c(t.resources.extensions)||"—"}),n("reloadSkillList",{names:c(t.resources.skills)||"—"}),n("reloadPromptList",{names:c(t.resources.prompts)||"—"})].join(`
|
|
246
|
-
`):"";return e.jsxs("div",{className:`reload-event${r?" failed":""}`,role:"status",title:a?`${a}${o}
|
|
247
|
-
${l}`:void 0,children:[e.jsx("div",{className:"reload-command",children:e.jsx("code",{children:"/reload"})}),e.jsxs("div",{className:"reload-event-line",children:[e.jsx("span",{className:t.phase==="running"?"reload-dots":"reload-mark","aria-hidden":"true",children:t.phase==="running"?e.jsxs(e.Fragment,{children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}):r?"!":"✓"}),e.jsxs("span",{children:[i,t.phase==="done"&&a?` · ${a}${o}`:o]})]}),r&&e.jsxs("details",{className:"reload-errors",children:[e.jsx("summary",{children:n("reloadDetails")}),e.jsx("ul",{children:s.map((p,u)=>e.jsxs("li",{children:[e.jsx("strong",{children:p.path||n("reloadGeneralError")}),e.jsx("span",{children:p.message})]},`${p.path}-${u}`))})]})]})}const Cm=d.memo(function({recovery:n,state:s,connected:r=!0,silenceNotified:i=!1,liveOutputs:a,toolStatuses:o,onEdit:c,onKillBash:l,onStop:p,thinkingWrap:u,toolsWrap:f,pendingEcho:k,reloadEvents:j=[]}){var Ot,Vt,jt,Xt;const I=nt(),E=d.useMemo(()=>yd(s.messages),[s.messages]);s={...s,messages:E};const $=d.useMemo(()=>Ms(s.streamingMessage?[...s.messages,s.streamingMessage]:s.messages,s.isStreaming),[s.messages,s.streamingMessage,s.isStreaming]),N=new Map($.incidents.flatMap(K=>[...K.leaks,K.last].map(ee=>[ee.id,K]))),R=d.useMemo(()=>{const K=[...j.filter(Be=>Be.conversationId===s.conversationId).map(Be=>({kind:"reload",event:Be})),...s.cwdEvents.filter(Be=>Be.cwd===s.cwd).map(Be=>({kind:"cwd",event:Be}))].sort((Be,te)=>Be.event.timestamp-te.event.timestamp),ee=[];let Ke=0;for(s.messages.forEach((Be,te)=>{for(;Ke<K.length&&K[Ke].event.timestamp<=(Be.timestamp??0);)ee.push(K[Ke++]);ee.push({kind:"message",message:Be,index:te})});Ke<K.length;)ee.push(K[Ke++]);return ee},[s.messages,s.conversationId,s.cwd,s.cwdEvents,j]),y=d.useRef(null),[L,b]=d.useState(!0),[F,B]=d.useState(!1),ie=d.useRef(!0),Q=d.useRef(0),q=d.useRef(!1);d.useLayoutEffect(()=>{const K=y.current,ee=es.get(s.conversationId);return K&&ee&&(ie.current=ee.bottom,q.current=!ee.bottom,b(ee.bottom),K.scrollTop=ee.bottom?K.scrollHeight:ee.top),()=>{K&&(es.delete(s.conversationId),es.set(s.conversationId,{top:K.scrollTop,bottom:ie.current,hidden:Ne.current,expanded:O.current,heights:J.current}),es.size>24&&es.delete(es.keys().next().value))}},[s.conversationId]);const[ke,Re]=d.useState(()=>{var K;return((K=es.get(s.conversationId))==null?void 0:K.expanded)??new Set}),O=d.useRef(ke);O.current=ke;const[_e,M]=d.useState(!1),V=s.streamingMessage?[...s.messages,s.streamingMessage]:s.messages,ve=d.useMemo(()=>{const K=new Map;for(const ee of s.messages)ee.role==="toolResult"&&ee.toolCallId&&K.set(ee.toolCallId,ee);return K},[s.messages]),ye=d.useMemo(()=>Ec(s.messages,ve),[s.messages,ve]),oe=(Ot=s.streamingMessage)!=null&&Ot.content.some(K=>{var ee;return K.type==="toolCall"&&typeof K.id=="string"&&((ee=ve.get(K.id))==null?void 0:ee.planSnapshot)})?s.streamingMessage:null,Fe=d.useMemo(()=>sm(oe?[...s.messages,oe]:s.messages,ve,s.conversationId),[s.messages,oe,ve,s.conversationId]),U=d.useMemo(()=>Mo(s.messages),[s.messages]),fe=d.useMemo(()=>sh(s.messages),[s.messages]),ce=d.useMemo(()=>om(s.messages),[s.messages]),ae=lu(V),z=((Vt=s.streamingMessage)==null?void 0:Vt.content.some(K=>K.type==="text"?typeof K.text=="string"&&!!K.text.trim()||!!K.truncated:K.type==="thinking"?typeof K.thinking=="string"&&!!K.thinking.trim():!0))??!1,Z=d.useMemo(()=>Lc(s.messages,s.taskProgress,s.cwd,s.isStreaming),[s.messages,s.taskProgress,s.cwd,s.isStreaming]),W=s.messages.findLastIndex(K=>K.role==="user"),ge=V.length>0?V[V.length-1].id:null,Ie=s.messages.length>Va?Math.max(0,s.messages.length-km):0,Ae=(jt=s.streamingMessage)!=null&&jt.content.length&&s.streamingMessage.content.every(K=>K.type==="toolCall"&&K.name==="bash")?s.streamingMessage:null,re=d.useMemo(()=>nh(Ae?[...s.messages,Ae]:s.messages,Ie,new Set(ce.keys())),[s.messages,Ae,Ie,ce]),we=d.useMemo(()=>im(s.messages,Ie,ke,new Set(ce.keys())),[s.messages,Ie,ke,ce]),[A,xe]=d.useState(()=>{var K;return((K=es.get(s.conversationId))==null?void 0:K.hidden)??new Set}),[_,Se]=d.useState(()=>new Set),J=d.useRef(((Xt=es.get(s.conversationId))==null?void 0:Xt.heights)??new Map),De=d.useMemo(()=>{const K=new Set(A);for(const ee of s.messages.slice(0,Ie))J.current.has(ee.id)||K.add(ee.id);return K},[A,s.messages,Ie]),G=d.useRef(new Map),Oe=d.useRef(0),Ne=d.useRef(De);Ne.current=De;const Ee=s.messages.length>Va&&!_e,et=d.useRef(Ee);et.current=Ee;const Ce=pm(s.messages,J.current,ym),be=d.useRef(Ce);be.current=Ce;const ze=d.useCallback(()=>{const K=y.current;if(!K)return;if(!et.current){xe(Je=>Je.size?new Set:Je);return}const ee=K.getBoundingClientRect(),Ke={top:ee.top-Ka,bottom:ee.bottom+Ka},Be=[];for(const[Je,qe]of G.current){const yt=qe.getBoundingClientRect();Be.push({id:Je,top:yt.top,bottom:yt.bottom}),J.current.set(Je,yt.bottom-yt.top)}const te=dm(Be,Ke,be.current,Ne.current);for(const Je of te.hide){const qe=G.current.get(Je);qe&&J.current.set(Je,qe.offsetHeight)}xe(()=>um(Ne.current,te))},[]),tt=d.useCallback(()=>{Oe.current||(Oe.current=requestAnimationFrame(()=>{Oe.current=0,ze()}))},[ze]);d.useLayoutEffect(()=>{ze()},[ze,s.messages,ke]);const Ye=d.useRef(_e);d.useLayoutEffect(()=>{Ye.current&&!_e&&ze(),Ye.current=_e},[_e,ze]);const Le=d.useCallback((K,ee)=>{J.current.set(K,ee)},[]),Xe=d.useCallback(K=>{K&&G.current.set(K.dataset.lazyId??"",K)},[]);d.useEffect(()=>{const K=new Set(s.messages.map(ee=>ee.id));for(const[ee,Ke]of G.current)K.has(ee)||(G.current.delete(ee),J.current.delete(ee));xe(ee=>{let Ke=!1;const Be=new Set;for(const te of ee)K.has(te)?Be.add(te):Ke=!0;return Ke?Be:ee})},[s.messages,ke]),d.useEffect(()=>()=>cancelAnimationFrame(Oe.current),[]);const vt=d.useMemo(()=>{const K=[];for(const ee of s.messages){if(ee.role!=="user"||ee.origin==="auto-reminder"||Pi(ee)||Ai(ee))continue;const Ke=ee.content.map(Je=>{var qe;return((qe=Cs(Je))==null?void 0:qe.text)??""}).filter(Boolean).join(" "),Be=Es(Ke),te=Tl(Be?Be.userMessage??`skill:${Be.name}`:Ke);te&&K.push({id:ee.id,text:te})}return K},[s.messages]),se=d.useMemo(()=>{const K=new Map;return vt.forEach((ee,Ke)=>K.set(ee.id,Ke)),K},[vt]),[Ue,w]=d.useState(-1),H=d.useRef(-1),X=d.useRef(vt);d.useEffect(()=>{X.current=vt},[vt]);const[me,$e]=d.useState({}),Pe=d.useCallback(()=>{const K=y.current;if(!K)return;const ee=K.getBoundingClientRect().top,Ke=Math.max(K.scrollHeight,1),Be={},te=new Map(Array.from(K.querySelectorAll("[data-msg-id]"),Je=>[Je.dataset.msgId,Je]));for(const Je of X.current){const qe=te.get(Je.id);qe&&(Be[Je.id]=Math.max(.02,Math.min(.98,(qe.getBoundingClientRect().top-ee+K.scrollTop)/Ke)))}$e(Je=>Object.keys(Be).length===Object.keys(Je).length&&Object.keys(Be).every(qe=>Math.abs(Be[qe]-Je[qe])<.002)?Je:Be)},[]);d.useLayoutEffect(()=>{const K=y.current;if(!K)return;let ee=requestAnimationFrame(Pe);const Ke=()=>{cancelAnimationFrame(ee),ee=requestAnimationFrame(Pe)},Be=new MutationObserver(Ke);return Be.observe(K,{childList:!0,subtree:!0}),window.addEventListener("resize",Ke),()=>{cancelAnimationFrame(ee),Be.disconnect(),window.removeEventListener("resize",Ke)}},[vt,Pe]);const st=d.useCallback(()=>{const K=y.current,ee=X.current;if(!K||ee.length===0)return;const Ke=K.getBoundingClientRect().top,Be=140;let te=-1;const Je=new Map(Array.from(K.querySelectorAll("[data-msg-id]"),qe=>[qe.dataset.msgId,qe]));for(let qe=0;qe<ee.length;qe++){const yt=Je.get(ee[qe].id);if(yt)if(yt.getBoundingClientRect().top<=Ke+Be)te=qe;else break}te!==H.current&&(H.current=te,w(te))},[]);d.useEffect(()=>{st()},[vt,st]);const lt=d.useCallback(K=>{Re(ee=>ee.has(K)?ee:new Set(ee).add(K))},[]),g=d.useCallback(K=>{Re(ee=>{if(K.every(Be=>ee.has(Be)))return ee;const Ke=new Set(ee);for(const Be of K)Ke.add(Be);return Ke})},[]),ne=d.useCallback(K=>{const ee=s.messages.find(qe=>qe.id===K),Ke=(ee==null?void 0:ee.role)==="toolResult"&&ee.toolCallId?re.sources.get(ee.toolCallId)??K:K,Be=re.owners.get(Ke)??Ke,te=s.messages.findIndex(qe=>qe.id===Be);mn.flushSync(()=>{te>=0&&te<Ie&&!ke.has(Be)&<(Be),Se(qe=>qe.has(Be)?qe:new Set(qe).add(Be))});const Je=ee!=null&&ee.toolCallId?[ee.toolCallId]:(ee==null?void 0:ee.content.flatMap(qe=>qe.type==="toolCall"&&qe.name==="bash"&&typeof qe.id=="string"?[qe.id]:[]))??[];for(const qe of Je)mn.flushSync(()=>window.dispatchEvent(new CustomEvent("pi:reveal-tool",{detail:{toolCallId:qe,search:!0}})))},[s.messages,Ie,ke,lt,re]);d.useEffect(()=>{const K=ee=>{if(!(ee.ctrlKey||ee.metaKey)||ee.key.toLowerCase()!=="f")return;const Ke=ee.target;Ke&&(Ke.tagName==="INPUT"||Ke.tagName==="TEXTAREA"||Ke.isContentEditable)||(ee.preventDefault(),M(!0))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[]);const We=d.useCallback(K=>{Re(ee=>{if(!ee.has(K))return ee;const Ke=new Set(ee);return Ke.delete(K),Ke})},[]),He=d.useCallback(K=>{K=re.owners.get(K)??K;const ee=s.messages.findIndex(Be=>Be.id===K);mn.flushSync(()=>{ee>=0&&ee<Ie&&!ke.has(K)&<(K),Se(Be=>Be.has(K)?Be:new Set(Be).add(K))});const Ke=X.current.findIndex(Be=>Be.id===K);H.current=Ke,w(Ke),requestAnimationFrame(()=>{var te,Je,qe;const Be=(te=y.current)==null?void 0:te.querySelector(`[data-msg-id="${K}"]`);Be&&((Je=y.current)==null||Je.querySelectorAll(".msg-flash").forEach(yt=>yt.classList.remove("msg-flash")),Be.scrollIntoView({block:"start"}),Be.classList.remove("msg-flash"),Be.offsetWidth,Be.classList.add("msg-flash"),Be!==((qe=y.current)==null?void 0:qe.lastElementChild)&&(q.current=!0))})},[s.messages,Ie,ke,lt,re]);d.useEffect(()=>{const K=Ke=>{var te;const Be=(te=Ke.detail)==null?void 0:te.messageId;Be&&V.some(Je=>Je.id===Be)&&He(Be)},ee=Ke=>{let{messageId:Be,toolCallId:te,todoItemIds:Je}=Ke.detail??{};const qe=te?Fe.get(te):void 0;qe!=null&&qe.target&&({messageId:Be,toolCallId:te}=qe.target),!(!Be||!te||!V.some(yt=>yt.id===Be))&&(He(Be),requestAnimationFrame(()=>{mn.flushSync(()=>window.dispatchEvent(new CustomEvent("pi:reveal-tool",{detail:{toolCallId:te}}))),requestAnimationFrame(()=>{var Kt,an;const yt=(Kt=y.current)==null?void 0:Kt.querySelector(`[data-tool-call-id="${CSS.escape(te)}"]`);if(yt){if(Je!=null&&Je.length){(an=y.current)==null||an.querySelectorAll(".todo-item-flash").forEach(Ct=>Ct.classList.remove("todo-item-flash"));const Zt=Array.from(yt.querySelectorAll("[data-todo-item-id]")).filter(Ct=>Je.includes(Ct.dataset.todoItemId??""));if(Zt.length){Zt[0].focus({preventScroll:!0}),Zt[0].scrollIntoView({block:"center"});for(const Ct of Zt)Ct.offsetWidth,Ct.classList.add("todo-item-flash");window.setTimeout(()=>Zt.forEach(Ct=>Ct.classList.remove("todo-item-flash")),1800);return}}yt.scrollIntoView({block:"center"}),yt.classList.remove("change-card-flash"),yt.offsetWidth,yt.classList.add("change-card-flash"),window.setTimeout(()=>yt.classList.remove("change-card-flash"),1800)}})}))};return window.addEventListener("pi:jump-message",K),window.addEventListener("pi:jump-tool",ee),()=>{window.removeEventListener("pi:jump-message",K),window.removeEventListener("pi:jump-tool",ee)}},[He,V,Fe]);const ct=d.useCallback(()=>{const K=y.current;if(!K)return;const ee=K.scrollTop-Q.current;Q.current=K.scrollTop;const Ke=K.scrollHeight-K.scrollTop-K.clientHeight;B(Ke>K.clientHeight);const Be=Ke<80;ee<-4&&ee>-500?q.current=!0:Be&&ee>=0&&(q.current=!1),ie.current=Be&&!q.current,b(ie.current),st(),Pe(),tt()},[st,Pe,tt]),ft=d.useRef(!1);d.useEffect(()=>{const K=ft.current;if(ft.current=!!s.isStreaming,K&&!s.isStreaming&&!q.current){const ee=()=>{const Be=y.current;Be&&!q.current&&(Be.scrollTop=Be.scrollHeight,ie.current=!0,b(!0))};requestAnimationFrame(()=>requestAnimationFrame(ee));const Ke=setTimeout(ee,180);return()=>clearTimeout(Ke)}},[s.isStreaming]),d.useEffect(()=>{const K=y.current;K&&ie.current&&(K.scrollTop=K.scrollHeight),K&&B(K.scrollHeight-K.scrollTop-K.clientHeight>K.clientHeight)},[V,s.isStreaming,a]);const Mt=d.useCallback(()=>{const K=y.current;K&&(K.scrollTop=K.scrollHeight),ie.current=!0,q.current=!1,b(!0)},[]),Dt=d.useRef(null),[$t,Ft]=d.useState(!1);d.useEffect(()=>{if(!$t)return;const K=Ke=>{var Be;(Be=Dt.current)!=null&&Be.contains(Ke.target)||Ft(!1)},ee=Ke=>{Ke.key==="Escape"&&Ft(!1)};return document.addEventListener("pointerdown",K,!0),document.addEventListener("keydown",ee),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("keydown",ee)}},[$t]),d.useEffect(()=>{const K=Dt.current,ee=y.current;if(!K||!ee)return;const Ke=Be=>{Be.preventDefault();const te=K.querySelector(".qn-list");if(te&&te.contains(Be.target)&&te.scrollHeight>te.clientHeight){te.scrollTop+=Be.deltaY;return}ee.scrollTop+=Be.deltaY};return K.addEventListener("wheel",Ke,{passive:!1}),()=>K.removeEventListener("wheel",Ke)},[]);const[Yt,Ut]=d.useState(0);d.useEffect(()=>{const K=()=>{var ee;Ut(((ee=y.current)==null?void 0:ee.clientHeight)??0),tt()};return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[tt]);const it=vt.filter(K=>me[K.id]!==void 0),Rt=zh(it.map(K=>({id:K.id,position:me[K.id]})),Yt),zt=Rt.some(K=>K.ids.length>1);return e.jsxs("div",{className:"messages-wrap",children:[e.jsxs("div",{className:"messages",ref:y,onScroll:ct,children:[R.length===0&&!s.streamingMessage&&e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-logo-wrap",children:e.jsx("img",{className:"empty-logo",src:"/icon/1a-mark.svg",alt:""})}),e.jsx("h2",{className:"empty-title",children:I("welcomeTitle")}),e.jsx("p",{className:"empty-sub",children:I("welcomeSub")}),e.jsxs("div",{className:"empty-cwd",children:[e.jsx("span",{className:"empty-cwd-label",children:I("directory")}),e.jsx("span",{className:"empty-cwd-path",children:s.cwd})]}),e.jsx("div",{className:"empty-examples",children:bm(I).map(K=>e.jsxs("button",{type:"button",className:"empty-example",title:I("clickToFill"),onClick:()=>window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:K.prompt})),children:[e.jsx("span",{className:"empty-example-icon",children:K.icon}),e.jsx("span",{className:"empty-example-text",children:K.text})]},K.prompt))})]}),R.map(K=>{var an,Zt,Ct,cn;if(K.kind==="reload")return e.jsx(jm,{event:K.event},`reload-${K.event.requestId}`);if(K.kind==="cwd")return e.jsxs("div",{className:"goal-event cwd-event",role:"status",children:[e.jsx("span",{"aria-hidden":"true",children:"↪"}),e.jsx("span",{children:I("cwdSwitchEvent",{path:K.event.cwd.replace(/^\/(?:Users|home)\/[^/]+(?=\/|$)/,"~")})})]},`cwd-${K.event.timestamp}`);const{message:ee,index:Ke}=K;if(fe.absorbed.has(ee.id))return null;if(ee.origin==="auto-reminder")return e.jsx(zr,{message:ee,toolResults:ve,liveOutputs:Kr,toolStatuses:o,streaming:!1,isLast:!1},ee.id);const Be=ht=>{const Et=ce.get(Ke);return Et?e.jsxs(d.Fragment,{children:[e.jsx("div",{className:"time-gap","aria-label":I("timeGapAt",{time:Et}),title:ee.timestamp?new Date(ee.timestamp).toLocaleString():void 0,children:e.jsx("span",{children:Et})}),ht]},ee.id):ht},te=fe.groups.get(ee.id);if(te)return Be(e.jsxs("div",{className:`goal-event ${te.kind}`,"data-msg-id":ee.id,children:[e.jsx("span",{"aria-hidden":"true",children:te.kind==="complete"?"✓":"◎"}),e.jsx("span",{children:I(te.kind==="complete"?"goalEventComplete":"goalEventSet",{text:te.text})}),te.ids.length>1&&e.jsxs("span",{className:"goal-event-count",children:["×",te.ids.length]}),te.kind==="complete"&&e.jsxs("details",{className:"goal-event-details",children:[e.jsx("summary",{children:I("goalReviewDetails")}),e.jsx("pre",{children:ee.content.map(ht=>ht.type==="text"?ht.text:"").join(`
|
|
248
|
-
`)})]}),te.ids.slice(1).map(ht=>e.jsx("span",{"data-msg-id":ht},ht))]},ee.id));const Je=Ke<Ie,qe=Je&&ke.has(ee.id);if(Je&&!qe){if(we.absorbed.has(Ke))return null;const ht=we.groupAt.get(Ke);return ht?Be(e.jsx(za,{id:ee.id,show:!Ee||Ce.has(ee.id)||_.has(ee.id)||!De.has(ee.id),height:J.current.get(ee.id)??30,containerRef:y,onMeasured:Le,lazyRef:Xe,children:e.jsx(lm,{messages:ht,onExpand:g})},ee.id)):null}if(re.owners.has(ee.id))return Z.has(ee.id)?e.jsx(ca,{files:Z.get(ee.id)},ee.id):null;const yt=ee.role==="user"?se.get(ee.id):void 0,Kt=!Ee||Ce.has(ee.id)||_.has(ee.id)||!De.has(ee.id);return Be(e.jsxs(za,{id:ee.id,show:Kt,height:J.current.get(ee.id)??Pl(ee.role,ee.customType),containerRef:y,onMeasured:Le,lazyRef:Xe,children:[e.jsx(zr,{recovery:n,incident:N.get(ee.id),message:re.projected.get(ee.id)??ee,toolMessageIds:re.sources,continuation:!!ae.get(ee.id)&&!De.has(ae.get(ee.id))&&!(Ke<Ie&&!ke.has(ae.get(ee.id))),qnIndex:yt,qnActive:yt!==void 0?yt===Ue:void 0,onJump:He,toolResults:ve,planViews:Fe,retriedEditIds:ye,liveOutputs:Ga(ee)?a:Kr,toolStatuses:o,streaming:s.isStreaming&&r&&Ke>W,toolsRunning:s.isStreaming&&Ke>W,bashActive:s.isStreaming&&Ke>W&&!s.messages.slice(Ke+1).some(ht=>ht.role==="assistant"&&ht.content.some(Et=>Et.type==="text"&&typeof Et.text=="string"&&Et.text.trim()))&&!((an=s.streamingMessage)!=null&&an.content.some(ht=>ht.type==="text"&&typeof ht.text=="string"&&ht.text.trim())),bashTitle:(Zt=s.messages.slice(W<Ke?W:0,Ke+1).findLast(ht=>ht.role==="assistant"&&ht.content.some(Et=>Et.type==="text"&&typeof Et.text=="string"&&Et.text.trim())))==null?void 0:Zt.content.filter(ht=>ht.type==="text").map(ht=>ht.type==="text"&&typeof ht.text=="string"?ht.text:"").join(" ").slice(0,80),onKillBash:l,toolsWrap:f,thinkingWrap:u,isLast:ee.id===ge,onEdit:c,conversationId:s.conversationId,questionAttachments:U.get(ee.id),onCollapse:qe?We:void 0},ee.id),Z.has(ee.id)&&e.jsx(ca,{files:Z.get(ee.id)}),ee.role==="assistant"&&e.jsx(th,{message:ee,last:ee.id===((Ct=s.messages.findLast(ht=>ht.role==="assistant"))==null?void 0:Ct.id),regenerate:!s.isStreaming&&r&&!((cn=s.tree)!=null&&cn.verifying)&&c?()=>{const ht=s.messages.slice(0,Ke).findLast(Bt=>Bt.role==="user"&&Bt.origin!=="auto-reminder");if(!ht)return;const Et=ht.questionText??ht.content.map(Bt=>Bt.type==="text"?Bt.text:"").join(`
|
|
249
|
-
`),Ht=Es(Et);c(ht.id,Ht?`/skill:${Ht.name}${Ht.userMessage?` ${Ht.userMessage}`:""}`:Et,U.get(ht.id),{entryId:ht.entryId})}:void 0})]},ee.id))}),s.streamingMessage&&z&&!re.owners.has(s.streamingMessage.id)&&e.jsx(zr,{recovery:n,incident:N.get(s.streamingMessage.id),message:s.streamingMessage,continuation:!!ae.get(s.streamingMessage.id),toolResults:ve,planViews:Fe,retriedEditIds:ye,liveOutputs:Ga(s.streamingMessage)?a:Kr,toolStatuses:o,streaming:r,toolsRunning:s.isStreaming,isLast:!0,onEdit:c,conversationId:s.conversationId,onKillBash:l,toolsWrap:f,thinkingWrap:u},s.streamingMessage.id),e.jsx("div",{className:"trailing-working",children:e.jsx(Go,{onStop:p,state:s,connected:r,silenceNotified:i,toolStatuses:o})}),k&&k.conversationId===s.conversationId&&e.jsxs("div",{className:"msg msg-user pending-echo","data-role":"user",children:[e.jsxs("div",{className:"msg-meta",children:[e.jsx("span",{className:"msg-role",children:I("role.user")}),e.jsxs("span",{className:"pending-echo-tag",children:[e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),I("sending")]})]}),e.jsx("div",{className:"msg-body",children:e.jsx("div",{className:"msg-text",children:k.text})})]})]}),!L&&F&&(()=>{const K=e.jsxs("button",{type:"button",className:"scroll-bottom",onClick:Mt,children:[e.jsx(No,{})," ",I("backToBottom")]}),ee=document.querySelector(".design-workspace .view-pane:not(.hidden) .main > .inputbar");return ee?mn.createPortal(K,ee):K})(),e.jsx(vm,{containerRef:y,messages:V,open:_e,onClose:()=>M(!1),onEnsureExpanded:ne}),vt.length>0&&e.jsxs("div",{className:`qn-rail ${zt?"many":""} ${$t?"open":""}`,ref:Dt,"aria-label":I("questionNavTitle"),onPointerEnter:()=>Ft(!0),onPointerLeave:()=>Ft(!1),onFocusCapture:()=>Ft(!0),children:[Rt.map(K=>{var Ke;const ee=it.find(Be=>Be.id===K.ids[0]);return e.jsx("button",{type:"button",className:`qn-bar ${K.ids.length>1?"cluster":""} ${K.ids.includes(((Ke=vt[Ue])==null?void 0:Ke.id)??"")?"active":""}`,style:{top:`${K.position*100}%`},"aria-label":K.ids.length>1?I("questionMarkerGroup",{n:K.ids.length}):`${vt.indexOf(ee)+1}. ${ee.text}`,onClick:()=>{He(ee.id),Ft(!1)},children:e.jsxs("span",{className:"qn-bar-text",children:[vt.indexOf(ee)+1,". ",ee.text]})},K.ids.join(":"))}),zt&&e.jsx("div",{className:"qn-list",children:vt.map((K,ee)=>e.jsxs("button",{type:"button",className:`qn-list-item ${ee===Ue?"active":""}`,"aria-label":`${ee+1}. ${K.text}`,onClick:()=>{He(K.id),Ft(!1)},children:[e.jsx("span",{className:"qn-list-idx",children:ee+1}),e.jsx("span",{className:"qn-list-text",children:K.text})]},K.id))})]})]})},(t,n)=>t.active===!1&&n.active===!1&&t.state.conversationId===n.state.conversationId?!0:Object.keys(n).every(s=>t[s]===n[s]));function Sm({conversationId:t,active:n,text:s,replace:r,restoreImages:i}){const a=nt(),[o,c]=d.useState();if(d.useEffect(()=>{const p=()=>c(n?Ed(t):void 0);return p(),window.addEventListener("pi-tree-draft",p),()=>window.removeEventListener("pi-tree-draft",p)},[t,n]),d.useEffect(()=>{var p;o&&o.conversationId===t&&n&&!s.trim()&&(r(o.text),(p=o.images)!=null&&p.length&&(i==null||i(o.images)),xa(t,o.id))},[o,t,n,s,r,i]),!o||o.conversationId!==t||!n||!s.trim())return null;const l=p=>{var u;p!==void 0&&(r(p),(u=o.images)!=null&&u.length&&(i==null||i(o.images))),xa(t,o.id)};return e.jsxs("section",{className:"tree-draft-restore",role:"alert",children:[e.jsx("p",{children:a("treeDraftConflict")}),e.jsxs("details",{children:[e.jsx("summary",{children:a("treeReturnedText")}),e.jsx("pre",{children:o.text})]}),e.jsx("button",{onClick:()=>l(o.text),children:a("treeReplaceDraft")}),e.jsx("button",{onClick:()=>l(`${s}
|
|
250
|
-
|
|
251
|
-
${o.text}`),children:a("treeAppendDraft")}),e.jsx("button",{onClick:()=>l(),children:a("treeKeepDraft")})]})}function Nm(t,n){const s=r=>{var c;const i=r.replace(/\\/g,"/"),a=/^(?:\/|[A-Za-z]:\/)/.test(i)?i:`${((c=n.editorSnapshot)==null?void 0:c.cwd)??""}/${i}`,o=[];for(const l of a.split("/"))l===".."?o.pop():l&&l!=="."&&o.push(l);return o.join("/")};return[...t.filter(r=>r.nativeRef||r.mode==="lines"||r.imageData||r.fileData||r.uploadPath||s(r.path)!==s(n.path)),n]}function Em(t){const n=t.input+t.cacheRead+t.cacheWrite;return n>0?Math.round(t.cacheRead/n*100):null}const Ja=t=>new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(t);function Tm({stats:t}){const n=nt(),s=d.useRef(null),[r,i]=d.useState(!1),a=d.useRef(!1);d.useEffect(()=>{if(!r)return;const u=k=>{var j;(j=s.current)!=null&&j.contains(k.target)||(i(!1),a.current=!1)},f=k=>{k.key==="Escape"&&(i(!1),a.current=!1)};return document.addEventListener("pointerdown",u,!0),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",u,!0),document.removeEventListener("keydown",f)}},[r]);const o=t==null?void 0:t.contextUsage,c=(o==null?void 0:o.percent)===null||(o==null?void 0:o.percent)===void 0?null:Math.round(o.percent),l=c===null?0:Math.max(0,Math.min(100,c)),p=t?Em(t.tokens):null;return!(c!==null&&c>0)&&!(p!==null&&p>0)?null:e.jsxs("div",{className:"usage-control",ref:s,onPointerEnter:()=>i(!0),onPointerLeave:()=>{a.current||i(!1)},children:[e.jsxs("button",{type:"button",className:`usage-trigger${c!==null&&c>=80?" warn":""}`,title:`${n("usageContextTitle")} · ${n("usageCacheTitle")}`,"aria-label":`${n("usageContextTitle")} ${c??"—"}%`,"aria-expanded":r,onPointerDown:()=>{a.current=!a.current,i(a.current)},onClick:u=>{u.detail===0&&(a.current=!a.current,i(a.current))},children:[c!==null&&c>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"usage-context-label",children:n("context")}),e.jsxs("span",{className:"usage-percent",children:[c,"%"]})]}),p!==null&&p>0&&e.jsxs("span",{className:"usage-cache-short",children:[c!==null&&c>0?"· ":"",n("usageCacheShort")," ",e.jsxs("strong",{className:p<50?"warn":"",children:[p,"%"]})]})]}),r&&e.jsxs("div",{className:"usage-popover",role:"dialog","aria-label":n("usageContextTitle"),children:[e.jsxs("div",{className:"usage-head",children:[e.jsx("strong",{children:n("usageContextTitle")}),e.jsxs("span",{children:[(o==null?void 0:o.tokens)===null||(o==null?void 0:o.tokens)===void 0?"—":Ja(o.tokens)," / ",o!=null&&o.contextWindow?Ja(o.contextWindow):"—"]})]}),e.jsx("div",{className:"usage-progress",role:"img","aria-label":`${n("usageContextTitle")} ${c??"—"}%`,children:e.jsx("span",{className:c!==null&&c>=80?"warn":"",style:{width:`${l}%`}})}),e.jsxs("div",{className:"usage-head usage-cache-section",children:[e.jsx("strong",{children:n("usageCacheTitle")}),e.jsx("span",{className:p!==null&&p<50?"warn":"",children:p===null?"—":`${p}%`})]})]})]})}const Rm=d.memo(function({active:n=!0,currentFile:s,contextReader:r,contextSaver:i,stats:a,ready:o,promptResult:c,verifying:l,pendingCount:p=0,queue:u,workingStatus:f,streaming:k,silentActivity:j,messages:I,slashCommands:E,modelState:$,models:N,modelsLoading:R,send:y,activeConversationId:L,setPendingEcho:b,attachments:F,onRemoveAttachment:B,onAddImageFiles:ie,onAddLocalFiles:Q,onNotice:q,onSent:ke,onManageModels:Re}){var $e,Pe,st,lt;const O=nt(),[_e,M]=d.useState({}),V=s&&_e[L]!==s.id?s:null,ve=d.useRef(null),{locale:ye}=Qn(),oe=g=>ye==="en"&&g.descriptionEn?g.descriptionEn:g.description??"",Fe=g=>ye==="en"&&g.argumentHintEn?g.argumentHintEn:g.argumentHint??"",U=d.useRef(new Map),fe=d.useRef(L),[ce,ae]=d.useState(""),[z,Z]=d.useState("steer"),[W,ge]=d.useState(!1),[Ie,Ae]=d.useState(!1);d.useEffect(()=>{Z("steer"),ge(!1),Ae(!1)},[L,k]);const re=()=>y({type:"recall_queue",conversationId:L,requestId:Qt()}),we=()=>{const g=y({type:"abort"});Ue||q(g?"warning":"error",O(g?"stopQueuedAfterReconnect":"stopUnavailable"))},A=u?[...u.steering.map(g=>({text:g,steer:!0})),...u.followUp.map(g=>({text:g,steer:!1}))]:[];d.useLayoutEffect(()=>{fe.current!==L&&(ce?U.current.set(fe.current,ce):U.current.delete(fe.current),fe.current=L,ae(U.current.get(L)??""),U.current.delete(L))},[L,ce]),Ao(L,n,ae),d.useEffect(()=>{const g=ve.current;!g||(c==null?void 0:c.requestId)!==g.id||(ve.current=null,c.ok&&(c.attachmentsConsumed!==!1&&ke(g.conversation,g.attachments),g.conversation===L?(ae(ne=>ne===g.text?"":ne),!g.queued&&!c.commandExecuted&&g.text.trim()!=="/reload"&&b(L,g.text.trim())):U.current.get(g.conversation)===g.text&&U.current.delete(g.conversation)))},[c,L,ke,b]),d.useEffect(()=>{o||(ve.current=null)},[o]);const[xe,_]=d.useState(!1),[Se,J]=d.useState(null),[De,G]=d.useState(0),[Oe,Ne]=d.useState(!1),[Ee,et]=d.useState(void 0),Ce=d.useRef(null),be=d.useRef(null),ze=d.useRef(null),tt={builtin:O("slashBuiltin"),extension:O("slashExtension"),prompt:O("slashPrompt"),skill:O("slashSkill"),plugin:O("slashPlugin")},Ye=g=>{const ne=g.match(/^\/([^\s]*)$/);if(ne&&o){const We=ne[1].toLowerCase(),He=E.filter(ct=>{const ft=ct.name.toLowerCase();if(ft.startsWith(We))return!0;const Mt=ft.indexOf(":");return Mt>=0&&ft.slice(Mt+1).startsWith(We)});J(He.length>0?He:null),G(0)}else J(null)};d.useEffect(()=>{var ne;const g=(ne=ze.current)==null?void 0:ne.querySelector(".slash-item.active");g==null||g.scrollIntoView({block:"nearest"})},[De,Se]);const Le=g=>{var ft;const ne=Se??[],We=g??ne[De%Math.max(ne.length,1)];if(!We){J(null);return}const He=ce.match(/^\/([^\s]*)([\s\S]*)$/),ct=He?He[2]:"";ae(`/${We.name} ${ct}`),J(null),(ft=Ce.current)==null||ft.focus()},Xe=async()=>{const ne=[...I].reverse().find(He=>He.role==="assistant"&&He.content.some(ct=>ct.type==="text"&&ct.text)),We=ne==null?void 0:ne.content.filter(He=>He.type==="text").map(He=>He.text).join(`
|
|
252
|
-
`);if(!We){q("warning",O("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(We),q("info",O("slashCopied"))}catch{q("error",O("slashCopyFailed"))}},vt=g=>{if(!g||g.length===0){q("warning",O("foldersNotSupported"));return}const ne=Array.from(g).filter(He=>ns(He.type)),We=Array.from(g).filter(He=>!ns(He.type));ne.length>0&&ie(ne),We.length>0&&Q(We)},se=g=>{var He;const ne=(He=g.clipboardData)==null?void 0:He.items;if(!ne)return;const We=[];for(const ct of ne)if(ct.kind==="file"&&ns(ct.type)){const ft=ct.getAsFile();ft&&We.push(ft)}We.length!==0&&(g.preventDefault(),ie(We))},Ue=o,w=d.useRef(ce);d.useEffect(()=>{w.current=ce},[ce]),d.useEffect(()=>{Ye(w.current)},[E]),d.useEffect(()=>{const g=ne=>{var He;const We=ne.detail;ae(We),(He=Ce.current)==null||He.focus()};return window.addEventListener("pi-web:fill",g),()=>window.removeEventListener("pi-web:fill",g)},[]),d.useEffect(()=>{if(!Oe)return;const g=ne=>{ne.key==="Escape"&&Ne(!1)};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[Oe]),d.useEffect(()=>{const g=Ce.current;if(!g)return;g.style.height="auto";const ne=g.scrollHeight>220;g.style.height=`${Math.min(g.scrollHeight,220)}px`,g.style.overflowY=ne?"auto":"hidden"},[ce]);const H=(g=!1)=>{var ft,Mt,Dt,$t,Ft,Yt,Ut;if(l){q("info",O("treeVerifying"));return}const ne=ce.trim(),We=E.some(it=>it.source==="extension"&&it.name===ne.slice(1).split(" ",1)[0])&&ne.startsWith("/"),He=F.some(it=>it.imageData||it.fileData);if(ve.current||!Ue||!ne&&!He)return;if(ne==="/help"){const it=(Mt=(ft=Ce.current)==null?void 0:ft.closest(".inputbox"))==null?void 0:Mt.getBoundingClientRect();et(it==null?void 0:it.width),Ne(!0),ae(""),(Dt=Ce.current)==null||Dt.focus();return}if(ne==="/copy"){ae(""),($t=Ce.current)==null||$t.focus(),Xe();return}const ct=()=>{var zt;let it=F.map(({key:Ot,isDir:Vt,...jt})=>jt);if(V&&!We){const Ot=(zt=r.current)==null?void 0:zt.call(r,V.id);if(!(Ot!=null&&Ot.editorSnapshot)||Ot.path!==V.path||Ot.editorSnapshot.cwd!==V.cwd){q("error",O("currentFileUnavailable"));return}if(new TextEncoder().encode(Ot.editorSnapshot.text).length>512*1024){q("error",O("currentFileTooLarge"));return}it=Nm(it,Ot)}const Rt=Qt();y({type:"prompt",text:ne,queue:g,requestId:Rt,attachments:it})&&(ve.current={id:Rt,conversation:L,text:ce,queued:k,attachments:F})};if(V&&!We){const it=(Ft=r.current)==null?void 0:Ft.call(r,V.id);if(it!=null&&it.editorSnapshot&&new TextEncoder().encode(it.editorSnapshot.text).length>512*1024){q("error",O("currentFileTooLarge"));return}if((Yt=it==null?void 0:it.editorSnapshot)!=null&&Yt.dirty){if(!((Ut=i.current)==null?void 0:Ut.call(i,V.id,ct))){q("error",O("currentFileSaving"));return}return}}ct()},X=g=>{if(!g.nativeEvent.isComposing){if(Se&&Se.length>0)switch(g.key){case"ArrowDown":g.preventDefault(),G(ne=>(ne+1)%Se.length);return;case"ArrowUp":g.preventDefault(),G(ne=>(ne-1+Se.length)%Se.length);return;case"Tab":case"Enter":g.preventDefault(),Le();return;case"Escape":g.preventDefault(),J(null);return}if(g.key==="Escape"){g.preventDefault(),g.stopPropagation(),W?ge(!1):ce?ae(""):k&&we();return}if(g.key==="ArrowUp"&&!ce&&p===1){g.preventDefault(),re();return}g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),H(k&&(g.altKey?z!=="followUp":z==="followUp")))}},me=()=>e.jsxs("div",{className:"inputbox-actions",children:[k&&e.jsx("button",{type:"button",className:"btn composer-action stop",title:`${O("stopTask")} · Esc`,"aria-label":O("stopTask"),onClick:we,children:e.jsx(ls,{"aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"btn composer-action send",title:O("sendTip"),"aria-label":O("sendTip"),disabled:!Ue||l||!ce.trim()&&!F.some(g=>g.imageData||g.fileData),onClick:()=>H(k&&z==="followUp"),children:e.jsx(cr,{"aria-hidden":"true"})})]});return e.jsxs("div",{className:`inputbar${xe?" drop-active":""}`,onDragOver:g=>{g.preventDefault(),g.stopPropagation(),_(!0)},onDragLeave:g=>{g.currentTarget.contains(g.relatedTarget)||_(!1)},onDrop:g=>{var ne;g.preventDefault(),g.stopPropagation(),_(!1),vt(((ne=g.dataTransfer)==null?void 0:ne.files)??null)},children:[xe&&e.jsx("div",{className:"drop-overlay",children:e.jsxs("span",{children:["📎 ",O("dropHereToAttach")]})}),Se&&Se.length>0&&e.jsxs("div",{className:"slash-menu",role:"listbox",ref:ze,"aria-label":O("slashCommands"),children:[e.jsxs("div",{className:"slash-menu-hint",children:[e.jsx("span",{children:O("slashMenuHint")}),e.jsx("span",{className:"slash-menu-close",onClick:()=>J(null),children:"Esc"})]}),Se.map((g,ne)=>e.jsxs("button",{type:"button",className:`slash-item${ne===De?" active":""}`,onMouseEnter:()=>G(ne),onClick:()=>Le(g),children:[e.jsxs("span",{className:"slash-name",children:["/",g.name]}),e.jsx("span",{className:`slash-source ${g.source}`,children:tt[g.source]}),e.jsxs("span",{className:"slash-desc",children:[oe(g),g.argumentHint&&e.jsx("span",{className:"slash-hint",children:Fe(g)})]})]},g.name))]}),Oe&&e.jsx("div",{className:"modal-backdrop",onClick:()=>Ne(!1),children:e.jsxs("div",{className:"slash-help",style:Ee?{width:Ee}:void 0,onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"slash-help-head",children:[e.jsxs("span",{children:["⚡ ",O("slashHelpTitle")]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>Ne(!1),children:O("close")})]}),e.jsx("div",{className:"slash-help-body",children:E.length===0?e.jsx("div",{className:"slash-help-empty",children:O("slashLoading")}):E.map(g=>e.jsxs("div",{className:"slash-help-row",children:[e.jsxs("span",{className:"slash-help-cmd",children:["/",g.name]}),e.jsx("span",{className:`slash-source ${g.source}`,children:tt[g.source]}),e.jsxs("span",{className:"slash-help-desc",children:[oe(g),g.argumentHint&&e.jsx("span",{className:"slash-hint",children:Fe(g)})]})]},g.name))})]})}),e.jsx(Sm,{conversationId:L,active:n,text:ce,replace:ae,restoreImages:g=>ie(g.map((ne,We)=>{const He=Uint8Array.from(atob(ne.data),ct=>ct.charCodeAt(0));return new File([He],`recalled-${We}.${ne.mimeType.split("/")[1]??"png"}`,{type:ne.mimeType})}))}),f&&e.jsx("div",{className:"composer-working",children:f}),p>0&&e.jsxs("div",{className:"composer-queue",children:[e.jsxs("div",{className:"composer-queue-head",children:[p>1?e.jsxs("button",{type:"button",className:"queue-toggle","aria-expanded":Ie,onClick:()=>Ae(!Ie),children:[O("pendingMessages",{n:p})," ",Ie?"▴":"▾"]}):e.jsxs("span",{className:"queue-single",children:[e.jsx("span",{className:"queue-badge",children:O(($e=A[0])!=null&&$e.steer?"queueSteerTag":"queueFollowTag")}),e.jsx("span",{className:"queued-text",title:tr(((Pe=A[0])==null?void 0:Pe.text)??""),children:tr(((st=A[0])==null?void 0:st.text)??"")})]}),p===1&&e.jsx("span",{className:"queue-when",children:O((lt=A[0])!=null&<.steer?"deliverySteerHint":"deliveryFollowHint")}),e.jsxs("button",{type:"button",className:"recall-queue",title:O("recallQueue"),disabled:!Ue,onClick:re,children:[e.jsx(bo,{"aria-hidden":"true"}),O("recallQueueEdit")]})]}),Ie&&p>1&&e.jsx("div",{className:"composer-queue-list",children:A.map((g,ne)=>e.jsxs("div",{className:"composer-queue-item",children:[e.jsx("span",{className:"queue-badge",children:O(g.steer?"queueSteerTag":"queueFollowTag")}),e.jsx("span",{className:"queued-text",title:tr(g.text),children:tr(g.text)}),e.jsx("span",{className:"queue-when",children:O(g.steer?"deliverySteerHint":"deliveryFollowHint")})]},ne))})]}),e.jsxs("div",{className:`inputbox${ce.length>0?" has-draft":""}`,children:[(c==null?void 0:c.commandExecuted)&&c.conversationId===L&&F.length>0&&e.jsx("div",{role:"status",children:O("commandAttachmentsRetained")}),(F.length>0||V)&&e.jsxs("div",{className:"attach-row",children:[V&&e.jsxs("span",{className:"attach-chip current-file",title:`${V.cwd}/${V.path}`,children:["@",V.name,V.dirty?` · ${O("currentFileUnsaved")}`:"",e.jsx("button",{type:"button",className:"attach-remove",title:O("removeAttachment"),onClick:()=>M(g=>({...g,[L]:V.id})),children:"×"})]}),F.map(g=>e.jsxs("span",{className:`attach-chip ${g.imageData?"image":g.fileData?"file":g.mode}`,title:g.imageData?O("attachImage",{name:g.name}):g.fileData?O("attachFile",{name:g.name}):g.isDir?O("folderRef",{path:g.path}):g.mode==="reference"?O("refOnly",{path:g.path}):g.mode==="lines"&&g.lines?O("attachLines",{path:g.path,start:g.lines.start,end:g.lines.end}):O("attachContent",{path:g.path}),children:[g.imageData?"🖼":g.fileData?"📄":g.isDir?"📁":g.mode==="reference"?"🔗":"📎"," ",g.name,g.mode==="lines"&&g.lines&&e.jsxs("span",{className:"attach-range",children:["L",g.lines.start,"-",g.lines.end]}),e.jsx("button",{type:"button",className:"attach-remove",title:O("removeAttachment"),onClick:()=>B(g.key??g.path),children:"×"})]},g.key??`${g.path}|${g.mode}|${g.lines?`${g.lines.start}-${g.lines.end}`:""}`)),e.jsx("span",{className:"attach-hint",children:O("attachHint")})]}),e.jsx("input",{ref:be,type:"file",multiple:!0,hidden:!0,onChange:g=>{vt(g.target.files),g.target.value=""}}),e.jsxs("div",{className:"inputbox-row",children:[e.jsx("button",{type:"button",className:"btn attach-img",title:O("uploadFile"),disabled:!Ue,onClick:()=>{var g;return(g=be.current)==null?void 0:g.click()},children:e.jsx(ta,{})}),e.jsx("textarea",{ref:Ce,value:ce,rows:1,placeholder:Ue?k?j?O(j==="model"?"placeholderModelSilent":"placeholderToolSilent"):O("placeholderStreamingModes",{primary:O(z==="steer"?"queueSteerTag":"queueFollowTag"),alternate:O(z==="steer"?"queueFollowTag":"queueSteerTag")}):O("composerPlaceholder"):O("placeholderConnecting"),disabled:!Ue,onChange:g=>{ae(g.target.value),Ye(g.target.value)},onKeyDown:X,onPaste:se})]}),e.jsxs("div",{className:"input-tools",children:[e.jsxs("div",{className:"input-tools-left",children:[e.jsx("button",{type:"button",className:"btn composer-attach",title:O("uploadFile"),disabled:!Ue,onClick:()=>{var g;return(g=be.current)==null?void 0:g.click()},children:e.jsx(gs,{})}),e.jsx(yl,{state:$,models:N,modelsLoading:R,send:y,onManageModels:Re,compact:!0,segmented:!0}),k&&e.jsx("div",{className:"delivery-control",children:e.jsx(js,{direction:"up",open:W,onOpenChange:ge,trigger:O(z==="steer"?"queueSteerTag":"queueFollowTag"),children:["steer","followUp"].map(g=>e.jsx(Gn,{active:z===g,onClick:()=>{var ne;Z(g),ge(!1),(ne=Ce.current)==null||ne.focus()},children:e.jsxs("span",{className:"delivery-option",children:[e.jsx("strong",{children:O(g==="steer"?"queueSteerTag":"queueFollowTag")}),e.jsx("small",{children:O(g==="steer"?"deliverySteerHint":"deliveryFollowHint")})]})},g))})})]}),e.jsxs("div",{className:"input-tools-right",children:[e.jsx(Tm,{stats:a}),e.jsx("button",{type:"button",className:"btn attach-img",title:O("uploadFile"),disabled:!Ue,onClick:()=>{var g;return(g=be.current)==null?void 0:g.click()},children:e.jsx(ta,{})}),me()]})]})]})]})});function Im({chat:t,send:n}){var $,N;const s=nt(),r=t.agentSilence,[i,a]=d.useState(Date.now()),[o,c]=d.useState(!1);if(d.useEffect(()=>{c(!1)},[r==null?void 0:r.since,r==null?void 0:r.conversationId]),d.useEffect(()=>{if(!r)return;const R=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(R)},[r]),($=t.state)!=null&&$.recovery&&Object.values(t.state.recovery).some(Boolean)||!t.ready||!r||r.conversationId!==t.activeConversationId||!((N=t.state)!=null&&N.isStreaming))return null;const l=Math.max(0,Math.floor((i-r.since)/1e3)),p=`${Math.floor(l/60)}:${String(l%60).padStart(2,"0")}`,u=t.state.messages,f=u.findLastIndex(R=>R.role==="user"),k=u[f],j=(k==null?void 0:k.content.map(R=>R.type==="text"&&typeof R.text=="string"?R.text:"").filter(Boolean).join(`
|
|
253
|
-
`).trim())??"",I=u.slice(f+1).some(R=>R.content.some(y=>y.type==="toolCall")),E=r.activity==="model"&&!!j&&!I&&(k==null?void 0:k.content.every(R=>R.type==="text"));return e.jsxs("div",{className:`agent-silence ${r.activity}`,role:"status",children:[e.jsxs("span",{className:"agent-silence-label",children:["⚠ ",r.activity==="tool"?s("toolSilent",{duration:p}):s("modelSilent",{duration:p})]}),o?e.jsx("button",{type:"button",onClick:()=>c(!1),children:s("actions")}):e.jsxs("span",{className:"agent-silence-actions",children:[e.jsx("button",{type:"button",onClick:()=>n({type:"abort"}),children:s("stop")}),e.jsx("button",{type:"button",disabled:!E,title:E?void 0:s("retrySilentUnavailable"),onClick:()=>{E&&n({type:"retry_silent_prompt",conversationId:r.conversationId,text:j})},children:s("retry")}),e.jsx("button",{type:"button",onClick:()=>c(!0),children:s("continueWaiting")})]})]})}function Lm(t){const s=t.replaceAll("\\","/").replace(/^(?:\/(?:Users|home)\/[^/]+|[a-zA-Z]:\/Users\/[^/]+)(?=\/|$)/,"~"),r=s.split("/");return r.length>3?`${r.slice(0,2).join("/")}/…/${r.at(-1)}`:s}function Mm({chat:t,send:n}){var L;const s=nt(),r=t.state,[i,a]=d.useState(!1),[o,c]=d.useState(""),[l,p]=d.useState(0),u=d.useRef(null),f=t.pathCompletions;if(d.useEffect(()=>{!t.ready||!(r!=null&&r.cwd)||n({type:"get_git_branch"})},[t.ready,r==null?void 0:r.cwd,t.scmDirty,n]),d.useEffect(()=>{const b=()=>{t.ready&&n({type:"get_git_branch"})};return window.addEventListener("focus",b),()=>window.removeEventListener("focus",b)},[t.ready,n]),d.useEffect(()=>{if(!i)return;const b=setTimeout(()=>{n({type:"complete_path",path:o})},150);return()=>clearTimeout(b)},[o,i,n]),d.useEffect(()=>p(0),[f]),d.useEffect(()=>{const b=document.querySelector(`.status-completions .pc-item[data-idx="${l}"]`);b==null||b.scrollIntoView({block:"nearest"})},[l]),!r)return null;const k=((L=t.gitBranch)==null?void 0:L.cwd)===r.cwd?t.gitBranch:null,j=k!=null&&k.notRepo?s("notGitRepoShort"):k!=null&&k.branch?k.detached?`${s("scmDetached")} · ${k.branch}`:k.branch:"—",I=t.ready?"ok":"busy",E=t.ready?s("connected"):s("connecting"),$=()=>{c(r.cwd),a(!0)},N=(b,F)=>{var ie;const B=b.includes("\\")?"\\":"/";c(F?`${b}${B}`:b),p(0),(ie=u.current)==null||ie.focus()},R=b=>{const F=b.trim();F&&F!==r.cwd&&n({type:"set_cwd",path:F,source:"ui"}),a(!1)},y=b=>{if(b.key==="ArrowDown")b.preventDefault(),p(F=>Math.min(F+1,f.length-1));else if(b.key==="ArrowUp")b.preventDefault(),p(F=>Math.max(F-1,0));else if(b.key==="Tab"&&f.length>0){b.preventDefault();const F=f[Math.min(l,f.length-1)];N(F.path,F.type==="dir")}else if(b.key==="Enter"&&!b.nativeEvent.isComposing){const F=o.trim();if(F.endsWith("/")||F.endsWith("\\"))R(F);else if(f.some(B=>B.path===F))R(F);else if(f.length>0&&f[l]){b.preventDefault();const B=f[l];N(B.path,B.type==="dir")}else R(F)}else b.key==="Escape"&&(f.length>0?(b.stopPropagation(),n({type:"complete_path",path:""})):a(!1))};return e.jsxs("footer",{className:"statusbar",children:[e.jsx("span",{className:`status-dot ${I}`,title:E}),e.jsx("span",{className:"status-item status-connection",children:E}),t.serverVersion&&e.jsxs("span",{className:"status-item status-version",title:`pi-harness v${t.serverVersion}`,children:["v",t.serverVersion]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item status-branch",title:k!=null&&k.notRepo?j:`${s("scmCurrentBranch")}: ${j}`,children:[!(k!=null&&k.notRepo)&&e.jsx("span",{className:"workspace-stat-label",children:s("workspaceBranch")}),e.jsx("span",{className:"status-branch-name",children:j})]}),t.statuses.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"status-sep",children:"·"}),e.jsx("span",{className:"status-item ext-status",title:s("pluginStatus"),children:t.statuses.map(b=>b.text).join(" · ")})]}),e.jsx("span",{id:"wiki-status-slot"}),i?e.jsxs("div",{className:"status-cwd-wrap",children:[e.jsx("input",{ref:u,className:"status-cwd-input",value:o,autoFocus:!0,placeholder:s("enterPath"),onChange:b=>c(b.target.value),onKeyDown:y,onBlur:()=>a(!1)}),f.length>0&&e.jsx("ul",{className:"status-completions",onMouseDown:b=>b.preventDefault(),children:f.map((b,F)=>e.jsx("li",{children:e.jsxs("button",{type:"button","data-idx":F,className:`pc-item ${F===l?"sel":""}`,onMouseEnter:()=>p(F),onClick:()=>N(b.path,b.type==="dir"),children:[e.jsx("span",{className:"pc-icon",children:b.type==="dir"?e.jsx(Us,{}):e.jsx(Ws,{})}),e.jsxs("span",{className:"pc-body",children:[e.jsx("span",{className:"pc-name",children:b.name}),e.jsx("span",{className:"pc-path",children:b.path})]})]})},b.path))})]}):e.jsxs("button",{type:"button",className:"status-item status-cwd",title:s("cwdTip",{path:r.cwd}),onClick:$,children:[e.jsx("span",{className:"workspace-stat-label",children:s("workspacePath")}),e.jsx("span",{className:"workspace-stat-path",children:Lm(r.cwd)})]})]})}function mi({dialog:t,send:n}){const s=nt(),[r,i]=d.useState(""),[a,o]=d.useState(0),c=u=>{n({type:"dialog_response",conversationId:t.conversationId,id:t.id,value:u})};d.useEffect(()=>{i(t.kind==="editor"?String(t.args[0]??""):""),o(0);const u=f=>{f.key==="Escape"&&c(null)};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t.id]);const l=Array.isArray(t.args[0])?t.args[0]:[],p=typeof t.args[0]=="string"?t.args[0]:"";return e.jsxs("div",{className:"dialog-inline","data-dialog-kind":t.kind,children:[e.jsxs("div",{className:"dialog-head",children:[e.jsx("span",{className:"dialog-badge",children:s("pluginRequest")}),t.title&&t.title!==s("pluginRequest")&&e.jsx("span",{className:"dialog-title",children:t.title}),e.jsx("button",{type:"button",className:"dialog-dismiss",title:s("cancel"),onClick:()=>c(null),children:"✕"})]}),t.kind==="select"&&e.jsxs("div",{className:"dialog-options",children:[l.map((u,f)=>e.jsx("button",{type:"button",className:`dialog-option ${f===a?"sel":""}`,onMouseEnter:()=>o(f),onClick:()=>c(u),children:u},f)),l.length===0&&e.jsx("div",{className:"dialog-hint",children:s("noOptions")})]}),t.kind==="confirm"&&e.jsxs("div",{className:"dialog-body",children:[e.jsx("p",{children:p}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>c(!1),children:s("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>c(!0),children:s("ok")})]})]}),(t.kind==="input"||t.kind==="editor")&&e.jsxs("div",{className:"dialog-body",children:[t.kind==="editor"?e.jsx("textarea",{className:"dialog-input",rows:8,value:r,autoFocus:!0,onChange:u=>i(u.target.value)}):e.jsx("input",{className:"dialog-input",value:r,placeholder:p||s("inputPlaceholder"),autoFocus:!0,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.nativeEvent.isComposing&&c(r)}}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>c(null),children:s("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>c(r),children:s("ok")})]})]})]})}function Pm(t){if(t.x==="?"&&t.y==="?")return"untracked";const n=t.x!==" "&&t.x!=="?",s=t.y!==" "&&t.y!=="?";return n&&s?"both":n?"staged":"unstaged"}function Am({chat:t,send:n,terminal:s,active:r,commitToShow:i,onSwitchToTerminal:a}){var Xe,vt;const o=nt(),[c,l]=d.useState(null),[p,u]=d.useState([]),[f,k]=d.useState(""),[j,I]=d.useState(new Map),[E,$]=d.useState("changes"),[N,R]=d.useState([]),[y,L]=d.useState(null),[b,F]=d.useState(""),[B,ie]=d.useState(!1),[Q,q]=d.useState(null),[ke,Re]=d.useState(null),[O,_e]=d.useState(!1),[M,V]=d.useState(!1),[ve,ye]=d.useState(!1),[oe,Fe]=d.useState(null),[U,fe]=d.useState(!1),[ce,ae]=d.useState(""),z=d.useRef(0),Z=d.useRef(-1),W=d.useRef(-1),ge=d.useRef(-1),Ie=d.useRef(-1),Ae=d.useRef(void 0),re=d.useRef(null),we=d.useRef([]),A=d.useCallback(se=>{if(se.reqId===Z.current){if(Z.current=-1,V(!1),Fe(null),!se.ok){Fe(se.error??"查询失败");return}if(se.notRepo){fe(!0),l(null),u([]),I(new Map),R([]),L(null),F(""),Re(null);return}fe(!1);const Ue={branch:se.branch??"",detached:!!se.detached,upstream:se.upstream??null,ahead:se.ahead??0,behind:se.behind??0,upstreamGone:!!se.upstreamGone,files:(se.files??[]).map(X=>({...X}))},w=(se.branches??[]).map(X=>({...X})),H=new Map;for(const[X,me]of Object.entries(se.stats??{}))H.set(X,{add:me[0],del:me[1]});l(Ue),u(w),I(H),k(X=>{var me;return Ue.detached?X||"":Ue.branch&&w.some($e=>$e.name===Ue.branch)?Ue.branch:X&&w.some($e=>$e.name===X)?X:((me=w[0])==null?void 0:me.name)??""}),Re(X=>X&&!Ue.files.some(me=>me.path===X.file.path)?null:X)}else if(se.reqId===W.current){if(W.current=-1,_e(!1),!se.ok){Fe(se.error??"查询失败");return}const Ue=re.current;if(!Ue)return;Re({file:Ue,staged:se.stagedText??"",worktree:se.worktreeText??"",untracked:!!se.untracked,untrackedText:se.untrackedText,untrackedKind:se.untrackedKind,untrackedTruncated:se.untrackedTruncated})}else if(se.reqId===Ie.current){if(Ie.current=-1,ye(!1),!se.ok){Fe(se.error??"查询失败");return}R((se.history??[]).map(Ue=>({...Ue})))}else if(se.reqId===ge.current){if(ge.current=-1,ie(!1),!se.ok){Fe(se.error??"查询失败");return}F(se.text??"")}},[]);d.useEffect(()=>{const se=t.scmData;se&&se.type==="scm_data"&&A(se)},[t.scmData,A]);const xe=d.useCallback((se,Ue)=>{if(!t.ready||t.status!=="open")return!1;const w=++z.current;return n({...se,reqId:w})?(Ue.current=w,!0):(z.current-=1,!1)},[t.ready,t.status,n]),_=d.useCallback((se=!1,Ue=!1)=>{var w;!t.ready||t.status!=="open"||(w=t.state)!=null&&w.cwd&&(Ae.current!==void 0&&Ae.current!==t.state.cwd&&(l(null),u([]),I(new Map),R([]),ye(!1),Ie.current=-1,L(null),F(""),Re(null),q(null)),Ae.current=t.state.cwd,Fe(null),xe({type:"scm_status"},Z)&&(Ue||V(!0)))},[t.ready,(Xe=t.state)==null?void 0:Xe.cwd,t.status,xe]),Se=d.useCallback(se=>{q(se),L(null),re.current=se,Re(null),_e(!0),Fe(null),xe({type:"scm_filediff",path:se.path},W)||(_e(!1),Fe(o("scmConnecting")))},[xe,o]),J=d.useCallback(se=>{L(se),q(null),Re(null),F(""),ie(!0),Fe(null),xe({type:"scm_commit",hash:se.hash},ge)||ie(!1)},[xe]),De=d.useCallback((se,Ue)=>{var X,me;if(!t.ready)return;const w={name:se,command:Ue,cwd:"${pwd}"},H=t.terminals.find($e=>$e.title===se);if(H)s.restart(H.id),n({type:"run_command",terminalId:H.id,conversationId:H.conversationId,command:w,cols:80,rows:24});else{const $e=Qt();s.create({id:$e,conversationId:t.activeConversationId||((X=t.state)==null?void 0:X.conversationId)||"",title:se,cwd:((me=t.state)==null?void 0:me.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:w})}a()},[t.ready,(vt=t.state)==null?void 0:vt.cwd,t.terminals,a,n,s]),G=d.useCallback(()=>{const se=ce.trim();if(!se||U)return;const Ue=se.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");De("git commit",`git add -A && git commit -m "${Ue}"`),ae("")},[ce,U,De]),Oe=se=>`'${se.replace(/'/g,"'\\''")}`,Ne=d.useCallback(se=>{U||De("git add",`git add -- ${Oe(se.path)}`)},[U,De]),Ee=d.useCallback(se=>{U||De("git reset",`git reset HEAD -- ${Oe(se.path)}`)},[U,De]),et=d.useCallback(()=>{if(!f||U)return;const se=p.find(Ue=>Ue.name===f);if(se!=null&&se.remote&&typeof se.remote=="string"){const Ue=f.slice(se.remote.length+1);De("git checkout",`git checkout -b ${Ue} ${f} || git checkout ${f}`)}else De("git checkout",`git checkout ${f}`)},[f,p,U,De]),Ce=d.useCallback(()=>De("git push","git push"),[De]),be=d.useCallback(()=>De("git pull","git pull"),[De]),ze=d.useCallback(()=>{xe({type:"scm_history"},Ie)||(Ie.current=-1)},[xe]);d.useEffect(()=>{r&&_()},[r,_]),d.useEffect(()=>{E==="history"&&c&&ze()},[E,c,ze]);const tt=d.useRef(null);d.useEffect(()=>{!r||!t.ready||t.status!=="open"||!i||tt.current===i.token||(tt.current=i.token,$("history"),J({hash:i.hash,shortHash:i.hash,subject:"",author:"",date:"",decorations:"",graph:""}))},[r,t.ready,t.status,i,J]),d.useEffect(()=>{t.scmDirty>0&&r&&_(!1,!0)},[t.scmDirty]),d.useEffect(()=>{if(!r||!t.ready||t.status!=="open")return;const se=setInterval(()=>{document.visibilityState!=="hidden"&&_(!1,!0)},3e4);return()=>clearInterval(se)},[r,t.ready,t.status,_]),d.useEffect(()=>{const se=we.current;if(we.current=t.terminals,!r)return;t.terminals.some(w=>{var X;return w.running!==!1?!1:((X=se.find(me=>me.id===w.id))==null?void 0:X.running)===!0&&/^git /.test(w.title)})&&t.ready&&t.status==="open"&&(_(!1,!0),E==="history"&&c&&ze())},[t.terminals,r,t.ready,t.status,_,E,c,ze]);const Ye={staged:o("scmStaged"),unstaged:o("scmUnstaged"),untracked:o("scmUntracked"),both:o("scmStagedUnstaged")},Le=se=>{const Ue=se.split(`
|
|
254
|
-
`);return e.jsx("pre",{className:"scm-diff-pre",children:Ue.map((w,H)=>{let X="";return w.startsWith("diff --git")||w.startsWith("index ")||w.startsWith("new file")||w.startsWith("deleted file")||w.startsWith("old mode")||w.startsWith("new mode")||w.startsWith("similarity index")||w.startsWith("rename ")||w.startsWith("copy ")||w.startsWith("Binary files")||w.startsWith("---")||w.startsWith("+++")?X="hdr":w.startsWith("@@")?X="hunk":w.startsWith("+")?X="add":w.startsWith("-")&&(X="del"),e.jsx("div",{className:`scm-diff-line ${X}`,children:w||" "},H)})})};return e.jsxs("div",{className:"scm-view",children:[e.jsxs("div",{className:"scm-header",children:[e.jsxs("div",{className:"scm-title-row",children:[e.jsxs("span",{className:"scm-title",children:[e.jsx(os,{}),o("scmTitle")]}),e.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":E==="changes",className:E==="changes"?"active":"",onClick:()=>{$("changes"),Fe(null)},children:o("scmChanges")}),e.jsx("button",{type:"button",role:"tab","aria-selected":E==="history",className:E==="history"?"active":"",onClick:()=>{$("history"),Fe(null)},children:o("scmHistory")})]}),e.jsx("button",{type:"button",className:"panel-refresh",title:o("scmRefreshTip"),disabled:M,onClick:()=>_(!0),children:e.jsx(Is,{className:M?"scm-spin":""})})]}),e.jsxs("div",{className:"scm-row",children:[e.jsxs("span",{className:"scm-branch-current",title:o("scmCurrentBranch"),children:[e.jsx(os,{}),c?c.detached?o("scmDetached"):c.branch:"…",(c==null?void 0:c.upstream)&&e.jsx("span",{className:"scm-upstream",children:c.upstreamGone?o("scmUpstreamGone"):c.ahead>0||c.behind>0?o("scmAheadBehind",{ahead:c.ahead,behind:c.behind}):c.upstream})]}),e.jsxs("select",{className:"scm-select",value:f,disabled:U||p.length===0,title:o("scmSwitchBranch"),onChange:se=>k(se.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:o("scmSelectBranch")}),p.filter(se=>!se.remote).map(se=>e.jsx("option",{value:se.name,children:se.current?`* ${se.name}`:se.name},se.name)),p.some(se=>se.remote)&&e.jsx("optgroup",{label:o("scmRemoteBranches"),children:p.filter(se=>se.remote).map(se=>e.jsx("option",{value:se.name,children:se.name},se.name))})]}),e.jsxs("button",{type:"button",className:"btn",disabled:!f||f===(c==null?void 0:c.branch)||U,title:o("scmSwitchBranchTip",{branch:f}),onClick:et,children:[e.jsx(os,{}),o("scmSwitch")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||U,title:o("scmPushTip"),onClick:Ce,children:[e.jsx(cr,{}),o("scmPush")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||U,title:o("scmPullTip"),onClick:be,children:[e.jsx(No,{}),o("scmPull")]}),e.jsx("input",{className:"scm-commit-input",value:ce,placeholder:o("scmCommitPlaceholder"),disabled:U,onChange:se=>ae(se.target.value),onKeyDown:se=>{se.key==="Enter"&&!se.nativeEvent.isComposing&&G()}}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!ce.trim()||U,title:o("scmCommitTip"),onClick:G,children:[e.jsx(ss,{}),o("scmCommit")]})]})]}),e.jsxs("div",{className:"scm-body",children:[E==="history"?e.jsxs("div",{className:"scm-history",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:o("scmHistory")}),N.length>0&&e.jsx("span",{className:"scm-files-count",children:N.length})]}),e.jsx("div",{className:"scm-history-list",children:U?e.jsx("div",{className:"scm-empty",children:o("scmNotGitRepo")}):!c||ve?e.jsx("div",{className:"scm-empty",children:t.status==="open"?o("scmLoading"):o("scmConnecting")}):N.length===0?e.jsx("div",{className:"scm-empty",children:o("scmNoHistory")}):N.map(se=>e.jsxs("button",{type:"button",className:`scm-commit ${(y==null?void 0:y.hash)===se.hash?"active":""}`,onClick:()=>J(se),title:se.hash,children:[e.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:se.graph||"* "}),e.jsxs("span",{className:"scm-commit-info",children:[e.jsx("span",{className:"scm-commit-subject",children:se.subject}),e.jsxs("span",{className:"scm-commit-meta",children:[se.shortHash," · ",se.author," · ",se.date]}),se.decorations&&e.jsx("span",{className:"scm-commit-refs",children:se.decorations})]})]},se.hash))})]}):e.jsxs("div",{className:"scm-files",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:o("scmChanges")}),c&&c.files.length>0&&e.jsx("span",{className:"scm-files-count",children:c.files.length})]}),e.jsx("div",{className:"scm-files-list",children:U?e.jsx("div",{className:"scm-empty",children:o("scmNotGitRepo")}):c?c.files.length===0?e.jsx("div",{className:"scm-empty",children:o("scmNoChanges")}):c.files.map(se=>{const Ue=Pm(se),w=j.get(se.path);return e.jsxs("div",{className:`scm-file ${(Q==null?void 0:Q.path)===se.path?"active":""}`,title:Ye[Ue],onClick:()=>Se(se),children:[e.jsx("span",{className:"scm-file-xy x",children:Ue==="untracked"?" ":se.x!==" "?se.x:" "}),e.jsx("span",{className:`scm-file-xy y${Ue==="untracked"?" untracked":""}`,"aria-label":Ue==="untracked"?o("scmUntracked"):void 0,children:Ue==="untracked"?o("scmUntrackedBadge"):se.y!==" "?se.y:" "}),e.jsx("span",{className:"scm-file-path",children:se.path}),w&&(w.add>0||w.del>0)&&e.jsxs("span",{className:"scm-file-stat",children:[w.add>0&&e.jsxs("span",{className:"add",children:["+",w.add]}),w.del>0&&e.jsxs("span",{className:"del",children:["-",w.del]})]}),e.jsxs("span",{className:"scm-file-actions",children:[(se.y!==" "||Ue==="untracked")&&e.jsx("button",{type:"button",className:"scm-act",title:o("scmStageTip",{path:se.path}),onClick:H=>{H.stopPropagation(),Ne(se)},children:"+"}),Ue==="staged"||Ue==="both"?e.jsx("button",{type:"button",className:"scm-act",title:o("scmUnstageTip",{path:se.path}),onClick:H=>{H.stopPropagation(),Ee(se)},children:"−"}):null]})]},se.path)}):e.jsx("div",{className:"scm-empty",children:t.status==="open"?o("scmLoading"):o("scmConnecting")})})]}),e.jsxs("div",{className:"scm-diff",children:[e.jsxs("div",{className:"scm-diff-header",children:[e.jsx("span",{children:E==="history"?y?`${y.shortHash} ${y.subject}`:o("scmCommitDetail"):Q?Q.path:o("scmDiff")}),(E==="history"?B:O)&&e.jsx("span",{className:"scm-diff-loading",children:o("scmLoading")})]}),e.jsx("div",{className:"scm-diff-body",children:E==="history"?e.jsxs(e.Fragment,{children:[oe&&e.jsx("div",{className:"scm-error",children:oe}),!y&&!oe&&e.jsx("div",{className:"scm-empty",children:o("scmSelectCommitHint")}),y&&B&&!oe&&e.jsx("div",{className:"scm-empty",children:o("scmLoading")}),y&&!B&&!oe&&b?Le(b):null]}):e.jsxs(e.Fragment,{children:[oe&&e.jsx("div",{className:"scm-error",children:oe}),!Q&&!oe&&e.jsx("div",{className:"scm-empty",children:o("scmSelectFileHint")}),Q&&!ke&&!oe&&e.jsx("div",{className:"scm-empty",children:o("scmLoading")}),Q&&ke&&ke.untracked&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:o("scmUntracked")}),ke.untrackedKind==="text"?ke.untrackedText?e.jsx("pre",{className:"scm-diff-pre scm-untracked-content",children:ke.untrackedText}):e.jsx("div",{className:"scm-empty",children:o("scmEmptyFile")}):e.jsx("div",{className:"scm-empty",children:o(ke.untrackedKind==="directory"?"scmUntrackedDirectory":"scmUntrackedBinary")}),ke.untrackedTruncated&&e.jsx("div",{className:"scm-empty",children:o("scmPreviewTruncated")})]}),Q&&ke&&!ke.untracked&&e.jsxs(e.Fragment,{children:[ke.staged&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:o("scmStaged")}),Le(ke.staged)]}),ke.worktree&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:o("scmUnstaged")}),Le(ke.worktree)]}),!ke.staged&&!ke.worktree&&e.jsx("div",{className:"scm-empty",children:o("scmNoDiff")})]})]})})]})]}),e.jsxs("div",{className:"scm-hint",children:[e.jsx(ki,{}),e.jsx("span",{children:o("scmRunsInTerminal")}),e.jsx("button",{type:"button",className:"scm-goto-term",onClick:a,children:o("scmViewTerminal")})]})]})}function Dm({entry:t,send:n}){const s=d.useRef(null);return d.useEffect(()=>{const r=s.current;if(!r)return;let i;try{i=t.module.mount(r,Hd(t.info.id,a=>n(a)))}catch(a){console.error(`[plugin:${t.info.id}] mount failed:`,a),r.textContent=`插件 ${t.info.name} 挂载失败`}return()=>{if(typeof i=="function")try{i()}catch(a){console.error(`[plugin:${t.info.id}] cleanup failed:`,a)}r.textContent=""}},[t,n]),e.jsx("div",{className:"plugin-view",ref:s})}function $m({send:t,piConfigured:n,piAgentInstalled:s,providers:r,installResult:i,onClose:a}){const o=nt(),[c,l]=d.useState(!1),[p,u]=d.useState(""),[f,k]=d.useState(""),[j,I]=d.useState(!1);d.useEffect(()=>{t({type:"list_providers"})},[t]),d.useEffect(()=>{n&&a()},[n,a]),d.useEffect(()=>{i&&l(!1)},[i]),d.useEffect(()=>{var L;!p&&r.length>0&&u(((L=r.find(b=>!b.configured))==null?void 0:L.id)??r[0].id)},[r,p]);const E=()=>{c||(l(!0),t({type:"install_pi_agent"}))},$=()=>{!f.trim()||j||(I(!0),t({type:"set_provider_api_key",provider:p.trim(),apiKey:f.trim()}),setTimeout(()=>I(!1),3e3))},N=()=>{t({type:"get_state"}),t({type:"list_providers"})},R=r.find(L=>L.id===p),y=i!==null&&!i.ok;return e.jsx("div",{className:"modal-backdrop",children:e.jsxs("div",{className:"modal setup-modal",children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":o("close"),onClick:a,children:e.jsx(qt,{})}),e.jsxs("div",{className:"modal-head",children:[e.jsx(wi,{className:"modal-head-icon"}),e.jsx("h2",{children:o("setupTitle")})]}),e.jsx("p",{className:"modal-desc",children:o("setupDesc")}),y?e.jsxs("div",{className:"setup-failed",children:[e.jsx("div",{className:"setup-done",children:o("installFailed")}),e.jsx("pre",{className:"setup-detail",children:i.detail}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:c,onClick:E,children:o("retryInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:a,children:o("skip")})]})]}):s||i!=null&&i.ok?e.jsxs("div",{className:"setup-key-form",children:[e.jsx("div",{className:"setup-done",children:i!=null&&i.ok?o("installDone"):o("cliReadyHint")}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("provider")}),e.jsxs("select",{value:p,onChange:L=>u(L.target.value),children:[r.length===0&&e.jsx("option",{value:"",children:o("loading")}),r.map(L=>e.jsxs("option",{value:L.id,children:[L.name,"(",L.id,")",L.configured?` · ${o("configured")}`:""]},L.id))]}),(R==null?void 0:R.configured)&&e.jsx("div",{className:"field-hint",children:o("providerKeyReady")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiKey")}),e.jsx("input",{type:"password",value:f,onChange:L=>k(L.target.value),placeholder:"sk-…"})]}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:!f.trim()||j||!p,onClick:$,children:o(j?"saving":"saveAndStart")}),e.jsxs("button",{type:"button",className:"btn",onClick:N,children:[e.jsx(Is,{})," ",o("recheck")]})]})]}):e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:c,onClick:E,children:o(c?"installing":"autoInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:a,children:o("skip")})]})]})})}const Fm=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],Oi=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),Om=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[Oi()]});function Qa(t){return{providerId:t.providerId,nonChatModelCount:t.nonChatModelCount,name:t.name??"",api:t.api??"openai-completions",baseUrl:t.baseUrl??"",apiKey:t.apiKey??"",authHeader:t.authHeader??!1,models:(t.models.length?t.models:[Oi()]).map(n=>{var s;return{id:n.id,name:n.name??"",reasoning:n.reasoning??!1,input:(s=n.input)!=null&&s.includes("image")?"text-image":"text",contextWindow:n.contextWindow?String(n.contextWindow):"",maxTokens:n.maxTokens?String(n.maxTokens):""}})}}function _m({send:t,providers:n,providerStatus:s,fetchModelsResult:r,refreshProviderResult:i,cloneProviderResult:a,onClose:o}){const c=nt(),[l,p]=d.useState(null),[u,f]=d.useState({}),[k,j]=d.useState(null),[I,E]=d.useState({}),[$,N]=d.useState(!1),[R,y]=d.useState(0),[L,b]=d.useState(null),F=d.useRef(0),[B,ie]=d.useState({});d.useRef(0);const Q=d.useRef(0),[q,ke]=d.useState(null),Re=d.useRef(0),O=d.useRef(0);d.useEffect(()=>{t({type:"list_models_config"}),t({type:"list_providers"})},[t]);const _e=()=>{if(!l)return;const U=l.baseUrl.trim();if(!U){b({ok:!1,text:c("fetchModelsNeedBaseUrl")});return}if($)return;N(!0),b(null);const fe=R+1;y(fe),t({type:"fetch_models",reqId:fe,baseUrl:U,apiKey:l.apiKey.trim()||void 0,authHeader:l.authHeader,api:l.api})};d.useEffect(()=>{var U;if(!(!r||r.reqId===F.current))if(F.current=r.reqId,N(!1),r.ok&&((U=r.models)!=null&&U.length)){const fe=r.models;p(ce=>{if(!ce)return ce;const ae=ce.models.map(ge=>{var re;if(!ge.id.trim())return ge;const Ie=fe.find(we=>we.id===ge.id.trim());if(!Ie)return ge;const Ae={...ge};return!Ae.name&&Ie.name&&(Ae.name=Ie.name),!Ae.contextWindow&&Ie.contextWindow&&(Ae.contextWindow=String(Ie.contextWindow)),!Ae.maxTokens&&Ie.maxTokens&&(Ae.maxTokens=String(Ie.maxTokens)),Ae.input==="text"&&((re=Ie.input)!=null&&re.includes("image"))&&(Ae.input="text-image"),!Ae.reasoning&&Ie.reasoning&&(Ae.reasoning=!0),Ae}),z=new Set(ae.map(ge=>ge.id.trim()).filter(Boolean)),Z=fe.filter(ge=>!z.has(ge.id)).map(ge=>{var Ie;return{id:ge.id,name:ge.name??"",reasoning:ge.reasoning??!1,input:(Ie=ge.input)!=null&&Ie.includes("image")?"text-image":"text",contextWindow:ge.contextWindow?String(ge.contextWindow):"",maxTokens:ge.maxTokens?String(ge.maxTokens):""}}),W=[...ae,...Z];return W.some(ge=>ge.id.trim())?{...ce,models:W.filter(ge=>ge.id.trim())}:ce}),b({ok:!0,text:c("fetchModelsOk",{n:fe.length})})}else b({ok:!1,text:r.error||c("fetchModelsEmpty")})},[r]);const M=U=>{const fe=(u[U.id]??"").trim();!fe||k||(j(U.id),t({type:"set_provider_api_key",provider:U.id,apiKey:fe}),setTimeout(()=>{j(null),f(ce=>({...ce,[U.id]:""})),E(ce=>({...ce,[U.id]:!1})),t({type:"list_providers"})},1500))},V=()=>{if(!l)return;const U=l.providerId.trim(),fe=l.models.filter(ae=>ae.id.trim()).map(ae=>({id:ae.id.trim(),name:ae.name.trim()||void 0,reasoning:ae.reasoning||void 0,input:ae.input==="text-image"?["text","image"]:void 0,contextWindow:ae.contextWindow?Number(ae.contextWindow):void 0,maxTokens:ae.maxTokens?Number(ae.maxTokens):void 0})),ce={providerId:U,name:l.name.trim()||void 0,api:l.api.trim()||void 0,baseUrl:l.baseUrl.trim()||void 0,apiKey:l.apiKey.trim()||void 0,authHeader:l.authHeader||void 0,models:fe};t({type:"save_model_config",providerId:U,config:ce}),o()};d.useEffect(()=>{!i||i.reqId===Q.current||(Q.current=i.reqId,ie({}))},[i]);const ve=U=>{if(q)return;ke(U.id);const fe=++Re.current+Date.now();t({type:"clone_provider",provider:U.id,reqId:fe})};d.useEffect(()=>{!a||a.reqId===O.current||(O.current=a.reqId,ke(null),a.ok&&a.config&&p(Qa({...a.config,apiKey:""})))},[a]);const ye=U=>{window.confirm(c("clearKeyConfirm",{id:U}))&&t({type:"clear_provider_api_key",provider:U})},oe=U=>{window.confirm(c("deleteProviderConfirm",{id:U.providerId,n:U.models.length}))&&t({type:"delete_model_config",providerId:U.providerId})},Fe=(U,fe)=>{l&&p({...l,models:l.models.map((ce,ae)=>ae===U?{...ce,...fe}:ce)})};return e.jsx("div",{className:"modal-backdrop",onClick:o,children:e.jsxs("div",{className:"modal model-modal",onClick:U=>U.stopPropagation(),children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":c("close"),onClick:o,children:e.jsx(qt,{})}),e.jsx("div",{className:"modal-head",children:e.jsx("h2",{children:c(l?"editProvider":"manageModelsTitle")})}),l?e.jsxs("div",{className:"provider-form",children:[e.jsxs("div",{className:"form-grid",children:[e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:[c("providerId")," ",e.jsx("em",{children:c("providerIdHint")})]}),e.jsx("input",{type:"text",value:l.providerId,disabled:n.some(U=>U.providerId===l.providerId),onChange:U=>p({...l,providerId:U.target.value}),placeholder:"my-proxy"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:c("displayName")}),e.jsx("input",{type:"text",value:l.name,onChange:U=>p({...l,name:U.target.value}),placeholder:c("displayNamePh")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:c("apiType")}),e.jsx("select",{value:l.api,onChange:U=>p({...l,api:U.target.value}),children:Fm.map(U=>e.jsx("option",{value:U,children:U},U))})]}),e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:["baseUrl ",e.jsx("em",{children:c("baseUrlHint")})]}),e.jsx("input",{type:"text",value:l.baseUrl,onChange:U=>p({...l,baseUrl:U.target.value}),placeholder:"http://localhost:11434/v1"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:c("apiKey")}),e.jsx("input",{type:"password",value:l.apiKey,onChange:U=>p({...l,apiKey:U.target.value}),placeholder:c("apiKeyHint")})]}),e.jsxs("label",{className:"field check",children:[e.jsx("input",{type:"checkbox",checked:l.authHeader,onChange:U=>p({...l,authHeader:U.target.checked})}),e.jsx("span",{children:c("authHeader")})]})]}),!!l.nonChatModelCount&&e.jsx("p",{className:"hint",children:c("nonChatModelsPreserved",{n:l.nonChatModelCount})}),e.jsxs("div",{className:"model-section-head",children:[e.jsx("span",{className:"form-section-title",children:c("modelsTitle")}),e.jsxs("span",{className:"model-section-actions",children:[L&&e.jsx("span",{className:`fetch-msg ${L.ok?"ok":"err"}`,title:L.text,children:L.text}),e.jsxs("button",{type:"button",className:"btn sm",disabled:$||!l.baseUrl.trim(),title:c("fetchModelsHint"),onClick:_e,children:[e.jsx(yi,{})," ",c($?"fetchingModels":"fetchModels")]})]})]}),l.models.map((U,fe)=>e.jsxs("div",{className:"model-row",children:[e.jsx("input",{type:"text",value:U.id,onChange:ce=>Fe(fe,{id:ce.target.value}),placeholder:c("modelIdReq")}),e.jsx("input",{type:"text",value:U.name,onChange:ce=>Fe(fe,{name:ce.target.value}),placeholder:c("displayName")}),e.jsxs("select",{value:U.input,onChange:ce=>Fe(fe,{input:ce.target.value}),children:[e.jsx("option",{value:"text",children:c("text")}),e.jsx("option",{value:"text-image",children:c("textImage")})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:U.reasoning,onChange:ce=>Fe(fe,{reasoning:ce.target.checked})}),e.jsx("span",{children:c("reasoning")})]}),e.jsx("input",{type:"number",value:U.contextWindow,onChange:ce=>Fe(fe,{contextWindow:ce.target.value}),placeholder:c("contextWindow"),title:"contextWindow"}),e.jsx("input",{type:"number",value:U.maxTokens,onChange:ce=>Fe(fe,{maxTokens:ce.target.value}),placeholder:c("maxOutput"),title:"maxTokens"}),e.jsx("button",{type:"button",className:"iconbtn danger",title:c("removeModel"),onClick:()=>p({...l,models:l.models.filter((ce,ae)=>ae!==fe)}),children:e.jsx(Pr,{})})]},fe)),e.jsxs("button",{type:"button",className:"btn",onClick:()=>p({...l,models:[...l.models,Oi()]}),children:[e.jsx(gs,{})," ",c("addModel")]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>p(null),children:c("cancel")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!l.providerId.trim()||!l.models.some(U=>U.id.trim()),onClick:V,children:c("save")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section-title",children:[c("builtinProviders")," ",e.jsx("em",{className:"section-hint",children:c("hintKeyOnly")})]}),e.jsxs("div",{className:"provider-list",children:[s.length===0&&e.jsx("div",{className:"dd-loading",children:c("loading")}),s.map(U=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:U.name}),e.jsxs("span",{className:"provider-sub",children:[U.id,U.configured&&e.jsx("span",{className:"auth-badge",children:c("configuredBadge")}),U.source&&!U.configured&&e.jsx("span",{className:"auth-badge dim",children:U.source})]})]}),e.jsxs("div",{className:"provider-actions",children:[U.oauth&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn sm",type:"button",onClick:()=>t({type:"login_provider",provider:U.id}),children:U.id==="openai"?c("providerChatGPTLogin"):c("providerLogin")}),U.configured&&U.source==="stored"&&e.jsx("button",{className:"btn sm",type:"button",onClick:()=>t({type:"logout_provider",provider:U.id}),children:c("providerLogout")})]}),U.configured&&!I[U.id]?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"auth-badge",children:c("keyReady")}),e.jsxs("button",{type:"button",className:"btn sm",title:c("replaceKeyTitle"),onClick:()=>E(fe=>({...fe,[U.id]:!0})),children:[e.jsx(ia,{})," ",c("replaceKey")]}),U.source==="stored"&&e.jsxs("button",{type:"button",className:"btn sm danger",title:c("clearKeyTitle"),onClick:()=>ye(U.id),children:[e.jsx(Pr,{})," ",c("clearKey")]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",className:"key-input",placeholder:c("pasteKey"),value:u[U.id]??"",onChange:fe=>f(ce=>({...ce,[U.id]:fe.target.value}))}),e.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(u[U.id]??"").trim()||k===U.id,onClick:()=>M(U),children:[e.jsx(Jc,{})," ",k===U.id?c("savingKey"):c("saveKey")]})]}),e.jsxs("button",{type:"button",className:"btn sm",disabled:q!==null,title:c("cloneProviderTitle"),onClick:()=>ve(U),children:[e.jsx(Ls,{})," ",q===U.id?c("cloning"):c("cloneProvider")]})]})]},U.id))]}),e.jsx("div",{className:"form-section-title",children:c("customProviders")}),e.jsx("p",{className:"modal-desc",children:c("customDesc")}),n.length===0&&e.jsx("div",{className:"dd-loading",children:c("noCustomProviders")}),e.jsx("div",{className:"provider-list",children:n.map(U=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:U.providerId}),e.jsxs("span",{className:"provider-sub",children:[U.api??"—",U.baseUrl?` · ${U.baseUrl}`:"",U.models.length>0&&` · ${c("modelsCount",{n:U.models.length})}`]})]}),e.jsxs("div",{className:"provider-actions",children:[e.jsx("button",{type:"button",className:"iconbtn",title:c("edit"),onClick:()=>p(Qa(U)),children:e.jsx(ia,{})}),e.jsx("button",{type:"button",className:"iconbtn danger",title:c("delete"),onClick:()=>oe(U),children:e.jsx(Pr,{})})]})]},U.providerId))}),e.jsx("div",{className:"modal-actions",children:e.jsxs("button",{type:"button",className:"btn primary",onClick:()=>p(Om()),children:[e.jsx(gs,{})," ",c("addProvider")]})})]})]})})}function Al(t,n){return t===void 0||!Number.isFinite(t)?"—":n==="zh"?t>=1e4?`${Number((t/1e4).toFixed(t>=1e5?0:1))} 万 / 月`:`${t.toLocaleString("zh-CN")} / 月`:`${new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(t)} / mo`}function Hm(t,n,s=Date.now()){if(!t||!Number.isFinite(t))return"";const r=new Date(t),i=new Date(s),a=Math.max(0,Math.round((Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())-Date.UTC(r.getFullYear(),r.getMonth(),r.getDate()))/864e5));if(a<=1)return n==="zh"?a?"昨天":"今天":a?"Yesterday":"Today";if(a<7)return n==="zh"?`${a} 天前`:`${a} days ago`;if(a<=30){const o=Math.floor(a/7);return n==="zh"?`${o} 周前`:`${o} ${o===1?"week":"weeks"} ago`}return r.toLocaleDateString(n==="zh"?"zh-CN":"en-US")}function Bm(t,n){const s=t.filter(r=>r.kind==="npm"&&r.name===n);return s.find(r=>r.update&&r.trusted&&!r.protected&&!r.pinned)??s[0]}const fi={extensions:"extTypeExtension",skills:"extTypeSkill",prompts:"extTypePrompt",themes:"extTypeTheme"};function Um({catalog:t,packages:n,working:s,inspect:r,update:i,details:a}){const o=nt(),{locale:c}=Qn(),[l,p]=d.useState(),[u,f]=d.useState(),[k,j]=d.useState(""),[I,E]=d.useState(0);d.useEffect(()=>{if(f(void 0),j(""),!l)return;const N=new AbortController;return a(`npm:${l}`,N.signal).then(R=>{N.signal.aborted||f(R)}).catch(R=>{N.signal.aborted||j(R.message)}),()=>N.abort()},[l,I,a]);const $=N=>[N.author,N.version&&`v${N.version}`,Al(N.downloads,c),Hm(N.date,c)].filter(Boolean).join(" · ");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ext-catalog-list",children:t==null?void 0:t.items.map(N=>{const R=Bm(n,N.name),y=l===N.name,L=!!(R!=null&&R.update)&&R.trusted&&!R.protected&&!R.pinned,b=c==="zh"&&N.descriptionZh?N.descriptionZh:N.description;return e.jsxs("article",{className:`ext-catalog-row ${y?"expanded":""}`,children:[e.jsxs("div",{className:"ext-catalog-line",children:[e.jsxs("button",{className:"ext-catalog-expand","aria-expanded":y,"aria-label":`${o("extDetails")} ${N.name}`,onClick:()=>p(y?void 0:N.name),children:[e.jsxs("span",{className:"ext-catalog-identity",children:[e.jsx("strong",{title:N.name,children:N.name}),e.jsx("small",{title:$(N),children:$(N)})]}),e.jsx("span",{className:"ext-catalog-summary",title:b,children:b})]}),e.jsx("button",{className:`ext-catalog-action ${L?"update":R?"installed":"install"}`,disabled:s||!!R&&!L,onClick:()=>L?i(R):r(`npm:${N.name}`),children:o(R?L?"extUpdate":"extInstalled":"extInstall")})]}),y&&e.jsxs("div",{className:"ext-catalog-detail",children:[e.jsxs("div",{children:[e.jsx("p",{children:(u==null?void 0:u.description)||N.description}),u?e.jsxs("div",{className:"ext-resource-counts",children:[Object.entries(fi).filter(([F])=>{var B;return(B=u.resources[F])==null?void 0:B.length}).map(([F,B])=>e.jsxs("span",{children:[o(B)," ",u.resources[F].length]},F)),!Object.values(u.resources).some(F=>F.length)&&e.jsx("span",{children:o("extResourcesUnknown")})]}):k?e.jsxs("p",{role:"alert",children:[k," ",e.jsx("button",{onClick:()=>E(F=>F+1),children:o("extRetry")})]}):e.jsx("small",{role:"status",children:o("loading")})]}),e.jsxs("aside",{children:[e.jsxs("code",{children:["npm:",N.name]}),e.jsx("span",{children:(u==null?void 0:u.license)||(u?o("extLicenseUnknown"):"")}),((u==null?void 0:u.repository)||N.repository)&&e.jsxs("a",{href:(u==null?void 0:u.repository)||N.repository,target:"_blank",rel:"noreferrer",children:[o("extViewSource")," ↗"]}),e.jsxs("a",{href:N.url,target:"_blank",rel:"noreferrer",children:[o("extCatalogPage")," ↗"]})]})]})]},N.name)})}),t&&e.jsx("p",{className:"ext-catalog-origin",children:o(t.total===void 0?"extCatalogOriginPage":"extCatalogOrigin",{count:(t.total??t.items.length).toLocaleString(c==="zh"?"zh-CN":"en-US")})})]})}async function Mn(t,n,s={},r){const i=await fetch(Sn("/api/extensions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,clientId:fn(),cwd:t,action:n}),signal:r}),a=await i.json();if(!i.ok)throw Error(a.error??i.statusText);return a}function Dl({cwd:t,reload:n,onUpdateCount:s,mode:r="manage",children:i}){var st,lt;const a=nt(),{locale:o}=Qn(),c=d.useCallback((g,ne)=>Mn(t,"details",{source:g},ne),[t]),[l,p]=d.useState(),[u,f]=d.useState("installed"),[k,j]=d.useState(""),[I,E]=d.useState(""),[$,N]=d.useState("downloads"),[R,y]=d.useState(1),[L,b]=d.useState(),[F,B]=d.useState(),ie=d.useRef(),[Q,q]=d.useState(),[ke,Re]=d.useState(),[O,_e]=d.useState(),[M,V]=d.useState(""),[ve,ye]=d.useState(!1),[oe,Fe]=d.useState(!1),[U,fe]=d.useState(!1),[ce,ae]=d.useState(""),[z,Z]=d.useState(!1),[W,ge]=d.useState(),[Ie,Ae]=d.useState("user"),[re,we]=d.useState(!1),[A,xe]=d.useState(),_=d.useRef(),[Se,J]=d.useState(),[De,G]=d.useState(!1),[Oe,Ne]=d.useState(!1),[Ee,et]=d.useState(()=>localStorage.getItem("pi-extensions-autocheck")!=="false"),Ce=d.useRef(!0),be=d.useRef(0);d.useEffect(()=>{if(!O||O.content===O.original)return;const g=ne=>{ne.preventDefault(),ne.returnValue=""};return window.addEventListener("beforeunload",g),()=>window.removeEventListener("beforeunload",g)},[O]);const ze=d.useRef(null);d.useEffect(()=>{var ct;if(!z&&!A)return;const g=document.activeElement,ne=ze.current,We=()=>Array.from((ne==null?void 0:ne.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), a[href], [tabindex="0"]'))??[]);(ct=We()[0])==null||ct.focus();const He=ft=>{if(ft.key!=="Tab")return;const Mt=We(),Dt=Mt[0],$t=Mt.at(-1);ft.shiftKey&&(document.activeElement===Dt||!(ne!=null&&ne.contains(document.activeElement)))?(ft.preventDefault(),$t==null||$t.focus()):!ft.shiftKey&&(document.activeElement===$t||!(ne!=null&&ne.contains(document.activeElement)))&&(ft.preventDefault(),Dt==null||Dt.focus())};return document.addEventListener("keydown",He),()=>{document.removeEventListener("keydown",He),g instanceof HTMLElement&&g.isConnected&&g.focus()}},[z,!!A]);const tt=`pi-extensions-job:${t}`;async function Ye(g=!1){const ne=++be.current;g&&fe(!0);try{const We=await Mn(t,g?"check":"list");if(Ce.current&&ne===be.current){p(We);const He=ie.current&&We.packages.find(ct=>ct.name===ie.current);He&&(B(He.id),q(He.id),ie.current=void 0),We.autoCheck!==void 0&&et(We.autoCheck),V("")}}catch(We){Ce.current&&V(We.message)}finally{Ce.current&&fe(!1)}}d.useEffect(()=>{Ce.current=!0,Ye();const g=sessionStorage.getItem(tt);return g&&Mn(t,"job",{id:g}).then(J).catch(()=>sessionStorage.removeItem(tt)),()=>{Ce.current=!1}},[t]),d.useEffect(()=>{if(!Ee||!l||(Se==null?void 0:Se.phase)==="running")return;const g=Math.max(0,(l.checkedAt??0)+360*60*1e3-Date.now()),ne=setTimeout(()=>void Ye(!0),g);return()=>clearTimeout(ne)},[Ee,l==null?void 0:l.checkedAt,!!l,Se==null?void 0:Se.phase]),d.useEffect(()=>{if(u!=="browse")return;const g=new AbortController;Fe(!0),b(void 0);const ne=setTimeout(()=>void Mn(t,"search",{query:k,type:I,sort:$,page:R},g.signal).then(We=>{b(We),V("")}).catch(We=>{g.signal.aborted||V(We.message)}).finally(()=>{g.signal.aborted||Fe(!1)}),300);return()=>{clearTimeout(ne),g.abort()}},[t,u,k,I,$,R]),d.useEffect(()=>{if((Se==null?void 0:Se.phase)!=="running")return;let g=!1;const ne=setInterval(()=>void Mn(t,"job",{id:Se.id}).then(We=>{var He;g||(J(We),We.phase!=="running"&&(sessionStorage.removeItem(tt),Ne(!0),We.phase==="done"&&((He=_.current)==null?void 0:He.action)==="install"&&(Z(!1),ge(void 0),f("installed"),j("")),Ye()))}).catch(We=>{g||V(We.message)}),800);return()=>{g=!0,clearInterval(ne)}},[Se==null?void 0:Se.id,Se==null?void 0:Se.phase,t]);async function Le(g,ne=l==null?void 0:l.version){if(ne){_.current=g,g.action==="install"&&(ie.current=W==null?void 0:W.name),ye(!0),V("");try{const We=await Mn(t,"start",{operation:g,version:ne});if(!Ce.current)return;J(We),sessionStorage.setItem(tt,We.id),xe(void 0),g.action!=="install"&&(Z(!1),ge(void 0))}catch(We){V(We.message)}finally{ye(!1)}}}async function Xe(g){ye(!0),V("");try{const ne=await Mn(t,"preview",{source:g});if(!Ce.current)return;ge(ne),J(void 0),ae(g),Z(!0),we(!1)}catch(ne){V(ne.message)}finally{ye(!1)}}async function vt(g){try{xt!=null&&xt.openExtensionPath?await xt.openExtensionPath({clientId:fn(),cwd:t,id:g.id}):await navigator.clipboard.writeText(g.path??g.source)}catch(ne){V(ne.message)}}const se=ve||(Se==null?void 0:Se.phase)==="running",Ue=(l==null?void 0:l.packages.filter(g=>g.update&&!g.protected))??[];d.useEffect(()=>s==null?void 0:s(Ue.length),[Ue.length,s]);const w=(l==null?void 0:l.packages.filter(g=>(r!=="updates"||g.kind!=="file"&&!g.protected)&&`${g.name} ${g.source}`.toLowerCase().includes(k.toLowerCase())))??[];d.useEffect(()=>{if(!F)return;let g=!1;return Re(void 0),Mn(t,"notes",{id:F}).then(ne=>{g||Re(ne)}).catch(()=>{}),()=>{g=!0}},[F,t]);async function H(g){try{const ne=await Mn(t,"file",{id:g.id});_e({...ne,original:ne.content,id:g.id,name:g.name})}catch(ne){V(ne.message)}}async function X(){if(O){ye(!0);try{await Mn(t,"save-file",{id:O.id,version:O.version,content:O.content}),_e(void 0),Ne(!0)}catch(g){V(g.message)}finally{ye(!1)}}}const me=g=>g in fi?a(fi[g]):g,$e=g=>Object.entries(g.resources).filter(([,ne])=>ne.length).map(([ne,We])=>e.jsxs("span",{children:[me(ne)," ",We.length]},ne));function Pe(g){var We;const ne=F===g.id;return e.jsxs("article",{className:`ext-row${g.enabled?"":" ext-disabled"}`,"data-extension-id":g.id,children:[e.jsxs("div",{className:"ext-row-main",children:[e.jsx("button",{className:"ext-expand","aria-label":`${a("extDetails")} ${g.name}`,"aria-expanded":ne,onClick:()=>B(ne?void 0:g.id),children:ne?e.jsx(nn,{}):e.jsx(_t,{})}),e.jsxs("div",{className:"ext-row-info",children:[e.jsxs("div",{className:"ext-name",children:[e.jsx("strong",{children:g.name}),Q===g.id&&e.jsx("span",{className:"ext-new",children:a("extNew")})]}),e.jsxs("div",{className:"ext-meta",children:[g.kind==="file"?e.jsx("code",{title:g.path,children:(We=g.path)==null?void 0:We.replace(/^\/Users\/[^/]+|^\/home\/[^/]+/,"~")}):e.jsxs("span",{children:[g.kind," · ",a(g.scope==="user"?"extPersonal":"extProject")]}),!g.trusted&&e.jsx("span",{className:"ext-pin",children:a("extUntrustedNotLoaded")})]})]}),g.kind!=="file"&&e.jsx("div",{className:"ext-resource-counts",children:$e(g)}),r==="manage"&&g.kind==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void vt(g),children:a(xt!=null&&xt.openExtensionPath?"extOpen":"extCopyPath")}),e.jsx("button",{disabled:se,onClick:n,children:a("extReload")})]}),e.jsxs("div",{className:"ext-version",children:[r==="manage"&&g.update&&!g.protected&&g.trusted&&!g.pinned?e.jsxs("button",{className:"ext-version-update",disabled:se||U,onClick:()=>void Le({action:"update",id:g.id}),children:[g.version,g.latest&&` → ${g.latest}`," · ",a("extUpdate")]}):e.jsxs(e.Fragment,{children:[g.version??(g.kind==="git"?"git":""),g.latest&&g.update&&e.jsxs("span",{children:[" → ",g.latest]})]}),g.pinned&&e.jsxs("span",{className:"ext-pin",children:[e.jsx(Kc,{}),a("extPinned")]})]}),r==="updates"&&g.update&&!g.protected&&e.jsx("button",{className:"ext-update",disabled:se||U,onClick:()=>void Le({action:"update",id:g.id}),children:a("extUpdate")}),r!=="updates"&&e.jsx("input",{className:"ext-switch",role:"switch",type:"checkbox","aria-label":`${a("extEnable")} ${g.name}`,checked:g.enabled,disabled:se||U||!g.trusted||g.protected,onChange:He=>void Le({action:"toggle",id:g.id,enabled:He.target.checked})})]}),ne&&e.jsxs("div",{className:"ext-details",children:[e.jsx("p",{children:g.description??g.source}),e.jsx("code",{className:"ext-source",children:g.source}),e.jsxs("div",{className:"ext-actions",children:[g.kind==="file"&&e.jsx("button",{disabled:se||!g.trusted,onClick:()=>void H(g),children:a("extEditFile")}),g.kind==="npm"&&e.jsxs("a",{href:`https://pi.dev/packages/${g.name}`,target:"_blank",rel:"noreferrer",children:[e.jsx(wo,{}),"pi.dev"]}),g.path&&e.jsxs("button",{onClick:()=>void vt(g),children:[e.jsx(Us,{}),a(xt!=null&&xt.openExtensionPath?"extOpen":"extCopyPath")]}),g.pinned&&e.jsx("button",{disabled:se||U||!g.trusted||g.protected,onClick:()=>xe({operation:{action:"unpin",id:g.id},name:g.name}),children:a("extUnpin")}),g.kind!=="file"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:se||U||!(l!=null&&l.trusted)||g.protected,onClick:()=>xe({operation:{action:"move",id:g.id},name:g.name}),children:a(g.scope==="user"?"extMoveProject":"extMovePersonal")}),e.jsx("button",{className:"ext-danger",disabled:se||U||!g.trusted||g.protected,onClick:()=>xe({operation:{action:"remove",id:g.id},name:g.name}),children:a(g.kind==="local"?"extRemoveReference":"extUninstall")})]})]}),ke&&e.jsxs("div",{className:"ext-release-notes",children:[e.jsxs("strong",{children:[a("extReleaseNotes")," ",ke.title]}),ke.notes.length?e.jsx("ul",{children:ke.notes.map((He,ct)=>e.jsx("li",{children:He},ct))}):e.jsx("p",{children:a("extNoNotes")}),ke.url&&e.jsxs("a",{href:ke.url,target:"_blank",rel:"noreferrer",children:[a("extViewNotes")," ↗"]})]}),Object.entries(g.resources).some(([,He])=>He.length>0)&&e.jsxs("details",{children:[e.jsx("summary",{children:a("extResources")}),Object.entries(g.resources).filter(([,He])=>He.length).map(([He,ct])=>e.jsxs("div",{children:[e.jsx("strong",{children:me(He)}),e.jsx("pre",{children:ct.join(`
|
|
255
|
-
`)})]},He))]}),e.jsx("p",{className:"ext-muted",children:a("extResourceConfig")})]})]},g.id)}return e.jsxs("section",{className:`extensions-panel ${r==="manage"?"extensions-v3":""}`,children:[e.jsxs("header",{className:"ext-header",children:[e.jsx("h2",{children:r==="updates"?a("componentUpdates"):"Extensions"}),r==="updates"&&e.jsx("span",{className:"settings-count",children:l!=null&&l.checkedAt?a("v2LastChecked",{time:new Date(l.checkedAt).toLocaleDateString()===new Date().toLocaleDateString()?new Date(l.checkedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):new Date(l.checkedAt).toLocaleDateString([],{month:"short",day:"numeric"})}):a("extNotChecked")}),e.jsx("div",{className:"settings-heading-actions",children:r==="updates"?e.jsx("button",{disabled:U||se,onClick:()=>void Ye(!0),children:a(U?"extChecking":"settingsCheckNow")}):e.jsx("button",{disabled:se,onClick:()=>{ae(""),ge(void 0),J(void 0),V(""),Z(!0)},children:a("extInstallSource")})})]}),r==="manage"&&e.jsx("div",{className:"ext-v3-tabs",role:"tablist","aria-label":"Extensions",children:["installed","browse"].map(g=>e.jsx("button",{role:"tab",tabIndex:u===g?0:-1,onKeyDown:ne=>{var We,He;if(["ArrowLeft","ArrowRight","Home","End"].includes(ne.key)){ne.preventDefault();const ct=ne.key==="Home"?"installed":ne.key==="End"||g==="installed"?"browse":"installed";f(ct),j(""),y(1),(He=(We=ne.currentTarget.parentElement)==null?void 0:We.querySelectorAll('[role="tab"]')[ct==="installed"?0:1])==null||He.focus()}},"aria-selected":u===g,onClick:()=>{f(g),j(""),y(1)},children:g==="installed"?`${a("extInstalled")} · ${(l==null?void 0:l.packages.filter(ne=>ne.kind!=="file").length)??0}`:a("extBrowse")},g))}),i,M&&!z&&e.jsxs("div",{className:"ext-error",role:"alert",children:[M,e.jsx("button",{onClick:()=>void Ye(),children:a("extRefresh")})]}),Se&&!z&&e.jsxs("div",{className:`ext-job ${Se.phase==="error"?"ext-error":""}`,role:"status",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a(Se.phase==="running"?"extRunning":Se.phase==="done"?"extDone":"extFailed")}),e.jsx("button",{onClick:()=>G(!De),children:a("extLog")})]}),Se.error&&e.jsx("p",{children:Se.error}),Se.phase==="error"&&_.current&&e.jsx("button",{disabled:se,onClick:()=>{var g;return((g=_.current)==null?void 0:g.action)==="install"?void Xe(ce):void Le(_.current)},children:a("extRetry")}),e.jsx("pre",{children:De?Se.log:Se.log.split(`
|
|
256
|
-
`).filter(Boolean).slice(-3).join(`
|
|
257
|
-
`)})]}),Oe&&e.jsxs("div",{className:"ext-notice",children:[a("extReloadHint")," ",e.jsx("button",{disabled:se,onClick:()=>{n(),Ne(!1)},children:a("extReload")})]}),u==="installed"?e.jsxs(e.Fragment,{children:[r==="updates"&&Ue.length>0&&e.jsxs("div",{className:"ext-update-banner",children:[e.jsx(yi,{}),e.jsxs("div",{children:[e.jsxs("strong",{children:[Ue.length," ",a("extUpdatesAvailable")]}),e.jsx("p",{children:Ue.map(g=>g.name).join(" · ")})]}),e.jsx("button",{className:"ext-primary",disabled:se||U,onClick:()=>xe({operation:{action:"update-all"},name:Ue.map(g=>g.name).join(", ")}),children:a("extUpdateAll")})]}),l?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"settings-group-title",children:[a("settingsPackages"),e.jsx("small",{children:a("v2PackagesHint")})]}),e.jsxs("div",{className:"ext-list",children:[w.filter(g=>g.kind!=="file").map(Pe),!w.some(g=>g.kind!=="file")&&e.jsxs("div",{className:"settings-empty",children:[e.jsx("p",{children:a("v2NoPackages")}),r==="manage"&&e.jsx("button",{onClick:()=>f("browse"),children:a("extBrowse")})]})]}),r==="manage"&&w.some(g=>g.kind==="file")&&e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"ext-group-title",children:[a("extSingleFiles"),e.jsx("small",{children:a("v2FilesHint")})]}),e.jsx("div",{className:"ext-list",children:w.filter(g=>g.kind==="file").map(Pe)})]})]}):e.jsx("p",{className:"ext-empty",children:a("loading")}),r==="updates"&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"settings-group-title",children:a("v2UpdatePolicy")}),e.jsxs("div",{className:"settings-group",children:[e.jsxs("label",{className:"settings-list-row",children:[e.jsxs("span",{children:[a("settingsAutoCheck"),e.jsx("small",{className:"settings-description",children:a("v2AutoCheckHint")})]}),e.jsx("input",{className:"settings-switch",role:"switch",type:"checkbox","aria-label":a("settingsAutoCheck"),disabled:!l||se,checked:Ee,onChange:g=>{const ne=g.target.checked;et(ne),Mn(t,"preferences",{enabled:ne}).catch(We=>{et(!ne),V(We.message)})}})]}),e.jsxs("div",{className:"settings-list-row",children:[e.jsxs("span",{children:[a("v2InstallPolicy"),e.jsx("small",{className:"settings-description",children:a("v2InstallHint")})]}),e.jsx("span",{className:"settings-readonly",children:a("v2ManualInstall")})]})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ext-filters",children:[e.jsxs("label",{className:"ext-search",children:[e.jsx(ts,{}),e.jsx("input",{type:"search",value:k,onChange:g=>{j(g.target.value),y(1)},placeholder:a("extSearch"),"aria-label":a("extSearch")})]}),e.jsx("div",{className:"ext-type-filters",children:["","extension","skill","prompt","theme"].map(g=>e.jsx("button",{"aria-pressed":I===g,onClick:()=>{E(g),y(1)},children:g?me(`${g}s`):a("extAllTypes")},g))}),e.jsxs("select",{"aria-label":a("extSort"),value:$,onChange:g=>{N(g.target.value),y(1)},children:[e.jsx("option",{value:"downloads",children:a("extPopular")}),e.jsx("option",{value:"recent",children:a("extRecent")})]})]}),oe?e.jsx("p",{className:"ext-empty",role:"status",children:a("loading")}):e.jsx(Um,{catalog:L,packages:(l==null?void 0:l.packages)??[],working:se||U||!l,inspect:g=>void Xe(g),update:g=>void Le({action:"update",id:g.id}),details:c}),L&&!L.items.length&&e.jsx("p",{className:"ext-empty",children:a("extNoResults")}),L&&e.jsxs("div",{className:"ext-pagination",children:[e.jsx("button",{disabled:R<=1,onClick:()=>y(R-1),children:a("extPrevious")}),e.jsxs("span",{children:[R," / ",L.pages]}),e.jsx("button",{disabled:R>=L.pages,onClick:()=>y(R+1),children:a("extNext")})]})]}),O&&e.jsx("div",{className:"ext-dialog-backdrop",children:e.jsxs("div",{className:"ext-dialog ext-editor","data-dirty":O.content!==O.original,role:"dialog","aria-modal":"true","aria-label":a("extEditFile"),onKeyDown:g=>{g.key==="Escape"&&g.stopPropagation()},children:[e.jsx("header",{children:e.jsx("h3",{children:O.name})}),e.jsx("textarea",{"aria-label":a("extEditFile"),value:O.content,onChange:g=>_e({...O,content:g.target.value}),spellCheck:!1}),e.jsx("p",{children:a("extEditHint")}),M&&e.jsx("p",{role:"alert",className:"ext-error",children:M}),e.jsxs("footer",{children:[e.jsx("button",{disabled:ve,onClick:()=>{(O.content===O.original||window.confirm(a("extDiscard")))&&_e(void 0)},children:a("extCancel")}),e.jsx("button",{className:"ext-primary",disabled:ve,onClick:()=>void X(),children:a("extSaveFile")})]})]})}),(z||A)&&e.jsx("div",{className:"ext-dialog-backdrop",onClick:()=>{ve||(Z(!1),xe(void 0))},children:e.jsxs("div",{ref:ze,className:"ext-dialog",role:"dialog","aria-modal":"true","aria-label":a(z?"extInstall":"extConfirm"),onClick:g=>g.stopPropagation(),onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),Z(!1),xe(void 0))},children:[e.jsxs("header",{children:[e.jsxs("h3",{children:[a(z?"extInstall":"extConfirm"),z&&W&&e.jsxs(e.Fragment,{children:[" ",e.jsx("code",{children:W.name})]})]}),e.jsx("button",{"aria-label":a("close"),onClick:()=>{Z(!1),xe(void 0)},children:e.jsx(qt,{})})]}),z?e.jsx(e.Fragment,{children:W?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"ext-install-meta",children:[W.author,W.version&&`v${W.version}`,((st=L==null?void 0:L.items.find(g=>g.name===W.name))==null?void 0:st.downloads)!==void 0?Al((lt=L.items.find(g=>g.name===W.name))==null?void 0:lt.downloads,o):void 0].filter(Boolean).join(" · ")}),e.jsxs("div",{className:"ext-preview-resources",children:[e.jsx("strong",{children:a("extWillLoad")}),Object.keys(W.resources).length?Object.entries(W.resources).map(([g,ne])=>e.jsxs("p",{children:[e.jsx("span",{children:me(g)}),e.jsx("code",{children:ne.join(", ")||a("extNoneDeclared")})]},g)):e.jsx("p",{children:a("extResourcesUnknown")})]}),e.jsxs("div",{className:"ext-install-scope",children:[e.jsx("strong",{children:a("extScope")}),e.jsx("div",{className:"ext-scope-segments",children:["user","project"].map(g=>e.jsx("button",{"aria-pressed":Ie===g,disabled:se||g==="project"&&!(l!=null&&l.trusted),onClick:()=>Ae(g),children:a(g==="user"?"extPersonal":"extInstallProject")},g))}),e.jsx("code",{children:Ie==="user"?"~/.pi/agent/settings.json":".pi/settings.json"}),!(l!=null&&l.trusted)&&e.jsx("small",{children:a("extProjectUntrusted")})]}),W.canPin&&e.jsxs("label",{className:"ext-auto",children:[e.jsx("input",{type:"checkbox",checked:re,disabled:se,onChange:g=>we(g.target.checked)}),a("extPinVersion")," ",W.version]}),e.jsx("p",{className:"ext-security",children:a("extSecurity")}),e.jsxs("code",{className:"ext-command",children:["pi install ",re&&W.canPin?`${W.source.replace(/^(npm:(?:@[^/]+\/)?[^@]+)(?:@.*)?$/,"$1")}@${W.version}`:W.source,Ie==="project"?" --local":""]}),e.jsxs("footer",{children:[W.repository&&e.jsxs("a",{href:W.repository,target:"_blank",rel:"noreferrer",children:[a("extViewSource")," ↗"]}),e.jsx("button",{onClick:()=>Z(!1),children:a("extCancel")}),e.jsx("button",{className:"ext-primary",disabled:se||U,onClick:()=>void(async()=>{if((Se==null?void 0:Se.phase)==="error"||M){ye(!0);try{const[g,ne]=await Promise.all([Mn(t,"preview",{source:W.source}),Mn(t,"list")]);if(!Ce.current)return;ge(g),p(ne),await Le({action:"install",ticket:g.ticket,scope:Ie,pin:re},ne.version)}catch(g){V(g.message)}finally{ye(!1)}}else await Le({action:"install",ticket:W.ticket,scope:Ie,pin:re})})(),children:a((Se==null?void 0:Se.phase)==="running"?"extInstalling":(Se==null?void 0:Se.phase)==="error"||M?"extRetry":"extInstall")})]})]}):e.jsxs("form",{onSubmit:g=>{g.preventDefault(),Xe(ce)},children:[e.jsxs("label",{children:[a("extSource"),e.jsx("input",{autoFocus:!0,value:ce,onChange:g=>ae(g.target.value),placeholder:"npm:@scope/name · git:github.com/owner/repo · ./local-path"})]}),e.jsx("button",{className:"ext-primary",disabled:ve||!ce.trim(),type:"submit",children:a("extReview")})]})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:A==null?void 0:A.name}),e.jsx("p",{children:a((A==null?void 0:A.operation.action)==="remove"?"extRemoveHint":(A==null?void 0:A.operation.action)==="move"?"extMoveHint":(A==null?void 0:A.operation.action)==="unpin"?"extUnpinHint":"extUpdateHint")}),e.jsxs("footer",{children:[e.jsx("button",{onClick:()=>xe(void 0),children:a("extCancel")}),e.jsx("button",{className:"ext-primary",disabled:ve||U,onClick:()=>A&&void Le(A.operation),children:a("extConfirm")})]})]}),(Se==null?void 0:Se.phase)==="error"&&z&&e.jsx("pre",{className:"ext-install-error",role:"alert",children:[Se.error,Se.log.split(`
|
|
258
|
-
`).filter(Boolean).slice(-3).join(`
|
|
259
|
-
`)].filter(Boolean).join(`
|
|
260
|
-
`)}),M&&e.jsx("p",{className:"ext-error",role:"alert",children:M})]})})]})}function Wm({cwd:t,updates:n,reload:s,onUpdateCount:r}){const i=nt();return e.jsx(Dl,{cwd:t,mode:"updates",reload:s,onUpdateCount:r,children:e.jsx("div",{className:"settings-group",children:n==null?void 0:n.items.filter(a=>a.id==="builtin:agent").map(a=>e.jsxs("div",{className:"settings-list-row",children:[e.jsxs("span",{children:["Pi",e.jsx("small",{className:"settings-description",children:i("v2PiHint")})]}),e.jsx("span",{className:"component-version",children:a.current??"—"}),e.jsx("span",{className:"settings-readonly",children:i("settingsBundled")})]},a.id))})},t)}function qm({cwd:t,conversationId:n}){const s=nt(),[r,i]=d.useState(),[a,o]=d.useState(""),[c,l]=d.useState(),[p,u]=d.useState(!1),[f,k]=d.useState(!1),[j,I]=d.useState(!1),[E,$]=d.useState(!1),[N,R]=d.useState(),[y,L]=d.useState(!1),[b,F]=d.useState(!1),[B,ie]=d.useState(!1),Q=d.useRef(!0),q=d.useRef(0),ke=d.useRef(!1),Re=!!c&&c.text!==c.initial;async function O(re,we={}){const A=await fetch(Sn("/api/system-prompt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:fn(),cwd:t,conversationId:n,action:re,...we})}),xe=await A.json();if(!A.ok)throw Error(xe.error??A.statusText);return xe}async function _e(){if(ke.current)return;const re=++q.current;try{const we=await O("get");Q.current&&q.current===re&&i(we)}catch(we){Q.current&&q.current===re&&o(we.message)}}d.useEffect(()=>{Q.current=!0,_e();const re=setInterval(()=>void _e(),2e3);return()=>{Q.current=!1,clearInterval(re)}},[t,n]),d.useEffect(()=>{if(!Re)return;const re=we=>{we.preventDefault(),we.returnValue=""};return window.addEventListener("beforeunload",re),()=>window.removeEventListener("beforeunload",re)},[Re]);const M=()=>!Re||window.confirm(s("promptDiscard"));function V(re,we=!1){if(!M())return;const A=we&&!re.exists?(r==null?void 0:r.defaultPreamble)??"":re.content;l({file:re,text:A,initial:A,confirmed:!we}),F(!1),o("")}async function ve(re,we){if(!(re==="restore"&&(!M()||!window.confirm(s("promptRestoreConfirm",{path:(we==null?void 0:we.path)??""}))))){ke.current=!0,L(!0),o(""),++q.current;try{const A=await O(re,we?{id:we.id,version:we.version,...re==="save"?{content:c==null?void 0:c.text}:{}}:{});Q.current&&(i(A),re!=="retry"&&l(void 0),R(we==null?void 0:we.id),F(!0))}catch(A){Q.current&&o(A.message)}finally{ke.current=!1,Q.current&&L(!1)}}}async function ye(){if(M())try{const re=await O("get");if(!Q.current)return;i(re);const we=re.files.find(A=>A.id===(c==null?void 0:c.file.id));we&&l({file:we,text:we.content,initial:we.content,confirmed:!0}),o("")}catch(re){o(re.message)}}async function oe(){try{await navigator.clipboard.writeText((r==null?void 0:r.raw)??""),ie(!0)}catch{o(s("promptCopyFailed"))}}function Fe(re){return!c||c.file.kind!==re?null:e.jsxs("div",{className:"prompt-editor","data-dirty":Re,children:[re==="system"&&e.jsx("div",{className:"prompt-warning",children:s("promptReplaceWarning")}),c.confirmed?e.jsxs(e.Fragment,{children:[re!=="context"&&e.jsxs("label",{className:"prompt-scope",children:[s("promptScope"),e.jsx("select",{disabled:y,value:c.file.id,onChange:we=>{const A=r==null?void 0:r.files.find(xe=>xe.id===we.target.value);if(A&&M()){const xe=re==="system"&&!A.exists?(r==null?void 0:r.defaultPreamble)??"":A.content;l({file:A,text:xe,initial:xe,confirmed:!0})}},children:r==null?void 0:r.files.filter(we=>we.kind===re).map(we=>e.jsxs("option",{value:we.id,disabled:!we.editable,children:[s(we.scope==="user"?"promptUser":"promptProject"),we.editable?"":` · ${s("promptUntrusted")}`]},we.id))})]}),e.jsx("code",{className:"prompt-editor-path",children:c.file.path}),re==="context"&&e.jsx("p",{className:"prompt-muted",children:s("promptContextHint")}),e.jsx("textarea",{autoFocus:!0,value:c.text,onChange:we=>l({...c,text:we.target.value}),spellCheck:!1,"aria-label":s("promptEditor"),disabled:y}),e.jsxs("div",{className:"prompt-editor-actions",children:[e.jsx("span",{children:s("promptNativeSave")}),e.jsx("button",{disabled:y,onClick:()=>void ye(),children:s("promptReloadFile")}),e.jsx("button",{disabled:y,onClick:()=>{M()&&l(void 0)},children:s("cancel")}),e.jsx("button",{className:"prompt-primary",disabled:y||!c.file.editable||(r==null?void 0:r.opaque),onClick:()=>void ve("save",c.file),children:s(y?"promptSaving":"promptSave")})]})]}):e.jsxs("div",{className:"prompt-editor-actions",children:[e.jsx("button",{onClick:()=>l(void 0),children:s("cancel")}),e.jsx("button",{className:"prompt-primary",onClick:()=>l({...c,confirmed:!0}),children:s("promptContinueReplace")})]})]})}if(!r)return e.jsxs("section",{className:"system-prompt-panel",children:[e.jsx("p",{children:s("loading")}),a&&e.jsx("p",{role:"alert",children:a})]});const U=re=>{var we;return(we=r.sections.find(A=>A.name===re))==null?void 0:we.text},fe=r.files.find(re=>re.kind==="system"&&re.active),ce=r.files.filter(re=>re.kind==="append"&&re.active),ae=r.files.filter(re=>re.kind==="context"&&re.exists),z=r.files.find(re=>re.kind==="context"&&!re.exists&&re.editable),Z=new Map;for(const re of r.rules){const we=`${re.kind}:${re.name??""}:${re.path??""}`;Z.set(we,[...Z.get(we)??[],re])}const W=re=>r.files.find(we=>we.kind===re&&we.scope===(r.trusted?"project":"user")),ge=re=>r.rules.filter(we=>we.kind===re).length,Ie=r.files.some(re=>re.id===N&&re.exists&&!re.active),Ae=r.custom?" prompt-inactive":"";return e.jsxs("section",{className:"system-prompt-panel","aria-label":s("settingsSystemPrompt"),children:[e.jsxs("header",{className:"prompt-heading",children:[e.jsx("h2",{children:s("settingsSystemPrompt")}),e.jsxs("span",{className:"prompt-token",title:s("promptTokenHint"),children:[s("promptTokens",{n:r.tokens.toLocaleString()})," · ",s("v2PromptHint")]}),e.jsxs("div",{className:"prompt-heading-actions",children:[e.jsx("button",{className:"prompt-link",disabled:!!c,onClick:()=>u(!p),children:s(p?"promptViewSections":"promptViewRaw")}),e.jsxs("button",{onClick:()=>void oe(),children:[B?e.jsx(ss,{}):e.jsx(Ls,{}),s(B?"promptCopied":"promptCopy")]})]})]}),(b||r.pending)&&!r.reloadError&&e.jsxs("p",{className:"prompt-save-status",role:"status",children:[e.jsx(ss,{}),s(r.pending?"promptSavedPending":Ie?"promptSavedShadowed":"promptSavedNext")]}),a&&e.jsx("p",{className:"prompt-error",role:"alert",children:a}),r.reloadError&&e.jsxs("div",{className:"prompt-error",role:"alert",children:[s("promptReloadFailed")," ",r.reloadError,e.jsx("button",{disabled:y,onClick:()=>void ve("retry"),children:s("promptRetry")})]}),r.opaque?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"prompt-warning",children:s(r.forced?"promptForced":"promptOpaque")}),e.jsx("pre",{className:"prompt-raw",children:r.raw})]}):p?e.jsx("pre",{className:"prompt-raw",children:r.raw}):e.jsxs("div",{className:"prompt-sections",children:[e.jsxs("div",{className:`prompt-section${(c==null?void 0:c.file.kind)==="system"?" prompt-editing":""}`,children:[e.jsxs("div",{className:"prompt-section-line",children:[e.jsxs("span",{className:"prompt-label",children:[s("promptDefault"),e.jsx("small",{className:"settings-description",children:s("v2IdentityHint")})]}),e.jsxs("div",{className:"prompt-summary",children:[e.jsx("button",{className:"prompt-text-button","aria-expanded":j,onClick:()=>I(!j),children:r.custom?s("promptReplaced"):s("promptBuiltinIdentity")}),r.custom&&fe&&e.jsx("code",{className:"prompt-file-path",children:fe.path})]}),e.jsx("div",{className:"prompt-row-actions",children:r.custom&&fe?e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:y||!fe.editable,onClick:()=>V(fe),children:s("promptEdit")}),e.jsx("button",{disabled:y||!fe.editable,onClick:()=>void ve("restore",fe),children:s("promptRestore")})]}):e.jsx("button",{disabled:y,onClick:()=>V(W("system"),!0),children:s("promptReplace")})})]}),j&&e.jsx("pre",{className:"prompt-section-text",children:U("preamble")}),Fe("system")]}),e.jsx("div",{className:`prompt-section${Ae}`,children:e.jsxs("div",{className:"prompt-section-line",children:[e.jsxs("span",{className:"prompt-label",children:[s("promptTools")," · ",r.tools.length,e.jsx("small",{className:"settings-description",children:s("v2ToolsHint")})]}),e.jsx("div",{className:"prompt-tool-list",children:r.tools.map(re=>e.jsx("code",{className:re.custom?"prompt-custom-tool":"",title:re.path,children:re.name},re.name))}),e.jsx("span",{className:"prompt-auto",children:s(r.custom?"promptInactive":"promptAutomatic")})]})}),e.jsxs("div",{className:`prompt-section${Ae}`,children:[e.jsxs("div",{className:"prompt-section-line",children:[e.jsxs("span",{className:"prompt-label",children:[s("promptRules")," · ",r.rules.length,e.jsx("small",{className:"settings-description",children:s("v2RulesHint")})]}),e.jsx("div",{className:"prompt-summary",children:s("promptRuleSummary",{builtin:ge("builtin"),tools:ge("tool"),extensions:ge("extension")+ge("unknown")})}),e.jsxs("button",{className:"prompt-link","aria-expanded":f,onClick:()=>k(!f),children:[f?e.jsx(nn,{}):e.jsx(_t,{}),s(f?"promptCollapse":"promptExpand")]})]}),f&&e.jsx("div",{className:"prompt-rule-groups",children:[...Z].map(([re,we])=>e.jsxs("div",{className:"prompt-rule-group",children:[e.jsxs("span",{title:we[0].path,children:[we[0].name??s(we[0].kind==="builtin"?"promptBuiltin":we[0].kind==="extension"?"promptExtension":"promptRuntime")," · ",we.length]}),e.jsx("ul",{children:we.map((A,xe)=>e.jsx("li",{children:A.text},xe))})]},re))})]}),e.jsxs("div",{className:`prompt-section${Ae}`,children:[e.jsxs("div",{className:"prompt-section-line",children:[e.jsxs("span",{className:"prompt-label",children:[s("promptDocs"),e.jsx("small",{className:"settings-description",children:s("v2DocsHint")})]}),e.jsx("button",{className:"prompt-text-button prompt-summary","aria-expanded":E,onClick:()=>$(!E),children:s("promptDocsSummary")}),e.jsx("span",{className:"prompt-auto",children:s(r.custom?"promptInactive":"promptAutomatic")})]}),E&&U("docs")&&e.jsx("pre",{className:"prompt-section-text",children:U("docs")})]}),e.jsxs("div",{className:`prompt-section${(c==null?void 0:c.file.kind)==="append"?" prompt-editing":""}`,children:[e.jsxs("div",{className:"prompt-section-line",children:[e.jsxs("span",{className:"prompt-label",children:[s("promptAppend"),e.jsx("small",{className:"settings-description",children:s("v2AppendHint")})]}),e.jsx("div",{className:"prompt-summary",children:ce.length?ce.map(re=>e.jsx("code",{className:"prompt-file-path",children:re.path},re.id)):e.jsx("span",{className:"prompt-muted",children:U("addendum")?s("promptRuntime"):s("promptNotSet")})}),e.jsx("div",{className:"prompt-row-actions",children:e.jsx("button",{disabled:y||!(ce[0]??W("append")).editable,onClick:()=>V(ce[0]??W("append")),children:s(ce.length?"promptEdit":"promptAdd")})})]}),Fe("append")]}),e.jsxs("div",{className:`prompt-section${(c==null?void 0:c.file.kind)==="context"?" prompt-editing":""}`,children:[e.jsxs("div",{className:"prompt-section-line prompt-context-line",children:[e.jsxs("span",{className:"prompt-label",children:[s("promptContext"),e.jsx("small",{className:"settings-description",children:s("v2ContextHint")})]}),e.jsx("div",{className:"prompt-context-files",children:ae.length?ae.map(re=>e.jsxs("div",{className:"prompt-context-file",children:[e.jsx("code",{title:re.path,children:re.path.split(/[\\/]/).pop()}),e.jsxs("span",{className:"prompt-token",title:re.changedOnDisk?s("promptDiskChanged"):s("promptTokenHint"),children:[re.tokens.toLocaleString()," tok",re.changedOnDisk?" *":""]}),e.jsx("button",{className:"prompt-link",disabled:y||!re.editable,title:re.error,onClick:()=>V(re),children:s("promptEdit")})]},re.id)):e.jsx("span",{className:"prompt-muted",children:s("promptNoContext")})}),z&&e.jsx("button",{className:"prompt-link",disabled:y,onClick:()=>V(z),children:s("v2CreateAgents")})]}),Fe("context")]}),r.sections.filter(re=>!["preamble","tools","rules","docs","addendum","project_context","skills","cwd"].includes(re.name)).map(re=>e.jsxs("div",{className:"prompt-section",children:[e.jsxs("div",{className:"prompt-section-line",children:[e.jsx("span",{className:"prompt-label",children:re.name}),e.jsx("span",{className:"prompt-summary",children:s("promptRuntimeSection")}),e.jsx("span",{className:"prompt-auto",children:s("promptAutomatic")})]}),e.jsx("pre",{className:"prompt-section-text",children:re.text})]},re.name))]})]})}const Ya=["codemode","deferred","direct","hidden"];function zm(t,n){const s=t.toolExposure&&typeof t.toolExposure=="object"?t.toolExposure:{},r=s[n],i=Object.entries(s).find(([o])=>new RegExp(`^${o.split("*").map(c=>c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")}$`).test(n)),a=r??(i==null?void 0:i[1])??String(t.exposure??"codemode");return{value:a==="codemode-deferred"?"codemode":a,override:r!==void 0||i!==void 0}}function Vm(t,n){const s=JSON.parse(t),r=s.mcpServers??s.servers??s.mcp;if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Expected mcpServers, servers, or mcp");const i={...n.mcpServers??{}};for(const[a,o]of Object.entries(r)){if(Object.hasOwn(i,a))throw new Error(`Server already exists: ${a}`);if(!o||typeof o!="object"||Array.isArray(o))throw new Error(`Invalid server: ${a}`);const c={...o};if(c.type==="local"){if(c.type="stdio",Array.isArray(c.command)){const[p,...u]=c.command;c.command=p,c.args=u}c.environment&&(c.env=c.environment,delete c.environment)}c.type==="remote"&&(c.type="http");const l=JSON.stringify(c).replace(/\{env:([A-Za-z_][A-Za-z0-9_]*)\}/g,"${$1}");if(/\$\{input:/.test(l))throw new Error("Replace ${input:...} with ${ENV_NAME} before importing");i[a]=JSON.parse(l)}return{...n,mcpServers:i}}function Km({cwd:t,send:n,dialog:s}){const r=nt(),[i,a]=d.useState("global"),[o,c]=d.useState(),[l,p]=d.useState(),[u,f]=d.useState("on"),[k,j]=d.useState(3e3),[I,E]=d.useState(""),[$,N]=d.useState(""),[R,y]=d.useState(""),[L,b]=d.useState(!1),[F,B]=d.useState(!1),[ie,Q]=d.useState([]),[q,ke]=d.useState(""),[Re,O]=d.useState([]),[_e,M]=d.useState(),[V,ve]=d.useState(),[ye,oe]=d.useState(),[Fe,U]=d.useState(),[fe,ce]=d.useState(!1),ae=!!o&&I!==JSON.stringify(o.document,null,2),z=d.useRef(!1),Z=d.useRef(new Map),W=(J,De={},G=!1)=>{if(J!=="get"&&z.current)return;J!=="get"&&(z.current=!0);const Oe=Qt();Z.current.set(Oe,{action:J,preserve:G}),J!=="get"&&B(!0),n({type:"native_mcp_request",requestId:Oe,cwd:t,scope:i,action:J,...De})||(Z.current.delete(Oe),z.current=!1,B(!1),N(r("connectionDisconnected")))};d.useEffect(()=>{Z.current.clear(),z.current=!1,c(void 0),p(void 0),E(""),N(""),y(""),Q([]),O([]),B(!1),ve(void 0),oe(void 0),U(void 0),M(void 0);const J=Oe=>{const Ne=Oe.detail,Ee=Z.current.get(Ne.requestId);if(!(!Ee||Ne.cwd!==t||Ne.state&&Ne.state.scope!==i)){if(Z.current.delete(Ne.requestId),Ee.action!=="get"&&(z.current=!1,B(!1)),Ne.error){N(Ne.error),Ee.action==="codemode"&&Ne.codemode&&(p(Ne.codemode),f(Ne.codemode.mode),j(Ne.codemode.inlineBudget));return}Ee.preserve||N(""),b(!!Ne.pending),Ne.state&&!Ee.preserve&&(c(Ne.state),E(JSON.stringify(Ne.state.document,null,2))),Ne.codemode&&(!Ee.preserve||Ee.action==="codemode")&&(p(Ne.codemode),f(Ne.codemode.mode),j(Ne.codemode.inlineBudget)),Ne.codemode&&Ee.preserve&&Ee.action!=="codemode"&&p(et=>et?{...et,effectiveMode:Ne.codemode.effectiveMode,effectiveInlineBudget:Ne.codemode.effectiveInlineBudget}:Ne.codemode),Ne.servers&&Q(Ne.servers),Ne.statusText!==void 0&&ke(Ne.statusText),Ne.toolInfo&&O(Ne.toolInfo),Ne.log!==void 0&&U(Ne.log)}},De=Oe=>y(Oe.detail);window.addEventListener("pi-native-mcp-event",J),window.addEventListener("pi-mcp-notice",De),W("get");const G=setInterval(()=>{Z.current.size||W("get",{},!0)},3e3);return()=>{clearInterval(G),window.removeEventListener("pi-native-mcp-event",J),window.removeEventListener("pi-mcp-notice",De)}},[t,i,n]),d.useEffect(()=>{if(!ae&&!F&&!V&&ye===void 0)return;const J=De=>{De.preventDefault(),De.returnValue=""};return window.addEventListener("beforeunload",J),()=>window.removeEventListener("beforeunload",J)},[ae,F,V,ye]);const ge=J=>{try{const De=JSON.parse(I);J(De),E(JSON.stringify(De,null,2)),N(""),W("save",{version:o==null?void 0:o.version,document:De})}catch(De){N(De.message)}},Ie=()=>{try{W("save",{version:o==null?void 0:o.version,document:JSON.parse(I)})}catch(J){N(J.message)}};let Ae={};try{const J=JSON.parse(I);J&&typeof J=="object"&&!Array.isArray(J)&&(Ae=J)}catch{}const re=Ae.mcpServers??{},we=re&&typeof re=="object"&&!Array.isArray(re)?re:{},A=J=>{var G;const De=(G=ie.find(Oe=>Oe.name===J))==null?void 0:G.state;return De==="needs-auth"||De==="failed"||De==="error"?0:De==="starting"||De==="connecting"||De==="disconnected"?1:2},xe=[...new Set([...Object.keys(we),...ie.map(J=>J.name)])].sort((J,De)=>A(J)-A(De)||J.localeCompare(De)),_=(J,De)=>ge(G=>{const Oe={...G.mcpServers??{}};De===null?delete Oe[J]:Oe[J]=De,G.mcpServers=Oe}),Se=()=>{if(V)try{if(!/^[\w-]+$/.test(V.name)||!V.original&&Object.hasOwn(we,V.name))throw new Error(r("mcpNameConflict"));const J=JSON.parse(V.json);if(!J||typeof J!="object"||Array.isArray(J))throw new Error(r("mcpInvalidServer"));_(V.name,J),ve(void 0)}catch(J){N(J.message)}};return e.jsxs("section",{className:"native-mcp-panel mcp-workbench","data-dirty":ae||F||!!V||ye!==void 0,children:[e.jsxs("header",{className:"mcp-page-head",children:[e.jsx("h3",{children:r("nativeMcp")}),e.jsxs("div",{className:"settings-heading-actions",children:[e.jsx("button",{disabled:!o||F,onClick:()=>ce(!0),children:r("v2EditMcp")}),e.jsx("button",{disabled:F,onClick:()=>W("log",{},!0),children:r("extLog")})]})]}),s&&e.jsx(mi,{dialog:s,send:n}),R&&e.jsx("div",{className:"mcp-notice",children:e.jsx(Fo,{text:R})}),e.jsxs("h4",{className:"settings-group-title",children:[r("mcpServersTitle"),e.jsx("small",{children:r("v2ServersHint")})]}),e.jsxs("div",{className:"mcp-scope-row",children:[e.jsxs("span",{title:o==null?void 0:o.path,children:[r("mcpScope"),e.jsx("small",{className:"settings-description",children:r("v2ScopeHint")})]}),e.jsx("div",{className:"settings-segment",role:"group","aria-label":r("mcpScope"),children:["global","project"].map(J=>e.jsx("button",{disabled:F,"aria-pressed":i===J,onClick:()=>{(!ae&&!V&&ye===void 0||window.confirm(r("mcpDiscard")))&&a(J)},children:r(J==="global"?"mcpGlobal":"mcpProject")},J))})]}),i==="project"&&!(o!=null&&o.trusted)&&e.jsxs("p",{className:"mcp-warning",children:[r("mcpUntrusted")," ",e.jsx("button",{disabled:F,onClick:()=>W("trust"),children:r("mcpTrust")})]}),L&&e.jsx("p",{className:"mcp-warning",role:"status",children:r("mcpPending")}),$&&e.jsxs("p",{className:"mcp-error",role:"alert",children:[$," ",e.jsx("button",{disabled:F,onClick:()=>{(!ae||window.confirm(r("mcpDiscard")))&&W("get")},children:r("promptReloadFile")})]}),e.jsxs("div",{className:"mcp-section-head",children:[e.jsx("span",{children:xe.length?"":r("v2NoServersHint")}),e.jsx("button",{disabled:!o||F,onClick:()=>oe(""),children:r("mcpImport")}),e.jsxs("button",{disabled:!o||F,onClick:()=>ve({name:"",json:`{
|
|
261
|
-
"url": "https://example.com/mcp",
|
|
262
|
-
"exposure": "codemode"
|
|
263
|
-
}`}),children:["+ ",r("mcpNew")]})]}),ye!==void 0&&e.jsxs("div",{className:"mcp-editor",children:[e.jsx("h4",{children:r("mcpImport")}),e.jsx("p",{children:r("mcpImportHelp")}),e.jsx("textarea",{"aria-label":r("mcpImport"),rows:8,value:ye,onChange:J=>oe(J.target.value)}),e.jsx("button",{onClick:()=>{try{const J=Vm(ye,JSON.parse(I));E(JSON.stringify(J,null,2)),W("save",{version:o==null?void 0:o.version,document:J}),oe(void 0),N("")}catch(J){N(J.message)}},children:r("settingsImportSave")}),e.jsx("button",{onClick:()=>oe(void 0),children:r("cancel")})]}),V&&e.jsxs("div",{className:"mcp-editor",children:[e.jsxs("label",{children:[r("mcpName"),e.jsx("input",{disabled:!!V.original,value:V.name,onChange:J=>ve({...V,name:J.target.value})})]}),e.jsx("p",{children:r("mcpEditorHelp")}),e.jsx("textarea",{"aria-label":r("mcpConfig"),rows:10,value:V.json,onChange:J=>ve({...V,json:J.target.value}),spellCheck:!1}),e.jsx("button",{disabled:F,onClick:Se,children:r("save")}),e.jsx("button",{onClick:()=>ve(void 0),children:r("cancel")})]}),e.jsx("div",{className:"mcp-server-list",children:xe.map(J=>{const De=we[J],G=De&&typeof De=="object"?De:void 0,Oe=ie.find(Ce=>Ce.name===J),Ne=Re.filter(Ce=>Ce.name.startsWith(`mcp__${J.replace(/-/g,"_")}__`)),Ee=(Oe==null?void 0:Oe.state)??((G==null?void 0:G.enabled)===!1?"disabled":q?"unknown":"connecting"),et=Ee==="needs-auth"?"mcpNeedsAuth":Ee==="connected"?"mcpConnected":Ee==="connecting"||Ee==="starting"?"mcpConnecting":Ee==="disabled"?"mcpDisabled":Ee==="disconnected"?"mcpDisconnected":Ee==="unknown"?"mcpNotLoaded":"mcpFailed";return e.jsxs("article",{className:`mcp-server ${Ee}`,children:[e.jsxs("div",{className:"mcp-server-head",children:[e.jsxs("button",{className:"mcp-server-toggle","aria-expanded":_e===J,onClick:()=>M(_e===J?void 0:J),children:[e.jsx("span",{"aria-hidden":"true",children:_e===J?"⌄":"›"}),e.jsx("i",{className:"mcp-state-dot"}),e.jsx("strong",{children:J}),e.jsx("small",{children:G!=null&&G.url?"http":G!=null&&G.command?"stdio":r("mcpRuntime")})]}),e.jsxs("span",{className:"mcp-server-state",children:[r(et),Ee==="connected"&&` · ${(Oe==null?void 0:Oe.toolCount)??Ne.length}`]}),G&&e.jsx("select",{"aria-label":`${J} ${r("mcpExposure")}`,value:String(G.exposure??"codemode").replace("codemode-deferred","codemode"),disabled:F,onChange:Ce=>_(J,{...G,exposure:Ce.target.value}),children:Ya.map(Ce=>e.jsx("option",{children:Ce},Ce))})]}),_e===J&&e.jsxs("div",{className:"mcp-server-body",children:[e.jsx("p",{className:"mcp-endpoint",children:G!=null&&G.description?String(G.description):""}),e.jsx("code",{className:"mcp-endpoint",children:G!=null&&G.url?(()=>{try{const Ce=new URL(String(G.url));return Ce.username="",Ce.password="",Ce.search="",Ce.href}catch{return"HTTP"}})():String((G==null?void 0:G.command)??"")}),Ee==="needs-auth"&&e.jsxs("div",{className:"mcp-warning",children:[e.jsx("p",{children:r("mcpAuthHelp")}),e.jsx("button",{disabled:F,onClick:()=>W("command",{command:"login",name:J},!0),children:r("mcp_login")}),e.jsx("p",{children:r("mcpRemoteLogin")})]}),Oe&&Ee!=="connected"&&Ee!=="needs-auth"&&e.jsx("pre",{className:"mcp-diagnostic",children:Oe.detail}),e.jsxs("div",{className:"mcp-tool-table",children:[e.jsxs("div",{className:"mcp-tool-heading",children:[e.jsx("span",{children:r("mcpTools")}),e.jsx("span",{children:r("mcpAnnotations")}),e.jsx("span",{children:r("mcpActualExposure")})]}),Ne.map(Ce=>{var tt;const be=Ce.name.split("__").slice(2).join("__"),ze=zm(G??{},be);return e.jsxs("div",{children:[e.jsx("code",{title:Ce.description,children:be}),e.jsx("span",{children:Ce.destructive?r("mcpDestructive"):Ce.readOnly?r("mcpReadOnly"):"—"}),G?e.jsxs("span",{className:"mcp-exposure-control",children:[e.jsx("small",{children:Ce.exposure}),e.jsxs("select",{"aria-label":`${be} ${r("mcpActualExposure")}`,title:`${r("mcpActualExposure")}: ${Ce.exposure}`,value:((tt=G.toolExposure)==null?void 0:tt[be])??"inherit",disabled:F,onChange:Ye=>{const Le={...G.toolExposure??{}};Ye.target.value==="inherit"?delete Le[be]:Le[be]=Ye.target.value,_(J,{...G,toolExposure:Le})},children:[e.jsxs("option",{value:"inherit",children:[r("mcpInherit")," · ",ze.value]}),Ya.map(Ye=>e.jsxs("option",{value:Ye,children:[Ye," *"]},Ye))]})]}):e.jsx("code",{children:Ce.exposure})]},Ce.name)}),!Ne.length&&e.jsx("p",{children:r("mcpNoTools")})]}),e.jsxs("div",{className:"mcp-server-actions",children:[i==="project"&&!G&&e.jsx("button",{disabled:F,onClick:()=>_(J,{enabled:Ee==="disabled"}),children:r(Ee==="disabled"?"mcpEnableProject":"mcpDisableProject")}),["reconnect","login","logout"].map(Ce=>e.jsx("button",{disabled:F||!Oe||Ee==="disabled",onClick:()=>W("command",{command:Ce,name:J},!0),children:r(`mcp_${Ce}`)},Ce)),G&&e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:F,onClick:()=>_(J,{...G,enabled:G.enabled===!1}),children:r(G.enabled===!1?"mcpEnableServer":"mcpDisableServer")}),e.jsx("button",{disabled:F,onClick:()=>ve({original:J,name:J,json:JSON.stringify(G,null,2)}),children:r("mcpEdit")}),e.jsx("button",{disabled:F,onClick:()=>{window.confirm(r("mcpRemoveConfirm",{name:J}))&&_(J,null)},children:r("delete")})]})]})]})]},J)})}),ae&&!F&&e.jsxs("div",{className:"mcp-save-row",role:"status",children:[e.jsx("span",{children:r("mcpUnsaved")}),e.jsx("button",{onClick:Ie,children:r("settingsRetrySave")}),e.jsx("button",{onClick:()=>{window.confirm(r("mcpDiscard"))&&W("get")},children:r("promptReloadFile")})]}),e.jsxs("h4",{className:"settings-group-title",children:["Codemode",e.jsx("small",{children:r("v2CodemodeHint")})]}),e.jsxs("div",{className:"settings-group",children:[e.jsxs("div",{className:"mcp-setting-row",children:[e.jsxs("span",{title:r("mcpModeHelp"),children:[r("settingsToolPresentation"),e.jsx("small",{className:"settings-description",children:r("v2ModeHint")})]}),e.jsx("div",{className:"settings-segment",role:"group","aria-label":"codemode.mode",children:["on","only"].map(J=>e.jsx("button",{"aria-pressed":u===J,disabled:!l||F,onClick:()=>W("codemode",{version:l==null?void 0:l.version,codemode:{mode:J,inlineBudget:k}},!0),children:J},J))})]}),e.jsxs("div",{className:"mcp-setting-row",children:[e.jsxs("span",{title:r("mcpBudgetHelp"),children:[r("settingsDeclarationBudget"),e.jsx("small",{className:"settings-description",children:r("v2BudgetHint")})]}),e.jsx("div",{className:"settings-segment",role:"group","aria-label":"codemode.inlineBudget",children:[...new Set([0,3e3,8e3,k])].sort((J,De)=>J-De).map(J=>e.jsx("button",{"aria-pressed":k===J,disabled:!l||F,onClick:()=>W("codemode",{version:l==null?void 0:l.version,codemode:{mode:u,inlineBudget:J}},!0),children:J},J))})]}),e.jsxs("label",{className:"mcp-setting-row",children:[e.jsxs("span",{title:r("mcpAutoHelp"),children:[r("settingsAutoCodemode"),e.jsx("small",{className:"settings-description",children:r("v2AutoHint")})]}),e.jsx("input",{className:"settings-switch",type:"checkbox",role:"switch","aria-label":"autoEnableCodemode",disabled:!o||F,checked:typeof Ae.autoEnableCodemode=="boolean"?Ae.autoEnableCodemode:(o==null?void 0:o.inheritedAutoEnableCodemode)??!0,onChange:J=>ge(De=>{De.autoEnableCodemode=J.target.checked})})]})]}),e.jsx("footer",{className:"settings-paths",children:o!=null&&o.paths?e.jsxs(e.Fragment,{children:[e.jsxs("code",{children:[r("mcpGlobal")," · ",o.paths.global]}),e.jsxs("code",{children:[r("mcpProject")," · ",o.paths.project]})]}):e.jsx("code",{children:o==null?void 0:o.path})}),fe&&e.jsx("div",{className:"ext-dialog-backdrop",children:e.jsxs("div",{className:"ext-dialog mcp-json-dialog",role:"dialog","aria-modal":"true","aria-label":r("v2EditMcp"),onKeyDown:J=>{J.key==="Escape"&&J.stopPropagation()},children:[e.jsx("header",{children:e.jsx("h3",{children:r("v2EditMcp")})}),e.jsx("p",{children:r("mcpJsonHelp")}),e.jsx("code",{children:o==null?void 0:o.path}),e.jsx("textarea",{"aria-label":r("mcpConfig"),rows:15,value:I,disabled:F,onChange:J=>E(J.target.value),spellCheck:!1}),$&&e.jsx("p",{className:"mcp-error",role:"alert",children:$}),e.jsxs("footer",{children:[e.jsx("button",{disabled:F,onClick:()=>{(!ae||window.confirm(r("mcpDiscard")))&&(E(JSON.stringify(o==null?void 0:o.document,null,2)),ce(!1))},children:r("close")}),e.jsx("button",{disabled:F||!ae,onClick:Ie,children:r("save")})]})]})}),Fe!==void 0&&e.jsxs("details",{className:"mcp-advanced",open:!0,children:[e.jsx("summary",{children:"mcp.log"}),e.jsx("pre",{children:Fe}),e.jsx("button",{onClick:()=>U(void 0),children:r("close")})]})]})}function Gm({cwd:t,reload:n}){const s=nt(),[r,i]=d.useState(),[a,o]=d.useState(""),[c,l]=d.useState("all"),[p,u]=d.useState(!1),[f,k]=d.useState(!1),[j,I]=d.useState(""),E=d.useRef(!0);async function $(b,F={}){u(!0),I("");try{const B=await fetch(Sn("/api/extensions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:fn(),cwd:t,action:b,...F})}),ie=await B.json();if(!B.ok)throw Error(ie.error??B.statusText);E.current&&(i(ie),b==="skills-toggle"&&k(!0))}catch(B){E.current&&I(B.message)}finally{E.current&&u(!1)}}d.useEffect(()=>(E.current=!0,$("skills-list"),()=>{E.current=!1}),[t]);const N=(r==null?void 0:r.skills)??[],R=N.filter(b=>(c==="all"||b.source===c)&&`${b.name} ${b.description}`.toLowerCase().includes(a.toLowerCase())),y=N.filter(b=>b.enabled),L=Math.ceil(y.filter(b=>b.promptVisible).reduce((b,F)=>b+F.name.length+F.description.length,0)/4);return e.jsxs("section",{className:"settings-skills",children:[e.jsxs("header",{className:"settings-page-heading",children:[e.jsx("h2",{className:"settings-page-title",children:s("settingsSkills")}),e.jsx("span",{className:"settings-count",children:s("v2SkillCount",{n:N.length,enabled:y.length,tokens:L})}),e.jsx("button",{disabled:!r,onClick:()=>void(xt!=null&&xt.openExtensionPath?xt.openExtensionPath({clientId:fn(),cwd:t,id:"skills:user"}):navigator.clipboard.writeText((r==null?void 0:r.paths.join(`
|
|
264
|
-
`))??"")).catch(b=>I(b.message)),children:s(xt!=null&&xt.openExtensionPath?"v2OpenSkills":"v2CopyPaths")})]}),e.jsx("p",{className:"settings-intro",children:s("v2SkillsIntro")}),j&&e.jsxs("p",{className:"settings-error",role:"alert",children:[j," ",e.jsx("button",{disabled:p,onClick:()=>void $("skills-list"),children:s("extRefresh")})]}),f&&e.jsxs("p",{className:"ext-notice",role:"status",children:[s("v2SkillsChanged")," ",e.jsx("button",{disabled:p,onClick:()=>{n(),k(!1)},children:s("extReload")})]}),e.jsxs("div",{className:"skills-filters",children:[e.jsx("input",{type:"search",value:a,onChange:b=>o(b.target.value),placeholder:s("v2SkillSearch"),"aria-label":s("v2SkillSearch")}),e.jsx("div",{className:"settings-segment",role:"group","aria-label":s("extScope"),children:["all","user","project","package"].map(b=>e.jsx("button",{"aria-pressed":c===b,onClick:()=>l(b),children:s(b==="all"?"v2SkillAll":b==="user"?"extPersonal":b==="project"?"extProject":"v2SkillPackage")},b))})]}),e.jsxs("div",{className:"settings-group",children:[R.map(b=>e.jsxs("label",{className:`settings-skill-row${b.enabled?"":" disabled"}`,children:[e.jsxs("span",{className:"settings-skill-info",children:[e.jsx("code",{children:b.name}),e.jsx("small",{title:b.description,children:b.description})]}),e.jsx("span",{className:"settings-readonly",title:b.path,children:s(b.source==="package"?"v2SkillPackage":b.scope==="project"?"extProject":"extPersonal")}),e.jsx("input",{type:"checkbox",role:"switch",className:"settings-switch","aria-label":`${s("extEnable")} ${b.name}`,checked:b.enabled,disabled:p||!b.canToggle,onChange:F=>void $("skills-toggle",{id:b.id,enabled:F.target.checked,version:r==null?void 0:r.version})})]},b.id)),!R.length&&e.jsx("p",{className:"settings-empty",children:s(r?"extNoResults":"loading")})]}),e.jsxs("footer",{className:"settings-paths",children:[s("v2SkillsPaths"),r==null?void 0:r.paths.map(b=>e.jsx("code",{children:b},b))]})]})}function Jm({chat:t,send:n,onClose:s}){var j,I,E,$,N,R,y;const r=nt(),[i,a]=d.useState(0),o=()=>!document.querySelector('.ext-editor[data-dirty="true"], .prompt-editor[data-dirty="true"], .mcp-workbench[data-dirty="true"]')||window.confirm(r("extDiscard")),c=()=>{o()&&s()};d.useEffect(()=>{const L=b=>{b.key==="Escape"&&!b.defaultPrevented&&c()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[s]);const[l,p]=d.useState("prompt"),u=t.settings;d.useEffect(()=>{l==="updates"&&t.ready&&n({type:"check_component_updates",requestId:Qt()})},[l,t.ready,(j=t.state)==null?void 0:j.cwd,n]);const f=[{id:"prompt",label:r("settingsSystemPrompt"),icon:e.jsx(_s,{})},{id:"skills",label:r("settingsSkills"),icon:e.jsx(wi,{})},{id:"extensions",label:r("settingsExtensions"),icon:e.jsx(zc,{})},{id:"native-mcp",label:r("nativeMcp"),icon:e.jsx(rd,{})},{id:"updates",label:r("componentUpdates"),icon:e.jsx(Is,{})}],k=((I=t.componentUpdates)==null?void 0:I.cwd)===((E=t.state)==null?void 0:E.cwd)?t.componentUpdates:null;return e.jsx("div",{className:"modal-backdrop",onClick:c,children:e.jsxs("div",{className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-label":r("settingsTitle"),onClick:L=>L.stopPropagation(),children:[e.jsx("div",{className:"modal-head",children:e.jsx("button",{className:"icon-btn","aria-label":r("close"),onClick:c,children:e.jsx(qt,{})})}),e.jsxs("div",{className:"settings-layout",children:[e.jsxs("nav",{className:"settings-rail","aria-label":r("settingsTitle"),children:[e.jsx("h2",{children:r("settingsTitle")}),f.map(L=>e.jsxs("button",{title:L.label,className:`settings-tab${l===L.id?" active":""}`,onClick:()=>{o()&&p(L.id)},children:[e.jsx("span",{className:"settings-tab-icon",children:L.icon}),e.jsxs("span",{className:"settings-tab-label",children:[L.label,L.id==="updates"&&i>0&&e.jsx("span",{className:"ext-rail-badge",children:i})]})]},L.id))]}),e.jsx("div",{className:"modal-body",children:e.jsx("div",{className:"set-section",children:u?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"tree-edit-preference",children:[e.jsx("input",{type:"checkbox",checked:u.editResendNewSession??!1,onChange:L=>n({type:"set_settings",editResendNewSession:L.target.checked})}),r("treeEditNewSession")]}),(($=t.state)==null?void 0:$.planSettings)&&e.jsxs("div",{className:"plan-settings",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:t.state.planSettings.enabled,disabled:!t.ready,onChange:L=>n({type:"set_plan_enabled",conversationId:t.state.conversationId,enabled:L.target.checked})}),r("planEnabled")]}),e.jsx("p",{children:r("planEnabledHint")}),t.state.planSettings.available?t.state.planSettings.pending?e.jsx("p",{children:r("planPending")}):null:e.jsx("p",{children:r(t.state.planSettings.reason==="conflict"?"planConflict":"planMissing")})]}),l==="prompt"&&t.state&&e.jsx(qm,{cwd:t.state.cwd,conversationId:t.state.conversationId},`${t.state.cwd}:${t.state.conversationId}`),l==="skills"&&t.state&&e.jsx(Gm,{cwd:t.state.cwd,reload:()=>n({type:"extensions_reload"})},t.state.cwd),l==="extensions"&&((N=t.state)==null?void 0:N.cwd)&&e.jsx(Dl,{cwd:t.state.cwd,onUpdateCount:a,reload:()=>n({type:"extensions_reload"})},t.state.cwd),l==="native-mcp"&&((R=t.state)==null?void 0:R.cwd)&&e.jsx(Km,{cwd:t.state.cwd,send:n,dialog:t.dialog},`${t.state.cwd}:${t.state.conversationId}`),l==="updates"&&e.jsx(Wm,{cwd:((y=t.state)==null?void 0:y.cwd)??"",updates:k,onUpdateCount:a,reload:()=>n({type:"extensions_reload"})})]}):e.jsx("p",{children:r("loading")})})})]})]})})}function Qm(t,n){const s=Math.max(0,Date.now()-t),r=Math.floor(s/6e4);if(r<1)return n("bgTaskJustNow");if(r<60)return n("bgTaskMinutes",{n:r});const i=Math.floor(r/60);return i<24?n("bgTaskHours",{n:i}):n("bgTaskDays",{n:Math.floor(i/24)})}function Ym({servers:t,send:n,onClose:s}){const r=nt(),[i,a]=d.useState(new Set),o=c=>a(l=>{const p=new Set(l);return p.has(c)?p.delete(c):p.add(c),p});return d.useEffect(()=>{n({type:"list_bg_servers"})},[]),e.jsx("div",{className:"modal-backdrop",onClick:s,children:e.jsxs("div",{className:"bg-task-modal",onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{className:"bg-task-head",children:[e.jsxs("span",{className:"bg-task-title",children:[e.jsx(ys,{})," ",r("bgTasks"),t.length>0&&e.jsx("em",{className:"bg-task-count",children:t.length})]}),e.jsx("button",{type:"button",className:"btn",title:r("close"),onClick:s,children:e.jsx(qt,{})})]}),t.length===0?e.jsxs("div",{className:"bg-task-empty",children:[e.jsx(ys,{}),e.jsx("span",{children:r("bgTasksEmpty")}),e.jsx("small",{children:r("bgTasksDesc")})]}):e.jsx("ul",{className:"bg-task-list",children:t.map(c=>{const l=!!c.taskId,p=c.taskId??String(c.port);return e.jsxs("li",{className:"bg-task-item",children:[e.jsx("span",{className:"bg-task-icon",title:l?c.plugin:r("bgTaskPort")}),e.jsxs("div",{className:"bg-task-info",children:[e.jsxs("div",{className:"bg-task-line1",children:[l?e.jsxs("span",{className:"bg-task-port",title:c.taskId,children:["🧩 ",c.plugin]}):e.jsxs("span",{className:"bg-task-port",children:[":",c.port]}),c.name&&e.jsx("span",{className:"bg-task-name",children:c.name})]}),e.jsxs("div",{className:"bg-task-line2",children:[!l&&e.jsxs("span",{children:[r("bgTaskPid")," ",c.pid]}),e.jsxs("span",{children:[r("bgTaskSince")," ",Qm(c.since,r)]}),l&&c.status&&e.jsx("span",{className:"bg-task-status",children:c.status})]}),c.command&&e.jsxs("button",{type:"button",className:`bg-task-cmd ${i.has(p)?"open":""}`,title:`${r("bgTaskCommand")}: ${c.command}`,onClick:()=>o(p),children:[e.jsx(ki,{}),e.jsx("code",{children:c.command})]})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stop",title:r("bgTaskStop"),onClick:()=>n(l?{type:"kill_background_server",taskId:c.taskId}:{type:"kill_background_server",port:c.port}),children:[e.jsx(ls,{}),e.jsx("span",{children:r("bgTaskStop")})]})]},p)})}),e.jsxs("div",{className:"bg-task-foot",children:[e.jsxs("button",{type:"button",className:"btn",title:r("bgTaskRefresh"),onClick:()=>n({type:"list_bg_servers"}),children:[e.jsx(Is,{}),e.jsx("span",{children:r("bgTaskRefresh")})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:t.length===0,title:r("bgTaskStopAll"),onClick:()=>n({type:"kill_background_servers"}),children:[e.jsx(ls,{}),e.jsx("span",{children:r("bgTaskStopAll")})]})]})]})})}function rr(t,n){return t.toLowerCase().includes(n)}function Xm({send:t,sessions:n,projects:s,cwd:r,fileSearch:i,onClose:a,onSwitchSession:o,onSwitchProject:c,onPreviewFile:l}){const p=nt(),u=d.useRef(null),[f,k]=d.useState(""),j=d.useDeferredValue(f),[I,E]=d.useState(0),$=d.useRef(1),N=d.useRef(0),R=d.useRef(null);d.useEffect(()=>{t({type:"list_sessions"}),t({type:"list_projects"}),requestAnimationFrame(()=>{var M;return(M=u.current)==null?void 0:M.focus()})},[]);const[y,L]=d.useState(!1);d.useEffect(()=>{R.current&&clearTimeout(R.current);const M=j.trim();if(M)return R.current=setTimeout(()=>{const V=++$.current;N.current=V,L(!0),t({type:"search_files",reqId:V,query:M})},300),()=>{R.current&&clearTimeout(R.current)}},[j]);const b=j.trim().toLowerCase(),F=d.useMemo(()=>b?n.filter(M=>rr(M.firstMessage??"",b)||rr(M.name??"",b)||rr(M.path.split(/[\\/]/).pop()??"",b)).slice(0,20):[],[n,b]),B=d.useMemo(()=>b?s.filter(M=>rr(M.path,b)).slice(0,10):[],[s,b]),ie=d.useMemo(()=>!b||!i||i.reqId!==N.current||!i.ok?[]:i.results,[i,b]);d.useEffect(()=>{i&&i.reqId===N.current&&N.current!==0&&L(!1)},[i]);const Q=!!i&&i.ok&&i.truncated,q=d.useMemo(()=>[...F.map(M=>({kind:"session",path:M.path})),...B.map(M=>({kind:"project",path:M.path})),...ie.filter(M=>M.type==="file").map(M=>({kind:"file",path:M.path,name:M.name}))],[F,B,ie]);d.useEffect(()=>{E(0)},[j]);const ke=d.useCallback(M=>{M&&(M.kind==="session"?o(M.path):M.kind==="project"?c(M.path):l(M.path,M.name),a())},[o,c,l,a]);d.useEffect(()=>{const M=V=>{V.key==="Escape"?(V.preventDefault(),V.stopPropagation(),a()):V.key==="ArrowDown"?(V.preventDefault(),E(ve=>Math.min(ve+1,q.length-1))):V.key==="ArrowUp"?(V.preventDefault(),E(ve=>Math.max(ve-1,0))):V.key==="Enter"&&(V.preventDefault(),ke(q[I]))};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[q,I,ke,a]);const Re=F.length+B.length+ie.length,O=(M,V,ve)=>e.jsxs("div",{className:"gs-section-head",children:[ve,e.jsx("span",{children:M}),e.jsx("em",{children:V})]});let _e=-1;return e.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:a,children:e.jsxs("div",{className:"gs-modal",onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{className:"gs-input-row",children:[e.jsx(ts,{}),e.jsx("input",{ref:u,type:"text",value:f,placeholder:p("gsPlaceholder"),onChange:M=>k(M.target.value)}),e.jsx("button",{type:"button",className:"gs-close",title:p("close"),onClick:a,children:e.jsx(qt,{})})]}),e.jsxs("div",{className:"gs-results",children:[!b&&e.jsx("div",{className:"gs-empty",children:p("gsHint")}),b&&Re===0&&!Q&&e.jsx("div",{className:"gs-empty",children:p(y?"gsSearching":"gsNoResults")}),F.length>0&&e.jsxs("div",{className:"gs-section",children:[O(p("gsSessions"),F.length,e.jsx(vo,{})),F.map(M=>{_e++;const V=_e;return e.jsxs("button",{type:"button",className:V===I?"gs-item active":"gs-item",onMouseEnter:()=>E(V),onClick:()=>ke({kind:"session",path:M.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[M.name||M.path.split(/[\\/]/).pop(),e.jsx("em",{className:"gs-item-meta",children:M.messageCount})]}),e.jsx("span",{className:"gs-item-sub",children:cs(M.firstMessage)})]},M.path)})]}),B.length>0&&e.jsxs("div",{className:"gs-section",children:[O(p("gsProjects"),B.length,e.jsx(Us,{})),B.map(M=>{_e++;const V=_e,ve=r&&M.path===r;return e.jsxs("button",{type:"button",className:V===I?"gs-item active":"gs-item",onMouseEnter:()=>E(V),onClick:()=>ke({kind:"project",path:M.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[M.path.split(/[\\/]/).pop(),ve&&e.jsx("em",{className:"gs-item-meta",children:p("gsCurrentProject")})]}),e.jsx("span",{className:"gs-item-sub",children:M.path})]},M.path)})]}),(ie.length>0||b&&Q)&&e.jsxs("div",{className:"gs-section",children:[O(p("gsFiles"),ie.length,e.jsx(Zc,{})),ie.map(M=>{_e++;const V=_e;return e.jsxs("button",{type:"button",className:V===I?"gs-item active":"gs-item",disabled:M.type==="dir",title:M.type==="dir"?void 0:p("gsOpenPreview"),onMouseEnter:()=>E(V),onClick:()=>{M.type==="file"&&ke({kind:"file",path:M.path,name:M.name})},children:[e.jsx("span",{className:"gs-item-title",children:M.name}),e.jsx("span",{className:"gs-item-sub",children:M.path})]},`${M.type}:${M.path}`)}),Q&&e.jsx("div",{className:"gs-truncated",children:p("gsTruncated")})]})]}),e.jsxs("div",{className:"gs-foot",children:[e.jsxs("span",{children:["↑↓ ",p("gsNavigate")]}),e.jsxs("span",{children:["Enter ",p("gsOpen")]}),e.jsxs("span",{children:["Esc ",p("gsCloseHint")]})]})]})})}const Zm=d.memo(function({file:n,disabled:s}){const r=nt(),[i,a]=d.useState({offset:0}),[o,c]=d.useState(0),[l,p]=d.useState(null),[u,f]=d.useState(!1),[k,j]=d.useState("");d.useEffect(()=>{if(s){f(!1);return}const E=new AbortController,$=Qt();f(!0),j(""),p(null);const N=new URLSearchParams({clientId:fn(),cwd:n.cwd,path:n.path,requestId:$,offset:String(i.offset)});return i.table!==void 0&&N.set("table",i.table),(async()=>{try{const R=await fetch(Sn("/api/sqlite?"+N),{signal:E.signal}),y=await R.json();if(E.signal.aborted)return;if(!R.ok||y.error)throw new Error(y.error||r("dbLoadFailed"));if(y.requestId!==$||y.cwd!==n.cwd||y.path!==n.path||!y.data)throw new Error(r("dbLoadFailed"));p(y.data)}catch(R){E.signal.aborted||j(R.message)}finally{E.signal.aborted||f(!1)}})(),()=>E.abort()},[n.cwd,n.path,i.table,i.offset,o,s,r]);const I=u||s;return e.jsxs("section",{className:"sqlite-preview","aria-label":r("dbViewer"),children:[e.jsxs("div",{className:"sqlite-toolbar",children:[e.jsxs("span",{className:"sqlite-label",children:["SQLite · ",r("dbReadOnly")]}),e.jsx("button",{type:"button",className:"btn",disabled:I,onClick:()=>{a({offset:0}),c(E=>E+1)},children:r("dbRefresh")})]}),s&&e.jsx("div",{className:"fp-notice",children:r("dbUnavailable")}),u&&e.jsx("div",{className:"fp-empty",role:"status",children:r("loading")}),k&&e.jsxs("div",{className:"fp-notice",role:"alert",children:[r("dbLoadFailed")," ",k]}),l&&e.jsxs(e.Fragment,{children:[l.tables.length?e.jsxs("label",{className:"sqlite-table-picker",children:[e.jsx("span",{children:r("dbTable")}),e.jsx("select",{"aria-label":r("dbTable"),disabled:I,value:l.table??"",onChange:E=>a({table:E.target.value,offset:0}),children:l.tables.map(E=>e.jsxs("option",{value:E.name,children:[E.name,E.type==="view"?" · "+r("dbView"):""]},E.name))})]}):e.jsx("div",{className:"fp-empty",children:r("dbNoTables")}),(l.columnsTruncated||l.tablesTruncated)&&e.jsx("div",{className:"fp-notice",children:r("dbStructureLimited")}),l.queryError&&e.jsxs("div",{className:"fp-notice",role:"alert",children:[r("dbLoadFailed")," ",l.queryError]}),l.table!==null&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sqlite-grid-wrap",tabIndex:0,"aria-label":r("dbRows"),children:[e.jsxs("table",{className:"sqlite-grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"#"}),l.columns.map(E=>e.jsxs("th",{scope:"col",children:[e.jsxs("span",{children:[E.name,E.primaryKey?" 🔑":""]}),e.jsx("small",{children:E.type||"—"})]},E.name))]})}),e.jsx("tbody",{children:l.rows.map((E,$)=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:l.offset+$+1}),E.map((N,R)=>e.jsx("td",{className:N.kind==="null"||N.kind==="blob"?"sqlite-special":"",children:e.jsxs("span",{title:N.kind==="text"?N.value:void 0,children:[N.kind==="null"?"NULL":N.kind==="blob"?`BLOB · ${N.value} B`:N.value,N.truncated?"…":""]})},R))]},l.offset+$))})]}),!l.rows.length&&e.jsx("div",{className:"fp-empty",children:r("dbNoRows")})]}),e.jsxs("div",{className:"sqlite-pagination",children:[e.jsx("button",{className:"btn",disabled:I||l.offset===0,onClick:()=>a({table:l.table,offset:Math.max(0,l.offset-l.pageSize)}),children:r("dbPrevious")}),e.jsx("span",{children:r("dbRowRange",{start:l.rows.length?l.offset+1:0,end:l.offset+l.rows.length})}),e.jsx("button",{className:"btn",disabled:I||!l.hasMore,onClick:()=>a({table:l.table,offset:l.offset+l.pageSize}),children:r("dbNext")})]}),e.jsx("div",{className:"sqlite-hint",children:r("dbCellLimit")}),e.jsxs("details",{className:"sqlite-schema",children:[e.jsx("summary",{children:r("dbSchema")}),e.jsx("pre",{children:l.schema})]})]})]})]})}),ef="pi-harness:code-theme",Xa="pi-harness:code-theme";function Za(){try{const t=localStorage.getItem(ef);return t==="dark"||t==="system"?t:"light"}catch{return"light"}}function tf(t){const n=new Map;let s=0,r=!1,i=0;const a=()=>{i&&s>0&&!n.has(s)&&n.set(s,"deleted"),i=0};for(const o of t.split(`
|
|
265
|
-
`)){const c=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(o);if(c){a(),s=Number(c[1]),r=!0;continue}if(o.startsWith("diff --git ")||o.startsWith("--- ")||o.startsWith("+++ ")){a(),r=!1;continue}if(r){if(o.startsWith("-")){i++;continue}if(o.startsWith("+")){n.set(s,i>0?"changed":"added"),i>0&&i--,s++;continue}a(),o.startsWith(" ")&&s++}}return a(),n}const Gr=5e3;let Jr=-5e3;const nf=d.memo(function({result:n,guard:s,disabled:r,connected:i,contextReader:a,contextSaver:o,onContextChange:c,file:l,content:p,send:u,onAddLines:f,onAttach:k,onClose:j,fileChanged:I,scmData:E,scmDirty:$}){const N=nt(),[R,y]=d.useState(null),L=d.useRef(null),[b,F]=d.useState(!1),[B,ie]=d.useState(null),[Q,q]=d.useState(!1),[ke,Re]=d.useState(!1),[O,_e]=d.useState(!0),[M,V]=d.useState(""),ve=d.useRef(""),ye=te=>{ve.current=te,V(te)},oe=d.useRef(Qt()),[Fe,U]=d.useState(!0),[fe,ce]=d.useState(null),[ae,z]=d.useState(!1),[Z,W]=d.useState(""),[ge,Ie]=d.useState(!1),[Ae,re]=d.useState(!1),[we,A]=d.useState(!1),[xe,_]=d.useState(null),[Se,J]=d.useState(()=>new Date),[De,G]=d.useState(null),[Oe,Ne]=d.useState(!1),[Ee,et]=d.useState(Za);d.useEffect(()=>{const te=()=>et(Za());return window.addEventListener(Xa,te),()=>window.removeEventListener(Xa,te)},[]);const[Ce,be]=d.useState(100),ze=d.useRef(0),tt=d.useRef(!1),Ye=d.useRef(null),Le=d.useRef(""),Xe=d.useRef(""),vt=d.useRef(0),se=d.useRef(0),Ue=d.useRef(null),[w,H]=d.useState("saved"),[X,me]=d.useState(""),[$e,Pe]=d.useState(!1),[st,lt]=d.useState(null),g=R!==null&&M!==R.text,ne=()=>{r||(Le.current=Qt(),F(!0),me(""),u({type:"read_file",path:l.path,cwd:l.cwd,requestId:Le.current})||(F(!1),me(N("fileOffline"))))};d.useEffect(()=>{ne()},[l.path,l.cwd]),d.useEffect(()=>{(p==null?void 0:p.requestId)!==Le.current||(p==null?void 0:p.cwd)!==l.cwd||(p==null?void 0:p.path)!==l.path||(Le.current="",L.current=p,y(p),ie(null),ye(p.text),_e(p.kind==="text"&&!p.binary&&!p.truncated),U(!0),F(!1),Pe(!1),H("saved"),J(new Date),A(!1),_(null),ce(null))},[p,l.path,l.cwd]),d.useEffect(()=>{!p||p.requestId!==Xe.current||p.path!==l.path||p.cwd!==l.cwd||(Xe.current="",R&&p.version!==R.version&&(g?(_(p.text),A(!0)):(L.current=p,y(p),ye(p.text))))},[p,R,g,l.path,l.cwd]),d.useEffect(()=>{!I||!R||Ue.current||r||(Xe.current=Qt(),u({type:"read_file",path:l.path,cwd:l.cwd,requestId:Xe.current}))},[I,l.path,l.cwd,R,g,r,u]),d.useEffect(()=>{r||!i||(vt.current=--Jr,u({type:"scm_status",reqId:vt.current}))},[l.path,l.cwd,$,I,r,i,u]),d.useEffect(()=>{var te;if((E==null?void 0:E.cwd)===l.cwd)if(E.kind==="status"&&E.reqId===vt.current){const Je=!!E.ok&&!!((te=E.files)!=null&&te.some(qe=>qe.path.replaceAll("\\","/")===l.path));z(Je),Je||(W(""),Ie(!1))}else E.kind==="filediff"&&E.reqId===se.current&&(re(!1),Ie(!!E.ok&&!!E.untracked&&E.untrackedKind==="text"),W(E.ok?[E.stagedText,E.worktreeText,E.untrackedText].filter(Boolean).join(`
|
|
266
|
-
`):E.error??""))},[E,l.cwd,l.path]),d.useEffect(()=>{!ae||r||!i||!R||R.kind!=="text"||(se.current=--Jr,u({type:"scm_filediff",reqId:se.current,path:l.path}))},[ae,$,I,R==null?void 0:R.version,r,i,l.path,u]);const We=d.useMemo(()=>ge?new Map(((R==null?void 0:R.text.split(`
|
|
267
|
-
`))??[]).map((te,Je)=>[Je+1,"added"])):tf(Z),[Z,ge,R==null?void 0:R.text]);d.useEffect(()=>{var Je,qe;if(!n||n.cwd!==l.cwd||n.path!==l.path||(n.operation==="read"&&n.requestId===Le.current&&(Le.current="",F(!1),me(n.error??N("fileSaveFailed"))),n.operation!=="write"||n.requestId!==((Je=Ue.current)==null?void 0:Je.id)))return;const te=Ue.current;if(te)if(Ue.current=null,n.ok){const yt=L.current;if(yt){const Kt={...yt,text:te.text,version:n.version,size:new TextEncoder().encode(te.text).length,lines:te.text?te.text.split(`
|
|
268
|
-
`).length-(te.text.endsWith(`
|
|
269
|
-
`)?1:0):0};L.current=Kt,y(Kt)}H("saved"),J(new Date),ie(null),Pe(!1),me(""),(qe=te.next)==null||qe.call(te)}else H("failed"),Pe(!!n.conflict),me(n.error??N("fileSaveFailed"))},[n,l.cwd,l.path,N]),d.useEffect(()=>{if(!b)return;const te=()=>{Le.current="",F(!1),me(N("fileOffline"))};if(!i){te();return}const Je=setTimeout(te,15e3);return()=>clearTimeout(Je)},[b,i,N]),d.useEffect(()=>{if(w!=="saving")return;const te=()=>{Ue.current=null,H("failed"),me(N("fileOffline"))};if(!i){te();return}const Je=setTimeout(te,15e3);return()=>clearTimeout(Je)},[w,i,N]),d.useLayoutEffect(()=>(s.current=te=>{Ue.current||(g?lt({action:te}):te())},()=>{s.current=null}),[g,s]),d.useEffect(()=>{if(!g)return;const te=Je=>{Je.preventDefault(),Je.returnValue=""};return window.addEventListener("beforeunload",te),()=>window.removeEventListener("beforeunload",te)},[g]);const He=!!R&&R.kind==="text"&&!R.binary&&!R.truncated&&!b&&!r;d.useLayoutEffect(()=>{if(a)return a.current=te=>{var Je,qe;return He&&R&&te===oe.current?{path:l.path,mode:"inline",editorSnapshot:{cwd:l.cwd,text:ve.current,dirty:ve.current!==((Je=L.current)==null?void 0:Je.text),version:(qe=L.current)==null?void 0:qe.version}}:null},()=>{a.current=null}},[a,He,R,l.path,l.cwd]),d.useLayoutEffect(()=>{c==null||c(He?{...l,id:oe.current,dirty:g}:null)},[He,g,l,c]),d.useLayoutEffect(()=>()=>c==null?void 0:c(null),[c]),d.useLayoutEffect(()=>{if(o)return o.current=(te,Je)=>{const qe=L.current;return!He||!qe||te!==oe.current?!1:ve.current===qe.text?(Je(),!0):b||r||Ue.current?!1:(zt(!1,Je),!0)},()=>{o.current=null}},[o,He,b,r,M,l.path,l.cwd]),d.useEffect(()=>{const te=()=>{tt.current=!1,q(!1)};return window.addEventListener("mouseup",te),()=>{window.removeEventListener("mouseup",te),Ye.current&&clearTimeout(Ye.current)}},[]);const ct=d.useMemo(()=>{if(!R)return[];const te=R.text.split(`
|
|
270
|
-
`);return te.length>0&&te[te.length-1]===""&&te.pop(),te.slice(0,Gr)},[R]),ft=d.useMemo(()=>{const te=Ps(l.name);return!te||ct.length===0?null:rl(ct.join(`
|
|
271
|
-
`),te)},[ct,l.name]),Dt=((R==null?void 0:R.lines)??0)>Gr,$t=(te,Je)=>{if(Je){const qe=ze.current>0?ze.current:te;ie({start:Math.min(qe,te),end:Math.max(qe,te)})}else ze.current=te,ie({start:te,end:te})},Ft=()=>{B&&(f(l.path,l.name,B.start,B.end),Re(!0),Ye.current&&clearTimeout(Ye.current),Ye.current=setTimeout(()=>Re(!1),1400))},Yt=()=>{!ae||r||(ce("git"),re(!0),se.current=--Jr,u({type:"scm_filediff",reqId:se.current,path:l.path})||re(!1))},Ut=(te,Je)=>{if(!(te instanceof Element)||!te.closest(".fp-markdown"))return;const qe=window.getSelection();if(!qe||qe.isCollapsed||!qe.anchorNode||!Je.contains(qe.anchorNode))return;const yt=ht=>{const Et=ht instanceof Element?ht:ht==null?void 0:ht.parentElement,Ht=Et==null?void 0:Et.closest("[data-source-start]"),Bt=Number(Ht==null?void 0:Ht.dataset.sourceStart),St=Number(Ht==null?void 0:Ht.dataset.sourceEnd);return Bt>0&&St>=Bt?{start:Bt,end:St}:null},Kt=yt(qe.anchorNode),an=yt(qe.focusNode),Zt=Kt&&an?{start:Math.min(Kt.start,an.start),end:Math.max(Kt.end,an.end)}:rf(M,qe.toString());if(!Zt)return;ie(Zt);const Ct=qe.getRangeAt(0).getBoundingClientRect(),cn=Je.getBoundingClientRect();G({x:Math.max(12,Math.min(cn.width-260,Ct.left-cn.left)),y:Math.max(54,Math.min(cn.height-42,Ct.bottom-cn.top+8))})},it=R!==null&&R.kind==="text"&&!R.binary&&!R.truncated,Rt=()=>{it&&(_e(te=>!te),ie(null))},zt=(te=!1,Je)=>{if(!R||!it||b||r||Ue.current)return;const qe=Qt();Ue.current={id:qe,text:M,next:Je},H("saving"),me(""),u({type:"write_file",path:l.path,cwd:l.cwd,text:M,requestId:qe,expectedVersion:R.version,force:te})||(Ue.current=null,H("failed"),me(N("fileOffline")))},Ot=()=>{var te;return(te=s.current)==null?void 0:te.call(s,j)},Vt=te=>{be(Math.min(200,Math.max(50,te)))};B&&B.end-B.start+1;const jt=(R==null?void 0:R.binary)??!1,Xt=(R==null?void 0:R.truncated)??!1,K=(R==null?void 0:R.kind)??"text",ee=sf(l.name),Ke=ee&&Fe&&K==="text"&&!jt,Be=te=>Sn(`/api/file?clientId=${encodeURIComponent(fn())}&path=${encodeURIComponent(te)}`);return e.jsx("div",{className:"fp-embedded","data-code-theme":Ee,onKeyDown:te=>{!te.nativeEvent.isComposing&&(te.metaKey||te.ctrlKey)&&te.key.toLowerCase()==="s"&&(te.preventDefault(),te.stopPropagation(),zt())},children:e.jsxs("div",{className:`fp ${fe?"show-diff":""}`,style:{"--fp-zoom":Ce/100},onMouseUp:te=>Ut(te.target,te.currentTarget),children:[e.jsxs("div",{className:"fp-title-row",children:[e.jsx("button",{className:"fp-back","aria-label":N("backToFiles"),title:N("backToFiles"),onClick:Ot,disabled:w==="saving",children:"←"}),e.jsxs("span",{className:"fp-file-path",title:`${l.cwd}/${l.path}`,children:[e.jsx("span",{className:"fp-project-name",children:l.cwd.split(/[\\/]/).filter(Boolean).at(-1)}),e.jsx("span",{className:"fp-path-separator",children:" / "}),l.path.split(/[\\/]/).join(" / ")]}),e.jsxs("span",{className:"fp-header-status",role:"status",children:[w==="saving"?N("fileSaving"):w==="failed"?N("fileSaveFailed"):g?N("fileUnsaved"):R?N("fileSaved"):"",R&&!g&&w==="saved"&&e.jsxs("time",{children:[" · ",Se.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})]})]}),e.jsxs("div",{className:"fp-header-actions",children:[ee&&K==="text"&&e.jsxs("div",{className:"fp-view-switch",role:"group","aria-label":N("fileViewMode"),children:[e.jsx("button",{type:"button","aria-pressed":!fe&&Fe,onClick:()=>{ce(null),U(!0),_e(!0),ie(null)},children:N("fileViewPreview")}),e.jsx("button",{type:"button","aria-pressed":!fe&&!Fe,disabled:!it,onClick:()=>{ce(null),U(!1),_e(!0),ie(null)},children:N("fileViewSource")})]}),!ee&&it&&e.jsxs("div",{className:"fp-view-switch",role:"group","aria-label":N("fileEditMode"),children:[e.jsx("button",{type:"button","aria-pressed":!O,onClick:()=>{ce(null),_e(!1)},children:N("fileReadOnly")}),e.jsx("button",{type:"button","aria-pressed":O,onClick:()=>{ce(null),_e(!0)},children:N("fileEditShort")})]}),ae&&e.jsx("button",{type:"button",className:"fp-header-action","aria-pressed":fe==="git",onClick:()=>fe==="git"?ce(null):Yt(),children:N("fileChangesCount",{n:1})}),e.jsxs("button",{type:"button",className:"fp-header-action fp-reference",disabled:r,onClick:()=>k(l.path,l.name,"reference"),children:["@",N("fileReference")]}),e.jsxs("details",{className:"fp-more",children:[e.jsx("summary",{"aria-label":N("fileMoreActions"),children:e.jsx(Ss,{})}),e.jsxs("div",{className:"fp-more-actions",onClick:te=>{var Je;te.target instanceof Element&&te.target.closest("button")&&((Je=te.currentTarget.closest("details"))==null||Je.removeAttribute("open"))},children:[e.jsx("button",{className:"btn",disabled:r,onClick:()=>{wl(l.path,l.name).then(te=>{!te.ok&&!te.cancelled&&me(te.error)})},children:N("downloadFile")}),ee&&it&&e.jsx("button",{className:"btn",onClick:()=>{ce(null),U(!0),_e(!0)},children:N("editFile")}),!ee&&it&&e.jsx("button",{className:"btn",onClick:Rt,children:N(O?"exitEditFile":"editFile")}),K==="text"&&e.jsx("button",{className:"btn",onClick:()=>Ne(te=>!te),children:N(Oe?"disableWrap":"enableWrap")}),K==="text"&&e.jsxs("button",{className:"btn",onClick:()=>Vt(Ce-10),disabled:Ce<=50,children:[e.jsx(_c,{})," ",N("zoomOut")]}),K==="text"&&e.jsxs("button",{className:"btn",onClick:()=>Vt(Ce+10),disabled:Ce>=200,children:[e.jsx(Hc,{})," ",N("zoomIn")]}),K!=="video"&&K!=="none"&&K!=="sqlite"&&e.jsx("button",{className:"btn",onClick:()=>k(l.path,l.name,"inline"),children:N("attachInlineTip")})]})]}),it&&g&&w!=="saving"&&e.jsxs("button",{className:"btn primary fp-header-save",disabled:r,onClick:()=>zt(),children:[e.jsx(Uc,{})," ",N("saveFile")]})]})]}),we&&g&&e.jsxs("div",{className:"fp-external-banner",role:"alert",children:[N("fileExternalChanged"),e.jsx("button",{type:"button",onClick:()=>{var te;return(te=s.current)==null?void 0:te.call(s,ne)},children:N("fileReload")}),e.jsx("button",{type:"button",disabled:xe===null,onClick:()=>ce("external"),children:N("fileCompare")})]}),Xt&&K==="text"&&!jt&&e.jsx("div",{className:"fp-notice",children:N("previewTruncated")}),X&&e.jsxs("div",{className:"fp-notice",role:"alert",children:[X,e.jsx("button",{className:"btn",disabled:r||w==="saving",onClick:()=>{var te;return(te=s.current)==null?void 0:te.call(s,ne)},children:N("fileReload")}),$e&&e.jsx("button",{className:"btn",disabled:r,onClick:()=>{window.confirm(N("fileOverwriteConfirm"))&&zt(!0)},children:N("fileOverwrite")})]}),st&&e.jsxs("div",{className:"fp-leave",role:"alertdialog","aria-label":N("fileUnsaved"),children:[e.jsx("p",{children:N("fileLeavePrompt")}),e.jsx("button",{className:"btn primary",disabled:r,onClick:()=>{const te=st.action;lt(null),zt(!1,te)},children:N("fileSaveContinue")}),e.jsx("button",{className:"btn",onClick:()=>{const te=st.action;lt(null),te()},children:N("fileDiscard")}),e.jsx("button",{className:"btn",onClick:()=>lt(null),children:N("cancel")})]}),b&&!R&&e.jsx("div",{className:"fp-empty",children:N("loading")}),!b&&K==="none"&&!jt&&e.jsx("div",{className:"fp-empty",children:N("previewNotSupported")}),!b&&K==="sqlite"&&e.jsx(Zm,{file:l,disabled:r||!i}),!b&&K==="image"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("img",{className:"fp-media",src:Be(l.path),alt:l.name})}),!b&&K==="video"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("video",{className:"fp-media",src:Be(l.path),controls:!0,preload:"metadata"})}),!b&&Ke&&R&&(O&&it?e.jsx(vl,{file:l,value:M,readOnly:r||w==="saving",onChange:ye}):e.jsx("div",{className:"fp-markdown msg-text",children:e.jsx("div",{className:"fp-markdown-zoom",children:e.jsx(Fn,{text:it?M:R.text,imageSrc:te=>sl(te,l),sourceLines:!0})})})),!b&&jt&&K!=="image"&&K!=="sqlite"&&K!=="video"&&R&&e.jsxs("div",{className:"fp-hex-wrap",children:[e.jsxs("div",{className:"fp-notice",children:[N("binaryFile"),R.truncated&&N("binaryHexTruncated")]}),e.jsx("pre",{className:"fp-hex",children:R.text})]}),!b&&O&&!Ke&&K==="text"&&!jt&&R&&e.jsx(kl,{name:l.name,value:M,readOnly:r||w==="saving",onChange:ye,onSelectLines:(te,Je)=>{ie({start:te,end:Je}),G(null)},wrap:Oe,markers:g?void 0:We}),!b&&!Ke&&!O&&K==="text"&&!jt&&R&&ct.length===0&&e.jsx("div",{className:"fp-empty",children:N("emptyFile")}),!b&&!Ke&&!O&&K==="text"&&!jt&&ct.length>0&&e.jsxs("div",{className:`fp-code ${Q?"dragging":""} ${Oe?"":"no-wrap"}`,onMouseDown:te=>{te.button===0&&te.preventDefault()},children:[ct.map((te,Je)=>{const qe=Je+1,yt=B!==null&&qe>=B.start&&qe<=B.end;return e.jsxs("div",{"data-line":qe,className:`fp-line ${yt?"sel":""}`,onMouseDown:Kt=>{Kt.button===0&&($t(qe,Kt.shiftKey),tt.current=!0,q(!0))},onMouseEnter:()=>{tt.current&&$t(qe,!0)},children:[e.jsx("span",{className:`fp-num ${g?"":We.get(qe)??""}`,children:qe}),ft?e.jsx("span",{className:"fp-code-text hljs",dangerouslySetInnerHTML:{__html:ft[Je]||""}}):e.jsx("span",{className:"fp-code-text",children:te})]},qe)}),Dt&&e.jsx("div",{className:"fp-lines-note",children:N("previewLinesTruncated",{n:Gr})})]}),B&&!fe&&e.jsxs("button",{type:"button",className:`fp-quote-selection${De?" at-selection":""}`,style:De?{left:De.x,top:De.y}:void 0,disabled:r,onMouseDown:te=>te.preventDefault(),onClick:Ft,children:[ke?e.jsx(ss,{}):null,ke?N("addedToChat"):N("quoteSelection",{name:l.name,start:B.start,end:B.end})]}),fe==="git"&&e.jsx("div",{className:"fp-diff-view",role:"region","aria-label":N("fileViewChanges"),children:Ae?e.jsx("span",{className:"fp-empty",children:N("loading")}):Z?e.jsx("pre",{children:Z.split(`
|
|
272
|
-
`).map((te,Je)=>e.jsxs("span",{className:te.startsWith("+")&&!te.startsWith("+++")?"add":te.startsWith("-")&&!te.startsWith("---")?"del":te.startsWith("@@")?"hunk":"",children:[te,`
|
|
273
|
-
`]},Je))}):e.jsx("div",{className:"fp-empty",children:N("fileNoChanges")})}),fe==="external"&&e.jsxs("div",{className:"fp-diff-view fp-external-comparison",role:"region","aria-label":N("fileCompare"),children:[e.jsxs("section",{children:[e.jsx("h3",{children:N("fileLocalDraft")}),e.jsx("pre",{children:M})]}),e.jsxs("section",{children:[e.jsx("h3",{children:N("fileDiskVersion")}),e.jsx("pre",{children:xe})]})]})]})})});function sf(t){const n=t.toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function rf(t,n){const s=n.trim();if(!s)return null;let r=t.indexOf(s),i=r+s.length;if(r<0){let a="";const o=[];for(let p=0;p<t.length;p++){const u=t[p];if(/\s/.test(u)){if(a.endsWith(" "))continue;a+=" "}else a+=u;o.push(p)}const c=s.replace(/\s+/g," "),l=a.indexOf(c);if(l<0)return null;r=o[l],i=o[l+c.length-1]+1}return{start:t.slice(0,r).split(`
|
|
274
|
-
`).length,end:t.slice(0,i).split(`
|
|
275
|
-
`).length}}function eo(t){return t.filter(n=>n.nativeRef||n.mode==="lines"||n.isDir||n.imageData||n.fileData||!n.path)}const $l="pi-web-sounds",$s={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function Fl(){try{const t=localStorage.getItem($l);if(!t)return{...$s};const n=JSON.parse(t),s={...$s,...n};for(const r of["enabled","question","done","start","error"])typeof s[r]!="boolean"&&(s[r]=$s[r]);return typeof s.volume!="number"||!Number.isFinite(s.volume)?s.volume=$s.volume:s.volume=Math.round(Math.max(0,Math.min(100,s.volume))/5)*5,s}catch{return{...$s}}}function af(t){try{localStorage.setItem($l,JSON.stringify(t))}catch{}}let Fs=null;function of(){try{if(!Fs){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;Fs=new t}return Fs.state==="suspended"&&Fs.resume(),Fs}catch{return null}}const lf=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],cf=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],df=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],uf=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],pf={question:lf,done:cf,start:df,error:uf};function hf(t,n,s){const r=t.createOscillator(),i=t.createGain();r.type=n.type,r.frequency.value=n.freq;const a=t.currentTime+n.start,o=Math.max(1e-4,n.peak*s);i.gain.setValueAtTime(1e-4,a),i.gain.exponentialRampToValueAtTime(o,a+.012),i.gain.exponentialRampToValueAtTime(1e-4,a+n.dur),r.connect(i),i.connect(t.destination),r.start(a),r.stop(a+n.dur+.05)}function Os(t,n=Fl()){if(!n.enabled||!n[t])return;const s=of();if(!s)return;const r=Math.max(0,Math.min(1,n.volume/100));for(const i of pf[t])hf(s,i,r)}const mf=d.lazy(()=>Cr(()=>import("./TerminalPanel-CWh6vw_N.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.TerminalPanel}))),ff=d.lazy(()=>Cr(()=>import("./NodeWorkbench-C4U1PldE.js"),__vite__mapDeps([6,1,3,4,5])).then(t=>({default:t.NodeWorkbench})));function to({notice:t,onDismiss:n}){const s=nt(),[r,i]=d.useState(!1);d.useEffect(()=>{if(r||t.level!=="info")return;const o=setTimeout(()=>n(t.id),3e3);return()=>clearTimeout(o)},[r,t.id,t.level,n]);const a=t.level==="error"?ad:t.level==="warning"?Eo:Qc;return e.jsxs("div",{className:`notice notice-${t.level}${r?" paused":""}`,role:"status",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[e.jsx(a,{className:"notice-icon"}),e.jsx("span",{className:"notice-text",children:e.jsx(Fo,{text:t.text})}),e.jsx("button",{type:"button",className:"notice-close",title:s("close"),onClick:()=>n(t.id),children:e.jsx(qt,{})})]})}const gf=[],gi=180,Ol=520,_l=240,xi=t=>`pi-harness:${t}-panel-width`;function no(t){const n=Number(localStorage.getItem(xi(t)));return Number.isFinite(n)&&n>=gi&&n<=Ol?n:t==="editor"?480:t==="right"?300:_l}function so({side:t,width:n,onResize:s,onReset:r}){const i=nt(),a=d.useCallback(o=>{var j,I;o.preventDefault();const c=o.clientX,l=t==="editor"?((j=o.currentTarget.nextElementSibling)==null?void 0:j.getBoundingClientRect().width)??n:n,p=t==="editor"?Math.max(gi,l+(((I=o.currentTarget.previousElementSibling)==null?void 0:I.getBoundingClientRect().width)??0)-180):Ol;let u=l;const f=E=>{const $=t==="left"?E.clientX-c:c-E.clientX;u=Math.min(p,Math.max(gi,Math.round(l+$))),s(u)},k=()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",k),document.body.classList.remove("panel-resizing"),localStorage.setItem(xi(t),String(u))};window.addEventListener("pointermove",f),window.addEventListener("pointerup",k),document.body.classList.add("panel-resizing")},[t,n,s]);return e.jsx("div",{className:`resize-handle resize-${t==="editor"?"right":t}`,title:i("dragToResize"),onPointerDown:a,onDoubleClick:()=>{if(r){r();return}const o=t==="editor"?480:t==="right"?300:_l;s(o),localStorage.setItem(xi(t),String(o))}})}function xf(){var Ge,dt,ut,gt,It,Gt,dn,on,Nn,un,kn,tn,ln,Jt,An,En,ds,qn,Dn,Yn,pn,Xn,zn,At,Vn,Kn,Tn,jn,$n,Rn,us,Zn,rs,ps,hs;d.useEffect(()=>{var Y;return(Y=xt==null?void 0:xt.onBeforeClose)==null?void 0:Y.call(xt,Pd)},[]);const t=nt(),{locale:n}=Qn(),{chat:s,send:r,dismissNotice:i,pushNotice:a,setPendingEcho:o,terminal:c,switching:l,switchError:p}=Kd(),u=((Ge=s.state)==null?void 0:Ge.conversationId)===s.activeConversationId?s.state:null,f=Ip(((dt=s.state)==null?void 0:dt.cwd)??"",s.ready&&!l,s.scmDirty,s.scmData,r),k=s.conversations.find(Y=>Y.id===s.activeConversationId),j=s.sessions.find(Y=>Y.path===(u==null?void 0:u.sessionFile));fr((k==null?void 0:k.title)||cs((j==null?void 0:j.firstMessage)??"")||t("newChat"),j==null?void 0:j.firstMessage,j==null?void 0:j.name,Math.max((j==null?void 0:j.messageCount)??0,(k==null?void 0:k.messageCount)??0,(u==null?void 0:u.messages.length)??0),n,u==null?void 0:u.messages);const[I,E]=d.useState([]),$=d.useRef(new Map),N=d.useRef(s.activeConversationId);d.useLayoutEffect(()=>{N.current!==s.activeConversationId&&(I.length?$.current.set(N.current,I):$.current.delete(N.current),N.current=s.activeConversationId,E($.current.get(s.activeConversationId)??[]),$.current.delete(s.activeConversationId))},[s.activeConversationId,I]);const[R,y]=d.useState(null),L=d.useRef(null);d.useLayoutEffect(()=>{const Y=L.current;if(Y&&(Y.cwd!==(R==null?void 0:R.cwd)||Y.path!==(R==null?void 0:R.path))){E(eo);for(const[Te,Ze]of $.current)$.current.set(Te,eo(Ze))}L.current=R},[R]);const b=d.useRef(null),F=d.useRef(null),[B,ie]=d.useState(null);d.useEffect(()=>{var Y;!l&&((Y=s.state)!=null&&Y.cwd)&&R&&R.cwd!==s.state.cwd&&y(null)},[l,(ut=s.state)==null?void 0:ut.cwd,R]);const Q=d.useRef(null),q=d.useRef(null),ke=d.useRef(!1),Re=d.useRef(null),O=d.useCallback(Y=>{const Te=Y.type==="switch_conversation"||Y.type==="new_chat"||Y.type==="set_cwd"||Y.type==="switch_session"||Y.type==="prompt"&&/^\/cwd(?:\s|$)/.test(Y.text);return Te&&(ke.current||Re.current)?!1:Te&&q.current?(q.current(()=>{r(Y)}),!1):Te&&Q.current?(ve("chat"),g("right"),Q.current(()=>{r(Y)&&Y.type!=="switch_session"&&y(null)}),!1):r(Y)},[r]),[_e,M]=d.useState(!1);d.useEffect(()=>{const Y=()=>{var Te;(Te=s.state)!=null&&Te.cwd&&O({type:"native_mcp_request",action:"radius",scope:"global",cwd:s.state.cwd,requestId:Qt()})};return window.addEventListener("pi-configure-radius",Y),()=>window.removeEventListener("pi-configure-radius",Y)},[(gt=s.state)==null?void 0:gt.cwd,O]);const[V,ve]=d.useState("chat"),[ye,oe]=d.useState(null),[Fe,U]=d.useState(null),[fe,ce]=d.useState(!1),[ae,z]=d.useState(null),[Z,W]=d.useState(null),[ge,Ie]=d.useState(""),Ae=d.useRef(null),re=d.useRef(ye==null?void 0:ye.token);re.current=ye==null?void 0:ye.token;const we=d.useRef({cwd:(It=s.state)==null?void 0:It.cwd,conversationId:s.activeConversationId,epoch:0});we.current.cwd!==((Gt=s.state)==null?void 0:Gt.cwd)&&(we.current.epoch++,Re.current=null),we.current={...we.current,cwd:(dn=s.state)==null?void 0:dn.cwd,conversationId:s.activeConversationId};const A=d.useCallback(async Y=>{const Te=we.current;Te.cwd&&(Ie(""),oe({cwd:Te.cwd,path:Y,token:Qt()}),y(null),ve("wiki"),g(null))},[]);d.useEffect(()=>{var pt,kt;if(Re.current){if(Re.current!==((pt=s.state)==null?void 0:pt.conversationId)||Re.current!==s.activeConversationId)return;Re.current=null}const Y=ye;if(!Y||Fe!==Y.token||Y.cwd!==((kt=s.state)==null?void 0:kt.cwd)||ke.current||Ae.current===Y.token||!s.ready||l)return;Ae.current=Y.token,ke.current=!0,ce(!0),Ie("");const Te=s.activeConversationId,Ze=we.current.epoch;Pn(Y.cwd,"new-conversation",{path:Y.path,conversationId:Te}).then(Nt=>{we.current.cwd!==Y.cwd||we.current.epoch!==Ze||(Re.current=Nt.conversationId,z(Nt.conversationId),W(Y.token))}).catch(Nt=>{we.current.cwd===Y.cwd&&we.current.epoch===Ze&&re.current===Y.token&&Ie(Nt.message)}).finally(()=>{ke.current=!1,ce(!1)})},[ye,Fe,(on=s.state)==null?void 0:on.cwd,(Nn=s.state)==null?void 0:Nn.conversationId,s.activeConversationId,s.ready,l,fe]);const xe=Z===(ye==null?void 0:ye.token)&&ae===s.activeConversationId&&ae===((un=s.state)==null?void 0:un.conversationId),_=s.ready&&!l&&!fe&&xe,Se=d.useRef(null);d.useEffect(()=>{V!=="chat"||!_||Se.current===s.activeConversationId||r({type:"new_chat"})&&(Se.current=s.activeConversationId)},[V,_,s.activeConversationId,r]),d.useEffect(()=>{var Y;V==="wiki"&&s.ready&&!l&&!fe&&!Re.current&&ye&&ye.cwd===((Y=s.state)==null?void 0:Y.cwd)&&Z===ye.token&&ae&&ae!==s.activeConversationId&&A(ye.path)},[V,s.ready,l,fe,ye,(kn=s.state)==null?void 0:kn.cwd,s.activeConversationId,Z,ae,A]);const[J,De]=d.useState(null),G=d.useRef(new Set(["chat"]));G.current.add(V);const Oe=d.useMemo(()=>s.plugins.filter(Y=>{var Te,Ze;return!((Ze=(Te=s.settings)==null?void 0:Te.disabledPlugins)!=null&&Ze.includes(Y.id))}),[s.plugins,(tn=s.settings)==null?void 0:tn.disabledPlugins]),[Ne,Ee]=d.useState([]);d.useEffect(()=>Od(Ee),[]),d.useEffect(()=>{_d(Oe,s.pluginsEpoch)},[Oe,s.pluginsEpoch]);const[et,Ce]=d.useState(()=>localStorage.getItem("pi-left-collapsed")==="true"),[be,ze]=d.useState(!1),tt=d.useRef(null),Ye=d.useCallback(Y=>{ze(Y),Y?Ce(Te=>(tt.current=Te,!0)):tt.current!==null&&(Ce(tt.current),tt.current=null)},[]),Le=d.useMemo(()=>fo(u==null?void 0:u.taskProgress,(u==null?void 0:u.messages)??[],(u==null?void 0:u.cwd)??""),[u==null?void 0:u.taskProgress,u==null?void 0:u.messages,u==null?void 0:u.cwd]),[Xe,vt]=d.useState(()=>no("left")),[se,Ue]=d.useState(()=>no("right")),w=d.useCallback(Y=>vt(Y),[]),[H,X]=d.useState(()=>{const Y=Number(localStorage.getItem("pi-harness:editor-share"));return Number.isFinite(Y)&&Y>=.15&&Y<=.85?Y:.45}),me=d.useCallback(Y=>Ue(Y),[]),$e=d.useCallback(Y=>{const Te=document.querySelector(".view-pane.preview-open:not(.hidden)"),Ze=Te==null?void 0:Te.querySelector(".main"),pt=Te==null?void 0:Te.querySelector(".drawer-right"),kt=((Ze==null?void 0:Ze.getBoundingClientRect().width)??0)+((pt==null?void 0:pt.getBoundingClientRect().width)??0);if(kt>0){const Nt=Math.min(.85,Math.max(.15,Y/kt));X(Nt),localStorage.setItem("pi-harness:editor-share",String(Nt))}},[]),[Pe,st]=d.useState(!1),[lt,g]=d.useState(null),[ne,We]=d.useState(()=>window.matchMedia("(max-width: 768px)").matches),[He,ct]=d.useState(()=>window.matchMedia("(max-width: 1100px)").matches);d.useEffect(()=>{const Y=window.matchMedia("(max-width: 1100px)"),Te=Ze=>{ct(Ze.matches),g(null)};return Y.addEventListener("change",Te),()=>Y.removeEventListener("change",Te)},[]),d.useEffect(()=>{const Y=window.matchMedia("(max-width: 768px)"),Te=Ze=>We(Ze.matches);return Y.addEventListener("change",Te),()=>Y.removeEventListener("change",Te)},[]);const ft=d.useCallback((Y,Te,Ze,pt=!1,kt)=>{const Nt=`${Y}|${Ze}|${kt?`${kt.start}-${kt.end}`:""}`;E(Lt=>Lt.some(T=>`${T.path}|${T.mode}|${T.lines?`${T.lines.start}-${T.lines.end}`:""}`===Nt)?Lt:[...Lt,{path:Y,name:Te,mode:Ze,isDir:pt,...kt?{lines:kt}:{}}])},[]),Mt=d.useCallback((Y,Te)=>{var kt;if(l||!((kt=s.state)!=null&&kt.cwd))return;const Ze=s.state.cwd,pt=()=>{/\.(md|markdown)$/i.test(Y)?A(Y):(ve("chat"),g("right"),y({path:Y,name:Te,cwd:Ze}))};if(q.current){q.current(pt);return}Q.current?(ve("chat"),g("right"),Q.current(pt)):pt()},[l,(ln=s.state)==null?void 0:ln.cwd,A]);d.useEffect(()=>{const Y=Te=>{var Qe,rt;const Ze=Te.detail,pt=(rt=(Qe=s.state)==null?void 0:Qe.cwd)==null?void 0:rt.replaceAll("\\","/").replace(/\/$/,"");if(!pt||typeof(Ze==null?void 0:Ze.path)!="string")return;const kt=Ze.path.replaceAll("\\","/"),Nt=kt.startsWith(`${pt}/`)?kt.slice(pt.length+1):kt;if(Nt.startsWith("/")||/^[A-Za-z]:\//.test(Nt)||Nt.split("/").includes(".."))return;Mt(Nt,Nt.split("/").at(-1)??Nt);const Lt=Ze.line;if(!Number.isInteger(Lt)||!Lt||Lt<1)return;let T=0;const pe=()=>{var sn,Cn;if(((sn=document.querySelector(".fp-file-path"))==null?void 0:sn.title.replaceAll("\\","/"))!==`${pt}/${Nt}`){++T<40&&window.setTimeout(pe,100);return}const Tt=document.querySelector(`.fp-line[data-line="${Lt}"], .fp-edit-line[data-line="${Lt}"], .fp-markdown [data-source-start="${Lt}"]`)??Array.from(document.querySelectorAll(".fp-markdown [data-source-start][data-source-end]")).find(hn=>Number(hn.dataset.sourceStart)<=Lt&&Number(hn.dataset.sourceEnd)>=Lt);if(Tt){const hn=(Cn=Tt.closest(".fp-code-editor"))==null?void 0:Cn.querySelector(".fp-editor");if(hn){const Js=Number.parseFloat(getComputedStyle(hn).lineHeight)||22;hn.scrollTop=Math.max(0,(Lt-1)*Js-hn.clientHeight/2),hn.dispatchEvent(new Event("scroll",{bubbles:!0}))}else Tt.scrollIntoView({block:"center"});Tt.classList.add("from-tool"),window.setTimeout(()=>Tt.classList.remove("from-tool"),2e3)}else++T<40&&window.setTimeout(pe,100)};window.setTimeout(pe,100)};return window.addEventListener("pi-harness:open-tool-file",Y),()=>window.removeEventListener("pi-harness:open-tool-file",Y)},[Mt,(Jt=s.state)==null?void 0:Jt.cwd]);const[Dt,$t]=d.useState(!1),[Ft,Yt]=d.useState(!1),[Ut,it]=d.useState(!1),[Rt,zt]=d.useState(!1),[Ot,Vt]=d.useState(!1);d.useEffect(()=>{const Y=Te=>{var T,pe;const Ze=Te.detail,pt=(Ze==null?void 0:Ze.title)||"插件命令",kt=Ze==null?void 0:Ze.command;if(!kt||!s.ready)return;const Nt={name:pt,command:kt,cwd:"${pwd}"},Lt=s.terminals.find(Qe=>Qe.title===pt);if(Lt)c.restart(Lt.id),O({type:"run_command",terminalId:Lt.id,conversationId:Lt.conversationId,command:Nt,cols:80,rows:24});else{const Qe=Qt();c.create({id:Qe,conversationId:s.activeConversationId||((T=s.state)==null?void 0:T.conversationId)||"",title:pt,cwd:((pe=s.state)==null?void 0:pe.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:Nt})}ve("terminal")};return window.addEventListener("pi-harness:plugin-run-command",Y),()=>window.removeEventListener("pi-harness:plugin-run-command",Y)},[s,c,O]),d.useEffect(()=>{const Y=Te=>{V==="wiki"||!(Te.ctrlKey||Te.metaKey)||Te.key.toLowerCase()!=="k"||(Te.preventDefault(),Vt(Ze=>!Ze))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[V]);const[jt,Xt]=d.useState(Fl),K=d.useRef(null),ee=d.useRef(null),Ke=d.useRef(0),Be=d.useRef(!1),te=d.useRef(s.terminals);d.useEffect(()=>{af(jt)},[jt]),d.useEffect(()=>{var Te;const Y=te.current;te.current=s.terminals;for(const Ze of s.terminals){const pt=((Te=Ze.command)==null?void 0:Te.command)??"",kt=Y.find(Nt=>Nt.id===Ze.id);!(kt!=null&&kt.running)||Ze.running||(pt.startsWith("pi remove ")?O({type:"extensions_reload"}):(pt.startsWith("pi-harness install ")||pt.startsWith("pi-harness uninstall "))&&O({type:"plugins_reload"}))}},[s.terminals,O]),d.useEffect(()=>{var Ze;const Y=((Ze=s.state)==null?void 0:Ze.isStreaming)??!1,Te=K.current;K.current=Y,Te!==null&&(!Te&&Y?Os("start",jt):Te&&!Y&&Os("done",jt))},[(An=s.state)==null?void 0:An.isStreaming,jt]),d.useEffect(()=>{var Te;const Y=((Te=s.dialog)==null?void 0:Te.id)??null;Y!==null&&Y!==ee.current&&Os("question",jt),ee.current=Y},[s.dialog,jt]),d.useEffect(()=>{const Y=[...s.notices].reverse().find(Te=>Te.level==="error");Y&&Y.id!==Ke.current&&(Ke.current=Y.id,Os("error",jt))},[s.notices,jt]);const Je=d.useCallback(()=>y(null),[]),[qe,yt]=d.useState(0),Kt=()=>{const Y=()=>{y(null),ve("chat"),st(!1),g(ne||He?"right":null),yt(Te=>Te+1)};Q.current?Q.current(Y):Y()};d.useEffect(()=>{var Te;if(!qe)return;const Y=document.querySelector(".view-pane:not(.hidden) .task-progress");Y==null||Y.focus({preventScroll:!0}),(Te=Y==null?void 0:Y.querySelector(".task-plan-step.running"))==null||Te.scrollIntoView({block:"nearest"})},[qe]);const an=d.useCallback((Y,Te,Ze,pt)=>{ft(Y,Te,"lines",!1,{start:Ze,end:pt})},[ft]),Zt=Y=>E(Te=>Te.filter(Ze=>Ze.key?Ze.key!==Y:Ze.path!==Y)),Ct=d.useCallback(Y=>(!Y.type.startsWith("list_")&&!Y.type.startsWith("get_")&&g(null),O(Y)),[O]);d.useEffect(()=>{const Y=Te=>{if((Te.metaKey||Te.ctrlKey)&&!Te.shiftKey&&Te.key.toLowerCase()==="n"){if(Te.preventDefault(),q.current){q.current(()=>{ve("chat"),r({type:"new_chat"})});return}ve("chat"),Ct({type:"new_chat"})}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[Ct,r]);const cn=d.useRef(0),ht=d.useRef(0),Et=(Y,Te)=>{Te===N.current?E(Ze=>[...Ze,Y]):$.current.set(Te,[...$.current.get(Te)??[],Y])},Ht=(Y,Te)=>{var kt;const Ze=Date.now();(kt=s.state)!=null&&kt.model&&!s.state.model.vision&&Ze-ht.current>1e4&&(ht.current=Ze,a("warning",t("imageNotSupported")));const pt=`paste-${++cn.current}`;Et({path:"",key:pt,name:Y.name,mode:"inline",imageData:Y.data,mimeType:Y.mimeType},Te)},Bt=async(Y,Te=N.current)=>{for(const Ze of Y){const pt=await pi(Ze);if(!pt){a("error",t("imageLoadFailed",{name:Ze.name}));continue}Ht(pt,Te)}},St=20*1024*1024,en=d.useRef(0),yn=async(Y,Te)=>{if(Y.size>St){a("warning",t("fileTooLarge",{name:Y.name,size:St/1024/1024}));return}let Ze;try{Ze=(await new Promise((Nt,Lt)=>{const T=new FileReader;T.onload=()=>Nt(T.result),T.onerror=()=>Lt(T.error??new Error("read failed")),T.readAsDataURL(Y)})).replace(/^data:[^;]*;base64,/,"")}catch{a("error",t("fileLoadFailed",{name:Y.name}));return}const pt=`upload-${++en.current}`;Et({path:"",key:pt,name:Y.name,mode:"inline",fileData:Ze,size:Y.size,mimeType:Y.type||void 0},Te)},xn=async Y=>{const Te=N.current;for(const Ze of Y)ns(Ze.type)?await Bt([Ze],Te):await yn(Ze,Te)},Un=jd(s,O,()=>a("error",t("toolRecoveryFailed"))),Wn=d.useCallback((Y,Te,Ze,pt)=>{O({type:"edit_message",conversationId:s.activeConversationId,messageId:Y,text:Te,attachments:Ze,...pt})},[O,s.activeConversationId]),On=d.useCallback(()=>Yt(!0),[]),wn=d.useCallback((Y,Te)=>{const Ze=pt=>pt.filter(kt=>!Te.includes(kt));N.current===Y?E(Ze):$.current.set(Y,Ze($.current.get(Y)??[]))},[]),rn=d.useCallback(Zt,[]),bn=d.useCallback(Bt,[Bt]),vn=d.useCallback(xn,[xn]);d.useEffect(()=>{const Y=Te=>{var Lt;const{cwd:Ze,file:pt,complete:kt}=Te.detail;if(Ze!==((Lt=s.state)==null?void 0:Lt.cwd)||!(pt instanceof File)){kt(!1);return}const Nt=s.activeConversationId;pi(pt).then(T=>{T&&Ht(T,Nt),kt(!!T)}).catch(()=>kt(!1))};return window.addEventListener("pi-codemode-attach",Y),()=>window.removeEventListener("pi-codemode-attach",Y)},[(En=s.state)==null?void 0:En.cwd,s.activeConversationId,bn]);const h=(ds=s.state)==null?void 0:ds.model,v=(qn=s.state)==null?void 0:qn.thinkingLevel,S=(Dn=s.state)==null?void 0:Dn.availableThinkingLevels,P=d.useMemo(()=>u?{model:h??null,conversationId:u.conversationId,runSettings:u.runSettings,routedModel:u==null?void 0:u.routedModel,thinkingLevel:v??"off",availableThinkingLevels:S??[]}:null,[h,v,S,u==null?void 0:u.routedModel,u==null?void 0:u.conversationId,(Yn=u==null?void 0:u.runSettings)==null?void 0:Yn.autoCompaction,(pn=u==null?void 0:u.runSettings)==null?void 0:pn.autoRetry]),de=u==null?void 0:u.conversationId,le=u==null?void 0:u.cwd,je=d.useCallback(()=>!s.ready||!de||s.terminals.length!==0?!1:(c.create({id:Qt(),conversationId:de,title:t("terminalTitle",{n:1}),cwd:le??"",cols:80,rows:24,running:!0,exitCode:null}),!0),[s.ready,de,le,s.terminals.length,t,c]);return d.useEffect(()=>{if(Be.current){if(V!=="terminal"||s.terminals.length!==0){Be.current=!1;return}je()&&(Be.current=!1)}},[s.terminals.length,je,V]),e.jsx(Cc,{conversationId:(u==null?void 0:u.conversationId)??"",files:Le,active:V==="chat",onOpenChange:Ye,children:e.jsxs("div",{className:`app design-workspace ${be&&V==="chat"?"changes-open":""} ${V==="wiki"?"wiki-mode":""} ${et?"left-collapsed":""} ${R&&V==="chat"?"document-open":""}`,style:{"--left-w":`${Xe}px`,"--right-w":`${se}px`},onDragOver:Y=>{var Te;Array.from(((Te=Y.dataTransfer)==null?void 0:Te.types)??[]).includes("Files")&&(Y.preventDefault(),M(!0))},onDragLeave:Y=>{Y.currentTarget.contains(Y.relatedTarget)||M(!1)},onDrop:Y=>{var kt,Nt;if(M(!1),!Array.from(((kt=Y.dataTransfer)==null?void 0:kt.types)??[]).includes("Files"))return;Y.preventDefault();const Te=Array.from(((Nt=Y.dataTransfer)==null?void 0:Nt.files)??[]);if(Te.length===0){a("warning",t("foldersNotSupported"));return}const Ze=Te.filter(Lt=>ns(Lt.type)),pt=Te.filter(Lt=>!ns(Lt.type));Ze.length>0&&Bt(Ze),pt.length>0&&xn(pt)},children:[_e&&e.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:e.jsxs("span",{children:["📎 ",t("dropHereToAttach")]})}),V!=="nodes"&&V!=="wiki"&&e.jsx("div",{className:`panel-drawer drawer-left ${lt==="left"?"open":""}`,children:e.jsx($p,{incidentState:u?(Xn=Ms(u.streamingMessage?[...u.messages,u.streamingMessage]:u.messages,u.isStreaming).current)==null?void 0:Xn.state:void 0,onOpenSettings:()=>it(!0),onNewChat:()=>{ve("chat"),Ct({type:"new_chat"})},send:Ct,active:!ne||lt==="left",ready:s.ready&&!!u,status:s.status,cwd:((zn=s.state)==null?void 0:zn.cwd)??"",sessionFile:(u==null?void 0:u.sessionFile)??null,conversations:s.conversations,sessions:s.sessions,projects:s.projects,dirBrowse:s.dirBrowse,activeConversationId:s.activeConversationId})}),V!=="nodes"&&V!=="wiki"&&!ne&&!et&&e.jsx(so,{side:"left",width:Xe,onResize:w}),e.jsxs("div",{className:"workspace-column",children:[e.jsx(Ap,{leftCollapsed:et,gitChangeCount:f.files.length,onOpenTask:Kt,chat:s,send:O,terminal:c,view:V,plugins:Oe,onViewChange:Y=>{Be.current=Y==="terminal"&&s.terminals.length===0,Be.current&&je()&&(Be.current=!1);const Te=()=>{ve(Y),g(null)};V==="wiki"&&q.current?q.current(Te):Y==="wiki"&&Q.current?Q.current(Te):Te()},onOpenPanel:Y=>{Y==="left"&&!ne?(g(null),tt.current=null,Ce(Te=>(localStorage.setItem("pi-left-collapsed",String(!Te)),!Te))):Y==="right"&&!ne&&!He&&!R?st(Te=>!Te):(Y==="right"&&st(!1),g(Te=>Te===Y?null:Y))},onManageModels:()=>Yt(!0),onOpenSettings:()=>it(!0),onOpenBgTasks:()=>zt(!0),onOpenGlobalSearch:()=>Vt(!0),sound:jt,onSoundChange:Xt,onSoundPreview:Y=>Os(Y,jt)}),e.jsx(Jd,{state:u,send:O,connected:s.ready}),s.pendingDialogs.filter(Y=>Y.conversationId!==s.activeConversationId).map(Y=>e.jsxs("button",{className:"protocol-banner",onClick:()=>{if(ke.current||Re.current)return;const Te=()=>{r({type:"switch_conversation",id:Y.conversationId})&&ve("chat")};q.current?q.current(Te):Q.current?Q.current(Te):Te()},children:[t("pluginRequest")," · ",Y.source," · ",Y.title]},Y.id)),V==="wiki"&&s.dialog&&e.jsx(mi,{dialog:s.dialog,send:O}),p&&e.jsxs("div",{className:"protocol-banner",role:"alert",children:[e.jsx("button",{onClick:()=>O({type:"set_cwd",path:p,source:"ui"}),children:t("retryProjectSwitch")})," ",p]}),l&&e.jsxs("div",{className:"protocol-banner",role:"status",children:[t("switchingProject")," ",l]}),s.protocolMismatch&&e.jsxs("div",{className:"protocol-banner",children:["⚠ ",t("protocolMismatch")]}),V!=="chat"&&s.notices.length>0&&e.jsx("div",{className:"notices notices-overlay",children:s.notices.map(Y=>e.jsx(to,{notice:Y,onDismiss:i},Y.id))}),e.jsxs("div",{className:"layout",style:{"--left-w":`${Xe}px`,"--right-w":`${se}px`,"--editor-share":H},children:[lt&&(ne||He&&!R||lt==="left"&&!!R)&&e.jsx("div",{className:"drawer-backdrop",onClick:()=>g(null)}),e.jsxs("div",{className:`view-pane ${R?"preview-open":""} ${V==="chat"?"":"hidden"}`,children:[e.jsxs("main",{className:"main",children:[u?e.jsx(Gs.Provider,{value:u.cwd,children:e.jsx(Cm,{recovery:{...Un,models:s.models,onLoadModels:()=>{!s.models.length&&!s.modelsLoading&&O({type:"list_models"})}},active:V==="chat",connected:s.ready,silenceNotified:((At=s.agentSilence)==null?void 0:At.conversationId)===u.conversationId&&s.agentSilence.phase==="silent",state:u,liveOutputs:s.liveOutputs,toolStatuses:s.toolStatuses,onEdit:Wn,onStop:()=>O({type:"abort"}),thinkingWrap:((Vn=s.settings)==null?void 0:Vn.thinkingWrap)??!1,toolsWrap:((Kn=s.settings)==null?void 0:Kn.toolsWrap)??!0,pendingEcho:s.pendingEcho,reloadEvents:s.reloadEvents},u.conversationId)}):e.jsx("div",{className:"boot-wait",children:s.ready?t("loadingSession"):t("connectingServer")}),e.jsx(Im,{chat:s,send:O}),s.dialog&&e.jsx(mi,{dialog:s.dialog,send:O}),s.notices.length>0&&e.jsx("div",{className:"notices",children:s.notices.map(Y=>e.jsx(to,{notice:Y,onDismiss:i},Y.id))}),e.jsx(Rm,{active:V==="chat"&&!xe,currentFile:!l&&(B==null?void 0:B.cwd)===((Tn=s.state)==null?void 0:Tn.cwd)?B:null,contextReader:b,contextSaver:F,stats:u==null?void 0:u.stats,promptResult:s.promptResult,verifying:(jn=u==null?void 0:u.tree)==null?void 0:jn.verifying,queue:u==null?void 0:u.queue,pendingCount:((u==null?void 0:u.queue.steering.length)??0)+((u==null?void 0:u.queue.followUp.length)??0),send:O,ready:s.ready&&!!u&&!(V==="chat"&&(fe||xe)),streaming:(u==null?void 0:u.isStreaming)??!1,silentActivity:(($n=s.agentSilence)==null?void 0:$n.conversationId)===s.activeConversationId?s.agentSilence.activity:null,messages:(u==null?void 0:u.messages)??gf,slashCommands:s.slashCommands,modelState:P,models:s.models,modelsLoading:s.modelsLoading,activeConversationId:s.activeConversationId,setPendingEcho:o,attachments:I,onRemoveAttachment:rn,onAddImageFiles:bn,onAddLocalFiles:vn,onNotice:a,onManageModels:On,onSent:wn})]}),e.jsx(pd,{cwd:(u==null?void 0:u.cwd)??"",data:s.scmDiffData,send:O,ready:s.ready&&!l,notRepo:f.notRepo,branch:f.branch,defaultBase:f.base,branches:f.branches,dirty:s.scmDirty},(u==null?void 0:u.conversationId)??""),!ne&&(!He||!!R)&&(!Pe||!!R)&&e.jsx(so,{side:R?"editor":"right",width:R?480:se,onResize:R?$e:me,onReset:R?()=>{X(.45),localStorage.setItem("pi-harness:editor-share","0.45")}:void 0}),e.jsxs("div",{className:`panel-drawer drawer-right ${Pe&&!R?"files-collapsed":""} ${lt==="right"?"open":""}`,children:[e.jsx("div",{className:"file-list-host",hidden:!!R,children:e.jsx(Kp,{active:!Pe&&!R&&!l&&V==="chat"&&(!ne&&!He||lt==="right"),send:O,files:s.files,changed:f.files,notRepo:f.notRepo,fileChanged:s.fileChanged,widgets:s.widgets,messages:(u==null?void 0:u.messages)??[],streamingMessage:(u==null?void 0:u.streamingMessage)??null,taskProgress:u==null?void 0:u.taskProgress,isStreaming:u==null?void 0:u.isStreaming,conversationId:s.activeConversationId,agentSilence:s.agentSilence,cwd:((Rn=s.state)==null?void 0:Rn.cwd)??"",onAttach:(Y,Te,Ze,pt)=>{g(null),ft(Y,Te,Ze,pt)},onPreview:Mt,onNotice:(Y,Te)=>a(Y,Te)})}),R&&e.jsx(nf,{file:R,contextReader:b,contextSaver:F,onContextChange:ie,guard:Q,result:s.fileResult,disabled:!!l||R.cwd!==((us=s.state)==null?void 0:us.cwd),connected:s.status==="open",content:s.fileContent,fileChanged:s.fileChanged,scmData:((Zn=s.scmData)==null?void 0:Zn.type)==="scm_data"?s.scmData:null,scmDirty:s.scmDirty,send:O,onAddLines:an,onAttach:ft,onClose:Je},`${R.cwd}:${R.path}`)]})]}),e.jsx("div",{className:`view-pane ${V==="wiki"?"":"hidden"}`,children:G.current.has("wiki")&&s.state&&e.jsx(Np,{recovery:u==null?void 0:u.recovery,cwd:s.state.cwd,conversationId:s.activeConversationId,fileRequest:(ye==null?void 0:ye.cwd)===s.state.cwd?ye:null,messages:xe?s.state.messages:[],streaming:_&&s.state.isStreaming,live:_?s.state.streamingMessage:null,model:s.state.model,contextPercent:s.state.stats.contextUsage.percent,toolStatuses:s.toolStatuses,active:V==="wiki",ready:_,onContentRequested:U,sessionError:ge,writingBlocked:!!l||s.state.isStreaming,openDocument:A,thinkingWrap:((rs=s.settings)==null?void 0:rs.thinkingWrap)??!1,connected:s.ready,silenceNotified:((ps=s.agentSilence)==null?void 0:ps.conversationId)===s.state.conversationId&&s.agentSilence.phase==="silent",send:O,guard:q},s.state.cwd)}),e.jsx("div",{className:`view-pane ${V==="terminal"?"":"hidden"}`,children:e.jsx(d.Suspense,{fallback:null,children:G.current.has("terminal")&&e.jsx(mf,{active:V==="terminal"&&!l,chat:s,send:O,terminal:c})})}),e.jsx("div",{className:`view-pane ${V==="nodes"?"":"hidden"}`,children:e.jsx(d.Suspense,{fallback:null,children:G.current.has("nodes")&&e.jsx(ff,{active:V==="nodes",send:O})})}),e.jsx("div",{className:`view-pane ${V==="git"?"":"hidden"}`,children:G.current.has("git")&&e.jsx(Am,{chat:s,send:O,terminal:c,active:V==="git",commitToShow:J,onSwitchToTerminal:()=>ve("terminal")})}),Ne.map(Y=>{const Te=`plugin:${Y.info.id}`;return e.jsx("div",{className:`view-pane ${V===Te?"":"hidden"}`,children:G.current.has(Te)&&e.jsx(Dm,{entry:Y,send:O})},Y.info.id)})]})]}),e.jsx(Mm,{chat:s,send:O}),s.ready&&s.state&&s.state.piConfigured===!1&&!Dt&&!Ft&&e.jsx($m,{send:O,piConfigured:s.state.piConfigured,piAgentInstalled:s.state.piAgentInstalled,providers:s.providers,installResult:s.installResult,onClose:()=>$t(!0)}),e.jsx(Ep,{state:s.providerAuth,send:O}),Ft&&e.jsx(_m,{send:O,providers:s.modelsConfig,providerStatus:s.providers,fetchModelsResult:s.fetchModelsResult,refreshProviderResult:s.refreshProviderResult,cloneProviderResult:s.cloneProviderResult,onClose:()=>Yt(!1)}),e.jsx(Gd,{state:u,connected:s.ready,send:O}),Ut&&e.jsx(Jm,{chat:s,send:O,onClose:()=>it(!1)}),Rt&&e.jsx(Ym,{servers:s.bgServers,send:O,onClose:()=>zt(!1)}),Ot&&e.jsx(Xm,{send:O,sessions:s.sessions,projects:s.projects,cwd:((hs=s.state)==null?void 0:hs.cwd)??"",fileSearch:s.fileSearch,onClose:()=>Vt(!1),onSwitchSession:Y=>{O({type:"switch_session",path:Y})},onSwitchProject:Y=>{O({type:"set_cwd",path:Y,source:"ui"})},onPreviewFile:Mt})]})})}xt&&document.documentElement.classList.add("pi-desktop",`pi-desktop-${xt.platform}`);Cd();xc();kc.createRoot(document.getElementById("root")).render(e.jsx(d.StrictMode,{children:e.jsx(dd,{children:e.jsx(xf,{})})}));export{Is as F,gc as T,Cr as _,gs as a,wf as b,bf as c,ia as d,Pr as e,qt as f,ko as g,ki as h,Qt as r,nt as u};
|