@jingyi0605/codingns 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/AdaptiveButlerPage-SffCV4Vb.js +3 -0
- package/dist/public/assets/App-WOLwMld_.js +30 -0
- package/dist/public/assets/{BootstrapPage-Vu5oEJ8z.js → BootstrapPage--zExdgfM.js} +1 -1
- package/dist/public/assets/{ConversationPage-Cjpg6g0J.js → ConversationPage-D9pzRmOg.js} +2 -2
- package/dist/public/assets/{DesktopDetachPreviewPage-BgeEqbc5.js → DesktopDetachPreviewPage-DvI9CIKi.js} +1 -1
- package/dist/public/assets/{DesktopWindowPage-1WelvxdH.js → DesktopWindowPage-D8FpOSLE.js} +1 -1
- package/dist/public/assets/FileContextPanel-C8T7oqRN.js +1 -0
- package/dist/public/assets/GitSidebar-Bze7DNnc.js +6 -0
- package/dist/public/assets/{MobileCreateSessionSheet-DLq5qPkx.js → MobileCreateSessionSheet-CXSKMnYn.js} +1 -1
- package/dist/public/assets/MobileSheet-Gzc14EpR.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-DArgZI7L.js → MobileTopHeaderFrame-BWorAJ1C.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-0ywJKfBQ.js → MobileWorkspaceSwitcherHeader-DOr4pTUq.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-izoYMx9U.js → ServerSettingsModal-BYB0GvTl.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-C5aG8FIv.js → SessionIndexPage-CR3IARXX.js} +1 -1
- package/dist/public/assets/SettingsPage-B_BQtnwE.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-PQ-EM64j.js +1 -0
- package/dist/public/assets/{TerminalPage-CtKXIU0h.js → TerminalPage-CvnHXBhw.js} +12 -12
- package/dist/public/assets/{TerminalRuntimeFallbackModal-CRhOQOsT.js → TerminalRuntimeFallbackModal-D7Aq186N.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-DcYPsS-e.js → ToolFilesPage-Qzkc6K2I.js} +1 -1
- package/dist/public/assets/{ToolGitPage-CsPl89ty.js → ToolGitPage-BdNDN-cV.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-D0dvR8xK.js → ToolProcessesPage-EXJ9DHWI.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-4fP-KRiv.js → ToolsHomePage-CjF3CWzR.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-kvlfyxRo.js → WorkbenchLandingPage-DZPk4SmX.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-rwQib5In.js +3 -0
- package/dist/public/assets/{WorkbenchModal-Ctob14VR.js → WorkbenchModal-B09hC9b5.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-Cerk5uK7.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-DsW4mBTX.css +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-Com5kEXJ.js → WorkspaceDebugDetailPage-Bcq8s-Ma.js} +1 -1
- package/dist/public/assets/WorkspaceDetailPage-DNAa8pKr.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-BoiLuACV.js +1 -0
- package/dist/public/assets/client-runtime-manager-CRQ-F5d2.js +1 -0
- package/dist/public/assets/{default-session-permission-mode-CcGwR4Kk.js → default-session-permission-mode-D0wZ9Jek.js} +1 -1
- package/dist/public/assets/{file-tree-icon-UFVoVzhM.js → file-tree-icon-Dp_xhVfD.js} +14 -14
- package/dist/public/assets/index-C2G8Gmf1.js +42 -0
- package/dist/public/assets/{index-_52jxu4a.css → index-CpPTUeA3.css} +1 -1
- package/dist/public/assets/{preferences-service-KIYeE2gk.js → preferences-service-gOt2ZjKZ.js} +1 -1
- package/dist/public/assets/{session-runtime-machine-0KNSSPp5.js → session-runtime-machine-Dq3pW-UF.js} +8 -8
- package/dist/public/assets/{terminal-runtime-meta-AWXJpN4r.js → terminal-runtime-meta-BMT-rSEe.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-DBDRdptr.js → useRegisteredDebugTemplates-zMcEOGca.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/modules/client/client-controller.js +1 -1
- package/dist/server/modules/client/client-controller.js.map +1 -1
- package/dist/server/modules/client/client-service.d.ts +16 -2
- package/dist/server/modules/client/client-service.js +21 -3
- package/dist/server/modules/client/client-service.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +2 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +203 -8
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
- package/dist/server/modules/workbench/snapshot-revision.d.ts +4 -0
- package/dist/server/modules/workbench/snapshot-revision.js +13 -0
- package/dist/server/modules/workbench/snapshot-revision.js.map +1 -0
- package/dist/server/modules/workbench/workbench-service.d.ts +1 -0
- package/dist/server/modules/workbench/workbench-service.js +3 -2
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +6 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +10 -8
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/server/create-server.js +1 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/types/domain.d.ts +9 -0
- package/dist/server/ws/workbench-ws-hub.js +135 -33
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/AdaptiveButlerPage-R-XZw7pd.js +0 -3
- package/dist/public/assets/App-DkvE5EyM.js +0 -30
- package/dist/public/assets/FileContextPanel-D_ghXJuW.js +0 -1
- package/dist/public/assets/GitSidebar-D9f9Jxwr.js +0 -6
- package/dist/public/assets/MobileSheet-DLg-gX1t.js +0 -1
- package/dist/public/assets/SettingsPage-HJIC-P-4.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-DpyUTo9k.js +0 -1
- package/dist/public/assets/WorkbenchLayout-ByFw4eeu.js +0 -3
- package/dist/public/assets/WorkbenchShellRoute-BUITtdAg.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-Kw7JEZI3.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-D0Lrx4Uz.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-wR8d3aP9.js +0 -1
- package/dist/public/assets/index-Byp9hJ0c.js +0 -42
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var kr=Object.defineProperty;var Cr=(e,t,n)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var de=(e,t,n)=>Cr(e,typeof t!="symbol"?t+"":t,n);import{t as i,j as s,b as u,u as jr,C as Ht,a as Ln,m as Pn,D as wr,B as Nr,E as Sr}from"./index-Byp9hJ0c.js";import{d as gt,e as vt,f as on}from"./App-DkvE5EyM.js";import{e as Tr,O as Rr,P as Mr,Q as Ar,l as Kt,a as os,J as Lr,R as Pr,T as Ir,U as Er,V as Br,m as Or,n as _r,M as qr,i as Wr,j as In,W as Fr,X as Ur,Y as zr}from"./MobileSheet-DLg-gX1t.js";import{W as Mt,D as ls}from"./WorkbenchModal-Ctob14VR.js";import{u as cs,ad as Dr,a1 as $r}from"./WorkbenchLayout-ByFw4eeu.js";import{M as Hr,r as Kr}from"./file-tree-icon-UFVoVzhM.js";function Vt(e,t){if(!e)return{allowed:!1,hidden:!1,reason:i("conversation.capabilityDenied")};switch(t){case"send_message":return e.canSendMessage===!1?{allowed:!1,hidden:!1,reason:i("conversation.capabilitySendDisabled")}:{allowed:!0,hidden:!1,reason:null};case"attachments":return e.supportsAttachments?{allowed:!0,hidden:!1,reason:null}:{allowed:!1,hidden:!1,reason:i("conversation.capabilityAttachmentDisabled")};case"interrupt":return e.supportsInterrupt?{allowed:!0,hidden:!1,reason:null}:{allowed:!1,hidden:!1,reason:i("conversation.capabilityInterruptDisabled")};default:return{allowed:!1,hidden:!1,reason:i("conversation.capabilityDenied")}}}const Vr=new Set(["updateplan"]),us=new Set(["todowrite"]),tn=new Set(["todoread"]),ds=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function Gr(e,t){const n=Zr(e,t);return n||Jr(e,t)}function ms(e){return e.reduce((t,n)=>(t[n.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function Qr(e,t,n){if(!e)return null;if(nn(e.name)){const l=Ve(e);if(!l||!qt(l.value))return null;const d=ps(l.value,n);return!d||d.items.length===0?null:{provider:t,source:"plan",explanation:d.explanation,items:d.items,updatedAt:n}}const r=_t(e.name);if(!us.has(r)&&!tn.has(r)&&!ds.has(r))return null;const a=Ve(e,(tn.has(r),"prefer-output"));if(!a)return null;if(r==="taskdelete"||r==="taskremove"){const l=fs(a.value);return l.length>0?{provider:t,source:"todo",explanation:null,items:l.map((d,m)=>({id:d,title:`Task ${m+1}`,status:"cancelled",detail:d,updatedAt:n})),updatedAt:n}:null}const o=rt(a.value,n);return o.length===0?null:{provider:t,source:nn(e.name)?"plan":"todo",explanation:null,items:o,updatedAt:n}}function Zr(e,t){let n=null;for(const r of e){const a=r.toolCall;if(!a||_t(a.name)===""||!nn(a.name))continue;const o=Ve(a);if(!o||typeof o.value!="object"||o.value===null)continue;const l=ps(o.value,r.timestamp);!l||l.items.length===0||(n={provider:t,source:"plan",explanation:l.explanation,items:l.items,updatedAt:r.timestamp})}return n}function Jr(e,t){const n=new Map;let r=null;for(const o of e){const l=o.toolCall;if(!l)continue;const d=_t(l.name);if(us.has(d)){const v=Ve(l),x=v?rt(v.value,o.timestamp):[];x.length>0&&(Gt(n,x),r=o.timestamp);continue}if(tn.has(d)){const v=Ve(l,"prefer-output"),x=v?rt(v.value,o.timestamp):[];x.length>0&&(Gt(n,x),r=o.timestamp);continue}if(!ds.has(d))continue;const m=Ve(l,"prefer-output");if(!m)continue;if(d==="tasklist"||d==="taskget"){const v=rt(m.value,o.timestamp);v.length>0&&(Gt(n,v),r=o.timestamp);continue}if(d==="taskdelete"||d==="taskremove"){const v=fs(m.value);if(v.length>0){for(const x of v)n.delete(x);r=o.timestamp}continue}const k=rt(m.value,o.timestamp);if(k.length!==0){for(const v of k)Xr(n,v);r=o.timestamp}}const a=Array.from(n.values()).sort((o,l)=>o.updatedAt.localeCompare(l.updatedAt)).map(o=>({...o}));return a.length===0||!r?null:{provider:t,source:"todo",explanation:null,items:a,updatedAt:r}}function nn(e){return Vr.has(_t(e))}function ps(e,t){const n=Array.isArray(e.plan)?e.plan:null;if(!n||n.length===0)return null;const r=n.map((a,o)=>hs(a,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${o+1}`,fallbackStatus:"pending",updatedAt:t})).filter(a=>a!==null);return r.length===0?null:{items:r,explanation:O(e.explanation)}}function Ve(e,t="prefer-input"){const n=t==="prefer-output"?[{text:e.output,source:"output"},{text:e.input,source:"input"}]:[{text:e.input,source:"input"},{text:e.output,source:"output"}];for(const r of n){const a=Yr(r.text);if(a!==null)return{value:a,source:r.source}}return null}function Yr(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=Nt(t);if(n!==null)return n;const r=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(r!=null&&r[1]){const m=Nt(r[1].trim());if(m!==null)return m}const a=t.indexOf("{"),o=t.lastIndexOf("}");if(a>=0&&o>a){const m=Nt(t.slice(a,o+1));if(m!==null)return m}const l=t.indexOf("["),d=t.lastIndexOf("]");return l>=0&&d>l?Nt(t.slice(l,d+1)):null}function Nt(e){try{return JSON.parse(e)}catch{return null}}function rt(e,t){return at(e).map((r,a)=>hs(r,{fallbackIdPrefix:"task",fallbackTitle:`Task ${a+1}`,fallbackStatus:"pending",updatedAt:t})).filter(r=>r!==null)}function at(e){if(Array.isArray(e))return e.flatMap(n=>at(n));if(!qt(e))return[];if(si(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const n of t){if(!(n in e))continue;const r=at(e[n]);if(r.length>0)return r}return Object.values(e).flatMap(n=>at(n))}function fs(e){const n=at(e).map(a=>sn(a)).filter(a=>a!==null);if(n.length>0)return n;if(!qt(e))return[];const r=sn(e);return r?[r]:[]}function hs(e,t){if(!qt(e))return null;const n=O(e.step)??O(e.title)??O(e.content)??O(e.task)??O(e.text)??O(e.name)??O(e.subject)??O(e.description)??t.fallbackTitle,r=sn(e)??ni(t.fallbackIdPrefix,n),a=ti(e,n);return{id:r,title:n,status:ei(e.status,t.fallbackStatus),detail:a,updatedAt:t.updatedAt}}function Xr(e,t){const n=e.get(t.id);if(!n){e.set(t.id,{...t});return}e.set(t.id,{id:n.id,title:t.title||n.title,status:t.status,detail:t.detail??n.detail,updatedAt:t.updatedAt})}function Gt(e,t){e.clear();for(const n of t)e.set(n.id,{...n})}function ei(e,t){var r;const n=(r=O(e))==null?void 0:r.toLowerCase().replace(/[\s-]+/g,"_");return n?["pending","todo","open","queued","not_started","created"].includes(n)?"pending":["in_progress","progress","active","doing","running","started"].includes(n)?"in_progress":["completed","complete","done","success","succeeded","finished","closed"].includes(n)?"completed":["failed","error","errored"].includes(n)?"failed":["cancelled","canceled","aborted","skipped"].includes(n)?"cancelled":t:t}function ti(e,t){const n=[O(e.detail),O(e.details),O(e.description),O(e.reason),O(e.summary),O(e.note),O(e.priority)].filter(r=>r!==null);for(const r of n)if(r!==t)return r;return null}function sn(e){return O(e.id)??O(e.taskId)??O(e.task_id)??O(e.uuid)??O(e.key)}function ni(e,t){return`${e}:${t.trim().toLowerCase()}`}function si(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>O(t)!==null)}function _t(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function ri(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("rect",{x:"7",y:"5",width:"9",height:"11",rx:"2.5"}),s.jsx("path",{d:"M5.5 12.5H5A2 2 0 0 1 3 10.5V5a2 2 0 0 1 2-2h5.5"})]})}function ii(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"6",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"14",r:"2.25"}),s.jsx("path",{d:"M8.4 5.7h2.2a2.7 2.7 0 0 1 2.7 2.7v1.2"}),s.jsx("path",{d:"M8.1 5.9l4.1 6.2"})]})}function tl(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M10 2.8l1.6 3.4 3.8.5-2.8 2.6.7 3.9-3.3-1.8-3.3 1.8.7-3.9-2.8-2.6 3.8-.5L10 2.8z"}),s.jsx("path",{d:"M15.8 13.3l.7 1.5 1.7.2-1.2 1.1.3 1.8-1.5-.8-1.5.8.3-1.8-1.2-1.1 1.7-.2.7-1.5z"})]})}function nl(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"14",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"10",cy:"14",r:"2.2"}),s.jsx("path",{d:"M8.2 5h3.6"}),s.jsx("path",{d:"M10 7.2v4.6"}),s.jsx("path",{d:"M7.3 6.8l1.7 4"}),s.jsx("path",{d:"M12.7 6.8l-1.7 4"})]})}function sl(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"4.5",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"10",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"15.5",cy:"10",r:"1.5"})]})}function ai(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M4.5 5.5h1.2"}),s.jsx("path",{d:"M8 5.5h7.5"}),s.jsx("path",{d:"M4.5 10h1.2"}),s.jsx("path",{d:"M8 10h7.5"}),s.jsx("path",{d:"M4.5 14.5h1.2"}),s.jsx("path",{d:"M8 14.5h7.5"}),s.jsx("path",{d:"M5.1 5.5l.5.5 1-1"}),s.jsx("circle",{cx:"5.1",cy:"10",r:".8",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M5.1 14.5l.5.5 1-1"})]})}const En={in_progress:0,failed:1,pending:2,completed:3,cancelled:4};function oi({provider:e,messages:t,variant:n="header"}){const[r,a]=u.useState(!1),o=u.useMemo(()=>Gr(t,e),[t,e]);if(!o||o.items.length===0)return null;const l=ms(o.items),d=l.in_progress||l.pending,m=d>0?d:o.items.length,k=[...o.items].sort((x,g)=>{const j=En[x.status]-En[g.status];return j!==0?j:x.updatedAt.localeCompare(g.updatedAt)}),v=n==="composer"?"conversation-task-progress-button composer-task-progress-button":"conversation-header-ai-button conversation-task-progress-button";return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:v,"data-variant":n,"aria-label":i("conversation.taskProgressButton",{count:o.items.length}),title:i("conversation.taskProgressButton",{count:o.items.length}),onClick:()=>{a(!0)},children:[s.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:s.jsx(ai,{})}),s.jsx("span",{className:"conversation-task-progress-badge",children:m})]}),s.jsx(Mt,{open:r,title:i("conversation.taskProgressModalTitle"),description:i("conversation.taskProgressModalDescription",{count:o.items.length}),className:"conversation-task-progress-modal",onClose:()=>{a(!1)},children:s.jsxs("div",{className:"conversation-task-progress-modal-body",children:[s.jsxs("div",{className:"conversation-task-progress-summary",children:[s.jsx(st,{label:i("conversation.taskProgressSummaryTotal"),value:o.items.length}),s.jsx(st,{label:i("conversation.taskProgressStatusInProgress"),value:l.in_progress}),s.jsx(st,{label:i("conversation.taskProgressStatusPending"),value:l.pending}),s.jsx(st,{label:i("conversation.taskProgressStatusCompleted"),value:l.completed}),l.failed>0?s.jsx(st,{label:i("conversation.taskProgressStatusFailed"),value:l.failed}):null]}),o.explanation?s.jsxs("div",{className:"conversation-task-progress-explanation",children:[s.jsx("strong",{children:i("conversation.taskProgressExplanationTitle")}),s.jsx("p",{children:o.explanation})]}):null,s.jsx("ol",{className:"conversation-task-progress-list",children:k.map(x=>s.jsxs("li",{className:"conversation-task-progress-item","data-status":x.status,children:[s.jsx("span",{className:"conversation-task-progress-item-indicator","data-status":x.status,"aria-hidden":"true"}),s.jsxs("div",{className:"conversation-task-progress-item-body",children:[s.jsxs("div",{className:"conversation-task-progress-item-header",children:[s.jsx("strong",{children:x.title}),s.jsx("span",{className:"conversation-task-progress-item-status",children:li(x.status)})]}),x.detail?s.jsx("p",{className:"conversation-task-progress-item-detail",children:x.detail}):null]})]},x.id))})]})})]})}function st({label:e,value:t}){return s.jsxs("div",{className:"conversation-task-progress-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function li(e){switch(e){case"in_progress":return i("conversation.taskProgressStatusInProgress");case"completed":return i("conversation.taskProgressStatusCompleted");case"failed":return i("conversation.taskProgressStatusFailed");case"cancelled":return i("conversation.taskProgressStatusCancelled");case"pending":default:return i("conversation.taskProgressStatusPending")}}const ci="codingns.conversation.composer-draft:",ui=1,di=[{id:"builtin-stage-and-summarize",text:"请将本次会话变更的所有代码提交到git暂存区,然后总结一条中文的提交信息"},{id:"builtin-review-module",text:"分析本项目 模块的代码实现,并分析存在的问题"},{id:"builtin-group-commits",text:"分析当前项目中的未提交文件,按照功能模块进行分类提交,提交信息格式请参考我最近的提交记录"}];function ln(){return typeof window<"u"&&typeof window.localStorage<"u"}function mi(e){if(!e||typeof e!="object")return null;const t="id"in e?e.id:null,n="fileName"in e?e.fileName:null,r="mimeType"in e?e.mimeType:null,a="fileSize"in e?e.fileSize:null,o="lastModified"in e?e.lastModified:null,l="contentBase64"in e?e.contentBase64:null;if(typeof t!="string"||typeof n!="string"||typeof r!="string"||typeof a!="number"||typeof o!="number"||typeof l!="string")return null;const d=t.trim(),m=n.trim(),k=r.trim(),v=l.trim();return!d||!m||!k||a<0||o<0||!v?null:{id:d,fileName:m,mimeType:k,fileSize:a,lastModified:o,contentBase64:v}}function pi(e){if(!e||typeof e!="object")return null;const t="content"in e?e.content:null,n="attachments"in e?e.attachments:null;if(typeof t!="string"||!Array.isArray(n))return null;const r=n.map(a=>mi(a)).filter(a=>a!==null);return r.length!==n.length||t.length===0&&r.length===0?null:{content:t,attachments:r}}function ot(e){return`${ci}${e}`}function fi(e){var t,n;return{id:((n=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:n.call(t))??`phrase-${Date.now()}-${Math.random().toString(16).slice(2)}`,text:e.trim()}}function hi(e){if(!ln())return null;const t=e.trim();if(!t)return null;const n=window.localStorage.getItem(ot(t));if(!n)return null;try{const r=JSON.parse(n),a=r&&typeof r=="object"&&"draft"in r&&r.draft&&typeof r.draft=="object"?r.draft:r,o=pi(a);return o||(window.localStorage.removeItem(ot(t)),null)}catch{return window.localStorage.removeItem(ot(t)),null}}function gi(e,t){if(!ln())return!1;const n=e.trim();if(!n)return!1;if(t.content.length===0&&t.attachments.length===0)return gs(n),!0;try{return window.localStorage.setItem(ot(n),JSON.stringify({schemaVersion:ui,draft:t})),!0}catch{return!1}}function gs(e){if(!ln())return;const t=e.trim();t&&window.localStorage.removeItem(ot(t))}const Bn="workbench:focus-composer",lt="provider-default",On=["codex","claude-code","opencode","gemini","kimi"],vi=new Set(["codex","claude-code","opencode"]),xi=new Set(["codex","claude-code","opencode"]),_n={position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0};function bi(e){return[{id:lt,name:i("conversation.modelUseCliDefault"),provider:e,usesProviderDefault:!0}]}function qn(e){return bi(e)}function Wn(e){return e.usesProviderDefault===!0||e.id===lt}function yi(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${Date.now()}-${Math.random().toString(16).slice(2)}`}function Fn(e){if(e){e.value="";try{const t=e.showPicker;if(typeof t=="function"){t.call(e);return}}catch{}e.click()}}function ki(e,t,n,r){const a=globalThis.atob(n),o=Uint8Array.from(a,l=>l.charCodeAt(0));return new File([o],e,{type:t,lastModified:r})}function Ci(e){return e.trim().toLowerCase().startsWith("image/")}function ct(e){const t=e.type.trim().toLowerCase();return t.length>0?t:"application/octet-stream"}function vs(e){return Ci(ct(e))?"image":"file"}function xs(e,t=yi()){const n=vs(e);return{id:t,file:e,kind:n,previewUrl:n==="image"?URL.createObjectURL(e):null}}function ji(e){const t=ki(e.fileName,e.mimeType,e.contentBase64,e.lastModified);return xs(t,e.id)}function wi(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ni(e){const t=e.trim().replace(/\s+/g," ");return t.length===0?i("conversation.forkDraftEmpty"):t.length>140?`${t.slice(0,140)}…`:t}function Si(e,t){return t===e?xi.has(t)?null:i("conversation.forkProviderNativeUnsupported"):vi.has(t)?null:i("conversation.forkProviderReconstructedUnsupported")}function bs(e){return(e==null?void 0:e.canStartSession)===!1}function Ti(e){return bs(e)?(e==null?void 0:e.limitations[0])??i("conversation.capabilityDenied"):null}function Ri(e,t){return{id:t,kind:vs(e),fileName:e.name,mimeType:ct(e),fileSize:e.size}}function Un(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error("FILE_READ_FAILED"))},r.onload=()=>{const a=typeof r.result=="string"?r.result:"",o=a.includes(",")?a.split(",").at(-1)??"":a;t(o)},r.readAsDataURL(e)})}function Mi(e){e.forEach(t=>{t.previewUrl&&URL.revokeObjectURL(t.previewUrl)})}function Ai(e,t){const n=new Set(e.map(a=>`${a.file.name}:${a.file.size}:${a.file.lastModified}`)),r=[...e];return t.forEach(a=>{const o=`${a.name}:${a.size}:${a.lastModified}`;n.has(o)||(n.add(o),r.push(xs(a)))}),r}function Li(e,t,n){const r=e.nativeEvent;return r.isComposing||r.keyCode===229||t||n}function rl({capabilities:e,placeholder:t,draftStorageId:n,forkDraft:r=null,onClearForkDraft:a,onForkDraftChange:o,panelRef:l,portalContainer:d=null,hasActiveRun:m=null,canInterrupt:k=null,contextUsage:v=null,taskProvider:x=null,taskMessages:g=[],hasPendingQueuedMessages:j=!1,isSubmitting:b,isRunning:f=!1,onInterrupt:C,onQueueSend:T,onSend:M}){const R=gt(),I=u.useId(),D=u.useId(),[A,F]=u.useState(""),[L,$]=u.useState(""),[H,X]=u.useState("medium"),[U,K]=u.useState([]),[Ee,se]=u.useState(!1),[Be,me]=u.useState(!1),[G,ae]=u.useState(di),[re,ke]=u.useState(!1),[xt,pe]=u.useState(!1),[Oe,bt]=u.useState(""),[Ce,fe]=u.useState(!1),[he,ee]=u.useState(!1),[Qe,Ze]=u.useState(!1),[Je,je]=u.useState(!1),[Ye,Q]=u.useState(null),[_e,we]=u.useState(!1),[Ne,oe]=u.useState({}),[ge,qe]=u.useState(null),Se=u.useRef(null),Xe=u.useRef(null),yt=u.useRef(null),We=u.useRef(!1),Fe=u.useRef(!1),p=u.useRef(!1),N=u.useRef(null),E=u.useRef(new Set),Z=u.useRef(new Map),V=u.useRef(0),{showToast:Te}=vt(),Re=Tr(),Ue=u.useCallback(()=>{N.current!==null&&(globalThis.clearTimeout(N.current),N.current=null),p.current=!1},[]);u.useEffect(()=>Ue,[Ue]);const Y=Rr(e),le=jr(c=>Ht(Y)?c.profile.providers[Y]:null),et=(le==null?void 0:le.defaultModel)??null,tt=(le==null?void 0:le.defaultReasoningLevel)??null,Wt=u.useMemo(()=>Vt(e,"send_message"),[e]),fn=u.useMemo(()=>Vt(e,"interrupt"),[e]),te=u.useMemo(()=>Vt(e,"attachments"),[e]),ce=u.useMemo(()=>{var h;const c=(h=e==null?void 0:e.modelOptions)==null?void 0:h.map(y=>{var w;return{...y,provider:Y,supportedReasoningEfforts:(w=y.supportedReasoningEfforts)==null?void 0:w.filter(_=>_==="low"||_==="medium"||_==="high"||_==="xhigh")}});return c!=null&&c.length?c:qn(Y)},[e==null?void 0:e.modelOptions,Y]),ue=u.useMemo(()=>ce.find(c=>c.id===L)??null,[ce,L]),kt=Mr(e),Vs=Ar(e),Ft=u.useMemo(()=>[{value:"low",label:i("conversation.reasoningLow")},{value:"medium",label:i("conversation.reasoningMedium")},{value:"high",label:i("conversation.reasoningHigh")},{value:"xhigh",label:i("conversation.reasoningMaximum")}],[]),ie=u.useMemo(()=>{if(!kt)return[];const c=ue==null?void 0:ue.supportedReasoningEfforts;return!c||c.length===0?Ft:Ft.filter(h=>c.includes(h.value))},[kt,Ft,ue==null?void 0:ue.supportedReasoningEfforts]),Gs=u.useMemo(()=>ce.map(c=>({value:c.id,label:Wn(c)?i("conversation.modelUseCliDefault"):c.name})),[ce]),Qs=u.useMemo(()=>ie.map(c=>({value:c.value,label:c.label})),[ie]),Zs=u.useMemo(()=>[{command:"/plan",label:i("conversation.slashCommandPlan")},{command:"/review",label:i("conversation.slashCommandReview")},{command:"/explain",label:i("conversation.slashCommandExplain")}],[]),hn=(e==null?void 0:e.inRunInputMode)??"none",ve=!!r,Js=(r==null?void 0:r.targetProvider)??null,Ct=!!r&&(e==null?void 0:e.provider)===Js,xe=u.useMemo(()=>r?Ct?e:Ye??Kt(r.targetProvider):null,[e,Ye,r,Ct]),ze=u.useMemo(()=>{var h;if(!r)return[];const c=(h=xe==null?void 0:xe.modelOptions)==null?void 0:h.map(y=>{var w;return{...y,provider:r.targetProvider,supportedReasoningEfforts:(w=y.supportedReasoningEfforts)==null?void 0:w.filter(_=>_==="low"||_==="medium"||_==="high"||_==="xhigh")}});return c!=null&&c.length?c:qn(r.targetProvider)},[xe==null?void 0:xe.modelOptions,r]),Ys=u.useMemo(()=>ze.map(c=>({value:c.id,label:Wn(c)?i("conversation.modelUseCliDefault"):c.name})),[ze]),Xs=u.useMemo(()=>!r||!r.targetModel?lt:ze.some(c=>c.id===r.targetModel)?r.targetModel:lt,[ze,r]),Me=u.useMemo(()=>r?On.filter(c=>Si(r.sourceProvider,c)!==null?!1:!bs(Ne[c]??null)):[],[r,Ne]),gn=u.useMemo(()=>r?Me.length>0?Me:[r.targetProvider]:[],[r,Me]),er=u.useMemo(()=>gn.map(c=>({value:c,label:os(c,"full")})),[gn]),jt=u.useMemo(()=>r?Ti(Ne[r.targetProvider]??xe??null):null,[xe,r,Ne]),Ut=m??null,be=f||Ut===!0,tr=be&&hn==="streaming_guidance"&&Ut===!1&&!Lr(e),vn=!ve&&be&&hn==="streaming_guidance"&&!tr,zt=!ve&&be&&typeof T=="function"&&Pr(e,Ut),J=!ve&&be&&!vn&&!zt,Dt=ve&&!!jt,xn=A.trim().length>0||U.length>0,bn=k===!1&&be?fn.allowed:k??fn.allowed,$t=be&&bn&&!!C&&!Qe,nr=!xn&&(Je||b||be||j),yn=$t?i("conversation.capabilityInterrupt"):i("conversation.runtimeRunning"),kn=be?zt?i("conversation.queueGuidanceButton"):vn?i("conversation.sendGuidanceButton"):i("conversation.sendButton"):i("conversation.sendButton"),sr=u.useCallback(c=>{$(c),Ht(Y)&&Ln({providers:{[Y]:{defaultModel:c}}}).catch(()=>{})},[Y]),rr=u.useCallback(c=>{X(c),Ht(Y)&&Ln({providers:{[Y]:{defaultReasoningLevel:c}}}).catch(()=>{})},[Y]),wt=u.useCallback(c=>{E.current.forEach(h=>{URL.revokeObjectURL(h)}),E.current.clear(),c.forEach(h=>{h.previewUrl&&E.current.add(h.previewUrl)}),K(c)},[]),nt=u.useCallback(c=>{c.length!==0&&K(h=>{const y=Ai(h,c);return y.forEach(w=>{w.previewUrl&&E.current.add(w.previewUrl)}),y})},[]),ir=u.useCallback(c=>{Z.current.delete(c),K(h=>{const y=h.find(w=>w.id===c);return y!=null&&y.previewUrl&&(E.current.delete(y.previewUrl),URL.revokeObjectURL(y.previewUrl)),h.filter(w=>w.id!==c)})},[]),Cn=u.useCallback(c=>{const h=Array.from(c.target.files??[]);h.length>0&&nt(h),c.target.value=""},[nt]),ar=u.useCallback(c=>{var y;R.isMobile||!te.allowed||J||!((((y=c.dataTransfer.files)==null?void 0:y.length)??0)>0||Array.from(c.dataTransfer.items??[]).some(w=>w.kind==="file"))||(c.preventDefault(),c.dataTransfer.dropEffect="copy",Be||me(!0),ee(!1))},[te.allowed,Be,J,R.isMobile]),or=u.useCallback(c=>{const h=c.relatedTarget;h instanceof Node&&c.currentTarget.contains(h)||me(!1)},[]),lr=u.useCallback(c=>{if(R.isMobile||!te.allowed||J)return;const h=Array.from(c.dataTransfer.files??[]);h.length!==0&&(c.preventDefault(),me(!1),nt(h))},[te.allowed,J,nt,R.isMobile]),jn=u.useCallback(c=>{if(!te.allowed||J)return;const h=c==="camera"?yt.current:Xe.current;Fn(h),se(!1)},[te.allowed,J]),cr=u.useCallback(()=>{if(!(!te.allowed||J)){if(ee(!1),R.isNativeMobile){Re.trigger("selection"),se(!0);return}Fn(Xe.current)}},[te.allowed,Re,J,R.isNativeMobile]),ur=u.useCallback(()=>{ee(c=>!c)},[]),dr=u.useCallback(c=>{var h;F(y=>y.trimStart().startsWith(c)?y:y.trim()?`${c} ${y.trim()}`:`${c} `),ee(!1),(h=Se.current)==null||h.focus()},[]),De=u.useCallback(async c=>{const h=G;V.current+=1,ae(c),fe(!0);try{const y=await Ir(c.map(w=>({id:w.id,text:w.text})));return ae(y.items.map(w=>({id:w.id,text:w.text}))),!0}catch(y){return ae(h),Te({title:y instanceof Error?y.message:i("conversation.quickPhraseSaveFailed"),tone:"error"}),!1}finally{fe(!1)}},[G,Te]),mr=u.useCallback(async()=>{const c=Oe.trim();!c||!await De([...G,fi(c)])||(bt(""),pe(!1))},[De,Oe,G]),pr=u.useCallback(c=>{De(G.filter(h=>h.id!==c))},[De,G]),wn=u.useCallback((c,h)=>{const y=G.findIndex(W=>W.id===c);if(y<0)return;const w=y+h;if(w<0||w>=G.length)return;const _=[...G],[q]=_.splice(y,1);_.splice(w,0,q),De(_)},[De,G]),fr=u.useCallback(c=>{var h;F(c),ke(!1),(h=Se.current)==null||h.focus()},[]),Nn=u.useCallback(c=>{const h=c?hi(c):null,y=(h==null?void 0:h.attachments.map(w=>ji(w)))??[];Z.current=new Map(((h==null?void 0:h.attachments)??[]).map(w=>[w.id,w])),wt(y),F((h==null?void 0:h.content)??""),ee(!1)},[wt]);u.useEffect(()=>{if(!ce.length)return;if(et&&ce.some(h=>h.id===et)){L!==et&&$(et);return}if(ce.some(h=>h.id===L))return;const c=ce[0].id;$(c)},[ce,Y,L,et]),u.useEffect(()=>{if(!Er(Y)||ie.length===0)return;if(tt&&ie.some(y=>y.value===tt)){H!==tt&&X(tt);return}const c=e==null?void 0:e.defaultReasoningLevel;if(c&&ie.some(y=>y.value===c)){H!==c&&X(c);return}if(ie.some(y=>y.value===H))return;const h=ie[0].value;X(h)},[ie,e==null?void 0:e.defaultReasoningLevel,Y,H,tt]),u.useEffect(()=>{let c=!1;const h=V.current;return Br().then(y=>{c||V.current!==h||ae(y.items.map(w=>({id:w.id,text:w.text})))}).catch(()=>{}),()=>{c=!0}},[]),u.useEffect(()=>{Nn(n)},[n,Nn]),u.useEffect(()=>{if(!n)return;const c=n,h=new Set(U.map(_=>_.id));Z.current.forEach((_,q)=>{h.has(q)||Z.current.delete(q)});let y=!1;async function w(){if(A.length===0&&U.length===0){gs(c);return}const _=await Promise.all(U.map(async q=>{const W=Z.current.get(q.id);return W&&W.fileName===q.file.name&&W.fileSize===q.file.size&&W.lastModified===q.file.lastModified&&W.mimeType===ct(q.file)?W:{id:q.id,fileName:q.file.name,mimeType:ct(q.file),fileSize:q.file.size,lastModified:q.file.lastModified,contentBase64:await Un(q.file)}}));y||(Z.current=new Map(_.map(q=>[q.id,q])),gi(c,{content:A,attachments:_}))}return w(),()=>{y=!0}},[U,A,n]),u.useEffect(()=>{const c=Se.current;c&&(c.style.height="0px",c.style.height=`${Math.min(c.scrollHeight,120)}px`)},[A]),u.useEffect(()=>{te.allowed||(Z.current.clear(),se(!1),wt([]))},[te.allowed,wt]),u.useEffect(()=>{R.isMobile||se(!1)},[R.isMobile]),u.useEffect(()=>()=>{E.current.forEach(c=>{URL.revokeObjectURL(c)}),E.current.clear()},[]),u.useEffect(()=>{function c(){var h;(h=Se.current)==null||h.focus()}return window.addEventListener(Bn,c),()=>{window.removeEventListener(Bn,c)}},[]),u.useEffect(()=>{if(!r){Q(null),we(!1),oe({}),qe(null);return}if(Ct){Q(null),we(!1);return}let c=!1;return Q(Kt(r.targetProvider)),we(!0),Or(r.targetProvider,r.workspaceId).then(h=>{c||Q(h)}).catch(()=>{c||Q(Kt(r.targetProvider))}).finally(()=>{c||we(!1)}),()=>{c=!0}},[r==null?void 0:r.targetProvider,r==null?void 0:r.workspaceId,Ct]),u.useEffect(()=>{if(!r){oe({});return}let c=!1;return _r(On,r.workspaceId).then(h=>{c||oe(h)}),()=>{c=!0}},[r==null?void 0:r.workspaceId]),u.useEffect(()=>{!r||!o||Me.length!==0&&(Me.includes(r.targetProvider)||o({...r,targetProvider:Me[0]??r.targetProvider,targetModel:null}))},[r,o,Me]),u.useEffect(()=>{!r||!r.targetModel||!o||ze.some(c=>c.id===r.targetModel)||o({...r,targetModel:null})},[ze,r,o]);const hr=u.useCallback(c=>{if(!(!r||!o||c===r.targetProvider)){if(c!==r.sourceProvider&&r.targetProvider===r.sourceProvider){qe(c);return}o({...r,targetProvider:c,targetModel:null})}},[r,o]),gr=u.useCallback(c=>{!r||!o||o({...r,targetModel:c===lt?null:c})},[r,o]),vr=u.useCallback(()=>{!r||!ge||!o||(o({...r,targetProvider:ge,targetModel:null}),qe(null))},[r,o,ge]),Sn=u.useCallback(()=>{qe(null)},[]);async function xr(c){if(We.current)return;const h=A.trim(),y=U;if(h.length===0&&y.length===0||!Wt.allowed||J||Dt){Te({title:J?i("conversation.runtimeRunning"):jt??Wt.reason??i("conversation.capabilityDenied"),tone:"error"});return}We.current=!0,Re.trigger(c==="queue"?"selection":"action"),je(!0),F(""),K([]),se(!1),me(!1),ke(!1),pe(!1),ee(!1);try{const w=await Promise.all(y.map(async W=>({kind:W.kind,fileName:W.file.name,mimeType:ct(W.file),fileSize:W.file.size,contentBase64:await Un(W.file)}))),_=y.map(W=>Ri(W.file,W.id));await(c==="queue"&&T?T:M)(h,{model:ve||ue!=null&&ue.usesProviderDefault?void 0:L||void 0,reasoningLevel:ve?void 0:kt&&ie.length>0?H:void 0,attachments:w,attachmentMeta:_}),Mi(y),y.forEach(W=>{W.previewUrl&&E.current.delete(W.previewUrl)})}catch(w){F(h),K(y),Te({title:w instanceof Error&&w.message==="FILE_READ_FAILED"?i("conversation.attachmentReadFailed"):w instanceof Error?w.message:i("conversation.capabilityDenied"),tone:"error"})}finally{je(!1),We.current=!1}}async function Tn(c){c.preventDefault(),await xr(zt?"queue":"send")}async function br(){if(!(!bn||!C||Qe))try{Ze(!0),Re.trigger("action"),await C()}catch(c){Te({title:c instanceof Error?c.message:i("conversation.capabilityInterruptDisabled"),tone:"error"})}finally{Ze(!1)}}const Rn=Je||b||J||Dt||!Wt.allowed||!xn,Mn=Je||b||J||!te.allowed,yr=A.length===0&&!J,An=s.jsxs("section",{ref:l,className:"composer-panel",children:[s.jsxs("form",{className:"composer-form",onSubmit:Tn,children:[s.jsx("input",{id:I,ref:Xe,type:"file",multiple:!0,tabIndex:-1,"aria-hidden":"true",style:_n,onChange:Cn}),s.jsx("input",{id:D,ref:yt,type:"file",accept:"image/*",capture:"environment",tabIndex:-1,"aria-hidden":"true",style:_n,onChange:Cn}),s.jsxs("div",{className:"composer-input-container","data-drag-active":Be?"true":void 0,onDragOver:ar,onDragLeave:or,onDrop:lr,children:[r?s.jsxs("div",{className:"composer-fork-draft",children:[s.jsxs("div",{className:"composer-fork-draft-main",children:[s.jsxs("div",{className:"composer-fork-draft-copy",children:[s.jsx("span",{className:"composer-fork-draft-label",children:i("conversation.forkDraftLabel")}),s.jsx("span",{className:"composer-fork-draft-text",children:Ni(r.content)})]}),s.jsxs("div",{className:"composer-fork-config",children:[s.jsxs("div",{className:"composer-fork-config-grid",children:[s.jsxs("div",{className:"composer-fork-field",children:[s.jsx("span",{className:"composer-fork-model-label",children:i("conversation.forkTargetProviderLabel")}),s.jsx(St,{ariaLabel:i("conversation.forkTargetProviderLabel"),value:r.targetProvider,options:er,onChange:c=>hr(c),compact:!0})]}),s.jsxs("div",{className:"composer-fork-field",children:[s.jsx("span",{className:"composer-fork-model-label",children:i("conversation.forkTargetModelLabel")}),s.jsx(St,{ariaLabel:i("conversation.forkTargetModelLabel"),value:Xs,options:Ys,onChange:gr,disabled:_e||Dt,compact:!0})]})]}),jt?s.jsx("p",{className:"composer-capability-hint",children:jt}):null]})]}),a?s.jsx("button",{type:"button",className:"composer-fork-draft-clear","aria-label":i("conversation.forkDraftClear"),title:i("conversation.forkDraftClear"),onClick:a,children:s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):null]}):null,U.length>0?s.jsx("div",{className:"composer-attachments",children:U.map(c=>s.jsxs("div",{className:"composer-attachment-card",children:[c.previewUrl?s.jsx("img",{src:c.previewUrl,alt:i("conversation.attachmentPreviewAlt"),className:"composer-attachment-preview"}):s.jsx("div",{className:"composer-attachment-file","aria-hidden":"true",children:s.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),s.jsx("path",{d:"M14 2v5h5"}),s.jsx("path",{d:"M9 13h6"}),s.jsx("path",{d:"M9 17h6"})]})}),s.jsxs("div",{className:"composer-attachment-meta",children:[s.jsx("span",{className:"attachment-name",title:c.file.name,children:c.file.name}),s.jsx("span",{className:"attachment-size",children:wi(c.file.size)})]}),s.jsx("button",{type:"button",className:"attachment-remove",onClick:()=>ir(c.id),"aria-label":i("conversation.removeAttachment"),children:s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},c.id))}):null,Be?s.jsx("div",{className:"composer-drop-hint",children:i("conversation.attachmentDropHint")}):null,s.jsxs("div",{className:"composer-input-wrapper",children:[s.jsx("textarea",{ref:Se,className:"composer-input",value:A,placeholder:t??i("conversation.composerPlaceholder"),readOnly:J,"aria-readonly":J,onChange:c=>F(c.target.value),rows:1,onFocus:()=>ee(!1),onCompositionStart:()=>{Ue(),Fe.current=!0},onCompositionEnd:()=>{Fe.current=!1,p.current=!0,N.current=globalThis.setTimeout(()=>{p.current=!1,N.current=null},0)},onPaste:c=>{if(J||!te.allowed)return;const h=Array.from(c.clipboardData.items).filter(y=>y.kind==="file").map(y=>y.getAsFile()).filter(y=>!!y);h.length!==0&&(c.preventDefault(),nt(h))},onKeyDown:c=>{if(c.key==="Escape"&&ee(!1),c.key==="Enter"&&!c.shiftKey){if(Li(c,Fe.current,p.current))return;c.preventDefault(),Rn||Tn(c)}}}),s.jsx("div",{className:"composer-input-actions",children:nr?s.jsx("button",{className:"composer-send composer-send-busy",type:"button",disabled:!$t,onClick:()=>{$t&&br()},"aria-label":yn,title:yn,children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("rect",{x:"6",y:"6",width:"12",height:"12"})})}):s.jsx("button",{className:"composer-send",type:"submit",disabled:Rn,"aria-label":kn,title:kn,children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[s.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),s.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})})]}),he?s.jsx("div",{className:"composer-slash-menu",role:"menu","aria-label":i("conversation.slashMenuTitle"),children:Zs.map(c=>s.jsxs("button",{type:"button",className:"composer-slash-item",onClick:()=>dr(c.command),children:[s.jsx("span",{className:"composer-slash-command",children:c.command}),s.jsx("span",{className:"composer-slash-label",children:c.label})]},c.command))}):null,s.jsxs("div",{className:"composer-controls",children:[s.jsxs("div",{className:"composer-controls-left",children:[te.allowed?R.isNativeMobile?s.jsx("button",{type:"button",className:"composer-attach-btn","aria-label":i("conversation.attachFiles"),title:i("conversation.attachFiles"),disabled:Mn,onClick:cr,children:s.jsx(Qt,{})}):Mn?s.jsx("button",{type:"button",className:"composer-attach-btn","aria-label":i("conversation.attachFiles"),title:i("conversation.attachFiles"),disabled:!0,children:s.jsx(Qt,{})}):s.jsx("label",{htmlFor:I,className:"composer-attach-btn","aria-label":i("conversation.attachFiles"),title:i("conversation.attachFiles"),onClick:()=>{ee(!1)},children:s.jsx(Qt,{})}):null,ve?null:s.jsx(St,{ariaLabel:i("conversation.modelSelectorLabel"),value:L,options:Gs,onChange:sr}),!ve&&kt&&ie.length>0?s.jsx(St,{ariaLabel:i("conversation.reasoningSelectorLabel"),value:H,options:Qs,onChange:c=>rr(c),compact:!0}):null,Vs?s.jsxs("button",{type:"button",className:"composer-slash-btn",onClick:ur,title:i("conversation.slashMenu"),children:[s.jsx("span",{className:"slash-icon",children:"/"}),s.jsx("span",{children:i("conversation.slashMenu")})]}):null,s.jsx(qi,{contextUsage:v}),s.jsx(oi,{provider:x,messages:g,variant:"composer"})]}),yr?s.jsx("div",{className:"composer-quick-phrase-group",children:s.jsx("button",{type:"button",className:"composer-quick-phrase-trigger","aria-label":i("conversation.quickPhraseTrigger"),title:i("conversation.quickPhraseTrigger"),onClick:()=>{ke(!0),ee(!1)},children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M7 8h10"}),s.jsx("path",{d:"M7 12h8"}),s.jsx("path",{d:"M7 16h5"}),s.jsx("path",{d:"M5 5h14v14H9l-4 4V5z"})]})})}):null]})]})]}),s.jsx(Mt,{open:re,title:i("conversation.quickPhraseModalTitle"),description:i("conversation.quickPhraseModalDescription"),className:"composer-quick-phrase-modal",onClose:()=>{ke(!1),pe(!1)},children:s.jsxs("div",{className:"composer-quick-phrase-modal-body",children:[s.jsxs("div",{className:"composer-quick-phrase-toolbar",children:[s.jsx("div",{className:"composer-quick-phrase-toolbar-copy",children:s.jsx("span",{children:i("conversation.quickPhraseListLabel")})}),s.jsx("button",{type:"button",className:"primary-button",disabled:Ce,onClick:()=>pe(!0),children:i("conversation.quickPhraseOpenCreateAction")})]}),s.jsx("div",{className:"composer-quick-phrase-list",role:"list","aria-label":i("conversation.quickPhraseListLabel"),children:G.length===0?s.jsx("div",{className:"composer-quick-phrase-empty",children:i("conversation.quickPhraseEmpty")}):G.map((c,h)=>s.jsxs("div",{className:"composer-quick-phrase-item",role:"listitem",children:[s.jsxs("button",{type:"button",className:"composer-quick-phrase-select",onClick:()=>fr(c.text),children:[s.jsx("span",{className:"composer-quick-phrase-order",children:i("conversation.quickPhraseOrderLabel",{index:h+1})}),s.jsx("span",{className:"composer-quick-phrase-text",children:c.text})]}),s.jsxs("div",{className:"composer-quick-phrase-actions",children:[s.jsx("button",{type:"button",className:"composer-quick-phrase-action",disabled:Ce||h===0,"aria-label":i("conversation.quickPhraseMoveUp"),title:i("conversation.quickPhraseMoveUp"),onClick:()=>wn(c.id,-1),children:"↑"}),s.jsx("button",{type:"button",className:"composer-quick-phrase-action",disabled:Ce||h===G.length-1,"aria-label":i("conversation.quickPhraseMoveDown"),title:i("conversation.quickPhraseMoveDown"),onClick:()=>wn(c.id,1),children:"↓"}),s.jsx("button",{type:"button",className:"composer-quick-phrase-action is-danger",disabled:Ce,"aria-label":i("conversation.quickPhraseDelete"),title:i("conversation.quickPhraseDelete"),onClick:()=>pr(c.id),children:"×"})]})]},c.id))})]})}),s.jsx(Mt,{open:xt,title:i("conversation.quickPhraseCreateModalTitle"),description:i("conversation.quickPhraseCreateModalDescription"),className:"composer-quick-phrase-create-modal",onClose:()=>pe(!1),children:s.jsxs("div",{className:"composer-quick-phrase-modal-body",children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:i("conversation.quickPhraseCreateLabel")}),s.jsx("textarea",{className:"composer-quick-phrase-textarea",value:Oe,placeholder:i("conversation.quickPhraseCreatePlaceholder"),rows:4,onChange:c=>bt(c.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>pe(!1),children:i("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:Ce||Oe.trim().length===0,onClick:()=>{mr()},children:i("conversation.quickPhraseCreateAction")})]})]})}),s.jsx(Mt,{open:ge!==null,title:i("conversation.forkSwitchConfirmTitle"),description:i("conversation.forkSwitchConfirmDescription"),className:"composer-fork-confirm-modal",onClose:Sn,children:s.jsxs("div",{className:"composer-fork-confirm-body",children:[s.jsxs("div",{className:"composer-fork-confirm-list",children:[s.jsxs("div",{className:"composer-fork-confirm-item",children:[s.jsx("span",{className:"composer-fork-confirm-icon is-keep","aria-hidden":"true",children:s.jsx(Bi,{})}),s.jsxs("div",{className:"composer-fork-confirm-copy",children:[s.jsx("strong",{children:i("conversation.forkSwitchConfirmKeepTitle")}),s.jsx("p",{children:i("conversation.forkSwitchConfirmKeepBody")})]})]}),s.jsxs("div",{className:"composer-fork-confirm-item",children:[s.jsx("span",{className:"composer-fork-confirm-icon is-convert","aria-hidden":"true",children:s.jsx(Oi,{})}),s.jsxs("div",{className:"composer-fork-confirm-copy",children:[s.jsx("strong",{children:i("conversation.forkSwitchConfirmConvertTitle")}),s.jsx("p",{children:i("conversation.forkSwitchConfirmConvertBody")})]})]}),s.jsxs("div",{className:"composer-fork-confirm-item",children:[s.jsx("span",{className:"composer-fork-confirm-icon is-drop","aria-hidden":"true",children:s.jsx(_i,{})}),s.jsxs("div",{className:"composer-fork-confirm-copy",children:[s.jsx("strong",{children:i("conversation.forkSwitchConfirmDropTitle")}),s.jsx("p",{children:i("conversation.forkSwitchConfirmDropBody")})]})]})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",onClick:Sn,children:i("conversation.forkSwitchKeepNative")}),s.jsx("button",{type:"button",className:"primary-button",onClick:vr,children:i("conversation.forkSwitchConfirmAction")})]})]})}),s.jsx(Pi,{open:Ee&&R.isNativeMobile,onClose:()=>se(!1),onSelectCamera:()=>jn("camera"),onSelectLibrary:()=>jn("library")})]});return d?on.createPortal(An,d):An}function Pi({open:e,onClose:t,onSelectCamera:n,onSelectLibrary:r}){return s.jsx(qr,{open:e,title:i("conversation.attachmentSourceSheetTitle"),description:i("conversation.attachmentSourceSheetDescription"),kind:"action",height:"auto",className:"composer-attachment-sheet",cardClassName:"composer-attachment-sheet-card",bodyClassName:"composer-attachment-sheet-body",showHandle:!0,onClose:t,children:s.jsxs(Wr,{className:"composer-attachment-sheet-actions",children:[s.jsx(In,{as:"button",className:"mobile-workspace-home-row composer-attachment-sheet-option","aria-label":i("conversation.attachmentTakePhoto"),label:i("conversation.attachmentTakePhoto"),description:i("conversation.attachmentTakePhotoHint"),trailing:s.jsx(Ii,{}),onClick:n}),s.jsx(In,{as:"button",className:"mobile-workspace-home-row composer-attachment-sheet-option","aria-label":i("conversation.attachmentChooseFromLibrary"),label:i("conversation.attachmentChooseFromLibrary"),description:i("conversation.attachmentChooseFromLibraryHint"),trailing:s.jsx(Ei,{}),onClick:r})]})})}function Ii(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M4 8h3l1.5-2h7L17 8h3a1 1 0 0 1 1 1v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9a1 1 0 0 1 1-1Z"}),s.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}function Qt(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),s.jsx("path",{d:"M8 12h8M12 8v8"})]})}function Ei(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 15 3-3 2.5 2.5 3-4L18 13.5"}),s.jsx("circle",{cx:"8.75",cy:"8.75",r:"1.25",fill:"currentColor",stroke:"none"})]})}function Bi(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 3 4 7v5c0 5 3.5 8 8 9 4.5-1 8-4 8-9V7l-8-4Z"}),s.jsx("path",{d:"m9.5 12 1.8 1.8L15 10.2"})]})}function Oi(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M4 7h9"}),s.jsx("path",{d:"m10 3 4 4-4 4"}),s.jsx("path",{d:"M20 17h-9"}),s.jsx("path",{d:"m14 13-4 4 4 4"})]})}function _i(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m7 7 10 10"}),s.jsx("path",{d:"M17 7 7 17"}),s.jsx("path",{d:"M12 3v2"}),s.jsx("path",{d:"M12 19v2"})]})}function St({ariaLabel:e,value:t,options:n,onChange:r,disabled:a=!1,compact:o=!1}){const[l,d]=u.useState(!1),m=u.useRef(null),k=u.useRef(null),v=u.useRef(null),[x,g]=u.useState(null),j=u.useId(),b=n.find(C=>C.value===t)??n[0]??null,f=u.useCallback(()=>{const C=k.current;if(!C||typeof window>"u")return;const T=C.getBoundingClientRect(),M=window.innerWidth,R=window.innerHeight,I=12,D=10,A=Math.max(160,M-I*2),F=o?140:220,L=Math.min(A,Math.max(T.width,F)),$=Math.min(Math.max(I,T.left),Math.max(I,M-L-I)),H=T.top-I,X=R-T.bottom-I,U=H>=180||H>=X;g({position:"fixed",left:$,width:L,maxWidth:A,top:U?void 0:T.bottom+D,bottom:U?R-T.top+D:void 0})},[o]);return u.useEffect(()=>{if(!l)return;function C(M){var I,D;const R=M.target;!((I=m.current)!=null&&I.contains(R))&&!((D=v.current)!=null&&D.contains(R))&&d(!1)}function T(M){M.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",C),window.addEventListener("keydown",T),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),f(),()=>{window.removeEventListener("pointerdown",C),window.removeEventListener("keydown",T),window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[l,f]),b?s.jsxs("div",{ref:m,className:`composer-mac-select ${o?"is-compact":""}`,"data-open":l?"true":"false",children:[s.jsxs("button",{ref:k,type:"button",className:"composer-mac-select-trigger","aria-label":e,"aria-haspopup":"listbox","aria-expanded":l,"aria-controls":j,disabled:a,onClick:()=>d(C=>!C),children:[s.jsx("span",{className:"composer-mac-select-label",children:b.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),l&&x&&typeof document<"u"?on.createPortal(s.jsx("div",{ref:v,className:"composer-mac-select-popover",style:x,role:"presentation",children:s.jsx("div",{id:j,className:"composer-mac-select-list",role:"listbox","aria-label":e,children:n.map(C=>{const T=C.value===t;return s.jsxs("button",{type:"button",role:"option","aria-selected":T,className:`composer-mac-select-option ${T?"is-selected":""}`,onClick:()=>{r(C.value),d(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:T?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:C.label})]},C.value)})})}),document.body):null]}):null}function qi({contextUsage:e}){const[t,n]=u.useState(!1),r=u.useRef(null),a=u.useRef(null),[o,l]=u.useState(null),d=u.useId(),m=e?Math.round(e.usageRatio*100):null,k=e?Math.max(0,Math.min(e.usageRatio,1)):0,v=Wi(k),x=e?Fi(e.contextWindowSource):null,g=e?`${i("conversation.contextUsageTitle")} ${m}%`:i("conversation.contextUsageUnavailable"),j=u.useCallback(()=>{const b=r.current;if(!b||typeof window>"u")return;const f=b.getBoundingClientRect(),C=window.innerWidth,T=window.innerHeight,M=12,R=10,I=Math.min(240,Math.max(188,C-M*2)),D=Math.min(Math.max(M,f.left+f.width/2-I/2),Math.max(M,C-I-M)),A=f.top-M,F=T-f.bottom-M,L=A>=140||A>=F;l({position:"fixed",left:D,width:I,maxWidth:C-M*2,top:L?void 0:f.bottom+R,bottom:L?T-f.top+R:void 0})},[]);return u.useEffect(()=>{if(!t)return;function b(C){var M,R;const T=C.target;!((M=r.current)!=null&&M.contains(T))&&!((R=a.current)!=null&&R.contains(T))&&n(!1)}function f(C){C.key==="Escape"&&n(!1)}return window.addEventListener("pointerdown",b),window.addEventListener("keydown",f),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),j(),()=>{window.removeEventListener("pointerdown",b),window.removeEventListener("keydown",f),window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[t,j]),s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:r,type:"button",className:`composer-context-ring ${v}`,style:{"--context-usage-progress":`${k}`},"aria-label":g,"aria-expanded":t,"aria-describedby":t?d:void 0,onClick:()=>n(b=>!b),onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),onFocus:()=>n(!0),onBlur:()=>n(!1),children:s.jsx("span",{className:"composer-context-ring-value",children:m===null?"--":s.jsxs(s.Fragment,{children:[s.jsx("span",{children:m}),s.jsx("span",{className:"composer-context-ring-suffix",children:"%"})]})})}),t&&o&&typeof document<"u"?on.createPortal(s.jsx("div",{ref:a,id:d,className:"composer-context-tooltip",style:o,role:"tooltip",children:e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"composer-context-tooltip-title",children:i("conversation.contextUsageTitle")}),s.jsxs("div",{className:"composer-context-tooltip-line",children:[m,"% · ",Zt(e.promptTokens)," /"," ",Zt(e.contextWindow)," tokens"]}),e.cachedInputTokens>0?s.jsx("div",{className:"composer-context-tooltip-line",children:i("conversation.contextUsageCachedTokens").replace("{count}",Zt(e.cachedInputTokens))}):null,x?s.jsx("div",{className:"composer-context-tooltip-meta",children:x}):null,e.isEstimated?s.jsx("div",{className:"composer-context-tooltip-meta",children:i("conversation.contextUsageEstimated")}):null]}):s.jsx("div",{className:"composer-context-tooltip-line",children:i("conversation.contextUsageUnavailable")})}),document.body):null]})}function Wi(e){return e>=.95?"is-critical":e>=.8?"is-warning":"is-normal"}function Fi(e){switch(e){case"provider-log":return i("conversation.contextUsageSourceProviderLog");case"provider-runtime":return i("conversation.contextUsageSourceProviderRuntime");case"provider-config":return i("conversation.contextUsageSourceProviderConfig");case"model-map":return i("conversation.contextUsageSourceModelMap");default:return""}}function Zt(e){return new Intl.NumberFormat().format(e)}const Lt="*** Begin Patch",Pt="*** End Patch";function zn(e){const t=e.replace(/\r\n/g,`
|
|
1
|
+
var kr=Object.defineProperty;var Cr=(e,t,n)=>t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var de=(e,t,n)=>Cr(e,typeof t!="symbol"?t+"":t,n);import{t as i,j as s,b as d,u as jr,D as Ht,a as Ln,l as Pn,E as wr,F as Nr,C as Sr}from"./index-C2G8Gmf1.js";import{d as gt,e as vt,f as on}from"./App-WOLwMld_.js";import{e as Tr,Q as Rr,R as Mr,T as Ar,n as Kt,a as os,L as Lr,U as Pr,V as Ir,W as Er,X as Br,o as Or,p as _r,M as qr,i as Wr,j as In,Y as Fr,Z as Ur,_ as zr}from"./MobileSheet-Gzc14EpR.js";import{W as Mt,D as ls}from"./WorkbenchModal-B09hC9b5.js";import{u as cs,ad as Dr,a1 as $r}from"./WorkbenchLayout-rwQib5In.js";import{M as Hr,r as Kr}from"./file-tree-icon-Dp_xhVfD.js";function Vt(e,t){if(!e)return{allowed:!1,hidden:!1,reason:i("conversation.capabilityDenied")};switch(t){case"send_message":return e.canSendMessage===!1?{allowed:!1,hidden:!1,reason:i("conversation.capabilitySendDisabled")}:{allowed:!0,hidden:!1,reason:null};case"attachments":return e.supportsAttachments?{allowed:!0,hidden:!1,reason:null}:{allowed:!1,hidden:!1,reason:i("conversation.capabilityAttachmentDisabled")};case"interrupt":return e.supportsInterrupt?{allowed:!0,hidden:!1,reason:null}:{allowed:!1,hidden:!1,reason:i("conversation.capabilityInterruptDisabled")};default:return{allowed:!1,hidden:!1,reason:i("conversation.capabilityDenied")}}}const Vr=new Set(["updateplan"]),us=new Set(["todowrite"]),tn=new Set(["todoread"]),ds=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function Gr(e,t){const n=Qr(e,t);return n||Jr(e,t)}function ms(e){return e.reduce((t,n)=>(t[n.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function Zr(e,t,n){if(!e)return null;if(nn(e.name)){const l=Ve(e);if(!l||!qt(l.value))return null;const u=ps(l.value,n);return!u||u.items.length===0?null:{provider:t,source:"plan",explanation:u.explanation,items:u.items,updatedAt:n}}const r=_t(e.name);if(!us.has(r)&&!tn.has(r)&&!ds.has(r))return null;const a=Ve(e,(tn.has(r),"prefer-output"));if(!a)return null;if(r==="taskdelete"||r==="taskremove"){const l=fs(a.value);return l.length>0?{provider:t,source:"todo",explanation:null,items:l.map((u,m)=>({id:u,title:`Task ${m+1}`,status:"cancelled",detail:u,updatedAt:n})),updatedAt:n}:null}const o=rt(a.value,n);return o.length===0?null:{provider:t,source:nn(e.name)?"plan":"todo",explanation:null,items:o,updatedAt:n}}function Qr(e,t){let n=null;for(const r of e){const a=r.toolCall;if(!a||_t(a.name)===""||!nn(a.name))continue;const o=Ve(a);if(!o||typeof o.value!="object"||o.value===null)continue;const l=ps(o.value,r.timestamp);!l||l.items.length===0||(n={provider:t,source:"plan",explanation:l.explanation,items:l.items,updatedAt:r.timestamp})}return n}function Jr(e,t){const n=new Map;let r=null;for(const o of e){const l=o.toolCall;if(!l)continue;const u=_t(l.name);if(us.has(u)){const p=Ve(l),x=p?rt(p.value,o.timestamp):[];x.length>0&&(Gt(n,x),r=o.timestamp);continue}if(tn.has(u)){const p=Ve(l,"prefer-output"),x=p?rt(p.value,o.timestamp):[];x.length>0&&(Gt(n,x),r=o.timestamp);continue}if(!ds.has(u))continue;const m=Ve(l,"prefer-output");if(!m)continue;if(u==="tasklist"||u==="taskget"){const p=rt(m.value,o.timestamp);p.length>0&&(Gt(n,p),r=o.timestamp);continue}if(u==="taskdelete"||u==="taskremove"){const p=fs(m.value);if(p.length>0){for(const x of p)n.delete(x);r=o.timestamp}continue}const y=rt(m.value,o.timestamp);if(y.length!==0){for(const p of y)Xr(n,p);r=o.timestamp}}const a=Array.from(n.values()).sort((o,l)=>o.updatedAt.localeCompare(l.updatedAt)).map(o=>({...o}));return a.length===0||!r?null:{provider:t,source:"todo",explanation:null,items:a,updatedAt:r}}function nn(e){return Vr.has(_t(e))}function ps(e,t){const n=Array.isArray(e.plan)?e.plan:null;if(!n||n.length===0)return null;const r=n.map((a,o)=>hs(a,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${o+1}`,fallbackStatus:"pending",updatedAt:t})).filter(a=>a!==null);return r.length===0?null:{items:r,explanation:O(e.explanation)}}function Ve(e,t="prefer-input"){const n=t==="prefer-output"?[{text:e.output,source:"output"},{text:e.input,source:"input"}]:[{text:e.input,source:"input"},{text:e.output,source:"output"}];for(const r of n){const a=Yr(r.text);if(a!==null)return{value:a,source:r.source}}return null}function Yr(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=Nt(t);if(n!==null)return n;const r=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(r!=null&&r[1]){const m=Nt(r[1].trim());if(m!==null)return m}const a=t.indexOf("{"),o=t.lastIndexOf("}");if(a>=0&&o>a){const m=Nt(t.slice(a,o+1));if(m!==null)return m}const l=t.indexOf("["),u=t.lastIndexOf("]");return l>=0&&u>l?Nt(t.slice(l,u+1)):null}function Nt(e){try{return JSON.parse(e)}catch{return null}}function rt(e,t){return at(e).map((r,a)=>hs(r,{fallbackIdPrefix:"task",fallbackTitle:`Task ${a+1}`,fallbackStatus:"pending",updatedAt:t})).filter(r=>r!==null)}function at(e){if(Array.isArray(e))return e.flatMap(n=>at(n));if(!qt(e))return[];if(si(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const n of t){if(!(n in e))continue;const r=at(e[n]);if(r.length>0)return r}return Object.values(e).flatMap(n=>at(n))}function fs(e){const n=at(e).map(a=>sn(a)).filter(a=>a!==null);if(n.length>0)return n;if(!qt(e))return[];const r=sn(e);return r?[r]:[]}function hs(e,t){if(!qt(e))return null;const n=O(e.step)??O(e.title)??O(e.content)??O(e.task)??O(e.text)??O(e.name)??O(e.subject)??O(e.description)??t.fallbackTitle,r=sn(e)??ni(t.fallbackIdPrefix,n),a=ti(e,n);return{id:r,title:n,status:ei(e.status,t.fallbackStatus),detail:a,updatedAt:t.updatedAt}}function Xr(e,t){const n=e.get(t.id);if(!n){e.set(t.id,{...t});return}e.set(t.id,{id:n.id,title:t.title||n.title,status:t.status,detail:t.detail??n.detail,updatedAt:t.updatedAt})}function Gt(e,t){e.clear();for(const n of t)e.set(n.id,{...n})}function ei(e,t){var r;const n=(r=O(e))==null?void 0:r.toLowerCase().replace(/[\s-]+/g,"_");return n?["pending","todo","open","queued","not_started","created"].includes(n)?"pending":["in_progress","progress","active","doing","running","started"].includes(n)?"in_progress":["completed","complete","done","success","succeeded","finished","closed"].includes(n)?"completed":["failed","error","errored"].includes(n)?"failed":["cancelled","canceled","aborted","skipped"].includes(n)?"cancelled":t:t}function ti(e,t){const n=[O(e.detail),O(e.details),O(e.description),O(e.reason),O(e.summary),O(e.note),O(e.priority)].filter(r=>r!==null);for(const r of n)if(r!==t)return r;return null}function sn(e){return O(e.id)??O(e.taskId)??O(e.task_id)??O(e.uuid)??O(e.key)}function ni(e,t){return`${e}:${t.trim().toLowerCase()}`}function si(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>O(t)!==null)}function _t(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function ri(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("rect",{x:"7",y:"5",width:"9",height:"11",rx:"2.5"}),s.jsx("path",{d:"M5.5 12.5H5A2 2 0 0 1 3 10.5V5a2 2 0 0 1 2-2h5.5"})]})}function ii(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"6",r:"2.25"}),s.jsx("circle",{cx:"14",cy:"14",r:"2.25"}),s.jsx("path",{d:"M8.4 5.7h2.2a2.7 2.7 0 0 1 2.7 2.7v1.2"}),s.jsx("path",{d:"M8.1 5.9l4.1 6.2"})]})}function tl(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M10 2.8l1.6 3.4 3.8.5-2.8 2.6.7 3.9-3.3-1.8-3.3 1.8.7-3.9-2.8-2.6 3.8-.5L10 2.8z"}),s.jsx("path",{d:"M15.8 13.3l.7 1.5 1.7.2-1.2 1.1.3 1.8-1.5-.8-1.5.8.3-1.8-1.2-1.1 1.7-.2.7-1.5z"})]})}function nl(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"14",cy:"5",r:"2.2"}),s.jsx("circle",{cx:"10",cy:"14",r:"2.2"}),s.jsx("path",{d:"M8.2 5h3.6"}),s.jsx("path",{d:"M10 7.2v4.6"}),s.jsx("path",{d:"M7.3 6.8l1.7 4"}),s.jsx("path",{d:"M12.7 6.8l-1.7 4"})]})}function sl(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"conversation-action-icon",children:[s.jsx("circle",{cx:"4.5",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"10",cy:"10",r:"1.5"}),s.jsx("circle",{cx:"15.5",cy:"10",r:"1.5"})]})}function ai(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[s.jsx("path",{d:"M4.5 5.5h1.2"}),s.jsx("path",{d:"M8 5.5h7.5"}),s.jsx("path",{d:"M4.5 10h1.2"}),s.jsx("path",{d:"M8 10h7.5"}),s.jsx("path",{d:"M4.5 14.5h1.2"}),s.jsx("path",{d:"M8 14.5h7.5"}),s.jsx("path",{d:"M5.1 5.5l.5.5 1-1"}),s.jsx("circle",{cx:"5.1",cy:"10",r:".8",fill:"currentColor",stroke:"none"}),s.jsx("path",{d:"M5.1 14.5l.5.5 1-1"})]})}const En={in_progress:0,failed:1,pending:2,completed:3,cancelled:4};function oi({provider:e,messages:t,variant:n="header"}){const[r,a]=d.useState(!1),o=d.useMemo(()=>Gr(t,e),[t,e]);if(!o||o.items.length===0)return null;const l=ms(o.items),u=l.in_progress||l.pending,m=u>0?u:o.items.length,y=[...o.items].sort((x,v)=>{const j=En[x.status]-En[v.status];return j!==0?j:x.updatedAt.localeCompare(v.updatedAt)}),p=n==="composer"?"conversation-task-progress-button composer-task-progress-button":"conversation-header-ai-button conversation-task-progress-button";return s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:p,"data-variant":n,"aria-label":i("conversation.taskProgressButton",{count:o.items.length}),title:i("conversation.taskProgressButton",{count:o.items.length}),onClick:()=>{a(!0)},children:[s.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:s.jsx(ai,{})}),s.jsx("span",{className:"conversation-task-progress-badge",children:m})]}),s.jsx(Mt,{open:r,title:i("conversation.taskProgressModalTitle"),description:i("conversation.taskProgressModalDescription",{count:o.items.length}),className:"conversation-task-progress-modal",onClose:()=>{a(!1)},children:s.jsxs("div",{className:"conversation-task-progress-modal-body",children:[s.jsxs("div",{className:"conversation-task-progress-summary",children:[s.jsx(st,{label:i("conversation.taskProgressSummaryTotal"),value:o.items.length}),s.jsx(st,{label:i("conversation.taskProgressStatusInProgress"),value:l.in_progress}),s.jsx(st,{label:i("conversation.taskProgressStatusPending"),value:l.pending}),s.jsx(st,{label:i("conversation.taskProgressStatusCompleted"),value:l.completed}),l.failed>0?s.jsx(st,{label:i("conversation.taskProgressStatusFailed"),value:l.failed}):null]}),o.explanation?s.jsxs("div",{className:"conversation-task-progress-explanation",children:[s.jsx("strong",{children:i("conversation.taskProgressExplanationTitle")}),s.jsx("p",{children:o.explanation})]}):null,s.jsx("ol",{className:"conversation-task-progress-list",children:y.map(x=>s.jsxs("li",{className:"conversation-task-progress-item","data-status":x.status,children:[s.jsx("span",{className:"conversation-task-progress-item-indicator","data-status":x.status,"aria-hidden":"true"}),s.jsxs("div",{className:"conversation-task-progress-item-body",children:[s.jsxs("div",{className:"conversation-task-progress-item-header",children:[s.jsx("strong",{children:x.title}),s.jsx("span",{className:"conversation-task-progress-item-status",children:li(x.status)})]}),x.detail?s.jsx("p",{className:"conversation-task-progress-item-detail",children:x.detail}):null]})]},x.id))})]})})]})}function st({label:e,value:t}){return s.jsxs("div",{className:"conversation-task-progress-summary-card",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t})]})}function li(e){switch(e){case"in_progress":return i("conversation.taskProgressStatusInProgress");case"completed":return i("conversation.taskProgressStatusCompleted");case"failed":return i("conversation.taskProgressStatusFailed");case"cancelled":return i("conversation.taskProgressStatusCancelled");case"pending":default:return i("conversation.taskProgressStatusPending")}}const ci="codingns.conversation.composer-draft:",ui=1,di=[{id:"builtin-stage-and-summarize",text:"请将本次会话变更的所有代码提交到git暂存区,然后总结一条中文的提交信息"},{id:"builtin-review-module",text:"分析本项目 模块的代码实现,并分析存在的问题"},{id:"builtin-group-commits",text:"分析当前项目中的未提交文件,按照功能模块进行分类提交,提交信息格式请参考我最近的提交记录"}];function ln(){return typeof window<"u"&&typeof window.localStorage<"u"}function mi(e){if(!e||typeof e!="object")return null;const t="id"in e?e.id:null,n="fileName"in e?e.fileName:null,r="mimeType"in e?e.mimeType:null,a="fileSize"in e?e.fileSize:null,o="lastModified"in e?e.lastModified:null,l="contentBase64"in e?e.contentBase64:null;if(typeof t!="string"||typeof n!="string"||typeof r!="string"||typeof a!="number"||typeof o!="number"||typeof l!="string")return null;const u=t.trim(),m=n.trim(),y=r.trim(),p=l.trim();return!u||!m||!y||a<0||o<0||!p?null:{id:u,fileName:m,mimeType:y,fileSize:a,lastModified:o,contentBase64:p}}function pi(e){if(!e||typeof e!="object")return null;const t="content"in e?e.content:null,n="attachments"in e?e.attachments:null;if(typeof t!="string"||!Array.isArray(n))return null;const r=n.map(a=>mi(a)).filter(a=>a!==null);return r.length!==n.length||t.length===0&&r.length===0?null:{content:t,attachments:r}}function ot(e){return`${ci}${e}`}function fi(e){var t,n;return{id:((n=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:n.call(t))??`phrase-${Date.now()}-${Math.random().toString(16).slice(2)}`,text:e.trim()}}function hi(e){if(!ln())return null;const t=e.trim();if(!t)return null;const n=window.localStorage.getItem(ot(t));if(!n)return null;try{const r=JSON.parse(n),a=r&&typeof r=="object"&&"draft"in r&&r.draft&&typeof r.draft=="object"?r.draft:r,o=pi(a);return o||(window.localStorage.removeItem(ot(t)),null)}catch{return window.localStorage.removeItem(ot(t)),null}}function gi(e,t){if(!ln())return!1;const n=e.trim();if(!n)return!1;if(t.content.length===0&&t.attachments.length===0)return gs(n),!0;try{return window.localStorage.setItem(ot(n),JSON.stringify({schemaVersion:ui,draft:t})),!0}catch{return!1}}function gs(e){if(!ln())return;const t=e.trim();t&&window.localStorage.removeItem(ot(t))}const Bn="workbench:focus-composer",lt="provider-default",On=["codex","claude-code","opencode","gemini","kimi"],vi=new Set(["codex","claude-code","opencode"]),xi=new Set(["codex","claude-code","opencode"]),_n={position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0};function bi(e){return[{id:lt,name:i("conversation.modelUseCliDefault"),provider:e,usesProviderDefault:!0}]}function qn(e){return bi(e)}function Wn(e){return e.usesProviderDefault===!0||e.id===lt}function yi(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${Date.now()}-${Math.random().toString(16).slice(2)}`}function Fn(e){if(e){e.value="";try{const t=e.showPicker;if(typeof t=="function"){t.call(e);return}}catch{}e.click()}}function ki(e,t,n,r){const a=globalThis.atob(n),o=Uint8Array.from(a,l=>l.charCodeAt(0));return new File([o],e,{type:t,lastModified:r})}function Ci(e){return e.trim().toLowerCase().startsWith("image/")}function ct(e){const t=e.type.trim().toLowerCase();return t.length>0?t:"application/octet-stream"}function vs(e){return Ci(ct(e))?"image":"file"}function xs(e,t=yi()){const n=vs(e);return{id:t,file:e,kind:n,previewUrl:n==="image"?URL.createObjectURL(e):null}}function ji(e){const t=ki(e.fileName,e.mimeType,e.contentBase64,e.lastModified);return xs(t,e.id)}function wi(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ni(e){const t=e.trim().replace(/\s+/g," ");return t.length===0?i("conversation.forkDraftEmpty"):t.length>140?`${t.slice(0,140)}…`:t}function Si(e,t){return t===e?xi.has(t)?null:i("conversation.forkProviderNativeUnsupported"):vi.has(t)?null:i("conversation.forkProviderReconstructedUnsupported")}function bs(e){return(e==null?void 0:e.canStartSession)===!1}function Ti(e){return bs(e)?(e==null?void 0:e.limitations[0])??i("conversation.capabilityDenied"):null}function Ri(e,t){return{id:t,kind:vs(e),fileName:e.name,mimeType:ct(e),fileSize:e.size}}function Un(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error("FILE_READ_FAILED"))},r.onload=()=>{const a=typeof r.result=="string"?r.result:"",o=a.includes(",")?a.split(",").at(-1)??"":a;t(o)},r.readAsDataURL(e)})}function Mi(e){e.forEach(t=>{t.previewUrl&&URL.revokeObjectURL(t.previewUrl)})}function Ai(e,t){const n=new Set(e.map(a=>`${a.file.name}:${a.file.size}:${a.file.lastModified}`)),r=[...e];return t.forEach(a=>{const o=`${a.name}:${a.size}:${a.lastModified}`;n.has(o)||(n.add(o),r.push(xs(a)))}),r}function Li(e,t,n){const r=e.nativeEvent;return r.isComposing||r.keyCode===229||t||n}function rl({capabilities:e,placeholder:t,draftStorageId:n,forkDraft:r=null,onClearForkDraft:a,onForkDraftChange:o,panelRef:l,portalContainer:u=null,hasActiveRun:m=null,canInterrupt:y=null,contextUsage:p=null,taskProvider:x=null,taskMessages:v=[],hasPendingQueuedMessages:j=!1,isSubmitting:b,isRunning:h=!1,onInterrupt:C,onQueueSend:T,onSend:M}){const R=gt(),I=d.useId(),D=d.useId(),[A,F]=d.useState(""),[L,$]=d.useState(""),[H,X]=d.useState("medium"),[U,K]=d.useState([]),[Ee,se]=d.useState(!1),[Be,me]=d.useState(!1),[G,ae]=d.useState(di),[re,ke]=d.useState(!1),[xt,pe]=d.useState(!1),[Oe,bt]=d.useState(""),[Ce,fe]=d.useState(!1),[he,ee]=d.useState(!1),[Ze,Qe]=d.useState(!1),[Je,je]=d.useState(!1),[Ye,Z]=d.useState(null),[_e,we]=d.useState(!1),[Ne,oe]=d.useState({}),[ge,qe]=d.useState(null),Se=d.useRef(null),Xe=d.useRef(null),yt=d.useRef(null),We=d.useRef(!1),Fe=d.useRef(!1),f=d.useRef(!1),N=d.useRef(null),E=d.useRef(new Set),Q=d.useRef(new Map),V=d.useRef(0),{showToast:Te}=vt(),Re=Tr(),Ue=d.useCallback(()=>{N.current!==null&&(globalThis.clearTimeout(N.current),N.current=null),f.current=!1},[]);d.useEffect(()=>Ue,[Ue]);const Y=Rr(e),le=jr(c=>Ht(Y)?c.profile.providers[Y]:null),et=(le==null?void 0:le.defaultModel)??null,tt=(le==null?void 0:le.defaultReasoningLevel)??null,Wt=d.useMemo(()=>Vt(e,"send_message"),[e]),fn=d.useMemo(()=>Vt(e,"interrupt"),[e]),te=d.useMemo(()=>Vt(e,"attachments"),[e]),ce=d.useMemo(()=>{var g;const c=(g=e==null?void 0:e.modelOptions)==null?void 0:g.map(k=>{var w;return{...k,provider:Y,supportedReasoningEfforts:(w=k.supportedReasoningEfforts)==null?void 0:w.filter(_=>_==="low"||_==="medium"||_==="high"||_==="xhigh")}});return c!=null&&c.length?c:qn(Y)},[e==null?void 0:e.modelOptions,Y]),ue=d.useMemo(()=>ce.find(c=>c.id===L)??null,[ce,L]),kt=Mr(e),Vs=Ar(e),Ft=d.useMemo(()=>[{value:"low",label:i("conversation.reasoningLow")},{value:"medium",label:i("conversation.reasoningMedium")},{value:"high",label:i("conversation.reasoningHigh")},{value:"xhigh",label:i("conversation.reasoningMaximum")}],[]),ie=d.useMemo(()=>{if(!kt)return[];const c=ue==null?void 0:ue.supportedReasoningEfforts;return!c||c.length===0?Ft:Ft.filter(g=>c.includes(g.value))},[kt,Ft,ue==null?void 0:ue.supportedReasoningEfforts]),Gs=d.useMemo(()=>ce.map(c=>({value:c.id,label:Wn(c)?i("conversation.modelUseCliDefault"):c.name})),[ce]),Zs=d.useMemo(()=>ie.map(c=>({value:c.value,label:c.label})),[ie]),Qs=d.useMemo(()=>[{command:"/plan",label:i("conversation.slashCommandPlan")},{command:"/review",label:i("conversation.slashCommandReview")},{command:"/explain",label:i("conversation.slashCommandExplain")}],[]),hn=(e==null?void 0:e.inRunInputMode)??"none",ve=!!r,Js=(r==null?void 0:r.targetProvider)??null,Ct=!!r&&(e==null?void 0:e.provider)===Js,xe=d.useMemo(()=>r?Ct?e:Ye??Kt(r.targetProvider):null,[e,Ye,r,Ct]),ze=d.useMemo(()=>{var g;if(!r)return[];const c=(g=xe==null?void 0:xe.modelOptions)==null?void 0:g.map(k=>{var w;return{...k,provider:r.targetProvider,supportedReasoningEfforts:(w=k.supportedReasoningEfforts)==null?void 0:w.filter(_=>_==="low"||_==="medium"||_==="high"||_==="xhigh")}});return c!=null&&c.length?c:qn(r.targetProvider)},[xe==null?void 0:xe.modelOptions,r]),Ys=d.useMemo(()=>ze.map(c=>({value:c.id,label:Wn(c)?i("conversation.modelUseCliDefault"):c.name})),[ze]),Xs=d.useMemo(()=>!r||!r.targetModel?lt:ze.some(c=>c.id===r.targetModel)?r.targetModel:lt,[ze,r]),Me=d.useMemo(()=>r?On.filter(c=>Si(r.sourceProvider,c)!==null?!1:!bs(Ne[c]??null)):[],[r,Ne]),gn=d.useMemo(()=>r?Me.length>0?Me:[r.targetProvider]:[],[r,Me]),er=d.useMemo(()=>gn.map(c=>({value:c,label:os(c,"full")})),[gn]),jt=d.useMemo(()=>r?Ti(Ne[r.targetProvider]??xe??null):null,[xe,r,Ne]),Ut=m??null,be=h||Ut===!0,tr=be&&hn==="streaming_guidance"&&Ut===!1&&!Lr(e),vn=!ve&&be&&hn==="streaming_guidance"&&!tr,zt=!ve&&be&&typeof T=="function"&&Pr(e,Ut),J=!ve&&be&&!vn&&!zt,Dt=ve&&!!jt,xn=A.trim().length>0||U.length>0,bn=y===!1&&be?fn.allowed:y??fn.allowed,$t=be&&bn&&!!C&&!Ze,nr=!xn&&(Je||b||be||j),yn=$t?i("conversation.capabilityInterrupt"):i("conversation.runtimeRunning"),kn=be?zt?i("conversation.queueGuidanceButton"):vn?i("conversation.sendGuidanceButton"):i("conversation.sendButton"):i("conversation.sendButton"),sr=d.useCallback(c=>{$(c),Ht(Y)&&Ln({providers:{[Y]:{defaultModel:c}}}).catch(()=>{})},[Y]),rr=d.useCallback(c=>{X(c),Ht(Y)&&Ln({providers:{[Y]:{defaultReasoningLevel:c}}}).catch(()=>{})},[Y]),wt=d.useCallback(c=>{E.current.forEach(g=>{URL.revokeObjectURL(g)}),E.current.clear(),c.forEach(g=>{g.previewUrl&&E.current.add(g.previewUrl)}),K(c)},[]),nt=d.useCallback(c=>{c.length!==0&&K(g=>{const k=Ai(g,c);return k.forEach(w=>{w.previewUrl&&E.current.add(w.previewUrl)}),k})},[]),ir=d.useCallback(c=>{Q.current.delete(c),K(g=>{const k=g.find(w=>w.id===c);return k!=null&&k.previewUrl&&(E.current.delete(k.previewUrl),URL.revokeObjectURL(k.previewUrl)),g.filter(w=>w.id!==c)})},[]),Cn=d.useCallback(c=>{const g=Array.from(c.target.files??[]);g.length>0&&nt(g),c.target.value=""},[nt]),ar=d.useCallback(c=>{var k;R.isMobile||!te.allowed||J||!((((k=c.dataTransfer.files)==null?void 0:k.length)??0)>0||Array.from(c.dataTransfer.items??[]).some(w=>w.kind==="file"))||(c.preventDefault(),c.dataTransfer.dropEffect="copy",Be||me(!0),ee(!1))},[te.allowed,Be,J,R.isMobile]),or=d.useCallback(c=>{const g=c.relatedTarget;g instanceof Node&&c.currentTarget.contains(g)||me(!1)},[]),lr=d.useCallback(c=>{if(R.isMobile||!te.allowed||J)return;const g=Array.from(c.dataTransfer.files??[]);g.length!==0&&(c.preventDefault(),me(!1),nt(g))},[te.allowed,J,nt,R.isMobile]),jn=d.useCallback(c=>{if(!te.allowed||J)return;const g=c==="camera"?yt.current:Xe.current;Fn(g),se(!1)},[te.allowed,J]),cr=d.useCallback(()=>{if(!(!te.allowed||J)){if(ee(!1),R.isNativeMobile){Re.trigger("selection"),se(!0);return}Fn(Xe.current)}},[te.allowed,Re,J,R.isNativeMobile]),ur=d.useCallback(()=>{ee(c=>!c)},[]),dr=d.useCallback(c=>{var g;F(k=>k.trimStart().startsWith(c)?k:k.trim()?`${c} ${k.trim()}`:`${c} `),ee(!1),(g=Se.current)==null||g.focus()},[]),De=d.useCallback(async c=>{const g=G;V.current+=1,ae(c),fe(!0);try{const k=await Ir(c.map(w=>({id:w.id,text:w.text})));return ae(k.items.map(w=>({id:w.id,text:w.text}))),!0}catch(k){return ae(g),Te({title:k instanceof Error?k.message:i("conversation.quickPhraseSaveFailed"),tone:"error"}),!1}finally{fe(!1)}},[G,Te]),mr=d.useCallback(async()=>{const c=Oe.trim();!c||!await De([...G,fi(c)])||(bt(""),pe(!1))},[De,Oe,G]),pr=d.useCallback(c=>{De(G.filter(g=>g.id!==c))},[De,G]),wn=d.useCallback((c,g)=>{const k=G.findIndex(W=>W.id===c);if(k<0)return;const w=k+g;if(w<0||w>=G.length)return;const _=[...G],[q]=_.splice(k,1);_.splice(w,0,q),De(_)},[De,G]),fr=d.useCallback(c=>{var g;F(c),ke(!1),(g=Se.current)==null||g.focus()},[]),Nn=d.useCallback(c=>{const g=c?hi(c):null,k=(g==null?void 0:g.attachments.map(w=>ji(w)))??[];Q.current=new Map(((g==null?void 0:g.attachments)??[]).map(w=>[w.id,w])),wt(k),F((g==null?void 0:g.content)??""),ee(!1)},[wt]);d.useEffect(()=>{if(!ce.length)return;if(et&&ce.some(g=>g.id===et)){L!==et&&$(et);return}if(ce.some(g=>g.id===L))return;const c=ce[0].id;$(c)},[ce,Y,L,et]),d.useEffect(()=>{if(!Er(Y)||ie.length===0)return;if(tt&&ie.some(k=>k.value===tt)){H!==tt&&X(tt);return}const c=e==null?void 0:e.defaultReasoningLevel;if(c&&ie.some(k=>k.value===c)){H!==c&&X(c);return}if(ie.some(k=>k.value===H))return;const g=ie[0].value;X(g)},[ie,e==null?void 0:e.defaultReasoningLevel,Y,H,tt]),d.useEffect(()=>{let c=!1;const g=V.current;return Br().then(k=>{c||V.current!==g||ae(k.items.map(w=>({id:w.id,text:w.text})))}).catch(()=>{}),()=>{c=!0}},[]),d.useEffect(()=>{Nn(n)},[n,Nn]),d.useEffect(()=>{if(!n)return;const c=n,g=new Set(U.map(_=>_.id));Q.current.forEach((_,q)=>{g.has(q)||Q.current.delete(q)});let k=!1;async function w(){if(A.length===0&&U.length===0){gs(c);return}const _=await Promise.all(U.map(async q=>{const W=Q.current.get(q.id);return W&&W.fileName===q.file.name&&W.fileSize===q.file.size&&W.lastModified===q.file.lastModified&&W.mimeType===ct(q.file)?W:{id:q.id,fileName:q.file.name,mimeType:ct(q.file),fileSize:q.file.size,lastModified:q.file.lastModified,contentBase64:await Un(q.file)}}));k||(Q.current=new Map(_.map(q=>[q.id,q])),gi(c,{content:A,attachments:_}))}return w(),()=>{k=!0}},[U,A,n]),d.useEffect(()=>{const c=Se.current;c&&(c.style.height="0px",c.style.height=`${Math.min(c.scrollHeight,120)}px`)},[A]),d.useEffect(()=>{te.allowed||(Q.current.clear(),se(!1),wt([]))},[te.allowed,wt]),d.useEffect(()=>{R.isMobile||se(!1)},[R.isMobile]),d.useEffect(()=>()=>{E.current.forEach(c=>{URL.revokeObjectURL(c)}),E.current.clear()},[]),d.useEffect(()=>{function c(){var g;(g=Se.current)==null||g.focus()}return window.addEventListener(Bn,c),()=>{window.removeEventListener(Bn,c)}},[]),d.useEffect(()=>{if(!r){Z(null),we(!1),oe({}),qe(null);return}if(Ct){Z(null),we(!1);return}let c=!1;return Z(Kt(r.targetProvider)),we(!0),Or(r.targetProvider,r.workspaceId).then(g=>{c||Z(g)}).catch(()=>{c||Z(Kt(r.targetProvider))}).finally(()=>{c||we(!1)}),()=>{c=!0}},[r==null?void 0:r.targetProvider,r==null?void 0:r.workspaceId,Ct]),d.useEffect(()=>{if(!r){oe({});return}let c=!1;return _r(On,r.workspaceId).then(g=>{c||oe(g)}),()=>{c=!0}},[r==null?void 0:r.workspaceId]),d.useEffect(()=>{!r||!o||Me.length!==0&&(Me.includes(r.targetProvider)||o({...r,targetProvider:Me[0]??r.targetProvider,targetModel:null}))},[r,o,Me]),d.useEffect(()=>{!r||!r.targetModel||!o||ze.some(c=>c.id===r.targetModel)||o({...r,targetModel:null})},[ze,r,o]);const hr=d.useCallback(c=>{if(!(!r||!o||c===r.targetProvider)){if(c!==r.sourceProvider&&r.targetProvider===r.sourceProvider){qe(c);return}o({...r,targetProvider:c,targetModel:null})}},[r,o]),gr=d.useCallback(c=>{!r||!o||o({...r,targetModel:c===lt?null:c})},[r,o]),vr=d.useCallback(()=>{!r||!ge||!o||(o({...r,targetProvider:ge,targetModel:null}),qe(null))},[r,o,ge]),Sn=d.useCallback(()=>{qe(null)},[]);async function xr(c){if(We.current)return;const g=A.trim(),k=U;if(g.length===0&&k.length===0||!Wt.allowed||J||Dt){Te({title:J?i("conversation.runtimeRunning"):jt??Wt.reason??i("conversation.capabilityDenied"),tone:"error"});return}We.current=!0,Re.trigger(c==="queue"?"selection":"action"),je(!0),F(""),K([]),se(!1),me(!1),ke(!1),pe(!1),ee(!1);try{const w=await Promise.all(k.map(async W=>({kind:W.kind,fileName:W.file.name,mimeType:ct(W.file),fileSize:W.file.size,contentBase64:await Un(W.file)}))),_=k.map(W=>Ri(W.file,W.id));await(c==="queue"&&T?T:M)(g,{model:ve||ue!=null&&ue.usesProviderDefault?void 0:L||void 0,reasoningLevel:ve?void 0:kt&&ie.length>0?H:void 0,attachments:w,attachmentMeta:_}),Mi(k),k.forEach(W=>{W.previewUrl&&E.current.delete(W.previewUrl)})}catch(w){F(g),K(k),Te({title:w instanceof Error&&w.message==="FILE_READ_FAILED"?i("conversation.attachmentReadFailed"):w instanceof Error?w.message:i("conversation.capabilityDenied"),tone:"error"})}finally{je(!1),We.current=!1}}async function Tn(c){c.preventDefault(),await xr(zt?"queue":"send")}async function br(){if(!(!bn||!C||Ze))try{Qe(!0),Re.trigger("action"),await C()}catch(c){Te({title:c instanceof Error?c.message:i("conversation.capabilityInterruptDisabled"),tone:"error"})}finally{Qe(!1)}}const Rn=Je||b||J||Dt||!Wt.allowed||!xn,Mn=Je||b||J||!te.allowed,yr=A.length===0&&!J,An=s.jsxs("section",{ref:l,className:"composer-panel",children:[s.jsxs("form",{className:"composer-form",onSubmit:Tn,children:[s.jsx("input",{id:I,ref:Xe,type:"file",multiple:!0,tabIndex:-1,"aria-hidden":"true",style:_n,onChange:Cn}),s.jsx("input",{id:D,ref:yt,type:"file",accept:"image/*",capture:"environment",tabIndex:-1,"aria-hidden":"true",style:_n,onChange:Cn}),s.jsxs("div",{className:"composer-input-container","data-drag-active":Be?"true":void 0,onDragOver:ar,onDragLeave:or,onDrop:lr,children:[r?s.jsxs("div",{className:"composer-fork-draft",children:[s.jsxs("div",{className:"composer-fork-draft-main",children:[s.jsxs("div",{className:"composer-fork-draft-copy",children:[s.jsx("span",{className:"composer-fork-draft-label",children:i("conversation.forkDraftLabel")}),s.jsx("span",{className:"composer-fork-draft-text",children:Ni(r.content)})]}),s.jsxs("div",{className:"composer-fork-config",children:[s.jsxs("div",{className:"composer-fork-config-grid",children:[s.jsxs("div",{className:"composer-fork-field",children:[s.jsx("span",{className:"composer-fork-model-label",children:i("conversation.forkTargetProviderLabel")}),s.jsx(St,{ariaLabel:i("conversation.forkTargetProviderLabel"),value:r.targetProvider,options:er,onChange:c=>hr(c),compact:!0})]}),s.jsxs("div",{className:"composer-fork-field",children:[s.jsx("span",{className:"composer-fork-model-label",children:i("conversation.forkTargetModelLabel")}),s.jsx(St,{ariaLabel:i("conversation.forkTargetModelLabel"),value:Xs,options:Ys,onChange:gr,disabled:_e||Dt,compact:!0})]})]}),jt?s.jsx("p",{className:"composer-capability-hint",children:jt}):null]})]}),a?s.jsx("button",{type:"button",className:"composer-fork-draft-clear","aria-label":i("conversation.forkDraftClear"),title:i("conversation.forkDraftClear"),onClick:a,children:s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):null]}):null,U.length>0?s.jsx("div",{className:"composer-attachments",children:U.map(c=>s.jsxs("div",{className:"composer-attachment-card",children:[c.previewUrl?s.jsx("img",{src:c.previewUrl,alt:i("conversation.attachmentPreviewAlt"),className:"composer-attachment-preview"}):s.jsx("div",{className:"composer-attachment-file","aria-hidden":"true",children:s.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),s.jsx("path",{d:"M14 2v5h5"}),s.jsx("path",{d:"M9 13h6"}),s.jsx("path",{d:"M9 17h6"})]})}),s.jsxs("div",{className:"composer-attachment-meta",children:[s.jsx("span",{className:"attachment-name",title:c.file.name,children:c.file.name}),s.jsx("span",{className:"attachment-size",children:wi(c.file.size)})]}),s.jsx("button",{type:"button",className:"attachment-remove",onClick:()=>ir(c.id),"aria-label":i("conversation.removeAttachment"),children:s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},c.id))}):null,Be?s.jsx("div",{className:"composer-drop-hint",children:i("conversation.attachmentDropHint")}):null,s.jsxs("div",{className:"composer-input-wrapper",children:[s.jsx("textarea",{ref:Se,className:"composer-input",value:A,placeholder:t??i("conversation.composerPlaceholder"),readOnly:J,"aria-readonly":J,onChange:c=>F(c.target.value),rows:1,onFocus:()=>ee(!1),onCompositionStart:()=>{Ue(),Fe.current=!0},onCompositionEnd:()=>{Fe.current=!1,f.current=!0,N.current=globalThis.setTimeout(()=>{f.current=!1,N.current=null},0)},onPaste:c=>{if(J||!te.allowed)return;const g=Array.from(c.clipboardData.items).filter(k=>k.kind==="file").map(k=>k.getAsFile()).filter(k=>!!k);g.length!==0&&(c.preventDefault(),nt(g))},onKeyDown:c=>{if(c.key==="Escape"&&ee(!1),c.key==="Enter"&&!c.shiftKey){if(Li(c,Fe.current,f.current))return;c.preventDefault(),Rn||Tn(c)}}}),s.jsx("div",{className:"composer-input-actions",children:nr?s.jsx("button",{className:"composer-send composer-send-busy",type:"button",disabled:!$t,onClick:()=>{$t&&br()},"aria-label":yn,title:yn,children:s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("rect",{x:"6",y:"6",width:"12",height:"12"})})}):s.jsx("button",{className:"composer-send",type:"submit",disabled:Rn,"aria-label":kn,title:kn,children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[s.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),s.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})})]}),he?s.jsx("div",{className:"composer-slash-menu",role:"menu","aria-label":i("conversation.slashMenuTitle"),children:Qs.map(c=>s.jsxs("button",{type:"button",className:"composer-slash-item",onClick:()=>dr(c.command),children:[s.jsx("span",{className:"composer-slash-command",children:c.command}),s.jsx("span",{className:"composer-slash-label",children:c.label})]},c.command))}):null,s.jsxs("div",{className:"composer-controls",children:[s.jsxs("div",{className:"composer-controls-left",children:[te.allowed?R.isNativeMobile?s.jsx("button",{type:"button",className:"composer-attach-btn","aria-label":i("conversation.attachFiles"),title:i("conversation.attachFiles"),disabled:Mn,onClick:cr,children:s.jsx(Zt,{})}):Mn?s.jsx("button",{type:"button",className:"composer-attach-btn","aria-label":i("conversation.attachFiles"),title:i("conversation.attachFiles"),disabled:!0,children:s.jsx(Zt,{})}):s.jsx("label",{htmlFor:I,className:"composer-attach-btn","aria-label":i("conversation.attachFiles"),title:i("conversation.attachFiles"),onClick:()=>{ee(!1)},children:s.jsx(Zt,{})}):null,ve?null:s.jsx(St,{ariaLabel:i("conversation.modelSelectorLabel"),value:L,options:Gs,onChange:sr}),!ve&&kt&&ie.length>0?s.jsx(St,{ariaLabel:i("conversation.reasoningSelectorLabel"),value:H,options:Zs,onChange:c=>rr(c),compact:!0}):null,Vs?s.jsxs("button",{type:"button",className:"composer-slash-btn",onClick:ur,title:i("conversation.slashMenu"),children:[s.jsx("span",{className:"slash-icon",children:"/"}),s.jsx("span",{children:i("conversation.slashMenu")})]}):null,s.jsx(qi,{contextUsage:p}),s.jsx(oi,{provider:x,messages:v,variant:"composer"})]}),yr?s.jsx("div",{className:"composer-quick-phrase-group",children:s.jsx("button",{type:"button",className:"composer-quick-phrase-trigger","aria-label":i("conversation.quickPhraseTrigger"),title:i("conversation.quickPhraseTrigger"),onClick:()=>{ke(!0),ee(!1)},children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M7 8h10"}),s.jsx("path",{d:"M7 12h8"}),s.jsx("path",{d:"M7 16h5"}),s.jsx("path",{d:"M5 5h14v14H9l-4 4V5z"})]})})}):null]})]})]}),s.jsx(Mt,{open:re,title:i("conversation.quickPhraseModalTitle"),description:i("conversation.quickPhraseModalDescription"),className:"composer-quick-phrase-modal",onClose:()=>{ke(!1),pe(!1)},children:s.jsxs("div",{className:"composer-quick-phrase-modal-body",children:[s.jsxs("div",{className:"composer-quick-phrase-toolbar",children:[s.jsx("div",{className:"composer-quick-phrase-toolbar-copy",children:s.jsx("span",{children:i("conversation.quickPhraseListLabel")})}),s.jsx("button",{type:"button",className:"primary-button",disabled:Ce,onClick:()=>pe(!0),children:i("conversation.quickPhraseOpenCreateAction")})]}),s.jsx("div",{className:"composer-quick-phrase-list",role:"list","aria-label":i("conversation.quickPhraseListLabel"),children:G.length===0?s.jsx("div",{className:"composer-quick-phrase-empty",children:i("conversation.quickPhraseEmpty")}):G.map((c,g)=>s.jsxs("div",{className:"composer-quick-phrase-item",role:"listitem",children:[s.jsxs("button",{type:"button",className:"composer-quick-phrase-select",onClick:()=>fr(c.text),children:[s.jsx("span",{className:"composer-quick-phrase-order",children:i("conversation.quickPhraseOrderLabel",{index:g+1})}),s.jsx("span",{className:"composer-quick-phrase-text",children:c.text})]}),s.jsxs("div",{className:"composer-quick-phrase-actions",children:[s.jsx("button",{type:"button",className:"composer-quick-phrase-action",disabled:Ce||g===0,"aria-label":i("conversation.quickPhraseMoveUp"),title:i("conversation.quickPhraseMoveUp"),onClick:()=>wn(c.id,-1),children:"↑"}),s.jsx("button",{type:"button",className:"composer-quick-phrase-action",disabled:Ce||g===G.length-1,"aria-label":i("conversation.quickPhraseMoveDown"),title:i("conversation.quickPhraseMoveDown"),onClick:()=>wn(c.id,1),children:"↓"}),s.jsx("button",{type:"button",className:"composer-quick-phrase-action is-danger",disabled:Ce,"aria-label":i("conversation.quickPhraseDelete"),title:i("conversation.quickPhraseDelete"),onClick:()=>pr(c.id),children:"×"})]})]},c.id))})]})}),s.jsx(Mt,{open:xt,title:i("conversation.quickPhraseCreateModalTitle"),description:i("conversation.quickPhraseCreateModalDescription"),className:"composer-quick-phrase-create-modal",onClose:()=>pe(!1),children:s.jsxs("div",{className:"composer-quick-phrase-modal-body",children:[s.jsxs("label",{className:"workbench-modal-field",children:[s.jsx("span",{children:i("conversation.quickPhraseCreateLabel")}),s.jsx("textarea",{className:"composer-quick-phrase-textarea",value:Oe,placeholder:i("conversation.quickPhraseCreatePlaceholder"),rows:4,onChange:c=>bt(c.target.value)})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",onClick:()=>pe(!1),children:i("common.cancel")}),s.jsx("button",{type:"button",className:"primary-button",disabled:Ce||Oe.trim().length===0,onClick:()=>{mr()},children:i("conversation.quickPhraseCreateAction")})]})]})}),s.jsx(Mt,{open:ge!==null,title:i("conversation.forkSwitchConfirmTitle"),description:i("conversation.forkSwitchConfirmDescription"),className:"composer-fork-confirm-modal",onClose:Sn,children:s.jsxs("div",{className:"composer-fork-confirm-body",children:[s.jsxs("div",{className:"composer-fork-confirm-list",children:[s.jsxs("div",{className:"composer-fork-confirm-item",children:[s.jsx("span",{className:"composer-fork-confirm-icon is-keep","aria-hidden":"true",children:s.jsx(Bi,{})}),s.jsxs("div",{className:"composer-fork-confirm-copy",children:[s.jsx("strong",{children:i("conversation.forkSwitchConfirmKeepTitle")}),s.jsx("p",{children:i("conversation.forkSwitchConfirmKeepBody")})]})]}),s.jsxs("div",{className:"composer-fork-confirm-item",children:[s.jsx("span",{className:"composer-fork-confirm-icon is-convert","aria-hidden":"true",children:s.jsx(Oi,{})}),s.jsxs("div",{className:"composer-fork-confirm-copy",children:[s.jsx("strong",{children:i("conversation.forkSwitchConfirmConvertTitle")}),s.jsx("p",{children:i("conversation.forkSwitchConfirmConvertBody")})]})]}),s.jsxs("div",{className:"composer-fork-confirm-item",children:[s.jsx("span",{className:"composer-fork-confirm-icon is-drop","aria-hidden":"true",children:s.jsx(_i,{})}),s.jsxs("div",{className:"composer-fork-confirm-copy",children:[s.jsx("strong",{children:i("conversation.forkSwitchConfirmDropTitle")}),s.jsx("p",{children:i("conversation.forkSwitchConfirmDropBody")})]})]})]}),s.jsxs("div",{className:"workbench-modal-actions",children:[s.jsx("button",{type:"button",className:"secondary-button",onClick:Sn,children:i("conversation.forkSwitchKeepNative")}),s.jsx("button",{type:"button",className:"primary-button",onClick:vr,children:i("conversation.forkSwitchConfirmAction")})]})]})}),s.jsx(Pi,{open:Ee&&R.isNativeMobile,onClose:()=>se(!1),onSelectCamera:()=>jn("camera"),onSelectLibrary:()=>jn("library")})]});return u?on.createPortal(An,u):An}function Pi({open:e,onClose:t,onSelectCamera:n,onSelectLibrary:r}){return s.jsx(qr,{open:e,title:i("conversation.attachmentSourceSheetTitle"),description:i("conversation.attachmentSourceSheetDescription"),kind:"action",height:"auto",className:"composer-attachment-sheet",cardClassName:"composer-attachment-sheet-card",bodyClassName:"composer-attachment-sheet-body",showHandle:!0,onClose:t,children:s.jsxs(Wr,{className:"composer-attachment-sheet-actions",children:[s.jsx(In,{as:"button",className:"mobile-workspace-home-row composer-attachment-sheet-option","aria-label":i("conversation.attachmentTakePhoto"),label:i("conversation.attachmentTakePhoto"),description:i("conversation.attachmentTakePhotoHint"),trailing:s.jsx(Ii,{}),onClick:n}),s.jsx(In,{as:"button",className:"mobile-workspace-home-row composer-attachment-sheet-option","aria-label":i("conversation.attachmentChooseFromLibrary"),label:i("conversation.attachmentChooseFromLibrary"),description:i("conversation.attachmentChooseFromLibraryHint"),trailing:s.jsx(Ei,{}),onClick:r})]})})}function Ii(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M4 8h3l1.5-2h7L17 8h3a1 1 0 0 1 1 1v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9a1 1 0 0 1 1-1Z"}),s.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}function Zt(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),s.jsx("path",{d:"M8 12h8M12 8v8"})]})}function Ei(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2.5"}),s.jsx("path",{d:"m7.5 15 3-3 2.5 2.5 3-4L18 13.5"}),s.jsx("circle",{cx:"8.75",cy:"8.75",r:"1.25",fill:"currentColor",stroke:"none"})]})}function Bi(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M12 3 4 7v5c0 5 3.5 8 8 9 4.5-1 8-4 8-9V7l-8-4Z"}),s.jsx("path",{d:"m9.5 12 1.8 1.8L15 10.2"})]})}function Oi(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"M4 7h9"}),s.jsx("path",{d:"m10 3 4 4-4 4"}),s.jsx("path",{d:"M20 17h-9"}),s.jsx("path",{d:"m14 13-4 4 4 4"})]})}function _i(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[s.jsx("path",{d:"m7 7 10 10"}),s.jsx("path",{d:"M17 7 7 17"}),s.jsx("path",{d:"M12 3v2"}),s.jsx("path",{d:"M12 19v2"})]})}function St({ariaLabel:e,value:t,options:n,onChange:r,disabled:a=!1,compact:o=!1}){const[l,u]=d.useState(!1),m=d.useRef(null),y=d.useRef(null),p=d.useRef(null),[x,v]=d.useState(null),j=d.useId(),b=n.find(C=>C.value===t)??n[0]??null,h=d.useCallback(()=>{const C=y.current;if(!C||typeof window>"u")return;const T=C.getBoundingClientRect(),M=window.innerWidth,R=window.innerHeight,I=12,D=10,A=Math.max(160,M-I*2),F=o?140:220,L=Math.min(A,Math.max(T.width,F)),$=Math.min(Math.max(I,T.left),Math.max(I,M-L-I)),H=T.top-I,X=R-T.bottom-I,U=H>=180||H>=X;v({position:"fixed",left:$,width:L,maxWidth:A,top:U?void 0:T.bottom+D,bottom:U?R-T.top+D:void 0})},[o]);return d.useEffect(()=>{if(!l)return;function C(M){var I,D;const R=M.target;!((I=m.current)!=null&&I.contains(R))&&!((D=p.current)!=null&&D.contains(R))&&u(!1)}function T(M){M.key==="Escape"&&u(!1)}return window.addEventListener("pointerdown",C),window.addEventListener("keydown",T),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),h(),()=>{window.removeEventListener("pointerdown",C),window.removeEventListener("keydown",T),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}},[l,h]),b?s.jsxs("div",{ref:m,className:`composer-mac-select ${o?"is-compact":""}`,"data-open":l?"true":"false",children:[s.jsxs("button",{ref:y,type:"button",className:"composer-mac-select-trigger","aria-label":e,"aria-haspopup":"listbox","aria-expanded":l,"aria-controls":j,disabled:a,onClick:()=>u(C=>!C),children:[s.jsx("span",{className:"composer-mac-select-label",children:b.label}),s.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),l&&x&&typeof document<"u"?on.createPortal(s.jsx("div",{ref:p,className:"composer-mac-select-popover",style:x,role:"presentation",children:s.jsx("div",{id:j,className:"composer-mac-select-list",role:"listbox","aria-label":e,children:n.map(C=>{const T=C.value===t;return s.jsxs("button",{type:"button",role:"option","aria-selected":T,className:`composer-mac-select-option ${T?"is-selected":""}`,onClick:()=>{r(C.value),u(!1)},children:[s.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:T?"✓":""}),s.jsx("span",{className:"composer-mac-select-option-label",children:C.label})]},C.value)})})}),document.body):null]}):null}function qi({contextUsage:e}){const[t,n]=d.useState(!1),r=d.useRef(null),a=d.useRef(null),[o,l]=d.useState(null),u=d.useId(),m=e?Math.round(e.usageRatio*100):null,y=e?Math.max(0,Math.min(e.usageRatio,1)):0,p=Wi(y),x=e?Fi(e.contextWindowSource):null,v=e?`${i("conversation.contextUsageTitle")} ${m}%`:i("conversation.contextUsageUnavailable"),j=d.useCallback(()=>{const b=r.current;if(!b||typeof window>"u")return;const h=b.getBoundingClientRect(),C=window.innerWidth,T=window.innerHeight,M=12,R=10,I=Math.min(240,Math.max(188,C-M*2)),D=Math.min(Math.max(M,h.left+h.width/2-I/2),Math.max(M,C-I-M)),A=h.top-M,F=T-h.bottom-M,L=A>=140||A>=F;l({position:"fixed",left:D,width:I,maxWidth:C-M*2,top:L?void 0:h.bottom+R,bottom:L?T-h.top+R:void 0})},[]);return d.useEffect(()=>{if(!t)return;function b(C){var M,R;const T=C.target;!((M=r.current)!=null&&M.contains(T))&&!((R=a.current)!=null&&R.contains(T))&&n(!1)}function h(C){C.key==="Escape"&&n(!1)}return window.addEventListener("pointerdown",b),window.addEventListener("keydown",h),window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),j(),()=>{window.removeEventListener("pointerdown",b),window.removeEventListener("keydown",h),window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[t,j]),s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:r,type:"button",className:`composer-context-ring ${p}`,style:{"--context-usage-progress":`${y}`},"aria-label":v,"aria-expanded":t,"aria-describedby":t?u:void 0,onClick:()=>n(b=>!b),onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),onFocus:()=>n(!0),onBlur:()=>n(!1),children:s.jsx("span",{className:"composer-context-ring-value",children:m===null?"--":s.jsxs(s.Fragment,{children:[s.jsx("span",{children:m}),s.jsx("span",{className:"composer-context-ring-suffix",children:"%"})]})})}),t&&o&&typeof document<"u"?on.createPortal(s.jsx("div",{ref:a,id:u,className:"composer-context-tooltip",style:o,role:"tooltip",children:e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"composer-context-tooltip-title",children:i("conversation.contextUsageTitle")}),s.jsxs("div",{className:"composer-context-tooltip-line",children:[m,"% · ",Qt(e.promptTokens)," /"," ",Qt(e.contextWindow)," tokens"]}),e.cachedInputTokens>0?s.jsx("div",{className:"composer-context-tooltip-line",children:i("conversation.contextUsageCachedTokens").replace("{count}",Qt(e.cachedInputTokens))}):null,x?s.jsx("div",{className:"composer-context-tooltip-meta",children:x}):null,e.isEstimated?s.jsx("div",{className:"composer-context-tooltip-meta",children:i("conversation.contextUsageEstimated")}):null]}):s.jsx("div",{className:"composer-context-tooltip-line",children:i("conversation.contextUsageUnavailable")})}),document.body):null]})}function Wi(e){return e>=.95?"is-critical":e>=.8?"is-warning":"is-normal"}function Fi(e){switch(e){case"provider-log":return i("conversation.contextUsageSourceProviderLog");case"provider-runtime":return i("conversation.contextUsageSourceProviderRuntime");case"provider-config":return i("conversation.contextUsageSourceProviderConfig");case"model-map":return i("conversation.contextUsageSourceModelMap");default:return""}}function Qt(e){return new Intl.NumberFormat().format(e)}const Lt="*** Begin Patch",Pt="*** End Patch";function zn(e){const t=e.replace(/\r\n/g,`
|
|
2
2
|
`);if(!t.includes(Lt)||!t.includes(Pt))return null;const n=t.split(`
|
|
3
|
-
`),r=[];let a=null,o=null;for(const l of n){if(l===Lt||l===Pt)continue;if(l.startsWith("*** Update File: ")){a=Jt("update",l.slice(17)),r.push(a),o=null;continue}if(l.startsWith("*** Add File: ")){a=Jt("add",l.slice(14)),r.push(a),o={oldLineNumber:0,newLineNumber:1};continue}if(l.startsWith("*** Delete File: ")){a=Jt("delete",l.slice(17)),r.push(a),o=null;continue}if(!a)continue;if(l.startsWith("*** Move to: ")){a.nextPath=l.slice(13),a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null});continue}if(l.startsWith("@@")){o=$i(l)??{oldLineNumber:0,newLineNumber:0},a.lines.push({kind:"hunk",text:l,oldLineNumber:null,newLineNumber:null});continue}if(l==="*** End of File"){a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null});continue}if(a.action==="add"&&l.startsWith("+")){a.additions+=1,a.statsKnown=!0,a.lines.push({kind:"add",text:l,oldLineNumber:null,newLineNumber:(o==null?void 0:o.newLineNumber)??a.additions}),o&&(o.newLineNumber+=1);continue}if(!o){a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null});continue}if(l.startsWith("+")){a.additions+=1,a.statsKnown=!0,a.lines.push({kind:"add",text:l,oldLineNumber:null,newLineNumber:o.newLineNumber}),o.newLineNumber+=1;continue}if(l.startsWith("-")){a.deletions+=1,a.statsKnown=!0,a.lines.push({kind:"remove",text:l,oldLineNumber:o.oldLineNumber,newLineNumber:null}),o.oldLineNumber+=1;continue}if(l.startsWith(" ")||l.length===0){a.lines.push({kind:"context",text:l,oldLineNumber:o.oldLineNumber,newLineNumber:o.newLineNumber}),o.oldLineNumber+=1,o.newLineNumber+=1;continue}a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null})}return r.length===0?null:{files:r,totalAdditions:r.reduce((l,
|
|
3
|
+
`),r=[];let a=null,o=null;for(const l of n){if(l===Lt||l===Pt)continue;if(l.startsWith("*** Update File: ")){a=Jt("update",l.slice(17)),r.push(a),o=null;continue}if(l.startsWith("*** Add File: ")){a=Jt("add",l.slice(14)),r.push(a),o={oldLineNumber:0,newLineNumber:1};continue}if(l.startsWith("*** Delete File: ")){a=Jt("delete",l.slice(17)),r.push(a),o=null;continue}if(!a)continue;if(l.startsWith("*** Move to: ")){a.nextPath=l.slice(13),a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null});continue}if(l.startsWith("@@")){o=$i(l)??{oldLineNumber:0,newLineNumber:0},a.lines.push({kind:"hunk",text:l,oldLineNumber:null,newLineNumber:null});continue}if(l==="*** End of File"){a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null});continue}if(a.action==="add"&&l.startsWith("+")){a.additions+=1,a.statsKnown=!0,a.lines.push({kind:"add",text:l,oldLineNumber:null,newLineNumber:(o==null?void 0:o.newLineNumber)??a.additions}),o&&(o.newLineNumber+=1);continue}if(!o){a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null});continue}if(l.startsWith("+")){a.additions+=1,a.statsKnown=!0,a.lines.push({kind:"add",text:l,oldLineNumber:null,newLineNumber:o.newLineNumber}),o.newLineNumber+=1;continue}if(l.startsWith("-")){a.deletions+=1,a.statsKnown=!0,a.lines.push({kind:"remove",text:l,oldLineNumber:o.oldLineNumber,newLineNumber:null}),o.oldLineNumber+=1;continue}if(l.startsWith(" ")||l.length===0){a.lines.push({kind:"context",text:l,oldLineNumber:o.oldLineNumber,newLineNumber:o.newLineNumber}),o.oldLineNumber+=1,o.newLineNumber+=1;continue}a.lines.push({kind:"meta",text:l,oldLineNumber:null,newLineNumber:null})}return r.length===0?null:{files:r,totalAdditions:r.reduce((l,u)=>l+u.additions,0),totalDeletions:r.reduce((l,u)=>l+u.deletions,0)}}function Ui(e,t=[]){const n=e.replace(/\r\n/g,`
|
|
4
4
|
`).trim();if(!n)return null;if(n.includes(Lt)&&n.includes(Pt))return n;const r=[...new Set(t.map(a=>a.trim()).filter(a=>a.length>0))];return r.length!==1||!Hi(n)?null:[Lt,`*** Update File: ${r[0]}`,n,Pt].join(`
|
|
5
5
|
`)}function zi(e){const t=Ki(e);if(!t)return[];const n=t.replace(/\r\n/g,`
|
|
6
6
|
`).split(`
|
|
7
|
-
`),r=[];let a=!1;for(const o of n){const l=o.trim();if(!a){/^Success\.\s+Updated the following files:/i.test(l)&&(a=!0);continue}if(!l){if(r.length>0)break;continue}const
|
|
8
|
-
@@`)||e.startsWith("+")||e.startsWith("-")}function Ki(e){const t=e.trim();if(!t)return"";if(!t.startsWith("{"))return t;try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n;if(typeof r.output=="string"&&r.output.trim().length>0)return r.output;if(typeof r.result=="string"&&r.result.trim().length>0)return r.result;if(typeof r.message=="string"&&r.message.trim().length>0)return r.message}catch{return t}return t}const Vi=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,Gi=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,
|
|
7
|
+
`),r=[];let a=!1;for(const o of n){const l=o.trim();if(!a){/^Success\.\s+Updated the following files:/i.test(l)&&(a=!0);continue}if(!l){if(r.length>0)break;continue}const u=l.match(/^[A-Z?]\s+(.+)$/),m=((u==null?void 0:u[1])??l).trim();if(!m)break;r.push(m)}return[...new Set(r)]}function Di(e){return e.replace(/\\/g,"/").split("/").at(-1)||e}function Jt(e,t){return{path:t,nextPath:null,action:e,additions:0,deletions:0,statsKnown:!1,lines:[]}}function $i(e){const t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function Hi(e){return e.startsWith("@@")||e.startsWith("*** Update File: ")||e.startsWith("*** Add File: ")||e.startsWith("*** Delete File: ")||e.includes(`
|
|
8
|
+
@@`)||e.startsWith("+")||e.startsWith("-")}function Ki(e){const t=e.trim();if(!t)return"";if(!t.startsWith("{"))return t;try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n;if(typeof r.output=="string"&&r.output.trim().length>0)return r.output;if(typeof r.result=="string"&&r.result.trim().length>0)return r.result;if(typeof r.message=="string"&&r.message.trim().length>0)return r.message}catch{return t}return t}const Vi=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,Gi=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,Zi=/<img\b[^>]*src=["'](data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)["'][^>]*>/gi,Qi=/<image\b([^>]*)>([\s\S]*?)<\/image>/gi,Ji=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g;function ut(e){const t=Yi(e),n=Xi(t);return n||ys(t)}function Yi(e){return e.replace(Ji,"")}function Xi(e){const t=e.trim();if(!ea(t))return null;try{const n=JSON.parse(t),r=ta(n);return r.text||r.inlineImages.length>0?r:null}catch{return null}}function ea(e){return e.length<2?!1:e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")}function ta(e){const t=[],n=[];return At(e,t,n),{text:Cs(t.join(`
|
|
9
9
|
|
|
10
|
-
`)),inlineImages:ks(n)}}function At(e,t,n){if(typeof e=="string"){const l=ys(e);l.text&&t.push(l.text),n.push(...l.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(l=>At(l,t,n));return}if(typeof e!="object")return;const r=e,a=new Set,o=na(r);o&&(n.push(o),["type","source","media_type","mime_type","mimeType","data","image_url","imageUrl","url","src","alt","name"].forEach(l=>{l in r&&a.add(l)}));for(const l of["image_url","url","src","source"]){const
|
|
10
|
+
`)),inlineImages:ks(n)}}function At(e,t,n){if(typeof e=="string"){const l=ys(e);l.text&&t.push(l.text),n.push(...l.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(l=>At(l,t,n));return}if(typeof e!="object")return;const r=e,a=new Set,o=na(r);o&&(n.push(o),["type","source","media_type","mime_type","mimeType","data","image_url","imageUrl","url","src","alt","name"].forEach(l=>{l in r&&a.add(l)}));for(const l of["image_url","url","src","source"]){const u=r[l];typeof u!="string"||!js(u)||(n.push(Pe(u,ne(r.alt))),a.add(l))}for(const l of["text","message","content","output","result","summary","caption"])l in r&&(a.add(l),At(r[l],t,n));a.size>0||Object.values(r).forEach(l=>{At(l,t,n)})}function ys(e){const t=[];let n=e;return n=n.replace(Qi,(r,a,o)=>{const l=oa(a,"name"),u=aa(o);return u!=null&&u.url&&t.push(Pe(u.url,u.altText||l)),""}),n=n.replace(Gi,(r,a,o)=>(t.push(Pe(o,a)),"")),n=n.replace(Zi,(r,a)=>(t.push(Pe(a,null)),"")),n=n.replace(Vi,(r,a,o)=>(t.push(Pe(r,null,`image/${a}`,It(o))),"")),{text:Cs(n),inlineImages:ks(t)}}function Pe(e,t,n,r){const a=n??sa(e)??"image/png";return{url:e,mimeType:a,altText:dt(t),estimatedBytes:r??ra(e)}}function na(e){const t=ia(e.source);if(t){const a=ne(t.type).trim().toLowerCase(),o=$n(t.media_type??t.mime_type??t.mimeType),l=Dn(t.data);if(a==="base64"&&o&&l)return Pe(`data:${o};base64,${l}`,dt(ne(t.alt)||ne(t.name)||ne(e.alt)||ne(e.name)),o,It(l))}const n=$n(e.media_type??e.mime_type??e.mimeType),r=Dn(e.data);return n&&r?Pe(`data:${n};base64,${r}`,dt(ne(e.alt)||ne(e.name)),n,It(r)):null}function ks(e){const t=new Map;return e.forEach(n=>{t.has(n.url)||t.set(n.url,n)}),[...t.values()]}function Cs(e){return e.replace(/\r\n/g,`
|
|
11
11
|
`).replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
|
|
12
12
|
`).replace(/\n{3,}/g,`
|
|
13
13
|
|
|
14
|
-
`).trim()}function js(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function sa(e){var n;const t=e.match(/^data:(image\/[a-zA-Z0-9.+-]+);base64,/i);return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())??null}function ra(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?It(t[1]):null}function It(e){const t=e.trim(),n=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.max(0,Math.floor(t.length*3/4)-n)}function dt(e){const t=ne(e).trim();return t.length>0?t:null}function Dn(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function $n(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.startsWith("image/")?t:null}function ne(e){return typeof e=="string"?e:""}function ia(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function aa(e){const t=e.trim();if(t.length===0)return null;try{const n=JSON.parse(t),r=ne(n.image_url??n.imageUrl).trim(),a=dt(ne(n.name)||ne(n.alt));return{url:js(r)?r:null,altText:a}}catch{const n=t.match(/(data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)/i);return n?{url:n[1],altText:null}:null}}function oa(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e.match(new RegExp(`${n}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return dt((r==null?void 0:r[1])??(r==null?void 0:r[2])??(r==null?void 0:r[3])??(r==null?void 0:r[4])??"")}const ws="codingns.user-app.conversation-scroll",$e=1,la=200,ca=1e7;function Ns(){return typeof window<"u"&&typeof window.localStorage<"u"}function Ss(e){return e.trim()}function Ts(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),ca)}function Rs(e){return!e||typeof e!="object"?null:{scrollTop:Ts(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function Ms(){if(!Ns())return{schemaVersion:$e,bySessionId:{}};const e=window.localStorage.getItem(ws);if(!e)return{schemaVersion:$e,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==$e||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:$e,bySessionId:{}};const n=Object.fromEntries(Object.entries(t.bySessionId).map(([r,a])=>{const o=Rs(a);return o?[r,o]:null}).filter(r=>!!r));return{schemaVersion:$e,bySessionId:n}}catch{return{schemaVersion:$e,bySessionId:{}}}}function ua(e){if(Ns())try{window.localStorage.setItem(ws,JSON.stringify(e))}catch{}}function Tt(e){const t=Ss(e);if(!t)return null;const n=Ms().bySessionId[t],r=Rs(n);return r?{scrollTop:r.scrollTop,stickToBottom:r.stickToBottom,lastMessageSignature:r.lastMessageSignature}:null}function Hn(e,t){const n=Ss(e);if(!n)return;const r=Ms();r.bySessionId[n]={scrollTop:Ts(t.scrollTop),stickToBottom:t.stickToBottom,lastMessageSignature:t.lastMessageSignature,updatedAt:Date.now()};const a=Object.entries(r.bySessionId).sort((o,l)=>l[1].updatedAt-o[1].updatedAt).slice(0,la);r.bySessionId=Object.fromEntries(a),ua(r)}function da(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function As(e){var r;const t=e.match(/^\s*<turn_aborted>([\s\S]*?)<\/turn_aborted>\s*$/i);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";return!n||/^previous turn aborted$/i.test(n)?{detail:null}:{detail:n}}function ma(e){return e==="user"?i("conversation.turnAbortedUser"):e==="runtime"?i("conversation.turnAbortedUnexpected"):i("conversation.turnAbortedGeneric")}const pa=480,Kn=80,Vn=240,fa=120,ha=18,ga=50,va=3500,Ls=u.createContext(!1);function rn(e){return e.replace(/\\/g,"/")}function Et(e){return/^[a-zA-Z]:\//.test(e)}function xa(e){return e.startsWith("/")||e.startsWith("//")||Et(e)}function ba(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!Et(e)}function Gn(e){return e.replace(/\/+$/,"")}function ya(e){const t=e.indexOf("#"),n=t>=0?e.slice(0,t):e,r=n.indexOf("?");return(r>=0?n.slice(0,r):n).replace(/:(\d+)(?::(\d+))?$/,"")}function ka(e){const t=[];for(const n of rn(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")}function cn(e){try{return decodeURIComponent(e)}catch{return e}}function Ca(e,t){const n=cn(e).trim();if(!n||n.startsWith("#"))return null;let r=n;if(/^file:\/\//i.test(r))try{r=decodeURIComponent(new URL(r).pathname),/^\/[a-zA-Z]:\//.test(r)&&(r=r.slice(1))}catch{return null}else if(ba(r))return null;if(r=rn(ya(r.trim())),!r)return null;const a=Gn(rn(t.trim()));if(!a)return null;if(xa(r)){const o=Gn(r),l=Et(a)?a.toLowerCase():a,d=Et(o)?o.toLowerCase():o;if(d===l)return null;const m=`${l}/`;return d.startsWith(m)?o.slice(a.length+1):null}return ka(r)}function Bt(e){return e.kind==="tool_call"||e.kind==="tool_result"}function Ps(e){return e.toolCall?e.toolCall:Bt(e)?{callId:e.rawRef||e.id,name:"tool",input:e.kind==="tool_call"?e.content:"",output:e.kind==="tool_result"&&e.content?e.content:null,error:null,status:e.kind==="tool_call"?"running":"completed"}:null}function ja(e){return e==="shell_command"||e==="tool"?i("conversation.roleTool"):e}function un(e){if(!e.trim())return null;try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function Ae(e,t){const n=e[t];return typeof n=="string"?n:""}function mt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function z(e,t){if(!e)return null;const n=e[t];return mt(n)?n:null}function Yt(e,t){if(!e)return null;const n=e[t];return Array.isArray(n)?n:null}function P(e,t){if(!e)return null;const n=e[t];if(typeof n=="string"){const r=n.trim();return r||null}return typeof n=="number"||typeof n=="boolean"?String(n):null}function wa(e){const t=[e.output,e.input];for(const n of t){const r=Is(n,0);if(r)return r}return null}function Is(e,t){if(!(e!=null&&e.trim())||t>2)return null;try{return Es(JSON.parse(e),t)}catch{return null}}function Es(e,t){if(!mt(e))return null;if(Na(e))return{ok:!0,capability:P(e,"capability")??"",auditId:P(e,"auditId")??"",timestamp:P(e,"timestamp")??"",targetRef:{kind:P(z(e,"targetRef"),"kind")??"none",id:P(z(e,"targetRef"),"id")},payload:z(e,"payload")??{}};const n=["output","result","data","payload"];for(const r of n){const a=e[r];if(typeof a=="string"){const o=Is(a,t+1);if(o)return o}if(mt(a)){const o=Es(a,t+1);if(o)return o}}return null}function Na(e){return e.ok===!0&&typeof e.capability=="string"&&typeof e.auditId=="string"&&typeof e.timestamp=="string"&&mt(e.targetRef)&&mt(e.payload)}function Sa(e){const t=new Map,n=new Map,r=new Map;return e.forEach(a=>{t.set(a.workspace.id,a.workspace.name),a.sessions.forEach(o=>{const l=typeof o.title=="string"&&o.title.trim()?o.title.trim():o.sessionId;n.set(o.sessionId,l),r.set(o.sessionId,a.workspace.id)})}),{workspaceNamesById:t,sessionNamesById:n,sessionWorkspaceIdsById:r}}function Ta(e,t){const n=wa(e);return n?{...Os(n.capability),rows:_a(n,t)}:null}function Ra(e,t){const n=Ma(e);if(!n)return null;const r=Aa(n);return r?{...Ia(r),rows:Oa(r,t)}:null}function Ma(e){const t=un(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(!n)return null;const r=n.indexOf("codingns assistant");return r<0?null:n.slice(r).trim()}function Aa(e){const t=La(e),n=t.findIndex((v,x)=>v==="codingns"&&t[x+1]==="assistant");if(n<0)return null;const r=t.slice(n+2);if(r.length===0||r[0]==="--help"||r[0]==="-h")return{group:null,action:null,mode:"help",options:{},positionals:[]};if(r[0]==="help")return{group:r[1]??null,action:r[2]??null,mode:"help",options:{},positionals:[]};const a=r[0]??null,o=r[1],l=o&&!o.startsWith("-")?o:null,d=r.slice(l?2:1),{options:m,positionals:k}=Pa(d);return!l&&m["--help"]?{group:a,action:null,mode:"help",options:m,positionals:k}:{group:a,action:l,mode:"execute",options:m,positionals:k}}function La(e){const t=[],n=/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`|\S+/g;for(const r of e.matchAll(n)){const a=r[0]??"";if(!a)continue;const o=a[0];if((o==='"'||o==="'"||o==="`")&&a[a.length-1]===o){t.push(a.slice(1,-1));continue}t.push(a)}return t}function Pa(e){const t={},n=[];for(let r=0;r<e.length;r+=1){const a=e[r]??"";if(!a.startsWith("--")){n.push(a);continue}const o=e[r+1];if(!o||o.startsWith("--")){t[a]=!0;continue}t[a]=o,r+=1}return{options:t,positionals:n}}function Ia(e){if(e.mode==="help")return Ea(e.group,e.action);const t=Ba(e.group,e.action);return t?Os(t):{kind:dn(e.group),badge:Bs(e.group),title:i("conversation.assistantCapabilityQueryTitle"),summary:i("conversation.assistantCliSummaryCommand")}}function Ea(e,t){return e?e==="sessions"?{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:t?i("conversation.assistantCliHelpSessionActionTitle",{action:t}):i("conversation.assistantCliHelpSessionsTitle"),summary:i("conversation.assistantCliSummaryHelp")}:e==="timers"?{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCliHelpTimersTitle"),summary:i("conversation.assistantCliSummaryHelp")}:e==="terminals"?{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCliHelpTerminalsTitle"),summary:i("conversation.assistantCliSummaryHelp")}:e==="workspaces"||e==="worktrees"?{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCliHelpWorkspacesTitle"),summary:i("conversation.assistantCliSummaryHelp")}:{kind:dn(e),badge:Bs(e),title:i("conversation.assistantCliHelpGenericTitle",{group:e}),summary:i("conversation.assistantCliSummaryHelp")}:{kind:"query",badge:i("conversation.assistantCapabilityBadgeQuery"),title:i("conversation.assistantCliHelpRootTitle"),summary:i("conversation.assistantCliSummaryHelp")}}function Ba(e,t){const n=e==null?void 0:e.trim(),r=t==null?void 0:t.trim();return n?n==="capabilities"&&r==="list"?"capabilities.list":n==="projects"&&r==="list"?"projects.list":n==="projects"&&r==="get"?"projects.get":n==="sessions"&&r==="list"?"projects.sessions.list":n==="sessions"&&r==="get"?"sessions.get":n==="sessions"&&r==="messages"?"sessions.messages.list":n==="sessions"&&r==="runtime"?"sessions.runtime.get":n==="sessions"&&r==="start"?"projects.sessions.start":n==="sessions"&&r==="send"?"sessions.message.send":n==="sessions"&&r==="fork"?"sessions.fork":n==="timers"&&r==="create"?"timers.create":n==="timers"&&r==="cancel"?"timers.cancel":n==="timers"&&r==="list"?"timers.list":n==="terminals"&&r==="send"?"terminals.input.send":n==="terminals"&&r==="close"?"terminals.close":n==="terminals"&&r==="history"?"terminals.history.read":n==="terminals"&&r==="list"?"terminals.list":n==="workspaces"&&r==="list"?"workspaces.list":n==="workspaces"&&r==="clone"?"workspaces.clone":n==="workspaces"&&r==="import"?"workspaces.import":n==="workspaces"&&r==="management"?"workspaces.management.get":n==="worktrees"&&r==="tree"?"worktrees.tree":n==="worktrees"&&r==="create"?"worktrees.create":null:null}function dn(e){switch(e){case"sessions":case"projects":return"session";case"timers":return"automation";case"terminals":return"terminal";case"workspaces":case"worktrees":return"workspace";case"debug-targets":case"debug-runtimes":return"debug";default:return"query"}}function Bs(e){switch(dn(e)){case"session":return i("conversation.assistantCapabilityBadgeSession");case"automation":return i("conversation.assistantCapabilityBadgeAutomation");case"terminal":return i("conversation.assistantCapabilityBadgeTerminal");case"workspace":return i("conversation.assistantCapabilityBadgeWorkspace");case"debug":return i("conversation.assistantCapabilityBadgeDebug");case"query":default:return i("conversation.assistantCapabilityBadgeQuery")}}function Oa(e,t){const n=[],r=He(e,"--session-id")??e.positionals[0]??null,a=He(e,"--project")??He(e,"--project-id");return e.mode==="help"?(S(n,i("conversation.assistantCliLabelScope"),e.group??i("conversation.assistantCliScopeRoot")),S(n,i("conversation.assistantCliLabelAction"),e.action),n):(e.group==="sessions"&&S(n,i("conversation.assistantCapabilityLabelSession"),Ie(r,null,t)),e.group==="timers"&&(S(n,i("conversation.assistantCapabilityLabelSession"),Ie(r,null,t)),S(n,i("conversation.assistantCliLabelDelay"),He(e,"--after-seconds"))),e.group==="terminals"&&S(n,i("conversation.assistantCapabilityLabelTerminal"),e.positionals[0]??null),(e.group==="workspaces"||e.group==="worktrees")&&S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(e.positionals[0]??null,null,t)),S(n,i("conversation.assistantCliLabelProject"),a),S(n,i("conversation.assistantCliLabelMessage"),He(e,"--message")),S(n,i("conversation.assistantCliLabelInput"),He(e,"--input")),n.slice(0,4))}function He(e,t){const n=e.options[t];return typeof n=="string"?n:null}function Os(e){switch(e){case"projects.sessions.start":return{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilityProjectSessionStartTitle"),summary:i("conversation.assistantCapabilitySummarySessionStart")};case"sessions.message.send":return{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilitySessionSendTitle"),summary:i("conversation.assistantCapabilitySummarySessionSend")};case"sessions.fork":return{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilitySessionForkTitle"),summary:i("conversation.assistantCapabilitySummarySessionFork")};case"timers.create":return{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCapabilityTimerCreateTitle"),summary:i("conversation.assistantCapabilitySummaryTimerCreate")};case"timers.cancel":return{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCapabilityTimerCancelTitle"),summary:i("conversation.assistantCapabilitySummaryTimerCancel")};case"terminals.input.send":return{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCapabilityTerminalInputTitle"),summary:i("conversation.assistantCapabilitySummaryTerminalInput")};case"terminals.close":return{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCapabilityTerminalCloseTitle"),summary:i("conversation.assistantCapabilitySummaryTerminalClose")};case"workspaces.directory.create":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceDirectoryCreateTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.import":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceImportTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.clone":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceCloneTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.navigation-state.update":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceNavigationUpdateTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.remove":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceRemoveTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"worktrees.create":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorktreeCreateTitle"),summary:i("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.merge-into-parent":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorktreeMergeTitle"),summary:i("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.cleanup":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorktreeCleanupTitle"),summary:i("conversation.assistantCapabilitySummaryWorktree")};case"debug-targets.run":return{kind:"debug",badge:i("conversation.assistantCapabilityBadgeDebug"),title:i("conversation.assistantCapabilityDebugRunTitle"),summary:i("conversation.assistantCapabilitySummaryDebug")};default:return e.startsWith("sessions.")||e.startsWith("projects.")?{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilitySessionReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("timers.")?{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCapabilityAutomationReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("terminals.")?{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCapabilityTerminalReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("workspaces.")||e.startsWith("worktrees.")?{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("debug-targets.")||e.startsWith("debug-runtimes.")?{kind:"debug",badge:i("conversation.assistantCapabilityBadgeDebug"),title:i("conversation.assistantCapabilityDebugReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:{kind:"query",badge:i("conversation.assistantCapabilityBadgeQuery"),title:i("conversation.assistantCapabilityQueryTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}}}function _a(e,t){const n=[],r=e.payload;switch(e.capability){case"projects.sessions.start":{const a=z(r,"session");S(n,i("conversation.assistantCapabilityLabelSession"),Ie(P(a,"sessionId"),P(a,"title"),t)),S(n,i("conversation.assistantCapabilityLabelProvider"),P(a,"provider"));break}case"sessions.message.send":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelSession"),Ie(e.targetRef.id,null,t)),S(n,i("conversation.assistantCapabilityLabelWorkspace"),_s(e.targetRef.id,t)),S(n,i("conversation.assistantCapabilityLabelStatus"),i("conversation.assistantCapabilityStatusCompleted")),S(n,i("conversation.assistantCapabilityLabelDueAt"),Qn(P(a,"acceptedAt")??e.timestamp));break}case"sessions.fork":{const a=z(r,"session");S(n,i("conversation.assistantCapabilityLabelSession"),Ie(P(a,"sessionId"),P(a,"title"),t)),S(n,i("conversation.assistantCapabilityLabelProvider"),P(a,"provider"));break}case"timers.create":case"timers.cancel":{const a=z(r,"timer"),o=z(a,"controlSession"),l=z(o,"session");S(n,i("conversation.assistantCapabilityLabelTimer"),P(a,"title")),S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(l,"workspaceId"),null,t)),S(n,i("conversation.assistantCapabilityLabelSession"),Ie(P(a,"targetSessionId"),null,t)),S(n,i("conversation.assistantCapabilityLabelDueAt"),Qn(P(a,"dueAt"))),S(n,i("conversation.assistantCapabilityLabelStatus"),Fa(P(a,"status")));break}case"terminals.input.send":case"terminals.close":S(n,i("conversation.assistantCapabilityLabelTerminal"),e.targetRef.id);break;case"workspaces.directory.create":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelPath"),P(a,"path"));break}case"workspaces.import":case"workspaces.clone":case"workspaces.remove":{const a=z(r,"workspace");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(a,"id")??e.targetRef.id,P(a,"name"),t)),S(n,i("conversation.assistantCapabilityLabelPath"),P(a,"path"));break}case"workspaces.navigation-state.update":{const a=z(r,"state");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(a,"workspaceId")??e.targetRef.id,null,t)),S(n,i("conversation.assistantCapabilityLabelStatus"),P(a,"collapsed")==="true"?i("conversation.assistantCapabilityNavigationCollapsed"):i("conversation.assistantCapabilityNavigationExpanded"));break}case"worktrees.create":{const a=z(r,"result"),o=z(a,"workspace");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(o,"id")??e.targetRef.id,P(o,"name"),t)),S(n,i("conversation.assistantCapabilityLabelBranch"),P(a,"branchName"));break}case"worktrees.merge-into-parent":case"worktrees.cleanup":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(e.targetRef.id,null,t)),S(n,i("conversation.assistantCapabilityLabelStatus"),P(a,"status"));break}case"debug-targets.run":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelDebugTarget"),e.targetRef.id),S(n,i("conversation.assistantCapabilityLabelRuntime"),P(a,"runtimeId"));break}}return qa(n,e,t),n.slice(0,4)}function qa(e,t,n){t.targetRef.kind==="session"&&(S(e,i("conversation.assistantCapabilityLabelSession"),Ie(t.targetRef.id,null,n)),S(e,i("conversation.assistantCapabilityLabelWorkspace"),_s(t.targetRef.id,n))),(t.targetRef.kind==="workspace"||t.targetRef.kind==="worktree")&&S(e,i("conversation.assistantCapabilityLabelWorkspace"),ye(t.targetRef.id,null,n)),t.targetRef.kind==="terminal"&&S(e,i("conversation.assistantCapabilityLabelTerminal"),t.targetRef.id),t.targetRef.kind==="timer"&&S(e,i("conversation.assistantCapabilityLabelTimer"),t.targetRef.id);const r=Wa(t.payload);r!==null&&S(e,i("conversation.assistantCapabilityLabelCount"),String(r))}function S(e,t,n){const r=n==null?void 0:n.trim();r&&(e.some(a=>a.label===t)||e.push({label:t,value:r}))}function Ie(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const a=e==null?void 0:e.trim();return a?n.sessionNamesById.get(a)??a:null}function ye(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const a=e==null?void 0:e.trim();return a?n.workspaceNamesById.get(a)??a:null}function _s(e,t){const n=e==null?void 0:e.trim();return n?ye(t.sessionWorkspaceIdsById.get(n)??null,null,t):null}function Wa(e){const t=Yt(e,"items");if(t)return t.length;const n=z(e,"page"),r=Yt(n,"items");if(r)return r.length;const a=z(e,"history"),o=Yt(a,"items");return o?o.length:null}function Qn(e){const t=e==null?void 0:e.trim();if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n)):t}function Fa(e){switch(e){case"active":return i("conversation.assistantCapabilityStatusActive");case"completed":return i("conversation.assistantCapabilityStatusCompleted");case"cancelled":return i("conversation.assistantCapabilityStatusCancelled");case"failed":return i("conversation.assistantCapabilityStatusFailed");default:return e}}function Ua({kind:e}){switch(e){case"session":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M5 7.5A2.5 2.5 0 0 1 7.5 5h9A2.5 2.5 0 0 1 19 7.5v5A2.5 2.5 0 0 1 16.5 15H11l-4 4v-4H7.5A2.5 2.5 0 0 1 5 12.5z"})});case"automation":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"7.5"}),s.jsx("path",{d:"M12 8.5v4.2l2.8 1.8"})]});case"terminal":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"m7 8 3.5 3.5L7 15"}),s.jsx("path",{d:"M13 15h4"}),s.jsx("rect",{x:"4.5",y:"5.5",width:"15",height:"13",rx:"2.5"})]});case"workspace":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M4.5 8.5A2.5 2.5 0 0 1 7 6h3l1.5 1.5H17A2.5 2.5 0 0 1 19.5 10v6A2.5 2.5 0 0 1 17 18.5H7A2.5 2.5 0 0 1 4.5 16z"})});case"debug":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M9 4.5h6"}),s.jsx("path",{d:"M10 8h4a4 4 0 0 1 4 4v1a6 6 0 0 1-12 0v-1a4 4 0 0 1 4-4Z"}),s.jsx("path",{d:"M4.5 11h3M16.5 11h3M5.5 7.5l2 1.5M18.5 7.5l-2 1.5"})]});case"query":default:return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"11",cy:"11",r:"5.5"}),s.jsx("path",{d:"m16 16 3.5 3.5"})]})}}function za(e){if(e.name==="apply_patch"){const o=zn(e.input);if(o)return o;const l=zi(e.output||e.error||""),d=Ui(e.input,l);return d?zn(d):null}if(e.name!=="Write"&&e.name!=="Edit"&&e.name!=="MultiEdit")return null;const t=un(e.input);if(!t)return null;const n=Ae(t,"file_path")||Ae(t,"path");if(!n)return null;if(e.name==="Write"){const o=Ae(t,"content"),l=o.length>0?o.split(/\r?\n/):[];return{files:[{path:n,nextPath:null,action:"add",additions:l.length,deletions:0,statsKnown:!0,lines:l.map((d,m)=>({kind:"add",text:`+${d}`,oldLineNumber:null,newLineNumber:m+1}))}],totalAdditions:l.length,totalDeletions:0}}if(e.name==="Edit"){const o=Ae(t,"old_string").split(/\r?\n/),l=Ae(t,"new_string").split(/\r?\n/);return Zn(n,[{oldLines:o,newLines:l}])}const a=(Array.isArray(t.edits)?t.edits:[]).map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return null;const l=o;return{oldLines:Ae(l,"old_string").split(/\r?\n/),newLines:Ae(l,"new_string").split(/\r?\n/)}}).filter(o=>!!o);return a.length>0?Zn(n,a):null}function Zn(e,t){const n=[];let r=0,a=0;return t.forEach((o,l)=>{n.push({kind:"hunk",text:`@@ -1,${o.oldLines.length} +1,${o.newLines.length} @@`,oldLineNumber:null,newLineNumber:null}),o.oldLines.forEach((d,m)=>{d.length===0&&o.oldLines.length===1&&o.newLines.length>0||(a+=1,n.push({kind:"remove",text:`-${d}`,oldLineNumber:m+1,newLineNumber:null}))}),o.newLines.forEach((d,m)=>{d.length===0&&o.newLines.length===1&&o.oldLines.length>0||(r+=1,n.push({kind:"add",text:`+${d}`,oldLineNumber:null,newLineNumber:m+1}))}),l<t.length-1&&n.push({kind:"meta",text:"***",oldLineNumber:null,newLineNumber:null})}),{files:[{path:e,nextPath:null,action:"update",additions:r,deletions:a,statsKnown:!0,lines:n}],totalAdditions:r,totalDeletions:a}}function Da(e){const t=un(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(n)return`${i("conversation.toolPreviewCommand")}:${n}`;if(e.name==="read_thread_terminal")return i("conversation.toolPreviewTerminal");const r=e.input||e.error||e.output||i("conversation.toolResultEmpty");return r.length>60?`${r.slice(0,60)}...`:r}function $a(e){var o;const t=e.map(l=>({message:l,tool:Ps(l)})).filter(l=>!!l.tool);if(t.length===0)return null;const n={...t[0].tool};let r=!1,a=!1;for(const{message:l,tool:d}of t)l.kind==="tool_call"&&(r=!0,!n.input&&d.input&&(n.input=d.input)),l.kind==="tool_result"&&(a=!0,n.output=d.output,n.error=d.error,n.status=d.status,!n.input&&d.input&&(n.input=d.input)),!n.name&&d.name&&(n.name=d.name);return{key:t.map(({message:l})=>l.id).join(":"),tool:n,hasRequest:r,hasResult:a,updatedAt:((o=t.at(-1))==null?void 0:o.message.timestamp)??t[0].message.timestamp}}function Ha(e){const t=new Map;for(const n of e){const r=Ps(n);if(!r)continue;const a=t.get(r.callId);if(a){a.messages.push(n);continue}t.set(r.callId,{messages:[n],firstSequence:n.sequence})}return Array.from(t.values()).sort((n,r)=>n.firstSequence-r.firstSequence).map(n=>$a(n.messages)).filter(n=>!!n)}function Ka(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e[n];if(Va(e,n))continue;if(!Bt(r)){t.push({type:"message",key:r.id,message:r});continue}const a=[r];let o=n+1;for(;o<e.length;){const d=e[o];if(!Bt(d))break;a.push(d),o+=1}const l=Ha(a);if(l.length===0){t.push({type:"message",key:r.id,message:r}),n=o-1;continue}l.forEach(d=>{t.push({type:"tool_group",key:d.key,group:d})}),n=o-1}return t}function Va(e,t){const n=e[t];if(!n||As(n.content)===null)return!1;for(let r=t-1;r>=0;r-=1){const a=e[r];if(!(!a||Bt(a)))return a.role==="user"}return!1}function Ga(e,t){if(!Fr(null,e))return!1;const n=t.trim();return/AGENTS\.md instructions for/i.test(n)&&/<INSTRUCTIONS>/i.test(n)&&/<\/INSTRUCTIONS>/i.test(n)}function Qa(e,t){if(e!=="claude-code")return!1;const n=t.trim();return/Base directory for this skill:/i.test(n)&&/^#\s+.+/im.test(n)&&/\bARGUMENTS:/i.test(n)}function Za(e,t){if(e==="skill_context"){const r=t.split(/\r?\n/).map(a=>a.trim()).find(a=>/^#\s+/.test(a));if(r)return r.replace(/^#+\s*/,"")}const n=t.split(/\r?\n/).map(r=>r.trim()).find(Boolean);return n?n.replace(/^#+\s*/,""):i("conversation.rulesMessageTitle")}function Ja(e,t){const n=new Set;if(t!=="kimi")return n;for(const r of e){if(r.role==="system"&&r.kind==="text"){n.add(r.id);continue}break}return n}function pt(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>pt(n)).join(""):e&&typeof e=="object"&&"props"in e?pt(((t=e.props)==null?void 0:t.children)??""):""}function Ya(e){const t=Array.isArray(e)?e[0]:e;if(!u.isValidElement(t))return null;const n=t.props,r=typeof n.className=="string"?n.className:"",a=/language-([^\s]+)/.exec(r);return{content:pt(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(a==null?void 0:a[1])??null}}function Xa(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function mn(e,t){var n;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!Xa(e))throw new Error(i("conversation.copyContentFailed"))}}function eo({className:e,children:t,onCopy:n}){const r=u.useContext(Ls),a=pt(t).trim();if(r||!a)return s.jsx("code",{className:e||void 0,children:t});function o(l){l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),n(a))}return s.jsx("code",{className:[e,"markdown-inline-copy"].filter(Boolean).join(" "),role:"button",tabIndex:0,"aria-label":i("conversation.copyAction"),onClick:()=>n(a),onKeyDown:o,children:t})}function to({href:e,children:t,className:n,onInteract:r}){const a=pt(t).trim()||(e?cn(e).trim():"");return s.jsx(Ls.Provider,{value:!0,children:s.jsx("a",{href:e,className:[n,"markdown-interactive-link"].filter(Boolean).join(" "),onClick:o=>{o.preventDefault(),r(e,a)},children:t})})}function qs({language:e,codeClassName:t,content:n}){const{showToast:r}=vt(),a=gt(),o=(e==null?void 0:e.trim().toLowerCase())??null,l=o==="text",d=o||"code";async function m(){try{await mn(n,a),r({title:i("conversation.copyContentSuccess"),tone:"success"})}catch(k){r({title:k instanceof Error?k.message:i("conversation.copyContentFailed"),tone:"error"})}}return s.jsxs("div",{className:`code-block${l?" text-code-block":""}`,children:[s.jsxs("div",{className:"code-header",children:[s.jsx("span",{className:"code-header-label",children:d}),s.jsx("button",{className:"code-copy-button",type:"button",onClick:()=>void m(),children:i("conversation.copyAction")})]}),s.jsx("pre",{className:t,children:s.jsx("code",{children:n})})]})}function it({content:e,className:t}){const{showToast:n}=vt(),r=gt(),{navigationGroups:a,currentWorkspaceId:o,revealWorkspaceFile:l}=cs(),d=u.useMemo(()=>{var v;return((v=a.find(x=>x.workspace.id===o))==null?void 0:v.workspace)??null},[o,a]);async function m(v){if(v.trim())try{await mn(v,r),n({title:i("conversation.copyContentSuccess"),tone:"success"})}catch(x){n({title:x instanceof Error?x.message:i("conversation.copyContentFailed"),tone:"error"})}}function k(v,x){const g=v&&(d!=null&&d.path)?Ca(v,d.path):null;g&&l({workspaceId:(d==null?void 0:d.id)??o,filePath:g,openViewer:!1})||m(x||(v?cn(v).trim():""))}return s.jsx("div",{className:t,children:s.jsx(Hr,{remarkPlugins:[Kr],components:{p:({node:v,...x})=>s.jsx("p",{...x}),a(v){return s.jsx(to,{href:typeof v.href=="string"?v.href:void 0,className:typeof v.className=="string"?v.className:void 0,onInteract:k,children:v.children})},pre(v){const x=Ya(v.children);return x?s.jsx(qs,{language:x.language,codeClassName:x.codeClassName,content:x.content}):s.jsx("pre",{children:v.children})},code(v){const x=typeof v.className=="string"?v.className:"";return s.jsx(eo,{className:x||void 0,onCopy:g=>{m(g)},children:v.children})}},children:e})})}function Jn(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function no(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Rt({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){return s.jsx(so,{sessionId:e,attachments:n,attachmentPayloads:t,inlineImages:r})}function so({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){const[a,o]=u.useState({}),[l,d]=u.useState(null),m=u.useMemo(()=>n.map((g,j)=>{const b=Jn(g,t==null?void 0:t[j]);if(b)return{id:g.id,kind:g.kind,fileName:g.fileName,fileSize:g.fileSize,url:b,status:"ready"};const f=a[g.id];return{id:g.id,kind:g.kind,fileName:g.fileName,fileSize:g.fileSize,url:(f==null?void 0:f.url)??null,status:(f==null?void 0:f.status)??(e?"loading":"error")}}),[t,n,a,e]),k=u.useMemo(()=>r.map((g,j)=>({id:`inline-image-${j}`,kind:"image",fileName:g.altText||`${i("conversation.imageAttachmentLabel")} ${j+1}`,fileSize:g.estimatedBytes,url:g.url,status:"ready"})),[r]),v=u.useMemo(()=>[...k,...m],[m,k]),x=v.find(g=>g.id===l)??null;return u.useEffect(()=>{if(!l)return;function g(j){j.key==="Escape"&&d(null)}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[l]),u.useEffect(()=>{const g=n.filter((f,C)=>!Jn(f,t==null?void 0:t[C]));if(!e||g.length===0){o({});return}let j=!1;const b=[];return o(Object.fromEntries(g.map(f=>[f.id,{id:f.id,kind:f.kind,fileName:f.fileName,fileSize:f.fileSize,url:null,status:"loading"}]))),Promise.all(g.map(async f=>{try{const C=await Ur(e,f.id),T=URL.createObjectURL(C);return b.push(T),{id:f.id,kind:f.kind,fileName:f.fileName,fileSize:f.fileSize,url:T,status:"ready"}}catch{return{id:f.id,kind:f.kind,fileName:f.fileName,fileSize:f.fileSize,url:null,status:"error"}}})).then(f=>{if(j){b.forEach(C=>URL.revokeObjectURL(C));return}o(Object.fromEntries(f.map(C=>[C.id,C])))}),()=>{j=!0,b.forEach(f=>URL.revokeObjectURL(f))}},[t,n,e]),v.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-attachments",children:v.map(g=>{const j=g.kind==="image",b=g.status==="loading"?i("conversation.attachmentPreviewLoading"):g.status==="error"?i("conversation.attachmentPreviewUnavailable"):j?i("conversation.attachmentPreviewOpen"):i("conversation.attachmentDownload"),f=no(g.fileSize),C=s.jsx("div",{className:"message-attachment-card",children:j?g.url?s.jsx("img",{className:"message-attachment-thumbnail",src:g.url,alt:g.fileName||i("conversation.attachmentPreviewAlt"),loading:"lazy"}):s.jsx("div",{className:"message-attachment-placeholder","aria-hidden":"true",children:g.status==="loading"?i("conversation.attachmentPreviewLoading"):i("conversation.attachmentPreviewUnavailable")}):s.jsxs("div",{className:"message-attachment-file-card",children:[s.jsx("div",{className:"message-attachment-file-icon","aria-hidden":"true",children:s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),s.jsx("path",{d:"M14 2v5h5"}),s.jsx("path",{d:"M9 13h6"}),s.jsx("path",{d:"M9 17h6"})]})}),s.jsxs("div",{className:"message-attachment-file-meta",children:[s.jsx("strong",{title:g.fileName,children:g.fileName}),s.jsx("span",{children:f??i("conversation.fileAttachmentLabel")})]})]})});return!j&&g.url?s.jsx("a",{className:"message-attachment-button",href:g.url,download:g.fileName,"aria-label":`${g.fileName} - ${b}`,title:b,children:C},g.id):s.jsx("button",{type:"button",className:"message-attachment-button",onClick:()=>j&&g.url&&d(g.id),disabled:!g.url,"aria-label":`${g.fileName} - ${b}`,title:b,children:C},g.id)})}),s.jsx(ls,{open:!!(x!=null&&x.url),title:i("conversation.imagePreviewTitle"),description:x==null?void 0:x.fileName,size:"xwide",layout:"viewer",className:"message-image-modal",bodyClassName:"message-image-modal-body",onClose:()=>d(null),children:x!=null&&x.url?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-image-modal-stage",children:s.jsx("img",{className:"message-image-modal-image",src:x.url,alt:x.fileName||i("conversation.attachmentPreviewAlt")})}),s.jsx("p",{className:"message-image-modal-hint",children:i("conversation.imagePreviewHint")})]}):null})]})}function ro(){return s.jsx("div",{className:"timeline-skeleton","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("article",{className:`timeline-skeleton-item ${t%2===0?"assistant":"user"}`,children:[s.jsx("div",{className:"timeline-skeleton-avatar"}),s.jsxs("div",{className:"timeline-skeleton-bubble",children:[s.jsx("span",{className:"timeline-skeleton-line long"}),s.jsx("span",{className:"timeline-skeleton-line medium"}),s.jsx("span",{className:"timeline-skeleton-line short"})]})]},t))})}function io({tool:e,preview:t}){const[n,r]=u.useState(null),a=n===null?null:t.files[n]??null;return u.useEffect(()=>{if(n===null)return;function o(l){l.key==="Escape"&&r(null)}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"tool-call-item apply-patch-item",children:t.files.map((o,l)=>s.jsxs("button",{type:"button",className:"apply-patch-summary-row",onClick:()=>r(l),children:[s.jsx("span",{className:"apply-patch-summary-label",children:Xn(o.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:Xt(o),children:Di(o.nextPath??o.path)}),ts(o)]},es(o,l)))}),s.jsx(ls,{open:a!==null,title:i("conversation.applyPatchDialogTitle"),description:i("conversation.applyPatchDialogDescription"),size:"full",layout:"viewer",className:"apply-patch-modal",bodyClassName:"apply-patch-modal-body",onClose:()=>r(null),children:a?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"apply-patch-modal-totals",children:mo(a)}),s.jsxs("section",{className:"apply-patch-file-panel",children:[s.jsxs("div",{className:"apply-patch-file-panel-header",children:[s.jsxs("div",{className:"apply-patch-file-panel-title",children:[s.jsx("span",{className:"apply-patch-summary-label",children:Xn(a.action)}),s.jsx("strong",{children:Xt(a)})]}),ts(a)]}),s.jsx("div",{className:"apply-patch-diff-view",children:s.jsx("div",{className:"apply-patch-diff-scroll",children:a.lines.map((o,l)=>s.jsxs("div",{className:`apply-patch-diff-line ${po(o.kind)}`,children:[s.jsx("span",{className:"apply-patch-line-number",children:ns(o.oldLineNumber)}),s.jsx("span",{className:"apply-patch-line-number",children:ns(o.newLineNumber)}),s.jsx("span",{className:"apply-patch-line-content",children:o.text||" "})]},`${Xt(a)}:${l}`))})})]},es(a,n??0)),e.error?s.jsxs("section",{className:"apply-patch-error-panel",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:"tool-call-error",children:e.error})]}):null]}):null})]})}function ao({group:e}){const[t,n]=u.useState(!1),{navigationGroups:r}=cs(),{tool:a,hasRequest:o,hasResult:l}=e,d=ja(a.name),m=u.useMemo(()=>Sa(r),[r]),k=u.useMemo(()=>Ta(a,m),[m,a]),v=u.useMemo(()=>Ra(a,m),[m,a]),x=u.useMemo(()=>Qr(a,null,e.updatedAt),[e.updatedAt,a]),g=u.useMemo(()=>za(a),[a.input,a.name]);if(g)return s.jsx(io,{tool:a,preview:g});if(k)return s.jsx(Yn,{tool:a,snapshot:k,expanded:t,hasRequest:o,hasResult:l,onToggleExpanded:()=>{n(f=>!f)}});if(v)return s.jsx(Yn,{tool:a,snapshot:v,expanded:t,hasRequest:o,hasResult:l,onToggleExpanded:()=>{n(f=>!f)}});if(x)return s.jsx(oo,{tool:a,snapshot:x,expanded:t,hasRequest:o,hasResult:l,onToggleExpanded:()=>{n(f=>!f)}});const j=Da(a),b=!!(a.input||a.output||a.error);return s.jsxs("div",{className:`tool-call-item ${l?"tool-result":""}`,children:[s.jsxs("button",{type:"button",className:"tool-call-header",onClick:()=>b&&n(f=>!f),children:[s.jsxs("div",{className:"tool-call-info",children:[s.jsx("span",{className:"tool-call-name",children:d}),s.jsx("span",{className:"tool-call-input-preview",children:j})]}),s.jsx("div",{className:"tool-call-meta",children:b&&s.jsx("span",{className:`tool-call-toggle ${t?"expanded":""}`,children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})})})]}),t&&b&&s.jsxs("div",{className:"tool-call-output",children:[o&&a.input&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolInputLabel")}),s.jsx("pre",{children:a.input})]}),(l||a.error||a.output)&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:a.error?"tool-call-error":void 0,children:a.error||a.output||i("conversation.toolResultEmpty")})]})]})]})}function Yn({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:a,onToggleExpanded:o}){const l=n?i("conversation.assistantCapabilityRawCollapse"):i("conversation.assistantCapabilityRawExpand");return s.jsxs("div",{className:"tool-call-item assistant-capability-item","data-kind":t.kind,children:[s.jsxs("div",{className:"assistant-capability-header",children:[s.jsxs("div",{className:"assistant-capability-heading",children:[s.jsx("span",{className:"assistant-capability-icon",children:s.jsx(Ua,{kind:t.kind})}),s.jsxs("div",{className:"assistant-capability-heading-main",children:[s.jsx("span",{className:"assistant-capability-badge",children:t.badge}),s.jsx("strong",{children:t.title}),s.jsx("span",{className:"assistant-capability-summary",children:t.summary})]})]}),s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:l})]}),t.rows.length>0?s.jsx("div",{className:"assistant-capability-list",children:t.rows.map(d=>s.jsxs("div",{className:"assistant-capability-row",children:[s.jsx("span",{className:"assistant-capability-row-label",children:d.label}),s.jsx("span",{className:"assistant-capability-row-value",children:d.value})]},d.label))}):null,n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,a||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||i("conversation.toolResultEmpty")})]}):null]}):null]})}function oo({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:a,onToggleExpanded:o}){const l=ms(t.items),d=n?i("conversation.taskCardRawCollapse"):i("conversation.taskCardRawExpand");return s.jsxs("div",{className:"tool-call-item task-tool-item",children:[s.jsxs("div",{className:"task-tool-header",children:[s.jsxs("div",{className:"task-tool-heading",children:[s.jsx("span",{className:"task-tool-badge",children:t.source==="plan"?i("conversation.taskCardPlanTitle"):i("conversation.taskCardTodoTitle")}),s.jsxs("div",{className:"task-tool-heading-main",children:[s.jsx("strong",{children:lo(t,e.name)}),s.jsx("span",{className:"task-tool-summary-text",children:co(t.items,l)})]})]}),s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:d})]}),s.jsx("ol",{className:"task-tool-list",children:t.items.map(m=>s.jsxs("li",{className:"task-tool-list-item","data-status":m.status,children:[s.jsx("span",{className:"task-tool-item-indicator","data-status":m.status,"aria-hidden":"true"}),s.jsx("strong",{className:"task-tool-item-title",children:m.title}),m.detail?s.jsx("span",{className:"task-tool-item-detail",children:m.detail}):null,s.jsx("span",{className:"task-tool-item-status",children:uo(m.status)})]},m.id))}),n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,a||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||i("conversation.toolResultEmpty")})]}):null]}):null]})}function lo(e,t){if(e.source==="plan")return i("conversation.taskCardPlanUpdated");const n=t.trim().toLowerCase();return n==="taskcreate"||n==="todowrite"||n==="todoread"?i("conversation.taskCardTodoUpdated"):n.startsWith("task")?i("conversation.taskCardTodoUpdated"):i("conversation.taskCardTodoUpdated")}function co(e,t){const n=[i("conversation.taskCardSummaryTotal",{count:e.length})];return t.in_progress>0&&n.push(i("conversation.taskCardSummaryInProgress",{count:t.in_progress})),t.pending>0&&n.push(i("conversation.taskCardSummaryPending",{count:t.pending})),t.completed>0&&n.push(i("conversation.taskCardSummaryCompleted",{count:t.completed})),t.failed>0&&n.push(i("conversation.taskCardSummaryFailed",{count:t.failed})),n.join(" / ")}function uo(e){switch(e){case"in_progress":return i("conversation.taskProgressStatusInProgress");case"completed":return i("conversation.taskProgressStatusCompleted");case"failed":return i("conversation.taskProgressStatusFailed");case"cancelled":return i("conversation.taskProgressStatusCancelled");case"pending":default:return i("conversation.taskProgressStatusPending")}}function Xn(e){return e==="add"?i("conversation.applyPatchAddedLabel"):e==="delete"?i("conversation.applyPatchDeletedLabel"):i("conversation.applyPatchEditedLabel")}function Xt(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function es(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function ts(e){return e.statsKnown?s.jsxs("span",{className:"apply-patch-summary-stats",children:[s.jsxs("span",{className:"apply-patch-summary-added",children:["+",e.additions]}),s.jsxs("span",{className:"apply-patch-summary-removed",children:["-",e.deletions]})]}):s.jsx("span",{className:"apply-patch-summary-stats",children:s.jsx("span",{className:"apply-patch-summary-edited",children:i("conversation.applyPatchEditedStat")})})}function mo(e){return e.statsKnown?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"apply-patch-stat-pill positive",children:[i("conversation.applyPatchAddedStat")," +",e.additions]}),s.jsxs("span",{className:"apply-patch-stat-pill negative",children:[i("conversation.applyPatchRemovedStat")," -",e.deletions]})]}):s.jsx("span",{className:"apply-patch-stat-pill neutral",children:i("conversation.applyPatchEditedStat")})}function po(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function ns(e){return e===null||e<=0?"":String(e)}function fo(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ws({timestamp:e,leading:t,children:n}){return s.jsxs("div",{className:"user-message-footer",children:[s.jsx("div",{className:"user-message-footer-leading",children:t}),s.jsxs("div",{className:"user-message-footer-trailing",children:[s.jsx("time",{className:"message-time",dateTime:e,children:fo(e)}),n]})]})}function Le({text:e,canCopy:t=!0,canFork:n=!1,compact:r=!1,onFork:a}){const{showToast:o}=vt(),l=gt(),[d,m]=u.useState(!1),[k,v]=u.useState(!1),x=e.trim().length>0,g=t&&x;async function j(){if(!(!g||d)){m(!0);try{await mn(e,l),o({title:i("conversation.copyContentSuccess"),tone:"success"})}catch(f){o({title:f instanceof Error?f.message:i("conversation.copyContentFailed"),tone:"error"})}finally{m(!1)}}}async function b(){if(!(!a||k)){v(!0);try{await a()}finally{v(!1)}}}return!g&&!n?null:s.jsxs("div",{className:r?"message-metadata-bar compact":"message-metadata-bar",children:[g?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":i("conversation.copyAction"),title:i("conversation.copyAction"),onClick:()=>{j()},disabled:d,children:s.jsx(ri,{})}):null,n?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":k?i("conversation.forkingAction"):i("conversation.forkFromHereAction"),title:k?i("conversation.forkingAction"):i("conversation.forkFromHereAction"),onClick:()=>{b()},disabled:k,children:s.jsx(ii,{})}):null]})}function ho({message:e,kind:t,tone:n,actionState:r,onRetry:a,onForkMessage:o}){const[l,d]=u.useState(!1),m=Za(t,e.content),k=n==="user-message",v=t==="system_prompt"?i("conversation.systemPromptTitle"):t==="skill_context"?i("conversation.skillContextTitle"):i("conversation.rulesMessageTitle"),x=t==="system_prompt"?i("conversation.systemPromptHint"):t==="skill_context"?i("conversation.skillContextHint"):i("conversation.rulesMessageHint"),g=l?t==="system_prompt"?i("conversation.systemPromptCollapse"):t==="skill_context"?i("conversation.skillContextCollapse"):i("conversation.rulesMessageCollapse"):t==="system_prompt"?i("conversation.systemPromptExpand"):t==="skill_context"?i("conversation.skillContextExpand"):i("conversation.rulesMessageExpand");return s.jsx("article",{className:`message-item ${n} rules-message-row`,"data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsxs("div",{className:"rules-message-card",children:[s.jsxs("button",{type:"button",className:"rules-message-toggle","aria-expanded":l,onClick:()=>d(j=>!j),children:[s.jsxs("div",{className:"rules-message-heading",children:[s.jsx("span",{className:"rules-message-badge",children:v}),s.jsx("span",{className:"rules-message-summary",children:m})]}),s.jsx("span",{className:"rules-message-action",children:g})]}),s.jsx("p",{className:"rules-message-hint",children:x}),l&&s.jsx("div",{className:"rules-message-body",children:s.jsx(it,{content:e.content,className:"message-text message-content markdown-content"})}),k?s.jsx(Ws,{timestamp:e.timestamp,children:s.jsx(Le,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),compact:!0,onFork:o?()=>o(e):null})}):s.jsx(Le,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(e):null})]}),e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>a(e.clientRequestId),children:i("conversation.resendButton")})]})})}function go({message:e,provider:t,interruptedSource:n=null,foldedPromptKind:r=null,actionState:a,onRetry:o,onForkMessage:l,assistantAvatar:d}){const m=e.role==="user",k=e.kind==="thinking",v=e.role==="assistant"&&e.kind==="text",x=t==="codex"&&e.kind==="text"?As(e.content):null,g=r??(Ga(t,e.content)?"rules":Qa(t,e.content)?"skill_context":null),j=u.useMemo(()=>ut(e.content),[e.content]),b=j.text,f=j.inlineImages,[C,T]=u.useState(!1),[M,R]=u.useState(!1),[I,D]=u.useState(null),[A,F]=u.useState(null);if(g){const L=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return s.jsx(ho,{message:e,kind:g,tone:L,actionState:a,onRetry:o,onForkMessage:l})}if(x){const L=ma(n),$=x.detail?`${L}
|
|
14
|
+
`).trim()}function js(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function sa(e){var n;const t=e.match(/^data:(image\/[a-zA-Z0-9.+-]+);base64,/i);return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())??null}function ra(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?It(t[1]):null}function It(e){const t=e.trim(),n=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.max(0,Math.floor(t.length*3/4)-n)}function dt(e){const t=ne(e).trim();return t.length>0?t:null}function Dn(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function $n(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.startsWith("image/")?t:null}function ne(e){return typeof e=="string"?e:""}function ia(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function aa(e){const t=e.trim();if(t.length===0)return null;try{const n=JSON.parse(t),r=ne(n.image_url??n.imageUrl).trim(),a=dt(ne(n.name)||ne(n.alt));return{url:js(r)?r:null,altText:a}}catch{const n=t.match(/(data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)/i);return n?{url:n[1],altText:null}:null}}function oa(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e.match(new RegExp(`${n}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return dt((r==null?void 0:r[1])??(r==null?void 0:r[2])??(r==null?void 0:r[3])??(r==null?void 0:r[4])??"")}const ws="codingns.user-app.conversation-scroll",$e=1,la=200,ca=1e7;function Ns(){return typeof window<"u"&&typeof window.localStorage<"u"}function Ss(e){return e.trim()}function Ts(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),ca)}function Rs(e){return!e||typeof e!="object"?null:{scrollTop:Ts(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function Ms(){if(!Ns())return{schemaVersion:$e,bySessionId:{}};const e=window.localStorage.getItem(ws);if(!e)return{schemaVersion:$e,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==$e||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:$e,bySessionId:{}};const n=Object.fromEntries(Object.entries(t.bySessionId).map(([r,a])=>{const o=Rs(a);return o?[r,o]:null}).filter(r=>!!r));return{schemaVersion:$e,bySessionId:n}}catch{return{schemaVersion:$e,bySessionId:{}}}}function ua(e){if(Ns())try{window.localStorage.setItem(ws,JSON.stringify(e))}catch{}}function Tt(e){const t=Ss(e);if(!t)return null;const n=Ms().bySessionId[t],r=Rs(n);return r?{scrollTop:r.scrollTop,stickToBottom:r.stickToBottom,lastMessageSignature:r.lastMessageSignature}:null}function Hn(e,t){const n=Ss(e);if(!n)return;const r=Ms();r.bySessionId[n]={scrollTop:Ts(t.scrollTop),stickToBottom:t.stickToBottom,lastMessageSignature:t.lastMessageSignature,updatedAt:Date.now()};const a=Object.entries(r.bySessionId).sort((o,l)=>l[1].updatedAt-o[1].updatedAt).slice(0,la);r.bySessionId=Object.fromEntries(a),ua(r)}function da(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function As(e){var r;const t=e.match(/^\s*<turn_aborted>([\s\S]*?)<\/turn_aborted>\s*$/i);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";return!n||/^previous turn aborted$/i.test(n)?{detail:null}:{detail:n}}function ma(e){return e==="user"?i("conversation.turnAbortedUser"):e==="runtime"?i("conversation.turnAbortedUnexpected"):i("conversation.turnAbortedGeneric")}const pa=480,Kn=80,Vn=240,fa=120,ha=18,ga=50,va=3500,Ls=d.createContext(!1);function rn(e){return e.replace(/\\/g,"/")}function Et(e){return/^[a-zA-Z]:\//.test(e)}function xa(e){return e.startsWith("/")||e.startsWith("//")||Et(e)}function ba(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!Et(e)}function Gn(e){return e.replace(/\/+$/,"")}function ya(e){const t=e.indexOf("#"),n=t>=0?e.slice(0,t):e,r=n.indexOf("?");return(r>=0?n.slice(0,r):n).replace(/:(\d+)(?::(\d+))?$/,"")}function ka(e){const t=[];for(const n of rn(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")}function cn(e){try{return decodeURIComponent(e)}catch{return e}}function Ca(e,t){const n=cn(e).trim();if(!n||n.startsWith("#"))return null;let r=n;if(/^file:\/\//i.test(r))try{r=decodeURIComponent(new URL(r).pathname),/^\/[a-zA-Z]:\//.test(r)&&(r=r.slice(1))}catch{return null}else if(ba(r))return null;if(r=rn(ya(r.trim())),!r)return null;const a=Gn(rn(t.trim()));if(!a)return null;if(xa(r)){const o=Gn(r),l=Et(a)?a.toLowerCase():a,u=Et(o)?o.toLowerCase():o;if(u===l)return null;const m=`${l}/`;return u.startsWith(m)?o.slice(a.length+1):null}return ka(r)}function Bt(e){return e.kind==="tool_call"||e.kind==="tool_result"}function Ps(e){return e.toolCall?e.toolCall:Bt(e)?{callId:e.rawRef||e.id,name:"tool",input:e.kind==="tool_call"?e.content:"",output:e.kind==="tool_result"&&e.content?e.content:null,error:null,status:e.kind==="tool_call"?"running":"completed"}:null}function ja(e){return e==="shell_command"||e==="tool"?i("conversation.roleTool"):e}function un(e){if(!e.trim())return null;try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function Ae(e,t){const n=e[t];return typeof n=="string"?n:""}function mt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function z(e,t){if(!e)return null;const n=e[t];return mt(n)?n:null}function Yt(e,t){if(!e)return null;const n=e[t];return Array.isArray(n)?n:null}function P(e,t){if(!e)return null;const n=e[t];if(typeof n=="string"){const r=n.trim();return r||null}return typeof n=="number"||typeof n=="boolean"?String(n):null}function wa(e){const t=[e.output,e.input];for(const n of t){const r=Is(n,0);if(r)return r}return null}function Is(e,t){if(!(e!=null&&e.trim())||t>2)return null;try{return Es(JSON.parse(e),t)}catch{return null}}function Es(e,t){if(!mt(e))return null;if(Na(e))return{ok:!0,capability:P(e,"capability")??"",auditId:P(e,"auditId")??"",timestamp:P(e,"timestamp")??"",targetRef:{kind:P(z(e,"targetRef"),"kind")??"none",id:P(z(e,"targetRef"),"id")},payload:z(e,"payload")??{}};const n=["output","result","data","payload"];for(const r of n){const a=e[r];if(typeof a=="string"){const o=Is(a,t+1);if(o)return o}if(mt(a)){const o=Es(a,t+1);if(o)return o}}return null}function Na(e){return e.ok===!0&&typeof e.capability=="string"&&typeof e.auditId=="string"&&typeof e.timestamp=="string"&&mt(e.targetRef)&&mt(e.payload)}function Sa(e){const t=new Map,n=new Map,r=new Map;return e.forEach(a=>{t.set(a.workspace.id,a.workspace.name),a.sessions.forEach(o=>{const l=typeof o.title=="string"&&o.title.trim()?o.title.trim():o.sessionId;n.set(o.sessionId,l),r.set(o.sessionId,a.workspace.id)})}),{workspaceNamesById:t,sessionNamesById:n,sessionWorkspaceIdsById:r}}function Ta(e,t){const n=wa(e);return n?{...Os(n.capability),rows:_a(n,t)}:null}function Ra(e,t){const n=Ma(e);if(!n)return null;const r=Aa(n);return r?{...Ia(r),rows:Oa(r,t)}:null}function Ma(e){const t=un(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(!n)return null;const r=n.indexOf("codingns assistant");return r<0?null:n.slice(r).trim()}function Aa(e){const t=La(e),n=t.findIndex((p,x)=>p==="codingns"&&t[x+1]==="assistant");if(n<0)return null;const r=t.slice(n+2);if(r.length===0||r[0]==="--help"||r[0]==="-h")return{group:null,action:null,mode:"help",options:{},positionals:[]};if(r[0]==="help")return{group:r[1]??null,action:r[2]??null,mode:"help",options:{},positionals:[]};const a=r[0]??null,o=r[1],l=o&&!o.startsWith("-")?o:null,u=r.slice(l?2:1),{options:m,positionals:y}=Pa(u);return!l&&m["--help"]?{group:a,action:null,mode:"help",options:m,positionals:y}:{group:a,action:l,mode:"execute",options:m,positionals:y}}function La(e){const t=[],n=/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`|\S+/g;for(const r of e.matchAll(n)){const a=r[0]??"";if(!a)continue;const o=a[0];if((o==='"'||o==="'"||o==="`")&&a[a.length-1]===o){t.push(a.slice(1,-1));continue}t.push(a)}return t}function Pa(e){const t={},n=[];for(let r=0;r<e.length;r+=1){const a=e[r]??"";if(!a.startsWith("--")){n.push(a);continue}const o=e[r+1];if(!o||o.startsWith("--")){t[a]=!0;continue}t[a]=o,r+=1}return{options:t,positionals:n}}function Ia(e){if(e.mode==="help")return Ea(e.group,e.action);const t=Ba(e.group,e.action);return t?Os(t):{kind:dn(e.group),badge:Bs(e.group),title:i("conversation.assistantCapabilityQueryTitle"),summary:i("conversation.assistantCliSummaryCommand")}}function Ea(e,t){return e?e==="sessions"?{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:t?i("conversation.assistantCliHelpSessionActionTitle",{action:t}):i("conversation.assistantCliHelpSessionsTitle"),summary:i("conversation.assistantCliSummaryHelp")}:e==="timers"?{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCliHelpTimersTitle"),summary:i("conversation.assistantCliSummaryHelp")}:e==="terminals"?{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCliHelpTerminalsTitle"),summary:i("conversation.assistantCliSummaryHelp")}:e==="workspaces"||e==="worktrees"?{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCliHelpWorkspacesTitle"),summary:i("conversation.assistantCliSummaryHelp")}:{kind:dn(e),badge:Bs(e),title:i("conversation.assistantCliHelpGenericTitle",{group:e}),summary:i("conversation.assistantCliSummaryHelp")}:{kind:"query",badge:i("conversation.assistantCapabilityBadgeQuery"),title:i("conversation.assistantCliHelpRootTitle"),summary:i("conversation.assistantCliSummaryHelp")}}function Ba(e,t){const n=e==null?void 0:e.trim(),r=t==null?void 0:t.trim();return n?n==="capabilities"&&r==="list"?"capabilities.list":n==="projects"&&r==="list"?"projects.list":n==="projects"&&r==="get"?"projects.get":n==="sessions"&&r==="list"?"projects.sessions.list":n==="sessions"&&r==="get"?"sessions.get":n==="sessions"&&r==="messages"?"sessions.messages.list":n==="sessions"&&r==="runtime"?"sessions.runtime.get":n==="sessions"&&r==="start"?"projects.sessions.start":n==="sessions"&&r==="send"?"sessions.message.send":n==="sessions"&&r==="fork"?"sessions.fork":n==="timers"&&r==="create"?"timers.create":n==="timers"&&r==="cancel"?"timers.cancel":n==="timers"&&r==="list"?"timers.list":n==="terminals"&&r==="send"?"terminals.input.send":n==="terminals"&&r==="close"?"terminals.close":n==="terminals"&&r==="history"?"terminals.history.read":n==="terminals"&&r==="list"?"terminals.list":n==="workspaces"&&r==="list"?"workspaces.list":n==="workspaces"&&r==="clone"?"workspaces.clone":n==="workspaces"&&r==="import"?"workspaces.import":n==="workspaces"&&r==="management"?"workspaces.management.get":n==="worktrees"&&r==="tree"?"worktrees.tree":n==="worktrees"&&r==="create"?"worktrees.create":null:null}function dn(e){switch(e){case"sessions":case"projects":return"session";case"timers":return"automation";case"terminals":return"terminal";case"workspaces":case"worktrees":return"workspace";case"debug-targets":case"debug-runtimes":return"debug";default:return"query"}}function Bs(e){switch(dn(e)){case"session":return i("conversation.assistantCapabilityBadgeSession");case"automation":return i("conversation.assistantCapabilityBadgeAutomation");case"terminal":return i("conversation.assistantCapabilityBadgeTerminal");case"workspace":return i("conversation.assistantCapabilityBadgeWorkspace");case"debug":return i("conversation.assistantCapabilityBadgeDebug");case"query":default:return i("conversation.assistantCapabilityBadgeQuery")}}function Oa(e,t){const n=[],r=He(e,"--session-id")??e.positionals[0]??null,a=He(e,"--project")??He(e,"--project-id");return e.mode==="help"?(S(n,i("conversation.assistantCliLabelScope"),e.group??i("conversation.assistantCliScopeRoot")),S(n,i("conversation.assistantCliLabelAction"),e.action),n):(e.group==="sessions"&&S(n,i("conversation.assistantCapabilityLabelSession"),Ie(r,null,t)),e.group==="timers"&&(S(n,i("conversation.assistantCapabilityLabelSession"),Ie(r,null,t)),S(n,i("conversation.assistantCliLabelDelay"),He(e,"--after-seconds"))),e.group==="terminals"&&S(n,i("conversation.assistantCapabilityLabelTerminal"),e.positionals[0]??null),(e.group==="workspaces"||e.group==="worktrees")&&S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(e.positionals[0]??null,null,t)),S(n,i("conversation.assistantCliLabelProject"),a),S(n,i("conversation.assistantCliLabelMessage"),He(e,"--message")),S(n,i("conversation.assistantCliLabelInput"),He(e,"--input")),n.slice(0,4))}function He(e,t){const n=e.options[t];return typeof n=="string"?n:null}function Os(e){switch(e){case"projects.sessions.start":return{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilityProjectSessionStartTitle"),summary:i("conversation.assistantCapabilitySummarySessionStart")};case"sessions.message.send":return{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilitySessionSendTitle"),summary:i("conversation.assistantCapabilitySummarySessionSend")};case"sessions.fork":return{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilitySessionForkTitle"),summary:i("conversation.assistantCapabilitySummarySessionFork")};case"timers.create":return{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCapabilityTimerCreateTitle"),summary:i("conversation.assistantCapabilitySummaryTimerCreate")};case"timers.cancel":return{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCapabilityTimerCancelTitle"),summary:i("conversation.assistantCapabilitySummaryTimerCancel")};case"terminals.input.send":return{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCapabilityTerminalInputTitle"),summary:i("conversation.assistantCapabilitySummaryTerminalInput")};case"terminals.close":return{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCapabilityTerminalCloseTitle"),summary:i("conversation.assistantCapabilitySummaryTerminalClose")};case"workspaces.directory.create":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceDirectoryCreateTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.import":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceImportTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.clone":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceCloneTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.navigation-state.update":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceNavigationUpdateTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.remove":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceRemoveTitle"),summary:i("conversation.assistantCapabilitySummaryWorkspace")};case"worktrees.create":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorktreeCreateTitle"),summary:i("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.merge-into-parent":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorktreeMergeTitle"),summary:i("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.cleanup":return{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorktreeCleanupTitle"),summary:i("conversation.assistantCapabilitySummaryWorktree")};case"debug-targets.run":return{kind:"debug",badge:i("conversation.assistantCapabilityBadgeDebug"),title:i("conversation.assistantCapabilityDebugRunTitle"),summary:i("conversation.assistantCapabilitySummaryDebug")};default:return e.startsWith("sessions.")||e.startsWith("projects.")?{kind:"session",badge:i("conversation.assistantCapabilityBadgeSession"),title:i("conversation.assistantCapabilitySessionReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("timers.")?{kind:"automation",badge:i("conversation.assistantCapabilityBadgeAutomation"),title:i("conversation.assistantCapabilityAutomationReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("terminals.")?{kind:"terminal",badge:i("conversation.assistantCapabilityBadgeTerminal"),title:i("conversation.assistantCapabilityTerminalReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("workspaces.")||e.startsWith("worktrees.")?{kind:"workspace",badge:i("conversation.assistantCapabilityBadgeWorkspace"),title:i("conversation.assistantCapabilityWorkspaceReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:e.startsWith("debug-targets.")||e.startsWith("debug-runtimes.")?{kind:"debug",badge:i("conversation.assistantCapabilityBadgeDebug"),title:i("conversation.assistantCapabilityDebugReadTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}:{kind:"query",badge:i("conversation.assistantCapabilityBadgeQuery"),title:i("conversation.assistantCapabilityQueryTitle"),summary:i("conversation.assistantCapabilitySummaryRead")}}}function _a(e,t){const n=[],r=e.payload;switch(e.capability){case"projects.sessions.start":{const a=z(r,"session");S(n,i("conversation.assistantCapabilityLabelSession"),Ie(P(a,"sessionId"),P(a,"title"),t)),S(n,i("conversation.assistantCapabilityLabelProvider"),P(a,"provider"));break}case"sessions.message.send":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelSession"),Ie(e.targetRef.id,null,t)),S(n,i("conversation.assistantCapabilityLabelWorkspace"),_s(e.targetRef.id,t)),S(n,i("conversation.assistantCapabilityLabelStatus"),i("conversation.assistantCapabilityStatusCompleted")),S(n,i("conversation.assistantCapabilityLabelDueAt"),Zn(P(a,"acceptedAt")??e.timestamp));break}case"sessions.fork":{const a=z(r,"session");S(n,i("conversation.assistantCapabilityLabelSession"),Ie(P(a,"sessionId"),P(a,"title"),t)),S(n,i("conversation.assistantCapabilityLabelProvider"),P(a,"provider"));break}case"timers.create":case"timers.cancel":{const a=z(r,"timer"),o=z(a,"controlSession"),l=z(o,"session");S(n,i("conversation.assistantCapabilityLabelTimer"),P(a,"title")),S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(l,"workspaceId"),null,t)),S(n,i("conversation.assistantCapabilityLabelSession"),Ie(P(a,"targetSessionId"),null,t)),S(n,i("conversation.assistantCapabilityLabelDueAt"),Zn(P(a,"dueAt"))),S(n,i("conversation.assistantCapabilityLabelStatus"),Fa(P(a,"status")));break}case"terminals.input.send":case"terminals.close":S(n,i("conversation.assistantCapabilityLabelTerminal"),e.targetRef.id);break;case"workspaces.directory.create":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelPath"),P(a,"path"));break}case"workspaces.import":case"workspaces.clone":case"workspaces.remove":{const a=z(r,"workspace");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(a,"id")??e.targetRef.id,P(a,"name"),t)),S(n,i("conversation.assistantCapabilityLabelPath"),P(a,"path"));break}case"workspaces.navigation-state.update":{const a=z(r,"state");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(a,"workspaceId")??e.targetRef.id,null,t)),S(n,i("conversation.assistantCapabilityLabelStatus"),P(a,"collapsed")==="true"?i("conversation.assistantCapabilityNavigationCollapsed"):i("conversation.assistantCapabilityNavigationExpanded"));break}case"worktrees.create":{const a=z(r,"result"),o=z(a,"workspace");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(P(o,"id")??e.targetRef.id,P(o,"name"),t)),S(n,i("conversation.assistantCapabilityLabelBranch"),P(a,"branchName"));break}case"worktrees.merge-into-parent":case"worktrees.cleanup":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelWorkspace"),ye(e.targetRef.id,null,t)),S(n,i("conversation.assistantCapabilityLabelStatus"),P(a,"status"));break}case"debug-targets.run":{const a=z(r,"result");S(n,i("conversation.assistantCapabilityLabelDebugTarget"),e.targetRef.id),S(n,i("conversation.assistantCapabilityLabelRuntime"),P(a,"runtimeId"));break}}return qa(n,e,t),n.slice(0,4)}function qa(e,t,n){t.targetRef.kind==="session"&&(S(e,i("conversation.assistantCapabilityLabelSession"),Ie(t.targetRef.id,null,n)),S(e,i("conversation.assistantCapabilityLabelWorkspace"),_s(t.targetRef.id,n))),(t.targetRef.kind==="workspace"||t.targetRef.kind==="worktree")&&S(e,i("conversation.assistantCapabilityLabelWorkspace"),ye(t.targetRef.id,null,n)),t.targetRef.kind==="terminal"&&S(e,i("conversation.assistantCapabilityLabelTerminal"),t.targetRef.id),t.targetRef.kind==="timer"&&S(e,i("conversation.assistantCapabilityLabelTimer"),t.targetRef.id);const r=Wa(t.payload);r!==null&&S(e,i("conversation.assistantCapabilityLabelCount"),String(r))}function S(e,t,n){const r=n==null?void 0:n.trim();r&&(e.some(a=>a.label===t)||e.push({label:t,value:r}))}function Ie(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const a=e==null?void 0:e.trim();return a?n.sessionNamesById.get(a)??a:null}function ye(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const a=e==null?void 0:e.trim();return a?n.workspaceNamesById.get(a)??a:null}function _s(e,t){const n=e==null?void 0:e.trim();return n?ye(t.sessionWorkspaceIdsById.get(n)??null,null,t):null}function Wa(e){const t=Yt(e,"items");if(t)return t.length;const n=z(e,"page"),r=Yt(n,"items");if(r)return r.length;const a=z(e,"history"),o=Yt(a,"items");return o?o.length:null}function Zn(e){const t=e==null?void 0:e.trim();if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n)):t}function Fa(e){switch(e){case"active":return i("conversation.assistantCapabilityStatusActive");case"completed":return i("conversation.assistantCapabilityStatusCompleted");case"cancelled":return i("conversation.assistantCapabilityStatusCancelled");case"failed":return i("conversation.assistantCapabilityStatusFailed");default:return e}}function Ua({kind:e}){switch(e){case"session":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M5 7.5A2.5 2.5 0 0 1 7.5 5h9A2.5 2.5 0 0 1 19 7.5v5A2.5 2.5 0 0 1 16.5 15H11l-4 4v-4H7.5A2.5 2.5 0 0 1 5 12.5z"})});case"automation":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"7.5"}),s.jsx("path",{d:"M12 8.5v4.2l2.8 1.8"})]});case"terminal":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"m7 8 3.5 3.5L7 15"}),s.jsx("path",{d:"M13 15h4"}),s.jsx("rect",{x:"4.5",y:"5.5",width:"15",height:"13",rx:"2.5"})]});case"workspace":return s.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:s.jsx("path",{d:"M4.5 8.5A2.5 2.5 0 0 1 7 6h3l1.5 1.5H17A2.5 2.5 0 0 1 19.5 10v6A2.5 2.5 0 0 1 17 18.5H7A2.5 2.5 0 0 1 4.5 16z"})});case"debug":return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("path",{d:"M9 4.5h6"}),s.jsx("path",{d:"M10 8h4a4 4 0 0 1 4 4v1a6 6 0 0 1-12 0v-1a4 4 0 0 1 4-4Z"}),s.jsx("path",{d:"M4.5 11h3M16.5 11h3M5.5 7.5l2 1.5M18.5 7.5l-2 1.5"})]});case"query":default:return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[s.jsx("circle",{cx:"11",cy:"11",r:"5.5"}),s.jsx("path",{d:"m16 16 3.5 3.5"})]})}}function za(e){if(e.name==="apply_patch"){const o=zn(e.input);if(o)return o;const l=zi(e.output||e.error||""),u=Ui(e.input,l);return u?zn(u):null}if(e.name!=="Write"&&e.name!=="Edit"&&e.name!=="MultiEdit")return null;const t=un(e.input);if(!t)return null;const n=Ae(t,"file_path")||Ae(t,"path");if(!n)return null;if(e.name==="Write"){const o=Ae(t,"content"),l=o.length>0?o.split(/\r?\n/):[];return{files:[{path:n,nextPath:null,action:"add",additions:l.length,deletions:0,statsKnown:!0,lines:l.map((u,m)=>({kind:"add",text:`+${u}`,oldLineNumber:null,newLineNumber:m+1}))}],totalAdditions:l.length,totalDeletions:0}}if(e.name==="Edit"){const o=Ae(t,"old_string").split(/\r?\n/),l=Ae(t,"new_string").split(/\r?\n/);return Qn(n,[{oldLines:o,newLines:l}])}const a=(Array.isArray(t.edits)?t.edits:[]).map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return null;const l=o;return{oldLines:Ae(l,"old_string").split(/\r?\n/),newLines:Ae(l,"new_string").split(/\r?\n/)}}).filter(o=>!!o);return a.length>0?Qn(n,a):null}function Qn(e,t){const n=[];let r=0,a=0;return t.forEach((o,l)=>{n.push({kind:"hunk",text:`@@ -1,${o.oldLines.length} +1,${o.newLines.length} @@`,oldLineNumber:null,newLineNumber:null}),o.oldLines.forEach((u,m)=>{u.length===0&&o.oldLines.length===1&&o.newLines.length>0||(a+=1,n.push({kind:"remove",text:`-${u}`,oldLineNumber:m+1,newLineNumber:null}))}),o.newLines.forEach((u,m)=>{u.length===0&&o.newLines.length===1&&o.oldLines.length>0||(r+=1,n.push({kind:"add",text:`+${u}`,oldLineNumber:null,newLineNumber:m+1}))}),l<t.length-1&&n.push({kind:"meta",text:"***",oldLineNumber:null,newLineNumber:null})}),{files:[{path:e,nextPath:null,action:"update",additions:r,deletions:a,statsKnown:!0,lines:n}],totalAdditions:r,totalDeletions:a}}function Da(e){const t=un(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(n)return`${i("conversation.toolPreviewCommand")}:${n}`;if(e.name==="read_thread_terminal")return i("conversation.toolPreviewTerminal");const r=e.input||e.error||e.output||i("conversation.toolResultEmpty");return r.length>60?`${r.slice(0,60)}...`:r}function $a(e){var o;const t=e.map(l=>({message:l,tool:Ps(l)})).filter(l=>!!l.tool);if(t.length===0)return null;const n={...t[0].tool};let r=!1,a=!1;for(const{message:l,tool:u}of t)l.kind==="tool_call"&&(r=!0,!n.input&&u.input&&(n.input=u.input)),l.kind==="tool_result"&&(a=!0,n.output=u.output,n.error=u.error,n.status=u.status,!n.input&&u.input&&(n.input=u.input)),!n.name&&u.name&&(n.name=u.name);return{key:t.map(({message:l})=>l.id).join(":"),tool:n,hasRequest:r,hasResult:a,updatedAt:((o=t.at(-1))==null?void 0:o.message.timestamp)??t[0].message.timestamp}}function Ha(e){const t=new Map;for(const n of e){const r=Ps(n);if(!r)continue;const a=t.get(r.callId);if(a){a.messages.push(n);continue}t.set(r.callId,{messages:[n],firstSequence:n.sequence})}return Array.from(t.values()).sort((n,r)=>n.firstSequence-r.firstSequence).map(n=>$a(n.messages)).filter(n=>!!n)}function Ka(e){const t=[];for(let n=0;n<e.length;n+=1){const r=e[n];if(Va(e,n))continue;if(!Bt(r)){t.push({type:"message",key:r.id,message:r});continue}const a=[r];let o=n+1;for(;o<e.length;){const u=e[o];if(!Bt(u))break;a.push(u),o+=1}const l=Ha(a);if(l.length===0){t.push({type:"message",key:r.id,message:r}),n=o-1;continue}l.forEach(u=>{t.push({type:"tool_group",key:u.key,group:u})}),n=o-1}return t}function Va(e,t){const n=e[t];if(!n||As(n.content)===null)return!1;for(let r=t-1;r>=0;r-=1){const a=e[r];if(!(!a||Bt(a)))return a.role==="user"}return!1}function Ga(e,t){if(!Fr(null,e))return!1;const n=t.trim();return/AGENTS\.md instructions for/i.test(n)&&/<INSTRUCTIONS>/i.test(n)&&/<\/INSTRUCTIONS>/i.test(n)}function Za(e,t){if(e!=="claude-code")return!1;const n=t.trim();return/Base directory for this skill:/i.test(n)&&/^#\s+.+/im.test(n)&&/\bARGUMENTS:/i.test(n)}function Qa(e,t){if(e==="skill_context"){const r=t.split(/\r?\n/).map(a=>a.trim()).find(a=>/^#\s+/.test(a));if(r)return r.replace(/^#+\s*/,"")}const n=t.split(/\r?\n/).map(r=>r.trim()).find(Boolean);return n?n.replace(/^#+\s*/,""):i("conversation.rulesMessageTitle")}function Ja(e,t){const n=new Set;if(t!=="kimi")return n;for(const r of e){if(r.role==="system"&&r.kind==="text"){n.add(r.id);continue}break}return n}function pt(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>pt(n)).join(""):e&&typeof e=="object"&&"props"in e?pt(((t=e.props)==null?void 0:t.children)??""):""}function Ya(e){const t=Array.isArray(e)?e[0]:e;if(!d.isValidElement(t))return null;const n=t.props,r=typeof n.className=="string"?n.className:"",a=/language-([^\s]+)/.exec(r);return{content:pt(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(a==null?void 0:a[1])??null}}function Xa(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function mn(e,t){var n;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!Xa(e))throw new Error(i("conversation.copyContentFailed"))}}function eo({className:e,children:t,onCopy:n}){const r=d.useContext(Ls),a=pt(t).trim();if(r||!a)return s.jsx("code",{className:e||void 0,children:t});function o(l){l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),n(a))}return s.jsx("code",{className:[e,"markdown-inline-copy"].filter(Boolean).join(" "),role:"button",tabIndex:0,"aria-label":i("conversation.copyAction"),onClick:()=>n(a),onKeyDown:o,children:t})}function to({href:e,children:t,className:n,onInteract:r}){const a=pt(t).trim()||(e?cn(e).trim():"");return s.jsx(Ls.Provider,{value:!0,children:s.jsx("a",{href:e,className:[n,"markdown-interactive-link"].filter(Boolean).join(" "),onClick:o=>{o.preventDefault(),r(e,a)},children:t})})}function qs({language:e,codeClassName:t,content:n}){const{showToast:r}=vt(),a=gt(),o=(e==null?void 0:e.trim().toLowerCase())??null,l=o==="text",u=o||"code";async function m(){try{await mn(n,a),r({title:i("conversation.copyContentSuccess"),tone:"success"})}catch(y){r({title:y instanceof Error?y.message:i("conversation.copyContentFailed"),tone:"error"})}}return s.jsxs("div",{className:`code-block${l?" text-code-block":""}`,children:[s.jsxs("div",{className:"code-header",children:[s.jsx("span",{className:"code-header-label",children:u}),s.jsx("button",{className:"code-copy-button",type:"button",onClick:()=>void m(),children:i("conversation.copyAction")})]}),s.jsx("pre",{className:t,children:s.jsx("code",{children:n})})]})}function it({content:e,className:t}){const{showToast:n}=vt(),r=gt(),{navigationGroups:a,currentWorkspaceId:o,revealWorkspaceFile:l}=cs(),u=d.useMemo(()=>{var p;return((p=a.find(x=>x.workspace.id===o))==null?void 0:p.workspace)??null},[o,a]);async function m(p){if(p.trim())try{await mn(p,r),n({title:i("conversation.copyContentSuccess"),tone:"success"})}catch(x){n({title:x instanceof Error?x.message:i("conversation.copyContentFailed"),tone:"error"})}}function y(p,x){const v=p&&(u!=null&&u.path)?Ca(p,u.path):null;v&&l({workspaceId:(u==null?void 0:u.id)??o,filePath:v,openViewer:!1})||m(x||(p?cn(p).trim():""))}return s.jsx("div",{className:t,children:s.jsx(Hr,{remarkPlugins:[Kr],components:{p:({node:p,...x})=>s.jsx("p",{...x}),a(p){return s.jsx(to,{href:typeof p.href=="string"?p.href:void 0,className:typeof p.className=="string"?p.className:void 0,onInteract:y,children:p.children})},pre(p){const x=Ya(p.children);return x?s.jsx(qs,{language:x.language,codeClassName:x.codeClassName,content:x.content}):s.jsx("pre",{children:p.children})},code(p){const x=typeof p.className=="string"?p.className:"";return s.jsx(eo,{className:x||void 0,onCopy:v=>{m(v)},children:p.children})}},children:e})})}function Jn(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function no(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Rt({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){return s.jsx(so,{sessionId:e,attachments:n,attachmentPayloads:t,inlineImages:r})}function so({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){const[a,o]=d.useState({}),[l,u]=d.useState(null),m=d.useMemo(()=>n.map((v,j)=>{const b=Jn(v,t==null?void 0:t[j]);if(b)return{id:v.id,kind:v.kind,fileName:v.fileName,fileSize:v.fileSize,url:b,status:"ready"};const h=a[v.id];return{id:v.id,kind:v.kind,fileName:v.fileName,fileSize:v.fileSize,url:(h==null?void 0:h.url)??null,status:(h==null?void 0:h.status)??(e?"loading":"error")}}),[t,n,a,e]),y=d.useMemo(()=>r.map((v,j)=>({id:`inline-image-${j}`,kind:"image",fileName:v.altText||`${i("conversation.imageAttachmentLabel")} ${j+1}`,fileSize:v.estimatedBytes,url:v.url,status:"ready"})),[r]),p=d.useMemo(()=>[...y,...m],[m,y]),x=p.find(v=>v.id===l)??null;return d.useEffect(()=>{if(!l)return;function v(j){j.key==="Escape"&&u(null)}return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[l]),d.useEffect(()=>{const v=n.filter((h,C)=>!Jn(h,t==null?void 0:t[C]));if(!e||v.length===0){o({});return}let j=!1;const b=[];return o(Object.fromEntries(v.map(h=>[h.id,{id:h.id,kind:h.kind,fileName:h.fileName,fileSize:h.fileSize,url:null,status:"loading"}]))),Promise.all(v.map(async h=>{try{const C=await Ur(e,h.id),T=URL.createObjectURL(C);return b.push(T),{id:h.id,kind:h.kind,fileName:h.fileName,fileSize:h.fileSize,url:T,status:"ready"}}catch{return{id:h.id,kind:h.kind,fileName:h.fileName,fileSize:h.fileSize,url:null,status:"error"}}})).then(h=>{if(j){b.forEach(C=>URL.revokeObjectURL(C));return}o(Object.fromEntries(h.map(C=>[C.id,C])))}),()=>{j=!0,b.forEach(h=>URL.revokeObjectURL(h))}},[t,n,e]),p.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-attachments",children:p.map(v=>{const j=v.kind==="image",b=v.status==="loading"?i("conversation.attachmentPreviewLoading"):v.status==="error"?i("conversation.attachmentPreviewUnavailable"):j?i("conversation.attachmentPreviewOpen"):i("conversation.attachmentDownload"),h=no(v.fileSize),C=s.jsx("div",{className:"message-attachment-card",children:j?v.url?s.jsx("img",{className:"message-attachment-thumbnail",src:v.url,alt:v.fileName||i("conversation.attachmentPreviewAlt"),loading:"lazy"}):s.jsx("div",{className:"message-attachment-placeholder","aria-hidden":"true",children:v.status==="loading"?i("conversation.attachmentPreviewLoading"):i("conversation.attachmentPreviewUnavailable")}):s.jsxs("div",{className:"message-attachment-file-card",children:[s.jsx("div",{className:"message-attachment-file-icon","aria-hidden":"true",children:s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[s.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),s.jsx("path",{d:"M14 2v5h5"}),s.jsx("path",{d:"M9 13h6"}),s.jsx("path",{d:"M9 17h6"})]})}),s.jsxs("div",{className:"message-attachment-file-meta",children:[s.jsx("strong",{title:v.fileName,children:v.fileName}),s.jsx("span",{children:h??i("conversation.fileAttachmentLabel")})]})]})});return!j&&v.url?s.jsx("a",{className:"message-attachment-button",href:v.url,download:v.fileName,"aria-label":`${v.fileName} - ${b}`,title:b,children:C},v.id):s.jsx("button",{type:"button",className:"message-attachment-button",onClick:()=>j&&v.url&&u(v.id),disabled:!v.url,"aria-label":`${v.fileName} - ${b}`,title:b,children:C},v.id)})}),s.jsx(ls,{open:!!(x!=null&&x.url),title:i("conversation.imagePreviewTitle"),description:x==null?void 0:x.fileName,size:"xwide",layout:"viewer",className:"message-image-modal",bodyClassName:"message-image-modal-body",onClose:()=>u(null),children:x!=null&&x.url?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"message-image-modal-stage",children:s.jsx("img",{className:"message-image-modal-image",src:x.url,alt:x.fileName||i("conversation.attachmentPreviewAlt")})}),s.jsx("p",{className:"message-image-modal-hint",children:i("conversation.imagePreviewHint")})]}):null})]})}function ro(){return s.jsx("div",{className:"timeline-skeleton","aria-hidden":"true",children:Array.from({length:3},(e,t)=>s.jsxs("article",{className:`timeline-skeleton-item ${t%2===0?"assistant":"user"}`,children:[s.jsx("div",{className:"timeline-skeleton-avatar"}),s.jsxs("div",{className:"timeline-skeleton-bubble",children:[s.jsx("span",{className:"timeline-skeleton-line long"}),s.jsx("span",{className:"timeline-skeleton-line medium"}),s.jsx("span",{className:"timeline-skeleton-line short"})]})]},t))})}function io({tool:e,preview:t}){const[n,r]=d.useState(null),a=n===null?null:t.files[n]??null;return d.useEffect(()=>{if(n===null)return;function o(l){l.key==="Escape"&&r(null)}return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"tool-call-item apply-patch-item",children:t.files.map((o,l)=>s.jsxs("button",{type:"button",className:"apply-patch-summary-row",onClick:()=>r(l),children:[s.jsx("span",{className:"apply-patch-summary-label",children:Xn(o.action)}),s.jsx("span",{className:"apply-patch-summary-file",title:Xt(o),children:Di(o.nextPath??o.path)}),ts(o)]},es(o,l)))}),s.jsx(ls,{open:a!==null,title:i("conversation.applyPatchDialogTitle"),description:i("conversation.applyPatchDialogDescription"),size:"full",layout:"viewer",className:"apply-patch-modal",bodyClassName:"apply-patch-modal-body",onClose:()=>r(null),children:a?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"apply-patch-modal-totals",children:mo(a)}),s.jsxs("section",{className:"apply-patch-file-panel",children:[s.jsxs("div",{className:"apply-patch-file-panel-header",children:[s.jsxs("div",{className:"apply-patch-file-panel-title",children:[s.jsx("span",{className:"apply-patch-summary-label",children:Xn(a.action)}),s.jsx("strong",{children:Xt(a)})]}),ts(a)]}),s.jsx("div",{className:"apply-patch-diff-view",children:s.jsx("div",{className:"apply-patch-diff-scroll",children:a.lines.map((o,l)=>s.jsxs("div",{className:`apply-patch-diff-line ${po(o.kind)}`,children:[s.jsx("span",{className:"apply-patch-line-number",children:ns(o.oldLineNumber)}),s.jsx("span",{className:"apply-patch-line-number",children:ns(o.newLineNumber)}),s.jsx("span",{className:"apply-patch-line-content",children:o.text||" "})]},`${Xt(a)}:${l}`))})})]},es(a,n??0)),e.error?s.jsxs("section",{className:"apply-patch-error-panel",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:"tool-call-error",children:e.error})]}):null]}):null})]})}function ao({group:e}){const[t,n]=d.useState(!1),{navigationGroups:r}=cs(),{tool:a,hasRequest:o,hasResult:l}=e,u=ja(a.name),m=d.useMemo(()=>Sa(r),[r]),y=d.useMemo(()=>Ta(a,m),[m,a]),p=d.useMemo(()=>Ra(a,m),[m,a]),x=d.useMemo(()=>Zr(a,null,e.updatedAt),[e.updatedAt,a]),v=d.useMemo(()=>za(a),[a.input,a.name]);if(v)return s.jsx(io,{tool:a,preview:v});if(y)return s.jsx(Yn,{tool:a,snapshot:y,expanded:t,hasRequest:o,hasResult:l,onToggleExpanded:()=>{n(h=>!h)}});if(p)return s.jsx(Yn,{tool:a,snapshot:p,expanded:t,hasRequest:o,hasResult:l,onToggleExpanded:()=>{n(h=>!h)}});if(x)return s.jsx(oo,{tool:a,snapshot:x,expanded:t,hasRequest:o,hasResult:l,onToggleExpanded:()=>{n(h=>!h)}});const j=Da(a),b=!!(a.input||a.output||a.error);return s.jsxs("div",{className:`tool-call-item ${l?"tool-result":""}`,children:[s.jsxs("button",{type:"button",className:"tool-call-header",onClick:()=>b&&n(h=>!h),children:[s.jsxs("div",{className:"tool-call-info",children:[s.jsx("span",{className:"tool-call-name",children:u}),s.jsx("span",{className:"tool-call-input-preview",children:j})]}),s.jsx("div",{className:"tool-call-meta",children:b&&s.jsx("span",{className:`tool-call-toggle ${t?"expanded":""}`,children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"6 9 12 15 18 9"})})})})]}),t&&b&&s.jsxs("div",{className:"tool-call-output",children:[o&&a.input&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolInputLabel")}),s.jsx("pre",{children:a.input})]}),(l||a.error||a.output)&&s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:a.error?"tool-call-error":void 0,children:a.error||a.output||i("conversation.toolResultEmpty")})]})]})]})}function Yn({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:a,onToggleExpanded:o}){const l=n?i("conversation.assistantCapabilityRawCollapse"):i("conversation.assistantCapabilityRawExpand");return s.jsxs("div",{className:"tool-call-item assistant-capability-item","data-kind":t.kind,children:[s.jsxs("div",{className:"assistant-capability-header",children:[s.jsxs("div",{className:"assistant-capability-heading",children:[s.jsx("span",{className:"assistant-capability-icon",children:s.jsx(Ua,{kind:t.kind})}),s.jsxs("div",{className:"assistant-capability-heading-main",children:[s.jsx("span",{className:"assistant-capability-badge",children:t.badge}),s.jsx("strong",{children:t.title}),s.jsx("span",{className:"assistant-capability-summary",children:t.summary})]})]}),s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:l})]}),t.rows.length>0?s.jsx("div",{className:"assistant-capability-list",children:t.rows.map(u=>s.jsxs("div",{className:"assistant-capability-row",children:[s.jsx("span",{className:"assistant-capability-row-label",children:u.label}),s.jsx("span",{className:"assistant-capability-row-value",children:u.value})]},u.label))}):null,n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,a||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||i("conversation.toolResultEmpty")})]}):null]}):null]})}function oo({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:a,onToggleExpanded:o}){const l=ms(t.items),u=n?i("conversation.taskCardRawCollapse"):i("conversation.taskCardRawExpand");return s.jsxs("div",{className:"tool-call-item task-tool-item",children:[s.jsxs("div",{className:"task-tool-header",children:[s.jsxs("div",{className:"task-tool-heading",children:[s.jsx("span",{className:"task-tool-badge",children:t.source==="plan"?i("conversation.taskCardPlanTitle"):i("conversation.taskCardTodoTitle")}),s.jsxs("div",{className:"task-tool-heading-main",children:[s.jsx("strong",{children:lo(t,e.name)}),s.jsx("span",{className:"task-tool-summary-text",children:co(t.items,l)})]})]}),s.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:u})]}),s.jsx("ol",{className:"task-tool-list",children:t.items.map(m=>s.jsxs("li",{className:"task-tool-list-item","data-status":m.status,children:[s.jsx("span",{className:"task-tool-item-indicator","data-status":m.status,"aria-hidden":"true"}),s.jsx("strong",{className:"task-tool-item-title",children:m.title}),m.detail?s.jsx("span",{className:"task-tool-item-detail",children:m.detail}):null,s.jsx("span",{className:"task-tool-item-status",children:uo(m.status)})]},m.id))}),n?s.jsxs("div",{className:"tool-call-output",children:[r&&e.input?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolInputLabel")}),s.jsx("pre",{children:e.input})]}):null,a||e.error||e.output?s.jsxs("div",{className:"tool-call-section",children:[s.jsx("div",{className:"tool-call-section-label",children:i("conversation.toolResultLabel")}),s.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||i("conversation.toolResultEmpty")})]}):null]}):null]})}function lo(e,t){if(e.source==="plan")return i("conversation.taskCardPlanUpdated");const n=t.trim().toLowerCase();return n==="taskcreate"||n==="todowrite"||n==="todoread"?i("conversation.taskCardTodoUpdated"):n.startsWith("task")?i("conversation.taskCardTodoUpdated"):i("conversation.taskCardTodoUpdated")}function co(e,t){const n=[i("conversation.taskCardSummaryTotal",{count:e.length})];return t.in_progress>0&&n.push(i("conversation.taskCardSummaryInProgress",{count:t.in_progress})),t.pending>0&&n.push(i("conversation.taskCardSummaryPending",{count:t.pending})),t.completed>0&&n.push(i("conversation.taskCardSummaryCompleted",{count:t.completed})),t.failed>0&&n.push(i("conversation.taskCardSummaryFailed",{count:t.failed})),n.join(" / ")}function uo(e){switch(e){case"in_progress":return i("conversation.taskProgressStatusInProgress");case"completed":return i("conversation.taskProgressStatusCompleted");case"failed":return i("conversation.taskProgressStatusFailed");case"cancelled":return i("conversation.taskProgressStatusCancelled");case"pending":default:return i("conversation.taskProgressStatusPending")}}function Xn(e){return e==="add"?i("conversation.applyPatchAddedLabel"):e==="delete"?i("conversation.applyPatchDeletedLabel"):i("conversation.applyPatchEditedLabel")}function Xt(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function es(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function ts(e){return e.statsKnown?s.jsxs("span",{className:"apply-patch-summary-stats",children:[s.jsxs("span",{className:"apply-patch-summary-added",children:["+",e.additions]}),s.jsxs("span",{className:"apply-patch-summary-removed",children:["-",e.deletions]})]}):s.jsx("span",{className:"apply-patch-summary-stats",children:s.jsx("span",{className:"apply-patch-summary-edited",children:i("conversation.applyPatchEditedStat")})})}function mo(e){return e.statsKnown?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"apply-patch-stat-pill positive",children:[i("conversation.applyPatchAddedStat")," +",e.additions]}),s.jsxs("span",{className:"apply-patch-stat-pill negative",children:[i("conversation.applyPatchRemovedStat")," -",e.deletions]})]}):s.jsx("span",{className:"apply-patch-stat-pill neutral",children:i("conversation.applyPatchEditedStat")})}function po(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function ns(e){return e===null||e<=0?"":String(e)}function fo(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Ws({timestamp:e,leading:t,children:n}){return s.jsxs("div",{className:"user-message-footer",children:[s.jsx("div",{className:"user-message-footer-leading",children:t}),s.jsxs("div",{className:"user-message-footer-trailing",children:[s.jsx("time",{className:"message-time",dateTime:e,children:fo(e)}),n]})]})}function Le({text:e,canCopy:t=!0,canFork:n=!1,compact:r=!1,onFork:a}){const{showToast:o}=vt(),l=gt(),[u,m]=d.useState(!1),[y,p]=d.useState(!1),x=e.trim().length>0,v=t&&x;async function j(){if(!(!v||u)){m(!0);try{await mn(e,l),o({title:i("conversation.copyContentSuccess"),tone:"success"})}catch(h){o({title:h instanceof Error?h.message:i("conversation.copyContentFailed"),tone:"error"})}finally{m(!1)}}}async function b(){if(!(!a||y)){p(!0);try{await a()}finally{p(!1)}}}return!v&&!n?null:s.jsxs("div",{className:r?"message-metadata-bar compact":"message-metadata-bar",children:[v?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":i("conversation.copyAction"),title:i("conversation.copyAction"),onClick:()=>{j()},disabled:u,children:s.jsx(ri,{})}):null,n?s.jsx("button",{type:"button",className:"message-metadata-action","aria-label":y?i("conversation.forkingAction"):i("conversation.forkFromHereAction"),title:y?i("conversation.forkingAction"):i("conversation.forkFromHereAction"),onClick:()=>{b()},disabled:y,children:s.jsx(ii,{})}):null]})}function ho({message:e,kind:t,tone:n,actionState:r,onRetry:a,onForkMessage:o}){const[l,u]=d.useState(!1),m=Qa(t,e.content),y=n==="user-message",p=t==="system_prompt"?i("conversation.systemPromptTitle"):t==="skill_context"?i("conversation.skillContextTitle"):i("conversation.rulesMessageTitle"),x=t==="system_prompt"?i("conversation.systemPromptHint"):t==="skill_context"?i("conversation.skillContextHint"):i("conversation.rulesMessageHint"),v=l?t==="system_prompt"?i("conversation.systemPromptCollapse"):t==="skill_context"?i("conversation.skillContextCollapse"):i("conversation.rulesMessageCollapse"):t==="system_prompt"?i("conversation.systemPromptExpand"):t==="skill_context"?i("conversation.skillContextExpand"):i("conversation.rulesMessageExpand");return s.jsx("article",{className:`message-item ${n} rules-message-row`,"data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsxs("div",{className:"rules-message-card",children:[s.jsxs("button",{type:"button",className:"rules-message-toggle","aria-expanded":l,onClick:()=>u(j=>!j),children:[s.jsxs("div",{className:"rules-message-heading",children:[s.jsx("span",{className:"rules-message-badge",children:p}),s.jsx("span",{className:"rules-message-summary",children:m})]}),s.jsx("span",{className:"rules-message-action",children:v})]}),s.jsx("p",{className:"rules-message-hint",children:x}),l&&s.jsx("div",{className:"rules-message-body",children:s.jsx(it,{content:e.content,className:"message-text message-content markdown-content"})}),y?s.jsx(Ws,{timestamp:e.timestamp,children:s.jsx(Le,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),compact:!0,onFork:o?()=>o(e):null})}):s.jsx(Le,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(e):null})]}),e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>a(e.clientRequestId),children:i("conversation.resendButton")})]})})}function go({message:e,provider:t,interruptedSource:n=null,foldedPromptKind:r=null,actionState:a,onRetry:o,onForkMessage:l,assistantAvatar:u}){const m=e.role==="user",y=e.kind==="thinking",p=e.role==="assistant"&&e.kind==="text",x=t==="codex"&&e.kind==="text"?As(e.content):null,v=r??(Ga(t,e.content)?"rules":Za(t,e.content)?"skill_context":null),j=d.useMemo(()=>ut(e.content),[e.content]),b=j.text,h=j.inlineImages,[C,T]=d.useState(!1),[M,R]=d.useState(!1),[I,D]=d.useState(null),[A,F]=d.useState(null);if(v){const L=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return s.jsx(ho,{message:e,kind:v,tone:L,actionState:a,onRetry:o,onForkMessage:l})}if(x){const L=ma(n),$=x.detail?`${L}
|
|
15
15
|
|
|
16
|
-
${x.detail}`:L;return s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:d??s.jsx(en,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(it,{content:$,className:"message-text message-content markdown-content"}),s.jsx(Le,{text:$,canCopy:a.canCopy,canFork:!1,onFork:null})]})]})}if(m){const L=e.origin==="butler_proxy"||vo(e.clientRequestId),$=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function H(){if(!$)return;const U=!C;if(T(U),!(!U||A||M)){R(!0),D(null);try{const K=await Dr(e.originRef);F(K.task)}catch(K){D(K instanceof Error?K.message:i("conversation.butlerOriginDetailLoadFailed"))}finally{R(!1)}}}const X=L?$?s.jsxs("div",{className:"message-origin-detail-anchor",children:[s.jsx("button",{type:"button",className:"message-origin-badge message-origin-badge-button","aria-expanded":C,onClick:()=>{H()},children:i("conversation.butlerProxyMessageBadge")}),C?s.jsxs("div",{className:"message-origin-detail-popover",role:"dialog","aria-live":"polite",children:[s.jsx("strong",{children:i("conversation.butlerOriginDetailTitle")}),M?s.jsx("p",{children:i("conversation.butlerOriginDetailLoading")}):I?s.jsx("p",{children:I}):A?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:[i("conversation.butlerOriginDetailObjectiveLabel"),":",A.objective]}),s.jsxs("p",{children:[i("conversation.butlerOriginDetailStatusLabel"),":",xo(A.status)]}),s.jsxs("p",{children:[i("conversation.butlerOriginDetailSummaryLabel"),":",A.lastAutomationSummary||i("conversation.butlerAnalysisEmpty")]}),A.waitingReason?s.jsxs("p",{children:[i("conversation.butlerOriginDetailWaitingReasonLabel"),":",A.waitingReason]}):null]}):s.jsx("p",{children:i("conversation.butlerAnalysisEmpty")})]}):null]}):s.jsx("span",{className:"message-origin-badge",children:i("conversation.butlerProxyMessageBadge")}):null;return s.jsx("article",{className:"message-item user-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:f}),b?s.jsx(it,{content:b,className:"message-text message-content markdown-content"}):null,e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>o(e.clientRequestId),children:i("conversation.resendButton")}),s.jsx(Ws,{timestamp:e.timestamp,leading:X,children:s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),compact:!0,onFork:l?()=>l(e):null})})]})})}return k?s.jsxs("article",{className:"message-item assistant-message thinking-message-row","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:d??s.jsx(en,{})}),s.jsxs("div",{className:"thinking-message-content",children:[s.jsx("div",{className:"thinking-message-label",children:i("conversation.thinkingLabel")}),s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:f}),b&&s.jsx(it,{content:b,className:"message-text message-content markdown-content thinking-message-text"}),s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),onFork:l?()=>l(e):null})]})]}):v?s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:d??s.jsx(en,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:f}),b&&s.jsx(it,{content:b,className:"message-text message-content markdown-content"}),s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),onFork:l?()=>l(e):null})]})]}):s.jsx("article",{className:"message-item system-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:f}),b?s.jsx("div",{className:"message-text message-content",children:s.jsx(qs,{language:"text",content:b})}):null,s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),onFork:l?()=>l(e):null})]})})}function en(){return s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4M12 8h.01"})]})}function vo(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function xo(e){switch(e){case"waiting_user":return i("shell.butlerAutomationStatusWaitingUser");case"completed":return i("shell.butlerAutomationStatusCompleted");case"failed":return i("shell.butlerAutomationStatusFailed");case"cancelled":return i("shell.butlerAutomationStatusCancelled");case"active":default:return i("shell.butlerAutomationStatusActive")}}function il({sessionId:e="session",messages:t,historyState:n,loadingOlderMessages:r=!1,hasOlderMessages:a=!1,onLoadOlderMessages:o=()=>{},onRetryMessage:l,onForkMessage:d,provider:m,interruptedSource:k=null,runtimeThinkingPlaceholder:v=null,assistantAvatar:x}){var Fe;const{showToast:g}=vt(),j=gt(),b=u.useRef(null),f=u.useRef(e),C=u.useRef(0),T=u.useRef(null),M=u.useRef(!0),R=u.useRef(null),I=u.useRef(null),D=u.useRef(!1),A=u.useRef(Tt(e)),F=u.useRef(((Fe=Tt(e))==null?void 0:Fe.lastMessageSignature)??null),L=u.useRef(Tt(e)),$=u.useRef(null),H=u.useRef(null),X=u.useRef(null),U=u.useRef(0),K=u.useRef(!1),Ee=u.useRef(null),se=u.useRef(null),[Be,me]=u.useState(!1),[G,ae]=u.useState(!1),re=u.useRef(!1),ke=Ka(t),xt=j.isMobile?0:va,pe=u.useMemo(()=>Ja(t,m),[t,m]),Oe=u.useMemo(()=>bo(t),[t]),bt=n==="loading"&&t.length===0;function Ce(p){const E=p.scrollHeight-p.clientHeight-p.scrollTop<=Kn;return{scrollTop:p.scrollTop,stickToBottom:E,lastMessageSignature:re.current&&!E?F.current:Ke(t.at(-1)??null)}}function fe(p){return L.current=Ce(p),L.current}function he(p){const N=p.scrollHeight-p.clientHeight-p.scrollTop,E=N<=Kn;M.current=E,E&&re.current&&(Q(),re.current=!1,F.current=Ke(t.at(-1)??null),ae(!1)),me(t.length>0&&(N>Vn||re.current)),fe(p)}function ee(p=b.current){p&&fe(p),L.current&&Hn(e,L.current)}function Qe(p){L.current&&Hn(p,L.current)}function Ze(){$.current!==null&&(window.clearTimeout($.current),$.current=null)}function Je(){Ze(),$.current=window.setTimeout(()=>{$.current=null,ee()},fa)}function je(p){p.scrollTop=p.scrollHeight}function Ye(){H.current!==null&&(window.clearTimeout(H.current),H.current=null)}function Q(){Ye(),K.current=!1,X.current=null,U.current=0,Ee.current=null}function _e(p,N){const E=Math.max(0,p.scrollHeight-p.clientHeight),Z=Math.max(0,Math.min(N,E));Ee.current=Z,p.scrollTop=Z,M.current=!1,me(t.length>0&&(E-Z>Vn||re.current))}function we(){Ye(),K.current&&(H.current=window.setTimeout(()=>{H.current=null;const p=b.current,N=X.current;if(!p||N===null){Q();return}if(_e(p,N),Date.now()<U.current){we();return}Q(),he(p)},ga))}function Ne(p,N){if(xt<=0){_e(N,p),Q();return}K.current=!0,X.current=p,U.current=Date.now()+xt,_e(N,p),we()}function oe(){K.current&&Q()}function ge(p){return D.current||!a||r||n!=="ready"||p.scrollTop>pa?!1:(D.current=!0,R.current=p.scrollHeight-p.scrollTop,I.current=Ke(t[0]??null),o(),!0)}u.useEffect(()=>{n==="error"&&g({title:i("conversation.historyLoadFailed"),tone:"error"})},[n,g]),u.useLayoutEffect(()=>{var p,N;f.current!==e&&(Qe(f.current),f.current=e,C.current=0,T.current=null,A.current=Tt(e),F.current=((p=A.current)==null?void 0:p.lastMessageSignature)??null,L.current=A.current,M.current=((N=A.current)==null?void 0:N.stickToBottom)??!0,R.current=null,I.current=null,Q(),re.current=!1,ae(!1),me(!1))},[e]),u.useLayoutEffect(()=>()=>{Ze(),Q(),Qe(f.current)},[e]),u.useLayoutEffect(()=>{const p=b.current,N=Ke(t.at(-1)??null);if(!p){C.current=t.length,T.current=N;return}const E=C.current,Z=T.current,V=A.current;if(V&&n==="ready"){const le=!V.stickToBottom&&V.lastMessageSignature!==null&&N!==null&&V.lastMessageSignature!==N;V.stickToBottom?(Q(),je(p)):Ne(V.scrollTop,p),re.current=le,F.current=V.lastMessageSignature,ae(le),A.current=null,he(p),C.current=t.length,T.current=N,fe(p);return}if(V&&n==="error"){V.stickToBottom?(Q(),je(p)):Ne(V.scrollTop,p),A.current=null,he(p),C.current=t.length,T.current=N,fe(p);return}if(K.current){_e(p,X.current??p.scrollTop),C.current=t.length,T.current=N,fe(p);return}const Te=Ke(t[0]??null),Re=R.current,Ue=I.current;Re!==null&&!r&&Ue!==null&&Ue!==Te&&t.length>=E?(p.scrollTop=Math.max(0,p.scrollHeight-Re),R.current=null,I.current=null):R.current!==null&&!r?(R.current=null,I.current=null):M.current&&(E===0||t.length!==E||N!==Z)&&je(p),he(p),C.current=t.length,T.current=N},[n,r,t,e]),u.useEffect(()=>{if(!a){D.current=!1;return}!r&&R.current===null&&(D.current=!1)},[a,r,t.length]);function qe(){const p=b.current;if(p){if(K.current){const N=Ee.current;N!==null&&Math.abs(p.scrollTop-N)<=1?Ee.current=null:oe()}he(p),Je(),ge(p)}}function Se(p){if(p.deltaY!==0&&oe(),p.deltaY>=0)return;const N=b.current;N&&ge(N)}function Xe(p){var N;oe(),se.current=((N=p.touches[0])==null?void 0:N.clientY)??null}function yt(p){var V;const N=se.current,E=((V=p.touches[0])==null?void 0:V.clientY)??null;if(N===null||E===null||E-N<ha)return;oe();const Z=b.current;Z&&ge(Z)}function We(){se.current=null}return s.jsxs("section",{className:"message-timeline",children:[n==="loading"&&s.jsx("div",{className:"timeline-status",children:s.jsx("span",{className:"status-text",children:i("conversation.historyLoading")})}),s.jsxs("div",{ref:b,className:"message-list",onScroll:qe,onPointerDown:oe,onWheel:Se,onTouchStart:Xe,onTouchMove:yt,onTouchEnd:We,onTouchCancel:We,children:[bt?s.jsx(ro,{}):null,r?s.jsx("div",{className:"timeline-status timeline-status-inline",children:s.jsx("span",{className:"status-text",children:i("conversation.historyLoadingOlder")})}):null,ke.length===0&&n==="ready"&&s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:i("conversation.timelineEmpty")})}),ke.map(p=>p.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx(ao,{group:p.group})},p.key):s.jsx(go,{message:p.message,provider:m,foldedPromptKind:pe.has(p.message.id)?"system_prompt":null,actionState:Oe.get(p.message.id)??{canCopy:p.message.role==="user",canFork:!1},onRetry:l,onForkMessage:d,interruptedSource:k,assistantAvatar:x},p.key)),v?s.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline",children:s.jsxs("span",{className:"status-text thinking-status-text","aria-label":v,children:[s.jsx("span",{children:da(v)||v}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})}):null]}),Be?s.jsxs("button",{type:"button",className:"conversation-scroll-to-bottom-button","data-has-new":G?"true":"false","aria-label":i("conversation.scrollToBottomAction"),title:i("conversation.scrollToBottomAction"),onClick:()=>{const p=b.current;p&&(Q(),je(p),re.current=!1,F.current=Ke(t.at(-1)??null),ae(!1),he(p),ee(p))},children:[G?s.jsx("span",{className:"conversation-scroll-to-bottom-button-badge",children:"NEW"}):null,s.jsx("svg",{className:"conversation-scroll-to-bottom-button-icon",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:s.jsx("path",{d:"M10 4.25a.75.75 0 0 1 .75.75v7.19l2.72-2.72a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V5a.75.75 0 0 1 .75-.75Zm-4 11a.75.75 0 0 1 0-1.5h8a.75.75 0 0 1 0 1.5H6Z",fill:"currentColor"})})]}):null]})}function Ke(e){return e?JSON.stringify({id:e.id,content:e.content,attachments:e.attachments,timestamp:e.timestamp,deliveryState:e.deliveryState,toolCall:e.toolCall?{status:e.toolCall.status,output:e.toolCall.output,error:e.toolCall.error}:null}):null}function bo(e){const t=new Map;let n=0;function r(a){let o=null;for(let l=a-1;l>=n;l-=1){const d=e[l];if(!(!d||!yo(d))){o=d.id;break}}for(let l=n;l<a;l+=1){const d=e[l];if(d){if(d.role==="user"){t.set(d.id,{canCopy:!0,canFork:!1});continue}t.set(d.id,{canCopy:d.id===o,canFork:d.id===o})}}}for(let a=0;a<e.length;a+=1){const o=e[a];o&&o.role==="user"&&a>n&&(r(a),n=a)}return r(e.length),t}function yo(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function al({requests:e,replyingRequestId:t,onReply:n}){const[r,a]=u.useState({}),o=u.useMemo(()=>e.filter(l=>l.status==="pending"),[e]);return o.length===0?null:s.jsxs("section",{className:"permission-request-list",children:[s.jsxs("div",{className:"permission-request-list-header",children:[s.jsx("div",{children:s.jsx("strong",{children:i("conversation.permissionRequestSectionTitle")})}),s.jsx("span",{className:"permission-request-count",children:o.length})]}),s.jsx("div",{className:"permission-request-stack",children:o.map(l=>{var g,j;const d=r[l.id]??{},m=l.paths.filter(Boolean),k=l.kind==="command"&&!!((g=l.command)!=null&&g.trim()),v=l.questions.length===0&&m.length===0&&!k&&!!((j=l.summary)!=null&&j.trim()),x=l.kind==="user_input"&&l.questions.some(b=>{var f;return(((f=d[b.id])==null?void 0:f.filter(Boolean).length)??0)===0});return s.jsxs("article",{className:"permission-request-card",children:[s.jsxs("header",{className:"permission-request-card-header",children:[s.jsxs("div",{className:"permission-request-provider",children:[s.jsx("span",{className:"permission-request-provider-icon","aria-hidden":"true",children:s.jsx("img",{src:zr(l.provider),alt:"",loading:"lazy"})}),s.jsxs("div",{className:"permission-request-provider-copy",children:[s.jsx("strong",{children:l.title}),s.jsx("span",{children:os(l.provider,"full")})]})]}),s.jsx("span",{className:"permission-request-kind",children:ko(l.kind)})]}),s.jsxs("div",{className:"permission-request-card-body",children:[m.length>0?s.jsx("div",{className:"permission-request-block",children:s.jsx("ul",{className:"permission-request-target-list",children:m.map(b=>s.jsxs("li",{className:"permission-request-target-item",children:[s.jsx("strong",{children:Co(b)}),s.jsx("span",{children:b})]},`${l.id}:${b}`))})}):null,k?s.jsxs("div",{className:"permission-request-block",children:[s.jsx("div",{className:"permission-request-block-label",children:i("conversation.permissionRequestCommandLabel")}),s.jsx("pre",{children:l.command})]}):null,v?s.jsx("p",{className:"permission-request-summary",children:l.summary}):null,l.questions.length>0?s.jsxs("div",{className:"permission-request-block",children:[s.jsx("div",{className:"permission-request-block-label",children:i("conversation.permissionRequestQuestionsLabel")}),s.jsx("div",{className:"permission-request-question-list",children:l.questions.map(b=>s.jsxs("div",{className:"permission-request-question",children:[s.jsx("div",{className:"permission-request-question-header",children:b.header}),s.jsx("p",{children:b.question}),s.jsx("div",{className:"permission-request-question-options",children:b.options.map(f=>{var T;const C=((T=d[b.id])==null?void 0:T.includes(f.label))??!1;return s.jsxs("label",{className:"permission-request-question-option",children:[s.jsx("input",{type:"radio",name:`${l.id}:${b.id}`,checked:C,onChange:()=>{a(M=>({...M,[l.id]:{...M[l.id]??{},[b.id]:[f.label]}}))}}),s.jsxs("span",{children:[s.jsx("strong",{children:f.label}),f.description?s.jsx("small",{children:f.description}):null]})]},`${b.id}:${f.label}`)})})]},b.id))})]}):null]}),s.jsx("footer",{className:"permission-request-card-footer",children:l.actions.map(b=>s.jsx("button",{type:"button",className:`permission-request-action permission-request-action-${b.tone}`,disabled:t===l.id||b.value==="submit"&&x,onClick:()=>void n(l.id,{action:b.value,answers:Object.keys(d).length>0?d:void 0}),children:t===l.id?i("conversation.permissionRequestSubmitting"):b.label},`${l.id}:${b.value}`))})]},l.id)})})]})}function ko(e){return e==="command"?i("conversation.permissionRequestKindCommand"):e==="file_change"?i("conversation.permissionRequestKindFileChange"):e==="permissions"?i("conversation.permissionRequestKindPermissions"):e==="user_input"?i("conversation.permissionRequestKindUserInput"):i("conversation.permissionRequestKindToolCall")}function Co(e){return e.split(/[/\\]+/).filter(Boolean).at(-1)??e}class ol{constructor(t){de(this,"socket",null);de(this,"disposed",!1);de(this,"authRecoveryInFlight",!1);de(this,"latestCursor");de(this,"subscribed",!1);de(this,"pendingOlderRequest",null);de(this,"inFlightOlderRequest",null);de(this,"connectionManager");this.options=t,this.latestCursor=t.cursor,this.connectionManager=new $r({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}updateCursor(t){this.latestCursor=t}reconnectNow(){this.connectionManager.reconnectNow()}requestOlderMessages(t,n){return jo(this.socket)?this.subscribed?(this.sendOlderMessagesRequest(t,n),!0):(this.pendingOlderRequest={cursor:t,limit:n},!0):!1}close(){var t;this.disposed=!0,this.subscribed=!1,this.pendingOlderRequest=null,this.inFlightOlderRequest=null,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var l;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(l=Pn.getState().session)==null?void 0:l.accessToken;if(!n){this.options.onUnauthorized();return}const r=wr(),a=`${Nr("/ws",r)}?access_token=${encodeURIComponent(n)}`,o=Sr(r).createWebSocket({path:"/ws",baseUrl:r,url:a});this.subscribed=!1,this.socket=o,o.addEventListener("open",()=>{o.send(JSON.stringify({type:"session.subscribe",sessionId:this.options.sessionId,cursor:this.latestCursor,limit:this.options.limit}))}),o.addEventListener("message",d=>{if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const m=JSON.parse(d.data);if(m.type==="system.connected"){this.connectionManager.markConnected();return}if(m.type==="session.subscribed"){this.subscribed=!0,this.options.onSubscribed(),this.flushPendingOlderRequest();return}if(m.type==="session.error"){if(this.clearOlderMessagesRequest(),m.error_code==="UNAUTHORIZED"){this.handleUnauthorized();return}this.options.onError(m);return}if(m.type==="session.runtime_status"){this.options.onRuntimeStatus(m);return}if(m.type==="session.activity"){this.options.onActivity(m);return}if(m.type==="session.history_older"){this.clearOlderMessagesRequest(),this.options.onOlderHistory(m);return}if(m.type==="session.runtime_message"){this.options.onRuntimeMessage(m);return}if(m.type==="session.runtime_error"){this.options.onRuntimeError(m);return}if(m.type==="session.interrupted"){this.options.onInterrupted(m);return}if(m.type==="session.permission_request"){this.options.onPermissionRequest(m);return}if(m.type==="session.permission_request_resolved"){this.options.onPermissionRequestResolved(m);return}this.latestCursor=m.cursor,this.options.onEnvelope(m)}),o.addEventListener("close",()=>{this.disposed||this.socket!==o||(this.subscribed=!1,this.requeueInFlightOlderRequest(),this.connectionManager.markDisconnected())}),o.addEventListener("error",()=>{this.disposed||this.socket!==o||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0,this.subscribed=!1,this.requeueInFlightOlderRequest();const t=this.socket;this.socket=null,t==null||t.close(),Pn.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendOlderMessagesRequest(t,n){var r;this.inFlightOlderRequest={cursor:t,limit:n},(r=this.socket)==null||r.send(JSON.stringify({type:"session.load_older",sessionId:this.options.sessionId,cursor:t,limit:n}))}flushPendingOlderRequest(){if(!this.pendingOlderRequest)return;const t=this.pendingOlderRequest;this.pendingOlderRequest=null,this.sendOlderMessagesRequest(t.cursor,t.limit)}clearOlderMessagesRequest(){this.pendingOlderRequest=null,this.inFlightOlderRequest=null}requeueInFlightOlderRequest(){this.inFlightOlderRequest&&(this.pendingOlderRequest=this.inFlightOlderRequest,this.inFlightOlderRequest=null)}}function jo(e){return e!==null&&e.readyState===1}const wo=3*1e3;function ll(e){return{session:(e==null?void 0:e.session)??null,capabilities:(e==null?void 0:e.capabilities)??null,runtimeHasActiveRun:(e==null?void 0:e.runtimeHasActiveRun)??null,runtimeCanInterrupt:(e==null?void 0:e.runtimeCanInterrupt)??null,contextUsage:(e==null?void 0:e.contextUsage)??null,messages:(e==null?void 0:e.messages)??[],permissionRequests:(e==null?void 0:e.permissionRequests)??[],queuedMessages:(e==null?void 0:e.queuedMessages)??[],historyState:"idle",loadingOlderMessages:!1,olderCursor:(e==null?void 0:e.olderCursor)??null,hasOlderMessages:(e==null?void 0:e.hasOlderMessages)??!1,connectionState:"closed",lastCursor:(e==null?void 0:e.lastCursor)??null,pagesLoaded:(e==null?void 0:e.pagesLoaded)??0,interruptSource:(e==null?void 0:e.interruptSource)??null,errorCode:null,errorDetail:null}}function Fs(e,t,n="sent",r=null){const a=t.kind??(t.role==="tool"?"tool_result":"text"),o=t.toolCall??(a==="tool_call"||a==="tool_result"?{callId:t.rawRef||t.messageId,name:"tool",input:a==="tool_call"?t.content:"",output:a==="tool_result"&&t.content?t.content:null,error:null,status:a==="tool_call"?"running":"completed"}:null);return{id:t.messageId,sessionId:e,role:t.role,kind:a,content:t.content,toolCall:o,attachments:t.attachments??[],attachmentPayloads:null,origin:t.origin??null,originRef:t.originRef??null,timestamp:t.timestamp,sequence:t.sequence,rawRef:t.rawRef,deliveryState:n,clientRequestId:r}}function cl(e,t,n,r=[],a=[],o=Number.MAX_SAFE_INTEGER){return{id:`pending-${n}`,sessionId:e,role:"user",kind:"text",content:t,toolCall:null,attachments:r,attachmentPayloads:a,origin:null,originRef:null,timestamp:new Date().toISOString(),sequence:o,rawRef:`pending://${n}`,deliveryState:"sending",clientRequestId:n}}function ul(e,t,n){const r=new Map;for(const a of e)r.set(a.id,a);for(const a of n){const o=Fs(t,a),l=Vo(r,o);if(l&&l!==o.id)continue;const d=Ko(r,o);d&&d!==o.id&&r.delete(d);const m=r.get(a.messageId)??null;r.set(a.messageId,m?Po(m,o):o)}return Us(Array.from(r.values()))}function dl(e,t,n,r){const a=r===null?null:e.find(m=>m.clientRequestId===r)??null,o=e.filter(m=>m.clientRequestId!==r),l=Fs(t,n,"sent",r),d=Lo(l,a);return Us([...o.filter(m=>m.id!==d.id),d])}function ml(e,t){return e.map(n=>n.clientRequestId===t?{...n,deliveryState:"failed"}:n)}function No(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!Io(r,n)){t.push(n);continue}t[t.length-1]=Oo(r,n)}return t}function So(e){const t=[];let n=null,r=!1;for(const a of e)if(!Eo(n,a,r)){if(t.push(a),ft(a)){n=a,r=!1;continue}n&&an(a)&&(r=!0)}return t}function To(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!zs(r,n)){t.push(n);continue}t[t.length-1]=Ds(r,n)}return t}function Ro(e){const t=[];for(const n of e){if(t.push(n),t.length<4)continue;const r=t[t.length-4],a=t[t.length-3],o=t[t.length-2],l=t[t.length-1];Bo(r,a,o,l)&&t.splice(t.length-3,3,Ds(a,l))}return t}function Mo(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!_o(r,n)){t.push(n);continue}t[t.length-1]=Wo(r,n)}return t}function Ao(e){const t=[];for(const n of e){const r=t.findIndex(a=>qo(a,n));if(r===-1){t.push(n);continue}t[r]=Fo(t[r],n)}return t}function Us(e){const t=[...e].sort((n,r)=>n.sequence!==r.sequence?n.sequence-r.sequence:n.timestamp.localeCompare(r.timestamp));return Ao(Mo(So(Ro(To(No(t))))))}function Lo(e,t){if(!t)return e;const n=e.attachments??[];return{...e,attachments:n.length>0?n:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function Po(e,t){if(e.id!==t.id)return t;if(e.role!==t.role||e.kind!==t.kind||e.rawRef!==t.rawRef)return ht(e,t);const n=Uo(e.toolCall,t.toolCall),r=Do(e.content,t.content,e.timestamp,t.timestamp),a=$o(e.attachments,t.attachments);return{...ht(e,t),content:r,toolCall:n,attachments:a,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,timestamp:e.timestamp.localeCompare(t.timestamp)>=0?e.timestamp:t.timestamp,sequence:Math.max(e.sequence,t.sequence)}}function Io(e,t){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!==t.role||e.kind!==t.kind||e.toolCall!==null||t.toolCall!==null||e.kind!=="text"&&e.kind!=="thinking")return!1;const n=ut(e.content),r=ut(t.content);return Ge(e.timestamp,t.timestamp,wo)&&B(n.text)===B(r.text)&&Ho(n.inlineImages,r.inlineImages)}function Eo(e,t,n){return!e||n||!ft(e)||!ft(t)?!1:Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function ft(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function an(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&e.kind==="text"}function zs(e,t){return an(e)&&an(t)&&Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function Bo(e,t,n,r){return!e||!t||!n||!r||!ft(e)||!ft(n)?!1:zs(t,r)&&Ge(e.timestamp,n.timestamp,120*1e3)&&B(e.content)===B(n.content)}function Ds(e,t){var l,d;const n=((l=e.attachments)==null?void 0:l.length)??0,r=((d=t.attachments)==null?void 0:d.length)??0;if(n!==r)return n>r?e:t;const a=B(e.content).length,o=B(t.content).length;return a!==o?a>o?e:t:ht(e,t)}function Oo(e,t){var m,k;const n=((m=e.attachments)==null?void 0:m.length)??0,r=((k=t.attachments)==null?void 0:k.length)??0;if(n!==r)return n>r?e:t;const a=ut(e.content).inlineImages.length,o=ut(t.content).inlineImages.length;if(a!==o)return a>o?e:t;const l=e.content!==B(e.content),d=t.content!==B(t.content);return l!==d?l?t:e:t}function _o(e,t){return!ss(e)||!ss(t)?!1:e.role===t.role&&Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function qo(e,t){return!rs(e)||!rs(t)?!1:e.role===t.role&&Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function ss(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function rs(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function Wo(e,t){var m,k;const n=((m=e.attachments)==null?void 0:m.length)??0,r=((k=t.attachments)==null?void 0:k.length)??0;if(n!==r)return n>r?e:t;const a=B(e.content).length,o=B(t.content).length;if(a!==o)return a>o?e:t;const l=e.rawRef.includes("#file="),d=t.rawRef.includes("#file=");return l!==d?l?e:t:ht(e,t)}function Fo(e,t){var m,k;const n=((m=e.attachments)==null?void 0:m.length)??0,r=((k=t.attachments)==null?void 0:k.length)??0;if(n!==r)return n>r?e:t;const a=B(e.content).length,o=B(t.content).length;if(a!==o)return a>o?e:t;const l=e.rawRef.includes("/context#"),d=t.rawRef.includes("/context#");return l!==d?l?e:t:ht(e,t)}function Uo(e,t){return e?t?{...zo(e,t),input:$s(e.input,t.input),output:as(e.output,t.output),error:as(e.error,t.error)}:e:t}function zo(e,t){const n=is(e.status),r=is(t.status);return r!==n?r>n?t:e:t}function is(e){return e==="running"?0:1}function Do(e,t,n,r){const a=B(e),o=B(t);return a===o?e.length>=t.length?e:t:a.length>o.length&&a.includes(o)?e:o.length>a.length&&o.includes(a)||r.localeCompare(n)>=0?t:e}function $o(e,t){const n=(e==null?void 0:e.length)??0,r=(t==null?void 0:t.length)??0;return r!==n?r>n?t:e:t??e}function $s(e,t){return t.length>e.length?t:e}function as(e,t){return e===null?t:t===null?e:$s(e,t)}function ht(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function B(e){return e.replace(/\r\n/g,`
|
|
17
|
-
`).trimEnd()}function Ho(e,t){return e.length===0||t.length===0?!0:e.length!==t.length?!1:e.every((n,r)=>{var a;return n.url===((a=t[r])==null?void 0:a.url)})}function Ko(e,t){return Ks(t)?Hs(e,t,"optimistic"):null}function Vo(e,t){return pn(t)?Hs(e,t,"authoritative"):null}function Hs(e,t,n){const r=Ot(t.timestamp),a=B(t.content);let o=null,l=Number.POSITIVE_INFINITY;for(const[
|
|
16
|
+
${x.detail}`:L;return s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:u??s.jsx(en,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(it,{content:$,className:"message-text message-content markdown-content"}),s.jsx(Le,{text:$,canCopy:a.canCopy,canFork:!1,onFork:null})]})]})}if(m){const L=e.origin==="butler_proxy"||vo(e.clientRequestId),$=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function H(){if(!$)return;const U=!C;if(T(U),!(!U||A||M)){R(!0),D(null);try{const K=await Dr(e.originRef);F(K.task)}catch(K){D(K instanceof Error?K.message:i("conversation.butlerOriginDetailLoadFailed"))}finally{R(!1)}}}const X=L?$?s.jsxs("div",{className:"message-origin-detail-anchor",children:[s.jsx("button",{type:"button",className:"message-origin-badge message-origin-badge-button","aria-expanded":C,onClick:()=>{H()},children:i("conversation.butlerProxyMessageBadge")}),C?s.jsxs("div",{className:"message-origin-detail-popover",role:"dialog","aria-live":"polite",children:[s.jsx("strong",{children:i("conversation.butlerOriginDetailTitle")}),M?s.jsx("p",{children:i("conversation.butlerOriginDetailLoading")}):I?s.jsx("p",{children:I}):A?s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:[i("conversation.butlerOriginDetailObjectiveLabel"),":",A.objective]}),s.jsxs("p",{children:[i("conversation.butlerOriginDetailStatusLabel"),":",xo(A.status)]}),s.jsxs("p",{children:[i("conversation.butlerOriginDetailSummaryLabel"),":",A.lastAutomationSummary||i("conversation.butlerAnalysisEmpty")]}),A.waitingReason?s.jsxs("p",{children:[i("conversation.butlerOriginDetailWaitingReasonLabel"),":",A.waitingReason]}):null]}):s.jsx("p",{children:i("conversation.butlerAnalysisEmpty")})]}):null]}):s.jsx("span",{className:"message-origin-badge",children:i("conversation.butlerProxyMessageBadge")}):null;return s.jsx("article",{className:"message-item user-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:h}),b?s.jsx(it,{content:b,className:"message-text message-content markdown-content"}):null,e.deliveryState==="failed"&&e.clientRequestId&&s.jsx("button",{className:"retry-button",type:"button",onClick:()=>o(e.clientRequestId),children:i("conversation.resendButton")}),s.jsx(Ws,{timestamp:e.timestamp,leading:X,children:s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),compact:!0,onFork:l?()=>l(e):null})})]})})}return y?s.jsxs("article",{className:"message-item assistant-message thinking-message-row","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:u??s.jsx(en,{})}),s.jsxs("div",{className:"thinking-message-content",children:[s.jsx("div",{className:"thinking-message-label",children:i("conversation.thinkingLabel")}),s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:h}),b&&s.jsx(it,{content:b,className:"message-text message-content markdown-content thinking-message-text"}),s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),onFork:l?()=>l(e):null})]})]}):p?s.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[s.jsx("div",{className:"message-avatar",children:u??s.jsx(en,{})}),s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:h}),b&&s.jsx(it,{content:b,className:"message-text message-content markdown-content"}),s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),onFork:l?()=>l(e):null})]})]}):s.jsx("article",{className:"message-item system-message","data-message-id":e.id,children:s.jsxs("div",{className:"message-content-wrapper",children:[s.jsx(Rt,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:h}),b?s.jsx("div",{className:"message-text message-content",children:s.jsx(qs,{language:"text",content:b})}):null,s.jsx(Le,{text:b,canCopy:a.canCopy,canFork:a.canFork&&!!(l&&e.deliveryState==="sent"),onFork:l?()=>l(e):null})]})})}function en(){return s.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 16v-4M12 8h.01"})]})}function vo(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function xo(e){switch(e){case"waiting_user":return i("shell.butlerAutomationStatusWaitingUser");case"completed":return i("shell.butlerAutomationStatusCompleted");case"failed":return i("shell.butlerAutomationStatusFailed");case"cancelled":return i("shell.butlerAutomationStatusCancelled");case"active":default:return i("shell.butlerAutomationStatusActive")}}function il({sessionId:e="session",messages:t,historyState:n,loadingOlderMessages:r=!1,hasOlderMessages:a=!1,onLoadOlderMessages:o=()=>{},onRetryMessage:l,onForkMessage:u,provider:m,interruptedSource:y=null,runtimeThinkingPlaceholder:p=null,assistantAvatar:x}){var Fe;const{showToast:v}=vt(),j=gt(),b=d.useRef(null),h=d.useRef(e),C=d.useRef(0),T=d.useRef(null),M=d.useRef(!0),R=d.useRef(null),I=d.useRef(null),D=d.useRef(!1),A=d.useRef(Tt(e)),F=d.useRef(((Fe=Tt(e))==null?void 0:Fe.lastMessageSignature)??null),L=d.useRef(Tt(e)),$=d.useRef(null),H=d.useRef(null),X=d.useRef(null),U=d.useRef(0),K=d.useRef(!1),Ee=d.useRef(null),se=d.useRef(null),[Be,me]=d.useState(!1),[G,ae]=d.useState(!1),re=d.useRef(!1),ke=Ka(t),xt=j.isMobile?0:va,pe=d.useMemo(()=>Ja(t,m),[t,m]),Oe=d.useMemo(()=>bo(t),[t]),bt=n==="loading"&&t.length===0;function Ce(f){const E=f.scrollHeight-f.clientHeight-f.scrollTop<=Kn;return{scrollTop:f.scrollTop,stickToBottom:E,lastMessageSignature:re.current&&!E?F.current:Ke(t.at(-1)??null)}}function fe(f){return L.current=Ce(f),L.current}function he(f){const N=f.scrollHeight-f.clientHeight-f.scrollTop,E=N<=Kn;M.current=E,E&&re.current&&(Z(),re.current=!1,F.current=Ke(t.at(-1)??null),ae(!1)),me(t.length>0&&(N>Vn||re.current)),fe(f)}function ee(f=b.current){f&&fe(f),L.current&&Hn(e,L.current)}function Ze(f){L.current&&Hn(f,L.current)}function Qe(){$.current!==null&&(window.clearTimeout($.current),$.current=null)}function Je(){Qe(),$.current=window.setTimeout(()=>{$.current=null,ee()},fa)}function je(f){f.scrollTop=f.scrollHeight}function Ye(){H.current!==null&&(window.clearTimeout(H.current),H.current=null)}function Z(){Ye(),K.current=!1,X.current=null,U.current=0,Ee.current=null}function _e(f,N){const E=Math.max(0,f.scrollHeight-f.clientHeight),Q=Math.max(0,Math.min(N,E));Ee.current=Q,f.scrollTop=Q,M.current=!1,me(t.length>0&&(E-Q>Vn||re.current))}function we(){Ye(),K.current&&(H.current=window.setTimeout(()=>{H.current=null;const f=b.current,N=X.current;if(!f||N===null){Z();return}if(_e(f,N),Date.now()<U.current){we();return}Z(),he(f)},ga))}function Ne(f,N){if(xt<=0){_e(N,f),Z();return}K.current=!0,X.current=f,U.current=Date.now()+xt,_e(N,f),we()}function oe(){K.current&&Z()}function ge(f){return D.current||!a||r||n!=="ready"||f.scrollTop>pa?!1:(D.current=!0,R.current=f.scrollHeight-f.scrollTop,I.current=Ke(t[0]??null),o(),!0)}d.useEffect(()=>{n==="error"&&v({title:i("conversation.historyLoadFailed"),tone:"error"})},[n,v]),d.useLayoutEffect(()=>{var f,N;h.current!==e&&(Ze(h.current),h.current=e,C.current=0,T.current=null,A.current=Tt(e),F.current=((f=A.current)==null?void 0:f.lastMessageSignature)??null,L.current=A.current,M.current=((N=A.current)==null?void 0:N.stickToBottom)??!0,R.current=null,I.current=null,Z(),re.current=!1,ae(!1),me(!1))},[e]),d.useLayoutEffect(()=>()=>{Qe(),Z(),Ze(h.current)},[e]),d.useLayoutEffect(()=>{const f=b.current,N=Ke(t.at(-1)??null);if(!f){C.current=t.length,T.current=N;return}const E=C.current,Q=T.current,V=A.current;if(V&&n==="ready"){const le=!V.stickToBottom&&V.lastMessageSignature!==null&&N!==null&&V.lastMessageSignature!==N;V.stickToBottom?(Z(),je(f)):Ne(V.scrollTop,f),re.current=le,F.current=V.lastMessageSignature,ae(le),A.current=null,he(f),C.current=t.length,T.current=N,fe(f);return}if(V&&n==="error"){V.stickToBottom?(Z(),je(f)):Ne(V.scrollTop,f),A.current=null,he(f),C.current=t.length,T.current=N,fe(f);return}if(K.current){_e(f,X.current??f.scrollTop),C.current=t.length,T.current=N,fe(f);return}const Te=Ke(t[0]??null),Re=R.current,Ue=I.current;Re!==null&&!r&&Ue!==null&&Ue!==Te&&t.length>=E?(f.scrollTop=Math.max(0,f.scrollHeight-Re),R.current=null,I.current=null):R.current!==null&&!r?(R.current=null,I.current=null):M.current&&(E===0||t.length!==E||N!==Q)&&je(f),he(f),C.current=t.length,T.current=N},[n,r,t,e]),d.useEffect(()=>{if(!a){D.current=!1;return}!r&&R.current===null&&(D.current=!1)},[a,r,t.length]);function qe(){const f=b.current;if(f){if(K.current){const N=Ee.current;N!==null&&Math.abs(f.scrollTop-N)<=1?Ee.current=null:oe()}he(f),Je(),ge(f)}}function Se(f){if(f.deltaY!==0&&oe(),f.deltaY>=0)return;const N=b.current;N&&ge(N)}function Xe(f){var N;oe(),se.current=((N=f.touches[0])==null?void 0:N.clientY)??null}function yt(f){var V;const N=se.current,E=((V=f.touches[0])==null?void 0:V.clientY)??null;if(N===null||E===null||E-N<ha)return;oe();const Q=b.current;Q&&ge(Q)}function We(){se.current=null}return s.jsxs("section",{className:"message-timeline",children:[n==="loading"&&s.jsx("div",{className:"timeline-status",children:s.jsx("span",{className:"status-text",children:i("conversation.historyLoading")})}),s.jsxs("div",{ref:b,className:"message-list",onScroll:qe,onPointerDown:oe,onWheel:Se,onTouchStart:Xe,onTouchMove:yt,onTouchEnd:We,onTouchCancel:We,children:[bt?s.jsx(ro,{}):null,r?s.jsx("div",{className:"timeline-status timeline-status-inline",children:s.jsx("span",{className:"status-text",children:i("conversation.historyLoadingOlder")})}):null,ke.length===0&&n==="ready"&&s.jsx("div",{className:"timeline-empty",children:s.jsx("p",{className:"status-text",children:i("conversation.timelineEmpty")})}),ke.map(f=>f.type==="tool_group"?s.jsx("article",{className:"message-item tool-message-row",children:s.jsx(ao,{group:f.group})},f.key):s.jsx(go,{message:f.message,provider:m,foldedPromptKind:pe.has(f.message.id)?"system_prompt":null,actionState:Oe.get(f.message.id)??{canCopy:f.message.role==="user",canFork:!1},onRetry:l,onForkMessage:u,interruptedSource:y,assistantAvatar:x},f.key)),p?s.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline",children:s.jsxs("span",{className:"status-text thinking-status-text","aria-label":p,children:[s.jsx("span",{children:da(p)||p}),s.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})}):null]}),Be?s.jsxs("button",{type:"button",className:"conversation-scroll-to-bottom-button","data-has-new":G?"true":"false","aria-label":i("conversation.scrollToBottomAction"),title:i("conversation.scrollToBottomAction"),onClick:()=>{const f=b.current;f&&(Z(),je(f),re.current=!1,F.current=Ke(t.at(-1)??null),ae(!1),he(f),ee(f))},children:[G?s.jsx("span",{className:"conversation-scroll-to-bottom-button-badge",children:"NEW"}):null,s.jsx("svg",{className:"conversation-scroll-to-bottom-button-icon",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:s.jsx("path",{d:"M10 4.25a.75.75 0 0 1 .75.75v7.19l2.72-2.72a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V5a.75.75 0 0 1 .75-.75Zm-4 11a.75.75 0 0 1 0-1.5h8a.75.75 0 0 1 0 1.5H6Z",fill:"currentColor"})})]}):null]})}function Ke(e){return e?JSON.stringify({id:e.id,content:e.content,attachments:e.attachments,timestamp:e.timestamp,deliveryState:e.deliveryState,toolCall:e.toolCall?{status:e.toolCall.status,output:e.toolCall.output,error:e.toolCall.error}:null}):null}function bo(e){const t=new Map;let n=0;function r(a){let o=null;for(let l=a-1;l>=n;l-=1){const u=e[l];if(!(!u||!yo(u))){o=u.id;break}}for(let l=n;l<a;l+=1){const u=e[l];if(u){if(u.role==="user"){t.set(u.id,{canCopy:!0,canFork:!1});continue}t.set(u.id,{canCopy:u.id===o,canFork:u.id===o})}}}for(let a=0;a<e.length;a+=1){const o=e[a];o&&o.role==="user"&&a>n&&(r(a),n=a)}return r(e.length),t}function yo(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function al({requests:e,replyingRequestId:t,onReply:n}){const[r,a]=d.useState({}),o=d.useMemo(()=>e.filter(l=>l.status==="pending"),[e]);return o.length===0?null:s.jsxs("section",{className:"permission-request-list",children:[s.jsxs("div",{className:"permission-request-list-header",children:[s.jsx("div",{children:s.jsx("strong",{children:i("conversation.permissionRequestSectionTitle")})}),s.jsx("span",{className:"permission-request-count",children:o.length})]}),s.jsx("div",{className:"permission-request-stack",children:o.map(l=>{var v,j;const u=r[l.id]??{},m=l.paths.filter(Boolean),y=l.kind==="command"&&!!((v=l.command)!=null&&v.trim()),p=l.questions.length===0&&m.length===0&&!y&&!!((j=l.summary)!=null&&j.trim()),x=l.kind==="user_input"&&l.questions.some(b=>{var h;return(((h=u[b.id])==null?void 0:h.filter(Boolean).length)??0)===0});return s.jsxs("article",{className:"permission-request-card",children:[s.jsxs("header",{className:"permission-request-card-header",children:[s.jsxs("div",{className:"permission-request-provider",children:[s.jsx("span",{className:"permission-request-provider-icon","aria-hidden":"true",children:s.jsx("img",{src:zr(l.provider),alt:"",loading:"lazy"})}),s.jsxs("div",{className:"permission-request-provider-copy",children:[s.jsx("strong",{children:l.title}),s.jsx("span",{children:os(l.provider,"full")})]})]}),s.jsx("span",{className:"permission-request-kind",children:ko(l.kind)})]}),s.jsxs("div",{className:"permission-request-card-body",children:[m.length>0?s.jsx("div",{className:"permission-request-block",children:s.jsx("ul",{className:"permission-request-target-list",children:m.map(b=>s.jsxs("li",{className:"permission-request-target-item",children:[s.jsx("strong",{children:Co(b)}),s.jsx("span",{children:b})]},`${l.id}:${b}`))})}):null,y?s.jsxs("div",{className:"permission-request-block",children:[s.jsx("div",{className:"permission-request-block-label",children:i("conversation.permissionRequestCommandLabel")}),s.jsx("pre",{children:l.command})]}):null,p?s.jsx("p",{className:"permission-request-summary",children:l.summary}):null,l.questions.length>0?s.jsxs("div",{className:"permission-request-block",children:[s.jsx("div",{className:"permission-request-block-label",children:i("conversation.permissionRequestQuestionsLabel")}),s.jsx("div",{className:"permission-request-question-list",children:l.questions.map(b=>s.jsxs("div",{className:"permission-request-question",children:[s.jsx("div",{className:"permission-request-question-header",children:b.header}),s.jsx("p",{children:b.question}),s.jsx("div",{className:"permission-request-question-options",children:b.options.map(h=>{var T;const C=((T=u[b.id])==null?void 0:T.includes(h.label))??!1;return s.jsxs("label",{className:"permission-request-question-option",children:[s.jsx("input",{type:"radio",name:`${l.id}:${b.id}`,checked:C,onChange:()=>{a(M=>({...M,[l.id]:{...M[l.id]??{},[b.id]:[h.label]}}))}}),s.jsxs("span",{children:[s.jsx("strong",{children:h.label}),h.description?s.jsx("small",{children:h.description}):null]})]},`${b.id}:${h.label}`)})})]},b.id))})]}):null]}),s.jsx("footer",{className:"permission-request-card-footer",children:l.actions.map(b=>s.jsx("button",{type:"button",className:`permission-request-action permission-request-action-${b.tone}`,disabled:t===l.id||b.value==="submit"&&x,onClick:()=>void n(l.id,{action:b.value,answers:Object.keys(u).length>0?u:void 0}),children:t===l.id?i("conversation.permissionRequestSubmitting"):b.label},`${l.id}:${b.value}`))})]},l.id)})})]})}function ko(e){return e==="command"?i("conversation.permissionRequestKindCommand"):e==="file_change"?i("conversation.permissionRequestKindFileChange"):e==="permissions"?i("conversation.permissionRequestKindPermissions"):e==="user_input"?i("conversation.permissionRequestKindUserInput"):i("conversation.permissionRequestKindToolCall")}function Co(e){return e.split(/[/\\]+/).filter(Boolean).at(-1)??e}class ol{constructor(t){de(this,"socket",null);de(this,"disposed",!1);de(this,"authRecoveryInFlight",!1);de(this,"latestCursor");de(this,"subscribed",!1);de(this,"pendingOlderRequest",null);de(this,"inFlightOlderRequest",null);de(this,"connectionManager");this.options=t,this.latestCursor=t.cursor,this.connectionManager=new $r({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}updateCursor(t){this.latestCursor=t}reconnectNow(){this.connectionManager.reconnectNow()}requestOlderMessages(t,n){return jo(this.socket)?this.subscribed?(this.sendOlderMessagesRequest(t,n),!0):(this.pendingOlderRequest={cursor:t,limit:n},!0):!1}close(){var t;this.disposed=!0,this.subscribed=!1,this.pendingOlderRequest=null,this.inFlightOlderRequest=null,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var m;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(m=Pn.getState().session)==null?void 0:m.accessToken;if(!n){this.options.onUnauthorized();return}const r=wr(),a=Nr(r),o=a.baseUrl,l=`${Sr("/ws",o)}?access_token=${encodeURIComponent(n)}`,u=a.transport.createWebSocket({path:"/ws",baseUrl:o,url:l});this.subscribed=!1,this.socket=u,u.addEventListener("open",()=>{u.send(JSON.stringify({type:"session.subscribe",sessionId:this.options.sessionId,cursor:this.latestCursor,limit:this.options.limit}))}),u.addEventListener("message",y=>{if(!(y instanceof MessageEvent)||typeof y.data!="string")return;const p=JSON.parse(y.data);if(p.type==="system.connected"){this.connectionManager.markConnected();return}if(p.type==="session.subscribed"){this.subscribed=!0,this.options.onSubscribed(),this.flushPendingOlderRequest();return}if(p.type==="session.error"){if(this.clearOlderMessagesRequest(),p.error_code==="UNAUTHORIZED"){this.handleUnauthorized();return}this.options.onError(p);return}if(p.type==="session.runtime_status"){this.options.onRuntimeStatus(p);return}if(p.type==="session.activity"){this.options.onActivity(p);return}if(p.type==="session.history_older"){this.clearOlderMessagesRequest(),this.options.onOlderHistory(p);return}if(p.type==="session.runtime_message"){this.options.onRuntimeMessage(p);return}if(p.type==="session.runtime_error"){this.options.onRuntimeError(p);return}if(p.type==="session.interrupted"){this.options.onInterrupted(p);return}if(p.type==="session.permission_request"){this.options.onPermissionRequest(p);return}if(p.type==="session.permission_request_resolved"){this.options.onPermissionRequestResolved(p);return}this.latestCursor=p.cursor,this.options.onEnvelope(p)}),u.addEventListener("close",()=>{this.disposed||this.socket!==u||(this.subscribed=!1,this.requeueInFlightOlderRequest(),this.connectionManager.markDisconnected())}),u.addEventListener("error",()=>{this.disposed||this.socket!==u||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0,this.subscribed=!1,this.requeueInFlightOlderRequest();const t=this.socket;this.socket=null,t==null||t.close(),Pn.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendOlderMessagesRequest(t,n){var r;this.inFlightOlderRequest={cursor:t,limit:n},(r=this.socket)==null||r.send(JSON.stringify({type:"session.load_older",sessionId:this.options.sessionId,cursor:t,limit:n}))}flushPendingOlderRequest(){if(!this.pendingOlderRequest)return;const t=this.pendingOlderRequest;this.pendingOlderRequest=null,this.sendOlderMessagesRequest(t.cursor,t.limit)}clearOlderMessagesRequest(){this.pendingOlderRequest=null,this.inFlightOlderRequest=null}requeueInFlightOlderRequest(){this.inFlightOlderRequest&&(this.pendingOlderRequest=this.inFlightOlderRequest,this.inFlightOlderRequest=null)}}function jo(e){return e!==null&&e.readyState===1}const wo=3*1e3;function ll(e){return{session:(e==null?void 0:e.session)??null,capabilities:(e==null?void 0:e.capabilities)??null,runtimeHasActiveRun:(e==null?void 0:e.runtimeHasActiveRun)??null,runtimeCanInterrupt:(e==null?void 0:e.runtimeCanInterrupt)??null,contextUsage:(e==null?void 0:e.contextUsage)??null,messages:(e==null?void 0:e.messages)??[],permissionRequests:(e==null?void 0:e.permissionRequests)??[],queuedMessages:(e==null?void 0:e.queuedMessages)??[],historyState:"idle",loadingOlderMessages:!1,olderCursor:(e==null?void 0:e.olderCursor)??null,hasOlderMessages:(e==null?void 0:e.hasOlderMessages)??!1,connectionState:"closed",lastCursor:(e==null?void 0:e.lastCursor)??null,pagesLoaded:(e==null?void 0:e.pagesLoaded)??0,interruptSource:(e==null?void 0:e.interruptSource)??null,errorCode:null,errorDetail:null}}function Fs(e,t,n="sent",r=null){const a=t.kind??(t.role==="tool"?"tool_result":"text"),o=t.toolCall??(a==="tool_call"||a==="tool_result"?{callId:t.rawRef||t.messageId,name:"tool",input:a==="tool_call"?t.content:"",output:a==="tool_result"&&t.content?t.content:null,error:null,status:a==="tool_call"?"running":"completed"}:null);return{id:t.messageId,sessionId:e,role:t.role,kind:a,content:t.content,toolCall:o,attachments:t.attachments??[],attachmentPayloads:null,origin:t.origin??null,originRef:t.originRef??null,timestamp:t.timestamp,sequence:t.sequence,rawRef:t.rawRef,deliveryState:n,clientRequestId:r}}function cl(e,t,n,r=[],a=[],o=Number.MAX_SAFE_INTEGER){return{id:`pending-${n}`,sessionId:e,role:"user",kind:"text",content:t,toolCall:null,attachments:r,attachmentPayloads:a,origin:null,originRef:null,timestamp:new Date().toISOString(),sequence:o,rawRef:`pending://${n}`,deliveryState:"sending",clientRequestId:n}}function ul(e,t,n){const r=new Map;for(const a of e)r.set(a.id,a);for(const a of n){const o=Fs(t,a),l=Vo(r,o);if(l&&l!==o.id)continue;const u=Ko(r,o);u&&u!==o.id&&r.delete(u);const m=r.get(a.messageId)??null;r.set(a.messageId,m?Po(m,o):o)}return Us(Array.from(r.values()))}function dl(e,t,n,r){const a=r===null?null:e.find(m=>m.clientRequestId===r)??null,o=e.filter(m=>m.clientRequestId!==r),l=Fs(t,n,"sent",r),u=Lo(l,a);return Us([...o.filter(m=>m.id!==u.id),u])}function ml(e,t){return e.map(n=>n.clientRequestId===t?{...n,deliveryState:"failed"}:n)}function No(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!Io(r,n)){t.push(n);continue}t[t.length-1]=Oo(r,n)}return t}function So(e){const t=[];let n=null,r=!1;for(const a of e)if(!Eo(n,a,r)){if(t.push(a),ft(a)){n=a,r=!1;continue}n&&an(a)&&(r=!0)}return t}function To(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!zs(r,n)){t.push(n);continue}t[t.length-1]=Ds(r,n)}return t}function Ro(e){const t=[];for(const n of e){if(t.push(n),t.length<4)continue;const r=t[t.length-4],a=t[t.length-3],o=t[t.length-2],l=t[t.length-1];Bo(r,a,o,l)&&t.splice(t.length-3,3,Ds(a,l))}return t}function Mo(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!_o(r,n)){t.push(n);continue}t[t.length-1]=Wo(r,n)}return t}function Ao(e){const t=[];for(const n of e){const r=t.findIndex(a=>qo(a,n));if(r===-1){t.push(n);continue}t[r]=Fo(t[r],n)}return t}function Us(e){const t=[...e].sort((n,r)=>n.sequence!==r.sequence?n.sequence-r.sequence:n.timestamp.localeCompare(r.timestamp));return Ao(Mo(So(Ro(To(No(t))))))}function Lo(e,t){if(!t)return e;const n=e.attachments??[];return{...e,attachments:n.length>0?n:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function Po(e,t){if(e.id!==t.id)return t;if(e.role!==t.role||e.kind!==t.kind||e.rawRef!==t.rawRef)return ht(e,t);const n=Uo(e.toolCall,t.toolCall),r=Do(e.content,t.content,e.timestamp,t.timestamp),a=$o(e.attachments,t.attachments);return{...ht(e,t),content:r,toolCall:n,attachments:a,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,timestamp:e.timestamp.localeCompare(t.timestamp)>=0?e.timestamp:t.timestamp,sequence:Math.max(e.sequence,t.sequence)}}function Io(e,t){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!==t.role||e.kind!==t.kind||e.toolCall!==null||t.toolCall!==null||e.kind!=="text"&&e.kind!=="thinking")return!1;const n=ut(e.content),r=ut(t.content);return Ge(e.timestamp,t.timestamp,wo)&&B(n.text)===B(r.text)&&Ho(n.inlineImages,r.inlineImages)}function Eo(e,t,n){return!e||n||!ft(e)||!ft(t)?!1:Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function ft(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function an(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&e.kind==="text"}function zs(e,t){return an(e)&&an(t)&&Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function Bo(e,t,n,r){return!e||!t||!n||!r||!ft(e)||!ft(n)?!1:zs(t,r)&&Ge(e.timestamp,n.timestamp,120*1e3)&&B(e.content)===B(n.content)}function Ds(e,t){var l,u;const n=((l=e.attachments)==null?void 0:l.length)??0,r=((u=t.attachments)==null?void 0:u.length)??0;if(n!==r)return n>r?e:t;const a=B(e.content).length,o=B(t.content).length;return a!==o?a>o?e:t:ht(e,t)}function Oo(e,t){var m,y;const n=((m=e.attachments)==null?void 0:m.length)??0,r=((y=t.attachments)==null?void 0:y.length)??0;if(n!==r)return n>r?e:t;const a=ut(e.content).inlineImages.length,o=ut(t.content).inlineImages.length;if(a!==o)return a>o?e:t;const l=e.content!==B(e.content),u=t.content!==B(t.content);return l!==u?l?t:e:t}function _o(e,t){return!ss(e)||!ss(t)?!1:e.role===t.role&&Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function qo(e,t){return!rs(e)||!rs(t)?!1:e.role===t.role&&Ge(e.timestamp,t.timestamp,120*1e3)&&B(e.content)===B(t.content)}function ss(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function rs(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function Wo(e,t){var m,y;const n=((m=e.attachments)==null?void 0:m.length)??0,r=((y=t.attachments)==null?void 0:y.length)??0;if(n!==r)return n>r?e:t;const a=B(e.content).length,o=B(t.content).length;if(a!==o)return a>o?e:t;const l=e.rawRef.includes("#file="),u=t.rawRef.includes("#file=");return l!==u?l?e:t:ht(e,t)}function Fo(e,t){var m,y;const n=((m=e.attachments)==null?void 0:m.length)??0,r=((y=t.attachments)==null?void 0:y.length)??0;if(n!==r)return n>r?e:t;const a=B(e.content).length,o=B(t.content).length;if(a!==o)return a>o?e:t;const l=e.rawRef.includes("/context#"),u=t.rawRef.includes("/context#");return l!==u?l?e:t:ht(e,t)}function Uo(e,t){return e?t?{...zo(e,t),input:$s(e.input,t.input),output:as(e.output,t.output),error:as(e.error,t.error)}:e:t}function zo(e,t){const n=is(e.status),r=is(t.status);return r!==n?r>n?t:e:t}function is(e){return e==="running"?0:1}function Do(e,t,n,r){const a=B(e),o=B(t);return a===o?e.length>=t.length?e:t:a.length>o.length&&a.includes(o)?e:o.length>a.length&&o.includes(a)||r.localeCompare(n)>=0?t:e}function $o(e,t){const n=(e==null?void 0:e.length)??0,r=(t==null?void 0:t.length)??0;return r!==n?r>n?t:e:t??e}function $s(e,t){return t.length>e.length?t:e}function as(e,t){return e===null?t:t===null?e:$s(e,t)}function ht(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function B(e){return e.replace(/\r\n/g,`
|
|
17
|
+
`).trimEnd()}function Ho(e,t){return e.length===0||t.length===0?!0:e.length!==t.length?!1:e.every((n,r)=>{var a;return n.url===((a=t[r])==null?void 0:a.url)})}function Ko(e,t){return Ks(t)?Hs(e,t,"optimistic"):null}function Vo(e,t){return pn(t)?Hs(e,t,"authoritative"):null}function Hs(e,t,n){const r=Ot(t.timestamp),a=B(t.content);let o=null,l=Number.POSITIVE_INFINITY;for(const[u,m]of e.entries()){if(!(n==="optimistic"?pn(m):Ks(m))||B(m.content)!==a)continue;const p=Ot(m.timestamp),x=Math.abs(p-r);x>300*1e3||x<l&&(o=u,l=x)}return o}function pn(e){return e.role!=="user"||e.kind!=="text"||e.deliveryState==="failed"?!1:e.rawRef.startsWith("pending://")||e.rawRef.startsWith("synthetic://")||e.rawRef.includes("#synthetic")}function Ks(e){return e.role==="user"&&e.kind==="text"&&!pn(e)}function Ot(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function pl(e){return e.reduce((n,r)=>Number.isFinite(r.sequence)&&r.sequence>n?r.sequence:n,0)+1}function Ge(e,t,n){return Math.abs(Ot(e)-Ot(t))<=n}export{tl as B,rl as C,sl as M,al as P,ol as R,cl as a,ml as b,ll as c,il as d,nl as e,pl as g,ul as m,dl as r,Fs as t};
|