@deepseekcode/cli 1.0.29 → 1.0.30

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.
Files changed (30) hide show
  1. package/README.md +159 -99
  2. package/dist/cli.js +1480 -1477
  3. package/package.json +1 -1
  4. package/web/dist/assets/AutomationView-Y4qkPsrX.js +1 -0
  5. package/web/dist/assets/{ChannelConfigView-DG4_15oh.js → ChannelConfigView-BqEclPUB.js} +3 -3
  6. package/web/dist/assets/{ConnectorsView-ByedXSa-.js → ConnectorsView-Cz4uqSmh.js} +1 -1
  7. package/web/dist/assets/{FileTreeView-DPA2dhx_.js → FileTreeView-BWPOqGPh.js} +1 -1
  8. package/web/dist/assets/{HookConfigView-BJnvqm3N.js → HookConfigView-japq3zFX.js} +1 -1
  9. package/web/dist/assets/{ModelsView-BBbmRxwR.js → ModelsView-Dbo4GErV.js} +1 -1
  10. package/web/dist/assets/{PluginsView-DxIWxsB-.js → PluginsView-C1BPNAQx.js} +1 -1
  11. package/web/dist/assets/SessionGrid-BGpz0-op.css +1 -0
  12. package/web/dist/assets/SessionGrid-F23LrdJ2.js +42 -0
  13. package/web/dist/assets/{SettingsPanel-ivpxRR6O.js → SettingsPanel-CGJbV37j.js} +3 -3
  14. package/web/dist/assets/{SkillsView-Cpr_kpor.js → SkillsView-CecX9sxV.js} +1 -1
  15. package/web/dist/assets/{TemplatesTab-Cvyxqayr.js → TemplatesTab-BtbjQDQk.js} +1 -1
  16. package/web/dist/assets/{TerminalView-DTN8hmcS.js → TerminalView-6U_87hSL.js} +1 -1
  17. package/web/dist/assets/{ThreeScene-CukEnQe-.js → ThreeScene-Zhjwe9nT.js} +1 -1
  18. package/web/dist/assets/{ToolsView-D_FET-NB.js → ToolsView-DO0_61eJ.js} +1 -1
  19. package/web/dist/assets/{icons-Cu8fYt4q.js → icons-Di-qMB6n.js} +124 -109
  20. package/web/dist/assets/index-BbLAiXis.css +1 -0
  21. package/web/dist/assets/index-Dkxsd1Rx.js +484 -0
  22. package/web/dist/assets/{markdown-Bym7wmT0.js → markdown-D-c9V8Xq.js} +1 -1
  23. package/web/dist/assets/{panels-BEKHl5l-.js → panels-CpHTincc.js} +1 -1
  24. package/web/dist/assets/{react-vendor-D76F8wnc.js → react-vendor-DU8XgZt2.js} +1 -1
  25. package/web/dist/assets/{state-CZakZ3-m.js → state-D2vcUGVk.js} +1 -1
  26. package/web/dist/index.html +7 -7
  27. package/web/dist/assets/AutomationView-BJSLQ2Ka.js +0 -1
  28. package/web/dist/assets/SessionGrid-D-1XpCZg.js +0 -39
  29. package/web/dist/assets/index-C7rIgpwO.js +0 -484
  30. package/web/dist/assets/index-CYAcRfnc.css +0 -1
