@deepseekcode/cli 1.0.22 → 1.0.23
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 +1077 -1211
- package/package.json +1 -1
- package/web/dist/assets/{AutomationView-Z7E_x8jk.js → AutomationView-BbLzZ7Db.js} +1 -1
- package/web/dist/assets/ChannelConfigView-CjcMwBSL.js +8 -0
- package/web/dist/assets/ConnectorsView-CTFoG0sF.js +1 -0
- package/web/dist/assets/{FileTreeView-6huCqCNC.js → FileTreeView-_N5eobgO.js} +1 -1
- package/web/dist/assets/{HookConfigView-BJ-VvTcl.js → HookConfigView-DM6IVFGm.js} +1 -1
- package/web/dist/assets/{ModelsView-DTfQ2XYb.js → ModelsView-CPm2WAbG.js} +2 -2
- package/web/dist/assets/PluginsView-D9pzIe-R.js +1 -0
- package/web/dist/assets/SessionGrid-C-Z-kzmG.js +35 -0
- package/web/dist/assets/SettingsPanel-D9kr-sFj.js +4 -0
- package/web/dist/assets/SkillsView-CS0XvZ4N.js +1 -0
- package/web/dist/assets/{TemplatesTab-M7MnMuN6.js → TemplatesTab-Pwfjxer7.js} +1 -1
- package/web/dist/assets/TerminalView-C__4-QSL.js +3 -0
- package/web/dist/assets/{ToolsView-DmzLnZ1I.js → ToolsView-Y5MpTnXY.js} +1 -1
- package/web/dist/assets/{icons-ZBQi-Ogj.js → icons-BXecaLRH.js} +114 -119
- package/web/dist/assets/index-CFxV9r1K.css +1 -0
- package/web/dist/assets/index-CcPIw0Dj.js +68 -0
- package/web/dist/assets/{markdown-4Q3UQbv9.js → markdown-BASfeONY.js} +1 -1
- package/web/dist/assets/{panels-CwhLUZOq.js → panels-Bod3sKnK.js} +1 -1
- package/web/dist/assets/{react-vendor-LdB92qnf.js → react-vendor-7At16BnY.js} +1 -1
- package/web/dist/assets/{state-4vIOJjS6.js → state-D4zgKwQs.js} +1 -1
- package/web/dist/index.html +7 -7
- package/web/dist/assets/AuditView-C8pvciLV.js +0 -1
- package/web/dist/assets/ChannelConfigView-2-i0ictg.js +0 -8
- package/web/dist/assets/ConnectorsView-CSGJfYer.js +0 -1
- package/web/dist/assets/InboxView-DXjF5APJ.js +0 -1
- package/web/dist/assets/PluginsView-CeIWhIfR.js +0 -1
- package/web/dist/assets/SessionGrid-BCsOMJRn.js +0 -29
- package/web/dist/assets/SettingsPanel-DkKIVWYT.js +0 -4
- package/web/dist/assets/SkillsView-CPT12zSi.js +0 -1
- package/web/dist/assets/TerminalView-j231tG2H.js +0 -3
- package/web/dist/assets/index-BWp0OZYm.css +0 -1
- package/web/dist/assets/index-sYOn5Yyn.js +0 -67
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./markdown-4Q3UQbv9.js";import{a as l,Y as ss,al as Ae,d as fe,K as we,aD as Pe,X as Ie,aQ as ot,E as ns,Z as je,l as ct,L as ze,u as bt,F as dt,aR as ut,aH as Gs,D as Zs,k as Vs,aS as Qs,ax as Xs,aT as _t,aU as Ys,h as Me,am as en,b as tn,ar as sn,aG as nn,aa as rs,$ as as,aV as rn,_ as At,n as ls,aN as gt,aM as an,a4 as is,ab as ln,aW as on,aX as cn,ag as dn,aY as un,f as xn,i as pn,S as mn,t as hn,aZ as _e,y as fn,a_ as bn,m as gn,a$ as kn,a0 as yn,p as wn,q as jn,j as vn}from"./icons-ZBQi-Ogj.js";import{D as Nn,d as Z,h as zt,i as Sn,o as os,c as K,j as Le,k as cs,w as W,l as xt,u as ye,R as ds,a as ae,t as Q,m as le,n as Cn,p as En,W as _n,q as An,r as pt,b as us,s as mt,f as ht,E as zn,M as Mn,v as In,x as Rn,y as xs,z as $n,A as Tn,F as Dn,G as Be,H as Pn,J as ps}from"./index-sYOn5Yyn.js";import"./react-vendor-LdB92qnf.js";import"./state-4vIOJjS6.js";import"./panels-CwhLUZOq.js";class Ln extends Nn{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}}const On=new Ln;function qn(r,t,s){return On.diff(r,t,s)}function Mt({value:r,max:t=100,size:s="md",variant:n="default",showLabel:a=!1,className:o}){const c=Math.min(Math.max(r/t*100,0),100),d={sm:"h-1",md:"h-2",lg:"h-3"},x={default:"bg-accent-blue",success:"bg-accent-green",warning:"bg-accent-yellow",error:"bg-accent-red"};return e.jsxs("div",{className:Z("w-full",o),children:[e.jsx("div",{className:Z("w-full bg-dark-border rounded-full overflow-hidden",d[s]),children:e.jsx("div",{className:Z("h-full rounded-full transition-all duration-300",x[n]),style:{width:`${c}%`}})}),a&&e.jsxs("span",{className:"text-xs text-dark-muted mt-1",children:[Math.round(c),"%"]})]})}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 It={},Rt;function Bn(){return Rt||(Rt=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)),It}Bn();var $t={},Tt;function Fn(){return Tt||(Tt=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)),$t}Fn();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={},Pt;function Hn(){return Pt||(Pt=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}Hn();(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 c=s.tokenStack=[];s.code=s.code.replace(a,function(d){if(typeof o=="function"&&!o(d))return d;for(var x=c.length,i;s.code.indexOf(i=t(n,x))!==-1;)++x;return c[x]=d,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 c(d){for(var x=0;x<d.length&&!(a>=o.length);x++){var i=d[x];if(typeof i=="string"||i.content&&typeof i.content=="string"){var m=o[a],b=s.tokenStack[m],h=typeof i=="string"?i:i.content,f=t(n,m),y=h.indexOf(f);if(y>-1){++a;var w=h.substring(0,y),k=new r.Token(n,r.tokenize(b,s.grammar),"language-"+n,b),u=h.substring(y+f.length),S=[];w&&S.push.apply(S,c([w])),S.push(k),u&&S.push.apply(S,c([u])),typeof i=="string"?d.splice.apply(d,[x,1].concat(S)):i.content=S}}else i.content&&c(i.content)}return d}c(s.tokens)}}})})(Prism);var Lt={},Ot;function Jn(){return Ot||(Ot=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 c={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:r.languages.php},d=[{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:c}},{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:c}}];r.languages.insertBefore("php","variable",{string:d,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:t,string:d,"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(x){if(/<\?/.test(x.code)){var i=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;r.languages["markup-templating"].buildPlaceholders(x,"php",i)}}),r.hooks.add("after-tokenize",function(x){r.languages["markup-templating"].tokenizePlaceholders(x,"php")})})(Prism)),Lt}Jn();var qt={},Bt;function Wn(){return Bt||(Bt=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)),qt}Wn();const Un=.4;function Ft(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 Kn(r,t){const s=qn(Ft(r),Ft(t)),n=r.length+t.length;let a=0;const o=[],c=[];let d=0,x=0;for(const i of s){const m=i.value.reduce((b,h)=>b+h.length,0);i.removed?(a+=m,o.push({start:d,end:d+m}),d+=m):i.added?(a+=m,c.push({start:x,end:x+m}),x+=m):(d+=m,x+=m)}return n>0&&a/n>Un?[[],[]]:[o,c]}function ms(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 hs(r){let t=r.oldStart,s=r.newStart;const n=[];for(const a of r.lines){const o=a[0]==="+"||a[0]==="-"?a[0]:" ",c=a.slice(1);let d=null,x=null;o==="-"?d=t++:(o==="+"||(d=t++),x=s++),n.push({marker:o,code:c,oldLine:d,newLine:x})}return n}const Gn=l.memo(function({filePath:t,content:s,language:n}){if(!s&&!t)return null;const[a,o]=l.useState("unified"),[c,d]=l.useState(!1),x=Zn(t,n),i=(s==null?void 0:s.includes("@@"))||(s==null?void 0:s.includes("+++"))||(s==null?void 0:s.includes("---")),m=i?Vn(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"}),m&&e.jsxs("span",{className:"text-xs ml-2 flex gap-2",children:[e.jsxs("span",{className:"text-green-400",children:["+",m.additions]}),e.jsxs("span",{className:"text-red-400",children:["-",m.deletions]})]}),e.jsx("span",{className:"text-xs text-dark-muted ml-auto",children:x}),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:()=>d(!c),className:"text-xs text-dark-muted hover:text-dark-fg ml-1",children:c?"▶":"▼"})]}),!c&&e.jsxs("div",{className:"bg-dark-bg overflow-x-auto max-h-96 overflow-y-auto custom-scrollbar",children:[i?a==="unified"?er(s||"",x):tr(s||"",x):e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:s||"(no content)"}),m&&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:["+",m.additions," additions"]}),e.jsxs("span",{className:"text-red-400",children:["-",m.deletions," deletions"]}),e.jsxs("span",{children:[m.hunks," hunks"]})]})]})]})});function Zn(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 Vn(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 Qn(r){const t=[],s=(a,o)=>{if(!o)return;const c=t[t.length-1];c&&c.type===a?c.text+=o:t.push({type:a,text:o})},n=(a,o)=>{if(typeof a=="string"){s(o,a);return}const c=a.type||o;if(typeof a.content=="string"){s(c,a.content);return}for(const d of a.content)n(d,c)};for(const a of r)n(a,"");return t}function fs(r,t){const s=zt.languages[t];if(!s)return[{type:"",text:r}];try{return Qn(zt.tokenize(r,s))}catch{return[{type:"",text:r}]}}function Xn(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,c=n+a.text.length;let d=0;for(const x of t){const i=Math.max(0,x.start-o),m=Math.min(a.text.length,x.end-o);m<=0||i>=a.text.length||(i>d&&s.push({type:a.type,text:a.text.slice(d,i),word:!1}),s.push({type:a.type,text:a.text.slice(i,m),word:!0}),d=m)}d<a.text.length&&s.push({type:a.type,text:a.text.slice(d),word:!1}),n=c}return s}function Yn({code:r,marker:t,lang:s,ranges:n}){const a=t==="-"?[{type:"",text:r}]:fs(r,s),o=Xn(a,n),c=t==="+"?"bg-green-900/30":t==="-"?"bg-red-900/30":"",d=t==="+"?"bg-green-700/60":"bg-red-700/60";return e.jsx("span",{className:`flex-1 whitespace-pre-wrap px-2 ${c}`,children:o.length===0?" ":o.map((x,i)=>e.jsx("span",{className:[x.type?`token ${x.type}`:"",x.word&&t!==" "?d:""].join(" "),children:x.text},i))})}function er(r,t){const s=ms(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 c=hs(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 d=new Map;for(let x=0;x<c.length;){if(c[x].marker!=="-"){x++;continue}const i=x;for(;x<c.length&&c[x].marker==="-";)x++;const m=x;for(;x<c.length&&c[x].marker==="+";)x++;const b=Math.min(m-i,x-m);for(let h=0;h<b;h++){const[f,y]=Kn(c[i+h].code,c[m+h].code);d.set(i+h,f),d.set(m+h,y)}}for(let x=0;x<c.length;x++){const i=c[x],m=i.marker==="+",b=i.marker==="-",h=m?"bg-green-900/30":b?"bg-red-900/30":"",f=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 ${h} ${m?"text-green-400":b?"text-red-400":"text-dark-muted"}`,children:[i.marker===" "?"":i.marker,f??""]}),e.jsx(Yn,{code:i.code,marker:i.marker,lang:t,ranges:d.get(x)??[]})]},a++))}}return e.jsx("div",{children:n})}function Ht({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}]:fs(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,c)=>e.jsx("span",{className:o.type?`token ${o.type}`:"",children:o.text},c))})}function tr(r,t){const s=ms(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=hs(a);n.push({left:`@@ -${a.oldStart},${a.oldLines} +${a.newStart},${a.newLines} @@`,right:"",type:"header"});let c=[],d=[];const x=()=>{(c.length>0||d.length>0)&&(sr(n,c,d),c=[],d=[])};for(const i of o)i.marker==="-"?c.push(i.code):i.marker==="+"?d.push(i.code):(x(),n.push({left:i.code,right:i.code,type:"context"}));x()}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(Ht,{code:a.type==="replace"||a.type==="delete"?"- "+a.left:a.left,lang:t,kind:a.type==="replace"||a.type==="delete"?"remove":"context"}),e.jsx(Ht,{code:a.type==="replace"||a.type==="add"?"+ "+a.right:a.right,lang:t,kind:a.type==="replace"||a.type==="add"?"add":"context"})]},o))]})}function sr(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]??"":"",c=a<s.length?s[a]??"":"";r.push({left:o,right:c,type:a<t.length&&a<s.length?"replace":a<t.length?"delete":"add"})}}function bs(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 c=Math.floor((Date.now()-s.current)/1e3),d=c>=60?`${Math.floor(c/60)}m ${c%60}s`:`${c}s`;n.textContent=d};a();const o=setInterval(a,1e3);return()=>clearInterval(o)},[r]),t}function nr(r){return typeof r=="string"?r:r&&typeof r=="object"?JSON.stringify(r,null,2):String(r??"")}function rr(r){let t=null;if(typeof r=="string")try{const s=JSON.parse(r);s&&typeof s=="object"&&!Array.isArray(s)&&(t=s)}catch{return}else r&&typeof r=="object"&&!Array.isArray(r)&&(t=r);if(t)return t.filePath||t.path||t.file||t.file_path}const gs=l.memo(function({toolCall:t,defaultCollapsed:s=!0}){const n=t.status==="running",a=bs(n),o=t.result!==void 0&&t.result!==null,c=t.status==="error",d=Sn(t.name),x=o?nr(t.result):"",i=t.diff||(d&&x&&(x.includes("@@")||x.includes("+++")||x.includes("---"))?x:void 0),m=rr(t.args),[b,h]=l.useState(s),f=t.duration??0,y=f>0?f>=60?`${Math.floor(f/60)}m ${f%60}s`:`${f}s`:"",w=n?"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:()=>h(!b),children:[n?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}),d&&m&&!c&&e.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),os(m)},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
|
|
4
|
-
hover:bg-dark-hover hover:border-accent-blue/40 transition-colors`,title:m,children:[e.jsx(ss,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:m})]}),n&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Ae,{size:10}),e.jsx("span",{ref:a,children:"0s"})]}),!n&&y&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Ae,{size:10}),e.jsx("span",{children:y})]}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${b?"":"rotate-180"}`,children:e.jsx(fe,{size:13})})]}),!b&&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:"参数"}),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)})]}),o&&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:c?"错误":"结果"}),d&&(i||x)?e.jsx(Gn,{filePath:m,content:i||x}):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:x})]})]})]})}),ar=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:d=>{d.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})}),lr=l.memo(function({step:t,defaultCollapsed:s=!0}){const[n,a]=l.useState(s),[o,c]=l.useState(!0),d=t.status==="running",x=bs(d),i=t.description||t.thought||t.result||t.action||t.toolCalls&&t.toolCalls.length>0,m=t.duration??0,b=m>0?m>=60?`${Math.floor(m/60)}m ${m%60}s`:`${m}s`:"",h={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:()=>i&&a(!n),children:[d?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 ${h} ${t.status==="pending"?"opacity-60":""}`}),e.jsx("span",{className:"text-[13px] text-dark-text truncate",children:t.title}),d&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Ae,{size:10}),e.jsx("span",{ref:x,children:"0s"})]}),!d&&b&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Ae,{size:10}),e.jsx("span",{children:b})]}),i&&e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${n?"":"rotate-180"}`,children:e.jsx(fe,{size:13})})]}),!n&&i&&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(!o),children:[o?e.jsx(we,{size:12}):e.jsx(fe,{size:12}),e.jsx("span",{children:"🧠 思考"}),o&&e.jsxs("span",{className:"text-[10px] text-dark-muted truncate max-w-[200px]",children:[t.thought.slice(0,80).replace(/\n/g," "),"..."]})]}),!o&&e.jsx("div",{className:"text-dark-muted italic whitespace-pre-wrap leading-snug mt-1",children:t.thought.replace(/\n\s*\n+/g,`
|
|
5
|
-
`)})]}),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.jsx("div",{className:"flex items-center gap-1 text-accent-yellow mb-0.5",children:"⚡ 执行"}),e.jsx("div",{className:"text-dark-text leading-snug font-mono text-[11px]",children:t.action})]}),t.toolCalls&&t.toolCalls.length>0&&t.toolCalls.map(f=>e.jsx("div",{className:"px-1 py-0.5",children:e.jsx(gs,{toolCall:f})},f.id)),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.jsx("div",{className:"flex items-center gap-1 text-accent-green mb-0.5",children:"✓ 结果"}),e.jsx(ar,{text:t.result,maxLength:500})]})]})]})}),ir=l.memo(function({steps:t,isGenerating:s}){const{t:n}=K(),[a,o]=l.useState(s),c=l.useRef(s);l.useEffect(()=>{c.current&&!s&&o(!1),c.current=s},[s]);const d=t.length,x=s||t.some(f=>f.status==="running"),i=[...t].reverse().find(f=>f.status==="running"),m=t[t.length-1],b=(i==null?void 0:i.title)||(m==null?void 0:m.title)||"",h=`${d} ${n(d===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(fe,{size:13}):e.jsx(we,{size:13})}),x?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:x?`${n("chat.runningSteps")} ${h}…`:h}),x&&b&&e.jsxs("span",{className:"min-w-0 flex-1 truncate pl-1 text-xs text-dark-muted/70",children:["· ",b]})]}),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(f=>e.jsx(lr,{step:f},f.id))})]})});function ks(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 c=o.payload;typeof c=="string"?s=c:c&&typeof c=="object"?(n=c,s=JSON.stringify(c,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 kt=/\b(bash|shell|exec|cmd|powershell|terminal)\b/i,ys=/write_file|write|save|create|upload|deploy|publish/i,ws=/edit_file|edit|patch|apply|update|replace/i,js=/read_file|read|view|cat|open|list|dir\b/i,or=/file_delete|delete|remove|unlink|\brm\b|\bdel\b/i,cr=/\b(glob|find|locate)\b/i,dr=/\b(grep|rg|search_contents)\b/i,ur=/web_search|search_web|browse/i,vs=/web_fetch|fetch|http|curl|wget|download|request|api/i,xr=/git|commit|merge|rebase|push|checkout/i,pr=/install|uninstall|npm|pnpm|yarn|pip|cargo|gem|apt|brew|choco/i,yt=/send_message|send_file|message|notify|post/i;function Ns(r){const t=r.toLowerCase();return kt.test(t)?"verbRunCommand":ur.test(t)?"verbSearchWeb":ys.test(t)?"verbWriteFile":ws.test(t)?"verbEditFile":or.test(t)?"verbDeleteFile":js.test(t)?"verbReadFile":dr.test(t)?"verbSearchContents":cr.test(t)?"verbFindFiles":vs.test(t)?"verbFetchUrl":xr.test(t)?"verbGit":pr.test(t)?"verbInstall":yt.test(t)?"verbSendMessage":"verbRunTool"}function Xe(r,t){const s=(r??"").replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t-1)}…`:s}function mr(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 Ss(r,t){const{payloadText:s,args:n}=ks(t),a=r.toLowerCase();if(kt.test(a))return"";const o=mr(n);if(o)return o;const c=s.match(/(?:file_path|path|file)["\s:=]+([^\s",}]+)/i);if(c!=null&&c[1])return c[1];if(vs.test(a)&&typeof(n==null?void 0:n.url)=="string"&&n.url)return Xe(n.url,48);if(yt.test(a)){const d=typeof(n==null?void 0:n.text)=="string"?n.text:typeof(n==null?void 0:n.message)=="string"?n.message:s;return Xe(d,48)}return Xe(s,48)}function Cs(r,t){const{payloadText:s,args:n}=ks(t),a=r.toLowerCase();if(kt.test(a)){const o=typeof(n==null?void 0:n.command)=="string"?n.command:s;return o?{text:o,mono:!0}:null}if(ys.test(a)||ws.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 c=Jt(n);if(c)return{text:c,mono:!0}}return s?{text:s,mono:!0}:null}if(yt.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(js.test(a))return null;if(n){const o=Jt(n);if(o)return{text:o,mono:!0}}return s?{text:s,mono:!0}:null}function Jt(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 Es(r,t){const s=Le(t);return s?{path:s,external:!0}:{key:"scopeLocal",external:!1}}function _s({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 Ye=5,et=420;function ft({text:r,mono:t=!0}){const{t:s}=K("hook"),[n,a]=l.useState(!1),o=r.split(`
|
|
6
|
-
`),c=o.length>Ye||r.length>et;let d=r;!n&&c&&(d=o.slice(0,Ye).join(`
|
|
7
|
-
`),d.length>et&&(d=`${d.slice(0,et).trimEnd()}…`));const x=n?s("showLess"):o.length>Ye?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:[d,c&&e.jsx("button",{type:"button",onClick:()=>a(i=>!i),className:"mt-1 block text-[11px] text-accent-blue hover:underline",children:x})]})}const tt=15,hr=l.memo(function({approval:t,onResolved:s}){const{t:n}=K("hook"),[a,o]=l.useState(!1),[c,d]=l.useState(tt),x=l.useRef(null),i=t.status==="pending",{level:m,reasonKey:b}=cs(t.toolName,t.askPayload),h=ds[m],f=Cs(t.toolName,t.askPayload),y=Es(t.toolName,t.askPayload),w=Le(t.askPayload)!==null;l.useEffect(()=>{if(i)return d(tt),x.current=setInterval(()=>{d(A=>A<=1?(x.current&&clearInterval(x.current),0):A-1)},1e3),()=>{x.current&&clearInterval(x.current)}},[i,t.approvalId]),l.useEffect(()=>{const A=(t.timeoutMs??15e3)>0;c===0&&i&&!a&&A&&k()},[c]);const k=l.useCallback(()=>{!i||a||(o(!0),x.current&&clearInterval(x.current),W.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"approved"))},[i,a,t.approvalId,s]),u=l.useCallback(()=>{!i||a||(o(!0),x.current&&clearInterval(x.current),W.send({type:"hook_deny",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"denied"))},[i,a,t.approvalId,s]),S=l.useCallback(()=>{if(!i||a)return;o(!0),x.current&&clearInterval(x.current);const A=xt.getState(),B=Le(t.askPayload);B?(A.addToSessionAllowList(t.toolName,B),W.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId,sessionAllow:!0})})):(A.addToSessionAllowList(t.toolName),W.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]),_=l.useCallback(()=>{!i||a||(o(!0),x.current&&clearInterval(x.current),xt.getState().setAutoMode(!0),ye.getState().setAuto(!0),W.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),s==null||s(t.approvalId,"approved"))},[i,a,t.approvalId,s]);if(!i){const A=t.status==="approved";return e.jsx("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-xs ${A?"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:A?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{size:14}),e.jsxs("span",{children:[n("alreadyAllowed"),t.toolName]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14}),e.jsxs("span",{children:[n("alreadyDenied"),t.toolName]})]})})}const j=c/tt*100,C=c<=5,z=[{id:"allow",index:1,label:n("optionAllow"),hint:n("optionAllowHint"),action:k,kind:"primary"},{id:"allow_session",index:3,label:n("optionAllowAlways"),hint:w?n("optionAllowPathHint"):n("optionAllowAlwaysHint",{tool:t.toolName}),action:S,kind:"secondary"},{id:"auto_mode",index:4,label:n("optionAutoMode"),hint:n("optionAutoModeHint"),action:_,kind:"secondary"},{id:"deny",index:2,label:n("optionDeny"),hint:n("optionDenyHint"),action:u,kind:"danger"}],M={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":h.border}`,children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 border-b ${h.bg} ${y.external?"border-amber-500/30":h.border}`,children:[e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${rc.badge}",children:[h.icon," ",m]}),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(ot,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(_s,{pre:n(Ns(t.toolName)),obj:Ss(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(ns,{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(Ae,{size:11,className:C?"text-accent-red":"text-dark-muted"}),e.jsxs("span",{className:`text-[11px] font-mono ${C?"text-accent-red animate-pulse":"text-dark-muted"}`,children:[c,"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 ${C?"bg-accent-red":c<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${j}%`}})})]})]}),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(b)})]}),f&&e.jsx(ft,{text:f.text,mono:f.mono}),(m==="CRITICAL"||m==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-[11px] px-2 py-1 rounded ${h.bg} ${h.text}`,children:[e.jsx(je,{size:12}),e.jsx("span",{children:n(m==="CRITICAL"?"highRiskWarning":"mediumRiskConfirm")})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:z.map(A=>e.jsxs("button",{onClick:A.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 ${M[A.kind]}`,children:[e.jsx("span",{className:`text-[9px] font-mono rounded px-0.5 ${A.kind==="primary"?"bg-white/20":"bg-dark-surface text-dark-muted"}`,children:A.index}),e.jsx("span",{children:A.label}),e.jsx("span",{className:`text-[10px] ${A.kind==="primary"?"text-white/70":"text-dark-muted/60"} hidden sm:inline`,children:A.hint})]},A.id))}),e.jsx("div",{className:"text-[10px] text-dark-muted/50 pt-0.5 border-t border-dark-border/50",children:n("clickToSelect")})]})]})}),Fe={xlsx:{icon:ut,label:"Excel"},xls:{icon:ut,label:"Excel"},csv:{icon:dt,label:"CSV"},docx:{icon:dt,label:"Word"},text:{icon:bt,label:"文本"}};function Wt(r){return!r&&r!==0?"—":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/1024/1024).toFixed(2)} MB`}const fr=l.memo(function({job:t}){var b,h;const{t:s}=K(),{stage:n}=t,a=l.useCallback(f=>{ae.files.download(f).then(y=>{y.success||Q.error(y.error||s("fileJob.downloadFailed"))})},[s]),o=l.useMemo(()=>t.attachments||[],[t.attachments]),c=l.useMemo(()=>t.parsedFiles||[],[t.parsedFiles]),d=l.useMemo(()=>t.mapping||[],[t.mapping]),x=l.useMemo(()=>t.result||[],[t.result]),i=t.renderProgress??(n==="rendering"?0:100),m=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(ct,{size:15,className:"text-accent-green shrink-0"}):n==="error"?e.jsx(je,{size:15,className:"text-accent-red shrink-0"}):e.jsx(ze,{size:15,className:"text-accent-blue animate-spin shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-dark-text",children:br(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((f,y)=>{const w=Fe[f.kind]||Fe.text,k=w.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(k,{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:f.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[Wt(f.size)," · ",w.label,f.role&&f.role!=="unknown"&&e.jsxs("span",{className:Z("ml-1",f.role==="data"?"text-accent-green":"text-accent-purple"),children:["· ",f.role==="data"?s("fileJob.roleData"):s("fileJob.roleTemplate")]})]})]})]},`${f.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:((b=o[0])==null?void 0:b.fileName)||((h=c[0])==null?void 0:h.fileName)||""})}),e.jsx(Mt,{value:m,size:"sm",showLabel:!0})]}),c.length>0&&n!=="error"&&e.jsxs("div",{className:"space-y-1.5",children:[c.map(f=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx(ct,{size:13,className:"text-accent-green shrink-0"}),e.jsx("span",{className:"truncate",children:f.fileName}),e.jsx("span",{className:"text-[10px] text-dark-muted/70",children:s("fileJob.parsedSummary",{rows:f.rowCount,fields:f.fields.length})})]},f.fileName)),c[0]&&e.jsxs("div",{className:"flex flex-wrap gap-1 pt-1",children:[c[0].fields.slice(0,12).map(f=>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:f},f)),c[0].fields.length>12&&e.jsxs("span",{className:"text-[10px] text-dark-muted/60",children:["+",c[0].fields.length-12]})]})]}),d.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[11px] text-dark-muted",children:s("fileJob.mappingTitle")}),e.jsx("div",{className:"overflow-hidden rounded-lg border border-dark-border",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-dark-bg text-dark-muted",children:[e.jsx("th",{className:"text-left px-2.5 py-1.5 font-medium",children:s("fileJob.templatePlaceholder")}),e.jsx("th",{className:"px-2 py-1.5"}),e.jsx("th",{className:"text-left px-2.5 py-1.5 font-medium",children:s("fileJob.dataField")})]})}),e.jsx("tbody",{children:d.slice(0,8).map(f=>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:"{{"+f.placeholder+"}}"}),e.jsx("td",{className:"px-2 py-1.5 text-dark-muted",children:e.jsx(Gs,{size:11})}),e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-accent-blue",children:f.field})]},f.placeholder))})]})}),d.length>8&&e.jsx("div",{className:"text-[10px] text-dark-muted/60",children:s("fileJob.mappingMore",{n:d.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(Mt,{value:i,size:"sm",variant:"warning",showLabel:!0})]}),x.length>0&&n==="complete"&&e.jsx("div",{className:"space-y-1.5",children:x.map(f=>{const w=(Fe[f.format]||Fe.text).icon,k=f.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(w,{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:f.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[Wt(f.size)," · ",f.successCount,"/",f.rowCount," 行",k&&e.jsxs("span",{className:"text-accent-red",children:[" · ",f.failedRows.length," 行失败"]})]})]}),e.jsxs("button",{onClick:()=>os(f.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(ss,{size:12}),s("chat.previewInPanel")]}),e.jsxs("button",{onClick:()=>a(f.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(Zs,{size:12}),s("fileJob.download")]})]}),k&&e.jsxs("div",{className:"mt-1.5 space-y-0.5 border-t border-dark-border/50 pt-1.5",children:[f.failedRows.slice(0,3).map(u=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-red",children:[e.jsx(Vs,{size:10,className:"shrink-0"}),e.jsxs("span",{children:["#",u.index+1]}),e.jsx("span",{className:"truncate",children:u.error})]},u.index)),f.failedRows.length>3&&e.jsxs("div",{className:"text-[10px] text-dark-muted/70",children:["+",f.failedRows.length-3," 行"]})]})]},f.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(je,{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 br(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 Ut={auth:{icon:Ys,color:"text-accent-red"},rate_limit:{icon:_t,color:"text-accent-yellow"},timeout:{icon:_t,color:"text-accent-yellow"},network:{icon:Xs,color:"text-accent-yellow"},model:{icon:Qs,color:"text-accent-red"},tool:{icon:je,color:"text-accent-yellow"},unknown:{icon:je,color:"text-accent-red"}},gr=l.memo(function({error:t,onRetry:s}){const{t:n}=K(),[a,o]=l.useState(!1),c=Ut[t.category]||Ut.unknown,d=c.icon,x=()=>{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(d,{size:18,className:Z("shrink-0 mt-0.5",c.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(Me,{size:11}),n("errorCard.retry")]}),t.category==="auth"&&e.jsxs("button",{onClick:x,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(en,{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(fe,{size:11,className:Z("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 st({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 Kt({message:r,sessionId:t,onRegenerate:s,onDeleteMessage:n}){const{t:a}=K(),[o,c]=l.useState(!1),d=l.useRef(null);l.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const x=l.useCallback(async()=>{try{await navigator.clipboard.writeText(r.content||r.thinking||""),c(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),2e3)}catch(i){console.error("Failed to copy message:",i)}},[r.content,r.thinking]);return t?e.jsxs(e.Fragment,{children:[e.jsx(st,{onClick:x,title:a("chat.copyMessage"),children:o?e.jsx(Pe,{size:12,className:"text-accent-green"}):e.jsx(tn,{size:12})}),r.type==="assistant"&&s&&e.jsx(st,{onClick:()=>s(r.id),title:a("chat.regenerate"),children:e.jsx(Me,{size:12})}),n&&e.jsx(st,{onClick:()=>n(r.id),title:a("chat.deleteMessage"),danger:!0,children:e.jsx(sn,{size:12})})]}):null}function Gt({ts:r,align:t,children:s}){const{i18n:n}=K(),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 kr(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 yr({index:r,text:t,isGenerating:s,collapsed:n,onToggle:a}){const{t:o}=K();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(we,{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,`
|
|
8
|
-
|
|
9
|
-
`)})]})}const wr=l.memo(function({message:t,sessionId:s,onRegenerate:n,onDeleteMessage:a}){var u,S,_;const{t:o}=K(),c=le(j=>{var z;if(!s||!j.generatingSessions.includes(s))return!1;const C=j.messagesBySession[s];return C?((z=C[C.length-1])==null?void 0:z.id)===t.id:!1}),d=l.useMemo(()=>t.thinkingBlocks&&t.thinkingBlocks.length>0?t.thinkingBlocks:t.thinking?[{index:Number.MIN_SAFE_INTEGER,text:t.thinking}]:[],[t.thinkingBlocks,t.thinking]),[x,i]=l.useState({}),m=l.useRef(c);l.useEffect(()=>{m.current&&!c&&i(j=>{const C={...j};for(const z of d)C[z.index]=!0;return C}),m.current=c},[c,d]);const b=l.useMemo(()=>kr(d,t.toolCalls),[d,t.toolCalls]),h=l.useCallback(j=>{i(C=>({...C,[j]:!(C[j]??!c)}))},[c]),f=t.type==="user",y=t.type==="system",w=l.useCallback((j,C)=>{if(!s)return;const M=le.getState().getMessages(s),A=M.findIndex(L=>L.id===t.id);if(A===-1)return;const B=M[A];if(!B)return;const N={...B,hookApproval:B.hookApproval?{...B.hookApproval,status:C}:void 0},$=[...M];$[A]=N,le.setState({messagesBySession:{...le.getState().messagesBySession,[s]:$}})},[s,t.id]);if(t.deleted)return null;if(f)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:(u=t.content)==null?void 0:u.replace(/\n{3,}/g,`
|
|
10
|
-
|
|
11
|
-
`)})}),e.jsx(Gt,{ts:t.timestamp,align:"right",children:e.jsx(Kt,{message:t,sessionId:s,onRegenerate:n,onDeleteMessage:a})})]})});if(y)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 k=!t.hookApproval&&!!(d.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(Gt,{ts:t.timestamp,align:"left",children:e.jsx(Kt,{message:t,sessionId:s,onRegenerate:n,onDeleteMessage:a})}),e.jsxs("div",{className:k?"pt-7":"",children:[t.steps&&t.steps.length>0&&!t.hookApproval?e.jsx(ir,{steps:t.steps,isGenerating:c}):e.jsx(e.Fragment,{children:b.length>0&&!t.hookApproval&&e.jsx("div",{className:"mb-1 space-y-0.5",children:b.map(j=>j.kind==="thinking"&&j.block?e.jsx(yr,{index:j.block.index,text:j.block.text,isGenerating:c,collapsed:x[j.block.index]??!c,onToggle:h},j.key):j.toolCall&&e.jsx(gs,{toolCall:j.toolCall},j.key))})}),t.content?e.jsx("div",{className:"leading-relaxed",children:e.jsx(Cn,{content:t.content.replace(/\n{3,}/g,`
|
|
12
|
-
|
|
13
|
-
`)})}):d.length===0&&!t.hookApproval&&((S=t.steps)!=null&&S.length)?null:d.length===0&&!t.hookApproval&&!((_=t.steps)!=null&&_.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:En(t.summary)}),t.fileJob&&e.jsx("div",{className:"mt-3",children:e.jsx(fr,{job:t.fileJob})}),t.errorCard&&e.jsx("div",{className:"mt-3",children:e.jsx(gr,{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(hr,{approval:t.hookApproval,onResolved:w})})]})]})})}),jr=l.memo(function({messages:t,isGenerating:s,sessionId:n,onSendSuggestion:a,onRegenerate:o,onDeleteMessage:c}){const{t:d}=K(),x=l.useRef(null),[i,m]=l.useState(!0),b=l.useRef(s);b.current=s;const h=l.useCallback(()=>{const k=x.current;if(!k)return;const u=k.scrollHeight-k.scrollTop-k.clientHeight;m(u<50)},[]),f=l.useCallback(()=>{const k=x.current;k&&(k.scrollTop=k.scrollHeight)},[]);l.useEffect(()=>{s&&(m(!0),f())},[s,f]),l.useEffect(()=>{i&&f()},[t,i,f]);const y=l.useMemo(()=>t.filter(k=>!k.deleted),[t]),w=l.useMemo(()=>[{icon:nn,label:d("chat.suggestionCode"),prompt:d("chat.suggestionCodePrompt")},{icon:rs,label:d("chat.suggestionAnalyze"),prompt:d("chat.suggestionAnalyzePrompt")},{icon:as,label:d("chat.suggestionAutomate"),prompt:d("chat.suggestionAutomatePrompt")}],[d]);return e.jsxs("div",{ref:x,onScroll:h,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:[y.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:d("chat.welcome")}),e.jsx("p",{className:"text-dark-muted text-sm mb-8",children:d("chat.welcomeDesc")}),a&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2.5 text-left",children:w.map(k=>e.jsxs("button",{onClick:()=>a(k.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(k.icon,{size:16,"aria-hidden":"true",className:"text-accent-blue mb-2"}),e.jsx("div",{className:"text-[13px] font-medium text-dark-text",children:k.label}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-dark-muted line-clamp-2",children:k.prompt})]},k.label))})]})}):e.jsx("div",{className:"flex flex-col",children:y.map(k=>e.jsx("div",{className:"px-4 py-2",children:e.jsx(wr,{message:k,sessionId:n,onRegenerate:o,onDeleteMessage:c})},k.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:d("chat.thinkingEllipsis")})]})]})}),vr={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"},Nr=l.memo(function(){const{t}=K(),s=ye(x=>x.mode),n=ye(x=>x.setBaseMode),a=ye(x=>x.toggleAuto),o=s==="normal"?"act":s,c=us(o),d=pt(o);return e.jsxs("div",{className:"flex items-center gap-1",children:[_n.map(x=>{const i=c===x,m=An[x],b=s!=="normal"&&i?vr[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(x),className:Z("px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",b),title:t("chat.clickToSwitchMode"),"aria-pressed":i,children:m.label},x)}),e.jsxs("button",{type:"button",role:"switch","aria-checked":d,onClick:()=>a(),className:Z("flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",d?"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(Me,{size:11,className:Z(d?"text-accent-yellow":"text-dark-muted")}),e.jsx("span",{children:t("plan.autoApprove")})]})]})}),Zt={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"}},Sr=l.memo(function(){const{t}=K(),s=mt(u=>u.model),n=mt(u=>u.setModel),a=ye(u=>u.mode),o=ht(u=>u.effort),c=ht(u=>u.setEffort),[d,x]=l.useState([]),[i,m]=l.useState(!1),b=l.useRef(null),h=l.useCallback(async()=>{try{const u=await ae.models.list();u.success&&u.data&&Array.isArray(u.data.models)&&x(u.data.models.filter(S=>S.enabled!==!1))}catch{}},[]);l.useEffect(()=>{h()},[h]),l.useEffect(()=>{const u=()=>{h()};return window.addEventListener("models-updated",u),()=>window.removeEventListener("models-updated",u)},[h]);const f=l.useCallback(()=>m(!1),[]);l.useEffect(()=>{if(!i)return;const u=_=>{b.current&&!b.current.contains(_.target)&&f()},S=_=>{_.key==="Escape"&&f()};return document.addEventListener("mousedown",u),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",S)}},[i,f]);const y=async u=>{f();const S=us(a==="normal"?"act":a),_=`${u.provider}:${u.id}`,j=S==="plan"?{plan:_}:S==="goal"?{goal:_}:{global:_,act:_};try{(await ae.models.setDefaults(j)).success&&(n(u.id),await h())}catch{}},w=u=>s===u.id||s===`${u.provider}:${u.id}`,k=Zt[o];return e.jsxs("div",{className:"relative",ref:b,children:[e.jsxs("button",{type:"button",onClick:()=>m(u=>!u),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(rn,{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(At,{size:12,className:`shrink-0 ${k.color}`}),e.jsx("span",{className:`text-xs font-medium ${k.color}`,children:t(k.labelKey)}),e.jsx(fe,{size:12,className:Z("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:[d.map(u=>{const S=w(u);return e.jsx("button",{type:"button",role:"option","aria-selected":S,onClick:()=>y(u),className:Z("w-full flex items-center gap-2 px-3 py-2 text-left transition-colors",S?"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:Z("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",S?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(Pe,{size:11,strokeWidth:3})}),e.jsx("span",{className:"text-xs font-semibold text-dark-text truncate",children:u.name||u.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:u.provider}),u.isGlobalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-green/20 text-accent-green",children:t("chat.globalDefault")}),u.isPlanDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-blue/20 text-accent-blue",children:t("chat.planDefault")}),u.isActDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-yellow/20 text-accent-yellow",children:t("chat.actDefault")}),u.isGoalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-purple/20 text-accent-purple",children:t("chat.goalDefault")})]})]})},`${u.provider}:${u.id}`)}),d.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(At,{size:11}),t("chat.effort")]}),e.jsx("div",{className:"py-1",children:zn.map(u=>{const S=Zt[u],_=u===o;return e.jsxs("button",{type:"button",role:"option","aria-selected":_,onClick:()=>{c(u),f()},className:Z("w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors",_?"bg-dark-hover":"hover:bg-dark-hover"),children:[e.jsx("span",{className:Z("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",_?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(Pe,{size:11,strokeWidth:3})}),e.jsx("span",{className:`text-xs font-medium ${_?S.color:"text-dark-text"}`,children:t(S.labelKey)})]},u)})})]})]})});function Cr(r,t){if(!r)return t;const s=r.includes("\\")?"\\":"/";return r.endsWith(s)?r+t:r+s+t}function Er(r){const t=r.replace(/[\\/]+$/,""),s=Math.max(t.lastIndexOf("\\"),t.lastIndexOf("/"));return s===-1?t:t.slice(s+1)}function _r({initial:r,onClose:t,onConfirm:s}){const{t:n}=K(),[a,o]=l.useState(r),[c,d]=l.useState(null),[x,i]=l.useState([]),[m,b]=l.useState(!1),[h,f]=l.useState(""),[y,w]=l.useState(r),k=l.useRef(null),u=l.useCallback(async j=>{b(!0),f("");try{const C=await ae.dirs.list(j);if(!C.success||!C.data){f(C.error||n("chat.dirPickerLoadError"));return}o(C.data.path),d(C.data.parent),i(C.data.dirs||[]),w(C.data.path)}catch(C){f(C instanceof Error?C.message:n("chat.dirPickerLoadError"))}finally{b(!1)}},[n]);l.useEffect(()=>{u(r)},[r,u]),l.useEffect(()=>{var j;(j=k.current)==null||j.focus()},[]),l.useEffect(()=>{const j=C=>{C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),t())};return document.addEventListener("keydown",j),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",j),document.body.style.overflow=""}},[t]);const S=l.useCallback(()=>{const j=y.trim();j&&u(j)},[y,u]),_=l.useCallback(()=>{c&&u(c)},[c,u]);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(ls,{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(Ie,{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(an,{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:k,value:y,onChange:j=>w(j.target.value),onKeyDown:j=>{j.key==="Enter"&&S()},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
|
|
14
|
-
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:S,disabled:m||!y.trim(),className:`shrink-0 rounded-lg border border-dark-border px-2.5 py-1.5 text-xs text-dark-muted
|
|
15
|
-
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 _(),disabled:m||!a,className:`shrink-0 flex items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-[11px] text-dark-muted
|
|
16
|
-
hover:bg-dark-hover hover:text-dark-text disabled:opacity-40 transition-colors`,children:[e.jsx(is,{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:m?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-dark-muted",children:[e.jsx(ze,{size:14,className:"animate-spin","aria-hidden":"true"}),n("chat.loading")]}):h?e.jsx("div",{className:"px-3 py-4 text-xs text-accent-red",children:h}):x.length===0?e.jsx("div",{className:"px-3 py-4 text-xs text-dark-muted/60 text-center",children:n("chat.dirPickerNoDirs")}):x.map(j=>{const C=Cr(a,j);return e.jsxs("button",{type:"button",onClick:()=>void u(C),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs text-dark-text
|
|
17
|
-
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:j}),e.jsx(we,{size:12,className:"shrink-0 ml-auto text-dark-muted/40","aria-hidden":"true"})]},j)})}),e.jsx("button",{type:"button",onClick:()=>s(a),disabled:!a||m,className:`w-full rounded-lg bg-accent-blue/90 text-white text-xs font-medium py-2
|
|
18
|
-
hover:bg-accent-blue disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:n("chat.dirPickerConfirm")})]})]})]})}const Ar=l.memo(function({workspaceDir:t,onSelect:s}){const{t:n}=K(),a=ht(b=>b.recentDirs),[o,c]=l.useState(!1),[d,x]=l.useState(!1),i=l.useRef(null);l.useEffect(()=>{if(!o)return;const b=f=>{i.current&&!i.current.contains(f.target)&&c(!1)},h=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",h)}},[o]);const m=l.useCallback(b=>{var f;const h=((f=b==null?void 0:b.trim)==null?void 0:f.call(b))||"";h&&(c(!1),x(!1),s(h))},[s]);return e.jsxs("div",{className:"relative shrink-0",ref:i,children:[e.jsxs("button",{type:"button",onClick:()=>c(b=>!b),className:Z("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(ls,{size:12,className:"shrink-0 text-accent-blue/80","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[11px]",children:t?Er(t):n("chat.noWorkspaceDir")}),e.jsx(fe,{size:11,className:Z("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(b=>{const h=b===t;return e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>m(b),className:Z("w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors group",h?"text-accent-blue bg-accent-blue/5":"text-dark-text hover:bg-dark-hover"),title:b,children:[e.jsx(gt,{size:12,className:Z("shrink-0",h?"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:b}),h&&e.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-accent-blue",children:"✓"})]},b)})}),e.jsx("div",{className:"border-t border-dark-border"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{c(!1),x(!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(we,{size:13,"aria-hidden":"true"}),n("chat.chooseOtherDir")]})]}),d&&e.jsx(_r,{initial:t||"",onClose:()=>x(!1),onConfirm:m})]})});function zr({isOpen:r,files:t,selectedIndex:s,query:n,isSearching:a,onSelect:o,onHover:c,selectedCount:d=0,onFinish:x}){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:[d>0&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-accent-blue/20 text-accent-blue font-medium",children:["已选 ",d]}),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(ze,{size:16,className:"animate-spin"}),e.jsx("span",{children:"搜索文件中..."})]}):e.jsx("span",{children:"未找到匹配的文件"})}):t.map((i,m)=>e.jsxs("button",{onClick:()=>o(i),onMouseEnter:()=>c(m),className:`w-full px-3 py-1.5 flex items-center gap-2 text-left text-xs transition-colors border-l-2 ${m===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))]}),x&&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:d>0?`已选 ${d} 个文件`:"Enter 插入 · 可连续多选"}),e.jsx("button",{onClick:x,className:"px-3 py-1 text-[11px] rounded bg-accent-blue text-white hover:opacity-90 transition-opacity",children:"完成引用"})]})]}):null}function Mr({open:r,onClose:t,onSelect:s}){const{t:n}=K(),[a,o]=l.useState([]),[c,d]=l.useState(!1),[x,i]=l.useState("");l.useEffect(()=>{r&&(i(""),d(!0),ae.skills.list().then(b=>{const h=Array.isArray(b.data)?b.data:[];o(h.filter(f=>f.enabled!==!1))}).catch(()=>o([])).finally(()=>d(!1)))},[r]);const m=l.useMemo(()=>{const b=x.trim().toLowerCase();return b?a.filter(h=>[h.id,h.name,h.description,h.category,...h.tags||[]].join(" ").toLowerCase().includes(b)):a},[a,x]);return e.jsx(Mn,{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(rs,{size:14,className:"text-dark-muted shrink-0"}),e.jsx("input",{value:x,onChange:b=>i(b.target.value),placeholder:n("skills.pickPlaceholder"),autoFocus:!0,className:"flex-1 bg-transparent outline-none text-sm placeholder-dark-muted/60"}),c&&e.jsx(Me,{size:13,className:"animate-spin text-dark-muted"})]}),c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Me,{size:20,className:"animate-spin text-accent-blue"})}):m.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:m.map(b=>e.jsxs("button",{onClick:()=>s(b),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:[b.icon||"⭐"," ",b.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:b.injection||"lazy"})]}),e.jsxs("div",{className:"text-xs text-dark-muted truncate font-mono",children:["$",b.id]}),b.description&&e.jsx("div",{className:"text-xs text-dark-muted line-clamp-2",children:b.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:b.category||"—"}),e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-accent-blue shrink-0",children:[e.jsx(as,{size:11}),n("skills.pickUse")]})]})]},b.id))})]})})}const Ir=800,Vt=/\[Pasted text #(\d+)(?:\s*\+\d+ lines?)?\]/g;let Rr=0;const As=new Map;function $r(r){const t=++Rr;return As.set(t,r),t}function Tr(r){return r.length>Ir||zs(r)>0}function zs(r){return(r.match(/\r\n|\r|\n/g)||[]).length}function Dr(r){const t=$r(r),s=zs(r);return s===0?{id:t,label:`[Pasted text #${t}]`}:{id:t,label:`[Pasted text #${t} +${s} lines]`}}function Pr(r){return Vt.lastIndex=0,r.replace(Vt,(t,s)=>{const n=parseInt(s,10),a=As.get(n);return a!==void 0?a:t})}const Je=16e3;function nt(){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 Lr(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 Or(r,t){const s=new ArrayBuffer(44+r.length*2),n=new DataView(s),a=(c,d)=>{for(let x=0;x<d.length;x++)n.setUint8(c+x,d.charCodeAt(x))};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 c=0;c<r.length;c++){const d=Math.max(-1,Math.min(1,r[c]??0));n.setInt16(o,d<0?d*32768:d*32767,!0),o+=2}return s}function qr(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 Br(r){const[t,s]=l.useState("idle"),[n,a]=l.useState(0),o=l.useRef(null),c=l.useRef(null),d=l.useRef([]),x=l.useRef(null),i=l.useRef(0),m=l.useCallback(()=>{var w;(w=c.current)==null||w.getTracks().forEach(k=>k.stop()),c.current=null},[]),b=l.useCallback(()=>{x.current&&(clearInterval(x.current),x.current=null)},[]);l.useEffect(()=>()=>{b(),o.current&&o.current.state!=="inactive"&&o.current.stop(),m()},[b,m]);const h=l.useCallback(async()=>{if(t!=="idle")return;if(typeof MediaRecorder>"u")throw new Error("当前浏览器不支持语音输入(需要 MediaRecorder)。请使用 Chrome/Edge/Firefox 或桌面版。");let w;try{w=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}})}catch(u){throw u instanceof DOMException&&u.name==="NotAllowedError"?new Error("麦克风权限被拒绝。请在浏览器地址栏允许麦克风权限后重试。"):new Error("无法访问麦克风:"+(u instanceof Error?u.message:String(u)))}c.current=w,d.current=[];const k=new MediaRecorder(w,nt()?{mimeType:nt()}:void 0);k.ondataavailable=u=>{u.data&&u.data.size>0&&d.current.push(u.data)},o.current=k,k.start(),i.current=Date.now(),a(0),s("recording"),x.current=setInterval(()=>a(Date.now()-i.current),100)},[t]),f=l.useCallback(async()=>{var u;const w=o.current;if(!w||w.state==="inactive")throw new Error("当前没有进行中的录音。");const k=new Promise(S=>{w.onstop=()=>S()});w.stop(),await k,b(),m(),o.current=null,s("transcribing");try{const S=new Blob(d.current,{type:nt()||"audio/webm"});d.current=[];const _=await S.arrayBuffer(),j=new AudioContext;let C;try{C=await j.decodeAudioData(_)}finally{j.close()}if(C.duration<.25)return s("idle"),"";const M=await Lr(C),A=Or(M,Je),B=await qr(new Blob([A],{type:"audio/wav"})),N=await ae.stt.transcribe(r,B,"wav");if(!N.success)throw new Error(N.error||"语音转写失败");return((u=N.data)==null?void 0:u.text)??""}finally{s("idle")}},[r,b,m]),y=l.useCallback(()=>{const w=o.current;w&&w.state!=="inactive"&&w.stop(),o.current=null,d.current=[],b(),m(),s("idle")},[b,m]);return{state:t,elapsedMs:n,start:h,stop:f,cancel:y}}function Fr(){return typeof window<"u"&&!!window.__TAURI__}async function Hr(){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 Jr=({isOpen:r,commands:t,selectedIndex:s,filter:n,onSelect:a,onHover:o,containerRef:c})=>{const{t:d}=K();return!r||t.length===0?null:e.jsxs("div",{ref:c,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}`:d("slashCommands.quickCommands")}),e.jsx("span",{className:"opacity-70",children:d("slashCommands.help")})]}),t.map((x,i)=>e.jsxs("button",{"data-index":i,onClick:()=>a(x),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:x.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:["/",x.name]}),x.args&&e.jsx("span",{className:"text-xs text-dark-muted",children:x.args}),!x.local&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue shrink-0",children:d("slashCommands.backend")})]}),e.jsx("div",{className:"text-xs text-dark-muted truncate",children:x.description})]}),i===s&&e.jsx(ln,{size:14,className:"text-dark-muted shrink-0 mt-0.5","aria-hidden":"true"})]},x.id))]})},Ms=["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"],Qt=new RegExp(`(?:\\.(${Ms.join("|")})|dockerfile|makefile)$`,"i"),Wr=Ms.map(r=>`.${r}`).join(",")+",.Dockerfile,.Makefile",Ur=".deepseekcode/attachments",Kr=50*1024*1024,He=10,Gr=r=>/\.xlsx?$/i.test(r)?ut:/\.(csv|docx|txt|md|mdx|rst|adoc|json|jsonc|yaml|yml|toml|xml|html|css|scss|less|env|gitignore|gitattributes|editorconfig)$/i.test(r)?dt:/\.(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)?hn:bt,rt=3e3,Xt=5,at=50;function Zr(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 Vr(r,t){const s=r.lastIndexOf(`
|
|
19
|
-
`,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 Qr=l.memo(function({sessionId:t,onSend:s,onStop:n,onPause:a,onResume:o,slashOptions:c,workspaceDir:d,onWorkspaceSelect:x}){const{t:i}=K(),m=le(p=>{var g;return((g=p.sessionInputs)==null?void 0:g[t])??""}),b=le(p=>p.setSessionInput),h=le(p=>{var g;return((g=p.generatingSessions)==null?void 0:g.includes(t))??!1}),f=le(p=>{var g;return((g=p.pausedSessions)==null?void 0:g.includes(t))??!1}),y=l.useRef(null),w=l.useRef(null),k=l.useRef(!1),[u,S]=l.useState([]),[_,j]=l.useState(!1),[C,z]=l.useState(!1),M=l.useCallback(p=>{b(t,p)},[t,b]),[A,B]=l.useState(()=>{try{return localStorage.getItem("dsc.stt.lang")==="zh"?"zh":"en"}catch{return"en"}}),N=l.useCallback(()=>{B(p=>{const g=p==="en"?"zh":"en";try{localStorage.setItem("dsc.stt.lang",g)}catch{}return g})},[]),$=Br(A),L=l.useRef(null),oe=l.useCallback(async()=>{var p;try{if(!L.current){const I=await ae.stt.status();I.success&&I.data&&(L.current=I.data)}const g=L.current;if(!g)return!0;if(g.service!=="ok"&&g.service!=="stopped")return Q.warning(i("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1;const E=(p=g.backends)==null?void 0:p[A];return E&&!E.installed?(Q.warning(i("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1):!0}catch{return!0}},[i,A]);l.useEffect(()=>{const p=()=>{L.current=null};return window.addEventListener("stt-backends-changed",p),()=>window.removeEventListener("stt-backends-changed",p)},[]),l.useEffect(()=>{const p=g=>{var I;const E=(I=g.detail)==null?void 0:I.lang;(E==="en"||E==="zh")&&B(E)};return window.addEventListener("stt-lang-changed",p),()=>window.removeEventListener("stt-lang-changed",p)},[]);const F=l.useCallback(p=>{const g=y.current,E=(g==null?void 0:g.selectionStart)??m.length,I=m.slice(0,E)+p+m.slice(E);M(I),requestAnimationFrame(()=>{g==null||g.focus();const D=E+p.length;g&&(g.selectionStart=g.selectionEnd=D)})},[m,M]),ee=l.useCallback(async()=>{if($.state==="recording"){try{const g=await $.stop();g?F(g):Q.info(i("stt.noSpeech"))}catch(g){Q.error(g instanceof Error?g.message:String(g))}return}if(!($.state!=="idle"||!await oe()))try{await $.start()}catch(g){Q.error(g instanceof Error?g.message:String(g))}},[$,F,oe,i]),me=In(c),{isOpen:U,filter:ie,filteredCommands:O,selectedIndex:X,setSelectedIndex:re,selectNext:te,selectPrev:ce,executeCommand:G,openMenu:ue,closeMenu:V,setFilter:be,allCommands:v,containerRef:P}=me,[R,q]=l.useState(!1),[Y,xe]=l.useState(""),[de,ge]=l.useState([]),[We,ve]=l.useState(0),[Rs,wt]=l.useState(!1),[$s,Re]=l.useState(0),Ne=l.useRef(-1),Se=l.useRef(new Set),$e=l.useRef(null),Oe=l.useRef(null),Ue=l.useRef([]),he=l.useRef(!1);l.useEffect(()=>{Se.current=new Set,he.current=!1,q(!1),xe(""),ge([]),Re(0),V()},[t,V]);const jt=l.useDeferredValue(m),vt=mt(p=>p.estimateTokens),Ke=l.useMemo(()=>vt(jt),[jt,vt]),Nt=l.useCallback(()=>{const p=y.current;p&&(p.style.height="auto",p.style.height=Math.min(p.scrollHeight,200)+"px")},[]);l.useEffect(()=>{Nt()},[m,u.length,Nt]);const Ge=l.useCallback(()=>{if($e.current)return Promise.resolve($e.current);if(Oe.current)return Oe.current;wt(!0);const p=(async()=>{try{const g=await ae.files.list(),E=g.success&&g.data?g.data[0]:void 0;if(!E)return $e.current=[],[];const I=[],D=new Set,T=async(H,J)=>{if(J>Xt||I.length>=rt)return;const pe=[];for(const ne of H||[]){if(I.length>=rt)return;const Ee=ne.path.replace(/\\/g,"/");D.has(Ee)||(D.add(Ee),ne.type==="file"?I.push({...ne,path:Ee}):ne.children&&ne.children.length>0?await T(ne.children,J+1):J<Xt&&pe.push(ne))}if(pe.length===0)return;const se=await Promise.all(pe.map(async ne=>{var Ee;try{const Qe=await ae.files.list(ne.path.replace(/\\/g,"/"));return Qe.success&&Qe.data?((Ee=Qe.data[0])==null?void 0:Ee.children)||[]:[]}catch{return[]}}));for(const ne of se){if(I.length>=rt)return;await T(ne,J+1)}};return await T(E.children,1),$e.current=I,I}catch{return $e.current=[],[]}finally{Oe.current=null,wt(!1)}})();return Oe.current=p,p},[]),St=l.useCallback(async(p,g)=>{if(he.current){const H=Ne.current;if(H<0||g<H){he.current=!1,q(!1);return}const J=p.slice(H,g);if(/\s/.test(J)){he.current=!1,q(!1);return}Ne.current=H,xe(J),q(!0),ve(0);const pe=await Ge();Ue.current=pe;const se=J.toLowerCase();ge(pe.filter(ne=>!se||ne.path.toLowerCase().includes(se)).slice(0,at));return}const E=Zr(p,g);if(!E.active){R&&q(!1);return}Ne.current=E.start,xe(E.query),q(!0),ve(0);const I=await Ge();Ue.current=I;const D=E.query.toLowerCase(),T=I.filter(H=>!D||H.path.toLowerCase().includes(D)).slice(0,at);ge(T)},[R,Ge]),Ts=l.useCallback(p=>{const g=p.target.value,E=p.target.selectionStart??g.length;M(g),St(g,E);const I=Vr(g,E);I.active?(U||ue(),be(I.query),re(0)):U&&V()},[M,St,U,ue,be,re,V]),Ze=l.useCallback(p=>{const g=y.current,E=m,I=Ne.current>=0?Ne.current:(g==null?void 0:g.selectionStart)??E.length,D=Math.min(E.length,I+1+Y.length),T=`@${p.path} `,H=E.slice(0,I)+T+E.slice(D);Se.current.add(p.path),M(H),q(!0),xe(""),ge(Ue.current.slice(0,at)),ve(0),Re(Se.current.size),Ne.current=I+T.length,he.current=!0,requestAnimationFrame(()=>{g==null||g.focus(),g&&(g.selectionStart=g.selectionEnd=I+T.length)})},[m,Y,M]),Te=l.useCallback(()=>{he.current=!1,q(!1),xe(""),Re(0)},[]),Ve=l.useCallback(p=>{if(!p.args){const T=G(p,"");T!=null&&T.message&&(T.success?Q.success(T.message):Q.error(T.message)),M("");return}const g=y.current,E=(g==null?void 0:g.selectionStart)??m.length,I=m.lastIndexOf(`
|
|
20
|
-
`,E-1)+1,D=m.slice(0,I)+`/${p.name} `+m.slice(E);M(D),V(),requestAnimationFrame(()=>{g==null||g.focus();const T=I+p.name.length+2;g&&(g.selectionStart=g.selectionEnd=T)})},[m,M,G,V]),Ds=l.useCallback(p=>{const g=y.current,E=(g==null?void 0:g.selectionStart)??m.length,I=`$${p.id} `,D=m.slice(0,E)+I+m.slice(E);M(D),z(!1),he.current=!1,q(!1),xe(""),requestAnimationFrame(()=>{g==null||g.focus();const T=E+I.length;g&&(g.selectionStart=g.selectionEnd=T)})},[m,M]),Ce=l.useCallback(p=>{const g=Array.from(p);S(E=>{const I=He-E.length,D=E.slice();for(const T of g.slice(0,I)){if(!Qt.test(T.name)){Q.warning(i("fileJob.unsupportedType",{name:T.name}));continue}if(T.size>Kr){Q.error(i("fileJob.fileTooLarge",{name:T.name}));continue}if(D.some(H=>H.name===T.name)){Q.warning(i("fileJob.duplicateFile",{name:T.name}));continue}D.push({id:`att-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,file:T,name:T.name,size:T.size,uploading:!1})}return D.length>=He&&Q.warning(i("fileJob.maxAttachments",{n:He})),D})},[i]),Ps=l.useCallback(p=>{p.target.files&&p.target.files.length>0&&(Ce(p.target.files),p.target.value="")},[Ce]),Ls=l.useCallback(async()=>{var p;if(Fr()){const g=await Hr();if(!g||g.length===0)return;const E=await ae.fileJob.importPaths(g);if(E.success&&Array.isArray(E.data)){const I=E.data.filter(D=>Qt.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,"/")}));S(D=>{const T=He-D.length;return[...D,...I.slice(0,T)]})}else Q.error(E.error||i("fileJob.importFailed"))}else(p=w.current)==null||p.click()},[i]),Os=l.useCallback(p=>{S(g=>g.filter(E=>E.id!==p))},[]),qs=l.useCallback(p=>{p.preventDefault(),j(!0)},[]),Bs=l.useCallback(p=>{p.preventDefault(),j(!1)},[]),Fs=l.useCallback(p=>{p.preventDefault(),j(!1),p.dataTransfer.files&&p.dataTransfer.files.length>0&&Ce(p.dataTransfer.files)},[Ce]),Ct=l.useCallback(async()=>{var g;if(u.length===0)return"";const p=[];for(const E of u){if(E.path){p.push(`<attachment path="${E.path}" />`);continue}if(!E.file)continue;S(T=>T.map(H=>H.id===E.id?{...H,uploading:!0,error:void 0}:H));const I=`${Ur}/${E.name}`,D=await ae.files.upload(E.file,I);if(D.success&&((g=D.data)!=null&&g.path)){const T=D.data.path.replace(/\\/g,"/");S(H=>H.map(J=>J.id===E.id?{...J,uploading:!1,path:T}:J)),p.push(`<attachment path="${T}" />`)}else S(T=>T.map(H=>H.id===E.id?{...H,uploading:!1,error:D.error||i("fileJob.uploadFailed")}:H)),Q.error(`${E.name}: ${D.error||i("fileJob.uploadFailed")}`)}return p.length>0?`${p.join(`
|
|
21
|
-
`)}
|
|
22
|
-
|
|
23
|
-
`:""},[u,i]),Hs=l.useCallback(p=>{const g=p.clipboardData.getData("text/plain");if(p.clipboardData.files&&p.clipboardData.files.length>0){p.preventDefault(),Ce(p.clipboardData.files);return}if(!g||!Tr(g))return;p.preventDefault();const{label:E}=Dr(g),I=y.current;if(!I)return;const D=I.selectionStart,T=I.selectionEnd,H=I.value,J=H.slice(0,D)+E+H.slice(T);M(J),requestAnimationFrame(()=>{I.selectionStart=I.selectionEnd=D+E.length})},[M,Ce]),qe=l.useCallback(async()=>{const p=Pr(m);he.current=!1,q(!1),V();const g=p.trim(),E=u.length>0;if(!g&&!E)return;const I=p.trim();if(I.startsWith("/")&&!E){const J=Rn(I);if(J){const pe=v.find(se=>se.name===J.command);if(pe){const se=G(pe,J.args);se!=null&&se.message&&(se.success?Q.success(se.message):Q.error(se.message)),M(""),S([]),Se.current=new Set,Re(0);return}Q.error(i("slashCommands.unknownCommand",{cmd:`/${J.command}`}));return}}const D=Array.from(Se.current).filter(J=>p.includes(`@${J}`));let T="";if(E){if(u.some(J=>J.uploading)){Q.warning(i("fileJob.stillUploading"));return}T=await Ct()}const H=(T+p).trim();!H&&!E||(s(H||T.trim(),D.length>0?D:void 0),M(""),S([]),Se.current=new Set,Re(0))},[m,u,s,M,Ct,i,V,v,G]),Js=l.useCallback(p=>{if(!p.nativeEvent.isComposing){if(R&&de.length>0){if(p.key==="ArrowDown"){p.preventDefault(),ve(g=>(g+1)%de.length);return}if(p.key==="ArrowUp"){p.preventDefault(),ve(g=>(g-1+de.length)%de.length);return}if(p.key==="Enter"&&!p.shiftKey&&!p.ctrlKey&&!p.metaKey){const g=de[We];g&&(p.preventDefault(),Ze(g));return}if(p.key==="Escape"){p.preventDefault(),Te();return}}else if(R&&p.key==="Escape"){p.preventDefault(),Te();return}if(U&&O.length>0){if(p.key==="ArrowDown"){p.preventDefault(),te();return}if(p.key==="ArrowUp"){p.preventDefault(),ce();return}if(p.key==="Enter"&&!p.shiftKey&&!p.ctrlKey&&!p.metaKey){const g=O[X];g&&(p.preventDefault(),Ve(g));return}if(p.key==="Escape"){p.preventDefault(),V();return}}else if(U&&p.key==="Escape"){p.preventDefault(),V();return}if(p.key==="Escape"&&h){p.preventDefault(),f?o():a();return}if(p.key==="Enter"&&(p.ctrlKey||p.metaKey)){p.preventDefault(),qe();return}p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),qe())}},[h,f,qe,a,o,R,de,We,Ze,Te,U,O,X,te,ce,Ve,V]),Ws=l.useCallback(()=>{k.current=!0},[]),Us=l.useCallback(()=>{k.current=!1},[]),Et=Ke>8e3,Ks=m.trim().length>0||u.length>0;return e.jsxs("div",{className:"shrink-0 px-3 sm:px-4 pb-3 pt-2 bg-dark-bg",onDragOver:qs,onDragLeave:Bs,onDrop:Fs,children:[u.length>0&&e.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:u.map(p=>{const g=Gr(p.name);return e.jsxs("div",{className:Z("flex items-center gap-1.5 rounded-lg border px-2 py-1 text-xs transition-colors",p.error?"border-accent-red/40 bg-accent-red/5 text-accent-red":p.uploading?"border-accent-blue/40 bg-accent-blue/5 text-accent-blue":"border-dark-border bg-dark-surface text-dark-text"),children:[p.uploading?e.jsx(ze,{size:13,className:"animate-spin"}):e.jsx(g,{size:13}),e.jsx("span",{className:"max-w-[140px] truncate",children:p.name}),e.jsx("span",{className:"text-[10px] text-dark-muted",children:p.size>1024*1024?`${(p.size/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(p.size/1024))} KB`}),!p.uploading&&e.jsx("button",{onClick:()=>Os(p.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(Ie,{size:11})})]},p.id)})}),_&&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:[R&&e.jsx("div",{onMouseDown:p=>p.preventDefault(),"aria-hidden":!R,children:e.jsx(zr,{isOpen:R,files:de,selectedIndex:We,query:Y,isSearching:Rs,onSelect:Ze,onHover:ve,selectedCount:$s,onFinish:Te})}),U&&e.jsx("div",{onMouseDown:p=>p.preventDefault(),"aria-hidden":!U,children:e.jsx(Jr,{isOpen:U,commands:O,selectedIndex:X,filter:ie,onSelect:Ve,onHover:re,containerRef:P})}),e.jsx("textarea",{ref:y,value:m,onChange:Ts,onKeyDown:Js,onPaste:Hs,onBlur:()=>{R&&Te(),V()},onCompositionStart:Ws,onCompositionEnd:Us,placeholder:i(h?"chat.generatingPlaceholder":"chat.inputPlaceholder"),rows:1,disabled:h&&!f,"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
|
|
24
|
-
resize-none focus:outline-none min-h-[44px] max-h-[40vh] leading-relaxed
|
|
25
|
-
disabled:opacity-50 disabled:cursor-not-allowed`}),e.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-2.5",children:[x&&e.jsx(Ar,{workspaceDir:d,onSelect:x}),e.jsx(Nr,{}),e.jsx("span",{className:"hidden sm:block",children:e.jsx(Sr,{})}),e.jsx("div",{className:"flex-1"}),Ke>0&&m.length>0&&e.jsxs("span",{className:`text-[10px] tabular-nums ${Et?"text-accent-red font-medium":"text-dark-muted/60"}`,children:["~",Ke," tokens",Et?` · ${i("chat.nearLimit")}`:""]}),!h&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:N,disabled:$.state!=="idle",className:`flex h-8 items-center justify-center rounded-full px-2 text-[11px] font-semibold text-dark-muted transition-colors
|
|
26
|
-
hover:bg-dark-hover hover:text-dark-text disabled:opacity-40`,title:i("stt.langToggle"),"aria-label":i("stt.langToggle"),children:A==="en"?"EN":"中"}),e.jsx("button",{onClick:()=>void ee(),disabled:$.state==="transcribing",className:Z("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(ze,{size:15,className:"animate-spin","aria-hidden":"true"}):$.state==="recording"?e.jsx(on,{size:15,"aria-hidden":"true"}):e.jsx(cn,{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"]})]}),!h&&e.jsx("button",{onClick:()=>z(!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(dn,{size:15,"aria-hidden":"true"})}),!h&&e.jsx("button",{onClick:()=>void Ls(),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(un,{size:15,"aria-hidden":"true"})}),e.jsx("input",{ref:w,type:"file",multiple:!0,accept:Wr,className:"hidden",onChange:Ps}),h?e.jsxs("div",{className:"flex items-center gap-1.5",children:[f?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(xn,{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(pn,{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(mn,{size:13,"aria-hidden":"true"})})]}):e.jsx("button",{onClick:()=>void qe(),disabled:!Ks,className:`flex h-8 w-8 items-center justify-center rounded-full bg-dark-text text-dark-bg transition-all
|
|
27
|
-
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(is,{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(Mr,{open:C,onClose:()=>z(!1),onSelect:Ds})]})}),lt="其他(我来说明)",ke="推进",Xr="不选具体项,按你的最佳判断继续",Yr=15e3,ea=300;function Is(r){return l.useMemo(()=>{const t=r.options||[],s=t.some(d=>d.label===lt),n=t.some(d=>d.label===ke),a=[...t];n||a.push({label:ke,description:Xr}),s||a.push({label:lt,description:"输入自定义答案"});const o=s?a.findIndex(d=>d.label===lt):a.length-1,c=n?a.findIndex(d=>d.label===ke):a.length-(s?1:2);return{allItems:a,otherIdx:o,proceedIdx:c,displayItems:a}},[r])}function Yt({item:r,answered:t,selectedIdx:s,multiSelected:n,customInput:a,showCustomInput:o,onSelect:c,onToggleMulti:d,onProceed:x,onEnterCustom:i,onCancelCustom:m,onSubmitCustom:b,onCustomChange:h,inputRef:f}){const{otherIdx:y,proceedIdx:w,displayItems:k}=Is(r),u=!!r.multiSelect,S=_=>{if(_===w){x();return}if(_===y){i();return}if(u){d(_);return}c(_)};return e.jsxs("div",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:[k.map((_,j)=>{const C=s===j,z=n.has(j),M=j===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 ${C?"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:()=>S(j),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u&&e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center text-[10px] ${z?"bg-blue-600 border-blue-600 text-white":"border-gray-400 dark:border-gray-500"}`,children:z&&e.jsx(Pe,{size:10})}),e.jsxs("span",{className:`font-medium ${C?"text-blue-700 dark:text-blue-300":"text-gray-800 dark:text-gray-200"}`,children:[u?"":`${j+1}. `,_.label]}),j===w&&e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"(直接继续)"}),M&&e.jsx("span",{className:"text-xs text-gray-400",children:"(自定义)"})]}),_.description&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 ml-6",children:_.description})]}),M&&C&&o&&e.jsxs("div",{className:"mt-2 ml-4",children:[e.jsx("textarea",{ref:f,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:A=>h(A.target.value),onKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),b()),A.key==="Escape"&&m()},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:b,children:[e.jsx(_e,{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:m,children:[e.jsx(Ie,{size:12}),"取消"]})]})]})]},`opt-${j}`)}),t&&e.jsx("div",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-medium",children:"✓ 已回答"})]})}function ta({isOpen:r,onClose:t}){const[s,n]=l.useState(null),[a,o]=l.useState(-1),[c,d]=l.useState(new Set),[x,i]=l.useState(""),[m,b]=l.useState(!1),[h,f]=l.useState(!1),[y,w]=l.useState(0),[k,u]=l.useState([]),[S,_]=l.useState(!1),j=l.useRef(null),C=l.useRef(null),z=l.useMemo(()=>s?s.questions&&s.questions.length>0?s.questions:[{question:s.question,header:s.header,options:s.options,multiSelect:s.multiSelect}]:[],[s]),M=z.length>1,A=l.useCallback(v=>{n(v),o(v.multiSelect?-1:0),d(new Set),i(""),b(!1),f(!1),w(0),_(!1);const P=v.questions&&v.questions.length>0?v.questions:[v];u(P.map(()=>null))},[]);l.useEffect(()=>{C.current=s}),l.useEffect(()=>{if(r){const v=window.__pendingQuestion;v&&A(v)}},[r,A]),l.useEffect(()=>{const v=P=>{var xe;const R=P.detail,q=((xe=C.current)==null?void 0:xe.questionId)??null;if(R&&q&&R!==q)return;const Y=q;f(!0),setTimeout(()=>{var ge;const de=((ge=C.current)==null?void 0:ge.questionId)??null;Y&&de&&de!==Y||(t(),n(null),f(!1))},ea)};return window.addEventListener("ask-question-dismiss",v),()=>window.removeEventListener("ask-question-dismiss",v)},[t]),l.useEffect(()=>{if(!h)return;const v=setTimeout(()=>f(!1),Yr);return()=>clearTimeout(v)},[h]),l.useEffect(()=>{const v=()=>{const P=window.__pendingQuestion;P&&A(P)};return window.addEventListener("ask-question-required",v),()=>window.removeEventListener("ask-question-required",v)},[A]),l.useEffect(()=>{o(0),d(new Set),i(""),b(!1)},[y,S,s]);const B=z[y]||null,{allItems:N,otherIdx:$}=Is(B||{question:""}),L=l.useCallback((v,P)=>{h||!s||(f(!0),W.send({type:"question_answer",sessionId:W.getSessionId()??void 0,data:JSON.stringify({questionId:s.questionId,answer:v,selectedOptions:P})}))},[h,s]),oe=l.useCallback(()=>{h||!s||(f(!0),W.send({type:"question_answer",sessionId:W.getSessionId()??void 0,data:JSON.stringify({questionId:s.questionId,answers:z.map((v,P)=>k[P]||{answer:"(用户未回答)"})})}))},[h,s,z,k]),F=l.useCallback((v,P,R)=>{u(q=>{const Y=q.slice();return Y[v]={answer:P,selectedOptions:R},Y}),v<z.length-1?w(v+1):_(!0)},[z.length]),ee=l.useCallback(v=>{if(h||!s)return;const P=N[v];P&&(o(v),L(P.label,[P.label]))},[h,s,N,L]),me=l.useCallback(()=>{if(h||!s||a<0)return;const v=N[a];v&&L(v.label,[v.label])},[h,s,a,N,L]),U=l.useCallback(()=>{if(h||a<0)return;const v=N[a];v&&F(y,v.label,[v.label])},[h,a,N,F,y]),ie=l.useCallback(v=>{if(h)return;const P=N[v];P&&F(y,P.label,[P.label])},[h,N,F,y]),O=l.useCallback(v=>{h||d(P=>{const R=new Set(P);return R.has(v)?R.delete(v):R.add(v),R})},[h]),X=l.useCallback(()=>{if(h)return;const v=[...c].map(P=>{var R;return((R=N[P])==null?void 0:R.label)||""});M?F(y,v.join(", "),v):L(v.join(", "),v)},[h,c,N,M,F,y,L]),re=l.useCallback(()=>{h||(M?F(y,ke,[ke]):L(ke,[ke]))},[h,M,F,y,L]),te=l.useCallback(()=>{h||(o($),b(!0),setTimeout(()=>{var v;return(v=j.current)==null?void 0:v.focus()},100))},[h,$]),ce=l.useCallback(()=>{b(!1),i("")},[]),G=l.useCallback(()=>{if(h)return;const v=x||"(用户未输入)";M?F(y,v):L(v)},[h,x,M,F,y,L]),ue=l.useCallback(()=>{h||!s||(f(!0),W.send({type:"question_answer",sessionId:W.getSessionId()??void 0,data:JSON.stringify({questionId:s.questionId,answers:z.map(()=>({answer:"(cancelled)"}))})}))},[h,s,z]),V=l.useCallback(()=>{if(!h){if(M){if(m){b(!1),i("");return}if(S){_(!1),w(z.length-1);return}ue();return}if(m){b(!1),i("");return}L("(cancelled)")}},[h,M,m,S,z.length,ue,L]);if(!r||!s)return null;const be=k.filter(v=>!v).length;return e.jsx(xs,{isOpen:r,onClose:V,title:s.header||(M?"批量确认":"请回答"),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"}),"待回答",M?` · ${k.filter(Boolean).length}/${z.length}`:""]}),collapsedSummary:e.jsx("span",{className:"truncate",children:(B==null?void 0:B.question)||s.question}),maxHeight:"50vh",children:M?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:[z.map((v,P)=>{const R=!!k[P],q=!S&&y===P;return e.jsxs("button",{type:"button",onClick:()=>{w(P),_(!1)},className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${q?"bg-blue-600 text-white":R?"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",P+1," ",R?"✓":""]},`nav-${P}`)}),e.jsx("button",{type:"button",onClick:()=>_(!0),className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${S?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:"提交"})]}),S?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:"确认答案"}),z.map((v,P)=>{const R=k[P];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:[P+1,". "]}),v.question]}),e.jsx("div",{className:`text-xs shrink-0 max-w-[45%] text-right break-words ${R?"text-emerald-600 dark:text-emerald-400":"text-amber-600 dark:text-amber-400"}`,children:R?R.answer:"未回答"})]},`rev-${P}`)}),be>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(je,{size:14}),"有 ",be," 题未回答,将记为「未回答」。点击上方题号可回到对应题目修改。"]}),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:oe,disabled:h,children:[e.jsx(_e,{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:()=>{_(!1),w(z.length-1)},disabled:h,children:"返回修改"})]})]}):B?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:B.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:()=>{w(v=>Math.max(0,v-1)),_(!1)},disabled:y===0,children:[e.jsx(fn,{size:12}),"上一题"]}),y<z.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:()=>{w(v=>Math.min(z.length-1,v+1)),_(!1)},children:["下一题",e.jsx(we,{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:()=>_(!0),children:["查看提交",e.jsx(we,{size:12})]})]})]}),e.jsx(Yt,{item:B,answered:!!k[y],selectedIdx:a,multiSelected:c,customInput:x,showCustomInput:m,onSelect:ie,onToggleMulti:O,onProceed:re,onEnterCustom:te,onCancelCustom:ce,onSubmitCustom:G,onCustomChange:i,inputRef:j}),!m&&e.jsx("div",{className:"flex items-center gap-2",children:B.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:h||c.size===0,children:[e.jsx(_e,{size:14}),"完成本题 (",c.size," 项)"]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:U,disabled:h||a<0,children:[e.jsx(_e,{size:14}),"确认本题"]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:m?e.jsx("span",{children:"Enter 提交,Shift+Enter 换行"}):B.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(Yt,{item:z[0],answered:!1,selectedIdx:a,multiSelected:c,customInput:x,showCustomInput:m,onSelect:ee,onToggleMulti:O,onProceed:re,onEnterCustom:te,onCancelCustom:ce,onSubmitCustom:G,onCustomChange:i,inputRef:j}),!m&&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:h||c.size===0,children:[e.jsx(_e,{size:14}),"提交所选 (",c.size," 项)"]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:me,disabled:h||a<0,children:[e.jsx(_e,{size:14}),"提交"]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:h?e.jsx("span",{children:"提交中..."}):m?e.jsx("span",{children:"Enter 提交,Shift+Enter 换行"}):s.multiSelect?e.jsx("span",{children:"点击选项勾选,再点击「提交所选」提交;「推进」表示按 AI 判断继续"}):e.jsx("span",{children:"点击选项立即提交,或点击下方「提交」确认当前选项"})})]})})}const De=15;function sa({isOpen:r,onCloseModal:t}){const{t:s}=K("hook"),n=xt(),a=n.pendingApprovals,o=n.autoMode,c=n.setAutoMode,[d,x]=l.useState(0),[i,m]=l.useState(!1),[b,h]=l.useState(De),[f,y]=l.useState(!0),w=l.useRef(null),k=l.useRef(!1);l.useEffect(()=>{if(a.length!==0){if(o){a.forEach(R=>{W.send({type:"hook_allow",data:JSON.stringify({approvalId:R.approvalId})})}),n.clearApprovals();return}x(R=>Math.min(R,a.length-1))}},[a.length,o]);const u=a[d]??null,S=a.length>0&&u!==null,_=a.length,j=S?_-d-1:0;l.useEffect(()=>{if(!(!S||i||!r||!u))return h(De),w.current=setInterval(()=>{h(R=>R<=1?(w.current&&clearInterval(w.current),0):R-1)},1e3),()=>{w.current&&clearInterval(w.current)}},[S,i,r,u==null?void 0:u.approvalId]);const C=u?cs(u.toolName,u.askPayload):{level:"MEDIUM",reasonKey:"risk_default"},z=ds[C.level],M=$n[C.level==="CRITICAL"?"critical":C.level==="HIGH"?"high":C.level==="LOW"?"low":"medium"],A=u?Cs(u.toolName,u.askPayload):null,B=u?Tn(u.toolName,u.askPayload):null,N=u?{verb:Ns(u.toolName),target:Ss(u.toolName,u.askPayload)}:null,$=u?Le(u.askPayload)!==null:!1,L=u?Es(u.toolName,u.askPayload):null,oe=b/De*100,F=b<=5,ee=Pn(De-b),me=l.useCallback((R,q)=>{const Y=Dn.getState().activeSessionId;Y&&le.getState().updateHookApprovalStatus(Y,R,q)},[]),U=l.useCallback(R=>{u&&(R&&me(u.approvalId,R),m(!0),setTimeout(()=>{n.removeApproval(u.approvalId),x(0),m(!1),k.current=!1,h(De)},200))},[u==null?void 0:u.approvalId,n,me]),ie=l.useCallback(()=>{!u||i||k.current||(k.current=!0,w.current&&clearInterval(w.current),W.send({type:"hook_allow",data:JSON.stringify({approvalId:u.approvalId})}),U("approved"))},[u,U,i]),O=l.useCallback(()=>{!u||i||k.current||(k.current=!0,w.current&&clearInterval(w.current),W.send({type:"hook_deny",data:JSON.stringify({approvalId:u.approvalId})}),U("denied"))},[u,U,i]),X=l.useCallback(()=>{if(!u||i||k.current)return;k.current=!0,w.current&&clearInterval(w.current);const R=Le(u.askPayload);R?(n.addToSessionAllowList(u.toolName,R),W.send({type:"hook_allow",data:JSON.stringify({approvalId:u.approvalId,sessionAllow:!0})})):(n.addToSessionAllowList(u.toolName),W.send({type:"hook_allow",data:JSON.stringify({approvalId:u.approvalId})})),U("approved")},[u,U,n,i]),re=l.useCallback(()=>{!u||i||k.current||(k.current=!0,w.current&&clearInterval(w.current),c(!0),ye.getState().setAuto(!0),W.send({type:"hook_allow",data:JSON.stringify({approvalId:u.approvalId})}),U("approved"))},[u,U,i,c]),te=((u==null?void 0:u.timeoutMs)??15e3)>0,ce=(u==null?void 0:u.timeoutAction)==="deny"?O:ie;if(l.useEffect(()=>{b===0&&r&&!i&&u&&te&&ce()},[b,r,i,u,ce,te]),l.useEffect(()=>{if(!r||!f)return;const R=q=>{const Y=q.target;Y&&typeof Y.closest=="function"&&Y.closest('input, textarea, select, [contenteditable="true"]')||(q.key==="Escape"?(q.preventDefault(),q.stopPropagation(),O()):q.key==="Enter"?(q.preventDefault(),ie()):q.key==="1"?ie():q.key==="2"?O():q.key==="3"?X():q.key==="4"&&re())};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[r,f,ie,O,X,re]),!S||!u)return null;const G=s("optionAllowHint"),ue=s("optionDenyHint"),V=$?s("optionAllowPathHint"):s("optionAllowAlwaysHint",{tool:u.toolName}),be=s("optionAutoModeHint"),v=(A==null?void 0:A.text)??B??null,P=v?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:u.toolName}),e.jsx("span",{className:"truncate",children:v})]}):null;return e.jsx(xs,{isOpen:r,onClose:()=>t==null?void 0:t(),title:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ot,{className:"w-4 h-4 text-yellow-400"}),e.jsx("span",{children:s("hookApproval")}),e.jsxs("span",{className:"text-xs text-dark-muted",children:["(",d+1,"/",_,")"]})]}),badge:e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${z.badge}`,children:[z.icon," ",C.level]}),collapsedSummary:P,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 ${z.bg} border ${z.border}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-xs font-bold border ${z.badge}`,children:[z.icon," ",C.level]}),e.jsx("span",{className:"text-xs text-dark-muted truncate",children:s(C.reasonKey)}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto shrink-0",children:[e.jsx(Ae,{size:12,className:F?"text-accent-red":"text-dark-muted"}),e.jsx("span",{className:`text-xs font-mono ${F?"text-accent-red animate-pulse":"text-dark-muted"}`,children:te?`${b}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 ${F?"bg-accent-red":b<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${oe}%`}})})]})]}),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(ot,{size:15})}),N&&e.jsx(_s,{pre:s(N.verb),obj:N.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(ns,{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:u.toolName}),e.jsx("span",{className:"text-dark-muted/50",children:ee}),e.jsx("span",{className:"text-dark-muted/50",children:M.label}),u.timeoutAction&&e.jsxs("span",{className:`text-xs ${u.timeoutAction==="deny"?"text-accent-red":"text-accent-green"}`,children:["timeout: ",te?`${u.timeoutAction==="allow"?"auto-allow":"auto-deny"}${u.timeoutMs?` (${(u.timeoutMs/1e3).toFixed(0)}s)`:""}`:s("timeoutWaitUser")]})]}),A?e.jsx(ft,{text:A.text,mono:A.mono}):B?e.jsx(ft,{text:B}):null,(C.level==="CRITICAL"||C.level==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-xs px-2 py-1.5 rounded ${z.bg} ${z.text}`,children:[e.jsx(je,{size:13}),e.jsx("span",{children:C.level==="CRITICAL"?s("highRiskWarning"):s("mediumRiskConfirm")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:ie,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:Be.allow.label}),e.jsx("span",{className:"text-[11px] text-white/70 hidden sm:inline",children:G})]}),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:Be.allow_session.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:V})]}),e.jsxs("button",{onClick:re,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:Be.auto.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:be})]}),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:Be.deny.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:ue})]})]}),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:j>0?s("morePending",{n:j}):s("lastItem")})]})]})})}const na=l.memo(function(){const{t}=K(),[s,n]=l.useState(0),[a,o]=l.useState(0),c=l.useCallback(()=>{const d=W.getReconnectState();n(d.reconnecting?d.attempts:0),o(d.maxAttempts)},[]);return l.useEffect(()=>{const d=W.onReconnectAttempt((h,f)=>{n(h),o(f)}),x=W.onReconnectSuccess(()=>{n(0),o(0)}),i=W.onReconnectGiveUp(()=>n(0)),m=W.onClose(c),b=W.onOpen(c);return c(),()=>{d(),x(),i(),m(),b()}},[c]),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(Me,{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")})]})}),it="dsc-auto-access-banner-dismissed",ra=l.memo(function(){const{t}=K(),s=ye(d=>d.mode),[n,a]=l.useState(()=>localStorage.getItem(it)==="1");l.useEffect(()=>{pt(s==="normal"?"act":s)||localStorage.getItem(it)==="1"&&a(!1)},[s]);const o=l.useCallback(d=>{d&&localStorage.setItem(it,"1"),a(!0)},[]);return!(s!=="normal"&&pt(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(bn,{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(Ie,{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")})]})}),es=24,ts=240,aa={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"}},la=({status:r})=>r==="running"?e.jsx(ze,{size:12,className:"animate-spin text-accent-blue"}):r==="completed"?e.jsx(ct,{size:12,className:"text-accent-green"}):r==="failed"?e.jsx(wn,{size:12,className:"text-accent-red"}):r==="skipped"?e.jsx(jn,{size:12,className:"text-dark-muted"}):e.jsx(vn,{size:12,className:"text-dark-muted"}),ia=l.memo(function({sessionId:t,defaultExpanded:s,onClose:n}){const{t:a}=K(),[o,c]=l.useState(s??!1),[d,x]=l.useState(null),i=ps(N=>N.getTasksForSession(t)),[m,b]=l.useState(null),h=l.useRef(null),f=l.useRef(!1),y=l.useRef(null),w=l.useCallback(N=>{var $;N.button===0&&(N.target.closest("[data-taskboard-close]")||(f.current=!1,h.current={y:N.clientY,expanded:o,bodyHeight:(($=y.current)==null?void 0:$.offsetHeight)??0},N.currentTarget.setPointerCapture(N.pointerId)))},[o]),k=l.useCallback(N=>{const $=h.current;$&&(Math.abs(N.clientY-$.y)>4&&(f.current=!0),b(N.clientY-$.y))},[]),u=l.useCallback(N=>{const $=h.current;if(!$)return;const L=N.clientY-$.y;$.expanded&&L<-es?c(!1):!$.expanded&&L>es&&c(!0),h.current=null,b(null),setTimeout(()=>{f.current=!1},0)},[]),S=l.useCallback(()=>{if(f.current){f.current=!1;return}c(N=>!N)},[]),_=l.useCallback(N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),c($=>!$))},[]),j=m!==null,C=l.useMemo(()=>{const N=h.current;return m===null||!N?null:N.expanded?Math.min(ts,Math.max(0,N.bodyHeight+m)):Math.min(ts,Math.max(0,m))},[m]),z=l.useMemo(()=>{const N=i.length,$=i.filter(ee=>ee.status==="completed").length,L=i.filter(ee=>ee.status==="running").length,oe=i.filter(ee=>ee.status==="failed").length,F=N>0?Math.round($/N*100):0;return{total:N,completed:$,running:L,failed:oe,progress:F}},[i]),M=l.useMemo(()=>{const N={pending:[],running:[],completed:[],failed:[]};return i.forEach($=>{const L=$.status==="skipped"?"pending":$.status;N[L].push($)}),N},[i]),A=[...M.running,...M.failed,...M.pending.slice(0,5),...M.completed.slice(-3)],B=o||j;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:S,onKeyDown:_,onPointerDown:w,onPointerMove:k,onPointerUp:u,onPointerCancel:u,onLostPointerCapture:u,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(gn,{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:[z.completed,"/",z.total]}),z.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 ${z.running>0?"bg-accent-blue":z.failed>0?"bg-accent-red":"bg-accent-green"}`,style:{width:`${z.progress}%`}})}),z.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:N=>{N.stopPropagation(),n()},onKeyDown:N=>{N.key==="Enter"&&(N.stopPropagation(),n())},className:"p-0.5 rounded hover:bg-dark-hover transition-colors cursor-pointer",title:"Hide task drawer",children:e.jsx(Ie,{size:12,className:"text-dark-muted"})}),e.jsx(kn,{size:12,className:"text-dark-muted/40 shrink-0","aria-hidden":"true"}),o?e.jsx(yn,{size:14,className:"text-dark-muted"}):e.jsx(fe,{size:14,className:"text-dark-muted"})]})]}),B&&e.jsx("div",{ref:y,className:"border-t border-dark-border",style:C!==null?{height:C,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:[A.map(N=>e.jsx(ca,{task:N,isSelected:N.id===d,onClick:()=>x(d===N.id?null:N.id)},N.id)),M.pending.length>5&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[M.pending.length-5," more pending tasks"]}),M.completed.length>3&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[M.completed.length-3," more completed tasks"]})]})})]})}),oa=(r,t)=>{if(!r)return"";const s=(t||Date.now())-r;return s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`},ca=l.memo(function({task:t,isSelected:s,onClick:n}){const a=aa[t.status];return e.jsxs("div",{onClick:n,className:`rounded border p-2 cursor-pointer transition-all ${a.bg} border-dark-border
|
|
28
|
-
${s?"ring-1 ring-accent-blue":"hover:border-dark-muted/40"}
|
|
29
|
-
${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(la,{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:oa(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"]})]})]})}),fa=l.memo(function({tabs:t,activeSessionId:s,onSend:n,onStop:a,onPause:o,onResume:c,activeTab:d,setActiveTab:x,createNewSession:i,clearMessages:m,setTheme:b,setThemePreset:h,toggleTerminal:f,setLogs:y,setUnreadLogs:w,showTaskBoard:k=!0,onToggleTaskBoard:u,onRegenerate:S,onDeleteMessage:_,hookDrawerOpen:j,onCloseHookDrawer:C,questionDrawerOpen:z,onCloseQuestionDrawer:M,workspaceDir:A,onWorkspaceSelect:B}){const N=l.useMemo(()=>({setActiveTab:x,createNewSession:i,clearMessages:m,setTheme:b,setThemePreset:h,toggleTerminal:f,setLogs:y,setUnreadLogs:w}),[x,i,m,b,h,f,y,w]),$=le(O=>s?O.messagesBySession[s]||[]:[]),L=le(O=>s?O.generatingSessions.includes(s):!1),oe=le(O=>s?O.pausedSessions.includes(s):!1),F=t.find(O=>O.id===s)||null;l.useEffect(()=>{if(!s)return;let O=!1;return ae.tasks.list(s).then(X=>{if(O||!X.success||!Array.isArray(X.data))return;const re={PENDING:"pending",RUNNING:"running",COMPLETED:"completed",FAILED:"failed",CANCELLED:"skipped"},te=Date.now(),ce=X.data.filter(G=>G.sessionId===s).map(G=>{const ue=new Date(G.createdAt).getTime()||te,V=new Date(G.updatedAt).getTime()||te;return{id:G.id,sessionId:s,title:G.title,status:re[G.status]||"pending",source:"task",description:G.description,progress:G.progress,createdAt:ue,updatedAt:V,raw:G}});ps.getState().setTasks(s,ce,"task")}).catch(()=>{}),()=>{O=!0}},[s]);const ee=l.useCallback((O,X)=>{s&&n(s,O,X)},[n,s]),me=l.useCallback(O=>{s&&n(s,O)},[n,s]),U=l.useCallback(O=>{s&&S&&S(s,O)},[S,s]),ie=l.useCallback(O=>{s&&_&&_(s,O)},[_,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(na,{}),e.jsx(ra,{}),F&&e.jsxs(e.Fragment,{children:[e.jsx(jr,{messages:$,isGenerating:L,isPaused:oe,sessionId:F.id,onSendSuggestion:me,onRegenerate:S?U:void 0,onDeleteMessage:_?ie:void 0}),e.jsx(sa,{isOpen:!!j,onCloseModal:C}),e.jsx(ta,{isOpen:!!z,onClose:M??(()=>{})}),k&&e.jsx(ia,{sessionId:F.id,defaultExpanded:!1,onClose:u},F.id),e.jsx(Qr,{sessionId:F.id,onSend:ee,onStop:()=>a(F.id),onPause:()=>o(F.id),onResume:()=>c(F.id),slashOptions:N,workspaceDir:A,onWorkspaceSelect:B})]})]})})});export{fa as SessionGrid};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./markdown-4Q3UQbv9.js";import{a as n,h as H,F as ee,Z as O,a7 as te,aO as se,l as W,L as U,b as G,b0 as V,o as ae,aV as J,D as ne,k as re,am as le,aa as Y,b1 as ce,b2 as q,E as ie,b3 as oe,aX as de,t as xe,b4 as ue,b5 as me,a8 as pe}from"./icons-ZBQi-Ogj.js";import{a as y,t as u,c as _,d as Q,f as he,T as ge,K as be,s as X}from"./index-sYOn5Yyn.js";import"./react-vendor-LdB92qnf.js";import"./state-4vIOJjS6.js";import"./panels-CwhLUZOq.js";function fe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function je(t){return new Date(t).toLocaleString()}function ke(){const[t,x]=n.useState([]),[l,a]=n.useState(null),[d,i]=n.useState(""),[j,N]=n.useState(""),[g,o]=n.useState(!1),[h,$]=n.useState(!1),C=n.useCallback(async()=>{o(!0);try{const c=await y.config.files.list();c.success&&Array.isArray(c.data)&&x(c.data)}catch{u.error("Failed to load config files")}finally{o(!1)}},[]),L=n.useCallback(async c=>{try{const z=await y.config.files.read(c);if(z.success&&z.data){const m=z.data;a(m.name),i(m.content),N(m.content)}}catch{u.error(`Failed to read ${c}`)}},[]);n.useEffect(()=>{C()},[C]);const M=n.useCallback(async()=>{if(l){$(!0);try{const c=await y.config.files.write(l,d);c.success?(N(d),u.success(`${l} saved`),C()):u.error(c.error||"Failed to save")}catch{u.error("Failed to save file")}finally{$(!1)}}},[l,d,C]),p=d!==j,S=(l==null?void 0:l.endsWith(".yaml"))||(l==null?void 0:l.endsWith(".yml")),D=l==null?void 0:l.endsWith(".json"),K=c=>S?c.replace(/(#.*)$/,'<span class="text-dark-muted">$1</span>').replace(/^(\s*)([\w-]+)(:)/,'$1<span class="text-accent-blue">$2</span>$3').replace(/:\s+(true|false|null|~)(\s*)$/,': <span class="text-accent-purple">$1</span>$2').replace(/:\s+(\d+\.?\d*)(\s*)$/,': <span class="text-accent-green">$1</span>$2').replace(/:\s+"([^"]*)"(\s*)$/,': <span class="text-accent-yellow">"$1"</span>$2'):D?c.replace(/(\s*"[^"]*")(\s*:)/g,'<span class="text-accent-blue">$1</span>$2').replace(/:\s+(true|false|null)/g,': <span class="text-accent-purple">$1</span>').replace(/:\s+(\d+\.?\d*)/g,': <span class="text-accent-green">$1</span>').replace(/:\s+"([^"]*)"/g,': <span class="text-accent-yellow">"$1"</span>'):c;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-dark-text",children:"Config Files"}),e.jsx("button",{onClick:C,disabled:g,className:"p-1.5 rounded hover:bg-dark-hover transition-colors text-dark-muted",title:"Refresh file list",children:e.jsx(H,{size:14,className:g?"animate-spin":""})})]}),t.length===0&&!g&&e.jsx("p",{className:"text-xs text-dark-muted",children:"No config files found in ~/.agent/"}),t.length>0&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-48 shrink-0 space-y-0.5 max-h-[300px] overflow-y-auto custom-scrollbar",children:t.map(c=>e.jsxs("button",{onClick:()=>L(c.name),className:`w-full text-left px-2.5 py-1.5 rounded text-xs flex items-center gap-2 transition-colors ${l===c.name?"bg-accent-blue/10 text-accent-blue":"text-dark-text hover:bg-dark-hover"}`,children:[e.jsx(ee,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:c.name}),!c.editable&&e.jsx("span",{className:"text-[10px] text-dark-muted shrink-0",title:"Read-only",children:"read"})]},c.name))}),l?e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx("span",{className:"text-dark-text font-medium",children:l}),t.find(c=>c.name===l)&&e.jsxs("span",{children:[fe(t.find(c=>c.name===l).size)," · ",je(t.find(c=>c.name===l).modified)]}),p&&e.jsxs("span",{className:"text-accent-yellow flex items-center gap-1",children:[e.jsx(O,{size:10}),"unsaved changes"]})]}),e.jsxs("button",{onClick:M,disabled:!p||h,className:`flex items-center gap-1 px-2.5 py-1 rounded text-xs transition-all ${p?"bg-accent-blue text-white hover:opacity-90":"bg-dark-hover text-dark-muted cursor-not-allowed"}`,children:[e.jsx(te,{size:12}),h?"Saving...":"Save"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"w-full h-[260px] p-3 rounded-lg bg-dark-bg border border-dark-border font-mono text-xs leading-relaxed overflow-auto custom-scrollbar pointer-events-none",dangerouslySetInnerHTML:{__html:d.split(`
|
|
2
|
-
`).map(K).join(`
|
|
3
|
-
`)||" "}}),e.jsx("textarea",{value:d,onChange:c=>i(c.target.value),className:"absolute inset-0 w-full h-full p-3 rounded-lg bg-transparent border border-dark-border font-mono text-xs leading-relaxed resize-none overflow-auto custom-scrollbar text-transparent caret-dark-text focus:outline-none focus:border-accent-blue/50",style:{color:"transparent"},spellCheck:!1})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-dark-muted",children:"Select a file to edit"})]})]})}function ve(){const{t}=_(),[x,l]=n.useState(null),[a,d]=n.useState(null),[i,j]=n.useState({running:!1,logs:[]}),[N,g]=n.useState(!1),o=n.useRef(null),h=n.useRef(i),$=n.useRef(null),[C,L]=n.useState(()=>{try{return localStorage.getItem("dsc.stt.lang")==="zh"?"zh":"en"}catch{return"en"}}),M=n.useCallback(r=>{L(r);try{localStorage.setItem("dsc.stt.lang",r)}catch{}window.dispatchEvent(new CustomEvent("stt-lang-changed",{detail:{lang:r}}))},[]);n.useEffect(()=>{h.current=i},[i]);const p=n.useCallback(async()=>{g(!0);const r=await y.stt.status();r.success&&r.data?(l(r.data),r.data.env&&d(r.data.env)):r.error&&u.error(r.error),g(!1)},[]);n.useEffect(()=>{p()},[p]);const S=n.useCallback(async()=>{const r=await y.stt.installStatus();if(r.success&&r.data){const k=h.current.running;j(r.data),r.data.running?o.current=window.setTimeout(()=>void S(),1e3):(p(),k&&r.data.status==="done"&&window.dispatchEvent(new CustomEvent("stt-backends-changed")))}},[p]);n.useEffect(()=>()=>{o.current&&window.clearTimeout(o.current)},[]),n.useEffect(()=>{$.current&&($.current.scrollTop=$.current.scrollHeight)},[i.logs]);const D=n.useCallback(async r=>{var b,T,R,I;const k=await y.stt.install(r);k.success&&((b=k.data)!=null&&b.started)?(j({running:!0,backend:r,logs:[],status:"running"}),S()):(T=k.data)!=null&&T.alreadyRunning?(u.info(t("stt.setup.jobInProgress")),S()):j({running:!1,backend:r,logs:[],status:"error",error:k.error||((R=k.data)==null?void 0:R.error)||"install failed",manualCommand:(I=k.data)==null?void 0:I.manualCommand})},[S,t]),K=n.useCallback(async()=>{await y.stt.cancelInstall(),S()},[S]),c=n.useCallback(r=>{navigator.clipboard.writeText(r).then(()=>u.success(t("stt.setup.copySuccess")),()=>u.error(t("stt.setup.copyFailed")))},[t]),z=i.running?i.backend:void 0,m=i.running,A=r=>r?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-accent-green/15 text-accent-green",children:[e.jsx(W,{size:12}),t("stt.setup.installed")]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-dark-hover text-dark-muted",children:[e.jsx(re,{size:12}),t("stt.setup.notInstalled")]}),P=(r,k,b)=>{var s;const T=((s=x==null?void 0:x.backends)==null?void 0:s[r])??{installed:!1},R=z===r,I=m&&!R,F=C===r;return e.jsxs("div",{className:Q("rounded-lg border p-3 flex items-start justify-between gap-3 transition-colors cursor-pointer",F?"border-accent-blue/50 bg-accent-blue/5":"border-dark-border bg-dark-bg hover:border-dark-hover"),onClick:()=>M(r),children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:Q("w-9 h-9 shrink-0 rounded-lg flex items-center justify-center text-sm font-semibold",F?"bg-accent-blue/15 text-accent-blue":"bg-accent-blue/10 text-accent-blue"),children:r==="en"?"W":"F"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-dark-text",children:k}),A(T.installed),F&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-accent-blue/15 text-accent-blue",children:[e.jsx(V,{size:12}),t("stt.setup.inUse")]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-[11px] text-dark-muted",children:[e.jsx("code",{className:"text-[10px] bg-dark-hover px-1.5 py-0.5 rounded",children:b}),e.jsx("span",{children:t(r==="en"?"stt.setup.whisperDesc":"stt.setup.funasrDesc")})]}),r==="zh"&&e.jsxs("p",{className:"mt-1 text-[11px] text-dark-muted flex items-center gap-1",children:[e.jsx(J,{size:11}),t("stt.setup.torchHint")]}),F&&!T.installed&&e.jsxs("p",{className:"mt-1 text-[11px] text-accent-orange flex items-center gap-1",children:[e.jsx(O,{size:11}),t("stt.setup.engineNotInstalledHint")]})]})]}),e.jsx("div",{className:"shrink-0",onClick:f=>f.stopPropagation(),children:R?e.jsxs("button",{className:"btn btn-secondary cursor-not-allowed opacity-70",disabled:!0,children:[e.jsx(U,{size:14,className:"animate-spin"}),t("stt.setup.installing")]}):I?e.jsx("button",{className:"btn btn-secondary cursor-not-allowed opacity-50",disabled:!0,children:t("stt.setup.installing")}):T.installed?e.jsxs("button",{className:"btn btn-ghost",onClick:()=>void p(),title:t("stt.setup.recheck"),children:[e.jsx(H,{size:14}),t("stt.setup.recheck")]}):e.jsxs("button",{className:"btn btn-accent",onClick:()=>void D(r),children:[e.jsx(ne,{size:14}),t("stt.setup.install")]})})]})},B=(a==null?void 0:a.pythonAvailable)&&(a==null?void 0:a.pipAvailable);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-bg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-dark-text",children:[e.jsx(se,{size:14,className:"text-accent-blue"}),t("stt.setup.envCard")]}),e.jsxs("button",{className:"btn btn-ghost",onClick:()=>void p(),disabled:N,children:[e.jsx(H,{size:13,className:N?"animate-spin":""}),t("stt.setup.recheck")]})]}),e.jsxs("div",{className:"mt-2.5 space-y-2",children:[a?a.pythonAvailable?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-text",children:[e.jsx(W,{size:13,className:"text-accent-green"}),t("stt.setup.pythonOk",{version:(a.pythonVersion||"").replace(/^Python\s*/i,"")||a.pythonPath||"Python"}),a.pythonPath?e.jsx("code",{className:"text-[10px] text-dark-muted",children:a.pythonPath}):null]}):e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-accent-red/30 bg-accent-red/5 px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-red",children:[e.jsx(O,{size:13}),t("stt.setup.pythonMissing")]}),e.jsx("a",{className:"btn btn-secondary !py-1 !px-2 text-xs",href:"https://www.python.org/downloads/",target:"_blank",rel:"noreferrer",children:t("stt.setup.pythonGuide")})]}):e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx(U,{size:13,className:"animate-spin"}),t("stt.setup.envChecking")]}),a&&!a.pipAvailable&&e.jsxs("div",{className:"rounded-md border border-accent-red/30 bg-accent-red/5 px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-red",children:[e.jsx(O,{size:13}),t("stt.setup.pipMissing")]}),e.jsxs("div",{className:"mt-1.5",children:[e.jsx("div",{className:"text-[10px] text-dark-muted mb-1",children:t("stt.setup.pipGuide")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"flex-1 rounded bg-dark-bg border border-dark-border px-2 py-1 font-mono text-[10px] text-dark-text break-all select-all",children:[a.pythonPath||"python"," -m ensurepip --upgrade"]}),e.jsx("button",{className:"btn btn-ghost !py-1 !px-2 text-xs",onClick:()=>c(`${a.pythonPath||"python"} -m ensurepip --upgrade`),children:e.jsx(G,{size:12})})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-dark-text",children:[e.jsx(V,{size:14,className:"text-accent-blue"}),t("stt.setup.defaultEngine")]}),e.jsx("p",{className:"mt-1 text-[11px] text-dark-muted",children:t("stt.setup.defaultEngineHint")})]}),P("en",t("stt.setup.whisperTitle"),"base.en"),P("zh",t("stt.setup.funasrTitle"),"paraformer-zh"),m&&e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-bg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-blue font-medium",children:[e.jsx(U,{size:13,className:"animate-spin"}),t("stt.setup.installing"),e.jsxs("span",{className:"text-dark-muted font-normal",children:["(",z==="en"?"whisper":"funasr",")"]})]}),e.jsx("button",{className:"btn btn-danger !py-1 !px-2 text-xs",onClick:()=>void K(),children:t("stt.setup.cancel")})]}),e.jsx("div",{ref:$,className:"rounded-md border border-dark-border bg-dark-bg p-2.5 font-mono text-[11px] text-dark-muted overflow-auto max-h-48 whitespace-pre-wrap custom-scrollbar",children:i.logs.length===0?e.jsx("span",{className:"text-dark-muted/70",children:t("stt.setup.logWaiting")}):i.logs.join(`
|
|
4
|
-
`)})]}),!m&&i.status&&i.status!=="done"&&e.jsxs("div",{className:"rounded-lg border border-accent-red/30 bg-accent-red/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-accent-red font-medium",children:[e.jsx(O,{size:13}),i.status==="timeout"?t("stt.setup.installTimeout"):i.status==="cancelled"?t("stt.setup.installCancelled"):t("stt.setup.installFailed")]}),i.error?e.jsx("p",{className:"mt-1 text-xs text-accent-red/90 break-all",children:i.error}):null,(i.manualCommand||i.status==="error"&&z)&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"text-[10px] text-dark-muted mb-1 flex items-center gap-1",children:[e.jsx(ae,{size:11}),t("stt.setup.manualCommand")]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:"flex-1 rounded bg-dark-bg border border-dark-border px-2 py-1.5 font-mono text-[10px] text-dark-text break-all whitespace-pre-wrap select-all",children:i.manualCommand??(z==="zh"?`${(a==null?void 0:a.pythonPath)||"python"} -m pip install -U "funasr>=1.1.0" "modelscope>=1.15.0" "torch>=2.0.0"`:`${(a==null?void 0:a.pythonPath)||"python"} -m pip install "faster-whisper>=1.0.0"`)}),i.manualCommand&&e.jsxs("button",{className:"btn btn-ghost !py-1 !px-2 text-xs shrink-0",onClick:()=>c(i.manualCommand),children:[e.jsx(G,{size:12}),t("stt.setup.copyCommand")]})]})]})]}),!m&&i.status==="done"&&e.jsxs("div",{className:"rounded-lg border border-accent-green/30 bg-accent-green/5 px-3 py-2.5 flex items-center gap-2 text-xs text-accent-green",children:[e.jsx(W,{size:14}),t("stt.setup.installDone")]}),!m&&B&&x&&!x.backends.en.installed&&!x.backends.zh.installed&&e.jsx("p",{className:"text-[11px] text-dark-muted px-1",children:t("stt.setup.chooseHint")})]})}const ye=n.memo(function({nameKey:x,descriptionKey:l,colors:a,isSelected:d,onClick:i}){const{t:j}=_(),N=["bg","surface","border","text","muted","accentBlue","accentGreen","accentRed","accentYellow","accentPurple"];return e.jsxs("button",{onClick:i,className:`relative flex flex-col items-center rounded-xl p-2 transition-all focus:outline-none focus:ring-2 focus:ring-accent-blue/50 ${d?"ring-2 ring-accent-blue/60 bg-dark-bg border border-accent-blue/40 shadow-sm":"border border-dark-border hover:border-accent-blue/30 bg-dark-bg hover:shadow-sm"}`,title:j(l),"aria-pressed":d,"aria-label":j(x),children:[e.jsx("div",{className:"flex gap-[2px] rounded-md overflow-hidden w-full h-8 mb-1.5 border border-dark-border/40",children:N.map(g=>e.jsx("div",{className:"flex-1",style:{backgroundColor:a[g]},title:g},g))}),e.jsx("span",{className:`text-[11px] font-medium truncate w-full text-center ${d?"text-accent-blue":"text-dark-text"}`,children:j(x)}),d&&e.jsx("span",{className:"absolute top-1 right-1 w-4 h-4 bg-accent-blue rounded-full flex items-center justify-center shadow-sm",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:e.jsx("path",{d:"M1.5 4L3.5 6L6.5 2",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}),Z=[{key:"bg",labelKey:"settings.colorBg"},{key:"surface",labelKey:"settings.colorSurface"},{key:"border",labelKey:"settings.colorBorder"},{key:"text",labelKey:"settings.colorText"},{key:"muted",labelKey:"settings.colorMuted"},{key:"accentBlue",labelKey:"settings.colorAccentBlue"},{key:"accentGreen",labelKey:"settings.colorAccentGreen"},{key:"accentRed",labelKey:"settings.colorAccentRed"},{key:"accentYellow",labelKey:"settings.colorAccentYellow"},{key:"accentPurple",labelKey:"settings.colorAccentPurple"}],Ne={language:["language","lang","Chinese","中文","English","en","zh"],theme:["theme","dark","light","color","palette","custom"],provider:["provider","model","api","key","openai","anthropic","deepseek"],context:["context","max","window","token","上下文"],configFiles:["config","file","yaml","json","editor"],system:["system","server","uptime","restart","reboot"],about:["about","version","info"],stt:["voice","语音","stt","whisper","funasr","安装","install","python","pip","speech"]},Pe=n.memo(function({onNavigate:x,focusSection:l}){const{t:a}=_(),{theme:d,setTheme:i,themePresetId:j,setThemePreset:N,language:g,setLanguage:o,customTheme:h,customThemeEnabled:$,setCustomTheme:C,setCustomThemeEnabled:L,resetCustomTheme:M}=he(),[p,S]=n.useState($),D=n.useMemo(()=>d==="dark"?"dark":d==="light"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[d]),K=n.useMemo(()=>Object.values(ge),[]),[c,z]=n.useState(0),[m,A]=n.useState(!1),[P,B]=n.useState(!1),[r,k]=n.useState(""),b=n.useCallback(s=>{if(!r.trim())return!0;const f=r.toLowerCase().trim();return(Ne[s]??[]).some(w=>w.toLowerCase().includes(f))},[r]),T=n.useRef(null);n.useEffect(()=>{var s;(l==null?void 0:l.section)==="stt"&&((s=T.current)==null||s.scrollIntoView({behavior:"smooth",block:"start"}))},[l==null?void 0:l.nonce]),n.useEffect(()=>{let s=!0;const f=async()=>{try{const w=await y.system.status();s&&w.success&&w.data&&z(w.data.uptime)}catch{}};f();const v=setInterval(f,m?2e3:1e4);return()=>{s=!1,clearInterval(v)}},[m]);const R=n.useCallback(async()=>{if(window.confirm("Restart the server? All active sessions will be disconnected.")){A(!0);try{const s=await y.system.restart();s.success?u.info("Server restarting..."):(u.error(s.error||"Restart failed"),A(!1))}catch{u.error("Failed to send restart request"),A(!1)}}},[]),I=n.useCallback(async()=>{if(window.confirm("Shut down the server? This will stop the entire backend process.")&&window.confirm("Are you sure? All active sessions and unsaved work will be lost.")){B(!0);try{const s=await y.system.shutdown();s.success?u.info("Server shutting down..."):(u.error(s.error||"Shutdown failed"),B(!1))}catch{u.error("Failed to send shutdown request"),B(!1)}}},[]);n.useEffect(()=>{m&&c<1e4&&(A(!1),u.success("Server restarted"))},[c,m]);const F=s=>{const f=Math.floor(s/1e3),v=Math.floor(f/60),w=Math.floor(v/60);return w>0?`${w}h ${v%60}m`:v>0?`${v}m ${f%60}s`:`${f}s`};return e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar p-4 bg-transparent",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-4 rounded-xl border border-dark-border bg-dark-surface p-3",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 shrink-0",children:[e.jsx(le,{size:18,className:"text-accent-blue"}),a("settings.title")]}),e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(Y,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted pointer-events-none"}),e.jsx("input",{type:"text",value:r,onChange:s=>k(s.target.value),placeholder:"Search settings...",className:"w-full bg-dark-bg border border-dark-border rounded-lg pl-9 pr-3 py-1.5 text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),r&&e.jsx("button",{onClick:()=>k(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-dark-muted hover:text-dark-text text-xs p-1 rounded",children:"×"})]})]}),e.jsxs("div",{className:"space-y-5 max-w-3xl",children:[b("language")&&e.jsx(E,{icon:ce,iconColor:"text-accent-blue",title:a("settings.language"),children:e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(s=>e.jsx("button",{onClick:()=>o(s),className:`px-4 py-2 rounded-lg transition-all ${g===s?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:a(s==="zh-CN"?"settings.languageZh":"settings.languageEn")},s))})}),b("theme")&&e.jsxs(E,{icon:q,iconColor:"text-accent-purple",title:a("settings.theme"),children:[e.jsx("div",{className:"flex gap-2 mb-4",children:["dark","light","auto"].map(s=>e.jsx("button",{onClick:()=>i(s),className:`px-4 py-2 rounded-lg transition-all ${d===s?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:a(s==="dark"?"settings.themeDark":s==="light"?"settings.themeLight":"settings.themeAuto")},s))}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-text mb-2",children:a("settings.themePresets")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2",children:K.map(s=>{if(!s)return null;const f=(j||be)===s.id,v=D==="dark"?s.dark:s.light;return e.jsx(ye,{id:s.id,nameKey:s.nameKey,descriptionKey:s.descriptionKey,colors:v,isSelected:f,onClick:()=>N(s.id)},s.id)})})]}),e.jsxs("div",{className:"pt-4 border-t border-dark-border",children:[e.jsxs("button",{onClick:()=>{const s=!p;S(s),L(s)},className:"flex items-center gap-2 text-sm text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(q,{size:14}),e.jsx("span",{children:a("settings.customOverrides")}),e.jsx("span",{className:`w-8 h-4 rounded-full transition-colors ${p?"bg-accent-blue":"bg-dark-border"}`,children:e.jsx("span",{className:`block w-3 h-3 rounded-full bg-white transition-transform mt-0.5 ${p?"ml-4":"ml-0.5"}`})})]}),p&&e.jsx("p",{className:"text-[10px] text-dark-muted mt-1 mb-2",children:a("settings.customOverridesHint")}),p&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"flex gap-1 mb-3 rounded-lg overflow-hidden h-6",children:Z.map(({key:s})=>e.jsx("div",{className:"flex-1",style:{backgroundColor:h[s]},title:s},s))}),e.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2",children:Z.map(({key:s,labelKey:f})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:h[s],onChange:v=>C({[s]:v.target.value}),className:"w-8 h-8 rounded border border-dark-border cursor-pointer bg-transparent p-0.5 shrink-0"}),e.jsx("span",{className:"text-xs text-dark-muted flex-1 truncate",children:a(f)}),e.jsx("input",{type:"text",value:h[s],onChange:v=>{const w=v.target.value;/^#[0-9a-fA-F]{0,6}$/.test(w)&&C({[s]:w})},className:"w-16 bg-dark-bg border border-dark-border rounded px-1 py-0.5 text-xs text-dark-text font-mono text-center",maxLength:7})]},s))}),e.jsx("button",{onClick:M,className:"mt-2 text-xs text-dark-muted hover:text-accent-red transition-colors",children:a("settings.resetColors")})]})]})]}),b("provider")&&e.jsxs(E,{icon:J,iconColor:"text-accent-yellow",title:"Provider & Models",children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Configure AI providers, API keys, and model settings. Add or remove providers like OpenAI, Anthropic, DeepSeek, and more."}),e.jsxs("button",{onClick:()=>x==null?void 0:x("models"),className:"flex items-center gap-2 px-4 py-2 bg-accent-blue text-white rounded-lg hover:opacity-90 transition-opacity text-sm w-fit",children:[e.jsx(ie,{size:14}),"Manage Providers & Models"]})]}),b("context")&&e.jsx(E,{icon:oe,iconColor:"text-accent-blue",title:"Max Context",children:e.jsx(we,{})}),b("stt")&&e.jsx(E,{icon:de,iconColor:"text-accent-blue",title:a("stt.setup.title"),children:e.jsx("div",{ref:T,id:"settings-section-stt",className:"scroll-mt-4",children:e.jsx(ve,{})})}),b("configFiles")&&e.jsx(E,{icon:xe,iconColor:"text-accent-green",title:"Config Files (~/.agent/)",children:e.jsx(ke,{})}),b("system")&&e.jsx(E,{icon:ue,iconColor:"text-dark-muted",title:"System",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-dark-muted",children:"Server Uptime"}),e.jsx("span",{className:"text-dark-text font-mono",children:F(c)})]}),e.jsxs("button",{onClick:R,disabled:m,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${m?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(H,{size:14,className:m?"animate-spin":""}),m?"Restarting...":"Restart Server"]}),e.jsxs("button",{onClick:I,disabled:P,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${P?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(me,{size:14,className:P?"animate-pulse":""}),P?"Shutting Down...":"Shutdown Server"]})]})}),b("about")&&e.jsx(E,{icon:pe,iconColor:"text-accent-blue",title:a("settings.about"),children:e.jsxs("div",{className:"text-sm text-dark-muted space-y-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-dark-text",children:"DeepSeekCode Web"})," v1.0.0"]}),e.jsx("p",{children:a("settings.aboutDesc")}),e.jsx("p",{className:"text-xs",children:"Powered by React + TypeScript + TailwindCSS"})]})}),r.trim()&&!["language","theme","provider","context","stt","configFiles","system","about"].some(b)&&e.jsxs("div",{className:"text-center py-12 text-dark-muted",children:[e.jsx(Y,{size:32,className:"mx-auto mb-2 opacity-40"}),e.jsxs("p",{className:"text-sm",children:["No settings match “",r,"”"]})]})]})]})});function we(){const t=X(o=>o.maxContextTokens),x=X(o=>o.setMaxContextTokens),[l,a]=n.useState(String(t)),[d,i]=n.useState(!1),j=[32e3,64e3,128e3,256e3,512e3,1e6,2e6],N=async()=>{const o=parseInt(l,10);if(!(isNaN(o)||o<1e3)){i(!0),x(o);try{await y.config.provider.save({contextWindow:o}),u.success("Context window saved")}catch(h){u.error("Failed to save context window: "+(h instanceof Error?h.message:"Unknown error"))}i(!1)}},g=o=>o>=1e6?(o/1e6).toFixed(0)+"M":(o/1e3).toFixed(0)+"K";return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Set the maximum context window (in tokens) for your AI model. This controls how the progress bar and usage percentage are calculated."}),e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("input",{type:"number",value:l,onChange:o=>a(o.target.value),min:1e3,max:1e7,step:1e3,className:"w-32 bg-dark-bg border border-dark-border rounded-lg px-3 py-1.5 text-sm text-dark-text font-mono focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),e.jsx("span",{className:"text-sm text-dark-muted",children:"tokens"}),e.jsx("button",{onClick:N,disabled:d,className:"px-3 py-1.5 rounded-lg text-sm bg-accent-blue text-white hover:opacity-90 transition-opacity disabled:opacity-50",children:d?"Saving...":"Apply"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(o=>e.jsx("button",{onClick:async()=>{a(String(o)),x(o);try{await y.config.provider.save({contextWindow:o}),u.success("Context window saved")}catch(h){u.error("Failed to save context window: "+(h instanceof Error?h.message:"Unknown error"))}},className:"px-3 py-1 rounded-lg text-xs transition-all",children:g(o)},o))}),e.jsxs("p",{className:"text-xs text-dark-muted mt-2",children:["Current: ",e.jsx("span",{className:"font-mono text-dark-text",children:parseInt(l,10).toLocaleString()})," tokens"]})]})}function E({icon:t,iconColor:x,title:l,children:a}){return e.jsxs("div",{className:"rounded-xl border border-dark-border bg-dark-surface p-4",children:[e.jsxs("h3",{className:"font-medium mb-3 flex items-center gap-2",children:[e.jsx(t,{size:16,className:x}),l]}),a]})}export{Pe as SettingsPanel};
|