@deepseekcode/cli 1.0.23 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1095 -1074
- package/package.json +2 -2
- package/web/dist/assets/{AutomationView-BbLzZ7Db.js → AutomationView-MOGwMs0s.js} +1 -1
- package/web/dist/assets/{ChannelConfigView-CjcMwBSL.js → ChannelConfigView-CHWC4ETy.js} +1 -1
- package/web/dist/assets/{ConnectorsView-CTFoG0sF.js → ConnectorsView-DaP_wB0W.js} +1 -1
- package/web/dist/assets/{FileTreeView-_N5eobgO.js → FileTreeView-N64-Dser.js} +1 -1
- package/web/dist/assets/{HookConfigView-DM6IVFGm.js → HookConfigView-DsZDeVFi.js} +1 -1
- package/web/dist/assets/ModelsView-C1cE2wMN.js +2 -0
- package/web/dist/assets/PluginsView-CsSjjfrn.js +1 -0
- package/web/dist/assets/SessionGrid-Bg-UTI2P.js +37 -0
- package/web/dist/assets/{SettingsPanel-D9kr-sFj.js → SettingsPanel-pZbjabYJ.js} +3 -3
- package/web/dist/assets/{SkillsView-CS0XvZ4N.js → SkillsView-BrQY_vgT.js} +1 -1
- package/web/dist/assets/{TemplatesTab-Pwfjxer7.js → TemplatesTab-DSfCryw2.js} +1 -1
- package/web/dist/assets/{TerminalView-C__4-QSL.js → TerminalView-Drr72DaP.js} +1 -1
- package/web/dist/assets/{ToolsView-Y5MpTnXY.js → ToolsView-ByqbKwqW.js} +1 -1
- package/web/dist/assets/{icons-BXecaLRH.js → icons-B9mi2ie6.js} +114 -104
- package/web/dist/assets/index-DCj9TkXV.css +1 -0
- package/web/dist/assets/index-PcXINYWS.js +68 -0
- package/web/dist/assets/{markdown-BASfeONY.js → markdown-BrFQfawv.js} +1 -1
- package/web/dist/assets/{panels-Bod3sKnK.js → panels-BX-TtLOU.js} +1 -1
- package/web/dist/assets/{react-vendor-7At16BnY.js → react-vendor-CiRFOYk_.js} +1 -1
- package/web/dist/assets/{state-D4zgKwQs.js → state-BcoCffxz.js} +1 -1
- package/web/dist/index.html +7 -7
- package/web/dist/assets/ModelsView-CPm2WAbG.js +0 -2
- package/web/dist/assets/PluginsView-D9pzIe-R.js +0 -1
- package/web/dist/assets/SessionGrid-C-Z-kzmG.js +0 -35
- package/web/dist/assets/index-CFxV9r1K.css +0 -1
- package/web/dist/assets/index-CcPIw0Dj.js +0 -68
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./markdown-BASfeONY.js";import{a as l,Z as as,ak as Me,d as de,K as fe,aA as ze,X as je,aQ as ct,E as ls,_ as ve,l as dt,L as Re,u as bt,F as ut,aR as xt,aH as Qs,D as Ys,k as en,aS as tn,aw as sn,aT as At,aU as nn,h as $e,al as rn,i as is,aV as an,aW as ln,b as on,aq as cn,aX as dn,aG as un,aa as os,a0 as cs,aY as xn,$ as Mt,n as ds,aN as gt,aM as pn,a5 as us,ab as mn,aZ as hn,a_ as fn,ag as bn,a$ as gn,f as kn,S as yn,t as wn,b0 as Ae,y as vn,b1 as jn,m as Nn,b2 as Sn,a1 as Cn,p as En,q as _n,j as An}from"./icons-BXecaLRH.js";import{D as Mn,d as V,h as zt,c as W,i as zn,j as xs,o as ps,k as Le,l as ms,w as G,m as pt,u as we,R as hs,a as oe,t as Y,n as Rn,s as $n,r as Tn,f as Ue,p as ce,q as In,v as Pn,W as Dn,x as Ln,y as mt,b as fs,z as ht,E as On,M as Bn,A as Fn,F as qn,G as bs,H as Hn,J as Jn,K as Un,L as Fe,N as Wn,O as gs}from"./index-CcPIw0Dj.js";import"./react-vendor-7At16BnY.js";import"./state-D4zgKwQs.js";import"./panels-Bod3sKnK.js";class Kn extends Mn{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}}const Gn=new Kn;function Zn(r,t,s){return Gn.diff(r,t,s)}function Rt({value:r,max:t=100,size:s="md",variant:n="default",showLabel:a=!1,className:o}){const d=Math.min(Math.max(r/t*100,0),100),c={sm:"h-1",md:"h-2",lg:"h-3"},u={default:"bg-accent-blue",success:"bg-accent-green",warning:"bg-accent-yellow",error:"bg-accent-red"};return e.jsxs("div",{className:V("w-full",o),children:[e.jsx("div",{className:V("w-full bg-dark-border rounded-full overflow-hidden",c[s]),children:e.jsx("div",{className:V("h-full rounded-full transition-all duration-300",u[n]),style:{width:`${d}%`}})}),a&&e.jsxs("span",{className:"text-xs text-dark-muted mt-1",children:[Math.round(d),"%"]})]})}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(r){r.type==="entity"&&(r.attributes.title=r.content.replace(/&/,"&"))});Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,s){var n={};n["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[s]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};a["language-"+s]={pattern:/[\s\S]+/,inside:Prism.languages[s]};var o={};o[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",o)}});Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(r,t){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+r+")"+/\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.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 $t={},Tt;function Vn(){return Tt||(Tt=1,(function(r){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}),r.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:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},r.languages.rust["closure-params"].inside.rest=r.languages.rust,r.languages.rust.attribute.inside.string=r.languages.rust.string})(Prism)),$t}Vn();var It={},Pt;function Xn(){return Pt||(Pt=1,(function(r){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,n={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:/\./}};r.languages.java=r.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[n,{pattern:RegExp(/(^|[^\w.])/.source+s+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:n.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+s+/[A-Z]\w*\b/.source),lookbehind:!0,inside:n.inside}],keyword:t,function:[r.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/}),r.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),r.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":n,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+s+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:n.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+s+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:n.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)),It}Xn();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 Dt={},Lt;function Qn(){return Lt||(Lt=1,(function(r){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});r.languages.cpp=r.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/}),r.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}}),r.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:r.languages.cpp}}}}),r.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),r.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:r.languages.extend("cpp",{})}}),r.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},r.languages.cpp["base-clause"])})(Prism)),Dt}Qn();(function(r){function t(s,n){return"___"+s.toUpperCase()+n+"___"}Object.defineProperties(r.languages["markup-templating"]={},{buildPlaceholders:{value:function(s,n,a,o){if(s.language===n){var d=s.tokenStack=[];s.code=s.code.replace(a,function(c){if(typeof o=="function"&&!o(c))return c;for(var u=d.length,i;s.code.indexOf(i=t(n,u))!==-1;)++u;return d[u]=c,i}),s.grammar=r.languages.markup}}},tokenizePlaceholders:{value:function(s,n){if(s.language!==n||!s.tokenStack)return;s.grammar=r.languages[n];var a=0,o=Object.keys(s.tokenStack);function d(c){for(var u=0;u<c.length&&!(a>=o.length);u++){var i=c[u];if(typeof i=="string"||i.content&&typeof i.content=="string"){var p=o[a],f=s.tokenStack[p],m=typeof i=="string"?i:i.content,b=t(n,p),y=m.indexOf(b);if(y>-1){++a;var k=m.substring(0,y),S=new r.Token(n,r.tokenize(f,s.grammar),"language-"+n,f),x=m.substring(y+b.length),N=[];k&&N.push.apply(N,d([k])),N.push(S),x&&N.push.apply(N,d([x])),typeof i=="string"?c.splice.apply(c,[u,1].concat(N)):i.content=N}}else i.content&&d(i.content)}return c}d(s.tokens)}}})})(Prism);var Ot={},Bt;function Yn(){return Bt||(Bt=1,(function(r){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*\()/],n=/\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}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,o=/[{}\[\](),:;]/;r.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:n,operator:a,punctuation:o};var d={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:r.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:d}},{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:d}}];r.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:n,operator:a,punctuation:o}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),r.hooks.add("before-tokenize",function(u){if(/<\?/.test(u.code)){var i=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;r.languages["markup-templating"].buildPlaceholders(u,"php",i)}}),r.hooks.add("after-tokenize",function(u){r.languages["markup-templating"].tokenizePlaceholders(u,"php")})})(Prism)),Ot}Yn();var Ft={},qt;function er(){return qt||(qt=1,(function(r){r.languages.ruby=r.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:/[(){}[\].,;]/}),r.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var t={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:r.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete r.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("|")+")",n=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;r.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+n),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+n+/(?=:(?!:))/.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:/\./}}}),r.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 r.languages.ruby.string,r.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)/}),r.languages.rb=r.languages.ruby})(Prism)),Ft}er();const tr=.4;function Ht(r){const t=[];let s=0;for(;s<r.length;){const n=r[s];if(/[\p{L}\p{N}_]/u.test(n)){let a=s+1;for(;a<r.length&&/[\p{L}\p{N}_]/u.test(r[a]);)a++;t.push(r.slice(s,a)),s=a}else if(/\s/.test(n)){let a=s+1;for(;a<r.length&&/\s/.test(r[a]);)a++;t.push(r.slice(s,a)),s=a}else{const o=r.codePointAt(s)>65535?2:1;t.push(r.slice(s,s+o)),s+=o}}return t}function sr(r,t){const s=Zn(Ht(r),Ht(t)),n=r.length+t.length;let a=0;const o=[],d=[];let c=0,u=0;for(const i of s){const p=i.value.reduce((f,m)=>f+m.length,0);i.removed?(a+=p,o.push({start:c,end:c+p}),c+=p):i.added?(a+=p,d.push({start:u,end:u+p}),u+=p):(c+=p,u+=p)}return n>0&&a/n>tr?[[],[]]:[o,d]}function ks(r){const t=[];let s=null;for(const n of r.split(`
|
|
2
|
-
`)){if(n.startsWith("---")||n.startsWith("+++")||n.startsWith("index ")||n.startsWith("diff --git")||n.startsWith("==="))continue;const a=n.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(!n.startsWith("\\")){if(s&&(n.startsWith("+")||n.startsWith("-")||n.startsWith(" ")||n==="")){s.lines.push(n);continue}s&&n&&(t.push(s),s=null)}}return s&&t.push(s),t}function ys(r){let t=r.oldStart,s=r.newStart;const n=[];for(const a of r.lines){const o=a[0]==="+"||a[0]==="-"?a[0]:" ",d=a.slice(1);let c=null,u=null;o==="-"?c=t++:(o==="+"||(c=t++),u=s++),n.push({marker:o,code:d,oldLine:c,newLine:u})}return n}const nr=l.memo(function({filePath:t,content:s,language:n}){if(!s&&!t)return null;const[a,o]=l.useState("unified"),[d,c]=l.useState(!1),u=rr(t,n),i=(s==null?void 0:s.includes("@@"))||(s==null?void 0:s.includes("+++"))||(s==null?void 0:s.includes("---")),p=i?ar(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:u}),i&&e.jsxs("div",{className:"flex gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>o("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:()=>o("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(!d),className:"text-xs text-dark-muted hover:text-dark-fg ml-1",children:d?"▶":"▼"})]}),!d&&e.jsxs("div",{className:"bg-dark-bg overflow-x-auto max-h-96 overflow-y-auto custom-scrollbar",children:[i?a==="unified"?cr(s||"",u):dr(s||"",u):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 rr(r,t){var a;if(t)return t;if(!r)return"plaintext";const s=(a=r.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 ar(r){const t=r.split(`
|
|
3
|
-
`);let s=0,n=0,a=0;for(const o of t)o.startsWith("@@")?a++:o.startsWith("+")&&!o.startsWith("+++")?s++:o.startsWith("-")&&!o.startsWith("---")&&n++;return{additions:s,deletions:n,hunks:a,filesChanged:1}}function lr(r){const t=[],s=(a,o)=>{if(!o)return;const d=t[t.length-1];d&&d.type===a?d.text+=o:t.push({type:a,text:o})},n=(a,o)=>{if(typeof a=="string"){s(o,a);return}const d=a.type||o;if(typeof a.content=="string"){s(d,a.content);return}for(const c of a.content)n(c,d)};for(const a of r)n(a,"");return t}function ws(r,t){const s=zt.languages[t];if(!s)return[{type:"",text:r}];try{return lr(zt.tokenize(r,s))}catch{return[{type:"",text:r}]}}function ir(r,t){if(t.length===0)return r.map(a=>({...a,word:!1}));const s=[];let n=0;for(const a of r){const o=n,d=n+a.text.length;let c=0;for(const u of t){const i=Math.max(0,u.start-o),p=Math.min(a.text.length,u.end-o);p<=0||i>=a.text.length||(i>c&&s.push({type:a.type,text:a.text.slice(c,i),word:!1}),s.push({type:a.type,text:a.text.slice(i,p),word:!0}),c=p)}c<a.text.length&&s.push({type:a.type,text:a.text.slice(c),word:!1}),n=d}return s}function or({code:r,marker:t,lang:s,ranges:n}){const a=t==="-"?[{type:"",text:r}]:ws(r,s),o=ir(a,n),d=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 ${d}`,children:o.length===0?" ":o.map((u,i)=>e.jsx("span",{className:[u.type?`token ${u.type}`:"",u.word&&t!==" "?c:""].join(" "),children:u.text},i))})}function cr(r,t){const s=ks(r);if(s.length===0)return e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:r});const n=[];let a=0;for(const o of s){const d=ys(o);n.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:["@@ -",o.oldStart,",",o.oldLines," +",o.newStart,",",o.newLines," @@"]})]},a++));const c=new Map;for(let u=0;u<d.length;){if(d[u].marker!=="-"){u++;continue}const i=u;for(;u<d.length&&d[u].marker==="-";)u++;const p=u;for(;u<d.length&&d[u].marker==="+";)u++;const f=Math.min(p-i,u-p);for(let m=0;m<f;m++){const[b,y]=sr(d[i+m].code,d[p+m].code);c.set(i+m,b),c.set(p+m,y)}}for(let u=0;u<d.length;u++){const i=d[u],p=i.marker==="+",f=i.marker==="-",m=p?"bg-green-900/30":f?"bg-red-900/30":"",b=i.marker==="-"?i.oldLine:i.newLine;n.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 ${m} ${p?"text-green-400":f?"text-red-400":"text-dark-muted"}`,children:[i.marker===" "?"":i.marker,b??""]}),e.jsx(or,{code:i.code,marker:i.marker,lang:t,ranges:c.get(u)??[]})]},a++))}}return e.jsx("div",{children:n})}function Jt({code:r,lang:t,kind:s}){if(r==="")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 n=s==="remove"?[{type:"",text:r}]:ws(r,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:n.map((o,d)=>e.jsx("span",{className:o.type?`token ${o.type}`:"",children:o.text},d))})}function dr(r,t){const s=ks(r);if(s.length===0)return e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:r});const n=[];for(const a of s){const o=ys(a);n.push({left:`@@ -${a.oldStart},${a.oldLines} +${a.newStart},${a.newLines} @@`,right:"",type:"header"});let d=[],c=[];const u=()=>{(d.length>0||c.length>0)&&(ur(n,d,c),d=[],c=[])};for(const i of o)i.marker==="-"?d.push(i.code):i.marker==="+"?c.push(i.code):(u(),n.push({left:i.code,right:i.code,type:"context"}));u()}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"})]}),n.map((a,o)=>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},o):e.jsxs("div",{className:"flex",style:{minHeight:"1.25rem"},children:[e.jsx(Jt,{code:a.type==="replace"||a.type==="delete"?"- "+a.left:a.left,lang:t,kind:a.type==="replace"||a.type==="delete"?"remove":"context"}),e.jsx(Jt,{code:a.type==="replace"||a.type==="add"?"+ "+a.right:a.right,lang:t,kind:a.type==="replace"||a.type==="add"?"add":"context"})]},o))]})}function ur(r,t,s){const n=Math.max(t.length,s.length);for(let a=0;a<n;a++){const o=a<t.length?t[a]??"":"",d=a<s.length?s[a]??"":"";r.push({left:o,right:d,type:a<t.length&&a<s.length?"replace":a<t.length?"delete":"add"})}}function vs(r){const t=l.useRef(null),s=l.useRef(0);return l.useEffect(()=>{if(!r){s.current=0;return}s.current=Date.now();const n=t.current;if(!n)return;const a=()=>{const d=Math.floor((Date.now()-s.current)/1e3),c=d>=60?`${Math.floor(d/60)}m ${d%60}s`:`${d}s`;n.textContent=c};a();const o=setInterval(a,1e3);return()=>clearInterval(o)},[r]),t}function xr(r){return typeof r=="string"?r:r&&typeof r=="object"?JSON.stringify(r,null,2):String(r??"")}const Ut=20,pr=/\b(grep|search_contents)\b/i;function mr(r){return r===""?0:r.split(`
|
|
4
|
-
`).length}const Wt=l.memo(function({toolCall:t,defaultCollapsed:s=!0}){const{t:n}=W(),a=t.status==="running",o=vs(a),d=t.result!==void 0&&t.result!==null,c=t.status==="error",u=zn(t.name),i=d?xr(t.result):"",p=d?mr(i):0,m=pr.test(t.name)&&d&&!c&&p>Ut,[b,y]=l.useState(!1),k=m&&!b?i.split(`
|
|
5
|
-
`).slice(0,Ut).join(`
|
|
6
|
-
`)+`
|
|
7
|
-
${n("toolCall.linesTotal",{n:p})}`:i,S=t.diff||(u&&i&&(i.includes("@@")||i.includes("+++")||i.includes("---"))?i:void 0),x=xs(t.args),[N,R]=l.useState(s),A=t.duration??0,M=A>0?A>=60?`${Math.floor(A/60)}m ${A%60}s`:`${A}s`:"",w=a?"bg-accent-blue":c?"bg-accent-red":"bg-accent-green";return e.jsxs("div",{className:"rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"toolcall-row",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>R(!N),children:[a?e.jsx("span",{className:"inline-block w-3 h-3 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`w-2 h-2 shrink-0 rounded-full ${w}`}),e.jsx("span",{className:"text-xs text-dark-muted shrink-0",children:"🔧"}),e.jsx("span",{className:"font-medium text-[13px] text-dark-text truncate",children:t.name}),u&&x&&!c&&e.jsxs("button",{type:"button",onClick:j=>{j.stopPropagation(),ps(x)},className:`flex items-center gap-1 max-w-[16rem] shrink truncate rounded-full border border-dark-border/70 px-2 py-0.5 text-[11px] font-mono text-accent-blue
|
|
8
|
-
hover:bg-dark-hover hover:border-accent-blue/40 transition-colors`,title:x,children:[e.jsx(as,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:x})]}),a&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Me,{size:10}),e.jsx("span",{ref:o,children:"0s"})]}),!a&&M&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Me,{size:10}),e.jsx("span",{children:M})]}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${N?"":"rotate-180"}`,children:e.jsx(de,{size:13})})]}),!N&&e.jsxs("div",{className:"ml-4 pb-1 pl-3 border-l-2 border-dark-border/30 space-y-1",children:[e.jsxs("div",{className:"py-0.5 px-2",children:[e.jsx("div",{className:"text-[10px] text-dark-muted mb-0.5",children:n("step.params")}),e.jsx("pre",{className:"text-[11px] font-mono bg-dark-bg border border-dark-border p-2 rounded overflow-x-auto max-h-24 overflow-y-auto custom-scrollbar",children:typeof t.args=="string"?t.args:JSON.stringify(t.args,null,2)})]}),d&&e.jsxs("div",{className:"py-0.5 px-2",children:[e.jsx("div",{className:`text-[10px] mb-0.5 ${c?"text-accent-red":"text-accent-green"}`,children:n(c?"step.error":"step.result")}),u&&(S||i)?e.jsx(nr,{filePath:x,content:S||i}):e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:`text-[11px] font-mono bg-dark-bg border border-dark-border p-2 rounded overflow-x-auto max-h-48 overflow-y-auto custom-scrollbar whitespace-pre-wrap break-all ${c?"text-accent-red":"text-accent-green"}`,children:k}),m&&e.jsx("button",{type:"button","data-testid":"grep-result-toggle",onClick:()=>y(j=>!j),className:"mt-1 text-[10px] text-accent-blue hover:underline",children:b?n("toolCall.collapse"):n("toolCall.expandAll",{n:p})})]})]})]})]})}),kt=l.memo(function({toolCalls:t,label:s,defaultCollapsed:n=!0}){const{t:a}=W(),[o,d]=l.useState(n),c=l.useMemo(()=>{const k=new Map;for(const S of t)k.set(S.name,(k.get(S.name)??0)+1);return[...k.entries()].sort((S,x)=>x[1]-S[1])},[t]),u=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(Wt,{toolCall:k})}const p=c.slice(0,3),f=c.length-p.length,m=t.reduce((k,S)=>k+(S.duration??0),0),b=m>=60?`${Math.floor(m/60)}m ${m%60}s`:m>=1?`${m}s`:"",y=u==="running"?"bg-accent-blue":u==="error"?"bg-accent-red":"bg-accent-green";return e.jsxs("div",{className:"rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"toolcall-group",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>d(!o),"data-testid":"toolcall-group-toggle",children:[u==="running"?e.jsx("span",{className:"inline-block w-3 h-3 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`w-2 h-2 shrink-0 rounded-full ${y}`}),e.jsx("span",{className:"text-xs text-dark-muted shrink-0",children:"🔧"}),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,S])=>e.jsxs("span",{className:"shrink-0 rounded border border-dark-border/70 px-1.5 py-px text-[10.5px] font-mono text-dark-muted",children:[k," ×",S]},k)),f>0&&e.jsx("span",{className:"shrink-0 text-[10.5px] text-dark-muted",children:a("activity.toolNamesMore",{count:f})}),b&&e.jsx("span",{className:"shrink-0 text-[10px] text-dark-muted tabular-nums",children:b}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${o?"":"rotate-180"}`,children:e.jsx(de,{size:13})})]}),!o&&e.jsxs("div",{className:"ml-4 pb-1 pl-3 border-l-2 border-dark-border/30 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(Wt,{toolCall:k},k.id))]})]})}),hr=l.memo(function({text:t,maxLength:s=300,preformatted:n=!1}){const[a,o]=l.useState(!1);return t.length>s?e.jsxs("div",{children:[n?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:a?t:t.slice(0,s)+"..."}):e.jsx("div",{className:"text-dark-text leading-snug",children:a?t:t.slice(0,s)+"..."}),e.jsx("button",{onClick:c=>{c.stopPropagation(),o(!a)},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?"收起":"展开"})]}):n?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})}),fr=l.memo(function({step:t,defaultCollapsed:s=!0}){const{t:n}=W(),[a,o]=l.useState(s),[d,c]=l.useState(!0),u=t.status==="running",i=vs(u),p=t.description||t.thought||t.result||t.action||t.toolCalls&&t.toolCalls.length>0,f=t.duration??0,m=f>0?f>=60?`${Math.floor(f/60)}m ${f%60}s`:`${f}s`:"",b={pending:"bg-dark-muted/40",running:"bg-accent-blue",success:"bg-accent-green",error:"bg-accent-red",warning:"bg-accent-yellow"}[t.status]||"bg-dark-muted/40";return e.jsxs("div",{className:"rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"step-row",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>p&&o(!a),children:[u?e.jsx("span",{className:"inline-block w-3 h-3 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`w-2 h-2 shrink-0 rounded-full ${b} ${t.status==="pending"?"opacity-60":""}`}),e.jsx("span",{className:"text-[13px] text-dark-text truncate",children:t.title}),u&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Me,{size:10}),e.jsx("span",{ref:i,children:"0s"})]}),!u&&m&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Me,{size:10}),e.jsx("span",{children:m})]}),p&&e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${a?"":"rotate-180"}`,children:e.jsx(de,{size:13})})]}),!a&&p&&e.jsxs("div",{className:"ml-4 pb-1 pl-3 border-l-2 border-dark-border/30 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-blue/40 bg-accent-blue/5 rounded-r",children:[e.jsxs("div",{className:"flex items-center gap-1 text-accent-blue cursor-pointer hover:opacity-80 select-none",onClick:()=>c(!d),children:[d?e.jsx(fe,{size:12}):e.jsx(de,{size:12}),e.jsxs("span",{children:["🧠 ",n("step.thinking")]}),d&&e.jsxs("span",{className:"text-[10px] text-dark-muted truncate max-w-[200px]",children:[t.thought.slice(0,80).replace(/\n/g," "),"..."]})]}),!d&&e.jsx("div",{className:"text-dark-muted italic whitespace-pre-wrap leading-snug mt-1",children:t.thought.replace(/\n\s*\n+/g,`
|
|
9
|
-
`)})]}),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:["⚡ ",n("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(kt,{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:["✓ ",n("step.result")]}),e.jsx(hr,{text:t.result,maxLength:500})]})]})]})}),br=l.memo(function({steps:t,isGenerating:s}){const{t:n}=W(),[a,o]=l.useState(s),d=l.useRef(s);l.useEffect(()=>{d.current&&!s&&o(!1),d.current=s},[s]);const c=t.length,u=s||t.some(b=>b.status==="running"),i=[...t].reverse().find(b=>b.status==="running"),p=t[t.length-1],f=(i==null?void 0:i.title)||(p==null?void 0:p.title)||"",m=`${c} ${n(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:()=>o(!a),"data-testid":"turn-group-toggle",children:[e.jsx("span",{className:"shrink-0 text-dark-muted/60 transition-transform",children:a?e.jsx(de,{size:13}):e.jsx(fe,{size:13})}),u?e.jsx("span",{className:"inline-block w-3 h-3 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:"w-2 h-2 shrink-0 rounded-full bg-accent-green"}),e.jsx("span",{className:"text-xs text-dark-muted",children:u?`${n("chat.runningSteps")} ${m}…`:m}),u&&f&&e.jsxs("span",{className:"min-w-0 flex-1 truncate pl-1 text-xs text-dark-muted/70",children:["· ",f]})]}),a&&e.jsx("div",{className:"ml-3 pb-1 pl-3 border-l-2 border-dark-border/30 space-y-0.5",children:t.map(b=>e.jsx(fr,{step:b},b.id))})]})});function js(r){const t=r??"";let s=t,n=null,a=null;try{const o=JSON.parse(t);if(o&&typeof o=="object")if("payload"in o){a=typeof o.toolName=="string"?o.toolName:null;const d=o.payload;typeof d=="string"?s=d:d&&typeof d=="object"?(n=d,s=JSON.stringify(d,null,2)):s=""}else Array.isArray(o)||(n=o)}catch{s=t}if(!n&&s.length>0&&/^[\s]*[{[]/.test(s))try{const o=JSON.parse(s);o&&typeof o=="object"&&!Array.isArray(o)&&(n=o)}catch{}return{toolName:a,payloadText:s,args:n}}const yt=/\b(bash|shell|exec|cmd|powershell|terminal)\b/i,Ns=/write_file|write|save|create|upload|deploy|publish/i,Ss=/edit_file|edit|patch|apply|update|replace/i,Cs=/read_file|read|view|cat|open|list|dir\b/i,gr=/file_delete|delete|remove|unlink|\brm\b|\bdel\b/i,kr=/\b(glob|find|locate)\b/i,yr=/\b(grep|rg|search_contents)\b/i,wr=/web_search|search_web|browse/i,Es=/web_fetch|fetch|http|curl|wget|download|request|api/i,vr=/git|commit|merge|rebase|push|checkout/i,jr=/install|uninstall|npm|pnpm|yarn|pip|cargo|gem|apt|brew|choco/i,wt=/send_message|send_file|message|notify|post/i;function _s(r){const t=r.toLowerCase();return yt.test(t)?"verbRunCommand":wr.test(t)?"verbSearchWeb":Ns.test(t)?"verbWriteFile":Ss.test(t)?"verbEditFile":gr.test(t)?"verbDeleteFile":Cs.test(t)?"verbReadFile":yr.test(t)?"verbSearchContents":kr.test(t)?"verbFindFiles":Es.test(t)?"verbFetchUrl":vr.test(t)?"verbGit":jr.test(t)?"verbInstall":wt.test(t)?"verbSendMessage":"verbRunTool"}function Ye(r,t){const s=(r??"").replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t-1)}…`:s}function Nr(r){if(!r)return null;for(const t of["file_path","filePath","path","file","target"]){const s=r[t];if(typeof s=="string"&&s.length>0)return s}return null}function As(r,t){const{payloadText:s,args:n}=js(t),a=r.toLowerCase();if(yt.test(a))return"";const o=Nr(n);if(o)return o;const d=s.match(/(?:file_path|path|file)["\s:=]+([^\s",}]+)/i);if(d!=null&&d[1])return d[1];if(Es.test(a)&&typeof(n==null?void 0:n.url)=="string"&&n.url)return Ye(n.url,48);if(wt.test(a)){const c=typeof(n==null?void 0:n.text)=="string"?n.text:typeof(n==null?void 0:n.message)=="string"?n.message:s;return Ye(c,48)}return Ye(s,48)}function Ms(r,t){const{payloadText:s,args:n}=js(t),a=r.toLowerCase();if(yt.test(a)){const o=typeof(n==null?void 0:n.command)=="string"?n.command:s;return o?{text:o,mono:!0}:null}if(Ns.test(a)||Ss.test(a)){const o=typeof(n==null?void 0:n.content)=="string"?n.content:typeof(n==null?void 0:n.data)=="string"?n.data:"";if(o)return{text:o,mono:!0};if(n){const d=Kt(n);if(d)return{text:d,mono:!0}}return s?{text:s,mono:!0}:null}if(wt.test(a)){const o=typeof(n==null?void 0:n.text)=="string"?n.text:typeof(n==null?void 0:n.message)=="string"?n.message:s;return o?{text:o,mono:!1}:null}if(Cs.test(a))return null;if(n){const o=Kt(n);if(o)return{text:o,mono:!0}}return s?{text:s,mono:!0}:null}function Kt(r){return r?Object.entries(r).filter(([,t])=>t!=null).map(([t,s])=>{let n=typeof s=="string"?s:JSON.stringify(s);return n.length>96&&(n=`${n.slice(0,95)}…`),`${t}=${n.replace(/\n/g," ")}`}).join(" "):""}function zs(r,t){const s=Le(t);return s?{path:s,external:!0}:{key:"scopeLocal",external:!1}}function Rs({pre:r,obj:t}){return e.jsxs("span",{className:"min-w-0 text-sm text-dark-muted",children:[e.jsx("span",{children:r}),t&&e.jsx("b",{className:"font-semibold text-dark-text",children:t})]})}const et=5,tt=420;function ft({text:r,mono:t=!0}){const{t:s}=W("hook"),[n,a]=l.useState(!1),o=r.split(`
|
|
10
|
-
`),d=o.length>et||r.length>tt;let c=r;!n&&d&&(c=o.slice(0,et).join(`
|
|
11
|
-
`),c.length>tt&&(c=`${c.slice(0,tt).trimEnd()}…`));const u=n?s("showLess"):o.length>et?s("showAllLines",{n:o.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,d&&e.jsx("button",{type:"button",onClick:()=>a(i=>!i),className:"mt-1 block text-[11px] text-accent-blue hover:underline",children:u})]})}const st=15,Sr=l.memo(function({approval:t,onResolved:s}){const{t:n}=W("hook"),[a,o]=l.useState(!1),[d,c]=l.useState(st),u=l.useRef(null),i=t.status==="pending",{level:p,reasonKey:f}=ms(t.toolName,t.askPayload),m=hs[p],b=Ms(t.toolName,t.askPayload),y=zs(t.toolName,t.askPayload),k=Le(t.askPayload)!==null;l.useEffect(()=>{if(i)return c(st),u.current=setInterval(()=>{c(_=>_<=1?(u.current&&clearInterval(u.current),0):_-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[i,t.approvalId]),l.useEffect(()=>{const _=(t.timeoutMs??15e3)>0;d===0&&i&&!a&&_&&S()},[d]);const S=l.useCallback(()=>{!i||a||(o(!0),u.current&&clearInterval(u.current),G.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"approved"))},[i,a,t.approvalId,s]),x=l.useCallback(()=>{!i||a||(o(!0),u.current&&clearInterval(u.current),G.send({type:"hook_deny",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"denied"))},[i,a,t.approvalId,s]),N=l.useCallback(()=>{if(!i||a)return;o(!0),u.current&&clearInterval(u.current);const _=pt.getState(),F=Le(t.askPayload);F?(_.addToSessionAllowList(t.toolName,F),G.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId,sessionAllow:!0})})):(_.addToSessionAllowList(t.toolName),G.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})})),s==null||s(t.approvalId,"approved")},[i,a,t.approvalId,t.toolName,t.askPayload,s]),R=l.useCallback(()=>{!i||a||(o(!0),u.current&&clearInterval(u.current),pt.getState().setAutoMode(!0),we.getState().setAuto(!0),G.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"approved"))},[i,a,t.approvalId,s]);if(!i){const _=t.status==="approved";return e.jsx("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-xs ${_?"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:_?e.jsxs(e.Fragment,{children:[e.jsx(ze,{size:14}),e.jsxs("span",{children:[n("alreadyAllowed"),t.toolName]})]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{size:14}),e.jsxs("span",{children:[n("alreadyDenied"),t.toolName]})]})})}const A=d/st*100,M=d<=5,w=[{id:"allow",index:1,label:n("optionAllow"),hint:n("optionAllowHint"),action:S,kind:"primary"},{id:"allow_session",index:3,label:n("optionAllowAlways"),hint:k?n("optionAllowPathHint"):n("optionAllowAlwaysHint",{tool:t.toolName}),action:N,kind:"secondary"},{id:"auto_mode",index:4,label:n("optionAutoMode"),hint:n("optionAutoModeHint"),action:R,kind:"secondary"},{id:"deny",index:2,label:n("optionDeny"),hint:n("optionDenyHint"),action:x,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 ${y.external?"border-amber-500/40":m.border}`,children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 border-b ${m.bg} ${y.external?"border-amber-500/30":m.border}`,children:[e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${rc.badge}",children:[m.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(ct,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Rs,{pre:n(_s(t.toolName)),obj:As(t.toolName,t.askPayload)})}),y.external&&y.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:y.path,children:[e.jsx(ls,{size:10}),y.path.length>32?`${y.path.slice(0,31)}…`:y.path]}):e.jsx("span",{className:"text-[10px] text-dark-muted/60 shrink-0",children:n("scopeLocal")}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-1 shrink-0",children:[e.jsx(Me,{size:11,className:M?"text-accent-red":"text-dark-muted"}),e.jsxs("span",{className:`text-[11px] font-mono ${M?"text-accent-red animate-pulse":"text-dark-muted"}`,children:[d,"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 ${M?"bg-accent-red":d<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${A}%`}})})]})]}),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:n("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:n(f)})]}),b&&e.jsx(ft,{text:b.text,mono:b.mono}),(p==="CRITICAL"||p==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-[11px] px-2 py-1 rounded ${m.bg} ${m.text}`,children:[e.jsx(ve,{size:12}),e.jsx("span",{children:n(p==="CRITICAL"?"highRiskWarning":"mediumRiskConfirm")})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:w.map(_=>e.jsxs("button",{onClick:_.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[_.kind]}`,children:[e.jsx("span",{className:`text-[9px] font-mono rounded px-0.5 ${_.kind==="primary"?"bg-white/20":"bg-dark-surface text-dark-muted"}`,children:_.index}),e.jsx("span",{children:_.label}),e.jsx("span",{className:`text-[10px] ${_.kind==="primary"?"text-white/70":"text-dark-muted/60"} hidden sm:inline`,children:_.hint})]},_.id))}),e.jsx("div",{className:"text-[10px] text-dark-muted/50 pt-0.5 border-t border-dark-border/50",children:n("clickToSelect")})]})]})}),qe={xlsx:{icon:xt,label:"Excel"},xls:{icon:xt,label:"Excel"},csv:{icon:ut,label:"CSV"},docx:{icon:ut,label:"Word"},text:{icon:bt,label:"文本"}};function Gt(r){return!r&&r!==0?"—":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/1024/1024).toFixed(2)} MB`}const Cr=l.memo(function({job:t}){var f,m;const{t:s}=W(),{stage:n}=t,a=l.useCallback(b=>{oe.files.download(b).then(y=>{y.success||Y.error(y.error||s("fileJob.downloadFailed"))})},[s]),o=l.useMemo(()=>t.attachments||[],[t.attachments]),d=l.useMemo(()=>t.parsedFiles||[],[t.parsedFiles]),c=l.useMemo(()=>t.mapping||[],[t.mapping]),u=l.useMemo(()=>t.result||[],[t.result]),i=t.renderProgress??(n==="rendering"?0:100),p=t.parseProgress??(n==="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:[n==="complete"?e.jsx(dt,{size:15,className:"text-accent-green shrink-0"}):n==="error"?e.jsx(ve,{size:15,className:"text-accent-red shrink-0"}):e.jsx(Re,{size:15,className:"text-accent-blue animate-spin shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-dark-text",children:Er(n,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((b,y)=>{const k=qe[b.kind]||qe.text,S=k.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(S,{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:b.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[Gt(b.size)," · ",k.label,b.role&&b.role!=="unknown"&&e.jsxs("span",{className:V("ml-1",b.role==="data"?"text-accent-green":"text-accent-purple"),children:["· ",b.role==="data"?s("fileJob.roleData"):s("fileJob.roleTemplate")]})]})]})]},`${b.fileName}-${y}`)})}),n==="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)||((m=d[0])==null?void 0:m.fileName)||""})}),e.jsx(Rt,{value:p,size:"sm",showLabel:!0})]}),d.length>0&&n!=="error"&&e.jsxs("div",{className:"space-y-1.5",children:[d.map(b=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx(dt,{size:13,className:"text-accent-green shrink-0"}),e.jsx("span",{className:"truncate",children:b.fileName}),e.jsx("span",{className:"text-[10px] text-dark-muted/70",children:s("fileJob.parsedSummary",{rows:b.rowCount,fields:b.fields.length})})]},b.fileName)),d[0]&&e.jsxs("div",{className:"flex flex-wrap gap-1 pt-1",children:[d[0].fields.slice(0,12).map(b=>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:b},b)),d[0].fields.length>12&&e.jsxs("span",{className:"text-[10px] text-dark-muted/60",children:["+",d[0].fields.length-12]})]})]}),c.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:c.slice(0,8).map(b=>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:"{{"+b.placeholder+"}}"}),e.jsx("td",{className:"px-2 py-1.5 text-dark-muted",children:e.jsx(Qs,{size:11})}),e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-accent-blue",children:b.field})]},b.placeholder))})]})}),c.length>8&&e.jsx("div",{className:"text-[10px] text-dark-muted/60",children:s("fileJob.mappingMore",{n:c.length-8})})]}),n==="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(Rt,{value:i,size:"sm",variant:"warning",showLabel:!0})]}),u.length>0&&n==="complete"&&e.jsx("div",{className:"space-y-1.5",children:u.map(b=>{const k=(qe[b.format]||qe.text).icon,S=b.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(k,{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:b.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[Gt(b.size)," · ",b.successCount,"/",b.rowCount," 行",S&&e.jsxs("span",{className:"text-accent-red",children:[" · ",b.failedRows.length," 行失败"]})]})]}),e.jsxs("button",{onClick:()=>ps(b.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(as,{size:12}),s("chat.previewInPanel")]}),e.jsxs("button",{onClick:()=>a(b.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(Ys,{size:12}),s("fileJob.download")]})]}),S&&e.jsxs("div",{className:"mt-1.5 space-y-0.5 border-t border-dark-border/50 pt-1.5",children:[b.failedRows.slice(0,3).map(x=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-red",children:[e.jsx(en,{size:10,className:"shrink-0"}),e.jsxs("span",{children:["#",x.index+1]}),e.jsx("span",{className:"truncate",children:x.error})]},x.index)),b.failedRows.length>3&&e.jsxs("div",{className:"text-[10px] text-dark-muted/70",children:["+",b.failedRows.length-3," 行"]})]})]},b.path)})}),n==="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(ve,{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 Er(r,t){switch(r){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 Zt={auth:{icon:nn,color:"text-accent-red"},rate_limit:{icon:At,color:"text-accent-yellow"},timeout:{icon:At,color:"text-accent-yellow"},network:{icon:sn,color:"text-accent-yellow"},model:{icon:tn,color:"text-accent-red"},tool:{icon:ve,color:"text-accent-yellow"},unknown:{icon:ve,color:"text-accent-red"}},_r=l.memo(function({error:t,onRetry:s}){const{t:n}=W(),[a,o]=l.useState(!1),d=Zt[t.category]||Zt.unknown,c=d.icon,u=()=>{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:V("shrink-0 mt-0.5",d.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($e,{size:11}),n("errorCard.retry")]}),t.category==="auth"&&e.jsxs("button",{onClick:u,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(rn,{size:11}),n("errorCard.modelSettings")]}),t.detail&&e.jsxs("button",{onClick:()=>o(i=>!i),className:"flex items-center gap-0.5 text-[11px] text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(de,{size:11,className:V("transition-transform",a&&"rotate-180")}),n("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 Ar(r){const t=r.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)||r}function Mr({status:r}){switch(r){case"completed":return e.jsx(ze,{size:13,className:"shrink-0 text-accent-green","data-testid":"activity-status-completed"});case"failed":return e.jsx(je,{size:13,className:"shrink-0 text-accent-red","data-testid":"activity-status-failed"});case"running":return e.jsx("span",{className:"inline-block w-2.5 h-2.5 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin","data-testid":"activity-status-running"});case"waiting_user":return e.jsx(ln,{size:13,className:"shrink-0 text-accent-yellow","data-testid":"activity-status-waiting"});case"blocked":return e.jsx(an,{size:13,className:"shrink-0 text-accent-red","data-testid":"activity-status-blocked"});case"paused":return e.jsx(is,{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 zr=l.memo(function({activity:t,toolCalls:s,onAnswer:n}){const{t:a}=W(),[o,d]=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")&&d(!1),c.current=t.status},[t.status]);const u=l.useMemo(()=>{for(const y of s){const k=xs(y.args);if(k)return k}},[s]),i=t.endedAt?t.endedAt-t.startedAt:Date.now()-t.startedAt,p=i>=6e4?`${Math.round(i/6e4)}m`:i>=1500?`${Math.round(i/1e3)}s`:"",f=t.status==="waiting_user",m=t.status==="blocked",b=t.status==="paused";return e.jsxs("div",{className:`rounded-lg border transition-colors ${f?"border-accent-yellow/30 bg-accent-yellow/5":m?"border-accent-red/30 bg-accent-red/5":"border-dark-border/40 bg-dark-surface/30 hover:bg-dark-surface/50"}`,"data-testid":"activity-row",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>d(y=>!y),"data-testid":"activity-row-toggle",children:[e.jsx(Mr,{status:t.status}),e.jsx("span",{className:"min-w-0 text-[13px] font-medium text-dark-text truncate",children:t.title}),t.phase!=="analysis"&&e.jsx("span",{className:"shrink-0 rounded border border-dark-border/60 px-1 py-px text-[9.5px] uppercase tracking-wide text-dark-muted","data-testid":"activity-phase",children:a(`activity.phase.${t.phase}`)}),u&&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:Ar(u)}),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}),f&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-accent-yellow",children:a("activity.waitingUser")}),m&&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??""})}),b&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-dark-300",children:a("activity.paused")}),f&&n&&e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),n(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")}),!f&&s.length>0&&e.jsx(de,{size:12,className:`ml-auto shrink-0 text-dark-muted transition-transform ${o?"rotate-180":""}`})]}),o&&s.length>0&&e.jsx("div",{className:"px-1 pb-1",children:e.jsx(kt,{toolCalls:s})})]})});function Rr({index:r,text:t,isGenerating:s,collapsed:n,onToggle:a}){const{t:o}=W();return e.jsxs("div",{children:[e.jsxs("button",{className:"flex items-center gap-1.5 cursor-pointer select-none py-0.5 text-xs",onClick:()=>a(r),"data-testid":"thinking-toggle",children:[e.jsx(fe,{size:12,className:`text-dark-muted transition-transform ${n?"":"rotate-90"}`}),e.jsx("span",{className:s?"text-accent-blue/90 animate-pulse":"text-dark-muted",children:s?`${o("chat.thinking")}…`:o("chat.thoughtProcess")})]}),!n&&e.jsx("div",{className:"mt-1 text-xs text-dark-muted whitespace-pre-wrap break-words border-l-2 border-dark-border/40 pl-3 max-h-64 overflow-y-auto custom-scrollbar",children:t.replace(/\n{3,}/g,`
|
|
12
|
-
|
|
13
|
-
`)})]})}const $r=l.memo(function({message:t,sessionId:s,isGenerating:n,onAnswer:a}){const o=Rn(y=>$n(y,s,t.id)),d=l.useMemo(()=>o.length>0?o:!t.toolCalls||t.toolCalls.length===0?[]:Tn(s??"",t),[o,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]),[u,i]=l.useState({}),p=l.useRef(n);l.useEffect(()=>{p.current&&!n&&i(y=>{const k={...y};for(const S of c)k[S.index]=!0;return k}),p.current=n},[n,c]);const f=y=>{i(k=>({...k,[y]:!(k[y]??!n)}))},m=l.useMemo(()=>{const y=[];for(const k of c)y.push({key:`thinking-${k.index}`,index:k.index,kind:"thinking",block:k});for(const k of d)y.push({key:`activity-${k.id}`,index:k.blockRange[0],kind:"activity",activity:k});return y.sort((k,S)=>k.index-S.index),y},[c,d]),b=l.useMemo(()=>{const y={},k=t.toolCalls??[];for(const S of d)y[S.id]=S.toolCallIds.map(x=>k.find(N=>N.id===x)).filter(x=>!!x);return y},[d,t.toolCalls]);return m.length===0?null:e.jsx("div",{className:"mb-1 space-y-0.5","data-testid":"agent-activity-feed",children:m.map(y=>y.kind==="thinking"&&y.block?e.jsx(Rr,{index:y.block.index,text:y.block.text,isGenerating:n,collapsed:u[y.block.index]??!n,onToggle:f},y.key):y.activity?e.jsx(zr,{activity:y.activity,toolCalls:b[y.activity.id]??[],onAnswer:a},y.key):null)})});function nt({onClick:r,title:t,children:s,danger:n=!1}){return e.jsx("button",{onClick:r,title:t,"aria-label":t,className:`inline-flex items-center justify-center rounded p-1 transition-colors ${n?"text-dark-muted hover:text-accent-red hover:bg-accent-red/10":"text-dark-muted hover:text-dark-text hover:bg-dark-hover"}`,children:s})}function Vt({message:r,sessionId:t,onRegenerate:s,onDeleteMessage:n}){const{t:a}=W(),[o,d]=l.useState(!1),c=l.useRef(null);l.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const u=l.useCallback(async()=>{try{await navigator.clipboard.writeText(r.content||r.thinking||""),d(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>d(!1),2e3)}catch(i){console.error("Failed to copy message:",i)}},[r.content,r.thinking]);return t?e.jsxs(e.Fragment,{children:[e.jsx(nt,{onClick:u,title:a("chat.copyMessage"),children:o?e.jsx(ze,{size:12,className:"text-accent-green"}):e.jsx(on,{size:12})}),r.type==="assistant"&&s&&e.jsx(nt,{onClick:()=>s(r.id),title:a("chat.regenerate"),children:e.jsx($e,{size:12})}),n&&e.jsx(nt,{onClick:()=>n(r.id),title:a("chat.deleteMessage"),danger:!0,children:e.jsx(cn,{size:12})})]}):null}function Xt({ts:r,align:t,children:s}){const{i18n:n}=W(),a=n.language==="en"?"en-US":"zh-CN";return e.jsx("div",{className:"relative h-0 select-none",children:e.jsxs("div",{className:`absolute top-1 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 ${t==="right"?"right-0":"left-0"}`,children:[s,e.jsx("span",{className:"pl-1 text-[10px] text-dark-muted/50",children:new Date(r).toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"})})]})})}function Tr(r,t){const s=[];for(const n of r)s.push({key:`thinking-${n.index}`,index:n.index,kind:"thinking",block:n});for(const n of t??[])s.push({key:`tool-${n.id}`,index:n.index??Number.MAX_SAFE_INTEGER,kind:"tool",toolCall:n});return s.sort((n,a)=>n.index-a.index),s}function Ir({index:r,text:t,isGenerating:s,collapsed:n,onToggle:a}){const{t:o}=W();return e.jsxs("div",{children:[e.jsxs("button",{className:"flex items-center gap-1.5 cursor-pointer select-none py-0.5 text-xs",onClick:()=>a(r),"data-testid":"thinking-toggle",children:[e.jsx(fe,{size:12,className:`text-dark-muted transition-transform ${n?"":"rotate-90"}`}),e.jsx("span",{className:s?"text-accent-blue/90 animate-pulse":"text-dark-muted",children:s?`${o("chat.thinking")}…`:o("chat.thoughtProcess")})]}),!n&&e.jsx("div",{className:"mt-1 text-xs text-dark-muted whitespace-pre-wrap break-words border-l-2 border-dark-border/40 pl-3 max-h-64 overflow-y-auto custom-scrollbar",children:t.replace(/\n{3,}/g,`
|
|
14
|
-
|
|
15
|
-
`)})]})}const Pr=l.memo(function({message:t,sessionId:s,onRegenerate:n,onDeleteMessage:a}){var R,A,M;const{t:o}=W(),d=Ue(w=>w.developerView),c=ce(w=>{var _;if(!s||!w.generatingSessions.includes(s))return!1;const j=w.messagesBySession[s];return j?((_=j[j.length-1])==null?void 0:_.id)===t.id:!1}),u=l.useMemo(()=>t.thinkingBlocks&&t.thinkingBlocks.length>0?t.thinkingBlocks:t.thinking?[{index:Number.MIN_SAFE_INTEGER,text:t.thinking}]:[],[t.thinkingBlocks,t.thinking]),[i,p]=l.useState({}),f=l.useRef(c);l.useEffect(()=>{f.current&&!c&&p(w=>{const j={...w};for(const _ of u)j[_.index]=!0;return j}),f.current=c},[c,u]);const m=l.useMemo(()=>Tr(u,t.toolCalls),[u,t.toolCalls]),b=l.useMemo(()=>{const w=[];for(const j of m)if(j.kind==="thinking"&&j.block)w.push({key:j.key,kind:"thinking",block:j.block});else if(j.kind==="tool"&&j.toolCall){const _=w[w.length-1];_&&_.kind==="tools"?_.toolCalls.push(j.toolCall):w.push({key:`tools-${j.key}`,kind:"tools",toolCalls:[j.toolCall]})}return w},[m]),y=l.useCallback(w=>{p(j=>({...j,[w]:!(j[w]??!c)}))},[c]),k=t.type==="user",S=t.type==="system",x=l.useCallback((w,j)=>{if(!s)return;const F=ce.getState().getMessages(s),C=F.findIndex(v=>v.id===t.id);if(C===-1)return;const $=F[C];if(!$)return;const L={...$,hookApproval:$.hookApproval?{...$.hookApproval,status:j}:void 0},se=[...F];se[C]=L,ce.setState({messagesBySession:{...ce.getState().messagesBySession,[s]:se}})},[s,t.id]);if(t.deleted)return null;if(k)return e.jsx("div",{className:"group flex justify-end animate-fade-in-up px-1",children:e.jsxs("div",{className:"max-w-[92%] md:max-w-[78%]",children:[e.jsx("div",{className:"rounded-2xl rounded-br-md border border-dark-border/70 bg-dark-surface px-4 py-2.5 shadow-sm",children:e.jsx("div",{className:"text-dark-text whitespace-pre-wrap break-words leading-relaxed text-sm",children:(R=t.content)==null?void 0:R.replace(/\n{3,}/g,`
|
|
16
|
-
|
|
17
|
-
`)})}),e.jsx(Xt,{ts:t.timestamp,align:"right",children:e.jsx(Vt,{message:t,sessionId:s,onRegenerate:n,onDeleteMessage:a})})]})});if(S)return e.jsx("div",{className:"flex justify-center animate-fade-in-up px-1 py-1",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})});const N=!t.hookApproval&&!!(u.length>0||t.steps&&t.steps.length>0||t.toolCalls&&t.toolCalls.length>0);return e.jsx("div",{className:"group flex animate-fade-in-up px-1",children:e.jsxs("div",{className:"w-full max-w-full",children:[e.jsx(Xt,{ts:t.timestamp,align:"left",children:e.jsx(Vt,{message:t,sessionId:s,onRegenerate:n,onDeleteMessage:a})}),e.jsxs("div",{className:N?"pt-7":"",children:[t.steps&&t.steps.length>0&&!t.hookApproval?e.jsx(br,{steps:t.steps,isGenerating:c}):d?e.jsx(e.Fragment,{children:b.length>0&&!t.hookApproval&&e.jsx("div",{className:"mb-1 space-y-0.5",children:b.map(w=>w.kind==="thinking"?e.jsx(Ir,{index:w.block.index,text:w.block.text,isGenerating:c,collapsed:i[w.block.index]??!c,onToggle:y},w.key):e.jsx(kt,{toolCalls:w.toolCalls},w.key))})}):e.jsx($r,{message:t,sessionId:s,isGenerating:c}),t.content?e.jsx("div",{className:"leading-relaxed",children:e.jsx(In,{content:t.content.replace(/\n{3,}/g,`
|
|
18
|
-
|
|
19
|
-
`)})}):u.length===0&&!t.hookApproval&&((A=t.steps)!=null&&A.length)?null:u.length===0&&!t.hookApproval&&!((M=t.steps)!=null&&M.length)&&c?e.jsxs("div",{className:"flex items-center gap-3 py-1 text-xs text-dark-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.2s"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.4s"}})]}),o("chat.thinking"),"..."]}):null,t.summary&&!c&&e.jsx("div",{className:"mt-1.5 text-[11px] text-dark-muted/70","data-testid":"turn-summary",children:Pn(t.summary)}),t.fileJob&&e.jsx("div",{className:"mt-3",children:e.jsx(Cr,{job:t.fileJob})}),t.errorCard&&e.jsx("div",{className:"mt-3",children:e.jsx(_r,{error:t.errorCard,onRetry:s&&n?()=>n(t.id):void 0})}),t.hookApproval&&e.jsx("div",{className:"mt-3 border-l-2 border-accent-yellow/50 pl-3",children:e.jsx(Sr,{approval:t.hookApproval,onResolved:x})})]})]})})});function Dr(r,t=28){const s=r.replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t)}…`:s}const Lr="cubic-bezier(0.34, 1.56, 0.64, 1)",Or=l.memo(function({items:t,activeId:s,onJump:n}){const{t:a}=W(),[o,d]=l.useState(!1),c=l.useRef(null),u=l.useCallback(()=>{c.current&&window.clearTimeout(c.current),d(!0)},[]),i=l.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>d(!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:u,onMouseLeave:i,"data-testid":"rail-trigger",className:"pointer-events-auto relative flex items-center py-3",children:[e.jsxs("div",{"aria-hidden":!o,inert:!o,"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 ${o?"translate-x-0 scale-100 opacity-100":"pointer-events-none translate-x-4 scale-95 opacity-0"}`,style:{transitionTimingFunction:o?Lr:"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(dn,{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,f)=>{const m=p.id===s;return e.jsxs("button",{type:"button",role:"listitem",onClick:()=>n(p.id),title:p.content,"aria-current":m?"true":void 0,tabIndex:o?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 ${o?"translate-x-0 opacity-100":"translate-x-2 opacity-0"} ${m?"bg-accent-blue/10":"hover:bg-dark-hover"}`,style:{transitionDelay:o?`${Math.min(f*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 ${m?"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:f+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 ${m?"font-medium text-accent-blue":"text-dark-text/90"}`,children:p.content})}),e.jsx(fe,{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,f)=>{const m=Dr(p.content),b=p.id===s;return e.jsx("button",{type:"button",role:"listitem",onClick:()=>n(p.id),title:p.content,"aria-label":`${f+1}. ${m}`,"aria-current":b?"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:b?"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)})})]})})}),Br=l.memo(function({messages:t,isGenerating:s,sessionId:n,onSendSuggestion:a,onRegenerate:o,onDeleteMessage:d}){const{t:c}=W(),u=l.useRef(null),i=l.useRef(new Map),[p,f]=l.useState(!0),[m,b]=l.useState(null),[y,k]=l.useState(null),[S,x]=l.useState(0),N=l.useRef(null),R=l.useRef(s);R.current=s;const A=l.useMemo(()=>t.filter(v=>!v.deleted),[t]),M=l.useMemo(()=>A.filter(v=>v.type==="user").map(v=>({id:v.id,content:v.content})),[A]),w=l.useMemo(()=>M.map(v=>v.id),[M]),j=l.useCallback(v=>{if(v){const H=v.dataset.mid;H&&i.current.set(H,v)}},[]);l.useEffect(()=>{const v=new Set(w);for(const H of i.current.keys())v.has(H)||i.current.delete(H)},[w]);const _=l.useCallback(()=>{const v=u.current;if(!v||w.length===0){b(null);return}const H=v.getBoundingClientRect(),ne=H.top+H.height*.35;let J=w[0]??null;for(const ee of w){const O=i.current.get(ee);if(!(!O||!O.isConnected))if(O.getBoundingClientRect().top<=ne)J=ee;else break}v.scrollHeight-v.scrollTop-v.clientHeight<50&&(J=w[w.length-1]??J),b(J)},[w]),F=l.useCallback(()=>{const v=u.current;if(!v)return;const H=v.scrollHeight-v.scrollTop-v.clientHeight;f(H<50),_()},[_]);l.useEffect(()=>{_()},[t,_]);const C=l.useCallback(v=>{const H=u.current,ne=i.current.get(v);if(!H||!ne||!ne.isConnected)return;f(!1),k(v),x(X=>X+1),N.current&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>k(null),1600);const J=H.getBoundingClientRect(),ee=ne.getBoundingClientRect(),O=H.scrollTop+(ee.top-J.top)-H.clientHeight/2+ee.height/2;H.scrollTo({top:Math.max(0,O),behavior:"smooth"})},[]);l.useEffect(()=>()=>{N.current&&window.clearTimeout(N.current)},[]);const $=l.useCallback(()=>{const v=u.current;v&&(v.scrollTop=v.scrollHeight)},[]),L=l.useCallback(()=>{const v=u.current;v&&v.scrollTo({top:v.scrollHeight,behavior:"smooth"})},[]);l.useEffect(()=>{s&&(f(!0),$())},[s,$]),l.useEffect(()=>{p&&$()},[t,p,$]);const se=l.useMemo(()=>[{icon:un,label:c("chat.suggestionCode"),prompt:c("chat.suggestionCodePrompt")},{icon:os,label:c("chat.suggestionAnalyze"),prompt:c("chat.suggestionAnalyzePrompt")},{icon:cs,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:u,onScroll:F,className:"h-full overflow-y-auto custom-scrollbar",children:[A.length===0?e.jsx("div",{className:"flex min-h-[55vh] items-center justify-center p-6",children:e.jsxs("div",{className:"w-full max-w-xl px-4 text-center",children:[e.jsx("img",{src:"/logo.svg",alt:"deepseekcode",className:"w-14 h-14 mx-auto mb-5 rounded-2xl shadow-md"}),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:se.map(v=>e.jsxs("button",{onClick:()=>a(v.prompt),className:"group w-full rounded-xl border border-dark-border bg-dark-surface px-3.5 py-3 text-left transition-all duration-150 hover:border-accent-blue/40 hover:shadow-md hover:-translate-y-px",children:[e.jsx(v.icon,{size:16,"aria-hidden":"true",className:"text-accent-blue mb-2"}),e.jsx("div",{className:"text-[13px] font-medium text-dark-text",children:v.label}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-dark-muted line-clamp-2",children:v.prompt})]},v.label))})]})}):e.jsx("div",{className:"flex flex-col",children:A.map(v=>e.jsxs("div",{"data-mid":v.id,ref:j,className:"relative px-4 py-2",children:[y===v.id&&e.jsx("div",{className:"animate-rail-flash pointer-events-none absolute inset-0"},S),e.jsx(Pr,{message:v,sessionId:n,onRegenerate:o,onDeleteMessage:d})]},v.id))}),s&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted py-3 px-5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.2s"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.4s"}})]}),e.jsx("span",{children:c("chat.thinkingEllipsis")})]})]}),M.length>0&&e.jsx(Or,{items:M,activeId:m,onJump:C}),!p&&A.length>0&&e.jsx("button",{type:"button",onClick:L,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(de,{size:15})})]})}),Fr={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"},qr=l.memo(function(){const{t}=W(),s=we(u=>u.mode),n=we(u=>u.setBaseMode),a=we(u=>u.toggleAuto),o=s==="normal"?"act":s,d=fs(o),c=mt(o);return e.jsxs("div",{className:"flex items-center gap-1",children:[Dn.map(u=>{const i=d===u,p=Ln[u],f=s!=="normal"&&i?Fr[s]??"border-dark-border text-dark-muted":"border-dark-border text-dark-muted hover:bg-dark-hover";return e.jsx("button",{type:"button",onClick:()=>n(u),className:V("px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",f),title:t("chat.clickToSwitchMode"),"aria-pressed":i,children:p.label},u)}),e.jsxs("button",{type:"button",role:"switch","aria-checked":c,onClick:()=>a(),className:V("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($e,{size:11,className:V(c?"text-accent-yellow":"text-dark-muted")}),e.jsx("span",{children:t("plan.autoApprove")})]})]})}),Qt={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"}},Hr=l.memo(function(){const{t}=W(),s=ht(x=>x.model),n=ht(x=>x.setModel),a=we(x=>x.mode),o=Ue(x=>x.effort),d=Ue(x=>x.setEffort),[c,u]=l.useState([]),[i,p]=l.useState(!1),f=l.useRef(null),m=l.useCallback(async()=>{try{const x=await oe.models.list();x.success&&x.data&&Array.isArray(x.data.models)&&u(x.data.models.filter(N=>N.enabled!==!1))}catch{}},[]);l.useEffect(()=>{m()},[m]),l.useEffect(()=>{const x=()=>{m()};return window.addEventListener("models-updated",x),()=>window.removeEventListener("models-updated",x)},[m]);const b=l.useCallback(()=>p(!1),[]);l.useEffect(()=>{if(!i)return;const x=R=>{f.current&&!f.current.contains(R.target)&&b()},N=R=>{R.key==="Escape"&&b()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",N)}},[i,b]);const y=async x=>{b();const N=fs(a==="normal"?"act":a),R=`${x.provider}:${x.id}`,A=N==="plan"?{plan:R}:N==="goal"?{goal:R}:{global:R,act:R};try{(await oe.models.setDefaults(A)).success&&(n(x.id),await m())}catch{}},k=x=>s===x.id||s===`${x.provider}:${x.id}`,S=Qt[o];return e.jsxs("div",{className:"relative",ref:f,children:[e.jsxs("button",{type:"button",onClick:()=>p(x=>!x),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:t("chat.clickToSelectModel"),"aria-haspopup":"listbox","aria-expanded":i,children:[e.jsx(xn,{size:12,className:"shrink-0"}),e.jsx("span",{className:"font-medium max-w-[8rem] truncate",children:s||t("chat.selectModel")}),e.jsx("span",{className:"h-3 w-px bg-dark-border shrink-0","aria-hidden":"true"}),e.jsx(Mt,{size:12,className:`shrink-0 ${S.color}`}),e.jsx("span",{className:`text-xs font-medium ${S.color}`,children:t(S.labelKey)}),e.jsx(de,{size:12,className:V("transition-transform",i&&"rotate-180")})]}),i&&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.jsxs("div",{className:"py-1 max-h-[32vh] overflow-y-auto custom-scrollbar",children:[c.map(x=>{const N=k(x);return e.jsx("button",{type:"button",role:"option","aria-selected":N,onClick:()=>y(x),className:V("w-full flex items-center gap-2 px-3 py-2 text-left transition-colors",N?"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:V("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",N?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(ze,{size:11,strokeWidth:3})}),e.jsx("span",{className:"text-xs font-semibold text-dark-text truncate",children:x.name||x.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",children:x.provider}),x.isGlobalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-green/20 text-accent-green",children:t("chat.globalDefault")}),x.isPlanDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-blue/20 text-accent-blue",children:t("chat.planDefault")}),x.isActDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-yellow/20 text-accent-yellow",children:t("chat.actDefault")}),x.isGoalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-purple/20 text-accent-purple",children:t("chat.goalDefault")})]})]})},`${x.provider}:${x.id}`)}),c.length===0&&e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t("chat.noEnabledModels")})]}),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(Mt,{size:11}),t("chat.effort")]}),e.jsx("div",{className:"py-1",children:On.map(x=>{const N=Qt[x],R=x===o;return e.jsxs("button",{type:"button",role:"option","aria-selected":R,onClick:()=>{d(x),b()},className:V("w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors",R?"bg-dark-hover":"hover:bg-dark-hover"),children:[e.jsx("span",{className:V("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",R?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(ze,{size:11,strokeWidth:3})}),e.jsx("span",{className:`text-xs font-medium ${R?N.color:"text-dark-text"}`,children:t(N.labelKey)})]},x)})})]})]})});function Jr(r,t){if(!r)return t;const s=r.includes("\\")?"\\":"/";return r.endsWith(s)?r+t:r+s+t}function Ur(r){const t=r.replace(/[\\/]+$/,""),s=Math.max(t.lastIndexOf("\\"),t.lastIndexOf("/"));return s===-1?t:t.slice(s+1)}function Wr({initial:r,onClose:t,onConfirm:s}){const{t:n}=W(),[a,o]=l.useState(r),[d,c]=l.useState(null),[u,i]=l.useState([]),[p,f]=l.useState(!1),[m,b]=l.useState(""),[y,k]=l.useState(r),S=l.useRef(null),x=l.useCallback(async A=>{f(!0),b("");try{const M=await oe.dirs.list(A);if(!M.success||!M.data){b(M.error||n("chat.dirPickerLoadError"));return}o(M.data.path),c(M.data.parent),i(M.data.dirs||[]),k(M.data.path)}catch(M){b(M instanceof Error?M.message:n("chat.dirPickerLoadError"))}finally{f(!1)}},[n]);l.useEffect(()=>{x(r)},[r,x]),l.useEffect(()=>{var A;(A=S.current)==null||A.focus()},[]),l.useEffect(()=>{const A=M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),t())};return document.addEventListener("keydown",A),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",A),document.body.style.overflow=""}},[t]);const N=l.useCallback(()=>{const A=y.trim();A&&x(A)},[y,x]),R=l.useCallback(()=>{d&&x(d)},[d,x]);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(ds,{size:15,className:"text-accent-blue","aria-hidden":"true"}),n("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":n("a11y.close"),children:e.jsx(je,{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(pn,{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:S,value:y,onChange:A=>k(A.target.value),onKeyDown:A=>{A.key==="Enter"&&N()},placeholder:n("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
|
|
20
|
-
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:N,disabled:p||!y.trim(),className:`shrink-0 rounded-lg border border-dark-border px-2.5 py-1.5 text-xs text-dark-muted
|
|
21
|
-
hover:bg-dark-hover hover:text-dark-text disabled:opacity-40 transition-colors`,children:n("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||n("chat.noWorkspaceDir")}),e.jsxs("button",{type:"button",onClick:()=>void R(),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
|
|
22
|
-
hover:bg-dark-hover hover:text-dark-text disabled:opacity-40 transition-colors`,children:[e.jsx(us,{size:12,"aria-hidden":"true"}),n("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(Re,{size:14,className:"animate-spin","aria-hidden":"true"}),n("chat.loading")]}):m?e.jsx("div",{className:"px-3 py-4 text-xs text-accent-red",children:m}):u.length===0?e.jsx("div",{className:"px-3 py-4 text-xs text-dark-muted/60 text-center",children:n("chat.dirPickerNoDirs")}):u.map(A=>{const M=Jr(a,A);return e.jsxs("button",{type:"button",onClick:()=>void x(M),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs text-dark-text
|
|
23
|
-
hover:bg-dark-hover transition-colors group`,children:[e.jsx(gt,{size:13,className:"shrink-0 text-accent-yellow/80 group-hover:text-accent-yellow","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:A}),e.jsx(fe,{size:12,className:"shrink-0 ml-auto text-dark-muted/40","aria-hidden":"true"})]},A)})}),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
|
|
24
|
-
hover:bg-accent-blue disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:n("chat.dirPickerConfirm")})]})]})]})}const Kr=l.memo(function({workspaceDir:t,onSelect:s}){const{t:n}=W(),a=Ue(f=>f.recentDirs),[o,d]=l.useState(!1),[c,u]=l.useState(!1),i=l.useRef(null);l.useEffect(()=>{if(!o)return;const f=b=>{i.current&&!i.current.contains(b.target)&&d(!1)},m=b=>{b.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",m)}},[o]);const p=l.useCallback(f=>{var b;const m=((b=f==null?void 0:f.trim)==null?void 0:b.call(f))||"";m&&(d(!1),u(!1),s(m))},[s]);return e.jsxs("div",{className:"relative shrink-0",ref:i,children:[e.jsxs("button",{type:"button",onClick:()=>d(f=>!f),className:V("flex items-center gap-1 max-w-[180px] px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",o?"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:n("chat.clickToSwitchDir"),"aria-label":n("chat.clickToSwitchDir"),"aria-expanded":o,"aria-haspopup":"menu",children:[e.jsx(ds,{size:12,className:"shrink-0 text-accent-blue/80","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[11px]",children:t?Ur(t):n("chat.noWorkspaceDir")}),e.jsx(de,{size:11,className:V("shrink-0 transition-transform",o&&"rotate-180"),"aria-hidden":"true"})]}),o&&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:n("chat.recentDirs")}),a.length===0?e.jsx("div",{className:"px-3 pb-2 text-[11px] text-dark-muted/50 select-none",children:n("chat.noRecentDirs")}):e.jsx("div",{className:"max-h-56 overflow-y-auto custom-scrollbar",children:a.map(f=>{const m=f===t;return e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>p(f),className:V("w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors group",m?"text-accent-blue bg-accent-blue/5":"text-dark-text hover:bg-dark-hover"),title:f,children:[e.jsx(gt,{size:12,className:V("shrink-0",m?"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:f}),m&&e.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-accent-blue",children:"✓"})]},f)})}),e.jsx("div",{className:"border-t border-dark-border"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{d(!1),u(!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(fe,{size:13,"aria-hidden":"true"}),n("chat.chooseOtherDir")]})]}),c&&e.jsx(Wr,{initial:t||"",onClose:()=>u(!1),onConfirm:p})]})});function Gr({isOpen:r,files:t,selectedIndex:s,query:n,isSearching:a,onSelect:o,onHover:d,selectedCount:c=0,onFinish:u}){return r?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:n?`@${n}`:"@ file"}),e.jsxs("span",{className:"opacity-70 flex items-center gap-2",children:[c>0&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-accent-blue/20 text-accent-blue font-medium",children:["已选 ",c]}),e.jsx("span",{children:"↑↓ 选择 · Enter 插入(可连续多选)· Esc 关闭"})]})]}),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(Re,{size:16,className:"animate-spin"}),e.jsx("span",{children:"搜索文件中..."})]}):e.jsx("span",{children:"未找到匹配的文件"})}):t.map((i,p)=>e.jsxs("button",{onClick:()=>o(i),onMouseEnter:()=>d(p),className:`w-full px-3 py-1.5 flex items-center gap-2 text-left text-xs transition-colors border-l-2 ${p===s?"bg-accent-blue/20 text-accent-blue border-accent-blue":"hover:bg-dark-hover text-dark-text border-transparent"}`,children:[i.type==="directory"?e.jsx(gt,{size:12,className:"text-accent-yellow shrink-0"}):e.jsx(bt,{size:12,className:"text-dark-muted shrink-0"}),e.jsx("span",{className:"truncate",children:i.name}),e.jsx("span",{className:"text-[10px] text-dark-muted truncate ml-auto",children:i.path})]},i.id||i.path))]}),u&&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?`已选 ${c} 个文件`:"Enter 插入 · 可连续多选"}),e.jsx("button",{onClick:u,className:"px-3 py-1 text-[11px] rounded bg-accent-blue text-white hover:opacity-90 transition-opacity",children:"完成引用"})]})]}):null}function Zr({open:r,onClose:t,onSelect:s}){const{t:n}=W(),[a,o]=l.useState([]),[d,c]=l.useState(!1),[u,i]=l.useState("");l.useEffect(()=>{r&&(i(""),c(!0),oe.skills.list().then(f=>{const m=Array.isArray(f.data)?f.data:[];o(m.filter(b=>b.enabled!==!1))}).catch(()=>o([])).finally(()=>c(!1)))},[r]);const p=l.useMemo(()=>{const f=u.trim().toLowerCase();return f?a.filter(m=>[m.id,m.name,m.description,m.category,...m.tags||[]].join(" ").toLowerCase().includes(f)):a},[a,u]);return e.jsx(Bn,{isOpen:r,onClose:t,title:n("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(os,{size:14,className:"text-dark-muted shrink-0"}),e.jsx("input",{value:u,onChange:f=>i(f.target.value),placeholder:n("skills.pickPlaceholder"),autoFocus:!0,className:"flex-1 bg-transparent outline-none text-sm placeholder-dark-muted/60"}),d&&e.jsx($e,{size:13,className:"animate-spin text-dark-muted"})]}),d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx($e,{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:n("skills.pickEmpty")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:p.map(f=>e.jsxs("button",{onClick:()=>s(f),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:[f.icon||"⭐"," ",f.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:f.injection||"lazy"})]}),e.jsxs("div",{className:"text-xs text-dark-muted truncate font-mono",children:["$",f.id]}),f.description&&e.jsx("div",{className:"text-xs text-dark-muted line-clamp-2",children:f.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:f.category||"—"}),e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-accent-blue shrink-0",children:[e.jsx(cs,{size:11}),n("skills.pickUse")]})]})]},f.id))})]})})}const Vr=800,Yt=/\[Pasted text #(\d+)(?:\s*\+\d+ lines?)?\]/g;let Xr=0;const $s=new Map;function Qr(r){const t=++Xr;return $s.set(t,r),t}function Yr(r){return r.length>Vr||Ts(r)>0}function Ts(r){return(r.match(/\r\n|\r|\n/g)||[]).length}function ea(r){const t=Qr(r),s=Ts(r);return s===0?{id:t,label:`[Pasted text #${t}]`}:{id:t,label:`[Pasted text #${t} +${s} lines]`}}function ta(r){return Yt.lastIndex=0,r.replace(Yt,(t,s)=>{const n=parseInt(s,10),a=$s.get(n);return a!==void 0?a:t})}const Je=16e3;function rt(){const r=["audio/webm;codecs=opus","audio/webm","audio/mp4"];if(typeof MediaRecorder>"u")return"";for(const t of r)if(MediaRecorder.isTypeSupported(t))return t;return""}async function sa(r){if(r.sampleRate===Je&&r.numberOfChannels===1)return r.getChannelData(0);const t=Math.max(1,Math.ceil(r.length*Je/r.sampleRate)),s=new OfflineAudioContext(1,t,Je),n=s.createBufferSource();return n.buffer=r,n.connect(s.destination),n.start(0),(await s.startRendering()).getChannelData(0)}function na(r,t){const s=new ArrayBuffer(44+r.length*2),n=new DataView(s),a=(d,c)=>{for(let u=0;u<c.length;u++)n.setUint8(d+u,c.charCodeAt(u))};a(0,"RIFF"),n.setUint32(4,36+r.length*2,!0),a(8,"WAVE"),a(12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,1,!0),n.setUint32(24,t,!0),n.setUint32(28,t*2,!0),n.setUint16(32,2,!0),n.setUint16(34,16,!0),a(36,"data"),n.setUint32(40,r.length*2,!0);let o=44;for(let d=0;d<r.length;d++){const c=Math.max(-1,Math.min(1,r[d]??0));n.setInt16(o,c<0?c*32768:c*32767,!0),o+=2}return s}function ra(r){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>{const a=String(n.result||""),o=a.indexOf(",");t(o>=0?a.slice(o+1):a)},n.onerror=()=>s(n.error),n.readAsDataURL(r)})}function aa(r){const[t,s]=l.useState("idle"),[n,a]=l.useState(0),o=l.useRef(null),d=l.useRef(null),c=l.useRef([]),u=l.useRef(null),i=l.useRef(0),p=l.useCallback(()=>{var k;(k=d.current)==null||k.getTracks().forEach(S=>S.stop()),d.current=null},[]),f=l.useCallback(()=>{u.current&&(clearInterval(u.current),u.current=null)},[]);l.useEffect(()=>()=>{f(),o.current&&o.current.state!=="inactive"&&o.current.stop(),p()},[f,p]);const m=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(x){throw x instanceof DOMException&&x.name==="NotAllowedError"?new Error("麦克风权限被拒绝。请在浏览器地址栏允许麦克风权限后重试。"):new Error("无法访问麦克风:"+(x instanceof Error?x.message:String(x)))}d.current=k,c.current=[];const S=new MediaRecorder(k,rt()?{mimeType:rt()}:void 0);S.ondataavailable=x=>{x.data&&x.data.size>0&&c.current.push(x.data)},o.current=S,S.start(),i.current=Date.now(),a(0),s("recording"),u.current=setInterval(()=>a(Date.now()-i.current),100)},[t]),b=l.useCallback(async()=>{var x;const k=o.current;if(!k||k.state==="inactive")throw new Error("当前没有进行中的录音。");const S=new Promise(N=>{k.onstop=()=>N()});k.stop(),await S,f(),p(),o.current=null,s("transcribing");try{const N=new Blob(c.current,{type:rt()||"audio/webm"});c.current=[];const R=await N.arrayBuffer(),A=new AudioContext;let M;try{M=await A.decodeAudioData(R)}finally{A.close()}if(M.duration<.25)return s("idle"),"";const j=await sa(M),_=na(j,Je),F=await ra(new Blob([_],{type:"audio/wav"})),C=await oe.stt.transcribe(r,F,"wav");if(!C.success)throw new Error(C.error||"语音转写失败");return((x=C.data)==null?void 0:x.text)??""}finally{s("idle")}},[r,f,p]),y=l.useCallback(()=>{const k=o.current;k&&k.state!=="inactive"&&k.stop(),o.current=null,c.current=[],f(),p(),s("idle")},[f,p]);return{state:t,elapsedMs:n,start:m,stop:b,cancel:y}}function la(){return typeof window<"u"&&!!window.__TAURI__}async function ia(){const r=window.__TAURI__;if(!r)return null;try{const t=await r.core.invoke("pick_files");return Array.isArray(t)?t.map(s=>String(s)).filter(Boolean):null}catch(t){return console.warn("[native] pick_files failed, falling back to browser picker:",t),null}}const oa=({isOpen:r,commands:t,selectedIndex:s,filter:n,onSelect:a,onHover:o,containerRef:d})=>{const{t:c}=W();return!r||t.length===0?null:e.jsxs("div",{ref:d,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:n?`/${n}`:c("slashCommands.quickCommands")}),e.jsx("span",{className:"opacity-70",children:c("slashCommands.help")})]}),t.map((u,i)=>e.jsxs("button",{"data-index":i,onClick:()=>a(u),onMouseEnter:()=>o(i),className:`w-full px-3 py-2 flex items-start gap-3 text-left transition-colors border-l-2 ${i===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:u.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:["/",u.name]}),u.args&&e.jsx("span",{className:"text-xs text-dark-muted",children:u.args}),!u.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:u.description})]}),i===s&&e.jsx(mn,{size:14,className:"text-dark-muted shrink-0 mt-0.5","aria-hidden":"true"})]},u.id))]})},Is=["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"],es=new RegExp(`(?:\\.(${Is.join("|")})|dockerfile|makefile)$`,"i"),ca=Is.map(r=>`.${r}`).join(",")+",.Dockerfile,.Makefile",da=".deepseekcode/attachments",ua=50*1024*1024,He=10,xa=r=>/\.xlsx?$/i.test(r)?xt:/\.(csv|docx|txt|md|mdx|rst|adoc|json|jsonc|yaml|yml|toml|xml|html|css|scss|less|env|gitignore|gitattributes|editorconfig)$/i.test(r)?ut:/\.(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(r)?wn:bt,at=3e3,ts=5,lt=50;function pa(r,t){const s=r.slice(0,t),n=s.lastIndexOf("@");if(n===-1)return{active:!1,query:"",start:-1};const a=s.slice(n+1);return/^[\p{L}\p{N}_\-./]*$/u.test(a)?{active:!0,query:a,start:n}:{active:!1,query:"",start:-1}}function ma(r,t){const s=r.lastIndexOf(`
|
|
25
|
-
`,t-1)+1,n=r.slice(s,t);return n.startsWith("/")?/\s/.test(n)?{active:!1,query:""}:{active:!0,query:n.slice(1)}:{active:!1,query:""}}const ha=l.memo(function({sessionId:t,onSend:s,onStop:n,onPause:a,onResume:o,slashOptions:d,workspaceDir:c,onWorkspaceSelect:u}){const{t:i}=W(),p=ce(h=>{var g;return((g=h.sessionInputs)==null?void 0:g[t])??""}),f=ce(h=>h.setSessionInput),m=ce(h=>{var g;return((g=h.generatingSessions)==null?void 0:g.includes(t))??!1}),b=ce(h=>{var g;return((g=h.pausedSessions)==null?void 0:g.includes(t))??!1}),y=l.useRef(null),k=l.useRef(null),S=l.useRef(!1),[x,N]=l.useState([]),[R,A]=l.useState(!1),[M,w]=l.useState(!1),j=l.useCallback(h=>{f(t,h)},[t,f]),[_,F]=l.useState(()=>{try{return localStorage.getItem("dsc.stt.lang")==="zh"?"zh":"en"}catch{return"en"}}),C=l.useCallback(()=>{F(h=>{const g=h==="en"?"zh":"en";try{localStorage.setItem("dsc.stt.lang",g)}catch{}return g})},[]),$=aa(_),L=l.useRef(null),se=l.useCallback(async()=>{var h;try{if(!L.current){const T=await oe.stt.status();T.success&&T.data&&(L.current=T.data)}const g=L.current;if(!g)return!0;if(g.service!=="ok"&&g.service!=="stopped")return Y.warning(i("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1;const z=(h=g.backends)==null?void 0:h[_];return z&&!z.installed?(Y.warning(i("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1):!0}catch{return!0}},[i,_]);l.useEffect(()=>{const h=()=>{L.current=null};return window.addEventListener("stt-backends-changed",h),()=>window.removeEventListener("stt-backends-changed",h)},[]),l.useEffect(()=>{const h=g=>{var T;const z=(T=g.detail)==null?void 0:T.lang;(z==="en"||z==="zh")&&F(z)};return window.addEventListener("stt-lang-changed",h),()=>window.removeEventListener("stt-lang-changed",h)},[]);const v=l.useCallback(h=>{const g=y.current,z=(g==null?void 0:g.selectionStart)??p.length,T=p.slice(0,z)+h+p.slice(z);j(T),requestAnimationFrame(()=>{g==null||g.focus();const D=z+h.length;g&&(g.selectionStart=g.selectionEnd=D)})},[p,j]),H=l.useCallback(async()=>{if($.state==="recording"){try{const g=await $.stop();g?v(g):Y.info(i("stt.noSpeech"))}catch(g){Y.error(g instanceof Error?g.message:String(g))}return}if(!($.state!=="idle"||!await se()))try{await $.start()}catch(g){Y.error(g instanceof Error?g.message:String(g))}},[$,v,se,i]),ne=Fn(d),{isOpen:J,filter:ee,filteredCommands:O,selectedIndex:X,setSelectedIndex:ie,selectNext:re,selectPrev:ue,executeCommand:Z,openMenu:pe,closeMenu:Q,setFilter:ge,allCommands:E,containerRef:B}=ne,[I,q]=l.useState(!1),[te,me]=l.useState(""),[xe,ke]=l.useState([]),[We,Ne]=l.useState(0),[Ds,vt]=l.useState(!1),[Ls,Te]=l.useState(0),Se=l.useRef(-1),Ce=l.useRef(new Set),Ie=l.useRef(null),Oe=l.useRef(null),Ke=l.useRef([]),be=l.useRef(!1);l.useEffect(()=>{Ce.current=new Set,be.current=!1,q(!1),me(""),ke([]),Te(0),Q()},[t,Q]);const jt=l.useDeferredValue(p),Nt=ht(h=>h.estimateTokens),Ge=l.useMemo(()=>Nt(jt),[jt,Nt]),St=l.useCallback(()=>{const h=y.current;h&&(h.style.height="auto",h.style.height=Math.min(h.scrollHeight,200)+"px")},[]);l.useEffect(()=>{St()},[p,x.length,St]);const Ze=l.useCallback(()=>{if(Ie.current)return Promise.resolve(Ie.current);if(Oe.current)return Oe.current;vt(!0);const h=(async()=>{try{const g=await oe.files.list(),z=g.success&&g.data?g.data[0]:void 0;if(!z)return Ie.current=[],[];const T=[],D=new Set,P=async(U,K)=>{if(K>ts||T.length>=at)return;const he=[];for(const le of U||[]){if(T.length>=at)return;const _e=le.path.replace(/\\/g,"/");D.has(_e)||(D.add(_e),le.type==="file"?T.push({...le,path:_e}):le.children&&le.children.length>0?await P(le.children,K+1):K<ts&&he.push(le))}if(he.length===0)return;const ae=await Promise.all(he.map(async le=>{var _e;try{const Qe=await oe.files.list(le.path.replace(/\\/g,"/"));return Qe.success&&Qe.data?((_e=Qe.data[0])==null?void 0:_e.children)||[]:[]}catch{return[]}}));for(const le of ae){if(T.length>=at)return;await P(le,K+1)}};return await P(z.children,1),Ie.current=T,T}catch{return Ie.current=[],[]}finally{Oe.current=null,vt(!1)}})();return Oe.current=h,h},[]),Ct=l.useCallback(async(h,g)=>{if(be.current){const U=Se.current;if(U<0||g<U){be.current=!1,q(!1);return}const K=h.slice(U,g);if(/\s/.test(K)){be.current=!1,q(!1);return}Se.current=U,me(K),q(!0),Ne(0);const he=await Ze();Ke.current=he;const ae=K.toLowerCase();ke(he.filter(le=>!ae||le.path.toLowerCase().includes(ae)).slice(0,lt));return}const z=pa(h,g);if(!z.active){I&&q(!1);return}Se.current=z.start,me(z.query),q(!0),Ne(0);const T=await Ze();Ke.current=T;const D=z.query.toLowerCase(),P=T.filter(U=>!D||U.path.toLowerCase().includes(D)).slice(0,lt);ke(P)},[I,Ze]),Os=l.useCallback(h=>{const g=h.target.value,z=h.target.selectionStart??g.length;j(g),Ct(g,z);const T=ma(g,z);T.active?(J||pe(),ge(T.query),ie(0)):J&&Q()},[j,Ct,J,pe,ge,ie,Q]),Ve=l.useCallback(h=>{const g=y.current,z=p,T=Se.current>=0?Se.current:(g==null?void 0:g.selectionStart)??z.length,D=Math.min(z.length,T+1+te.length),P=`@${h.path} `,U=z.slice(0,T)+P+z.slice(D);Ce.current.add(h.path),j(U),q(!0),me(""),ke(Ke.current.slice(0,lt)),Ne(0),Te(Ce.current.size),Se.current=T+P.length,be.current=!0,requestAnimationFrame(()=>{g==null||g.focus(),g&&(g.selectionStart=g.selectionEnd=T+P.length)})},[p,te,j]),Pe=l.useCallback(()=>{be.current=!1,q(!1),me(""),Te(0)},[]),Xe=l.useCallback(h=>{if(!h.args){const P=Z(h,"");P!=null&&P.message&&(P.success?Y.success(P.message):Y.error(P.message)),j("");return}const g=y.current,z=(g==null?void 0:g.selectionStart)??p.length,T=p.lastIndexOf(`
|
|
26
|
-
`,z-1)+1,D=p.slice(0,T)+`/${h.name} `+p.slice(z);j(D),Q(),requestAnimationFrame(()=>{g==null||g.focus();const P=T+h.name.length+2;g&&(g.selectionStart=g.selectionEnd=P)})},[p,j,Z,Q]),Bs=l.useCallback(h=>{const g=y.current,z=(g==null?void 0:g.selectionStart)??p.length,T=`$${h.id} `,D=p.slice(0,z)+T+p.slice(z);j(D),w(!1),be.current=!1,q(!1),me(""),requestAnimationFrame(()=>{g==null||g.focus();const P=z+T.length;g&&(g.selectionStart=g.selectionEnd=P)})},[p,j]),Ee=l.useCallback(h=>{const g=Array.from(h);N(z=>{const T=He-z.length,D=z.slice();for(const P of g.slice(0,T)){if(!es.test(P.name)){Y.warning(i("fileJob.unsupportedType",{name:P.name}));continue}if(P.size>ua){Y.error(i("fileJob.fileTooLarge",{name:P.name}));continue}if(D.some(U=>U.name===P.name)){Y.warning(i("fileJob.duplicateFile",{name:P.name}));continue}D.push({id:`att-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,file:P,name:P.name,size:P.size,uploading:!1})}return D.length>=He&&Y.warning(i("fileJob.maxAttachments",{n:He})),D})},[i]),Fs=l.useCallback(h=>{h.target.files&&h.target.files.length>0&&(Ee(h.target.files),h.target.value="")},[Ee]),qs=l.useCallback(async()=>{var h;if(la()){const g=await ia();if(!g||g.length===0)return;const z=await oe.fileJob.importPaths(g);if(z.success&&Array.isArray(z.data)){const T=z.data.filter(D=>es.test(D.name)).map(D=>({id:`att-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:D.name,size:D.size,uploading:!1,path:D.path.replace(/\\/g,"/")}));N(D=>{const P=He-D.length;return[...D,...T.slice(0,P)]})}else Y.error(z.error||i("fileJob.importFailed"))}else(h=k.current)==null||h.click()},[i]),Hs=l.useCallback(h=>{N(g=>g.filter(z=>z.id!==h))},[]),Js=l.useCallback(h=>{h.preventDefault(),A(!0)},[]),Us=l.useCallback(h=>{h.preventDefault(),A(!1)},[]),Ws=l.useCallback(h=>{h.preventDefault(),A(!1),h.dataTransfer.files&&h.dataTransfer.files.length>0&&Ee(h.dataTransfer.files)},[Ee]),Et=l.useCallback(async()=>{var g;if(x.length===0)return"";const h=[];for(const z of x){if(z.path){h.push(`<attachment path="${z.path}" />`);continue}if(!z.file)continue;N(P=>P.map(U=>U.id===z.id?{...U,uploading:!0,error:void 0}:U));const T=`${da}/${z.name}`,D=await oe.files.upload(z.file,T);if(D.success&&((g=D.data)!=null&&g.path)){const P=D.data.path.replace(/\\/g,"/");N(U=>U.map(K=>K.id===z.id?{...K,uploading:!1,path:P}:K)),h.push(`<attachment path="${P}" />`)}else N(P=>P.map(U=>U.id===z.id?{...U,uploading:!1,error:D.error||i("fileJob.uploadFailed")}:U)),Y.error(`${z.name}: ${D.error||i("fileJob.uploadFailed")}`)}return h.length>0?`${h.join(`
|
|
27
|
-
`)}
|
|
28
|
-
|
|
29
|
-
`:""},[x,i]),Ks=l.useCallback(h=>{const g=h.clipboardData.getData("text/plain");if(h.clipboardData.files&&h.clipboardData.files.length>0){h.preventDefault(),Ee(h.clipboardData.files);return}if(!g||!Yr(g))return;h.preventDefault();const{label:z}=ea(g),T=y.current;if(!T)return;const D=T.selectionStart,P=T.selectionEnd,U=T.value,K=U.slice(0,D)+z+U.slice(P);j(K),requestAnimationFrame(()=>{T.selectionStart=T.selectionEnd=D+z.length})},[j,Ee]),Be=l.useCallback(async()=>{const h=ta(p);be.current=!1,q(!1),Q();const g=h.trim(),z=x.length>0;if(!g&&!z)return;const T=h.trim();if(T.startsWith("/")&&!z){const K=qn(T);if(K){const he=E.find(ae=>ae.name===K.command);if(he){const ae=Z(he,K.args);ae!=null&&ae.message&&(ae.success?Y.success(ae.message):Y.error(ae.message)),j(""),N([]),Ce.current=new Set,Te(0);return}Y.error(i("slashCommands.unknownCommand",{cmd:`/${K.command}`}));return}}const D=Array.from(Ce.current).filter(K=>h.includes(`@${K}`));let P="";if(z){if(x.some(K=>K.uploading)){Y.warning(i("fileJob.stillUploading"));return}P=await Et()}const U=(P+h).trim();!U&&!z||(s(U||P.trim(),D.length>0?D:void 0),j(""),N([]),Ce.current=new Set,Te(0))},[p,x,s,j,Et,i,Q,E,Z]),Gs=l.useCallback(h=>{if(!h.nativeEvent.isComposing){if(I&&xe.length>0){if(h.key==="ArrowDown"){h.preventDefault(),Ne(g=>(g+1)%xe.length);return}if(h.key==="ArrowUp"){h.preventDefault(),Ne(g=>(g-1+xe.length)%xe.length);return}if(h.key==="Enter"&&!h.shiftKey&&!h.ctrlKey&&!h.metaKey){const g=xe[We];g&&(h.preventDefault(),Ve(g));return}if(h.key==="Escape"){h.preventDefault(),Pe();return}}else if(I&&h.key==="Escape"){h.preventDefault(),Pe();return}if(J&&O.length>0){if(h.key==="ArrowDown"){h.preventDefault(),re();return}if(h.key==="ArrowUp"){h.preventDefault(),ue();return}if(h.key==="Enter"&&!h.shiftKey&&!h.ctrlKey&&!h.metaKey){const g=O[X];g&&(h.preventDefault(),Xe(g));return}if(h.key==="Escape"){h.preventDefault(),Q();return}}else if(J&&h.key==="Escape"){h.preventDefault(),Q();return}if(h.key==="Escape"&&m){h.preventDefault(),b?o():a();return}if(h.key==="Enter"&&(h.ctrlKey||h.metaKey)){h.preventDefault(),Be();return}h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),Be())}},[m,b,Be,a,o,I,xe,We,Ve,Pe,J,O,X,re,ue,Xe,Q]),Zs=l.useCallback(()=>{S.current=!0},[]),Vs=l.useCallback(()=>{S.current=!1},[]),_t=Ge>8e3,Xs=p.trim().length>0||x.length>0;return e.jsxs("div",{className:"shrink-0 px-3 sm:px-4 pb-3 pt-2 bg-dark-bg",onDragOver:Js,onDragLeave:Us,onDrop:Ws,children:[x.length>0&&e.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:x.map(h=>{const g=xa(h.name);return e.jsxs("div",{className:V("flex items-center gap-1.5 rounded-lg border px-2 py-1 text-xs transition-colors",h.error?"border-accent-red/40 bg-accent-red/5 text-accent-red":h.uploading?"border-accent-blue/40 bg-accent-blue/5 text-accent-blue":"border-dark-border bg-dark-surface text-dark-text"),children:[h.uploading?e.jsx(Re,{size:13,className:"animate-spin"}):e.jsx(g,{size:13}),e.jsx("span",{className:"max-w-[140px] truncate",children:h.name}),e.jsx("span",{className:"text-[10px] text-dark-muted",children:h.size>1024*1024?`${(h.size/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(h.size/1024))} KB`}),!h.uploading&&e.jsx("button",{onClick:()=>Hs(h.id),className:"rounded p-0.5 text-dark-muted hover:text-accent-red hover:bg-accent-red/10 transition-colors","aria-label":i("a11y.close"),children:e.jsx(je,{size:11})})]},h.id)})}),R&&e.jsx("div",{className:"mb-2 rounded-2xl border-2 border-dashed border-accent-blue/50 bg-accent-blue/5 py-3 text-center text-xs text-accent-blue",children:i("fileJob.dropHint")}),e.jsxs("div",{className:"relative rounded-2xl border border-dark-border bg-dark-surface shadow-sm transition-all duration-150 focus-within:border-accent-blue/50 focus-within:ring-4 focus-within:ring-accent-blue/10",children:[I&&e.jsx("div",{onMouseDown:h=>h.preventDefault(),"aria-hidden":!I,children:e.jsx(Gr,{isOpen:I,files:xe,selectedIndex:We,query:te,isSearching:Ds,onSelect:Ve,onHover:Ne,selectedCount:Ls,onFinish:Pe})}),J&&e.jsx("div",{onMouseDown:h=>h.preventDefault(),"aria-hidden":!J,children:e.jsx(oa,{isOpen:J,commands:O,selectedIndex:X,filter:ee,onSelect:Xe,onHover:ie,containerRef:B})}),e.jsx("textarea",{ref:y,value:p,onChange:Os,onKeyDown:Gs,onPaste:Ks,onBlur:()=>{I&&Pe(),Q()},onCompositionStart:Zs,onCompositionEnd:Vs,placeholder:i(m?"chat.generatingPlaceholder":"chat.inputPlaceholder"),rows:1,disabled:m&&!b,"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
|
|
30
|
-
resize-none focus:outline-none min-h-[44px] max-h-[40vh] leading-relaxed
|
|
31
|
-
disabled:opacity-50 disabled:cursor-not-allowed`}),e.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-2.5",children:[u&&e.jsx(Kr,{workspaceDir:c,onSelect:u}),e.jsx(qr,{}),e.jsx("span",{className:"hidden sm:block",children:e.jsx(Hr,{})}),e.jsx("div",{className:"flex-1"}),Ge>0&&p.length>0&&e.jsxs("span",{className:`text-[10px] tabular-nums ${_t?"text-accent-red font-medium":"text-dark-muted/60"}`,children:["~",Ge," tokens",_t?` · ${i("chat.nearLimit")}`:""]}),!m&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:C,disabled:$.state!=="idle",className:`flex h-8 items-center justify-center rounded-full px-2 text-[11px] font-semibold text-dark-muted transition-colors
|
|
32
|
-
hover:bg-dark-hover hover:text-dark-text disabled:opacity-40`,title:i("stt.langToggle"),"aria-label":i("stt.langToggle"),children:_==="en"?"EN":"中"}),e.jsx("button",{onClick:()=>void H(),disabled:$.state==="transcribing",className:V("flex h-8 w-8 items-center justify-center rounded-full text-dark-muted transition-colors",$.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:$.state==="recording"?i("stt.stopTitle"):i("stt.title"),"aria-label":$.state==="recording"?i("stt.stopTitle"):i("stt.title"),children:$.state==="transcribing"?e.jsx(Re,{size:15,className:"animate-spin","aria-hidden":"true"}):$.state==="recording"?e.jsx(hn,{size:15,"aria-hidden":"true"}):e.jsx(fn,{size:15,"aria-hidden":"true"})}),$.state==="recording"&&e.jsxs("span",{className:"text-[10px] tabular-nums text-accent-red","aria-hidden":"true",children:[($.elapsedMs/1e3).toFixed(0),"s"]})]}),!m&&e.jsx("button",{onClick:()=>w(!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:i("skills.pickTitle"),"aria-label":i("skills.pickTitle"),children:e.jsx(bn,{size:15,"aria-hidden":"true"})}),!m&&e.jsx("button",{onClick:()=>void qs(),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:i("fileJob.attach"),"aria-label":i("fileJob.attach"),children:e.jsx(gn,{size:15,"aria-hidden":"true"})}),e.jsx("input",{ref:k,type:"file",multiple:!0,accept:ca,className:"hidden",onChange:Fs}),m?e.jsxs("div",{className:"flex items-center gap-1.5",children:[b?e.jsx("button",{onClick:o,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:i("chat.resumeGen"),"aria-label":i("chat.resumeGen"),children:e.jsx(kn,{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:i("chat.pauseGen"),"aria-label":i("chat.pauseGen"),children:e.jsx(is,{size:14,"aria-hidden":"true"})}),e.jsx("button",{onClick:n,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:i("chat.stopGen"),"aria-label":i("chat.stopGen"),children:e.jsx(yn,{size:13,"aria-hidden":"true"})})]}):e.jsx("button",{onClick:()=>void Be(),disabled:!Xs,className:`flex h-8 w-8 items-center justify-center rounded-full bg-dark-text text-dark-bg transition-all
|
|
33
|
-
hover:opacity-80 active:scale-95 disabled:opacity-25 disabled:cursor-not-allowed`,title:i("chat.sendBtn"),"aria-label":i("chat.sendBtn"),children:e.jsx(us,{size:15,"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"mt-1.5 hidden sm:flex items-center justify-center gap-3 text-[10px] text-dark-muted/50 select-none",children:[e.jsx("span",{children:i("chat.shiftEnter")}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:i("chat.escHint")})]}),e.jsx(Zr,{open:M,onClose:()=>w(!1),onSelect:Bs})]})}),it="其他(我来说明)",ye="推进",fa="不选具体项,按你的最佳判断继续",ba=15e3,ga=300;function Ps(r){return l.useMemo(()=>{const t=r.options||[],s=t.some(c=>c.label===it),n=t.some(c=>c.label===ye),a=[...t];n||a.push({label:ye,description:fa}),s||a.push({label:it,description:"输入自定义答案"});const o=s?a.findIndex(c=>c.label===it):a.length-1,d=n?a.findIndex(c=>c.label===ye):a.length-(s?1:2);return{allItems:a,otherIdx:o,proceedIdx:d,displayItems:a}},[r])}function ss({item:r,answered:t,selectedIdx:s,multiSelected:n,customInput:a,showCustomInput:o,onSelect:d,onToggleMulti:c,onProceed:u,onEnterCustom:i,onCancelCustom:p,onSubmitCustom:f,onCustomChange:m,inputRef:b}){const{otherIdx:y,proceedIdx:k,displayItems:S}=Ps(r),x=!!r.multiSelect,N=R=>{if(R===k){u();return}if(R===y){i();return}if(x){c(R);return}d(R)};return e.jsxs("div",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:[S.map((R,A)=>{const M=s===A,w=n.has(A),j=A===y;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 ${M?"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:()=>N(A),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[x&&e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center text-[10px] ${w?"bg-blue-600 border-blue-600 text-white":"border-gray-400 dark:border-gray-500"}`,children:w&&e.jsx(ze,{size:10})}),e.jsxs("span",{className:`font-medium ${M?"text-blue-700 dark:text-blue-300":"text-gray-800 dark:text-gray-200"}`,children:[x?"":`${A+1}. `,R.label]}),A===k&&e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"(直接继续)"}),j&&e.jsx("span",{className:"text-xs text-gray-400",children:"(自定义)"})]}),R.description&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 ml-6",children:R.description})]}),j&&M&&o&&e.jsxs("div",{className:"mt-2 ml-4",children:[e.jsx("textarea",{ref:b,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:_=>m(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),f()),_.key==="Escape"&&p()},placeholder:"输入您的回答...",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:f,children:[e.jsx(Ae,{size:12}),"提交"]}),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(je,{size:12}),"取消"]})]})]})]},`opt-${A}`)}),t&&e.jsx("div",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-medium",children:"✓ 已回答"})]})}function ka({isOpen:r,onClose:t}){const[s,n]=l.useState(null),[a,o]=l.useState(-1),[d,c]=l.useState(new Set),[u,i]=l.useState(""),[p,f]=l.useState(!1),[m,b]=l.useState(!1),[y,k]=l.useState(0),[S,x]=l.useState([]),[N,R]=l.useState(!1),A=l.useRef(null),M=l.useRef(null),w=l.useMemo(()=>s?s.questions&&s.questions.length>0?s.questions:[{question:s.question,header:s.header,options:s.options,multiSelect:s.multiSelect}]:[],[s]),j=w.length>1,_=l.useCallback(E=>{n(E),o(E.multiSelect?-1:0),c(new Set),i(""),f(!1),b(!1),k(0),R(!1);const B=E.questions&&E.questions.length>0?E.questions:[E];x(B.map(()=>null))},[]);l.useEffect(()=>{M.current=s}),l.useEffect(()=>{if(r){const E=window.__pendingQuestion;E&&_(E)}},[r,_]),l.useEffect(()=>{const E=B=>{var me;const I=B.detail,q=((me=M.current)==null?void 0:me.questionId)??null;if(I&&q&&I!==q)return;const te=q;b(!0),setTimeout(()=>{var ke;const xe=((ke=M.current)==null?void 0:ke.questionId)??null;te&&xe&&xe!==te||(t(),n(null),b(!1))},ga)};return window.addEventListener("ask-question-dismiss",E),()=>window.removeEventListener("ask-question-dismiss",E)},[t]),l.useEffect(()=>{if(!m)return;const E=setTimeout(()=>b(!1),ba);return()=>clearTimeout(E)},[m]),l.useEffect(()=>{const E=()=>{const B=window.__pendingQuestion;B&&_(B)};return window.addEventListener("ask-question-required",E),()=>window.removeEventListener("ask-question-required",E)},[_]),l.useEffect(()=>{o(0),c(new Set),i(""),f(!1)},[y,N,s]);const F=w[y]||null,{allItems:C,otherIdx:$}=Ps(F||{question:""}),L=l.useCallback((E,B)=>{m||!s||(b(!0),G.send({type:"question_answer",sessionId:G.getSessionId()??void 0,data:JSON.stringify({questionId:s.questionId,answer:E,selectedOptions:B})}))},[m,s]),se=l.useCallback(()=>{m||!s||(b(!0),G.send({type:"question_answer",sessionId:G.getSessionId()??void 0,data:JSON.stringify({questionId:s.questionId,answers:w.map((E,B)=>S[B]||{answer:"(用户未回答)"})})}))},[m,s,w,S]),v=l.useCallback((E,B,I)=>{x(q=>{const te=q.slice();return te[E]={answer:B,selectedOptions:I},te}),E<w.length-1?k(E+1):R(!0)},[w.length]),H=l.useCallback(E=>{if(m||!s)return;const B=C[E];B&&(o(E),L(B.label,[B.label]))},[m,s,C,L]),ne=l.useCallback(()=>{if(m||!s||a<0)return;const E=C[a];E&&L(E.label,[E.label])},[m,s,a,C,L]),J=l.useCallback(()=>{if(m||a<0)return;const E=C[a];E&&v(y,E.label,[E.label])},[m,a,C,v,y]),ee=l.useCallback(E=>{if(m)return;const B=C[E];B&&v(y,B.label,[B.label])},[m,C,v,y]),O=l.useCallback(E=>{m||c(B=>{const I=new Set(B);return I.has(E)?I.delete(E):I.add(E),I})},[m]),X=l.useCallback(()=>{if(m)return;const E=[...d].map(B=>{var I;return((I=C[B])==null?void 0:I.label)||""});j?v(y,E.join(", "),E):L(E.join(", "),E)},[m,d,C,j,v,y,L]),ie=l.useCallback(()=>{m||(j?v(y,ye,[ye]):L(ye,[ye]))},[m,j,v,y,L]),re=l.useCallback(()=>{m||(o($),f(!0),setTimeout(()=>{var E;return(E=A.current)==null?void 0:E.focus()},100))},[m,$]),ue=l.useCallback(()=>{f(!1),i("")},[]),Z=l.useCallback(()=>{if(m)return;const E=u||"(用户未输入)";j?v(y,E):L(E)},[m,u,j,v,y,L]),pe=l.useCallback(()=>{m||!s||(b(!0),G.send({type:"question_answer",sessionId:G.getSessionId()??void 0,data:JSON.stringify({questionId:s.questionId,answers:w.map(()=>({answer:"(cancelled)"}))})}))},[m,s,w]),Q=l.useCallback(()=>{if(!m){if(j){if(p){f(!1),i("");return}if(N){R(!1),k(w.length-1);return}pe();return}if(p){f(!1),i("");return}L("(cancelled)")}},[m,j,p,N,w.length,pe,L]);if(!r||!s)return null;const ge=S.filter(E=>!E).length;return e.jsx(bs,{isOpen:r,onClose:Q,title:s.header||(j?"批量确认":"请回答"),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"}),"待回答",j?` · ${S.filter(Boolean).length}/${w.length}`:""]}),collapsedSummary:e.jsx("span",{className:"truncate",children:(F==null?void 0:F.question)||s.question}),maxHeight:"50vh",children:j?e.jsxs("div",{className:"flex flex-col gap-4",children:[s.autoResolutionMs&&s.autoResolutionMs>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-1.5",children:["⏱ ",Math.max(1,Math.round(s.autoResolutionMs/1e3)),"s 后未回答将自动按推荐项继续"]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[w.map((E,B)=>{const I=!!S[B],q=!N&&y===B;return e.jsxs("button",{type:"button",onClick:()=>{k(B),R(!1)},className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${q?"bg-blue-600 text-white":I?"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," ",I?"✓":""]},`nav-${B}`)}),e.jsx("button",{type:"button",onClick:()=>R(!0),className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${N?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:"提交"})]}),N?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:"确认答案"}),w.map((E,B)=>{const I=S[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,". "]}),E.question]}),e.jsx("div",{className:`text-xs shrink-0 max-w-[45%] text-right break-words ${I?"text-emerald-600 dark:text-emerald-400":"text-amber-600 dark:text-amber-400"}`,children:I?I.answer:"未回答"})]},`rev-${B}`)}),ge>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(ve,{size:14}),"有 ",ge," 题未回答,将记为「未回答」。点击上方题号可回到对应题目修改。"]}),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:se,disabled:m,children:[e.jsx(Ae,{size:14}),"提交全部答案"]}),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:()=>{R(!1),k(w.length-1)},disabled:m,children:"返回修改"})]})]}):F?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:F.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:()=>{k(E=>Math.max(0,E-1)),R(!1)},disabled:y===0,children:[e.jsx(vn,{size:12}),"上一题"]}),y<w.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:()=>{k(E=>Math.min(w.length-1,E+1)),R(!1)},children:["下一题",e.jsx(fe,{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:()=>R(!0),children:["查看提交",e.jsx(fe,{size:12})]})]})]}),e.jsx(ss,{item:F,answered:!!S[y],selectedIdx:a,multiSelected:d,customInput:u,showCustomInput:p,onSelect:ee,onToggleMulti:O,onProceed:ie,onEnterCustom:re,onCancelCustom:ue,onSubmitCustom:Z,onCustomChange:i,inputRef:A}),!p&&e.jsx("div",{className:"flex items-center gap-2",children:F.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:X,disabled:m||d.size===0,children:[e.jsx(Ae,{size:14}),"完成本题 (",d.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:J,disabled:m||a<0,children:[e.jsx(Ae,{size:14}),"确认本题"]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:p?e.jsx("span",{children:"Enter 提交,Shift+Enter 换行"}):F.multiSelect?e.jsx("span",{children:"点击选项勾选,再点击「完成本题」提交本题;「推进」表示按 AI 判断继续"}):e.jsx("span",{children:"点击选项完成本题自动进入下一题,或点击「确认本题」提交当前高亮项"})})]}):null]}):e.jsxs("div",{className:"flex flex-col gap-4",children:[s.autoResolutionMs&&s.autoResolutionMs>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-1.5",children:["⏱ ",Math.max(1,Math.round(s.autoResolutionMs/1e3)),"s 后未回答将自动按推荐项继续"]}),e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:s.question}),e.jsx(ss,{item:w[0],answered:!1,selectedIdx:a,multiSelected:d,customInput:u,showCustomInput:p,onSelect:H,onToggleMulti:O,onProceed:ie,onEnterCustom:re,onCancelCustom:ue,onSubmitCustom:Z,onCustomChange:i,inputRef:A}),!p&&e.jsx("div",{className:"flex items-center gap-2",children:s.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:X,disabled:m||d.size===0,children:[e.jsx(Ae,{size:14}),"提交所选 (",d.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:ne,disabled:m||a<0,children:[e.jsx(Ae,{size:14}),"提交"]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:m?e.jsx("span",{children:"提交中..."}):p?e.jsx("span",{children:"Enter 提交,Shift+Enter 换行"}):s.multiSelect?e.jsx("span",{children:"点击选项勾选,再点击「提交所选」提交;「推进」表示按 AI 判断继续"}):e.jsx("span",{children:"点击选项立即提交,或点击下方「提交」确认当前选项"})})]})})}const De=15;function ya({isOpen:r,onCloseModal:t}){const{t:s}=W("hook"),n=pt(),a=n.pendingApprovals,o=n.autoMode,d=n.setAutoMode,[c,u]=l.useState(0),[i,p]=l.useState(!1),[f,m]=l.useState(De),[b,y]=l.useState(!0),k=l.useRef(null),S=l.useRef(!1);l.useEffect(()=>{if(a.length!==0){if(o){a.forEach(I=>{G.send({type:"hook_allow",data:JSON.stringify({approvalId:I.approvalId})})}),n.clearApprovals();return}u(I=>Math.min(I,a.length-1))}},[a.length,o]);const x=a[c]??null,N=a.length>0&&x!==null,R=a.length,A=N?R-c-1:0;l.useEffect(()=>{if(!(!N||i||!r||!x))return m(De),k.current=setInterval(()=>{m(I=>I<=1?(k.current&&clearInterval(k.current),0):I-1)},1e3),()=>{k.current&&clearInterval(k.current)}},[N,i,r,x==null?void 0:x.approvalId]);const M=x?ms(x.toolName,x.askPayload):{level:"MEDIUM",reasonKey:"risk_default"},w=hs[M.level],j=Hn[M.level==="CRITICAL"?"critical":M.level==="HIGH"?"high":M.level==="LOW"?"low":"medium"],_=x?Ms(x.toolName,x.askPayload):null,F=x?Jn(x.toolName,x.askPayload):null,C=x?{verb:_s(x.toolName),target:As(x.toolName,x.askPayload)}:null,$=x?Le(x.askPayload)!==null:!1,L=x?zs(x.toolName,x.askPayload):null,se=f/De*100,v=f<=5,H=Wn(De-f),ne=l.useCallback((I,q)=>{const te=Un.getState().activeSessionId;te&&ce.getState().updateHookApprovalStatus(te,I,q)},[]),J=l.useCallback(I=>{x&&(I&&ne(x.approvalId,I),p(!0),setTimeout(()=>{n.removeApproval(x.approvalId),u(0),p(!1),S.current=!1,m(De)},200))},[x==null?void 0:x.approvalId,n,ne]),ee=l.useCallback(()=>{!x||i||S.current||(S.current=!0,k.current&&clearInterval(k.current),G.send({type:"hook_allow",data:JSON.stringify({approvalId:x.approvalId})}),J("approved"))},[x,J,i]),O=l.useCallback(()=>{!x||i||S.current||(S.current=!0,k.current&&clearInterval(k.current),G.send({type:"hook_deny",data:JSON.stringify({approvalId:x.approvalId})}),J("denied"))},[x,J,i]),X=l.useCallback(()=>{if(!x||i||S.current)return;S.current=!0,k.current&&clearInterval(k.current);const I=Le(x.askPayload);I?(n.addToSessionAllowList(x.toolName,I),G.send({type:"hook_allow",data:JSON.stringify({approvalId:x.approvalId,sessionAllow:!0})})):(n.addToSessionAllowList(x.toolName),G.send({type:"hook_allow",data:JSON.stringify({approvalId:x.approvalId})})),J("approved")},[x,J,n,i]),ie=l.useCallback(()=>{!x||i||S.current||(S.current=!0,k.current&&clearInterval(k.current),d(!0),we.getState().setAuto(!0),G.send({type:"hook_allow",data:JSON.stringify({approvalId:x.approvalId})}),J("approved"))},[x,J,i,d]),re=((x==null?void 0:x.timeoutMs)??15e3)>0,ue=(x==null?void 0:x.timeoutAction)==="deny"?O:ee;if(l.useEffect(()=>{f===0&&r&&!i&&x&&re&&ue()},[f,r,i,x,ue,re]),l.useEffect(()=>{if(!r||!b)return;const I=q=>{const te=q.target;te&&typeof te.closest=="function"&&te.closest('input, textarea, select, [contenteditable="true"]')||(q.key==="Escape"?(q.preventDefault(),q.stopPropagation(),O()):q.key==="Enter"?(q.preventDefault(),ee()):q.key==="1"?ee():q.key==="2"?O():q.key==="3"?X():q.key==="4"&&ie())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[r,b,ee,O,X,ie]),!N||!x)return null;const Z=s("optionAllowHint"),pe=s("optionDenyHint"),Q=$?s("optionAllowPathHint"):s("optionAllowAlwaysHint",{tool:x.toolName}),ge=s("optionAutoModeHint"),E=(_==null?void 0:_.text)??F??null,B=E?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:x.toolName}),e.jsx("span",{className:"truncate",children:E})]}):null;return e.jsx(bs,{isOpen:r,onClose:()=>t==null?void 0:t(),title:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ct,{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,"/",R,")"]})]}),badge:e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${w.badge}`,children:[w.icon," ",M.level]}),collapsedSummary:B,onExpandedChange:y,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 ${w.bg} border ${w.border}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-xs font-bold border ${w.badge}`,children:[w.icon," ",M.level]}),e.jsx("span",{className:"text-xs text-dark-muted truncate",children:s(M.reasonKey)}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto shrink-0",children:[e.jsx(Me,{size:12,className:v?"text-accent-red":"text-dark-muted"}),e.jsx("span",{className:`text-xs font-mono ${v?"text-accent-red animate-pulse":"text-dark-muted"}`,children:re?`${f}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 ${v?"bg-accent-red":f<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${se}%`}})})]})]}),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(ct,{size:15})}),C&&e.jsx(Rs,{pre:s(C.verb),obj:C.target})]}),L&&(L.external&&L.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:L.path,children:[e.jsx(ls,{size:10}),s("scopeExternal"),": ",L.path.length>48?`${L.path.slice(0,47)}…`:L.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:x.toolName}),e.jsx("span",{className:"text-dark-muted/50",children:H}),e.jsx("span",{className:"text-dark-muted/50",children:j.label}),x.timeoutAction&&e.jsxs("span",{className:`text-xs ${x.timeoutAction==="deny"?"text-accent-red":"text-accent-green"}`,children:["timeout: ",re?`${x.timeoutAction==="allow"?"auto-allow":"auto-deny"}${x.timeoutMs?` (${(x.timeoutMs/1e3).toFixed(0)}s)`:""}`:s("timeoutWaitUser")]})]}),_?e.jsx(ft,{text:_.text,mono:_.mono}):F?e.jsx(ft,{text:F}):null,(M.level==="CRITICAL"||M.level==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-xs px-2 py-1.5 rounded ${w.bg} ${w.text}`,children:[e.jsx(ve,{size:13}),e.jsx("span",{children:M.level==="CRITICAL"?s("highRiskWarning"):s("mediumRiskConfirm")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:ee,disabled:i,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:Fe.allow.label}),e.jsx("span",{className:"text-[11px] text-white/70 hidden sm:inline",children:Z})]}),e.jsxs("button",{onClick:X,disabled:i,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:Fe.allow_session.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:Q})]}),e.jsxs("button",{onClick:ie,disabled:i,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:Fe.auto.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:ge})]}),e.jsx("span",{className:"flex-1"}),e.jsxs("button",{onClick:O,disabled:i,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:Fe.deny.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:pe})]})]}),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:A>0?s("morePending",{n:A}):s("lastItem")})]})]})})}const wa=l.memo(function(){const{t}=W(),[s,n]=l.useState(0),[a,o]=l.useState(0),d=l.useCallback(()=>{const c=G.getReconnectState();n(c.reconnecting?c.attempts:0),o(c.maxAttempts)},[]);return l.useEffect(()=>{const c=G.onReconnectAttempt((m,b)=>{n(m),o(b)}),u=G.onReconnectSuccess(()=>{n(0),o(0)}),i=G.onReconnectGiveUp(()=>n(0)),p=G.onClose(d),f=G.onOpen(d);return d(),()=>{c(),u(),i(),p(),f()}},[d]),s<=0?null:e.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-2 text-xs text-accent-yellow bg-accent-yellow/10 border-b border-accent-yellow/20 select-none",role:"status","aria-live":"polite",children:[e.jsx($e,{size:13,className:"animate-spin shrink-0"}),e.jsx("span",{children:t("reconnect.reconnecting",{attempt:s,max:a})}),e.jsx("span",{className:"hidden sm:inline text-[10px] text-accent-yellow/70",children:t("reconnect.hint")})]})}),ot="dsc-auto-access-banner-dismissed",va=l.memo(function(){const{t}=W(),s=we(c=>c.mode),[n,a]=l.useState(()=>localStorage.getItem(ot)==="1");l.useEffect(()=>{mt(s==="normal"?"act":s)||localStorage.getItem(ot)==="1"&&a(!1)},[s]);const o=l.useCallback(c=>{c&&localStorage.setItem(ot,"1"),a(!0)},[]);return!(s!=="normal"&&mt(s))||n?null:e.jsxs("div",{className:"flex items-start gap-2 px-4 py-2 text-[11px] leading-snug text-accent-yellow bg-accent-yellow/10 border-b border-accent-yellow/20 select-none",role:"note",children:[e.jsx(jn,{size:14,className:"shrink-0 mt-0.5 text-accent-yellow"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium",children:t("autoAccess.title")}),e.jsxs("span",{className:"text-accent-yellow/80",children:[" ",t("autoAccess.desc")]})]}),e.jsx("button",{onClick:()=>o(!1),className:"shrink-0 rounded p-0.5 text-accent-yellow/70 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors",title:t("autoAccess.dismiss"),"aria-label":t("autoAccess.dismiss"),children:e.jsx(je,{size:12})}),e.jsx("button",{onClick:()=>o(!0),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] text-accent-yellow/70 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors whitespace-nowrap",children:t("autoAccess.neverShow")})]})}),ns=24,rs=240,ja={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"}},Na=({status:r})=>r==="running"?e.jsx(Re,{size:12,className:"animate-spin text-accent-blue"}):r==="completed"?e.jsx(dt,{size:12,className:"text-accent-green"}):r==="failed"?e.jsx(En,{size:12,className:"text-accent-red"}):r==="skipped"?e.jsx(_n,{size:12,className:"text-dark-muted"}):e.jsx(An,{size:12,className:"text-dark-muted"}),Sa=l.memo(function({sessionId:t,defaultExpanded:s,onClose:n}){const{t:a}=W(),[o,d]=l.useState(s??!1),[c,u]=l.useState(null),i=gs(C=>C.getTasksForSession(t)),[p,f]=l.useState(null),m=l.useRef(null),b=l.useRef(!1),y=l.useRef(null),k=l.useCallback(C=>{var $;C.button===0&&(C.target.closest("[data-taskboard-close]")||(b.current=!1,m.current={y:C.clientY,expanded:o,bodyHeight:(($=y.current)==null?void 0:$.offsetHeight)??0},C.currentTarget.setPointerCapture(C.pointerId)))},[o]),S=l.useCallback(C=>{const $=m.current;$&&(Math.abs(C.clientY-$.y)>4&&(b.current=!0),f(C.clientY-$.y))},[]),x=l.useCallback(C=>{const $=m.current;if(!$)return;const L=C.clientY-$.y;$.expanded&&L<-ns?d(!1):!$.expanded&&L>ns&&d(!0),m.current=null,f(null),setTimeout(()=>{b.current=!1},0)},[]),N=l.useCallback(()=>{if(b.current){b.current=!1;return}d(C=>!C)},[]),R=l.useCallback(C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),d($=>!$))},[]),A=p!==null,M=l.useMemo(()=>{const C=m.current;return p===null||!C?null:C.expanded?Math.min(rs,Math.max(0,C.bodyHeight+p)):Math.min(rs,Math.max(0,p))},[p]),w=l.useMemo(()=>{const C=i.length,$=i.filter(H=>H.status==="completed").length,L=i.filter(H=>H.status==="running").length,se=i.filter(H=>H.status==="failed").length,v=C>0?Math.round($/C*100):0;return{total:C,completed:$,running:L,failed:se,progress:v}},[i]),j=l.useMemo(()=>{const C={pending:[],running:[],completed:[],failed:[]};return i.forEach($=>{const L=$.status==="skipped"?"pending":$.status;C[L].push($)}),C},[i]),_=[...j.running,...j.failed,...j.pending.slice(0,5),...j.completed.slice(-3)],F=o||A;return i.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":o,onClick:N,onKeyDown:R,onPointerDown:k,onPointerMove:S,onPointerUp:x,onPointerCancel:x,onLostPointerCapture:x,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(Nn,{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:[w.completed,"/",w.total]}),w.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 ${w.running>0?"bg-accent-blue":w.failed>0?"bg-accent-red":"bg-accent-green"}`,style:{width:`${w.progress}%`}})}),w.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:[n&&e.jsx("span",{role:"button",tabIndex:0,"data-taskboard-close":!0,onClick:C=>{C.stopPropagation(),n()},onKeyDown:C=>{C.key==="Enter"&&(C.stopPropagation(),n())},className:"p-0.5 rounded hover:bg-dark-hover transition-colors cursor-pointer",title:"Hide task drawer",children:e.jsx(je,{size:12,className:"text-dark-muted"})}),e.jsx(Sn,{size:12,className:"text-dark-muted/40 shrink-0","aria-hidden":"true"}),o?e.jsx(Cn,{size:14,className:"text-dark-muted"}):e.jsx(de,{size:14,className:"text-dark-muted"})]})]}),F&&e.jsx("div",{ref:y,className:"border-t border-dark-border",style:M!==null?{height:M,overflow:"hidden"}:void 0,children:i.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:[_.map(C=>e.jsx(Ea,{task:C,isSelected:C.id===c,onClick:()=>u(c===C.id?null:C.id)},C.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"]})]})})]})}),Ca=(r,t)=>{if(!r)return"";const s=(t||Date.now())-r;return s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`},Ea=l.memo(function({task:t,isSelected:s,onClick:n}){const a=ja[t.status];return e.jsxs("div",{onClick:n,className:`rounded border p-2 cursor-pointer transition-all ${a.bg} border-dark-border
|
|
34
|
-
${s?"ring-1 ring-accent-blue":"hover:border-dark-muted/40"}
|
|
35
|
-
${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(Na,{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:Ca(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"]})]})]})}),Ta=l.memo(function({tabs:t,activeSessionId:s,onSend:n,onStop:a,onPause:o,onResume:d,activeTab:c,setActiveTab:u,createNewSession:i,clearMessages:p,setTheme:f,setThemePreset:m,toggleTerminal:b,setLogs:y,setUnreadLogs:k,showTaskBoard:S=!0,onToggleTaskBoard:x,onRegenerate:N,onDeleteMessage:R,hookDrawerOpen:A,onCloseHookDrawer:M,questionDrawerOpen:w,onCloseQuestionDrawer:j,workspaceDir:_,onWorkspaceSelect:F}){const C=l.useMemo(()=>({setActiveTab:u,createNewSession:i,clearMessages:p,setTheme:f,setThemePreset:m,toggleTerminal:b,setLogs:y,setUnreadLogs:k}),[u,i,p,f,m,b,y,k]),$=ce(O=>s?O.messagesBySession[s]||[]:[]),L=ce(O=>s?O.generatingSessions.includes(s):!1),se=ce(O=>s?O.pausedSessions.includes(s):!1),v=t.find(O=>O.id===s)||null;l.useEffect(()=>{if(!s)return;let O=!1;return oe.tasks.list(s).then(X=>{if(O||!X.success||!Array.isArray(X.data))return;const ie={PENDING:"pending",RUNNING:"running",COMPLETED:"completed",FAILED:"failed",CANCELLED:"skipped"},re=Date.now(),ue=X.data.filter(Z=>Z.sessionId===s).map(Z=>{const pe=new Date(Z.createdAt).getTime()||re,Q=new Date(Z.updatedAt).getTime()||re;return{id:Z.id,sessionId:s,title:Z.title,status:ie[Z.status]||"pending",source:"task",description:Z.description,progress:Z.progress,createdAt:pe,updatedAt:Q,raw:Z}});gs.getState().setTasks(s,ue,"task")}).catch(()=>{}),()=>{O=!0}},[s]);const H=l.useCallback((O,X)=>{s&&n(s,O,X)},[n,s]),ne=l.useCallback(O=>{s&&n(s,O)},[n,s]),J=l.useCallback(O=>{s&&N&&N(s,O)},[N,s]),ee=l.useCallback(O=>{s&&R&&R(s,O)},[R,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(wa,{}),e.jsx(va,{}),v&&e.jsxs(e.Fragment,{children:[e.jsx(Br,{messages:$,isGenerating:L,isPaused:se,sessionId:v.id,onSendSuggestion:ne,onRegenerate:N?J:void 0,onDeleteMessage:R?ee:void 0}),e.jsx(ya,{isOpen:!!A,onCloseModal:M}),e.jsx(ka,{isOpen:!!w,onClose:j??(()=>{})}),S&&e.jsx(Sa,{sessionId:v.id,defaultExpanded:!1,onClose:x},v.id),e.jsx(ha,{sessionId:v.id,onSend:H,onStop:()=>a(v.id),onPause:()=>o(v.id),onResume:()=>d(v.id),slashOptions:C,workspaceDir:_,onWorkspaceSelect:F})]})]})})});export{Ta as SessionGrid};
|