@@ -0,0 +1,42 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreeScene-Zhjwe9nT.js","assets/markdown-D-c9V8Xq.js","assets/icons-Di-qMB6n.js","assets/ThreeScene-DvOrMIoG.css"])))=>i.map(i=>d[i]);
2
+ var Xn=Object.defineProperty;var Yn=(n,t,s)=>t in n?Xn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var yt=(n,t,s)=>Yn(n,typeof t!="symbol"?t+"":t,s);import{j as e,r as Zn}from"./markdown-D-c9V8Xq.js";import{a as l,g as Qn,ag as Ks,aQ as er,aR as tr,O as Ze,F as ot,T as sr,aO as nr,_ as Vs,ak as Re,d as we,K as Se,af as rr,a1 as Gt,aA as Ee,X as Ae,aS as Lt,E as Js,$ as _e,l as zt,L as Fe,u as Wt,aT as Ft,aH as ar,D as ir,k as or,aU as Xs,aw as lr,aV as Pt,aW as cr,h as Xe,al as dr,i as Ys,aX as ur,aY as pr,aZ as hr,b as mr,aq as fr,a_ as xr,aG as gr,a$ as br,U as kr,b0 as yr,b1 as vr,a0 as is,B as wr,ap as jr,b2 as Nr,n as Zs,aN as Kt,aM as Sr,a6 as Qs,ab as Er,a2 as en,b3 as Tr,b4 as Ar,ac as Cr,b5 as Ir,f as Rr,S as _r,t as Mr,b6 as ze,y as Or,b7 as Dr,m as $r,b8 as Lr,p as zr,q as Fr,j as Pr,b9 as Br}from"./icons-Di-qMB6n.js";import{D as Hr,d as le,u as ee,h as Qe,i as tn,o as sn,j as Ye,k as nn,w as me,l as Bt,b as Ie,R as rn,a as ge,t as pe,m as Ur,s as qr,r as Gr,f as lt,n as ke,p as Wr,q as Kr,_ as Vr,v as os,W as Jr,x as Xr,y as Ht,c as at,z as Ve,A as an,E as Yr,F as Zr,G as Qr,H as ea,M as ta,J as sa,K as na,L as on,N as ra,O as aa,Q as nt,S as ia,T as ln}from"./index-Dkxsd1Rx.js";import{r as oa}from"./react-vendor-DU8XgZt2.js";import{n as ls,s as la,S as ca}from"./sttLanguages-BNRptAQA.js";import"./state-D2vcUGVk.js";import"./panels-CpHTincc.js";class da extends Hr{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}}const ua=new da;function pa(n,t,s){return ua.diff(n,t,s)}function cs({value:n,max:t=100,size:s="md",variant:r="default",showLabel:a=!1,className:i}){const o=Math.min(Math.max(n/t*100,0),100),c={sm:"h-1",md:"h-2",lg:"h-3"},d={default:"bg-accent-blue",success:"bg-accent-green",warning:"bg-accent-yellow",error:"bg-accent-red"};return e.jsxs("div",{className:le("w-full",i),children:[e.jsx("div",{className:le("w-full bg-dark-border rounded-full overflow-hidden",c[s]),children:e.jsx("div",{className:le("h-full rounded-full transition-all duration-300",d[r]),style:{width:`${o}%`}})}),a&&e.jsxs("span",{className:"text-xs text-dark-muted mt-1",children:[Math.round(o),"%"]})]})}function cn(n){const t=l.useRef(null),s=l.useRef(0);return l.useEffect(()=>{if(!n){s.current=0;return}s.current=Date.now();const r=t.current;if(!r)return;const a=()=>{const o=Math.floor((Date.now()-s.current)/1e3),c=o>=60?`${Math.floor(o/60)}m ${o%60}s`:`${o}s`;r.textContent=c};a();const i=setInterval(a,1e3);return()=>clearInterval(i)},[n]),t}var ha=Zn();const ds=Qn(ha);Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity;Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup;Prism.hooks.add("wrap",function(n){n.type==="entity"&&(n.attributes.title=n.content.replace(/&amp;/,"&"))});Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,s){var r={};r["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[s]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};a["language-"+s]={pattern:/[\s\S]+/,inside:Prism.languages[s]};var i={};i[t]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return t}),"i"),lookbehind:!0,greedy:!0,inside:a},Prism.languages.insertBefore("markup","cdata",i)}});Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(n,t){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+n+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:Prism.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});Prism.languages.html=Prism.languages.markup;Prism.languages.mathml=Prism.languages.markup;Prism.languages.svg=Prism.languages.markup;Prism.languages.xml=Prism.languages.extend("markup",{});Prism.languages.ssml=Prism.languages.xml;Prism.languages.atom=Prism.languages.xml;Prism.languages.rss=Prism.languages.xml;Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));Prism.languages.js=Prism.languages.javascript;var us={},ps;function ma(){return ps||(ps=1,(function(n){n.languages.typescript=n.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),n.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete n.languages.typescript.parameter,delete n.languages.typescript["literal-property"];var t=n.languages.extend("typescript",{});delete t["class-name"],n.languages.typescript["class-name"].inside=t,n.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t}}}}),n.languages.ts=n.languages.typescript})(Prism)),us}ma();(function(n){var t=n.util.clone(n.languages.javascript),s=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,r=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,a=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function i(d,u){return d=d.replace(/<S>/g,function(){return s}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return a}),RegExp(d,u)}a=i(a).source,n.languages.jsx=n.languages.extend("markup",t),n.languages.jsx.tag.pattern=i(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source),n.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,n.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,n.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,n.languages.jsx.tag.inside.comment=t.comment,n.languages.insertBefore("inside","attr-name",{spread:{pattern:i(/<SPREAD>/.source),inside:n.languages.jsx}},n.languages.jsx.tag),n.languages.insertBefore("inside","special-attr",{script:{pattern:i(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:n.languages.jsx}}},n.languages.jsx.tag);var o=function(d){return d?typeof d=="string"?d:typeof d.content=="string"?d.content:d.content.map(o).join(""):""},c=function(d){for(var u=[],p=0;p<d.length;p++){var h=d[p],f=!1;if(typeof h!="string"&&(h.type==="tag"&&h.content[0]&&h.content[0].type==="tag"?h.content[0].content[0].content==="</"?u.length>0&&u[u.length-1].tagName===o(h.content[0].content[1])&&u.pop():h.content[h.content.length-1].content==="/>"||u.push({tagName:o(h.content[0].content[1]),openedBraces:0}):u.length>0&&h.type==="punctuation"&&h.content==="{"?u[u.length-1].openedBraces++:u.length>0&&u[u.length-1].openedBraces>0&&h.type==="punctuation"&&h.content==="}"?u[u.length-1].openedBraces--:f=!0),(f||typeof h=="string")&&u.length>0&&u[u.length-1].openedBraces===0){var x=o(h);p<d.length-1&&(typeof d[p+1]=="string"||d[p+1].type==="plain-text")&&(x+=o(d[p+1]),d.splice(p+1,1)),p>0&&(typeof d[p-1]=="string"||d[p-1].type==="plain-text")&&(x=o(d[p-1])+x,d.splice(p-1,1),p--),d[p]=new n.Token("plain-text",x,null,x)}h.content&&typeof h.content!="string"&&c(h.content)}};n.hooks.add("after-tokenize",function(d){d.language!=="jsx"&&d.language!=="tsx"||c(d.tokens)})})(Prism);(function(n){var t=n.util.clone(n.languages.typescript);n.languages.tsx=n.languages.extend("jsx",t),delete n.languages.tsx.parameter,delete n.languages.tsx["literal-property"];var s=n.languages.tsx.tag;s.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+s.pattern.source+")",s.pattern.flags),s.lookbehind=!0})(Prism);(function(n){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;n.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},n.languages.css.atrule.inside.rest=n.languages.css;var s=n.languages.markup;s&&(s.tag.addInlined("style","css"),s.tag.addAttribute("style","css"))})(Prism);Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}};Prism.languages.webmanifest=Prism.languages.json;(function(n){var t="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",s={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:s,environment:{pattern:RegExp("\\$"+t),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+t),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};n.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+t),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:s}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+t),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},s.inside=n.languages.bash;for(var a=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],i=r.variable[1].inside,o=0;o<a.length;o++)i[a[o]]=n.languages.bash[a[o]];n.languages.sh=n.languages.bash,n.languages.shell=n.languages.bash})(Prism);var hs={},ms;function fa(){return ms||(ms=1,Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),hs}fa();(function(n){var t=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function s(p){return p=p.replace(/<inner>/g,function(){return t}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+p+")")}var r=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,a=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return r}),i=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;n.languages.markdown=n.languages.extend("markup",{}),n.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:n.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+a+i+"(?:"+a+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+a+i+")(?:"+a+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:n.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+a+")"+i+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+a+"$"),inside:{"table-header":{pattern:RegExp(r),alias:"important",inside:n.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:s(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:s(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:s(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:s(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(p){["url","bold","italic","strike","code-snippet"].forEach(function(h){p!==h&&(n.languages.markdown[p].inside.content.inside[h]=n.languages.markdown[h])})}),n.hooks.add("after-tokenize",function(p){if(p.language!=="markdown"&&p.language!=="md")return;function h(f){if(!(!f||typeof f=="string"))for(var x=0,g=f.length;x<g;x++){var k=f[x];if(k.type!=="code"){h(k.content);continue}var y=k.content[1],m=k.content[3];if(y&&m&&y.type==="code-language"&&m.type==="code-block"&&typeof y.content=="string"){var v=y.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");v=(/[a-z][\w-]*/i.exec(v)||[""])[0].toLowerCase();var _="language-"+v;m.alias?typeof m.alias=="string"?m.alias=[m.alias,_]:m.alias.push(_):m.alias=[_]}}}h(p.tokens)}),n.hooks.add("wrap",function(p){if(p.type==="code-block"){for(var h="",f=0,x=p.classes.length;f<x;f++){var g=p.classes[f],k=/language-(.+)/.exec(g);if(k){h=k[1];break}}var y=n.languages[h];if(y)p.content=n.highlight(u(p.content),y,h);else if(h&&h!=="none"&&n.plugins.autoloader){var m="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);p.attributes.id=m,n.plugins.autoloader.loadLanguages(h,function(){var v=document.getElementById(m);v&&(v.innerHTML=n.highlight(v.textContent,n.languages[h],h))})}}});var o=RegExp(n.languages.markup.tag.pattern.source,"gi"),c={amp:"&",lt:"<",gt:">",quot:'"'},d=String.fromCodePoint||String.fromCharCode;function u(p){var h=p.replace(o,"");return h=h.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(f,x){if(x=x.toLowerCase(),x[0]==="#"){var g;return x[1]==="x"?g=parseInt(x.slice(2),16):g=Number(x.slice(1)),d(g)}else{var k=c[x];return k||f}}),h}n.languages.md=n.languages.markdown})(Prism);(function(n){var t=/[*&][^\s[\]{},]+/,s=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+s.source+"(?:[ ]+"+t.source+")?|"+t.source+"(?:[ ]+"+s.source+")?)",a=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),i=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function o(c,d){d=(d||"").replace(/m/g,"")+"m";var u=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return c});return RegExp(u,d)}n.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return"(?:"+a+"|"+i+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:o(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:o(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:o(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:o(i),lookbehind:!0,greedy:!0},number:{pattern:o(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:s,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},n.languages.yml=n.languages.yaml})(Prism);Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/};Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/});Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}});delete Prism.languages.go["class-name"];var fs={},xs;function xa(){return xs||(xs=1,(function(n){for(var t=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,s=0;s<2;s++)t=t.replace(/<self>/g,function(){return t});t=t.replace(/<self>/g,function(){return/[^\s\S]/.source}),n.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},n.languages.rust["closure-params"].inside.rest=n.languages.rust,n.languages.rust.attribute.inside.string=n.languages.rust.string})(Prism)),fs}xa();var gs={},bs;function ga(){return bs||(bs=1,(function(n){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,s=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+s+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};n.languages.java=n.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+s+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+s+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:t,function:[n.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),n.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),n.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+s+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+s+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),gs}ga();Prism.languages.c=Prism.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/});Prism.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}});Prism.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},Prism.languages.c.string],char:Prism.languages.c.char,comment:Prism.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:Prism.languages.c}}}});Prism.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/});delete Prism.languages.c.boolean;var ks={},ys;function ba(){return ys||(ys=1,(function(n){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,s=/\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g,function(){return t.source});n.languages.cpp=n.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),n.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g,function(){return s})+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),n.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:n.languages.cpp}}}}),n.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),n.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:n.languages.extend("cpp",{})}}),n.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},n.languages.cpp["base-clause"])})(Prism)),ks}ba();(function(n){function t(s,r){return"___"+s.toUpperCase()+r+"___"}Object.defineProperties(n.languages["markup-templating"]={},{buildPlaceholders:{value:function(s,r,a,i){if(s.language===r){var o=s.tokenStack=[];s.code=s.code.replace(a,function(c){if(typeof i=="function"&&!i(c))return c;for(var d=o.length,u;s.code.indexOf(u=t(r,d))!==-1;)++d;return o[d]=c,u}),s.grammar=n.languages.markup}}},tokenizePlaceholders:{value:function(s,r){if(s.language!==r||!s.tokenStack)return;s.grammar=n.languages[r];var a=0,i=Object.keys(s.tokenStack);function o(c){for(var d=0;d<c.length&&!(a>=i.length);d++){var u=c[d];if(typeof u=="string"||u.content&&typeof u.content=="string"){var p=i[a],h=s.tokenStack[p],f=typeof u=="string"?u:u.content,x=t(r,p),g=f.indexOf(x);if(g>-1){++a;var k=f.substring(0,g),y=new n.Token(r,n.tokenize(h,s.grammar),"language-"+r,h),m=f.substring(g+x.length),v=[];k&&v.push.apply(v,o([k])),v.push(y),m&&v.push.apply(v,o([m])),typeof u=="string"?c.splice.apply(c,[d,1].concat(v)):u.content=v}}else u.content&&o(u.content)}return c}o(s.tokens)}}})})(Prism);var vs={},ws;function ka(){return ws||(ws=1,(function(n){var t=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,s=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],r=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,a=/<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,i=/[{}\[\](),:;]/;n.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:t,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:s,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:r,operator:a,punctuation:i};var o={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:n.languages.php},c=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:o}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:o}}];n.languages.insertBefore("php","variable",{string:c,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:t,string:c,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:s,number:r,operator:a,punctuation:i}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),n.hooks.add("before-tokenize",function(d){if(/<\?/.test(d.code)){var u=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;n.languages["markup-templating"].buildPlaceholders(d,"php",u)}}),n.hooks.add("after-tokenize",function(d){n.languages["markup-templating"].tokenizePlaceholders(d,"php")})})(Prism)),vs}ka();var js={},Ns;function ya(){return Ns||(Ns=1,(function(n){n.languages.ruby=n.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),n.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var t={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:n.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete n.languages.ruby.function;var s="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",r=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;n.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+s+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+r),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+r+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),n.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+s),greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+s),greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete n.languages.ruby.string,n.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),n.languages.rb=n.languages.ruby})(Prism)),js}ya();const va=.4;function Ss(n){const t=[];let s=0;for(;s<n.length;){const r=n[s];if(/[\p{L}\p{N}_]/u.test(r)){let a=s+1;for(;a<n.length&&/[\p{L}\p{N}_]/u.test(n[a]);)a++;t.push(n.slice(s,a)),s=a}else if(/\s/.test(r)){let a=s+1;for(;a<n.length&&/\s/.test(n[a]);)a++;t.push(n.slice(s,a)),s=a}else{const i=n.codePointAt(s)>65535?2:1;t.push(n.slice(s,s+i)),s+=i}}return t}function wa(n,t){const s=pa(Ss(n),Ss(t)),r=n.length+t.length;let a=0;const i=[],o=[];let c=0,d=0;for(const u of s){const p=u.value.reduce((h,f)=>h+f.length,0);u.removed?(a+=p,i.push({start:c,end:c+p}),c+=p):u.added?(a+=p,o.push({start:d,end:d+p}),d+=p):(c+=p,d+=p)}return r>0&&a/r>va?[[],[]]:[i,o]}function dn(n){const t=[];let s=null;for(const r of n.split(`
3
+ `)){if(r.startsWith("---")||r.startsWith("+++")||r.startsWith("index ")||r.startsWith("diff --git")||r.startsWith("==="))continue;const a=r.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);if(a){s&&t.push(s),s={oldStart:parseInt(a[1],10),oldLines:parseInt(a[2]??"1",10),newStart:parseInt(a[3],10),newLines:parseInt(a[4]??"1",10),lines:[]};continue}if(!r.startsWith("\\")){if(s&&(r.startsWith("+")||r.startsWith("-")||r.startsWith(" ")||r==="")){s.lines.push(r);continue}s&&r&&(t.push(s),s=null)}}return s&&t.push(s),t}function un(n){let t=n.oldStart,s=n.newStart;const r=[];for(const a of n.lines){const i=a[0]==="+"||a[0]==="-"?a[0]:" ",o=a.slice(1);let c=null,d=null;i==="-"?c=t++:(i==="+"||(c=t++),d=s++),r.push({marker:i,code:o,oldLine:c,newLine:d})}return r}const ja=l.memo(function({filePath:t,content:s,language:r}){if(!s&&!t)return null;const[a,i]=l.useState("unified"),[o,c]=l.useState(!1),d=Na(t,r),u=(s==null?void 0:s.includes("@@"))||(s==null?void 0:s.includes("+++"))||(s==null?void 0:s.includes("---")),p=u?Sa(s||""):null;return e.jsxs("div",{className:"mt-2 border border-dark-border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-dark-surface border-b border-dark-border",children:[e.jsx("span",{className:"text-accent-purple text-xs",children:"📝"}),e.jsx("span",{className:"text-xs font-mono text-dark-fg truncate",children:t||"file"}),p&&e.jsxs("span",{className:"text-xs ml-2 flex gap-2",children:[e.jsxs("span",{className:"text-green-400",children:["+",p.additions]}),e.jsxs("span",{className:"text-red-400",children:["-",p.deletions]})]}),e.jsx("span",{className:"text-xs text-dark-muted ml-auto",children:d}),u&&e.jsxs("div",{className:"flex gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>i("unified"),className:`text-xs px-1.5 py-0.5 rounded ${a==="unified"?"bg-accent-blue/20 text-accent-blue":"text-dark-muted hover:text-dark-fg"}`,title:"Unified view",children:"Unified"}),e.jsx("button",{onClick:()=>i("side-by-side"),className:`text-xs px-1.5 py-0.5 rounded ${a==="side-by-side"?"bg-accent-blue/20 text-accent-blue":"text-dark-muted hover:text-dark-fg"}`,title:"Side-by-side view",children:"Side"})]}),e.jsx("button",{onClick:()=>c(!o),className:"text-xs text-dark-muted hover:text-dark-fg ml-1",children:o?"▶":"▼"})]}),!o&&e.jsxs("div",{className:"bg-dark-bg overflow-x-auto max-h-96 overflow-y-auto custom-scrollbar",children:[u?a==="unified"?Ca(s||"",d):Ia(s||"",d):e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:s||"(no content)"}),p&&e.jsxs("div",{className:"sticky bottom-0 bg-dark-surface border-t border-dark-border px-3 py-1 flex gap-4 text-xs text-dark-muted",children:[e.jsxs("span",{className:"text-green-400",children:["+",p.additions," additions"]}),e.jsxs("span",{className:"text-red-400",children:["-",p.deletions," deletions"]}),e.jsxs("span",{children:[p.hunks," hunks"]})]})]})]})});function Na(n,t){var a;if(t)return t;if(!n)return"plaintext";const s=(a=n.split(".").pop())==null?void 0:a.toLowerCase();return{ts:"typescript",tsx:"typescript",mts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",go:"go",rs:"rust",cpp:"cpp",cxx:"cpp",hpp:"cpp",cc:"cpp",c:"cpp",h:"cpp",css:"css",scss:"css",html:"markup",htm:"markup",svg:"markup",xml:"xml",json:"json",yml:"yaml",yaml:"yaml",md:"markdown",sql:"sql",sh:"bash",bash:"bash",zsh:"bash",php:"php",rb:"ruby"}[s||""]||"plaintext"}function Sa(n){const t=n.split(`
4
+ `);let s=0,r=0,a=0;for(const i of t)i.startsWith("@@")?a++:i.startsWith("+")&&!i.startsWith("+++")?s++:i.startsWith("-")&&!i.startsWith("---")&&r++;return{additions:s,deletions:r,hunks:a,filesChanged:1}}function Ea(n){const t=[],s=(a,i)=>{if(!i)return;const o=t[t.length-1];o&&o.type===a?o.text+=i:t.push({type:a,text:i})},r=(a,i)=>{if(typeof a=="string"){s(i,a);return}const o=a.type||i;if(typeof a.content=="string"){s(o,a.content);return}for(const c of a.content)r(c,o)};for(const a of n)r(a,"");return t}function pn(n,t){const s=ds.languages[t];if(!s)return[{type:"",text:n}];try{return Ea(ds.tokenize(n,s))}catch{return[{type:"",text:n}]}}function Ta(n,t){if(t.length===0)return n.map(a=>({...a,word:!1}));const s=[];let r=0;for(const a of n){const i=r,o=r+a.text.length;let c=0;for(const d of t){const u=Math.max(0,d.start-i),p=Math.min(a.text.length,d.end-i);p<=0||u>=a.text.length||(u>c&&s.push({type:a.type,text:a.text.slice(c,u),word:!1}),s.push({type:a.type,text:a.text.slice(u,p),word:!0}),c=p)}c<a.text.length&&s.push({type:a.type,text:a.text.slice(c),word:!1}),r=o}return s}function Aa({code:n,marker:t,lang:s,ranges:r}){const a=t==="-"?[{type:"",text:n}]:pn(n,s),i=Ta(a,r),o=t==="+"?"bg-green-900/30":t==="-"?"bg-red-900/30":"",c=t==="+"?"bg-green-700/60":"bg-red-700/60";return e.jsx("span",{className:`flex-1 whitespace-pre-wrap px-2 ${o}`,children:i.length===0?" ":i.map((d,u)=>e.jsx("span",{className:[d.type?`token ${d.type}`:"",d.word&&t!==" "?c:""].join(" "),children:d.text},u))})}function Ca(n,t){const s=dn(n);if(s.length===0)return e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:n});const r=[];let a=0;for(const i of s){const o=un(i);r.push(e.jsxs("div",{className:"flex text-xs font-mono leading-snug bg-accent-blue/5 text-accent-blue font-bold px-2",style:{minHeight:"1.25rem"},children:[e.jsx("span",{className:"select-none shrink-0 text-right pr-1",children:"@"}),e.jsxs("span",{className:"flex-1 whitespace-pre-wrap",children:["@@ -",i.oldStart,",",i.oldLines," +",i.newStart,",",i.newLines," @@"]})]},a++));const c=new Map;for(let d=0;d<o.length;){if(o[d].marker!=="-"){d++;continue}const u=d;for(;d<o.length&&o[d].marker==="-";)d++;const p=d;for(;d<o.length&&o[d].marker==="+";)d++;const h=Math.min(p-u,d-p);for(let f=0;f<h;f++){const[x,g]=wa(o[u+f].code,o[p+f].code);c.set(u+f,x),c.set(p+f,g)}}for(let d=0;d<o.length;d++){const u=o[d],p=u.marker==="+",h=u.marker==="-",f=p?"bg-green-900/30":h?"bg-red-900/30":"",x=u.marker==="-"?u.oldLine:u.newLine;r.push(e.jsxs("div",{className:"flex text-xs font-mono leading-snug",style:{minHeight:"1.25rem"},children:[e.jsxs("span",{className:`select-none shrink-0 w-9 text-right pr-1 ${f} ${p?"text-green-400":h?"text-red-400":"text-dark-muted"}`,children:[u.marker===" "?"":u.marker,x??""]}),e.jsx(Aa,{code:u.code,marker:u.marker,lang:t,ranges:c.get(d)??[]})]},a++))}}return e.jsx("div",{children:r})}function Es({code:n,lang:t,kind:s}){if(n==="")return e.jsx("span",{className:"flex-1 px-2 border-r border-dark-border/30 font-mono text-xs leading-snug",style:{minHeight:"1.25rem"},children:" "});const r=s==="remove"?[{type:"",text:n}]:pn(n,t),a=s==="add"?"bg-green-900/30":s==="remove"?"bg-red-900/30":"";return e.jsx("span",{className:`flex-1 px-2 border-r border-dark-border/30 font-mono text-xs leading-snug ${a}`,children:r.map((i,o)=>e.jsx("span",{className:i.type?`token ${i.type}`:"",children:i.text},o))})}function Ia(n,t){const s=dn(n);if(s.length===0)return e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:n});const r=[];for(const a of s){const i=un(a);r.push({left:`@@ -${a.oldStart},${a.oldLines} +${a.newStart},${a.newLines} @@`,right:"",type:"header"});let o=[],c=[];const d=()=>{(o.length>0||c.length>0)&&(Ra(r,o,c),o=[],c=[])};for(const u of i)u.marker==="-"?o.push(u.code):u.marker==="+"?c.push(u.code):(d(),r.push({left:u.code,right:u.code,type:"context"}));d()}return e.jsxs("div",{children:[e.jsxs("div",{className:"flex border-b border-dark-border text-xs font-bold text-dark-muted",children:[e.jsx("div",{className:"flex-1 px-2 py-0.5 border-r border-dark-border",children:"Old"}),e.jsx("div",{className:"flex-1 px-2 py-0.5",children:"New"})]}),r.map((a,i)=>a.type==="header"?e.jsx("div",{className:"bg-accent-blue/5 text-accent-blue font-bold font-mono text-xs leading-snug px-2",children:a.left},i):e.jsxs("div",{className:"flex",style:{minHeight:"1.25rem"},children:[e.jsx(Es,{code:a.type==="replace"||a.type==="delete"?"- "+a.left:a.left,lang:t,kind:a.type==="replace"||a.type==="delete"?"remove":"context"}),e.jsx(Es,{code:a.type==="replace"||a.type==="add"?"+ "+a.right:a.right,lang:t,kind:a.type==="replace"||a.type==="add"?"add":"context"})]},i))]})}function Ra(n,t,s){const r=Math.max(t.length,s.length);for(let a=0;a<r;a++){const i=a<t.length?t[a]??"":"",o=a<s.length?s[a]??"":"";n.push({left:i,right:o,type:a<t.length&&a<s.length?"replace":a<t.length?"delete":"add"})}}function ve(n,t){let s=null;if(typeof n=="string")try{const r=JSON.parse(n);r&&typeof r=="object"&&!Array.isArray(r)&&(s=r)}catch{return""}else n&&typeof n=="object"&&!Array.isArray(n)&&(s=n);if(!s)return"";for(const r of t){const a=s[r];if(typeof a=="string"&&a)return a}return""}function Ce(n){return typeof n=="string"?n:n&&typeof n=="object"?JSON.stringify(n,null,2):String(n??"")}function _a(n){for(const t of n.split(`
5
+ `)){const s=t.trim();if(s)return s}return""}function Te({label:n,tone:t="text-dark-muted",children:s}){return e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("div",{className:`mb-0.5 text-[10px] ${t}`,children:n}),e.jsx("div",{className:"max-h-56 overflow-y-auto custom-scrollbar rounded border border-dark-border bg-dark-bg",children:s})]})}function Ma({toolCall:n}){const{t}=ee(),s=ve(n.args,["command","cmd","script"]),r=n.status==="error",a=Ce(n.result);return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[s&&e.jsx(Te,{label:t("step.params"),children:e.jsxs("pre",{className:"tv-pre",children:[e.jsx("span",{className:"select-none text-accent-green",children:"$ "}),s]})}),n.result!==void 0&&n.result!==null&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:a})})]})}function Oa({toolCall:n}){const t=Qe(n.args),s=Ce(n.result),r=n.diff||(s&&(s.includes("@@")||s.includes("+++")||s.includes("---"))?s:void 0);return!r&&!s?e.jsx(hn,{toolCall:n}):e.jsx("div",{className:"px-2 py-1",children:e.jsx(ja,{filePath:t,content:r||s})})}function Da({toolCall:n}){const{t}=ee(),s=Qe(n.args),r=n.status==="error",a=Ce(n.result);return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[s&&e.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1 font-mono text-[10.5px] text-accent-blue",title:s,children:e.jsx("span",{className:"truncate",children:s})}),n.result!==void 0&&n.result!==null&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:a})})]})}const Ts=20,$a=/\b(grep|search_contents)\b/i;function La(n){return n===""?0:n.split(`
6
+ `).length}function za({toolCall:n}){const{t}=ee(),s=ve(n.args,["pattern","query","regex"]),r=n.status==="error",a=n.result!==void 0&&n.result!==null,i=a?Ce(n.result):"",o=a?La(i):0,c=$a.test(n.name),d=n.noTruncate!==!0&&c&&a&&!r&&o>Ts,[u,p]=l.useState(!1),h=d&&!u?i.split(`
7
+ `).slice(0,Ts).join(`
8
+ `)+`
9
+ ${t("toolCall.linesTotal",{n:o})}`:i;return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[s&&e.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1 text-[10.5px] text-dark-muted",children:e.jsx("span",{className:"font-mono text-accent-blue",children:s})}),a&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:h})}),d&&e.jsx("div",{className:"px-2 pb-1",children:e.jsx("button",{type:"button","data-testid":"grep-result-toggle",onClick:()=>p(f=>!f),className:"text-[10px] text-accent-blue hover:underline",children:u?t("toolCall.collapse"):t("toolCall.expandAll",{n:o})})})]})}function Fa({toolCall:n}){const{t}=ee(),s=ve(n.args,["url","query"]),r=n.status==="error",a=Ce(n.result);return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[s&&e.jsx("div",{className:"truncate px-2 pt-1 font-mono text-[10.5px] text-accent-blue",title:s,children:s}),n.result!==void 0&&n.result!==null&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:a})})]})}function hn({toolCall:n}){const{t}=ee(),s=n.status==="error",r=n.result!==void 0&&n.result!==null;return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[e.jsx(Te,{label:t("step.params"),children:e.jsx("pre",{className:"tv-pre",children:typeof n.args=="string"?n.args:JSON.stringify(n.args,null,2)})}),r&&e.jsx(Te,{label:t(s?"step.error":"step.result"),tone:s?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${s?"text-accent-red":""}`,children:Ce(n.result)})})]})}function Pa({toolCall:n}){const{t}=ee(),s=n.status==="error",r=Ce(n.result),a=(n.attachments??[]).filter(i=>i.mime.startsWith("image/"));return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[a.length>0&&e.jsxs("div",{className:"px-2 pt-1",children:[e.jsx("div",{className:"mb-0.5 text-[10px] text-dark-muted",children:t("step.screenshot","Screenshot")}),e.jsx("div",{className:"max-h-72 overflow-y-auto custom-scrollbar rounded border border-dark-border bg-dark-bg",children:a.slice(0,4).map((i,o)=>e.jsx("img",{src:i.url,alt:i.filename??`computer screenshot ${o+1}`,className:"block w-full object-contain",loading:"lazy"},o))})]}),n.result!==void 0&&n.result!==null&&e.jsx(Te,{label:t(s?"step.error":"step.result"),tone:s?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${s?"text-accent-red":""}`,children:r})})]})}const Ba=/(?:^|[_\W])(bash|powershell|pwsh|cmd|command|shell|exec|terminal)(?:[_\W]|$)/i,Ha=/(?:^|[_\W])(read|cat|view|open)(?:[_\W]|$)/i,Ua=/(?:^|[_\W])(grep|glob|search|find|list)(?:[_\W]|$)/i,qa=/(?:^|[_\W])(webfetch|websearch|fetch|web|http|curl|url)(?:[_\W]|$)/i,Ga=/(?:^|[_\W])(computer)(?:[_\W]|$)/i;function Vt(n){return tn(n)?"diff":Ba.test(n)?"terminal":Ga.test(n)?"computer":qa.test(n)?"web":Ua.test(n)?"search":Ha.test(n)?"read":"generic"}function Wa(n,t){const s=Vt(n);let r="";switch(s){case"terminal":r=ve(t,["command","cmd","script"]);break;case"computer":if(r=ve(t,["action"])||ve(t,["scope"]),r){const i=r,o=i==="type"||i==="key"?ve(t,["text"]):i==="focus"?ve(t,["keyword"]):i==="scroll"?ve(t,["direction"]):"";r=o?`${i} ${o}`:i}break;case"diff":case"read":r=Qe(t)??"";break;case"search":r=ve(t,["pattern","query","regex","glob"]);break;case"web":r=ve(t,["url","query"]);break;default:try{const i=typeof t=="string"?JSON.parse(t):t;r=i&&typeof i=="object"?JSON.stringify(i):String(t??"")}catch{r=typeof t=="string"?t:""}}const a=r.replace(/\s+/g," ").trim();return a.length>64?`${a.slice(0,63)}…`:a}function Ka({toolCall:n}){switch(Vt(n.name)){case"terminal":return e.jsx(Ma,{toolCall:n});case"diff":return e.jsx(Oa,{toolCall:n});case"read":return e.jsx(Da,{toolCall:n});case"search":return e.jsx(za,{toolCall:n});case"web":return e.jsx(Fa,{toolCall:n});case"computer":return e.jsx(Pa,{toolCall:n});default:return e.jsx(hn,{toolCall:n})}}const Va={terminal:nr,diff:sr,read:ot,search:Ze,web:tr,computer:er,generic:Ks},As=l.memo(function({toolCall:t,defaultCollapsed:s=!0}){const r=t.status==="running",a=cn(r),i=t.result!==void 0&&t.result!==null,o=t.status==="error",c=tn(t.name),d=i?Ce(t.result):"",u=Qe(t.args),p=Wa(t.name,t.args),h=o&&i?_a(d):"",[f,x]=l.useState(s),g=t.duration??0,k=g>0?g>=60?`${Math.floor(g/60)}m ${g%60}s`:`${g}s`:"",y=r?"bg-accent-blue":o?"bg-accent-red":"bg-accent-green",m=r?"running":o?"error":"success",v=Va[Vt(t.name)];return e.jsxs("div",{className:"tl-row group rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"toolcall-row",children:[e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>x(!f),"data-testid":"toolcall-row-header",children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:r?e.jsx("span",{className:"inline-block h-3 w-3 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`tl-node ${y}`,"data-status":m})}),e.jsx("span",{className:`shrink-0 ${o?"text-accent-red":"text-dark-muted"}`,children:e.jsx(v,{size:12,"aria-hidden":"true"})}),e.jsx("span",{className:`font-medium text-[13px] shrink-0 truncate ${r?"text-shimmer":"text-dark-text"}`,children:t.name}),o&&h?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0 text-dark-muted/50",children:"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-accent-red",title:d,children:h})]}):p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0 text-dark-muted/50",children:"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-dark-muted",title:p,children:p})]}):e.jsx("span",{className:"min-w-0 flex-1"}),c&&u&&!o&&e.jsxs("button",{type:"button",onClick:_=>{_.stopPropagation(),sn(u)},className:`flex max-w-[16rem] shrink-0 items-center gap-1 truncate rounded-full border border-dark-border/70 px-2 py-0.5 text-[11px] font-mono text-accent-blue
10
+ transition-colors hover:border-accent-blue/40 hover:bg-dark-hover`,title:u,children:[e.jsx(Vs,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:u})]}),r&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[11px] tabular-nums text-accent-blue",children:[e.jsx(Re,{size:10}),e.jsx("span",{ref:a,children:"0s"})]}),!r&&k&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[10px] tabular-nums text-dark-muted",children:[e.jsx(Re,{size:10}),e.jsx("span",{children:k})]}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${f?"opacity-0 group-hover:opacity-100":"rotate-180"}`,children:e.jsx(we,{size:13})})]}),!f&&e.jsx("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25",children:e.jsx(Ka,{toolCall:t})})]})}),Jt=l.memo(function({toolCalls:t,label:s,defaultCollapsed:r=!0}){const{t:a}=ee(),[i,o]=l.useState(r),c=l.useMemo(()=>{const k=new Map;for(const y of t)k.set(y.name,(k.get(y.name)??0)+1);return[...k.entries()].sort((y,m)=>m[1]-y[1])},[t]),d=l.useMemo(()=>t.some(k=>k.status==="running")?"running":t.some(k=>k.status==="error")?"error":"completed",[t]);if(t.length===0)return null;if(t.length===1){const k=t[0];return e.jsx(As,{toolCall:k})}const p=c.slice(0,3),h=c.length-p.length,f=t.reduce((k,y)=>k+(y.duration??0),0),x=f>=60?`${Math.floor(f/60)}m ${f%60}s`:f>=1?`${f}s`:"",g=d==="running"?"bg-accent-blue":d==="error"?"bg-accent-red":"bg-accent-green";return e.jsxs("div",{className:"tl-row group rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"toolcall-group",children:[e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>o(!i),"data-testid":"toolcall-group-toggle",children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:d==="running"?e.jsx("span",{className:"inline-block w-3 h-3 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`tl-node ${g}`,"data-status":d==="error"?"error":"success"})}),e.jsx("span",{className:"text-dark-muted shrink-0",children:e.jsx(Ks,{size:12,"aria-hidden":"true"})}),e.jsx("span",{className:"font-medium text-[13px] text-dark-text shrink-0","data-testid":"toolcall-group-count",children:a("activity.toolCallCount",{count:t.length})}),p.map(([k,y])=>e.jsxs("span",{className:"shrink-0 rounded-full bg-dark-muted/10 px-1.5 py-px text-[10.5px] font-mono text-dark-muted",children:[k," ×",y]},k)),h>0&&e.jsx("span",{className:"shrink-0 text-[10.5px] text-dark-muted",children:a("activity.toolNamesMore",{count:h})}),x&&e.jsx("span",{className:"shrink-0 text-[10px] text-dark-muted tabular-nums",children:x}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${i?"opacity-0 group-hover:opacity-100":"rotate-180"}`,children:e.jsx(we,{size:13})})]}),!i&&e.jsxs("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25 space-y-0.5",children:[e.jsx("div",{className:"px-2 pt-0.5 text-[10px] uppercase tracking-wide text-dark-muted/60",children:s??a("activity.evidence")}),t.map(k=>e.jsx(As,{toolCall:k},k.id))]})]})}),Ja=l.memo(function({text:t,maxLength:s=300,preformatted:r=!1}){const{t:a}=ee(),[i,o]=l.useState(!1);return t.length>s?e.jsxs("div",{children:[r?e.jsx("pre",{className:"text-xs font-mono bg-dark-bg p-1.5 rounded overflow-x-auto custom-scrollbar mt-1 text-accent-green",children:i?t:t.slice(0,s)+"..."}):e.jsx("div",{className:"text-dark-text leading-snug",children:i?t:t.slice(0,s)+"..."}),e.jsx("button",{onClick:d=>{d.stopPropagation(),o(!i)},className:"mt-1 text-[10px] px-2 py-0.5 rounded bg-dark-hover text-accent-blue hover:bg-dark-border transition-colors",children:a(i?"common.collapse_short":"common.expand")})]}):r?e.jsx("pre",{className:"text-xs font-mono bg-dark-bg p-1.5 rounded overflow-x-auto custom-scrollbar mt-1 text-accent-green",children:t}):e.jsx("div",{className:"text-dark-text leading-snug",children:t})}),Xa=l.memo(function({step:t,defaultCollapsed:s=!0}){const{t:r}=ee(),[a,i]=l.useState(s),[o,c]=l.useState(!0),d=t.status==="running",u=cn(d),p=t.description||t.thought||t.result||t.action||t.toolCalls&&t.toolCalls.length>0,h=t.duration??0,f=h>0?h>=60?`${Math.floor(h/60)}m ${h%60}s`:`${h}s`:"";return e.jsxs("div",{className:"tl-row rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"step-row",children:[e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>p&&i(!a),children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:e.jsx("span",{className:"tl-node","data-status":t.status})}),e.jsx("span",{className:`text-[13px] truncate ${d?"text-shimmer":"text-dark-text"}`,children:t.title}),d&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Re,{size:10}),e.jsx("span",{ref:u,children:"0s"})]}),!d&&f&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Re,{size:10}),e.jsx("span",{children:f})]}),p&&e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${a?"":"rotate-180"}`,children:e.jsx(we,{size:13})})]}),!a&&p&&e.jsxs("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25 space-y-1",children:[t.description&&e.jsx("div",{className:"text-dark-muted py-0.5 px-2 text-xs",children:t.description}),t.thought&&e.jsxs("div",{className:"py-0.5 px-2 text-xs border-l-2 border-accent-purple/40 bg-accent-purple/5 rounded-r",children:[e.jsxs("div",{className:"flex items-center gap-1 text-accent-purple cursor-pointer hover:opacity-80 select-none",onClick:()=>c(!o),children:[o?e.jsx(Se,{size:12}):e.jsx(we,{size:12}),e.jsx(rr,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:r("step.thinking")}),o&&e.jsxs("span",{className:"text-[10px] text-dark-muted truncate max-w-[200px]",children:[t.thought.slice(0,80).replace(/\n/g," "),"..."]})]}),!o&&e.jsx("div",{className:"text-dark-muted italic whitespace-pre-wrap leading-snug mt-1",children:t.thought.replace(/\n\s*\n+/g,`
11
+ `)})]}),t.action&&e.jsxs("div",{className:"py-0.5 px-2 text-xs border-l-2 border-accent-yellow/40 bg-accent-yellow/5 rounded-r",children:[e.jsxs("div",{className:"flex items-center gap-1 text-accent-yellow mb-0.5",children:[e.jsx(Gt,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:r("step.action")})]}),e.jsx("div",{className:"text-dark-text leading-snug font-mono text-[11px]",children:t.action})]}),t.toolCalls&&t.toolCalls.length>0&&e.jsx("div",{className:"px-1 py-0.5",children:e.jsx(Jt,{toolCalls:t.toolCalls})}),t.result&&e.jsxs("div",{className:"py-0.5 px-2 text-xs border-l-2 border-accent-green/40 bg-accent-green/5 rounded-r",children:[e.jsxs("div",{className:"flex items-center gap-1 text-accent-green mb-0.5",children:[e.jsx(Ee,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:r("step.result")})]}),e.jsx(Ja,{text:t.result,maxLength:500})]})]})]})}),Ya=l.memo(function({steps:t,isGenerating:s}){const{t:r}=ee(),[a,i]=l.useState(s),o=l.useRef(s);l.useEffect(()=>{o.current&&!s&&i(!1),o.current=s},[s]);const c=t.length,d=s||t.some(x=>x.status==="running"),u=[...t].reverse().find(x=>x.status==="running"),p=t[t.length-1],h=(u==null?void 0:u.title)||(p==null?void 0:p.title)||"",f=`${c} ${r(c===1?"chat.stepCount":"chat.stepCountPlural")}`;return e.jsxs("div",{className:"mb-1 rounded-lg border border-dark-border/50 transition-colors","data-testid":"turn-group",children:[e.jsxs("button",{className:"flex w-full items-center gap-2 px-2 py-1 text-left cursor-pointer select-none hover:bg-dark-surface/40",onClick:()=>i(!a),"data-testid":"turn-group-toggle",children:[e.jsx("span",{className:"shrink-0 text-dark-muted/60 transition-transform",children:a?e.jsx(we,{size:13}):e.jsx(Se,{size:13})}),d?e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:e.jsx("span",{className:"tl-node bg-accent-blue","data-status":"running"})}):e.jsx("span",{className:"w-2 h-2 shrink-0 rounded-full bg-accent-green"}),e.jsx("span",{className:`text-xs ${d?"text-shimmer":"text-dark-muted"}`,children:d?`${r("chat.runningSteps")} ${f}…`:f}),d&&h&&e.jsxs("span",{className:"min-w-0 flex-1 truncate pl-1 text-xs text-dark-muted/70",children:["· ",h]})]}),a&&e.jsx("div",{className:"ml-[15px] pb-1 pl-3 border-l border-dark-border/25 space-y-0.5",children:t.map(x=>e.jsx(Xa,{step:x},x.id))})]})});function mn(n){const t=n??"";let s=t,r=null,a=null;try{const i=JSON.parse(t);if(i&&typeof i=="object")if("payload"in i){a=typeof i.toolName=="string"?i.toolName:null;const o=i.payload;typeof o=="string"?s=o:o&&typeof o=="object"?(r=o,s=JSON.stringify(o,null,2)):s=""}else Array.isArray(i)||(r=i)}catch{s=t}if(!r&&s.length>0&&/^[\s]*[{[]/.test(s))try{const i=JSON.parse(s);i&&typeof i=="object"&&!Array.isArray(i)&&(r=i)}catch{}return{toolName:a,payloadText:s,args:r}}const Xt=/\b(bash|shell|exec|cmd|powershell|terminal)\b/i,fn=/write_file|write|save|create|upload|deploy|publish/i,xn=/edit_file|edit|patch|apply|update|replace/i,gn=/read_file|read|view|cat|open|list|dir\b/i,Za=/file_delete|delete|remove|unlink|\brm\b|\bdel\b/i,Qa=/\b(glob|find|locate)\b/i,ei=/\b(grep|rg|search_contents)\b/i,ti=/web_search|search_web|browse/i,bn=/web_fetch|fetch|http|curl|wget|download|request|api/i,si=/git|commit|merge|rebase|push|checkout/i,ni=/install|uninstall|npm|pnpm|yarn|pip|cargo|gem|apt|brew|choco/i,Yt=/send_message|send_file|message|notify|post/i;function kn(n){const t=n.toLowerCase();return Xt.test(t)?"verbRunCommand":ti.test(t)?"verbSearchWeb":fn.test(t)?"verbWriteFile":xn.test(t)?"verbEditFile":Za.test(t)?"verbDeleteFile":gn.test(t)?"verbReadFile":ei.test(t)?"verbSearchContents":Qa.test(t)?"verbFindFiles":bn.test(t)?"verbFetchUrl":si.test(t)?"verbGit":ni.test(t)?"verbInstall":Yt.test(t)?"verbSendMessage":"verbRunTool"}function vt(n,t){const s=(n??"").replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t-1)}…`:s}function ri(n){if(!n)return null;for(const t of["file_path","filePath","path","file","target"]){const s=n[t];if(typeof s=="string"&&s.length>0)return s}return null}function yn(n,t){const{payloadText:s,args:r}=mn(t),a=n.toLowerCase();if(Xt.test(a))return"";const i=ri(r);if(i)return i;const o=s.match(/(?:file_path|path|file)["\s:=]+([^\s",}]+)/i);if(o!=null&&o[1])return o[1];if(bn.test(a)&&typeof(r==null?void 0:r.url)=="string"&&r.url)return vt(r.url,48);if(Yt.test(a)){const c=typeof(r==null?void 0:r.text)=="string"?r.text:typeof(r==null?void 0:r.message)=="string"?r.message:s;return vt(c,48)}return vt(s,48)}function vn(n,t){const{payloadText:s,args:r}=mn(t),a=n.toLowerCase();if(Xt.test(a)){const i=typeof(r==null?void 0:r.command)=="string"?r.command:s;return i?{text:i,mono:!0}:null}if(fn.test(a)||xn.test(a)){const i=typeof(r==null?void 0:r.content)=="string"?r.content:typeof(r==null?void 0:r.data)=="string"?r.data:"";if(i)return{text:i,mono:!0};if(r){const o=Cs(r);if(o)return{text:o,mono:!0}}return s?{text:s,mono:!0}:null}if(Yt.test(a)){const i=typeof(r==null?void 0:r.text)=="string"?r.text:typeof(r==null?void 0:r.message)=="string"?r.message:s;return i?{text:i,mono:!1}:null}if(gn.test(a))return null;if(r){const i=Cs(r);if(i)return{text:i,mono:!0}}return s?{text:s,mono:!0}:null}function Cs(n){return n?Object.entries(n).filter(([,t])=>t!=null).map(([t,s])=>{let r=typeof s=="string"?s:JSON.stringify(s);return r.length>96&&(r=`${r.slice(0,95)}…`),`${t}=${r.replace(/\n/g," ")}`}).join(" "):""}function wn(n,t){const s=Ye(t);return s?{path:s,external:!0}:{key:"scopeLocal",external:!1}}function jn({pre:n,obj:t}){return e.jsxs("span",{className:"min-w-0 text-sm text-dark-muted",children:[e.jsx("span",{children:n}),t&&e.jsx("b",{className:"font-semibold text-dark-text",children:t})]})}const wt=5,jt=420;function Ut({text:n,mono:t=!0}){const{t:s}=ee("hook"),[r,a]=l.useState(!1),i=n.split(`
12
+ `),o=i.length>wt||n.length>jt;let c=n;!r&&o&&(c=i.slice(0,wt).join(`
13
+ `),c.length>jt&&(c=`${c.slice(0,jt).trimEnd()}…`));const d=r?s("showLess"):i.length>wt?s("showAllLines",{n:i.length}):s("showAll");return e.jsxs("div",{className:`rounded-lg border border-dark-border bg-dark-surface p-2.5 text-xs leading-relaxed break-all whitespace-pre-wrap ${t?"font-mono":""} text-dark-text`,children:[c,o&&e.jsx("button",{type:"button",onClick:()=>a(u=>!u),className:"mt-1 block text-[11px] text-accent-blue hover:underline",children:d})]})}const Nt=15,ai=l.memo(function({approval:t,onResolved:s}){const{t:r}=ee("hook"),[a,i]=l.useState(!1),[o,c]=l.useState(Nt),d=l.useRef(null),u=t.status==="pending",{level:p,reasonKey:h}=nn(t.toolName,t.askPayload),f=rn[p],x=vn(t.toolName,t.askPayload),g=wn(t.toolName,t.askPayload),k=Ye(t.askPayload)!==null;l.useEffect(()=>{if(u)return c(Nt),d.current=setInterval(()=>{c(N=>N<=1?(d.current&&clearInterval(d.current),0):N-1)},1e3),()=>{d.current&&clearInterval(d.current)}},[u,t.approvalId]),l.useEffect(()=>{const N=(t.timeoutMs??15e3)>0;o===0&&u&&!a&&N&&y()},[o]);const y=l.useCallback(()=>{!u||a||(i(!0),d.current&&clearInterval(d.current),me.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"approved"))},[u,a,t.approvalId,s]),m=l.useCallback(()=>{!u||a||(i(!0),d.current&&clearInterval(d.current),me.send({type:"hook_deny",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"denied"))},[u,a,t.approvalId,s]),v=l.useCallback(()=>{if(!u||a)return;i(!0),d.current&&clearInterval(d.current);const N=Bt.getState(),L=Ye(t.askPayload);L?(N.addToSessionAllowList(t.toolName,L),me.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId,sessionAllow:!0})})):(N.addToSessionAllowList(t.toolName),me.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})})),s==null||s(t.approvalId,"approved")},[u,a,t.approvalId,t.toolName,t.askPayload,s]),_=l.useCallback(()=>{!u||a||(i(!0),d.current&&clearInterval(d.current),Bt.getState().setAutoMode(!0),Ie.getState().setAuto(!0),me.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"approved"))},[u,a,t.approvalId,s]);if(!u){const N=t.status==="approved";return e.jsx("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-xs ${N?"bg-accent-green/10 border border-accent-green/30 text-accent-green":"bg-accent-red/10 border border-accent-red/30 text-accent-red"}`,children:N?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14}),e.jsxs("span",{children:[r("alreadyAllowed"),t.toolName]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{size:14}),e.jsxs("span",{children:[r("alreadyDenied"),t.toolName]})]})})}const E=o/Nt*100,I=o<=5,O=[{id:"allow",index:1,label:r("optionAllow"),hint:r("optionAllowHint"),action:y,kind:"primary"},{id:"allow_session",index:3,label:r("optionAllowAlways"),hint:k?r("optionAllowPathHint"):r("optionAllowAlwaysHint",{tool:t.toolName}),action:v,kind:"secondary"},{id:"auto_mode",index:4,label:r("optionAutoMode"),hint:r("optionAutoModeHint"),action:_,kind:"secondary"},{id:"deny",index:2,label:r("optionDeny"),hint:r("optionDenyHint"),action:m,kind:"danger"}],j={primary:"bg-accent-blue text-white hover:opacity-90 shadow-sm",secondary:"border border-dark-border bg-dark-bg text-dark-text hover:bg-dark-hover",danger:"text-dark-muted hover:bg-red-500/10 hover:text-red-400"};return e.jsxs("div",{className:`bg-dark-bg border rounded-xl overflow-hidden ${g.external?"border-amber-500/40":f.border}`,children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 border-b ${f.bg} ${g.external?"border-amber-500/30":f.border}`,children:[e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${rc.badge}",children:[f.icon," ",p]}),e.jsx("span",{className:"flex-none w-6 h-6 rounded-md bg-accent-blue/10 text-accent-blue inline-flex items-center justify-center",children:e.jsx(Lt,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(jn,{pre:r(kn(t.toolName)),obj:yn(t.toolName,t.askPayload)})}),g.external&&g.path?e.jsxs("span",{className:"flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/30 shrink-0",title:g.path,children:[e.jsx(Js,{size:10}),g.path.length>32?`${g.path.slice(0,31)}…`:g.path]}):e.jsx("span",{className:"text-[10px] text-dark-muted/60 shrink-0",children:r("scopeLocal")}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-1 shrink-0",children:[e.jsx(Re,{size:11,className:I?"text-accent-red":"text-dark-muted"}),e.jsxs("span",{className:`text-[11px] font-mono ${I?"text-accent-red animate-pulse":"text-dark-muted"}`,children:[o,"s"]}),e.jsx("div",{className:"w-10 h-1 bg-dark-border rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-1000 ${I?"bg-accent-red":o<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${E}%`}})})]})]}),e.jsxs("div",{className:"px-3 py-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-dark-muted shrink-0",children:r("tool")}),e.jsx("code",{className:"text-accent-blue font-mono text-xs bg-dark-surface px-1.5 py-0.5 rounded",children:t.toolName}),e.jsx("span",{className:"text-[10px] text-dark-muted/50",children:r(h)})]}),x&&e.jsx(Ut,{text:x.text,mono:x.mono}),(p==="CRITICAL"||p==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-[11px] px-2 py-1 rounded ${f.bg} ${f.text}`,children:[e.jsx(_e,{size:12}),e.jsx("span",{children:r(p==="CRITICAL"?"highRiskWarning":"mediumRiskConfirm")})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:O.map(N=>e.jsxs("button",{onClick:N.action,disabled:a,className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-50 ${j[N.kind]}`,children:[e.jsx("span",{className:`text-[9px] font-mono rounded px-0.5 ${N.kind==="primary"?"bg-white/20":"bg-dark-surface text-dark-muted"}`,children:N.index}),e.jsx("span",{children:N.label}),e.jsx("span",{className:`text-[10px] ${N.kind==="primary"?"text-white/70":"text-dark-muted/60"} hidden sm:inline`,children:N.hint})]},N.id))}),e.jsx("div",{className:"text-[10px] text-dark-muted/50 pt-0.5 border-t border-dark-border/50",children:r("clickToSelect")})]})]})}),rt={xlsx:{icon:Ft},xls:{icon:Ft},csv:{icon:ot},docx:{icon:ot},text:{icon:Wt}};function Is(n){return!n&&n!==0?"—":n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/1024/1024).toFixed(2)} MB`}const ii=l.memo(function({job:t}){var f,x;const{t:s}=ee(),{stage:r}=t,a=l.useCallback(g=>{switch(g){case"xlsx":case"xls":return"Excel";case"csv":return"CSV";case"docx":return"Word";default:return s("fileJob.kindText")}},[s]),i=l.useCallback(g=>{ge.files.download(g).then(k=>{k.success||pe.error(k.error||s("fileJob.downloadFailed"))})},[s]),o=l.useMemo(()=>t.attachments||[],[t.attachments]),c=l.useMemo(()=>t.parsedFiles||[],[t.parsedFiles]),d=l.useMemo(()=>t.mapping||[],[t.mapping]),u=l.useMemo(()=>t.result||[],[t.result]),p=t.renderProgress??(r==="rendering"?0:100),h=t.parseProgress??(r==="parsing"?0:100);return e.jsxs("div",{className:"mt-2 rounded-xl border border-dark-border bg-dark-surface/60 overflow-hidden max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 border-b border-dark-border/60 bg-dark-surface",children:[r==="complete"?e.jsx(zt,{size:15,className:"text-accent-green shrink-0"}):r==="error"?e.jsx(_e,{size:15,className:"text-accent-red shrink-0"}):e.jsx(Fe,{size:15,className:"text-accent-blue animate-spin shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-dark-text",children:oi(r,s)}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-[10px] font-mono text-dark-muted/60",children:t.jobId})]}),e.jsxs("div",{className:"px-3.5 py-3 space-y-3",children:[o.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map((g,k)=>{const m=(rt[g.kind]||rt.text).icon;return e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-dark-border bg-dark-bg px-2.5 py-1.5",children:[e.jsx(m,{size:14,className:"text-accent-blue shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs text-dark-text truncate max-w-[160px]",children:g.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[Is(g.size)," · ",a(g.kind),g.role&&g.role!=="unknown"&&e.jsxs("span",{className:le("ml-1",g.role==="data"?"text-accent-green":"text-accent-purple"),children:["· ",g.role==="data"?s("fileJob.roleData"):s("fileJob.roleTemplate")]})]})]})]},`${g.fileName}-${k}`)})}),r==="parsing"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-dark-muted",children:s("fileJob.parsing",{file:((f=o[0])==null?void 0:f.fileName)||((x=c[0])==null?void 0:x.fileName)||""})}),e.jsx(cs,{value:h,size:"sm",showLabel:!0})]}),c.length>0&&r!=="error"&&e.jsxs("div",{className:"space-y-1.5",children:[c.map(g=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx(zt,{size:13,className:"text-accent-green shrink-0"}),e.jsx("span",{className:"truncate",children:g.fileName}),e.jsx("span",{className:"text-[10px] text-dark-muted/70",children:s("fileJob.parsedSummary",{rows:g.rowCount,fields:g.fields.length})})]},g.fileName)),c[0]&&e.jsxs("div",{className:"flex flex-wrap gap-1 pt-1",children:[c[0].fields.slice(0,12).map(g=>e.jsx("span",{className:"rounded bg-dark-bg border border-dark-border/60 px-1.5 py-0.5 text-[10px] font-mono text-dark-muted",children:g},g)),c[0].fields.length>12&&e.jsxs("span",{className:"text-[10px] text-dark-muted/60",children:["+",c[0].fields.length-12]})]})]}),d.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[11px] text-dark-muted",children:s("fileJob.mappingTitle")}),e.jsx("div",{className:"overflow-hidden rounded-lg border border-dark-border",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-dark-bg text-dark-muted",children:[e.jsx("th",{className:"text-left px-2.5 py-1.5 font-medium",children:s("fileJob.templatePlaceholder")}),e.jsx("th",{className:"px-2 py-1.5"}),e.jsx("th",{className:"text-left px-2.5 py-1.5 font-medium",children:s("fileJob.dataField")})]})}),e.jsx("tbody",{children:d.slice(0,8).map(g=>e.jsxs("tr",{className:"border-t border-dark-border/50",children:[e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-accent-purple",children:"{{"+g.placeholder+"}}"}),e.jsx("td",{className:"px-2 py-1.5 text-dark-muted",children:e.jsx(ar,{size:11})}),e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-accent-blue",children:g.field})]},g.placeholder))})]})}),d.length>8&&e.jsx("div",{className:"text-[10px] text-dark-muted/60",children:s("fileJob.mappingMore",{n:d.length-8})})]}),r==="rendering"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-dark-muted",children:s("fileJob.rendering",{current:t.currentRow||0,total:t.totalRows||0})}),e.jsx(cs,{value:p,size:"sm",variant:"warning",showLabel:!0})]}),u.length>0&&r==="complete"&&e.jsx("div",{className:"space-y-1.5",children:u.map(g=>{const y=(rt[g.format]||rt.text).icon,m=g.failedRows.length>0;return e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-bg px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{size:15,className:"text-accent-green shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-dark-text truncate",children:g.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[Is(g.size)," · ",s("fileJob.rowsDone",{done:g.successCount,total:g.rowCount}),m&&e.jsxs("span",{className:"text-accent-red",children:[" · ",s("fileJob.rowsFailed",{n:g.failedRows.length})]})]})]}),e.jsxs("button",{onClick:()=>sn(g.path),className:"flex items-center gap-1 rounded-md bg-dark-surface border border-dark-border text-dark-muted px-2 py-1 text-[11px] hover:bg-dark-hover hover:text-dark-text transition-colors",title:s("chat.previewInPanel"),children:[e.jsx(Vs,{size:12}),s("chat.previewInPanel")]}),e.jsxs("button",{onClick:()=>i(g.path),className:"flex items-center gap-1 rounded-md bg-accent-blue/10 text-accent-blue px-2 py-1 text-[11px] hover:bg-accent-blue/20 transition-colors",title:s("fileJob.download"),children:[e.jsx(ir,{size:12}),s("fileJob.download")]})]}),m&&e.jsxs("div",{className:"mt-1.5 space-y-0.5 border-t border-dark-border/50 pt-1.5",children:[g.failedRows.slice(0,3).map(v=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-red",children:[e.jsx(or,{size:10,className:"shrink-0"}),e.jsxs("span",{children:["#",v.index+1]}),e.jsx("span",{className:"truncate",children:v.error})]},v.index)),g.failedRows.length>3&&e.jsx("div",{className:"text-[10px] text-dark-muted/70",children:s("fileJob.moreRows",{n:g.failedRows.length-3})})]})]},g.path)})}),r==="error"&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-accent-red/30 bg-accent-red/5 px-3 py-2.5",children:[e.jsx(_e,{size:15,className:"text-accent-red shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium text-accent-red",children:t.error||s("fileJob.error")}),t.errorDetail&&e.jsx("div",{className:"mt-0.5 text-[11px] text-dark-muted break-words",children:t.errorDetail})]})]})]})]})});function oi(n,t){switch(n){case"uploaded":return t("fileJob.stageUploaded");case"parsing":return t("fileJob.stageParsing");case"mapping":return t("fileJob.stageMapping");case"rendering":return t("fileJob.stageRendering");case"complete":return t("fileJob.stageComplete");case"error":return t("fileJob.stageError");default:return t("fileJob.stageUploaded")}}const Rs={auth:{icon:cr,color:"text-accent-red"},rate_limit:{icon:Pt,color:"text-accent-yellow"},timeout:{icon:Pt,color:"text-accent-yellow"},network:{icon:lr,color:"text-accent-yellow"},model:{icon:Xs,color:"text-accent-red"},tool:{icon:_e,color:"text-accent-yellow"},unknown:{icon:_e,color:"text-accent-red"}},li=l.memo(function({error:t,onRetry:s}){const{t:r}=ee(),[a,i]=l.useState(!1),o=Rs[t.category]||Rs.unknown,c=o.icon,d=()=>{window.dispatchEvent(new CustomEvent("switch-tab",{detail:"models"}))};return e.jsxs("div",{className:"mt-2 max-w-2xl overflow-hidden rounded-xl border border-accent-red/30 bg-dark-surface",children:[e.jsxs("div",{className:"flex items-start gap-3 px-3.5 py-3",children:[e.jsx(c,{size:18,className:le("shrink-0 mt-0.5",o.color)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-dark-text",children:t.summary}),t.detail&&t.detail!==t.summary&&e.jsx("div",{className:"mt-0.5 text-[11px] text-dark-muted/80 break-words",children:t.detail.slice(0,160)}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[t.retryable&&s&&e.jsxs("button",{onClick:s,className:"flex items-center gap-1 rounded-md bg-accent-blue/10 text-accent-blue px-2 py-1 text-[11px] hover:bg-accent-blue/20 transition-colors",children:[e.jsx(Xe,{size:11}),r("errorCard.retry")]}),t.category==="auth"&&e.jsxs("button",{onClick:d,className:"flex items-center gap-1 rounded-md bg-dark-hover text-dark-text px-2 py-1 text-[11px] hover:bg-dark-border transition-colors",children:[e.jsx(dr,{size:11}),r("errorCard.modelSettings")]}),t.detail&&e.jsxs("button",{onClick:()=>i(u=>!u),className:"flex items-center gap-0.5 text-[11px] text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(we,{size:11,className:le("transition-transform",a&&"rotate-180")}),r("errorCard.details")]})]})]})]}),a&&t.detail&&e.jsx("div",{className:"border-t border-dark-border/60 bg-dark-bg px-3.5 py-2.5 text-[11px] font-mono text-dark-muted break-words max-h-40 overflow-y-auto custom-scrollbar",children:t.detail})]})});function ci(n){const t=n.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)||n}function di({status:n}){switch(n){case"completed":return e.jsx(Ee,{size:13,className:"shrink-0 text-accent-green","data-testid":"activity-status-completed"});case"failed":return e.jsx(Ae,{size:13,className:"shrink-0 text-accent-red","data-testid":"activity-status-failed"});case"running":return e.jsx("span",{className:"tl-node bg-accent-blue","data-status":"running","data-testid":"activity-status-running"});case"waiting_user":return e.jsx(pr,{size:13,className:"shrink-0 text-accent-yellow","data-testid":"activity-status-waiting"});case"blocked":return e.jsx(ur,{size:13,className:"shrink-0 text-accent-red","data-testid":"activity-status-blocked"});case"paused":return e.jsx(Ys,{size:13,className:"shrink-0 text-dark-300","data-testid":"activity-status-paused"});default:return e.jsx("span",{className:"inline-block w-2 h-2 shrink-0 rounded-full bg-dark-border"})}}const ui=l.memo(function({activity:t,toolCalls:s,onAnswer:r}){const{t:a}=ee(),[i,o]=l.useState(t.status==="running"),c=l.useRef(t.status);l.useEffect(()=>{(c.current==="running"||c.current==="waiting_user"||c.current==="paused")&&(t.status==="completed"||t.status==="failed")&&o(!1),c.current=t.status},[t.status]);const d=l.useMemo(()=>{for(const g of s){const k=Qe(g.args);if(k)return k}},[s]),u=t.endedAt?t.endedAt-t.startedAt:Date.now()-t.startedAt,p=u>=6e4?`${Math.round(u/6e4)}m`:u>=1500?`${Math.round(u/1e3)}s`:"",h=t.status==="waiting_user",f=t.status==="blocked",x=t.status==="paused";return e.jsxs("div",{className:`tl-row rounded-lg transition-colors ${h?"border border-accent-yellow/25 bg-accent-yellow/5":f?"border border-accent-red/25 bg-accent-red/5":"hover:bg-dark-surface/40"}`,"data-testid":"activity-row",children:[!h&&!f&&e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>o(g=>!g),"data-testid":"activity-row-toggle",children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:e.jsx(di,{status:t.status})}),e.jsx("span",{className:`min-w-0 text-[13px] font-medium truncate ${t.status==="running"?"text-shimmer":"text-dark-text"}`,children:t.title}),t.phase!=="analysis"&&e.jsx("span",{className:"status-pill","data-tone":"neutral","data-testid":"activity-phase",children:a(`activity.phase.${t.phase}`)}),d&&e.jsx("span",{className:"shrink-0 max-w-[14rem] truncate rounded-full border border-dark-border/70 px-2 py-0.5 font-mono text-[10.5px] text-accent-blue",children:ci(d)}),s.length>1&&e.jsx("span",{className:"shrink-0 text-[10.5px] text-dark-muted",children:a("activity.evidenceMore",{count:s.length-1})}),p&&e.jsx("span",{className:"shrink-0 text-[10.5px] text-dark-muted",children:p}),h&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-accent-yellow",children:a("activity.waitingUser")}),f&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-accent-red",title:t.blockedReason?a("activity.blocked",{reason:t.blockedReason}):void 0,children:a("activity.blocked",{reason:t.blockedReason??""})}),x&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-dark-300",children:a("activity.paused")}),h&&r&&e.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),r(t.id)},className:"shrink-0 rounded border border-accent-yellow/40 px-1.5 py-0.5 text-[10.5px] text-accent-yellow hover:bg-accent-yellow/10",children:a("activity.viewAndAnswer")}),!h&&s.length>0&&e.jsx(we,{size:12,className:`ml-auto shrink-0 text-dark-muted transition-transform ${i?"rotate-180":""}`})]}),i&&s.length>0&&e.jsx("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25",children:e.jsx(Jt,{toolCalls:s})})]})});function pi(n){for(const t of n.split(`
14
+ `)){const s=t.trim();if(s)return s}return""}function hi(n){var s;const t=n.split(`
15
+ `);for(let r=t.length-1;r>=0;r--){const a=(s=t[r])==null?void 0:s.trim();if(a)return a}return""}function Nn({index:n,text:t,isStreaming:s,collapsed:r,onToggle:a}){const{t:i}=ee(),o=r?s?hi(t):pi(t):"";return e.jsxs("div",{children:[e.jsxs("button",{className:"flex w-full cursor-pointer select-none items-center gap-1.5 py-0.5 text-left text-xs",onClick:()=>a(n),"data-testid":"thinking-toggle",children:[e.jsx(Se,{size:12,className:`shrink-0 text-dark-muted transition-transform ${r?"":"rotate-90"}`}),e.jsx("span",{className:`shrink-0 ${s?"text-shimmer":"text-dark-muted"}`,children:s?`${i("chat.thinking")}…`:i("chat.thoughtProcess")}),o&&e.jsx("span",{"data-testid":"thinking-summary",className:"min-w-0 flex-1 truncate text-dark-muted/60",title:o,children:o})]}),!r&&e.jsx("div",{"data-testid":"thinking-body",className:"mt-1 whitespace-pre-wrap break-words border-l border-dark-border/25 pl-3 text-xs text-dark-muted",children:t.replace(/\n{3,}/g,`
16
+
17
+ `)})]})}const mi=l.memo(function({message:t,sessionId:s,isGenerating:r,onAnswer:a}){const i=Ur(y=>qr(y,s,t.id)),o=l.useMemo(()=>i.length>0?i:!t.toolCalls||t.toolCalls.length===0?[]:Gr(s??"",t),[i,t,s]),c=l.useMemo(()=>t.thinkingBlocks&&t.thinkingBlocks.length>0?t.thinkingBlocks:t.thinking?[{index:Number.MIN_SAFE_INTEGER,text:t.thinking}]:[],[t.thinkingBlocks,t.thinking]),[d,u]=l.useState({}),p=!r||!!t.content;l.useEffect(()=>{p&&u(y=>{const m={...y};for(const v of c)m[v.index]=!0;return m})},[p,c]);const h=l.useMemo(()=>{let y=Number.MIN_SAFE_INTEGER;for(const m of c)y=Math.max(y,m.index);for(const m of t.toolCalls??[])y=Math.max(y,m.index??Number.MIN_SAFE_INTEGER);return y},[c,t.toolCalls]),f=y=>r&&!t.content&&y===h,x=y=>{const m=d[y]??(!!t.content||!r);u(v=>({...v,[y]:!m}))},g=l.useMemo(()=>{const y=[];for(const m of c)y.push({key:`thinking-${m.index}`,index:m.index,kind:"thinking",block:m});for(const m of o)y.push({key:`activity-${m.id}`,index:m.blockRange[0],kind:"activity",activity:m});return y.sort((m,v)=>m.index-v.index),y},[c,o]),k=l.useMemo(()=>{const y={},m=t.toolCalls??[];for(const v of o)y[v.id]=v.toolCallIds.map(_=>m.find(E=>E.id===_)).filter(_=>!!_);return y},[o,t.toolCalls]);return g.length===0?null:e.jsx("div",{className:"mb-1 space-y-0.5","data-testid":"agent-activity-feed",children:g.map(y=>y.kind==="thinking"&&y.block?e.jsx(Nn,{index:y.block.index,text:y.block.text,isStreaming:f(y.block.index),collapsed:d[y.block.index]??(!!t.content||!r),onToggle:x},y.key):y.activity?e.jsx(ui,{activity:y.activity,toolCalls:k[y.activity.id]??[],onAnswer:a},y.key):null)})}),Sn=5,fi=30,xi=["让我","我先","我现在","我发现","我注意到","我决定","我重新","我重试","我继续","我现在要","让我现在","let me","let's","i should","i need","i will","i'll","i am","i notice","i see","i try","i retry","i think","i continue","i re-","now i","first i","first, i"];function gi(n){const t=n.charCodeAt(0);return t>=19968&&t<=40959}function bi(n){let t="",s=!1;for(const r of n)r===" "||r===" "||r===" "?(s||(t+=" "),s=!0):(t+=r,s=!1);return t}function ki(n){return n>=97&&n<=122||n>=48&&n<=57||n===95}function En(n){const t=bi(n.trimStart().toLowerCase());return xi.some(s=>{if(!t.startsWith(s))return!1;const r=t[s.length];return r===void 0||gi(s)||s==="i re-"?!0:!ki(r.charCodeAt(0))})}function yi(n){if(!n)return!1;const t=n.split(/\r?\n/).slice(0,fi);let s=0;for(const r of t)if(r.trim())if(En(r)){if(s++,s>=Sn)return!0}else return!1;return!1}function vi(n,t){if(!n)return{body:n||"",absorbed:""};if(!yi(n))return{body:n,absorbed:""};const s=n.split(/\r?\n/);let r=0,a=0;for(const o of s){if(!o.trim()){a++;continue}if(En(o)){r++,a++;continue}break}if(r<Sn)return{body:n,absorbed:""};let i=0;for(const o of s.slice(0,a)){if(i+=o.length,i>=n.length)break;n.startsWith(`\r
18
+ `,i)?i+=2:(n[i]===`
19
+ `||n[i]==="\r")&&(i+=1)}return{body:n.slice(i),absorbed:n.slice(0,i)}}function St({onClick:n,title:t,children:s,danger:r=!1}){return e.jsx("button",{onClick:n,title:t,"aria-label":t,className:`inline-flex items-center justify-center rounded-md p-1.5 transition-colors ${r?"text-dark-muted hover:bg-accent-red/10 hover:text-accent-red":"text-dark-muted hover:bg-dark-hover hover:text-dark-text"}`,children:s})}function _s({message:n,sessionId:t,onRegenerate:s,onDeleteMessage:r}){const{t:a}=ee(),[i,o]=l.useState(!1),c=l.useRef(null);l.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const d=l.useCallback(async()=>{try{await navigator.clipboard.writeText(n.content||n.thinking||""),o(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>o(!1),2e3)}catch(u){console.error("Failed to copy message:",u)}},[n.content,n.thinking]);return t?e.jsxs("div",{className:"absolute bottom-2 right-3 z-10 flex items-center gap-0.5 rounded-lg border border-dark-border/60 bg-dark-bg/85 px-1 py-0.5 opacity-0 shadow-md backdrop-blur-sm transition-opacity duration-150 group-hover:opacity-100 group-focus-within:opacity-100",children:[e.jsx(St,{onClick:d,title:a("chat.copyMessage"),children:i?e.jsx(Ee,{size:13,className:"text-accent-green"}):e.jsx(mr,{size:13})}),n.type==="assistant"&&s&&e.jsx(St,{onClick:()=>s(n.id),title:a("chat.regenerate"),children:e.jsx(Xe,{size:13})}),r&&e.jsx(St,{onClick:()=>r(n.id),title:a("chat.deleteMessage"),danger:!0,children:e.jsx(fr,{size:13})})]}):null}function Ms({ts:n,children:t}){const{i18n:s}=ee(),r=s.language==="en"?"en-US":"zh-CN";return e.jsxs("div",{className:"absolute bottom-2 left-3 select-none z-10 flex items-center gap-0.5 text-[10.5px] leading-none whitespace-nowrap opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity duration-150",children:[e.jsx("span",{className:"pr-1 text-[10px] text-dark-muted/50",children:new Date(n).toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"})}),t]})}function wi(n,t){const s=[];for(const r of n)s.push({key:`thinking-${r.index}`,index:r.index,kind:"thinking",block:r});for(const r of t??[])s.push({key:`tool-${r.id}`,index:r.index??Number.MAX_SAFE_INTEGER,kind:"tool",toolCall:r});return s.sort((r,a)=>r.index-a.index),s}const ji=l.memo(function({message:t,sessionId:s,onRegenerate:r,onDeleteMessage:a}){var E,I,O;const{t:i}=ee(),o=lt(j=>j.developerView),c=ke(j=>{var L;if(!s||!j.generatingSessions.includes(s))return!1;const N=j.messagesBySession[s];return N?((L=N[N.length-1])==null?void 0:L.id)===t.id:!1}),d=l.useMemo(()=>t.thinkingBlocks&&t.thinkingBlocks.length>0?t.thinkingBlocks:t.thinking?[{index:Number.MIN_SAFE_INTEGER,text:t.thinking}]:[],[t.thinkingBlocks,t.thinking]),[u,p]=l.useState({}),h=!c||!!t.content;l.useEffect(()=>{h&&p(j=>{const N={...j};for(const L of d)N[L.index]=!0;return N})},[h,d]);const f=l.useMemo(()=>wi(d,t.toolCalls),[d,t.toolCalls]),x=l.useMemo(()=>{var L;if(!t.content)return"";if(!(!!t.thinking||(((L=t.thinkingBlocks)==null?void 0:L.length)??0)>0))return t.content;const{body:N}=vi(t.content);return N||t.content},[t.content,t.thinking,t.thinkingBlocks]),g=l.useMemo(()=>{const j=[];for(const N of f)if(N.kind==="thinking"&&N.block)j.push({key:N.key,kind:"thinking",block:N.block});else if(N.kind==="tool"&&N.toolCall){const L=j[j.length-1];L&&L.kind==="tools"?L.toolCalls.push(N.toolCall):j.push({key:`tools-${N.key}`,kind:"tools",toolCalls:[N.toolCall]})}return j},[f]),k=l.useMemo(()=>{let j=Number.MIN_SAFE_INTEGER;for(const N of d)j=Math.max(j,N.index);for(const N of t.toolCalls??[])j=Math.max(j,N.index??Number.MIN_SAFE_INTEGER);return j},[d,t.toolCalls]),y=l.useCallback(j=>{const N=u[j]??(!!t.content||!c);p(L=>({...L,[j]:!N}))},[c,t.content,u]),m=t.type==="user",v=t.type==="system",_=l.useCallback((j,N)=>{if(!s)return;const R=ke.getState().getMessages(s),T=R.findIndex(X=>X.id===t.id);if(T===-1)return;const U=R[T];if(!U)return;const K={...U,hookApproval:U.hookApproval?{...U.hookApproval,status:N}:void 0},W=[...R];W[T]=K,ke.setState({messagesBySession:{...ke.getState().messagesBySession,[s]:W}})},[s,t.id]);return t.deleted?null:m?e.jsxs("div",{className:"chat-msg","data-role":"user",children:[e.jsx("div",{className:"chat-avatar","aria-hidden":!0,children:e.jsx(hr,{size:14,strokeWidth:2.4})}),e.jsx("div",{className:"max-w-[78%] flex flex-col",children:e.jsxs("div",{className:"group relative inline-block self-end rounded-2xl border border-dark-border/40 bg-dark-surface px-4 pb-8 pt-2.5 text-dark-text shadow-sm",style:{borderBottomRightRadius:"0.375rem"},children:[e.jsx(Ms,{ts:t.timestamp}),e.jsx(_s,{message:t,sessionId:s,onRegenerate:r,onDeleteMessage:a}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[14.5px]",children:(E=t.content)==null?void 0:E.replace(/\n{3,}/g,`
20
+
21
+ `)})]})})]}):v?e.jsx("div",{className:"chat-msg","data-role":"system",children:e.jsx("div",{className:"text-[11px] text-dark-muted bg-dark-surface border border-dark-border/60 rounded-full px-3.5 py-1 max-w-[90%] text-center",children:t.content})}):e.jsxs("div",{className:"chat-msg","data-role":"assistant",children:[e.jsx("div",{className:"chat-avatar","aria-hidden":!0,children:e.jsx(Xs,{size:14,strokeWidth:2.4})}),e.jsxs("div",{className:"chat-card group relative",children:[e.jsx(Ms,{ts:t.timestamp}),e.jsx(_s,{message:t,sessionId:s,onRegenerate:r,onDeleteMessage:a}),t.steps&&t.steps.length>0&&!t.hookApproval?e.jsx(Ya,{steps:t.steps,isGenerating:c}):o?e.jsx(e.Fragment,{children:g.length>0&&!t.hookApproval&&e.jsx("div",{className:"mb-2 space-y-1",children:g.map(j=>j.kind==="thinking"?e.jsx(Nn,{index:j.block.index,text:j.block.text,isStreaming:c&&!t.content&&j.block.index===k,collapsed:u[j.block.index]??(!!t.content||!c),onToggle:y},j.key):e.jsx(Jt,{toolCalls:j.toolCalls},j.key))})}):e.jsx(mi,{message:t,sessionId:s,isGenerating:c}),t.content?e.jsx("div",{className:"leading-relaxed",children:e.jsx(Wr,{content:x.replace(/\n{3,}/g,`
22
+
23
+ `)})}):d.length===0&&!t.hookApproval&&((I=t.steps)!=null&&I.length)?null:d.length===0&&!t.hookApproval&&!((O=t.steps)!=null&&O.length)&&c?e.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-dark-muted","data-testid":"thinking-typing",children:[e.jsxs("span",{className:"chat-typing-dots",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsxs("span",{children:[i("chat.thinking"),"…"]})]}):null,t.summary&&!c&&e.jsx("div",{className:"mt-1.5 text-[11px] text-dark-muted/70","data-testid":"turn-summary",children:Kr(t.summary)}),t.fileJob&&e.jsx("div",{className:"mt-3",children:e.jsx(ii,{job:t.fileJob})}),t.errorCard&&e.jsx("div",{className:"mt-3",children:e.jsx(li,{error:t.errorCard,onRetry:s&&r?()=>r(t.id):void 0})}),t.hookApproval&&e.jsx("div",{className:"mt-3 border-l-2 border-accent-yellow/50 pl-3",children:e.jsx(ai,{approval:t.hookApproval,onResolved:_})})]})]})});function Ni(n,t=28){const s=n.replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t)}…`:s}const Si="cubic-bezier(0.34, 1.56, 0.64, 1)",Ei=l.memo(function({items:t,activeId:s,onJump:r}){const{t:a}=ee(),[i,o]=l.useState(!1),c=l.useRef(null),d=l.useCallback(()=>{c.current&&window.clearTimeout(c.current),o(!0)},[]),u=l.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>o(!1),180)},[]);return t.length===0?null:e.jsx("div",{role:"list","aria-label":a("chat.messageRail"),className:"pointer-events-none absolute right-4 top-1/2 z-30 hidden -translate-y-1/2 md:block",children:e.jsxs("div",{onMouseEnter:d,onMouseLeave:u,"data-testid":"rail-trigger",className:"pointer-events-auto relative flex items-center py-3",children:[e.jsxs("div",{"aria-hidden":!i,inert:!i,"data-testid":"rail-panel",className:`absolute right-full top-1/2 flex w-72 -translate-y-1/2 origin-right flex-col overflow-hidden rounded-xl border border-dark-border/70 bg-dark-bg/90 shadow-xl shadow-black/10 backdrop-blur-xl transition-all duration-300 ${i?"translate-x-0 scale-100 opacity-100":"pointer-events-none translate-x-4 scale-95 opacity-0"}`,style:{transitionTimingFunction:i?Si:"ease"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-dark-border/60 px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-dark-muted",children:[e.jsx(xr,{size:12,className:"text-accent-blue","aria-hidden":"true"}),a("chat.messageIndex")]}),e.jsx("span",{className:"rounded-full bg-dark-hover px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-dark-muted",children:t.length})]}),e.jsx("div",{className:"max-h-[55vh] overflow-y-auto p-1.5 custom-scrollbar",children:t.map((p,h)=>{const f=p.id===s;return e.jsxs("button",{type:"button",role:"listitem",onClick:()=>r(p.id),title:p.content,"aria-current":f?"true":void 0,tabIndex:i?0:-1,className:`group/item flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-all duration-200 ${i?"translate-x-0 opacity-100":"translate-x-2 opacity-0"} ${f?"bg-accent-blue/10":"hover:bg-dark-hover"}`,style:{transitionDelay:i?`${Math.min(h*24,264)}ms`:"0ms"},children:[e.jsx("span",{className:`mt-px flex h-4 w-4 shrink-0 items-center justify-center rounded text-[10px] font-semibold tabular-nums transition-colors duration-200 ${f?"bg-accent-blue text-white":"bg-dark-hover text-dark-muted group-hover/item:bg-dark-border/80 group-hover/item:text-dark-text"}`,children:h+1}),e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{"data-testid":"rail-entry-content",className:`block break-words text-xs leading-snug line-clamp-2 group-hover/item:line-clamp-none transition-colors duration-200 ${f?"font-medium text-accent-blue":"text-dark-text/90"}`,children:p.content})}),e.jsx(Se,{size:12,"aria-hidden":"true",className:"mt-0.5 shrink-0 -translate-x-1 text-dark-muted/50 opacity-0 transition-all duration-200 group-hover/item:translate-x-0 group-hover/item:opacity-100"})]},p.id)})})]}),e.jsx("div",{"data-testid":"rail-dots",className:"flex flex-col items-end gap-1",children:t.map((p,h)=>{const f=Ni(p.content),x=p.id===s;return e.jsx("button",{type:"button",role:"listitem",onClick:()=>r(p.id),title:p.content,"aria-label":`${h+1}. ${f}`,"aria-current":x?"true":void 0,className:"group/dot pointer-events-auto flex h-6 w-5 items-center justify-center rounded-full transition-colors duration-200 hover:bg-dark-surface/80",children:e.jsx("span",{className:x?"h-2 w-2 rounded-full bg-accent-blue ring-2 ring-accent-blue/25 transition-all duration-300 ease-out group-hover/dot:scale-125":"h-1.5 w-1.5 rounded-full bg-dark-muted/35 transition-all duration-300 ease-out group-hover/dot:scale-150 group-hover/dot:bg-dark-muted"})},p.id)})})]})})}),Ti=l.lazy(()=>Vr(()=>import("./ThreeScene-Zhjwe9nT.js"),__vite__mapDeps([0,1,2,3])));function Ai(){try{const n=document.createElement("canvas");return!!(n.getContext("webgl2")??n.getContext("webgl"))}catch{return!1}}function Ci(){return l.useMemo(Ai,[])?e.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 overflow-hidden [&_.threeui-background]:bg-transparent",children:[e.jsx(l.Suspense,{fallback:null,children:e.jsx(Ti,{})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/30 via-transparent to-black/40"})]}):null}const Et=24;function Ii({label:n}){const t=l.useRef(Date.now()),s=l.useRef(null),[r,a]=l.useState(!1);return l.useEffect(()=>{const i=window.setTimeout(()=>a(!0),15e3);return()=>window.clearTimeout(i)},[]),l.useEffect(()=>{if(!r)return;const i=()=>{const c=s.current;if(!c)return;const d=Math.floor((Date.now()-t.current)/1e3);c.textContent=d>=60?`${Math.floor(d/60)}m ${d%60}s`:`${d}s`};i();const o=window.setInterval(i,1e3);return()=>window.clearInterval(o)},[r]),e.jsxs("div",{className:"mx-auto flex max-w-[46rem] items-center gap-2 px-4 py-3 text-xs text-dark-muted sm:px-6",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent-blue animate-blink"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.2s"}}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.4s"}})]}),e.jsx("span",{className:"text-shimmer",children:n}),r&&e.jsxs("span",{className:"flex items-center gap-1 tabular-nums text-dark-muted/70",children:[e.jsx(Re,{size:10}),e.jsx("span",{ref:s,children:"15s"})]})]})}const Ri=l.memo(function({messages:t,isGenerating:s,sessionId:r,onSendSuggestion:a,onRegenerate:i,onDeleteMessage:o}){const{t:c}=ee(),d=l.useRef(null),u=l.useRef(new Map),[p,h]=l.useState(!0),[f,x]=l.useState(null),[g,k]=l.useState(null),[y,m]=l.useState(0),v=l.useRef(null),_=l.useRef(!1),E=l.useRef(null),I=l.useRef(s);I.current=s;const O=l.useMemo(()=>t.filter(C=>!C.deleted),[t]),j=l.useMemo(()=>{if(!s)return!1;const C=O[O.length-1];return!(!C||C.type!=="assistant"||C.content||C.steps&&C.steps.length>0)},[s,O]),N=l.useMemo(()=>O.filter(C=>C.type==="user").map(C=>({id:C.id,content:C.content})),[O]),L=l.useMemo(()=>N.map(C=>C.id),[N]),R=l.useCallback(C=>{if(C){const z=C.dataset.mid;z&&u.current.set(z,C)}},[]);l.useEffect(()=>{const C=new Set(L);for(const z of u.current.keys())C.has(z)||u.current.delete(z)},[L]);const T=l.useCallback(()=>{const C=d.current;if(!C||L.length===0){x(null);return}const z=C.getBoundingClientRect(),Z=z.top+z.height*.35;let F=L[0]??null;for(const D of L){const q=u.current.get(D);if(!(!q||!q.isConnected))if(q.getBoundingClientRect().top<=Z)F=D;else break}C.scrollHeight-C.scrollTop-C.clientHeight<Et&&(F=L[L.length-1]??F),x(F)},[L]),U=l.useCallback(()=>{const C=d.current;if(!C)return;const z=C.scrollHeight-C.scrollTop-C.clientHeight;_.current?z>=Et&&(_.current=!1):h(z<Et),T()},[T]);l.useEffect(()=>{T()},[t,T]);const K=l.useCallback(C=>{const z=d.current,Z=u.current.get(C);if(!z||!Z||!Z.isConnected)return;h(!1),k(C),m(ae=>ae+1),v.current&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>k(null),1600);const F=z.getBoundingClientRect(),D=Z.getBoundingClientRect(),q=z.scrollTop+(D.top-F.top)-z.clientHeight/2+D.height/2;E.current&&window.clearTimeout(E.current),_.current=!0,z.scrollTo({top:Math.max(0,q),behavior:"smooth"});const Y=()=>{_.current=!1};"onscrollend"in z&&z.addEventListener("scrollend",Y,{once:!0}),E.current=window.setTimeout(()=>{_.current=!1},1500)},[]);l.useEffect(()=>()=>{v.current&&window.clearTimeout(v.current),E.current&&window.clearTimeout(E.current)},[]);const W=l.useCallback(()=>{E.current&&window.clearTimeout(E.current),_.current=!1;const C=d.current;C&&(C.scrollTop=C.scrollHeight)},[]),X=l.useCallback(()=>{E.current&&window.clearTimeout(E.current),_.current=!1,h(!0);const C=d.current;C&&C.scrollTo({top:C.scrollHeight,behavior:"smooth"})},[]);l.useEffect(()=>{s&&(h(!0),W())},[s,W]);const re=l.useMemo(()=>{var z,Z,F;const C=O[O.length-1];return`${O.length}:${(C==null?void 0:C.id)??""}:${((z=C==null?void 0:C.content)==null?void 0:z.length)??0}:${((Z=C==null?void 0:C.toolCalls)==null?void 0:Z.length)??0}:${((F=C==null?void 0:C.thinkingBlocks)==null?void 0:F.length)??0}`},[O]),A=l.useRef(re);l.useEffect(()=>{if(!p){A.current=re;return}re!==A.current&&(A.current=re,W())},[re,p,W]);const V=l.useMemo(()=>[{icon:gr,label:c("chat.suggestionCode"),prompt:c("chat.suggestionCodePrompt")},{icon:Ze,label:c("chat.suggestionAnalyze"),prompt:c("chat.suggestionAnalyzePrompt")},{icon:Gt,label:c("chat.suggestionAutomate"),prompt:c("chat.suggestionAutomatePrompt")}],[c]);return e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsxs("div",{ref:d,onScroll:U,className:"h-full overflow-y-auto custom-scrollbar",children:[O.length===0?e.jsxs("div",{className:"relative flex min-h-[55vh] items-center justify-center px-4 py-10 sm:px-6",children:[e.jsx(Ci,{}),e.jsxs("div",{className:"relative w-full max-w-2xl px-1 text-center",children:[e.jsx("div",{className:"chat-empty-orb",children:e.jsx("img",{src:"/logo.svg",alt:"deepseekcode",className:"relative h-10 w-10"})}),e.jsx("h2",{className:"text-xl font-semibold tracking-tight mb-2",children:c("chat.welcome")}),e.jsx("p",{className:"text-dark-muted text-sm mb-8",children:c("chat.welcomeDesc")}),a&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2.5 text-left",children:V.map(C=>e.jsxs("button",{onClick:()=>a(C.prompt),className:"ui-card-interactive group w-full px-4 py-3.5 text-left",children:[e.jsx(C.icon,{size:16,"aria-hidden":"true",className:"text-accent-blue mb-2"}),e.jsx("div",{className:"text-[13px] font-medium text-dark-text",children:C.label}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-dark-muted line-clamp-2",children:C.prompt})]},C.label))})]})]}):e.jsx("div",{className:"chat-stack flex flex-col pb-8 pt-5",children:O.map((C,z)=>{const Z=O[z-1],F=Z?Z.type===C.type?"mt-2":"mt-5":"";return e.jsxs("div",{"data-mid":C.id,ref:R,className:`relative w-full ${F}`,children:[g===C.id&&e.jsx("div",{className:"animate-rail-flash pointer-events-none absolute inset-0"},y),e.jsx(ji,{message:C,sessionId:r,onRegenerate:i,onDeleteMessage:o})]},C.id)})}),s&&!j&&e.jsx(Ii,{label:c("chat.thinkingEllipsis")},r)]}),N.length>0&&e.jsx(Ei,{items:N,activeId:f,onJump:K}),!p&&O.length>0&&e.jsx("button",{type:"button",onClick:X,title:c("chat.backToBottom"),"aria-label":c("chat.backToBottom"),className:"absolute bottom-5 right-5 z-20 flex h-8 w-8 animate-fade-in-up items-center justify-center rounded-full border border-dark-border/70 bg-dark-surface/90 text-dark-muted shadow-lg backdrop-blur transition-all duration-200 hover:scale-110 hover:text-dark-text hover:shadow-xl",children:e.jsx(we,{size:15})})]})});function Pe(n){return n.recordId!==void 0?n.recordId:n.callId!==void 0?`${n.kind}\0call\0${n.callId}`:n.sourceSeq!==void 0?`${n.kind}\0seq\0${n.sourceSeq}`:`${n.kind}\0index\0${n.index}`}function Tn(n){return n===null||!Number.isFinite(n)?"—":`${String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g,",")} ms`}function Zt(n){return Tn(n===null?null:n*1e3)}const _i=2048,Mi=512;function Oi(n){return n.replace(/```[^\n]*\n([\s\S]*?)```/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^[ \t]*[-*+]\s+/gm,"").replace(/^[ \t]*>\s?/gm,"").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/~~(.*?)~~/g,"$1")}function ct(n){const t=n.slice(0,_i),s=Oi(t).replace(/\s+/g," ").trim(),r=s.slice(0,Mi).trimEnd();return t.length<n.length||r.length<s.length?`${r}…`:r}function Os(n){if(Number.isFinite(n))return Zt(n)}function Ge(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Di(n){if(typeof n=="string")return n;try{return JSON.stringify(n,null,2)}catch{return""}}function qt(n){if(typeof n=="string")return n;if(n==null)return"";try{return JSON.stringify(n,null,2)}catch{return String(n)}}function $i(n){if(n.status==="error")return{result:n.result===void 0?"error":qt(n.result)};const t=qt(n.result);return t===""?{result:"No output"}:{result:"",resultPreviewMarkdown:t}}function Li(n,t){var i;const s=(t==null?void 0:t.get(n.id))??null,r=((i=n.summary)==null?void 0:i.durationMs)!==void 0?(s??n.timestamp)+n.summary.durationMs:null,a=s!==null||r!==null;if(a)return{timingRecorded:a,stepStartTime:n.timestamp,firstTokenTime:s,completedTime:r,usageProvided:!1,outputTokens:null}}function zi(n,t,s){var o;const r=n.thinkingBlocks?n.thinkingBlocks.map(c=>c.text).join(`
24
+ `):n.thinking??"",a=Li(n,s),i=(o=n.summary)==null?void 0:o.durationMs;return{index:t,kind:"message",text:"",...n.content===""?{}:{previewMarkdown:n.content},sourceSeq:t,inputDetail:n.content,...r===""?{}:{thinkingDetail:r},...a===void 0?{}:{assistantMetrics:a},timeSeconds:i===void 0?null:i/1e3,startedAt:n.timestamp}}function Ds(n,t){const s=Di(n.args),r=qt(n.result),a=$i(n);return{index:t,kind:"tool",text:n.name,...s===""?{}:{previewMarkdown:s},sourceSeq:t,callId:n.id,...s===""?{}:{inputDetail:s},...r===""?{}:{outputDetail:r},...a,isError:n.status==="error",timeSeconds:n.duration??null,startedAt:n.timestamp}}function Fi(n,t){return{index:t,kind:"user",text:"",...n.content===""?{}:{previewMarkdown:n.content},sourceSeq:t,inputDetail:n.content,opensTurn:!0,timeSeconds:0,startedAt:n.timestamp}}function Pi(n,t){const s=[n.originalCount!==void 0?`original ${n.originalCount} msgs`:"",n.compressedCount!==void 0?`compressed ${n.compressedCount} msgs`:"",n.tokensSaved!==void 0?`freed ${n.tokensSaved} tokens`:""].filter(Boolean).join(", ");return{index:t,kind:"compacted",text:"Context compressed",sourceSeq:n.seq,...s===""?{}:{outputDetail:s},timeSeconds:0,startedAt:n.timestamp}}function Bi(n){var a;const t=[],s=[];for(const i of n)i.absTime===null||!Number.isFinite(i.absTime)||(s.push(i.absTime),i.cell.kind==="tool"&&i.cell.timeSeconds!==null&&Number.isFinite(i.cell.timeSeconds)&&s.push(i.absTime+i.cell.timeSeconds*1e3));if(s.length>=2){const i=Os((Math.max(...s)-Math.min(...s))/1e3);i!==void 0&&t.push(i)}else if(s.length===1){const i=(a=n.find(c=>c.absTime===s[0]))==null?void 0:a.cell.timeSeconds,o=i!=null?Os(i):void 0;o!==void 0&&t.push(o)}const r=new Map;for(const i of n)i.toolName===void 0||i.cell.kind!=="tool"||r.set(i.toolName,(r.get(i.toolName)??0)+1);for(const[i,o]of r)t.push(o>1?`${i}×${o}`:i);return t.length===0?void 0:t.join(" ")}function $s(n,t){const s=t.groups.map(({title:r,laid:a})=>{const i=Bi(a);return{title:r,...i!==void 0?{description:i}:{},cells:a.map(o=>o.cell)}});return{turn:n,groups:s}}function Ls(n){return Math.min(...n.groups.flatMap(t=>t.cells.map(s=>s.index)),Number.POSITIVE_INFINITY)}function Hi(n){const{messages:t,compacted:s=[],ttft:r}=n,a=new Map,i=[];let o=0,c=0,d=null;const u=x=>{let g=a.get(x);return g===void 0&&(g={groups:[]},a.set(x,g)),g},p=(x,g)=>{const k=u(x).groups,y=k[k.length-1];if((y==null?void 0:y.title)==="Message"){y.laid.push(g);return}k.push({title:"Message",laid:[g]})},h=(x,g,k)=>{if(k.length===0)return;const y=u(x).groups,m=`Step ${g}`,v=y.find(_=>_.title===m);if(v!==void 0){v.laid.push(...k);return}y.push({title:m,laid:[...k]})},f=[...t.map(x=>({kind:"message",message:x})),...s.map(x=>({kind:"compacted",record:x}))].sort((x,g)=>{const k=x.kind==="message"?x.message.timestamp:x.record.timestamp,y=g.kind==="message"?g.message.timestamp:g.record.timestamp;return k-y});for(const x of f){if(x.kind==="compacted"){const m=Pi(x.record,++o);i.push({groups:[{title:`Compaction ${x.record.seq}`,laid:[{absTime:Ge(x.record.timestamp),cell:m}]}]});continue}const g=x.message;if(g.type==="user"){c+=1;const m=Fi(g,++o);p(c,{absTime:Ge(g.timestamp),cell:m});continue}const k=c>0?c:d??1,y=zi(g,++o,r);p(k,{absTime:Ge(g.timestamp),cell:y}),d=k;for(const m of g.toolCalls??[]){const v=Ds(m,++o);p(k,{absTime:Ge(m.timestamp),toolName:m.name,callId:m.id,cell:v})}for(const[m,v]of(g.steps??[]).entries()){const _=(v.toolCalls??[]).map(E=>{const I=Ds(E,++o);return{absTime:Ge(E.timestamp),toolName:E.name,callId:E.id,cell:I}});h(k,m+1,_)}}return[...[...a.entries()].map(([x,g])=>$s(x,g)),...i.map(x=>$s(null,x))].sort((x,g)=>Ls(x)-Ls(g))}function pt(n){if(n.text!=="")return n.text;if(n.previewMarkdown!==void 0){const t=ct(n.previewMarkdown);if(t!=="")return t}if(n.result!==void 0&&n.result!=="")return n.result;if(n.resultPreviewMarkdown!==void 0){const t=ct(n.resultPreviewMarkdown);if(t!=="")return t}return n.kind}function Tt(n){return Tn(n)}function An(n){return n==="tool"||n==="subtool"?2:n==="message"||n==="compacted"?1:0}function zs(n){return n!=null&&Number.isFinite(n)}function Ui(n){if(!zs(n.startedAt))return null;const t=zs(n.timeSeconds)?Math.max(0,n.timeSeconds*1e3):0;return{start:n.startedAt,end:n.startedAt+t}}function Cn(n,t="sequence"){if(t!=="sequence")return qi(n,t==="duration");const s=[],r=[];for(const a of n){const i=a.groups.flatMap(o=>o.cells.filter(c=>c.requestOnly!==!0));i.length!==0&&(a.turn!==null&&r.push({turn:a.turn,time:s.length}),s.push(...i.map((o,c)=>({start:s.length+c,end:s.length+c+1,index:o.index,isError:o.isError===!0,kind:o.kind,label:o.text,lane:An(o.kind)}))))}return s.length===0?null:{start:0,end:s.length,spans:s,turnBoundaries:r}}function qi(n,t){const s=n.flatMap(u=>{const p=u.groups.flatMap(h=>h.cells.flatMap(f=>{if(f.requestOnly===!0)return[];const x=Ui(f);return x===null?[]:[{...x,index:f.index,isError:f.isError===!0,kind:f.kind,label:f.text,lane:An(f.kind)}]}));return p.length===0?[]:[{turn:u.turn,rawSpans:p}]}),r=s.flatMap(u=>u.rawSpans);if(r.length===0)return null;const a=new Map;let i=0,o=null;for(const u of[...r].sort((p,h)=>p.start-h.start||p.end-h.end))t&&o!==null&&u.start>o&&(i+=u.start-o),a.set(u,i),o=o===null?u.end:Math.max(o,u.end);const c=[],d=[];for(const u of s){const p=u.rawSpans.map(h=>{const f=a.get(h)??0;return{...h,start:h.start-f,end:h.end-f}});c.push(...p),u.turn!==null&&d.push({turn:u.turn,time:Math.min(...p.map(h=>h.start))})}return{start:Math.min(...c.map(u=>u.start)),end:Math.max(...c.map(u=>u.end)),spans:c,turnBoundaries:d}}function Gi(n,t,s="sequence"){const r=Cn(n,s);return new Set(r==null?void 0:r.spans.filter(a=>a.start<=t.end&&a.end>=t.start).map(a=>a.index))}function Wi(n,t){return n.length===t.length&&n.every((s,r)=>s===t[r])}function Ki(n){if(n.previewMarkdown===void 0)return"";const t=ct(n.previewMarkdown);return n.text===""?t:t===""?n.text:`${n.text} · ${t}`}function Vi(n){return n.resultPreviewMarkdown===void 0?n.result??"":ct(n.resultPreviewMarkdown)}function Ji(n,t,s){const r=[...s.sourceBlocks??[],...s.outputBlocks??[]];return[n===null?"between turns":`turn ${n}`,t,s.kind,s.kind==="message"?"assistant":"",s.text,s.previewMarkdown??"",s.inputDetail??"",s.outputDetail??"",s.thinkingDetail??"",s.schemaDetail??"",s.result??"",s.resultPreviewMarkdown??"",s.callId??"",...r.flatMap(a=>[a.type,a.content,a.callId??"",a.toolName??"",a.imageAlt??""])]}class Xi{constructor(){yt(this,"entries",new Map);yt(this,"layouts")}update(t){if(this.layouts===t)return!1;this.layouts=t;const s=new Set;for(const r of t)for(const a of r)for(const i of a.groups)for(const o of i.cells){if(o.requestOnly===!0)continue;const c=Pe(o),d=Ji(a.turn,i.title,o),u=this.entries.get(c),p=u!==void 0&&Wi(u.sources,d)?u:{sources:d,text:[...d,Ki(o),Vi(o)].join(`
25
+ `).toLocaleLowerCase()};this.entries.set(c,p),s.add(c)}for(const r of this.entries.keys())s.has(r)||this.entries.delete(r);return!0}search(t){const s=t.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);if(s.length===0)return null;const r=new Set;for(const[a,i]of this.entries)s.every(o=>i.text.includes(o))&&r.add(a);return r}}const Yi=l.memo(function({actualDuration:t,onActualDurationChange:s,allTurnsCollapsed:r,onToggleAllTurns:a,allAssistantsCollapsed:i,onToggleAllAssistants:o,searchQuery:c,onSearchQueryChange:d}){const{t:u}=ee();return e.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-dark-border/40 px-2",role:"toolbar",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-surface/60","aria-pressed":t,title:u(t?"trajectory.toolbar.equalWidth":"trajectory.toolbar.actualDuration"),onClick:()=>s(!t),children:[e.jsx(Pt,{size:13}),u("trajectory.toolbar.duration")]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-surface/60","aria-pressed":r,title:u(r?"trajectory.toolbar.expandTurns":"trajectory.toolbar.collapseTurns"),onClick:a,children:[r?e.jsx(br,{size:13}):e.jsx(kr,{size:13}),u("trajectory.toolbar.turns")]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-surface/60","aria-pressed":i,title:u(i?"trajectory.toolbar.expandCalls":"trajectory.toolbar.collapseCalls"),onClick:o,children:[e.jsx(yr,{size:13}),u("trajectory.toolbar.calls")]}),e.jsx("div",{className:"ml-auto flex min-w-0 flex-1 items-center justify-end",children:e.jsxs("div",{className:"relative flex w-56 items-center",children:[e.jsx(Ze,{size:12,className:"pointer-events-none absolute left-2 text-dark-muted/50"}),e.jsx("input",{type:"search",className:"h-7 w-full rounded border border-dark-border/40 bg-dark-surface/60 pl-7 pr-2 text-xs text-dark-text outline-none placeholder:text-dark-muted/40 focus:border-accent-blue/50","aria-label":u("trajectory.toolbar.search"),placeholder:u("trajectory.toolbar.searchPlaceholder"),value:c,onChange:p=>d(p.currentTarget.value)})]})})]})}),Zi=3,Qi=500;function eo(n){const t=n==null?void 0:n.stepStartTime,s=n==null?void 0:n.firstTokenTime,r=n==null?void 0:n.completedTime;return(n==null?void 0:n.timingRecorded)!==!0||typeof t!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(t)||!Number.isFinite(s)||!Number.isFinite(r)||s<t||r<s?{}:{ttftMs:s-t,decodingMs:r-s}}function to(n){const t=n.timeSeconds===null||!Number.isFinite(n.timeSeconds)?void 0:Math.max(0,n.timeSeconds*1e3),s=n.startedAt===null||!Number.isFinite(n.startedAt)?void 0:n.startedAt;return{...t===void 0?{}:{durationMs:t},...s===void 0?{}:{startedAt:s},...eo(n.assistantMetrics)}}function so(n){switch(n){case"system":return"SYSTEM";case"user":return"USER";case"context":return"CONTEXT";case"compacted":return"COMPACTED";case"message":return"ASSISTANT";case"tool":return"TOOL";case"subtool":return"SUBTOOL"}}function At(n){const t=new Date(n),s=a=>String(a).padStart(2,"0"),r=a=>String(a).padStart(3,"0");return`${s(t.getHours())}:${s(t.getMinutes())}:${s(t.getSeconds())}.${r(t.getMilliseconds())}`}function no(n,t){const s=so(n);if(t===void 0)return s;const r=t.durationMs===void 0?null:`Total ${Tt(t.durationMs)}`,a=t.startedAt===void 0?null:t.durationMs===void 0?`Started ${At(t.startedAt)}`:`${At(t.startedAt)} → ${At(t.startedAt+t.durationMs)}`,i=t.ttftMs===void 0||t.decodingMs===void 0?null:`TTFT ${Tt(t.ttftMs)} · Decoding ${Tt(t.decodingMs)}`,o=[r,i].filter(c=>c!==null).join(" · ");return[s,a,o].filter(c=>c!==null&&c!=="").join(`
26
+ `)}function ro(n,t){return n<=t?{start:n,end:t}:{start:t,end:n}}function ao(n){return Math.min(1,Math.max(0,n))}const io=l.memo(function({turns:t,mode:s,range:r,selectedIndex:a=null,searchMatchIndexes:i=null,onRangeChange:o,onRecordSelect:c}){const d=l.useMemo(()=>Cn(t,s),[s,t]),u=l.useMemo(()=>new Map(t.flatMap(A=>A.groups.flatMap(V=>V.cells.map(C=>[C.index,to(C)])))),[t]),p=l.useMemo(()=>new Map(t.flatMap(A=>A.groups.flatMap(V=>V.cells.map(C=>[C.index,pt(C)])))),[t]),h=l.useRef(null),f=l.useRef(null),[x,g]=l.useState(null),[k,y]=l.useState(null),m=l.useRef(null),[v,_]=l.useState(null);if(l.useEffect(()=>{d!==null&&r!==null&&(r.end<d.start||r.start>d.end)&&o(null)},[d,o,r]),l.useEffect(()=>{d!==null&&_(A=>A!==null&&(A.end<d.start||A.start>d.end)?null:A)},[d]),d===null)return e.jsxs("div",{className:"traj-root","data-empty":"",children:[e.jsxs("div",{className:"traj-labels","aria-hidden":"true",children:[e.jsx("span",{children:"Input"}),e.jsx("span",{children:"Model"}),e.jsx("span",{children:"Tools"})]}),e.jsx("div",{className:"traj-track"})]});const E=Math.max(1,d.end-d.start),I=(v==null?void 0:v.start)??d.start,O=v===null?E:Math.max(1,v.end-v.start),j=A=>{const V=h.current;if(!V)return 0;const C=V.getBoundingClientRect();return ao((A-C.left)/Math.max(1,C.width))},N=A=>I+A*O,L=A=>{if(A.button===2){o(null);return}const C=A.target.closest("[data-timeline-record-index]"),z=C===null?null:Number(C.dataset.timelineRecordIndex);if(z!==null&&Number.isFinite(z)){c==null||c(z);return}f.current={pointerId:A.pointerId,anchorFraction:j(A.clientX),anchorClientX:A.clientX,recordIndex:null},A.currentTarget.setPointerCapture(A.pointerId)},R=A=>{const V=f.current;if(V!==null&&A.pointerId===V.pointerId){const F=j(A.clientX);if(Math.abs(A.clientX-V.anchorClientX)>=Zi){const D=N(V.anchorFraction),q=N(F);g(ro(D,q))}return}const C=j(A.clientX),z=A.target.closest("[data-timeline-record-index]"),Z=z===null?null:Number(z.dataset.timelineRecordIndex);m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{y({fraction:C,recordIndex:Number.isFinite(Z)?Z:null})},Qi)},T=A=>{const V=f.current;V===null||A.pointerId!==V.pointerId||(f.current=null,x!==null&&(o(x),g(null)))},U=A=>{var V;((V=f.current)==null?void 0:V.pointerId)===A.pointerId&&(f.current=null,g(null))},K=A=>{if(d===null)return;const V=j(A.clientX),C=N(V),z=A.deltaY<0?.75:1.35,Z=Math.min(E,Math.max(1,O*z)),F=Math.min(Math.max(C-Z/2,d.start),d.end-Z);_({start:F,end:F+Z})},W=l.useRef(()=>{});W.current=K,l.useEffect(()=>{const A=h.current;if(!A)return;const V=C=>{C.preventDefault(),W.current(C)};return A.addEventListener("wheel",V,{passive:!1}),()=>A.removeEventListener("wheel",V)},[d]);const X=x??r,re=k==null?void 0:k.recordIndex;return e.jsxs("div",{className:"traj-root",children:[e.jsxs("div",{className:"traj-labels","aria-hidden":"true",children:[e.jsx("span",{children:"Input"}),e.jsx("span",{children:"Model"}),e.jsx("span",{children:"Tools"})]}),e.jsxs("div",{ref:h,className:"traj-track",role:"slider","aria-label":"Trajectory timeline",tabIndex:0,onKeyDown:A=>{A.key==="Escape"&&o(null)},onPointerDown:L,onPointerMove:R,onPointerUp:T,onPointerCancel:U,onPointerLeave:()=>{m.current&&clearTimeout(m.current),m.current=null,f.current===null&&y(null)},onDoubleClick:A=>{A.preventDefault(),o(null)},onContextMenu:A=>{A.preventDefault(),o(null)},children:[k!==null&&k.recordIndex===null&&x===null&&e.jsx("div",{className:"traj-hoverLine","aria-hidden":"true",style:{"--trajectory-hover-left":`${k.fraction*100}%`}}),X!==null&&e.jsx("div",{className:"traj-selection","data-dragging":x===null?void 0:"true","aria-hidden":"true",style:{"--trajectory-selection-left":`${(X.start-I)/O*100}%`,"--trajectory-selection-width":`${(X.end-X.start)/O*100}%`}}),e.jsx("div",{className:"traj-turnBoundaries","aria-hidden":"true",children:d.turnBoundaries.filter(A=>A.time>d.start&&A.time>=I&&A.time<=I+O).map(A=>e.jsx("span",{className:"traj-turnBoundary","data-turn":A.turn,style:{"--trajectory-turn-left":`${(A.time-d.start)/E*100}%`}},A.turn))}),e.jsx("div",{className:"traj-lanes","data-timeline-domain":"",children:d.spans.filter(A=>A.index===a||A.end>=I&&A.start<=I+O).map(A=>{const V=(A.start-d.start)/E,z=(A.end-A.start)/E*100,Z=u.get(A.index),F=Z==null?void 0:Z.ttftMs,D=Z==null?void 0:Z.decodingMs,q=F===void 0||D===void 0||F+D<=0?null:F/(F+D),Y=p.get(A.index)??A.label;return e.jsx("span",{"aria-hidden":"true",className:"traj-span","data-timeline-span":A.kind,"data-timeline-record-index":A.index,"data-assistant-timing":q===null?void 0:"true","data-error":A.isError||void 0,"data-current":A.index===a||void 0,"data-hovered":re===A.index||void 0,"data-search-match":i===null?void 0:i.has(A.index)?"true":"false","data-selected":X===null?void 0:A.start<=X.end&&A.end>=X.start?"true":"false",title:no(A.kind,Z),style:{"--trajectory-span-left":`${V*100}%`,"--trajectory-span-width":`${z}%`,"--trajectory-span-lane":A.lane,...q===null?{}:{"--trajectory-assistant-ttft":`${q*100}%`}},children:Y},A.index)})})]})]})});var In=oa();function oo(n,t,s){const r=new Array(n);return new Proxy(r,{get(a,i,o){if(typeof i=="string"){const c=i.charCodeAt(0);if(c>=48&&c<=57){const d=+i;if(Number.isInteger(d)&&d>=0&&d<n){let u=a[d];if(!u){const p=t[d*2];u=a[d]={index:d,key:s(d),start:p,size:t[d*2+1],end:p+t[d*2+1],lane:0}}return u}}if(i==="length")return n}return Reflect.get(a,i,o)}})}function Le(n,t,s){let r=s.initialDeps??[],a,i=!0;function o(){const c=n();return(c.length!==r.length||c.some((u,p)=>r[p]!==u))&&(r=c,a=t(...c),s!=null&&s.onChange&&!(i&&s.skipInitialOnChange)&&s.onChange(a),i=!1),a}return o.updateDeps=c=>{r=c},o}function Fs(n,t){if(n===void 0)throw new Error("Unexpected undefined");return n}const lo=(n,t)=>Math.abs(n-t)<1.01,co=(n,t,s)=>{let r;return Object.assign(function(...a){n.clearTimeout(r),r=n.setTimeout(()=>t.apply(this,a),s)},{cancel:()=>{n.clearTimeout(r)}})};let We;const Ct=()=>{if(We!==void 0)return We;if(typeof navigator>"u")return We=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return We=!0;const n=navigator.maxTouchPoints;return We=navigator.platform==="MacIntel"&&n!==void 0&&n>0},Ps=n=>{const{offsetWidth:t,offsetHeight:s}=n;return{width:t,height:s}},uo=n=>n,po=n=>{const t=Math.max(n.startIndex-n.overscan,0),r=Math.min(n.endIndex+n.overscan,n.count-1)-t+1,a=new Array(r);for(let i=0;i<r;i++)a[i]=t+i;return a},ho=(n,t)=>{const s=n.scrollElement;if(!s)return;const r=n.targetWindow;if(!r)return;const a=o=>{const{width:c,height:d}=o;t({width:Math.round(c),height:Math.round(d)})};if(a(Ps(s)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const c=()=>{const d=o[0];if(d!=null&&d.borderBoxSize){const u=d.borderBoxSize[0];if(u){a({width:u.inlineSize,height:u.blockSize});return}}a(Ps(s))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},dt={passive:!0},mo=typeof window>"u"?!0:"onscrollend"in window,fo=(n,t,s)=>{const r=n.scrollElement;if(!r)return;const a=n.targetWindow;if(!a)return;const i=n.options.useScrollendEvent&&mo;let o=0;const c=i?null:co(a,()=>t(o,!1),n.options.isScrollingResetDelay),d=h=>()=>{o=s(r),c==null||c(),t(o,h)},u=d(!0),p=d(!1);return r.addEventListener("scroll",u,dt),i&&r.addEventListener("scrollend",p,dt),()=>{r.removeEventListener("scroll",u),i&&r.removeEventListener("scrollend",p),c==null||c.cancel()}},xo=(n,t)=>fo(n,t,s=>{const{horizontal:r,isRtl:a}=n.options;return r?s.scrollLeft*(a&&-1||1):s.scrollTop}),go=(n,t,s)=>{if(s.options.useCachedMeasurements){const r=s.indexFromElement(n),a=s.options.getItemKey(r);return s.itemSizeCache.get(a)??s.options.estimateSize(r)}if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=s.indexFromElement(n),a=s.options.getItemKey(r),i=s.itemSizeCache.get(a);if(i!==void 0)return i}return n[s.options.horizontal?"offsetWidth":"offsetHeight"]},bo=(n,{adjustments:t=0,behavior:s},r)=>{var a,i;(i=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||i.call(a,{[r.options.horizontal?"left":"top"]:n+t,behavior:s})},ko=bo;class yo{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var s,r,a;return((a=(r=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let s=null;const r=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(a=>{a.forEach(i=>{const o=()=>{const c=i.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[u,p]of this.elementsCache)if(p===c){this.elementsCache.delete(u);break}return}this.isIndexInRange(d)&&this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),s=null},observe:a=>{var i;return(i=r())==null?void 0:i.observe(a,{box:"border-box"})},unobserve:a=>{var i;return(i=r())==null?void 0:i.unobserve(a)}}})(),this.range=null,this.setOptions=s=>{var r,a;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:uo,rangeExtractor:po,onChange:()=>{},measureElement:go,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const f in s){const x=s[f];x!==void 0&&(i[f]=x)}const o=this.options;let c=null,d=null,u=!1;if(o!==void 0&&o.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const f=o.count,x=i.count,g=this.getMeasurements(),k=f>0?((r=g[0])==null?void 0:r.key)??o.getItemKey(0):null,y=f>0?((a=g[f-1])==null?void 0:a.key)??o.getItemKey(f-1):null;if(x!==f||f>0&&x>0&&(i.getItemKey(0)!==k||i.getItemKey(x-1)!==y)){u=!0;const _=f>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;_&&(c=[_.key,this.getScrollOffset()-_.start]);const E=i.followOnAppend===!0?"auto":i.followOnAppend||null;E&&x>f&&this.isAtEnd(o.scrollEndThreshold)&&(f===0||i.getItemKey(x-1)!==y)&&(d=E)}}this.options=i,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let p=!1,h=0;if(c&&this.scrollOffset!==null){const[f,x]=c,g=this.getMeasurements(),{count:k,getItemKey:y}=this.options;let m=0;for(;m<k&&y(m)!==f;)m++;if(m<k){const v=g[m];if(v){const _=Math.max(0,v.start+x);_!==this.scrollOffset&&(h=_-this.scrollOffset,this.scrollOffset=_,p=!0)}}}(p||d)&&(this.pendingScrollAnchor=[p?c[0]:null,p?c[1]:0,d,h])},this.notify=s=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,s)},this.maybeNotify=Le(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,o)=>{if(o&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=o?c===i?this.scrollDirection:c<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!Ct()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",o,dt),i.addEventListener("touchend",c,dt),this.unsubs.push(()=>{i.removeEventListener("touchstart",o),i.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const a=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,a&&this.scrollElement&&this.options.enabled){const[i,o,c,d]=a;i!==null&&!c&&(Ct()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const s=this.getScrollOffset(),r=this.getMaxScrollOffset();if(s<0||s>r)return;if(this._iosDeferredAdjustment<0&&s>=r-1){this._iosDeferredAdjustment=0;return}const a=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=a,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Le(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,r,a,i,o,c,d,u)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:s,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:c,laneAssignmentMode:d,gap:u}),{key:!1}),this.isIndexInRange=s=>s>=0&&s<this.options.count,this.getMeasurements=Le(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:c,laneAssignmentMode:d,gap:u},p)=>{const h=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const m of this.laneAssignments.keys())m>=s&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),c===1){const m=s*2;let v=this._flatMeasurements;if(!v||v.length<m){const I=new Float64Array(m);v&&f>0&&I.set(v.subarray(0,f*2)),v=I,this._flatMeasurements=v}let _;if(f===0)_=r+a;else{const I=f-1;_=v[I*2]+v[I*2+1]+u}for(let I=f;I<s;I++){const O=i(I),j=h.get(O),N=typeof j=="number"?j:this.options.estimateSize(I);v[I*2]=_,v[I*2+1]=N,_+=N+u}const E=oo(s,v,i);return this.measurementsCache=E,E}const x=this.measurementsCache.slice(0,f),g=new Array(c).fill(void 0),k=new Float64Array(c);let y=0;for(let m=0;m<f;m++){const v=x[m];v&&(g[v.lane]===void 0&&y++,g[v.lane]=m,k[v.lane]=v.end)}for(let m=f;m<s;m++){const v=i(m),_=this.laneAssignments.get(m);let E,I;const O=d==="estimate"||h.has(v);if(_!==void 0&&this.options.lanes>1){E=_;const R=g[E],T=R!==void 0?x[R]:void 0;I=T?T.end+u:r+a}else if(y===c){let R=0,T=k[0],U=g[0];for(let K=1;K<c;K++){const W=k[K];(W<T||W===T&&g[K]<U)&&(R=K,T=W,U=g[K])}E=R,I=T+u,O&&this.laneAssignments.set(m,E)}else E=m%this.options.lanes,I=r+a,O&&this.laneAssignments.set(m,E);const j=h.get(v),N=typeof j=="number"?j:this.options.estimateSize(m),L=I+N;x[m]={index:m,start:I,size:N,end:L,key:v,lane:E},g[E]===void 0&&y++,g[E]=m,k[E]=L}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Le(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,r,a,i)=>s.length===0||r===0?(this.range=null,null):(this.range=wo(s,r,a,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Le(()=>{let s=null,r=null;const a=this.calculateRange();return a&&(s=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,r]},(s,r,a,i,o)=>i===null||o===null?[]:s({startIndex:i,endIndex:o,overscan:r,count:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const r=this.options.indexAttribute,a=s.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,a-i),c=Math.min(this.options.count-1,a+i);return s>=o&&s<=c}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((o,c)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(c))});return}const r=this.indexFromElement(s);if(!this.isIndexInRange(r))return;const a=this.options.getItemKey(r),i=this.elementsCache.get(a);i!==s&&(i&&this.observer.unobserve(i),this.observer.observe(s),this.elementsCache.set(a,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,r)=>{var a,i;if(!this.isIndexInRange(s))return;let o,c,d;const u=this._flatMeasurements;if(this.options.lanes===1&&u!==null)d=this.options.getItemKey(s),c=u[s*2],o=u[s*2+1];else{const f=this.measurementsCache[s];if(!f)return;d=f.key,c=f.start,o=f.size}const p=this.itemSizeCache.get(d)??o,h=r-p;if(h!==0){const f=this.options.anchorTo==="end"&&((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,x=f?this.getTotalSize():0,g=this.getScrollOffset()+this.scrollAdjustments,y=!this.itemSizeCache.has(d)?c<g:c+p<=g&&this.scrollDirection!=="backward",m=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:d,start:c,size:o,end:c+o,lane:0},h,this):y);(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(d,r),this.itemSizeCacheVersion++;let v=!1;f?v=this.applyScrollAdjustment(this.getTotalSize()-x):m&&(v=this.applyScrollAdjustment(h)),this.notify(v)}},this.getVirtualItems=Le(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,r)=>{const a=[];for(let i=0,o=s.length;i<o;i++){const c=s[i],d=r[c];a.push(d)}return a},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const r=this.getMeasurements();if(r.length===0)return;const a=this._flatMeasurements,i=this.options.lanes===1&&a!=null,o=Rn(0,r.length-1,i?c=>a[c*2]:c=>Fs(r[c]).start,s);return Fs(r[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,r,a=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=s>=o+i?"end":"start"),r==="center"?s+=(a-i)/2:r==="end"&&(s-=i);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,r="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const a=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[s];if(!o)return;if(r==="auto")if(o.end>=i+a-this.options.scrollPaddingEnd)r="end";else if(o.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),r];const c=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,r,o.size),r]},this.scrollToOffset=(s,{align:r="start",behavior:a="auto"}={})=>{this._iosDeferredAdjustment=0;const i=this.getOffsetForAlignment(s,r),o=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:r="auto",behavior:a="auto"}={})=>{this._iosDeferredAdjustment=0,s=Math.max(0,Math.min(s,this.options.count-1));const i=this.getOffsetForIndex(s,r);if(!i)return;const[o,c]=i,d=this.now();this.scrollState={index:s,align:c,behavior:a,startedAt:d,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+s,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1){const i=r.length-1,o=this._flatMeasurements;o!=null?a=o[i*2]+o[i*2+1]:a=((s=r[i])==null?void 0:s.end)??0}else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(c=>c===null);){const c=r[o];i[c.lane]===null&&(i[c.lane]=c.end),o--}a=Math.max(...i.filter(c=>c!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const r=this.getMeasurements();for(const a of r)a&&this.itemSizeCache.has(a.key)&&s.push({index:a.index,key:a.key,start:a.start,size:a.size,end:a.end,lane:a.lane});return s},this._scrollToOffset=(s,{adjustments:r,behavior:a})=>{this._intendedScrollOffset=s+(r??0),this.options.scrollToFn(s,{behavior:a,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,s){return t===0?!1:Ct()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=t,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:s}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,i=1,o=a!==this.scrollState.lastTargetOffset;if(!o&&lo(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==a&&this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const c=this.getSize()||600,d=Math.abs(a-this.getScrollOffset()),u=this.scrollState.behavior==="smooth"&&d>c;this.scrollState.lastTargetOffset=a,u||(this.scrollState.behavior="auto"),this._scrollToOffset(a,{adjustments:void 0,behavior:u?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Rn=(n,t,s,r)=>{for(;n<=t;){const a=(n+t)/2|0,i=s(a);if(i<r)n=a+1;else if(i>r)t=a-1;else return a}return n>0?n-1:0};function vo(n,t,s){let r=0;for(;r<=t;){const a=(r+t)/2|0,i=n[a*2];if(i<s)r=a+1;else if(i>s)t=a-1;else return a}return r>0?r-1:0}function wo(n,t,s,r,a){const i=n.length-1;if(n.length<=r)return{startIndex:0,endIndex:i};if(r===1&&a!==null){const u=vo(a,i,s);let p=u;const h=s+t;for(;p<i&&a[p*2]+a[p*2+1]<h;)p++;return{startIndex:u,endIndex:p}}let c=Rn(0,i,u=>n[u].start,s),d=c;if(r===1)for(;d<i&&n[d].end<s+t;)d++;else if(r>1){const u=Array(r).fill(0);for(;d<i&&u.some(h=>h<s+t);){const h=n[d];u[h.lane]=h.end,d++}const p=Array(r).fill(s+t);for(;c>=0&&p.some(h=>h>=s);){const h=n[c];p[h.lane]=h.start,c--}c=Math.max(0,c-c%r),d=Math.min(i,d+(r-1-d%r))}return{startIndex:c,endIndex:d}}const It=typeof document<"u"?l.useLayoutEffect:l.useEffect;function jo({useFlushSync:n=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...r}){const a=l.useReducer(p=>p+1,0)[1],i=l.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=t,i.current.mode=s;const o=p=>{const h=i.current;if(!h.enabled||!h.container)return;const f=p.getTotalSize();if(f!==h.lastSize){h.lastSize=f;const x=p.options.horizontal?"width":"height";h.container.style[x]=`${f}px`}},c=p=>{const h=i.current;if(!h.enabled||!h.container)return;o(p);const f=!!p.options.horizontal,x=h.mode==="transform",g=f?"left":"top",k=p.options.scrollMargin,y=p.getVirtualItems();for(const m of y){const v=m.start-k,_=p.elementsCache.get(m.key);_&&h.lastPositions.get(_)!==v&&(h.lastPositions.set(_,v),x?_.style.transform=f?`translate3d(${v}px, 0, 0)`:`translate3d(0, ${v}px, 0)`:_.style[g]=`${v}px`)}},d={...r,onChange:(p,h)=>{var f;const x=i.current;let g=!0;if(x.enabled){c(p);const k=p.range,y=x.prevRange;g=!y||y.isScrolling!==p.isScrolling||y.startIndex!==(k==null?void 0:k.startIndex)||y.endIndex!==(k==null?void 0:k.endIndex),g&&(x.prevRange=k?{startIndex:k.startIndex,endIndex:k.endIndex,isScrolling:p.isScrolling}:null)}g&&(n&&h?In.flushSync(a):a()),(f=r.onChange)==null||f.call(r,p,h)}},[u]=l.useState(()=>{const p=new yo(d);return Object.assign(p,{containerRef:h=>{const f=i.current;if(f.container=h,f.lastSize=null,h&&f.enabled){const x=p.getTotalSize();f.lastSize=x;const g=p.options.horizontal?"width":"height";h.style[g]=`${x}px`}}})});return u.setOptions(d),It(()=>u._didMount(),[]),It(()=>(o(u),u._willUpdate())),It(()=>{c(u)}),u}function No(n){return jo({observeElementRect:ho,observeElementOffset:xo,scrollToFn:ko,...n})}const So=30,Eo=20,To=9;function ut(n){const t=encodeURIComponent(Pe(n.cell));return n.collapsedSummaryKind===void 0?t:`${t}\0summary\0${n.collapsedSummaryKind}`}function Ao(n){const t=[];let s=[];for(const[r,a]of n.entries()){const i={logicalIndex:r,record:a};if(a.cell.requestOnly===!0){s.push(i);continue}const o=[...s,i];s=[],t.push({entries:o,height:a.collapsedSummaryKind===void 0?So:Eo,key:ut(a)})}return s.length>0&&t.push({entries:s,height:To,key:s.map(r=>ut(r.record)).join("|")}),t}const Co=["Input","Output","Think","Time"],Io=l.memo(function({turn:t}){return e.jsxs("div",{className:"sticky top-0 z-10 flex h-[26px] items-center border-b border-dark-border/40 bg-dark-surface/95 px-2 backdrop-blur",children:[e.jsxs("span",{className:"text-[11px] font-semibold text-dark-text",children:["Turn ",t]}),e.jsx("div",{className:"ml-auto flex items-center gap-3 pr-1 text-[10px] text-dark-muted/50","aria-hidden":"true",children:Co.map(s=>e.jsx("span",{className:"w-12 text-right",children:s},s))})]})}),Ro=l.memo(function({title:t,description:s}){return e.jsxs("div",{className:"flex h-[22px] items-center gap-2 px-2 text-[11px]",children:[e.jsx("span",{className:"font-medium text-dark-muted",children:t}),s!==void 0&&s!==""&&e.jsx("span",{className:"truncate text-dark-muted/50",children:s})]})}),_o={system:"System",user:"User",context:"Context",compacted:"Compacted",message:"Message",tool:"Tool",subtool:"Sub"},Mo={system:"bg-dark-surface text-dark-muted border-dark-border/40",user:"bg-accent-blue/10 text-accent-blue border-accent-blue/30",context:"bg-dark-surface text-dark-muted border-dark-border/40",compacted:"bg-amber-500/10 text-amber-500 border-amber-500/30",message:"bg-accent-green/10 text-accent-green border-accent-green/30",tool:"bg-accent-purple/10 text-accent-purple border-accent-purple/30",subtool:"bg-dark-surface text-dark-muted border-dark-border/40"},Oo=l.memo(function({cell:t,selected:s=!1,onClick:r}){const{index:a,kind:i,timeSeconds:o,input:c,output:d,think:u}=t,p=pt(t),h=i==="message";return e.jsxs("div",{className:["flex h-[30px] items-center gap-2 border-b border-dark-border/20 px-2 text-xs cursor-pointer select-none",s?"bg-accent-blue/10":"hover:bg-dark-surface/40"].join(" "),"data-kind":i,"data-selected":s||void 0,onClick:()=>r==null?void 0:r(a),children:[e.jsxs("span",{className:"w-10 shrink-0 text-right tabular-nums text-dark-muted/50",children:["#",a]}),e.jsx("span",{className:"w-[74px] shrink-0",children:e.jsx("span",{className:["inline-block rounded border px-1 py-px text-[10px] leading-none",Mo[i]].join(" "),children:_o[i]})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-dark-text",title:p,children:p}),e.jsxs("span",{className:"flex shrink-0 items-center gap-2 tabular-nums text-dark-muted/60",children:[h&&e.jsxs(e.Fragment,{children:[c!==void 0&&e.jsx("span",{title:"Input tokens",children:c}),d!==void 0&&e.jsx("span",{title:"Output tokens",children:d}),u!==void 0&&e.jsx("span",{title:"Reasoning tokens",children:u})]}),e.jsx("span",{className:"w-16 text-right",children:Zt(o)})]})]})}),Do=100,$o=12,Lo=600,zo=2;function Fo(n){const t=l.useRef({rows:[],structure:[]});if(t.current.rows===n)return t.current.structure;const s=t.current.structure.length===n.length&&n.every((r,a)=>{const i=t.current.structure[a];return(i==null?void 0:i.key)===r.key&&i.height===r.height})?t.current.structure:n.map(r=>({key:r.key,height:r.height}));return t.current={rows:n,structure:s},s}function Po(n){const t=[];for(const s of n){const r=[];for(const a of s.groups)a.cells.forEach((i,o)=>{r.push({turn:s.turn,group:a.title,groupDescription:a.description,groupStart:o===0,turnStart:r.length===0,cell:i,turnEnd:!1})});if(r.length>0){const a=r[r.length-1];a&&(a.turnEnd=!0)}t.push(...r)}return t}function Bo(n,t){const s=[];let r=[],a=null;const i=()=>{if(r.length!==0){if(a!==null&&t.has(a)){const o=r.filter(d=>d.cell.requestOnly!==!0&&d.cell.kind!=="system"),c=r[0];s.push({...c,groupStart:!0,turnStart:!0,turnEnd:!0,collapsedSummary:`Turn ${a} · ${o.length} records`,collapsedSummaryKind:"turn",cell:{...c.cell,index:c.cell.index}})}else s.push(...r);r=[],a=null}};for(const o of n)o.turnStart&&i(),a=o.turn,r.push(o);return i(),s}function Ho(n,t){var a;const s=[];let r=0;for(;r<n.length;){const i=n[r],o=n[r+1];if(i.cell.kind==="message"&&o!==void 0&&(o.cell.kind==="tool"||o.cell.kind==="subtool")&&t.has(Pe(i.cell))){let c=r+1;for(;c<n.length&&(n[c].cell.kind==="tool"||n[c].cell.kind==="subtool");)c+=1;const d=c-r-1;s.push({...i,groupStart:!0,turnEnd:((a=n[c-1])==null?void 0:a.turnEnd)??i.turnEnd,collapsedSummary:`${pt(i.cell)||"Message"} · ${d} tool call${d>1?"s":""}`,collapsedSummaryKind:"assistant"}),r=c;continue}s.push(i),r+=1}return s}function Uo(n,t){const s=[];let r=null,a=null;for(const i of n)i.turnStart&&(r=i),i.groupStart&&(a=i),t.has(i.cell.index)&&(r!==null&&s.length===0&&(s.push({...r,groupStart:!0,turnStart:!0}),r=null),a!==null&&s.length>0&&s[s.length-1].group!==i.group&&(s.push({...a,groupStart:!0,turnStart:!1}),a=null),s.push(i));return s}function Rt(n){if(n===null||!Number.isFinite(n))return"Not available";const t=new Date(n),s=o=>String(o).padStart(2,"0"),r=o=>String(o).padStart(3,"0"),a=`${s(t.getHours())}:${s(t.getMinutes())}:${s(t.getSeconds())}.${r(t.getMilliseconds())}`;return`${`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())}`} ${a}`}function qo(n){const t=[{id:"overview",label:"Summary"}];return n.inputDetail!==void 0&&n.inputDetail!==""&&t.push({id:"input",label:"Input"}),n.outputDetail!==void 0&&n.outputDetail!==""&&t.push({id:"output",label:"Output"}),n.thinkingDetail!==void 0&&n.thinkingDetail!==""&&t.push({id:"thinking",label:"Thinking"}),n.assistantMetrics!==void 0&&t.push({id:"timing",label:"Timing"}),(n.input!==void 0||n.output!==void 0||n.think!==void 0)&&t.push({id:"usage",label:"Usage"}),t}function Go({cell:n,onClose:t}){var c;const s=qo(n),[r,a]=l.useState(((c=s[0])==null?void 0:c.id)??"overview"),i=pt(n),o=()=>{switch(r){case"overview":return e.jsxs("dl",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-20 shrink-0",children:"Kind"}),e.jsx("dd",{className:"traj-detailValue",children:n.kind})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-20 shrink-0",children:"Index"}),e.jsxs("dd",{className:"traj-detailValue",children:["#",n.index]})]}),n.callId!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-20 shrink-0",children:"Call ID"}),e.jsx("dd",{className:"traj-detailValue break-all",children:n.callId})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-20 shrink-0",children:"Duration"}),e.jsx("dd",{className:"traj-detailValue",children:Zt(n.timeSeconds)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-20 shrink-0",children:"Started"}),e.jsx("dd",{className:"traj-detailValue",children:Rt(n.startedAt??null)})]}),n.isError===!0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-20 shrink-0",children:"Status"}),e.jsx("dd",{className:"traj-detailValue text-red-400",children:"error"})]}),i!==""&&e.jsxs("div",{className:"pt-1",children:[e.jsx("dt",{className:"traj-detailKey mb-1",children:"Summary"}),e.jsx("dd",{className:"traj-detailBody",children:i})]})]});case"input":return e.jsx("div",{className:"traj-detailBody",children:n.inputDetail});case"output":return e.jsx("div",{className:"traj-detailBody",children:n.outputDetail});case"thinking":return e.jsx("div",{className:"traj-detailBody",children:n.thinkingDetail});case"timing":{const d=n.assistantMetrics;if(!d)return null;const u=d.firstTokenTime!==null&&d.stepStartTime!==null?d.firstTokenTime-d.stepStartTime:null,p=d.completedTime!==null&&d.firstTokenTime!==null?d.completedTime-d.firstTokenTime:null;return e.jsxs("dl",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-24 shrink-0",children:"Step start"}),e.jsx("dd",{className:"traj-detailValue",children:Rt(d.stepStartTime)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-24 shrink-0",children:"First token"}),e.jsx("dd",{className:"traj-detailValue",children:Rt(d.firstTokenTime)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-24 shrink-0",children:"TTFT"}),e.jsx("dd",{className:"traj-detailValue",children:u===null?"—":`${u} ms`})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-24 shrink-0",children:"Decoding"}),e.jsx("dd",{className:"traj-detailValue",children:p===null?"—":`${p} ms`})]})]})}case"usage":return e.jsxs("dl",{className:"space-y-1.5",children:[n.input!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-24 shrink-0",children:"Input"}),e.jsx("dd",{className:"traj-detailValue",children:n.input})]}),n.output!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-24 shrink-0",children:"Output"}),e.jsx("dd",{className:"traj-detailValue",children:n.output})]}),n.think!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"traj-detailKey w-24 shrink-0",children:"Reasoning"}),e.jsx("dd",{className:"traj-detailValue",children:n.think})]}),n.input===void 0&&n.output===void 0&&n.think===void 0&&e.jsx("div",{className:"traj-detailValue",children:"Token usage not reported by provider yet."})]});default:return null}};return e.jsxs("div",{className:"flex h-full w-[360px] shrink-0 flex-col border-l border-dark-border/40 bg-dark-surface/40",children:[e.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b border-dark-border/40 px-3",children:[e.jsxs("span",{className:"text-xs font-medium text-dark-text",children:["Record #",n.index]}),e.jsx("button",{type:"button",className:"rounded p-1 text-dark-muted hover:bg-dark-surface/60",onClick:t,"aria-label":"Close details",children:e.jsx(Ae,{size:14})})]}),e.jsx("div",{className:"flex shrink-0 flex-wrap gap-1 border-b border-dark-border/40 px-2 py-1.5",children:s.map(d=>e.jsx("button",{type:"button",className:"traj-detailTab","data-active":r===d.id||void 0,onClick:()=>a(d.id),children:d.label},d.id))}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:o()})]})}function Wo({turns:n,searchMatchIndexes:t=null,selectedIndex:s,onSelectIndex:r,onDeselect:a,onClearSelection:i,collapsedTurns:o,onToggleTurn:c,collapsedAssistants:d,onToggleAssistant:u}){var R;const p=l.useRef(null),h=l.useMemo(()=>Po(n),[n]),f=l.useMemo(()=>s===null?void 0:h.find(T=>T.cell.index===s),[h,s]),x=l.useMemo(()=>{if(t!==null)return Uo(h,t);const T=o.size===0?h:Bo(h,o);return d.size===0?T:Ho(T,d)},[h,d,o,t]),g=l.useMemo(()=>Ao(x),[x]),k=Fo(g),y=x.length>Do,m=l.useCallback(T=>{var U;return((U=k[T])==null?void 0:U.height)??30},[k]),v=l.useCallback(T=>{var U;return((U=k[T])==null?void 0:U.key)??T},[k]),_=l.useCallback(()=>p.current,[]),E=No({count:y?k.length:0,enabled:y,estimateSize:m,getItemKey:v,getScrollElement:_,initialRect:{width:0,height:Lo},anchorTo:"end",overscan:$o,scrollEndThreshold:zo}),I=y?E.getVirtualItems():[],O=((R=I[0])==null?void 0:R.start)??0,j=y?E.getTotalSize():0,N=T=>{r(T)},L=T=>T.collapsedSummary!==void 0?e.jsxs("div",{className:"flex h-[20px] cursor-pointer items-center gap-2 px-2 text-xs text-dark-muted hover:bg-dark-surface/40",onClick:()=>{T.collapsedSummaryKind==="turn"&&T.turn!==null?c(T.turn):T.collapsedSummaryKind==="assistant"&&u(Pe(T.cell))},children:[e.jsx("span",{className:"text-dark-muted/50",children:"▸"}),e.jsx("span",{className:"truncate",children:T.collapsedSummary})]}):e.jsxs(e.Fragment,{children:[T.turnStart&&T.turn!==null&&e.jsx(Io,{turn:T.turn}),T.groupStart&&e.jsx(Ro,{title:T.group,description:T.groupDescription}),e.jsx(Oo,{cell:T.cell,selected:s===T.cell.index,onClick:N})]});return e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{ref:p,className:"min-w-0 flex-1 overflow-auto",onClick:T=>{T.target===T.currentTarget&&(i==null||i())},children:y?e.jsx("div",{style:{height:j,position:"relative"},children:I.map(T=>{const U=g[T.index];return U?e.jsx("div",{"data-virtual-row-key":U.key,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${T.start-O}px)`,height:U.height},children:U.entries.map(K=>e.jsx("div",{children:L(K.record)},ut(K.record)))},U.key):null})}):x.map(T=>e.jsx("div",{children:L(T)},ut(T)))}),f!==void 0&&e.jsx(Go,{cell:f.cell,onClose:a},f.cell.index)]})}const Ko=new Set,Vo=new Set,Jo=3e3;function Xo({sessionId:n,messages:t}){const[s,r]=l.useState(Ko),[a,i]=l.useState(Vo),[o,c]=l.useState(null),[d,u]=l.useState(!1),[p,h]=l.useState(""),[f]=l.useState(()=>new Xi),[x,g]=l.useState(0),k=l.useRef(null),y=l.useRef(!1),[m,v]=l.useState(null),_=os(D=>D.compactedBySession[n]??Yo),E=os(D=>D.ttftBySession[n]),I=l.useMemo(()=>{if(E!==void 0)return new Map(Object.entries(E))},[E]),O=l.useMemo(()=>Hi({messages:t,compacted:_,ttft:I}),[t,_,I]),j=d?"duration":"sequence";l.useEffect(()=>(k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{f.update([O]),g(D=>D+1),y.current=!0},y.current?Jo:0),()=>{k.current&&clearTimeout(k.current)}),[O,f]);const N=l.useMemo(()=>p.trim()===""?null:f.search(p),[p,x]),L=l.useMemo(()=>{if(N===null)return null;const D=new Set;for(const q of O)for(const Y of q.groups)for(const ae of Y.cells)N.has(Pe(ae))&&D.add(ae.index);return D},[O,N]),R=l.useMemo(()=>o===null?null:Gi(O,o,j),[O,j,o]),T=l.useMemo(()=>O.filter(D=>D.turn!==null&&D.groups.reduce((q,Y)=>q+Y.cells.filter(ae=>ae.requestOnly!==!0&&ae.kind!=="system").length,0)>1).flatMap(D=>D.turn===null?[]:[D.turn]),[O]),U=T.length>0&&T.every(D=>s.has(D)),K=l.useMemo(()=>{const D=[];for(const q of O){const Y=q.groups.flatMap(ae=>ae.cells);for(let ae=0;ae<Y.length;ae++){const ne=Y[ae];if((ne==null?void 0:ne.kind)!=="message")continue;const de=Y[ae+1];((de==null?void 0:de.kind)==="tool"||(de==null?void 0:de.kind)==="subtool")&&D.push(Pe(ne))}}return D},[O]),W=K.length>0&&K.every(D=>a.has(D)),X=l.useCallback(D=>{r(q=>{const Y=new Set(q);return Y.has(D)?Y.delete(D):Y.add(D),Y})},[]),re=l.useCallback(()=>{r(D=>{const q=new Set(D);if(U)for(const Y of T)q.delete(Y);else for(const Y of T)q.add(Y);return q})},[U,T]),A=l.useCallback(D=>{i(q=>{const Y=new Set(q);return Y.has(D)?Y.delete(D):Y.add(D),Y})},[]),V=l.useCallback(()=>{i(D=>{const q=new Set(D);if(W)for(const Y of K)q.delete(Y);else for(const Y of K)q.add(Y);return q})},[W,K]),C=l.useCallback(D=>{c(D)},[]),z=l.useCallback(D=>{R!==null&&!R.has(D)&&c(null),v(q=>q===D?null:D)},[R]),Z=l.useCallback(()=>{v(null)},[]),F=l.useCallback(()=>{c(null),v(null)},[]);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-conversation-composer-overlay":"",children:[e.jsx(Yi,{actualDuration:d,onActualDurationChange:D=>{u(D),c(null)},allTurnsCollapsed:U,onToggleAllTurns:re,allAssistantsCollapsed:W,onToggleAllAssistants:V,searchQuery:p,onSearchQueryChange:h}),e.jsx(io,{turns:O,mode:j,range:o,selectedIndex:m,searchMatchIndexes:L,onRangeChange:C,onRecordSelect:z}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx(Wo,{turns:O,searchMatchIndexes:L,selectedIndex:m,onSelectIndex:z,onDeselect:Z,onClearSelection:F,collapsedTurns:s,onToggleTurn:X,collapsedAssistants:a,onToggleAssistant:A})})]})}const Yo=[],Zo={plan:"border-accent-blue/30 text-accent-blue bg-accent-blue/10","auto-plan":"border-accent-cyan/30 text-accent-cyan bg-accent-cyan/10",act:"border-accent-green/30 text-accent-green bg-accent-green/10","auto-act":"border-accent-yellow/30 text-accent-yellow bg-accent-yellow/10",goal:"border-accent-purple/30 text-accent-purple bg-accent-purple/10","auto-goal":"border-accent-red/30 text-accent-red bg-accent-red/10",normal:"border-accent-green/30 text-accent-green"},Qo=l.memo(function(){const{t}=ee(),s=Ie(d=>d.mode),r=Ie(d=>d.setBaseMode),a=Ie(d=>d.toggleAuto),i=s==="normal"?"act":s,o=at(i),c=Ht(i);return e.jsxs("div",{className:"flex items-center gap-1",children:[Jr.map(d=>{const u=o===d,p=Xr[d],h=s!=="normal"&&u?Zo[s]??"border-dark-border text-dark-muted":"border-dark-border text-dark-muted hover:bg-dark-hover";return e.jsx("button",{type:"button",onClick:()=>r(d),className:le("px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",h),title:t("chat.clickToSwitchMode"),"aria-pressed":u,children:p.label},d)}),e.jsxs("button",{type:"button",role:"switch","aria-checked":c,onClick:()=>a(),className:le("flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",c?"border-accent-yellow/40 text-accent-yellow bg-accent-yellow/10":"border-dark-border text-dark-muted hover:bg-dark-hover"),title:t("plan.autoApprove"),children:[e.jsx(Xe,{size:11,className:le(c?"text-accent-yellow":"text-dark-muted")}),e.jsx("span",{children:t("plan.autoApprove")})]})]})}),Bs={off:{labelKey:"chat.effortOff",color:"text-dark-muted"},low:{labelKey:"chat.effortLow",color:"text-accent-green"},medium:{labelKey:"chat.effortMedium",color:"text-accent-yellow"},high:{labelKey:"chat.effortHigh",color:"text-accent-red"},extra_high:{labelKey:"chat.effortExtraHigh",color:"text-accent-purple"},max:{labelKey:"chat.effortMax",color:"text-accent-blue"}},el=l.memo(function(){const{t}=ee(),s=Ve(S=>S.model),r=Ve(S=>S.modelRef),a=Ve(S=>S.setModel),i=Ve(S=>S.setModelRef),o=Ie(S=>S.mode),c=lt(S=>S.effort),d=lt(S=>S.setEffort),[u,p]=l.useState([]),[h,f]=l.useState(!1),x=l.useRef(null),[g,k]=l.useState("global"),y=an(S=>S.activeSessionId),[m,v]=l.useState(!1),[_,E]=l.useState(""),[I,O]=l.useState(""),[j,N]=l.useState([]),[L,R]=l.useState(new Set),[T,U]=l.useState("none"),[K,W]=l.useState(!1),[X,re]=l.useState(null),[A,V]=l.useState(null),C=l.useMemo(()=>Array.from(new Set(u.map(S=>S.provider))),[u]),z=l.useCallback(async()=>{try{const S=await ge.models.list();S.success&&S.data&&Array.isArray(S.data.models)&&p(S.data.models.filter(te=>te.enabled!==!1))}catch{}},[]),Z=l.useCallback(()=>{var te,H;const S=Yr(r)||((te=u.find(be=>be.isGlobalDefault))==null?void 0:te.provider)||((H=u[0])==null?void 0:H.provider)||"";E(S),O(""),re(null),v(!0)},[r,u]),F=l.useCallback(()=>{v(!1),N([]),re(null)},[]),D=l.useCallback(async(S,te)=>{if(S){W(!0),re(null);try{const H=await ge.models.byProvider(S,te||void 0);H.success&&H.data?(N(H.data.models||[]),R(new Set(H.data.existing||[])),U(H.data.source)):(N([]),R(new Set),re(H.error||t("chat.loadModelsFailed")))}catch{N([]),R(new Set),re(t("chat.loadModelsFailed"))}finally{W(!1)}}},[t]);l.useEffect(()=>{if(!m)return;const S=setTimeout(()=>{D(_,I)},I?300:0);return()=>clearTimeout(S)},[m,_,I,D]),l.useEffect(()=>{z()},[z]),l.useEffect(()=>{const S=()=>{z()};return window.addEventListener("models-updated",S),()=>window.removeEventListener("models-updated",S)},[z]);const q=l.useCallback(()=>f(!1),[]);l.useEffect(()=>{if(!h)return;const S=H=>{x.current&&!x.current.contains(H.target)&&q()},te=H=>{H.key==="Escape"&&q()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",te)}},[h,q]);const Y=async S=>{if(q(),g==="session"){if(!y)return;try{(await ge.models.setSessionModel(y,S.provider,S.id)).success&&(a(S.id),i(`${S.provider}:${S.id}`))}catch{}return}const te=at(o==="normal"?"act":o),H=`${S.provider}:${S.id}`,be=te==="plan"?{plan:H}:te==="goal"?{goal:H}:{global:H,act:H};try{(await ge.models.setDefaults(be)).success&&(a(S.id),i(`${S.provider}:${S.id}`),await z())}catch{}},ae=async S=>{const te=L.has(S.id),H=`${_}:${S.id}`;V(S.id);try{if(!te){const Be=await ge.models.create({provider:_,model:{id:S.id,name:S.name||S.id}});if(!Be.success){re(Be.error||t("chat.addModelFailed"));return}}const be=at(o==="normal"?"act":o),xe=be==="plan"?{plan:H}:be==="goal"?{goal:H}:{global:H,act:H},et=await ge.models.setDefaults(xe);et.success?(a(S.id),i(H),F(),await z()):re(et.error||t("chat.switchModelFailed"))}catch{re(t("chat.addModelFailed"))}finally{V(null)}},ne=at(o==="normal"?"act":o),de=ne==="plan"?"isPlanDefault":ne==="goal"?"isGoalDefault":"isActDefault",M=S=>{const te=`${S.provider}:${S.id}`;if(r)return r===te;if(s===te)return!0;if(s!==S.id)return!1;const H=u.filter(xe=>xe.id===S.id);return H.length<=1?!0:(H.find(xe=>xe[de]===!0)??H.find(xe=>xe.isGlobalDefault)??H[0])===S},B=u.some(S=>S[de]===!0),J=u.find(S=>S.isGlobalDefault),ue=async()=>{q();const S=ne==="plan"?{plan:null}:ne==="goal"?{goal:null}:{act:null};try{(await ge.models.setDefaults(S)).success&&(J?(a(J.id),i(`${J.provider}:${J.id}`)):(a(""),i("")),await z())}catch{}},he=l.useMemo(()=>Zr(u),[u]),fe=Qr(s,r),je=Bs[c];return e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{type:"button",onClick:()=>f(S=>!S),className:"flex items-center gap-1 px-2 py-0.5 rounded-full border border-dark-border text-dark-muted whitespace-nowrap transition-colors hover:bg-dark-hover cursor-pointer",title:fe||t("chat.clickToSelectModel"),"aria-haspopup":"listbox","aria-expanded":h,children:[e.jsx(vr,{size:12,className:"shrink-0"}),e.jsx("span",{className:"font-medium max-w-[8rem] truncate",children:fe||t("chat.selectModel")}),e.jsx("span",{className:"h-3 w-px bg-dark-border shrink-0","aria-hidden":"true"}),e.jsx(is,{size:12,className:`shrink-0 ${je.color}`}),e.jsx("span",{className:`text-xs font-medium ${je.color}`,children:t(je.labelKey)}),e.jsx(we,{size:12,className:le("transition-transform",h&&"rotate-180")})]}),h&&e.jsxs("div",{role:"listbox","aria-label":t("chat.selectModel"),className:"absolute bottom-full left-0 mb-1 z-50 min-w-[260px] bg-dark-surface border border-dark-border rounded-lg shadow-xl overflow-hidden",children:[e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-dark-muted border-b border-dark-border",children:t("chat.selectModel")}),e.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-dark-border",children:[{key:"global",label:t("chat.applyScopeGlobal")},{key:"session",label:t("chat.applyScopeSession")}].map(({key:S,label:te})=>e.jsx("button",{type:"button",onClick:()=>k(S),title:S==="session"?t("chat.sessionScopeHint"):void 0,className:le("text-[11px] px-2 py-0.5 rounded-full border transition-colors cursor-pointer",g===S?"border-accent-blue text-accent-blue bg-accent-blue/10 font-medium":"border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover"),children:te},S))}),m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-2 py-1.5 border-b border-dark-border flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:F,title:t("chat.backToModels"),"aria-label":t("chat.backToModels"),className:"p-1 rounded hover:bg-dark-hover text-dark-muted hover:text-dark-text shrink-0",children:e.jsx(wr,{size:12})}),C.length>1?e.jsx("select",{value:_,onChange:S=>E(S.target.value),"aria-label":t("chat.selectProvider"),className:"max-w-[9rem] min-w-0 bg-dark-surface text-dark-text text-xs px-1.5 py-1 rounded border border-dark-border focus:outline-none focus:border-accent-blue",children:C.map(S=>e.jsx("option",{value:S,children:S},S))}):e.jsx("span",{className:"flex-1 min-w-0 text-xs font-medium text-dark-text truncate",children:_||t("chat.noConfiguredProviders")}),e.jsx("input",{value:I,onChange:S=>O(S.target.value),placeholder:t("chat.searchModels"),"aria-label":t("chat.searchModels"),className:"flex-1 min-w-0 bg-dark-bg text-dark-text text-xs px-2 py-1 rounded border border-dark-border placeholder-dark-muted/60 focus:outline-none focus:border-accent-blue"})]}),e.jsx("div",{className:"py-1 max-h-[32vh] overflow-y-auto custom-scrollbar",children:K?e.jsxs("div",{className:"px-3 py-2 text-xs text-dark-muted flex items-center gap-1.5",children:[e.jsx(jr,{size:11,className:"animate-spin"}),t("chat.loadingModels")]}):X?e.jsx("div",{className:"px-3 py-2 text-xs text-accent-red",children:X}):_?j.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t(I?"chat.noModelsFound":"chat.noProviderModels")}):e.jsxs(e.Fragment,{children:[T!=="none"&&e.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-[10px] text-dark-muted/70",children:t(T==="provider-api"?"chat.modelsSourceProviderApi":"chat.modelsSourceCatalog")}),j.map(S=>{const te=L.has(S.id),H=r===`${_}:${S.id}`;return e.jsxs("button",{type:"button",role:"option","aria-selected":H,onClick:()=>ae(S),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-dark-hover",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-dark-text truncate",children:S.name||S.id}),H&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-green/20 text-accent-green shrink-0",children:t("chat.currentModel")})]}),e.jsx("span",{className:"block text-[10px] text-dark-muted truncate mt-0.5",children:S.id})]}),te?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-green/20 text-accent-green shrink-0",children:t("chat.alreadyAdded")}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue shrink-0 whitespace-nowrap",children:A===S.id?t("chat.addingModel"):t("chat.addAndSwitch")})]},S.id)})]}):e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t("chat.noConfiguredProviders")})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"py-1 max-h-[32vh] overflow-y-auto custom-scrollbar",children:[B&&e.jsx("button",{type:"button",role:"option","aria-selected":!1,onClick:ue,title:t("chat.followGlobalDefaultHint"),className:"w-full flex items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-dark-hover border-b border-dark-border/60",children:e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"text-xs font-semibold text-accent-green flex items-center gap-1.5",children:[e.jsx(Nr,{size:11}),t("chat.followGlobalDefault")]}),e.jsx("span",{className:"block text-[10px] text-dark-muted mt-0.5 truncate",children:J?J.name||J.id:t("chat.noGlobalDefault")})]})}),he.map(([S,te])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-dark-border/60 bg-dark-bg/40",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-dark-muted truncate",children:S}),e.jsx("span",{className:"text-[10px] text-dark-muted/70",children:te.length})]}),te.map(H=>{const be=M(H);return e.jsx("button",{type:"button",role:"option","aria-selected":be,onClick:()=>Y(H),className:le("w-full flex items-center gap-2 px-3 py-2 text-left transition-colors",be?"bg-dark-hover":"hover:bg-dark-hover"),children:e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:le("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",be?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(Ee,{size:11,strokeWidth:3})}),e.jsx("span",{className:"text-xs font-semibold text-dark-text truncate",children:H.name||H.id})]}),e.jsxs("span",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.jsx("span",{className:"text-[10px] text-dark-muted truncate",children:H.id}),H.isGlobalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-green/20 text-accent-green",children:t("chat.globalDefault")}),H.isPlanDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-blue/20 text-accent-blue",children:t("chat.planDefault")}),H.isActDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-yellow/20 text-accent-yellow",children:t("chat.actDefault")}),H.isGoalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-purple/20 text-accent-purple",children:t("chat.goalDefault")})]})]})},`${H.provider}:${H.id}`)})]},S)),u.length===0&&e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t("chat.noEnabledModels")})]}),e.jsxs("button",{type:"button",onClick:Z,className:"w-full flex items-center gap-2 px-3 py-2 text-left border-t border-dark-border/60 text-[11px] font-medium text-accent-blue transition-colors hover:bg-dark-hover",children:[e.jsx(Ze,{size:11}),t("chat.browseMoreModels")]})]}),e.jsx("div",{className:"border-t border-dark-border","aria-hidden":"true"}),e.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-dark-muted border-b border-dark-border flex items-center gap-1",children:[e.jsx(is,{size:11}),t("chat.effort")]}),e.jsx("div",{className:"py-1",children:ea.map(S=>{const te=Bs[S],H=S===c;return e.jsxs("button",{type:"button",role:"option","aria-selected":H,onClick:()=>{d(S),q()},className:le("w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors",H?"bg-dark-hover":"hover:bg-dark-hover"),children:[e.jsx("span",{className:le("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",H?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(Ee,{size:11,strokeWidth:3})}),e.jsx("span",{className:`text-xs font-medium ${H?te.color:"text-dark-text"}`,children:t(te.labelKey)})]},S)})})]})]})});function tl(n,t){if(!n)return t;const s=n.includes("\\")?"\\":"/";return n.endsWith(s)?n+t:n+s+t}function sl(n){const t=n.replace(/[\\/]+$/,""),s=Math.max(t.lastIndexOf("\\"),t.lastIndexOf("/"));return s===-1?t:t.slice(s+1)}function nl({initial:n,onClose:t,onConfirm:s}){const{t:r}=ee(),[a,i]=l.useState(n),[o,c]=l.useState(null),[d,u]=l.useState([]),[p,h]=l.useState(!1),[f,x]=l.useState(""),[g,k]=l.useState(n),y=l.useRef(null),m=l.useCallback(async E=>{h(!0),x("");try{const I=await ge.dirs.list(E);if(!I.success||!I.data){x(I.error||r("chat.dirPickerLoadError"));return}i(I.data.path),c(I.data.parent),u(I.data.dirs||[]),k(I.data.path)}catch(I){x(I instanceof Error?I.message:r("chat.dirPickerLoadError"))}finally{h(!1)}},[r]);l.useEffect(()=>{m(n)},[n,m]),l.useEffect(()=>{var E;(E=y.current)==null||E.focus()},[]),l.useEffect(()=>{const E=I=>{I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),t())};return document.addEventListener("keydown",E),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",E),document.body.style.overflow=""}},[t]);const v=l.useCallback(()=>{const E=g.trim();E&&m(E)},[g,m]),_=l.useCallback(()=>{o&&m(o)},[o,m]);return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-hidden p-4",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-dark-surface border border-dark-border rounded-xl shadow-2xl animate-fade-in flex flex-col max-h-[70vh]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-dark-border shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[13px] font-semibold text-dark-text",children:[e.jsx(Zs,{size:15,className:"text-accent-blue","aria-hidden":"true"}),r("chat.dirPickerTitle")]}),e.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-dark-muted hover:bg-dark-hover hover:text-dark-text transition-colors","aria-label":r("a11y.close"),children:e.jsx(Ae,{size:15,"aria-hidden":"true"})})]}),e.jsxs("div",{className:"p-4 flex flex-col gap-3 min-h-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Sr,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-dark-muted/60","aria-hidden":"true"}),e.jsx("input",{ref:y,value:g,onChange:E=>k(E.target.value),onKeyDown:E=>{E.key==="Enter"&&v()},placeholder:r("chat.dirPickerEnterPath"),spellCheck:!1,className:`w-full rounded-lg border border-dark-border bg-dark-bg pl-8 pr-2.5 py-1.5 text-xs font-mono text-dark-text
27
+ placeholder-dark-muted/50 focus:outline-none focus:border-accent-blue/50 focus:ring-2 focus:ring-accent-blue/10`})]}),e.jsx("button",{type:"button",onClick:v,disabled:p||!g.trim(),className:`shrink-0 rounded-lg border border-dark-border px-2.5 py-1.5 text-xs text-dark-muted
28
+ hover:bg-dark-hover hover:text-dark-text disabled:opacity-40 transition-colors`,children:r("chat.dirPickerGo")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 truncate font-mono text-[11px] text-dark-muted bg-dark-bg rounded-md px-2 py-1 border border-dark-border",title:a,children:a||r("chat.noWorkspaceDir")}),e.jsxs("button",{type:"button",onClick:()=>void _(),disabled:p||!a,className:`shrink-0 flex items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-[11px] text-dark-muted
29
+ hover:bg-dark-hover hover:text-dark-text disabled:opacity-40 transition-colors`,children:[e.jsx(Qs,{size:12,"aria-hidden":"true"}),r("chat.dirPickerUp")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar rounded-lg border border-dark-border bg-dark-bg divide-y divide-dark-border/60",children:p?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-dark-muted",children:[e.jsx(Fe,{size:14,className:"animate-spin","aria-hidden":"true"}),r("chat.loading")]}):f?e.jsx("div",{className:"px-3 py-4 text-xs text-accent-red",children:f}):d.length===0?e.jsx("div",{className:"px-3 py-4 text-xs text-dark-muted/60 text-center",children:r("chat.dirPickerNoDirs")}):d.map(E=>{const I=tl(a,E);return e.jsxs("button",{type:"button",onClick:()=>void m(I),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs text-dark-text
30
+ hover:bg-dark-hover transition-colors group`,children:[e.jsx(Kt,{size:13,className:"shrink-0 text-accent-yellow/80 group-hover:text-accent-yellow","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:E}),e.jsx(Se,{size:12,className:"shrink-0 ml-auto text-dark-muted/40","aria-hidden":"true"})]},E)})}),e.jsx("button",{type:"button",onClick:()=>s(a),disabled:!a||p,className:`w-full rounded-lg bg-accent-blue/90 text-white text-xs font-medium py-2
31
+ hover:bg-accent-blue disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:r("chat.dirPickerConfirm")})]})]})]})}const rl=l.memo(function({workspaceDir:t,onSelect:s}){const{t:r}=ee(),a=lt(h=>h.recentDirs),[i,o]=l.useState(!1),[c,d]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{if(!i)return;const h=x=>{u.current&&!u.current.contains(x.target)&&o(!1)},f=x=>{x.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",f)}},[i]);const p=l.useCallback(h=>{var x;const f=((x=h==null?void 0:h.trim)==null?void 0:x.call(h))||"";f&&(o(!1),d(!1),s(f))},[s]);return e.jsxs("div",{className:"relative shrink-0",ref:u,children:[e.jsxs("button",{type:"button",onClick:()=>o(h=>!h),className:le("flex items-center gap-1 max-w-[180px] px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",i?"border-accent-blue/40 text-accent-blue bg-accent-blue/10":"border-dark-border text-dark-muted hover:bg-dark-hover hover:text-dark-text"),title:r("chat.clickToSwitchDir"),"aria-label":r("chat.clickToSwitchDir"),"aria-expanded":i,"aria-haspopup":"menu",children:[e.jsx(Zs,{size:12,className:"shrink-0 text-accent-blue/80","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[11px]",children:t?sl(t):r("chat.noWorkspaceDir")}),e.jsx(we,{size:11,className:le("shrink-0 transition-transform",i&&"rotate-180"),"aria-hidden":"true"})]}),i&&e.jsxs("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 w-72 max-w-[calc(100vw-1.5rem)] rounded-xl border border-dark-border bg-dark-surface shadow-2xl z-40 overflow-hidden animate-fade-in",children:[e.jsx("div",{className:"px-3 pt-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wide text-dark-muted/50 select-none",children:r("chat.recentDirs")}),a.length===0?e.jsx("div",{className:"px-3 pb-2 text-[11px] text-dark-muted/50 select-none",children:r("chat.noRecentDirs")}):e.jsx("div",{className:"max-h-56 overflow-y-auto custom-scrollbar",children:a.map(h=>{const f=h===t;return e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>p(h),className:le("w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors group",f?"text-accent-blue bg-accent-blue/5":"text-dark-text hover:bg-dark-hover"),title:h,children:[e.jsx(Kt,{size:12,className:le("shrink-0",f?"text-accent-blue":"text-accent-yellow/80 group-hover:text-accent-yellow"),"aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[11px]",children:h}),f&&e.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-accent-blue",children:"✓"})]},h)})}),e.jsx("div",{className:"border-t border-dark-border"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{o(!1),d(!0)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-xs text-accent-blue hover:bg-dark-hover transition-colors",children:[e.jsx(Se,{size:13,"aria-hidden":"true"}),r("chat.chooseOtherDir")]})]}),c&&In.createPortal(e.jsx(nl,{initial:t||"",onClose:()=>d(!1),onConfirm:p}),document.body)]})});function al({isOpen:n,files:t,selectedIndex:s,query:r,isSearching:a,onSelect:i,onHover:o,selectedCount:c=0,onFinish:d}){const{t:u}=ee();return n?e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-dark-surface border border-dark-border rounded-lg shadow-xl overflow-hidden z-50",children:[e.jsxs("div",{className:"max-h-60 overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-[11px] text-dark-muted border-b border-dark-border bg-dark-bg",children:[e.jsx("span",{className:"font-medium text-dark-text",children:r?`@${r}`:"@ file"}),e.jsxs("span",{className:"opacity-70 flex items-center gap-2",children:[c>0&&e.jsx("span",{className:"px-1.5 py-0.5 rounded-full bg-accent-blue/20 text-accent-blue font-medium",children:u("chat.selectedCountShort",{n:c})}),e.jsx("span",{children:u("chat.fileMentionHelpMulti")})]})]}),t.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-dark-muted text-xs flex flex-col items-center gap-1",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{size:16,className:"animate-spin"}),e.jsx("span",{children:u("chat.searchingFiles")})]}):e.jsx("span",{children:u("chat.noMatchingFiles")})}):t.map((p,h)=>e.jsxs("button",{onClick:()=>i(p),onMouseEnter:()=>o(h),className:`w-full px-3 py-1.5 flex items-center gap-2 text-left text-xs transition-colors border-l-2 ${h===s?"bg-accent-blue/20 text-accent-blue border-accent-blue":"hover:bg-dark-hover text-dark-text border-transparent"}`,children:[p.type==="directory"?e.jsx(Kt,{size:12,className:"text-accent-yellow shrink-0"}):e.jsx(Wt,{size:12,className:"text-dark-muted shrink-0"}),e.jsx("span",{className:"truncate",children:p.name}),e.jsx("span",{className:"text-[10px] text-dark-muted truncate ml-auto",children:p.path})]},p.id||p.path))]}),d&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-dark-border bg-dark-bg",children:[e.jsx("span",{className:"text-[10px] text-dark-muted",children:c>0?u("chat.selectedFilesCount",{n:c}):u("chat.enterInsertMulti")}),e.jsx("button",{onClick:d,className:"px-3 py-1 text-[11px] rounded bg-accent-blue text-white hover:opacity-90 transition-opacity",children:u("chat.finishMention")})]})]}):null}function il({open:n,onClose:t,onSelect:s}){const{t:r}=ee(),[a,i]=l.useState([]),[o,c]=l.useState(!1),[d,u]=l.useState("");l.useEffect(()=>{n&&(u(""),c(!0),ge.skills.list().then(h=>{const f=Array.isArray(h.data)?h.data:[];i(f.filter(x=>x.enabled!==!1))}).catch(()=>i([])).finally(()=>c(!1)))},[n]);const p=l.useMemo(()=>{const h=d.trim().toLowerCase();return h?a.filter(f=>[f.id,f.name,f.description,f.category,...f.tags||[]].join(" ").toLowerCase().includes(h)):a},[a,d]);return e.jsx(ta,{isOpen:n,onClose:t,title:r("skills.pickTitle"),size:"lg",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border focus-within:border-accent-blue",children:[e.jsx(Ze,{size:14,className:"text-dark-muted shrink-0"}),e.jsx("input",{value:d,onChange:h=>u(h.target.value),placeholder:r("skills.pickPlaceholder"),autoFocus:!0,className:"flex-1 bg-transparent outline-none text-sm placeholder-dark-muted/60"}),o&&e.jsx(Xe,{size:13,className:"animate-spin text-dark-muted"})]}),o?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Xe,{size:20,className:"animate-spin text-accent-blue"})}):p.length===0?e.jsx("div",{className:"text-center py-12 text-sm text-dark-muted",children:r("skills.pickEmpty")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:p.map(h=>e.jsxs("button",{onClick:()=>s(h),className:"text-left rounded-lg border border-dark-border p-3 flex flex-col gap-1 transition-colors hover:border-accent-blue/50 hover:bg-dark-hover",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[h.icon||"⭐"," ",h.name]}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dark-bg border border-dark-border text-dark-muted shrink-0",children:h.injection||"lazy"})]}),e.jsxs("div",{className:"text-xs text-dark-muted truncate font-mono",children:["$",h.id]}),h.description&&e.jsx("div",{className:"text-xs text-dark-muted line-clamp-2",children:h.description}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dark-bg border border-dark-border text-dark-muted truncate",children:h.category||"—"}),e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-accent-blue shrink-0",children:[e.jsx(Gt,{size:11}),r("skills.pickUse")]})]})]},h.id))})]})})}const ol=800,Je=/\[Pasted text #(\d+)(?:\s*\+\d+ lines?)?\]/g;let ll=0;const ht=new Map;function cl(n){const t=++ll;return ht.set(t,n),t}function dl(n){ht.delete(n)}function ul(n){return n.length>ol||_n(n)>0}function _n(n){return(n.match(/\r\n|\r|\n/g)||[]).length}function pl(n){const t=cl(n),s=_n(n);return s===0?{id:t,label:`[Pasted text #${t}]`}:{id:t,label:`[Pasted text #${t} +${s} lines]`}}function hl(n){return Je.lastIndex=0,n.replace(Je,(t,s)=>{const r=parseInt(s,10),a=ht.get(r);return a!==void 0?a:t})}function ml(n){Je.lastIndex=0;const t=[];let s;for(;(s=Je.exec(n))!==null;){const r=s[1];r!==void 0&&t.push(parseInt(r,10))}return Je.lastIndex=0,t}function fl(n){for(const t of n)ht.delete(t)}function xl(n){const t=n.match(/\[Pasted text #\d+(?:\s*\+\d+ lines?)?\]$/);return t?t[0]??null:null}function gl(n){const t=n.match(/^\[Pasted text #\d+(?:\s*\+\d+ lines?)?\]/);return t?t[0]??null:null}function Hs(n){const t=n.match(/#(\d+)/);t&&dl(parseInt(t[1]??"",10))}const it=16e3;function _t(){const n=["audio/webm;codecs=opus","audio/webm","audio/mp4"];if(typeof MediaRecorder>"u")return"";for(const t of n)if(MediaRecorder.isTypeSupported(t))return t;return""}async function bl(n){if(n.sampleRate===it&&n.numberOfChannels===1)return n.getChannelData(0);const t=Math.max(1,Math.ceil(n.length*it/n.sampleRate)),s=new OfflineAudioContext(1,t,it),r=s.createBufferSource();return r.buffer=n,r.connect(s.destination),r.start(0),(await s.startRendering()).getChannelData(0)}function kl(n,t){const s=new ArrayBuffer(44+n.length*2),r=new DataView(s),a=(o,c)=>{for(let d=0;d<c.length;d++)r.setUint8(o+d,c.charCodeAt(d))};a(0,"RIFF"),r.setUint32(4,36+n.length*2,!0),a(8,"WAVE"),a(12,"fmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),a(36,"data"),r.setUint32(40,n.length*2,!0);let i=44;for(let o=0;o<n.length;o++){const c=Math.max(-1,Math.min(1,n[o]??0));r.setInt16(i,c<0?c*32768:c*32767,!0),i+=2}return s}function yl(n){return new Promise((t,s)=>{const r=new FileReader;r.onload=()=>{const a=String(r.result||""),i=a.indexOf(",");t(i>=0?a.slice(i+1):a)},r.onerror=()=>s(r.error),r.readAsDataURL(n)})}function vl(n){const[t,s]=l.useState("idle"),[r,a]=l.useState(0),i=l.useRef(null),o=l.useRef(null),c=l.useRef([]),d=l.useRef(null),u=l.useRef(0),p=l.useCallback(()=>{var k;(k=o.current)==null||k.getTracks().forEach(y=>y.stop()),o.current=null},[]),h=l.useCallback(()=>{d.current&&(clearInterval(d.current),d.current=null)},[]);l.useEffect(()=>()=>{h(),i.current&&i.current.state!=="inactive"&&i.current.stop(),p()},[h,p]);const f=l.useCallback(async()=>{if(t!=="idle")return;if(typeof MediaRecorder>"u")throw new Error("当前浏览器不支持语音输入(需要 MediaRecorder)。请使用 Chrome/Edge/Firefox 或桌面版。");let k;try{k=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}})}catch(m){throw m instanceof DOMException&&m.name==="NotAllowedError"?new Error("麦克风权限被拒绝。请在浏览器地址栏允许麦克风权限后重试。"):new Error("无法访问麦克风:"+(m instanceof Error?m.message:String(m)))}o.current=k,c.current=[];const y=new MediaRecorder(k,_t()?{mimeType:_t()}:void 0);y.ondataavailable=m=>{m.data&&m.data.size>0&&c.current.push(m.data)},i.current=y,y.start(),u.current=Date.now(),a(0),s("recording"),d.current=setInterval(()=>a(Date.now()-u.current),100)},[t]),x=l.useCallback(async()=>{var m;const k=i.current;if(!k||k.state==="inactive")throw new Error("当前没有进行中的录音。");const y=new Promise(v=>{k.onstop=()=>v()});k.stop(),await y,h(),p(),i.current=null,s("transcribing");try{const v=new Blob(c.current,{type:_t()||"audio/webm"});c.current=[];const _=await v.arrayBuffer(),E=new AudioContext;let I;try{I=await E.decodeAudioData(_)}finally{E.close()}if(I.duration<.25)return s("idle"),"";const j=await bl(I),N=kl(j,it),L=await yl(new Blob([N],{type:"audio/wav"})),R=await ge.stt.transcribe(n,L,"wav");if(!R.success)throw new Error(R.error||"语音转写失败");return((m=R.data)==null?void 0:m.text)??""}finally{s("idle")}},[n,h,p]),g=l.useCallback(()=>{const k=i.current;k&&k.state!=="inactive"&&k.stop(),i.current=null,c.current=[],h(),p(),s("idle")},[h,p]);return{state:t,elapsedMs:r,start:f,stop:x,cancel:g}}const wl=({isOpen:n,commands:t,selectedIndex:s,filter:r,onSelect:a,onHover:i,containerRef:o})=>{const{t:c}=ee();return!n||t.length===0?null:e.jsxs("div",{ref:o,className:"absolute bottom-full left-0 right-0 mb-2 bg-dark-surface border border-dark-border rounded-lg shadow-xl overflow-hidden z-50 max-h-72 overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-[11px] text-dark-muted border-b border-dark-border bg-dark-bg",children:[e.jsx("span",{className:"font-medium text-dark-text",children:r?`/${r}`:c("slashCommands.quickCommands")}),e.jsx("span",{className:"opacity-70",children:c("slashCommands.help")})]}),t.map((d,u)=>e.jsxs("button",{"data-index":u,onClick:()=>a(d),onMouseEnter:()=>i(u),className:`w-full px-3 py-2 flex items-start gap-3 text-left transition-colors border-l-2 ${u===s?"bg-accent-blue/10 border-accent-blue":"border-transparent hover:bg-dark-hover"}`,children:[e.jsx("span",{className:"text-lg leading-none shrink-0","aria-hidden":"true",children:d.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-dark-text",children:["/",d.name]}),d.args&&e.jsx("span",{className:"text-xs text-dark-muted",children:d.args}),!d.local&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue shrink-0",children:c("slashCommands.backend")})]}),e.jsx("div",{className:"text-xs text-dark-muted truncate",children:d.description})]}),u===s&&e.jsx(Er,{size:14,className:"text-dark-muted shrink-0 mt-0.5","aria-hidden":"true"})]},d.id))]})},Mn=["xlsx","xls","csv","docx","txt","md","mdx","rst","adoc","ts","tsx","js","jsx","mjs","cjs","mts","cts","json","jsonc","yaml","yml","toml","xml","html","css","scss","less","py","rb","go","rs","java","kt","swift","c","h","cpp","hpp","cc","cs","sh","bash","zsh","ps1","bat","cmd","sql","graphql","proto","vue","svelte","astro","env","gitignore","gitattributes","editorconfig"],jl=new RegExp(`(?:\\.(${Mn.join("|")})|dockerfile|makefile)$`,"i"),On=["png","jpg","jpeg","webp","gif","bmp","svg"],Nl=new RegExp(`\\.(${On.join("|")})$`,"i"),Sl=10*1024*1024,El=Mn.map(n=>`.${n}`).join(",")+",.Dockerfile,.Makefile,"+On.map(n=>`.${n}`).join(","),Tl=".deepseekcode/attachments",Al=50*1024*1024,Mt=10,Cl=n=>/\.xlsx?$/i.test(n)?Ft:/\.(csv|docx|txt|md|mdx|rst|adoc|json|jsonc|yaml|yml|toml|xml|html|css|scss|less|env|gitignore|gitattributes|editorconfig)$/i.test(n)?ot:/\.(ts|tsx|js|jsx|mjs|cjs|mts|cts|py|rb|go|rs|java|kt|swift|c|h|cpp|hpp|cc|cs|sh|bash|zsh|ps1|bat|cmd|sql|graphql|proto|vue|svelte|astro|dockerfile|makefile)$/i.test(n)?Mr:Wt,Ot=3e3,Us=5,Dt=50;function Il(n,t){const s=n.slice(0,t),r=s.lastIndexOf("@");if(r===-1)return{active:!1,query:"",start:-1};const a=s.slice(r+1);return/^[\p{L}\p{N}_\-./]*$/u.test(a)?{active:!0,query:a,start:r}:{active:!1,query:"",start:-1}}function Rl(n,t){const s=n.lastIndexOf(`
32
+ `,t-1)+1,r=n.slice(s,t);return r.startsWith("/")?/\s/.test(r)?{active:!1,query:""}:{active:!0,query:r.slice(1)}:{active:!1,query:""}}const _l=l.memo(function({sessionId:t,onSend:s,onStop:r,onPause:a,onResume:i,slashOptions:o,workspaceDir:c,onWorkspaceSelect:d}){const{t:u}=ee(),p=ke(b=>{var w;return((w=b.sessionInputs)==null?void 0:w[t])??""}),h=ke(b=>b.setSessionInput),f=ke(b=>{var w;return((w=b.generatingSessions)==null?void 0:w.includes(t))??!1}),x=ke(b=>{var w;return((w=b.pausedSessions)==null?void 0:w.includes(t))??!1}),g=l.useRef(null),k=l.useRef(null),y=l.useRef(!1),[m,v]=l.useState([]),[_,E]=l.useState(!1),[I,O]=l.useState(!1),j=l.useCallback(b=>{h(t,b)},[t,h]),[N,L]=l.useState(()=>{try{return ls(localStorage.getItem("dsc.stt.lang"))}catch{return"en"}}),[R,T]=l.useState(!1),U=l.useRef(null),K=l.useCallback(b=>{L(b);try{localStorage.setItem("dsc.stt.lang",b)}catch{}T(!1)},[]);l.useEffect(()=>{if(!R)return;const b=$=>{U.current&&!U.current.contains($.target)&&T(!1)},w=$=>{$.key==="Escape"&&T(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",w)}},[R]);const W=vl(N),X=l.useRef(null),re=l.useCallback(async()=>{var b;try{if(!X.current){const P=await ge.stt.status();P.success&&P.data&&(X.current=P.data)}const w=X.current;if(!w)return!0;if(w.service!=="ok"&&w.service!=="stopped")return pe.warning(u("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1;const $=(b=w.backends)==null?void 0:b[N];return $&&!$.installed?(pe.warning(u("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1):!0}catch{return!0}},[u,N]);l.useEffect(()=>{const b=()=>{X.current=null};return window.addEventListener("stt-backends-changed",b),()=>window.removeEventListener("stt-backends-changed",b)},[]),l.useEffect(()=>{const b=w=>{var P;const $=ls((P=w.detail)==null?void 0:P.lang);L($)};return window.addEventListener("stt-lang-changed",b),()=>window.removeEventListener("stt-lang-changed",b)},[]);const A=l.useCallback(b=>{const w=g.current,$=(w==null?void 0:w.selectionStart)??p.length,P=p.slice(0,$)+b+p.slice($);j(P),requestAnimationFrame(()=>{w==null||w.focus();const Q=$+b.length;w&&(w.selectionStart=w.selectionEnd=Q)})},[p,j]),V=l.useCallback(async()=>{if(W.state==="recording"){try{const w=await W.stop();w?A(w):pe.info(u("stt.noSpeech"))}catch(w){pe.error(w instanceof Error?w.message:String(w))}return}if(!(W.state!=="idle"||!await re()))try{await W.start()}catch(w){pe.error(w instanceof Error?w.message:String(w))}},[W,A,re,u]),C=sa(o),{isOpen:z,filter:Z,filteredCommands:F,selectedIndex:D,setSelectedIndex:q,selectNext:Y,selectPrev:ae,executeCommand:ne,openMenu:de,closeMenu:M,setFilter:B,allCommands:J,containerRef:ue}=C,[he,fe]=l.useState(!1),[je,S]=l.useState(""),[te,H]=l.useState([]),[be,xe]=l.useState(0),[et,Be]=l.useState(!1),[$n,He]=l.useState(0),Me=l.useRef(-1),Oe=l.useRef(new Set),Ue=l.useRef(null),tt=l.useRef(null),mt=l.useRef([]),Ne=l.useRef(!1);l.useEffect(()=>{Oe.current=new Set,Ne.current=!1,fe(!1),S(""),H([]),He(0),M()},[t,M]);const Qt=l.useDeferredValue(p),es=Ve(b=>b.estimateTokens),ft=l.useMemo(()=>es(Qt),[Qt,es]),ts=l.useCallback(()=>{const b=g.current;b&&(b.style.height="auto",b.style.height=Math.min(b.scrollHeight,200)+"px")},[]);l.useEffect(()=>{ts()},[p,m.length,ts]);const xt=l.useCallback(()=>{if(Ue.current)return Promise.resolve(Ue.current);if(tt.current)return tt.current;Be(!0);const b=(async()=>{try{const w=await ge.files.list(),$=w.success&&w.data?w.data[0]:void 0;if(!$)return Ue.current=[],[];const P=[],Q=new Set,G=async(se,ce)=>{if(ce>Us||P.length>=Ot)return;const oe=[];for(const ie of se||[]){if(P.length>=Ot)return;const $e=ie.path.replace(/\\/g,"/");Q.has($e)||(Q.add($e),ie.type==="file"?P.push({...ie,path:$e}):ie.children&&ie.children.length>0?await G(ie.children,ce+1):ce<Us&&oe.push(ie))}if(oe.length===0)return;const ye=await Promise.all(oe.map(async ie=>{var $e;try{const kt=await ge.files.list(ie.path.replace(/\\/g,"/"));return kt.success&&kt.data?(($e=kt.data[0])==null?void 0:$e.children)||[]:[]}catch{return[]}}));for(const ie of ye){if(P.length>=Ot)return;await G(ie,ce+1)}};return await G($.children,1),Ue.current=P,P}catch{return Ue.current=[],[]}finally{tt.current=null,Be(!1)}})();return tt.current=b,b},[]),ss=l.useCallback(async(b,w)=>{if(Ne.current){const se=Me.current;if(se<0||w<se){Ne.current=!1,fe(!1);return}const ce=b.slice(se,w);if(/\s/.test(ce)){Ne.current=!1,fe(!1);return}Me.current=se,S(ce),fe(!0),xe(0);const oe=await xt();mt.current=oe;const ye=ce.toLowerCase();H(oe.filter(ie=>!ye||ie.path.toLowerCase().includes(ye)).slice(0,Dt));return}const $=Il(b,w);if(!$.active){he&&fe(!1);return}Me.current=$.start,S($.query),fe(!0),xe(0);const P=await xt();mt.current=P;const Q=$.query.toLowerCase(),G=P.filter(se=>!Q||se.path.toLowerCase().includes(Q)).slice(0,Dt);H(G)},[he,xt]),Ln=l.useCallback(b=>{const w=b.target.value,$=b.target.selectionStart??w.length;j(w),ss(w,$);const P=Rl(w,$);P.active?(z||de(),B(P.query),q(0)):z&&M()},[j,ss,z,de,B,q,M]),gt=l.useCallback(b=>{const w=g.current,$=p,P=Me.current>=0?Me.current:(w==null?void 0:w.selectionStart)??$.length,Q=Math.min($.length,P+1+je.length),G=`@${b.path} `,se=$.slice(0,P)+G+$.slice(Q);Oe.current.add(b.path),j(se),fe(!0),S(""),H(mt.current.slice(0,Dt)),xe(0),He(Oe.current.size),Me.current=P+G.length,Ne.current=!0,requestAnimationFrame(()=>{w==null||w.focus(),w&&(w.selectionStart=w.selectionEnd=P+G.length)})},[p,je,j]),qe=l.useCallback(()=>{Ne.current=!1,fe(!1),S(""),He(0)},[]),bt=l.useCallback(b=>{if(!b.args){const G=ne(b,"");G!=null&&G.message&&(G.success?pe.success(G.message):pe.error(G.message)),j("");return}const w=g.current,$=(w==null?void 0:w.selectionStart)??p.length,P=p.lastIndexOf(`
33
+ `,$-1)+1,Q=p.slice(0,P)+`/${b.name} `+p.slice($);j(Q),M(),requestAnimationFrame(()=>{w==null||w.focus();const G=P+b.name.length+2;w&&(w.selectionStart=w.selectionEnd=G)})},[p,j,ne,M]),zn=l.useCallback(b=>{const w=g.current,$=(w==null?void 0:w.selectionStart)??p.length,P=`$${b.id} `,Q=p.slice(0,$)+P+p.slice($);j(Q),O(!1),Ne.current=!1,fe(!1),S(""),requestAnimationFrame(()=>{w==null||w.focus();const G=$+P.length;w&&(w.selectionStart=w.selectionEnd=G)})},[p,j]),ns=l.useCallback(b=>new Promise((w,$)=>{const P=new FileReader;P.onload=()=>w(String(P.result??"")),P.onerror=()=>$(new Error("Failed to read image")),P.readAsDataURL(b)}),[]),De=l.useCallback(b=>{const w=Array.from(b);v($=>{const P=Mt-$.length,Q=$.slice();for(const G of w.slice(0,P)){const se=Nl.test(G.name);if(!se&&!jl.test(G.name)){pe.warning(u("fileJob.unsupportedType",{name:G.name}));continue}if(G.size>(se?Sl:Al)){pe.error(u("fileJob.fileTooLarge",{name:G.name}));continue}if(Q.some(oe=>oe.name===G.name)){pe.warning(u("fileJob.duplicateFile",{name:G.name}));continue}const ce={id:`att-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,file:G,name:G.name,size:G.size,uploading:!1};se&&ns(G).then(oe=>{v(ye=>ye.map(ie=>ie.id===ce.id?{...ie,imageDataUri:oe}:ie))}).catch(()=>{v(oe=>oe.filter(ye=>ye.id!==ce.id)),pe.error(u("fileJob.uploadFailed",{name:G.name}))}),Q.push(ce)}return Q.length>=Mt&&pe.warning(u("fileJob.maxAttachments",{n:Mt})),Q})},[u,ns]),Fn=l.useCallback(b=>{b.target.files&&b.target.files.length>0&&(De(b.target.files),b.target.value="")},[De]),Pn=l.useCallback(()=>{var b;(b=k.current)==null||b.click()},[]),Bn=l.useCallback(b=>{v(w=>w.filter($=>$.id!==b))},[]),Hn=l.useCallback(b=>{b.preventDefault(),E(!0)},[]),Un=l.useCallback(b=>{b.preventDefault(),E(!1)},[]),qn=l.useCallback(b=>{b.preventDefault(),E(!1),b.dataTransfer.files&&b.dataTransfer.files.length>0&&De(b.dataTransfer.files)},[De]),rs=l.useCallback(async()=>{var w;if(m.length===0)return"";const b=[];for(const $ of m){if($.imageDataUri)continue;if($.path){b.push(`<attachment path="${$.path}" />`);continue}if(!$.file)continue;v(G=>G.map(se=>se.id===$.id?{...se,uploading:!0,error:void 0}:se));const P=`${Tl}/${$.name}`,Q=await ge.files.upload($.file,P);if(Q.success&&((w=Q.data)!=null&&w.path)){const G=Q.data.path.replace(/\\/g,"/");v(se=>se.map(ce=>ce.id===$.id?{...ce,uploading:!1,path:G}:ce)),b.push(`<attachment path="${G}" />`)}else v(G=>G.map(se=>se.id===$.id?{...se,uploading:!1,error:Q.error||u("fileJob.uploadFailed")}:se)),pe.error(`${$.name}: ${Q.error||u("fileJob.uploadFailed")}`)}return b.length>0?`${b.join(`
34
+ `)}
35
+
36
+ `:""},[m,u]),Gn=l.useCallback(b=>{const w=b.clipboardData.getData("text/plain");if(b.clipboardData.files&&b.clipboardData.files.length>0){b.preventDefault(),De(b.clipboardData.files);return}if(!w||!ul(w))return;b.preventDefault();const{label:$}=pl(w),P=g.current;if(!P)return;const Q=P.selectionStart,G=P.selectionEnd,se=P.value,ce=se.slice(0,Q)+$+se.slice(G);j(ce),requestAnimationFrame(()=>{P.selectionStart=P.selectionEnd=Q+$.length})},[j,De]),st=l.useCallback(async()=>{const b=hl(p);fl(ml(b)),Ne.current=!1,fe(!1),M();const w=b.trim(),$=m.length>0;if(!w&&!$)return;const P=b.trim();if(P.startsWith("/")&&!$){const oe=na(P);if(oe){const ye=J.find(ie=>ie.name===oe.command);if(ye){const ie=ne(ye,oe.args);ie!=null&&ie.message&&(ie.success?pe.success(ie.message):pe.error(ie.message)),j(""),v([]),Oe.current=new Set,He(0);return}pe.error(u("slashCommands.unknownCommand",{cmd:`/${oe.command}`}));return}}const Q=Array.from(Oe.current).filter(oe=>b.includes(`@${oe}`));let G="";if($){if(m.some(oe=>oe.uploading)){pe.warning(u("fileJob.stillUploading"));return}G=await rs()}const se=(G+b).trim();if(!se&&!$)return;const ce=m.filter(oe=>oe.imageDataUri).map(oe=>oe.imageDataUri);s(se||G.trim(),Q.length>0?Q:void 0,ce.length>0?ce:void 0),j(""),v([]),Oe.current=new Set,He(0)},[p,m,s,j,rs,u,M,J,ne]),Wn=l.useCallback(b=>{if(!b.nativeEvent.isComposing){if((b.key==="Backspace"||b.key==="Delete")&&!b.ctrlKey&&!b.metaKey&&!b.altKey&&!b.shiftKey){const w=g.current;if(w&&w.selectionStart===w.selectionEnd){const $=w.selectionStart,P=w.value;if(b.key==="Backspace"&&$>0){const Q=xl(P.slice(0,$));if(Q){b.preventDefault(),j(P.slice(0,$-Q.length)+P.slice($)),Hs(Q),requestAnimationFrame(()=>{w.focus();const G=$-Q.length;w.selectionStart=w.selectionEnd=G});return}}else if(b.key==="Delete"&&$<P.length){const Q=gl(P.slice($));if(Q){b.preventDefault(),j(P.slice(0,$)+P.slice($+Q.length)),Hs(Q),requestAnimationFrame(()=>{w.focus(),w.selectionStart=w.selectionEnd=$});return}}}}if(he&&te.length>0){if(b.key==="ArrowDown"){b.preventDefault(),xe(w=>(w+1)%te.length);return}if(b.key==="ArrowUp"){b.preventDefault(),xe(w=>(w-1+te.length)%te.length);return}if(b.key==="Enter"&&!b.shiftKey&&!b.ctrlKey&&!b.metaKey){const w=te[be];w&&(b.preventDefault(),gt(w));return}if(b.key==="Escape"){b.preventDefault(),qe();return}}else if(he&&b.key==="Escape"){b.preventDefault(),qe();return}if(z&&F.length>0){if(b.key==="ArrowDown"){b.preventDefault(),Y();return}if(b.key==="ArrowUp"){b.preventDefault(),ae();return}if(b.key==="Enter"&&!b.shiftKey&&!b.ctrlKey&&!b.metaKey){const w=F[D];w&&(b.preventDefault(),bt(w));return}if(b.key==="Escape"){b.preventDefault(),M();return}}else if(z&&b.key==="Escape"){b.preventDefault(),M();return}if(b.key==="Escape"&&f){b.preventDefault(),x?i():a();return}if(b.key==="Enter"&&(b.ctrlKey||b.metaKey)){b.preventDefault(),st();return}b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),st())}},[f,x,st,a,i,he,te,be,gt,qe,z,F,D,Y,ae,bt,M,j]),Kn=l.useCallback(()=>{y.current=!0},[]),Vn=l.useCallback(()=>{y.current=!1},[]),as=ft>8e3,Jn=p.trim().length>0||m.length>0;return e.jsxs("div",{className:"chat-composer-shell shrink-0 px-3 pb-3 pt-2 sm:px-4",onDragOver:Hn,onDragLeave:Un,onDrop:qn,children:[m.length>0&&e.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:m.map(b=>{const w=Cl(b.name);return e.jsxs("div",{className:le("flex items-center gap-1.5 rounded-lg border px-2 py-1 text-xs transition-colors",b.error?"border-accent-red/40 bg-accent-red/5 text-accent-red":b.uploading?"border-accent-blue/40 bg-accent-blue/5 text-accent-blue":"border-dark-border bg-dark-surface text-dark-text"),children:[b.imageDataUri?e.jsx("img",{src:b.imageDataUri,alt:b.name,className:"h-6 w-6 rounded object-cover",title:u("fileJob.imagePreview")}):b.uploading?e.jsx(Fe,{size:13,className:"animate-spin"}):e.jsx(w,{size:13}),e.jsx("span",{className:"max-w-[140px] truncate",children:b.name}),e.jsx("span",{className:"text-[10px] text-dark-muted",children:b.size>1024*1024?`${(b.size/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(b.size/1024))} KB`}),!b.uploading&&e.jsx("button",{onClick:()=>Bn(b.id),className:"rounded p-0.5 text-dark-muted hover:text-accent-red hover:bg-accent-red/10 transition-colors","aria-label":u("a11y.close"),children:e.jsx(Ae,{size:11})})]},b.id)})}),_&&e.jsx("div",{className:"mb-2 rounded-xl border-2 border-dashed border-accent-blue/50 bg-accent-blue/5 py-3 text-center text-xs text-accent-blue",children:u("fileJob.dropHint")}),e.jsxs("div",{className:"chat-composer-card relative rounded-xl border transition-all duration-150",children:[he&&e.jsx("div",{onMouseDown:b=>b.preventDefault(),"aria-hidden":!he,children:e.jsx(al,{isOpen:he,files:te,selectedIndex:be,query:je,isSearching:et,onSelect:gt,onHover:xe,selectedCount:$n,onFinish:qe})}),z&&e.jsx("div",{onMouseDown:b=>b.preventDefault(),"aria-hidden":!z,children:e.jsx(wl,{isOpen:z,commands:F,selectedIndex:D,filter:Z,onSelect:bt,onHover:q,containerRef:ue})}),e.jsx("textarea",{ref:g,value:p,onChange:Ln,onKeyDown:Wn,onPaste:Gn,onBlur:()=>{he&&qe(),M()},onCompositionStart:Kn,onCompositionEnd:Vn,placeholder:u(f?"chat.generatingPlaceholder":"chat.inputPlaceholder"),rows:1,disabled:f&&!x,"aria-label":"Message input",className:`w-full bg-transparent px-4 pt-3.5 pb-2 text-sm text-dark-text placeholder-dark-muted/60
37
+ resize-none focus:outline-none min-h-[44px] max-h-[40vh] leading-relaxed
38
+ disabled:opacity-50 disabled:cursor-not-allowed`}),e.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-2.5",children:[d&&e.jsx(rl,{workspaceDir:c,onSelect:d}),e.jsx(Qo,{}),e.jsx("span",{className:"hidden sm:block",children:e.jsx(el,{})}),e.jsx("div",{className:"flex-1"}),ft>0&&p.length>0&&e.jsxs("span",{className:`text-[10px] tabular-nums ${as?"text-accent-red font-medium":"text-dark-muted/60"}`,children:["~",ft," tokens",as?` · ${u("chat.nearLimit")}`:""]}),!f&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("div",{ref:U,className:"relative",children:[e.jsxs("button",{onClick:()=>T(b=>!b),disabled:W.state!=="idle",className:`flex h-8 items-center justify-center gap-0.5 rounded-full px-2 text-[11px] font-semibold text-dark-muted transition-colors
39
+ hover:bg-dark-hover hover:text-dark-text disabled:opacity-40`,title:u("stt.langToggle"),"aria-label":u("stt.langToggle"),"aria-haspopup":"listbox","aria-expanded":R,children:[la(N).short,e.jsx(en,{size:11,"aria-hidden":"true"})]}),R&&e.jsxs("div",{role:"listbox","aria-label":u("stt.langToggle"),className:"absolute bottom-full right-0 mb-2 z-50 w-44 rounded-lg border border-dark-border bg-dark-surface shadow-lg py-1 max-h-72 overflow-auto custom-scrollbar",children:[ca.map(b=>e.jsxs("button",{role:"option","aria-selected":b.code===N,onClick:()=>K(b.code),className:le("flex w-full items-center justify-between gap-2 px-3 py-1.5 text-xs transition-colors",b.code===N?"text-accent-blue bg-accent-blue/10":"text-dark-text hover:bg-dark-hover"),children:[e.jsx("span",{className:"font-medium",children:b.label}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-dark-muted",children:[b.code==="zh"?"FunASR":"Whisper",b.code===N&&e.jsx(Ee,{size:12,"aria-hidden":"true"})]})]},b.code)),e.jsx("div",{className:"mt-1 border-t border-dark-border px-3 pt-1.5 pb-0.5 text-[10px] leading-relaxed text-dark-muted/70",children:u("stt.multiHint")})]})]}),e.jsx("button",{onClick:()=>void V(),disabled:W.state==="transcribing",className:le("flex h-8 w-8 items-center justify-center rounded-full text-dark-muted transition-colors",W.state==="recording"?"bg-accent-red/15 text-accent-red animate-pulse":"hover:bg-dark-hover hover:text-dark-text","disabled:opacity-40 disabled:cursor-not-allowed"),title:W.state==="recording"?u("stt.stopTitle"):u("stt.title"),"aria-label":W.state==="recording"?u("stt.stopTitle"):u("stt.title"),children:W.state==="transcribing"?e.jsx(Fe,{size:15,className:"animate-spin","aria-hidden":"true"}):W.state==="recording"?e.jsx(Tr,{size:15,"aria-hidden":"true"}):e.jsx(Ar,{size:15,"aria-hidden":"true"})}),W.state==="recording"&&e.jsxs("span",{className:"text-[10px] tabular-nums text-accent-red","aria-hidden":"true",children:[(W.elapsedMs/1e3).toFixed(0),"s"]})]}),!f&&e.jsx("button",{onClick:()=>O(!0),className:"flex h-8 w-8 items-center justify-center rounded-full text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text",title:u("skills.pickTitle"),"aria-label":u("skills.pickTitle"),children:e.jsx(Cr,{size:15,"aria-hidden":"true"})}),!f&&e.jsx("button",{onClick:()=>void Pn(),className:"flex h-8 w-8 items-center justify-center rounded-full text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text",title:u("fileJob.attach"),"aria-label":u("fileJob.attach"),children:e.jsx(Ir,{size:15,"aria-hidden":"true"})}),e.jsx("input",{ref:k,type:"file",multiple:!0,accept:El,className:"hidden",onChange:Fn}),f?e.jsxs("div",{className:"flex items-center gap-1.5",children:[x?e.jsx("button",{onClick:i,className:"flex h-8 w-8 items-center justify-center rounded-full bg-accent-green text-white transition-all hover:opacity-85 active:scale-95",title:u("chat.resumeGen"),"aria-label":u("chat.resumeGen"),children:e.jsx(Rr,{size:14,"aria-hidden":"true"})}):e.jsx("button",{onClick:a,className:"flex h-8 w-8 items-center justify-center rounded-full bg-accent-yellow text-white transition-all hover:opacity-85 active:scale-95",title:u("chat.pauseGen"),"aria-label":u("chat.pauseGen"),children:e.jsx(Ys,{size:14,"aria-hidden":"true"})}),e.jsx("button",{onClick:r,className:"flex h-8 w-8 items-center justify-center rounded-full bg-accent-red text-white transition-all hover:opacity-85 active:scale-95",title:u("chat.stopGen"),"aria-label":u("chat.stopGen"),children:e.jsx(_r,{size:13,"aria-hidden":"true"})})]}):e.jsx("button",{onClick:()=>void st(),disabled:!Jn,className:`flex h-8 w-8 items-center justify-center rounded-full bg-dark-text text-dark-bg transition-all
40
+ hover:opacity-80 active:scale-95 disabled:opacity-25 disabled:cursor-not-allowed`,title:u("chat.sendBtn"),"aria-label":u("chat.sendBtn"),children:e.jsx(Qs,{size:15,"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"mt-1.5 hidden select-none items-center justify-center gap-3 text-[10px] text-dark-muted/55 sm:flex",children:[e.jsx("span",{children:u("chat.shiftEnter")}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:u("chat.escHint")})]}),e.jsx(il,{open:I,onClose:()=>O(!1),onSelect:zn})]})}),Ml=15e3,Ol=300;function Dn(n){const{t}=ee();return l.useMemo(()=>{const s=t("chat.askOtherLabel"),r=t("chat.askProceedLabel"),a=n.options||[],i=a.some(p=>p.label===s),o=a.some(p=>p.label===r),c=[...a];o||c.push({label:r,description:t("chat.askProceedDesc")}),i||c.push({label:s,description:t("chat.askCustomDesc")});const d=i?c.findIndex(p=>p.label===s):c.length-1,u=o?c.findIndex(p=>p.label===r):c.length-(i?1:2);return{allItems:c,otherIdx:d,proceedIdx:u,displayItems:c}},[n,t])}function qs({item:n,answered:t,selectedIdx:s,multiSelected:r,customInput:a,showCustomInput:i,onSelect:o,onToggleMulti:c,onProceed:d,onEnterCustom:u,onCancelCustom:p,onSubmitCustom:h,onCustomChange:f,inputRef:x}){const{t:g}=ee(),{otherIdx:k,proceedIdx:y,displayItems:m}=Dn(n),v=!!n.multiSelect,_=E=>{if(E===y){d();return}if(E===k){u();return}if(v){c(E);return}o(E)};return e.jsxs("div",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:[m.map((E,I)=>{const O=s===I,j=r.has(I),N=I===k;return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${O?"bg-blue-50 dark:bg-blue-900/20 border border-blue-300 dark:border-blue-700":"bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-750"}`,onClick:()=>_(I),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[v&&e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center text-[10px] ${j?"bg-blue-600 border-blue-600 text-white":"border-gray-400 dark:border-gray-500"}`,children:j&&e.jsx(Ee,{size:10})}),e.jsxs("span",{className:`font-medium ${O?"text-blue-700 dark:text-blue-300":"text-gray-800 dark:text-gray-200"}`,children:[v?"":`${I+1}. `,E.label]}),I===y&&e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:g("chat.askDirectTag")}),N&&e.jsx("span",{className:"text-xs text-gray-400",children:g("chat.askCustomTag")})]}),E.description&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 ml-6",children:E.description})]}),N&&O&&i&&e.jsxs("div",{className:"mt-2 ml-4",children:[e.jsx("textarea",{ref:x,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none",rows:3,value:a,onChange:L=>f(L.target.value),onKeyDown:L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),h()),L.key==="Escape"&&p()},placeholder:g("chat.askAnswerPlaceholder"),autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-3 py-1 text-xs font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700",onClick:h,children:[e.jsx(ze,{size:12}),g("chat.askSubmit")]}),e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-3 py-1 text-xs font-medium text-gray-600 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 rounded-md hover:bg-gray-200 dark:hover:bg-gray-600",onClick:p,children:[e.jsx(Ae,{size:12}),g("common.cancel")]})]})]})]},`opt-${I}`)}),t&&e.jsx("div",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-medium",children:g("chat.askAnswered")})]})}function Dl({isOpen:n,onClose:t}){const{t:s}=ee(),[r,a]=l.useState(null),[i,o]=l.useState(-1),[c,d]=l.useState(new Set),[u,p]=l.useState(""),[h,f]=l.useState(!1),[x,g]=l.useState(!1),[k,y]=l.useState(0),[m,v]=l.useState([]),[_,E]=l.useState(!1),I=l.useRef(null),O=l.useRef(null),j=l.useMemo(()=>r?r.questions&&r.questions.length>0?r.questions:[{question:r.question,header:r.header,options:r.options,multiSelect:r.multiSelect}]:[],[r]),N=j.length>1,L=l.useCallback(M=>{a(M),o(M.multiSelect?-1:0),d(new Set),p(""),f(!1),g(!1),y(0),E(!1);const B=M.questions&&M.questions.length>0?M.questions:[M];v(B.map(()=>null))},[]);l.useEffect(()=>{O.current=r}),l.useEffect(()=>{if(n){const M=window.__pendingQuestion;M&&L(M)}},[n,L]),l.useEffect(()=>{const M=B=>{var fe;const J=B.detail,ue=((fe=O.current)==null?void 0:fe.questionId)??null;if(J&&ue&&J!==ue)return;const he=ue;g(!0),setTimeout(()=>{var S;const je=((S=O.current)==null?void 0:S.questionId)??null;he&&je&&je!==he||(t(),a(null),g(!1))},Ol)};return window.addEventListener("ask-question-dismiss",M),()=>window.removeEventListener("ask-question-dismiss",M)},[t]),l.useEffect(()=>{if(!x)return;const M=setTimeout(()=>g(!1),Ml);return()=>clearTimeout(M)},[x]),l.useEffect(()=>{const M=()=>{const B=window.__pendingQuestion;B&&L(B)};return window.addEventListener("ask-question-required",M),()=>window.removeEventListener("ask-question-required",M)},[L]),l.useEffect(()=>{o(0),d(new Set),p(""),f(!1)},[k,_,r]);const R=j[k]||null,{allItems:T,otherIdx:U}=Dn(R||{question:""}),K=l.useCallback((M,B)=>{x||!r||(g(!0),me.send({type:"question_answer",sessionId:me.getSessionId()??void 0,data:JSON.stringify({questionId:r.questionId,answer:M,selectedOptions:B})}))},[x,r]),W=l.useCallback(()=>{x||!r||(g(!0),me.send({type:"question_answer",sessionId:me.getSessionId()??void 0,data:JSON.stringify({questionId:r.questionId,answers:j.map((M,B)=>m[B]||{answer:s("chat.askUnansweredValue")})})}))},[x,r,j,m,s]),X=l.useCallback((M,B,J)=>{v(ue=>{const he=ue.slice();return he[M]={answer:B,selectedOptions:J},he}),M<j.length-1?y(M+1):E(!0)},[j.length]),re=l.useCallback(M=>{if(x||!r)return;const B=T[M];B&&(o(M),K(B.label,[B.label]))},[x,r,T,K]),A=l.useCallback(()=>{if(x||!r||i<0)return;const M=T[i];M&&K(M.label,[M.label])},[x,r,i,T,K]),V=l.useCallback(()=>{if(x||i<0)return;const M=T[i];M&&X(k,M.label,[M.label])},[x,i,T,X,k]),C=l.useCallback(M=>{if(x)return;const B=T[M];B&&X(k,B.label,[B.label])},[x,T,X,k]),z=l.useCallback(M=>{x||d(B=>{const J=new Set(B);return J.has(M)?J.delete(M):J.add(M),J})},[x]),Z=l.useCallback(()=>{if(x)return;const M=[...c].map(B=>{var J;return((J=T[B])==null?void 0:J.label)||""});N?X(k,M.join(", "),M):K(M.join(", "),M)},[x,c,T,N,X,k,K]),F=l.useCallback(()=>{if(x)return;const M=s("chat.askProceedLabel");N?X(k,M,[M]):K(M,[M])},[x,N,X,k,K,s]),D=l.useCallback(()=>{x||(o(U),f(!0),setTimeout(()=>{var M;return(M=I.current)==null?void 0:M.focus()},100))},[x,U]),q=l.useCallback(()=>{f(!1),p("")},[]),Y=l.useCallback(()=>{if(x)return;const M=u||s("chat.askEmptyInputValue");N?X(k,M):K(M)},[x,u,N,X,k,K,s]),ae=l.useCallback(()=>{x||!r||(g(!0),me.send({type:"question_answer",sessionId:me.getSessionId()??void 0,data:JSON.stringify({questionId:r.questionId,answers:j.map(()=>({answer:"(cancelled)"}))})}))},[x,r,j]),ne=l.useCallback(()=>{if(!x){if(N){if(h){f(!1),p("");return}if(_){E(!1),y(j.length-1);return}ae();return}if(h){f(!1),p("");return}K("(cancelled)")}},[x,N,h,_,j.length,ae,K]);if(!n||!r)return null;const de=m.filter(M=>!M).length;return e.jsx(on,{isOpen:n,onClose:ne,title:r.header||s(N?"chat.askBatchTitle":"chat.askSingleTitle"),badge:e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-accent-blue shrink-0",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-pulse"}),s("chat.askPendingBadge"),N?` · ${m.filter(Boolean).length}/${j.length}`:""]}),collapsedSummary:e.jsx("span",{className:"truncate",children:(R==null?void 0:R.question)||r.question}),maxHeight:"50vh",children:N?e.jsxs("div",{className:"flex flex-col gap-4",children:[r.autoResolutionMs&&r.autoResolutionMs>0&&e.jsx("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-md px-3 py-1.5",children:s("chat.askAutoContinue",{seconds:Math.max(1,Math.round(r.autoResolutionMs/1e3))})}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[j.map((M,B)=>{const J=!!m[B],ue=!_&&k===B;return e.jsxs("button",{type:"button",onClick:()=>{y(B),E(!1)},className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${ue?"bg-blue-600 text-white":J?"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-700 dark:text-emerald-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:["Q",B+1," ",J?"✓":""]},`nav-${B}`)}),e.jsx("button",{type:"button",onClick:()=>E(!0),className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${_?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:s("chat.askSubmit")})]}),_?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:s("chat.askReviewTitle")}),j.map((M,B)=>{const J=m[B];return e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed min-w-0",children:[e.jsxs("span",{className:"font-medium",children:[B+1,". "]}),M.question]}),e.jsx("div",{className:`text-xs shrink-0 max-w-[45%] text-right break-words ${J?"text-emerald-600 dark:text-emerald-400":"text-amber-600 dark:text-amber-400"}`,children:J?J.answer:s("chat.askNotAnswered")})]},`rev-${B}`)}),de>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-md px-3 py-2",children:[e.jsx(_e,{size:14}),s("chat.askUnansweredWarning",{count:de})]}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50",onClick:W,disabled:x,children:[e.jsx(ze,{size:14}),s("chat.askSubmitAll")]}),e.jsx("button",{type:"button",className:"inline-flex items-center gap-1 px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 rounded-md hover:bg-gray-200 dark:hover:bg-gray-600",onClick:()=>{E(!1),y(j.length-1)},disabled:x,children:s("chat.askBackToEdit")})]})]}):R?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed min-w-0",children:R.question}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 px-2 py-1 text-xs text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-40",onClick:()=>{y(M=>Math.max(0,M-1)),E(!1)},disabled:k===0,children:[e.jsx(Or,{size:12}),s("chat.askPrevQuestion")]}),k<j.length-1?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 px-2 py-1 text-xs text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700",onClick:()=>{y(M=>Math.min(j.length-1,M+1)),E(!1)},children:[s("chat.askNextQuestion"),e.jsx(Se,{size:12})]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 px-2 py-1 text-xs font-medium text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900/20 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/30",onClick:()=>E(!0),children:[s("chat.askViewSubmit"),e.jsx(Se,{size:12})]})]})]}),e.jsx(qs,{item:R,answered:!!m[k],selectedIdx:i,multiSelected:c,customInput:u,showCustomInput:h,onSelect:C,onToggleMulti:z,onProceed:F,onEnterCustom:D,onCancelCustom:q,onSubmitCustom:Y,onCustomChange:p,inputRef:I}),!h&&e.jsx("div",{className:"flex items-center gap-2",children:R.multiSelect?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:Z,disabled:x||c.size===0,children:[e.jsx(ze,{size:14}),s("chat.askFinishQuestion",{count:c.size})]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:V,disabled:x||i<0,children:[e.jsx(ze,{size:14}),s("chat.askConfirmQuestion")]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:h?e.jsx("span",{children:s("chat.askEnterHint")}):R.multiSelect?e.jsx("span",{children:s("chat.askMultiHintBatch")}):e.jsx("span",{children:s("chat.askSingleHintBatch")})})]}):null]}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.autoResolutionMs&&r.autoResolutionMs>0&&e.jsx("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-md px-3 py-1.5",children:s("chat.askAutoContinue",{seconds:Math.max(1,Math.round(r.autoResolutionMs/1e3))})}),e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:r.question}),e.jsx(qs,{item:j[0],answered:!1,selectedIdx:i,multiSelected:c,customInput:u,showCustomInput:h,onSelect:re,onToggleMulti:z,onProceed:F,onEnterCustom:D,onCancelCustom:q,onSubmitCustom:Y,onCustomChange:p,inputRef:I}),!h&&e.jsx("div",{className:"flex items-center gap-2",children:r.multiSelect?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:Z,disabled:x||c.size===0,children:[e.jsx(ze,{size:14}),s("chat.askSubmitSelected",{count:c.size})]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:A,disabled:x||i<0,children:[e.jsx(ze,{size:14}),s("chat.askSubmit")]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:x?e.jsx("span",{children:s("chat.askSubmitting")}):h?e.jsx("span",{children:s("chat.askEnterHint")}):r.multiSelect?e.jsx("span",{children:s("chat.askMultiHintSingle")}):e.jsx("span",{children:s("chat.askSingleHintSingle")})})]})})}const Ke=15;function $l({isOpen:n,onCloseModal:t}){const{t:s}=ee("hook"),r=Bt(),a=r.pendingApprovals,i=r.autoMode,o=r.setAutoMode,[c,d]=l.useState(0),[u,p]=l.useState(!1),[h,f]=l.useState(Ke),[x,g]=l.useState(!0),k=l.useRef(null),y=l.useRef(!1);l.useEffect(()=>{if(a.length!==0){if(i){a.forEach(B=>{me.send({type:"hook_allow",data:JSON.stringify({approvalId:B.approvalId})})}),r.clearApprovals();return}d(B=>Math.min(B,a.length-1))}},[a.length,i]);const m=a[c]??null,v=a.length>0&&m!==null,_=a.length,E=v?_-c-1:0;l.useEffect(()=>{if(!(!v||u||!n||!m))return f(Ke),k.current=setInterval(()=>{f(B=>B<=1?(k.current&&clearInterval(k.current),0):B-1)},1e3),()=>{k.current&&clearInterval(k.current)}},[v,u,n,m==null?void 0:m.approvalId]);const I=m?nn(m.toolName,m.askPayload):{level:"MEDIUM",reasonKey:"risk_default"},O=rn[I.level],j=ra[I.level==="CRITICAL"?"critical":I.level==="HIGH"?"high":I.level==="LOW"?"low":"medium"],N=m?vn(m.toolName,m.askPayload):null,L=m?aa(m.toolName,m.askPayload):null,R=m?{verb:kn(m.toolName),target:yn(m.toolName,m.askPayload)}:null,T=m?Ye(m.askPayload)!==null:!1,U=m?wn(m.toolName,m.askPayload):null,K=h/Ke*100,W=h<=5,X=ia(Ke-h),re=l.useCallback((B,J)=>{const ue=an.getState().activeSessionId;ue&&ke.getState().updateHookApprovalStatus(ue,B,J)},[]),A=l.useCallback(B=>{m&&(B&&re(m.approvalId,B),p(!0),setTimeout(()=>{r.removeApproval(m.approvalId),d(0),p(!1),y.current=!1,f(Ke)},200))},[m==null?void 0:m.approvalId,r,re]),V=l.useCallback(()=>{!m||u||y.current||(y.current=!0,k.current&&clearInterval(k.current),me.send({type:"hook_allow",data:JSON.stringify({approvalId:m.approvalId})}),A("approved"))},[m,A,u]),C=l.useCallback(()=>{!m||u||y.current||(y.current=!0,k.current&&clearInterval(k.current),me.send({type:"hook_deny",data:JSON.stringify({approvalId:m.approvalId})}),A("denied"))},[m,A,u]),z=l.useCallback(()=>{if(!m||u||y.current)return;y.current=!0,k.current&&clearInterval(k.current);const B=Ye(m.askPayload);B?(r.addToSessionAllowList(m.toolName,B),me.send({type:"hook_allow",data:JSON.stringify({approvalId:m.approvalId,sessionAllow:!0})})):(r.addToSessionAllowList(m.toolName),me.send({type:"hook_allow",data:JSON.stringify({approvalId:m.approvalId})})),A("approved")},[m,A,r,u]),Z=l.useCallback(()=>{!m||u||y.current||(y.current=!0,k.current&&clearInterval(k.current),o(!0),Ie.getState().setAuto(!0),me.send({type:"hook_allow",data:JSON.stringify({approvalId:m.approvalId})}),A("approved"))},[m,A,u,o]),F=((m==null?void 0:m.timeoutMs)??15e3)>0,D=(m==null?void 0:m.timeoutAction)==="deny"?C:V;if(l.useEffect(()=>{h===0&&n&&!u&&m&&F&&D()},[h,n,u,m,D,F]),l.useEffect(()=>{if(!n||!x)return;const B=J=>{const ue=J.target;ue&&typeof ue.closest=="function"&&ue.closest('input, textarea, select, [contenteditable="true"]')||(J.key==="Escape"?(J.preventDefault(),J.stopPropagation(),C()):J.key==="Enter"?(J.preventDefault(),V()):J.key==="1"?V():J.key==="2"?C():J.key==="3"?z():J.key==="4"&&Z())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[n,x,V,C,z,Z]),!v||!m)return null;const q=s("optionAllowHint"),Y=s("optionDenyHint"),ae=T?s("optionAllowPathHint"):s("optionAllowAlwaysHint",{tool:m.toolName}),ne=s("optionAutoModeHint"),de=(N==null?void 0:N.text)??L??null,M=de?e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-[11px] bg-dark-surface text-accent-blue px-1 py-0.5 rounded shrink-0",children:m.toolName}),e.jsx("span",{className:"truncate",children:de})]}):null;return e.jsx(on,{isOpen:n,onClose:()=>t==null?void 0:t(),title:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lt,{className:"w-4 h-4 text-yellow-400"}),e.jsx("span",{children:s("hookApproval")}),e.jsxs("span",{className:"text-xs text-dark-muted",children:["(",c+1,"/",_,")"]})]}),badge:e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${O.badge}`,children:[O.icon," ",I.level]}),collapsedSummary:M,onExpandedChange:g,maxHeight:"50vh",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg ${O.bg} border ${O.border}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-xs font-bold border ${O.badge}`,children:[O.icon," ",I.level]}),e.jsx("span",{className:"text-xs text-dark-muted truncate",children:s(I.reasonKey)}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto shrink-0",children:[e.jsx(Re,{size:12,className:W?"text-accent-red":"text-dark-muted"}),e.jsx("span",{className:`text-xs font-mono ${W?"text-accent-red animate-pulse":"text-dark-muted"}`,children:F?`${h}s`:"∞"}),e.jsx("div",{className:"w-12 h-1.5 bg-dark-border rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ${W?"bg-accent-red":h<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${K}%`}})})]})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("span",{className:"flex-none w-7 h-7 rounded-lg bg-accent-blue/10 text-accent-blue inline-flex items-center justify-center",children:e.jsx(Lt,{size:15})}),R&&e.jsx(jn,{pre:s(R.verb),obj:R.target})]}),U&&(U.external&&U.path?e.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/30 shrink-0",title:U.path,children:[e.jsx(Js,{size:10}),s("scopeExternal"),": ",U.path.length>48?`${U.path.slice(0,47)}…`:U.path]}):e.jsx("span",{className:"text-[11px] text-dark-muted/60 shrink-0",children:s("scopeLocal")}))]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-dark-muted shrink-0",children:s("tool")}),e.jsx("code",{className:"text-accent-blue font-mono text-xs bg-dark-surface px-1.5 py-0.5 rounded truncate",children:m.toolName}),e.jsx("span",{className:"text-dark-muted/50",children:X}),e.jsx("span",{className:"text-dark-muted/50",children:j.label}),m.timeoutAction&&e.jsxs("span",{className:`text-xs ${m.timeoutAction==="deny"?"text-accent-red":"text-accent-green"}`,children:["timeout: ",F?`${m.timeoutAction==="allow"?"auto-allow":"auto-deny"}${m.timeoutMs?` (${(m.timeoutMs/1e3).toFixed(0)}s)`:""}`:s("timeoutWaitUser")]})]}),N?e.jsx(Ut,{text:N.text,mono:N.mono}):L?e.jsx(Ut,{text:L}):null,(I.level==="CRITICAL"||I.level==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-xs px-2 py-1.5 rounded ${O.bg} ${O.text}`,children:[e.jsx(_e,{size:13}),e.jsx("span",{children:I.level==="CRITICAL"?s("highRiskWarning"):s("mediumRiskConfirm")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:V,disabled:u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-accent-blue text-white text-sm font-medium hover:opacity-90 shadow-sm transition-all disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono bg-white/20 rounded px-1",children:"1"}),e.jsx("span",{children:nt.allow.label}),e.jsx("span",{className:"text-[11px] text-white/70 hidden sm:inline",children:q})]}),e.jsxs("button",{onClick:z,disabled:u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-dark-border bg-dark-bg text-dark-text hover:bg-dark-hover text-sm transition-colors disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono text-dark-muted bg-dark-surface rounded px-1",children:"3"}),e.jsx("span",{children:nt.allow_session.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:ae})]}),e.jsxs("button",{onClick:Z,disabled:u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-dark-border bg-dark-bg text-dark-text hover:bg-dark-hover text-sm transition-colors disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono text-dark-muted bg-dark-surface rounded px-1",children:"4"}),e.jsx("span",{children:nt.auto.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:ne})]}),e.jsx("span",{className:"flex-1"}),e.jsxs("button",{onClick:C,disabled:u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-dark-muted hover:bg-red-500/10 hover:text-red-400 text-sm transition-colors disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono text-dark-muted/60 rounded px-1",children:"2"}),e.jsx("span",{children:nt.deny.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:Y})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-dark-muted/60",children:[e.jsx("span",{children:s("shortcutHint")}),e.jsx("span",{children:E>0?s("morePending",{n:E}):s("lastItem")})]})]})})}const $t="dsc-auto-access-banner-dismissed",Ll=l.memo(function(){const{t}=ee(),s=Ie(c=>c.mode),[r,a]=l.useState(()=>localStorage.getItem($t)==="1");l.useEffect(()=>{Ht(s==="normal"?"act":s)||localStorage.getItem($t)==="1"&&a(!1)},[s]);const i=l.useCallback(c=>{c&&localStorage.setItem($t,"1"),a(!0)},[]);return!(s!=="normal"&&Ht(s))||r?null:e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-1 text-[10.5px] leading-snug text-accent-yellow/75 bg-accent-yellow/[0.05] border-b border-accent-yellow/10 select-none",role:"note",title:t("autoAccess.desc"),children:[e.jsx(Dr,{size:11,className:"shrink-0 text-accent-yellow/70"}),e.jsxs("div",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:t("autoAccess.title")}),e.jsxs("span",{className:"text-accent-yellow/60",children:[" · ",t("autoAccess.desc")]})]}),e.jsx("button",{onClick:()=>i(!1),className:"shrink-0 rounded p-0.5 text-accent-yellow/50 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors",title:t("autoAccess.dismiss"),"aria-label":t("autoAccess.dismiss"),children:e.jsx(Ae,{size:11})}),e.jsx("button",{onClick:()=>i(!0),className:"shrink-0 rounded px-1 py-px text-[9.5px] text-accent-yellow/50 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors whitespace-nowrap",children:t("autoAccess.neverShow")})]})}),Gs=24,Ws=240,zl={pending:{color:"text-gray-400",bg:"bg-gray-500/10",label:"Pending"},running:{color:"text-blue-400",bg:"bg-blue-500/10",label:"Running"},completed:{color:"text-green-400",bg:"bg-green-500/10",label:"Done"},failed:{color:"text-red-400",bg:"bg-red-500/10",label:"Failed"},skipped:{color:"text-gray-500",bg:"bg-gray-500/5",label:"Skipped"}},Fl=({status:n})=>n==="running"?e.jsx(Fe,{size:12,className:"animate-spin text-accent-blue"}):n==="completed"?e.jsx(zt,{size:12,className:"text-accent-green"}):n==="failed"?e.jsx(zr,{size:12,className:"text-accent-red"}):n==="skipped"?e.jsx(Fr,{size:12,className:"text-dark-muted"}):e.jsx(Pr,{size:12,className:"text-dark-muted"}),Pl=l.memo(function({sessionId:t,defaultExpanded:s,onClose:r}){const{t:a}=ee(),[i,o]=l.useState(s??!1),[c,d]=l.useState(null),u=ln(R=>R.getTasksForSession(t)),[p,h]=l.useState(null),f=l.useRef(null),x=l.useRef(!1),g=l.useRef(null),k=l.useCallback(R=>{var T;R.button===0&&(R.target.closest("[data-taskboard-close]")||(x.current=!1,f.current={y:R.clientY,expanded:i,bodyHeight:((T=g.current)==null?void 0:T.offsetHeight)??0},R.currentTarget.setPointerCapture(R.pointerId)))},[i]),y=l.useCallback(R=>{const T=f.current;T&&(Math.abs(R.clientY-T.y)>4&&(x.current=!0),h(R.clientY-T.y))},[]),m=l.useCallback(R=>{const T=f.current;if(!T)return;const U=R.clientY-T.y;T.expanded&&U<-Gs?o(!1):!T.expanded&&U>Gs&&o(!0),f.current=null,h(null),setTimeout(()=>{x.current=!1},0)},[]),v=l.useCallback(()=>{if(x.current){x.current=!1;return}o(R=>!R)},[]),_=l.useCallback(R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),o(T=>!T))},[]),E=p!==null,I=l.useMemo(()=>{const R=f.current;return p===null||!R?null:R.expanded?Math.min(Ws,Math.max(0,R.bodyHeight+p)):Math.min(Ws,Math.max(0,p))},[p]),O=l.useMemo(()=>{const R=u.length,T=u.filter(X=>X.status==="completed").length,U=u.filter(X=>X.status==="running").length,K=u.filter(X=>X.status==="failed").length,W=R>0?Math.round(T/R*100):0;return{total:R,completed:T,running:U,failed:K,progress:W}},[u]),j=l.useMemo(()=>{const R={pending:[],running:[],completed:[],failed:[]};return u.forEach(T=>{const U=T.status==="skipped"?"pending":T.status;R[U].push(T)}),R},[u]),N=[...j.running,...j.failed,...j.pending.slice(0,5),...j.completed.slice(-3)],L=i||E;return u.length===0?null:e.jsxs("div",{className:"w-full shrink-0 mb-2 border border-dark-border rounded-lg bg-dark-bg/70 overflow-hidden",children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":i,onClick:v,onKeyDown:_,onPointerDown:k,onPointerMove:y,onPointerUp:m,onPointerCancel:m,onLostPointerCapture:m,className:"w-full flex items-center justify-between px-2.5 py-1.5 hover:bg-dark-hover transition-colors cursor-pointer select-none touch-none",title:a("chat.taskBoardDragHint"),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx($r,{size:14,className:"text-accent-blue shrink-0"}),e.jsx("span",{className:"text-xs font-medium text-dark-text",children:"Task Board"}),e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0",children:[O.completed,"/",O.total]}),O.total>0&&e.jsx("div",{className:"w-16 h-1.5 bg-dark-surface rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${O.running>0?"bg-accent-blue":O.failed>0?"bg-accent-red":"bg-accent-green"}`,style:{width:`${O.progress}%`}})}),O.running>0&&e.jsx("span",{className:"w-1.5 h-1.5 bg-accent-blue rounded-full animate-pulse shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[r&&e.jsx("span",{role:"button",tabIndex:0,"data-taskboard-close":!0,onClick:R=>{R.stopPropagation(),r()},onKeyDown:R=>{R.key==="Enter"&&(R.stopPropagation(),r())},className:"p-0.5 rounded hover:bg-dark-hover transition-colors cursor-pointer",title:"Hide task drawer",children:e.jsx(Ae,{size:12,className:"text-dark-muted"})}),e.jsx(Lr,{size:12,className:"text-dark-muted/40 shrink-0","aria-hidden":"true"}),i?e.jsx(en,{size:14,className:"text-dark-muted"}):e.jsx(we,{size:14,className:"text-dark-muted"})]})]}),L&&e.jsx("div",{ref:g,className:"border-t border-dark-border",style:I!==null?{height:I,overflow:"hidden"}:void 0,children:u.length===0?e.jsx("div",{className:"text-xs text-dark-muted py-4 text-center",children:a("chat.noTasks")}):e.jsxs("div",{className:"px-2.5 py-2 max-h-[240px] overflow-y-auto custom-scrollbar space-y-1.5",children:[N.map(R=>e.jsx(Hl,{task:R,isSelected:R.id===c,onClick:()=>d(c===R.id?null:R.id)},R.id)),j.pending.length>5&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[j.pending.length-5," more pending tasks"]}),j.completed.length>3&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[j.completed.length-3," more completed tasks"]})]})})]})}),Bl=(n,t)=>{if(!n)return"";const s=(t||Date.now())-n;return s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`},Hl=l.memo(function({task:t,isSelected:s,onClick:r}){const a=zl[t.status];return e.jsxs("div",{onClick:r,className:`rounded border p-2 cursor-pointer transition-all ${a.bg} border-dark-border
41
+ ${s?"ring-1 ring-accent-blue":"hover:border-dark-muted/40"}
42
+ ${t.status==="running"?"border-l-2 border-l-accent-blue":"border-l-2 border-l-transparent"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fl,{status:t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-dark-text truncate",children:t.title}),e.jsx("span",{className:`text-[10px] ${a.color} shrink-0`,children:a.label})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-dark-muted",children:[e.jsx("span",{children:t.agentType||t.source}),t.startedAt&&e.jsx("span",{children:Bl(t.startedAt,t.completedAt)})]})]})]}),t.status==="running"&&t.progress!==void 0&&e.jsx("div",{className:"mt-1.5",children:e.jsx("div",{className:"w-full h-1 bg-dark-bg rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent-blue rounded-full transition-all duration-500",style:{width:`${t.progress}%`}})})}),s&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-dark-border space-y-1",children:[t.description&&e.jsx("p",{className:"text-[10px] text-dark-muted",children:t.description}),t.error&&e.jsx("p",{className:"text-[10px] text-red-400",children:t.error}),t.result&&e.jsx("p",{className:"text-[10px] text-green-400",children:t.result}),t.dependencies&&t.dependencies.length>0&&e.jsxs("p",{className:"text-[10px] text-dark-muted",children:[t.dependencies.length," dependencies"]})]})]})}),Yl=l.memo(function({tabs:t,activeSessionId:s,onSend:r,onStop:a,onPause:i,onResume:o,activeTab:c,setActiveTab:d,createNewSession:u,clearMessages:p,setTheme:h,setThemePreset:f,toggleTerminal:x,setLogs:g,setUnreadLogs:k,showTaskBoard:y=!0,onToggleTaskBoard:m,onRegenerate:v,onDeleteMessage:_,hookDrawerOpen:E,onCloseHookDrawer:I,questionDrawerOpen:O,onCloseQuestionDrawer:j,workspaceDir:N,onWorkspaceSelect:L}){const R=l.useMemo(()=>({setActiveTab:d,createNewSession:u,clearMessages:p,setTheme:h,setThemePreset:f,toggleTerminal:x,setLogs:g,setUnreadLogs:k}),[d,u,p,h,f,x,g,k]),[T,U]=l.useState("chat"),{t:K}=ee(),W=ke(F=>s?F.messagesBySession[s]||[]:[]),X=ke(F=>s?F.generatingSessions.includes(s):!1),re=ke(F=>s?F.pausedSessions.includes(s):!1),A=t.find(F=>F.id===s)||null;l.useEffect(()=>{if(!s)return;let F=!1;return ge.tasks.list(s).then(D=>{if(F||!D.success||!Array.isArray(D.data))return;const q={PENDING:"pending",RUNNING:"running",COMPLETED:"completed",FAILED:"failed",CANCELLED:"skipped"},Y=Date.now(),ae=D.data.filter(ne=>ne.sessionId===s).map(ne=>{const de=new Date(ne.createdAt).getTime()||Y,M=new Date(ne.updatedAt).getTime()||Y;return{id:ne.id,sessionId:s,title:ne.title,status:q[ne.status]||"pending",source:"task",description:ne.description,progress:ne.progress,createdAt:de,updatedAt:M,raw:ne}});ln.getState().setTasks(s,ae,"task")}).catch(()=>{}),()=>{F=!0}},[s]);const V=l.useCallback((F,D)=>{s&&r(s,F,D)},[r,s]),C=l.useCallback(F=>{s&&r(s,F)},[r,s]),z=l.useCallback(F=>{s&&v&&v(s,F)},[v,s]),Z=l.useCallback(F=>{s&&_&&_(s,F)},[_,s]);return e.jsx("div",{className:"flex-1 flex min-h-0",children:e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[e.jsx(Ll,{}),A&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-8 shrink-0 items-center justify-end border-b border-dark-border/30 px-3",children:e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs text-dark-muted hover:bg-dark-surface/60","aria-pressed":T==="trajectory",title:K("trajectory.viewToggleTitle"),onClick:()=>U(F=>F==="chat"?"trajectory":"chat"),children:[e.jsx(Br,{size:13}),K("trajectory.viewToggle")]})}),T==="chat"?e.jsxs(e.Fragment,{children:[e.jsx(Ri,{messages:W,isGenerating:X,isPaused:re,sessionId:A.id,onSendSuggestion:C,onRegenerate:v?z:void 0,onDeleteMessage:_?Z:void 0}),e.jsx($l,{isOpen:!!E,onCloseModal:I}),e.jsx(Dl,{isOpen:!!O,onClose:j??(()=>{})}),y&&e.jsx(Pl,{sessionId:A.id,defaultExpanded:!1,onClose:m},A.id)]}):e.jsx(Xo,{sessionId:A.id,messages:W}),e.jsx(_l,{sessionId:A.id,onSend:V,onStop:()=>a(A.id),onPause:()=>i(A.id),onResume:()=>o(A.id),slashOptions:R,workspaceDir:N,onWorkspaceSelect:L})]})]})})});export{Yl as SessionGrid};